diff options
Diffstat (limited to 'views/global')
| -rw-r--r-- | views/global/router.php | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/views/global/router.php b/views/global/router.php index 9025113..527ad68 100644 --- a/views/global/router.php +++ b/views/global/router.php @@ -55,6 +55,18 @@ foreach (glob($MODELS_DIR . '/*.php') as $filename) { $TOKEN = (array_key_exists('token', $_COOKIE)) ? ($_COOKIE['token'] ?? "") : (""); +function redirect(string $href) { + echo '<script type="text/javascript">window.location.href = "' . $href . '";</script>'; + exit; +} + +function require_login() { + global $TOKEN; + if ($TOKEN === '') { + redirect('/login'); + } +} + if (str_ends_with($view, '.php')) { require_once $view; } |
