Siteβ―Builder
Editing:
states-delete-geo.php
writable 0666
<?php require_once rtrim($_SERVER['DOCUMENT_ROOT'], '/') . '/members/lib/auth.php'; require_login(); if (current_user()['role'] !== 'admin') forbidden_page(); // Recursively delete all files and folders in given directory function delete_geo_tree($dir) { if (!file_exists($dir)) return; foreach (scandir($dir) as $item) { if ($item === '.' || $item === '..') continue; $path = "$dir/$item"; if (is_dir($path)) { delete_geo_tree($path); @rmdir($path); } else { @unlink($path); } } } // Determine geo root based on document root $geoRoot = rtrim($_SERVER['DOCUMENT_ROOT'], '/') . '/geo'; $status = ''; if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['confirm_delete'])) { delete_geo_tree($geoRoot); $status = 'β All files and folders under <code>/geo</code> have been deleted.'; } ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Delete Geo Directory</title> <style> body { font-family: Arial, sans-serif; background: #f9f9f9; margin: 0; } header { display: flex; align-items: center; justify-content: space-between; background: #fff; padding: 0.5rem 1rem; border-bottom: 1px solid #ddd; } header a { text-decoration: none; color: #333; font-weight: bold; margin-left: 1rem; } main { max-width: 600px; margin: 2rem auto; background: #fff; padding: 1.5rem; border-radius: 4px; box-shadow: 0 2px 6px rgba(0,0,0,0.1); } h1 { color: #c00; } p.warning { background: #ffe5e5; color: #900; padding: 1rem; border: 1px solid #f5c2c2; border-radius: 4px; } form { margin-top: 1.5rem; text-align: center; } button { padding: 0.75rem 1.5rem; font-size: 1rem; color: #fff; background: #c00; border: none; border-radius: 4px; cursor: pointer; } button:disabled { background: #aaa; cursor: not-allowed; } #status { margin-top: 1rem; font-size: 1rem; } code { background: #eee; padding: 0.2rem 0.4rem; border-radius: 3px; } </style> </head> <body> <header> <div><a href="/">Home</a></div> <nav> <a href="/geo/statesadmin.php">States Admin</a> <a href="/geo/pages/update.php">City Pages</a> <a href="/geo/delete_geo.php">Delete Geo</a> </nav> </header> <main> <h1>β οΈ Delete Geo Directory</h1> <p class="warning"> This action <strong>cannot be undone</strong>. All files and folders under <code>/geo</code> will be permanently removed.<br> Please confirm you understand the consequences before proceeding. </p> <?php if ($status): ?> <div id="status"><?= $status ?></div> <?php else: ?> <form method="POST" onsubmit="return confirm('Are you absolutely sure? THIS WILL DELETE EVERYTHING in /geo.');"> <input type="hidden" name="confirm_delete" value="1"> <button type="submit">Yes, Delete All Geo Files</button> </form> <?php endif; ?> </main> </body> </html>
Save changes
Create folder
writable 0777
Create
Cancel