/** * URL: / */ public function index($data) { $model = new LoginModel(); if (!$model->isLoggedIn()) { header('location: ' . URL_LOGIN); exit; } }
require 'config.php'; require __DIR__ . '/../vendor/autoload.php'; // Autoloader require PATH_LIBRARIES . 'slaymaster3000/airbase-php/vendor/autoload.php'; // AirBase autoloader use AirBase\AirBase; use AirBase\Session; use AirBase\Bootstrap; use AirBase\PageNotFoundException; use AirBase\NotLoggedInException; use AirBase\NotLoggedOutException; use GrandTraining\admin\models\Login as LoginModel; // init the lib library AirBase::init(); AirBase::setIsLoggedInFunction(function () { return LoginModel::isLoggedIn(); }); try { Session::start(); // start a session $bootstrap = new Bootstrap(NAMESPACE_CONTROLLERS, PATH_CONTROLLERS, 'url'); // process the request } catch (PageNotFoundException $e) { if (AirBase::isLoggedIn()) { require PATH_ERROR_PAGES . '404.php'; } header('location: ' . URL); // always redirect to the home page if not logged in exit; } catch (NotLoggedInException $e) { header('location: ' . URL_LOGIN);