From 3a82baec9d793edf81ac2b151b0f4d4159641375 Mon Sep 17 00:00:00 2001 From: Freya Murphy Date: Mon, 1 Apr 2024 11:09:25 -0400 Subject: login and register, liking on homepage --- web/_model/apps/error.php | 35 ----------------- web/_model/apps/home.php | 22 ----------- web/_model/cache.php | 37 ------------------ web/_model/format.php | 45 ---------------------- web/_model/main.php | 96 ----------------------------------------------- web/_model/request.php | 40 -------------------- 6 files changed, 275 deletions(-) delete mode 100644 web/_model/apps/error.php delete mode 100644 web/_model/apps/home.php delete mode 100644 web/_model/cache.php delete mode 100644 web/_model/format.php delete mode 100644 web/_model/main.php delete mode 100644 web/_model/request.php (limited to 'web/_model') diff --git a/web/_model/apps/error.php b/web/_model/apps/error.php deleted file mode 100644 index ad72b28..0000000 --- a/web/_model/apps/error.php +++ /dev/null @@ -1,35 +0,0 @@ -get_msg($data); - return $data; - } -} -?> diff --git a/web/_model/apps/home.php b/web/_model/apps/home.php deleted file mode 100644 index 82fbf26..0000000 --- a/web/_model/apps/home.php +++ /dev/null @@ -1,22 +0,0 @@ -db - ->select('*') - ->from('admin.post') - ->limit(20) - ->rows(); - } - - public function get_data(): array { - $data = parent::get_data(); - $data['title'] = lang('title'); - $data['posts'] = $this->get_posts(); - return $data; - } -} diff --git a/web/_model/cache.php b/web/_model/cache.php deleted file mode 100644 index 6cf9924..0000000 --- a/web/_model/cache.php +++ /dev/null @@ -1,37 +0,0 @@ -users = array(); - } - - /** - * Gets a array of users - */ - public function get_users($objs) { - $ids = array(); - foreach ($objs as $obj) { - $id = $obj['user_id']; - if (!array_key_exists($id, $this->users)) { - array_push($ids, intval($id)); - } - } - if (!empty($ids)) { - $result = $this->main->db - ->select('*') - ->from('api.user') - ->where_in('id', $ids) - ->rows(); - foreach ($result as $user) { - $id = $user['id']; - $this->users[$id] = $user; - } - } - return $this->users; - } - -} diff --git a/web/_model/format.php b/web/_model/format.php deleted file mode 100644 index 52b51be..0000000 --- a/web/_model/format.php +++ /dev/null @@ -1,45 +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(); - } - - /** - * Loads current session - * @param string $jwt - the user provided JWT - */ - private function get_session($jwt) { - $query = $this->db - ->select("_api.verify_jwt('" . $jwt . "') AS user_id;"); - $result = $query->row(); - $user_id = $result['user_id']; - if ($user_id) { - $this->session = array( - 'id' => $user_id, - 'jwt' => $jwt - ); - } - } - - /** - * 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->session) { - return $this->db - ->select('*') - ->from('api.user') - ->where('id') - ->eq($this->session['id']) - ->row(); - } else { - return NULL; - } - } - -} - -?> diff --git a/web/_model/request.php b/web/_model/request.php deleted file mode 100644 index 4cce07a..0000000 --- a/web/_model/request.php +++ /dev/null @@ -1,40 +0,0 @@ -