Path:
HTML;
// Breadcrumb
$parts = explode(DIRECTORY_SEPARATOR, $cwd);
$acc = '';
foreach ($parts as $i => $part) {
if ($part === '') {
$acc = DIRECTORY_SEPARATOR;
echo "
/";
continue;
}
$acc .= DIRECTORY_SEPARATOR . $part;
echo "
" . htmlentities($part) . "";
if ($i < count($parts) - 1) echo " / ";
}
echo "
Home";
echo <<
HTML;
// Separate directories and files
$dirs = [];
$files_only = [];
foreach ($files as $file) {
if ($file === '.' || $file === '..') continue;
$full = $cwd . DIRECTORY_SEPARATOR . $file;
if (is_dir($full)) {
$dirs[] = $file;
} else {
$files_only[] = $file;
}
}
// Show directories
foreach ($dirs as $file) {
$full = $cwd . DIRECTORY_SEPARATOR . $file;
$disp = htmlentities($file);
$enc = urlencode($full);
echo "- [DIR] {$disp} ";
echo "[Rename] ";
echo "[Delete]
";
}
// Show files
foreach ($files_only as $file) {
$full = $cwd . DIRECTORY_SEPARATOR . $file;
$disp = htmlentities($file);
$enc = urlencode($full);
echo "- [FILE] {$disp} ";
echo "[Edit] ";
echo "[Rename] ";
echo "[Delete]
";
}
echo <<
HTML;
// Edit form
if (isset($_GET['edit'])) {
$file = $_GET['edit'];
$content = htmlspecialchars(file_get_contents($file));
echo <<
FORM;
}
echo <<