From a6f29034d18d5a5ce48d879845cce3544b0f8a3c Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sun, 2 Feb 2025 09:46:44 +0200 Subject: feat: Create require_login helper function and improve list update page --- views/global/router.php | 12 ++++++++++ views/list/new/index.php | 8 +------ views/list/update/index.php | 56 ++++++++++++++++++++++++++++----------------- views/styles.css | 4 ++-- 4 files changed, 50 insertions(+), 30 deletions(-) (limited to 'views') 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 ''; + exit; +} + +function require_login() { + global $TOKEN; + if ($TOKEN === '') { + redirect('/login'); + } +} + if (str_ends_with($view, '.php')) { require_once $view; } diff --git a/views/list/new/index.php b/views/list/new/index.php index 7f1aaf5..cc680b5 100644 --- a/views/list/new/index.php +++ b/views/list/new/index.php @@ -1,12 +1,6 @@ -

Create a new list

diff --git a/views/list/update/index.php b/views/list/update/index.php index b3737f0..5366110 100644 --- a/views/list/update/index.php +++ b/views/list/update/index.php @@ -1,30 +1,44 @@ - - - archiveLists(); $webpage = Database\Webpage::fromDBwid($_GET['wid']); } catch (Exception $e) {} ?> - - - -

To which list do you want to add "URL ?>"?

- -
- - - - - -
+ +

+ To which list do you want to add
+ URL ?>
+ from
+ Date ?>? +

+ +
+ + + + + +
+ + +

No page with identifier exists!

+ + +

You have no lists!

+ +
+ +
+ + diff --git a/views/styles.css b/views/styles.css index e2a712f..ffdd805 100644 --- a/views/styles.css +++ b/views/styles.css @@ -45,7 +45,7 @@ h1 { text-align: center; } -input, button, textarea { +input, button, textarea, select { color: inherit; background-image: url(/paper.jpg); @@ -72,7 +72,7 @@ input[type=text]:focus { outline: 2px solid var(--highlight-border-color); } -input[type=submit]:hover, button:hover { +input[type=submit]:hover, button:hover, select:hover { cursor: pointer; } -- cgit v1.2.3