update istall

This commit is contained in:
Flatlogic Bot 2026-04-01 09:16:10 +00:00
parent 197c4b56f7
commit 88ba3bb786
4 changed files with 21 additions and 2 deletions

View File

1
install.lock Normal file
View File

@ -0,0 +1 @@
2026-04-01 09:15:21

View File

@ -5,7 +5,7 @@ if (session_status() !== PHP_SESSION_ACTIVE) {
session_start(); 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.'); die('Installation already completed. To reinstall, delete the .installed file.');
} }
@ -74,6 +74,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
} }
} elseif ($step === 5) { } elseif ($step === 5) {
file_put_contents(__DIR__ . '/.installed', date('Y-m-d H:i:s')); 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'); header('Location: login.php');
exit; exit;
} }

View File

@ -6,7 +6,24 @@ if (session_status() !== PHP_SESSION_ACTIVE) {
} }
$publicPages = ["login.php", "logout.php", "install.php", "display.php", "ticket.php"]; $publicPages = ["login.php", "logout.php", "install.php", "display.php", "ticket.php"];
$currentPage = basename((string) ($_SERVER["PHP_SELF"] ?? "index.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"); header("Location: install.php");
exit; exit;
} }