diff --git a/setup.php b/setup.php index bb88005..973c570 100644 --- a/setup.php +++ b/setup.php @@ -216,7 +216,7 @@ $submitted_key = trim($_POST['admin_key_input'] ?? $_POST['admin_key_hidden']
GridTV is already configured.
Enter your admin key to edit the settings.
- +
@@ -349,6 +349,41 @@ function syncPersonalM3uToggle() { } allowPersonalEpgToggle?.addEventListener('change', syncPersonalM3uToggle); syncPersonalM3uToggle(); + +const GRIDTV_ADMIN_KEY_STORAGE = 'gridtv-admin-key'; +const setupAdminKeyInput = document.getElementById('setupAdminKeyInput'); +const setupAdminHiddenInput = document.querySelector('input[name="admin_key_hidden"]'); + +try { + const savedAdminKey = localStorage.getItem(GRIDTV_ADMIN_KEY_STORAGE) || ''; + if (setupAdminKeyInput && savedAdminKey) setupAdminKeyInput.value = savedAdminKey; + if (setupAdminHiddenInput && savedAdminKey) setupAdminHiddenInput.value = savedAdminKey; +} catch (_) {} + +if (setupAdminKeyInput?.form) { + setupAdminKeyInput.form.addEventListener('submit', () => { + try { + localStorage.setItem(GRIDTV_ADMIN_KEY_STORAGE, setupAdminKeyInput.value.trim()); + } catch (_) {} + }); +} + +if (setupAdminHiddenInput?.form) { + const persistHiddenAdminKey = () => { + try { + const currentKey = setupAdminHiddenInput.value.trim(); + if (currentKey) localStorage.setItem(GRIDTV_ADMIN_KEY_STORAGE, currentKey); + } catch (_) {} + }; + persistHiddenAdminKey(); + setupAdminHiddenInput.form.addEventListener('submit', persistHiddenAdminKey); +} + + +try { + localStorage.setItem(GRIDTV_ADMIN_KEY_STORAGE, ); +} catch (_) {} + diff --git a/src/lib/admin.php b/src/lib/admin.php index c969a86..9e7d8d5 100644 --- a/src/lib/admin.php +++ b/src/lib/admin.php @@ -30,6 +30,6 @@ function gridtv_require_admin(array $config, string $page_title = 'Admin'): arra } http_response_code(401); - echo 'GridTV — ' . htmlspecialchars($page_title) . '
Enter your admin key to access the ' . htmlspecialchars($page_title) . ' page.
' . ($error ? '
' . htmlspecialchars($error) . '
' : '') . '
'; + echo 'GridTV — ' . htmlspecialchars($page_title) . '
Enter your admin key to access the ' . htmlspecialchars($page_title) . ' page.
' . ($error ? '
' . htmlspecialchars($error) . '
' : '') . '
'; exit; }