public function getProfile() { if (empty(Lib\user())) { Lib\redirect(SITE_URL . '?action=login'); } echo Lib\template('../templates/profile.php', ['site_url' => SITE_URL, 'style' => Lib\style($_COOKIE['style'])]); }
public function postLogin() { $login = empty($_POST['login']) ? null : $_POST['login']; $password = empty($_POST['password']) ? null : $_POST['password']; if (!empty($_POST['token']) && Lib\valid_token($_POST['token'])) { Lib\user(Lib\connection(), $login, $password); } if (!empty(Lib\user())) { Lib\redirect(SITE_URL); } Lib\redirect(SITE_URL . '?action=login'); }
public function postHome($params = []) { if (empty(Lib\user())) { Lib\redirect(SITE_URL . '?action=login'); } $message_id = empty($_POST['message_id']) ? null : (int) $_POST['message_id']; $message = empty($_POST['message']) ? null : $_POST['message']; if (!empty($message) && Lib\valid_token($_POST['token'])) { isset($message_id) ? Lib\update_message(Lib\connection(), $message, $message_id) : Lib\insert_message(Lib\connection(), $message, 0); } Lib\redirect(SITE_URL . "?message_id={$message_id}"); }