aboutsummaryrefslogtreecommitdiff
path: root/views/global/router.php
diff options
context:
space:
mode:
Diffstat (limited to 'views/global/router.php')
-rw-r--r--views/global/router.php12
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;
}