diff --git a/cron.php b/cron.php index 2a398d3..683f605 100644 --- a/cron.php +++ b/cron.php @@ -1,6 +1,10 @@ '; } -if(!empty($_COOKIE['ytkns_login']) && is_string($_COOKIE['ytkns_login'])) { +if(!YTKNS_MAINTENANCE && !empty($_COOKIE['ytkns_login']) && is_string($_COOKIE['ytkns_login'])) { try { $session = UserSession::byToken($_COOKIE['ytkns_login']); $session->update(); @@ -152,13 +154,15 @@ if(!empty($zoneName)) { return; } - if(!empty($_GET['_refresh_screenshot'])) { - header('Location: /'); - $zoneInfo->takeScreenshot(); - return; - } + if(!YTKNS_MAINTENANCE) { + if(!empty($_GET['_refresh_screenshot'])) { + header('Location: /'); + $zoneInfo->takeScreenshot(); + return; + } - ZoneView::increment($zoneInfo, $_SERVER['REMOTE_ADDR']); + ZoneView::increment($zoneInfo, $_SERVER['REMOTE_ADDR']); + } echo (string)$zoneInfo->getPageBuilder(true); return; @@ -924,6 +928,12 @@ if($reqPath === '/settings/invites') { } if($reqPath === '/auth/login') { + if(YTKNS_MAINTENANCE) { + http_response_code(503); + echo html_information('You cannot log in during maintenance.'); + return; + } + if(UserSession::hasInstance()) { http_response_code(404); echo html_information('You are logged in already.'); @@ -985,6 +995,12 @@ if($reqPath === '/auth/login') { } if($reqPath === '/auth/register') { + if(YTKNS_MAINTENANCE) { + http_response_code(503); + echo html_information('You cannot register during maintenance.'); + return; + } + if(UserSession::hasInstance()) { http_response_code(404); echo html_information('You are logged in already.'); diff --git a/src/Config.php b/src/Config.php index 4cb0216..313a117 100644 --- a/src/Config.php +++ b/src/Config.php @@ -39,7 +39,7 @@ final class Config { public static function set(string $key, $value, bool $soft = false): void { self::$config[$key] = $value; - if(!$soft) { + if(!YTKNS_MAINTENANCE && !$soft) { $value = serialize($value); $save = DB::prepare('REPLACE INTO `ytkns_config` (`config_key`, `config_value`) VALUES (:key, :value)'); diff --git a/templates/header.html b/templates/header.html index e3c31e8..4d917dd 100644 --- a/templates/header.html +++ b/templates/header.html @@ -22,6 +22,7 @@