= 1024 && $i < count($units)-1) { $bytes /= 1024; $i++; } return round($bytes,2).' '.$units[$i]; } // === Download if (isset($_GET['download'])) { $file = realpath($_GET['download']); if ($file && strpos($file, $root) === 0 && is_file($file)) { header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename="'.basename($file).'"'); header('Content-Length: ' . filesize($file)); readfile($file); exit; } else { http_response_code(403); echo "Download not allowed."; exit; } } // === Edit if (isset($_GET['edit'])) { $file = realpath($_GET['edit']); if ($file && strpos($file, $root) === 0 && is_file($file)) { header('Content-Type: text/plain; charset=utf-8'); readfile($file); exit; } else { http_response_code(403); echo "Access denied"; exit; } } // Create if (isset($_POST['create_type'], $_POST['create_name'])) { $name = basename($_POST['create_name']); $t = $path.DIRECTORY_SEPARATOR.$name; if (is_dir($path)) { if ($_POST['create_type']==='folder' && !file_exists($t)) mkdir($t,0755); if ($_POST['create_type']==='file' && !file_exists($t)) file_put_contents($t,''); } header("Location:?path=".urlencode($path)); exit; } // Rename if (isset($_POST['rename_old'], $_POST['rename_new'])) { $old = realpath($path.DIRECTORY_SEPARATOR.$_POST['rename_old']); $new = $path.DIRECTORY_SEPARATOR.basename($_POST['rename_new']); if ($old && strpos($old,$root)===0) rename($old,$new); header("Location:?path=".urlencode($path)); exit; } // Save Edit if (isset($_POST['edit_file'], $_POST['content'])) { $f = realpath($_POST['edit_file']); if ($f && strpos($f,$root)===0) file_put_contents($f, $_POST['content']); header("Location:?path=".urlencode(dirname($f))); exit; } // Upload if (!empty($_FILES['upload']['tmp_name']) && $_FILES['upload']['error']===UPLOAD_ERR_OK) { $t = $path.DIRECTORY_SEPARATOR.basename($_FILES['upload']['name']); move_uploaded_file($_FILES['upload']['tmp_name'],$t); header("Location:?path=".urlencode($path)); exit; } // Remote URL if (!empty($_POST['remote_url'])) { $url = $_POST['remote_url']; $fn = basename(parse_url($url, PHP_URL_PATH)) ?: 'remote_'.time(); $t = $path.DIRECTORY_SEPARATOR.$fn; $c = @file_get_contents($url); if ($c!==false) file_put_contents($t,$c); header("Location:?path=".urlencode($path)); exit; } // Delete if (isset($_GET['delete'])) { $t = realpath($path.DIRECTORY_SEPARATOR.$_GET['delete']); if ($t && strpos($t,$root)===0) { is_dir($t)? rmdir($t) : unlink($t); } header("Location:?path=".urlencode($path)); exit; } ?>
File Manager – = safe_path(relative_path($path)) ?>
Kembali
Upload:
URL:
Upload
Folder
File
Nama
Ukuran
Aksi
$i,'f'=>$f] : $files[]=['n'=>$i,'f'=>$f]; } foreach($dirs as $d){ echo "
{$d['n']}
-
|
"; } foreach($files as $f){ $size = format_size(filesize($f['f'])); echo "
{$f['n']}
{$size}
"; echo "
| "; echo "
| "; echo "
|
"; } ?>
Rename
Rename
Batal
Edit File
Simpan
Batal
Buat
Buat
Batal