From 7f1782d7c626603251b3079068f5b3ab97dfc6c4 Mon Sep 17 00:00:00 2001 From: Fluffy-Bean Date: Thu, 6 Oct 2022 12:05:25 +0000 Subject: [PATCH] Start on rewriting classes for de-oopsie-ing --- app/app.php | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/app/app.php b/app/app.php index 4a46d70..4e4c1ec 100644 --- a/app/app.php +++ b/app/app.php @@ -106,11 +106,17 @@ class Account { Returns True if user is Returns False if user is NOT */ - function is_loggedin() { - if (isset($_SESSION["loggedin"]) && $_SESSION["loggedin"] === true) { - return True; + function is_loggedin($conn) { + $error = 0; + + if (!isset($_SESSION["loggedin"]) || $_SESSION["loggedin"] == false) $error += 1; + + if (empty($this->get_user_info($conn, $_SESSION["id"])) || $this->get_user_info($conn, $_SESSION["id"]) == null) $error += 1; + + if ($error > 0) { + return false; } else { - return False; + return true; } } /* @@ -143,7 +149,7 @@ class Account { Returns False if user is NOT privilaged */ function is_admin($conn, $id) { - if (isset($id) || !empty($id)) { + if (isset($id) && !empty($id)) { // Setting SQL query $sql = "SELECT admin FROM users WHERE id = ?";