diff --git a/.installed b/.installed deleted file mode 100644 index e69de29..0000000 diff --git a/install.lock b/install.lock new file mode 100644 index 0000000..1e7f719 --- /dev/null +++ b/install.lock @@ -0,0 +1 @@ +2026-04-01 09:15:21 \ No newline at end of file diff --git a/install.php b/install.php index 83a51b9..e9993e2 100644 --- a/install.php +++ b/install.php @@ -5,7 +5,7 @@ if (session_status() !== PHP_SESSION_ACTIVE) { session_start(); } -if (file_exists(__DIR__ . '/.installed')) { +if (file_exists(__DIR__ . '/.installed') || file_exists(__DIR__ . '/install.lock')) { die('Installation already completed. To reinstall, delete the .installed file.'); } @@ -74,6 +74,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { } } elseif ($step === 5) { file_put_contents(__DIR__ . '/.installed', date('Y-m-d H:i:s')); + file_put_contents(__DIR__ . '/install.lock', date('Y-m-d H:i:s')); header('Location: login.php'); exit; } diff --git a/queue_bootstrap.php b/queue_bootstrap.php index 263a45f..249685a 100644 --- a/queue_bootstrap.php +++ b/queue_bootstrap.php @@ -6,7 +6,24 @@ if (session_status() !== PHP_SESSION_ACTIVE) { } $publicPages = ["login.php", "logout.php", "install.php", "display.php", "ticket.php"]; $currentPage = basename((string) ($_SERVER["PHP_SELF"] ?? "index.php")); -if (!file_exists(__DIR__ . "/.installed") && $currentPage !== "install.php") { +$isInstalled = file_exists(__DIR__ . "/.installed") || file_exists(__DIR__ . "/install.lock"); +if (!$isInstalled) { + try { + if (file_exists(__DIR__ . '/db/config.php')) { + require_once __DIR__ . '/db/config.php'; + if (function_exists('db')) { + $pdo = db(); + $stmt = @$pdo->query("SELECT COUNT(*) FROM users"); + if ($stmt !== false && ((int)$stmt->fetchColumn()) > 0) { + $isInstalled = true; + @file_put_contents(__DIR__ . '/install.lock', date('Y-m-d H:i:s')); + } + } + } + } catch (\Throwable $e) {} +} + +if (!$isInstalled && $currentPage !== "install.php") { header("Location: install.php"); exit; }