made installer and seperated stuff into diferent files
This commit is contained in:
@@ -16,6 +16,30 @@ const THEME_STYLES = [
|
||||
'beige' => 'app/css/beige_mode.css',
|
||||
];
|
||||
|
||||
function projectKilnTableExists(string $table): bool
|
||||
{
|
||||
$stmt = db()->prepare(
|
||||
'SELECT COUNT(*) FROM information_schema.TABLES WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = ?'
|
||||
);
|
||||
$stmt->execute([$table]);
|
||||
|
||||
return (int)$stmt->fetchColumn() > 0;
|
||||
}
|
||||
|
||||
function projectKilnIsInstalled(): bool
|
||||
{
|
||||
if (!projectKilnTableExists('settings')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$stmt = db()->prepare(
|
||||
"SELECT COUNT(*) FROM settings WHERE setting_name = 'installed' AND LOWER(setting_value) = 'true'"
|
||||
);
|
||||
$stmt->execute();
|
||||
|
||||
return (int)$stmt->fetchColumn() > 0;
|
||||
}
|
||||
|
||||
function currentTheme(): string
|
||||
{
|
||||
$theme = 'dark';
|
||||
@@ -43,24 +67,34 @@ function currentTheme(): string
|
||||
return array_key_exists($storedTheme, THEME_STYLES) ? $storedTheme : $theme;
|
||||
}
|
||||
|
||||
$page = $_GET['page'] ?? 'home';
|
||||
$theme = currentTheme();
|
||||
$isInstalled = projectKilnIsInstalled();
|
||||
$theme = $isInstalled ? currentTheme() : 'dark';
|
||||
|
||||
$routes = [
|
||||
'home' => 'home.php',
|
||||
'login' => 'login.php',
|
||||
'logout' => 'logout.php',
|
||||
];
|
||||
if (!$isInstalled) {
|
||||
define('PROJECTKILN_INSTALL_EMBEDDED', true);
|
||||
|
||||
if (!isset($routes[$page])) {
|
||||
$pageFile = __DIR__ . '/app/404.php';
|
||||
ob_start();
|
||||
require __DIR__ . '/install/install.php';
|
||||
$pageContent = ob_get_clean();
|
||||
} else {
|
||||
$pageFile = __DIR__ . '/app/' . $routes[$page];
|
||||
}
|
||||
$page = $_GET['page'] ?? 'home';
|
||||
|
||||
ob_start();
|
||||
require $pageFile;
|
||||
$pageContent = ob_get_clean();
|
||||
$routes = [
|
||||
'home' => 'home.php',
|
||||
'login' => 'login.php',
|
||||
'logout' => 'logout.php',
|
||||
];
|
||||
|
||||
if (!isset($routes[$page])) {
|
||||
$pageFile = __DIR__ . '/app/404.php';
|
||||
} else {
|
||||
$pageFile = __DIR__ . '/app/' . $routes[$page];
|
||||
}
|
||||
|
||||
ob_start();
|
||||
require $pageFile;
|
||||
$pageContent = ob_get_clean();
|
||||
}
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
|
||||
Reference in New Issue
Block a user