From 5a2ba9c2e7605bb788bc406184547d22c6436867 Mon Sep 17 00:00:00 2001 From: Freya Murphy Date: Mon, 23 Dec 2024 11:13:27 -0500 Subject: v2.1.0, refactor w/ crimson --- src/web/_model/main.php | 119 ------------------------------------------------ 1 file changed, 119 deletions(-) delete mode 100644 src/web/_model/main.php (limited to 'src/web/_model/main.php') diff --git a/src/web/_model/main.php b/src/web/_model/main.php deleted file mode 100644 index cd34740..0000000 --- a/src/web/_model/main.php +++ /dev/null @@ -1,119 +0,0 @@ -db = new DatabaseHelper(); - /// load the current session - if (array_key_exists('jwt', $_SESSION)) { - $this->get_session($_SESSION['jwt']); - } else { - $this->session = NULL; - }; - /// init other vars - $this->users = array(); - $this->user = NULL; - } - - /** - * Loads current session - * @param string $jwt - the user provided JWT - */ - private function get_session($jwt) { - $query = $this->db - ->select("_api.verify_jwt(?) AS user_id;"); - $result = $query->row($jwt); - $user_id = $result['user_id']; - if ($user_id) { - $this->session = array( - 'id' => $user_id, - 'jwt' => $jwt - ); - $user = $this->user(); - if ($user === FALSE) { - /// valid jwt for invalid user!!! - $this->session = NULL; - $this->user = NULL; - } - } - } - - /** - * Gets the stamp for a asset path - * @param string $path - */ - private function asset_stamp($path): int { - $root = $GLOBALS['webroot']; - $path = $root . '/../public/' . $path; - return filemtime($path); - } - - /** - * Loads a css html link - * @param string $path - the path to the css file - */ - public function link_css($path) { - $stamp = $this->asset_stamp($path); - return ''; - } - - /** - * Loads a js html link - * @param string $path - the path to the js file - */ - public function link_js($path) { - $stamp = $this->asset_stamp($path); - return ''; - } - - /** - * Gets the current user - */ - public function user() { - if ($this->user) { - return $this->user; - } - if ($this->session) { - $this->user = $this->db - ->select('*') - ->from('api.user') - ->where('id') - ->eq($this->session['id']) - ->row(); - return $this->user; - } - return NULL; - } - - /** - * Formats a date - * @param string $date - the data in RFC3999 format - * @returns the formatted date - */ - public function date($date) { - $date=date_create($date); - return date_format($date, "Y-m-d D H:m"); - } - -} - -?> -- cgit v1.2.3-freya