'app/css/white_mode.css', 'dark' => 'app/css/dark_mode.css', 'purple' => 'app/css/purple_mode.css', 'green' => 'app/css/green_mode.css', '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'; $user = currentUser(); if (!$user) { return $theme; } $stmt = db()->prepare( 'SELECT setting_value FROM user_settings WHERE user_id = ? AND setting_name = ? LIMIT 1' ); $stmt->execute([ (int)$user['id'], 'theme' ]); $storedTheme = (string)($stmt->fetchColumn() ?: ''); return array_key_exists($storedTheme, THEME_STYLES) ? $storedTheme : $theme; } $isInstalled = projectKilnIsInstalled(); $theme = $isInstalled ? currentTheme() : 'dark'; if (!$isInstalled) { define('PROJECTKILN_INSTALL_EMBEDDED', true); ob_start(); require __DIR__ . '/install/install.php'; $pageContent = ob_get_clean(); } else { $page = $_GET['page'] ?? 'home'; $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(); } ?> ProjectKiln