diff --git a/.gitignore b/.gitignore
index f5a083b..497cd73 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
config.json
+.demo
data/
.DS_Store
diff --git a/setup.php b/setup.php
index 1f5a4fa..ec21324 100644
--- a/setup.php
+++ b/setup.php
@@ -1,5 +1,6 @@
Grid/ TV
+
+
Demo mode is enabled on this instance. Visitors can view the current configuration, but saving changes is disabled.
+
+
Enter your admin key to access the configuration.
= htmlspecialchars($error) ?>
@@ -219,7 +233,7 @@ $submitted_key = trim($_POST['admin_key_input'] ?? $_POST['admin_key_hidden']
- = $is_first_setup ? 'Welcome to GridTV. Fill in the fields below to get started.' : 'Edit your GridTV configuration.' ?>
+ = $is_first_setup ? 'Welcome to GridTV. Fill in the fields below to get started.' : ($demo_mode ? 'View the current GridTV configuration.' : 'Edit your GridTV configuration.') ?>
= htmlspecialchars($error) ?>
@@ -227,6 +241,7 @@ $submitted_key = trim($_POST['admin_key_input'] ?? $_POST['admin_key_hidden']
+
TV Group Name *
@@ -274,7 +289,10 @@ $submitted_key = trim($_POST['admin_key_input'] ?? $_POST['admin_key_hidden']
+
Save configuration
+
+ Saving is disabled in demo mode. Remove the .demo file on the server to restore normal editing.
diff --git a/src/lib/admin.php b/src/lib/admin.php
index 4c14170..c969a86 100644
--- a/src/lib/admin.php
+++ b/src/lib/admin.php
@@ -3,6 +3,10 @@
require_once __DIR__ . '/common.php';
function gridtv_require_admin(array $config, string $page_title = 'Admin'): array {
+ if (gridtv_is_demo_mode()) {
+ return ['unlocked' => true, 'error' => '', 'demo' => true];
+ }
+
if (session_status() !== PHP_SESSION_ACTIVE) {
session_start();
}
@@ -12,7 +16,7 @@ function gridtv_require_admin(array $config, string $page_title = 'Admin'): arra
$error = '';
if ($admin_key !== '' && hash_equals($admin_key, (string) $session_key)) {
- return ['unlocked' => true, 'error' => ''];
+ return ['unlocked' => true, 'error' => '', 'demo' => false];
}
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['admin_key_input'])) {
diff --git a/src/lib/common.php b/src/lib/common.php
index 00db619..388d72b 100644
--- a/src/lib/common.php
+++ b/src/lib/common.php
@@ -4,6 +4,14 @@ function gridtv_config_path(): string {
return dirname(__DIR__, 2) . '/config.json';
}
+function gridtv_demo_path(): string {
+ return dirname(__DIR__, 2) . '/.demo';
+}
+
+function gridtv_is_demo_mode(): bool {
+ return file_exists(gridtv_demo_path());
+}
+
function gridtv_load_config(): array {
$config_path = gridtv_config_path();
if (!file_exists($config_path)) {