├── README.md ├── Simple-File-Manager-Browser.php ├── caching-with-HTACCESS-examples ├── database-modifier-when-migrating-wordpress ├── filter-php-variable-sanitize.php ├── get-remote-url-content-data.php ├── my-sql-export (backup) database.php ├── my-sql-import (restore) database.php ├── mysql-commands (+Wordpress).php ├── remove-directory-recursively-(delete-folder+sub-files) ├── text-to-image.php ├── two-way-encrypt-decrypt-PHP-C_sharp ├── two-way-encrypt-decrypt.php └── zip-folder.php /README.md: -------------------------------------------------------------------------------- 1 | php-scripts 2 | =========== 3 | 4 | A collection of useful PHP scripts and functions. They're all designed to be _copy-and-paste-able_ into your current framework. 5 | 6 | - [Simple File Manager Browser](https://github.com/ttodua/useful-php-scripts/blob/master/Simple-File-Manager-Browser.php) 7 | - [Database Modifier when Migrating Wordpress](https://github.com/ttodua/useful-php-scripts/blob/master/database-modifier-when-migrating-wordpress) 8 | - [Filter PHP Variable Sanitize](https://github.com/ttodua/useful-php-scripts/blob/master/filter-php-variable-sanitize.php) 9 | - [Get Remote URL Content Data](https://github.com/ttodua/useful-php-scripts/blob/master/get-remote-url-content-data.php) 10 | - [MySQL Export Database](https://github.com/ttodua/useful-php-scripts/blob/master/my-sql-export%20(backup)%20database.php) 11 | - [MySQL Import Database](https://github.com/ttodua/useful-php-scripts/blob/master/my-sql-import%20(restore)%20database.php) 12 | - [MySQL Commands](https://github.com/ttodua/useful-php-scripts/blob/master/mysql-commands%20(%2BWordpress).php) 13 | - [Remove Directory Recursively](https://github.com/ttodua/useful-php-scripts/blob/master/remove-directory-recursively-(delete-folder%2Bsub-files)) 14 | - [Text to Image](https://github.com/ttodua/useful-php-scripts/blob/master/text-to-image.php) 15 | - [Two Way Encrypt-Decrypt](https://github.com/ttodua/useful-php-scripts/blob/master/two-way-encrypt-decrypt.php) 16 | - [Zip a Folder](https://github.com/ttodua/useful-php-scripts/blob/master/zip-folder.php) 17 | -------------------------------------------------------------------------------- /Simple-File-Manager-Browser.php: -------------------------------------------------------------------------------- 1 | " . $_SERVER['REMOTE_ADDR'] . '            (in FTP, open ' . $_SERVER['PHP_SELF'] . ' and insert your IP in the ALLOWED list).'); 43 | } 44 | if ('xxxxxx' == PASSWORD__WFMB) { 45 | die('please, open this file(' . $_SERVER['REQUEST_URI'] . ') and SET your password'); 46 | } 47 | } 48 | 49 | 50 | define('PASSWORD_SALT', 'P5`SU2"6]NALYR}'); 51 | /** 52 | * Local (absolute or relative) path of folder to manage. 53 | * 54 | * By default, the directory pafm is in is what is used. 55 | * 56 | * Setting this to a path outside of webroot works, 57 | * but will break URIs. 58 | * 59 | * This directive will be ignored if set to an 60 | * invalid directory. 61 | * 62 | */ 63 | define('ROOT', (isset($startdir) ? $startdir : $_SERVER['DOCUMENT_ROOT'])); //or '..' or '../..' or etc... 64 | 65 | /* 66 | * /configuration 67 | */ 68 | 69 | 70 | /* 71 | * bruteforce prevention options 72 | */ 73 | define('BRUTEFORCE_FILE', __DIR__ . '/_pafm_bruteforce'); 74 | 75 | define('BRUTEFORCE_ATTEMPTS', 5); 76 | 77 | /** 78 | * Attempt limit lockout time 79 | * 80 | * @var int unit: Seconds 81 | */ 82 | define('BRUTEFORCE_TIME_LOCK', 15 * 60); 83 | 84 | define('AUTHORIZE', (!$avoid_authrz ? true : false)); 85 | 86 | /** 87 | * files larger than this are not editable 88 | * 89 | * @var int unit: MegaBytes 90 | */ 91 | define('MaxEditableSize', 1); 92 | 93 | /* 94 | * Makefile 95 | * 1 -> 0 96 | */ 97 | define('DEV', 0); 98 | 99 | define('VERSION', '1.8 RC1'); 100 | 101 | define('CODEMIRROR_PATH', __DIR__ . '/_cm'); 102 | 103 | $path = isset($_GET['path']) ? $_GET['path'] : '.'; 104 | $pathURL = escape($path); 105 | $pathHTML = htmlspecialchars($path); 106 | $redir = '?path=' . $pathURL; 107 | 108 | $codeMirrorModes = array('html', 'md', 'js', 'php', 'css', 'py', 'rb'); //TODO: complete array 109 | 110 | $maxUpload = min(return_bytes(ini_get('post_max_size')), return_bytes(ini_get('upload_max_filesize'))); 111 | $dirContents = array('folders' => array(), 'files' => array()); 112 | $dirCount = array('folders' => 0, 'files' => 0); 113 | $footer = 'pafm v' . VERSION . ' ' 114 | . 'by mustafa and selnomeria'; 115 | 116 | /* 117 | * resource retrieval 118 | */ 119 | $_R_HEADERS = array('js' => 'text/javascript', 'css' => 'text/css', 'png' => 'image/png', 'gif' => 'image/gif'); 120 | $_R = array(); 121 | 122 | 123 | $_R['images/ajax.gif'] = 'data:image/gif;base64,R0lGODlhJAAkAMQaAGNjY7GxsX19fYWFhe/v7/Pz82lpaXR0dMLCwpmZmaOjo6urq3Jycry8vGpqapKSko6OjoGBgXV1dYiIiIqKioODg+jo6IKCgpSUlIaGhv///wAAAAAAAAAAAAAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh+QQJAAAaACwAAAAAJAAkAAAF/6AmjmRpnmiqrmzrvnAszyURCEJA0GoA/IAALyUAAgRDjQ2n0xSByGVu9/IBhdYf1ih8PX/R29RpRHrLqO8Rlg2i2l2XtHmaU5NDwoLhkFAaBS4FDRQSDgwLdyNtBwMILggDB1wmagYDCS4JAwZoJZaYmpyeJIyOkJKUNXt9f4Etg4WHiXhJBQgJCQivJhYKExMKFi8FCgPHpyfGyBi8KgQPBgYHEaEnEwMRB9IPim9GjZm3ubsa2JNXLKCPDcgDDRrGnVDqRgYKgRDuEBoWGPNgWLR58CqDuwwiCjxQ9UwMHQ3ujo2ww+PCtmkXapVA9+OARhIOjDj4OIKBEQYkRQssMLIgpRKH3lSEAAAh+QQJAAAaACwAAAAAJAAkAAAF+qAmjmRpnmiqrmzrvnAszyURCEJA0GoA/IAAT2PD6UQCIEAw9AEfBU0SyCzmdq7pz4DQOH/Cb/ClBRgSxNtVqmS6xAf0qexuER4GwyHSPYmFLwUICQkIUSdWR0OLBAsMDgcVEA2HLIlYJXADA30sf3NKBptyLHSgQKIDpCumJpqcb0qANY6QkpQul4u7IoKEhii+hZUsBQqbm50lCBEHeQ+YKsbIoygJB7LFx9SqGsLACQZtK3d5e8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9hLqMDpW4mly6anHImiy2Nj5GTlYkygoSGKL6Fh34PegcRCHabmwrELHQHCW/Mzc8qbQbTwsCq1c4s2coN1Q0asQN4enwrdA+HENUQGgUKm51dK7WQxxUi9atQycAH4MCIeqxCwXBgxAEJKrNiMDDCoMaNJzMWGFnAy+KSXR1DitQQAgA7'; 124 | 125 | $_R['js'] = 'function $(a){return document.getElementById(a)}var popup,fOp,edit,upload,shell,__AJAX_ACTIVE,__CODEMIRROR,__CODEMIRROR_MODE,__CODEMIRROR_LOADED,__CODEMIRROR_PATH="_cm",__CODEMIRROR_MODES={html:"htmlmixed",js:"javascript",py:"python",rb:"ruby",md:"markdown"};function ajax(b,g,e,c,a,d){__AJAX_ACTIVE=true;if(!a){json2markup(["div",{attributes:{id:"ajaxOverlay"}},"img",{attributes:{src:"' . $_R['images/ajax.gif'] . '",id:"ajaxImg",title:"Loading",alt:"Loading"}}],document.body);$("ajaxOverlay").style.height=document.body.offsetHeight+"px";fade($("ajaxOverlay"),0,6,25,"in")}var f=window.ActiveXObject?new ActiveXObject("MSXML2.XMLHTTP.3.0"):new XMLHttpRequest();d&&f.upload.addEventListener("progress",d,false);f.open(g,b,true);f.onreadystatechange=function(){if(f.readyState!=4){return}__AJAX_ACTIVE=false;a||fade($("ajaxOverlay"),6,0,25,"out",function(){document.body.removeChild($("ajaxOverlay"));document.body.removeChild($("ajaxImg"))});if(f.status==200||f.statusText=="OK"){if(f.responseText=="Please refresh the page and login"){alert(f.responseText)}else{c(f.responseText)}}else{alert("AJAX request unsuccessful.\nStatus Code: "+f.status+"\nStatus Text: "+f.statusText+"\nParameters: "+b)}f=null};if(g.toLowerCase()=="post"&&!a){f.setRequestHeader("Content-Type","application/x-www-form-urlencoded;charset=UTF-8")}f.send(e)}function json2markup(c,g){var b=0,a=c.length,d,f,e;for(;b=g}}if(b){e.style[d?"opacity":"filter"]=d?f/10:"alpha(opacity="+f*10+")"}else{clearInterval(a);if(i){i()}}},c)}popup={init:function(d,a){json2markup(["div",{attributes:{id:"popOverlay"},events:{click:popup.close}}],document.body);json2markup(["div",{attributes:{id:"popup"}},["div",{attributes:{id:"head"}},["a",{attributes:{id:"x",href:"#"},events:{click:function(f){popup.close();f.preventDefault?f.preventDefault():f.returnValue=false}},text:"[x]"},"span",{text:d}],"div",{attributes:{id:"body"}}]],document.body);var e=$("popup"),c=$("popOverlay"),b;json2markup(a,$("body"));if(b=$("moveListUL")){if(b.offsetHeight>(document.body.offsetHeight-150)){b.style.height=document.body.offsetHeight-150+"px"}}e.style.marginTop="-"+parseInt(e.offsetHeight)/2+"px";e.style.marginLeft="-"+parseInt(e.offsetWidth)/2+"px";fade(c,0,6,25,"in");document.onkeydown=function(f){if((f||window.event).keyCode==27){popup.close();return false}}},close:function(){if(__AJAX_ACTIVE){return}if($("popup")){var a=$("popOverlay");fade(a,6,0,25,"out",function(){document.body.removeChild(a)});document.body.removeChild($("popup"))}document.onkeydown=null}};fOp={rename:function(a,b){popup.init("Rename:",["form",{attributes:{action:"?do=rename&subject="+a+"&path="+b+"&nonce="+nonce,method:"post"}},["input",{attributes:{title:"Rename To",type:"text",name:"rename",value:a}},"input",{attributes:{title:"Ok",type:"submit",value:"\u2713"}}]])},create:function(a,b){popup.init("Create "+a+":",["form",{attributes:{method:"post",action:"?do=create&path="+b+"&f_type="+a+"&nonce="+nonce}},["input",{attributes:{title:"Filename",type:"text",name:"f_name"}},"input",{attributes:{title:"Ok",type:"submit",value:"\u2713"}}]])},chmod:function(c,b,a){popup.init("Chmod "+unescape(b)+":",["form",{attributes:{method:"post",action:"?do=chmod&subject="+b+"&path="+c+"&nonce="+nonce}},["input",{attributes:{title:"chmod",type:"text",name:"mod",value:a}},"input",{attributes:{title:"Ok",type:"submit",value:"\u2713"}}]])},copy:function(a,b){popup.init("Copy "+unescape(a)+":",["form",{attributes:{method:"post",action:"?do=copy&subject="+a+"&path="+b+"&nonce="+nonce}},["input",{attributes:{title:"copy to",type:"text",name:"to",value:"copy-"+a}},"input",{attributes:{title:"Ok",type:"submit",value:"\u2713"}}]])},moveList:function(a,b,c){ajax(("?do=moveList&subject="+a+"&path="+b+"&to="+c),"get",null,function(d){if(!$("popup")){popup.init("Move "+unescape(a)+" to:",Function("return "+d)())}else{var f=$("popup"),e;$("body").innerHTML="";json2markup(Function("return "+d)(),$("body"));if((e=$("moveListUL")).offsetHeight>(document.body.offsetHeight-150)){e.style.height=document.body.offsetHeight-150+"px"}f.style.marginTop="-"+parseInt(f.offsetHeight)/2+"px";f.style.marginLeft="-"+parseInt(f.offsetWidth)/2+"px"}})},remoteCopy:function(a){popup.init("Remote Copy:",["form",{attributes:{method:"post",action:"?do=remoteCopy&path="+a+"&nonce="+nonce,id:"remote-copy"}},["legend",{text:"Location: "},["br",{},"input",{attributes:{title:"Remote Copy",type:"text",name:"location"},events:{change:function(b){$("remoteCopyName").value=this.value.substring(this.value.lastIndexOf("/")+1)}}}],"legend",{text:"Name: "},["br",{},"input",{attributes:{id:"remoteCopyName",title:"Name",type:"text",name:"to"}}],"input",{attributes:{title:"Ok",type:"submit",value:"\u2713"}}]])}};edit={init:function(b,c,d,a){__CODEMIRROR_MODE=d;json2markup(["div",{attributes:{id:"editOverlay"}}],document.body);$("editOverlay").style.height="100%";json2markup(["div",{attributes:{id:"ea"}},["textarea",{attributes:{id:"ta",rows:"30",cols:"90"},events:{change:function(){window.__FILECHANGED=true}}},"br",{},"input",{attributes:{type:"text",value:unescape(b),readonly:""}},"input",{attributes:{type:"button",value:"CodeMirror"},events:{click:function(){if(a){edit.codeMirrorLoad()}else{if(confirm("Install CodeMirror?")){ajax("?do=installCodeMirror","get",null,function(e){if(e==""){edit.codeMirrorLoad()}else{alert("Install failed. Manually upload CodeMirrorand place it in _codemirror, in the same directory as pafm")}})}}this.disabled=true}}},"input",{attributes:{type:"button",value:"Save",id:"save"},events:{click:function(){edit.save(b,c)}}},"input",{attributes:{type:"button",value:"Exit",id:"exit"},events:{click:function(){edit.exit(b,c)}}},"span",{attributes:{id:"editMsg"}}]],document.body);document.onkeydown=function(f){if((f||window.event).keyCode==27){edit.exit(b,c);return false}};ajax("?do=readFile&path="+c+"&subject="+b,"get",null,function(e){$("ta").value=e});location="#header"},codeMirrorLoad:function(){if(!__CODEMIRROR_LOADED){json2markup(["script",{attributes:{src:__CODEMIRROR_PATH+"/cm.js",type:"text/javascript"},events:{load:function(){__CODEMIRROR_LOADED=true;edit.codeMirrorLoad()}}},"link",{attributes:{rel:"stylesheet",href:__CODEMIRROR_PATH+"/cm.css"}},],document.getElementsByTagName("head")[0])}else{var a=__CODEMIRROR_MODES[__CODEMIRROR_MODE]||__CODEMIRROR_MODE;__CODEMIRROR=CodeMirror.fromTextArea($("ta"),{onChange:function(){window.__FILECHANGED=true},lineNumbers:true});__CODEMIRROR.setOption("mode",a)}},save:function(b,c){__CODEMIRROR&&__CODEMIRROR.save();$("editMsg").innerHTML=null;var a="data="+encodeURIComponent($("ta").value);ajax("?do=saveEdit&subject="+b+"&path="+c+"&nonce="+nonce,"post",a,function(d){$("editMsg").className=d.indexOf("saved")==-1?"failed":"succeeded";$("editMsg").innerHTML=d});window.__FILESAVED=true;window.__FILECHANGED=false},exit:function(a,b){if(window.__FILECHANGED&&!confirm("Leave without saving?")){return}if(window.__FILESAVED){ajax("?do=getfs&path="+b+"&subject="+a,"get",null,function(e){var g=$("dirList").getElementsByTagName("li"),d=unescape(a),f=0,c=g.length;for(;f "+$("cmd").value;ajax($("shell").getAttribute("action"),"POST","cmd="+encodeURIComponent($("cmd").value),function(b){$("shell-history").innerHTML+="\n"+b;$("shell-history").scrollTop=$("shell-history").scrollHeight});$("cmd").value="";return false}};upload={init:function(b,a){popup.init("Upload:",["form",{attributes:{id:"upload",action:"?do=upload&path="+b,method:"post",enctype:"multipart/form-data",encoding:"multipart/form-data"}},["input",{attributes:{type:"hidden",name:"MAX_FILE_SIZE",value:a}},"input",{attributes:{type:"file",id:"file_input",name:"file"},events:{change:function(c){upload.chk(c.target.files[0].name,b)}}}],"div",{attributes:{id:"upload-drag"},events:{dragover:function(c){this.className="upload-dragover";c.preventDefault()},dragleave:function(){this.className=""},drop:function(c){c.preventDefault();upload.chk(c.dataTransfer.files[0].name,b,c.dataTransfer.files[0])},},text:"drag here"},"div",{attributes:{id:"response"},text:"php.ini upload limit: "+Math.floor(a/1048576)+" MB"}])},chk:function(a,d,b){var c=new FormData();c.append("file",b||$("file_input").files[0]);ajax("?do=fileExists&path="+d+"&subject="+a,"GET",null,function(e){if(e=="1"){json2markup(["input",{insert:"after",attributes:{type:"button",value:"Replace?"},events:{click:function(f){upload.submit(d,c)}}}],$("file_input"))}else{upload.submit(d,c)}})},submit:function(b,a){ajax("?do=upload&path="+b+"&nonce="+nonce,"POST",a,function(c){$("response").innerHTML=c;location.reload(true)},true,function(d){if(d.lengthComputable){var c=Math.round((d.loaded*100)/d.total);$("response").innerHTML="uploaded: "+c+"%"}})}};'; 126 | $_R['images/copy.png'] = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAW0lEQVR42mNkgIKGhob/DEQCoFpGGJsR2YD6+nqCmhsbG+lgAEgRsQCnAcS6hvYGYPMOstxIcwG6odR3ATZ/YtOEDBixKcKXrGGugyVpsgyAqmHE6wJ8fkfOTACWlX8HDBsg/gAAAABJRU5ErkJggg=='; 127 | $_R['images/cp.png'] = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAABZUlEQVR4nKWTsYoaURhGz+hoJdqmFIvgiGyVZ4i1xbZbJ7W1jxBIlyyCJLAvYLVvYSVYGBCrweY6w8w49473zr/FblgtVk32g6/8DufncuGd8QCCIOgBX4E7oHlho4CfwLflcqkA6Pf797PZTLbbrex2u7MNw1Cm06kEQfADoNrtdj8PBoPvw+EQay1aa4wxb1ZE6HQ6LBaLT9baRx/42Gq1SNP0n26v1WqIyAdfRCp5npNl2dXjPM9JkgQRqfgAWmuSJAFgPp+fHfd6PeI4pigKAHyA/X5PHMcAjEajs4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Ca3zMwDuL7xJmjGRUSp1Wr9LIoCAPAbCVuIcRUZG9UAAAAASUVORK5CYII='; 129 | $_R['images/dir.png'] = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAACXBIWXMAAAsSAAALEgHS3X78AAACX0lEQVQ4jZ2Su2tUQRSHf2fuje5uQswa4wNFBTWgJEExKETtUqql6N9gIwqCtWKrVlb2loJYiA9iZdBShKgpsutmN699Ze/ee3dmzjkWm8SYpHJgijkw3/l+Mwf4j0UEY4gMANB60RgyIirnxo6NPXt08/l8YaU8v1AvlBZXC8VyvVCqNErlxWalWo+qSZLa9XvhXyoRoBja1zd05drohCQdMVHHQD0gClhGO7LJcq29FMWudffxmzvvPn37YLbqsfOK1RY4ansr7BeKdR8vN9jGiWZCyR7Znz08MnF05PzZ4xcBYBuAAIIqDEu4K0BYLDfCn3PVQBXEArWWBa0OXGJlR4AqAM8AC+AEpIpaI4Z3DCIQGTIwBKLu+4VbAVAFnO/uUKGqMERQVQgLoJsa7QRQ1a6B542zqEIVYBawKOAFqrqzga4ZsGfQWlcVhYgARHBeAM9wnmVngCjYeTjroT0hnHPoWIeOtQiMgReFtxb5Pdn8v4C1TCKKNPUQBUqVGhaWGhgcyMFaD6iCjAmrKxFu3xq/P/X51/tNv9AlsIik1kFE0GjG2k6sDg5k4ZmRWg/rGGkSS+/BceT68v3bIgSGDHuGtSwiGvYEBGbWTscxiyIQNQF5JKmH8yIbBqpdhdli/UexEpV6M2FYbSbtQqVVDYKQBvozYV+uJwwMGe8cftcNLJMJNgVQQ2RWo7T5cbrwavLSyeuVpVbw4On0jamvc0++z9ZmWjHHQRjk9vZn8jOFRu312y8vts2RMRQAwJlTh4Yf3rv6cncmlwWwMXm5XDZz+cLw5OkTB0YB4A+kvH5q0102OwAAAABJRU5ErkJggg=='; 130 | $_R['images/edit.png'] = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAACXBIWXMAAAsSAAALEgHS3X78AAAC7klEQVQ4jVWTTWicVRSGn/sz08mYmWQymWmaiTajkoUtKDVCoQguSkVF+qdUwZULwSpUNy7cuBGVioIIQVAUhKpIFVHBhYt2YTu2toJuVITGQKckXxPzM990vpnv3nNdTCc2d3O53Pe85z3vOUc1m82Ho2jpEWsz7RCC5pajAIfS0bZad9/0yNu3ZXUrBLRSyABjoyh6aPv2iROlUsl57+3gIwAZrfj3Rio//uW1ynbu2zeZO5zPGh9CUOomzBprZHh4mFwu57z3/byqz2AUFFSGJGm7f1qZx5Nm79v9t+cODpngURpAWfGinXMsLCzYXq9n1YBbKYJ3FErjRGtrXPrzSjeTU4/G9+545ek95TeWV9ZGR4uFdSviCSFQrVbx3hFQEPoiUAGtDS/NJqxvOJN0Uzo3rvjv3vvsaHFl9XS3Pv2s9V5I05Try8u4tHfTuv8vAlitKOWzZuquGu+efOuZPbv21jYuniKtVJT13hMkUCmP470DBSEMqlCEENBaYbYVVfPsh7x86PfdJz+/RLu86/k3Xzz+sRURUpeyuLRImqZsegCEEFAKqpM7cRc+YmriC879cI4HMvtfOPD+Ox8AxnrvERHGymOIly3BxhhsrkDc+JTpyS/dmTPn7Wp8bO6p10/NiYQMKqR9BWnK0lKEdymofg9FApWJKczlT6jXTvNz40Jo21e589AT18EQgkdrw6aCcnkMEelPkIJsboj2r19z9x3f0zjfoJV5jfuPPMf8339s+gNgRQTnHNeuNfFeEO8pjJbxUYPdtSq/XNSscILZg8eJ1yOUNuHWcbcShCCB8fEKIoJ3jkq1ytw3X3E5/o29Dz7GPbOH2VhdRCmFyJZ4rFZavHiaV686L/1ykm7CkaNP0modYGTHJEm8hlbaaaMzSinZQtDpdHSSJEzX63awTAGwRjNSLNDrdTHGYIwJcRyTJIkedAnA1uv1s/Pz80P5fL4tIpvrPAAMzNJa+ziOizMzMz8N3gD/AUYHd3EVVX6oAAAAAElFTkSuQmCC'; 131 | $_R['images/extract.png'] = 'data:image/png;base64,iVBORw0KGgoAAAAN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qLIMAAAAASUVORK5CYII='; 135 | $_R['images/terminal.png'] = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAC7klEQVRIx+2VPYudVRSFn33e917RFANBIT/BykIEnUIhWjiM06gohFsEtLQZGAUHTGHnT1AJWIjBYFplEknAwgS1EBJ/gcFiTKJBZyYz7zl7L4tzPzP3JlNo52neD/Zee+21Pw78x8cA1tbWPmxSOmGWLCUr9xtJANEkS01IQrLqqgmM0Uz77O7eu33p24vvtU8/9eTx5WefOTMYvGlmBkCTGjAbxq9AhqHxlzCDCIGCUBDuFC9E1PcbN37xO7/f/KgtEU1EWO4O+PjTzzl27LHKydKQPrNkmfo2URMSiqjgCt54bZXu4F5z96+dR9uuy0lUg19v/sbtO3c5LJGOJrjgoNvn9VdXiRC5lCY1TcLMxgSvXN7i3Y31o4GLSQYSGqIoAncn59KmnN0kgcHO7h6bm2dYXV3hyuUtNjbWWVpaWgyMFmQrcs50XRepeGmNicY//PgTL760wvubH/DK6goXvjp3CEBUxhFBhBPh+OjpTozqBtaW4kkCKQB4+63TDAanAPj6my3On78wAXMnFFRTjdOZziN3XbX3QKAWkRhquLuzx2BwirNnP+OLc19WHbtuYQEWVkeBmWFgbUSYqqgIOHnyZUoUvHjV04xrV7+b8X9u+fl5ZQEgEBHCwwHU2rinDXenlDLbORLLyy8s5H2oy4bg4YEkS2AhwIuTc/fAtnwo+Ph/jIha27TJI+qYL8x7Lsj8YCOJJBBqWlR3is8LMBVhmv00+DyJFDH2TbUFHS/lyOzvW7MzLhFR27TOG60kiwhyKTxI/XlxtUCyCAEBBq2ZhXut+vo7pxGQUiKZAQlLRpMaupwnk6wgvGYeGjJ2R4hkCUO4BwqlttdrS85Ze3t79sTjxxm1bWoSWMIMjERKdSmO7oERcL0PhBcfzphzkDsO9vfrHGzf+uPPq9e+/+T69Z9PKALDCETCRvukbluJ/iN9er2W4W4kIuj3ezPliAiaptH29q2/cynboyurP15P/94R0PH/edj5B6O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+/TobXmOafbNuS2TozTJ5TOMYPTCYDALP/daf/+9v/tnPLy8vHdt//icPf39+3t7//pkqjOe7Xdf//kiJ69UZHYGHzPAMHpf7vpR//ffZHXGKHeMv/olP/pheLi4v/Zcvber4rHLm+zJ+/v7//qiv38/dz4ZcPtT6LfKne5Kf/52+aoMvz8/aHdM+jLl/7gff7+/uvr7OnMl7TmPv39/f/VZvb29u/Vo5HYF/7eev/ZaujKlf/88P/qmv/rn//smfXhu6HdNPfesP/30//41OXl5v/yu7vpRv/kdf/igP/mgP/tov/skf39/v/ecf/wsrPmPv/77f/ljPz8+//UXOvPnOzPnPPkyfXcrfXdrv/BQPbcrf/MU//2xOjo6ezs7v38/P/uqfDVpP/2zPLXpv/ojP/1x9zc3Nra3P/0vf/ZYv/vo//TW//wp+anMf/PVP/BP//KTf/FR////////yH5BAEAAH8ALAAAAAAYABgAAAf/gH+Cg4SFhoeIgyKLIoYuPBqRkho8LoMMMTEMhmp+np+fPIMGMjIGhjxYN14/N2swMDtzHbQNPlsNtB0AgmleGcDBGUEAByNSIzMzxyMHKYJQARbT1NQQJSDY2SBDEHKCKUsX4+TkLCZMOBERJiY4LN9/KxT09fYc+BIhIRL4HE2CyHARQKegwYN0aOyjQQfNkRWCxtTAQ7GiRYotHjxoQbGGGUEKntgZSbLkyA8oP4x0okDQADcVYsqcqeQKghcoULxAEGeAoDcCNggdugFOlSkYkipNquWNICFRPEiVSiXLhKtYs05g00bQAi0kwhIpUqes2bNmrSwQRICNChVFVb7cmUu3bl0kBASBSQLkjp6/gAML1nMijKACJ87wWcy4sePFXQoIypGgj+XLmDNfTtBDkBEie0KLHk06dBkdRgSJcWAjj+vXsGPnseFATKLbuHMfCgQAOw=='; 138 | $_R['images/chmod.gif'] = 'data:image/gif;base64,R0lGODlhEAAQAOYAAP+7POLi4v3KYv/GSv/KS//Tjc3Nzf/YeNLS0v/dqf/Ni9ra2sjIyebm5uKxS9a3hMHBwfbVlf/Xd//bqP/Zp//fffbXl//XhP/T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JD4MhCY4NxozLSocEkIYPg2SBh8BGzQgAS8pQjI+CqACHSMZKxYhKI4/FD4LrgCwAgIiBoBCMT48urs8sEUDUVERA0UsDzATLhAICMsPRtBGQQA7'; 140 | $_R['images/movehere.gif'] = 'data:image/gif;base64,R0lGODlhEAAQANU/APn5+VHDPE7BOz+0OnvbSLm6uUK3O7W2tky/O0S5O/39/fT09u7u8vz8/PX197Gxsc/Pz/b2+Pr6+7GysbKxsvj4+kC2Ovz/k+ry60i8O0i8PO3t8LGyspTmW+/v83bhOpriZojcZ4vgUPDz8rj7ZcnJybKxsejo7Zrrh6Pmgr6+vc/P0F/QPk2/PJvqffb595jjeO718LGxssr6hEHIE772drKysszNzMHCwsbFxZnpWvLy9fDw89HR0f///////yH5BAEAAD8ALAAAAAAQABAAAAaMwJ9wSCwOe70VctkDGHu+qNSHrBShjCzDc1pefbyweEP9BnbodJkI8QUCi3jcBxkiWoI8KjBy+H03QxosISEwKS4CGBERPiVDCTQEHToiBB8tFRU+OUMWhCAzNSQaMRISPjhDA6wWBhcJLw2zPipFBT6sCru7PgVFB7lTUgdFMhMmNhwUDw/ME0bRRkEAOw=='; 141 | $_R['images/ren.gif'] = 'data:image/gif;base64,R0lGODlhEAAQANU/APHy8/zbmqyVYyEhIV5eXsPDw5ucnKqrq/7BZ7Kysuu1SoKCgnx8fPzShS8wMejo6NfX2fz67vj4+ERERL29ve7v7//Zc4uLi+Xl5f79+lRUU2BPL7mtlfT19//IWd7h5ZKSknR0dP3+/vf4+9avtf7rx1lZWXpnQ/rcqElNVGhbQMOvhP+gtu/Mdv/PYZKUmZ6fora3uNvTwtelRNrCjeS9YPXO3VJVXOzs6//kkVBQUPn5+ff392ZmZv///////yH5BAEAAD8ALAAAAAAQABAAAAbAwN9OwuPtjkeJZNexsX4GBoFwKFASh4MhxIGQfqCew1Hw4SCLQ0LQ4FR+F8KYsntATC+aZXYa/RZyZCJ2MCsWChs3PD8hPRo6DBcLIQKHGw4mi409PSYaKSo1HidjGoud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DCYwUO4sOHDIh4IAiBii5w8kCNLnpwHi+I/ACYY2cO5s+fPnNUAEFQiAZ/TqFOrRp2gBOkkLvTInk27th4XGVz/UUFAA4HfwIMLB65CkXFCgQAAOw=='; 143 | $_R['css'] = 'html,body{height:100%;width:100%}body{margin:0;font-family:Calibri,Consolas,Trebuchet,sans-serif}a{text-decoration:none;color:#b22424}a:visited{color:#ff2f00}a:hover{color:#dd836f}img{border:0}a:hover.b,.b a:hover,#add a img:hover{border:1px dotted #b22424} #header{padding:.2em;background-color:#e8e8e8} #logout{float:right}.pathCrumbs a:hover{background-color:white}#dir-count{color:grey;font-size:small;margin:0 0 3px 10px}#dirList ul{list-style:none;margin:.5em 0 0 1.5em;padding:0}#dirList li{margin:.05em 0;padding:.1em 0 .1em .1em;width:98%}#dirList li:hover{background:#ebebeb;border-radius:5px}#body .pathCrumbs a:hover{background-color:#e8e8e8}#info li:hover{background:0} #file{padding-left:.3em;font-size:.7em;bottom:.10em} #fileop{position:absolute;right:3em;font-size:.7em;margin-top:.30em} .dir,.file{position:relative;bottom:.05em;right:.11em;font:bold 14px verdana,arial;color:black} .dir{background:url(' . $_R['images/dir.png'] . ') no-repeat bottom left;padding-left:1.45em;padding-top:2px}.file{padding-left:.30em}.mode, .fs,.extension, .filemtime{position:absolute;right:15em;font-family:Calibri,sans-serif; font-size:.7em;margin-top:.30em}.fs{margin-right:5%}.extension{margin-right:13%} .filemtime{margin-right:20%}.del,.edit,.rename,.move,.copy,.chmod, .extract{position:absolute;margin-top:.11em;min-width:1em;min-height:1em}.del{background:url(' . $_R['images/del.png'] . ') no-repeat top right;right:2.22em}.rename{background:url(' . $_R['images/ren.gif'] . ') no-repeat top right;right:3.33em}.move{background:url(' . $_R['images/move.gif'] . ') no-repeat top right;right:4.44em}.chmod{background:url(' . $_R['images/chmod.gif'] . ') no-repeat top right;right:6.55em}.copy{background:url(' . $_R['images/copy.png'] . ') no-repeat top right;right:5.56em}.extract{background:url(' . $_R['images/extract.png'] . ') no-repeat top right;right:8.92em}.edit{background:url(' . $_R['images/edit.png'] . ') no-repeat top right;right:7.65em} .backRestor{margin: 20px 0px 0px 20%;} .backRestor div{padding: 5px;display: inline-block; border-radius: 20px;} .backRestor .backupp{background-color: rgb(96, 219, 10);} .backRestor .restoree{background-color: pink;} .backRestor .db_backResto{float:right; background-color: yellow;} .my_zip{font-size:0.8em;background-color:yellow;color:black;position: absolute;right:9.55em;} .cp{background:url(' . $_R['images/cp.png'] . ') no-repeat top right;padding:0 0 1px 1px}#add{float:right;position:relative;right:2em;top:1em}#add a:hover,#add a:focus{border:0}#movelist{text-align:left;margin-left:.5em}#moveListUL{margin-top:.75em;margin-bottom:.5em;list-style:none;overflow:auto}#movelist a img{vertical-align:-15%}#movehere{margin-left:.5em;background:url(' . $_R['images/movehere.gif'] . ') no-repeat center left;padding-left:.90em;font-family:Calibri,sans-serif} #ea{position:absolute;top:0;left:0;z-index:125}#editMsg{margin-left:2px}.failed,.succeeded{color:red;font-weight:bold}.succeeded{color:green}.CodeMirror-scroll{width:800px;height:600px!important;border:1px solid black}#footer{position:relative;top:3em;padding-bottom:1em;clear:both; text-align:center;font-size:.85em}#footer a{font-style:italic}#popup{position:fixed;left:50%;top:50%;min-width:15em;min-height:3em;border:2px solid #525252;background:white;z-index:150;padding-bottom:10px} #head{background-color:#e8e8e8;font-family:Calibri,sans-serif} #x{float:right}#body{text-align:center;margin:.5em 0;padding:0 15px 5px;white-space:nowrap}#response{font-weight:bold;font-size:small;margin-top:10px}#shell-history{width:400px;height:300px}#upload-drag{border:2px dashed;color:grey;height:20px;margin-top:7px;padding:7px 0 10px;width:97%}#upload-drag.upload-dragover{border:2px dashed blue}#remote-copy{text-align:left}#remote-copy input[type="text"]{width:300px}#remote-copy input[type="submit"]{float:right;margin-top:8px} #popOverlay,#editOverlay, #ajaxOverlay{width:100%;height:100%;position:fixed;left:0;top:0; z-index:105;background-color:#fff!important}#editOverlay{opacity:1;filter:alpha(opacity = 100);z-index:115}#ajaxOverlay{z-index:150}#ajaxImg{position:fixed;left:50%;top:50%;margin-left:-1.5em;margin-top:-1em;z-index:160}'; 144 | 145 | 146 | if (!DEV && isset($_GET['r'])) { 147 | $r = $_GET['r']; 148 | $is_image = strpos($r, '.') !== false; 149 | //TODO: cache headers 150 | header('Content-Type: ' . $_R_HEADERS[$is_image ? getExt($r) : $r]); 151 | exit($is_image ? base64_decode($_R[$r]) : $_R[$r]); 152 | } 153 | 154 | /* 155 | * init 156 | */ 157 | $do = isset($_GET['do']) ? $_GET['do'] : null; 158 | 159 | if (AUTHORIZE) { 160 | session_start(); 161 | doAuth(); 162 | } 163 | 164 | $nonce = isset($_SESSION['nonce']) ? $_SESSION['nonce'] : ''; 165 | 166 | /* 167 | * A warning is issued when the timezone is not set. 168 | */ 169 | if (function_exists('date_default_timezone_set')) 170 | date_default_timezone_set('UTC'); 171 | $tz_offset = isset($_SESSION['tz_offset']) ? $_SESSION['tz_offset'] : 0; 172 | 173 | /** 174 | * directory checks and chdir 175 | */ 176 | 177 | if (!isNull(ROOT) && is_dir(ROOT)) 178 | chdir(ROOT); 179 | 180 | if (!is_dir($path)) { 181 | if ($path != '.') 182 | exit(header('Location: ?path=.')); 183 | else 184 | echo 'The current directory ' . getcwd() . ' can\'t be read'; 185 | } 186 | 187 | if (!is_readable($path)) { 188 | chmod($path, 0755); 189 | if (!is_readable($path)) 190 | echo 'path (' . $pathHTML . ') can\'t be read'; 191 | } 192 | 193 | /** 194 | * perform requested action 195 | */ 196 | if ($do) { 197 | if (isset($_GET['subject']) && !isNull($_GET['subject'])) { 198 | $subject = str_replace('/', null, $_GET['subject']); 199 | $subjectURL = escape($subject); 200 | $subjectHTML = htmlspecialchars($subject); 201 | } 202 | 203 | switch ($do) { 204 | case 'login': 205 | exit(doLogin()); 206 | case 'logout': 207 | exit(doLogout()); 208 | case 'shell': 209 | nonce_check(); 210 | exit(shell_exec($_POST['cmd'])); 211 | case 'create': 212 | nonce_check(); 213 | exit(doCreate($_POST['f_name'], $_GET['f_type'], $path)); 214 | case 'upload': 215 | nonce_check(); 216 | exit(doUpload($path)); 217 | case 'chmod': 218 | nonce_check(); 219 | exit(doChmod($subject, $path, $_POST['mod'])); 220 | case 'extract': 221 | nonce_check(); 222 | exit(doExtract($subject, $path)); 223 | case 'readFile': 224 | exit(doReadFile($subject, $path)); 225 | case 'rename': 226 | nonce_check(); 227 | exit(doRename($subject, $path)); 228 | case 'delete': 229 | nonce_check(); 230 | exit(doDelete($subject, $path)); 231 | case 'saveEdit': 232 | nonce_check(); 233 | exit(doSaveEdit($subject, $path)); 234 | case 'copy': 235 | nonce_check(); 236 | exit(doCopy($subject, $path)); 237 | case 'move': 238 | nonce_check(); 239 | exit(doMove($subject, $path)); 240 | case 'moveList': 241 | exit(moveList($subject, $path)); 242 | case 'installCodeMirror': 243 | exit(installCodeMirror()); 244 | case 'fileExists': 245 | exit(file_exists($path . '/' . $subject)); 246 | case 'getfs': 247 | exit(getFs($path . '/' . $subject)); 248 | case 'remoteCopy': 249 | nonce_check(); 250 | exit(doRemoteCopy($path)); 251 | } 252 | } 253 | 254 | /** 255 | * no action; list current directory 256 | */ 257 | getDirContents($path); 258 | 259 | /** 260 | * helper functions 261 | */ 262 | 263 | /** 264 | * @return bool returns true if any empty values are passed 265 | */ 266 | function isNull() { 267 | foreach (func_get_args() as $value) 268 | if (!strlen($value)) 269 | return true; 270 | return false; 271 | } 272 | 273 | function zipSupport() { 274 | if (function_exists('zip_open')) 275 | return 'function'; 276 | if (class_exists('ZipArchive')) 277 | return 'class'; 278 | if (strpos(PHP_OS, 'WIN') === false && @shell_exec('unzip')) 279 | return 'exec'; 280 | return false; 281 | } 282 | 283 | function escape($uri) { 284 | return str_replace('%2F', '/', rawurlencode($uri)); 285 | } 286 | 287 | function removeQuotes($subject, $single = true, $double = true) { 288 | if ($single) 289 | $subject = str_replace('\'', null, $subject); 290 | if ($double) 291 | $subject = str_replace('"', null, $subject); 292 | return $subject; 293 | } 294 | 295 | function return_bytes($val) { //for upload. http://php.net/ini_get 296 | $val = trim($val); 297 | $last = strtolower($val{strlen($val) - 1}); 298 | switch ($last) { 299 | case 'g': 300 | $val *= 1024; 301 | case 'm': 302 | $val *= 1024; 303 | case 'k': 304 | $val *= 1024; 305 | } 306 | 307 | return $val; 308 | } 309 | 310 | function getExt($file) { 311 | return strrpos($file, '.') ? strtolower(substr($file, strrpos($file, '.') + 1)) : '<>'; 312 | } 313 | 314 | function getMod($subject) { 315 | return substr(sprintf('%o', fileperms($subject)), -4); 316 | } 317 | 318 | function redirect() { 319 | global $redir; 320 | @header('Location: ' . $redir); 321 | } 322 | 323 | function refresh($message, $speed = 2) { 324 | global $redir; 325 | return '' . $message; 326 | } 327 | 328 | function getFs($file) { 329 | if (filesize($file) <= 1024) 330 | return filesize($file) . ' B'; 331 | elseif (filesize($file) <= 1024000) 332 | return round(filesize($file) / 1024, 2) . ' KB'; 333 | else 334 | return round(filesize($file) / 1024000, 2) . ' MB'; 335 | } 336 | 337 | function rrd($dir) { 338 | $handle = opendir($dir); 339 | while (($dirItem = readdir($handle)) !== false) { 340 | if ($dirItem == '.' || $dirItem == '..') 341 | continue; 342 | $path = $dir . '/' . $dirItem; 343 | is_dir($path) ? rrd($path) : unlink($path); 344 | } 345 | closedir($handle); 346 | return rmdir($dir); 347 | } 348 | 349 | function pathCrumbs() { 350 | global $pathHTML, $pathURL; 351 | $crumbs = explode('/', $pathHTML); 352 | $crumbsLink = explode('/', $pathURL); 353 | $pathSplit = ''; 354 | $crumb = str_replace('/', ' / ', dirname(getcwd())) . ' / '; 355 | for ($i = 0; $i < count($crumbs); $i++) { 356 | $slash = $i ? '/' : ''; 357 | $pathSplit .= $slash . $crumbsLink[$i]; 358 | $crumb .= '' 359 | . ($i ? $crumbs[$i] : '' . basename(getcwd()) . '') . " /\n"; 360 | } 361 | return $crumb; 362 | } 363 | 364 | //authorize functions 365 | function doAuth() { 366 | global $do, $pathURL, $footer; 367 | $pwd = isset($_SESSION['pwd']) ? $_SESSION['pwd'] : ''; 368 | if ($do == 'login' || $do == 'logout') 369 | return; //TODO: login/logout take place here 370 | if ($pwd != crypt(PASSWORD__WFMB, PASSWORD_SALT)) 371 | if ($do) 372 | exit('Please refresh the page and login'); 373 | else 374 | exit(' 375 | 376 | 377 | 378 | Log In | pafm 379 | 387 | 388 | 389 |
390 |
391 | Log in 392 | 393 | 394 | 395 |
396 |

' . $footer . '

397 |
398 | 401 | 402 | '); 403 | } 404 | 405 | function doLogin() { 406 | $pwd = isset($_POST['pwd']) ? $_POST['pwd'] : ''; 407 | $bruteforce_file_exists = file_exists(BRUTEFORCE_FILE); 408 | 409 | if ($bruteforce_file_exists) { 410 | $bruteforce_contents = explode('|', file_get_contents(BRUTEFORCE_FILE)); 411 | if ((time() - $bruteforce_contents[0]) < BRUTEFORCE_TIME_LOCK && $bruteforce_contents[1] >= BRUTEFORCE_ATTEMPTS) 412 | return refresh('Attempt limit reached, please wait: ' 413 | . ($bruteforce_contents[0] + BRUTEFORCE_TIME_LOCK - time()) . ' seconds'); 414 | } 415 | 416 | if ($pwd == PASSWORD__WFMB) { 417 | $_SESSION['tz_offset'] = intval($_POST['tz_offset']); 418 | $_SESSION['pwd'] = crypt(PASSWORD__WFMB, PASSWORD_SALT); 419 | $_SESSION['nonce'] = crypt(uniqid(), rand()); 420 | $bruteforce_file_exists && unlink(BRUTEFORCE_FILE); 421 | return redirect(); 422 | } 423 | 424 | $bruteforce_data = time() . '|'; 425 | /** 426 | * The second condition, if reached, implies an expired bruteforce lock 427 | */ 428 | if (!$bruteforce_file_exists || $bruteforce_contents[1] >= BRUTEFORCE_ATTEMPTS) 429 | $bruteforce_data .= 1; 430 | else 431 | $bruteforce_data .= ++$bruteforce_contents[1]; 432 | 433 | file_put_contents(BRUTEFORCE_FILE, $bruteforce_data); 434 | chmod(BRUTEFORCE_FILE, 0700); //prevent others from viewing 435 | return refresh('Password is incorrect'); 436 | } 437 | 438 | function doLogout() { 439 | session_destroy(); 440 | redirect(); 441 | } 442 | 443 | function nonce_check() { 444 | if (AUTHORIZE && $_GET['nonce'] != $_SESSION['nonce']) 445 | exit(refresh('Invalid nonce, try again.')); 446 | } 447 | 448 | //fOp functions 449 | function doCreate($f_name, $f_type, $path) { 450 | if (isNull($f_name)) 451 | return refresh('A filename has not been entered'); 452 | 453 | $invalidChars = strpos(PHP_OS, 'WIN') !== false ? '/\\|\/|:|\*|\?|\"|\<|\>|\|/' : '/\//'; 454 | if (preg_match($invalidChars, $f_name)) 455 | return refresh('Filename contains invalid characters'); 456 | 457 | if ($f_type == 'file' && !file_exists($path . '/' . $f_name)) 458 | fclose(fopen($path . '/' . $f_name, 'w')); 459 | elseif ($f_type == 'folder' && !file_exists($path . '/' . $f_name)) 460 | mkdir($path . '/' . $f_name); 461 | else 462 | return refresh(htmlspecialchars($f_name) . ' already exists'); 463 | redirect(); 464 | } 465 | 466 | function installCodeMirror() { 467 | mkdir(CODEMIRROR_PATH); 468 | $cmjs = CODEMIRROR_PATH . '/cm.js'; 469 | $cmcss = CODEMIRROR_PATH . '/cm.css'; 470 | $out = null; 471 | 472 | copy('http://cloud.github.com/downloads/mustafa0x/pafm/_codemirror.js', $cmjs); 473 | copy('http://cloud.github.com/downloads/mustafa0x/pafm/_codemirror.css', $cmcss); 474 | 475 | /** 476 | * avoid using modified CodeMirror files 477 | */ 478 | if (md5_file($cmjs) != '65f5ba3c8d38bb08544717fc93c14024') 479 | $out = unlink($cmjs); 480 | if (md5_file($cmcss) != '23d441d9125538e3c5d69448f8741bfe') 481 | $out = unlink($cmcss); 482 | 483 | return $out ? '-' : ''; 484 | } 485 | 486 | function doUpload($path) { 487 | if (!$_FILES) 488 | return refresh('$_FILES array can not be read. Check file size limits and the max execution time limit.'); 489 | 490 | $uploadErrors = array(null, 491 | 'The uploaded file exceeds the upload_max_filesize directive in php.ini.', 492 | 'The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.', 493 | 'The uploaded file was only partially uploaded.', 494 | 'No file was uploaded.', 495 | 'Missing a temporary folder.', 496 | 'Failed to write file to disk.', 497 | 'File upload stopped by extension.' 498 | ); 499 | $error_message = ' Please see File Upload Error Messages'; 500 | 501 | $fail = false; 502 | 503 | if ($_FILES['file']['error']) { 504 | if ($uploadErrors[$_FILES['file']['error']]) 505 | return refresh($uploadErrors[$_FILES['file']['error']] . $error_message); 506 | else 507 | return refresh('Unknown error occurred.' . $error_message); 508 | } 509 | 510 | if (!is_file($_FILES['file']['tmp_name'])) 511 | return refresh($_FILES['file']['name'] . ' could not be uploaded.' 512 | . 'Possible causes could be the post_max_size and memory_limit directives in php.ini.'); 513 | 514 | if (!is_uploaded_file($_FILES['file']['tmp_name'])) 515 | return refresh(basename($_FILES['file']['name']) . ' is not a POST-uploaded file'); 516 | 517 | if (!move_uploaded_file($_FILES['file']['tmp_name'], $path . '/' . basename($_FILES['file']['name']))) 518 | $fail = true; 519 | 520 | return $fail ? 'One or more files could not be moved.' : $_FILES['file']['name'] . ' uploaded'; 521 | } 522 | 523 | function doChmod($subject, $path, $mod) { 524 | if (isNull($mod)) 525 | return refresh('chmod field is empty'); 526 | 527 | chmod($path . '/' . $subject, octdec(strlen($mod) == 3 ? 0 . $mod : $mod)); 528 | redirect(); 529 | } 530 | 531 | function doExtract($subject, $path) { 532 | global $subjectHTML; 533 | switch (zipSupport()) { 534 | case 'function': 535 | if (!is_resource($zip = zip_open($path . '/' . $subject))) 536 | return refresh($subjectHTML . ' could not be read for extracting'); 537 | 538 | while ($zip_entry = zip_read($zip)) { 539 | zip_entry_open($zip, $zip_entry); 540 | if (substr(zip_entry_name($zip_entry), -1) == '/') { 541 | $zdir = substr(zip_entry_name($zip_entry), 0, -1); 542 | if (file_exists($path . '/' . $zdir)) 543 | return refresh(htmlspecialchars($zdir) . ' exists!'); 544 | mkdir($path . '/' . $zdir); 545 | } else { 546 | if (file_exists($path . '/' . zip_entry_name($zip_entry))) 547 | return refresh(htmlspecialchars($path . '/' . zip_entry_name($zip_entry)) . ' exists!'); 548 | 549 | $fopen = fopen($path . '/' . zip_entry_name($zip_entry), 'w'); 550 | $ze_fs = zip_entry_filesize($zip_entry); 551 | fwrite($fopen, zip_entry_read($zip_entry, $ze_fs), $ze_fs); 552 | } 553 | zip_entry_close($zip_entry); 554 | } 555 | zip_close($zip); 556 | break; 557 | case 'class': 558 | $zip = new ZipArchive(); 559 | if ($zip->open($path . '/' . $subject) !== true) 560 | return refresh($subjectHTML . ' could not be read for extracting'); 561 | $zip->extractTo($path); 562 | $zip->close(); 563 | break; 564 | case 'exec': 565 | shell_exec('unzip ' . escapeshellarg($path . '/' . $subject)); 566 | } 567 | redirect(); 568 | } 569 | 570 | function doReadFile($subject, $path) { 571 | return file_get_contents($path . '/' . $subject); 572 | } 573 | 574 | function doCopy($subject, $path) { 575 | $to = isset($_POST['to']) ? $_POST['to'] : ''; 576 | $dest = $path . '/' . $to; 577 | 578 | if (isNull($subject, $path, $to)) 579 | return refresh('Values could not be read'); 580 | 581 | if (is_dir($path . '/' . $subject)) { 582 | copyDir($path . '/' . $subject, $dest); 583 | redirect(); 584 | } 585 | 586 | if (file_exists($dest)) 587 | return refresh('Destination (' . $dest . ') exists'); 588 | 589 | if (!copy($path . '/' . $subject, $dest)) 590 | return refresh($subject . ' could not be copied to ' . $to); 591 | 592 | redirect(); 593 | } 594 | 595 | function copyDir($subject, $to) { 596 | if (file_exists($to) || !mkdir($to)) 597 | return refresh('Destination exists or creation of destination failed.'); 598 | 599 | $handle = opendir($subject); 600 | while (($dirItem = readdir($handle)) !== false) { 601 | if ($dirItem == '.' || $dirItem == '..') 602 | continue; 603 | 604 | $path = $subject . '/' . $dirItem; 605 | if (is_dir($path)) 606 | copyDir($path, $to . '/' . $dirItem); 607 | else 608 | copy($path, $to . '/' . $dirItem); 609 | } 610 | 611 | closedir($handle); 612 | } 613 | 614 | function doRemoteCopy($path) { 615 | $location = isset($_POST['location']) ? $_POST['location'] : ''; 616 | $to = isset($_POST['to']) ? $_POST['to'] : ''; 617 | $dest = $path . '/' . $to; 618 | 619 | if (isNull($path, $location, $to)) 620 | return refresh('Values could not be read'); 621 | 622 | if (file_exists($dest)) 623 | return refresh('Destination (' . $dest . ') exists'); 624 | 625 | if (!copy($location, $dest)) 626 | return refresh($location . ' could not be copied to ' . ($dest)); 627 | redirect(); 628 | } 629 | 630 | function doRename($subject, $path) { 631 | $rename = isset($_POST['rename']) ? $_POST['rename'] : ''; 632 | if (isNull($subject, $rename)) 633 | return refresh('Values could not be read'); 634 | 635 | if (file_exists($path . '/' . $rename)) 636 | return refresh(htmlspecialchars($rename) . ' exists, please choose another name'); 637 | 638 | rename($path . '/' . $subject, $path . '/' . $rename); 639 | redirect(); 640 | } 641 | 642 | function doDelete($subject, $path) { 643 | global $subjectHTML; 644 | $fullPath = $path . '/' . $subject; 645 | 646 | if (isNull($subject, $path)) 647 | return refresh('Values could not be read'); 648 | if (!file_exists($fullPath)) 649 | return refresh($subjectHTML . ' doesn\'t exist'); 650 | 651 | if (is_file($fullPath)) 652 | if (!unlink($fullPath)) 653 | return refresh($subjectHTML . ' could not be removed'); 654 | 655 | if (is_dir($fullPath)) 656 | if (!rrd($fullPath)) 657 | return refresh($subjectHTML . ' could not be removed'); 658 | 659 | redirect(); 660 | } 661 | 662 | function doSaveEdit($subject, $path) { 663 | global $subjectHTML, $tz_offset; 664 | $data = get_magic_quotes_gpc() ? stripslashes($_POST['data']) : $_POST['data']; 665 | if (!is_file($path . '/' . $subject)) 666 | return 'Error: ' . $subjectHTML . ' is not a valid file'; 667 | 668 | if (file_put_contents($path . '/' . $subject, $data) === false) 669 | return $subject . ' could not be saved'; 670 | else 671 | return 'saved at ' . date('H:i:s', time() + $tz_offset); 672 | } 673 | 674 | function doMove($subject, $path) { 675 | global $pathHTML, $subjectHTML; 676 | 677 | if (isset($_GET['to']) && !isNull($_GET['to'])) { 678 | $to = $_GET['to']; 679 | $toHTML = htmlspecialchars($to); 680 | $toURL = escape($to); 681 | } 682 | if (isNull($subject, $path, $to)) 683 | return refresh('Values could not be read'); 684 | 685 | if ($path == $to) 686 | return refresh('The source and destination are the same'); 687 | 688 | if (array_search($subject, explode('/', $to)) == array_search($subject, explode('/', $path . '/' . $subject))) 689 | return refresh($toHTML . ' is a subfolder of ' . $pathHTML); 690 | 691 | if (file_exists($to . '/' . $subject)) 692 | return refresh($subjectHTML . ' exists in ' . $toHTML); 693 | 694 | rename($path . '/' . $subject, $to . '/' . $subject); 695 | redirect(); 696 | } 697 | 698 | function moveList($subject, $path) { 699 | global $pathURL, $pathHTML, $subjectURL, $subjectHTML, $nonce; 700 | 701 | if (isset($_GET['to']) && !isNull($_GET['to'])) { 702 | $to = $_GET['to']; 703 | $toHTML = htmlspecialchars($to); 704 | $toURL = escape($to); 705 | } 706 | if (isNull($subject, $path, $to)) 707 | return refresh('Values could not be read'); 708 | 709 | $return = '["div", 710 | {attributes: {"id": "movelist"}}, 711 | [ 712 | "span", 713 | {attributes: {"class": "pathCrumbs"}}, 714 | [ 715 | '; 716 | $crumbs = explode('/', $toHTML); 717 | $crumbsLink = explode('/', $toURL); 718 | $pathSplit = ''; 719 | 720 | for ($i = 0; $i < count($crumbs); $i++) { 721 | $slash = $i ? '/' : null; 722 | $pathSplit .= $slash . $crumbsLink[$i]; 723 | $return .= ($i ? ',' : null) . '"a", 724 | { 725 | attributes : { 726 | "href" : "#", 727 | "title" : "Go to ' . $crumbs[$i] . '" 728 | }, 729 | events : { 730 | click : function(e){ 731 | fOp.moveList("' . $subjectURL . '", "' . $pathURL . '", "' . $pathSplit . '"); 732 | e.preventDefault ? e.preventDefault() : e.returnValue = false; 733 | } 734 | }, 735 | text : "' . ($i ? $crumbs[$i] : 'root') . '", 736 | postText : " / " 737 | }'; 738 | } 739 | 740 | $return .= ' 741 | ], 742 | "ul", 743 | {attributes: {"id": "moveListUL"}}'; 744 | 745 | $j = 0; 746 | //TODO: sort output 747 | $handle = opendir($to); 748 | while (($dirItem = readdir($handle)) !== false) { 749 | $fullPath = $to . '/' . $dirItem; 750 | if (!is_dir($fullPath) || $dirItem == '.' || $dirItem == '..') 751 | continue; 752 | $fullPathURL = escape($fullPath); 753 | $dirItemHTML = htmlspecialchars($dirItem); 754 | $return .= ', 755 | [ 756 | "li", 757 | {}, 758 | [ 759 | "a", 760 | { 761 | attributes : {"href" : "#"}, 762 | events : { 763 | click : function(e){ 764 | fOp.moveList("' . $subjectURL . '", "' . $pathURL . '", "' . $fullPathURL . '"); 765 | e.preventDefault ? e.preventDefault() : e.returnValue = false; 766 | } 767 | } 768 | }, 769 | ["img", {attributes: {"src": "' . $_R['images/odir.png'] . '", "title": "Open ' . $dirItemHTML . '"}}], 770 | "a", 771 | { 772 | attributes: {"href": "?do=move&subject=' . $subjectURL . '&path=' . $pathURL . '&to=' . $fullPathURL 773 | . '&nonce=' . $nonce . '", "title" : "move ' . $subject . ' to ' . $dirItemHTML . '", "class": "dir"}, 774 | text: "' . $dirItemHTML . '" 775 | } 776 | ] 777 | ]'; 778 | $j++; 779 | } 780 | if (!$j) 781 | $return .= ', 782 | "b", {text: "No directories found"}, 783 | "br", {}, 784 | "br", {}'; 785 | $return .= ', 786 | "a", 787 | { 788 | attributes: {"href": "?do=move&subject=' . $subjectURL . '&path=' . $pathURL . '&to=' . $toURL 789 | . '&nonce=' . $nonce . '", "id": "movehere", "title": "move here (' . $toHTML . ')"}, 790 | text : "move here" 791 | }] 792 | ]'; 793 | return $return; 794 | } 795 | 796 | function getDirContents($path) { 797 | global $dirContents, $dirCount; 798 | $itemType = ''; 799 | 800 | $dirHandle = opendir($path); 801 | while (($dirItem = readdir($dirHandle)) !== false) { 802 | if ($dirItem == '.' || $dirItem == '..') 803 | continue; 804 | $fullPath = $path . '/' . $dirItem; 805 | $itemType = is_file($fullPath) ? 'files' : 'folders'; 806 | $dirContents[$itemType][] = $dirItem; 807 | $dirCount[$itemType]++; 808 | } 809 | closedir($dirHandle); 810 | } 811 | 812 | /** 813 | * Output the file list 814 | */ 815 | function getDirs($path) { 816 | global $dirContents, $pathURL, $nonce, $tz_offset; 817 | 818 | if (!count($dirContents['folders'])) 819 | return; 820 | 821 | natcasesort($dirContents['folders']); 822 | 823 | 824 | //-------------------------edit ttt 825 | echo 826 | ''; 842 | //------------------------###edit ttt 843 | 844 | 845 | foreach ($dirContents['folders'] as $dirItem) { 846 | $dirItemURL = escape($dirItem); 847 | $dirItemHTML = htmlspecialchars($dirItem); 848 | $fullPath = $path . '/' . $dirItem; 849 | 850 | $mtime = filemtime($fullPath); 851 | $mod = getMod($path . '/' . $dirItem); 852 | 853 | //-------------------------edit ttt 854 | //remove starting dot 855 | $rawpathhh = substr($pathURL, 1);//if (substr($pathURL, 0, 2) == './') 856 | $myzip_pathh = ROOT . $rawpathhh . '/' . $dirItemHTML; 857 | //------------------------###edit ttt 858 | 859 | 860 | echo 861 | '
  • ' . 862 | "\n\t" . '' . $dirItemHTML . '' . 863 | "\n\t" . '' . date('y-m-d | H:i:s', $mtime + $tz_offset) . '' . 864 | "\n\t" . '' . $mod . '' . 865 | 866 | //-------------------------edit ttt 867 | "\n\t" . 'Zip' . 868 | 869 | //------------------------###edit ttt 870 | 871 | "\n\t" . '' . 872 | "\n\t" . '' . 873 | "\n\t" . '' . 874 | "\n\t" . '' . 875 | "\n\t" . '' . 876 | "\n
  • \n"; 877 | } 878 | } 879 | 880 | function getFiles($path) { 881 | global $dirContents, $pathURL, $codeMirrorModes, $nonce, $tz_offset; 882 | $filePath = $path == '.' ? '/' : '/' . $path . '/'; 883 | 884 | if (!count($dirContents['files'])) 885 | return; 886 | 887 | natcasesort($dirContents['files']); 888 | 889 | $codeMirrorExists = (int)is_dir(CODEMIRROR_PATH); 890 | $zipSupport = zipSupport(); 891 | 892 | //tt edition 893 | $correctpath = str_ireplace(separator__WFMB($_SERVER['DOCUMENT_ROOT']), '', separator__WFMB(ROOT)); 894 | $correctpath = str_ireplace('\\', '/', $correctpath); 895 | 896 | foreach ($dirContents['files'] as $dirItem) { 897 | $dirItemURL = escape($dirItem); 898 | $dirItemHTML = htmlspecialchars($dirItem); 899 | $fullPath = $path . '/' . $dirItem; 900 | 901 | $mtime = filemtime($fullPath); 902 | $mod = getMod($fullPath); 903 | $ext = getExt($dirItem); 904 | 905 | $cmSupport = in_array($ext, $codeMirrorModes) ? 'cp ' : ''; 906 | 907 | echo '
  • ' . 908 | "\n\t" . '' . $dirItemHTML . '' . 909 | 910 | //---- tt edition 911 | //if .sql, then show "RESTORE" button 912 | ((pathinfo($dirItem, PATHINFO_EXTENSION) == 'sql') ? '   (RESTORE INTO DATABASE)' : '') . 913 | //---- ##tt edition 914 | 915 | "\n\t" . '' . getfs($path . '/' . $dirItem) . '' . 916 | "\n\t" . '' . $ext . '' . 917 | "\n\t" . '' . date('y-m-d | H:i:s', $mtime + $tz_offset) . '' . 918 | "\n\t" . '' . $mod . '' . 919 | (($zipSupport && $ext == 'zip') 920 | ? "\n\t" . '' 921 | : '') . 922 | (filesize($fullPath) <= (1048576 * MaxEditableSize) 923 | ? "\n\t" . '' 924 | : '') . 925 | "\n\t" . '' . 926 | "\n\t" . '' . 927 | "\n\t" . '' . 928 | "\n\t" . '' . 929 | "\n\t" . '' . 930 | "\n
  • \n"; 931 | } 932 | } 933 | 934 | 935 | //----------------------------------------------------edit ttt ------------------------------------------------------- 936 | function downld($zip_name) { 937 | ob_get_clean(); 938 | //if (stristr($zip_name,'..')) {die("incorrrrrrect fileeee..");} 939 | header("Pragma: public"); 940 | header("Expires: 0"); 941 | header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); 942 | header("Cache-Control: private", false); 943 | header("Content-Type: application/zip"); 944 | header("Content-Disposition: attachment; filename=" . basename($zip_name) . ";"); 945 | header("Content-Transfer-Encoding: binary"); 946 | header("Content-Length: " . filesize($zip_name)); 947 | readfile($zip_name); 948 | } 949 | 950 | if (!empty($_GET['delete_filee'])) { 951 | chdir(dirname(__file__)); 952 | die((unlink($_GET['delete_filee']) ? 'deleted' : 'file doesnt exist')); 953 | } 954 | if (!empty($_GET['fildown'])) { 955 | chdir(dirname(__file__)); 956 | downld($_GET['fildown']); 957 | } 958 | 959 | 960 | // ====================================================== ZIPPER ====================================== // 961 | // https://github.com/ttodua/useful-php-scripts 962 | class ModifiedFlxZipArchive extends ZipArchive { 963 | public function addDirDoo($location, $name, $prohib_filenames = array()) { 964 | if (!file_exists($location)) { 965 | die("maybe file/folder path ( $location ) incorrect."); 966 | } 967 | $this->addEmptyDir($name); 968 | $name .= '/'; 969 | $location .= "/"; 970 | $dir = opendir($location); // Read all Files in Dir 971 | while ($file = readdir($dir)) { 972 | if ($file != '.' && $file != '..') { 973 | if (!in_array($name . $file, $prohib_filenames)) { 974 | if (filetype($location . $file) == 'dir') { 975 | $this->addDirDoo($location . $file, $name . $file, $prohib_filenames); 976 | } else { 977 | $this->addFile($location . $file, $name . $file); 978 | } 979 | } 980 | } 981 | } 982 | } 983 | 984 | public function FoldeerAdd($new_zip_filename1, $foldernameee1, $prohib_filenames1 = array()) { 985 | if ($this->open(dirname($foldernameee1) . '/' . $new_zip_filename1, ZipArchive::CREATE)) { 986 | $this->addDirDoo($foldernameee1, basename($foldernameee1), $prohib_filenames1); 987 | } else { 988 | die('cantttt start zipper. error_699'); 989 | } 990 | } 991 | 992 | } 993 | 994 | $MyZipper = new ModifiedFlxZipArchive; 995 | // ====================================================== ###ZIPPER### ====================================== // 996 | 997 | 998 | //download 999 | if (!empty($_GET['startzip'])) { 1000 | chdir(dirname(__file__)); 1001 | if (!empty($_GET['pathh'])) { 1002 | $foldernameee = $_GET['pathh']; 1003 | $foldernameee = preg_replace("/%u([0-9a-f]{3,4})/i", "&#x\\1;", urldecode($foldernameee)); 1004 | $foldernameee = html_entity_decode($foldernameee, null, 'UTF-8'); 1005 | //remove starting dot 1006 | //$foldernameee = substr($foldernameee,1); 1007 | $zip_filename = basename($foldernameee) . '___compressed.zip'; 1008 | $excl_var = $_GET['exlcud']; 1009 | $excl_var = preg_replace("/%u([0-9a-f]{3,4})/i", "&#x\\1;", urldecode($excl_var)); 1010 | $excl_var = html_entity_decode($excl_var, null, 'UTF-8'); 1011 | $exclude_some_files = explode(',', $excl_var); 1012 | // delte previous existing file 1013 | if (file_exists($zip_filename)) { 1014 | unlink($zip_filename); 1015 | } 1016 | //create an archive 1017 | $MyZipper->FoldeerAdd($zip_filename, $foldernameee, $exclude_some_files); 1018 | //download archive 1019 | //downld($zip_filename); //on the same ZIPPER execution, this made problems in some hostings, so better to redirect 1020 | $zip_old_path = str_replace('\\', DIRECTORY_SEPARATOR, str_replace('/', DIRECTORY_SEPARATOR, __DIR__ . '/' . $zip_filename)); 1021 | $zip_new_path = dirname($foldernameee) . '/' . $zip_filename; 1022 | echo('Download archive: ' . $zip_new_path . '

    After downloading, delete it! '); 1023 | exit; 1024 | } 1025 | } 1026 | 1027 | 1028 | // ====================================================== DataBase BACKUP/RESTORE ====================================== // 1029 | // https://github.com/ttodua/useful-php-scripts 1030 | function EXPORT_TABLES($host, $user, $pass, $name, $tables = false, $backup_name = false) { 1031 | $mysqli = new mysqli($host, $user, $pass, $name); 1032 | $mysqli->select_db($name); 1033 | $mysqli->query("SET NAMES 'utf8'"); 1034 | $queryTables = $mysqli->query('SHOW TABLES'); 1035 | while ($row = $queryTables->fetch_row()) { 1036 | $target_tables[] = $row[0]; 1037 | } 1038 | if ($tables !== false) { 1039 | $target_tables = array_intersect($target_tables, $tables); 1040 | } 1041 | foreach ($target_tables as $table) { 1042 | $result = $mysqli->query('SELECT * FROM ' . $table); 1043 | $fields_amount = $result->field_count; 1044 | $rows_num = $mysqli->affected_rows; 1045 | $res = $mysqli->query('SHOW CREATE TABLE ' . $table); 1046 | $TableMLine = $res->fetch_row(); 1047 | $content = (!isset($content) ? '' : $content) . "\n\n" . $TableMLine[1] . ";\n\n"; 1048 | for ($i = 0; $i < $fields_amount; $i++, $st_counter = 0) { 1049 | while ($row = $result->fetch_row()) { //when started (and every after 100 command cycle): 1050 | if ($st_counter % 100 == 0 || $st_counter == 0) { 1051 | $content .= "\nINSERT INTO " . $table . " VALUES"; 1052 | } 1053 | $content .= "\n("; 1054 | for ($j = 0; $j < $fields_amount; $j++) { 1055 | $row[$j] = str_replace("\n", "\\n", addslashes($row[$j])); 1056 | if (isset($row[$j])) { 1057 | $content .= '"' . $row[$j] . '"'; 1058 | } else { 1059 | $content .= '""'; 1060 | } 1061 | if ($j < ($fields_amount - 1)) { 1062 | $content .= ','; 1063 | } 1064 | } 1065 | $content .= ")"; 1066 | //every after 100 command cycle [or at last line] ....p.s. but should be inserted 1 cycle eariler 1067 | if ((($st_counter + 1) % 100 == 0 && $st_counter != 0) || $st_counter + 1 == $rows_num) { 1068 | $content .= ";"; 1069 | } else { 1070 | $content .= ","; 1071 | } 1072 | $st_counter = $st_counter + 1; 1073 | } 1074 | } 1075 | $content .= "\n\n\n"; 1076 | } 1077 | $backup_name = $backup_name ? $backup_name : $name . "___(" . date('H-i-s') . "_" . date('d-m-Y') . ")__rand" . rand(1, 11111111) . ".sql"; 1078 | header('Content-Type: application/octet-stream'); 1079 | header("Content-Transfer-Encoding: Binary"); 1080 | header("Content-disposition: attachment; filename=\"" . $backup_name . "\""); 1081 | echo $content; 1082 | exit; 1083 | } 1084 | 1085 | //https://github.com/ttodua/useful-php-scripts 1086 | function IMPORT_TABLES($host, $user, $pass, $dbname, $sql_file) { 1087 | if (!file_exists($sql_file)) { 1088 | die('Input the SQL filename correctly! Go Back.'); 1089 | } 1090 | $allLines = file($sql_file); 1091 | $mysqli = new mysqli($host, $user, $pass, $dbname); 1092 | if (mysqli_connect_errno()) { 1093 | echo "Failed to connect to MySQL: " . mysqli_connect_error(); 1094 | } 1095 | $zzzzzz = $mysqli->query('SET foreign_key_checks = 0'); 1096 | preg_match_all("/\nCREATE TABLE(.*?)\`(.*?)\`/si", "\n" . file_get_contents($sql_file), $target_tables); 1097 | foreach ($target_tables[2] as $table) { 1098 | $mysqli->query('DROP TABLE IF EXISTS ' . $table); 1099 | } 1100 | $zzzzzz = $mysqli->query('SET foreign_key_checks = 1'); 1101 | $mysqli->query("SET NAMES 'utf8'"); 1102 | $templine = ''; // Temporary variable, used to store current query 1103 | foreach ($allLines as $line) { // Loop through each line 1104 | if (substr($line, 0, 2) != '--' && $line != '') { 1105 | $templine .= $line; // (if it is not a comment..) Add this line to the current segment 1106 | if (substr(trim($line), -1, 1) == ';') { // If it has a semicolon at the end, it's the end of the query 1107 | $mysqli->query($templine) or print('Error performing query \'' . $templine . '\': ' . $mysqli->error . '

    '); 1108 | $templine = '';// Reset temp variable to empty 1109 | } 1110 | } 1111 | } 1112 | echo 'Importing finished. Now, Delete the import file.'; 1113 | } 1114 | 1115 | 1116 | if (!empty($_POST['dbaction'])) { 1117 | chdir(dirname(__file__)); 1118 | $dbhost = $_POST['dbHOST']; 1119 | $dbuser = $_POST['dbUSER']; 1120 | $dbpass = $_POST['dbPASS']; 1121 | $dbname = $_POST['dbNAME']; 1122 | if ($_POST['dbaction'] == 'exportt') { 1123 | EXPORT_TABLES($dbhost, $dbuser, $dbpass, $dbname); 1124 | } elseif ($_POST['dbaction'] == 'importt') { 1125 | IMPORT_TABLES($dbhost, $dbuser, $dbpass, $dbname, $_POST['sqlfilenamee']); 1126 | } 1127 | exit; 1128 | } 1129 | // ====================================================== ###DataBase RESTORE### ====================================== // 1130 | 1131 | //-------------------------###edit ttt 1132 | 1133 | 1134 | ?> 1135 | 1136 | 1137 | 1138 | 1139 | <?php echo basename(dirname(getcwd() . $pathHTML)) . '/' . basename(getcwd() . $pathURL); ?> | pafm 1140 | 1142 | 1143 | 1144 | 1145 | 1146 | 1147 | 1161 | 1162 | 1163 |
    1164 | 1168 | 1173 | 1177 | 1178 |
    1179 | DATABASE: Backup 1180 | | Restore 1181 |
    1182 | 1183 | 1184 | 1254 |
    1255 | 1256 | 1257 |
    1258 |
      1259 |
    • 1260 | nameextensionlast modifiedmodesizefile operations 1263 |
    • 1264 |
    1265 | 1266 |
    1267 |
    1268 |
    1269 | 1270 |
    1271 | Create 1272 | File:Create File 1273 | Create 1274 | Folder:Create Folder 1275 | Upload File:Upload File 1278 | 1279 |
    1280 | Open 1282 | Shell:Terminal 1283 |
    1284 | 1285 | 1296 | 1297 | 1298 | 1299 | -------------------------------------------------------------------------------- /caching-with-HTACCESS-examples: -------------------------------------------------------------------------------- 1 | ################################################################################## 2 | ########################### HTACCESS optimization (TT's version) ################# 3 | ################################################################################## 4 | ######################### ShortLink: https://github.com/ttodua/useful-php-scripts/blob/master/caching-with-HTACCESS-examples ####################### 5 | # NOTE 1: READ ALL NOTES & COMMENTS in this file, PLEASE! 6 | # NOTE 2: This approaches are needed very rarely. If you use CMS (i.e. WP or etc) there are excellent caching plugins, and use them. 7 | # NOTE 3: In some low-quality hostings, these codes won't work in HTACCESS. If you are serious, get a priced hosting. 8 | # NOTE 4: In some cases, if your hosting is limited, you can use different "CACHING" and "COMPRESSION" methods, 9 | # rather than the my codes. For this, read the commented lines in those blocks. 10 | # NOTE 5: Remember, in HTACCESS, instead of ONE-LINE fileType commands, i.e. 11 | # ExpiresByType image/jpg "access plus 3 months" 12 | # You can use: 13 | # 14 | # ExpiresDefault "access plus 3 months" 15 | # 16 | # NOTE 6: This doesn't user barely-used "Manifest" approaches. (Who needs them, read: http://goo.gl/3AFjt3 ) 17 | ################################################################################### 18 | ################################################################################### 19 | 20 | 21 | ########################################################### 22 | ########### Turn off `Last-Modified` ################## 23 | ########################################################### 24 | # Description: If you remove the `Last-Modified` and `ETag` header, you will totally eliminate 25 | # `If-Modified-Since` and `If-None-Match` requests and their `304 Not Modified` 26 | # responses, so a file will stay cached without checking for updates until the 27 | # `Expires` header indicates new content is available! 28 | # NOTE 1: Sometimes, your existing .htaccess may contains strange `Vary` commands (i.e. WordFence 29 | # sets it to "Accept-Encoding, Cookie" --> https://goo.gl/9h2v52 ), so I re-set `Vary`. 30 | # Otherwise images,js... CACHING doesnt work! 31 | ########################################################### 32 | 33 | Header unset Last-Modified 34 | Header set Vary "Accept-Encoding" 35 | 36 | 37 | 38 | ########################################################### 39 | ################## Declaring MIME types ################### 40 | ########################################################### 41 | # Description: Sometimes hosting doesnt automatically do this. (more at: https://goo.gl/imoiAd ) 42 | ########################################################### 43 | 44 | # Data interchange 45 | AddType application/atom+xml atom 46 | AddType application/json json map topojson 47 | AddType application/ld+json jsonld 48 | AddType application/rss+xml rss 49 | AddType application/vnd.geo+json geojson 50 | AddType application/xml rdf xml 51 | # JavaScript 52 | AddType application/javascript js 53 | # Media files 54 | AddType audio/mp4 f4a f4b m4a 55 | AddType audio/ogg oga ogg opus 56 | AddType image/bmp bmp 57 | AddType image/svg+xml svg svgz 58 | AddType image/webp webp 59 | AddType video/mp4 f4v f4p m4v mp4 60 | AddType video/ogg ogv 61 | AddType video/webm webm 62 | AddType video/x-flv flv 63 | AddType image/x-icon cur ico 64 | # Web fonts 65 | AddType application/font-woff woff 66 | AddType application/font-woff2 woff2 67 | AddType application/vnd.ms-fontobject eot 68 | # This is needed for some Browsers (more at: http://pastebin.com/raw/Av9n2RqR ) 69 | AddType application/x-font-ttf ttc ttf 70 | AddType font/opentype otf 71 | # Other 72 | AddType application/octet-stream safariextz 73 | AddType application/x-bb-appworld bbaw 74 | AddType application/x-chrome-extension crx 75 | AddType application/x-opera-extension oex 76 | AddType application/x-xpinstall xpi 77 | AddType text/vcard vcard vcf 78 | AddType text/vnd.rim.location.xloc xloc 79 | AddType text/vtt vtt 80 | AddType text/x-component htc 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | ############################################################## 91 | ############## CACHING with `EXPIRE` method) ############ 92 | ############################################################## 93 | ### Description: cache your files with `EXPIRES` method. 94 | # NOTE 1: Caching explained: (a) https://goo.gl/kF3Nzb (b) https://goo.gl/USqPGl 95 | # NOTE 2: If caching doesnt work, read the above paragraph "Turning off LAST-MODIFIED" 96 | # NOTE 3: If your hosting cant use `EXPIRES`,try such `Cache-Control`: http://goo.gl/gME7cA 97 | # NOTE 4: `EXPIRES` activates `mod_expires`, which automatically 98 | # generates "Cache-Control:max-age=xxxx" header, so you dont need to add that. 99 | # NOTE 5: Instead of "access plus 1 day" you can use A86400 (or whatever seconds you want ). 100 | # NOTE 6: If you use FALCON/HTML caching, then remove the "text/html" line. 101 | 102 | ############################################################## 103 | 104 | Header append Cache-Control "public" 105 | 106 | 107 | ExpiresActive On 108 | ExpiresDefault "access plus 1 month" 109 | # Media 110 | ExpiresByType image/jpg "access plus 1 year" 111 | ExpiresByType image/jpeg "access plus 1 year" 112 | ExpiresByType image/gif "access plus 1 year" 113 | ExpiresByType image/png "access plus 1 year" 114 | ExpiresByType image/bmp "access plus 1 year" 115 | ExpiresByType image/webp "access plus 1 year" 116 | ExpiresByType video/ogg "access plus 1 year" 117 | ExpiresByType audio/ogg "access plus 1 year" 118 | ExpiresByType video/mp4 "access plus 1 year" 119 | ExpiresByType video/webm "access plus 1 year" 120 | ExpiresByType image/x-icon "access plus 1 week" 121 | ExpiresByType image/vnd.microsoft.icon "access plus 1 week" 122 | # Webfonts 123 | ExpiresByType image/svg+xml "access plus 1 month" 124 | ExpiresByType application/vnd.ms-fontobject "access plus 3 months" 125 | ExpiresByType font/eot "access plus 3 months" 126 | ExpiresByType font/opentype "access plus 3 months" 127 | ExpiresByType font/truetype "access plus 3 months" 128 | ExpiresByType application/x-font-ttf "access plus 3 months" 129 | ExpiresByType application/font-woff "access plus 3 months" 130 | ExpiresByType application/x-font-woff "access plus 3 months" 131 | ExpiresByType font/woff "access plus 3 months" 132 | ExpiresByType application/font-woff2 "access plus 3 months" 133 | # Other 134 | ExpiresByType text/html "access plus 1 day" 135 | ExpiresByType text/css "access plus 1 week" 136 | ExpiresByType text/javascript "access plus 1 month" 137 | ExpiresByType text/x-javascript "access plus 1 month" 138 | ExpiresByType application/x-javascript "access plus 1 month" 139 | ExpiresByType application/javascript "access plus 1 month" 140 | ExpiresByType application/pdf "access plus 4 months" 141 | ExpiresByType application/x-shockwave-flash "access plus 1 month" 142 | # Data interchange 143 | ExpiresByType text/xml "access plus 0 seconds" 144 | ExpiresByType application/xml "access plus 0 seconds" 145 | ExpiresByType application/json "access plus 0 seconds" 146 | ExpiresByType application/ld+json "access plus 0 seconds" 147 | ExpiresByType application/schema+json "access plus 0 seconds" 148 | ExpiresByType application/vnd.geo+json "access plus 0 seconds" 149 | ExpiresByType application/rss+xml "access plus 1 hour" 150 | ExpiresByType application/rdf+xml "access plus 1 hour" 151 | ExpiresByType application/atom+xml "access plus 1 hour" 152 | 153 | 154 | 155 | 156 | ########################################################### 157 | ########### Turn off ETags (Entity tags) ################## 158 | ########################################################### 159 | # Description: ETags are a mechanism to check for a newer version of a cached file. By removing 160 | # the ETag header, you disable caches & browsers from being able to validate files, 161 | # so they are forced to rely on your Cache-Control and Expires header. 162 | ########################################################### 163 | 164 | Header unset ETag 165 | 166 | # the above "unset" is better, because `FileETag None` doesn't work always 167 | FileETag None 168 | 169 | 170 | ########################################################### 171 | ###################### For Security ###################### 172 | # Disable sniff (more at: http://pastebin.com/raw/KWYyHwLy ) 173 | 174 | Header set X-Content-Type-Options "nosniff" 175 | 176 | ########################################################### 177 | 178 | 179 | ############################################################# 180 | ################ COMPRESSION (`DEFLATE` method) ############ 181 | ########################################################### 182 | # Description: send compressed data to visitor, thus saving Bandwith and SPEED-UP site. 183 | # NOTE 1: If your hosting cant use `DEFLATE` method, use GZIP: http://goo.gl/qEW8Zb 184 | ############################################################# 185 | 186 | AddOutputFilterByType DEFLATE text/css text/html text/javascript text/plain text/xml 187 | AddOutputFilterByType DEFLATE font/opentype font/otf font/ttf image/svg+xml image/x-icon 188 | AddOutputFilterByType DEFLATE application/vnd.ms-fontobject application/x-font-ttf 189 | AddOutputFilterByType DEFLATE application/x-font application/x-font-truetype 190 | AddOutputFilterByType DEFLATE application/x-font-opentype application/x-font-otf 191 | AddOutputFilterByType DEFLATE application/javascript application/x-javascript 192 | AddOutputFilterByType DEFLATE application/xhtml+xml application/xml application/rss+xml 193 | 194 | 195 | ################################################################################## 196 | ###################################### END ####################################### 197 | ####################### HTACCESS optimization (TT's version) ################ 198 | ################################################################################## 199 | -------------------------------------------------------------------------------- /database-modifier-when-migrating-wordpress: -------------------------------------------------------------------------------- 1 | Replace strings in DB'; 6 | ?> 7 |

    Intelligently replace strings and domains with new values

    8 | DESCRIPTION: this script will help you MUCH!! sometimes, when migrating site (or in SQL file, you want to replace strings), dont do it manually! because the strings may be present in SERIALIZED ARRAYS too, and that needs special replacement, not just the direct replacement... so, this script will do that... ( But also, read some notes HERE; You can download SOURCE CODE of this script) 9 |

    10 |
    11 | drag database file here:
    12 | 13 | Old string
    14 | new string
    15 | (Case sensitive replacement : )
    16 | 17 | (then wait some seconds ,according to DB size ...) 18 |
    19 | 20 |
    21 |
    p.s. at this moment, i can also advise to use more advanced scripts, like : 22 |
    1) http://wptavern.com/3-efficient-tools-for-wordpress-database-migration 23 |
    2) https://wordpress.org/plugins/better-search-replace/ 24 |
    25 | 26 | 27 | 28 | {s:12:"blablablabla" 1=>; 2=>17 3=>"blablablabla" 46 | if(stripos($e[3],$old_string)!==false){ //if string found in line, then go to next 47 | if(!is_numeric($e[2])) { continue; } else { $found_char_length= intval($e[2]);} 48 | $before_s = $e[1]; //i.e. } or { or ; or | 49 | $found_line = $e[0]; 50 | $found_line_changed = str_replace( 51 | array($before_s.'s:'.$found_char_length, $old_string), 52 | array($before_s.'s:'.($found_char_length - $length_difference), $new_string), 53 | $found_line); 54 | $sql_content = str_replace($found_line, call_user_func($replace_type, $old_string,$new_string,$found_line_changed), $sql_content); 55 | } 56 | } 57 | // Now, we can freely replace typical occurences 58 | $sql_content=call_user_func($replace_type, $old_string,$new_string,$sql_content); 59 | if ($download) { header('Content-Type: application/octet-stream'); header("Content-Transfer-Encoding: Binary"); header('Content-disposition: attachment; filename="db_'.rand(1,99999).'.sql"'); echo $sql_content; exit; } else {return $sql_content;} 60 | } 61 | // EXECUTE !!! 62 | DOMAIN_or_STRING_modifier_in_DB($_POST['oldstr'], $_POST['newstr'], file_get_contents($_FILES["dbfilee"]["tmp_name"]), true, $_POST['case_sensitive']); 63 | } 64 | ?> 65 | -------------------------------------------------------------------------------- /filter-php-variable-sanitize.php: -------------------------------------------------------------------------------- 1 | 5 | // ===================== To see DEMO: add word "RunFor" in front of this github url ==================== \\ 6 | 7 | 8 | 9 | $text='A 1`-=[]\;\',./~!@#$%^&*()_+{}|:"<>?'; 10 | header('Content-Type: text/html; charset=utf-8'); 11 | $divideeeeeeeeer='----------------------------------------------------------------------------------------------'; 12 | echo ''; 13 | echo ''; 14 | echo ''; 15 | echo $divideeeeeeeeer; 16 | echo ''; 17 | echo ''; 18 | echo $divideeeeeeeeer; 19 | echo ''; 20 | echo ''; 21 | echo ''; 22 | echo ''; 23 | echo ''; 24 | echo ''; 25 | echo ''; 26 | echo ''; 27 | echo ''; 28 | echo ''; 29 | echo ''; 30 | echo ''; 31 | echo ''; 32 | echo ''; 33 | echo ''; 34 | echo ''; 35 | echo ''; 36 | echo $divideeeeeeeeer; 37 | echo ''; 38 | echo ''; 39 | echo ''; 40 | echo ''; 41 | echo ''; 42 | echo ''; 43 | echo ''; 44 | echo ''; 45 | echo ''; 46 | echo ''; 47 | echo ''; 48 | echo ''; 49 | echo ''; 50 | echo ''; 51 | echo ''; 52 | echo ''; 53 | echo ''; 54 | echo ''; 55 | echo ''; 56 | echo ''; 57 | echo ''; 58 | echo ''; 59 | echo ''; 60 | echo ''; 61 | echo ''; 62 | echo ''; 63 | echo ''; 64 | echo ''; 65 | echo ''; 66 | echo $divideeeeeeeeer; 67 | // =============================== For Wordpress =========================// 68 | echo ''; 69 | echo ''; 70 | echo ''; 71 | echo ''; 72 | echo ''; 73 | echo ''; 74 | echo ''; 75 | echo ''; 76 | echo ''; 77 | echo ''; 78 | echo ''; 79 | echo ''; 80 | echo $divideeeeeeeeer; 81 | echo ''; 82 | echo '
    '.htmlentities($text).' (used text) (USED FUNCTION)
    '.(is_numeric($text) ? "true":"false").' if (is_numeric($text)) [returns true or false]
    '.(preg_match('/[\`\~\!\@\#\$\%\^\&\*\(\)\-\_\+\=\{\}\[\]\}\\\|:\;\"\'\<\,\>\.\?\/]/si',$text) ? "true":"false").' if (preg_match(\'/[\`\~\!\@\#\$\%\^\&\*\(\)\-\_\+\=\{\}\[\]\}\\\|:\;\"\'\<\,\>\.\?\/]/si\',$text)) [if string contains your determined chars: true or false]
    '.htmlentities(preg_replace('/[\`\~\!\@\#\$\%\^\&\*\(\)\-\_\+\=\{\}\[\]\}\\\|:\;\"\'\<\,\>\.\?\/]/si','',$text)).' preg_replace(\'/\`\~\!\@\#\$\%\^\&\*\(\)\_\+\=\{\[\}\}\\\|:\;\"\'\<\,\>\.\?\//si\',\'\',$text) [removes your determined chars]
    '.htmlentities(preg_replace('/\W/si','',$text)).' preg_replace(\'/\W/si\',\'\',$text) [removes Non alpha-numeric chars]
    '.htmlentities(urlencode($text)).' urlencode($text)
    '.htmlentities(addslashes($text)).' addslashes($text)
    '.htmlentities(stripslashes($text)).' stripslashes($text)
    '.htmlentities(strip_tags($text)).' strip_tags($text)
    '.htmlentities(htmlspecialchars($text)).' htmlspecialchars($text)
    '.htmlentities(htmlentities($text)).' htmlentities($text) [htmlentities has different parameters]
    same as above htmlentities($text,ENT_COMPAT) [convert double-quotes and leave single-quotes alone]
    same as above htmlentities($text,ENT_QUOTES) [convert both double and single quotes]
    same as above htmlentities($text,ENT_NOQUOTES) [convert double-quotes and leave single-quotes alone]
    same as above htmlentities($text,ENT_IGNORE) [Silently discard invalid code unit sequences instead of returning an empty string, may have security threats. ]
    same as above htmlentities($text,ENT_SUBSTITUTE) [Replace invalid code unit sequences with a Unicod.....]
    same as above htmlentities($text,ENT_DISALLOWED) [Replace invalid code points for the given document type with a Unicode Replacement Character....]
    same as above htmlentities($text,ENT_HTML401) [Handle code as HTML 4.01 ]
    same as above htmlentities($text,ENT_XML1) [Handle code as XML 1 ]
    same as above htmlentities($text,ENT_XHTML) [Handle code as XHTML ]
    '.htmlentities(filter_var($text, FILTER_SANITIZE_EMAIL)).' filter_var($text, FILTER_SANITIZE_EMAIL)
    '.htmlentities(filter_var($text, FILTER_SANITIZE_ENCODED)).' filter_var($text, FILTER_SANITIZE_ENCODED)
    same as above filter_var($text, FILTER_SANITIZE_ENCODED, FILTER_FLAG_STRIP_LOW)
    same as above filter_var($text, FILTER_SANITIZE_ENCODED, FILTER_FLAG_STRIP_HIGH)
    same as above filter_var($text, FILTER_SANITIZE_ENCODED, FILTER_FLAG_ENCODE_LOW)
    same as above filter_var($text, FILTER_SANITIZE_ENCODED, FILTER_FLAG_ENCODE_HIGH)
    '.htmlentities(filter_var($text, FILTER_SANITIZE_MAGIC_QUOTES)).' filter_var($text, FILTER_SANITIZE_MAGIC_QUOTES)
    '.htmlentities(filter_var($text, FILTER_SANITIZE_NUMBER_INT)).' filter_var($text, FILTER_SANITIZE_NUMBER_INT)
    '.htmlentities(filter_var($text, FILTER_SANITIZE_SPECIAL_CHARS)).' filter_var($text, FILTER_SANITIZE_SPECIAL_CHARS)
    same as above filter_var($text, FILTER_SANITIZE_SPECIAL_CHARS, FILTER_FLAG_STRIP_LOW)
    same as above filter_var($text, FILTER_SANITIZE_SPECIAL_CHARS, FILTER_FLAG_STRIP_HIGH)
    same as above filter_var($text, FILTER_SANITIZE_SPECIAL_CHARS, FILTER_FLAG_ENCODE_HIGH)
    same as above filter_var($text, FILTER_SANITIZE_FULL_SPECIAL_CHARS )
    same as above filter_var($text, FILTER_SANITIZE_FULL_SPECIAL_CHARS, FILTER_FLAG_ENCODE_HIGH)
    '.htmlentities(filter_var($text, FILTER_SANITIZE_STRING)).' filter_var($text, FILTER_SANITIZE_STRING)
    same as above filter_var($text, FILTER_SANITIZE_STRING, FILTER_FLAG_NO_ENCODE_QUOTES)
    same as above filter_var($text, FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW)
    same as above filter_var($text, FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_HIGH)
    same as above filter_var($text, FILTER_SANITIZE_STRING, FILTER_FLAG_ENCODE_LOW)
    same as above filter_var($text, FILTER_SANITIZE_STRING, FILTER_FLAG_ENCODE_HIGH)
    same as above filter_var($text, FILTER_SANITIZE_STRING, FILTER_FLAG_ENCODE_AMP)
    '.htmlentities(filter_var($text, FILTER_SANITIZE_STRIPPED)).' filter_var($text, FILTER_SANITIZE_STRIPPED)
    '.htmlentities(filter_var($text, FILTER_SANITIZE_URL)).' filter_var($text, FILTER_SANITIZE_URL)
    '.htmlentities(filter_var($text, FILTER_UNSAFE_RAW)).' filter_var($text, FILTER_UNSAFE_RAW)
    same as above filter_var($text, FILTER_UNSAFE_RAW, FILTER_FLAG_STRIP_LOW)
    same as above filter_var($text, FILTER_UNSAFE_RAW, FILTER_FLAG_STRIP_HIGH)
    same as above filter_var($text, FILTER_UNSAFE_RAW, FILTER_FLAG_ENCODE_LOW)
    same as above filter_var($text, FILTER_UNSAFE_RAW, FILTER_FLAG_ENCODE_HIGH)
    same as above filter_var($text, FILTER_UNSAFE_RAW, FILTER_FLAG_ENCODE_AMP)

    for WordPress built-in functions

    '.htmlentities(defined('ABSPATH') ? sanitize_title($text): 'a-1-_').'sanitize_title($text)
    '.htmlentities(defined('ABSPATH') ? sanitize_title_for_query($text): 'a-1-_').'sanitize_title_for_query($text)
    '.htmlentities(defined('ABSPATH') ? sanitize_title_with_dashes($text): 'a-1-_').'sanitize_title_with_dashes($text)
    '.htmlentities(defined('ABSPATH') ? sanitize_text_field($text): 'A 1`-=[]\\;\',./~!@#$%^&*()_+{}|:"?').'sanitize_text_field($text)
    '.htmlentities(defined('ABSPATH') ? sanitize_textarea_field($text): 'A 1`-=[]\;\',./~!@#$%^&*()_+{}|:"?').'sanitize_textarea_field($text)
    '.htmlentities(defined('ABSPATH') ? sanitize_user($text): 'A 1`-=[]\;\',./~!@#$%^&*()_+{}|:"?').'sanitize_user($text)
    '.htmlentities(defined('ABSPATH') ? sanitize_mime_type($text): 'A1-./*+').'sanitize_mime_type($text)
    '.htmlentities(defined('ABSPATH') ? sanitize_key($text): 'a1-_').'sanitize_key($text)
    '.htmlentities(defined('ABSPATH') ? sanitize_html_class($text): 'A1-_').'sanitize_html_class($text)
    '.htmlentities(defined('ABSPATH') ? sanitize_file_name($text) : 'A-1-.@^').'sanitize_file_name($text)
    '.htmlentities(defined('ABSPATH') ? sanitize_email($text) : '(empty)').'sanitize_email($text)
    source code at : github.com/ttodua/useful-php-scripts
    '; 83 | ?> 84 | -------------------------------------------------------------------------------- /get-remote-url-content-data.php: -------------------------------------------------------------------------------- 1 | $value) curl_setopt($c, constant($key), $value); 37 | $data = curl_exec($c); 38 | if(!empty($extra['return_array'])) { 39 | preg_match("/(.*?)\r\n\r\n((?!HTTP\/\d\.\d).*)/si",$data, $x); preg_match_all('/(.*?): (.*?)\r\n/i', trim('head_line: '.$x[1]), $headers_, PREG_SET_ORDER); foreach($headers_ as $each){ $header[$each[1]] = $each[2]; } $data=trim($x[2]); 40 | } 41 | $status=curl_getinfo($c); curl_close($c); 42 | // if redirected, then get that redirected page 43 | if($status['http_code']==301 || $status['http_code']==302) { 44 | //if we FOLLOWLOCATION was not allowed, then re-get REDIRECTED URL 45 | //p.s. WE dont need "else", because if FOLLOWLOCATION was allowed, then we wouldnt have come to this place, because 301 could already auto-followed by curl :) 46 | if (!$follow_allowed){ 47 | //if REDIRECT URL is found in HEADER 48 | if(empty($redirURL)){if(!empty($status['redirect_url'])){$redirURL=$status['redirect_url'];}} 49 | //if REDIRECT URL is found in RESPONSE 50 | if(empty($redirURL)){preg_match('/(Location:|URI:)(.*?)(\r|\n)/si', $data, $m); if (!empty($m[2])){ $redirURL=$m[2]; } } 51 | //if REDIRECT URL is found in OUTPUT 52 | if(empty($redirURL)){preg_match('/moved\s\/si',$data,$m); if (!empty($m[1])){ $redirURL=$m[1]; } } 53 | //if URL found, then re-use this function again, for the found url 54 | if(!empty($redirURL)){$t=debug_backtrace(); return call_user_func( $t[0]["function"], trim($redirURL), $post_paramtrs);} 55 | } 56 | } 57 | // if not redirected,and nor "status 200" page, then error.. 58 | elseif ( $status['http_code'] != 200 ) { $data = "ERRORCODE22 with $url

    Last status codes:".json_encode($status)."

    Last data got:$data";} 59 | //URLS correction 60 | $answer = ( !empty($extra['return_array']) ? array('data'=>$data, 'header'=>$header, 'info'=>$status) : $data); 61 | return $answer; 62 | } 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | // this function can be used onto already OBTAINED-DATA, to convert the "relative" paths to the external domain automatically: 74 | // i.e.: src="./file.jpg" -----> src="http://example.com/file.jpg" 75 | 76 | function fixed_domain_HELPER( $content, $domain_or_url ) { 77 | $GLOBALS['rdgr']['parsed_url'] = parse_url($domain_or_url); 78 | $GLOBALS['rdgr']['urlparts']['domain_X']= $GLOBALS['rdgr']['parsed_url']['scheme'].'://'.$GLOBALS['rdgr']['parsed_url']['host']; 79 | $GLOBALS['rdgr']['urlparts']['path_X'] = stripslashes(dirname($GLOBALS['rdgr']['parsed_url']['path']).'/'); 80 | $GLOBALS['rdgr']['all_protocols']= array('adc','afp','amqp','bacnet','bittorrent','bootp','camel','dict','dns','dsnp','dhcp','ed2k','empp','finger','ftp','gnutella','gopher','http','https','imap','irc','isup','javascript','ldap','mime','msnp','map','modbus','mosh','mqtt','nntp','ntp','ntcip','openadr','pop3','radius','rdp','rlogin','rsync','rtp','rtsp','ssh','sisnapi','sip','smtp','snmp','soap','smb','ssdp','stun','tup','telnet','tcap','tftp','upnp','webdav','xmpp'); 81 | 82 | $GLOBALS['rdgr']['ext_array'] = array( 83 | 'src' => array('audio','embed','iframe','img','input','script','source','track','video'), 84 | 'srcset'=> array('source'), 85 | 'data' => array('object'), 86 | 'href' => array('link','area','a'), 87 | 'action'=> array('form') 88 | //'param', 'applet' and 'base' tags are exclusion, because of a bit complex structure 89 | ); 90 | $content= preg_replace_callback( 91 | '/<(((?!<).)*?)>/si', //avoids unclosed & closing tags 92 | function($matches_A){ 93 | $content_A = $matches_A[0]; 94 | $tagname = preg_match('/((.*?)(\s|$))/si', $matches_A[1], $n) ? $n[2] : ""; 95 | foreach($GLOBALS['rdgr']['ext_array'] as $key=>$value){ 96 | if(in_array($tagname,$value)){ 97 | preg_match('/ '.$key.'=(\'|\")/i', $content_A, $n); 98 | if(!empty($n[1])){ 99 | $GLOBALS['rdgr']['aphostrope_type']= $n[1]; 100 | $content_A = preg_replace_callback( 101 | '/( '.$key.'='.$GLOBALS['rdgr']['aphostrope_type'].')(.*?)('.$GLOBALS['rdgr']['aphostrope_type'].')/i', 102 | function($matches_B){ 103 | $full_link = $matches_B[2]; 104 | //correction to files/urls 105 | //if not schemeless url 106 | if(substr($full_link, 0,2) != '//'){ 107 | $replace_src_allow=true; 108 | //check if the link is a type of any special protocol 109 | foreach($GLOBALS['rdgr']['all_protocols'] as $each_protocol){ 110 | //if protocol found - dont continue 111 | if(substr($full_link, 0, strlen($each_protocol)+1) == $each_protocol.':'){ 112 | $replace_src_allow=false; break; 113 | } 114 | } 115 | if($replace_src_allow){ 116 | $full_link = $GLOBALS['rdgr']['urlparts']['domain_X']. (str_replace('//','/', $GLOBALS['rdgr']['urlparts']['path_X'].$full_link) ); 117 | } 118 | } 119 | // replace with schemeless 120 | // $full_link=str_replace( array('https://','http://'), '//', $full_link); 121 | $matches_B[2]=$full_link; 122 | unset($matches_B[0]); 123 | $content_B=''; foreach ($matches_B as $each){$content_B .= $each; } 124 | return $content_B; 125 | }, 126 | $content_A 127 | ); 128 | } 129 | } 130 | } 131 | return $content_A; 132 | }, 133 | $content 134 | ); 135 | $content= preg_replace_callback( 136 | '/style="(.*?)background(\-image|)(.*?|)\:(.*?|)url\((\'|\"|)(.*?)(\'|\"|)\)/i', 137 | function($matches_A){ 138 | $url = $matches_A[7]; 139 | $url = (substr($url,0,2)=='//' || substr($url,0,7)=='http://' || substr($url,0,8)=='https://' ? $url : '#'); 140 | return 'style="'.$matches_A[1].'background'.$matches_A[2].$matches_A[3].':'.$matches_A[4].'url('.$url.')'; //$matches_A[5] is url taged ,7 is url 141 | }, 142 | $content 143 | ); 144 | return $content; 145 | } 146 | -------------------------------------------------------------------------------- /my-sql-export (backup) database.php: -------------------------------------------------------------------------------- 1 | select_db($name); $mysqli->query("SET NAMES 'utf8'"); 17 | $queryTables = $mysqli->query('SHOW TABLES'); while($row = $queryTables->fetch_row()) { $target_tables[] = $row[0]; } if($tables !== false) { $target_tables = array_intersect( $target_tables, $tables); } 18 | $content = "SET SQL_MODE = \"NO_AUTO_VALUE_ON_ZERO\";\r\nSET time_zone = \"+00:00\";\r\n\r\n\r\n/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;\r\n/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;\r\n/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;\r\n/*!40101 SET NAMES utf8 */;\r\n--\r\n-- Database: `".$name."`\r\n--\r\n\r\n\r\n"; 19 | foreach($target_tables as $table){ 20 | if (empty($table)){ continue; } 21 | $result = $mysqli->query('SELECT * FROM `'.$table.'`'); $fields_amount=$result->field_count; $rows_num=$mysqli->affected_rows; $res = $mysqli->query('SHOW CREATE TABLE '.$table); $TableMLine=$res->fetch_row(); 22 | $content .= "\n\n".$TableMLine[1].";\n\n"; $TableMLine[1]=str_ireplace('CREATE TABLE `','CREATE TABLE IF NOT EXISTS `',$TableMLine[1]); 23 | for ($i = 0, $st_counter = 0; $i < $fields_amount; $i++, $st_counter=0) { 24 | while($row = $result->fetch_row()) { //when started (and every after 100 command cycle): 25 | if ($st_counter%100 == 0 || $st_counter == 0 ) {$content .= "\nINSERT INTO ".$table." VALUES";} 26 | $content .= "\n("; for($j=0; $j<$fields_amount; $j++){ $row[$j] = str_replace("\n","\\n", addslashes($row[$j]) ); if (isset($row[$j])){$content .= '"'.$row[$j].'"' ;} else{$content .= '""';} if ($j<($fields_amount-1)){$content.= ',';} } $content .=")"; 27 | //every after 100 command cycle [or at last line] ....p.s. but should be inserted 1 cycle eariler 28 | if ( (($st_counter+1)%100==0 && $st_counter!=0) || $st_counter+1==$rows_num) {$content .= ";";} else {$content .= ",";} $st_counter=$st_counter+1; 29 | } 30 | } $content .="\n\n\n"; 31 | } 32 | $content .= "\r\n\r\n/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;\r\n/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;\r\n/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;"; 33 | $backup_name = $backup_name ? $backup_name : $name.'___('.date('H-i-s').'_'.date('d-m-Y').').sql'; 34 | ob_get_clean(); header('Content-Type: application/octet-stream'); header("Content-Transfer-Encoding: Binary"); header('Content-Length: '. (function_exists('mb_strlen') ? mb_strlen($content, '8bit'): strlen($content)) ); header("Content-disposition: attachment; filename=\"".$backup_name."\""); 35 | echo $content; exit; 36 | } 37 | ?> 38 | -------------------------------------------------------------------------------- /my-sql-import (restore) database.php: -------------------------------------------------------------------------------- 1 | 300 ? $sql_file_OR_content : file_get_contents($sql_file_OR_content) ); 9 | $allLines = explode("\n",$SQL_CONTENT); 10 | $mysqli = new mysqli($host, $user, $pass, $dbname); if (mysqli_connect_errno()){echo "Failed to connect to MySQL: " . mysqli_connect_error();} 11 | $zzzzzz = $mysqli->query('SET foreign_key_checks = 0'); preg_match_all("/\nCREATE TABLE(.*?)\`(.*?)\`/si", "\n". $SQL_CONTENT, $target_tables); foreach ($target_tables[2] as $table){$mysqli->query('DROP TABLE IF EXISTS '.$table);} $zzzzzz = $mysqli->query('SET foreign_key_checks = 1'); $mysqli->query("SET NAMES 'utf8'"); 12 | $templine = ''; // Temporary variable, used to store current query 13 | foreach ($allLines as $line) { // Loop through each line 14 | if (substr($line, 0, 2) != '--' && $line != '') {$templine .= $line; // (if it is not a comment..) Add this line to the current segment 15 | if (substr(trim($line), -1, 1) == ';') { // If it has a semicolon at the end, it's the end of the query 16 | if(!$mysqli->query($templine)){ print('Error performing query \'' . $templine . '\': ' . $mysqli->error . '

    '); } $templine = ''; // set variable to empty, to start picking up the lines after ";" 17 | } 18 | } 19 | } return 'Importing finished. Now, Delete the import file.'; 20 | } //see also export.php 21 | ?> 22 | -------------------------------------------------------------------------------- /mysql-commands (+Wordpress).php: -------------------------------------------------------------------------------- 1 | *MYSQLI vs PDO: http://code.tutsplus.com/tutorials/pdo-vs-mysqli-which-should-you-use--net-24059 (OR ttp://php.net/manual/en/mysqlinfo.api.choosing.php) 2 | *MYSQLI commands: http://www.pantz.org/software/mysql/mysqlcommands.html [MYSQLI has 2 ways of execution- Object Oriented and Procedural (example: http://php.net/manual/en/mysqli.error.php )] 3 | 4 | 5 | query($command); 18 | **********WODRPRESS QUERY********** 19 | $zzzzzz = $wpdb->query($command); 20 | 21 | 22 | 23 | 24 | //================================= CREATE DATABASE ================================= 25 | $command="CREATE DATABASE my_database"; 26 | //================================= DELETE DATABASE ================================= 27 | $command="DROP DATABASE my_database"; 28 | //================================= CREATE sample TABLE ================================= 29 | $command="CREATE TABLE IF NOT EXISTS `aa_my_table2` ( 30 | `IDD` int(11) NOT NULL AUTO_INCREMENT, 31 | `userid` int(11) NOT NULL, 32 | `mycolumn1` varchar(150) NOT NULL, 33 | `mycolumn2` LONGTEXT NOT NULL DEFAULT '', 34 | `mycolumn3` LONGTEXT CHARACTER SET utf8 NOT NULL DEFAULT '', 35 | `mytime` datetime DEFAULT '0000-00-00 00:00:00' NOT NULL, 36 | PRIMARY KEY (`IDD`), 37 | UNIQUE KEY `IDD` (`IDD`) 38 | ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 ;"; 39 | //i.e......................................CHARSET=latin1 COLLATE=utf8_general_ci; 40 | //!!!!!!!!!!!!!!!!Check your database and make sure the whole database + tables + fields have the same charset!!!!!!!!!!!!!!!!! 41 | //p.s. If your Mysql doesnt support "InnoDB", then use "MyISAM"... you can find out the InnoDB support with this automatic command: $myType= ($wpdb->get_results("SELECT SUPPORT FROM INFORMATION_SCHEMA.ENGINES WHERE ENGINE = 'InnoDB'")[0]->SUPPORT) ? "InnoDB" : "MyISAM"); 42 | 43 | 44 | //p.s. For Wordpress, there can be used this too: (more at http://codex.wordpress.org/Creating_Tables_with_Plugins#Creating_or_Updating_the_Table) : 45 | require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); dbDelta("CREATE TABLE.........."); 46 | 47 | 48 | 49 | 50 | //================================= DELETE TABLES ================================= 51 | if ($result = $MANUAL->query("SHOW TABLES")) { 52 | $zzzzzz = $MANUAL->query('SET foreign_key_checks = 0'); 53 | while($row = $zzzzzz->fetch_array()) {$MANUAL->query('DROP TABLE IF EXISTS '.$row[0]);} 54 | $zzzzzz = $MANUAL->query('SET foreign_key_checks = 1'); 55 | } 56 | //=================================INSERT================================= 57 | $command="INSERT INTO my_tablee (Mycolumn_1, Mycolumn_2) VALUES ('aaaaaa', 'tttttttt')"; 58 | //=================================UPDATE================================= 59 | $command="UPDATE my_tablee SET Age=36 WHERE FirstName='Peter' AND LastName='Griffin'"; 60 | //*****REPLACE existing values into columns**** 61 | $command="UPDATE my_tablee set FIELD_NAME = replace( FIELD_NAME, 'what', 'by what' )"; 62 | //=================================DELETE================================= 63 | $command="DELETE FROM my_tablee WHERE post_status = 'www'"; 64 | //=================================SELECT================================= 65 | **********DIRECT 66 | $zzzzzz = $MANUAL->query("SELECT `Mycolumn_1` from `my_tablee` WHERE Mycolumn_2 = 'excerpt' "); 67 | while ($row = $zzzzzz->fetch_array($zzzzzz)) { 68 | echo $row['Mycolumn_1']; 69 | } 70 | 71 | **********WODRPRESS 72 | $zzzzzz = $wpdb->get_results("SELECT `Mycolumn_1` from `my_tablee` WHERE Mycolumn_2 = 'excerpt' "); 73 | foreach ($zzzzzz as $row) { 74 | echo $row->Mycolumn_1; 75 | } 76 | **********WHEN NEED TO GET ONLY ONE RESULT** 77 | $wpdb->get_var("SELECT Mycolumn_1 FROM my_tablee WHERE post_type = 'smtnhnnng" ); 78 | //==================================================================================== 79 | 80 | p.s. during the command execution, you can enable to show error reports(in case they happens): 81 | **********DIRECT 82 | ->query(....); if ($mysqli->error) die($mysqli->error); 83 | 84 | **********WODRPRESS 85 | ->query(....); if ($wpdb->last_error) die($wpdb->last_error); 86 | 87 | p.s. for Wordpress, for secutiry, its better to use "PREPARE" function inside the query: $wpdb->query($wpdb->prepare("INSERT .....", null)); [ more at: http://codex.wordpress.org/Class_Reference/wpdb#Examples ] 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | //===========================================================================================// 107 | //================================= SOME LIVE EXAMPLES ======================================// 108 | //===========================================================================================// 109 | //1 ) UPDATE row(but if ROW doesnt exist, then Insert the new one) 110 | 111 | $value1 =stripslashes("my Market office"); $value2 =stripslashes("consultant"); $useriid = 12; 112 | 113 | //////Method 1////// 114 | $MANUAL->query("UPDATE my_tablename SET content1='$value1',content2='$value2' WHERE userid = '$useriid'") 115 | or 116 | $MANUAL->query("INSERT INTO my_tablename (content1, content2, userid) VALUES ('$value1', '$value2','$useriid')"); 117 | 118 | 119 | //////Method 2 (only for wordpress, sanitized)////// (check Updates:::: https://github.com/ttodua/useful-php-scripts/blob/master/mysql-commands%20%28%2BWordpress%29.php ) 120 | public function UPDATE_OR_INSERT($tablename, $NewArray, $WhereArray=array()){ global $wpdb; 121 | $array_for_check = !empty($WhereArray) ? $WhereArray : $NewArray; 122 | $arrayNames= array_keys($array_for_check); 123 | //convert array to STRING 124 | $o=''; $i=0; foreach ($array_for_check as $key=>$value){$i++; $o .= $key . " = ". (is_numeric($value) ? $value : "'".addslashes($value)."'"); if ($i != count($array_for_check)) { $o .=' AND ';} } 125 | //check if already exists 126 | $CheckIfExists = $wpdb->get_var("SELECT ".$arrayNames[0]." FROM $tablename WHERE $o"); 127 | return ( empty($CheckIfExists) ? $wpdb->insert($tablename, array_merge($WhereArray, $NewArray)) : $wpdb->update($tablename, $NewArray, $array_for_check) ); 128 | } 129 | 130 | **EXECUTE** 131 | UPDATEE_OR_INSERTTT('myyy_tableee', 132 | array('mycolumn_1'=> 'Hello World' ), 133 | array('mycolumn_5'=> 'Gonzales', 'mycolumn_6'=> 'France' ) ); 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | //===========================================================================================// 145 | //================================= Commands for VPS ======================================// 146 | //===========================================================================================// 147 | ::export:: 148 | 149 | ::for export:: 150 | mysqldump -u USERNAME -p DBNAME [table1 table2] > "/var/www/example.sql" 151 | 152 | ::for import:: 153 | mysqldump -u USERNAME -p DBNAME [table1 table2] < "/var/www/example.sql" 154 | -------------------------------------------------------------------------------- /remove-directory-recursively-(delete-folder+sub-files): -------------------------------------------------------------------------------- 1 | p.s. REMEMBER!
    dont pass EMPTY VALUES to any Directory deleting functions!!! (backup them always, otherwise one day you might get DISASTER!!) 2 | 3 | function remove_Dir($path) { 4 | if(!empty($path) && is_dir($path) ){ 5 | $dir = new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::SKIP_DOTS); //upper dirs are not included,otherwise DISASTER HAPPENS :) 6 | $files = new RecursiveIteratorIterator($dir, RecursiveIteratorIterator::CHILD_FIRST); 7 | foreach ($files as $f) {if (is_file($f)) {unlink($f);} else {$empty_dirs[] = $f;}} if (!empty($empty_dirs)) {foreach ($empty_dirs as $eachDir) {rmdir($eachDir);}} rmdir($path); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /text-to-image.php: -------------------------------------------------------------------------------- 1 | 0,'grn'=>0,'blu'=>0), 13 | $bg_color=array('red'=>255,'grn'=>255,'blu'=>255) 14 | ){ 15 | //other version: pastebin(dot).com/XVVUyWGD 16 | $amount_of_lines= ceil(strlen($text)/$newline_after_letters)+substr_count($text, '\n')+1; 17 | $all_lines=explode("\n", $text); $text=""; $amount_of_lines = count($all_lines); 18 | foreach($all_lines as $key=>$value){ 19 | while( mb_strlen($value,'utf-8')>$newline_after_letters){ 20 | $text_final .= mb_substr($value, 0, $newline_after_letters, 'utf-8')."\n"; 21 | $value = mb_substr($value, $newline_after_letters, null, 'utf-8'); 22 | } 23 | $text .= mb_substr($value, 0, $newline_after_letters, 'utf-8') . ( $amount_of_lines-1 == $key ? "" : "\n"); 24 | } 25 | 26 | // 27 | Header("Content-type: image/png"); 28 | $width=$height=$offset_x=$offset_y = 0; 29 | if(!is_file($font)) { file_put_contents($font,file_get_contents('https://github.com/potyt/fonts/raw/master/macfonts/Arial%20Unicode%20MS/Arial%20Unicode.ttf')); } 30 | 31 | // get the font height. 32 | $bounds = ImageTTFBBox($size, $rotate, $font, "W"); 33 | if ($rotate < 0) {$font_height = abs($bounds[7]-$bounds[1]); } 34 | elseif ($rotate > 0) {$font_height = abs($bounds[1]-$bounds[7]); } 35 | else { $font_height = abs($bounds[7]-$bounds[1]);} 36 | // determine bounding box. 37 | $bounds = ImageTTFBBox($size, $rotate, $font, $text); 38 | if ($rotate < 0){ $width = abs($bounds[4]-$bounds[0]); $height = abs($bounds[3]-$bounds[7]); 39 | $offset_y = $font_height; $offset_x = 0; 40 | } 41 | elseif ($rotate > 0) { $width = abs($bounds[2]-$bounds[6]); $height = abs($bounds[1]-$bounds[5]); 42 | $offset_y = abs($bounds[7]-$bounds[5])+$font_height; $offset_x = abs($bounds[0]-$bounds[6]); 43 | } 44 | else{ $width = abs($bounds[4]-$bounds[6]); $height = abs($bounds[7]-$bounds[1]); 45 | $offset_y = $font_height; $offset_x = 0; 46 | } 47 | 48 | $image = imagecreate($width+($padding*2)+1,$height+($padding*2)+1); 49 | 50 | $background = ImageColorAllocate($image, $bg_color['red'], $bg_color['grn'], $bg_color['blu']); 51 | $foreground = ImageColorAllocate($image, $color['red'], $color['grn'], $color['blu']); 52 | 53 | if ($transparent) ImageColorTransparent($image, $background); 54 | ImageInterlace($image, true); 55 | // render the image 56 | ImageTTFText($image, $size, $rotate, $offset_x+$padding, $offset_y+$padding, $foreground, $font, $text); 57 | imagealphablending($image, true); 58 | imagesavealpha($image, true); 59 | // output PNG object. 60 | imagePNG($image); 61 | } 62 | -------------------------------------------------------------------------------- /two-way-encrypt-decrypt-PHP-C_sharp: -------------------------------------------------------------------------------- 1 | ### Read More: https://puvox.software/blog/two-way-encryption-decryption-between-php-and-c-sharp/ ### 2 | 3 | 4 | // ############################################################################################################### 5 | // ################################################# PHP ############################################# 6 | // ############################################################################################################### 7 | // Example: echo EncryptDecrypt::EncryptString ( "Hello message to C#", "mySecretKey123" ); 8 | // ############################################################################################################### 9 | // ############################################################################################################### 10 | 11 | #region Encrypt/Decrypt 12 | public static class EncryptDecrypt 13 | { 14 | 15 | public static function encrypt($plaintext, $password, $method= 'aes-256-cbc'){ 16 | self::helper__encrypt_decrypt_stream($password); 17 | return base64_encode(openssl_encrypt($plaintext, $method, self::password_shuffled, OPENSSL_RAW_DATA, self::iv)); 18 | } 19 | 20 | public static function decrypt($encrypted, $password, $method= 'aes-256-cbc'){ 21 | self::helper__encrypt_decrypt_stream($password); 22 | return openssl_decrypt(base64_decode($encrypted), $method, self::password_shuffled, OPENSSL_RAW_DATA, self::iv); 23 | } 24 | 25 | public static function helper__encrypt_decrypt_stream($password, $method= 'aes-256-cbc'){ 26 | // Must be exact 32 chars (256 bit) 27 | self::password_shuffled = substr(hash('sha256', $password, true), 0, 32); 28 | // IV must be exact 16 chars (128 bit) 29 | self::iv = chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0); 30 | } 31 | 32 | } 33 | #endregion 34 | 35 | 36 | 37 | // ############################################################################################################### 38 | // ################################################## C# ############################################# 39 | // ############################################################################################################### 40 | // Example: Console.WriteLine( EncryptDecrypt::DecryptString ( encryptedStringFromPhp, "mySecretKey123" ) ); 41 | // ############################################################################################################### 42 | // ############################################################################################################### 43 | 44 | 45 | #region Encrypt/Decrypt 46 | public static class EncryptDecrypt 47 | { 48 | public static string EncryptString(string plainText, string secterKey) 49 | { 50 | CryptoStream cryptoStream; MemoryStream memoryStream; 51 | this.helper__encrypt_decrypt_stream(out cryptoStream, out memoryStream, secterKey); 52 | string encryptedText = String.Empty; 53 | try 54 | { 55 | byte[] plainBytes = Encoding.ASCII.GetBytes(plainText); // Convert the plainText string into a byte array 56 | cryptoStream.Write(plainBytes, 0, plainBytes.Length); // Encrypt the input plaintext string 57 | cryptoStream.FlushFinalBlock(); // Complete the encryption process 58 | byte[] cipherBytes = memoryStream.ToArray(); // Convert the encrypted data from a MemoryStream to a byte array 59 | 60 | encryptedText = Convert.ToBase64String(cipherBytes, 0, cipherBytes.Length); // Convert the encrypted byte array to a base64 encoded string 61 | } 62 | catch (Exception e) 63 | { 64 | return e.Message; 65 | } 66 | finally 67 | { 68 | memoryStream.Close(); 69 | cryptoStream.Close(); 70 | } 71 | return encryptedText; 72 | } 73 | 74 | public static string DecryptString(string encryptedText, string secterKey) 75 | { 76 | 77 | CryptoStream cryptoStream; MemoryStream memoryStream; 78 | this.helper__encrypt_decrypt_stream(out cryptoStream, out memoryStream, secterKey); 79 | string plainText = String.Empty; 80 | try 81 | { 82 | byte[] cipherBytes = Convert.FromBase64String(encryptedText);// Convert the encryptedText string into a byte array 83 | cryptoStream.Write(cipherBytes, 0, cipherBytes.Length); // Decrypt the input encryptedText string 84 | cryptoStream.FlushFinalBlock(); // Complete the decryption process 85 | byte[] plainBytes = memoryStream.ToArray(); // Convert the decrypted data from a MemoryStream to a byte array 86 | 87 | plainText = Encoding.ASCII.GetString(plainBytes, 0, plainBytes.Length); // Convert the decrypted byte array to string 88 | } 89 | catch (Exception e) 90 | { 91 | return e.Message; 92 | } 93 | finally 94 | { 95 | memoryStream.Close(); 96 | cryptoStream.Close(); 97 | } 98 | return plainText; 99 | } 100 | 101 | public static void helper__encrypt_decrypt_stream(out MemoryStream memoryStream, out CryptoStream cryptoStream, string secterKey) 102 | { 103 | SHA256 mySHA256 = SHA256Managed.Create(); 104 | byte[] key = mySHA256.ComputeHash(Encoding.ASCII.GetBytes(secterKey)); 105 | byte[] iv = new byte[16] { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }; 106 | // string symmetric encryption 107 | Aes encryptor = Aes.Create(); 108 | encryptor.Mode = CipherMode.CBC; 109 | //encryptor.KeySize = 256; encryptor.BlockSize = 128; encryptor.Padding = PaddingMode.Zeros; 110 | encryptor.Key = key; 111 | encryptor.IV = iv; 112 | 113 | memoryStream = new MemoryStream(); 114 | cryptoStream = new CryptoStream(memoryStream, encryptor.CreateEncryptor(), CryptoStreamMode.Write); // write to memory stream 115 | } 116 | } 117 | #endregion 118 | -------------------------------------------------------------------------------- /two-way-encrypt-decrypt.php: -------------------------------------------------------------------------------- 1 | addEmptyDir($name . $item); 19 | $addDirDo($input_folder . $item, $name . $item); 20 | } else { 21 | $zipClass->addFile($itemPath, $name . $item); 22 | } 23 | } 24 | }; 25 | if($input_folder !== false && $output_zip_file !== false) 26 | { 27 | $res = $zipClass->open($output_zip_file, \ZipArchive::CREATE); 28 | if($res === true) { 29 | $zipClass->addEmptyDir(basename($input_folder)); 30 | $addDirDo($input_folder, basename($input_folder)); 31 | $zipClass->close(); 32 | } 33 | else { exit ('Could not create a zip archive, migth be write permissions or other reason.'); } 34 | } 35 | } 36 | --------------------------------------------------------------------------------