/** * */ public function __construct() { $action = $_GET['action']; if (isset($action) && $action !== '') { Login::loginRequired(); switch ($action) { case 'login': new Models\Login("login"); break; case 'save': case 'delete': case 'insert': new Models\Process($_REQUEST['form'], $action); break; default: $model = "\\Cunity\\Admin\\Models\\Pages\\" . ucfirst($action); if (!Models\Login::loggedIn()) { new View\Login(); } elseif (Request::isAjaxRequest()) { new $model(); } break; } } else { new View\Admin(); } }
/** * */ public function __construct() { if (Request::isAjaxRequest()) { $this->handleAjaxAction(); } $this->checkUser(); $this->render(); }
/** * @throws \Exception */ public function __construct() { View::initTranslator(); array_walk_recursive($_GET, [$this, 'trimhtml']); array_walk_recursive($_POST, [$this, 'trimhtml']); Cunity::init(); //use the filesdir hash as unique session name session_name("cunity-" . Cunity::get("settings")->getSetting("core.filesdir")); session_start(); if (Models\Request::isAjaxRequest()) { set_exception_handler([$this, 'handleAjaxException']); } else { set_exception_handler([$this, 'handleException']); } $this->handleQuery(); }
/** * */ protected function handleQuery() { if (!isset($_GET['m']) || empty($_GET['m'])) { if (Login::loggedIn()) { header("Location:" . Models\Generator\Url::convertUrl("index.php?m=profile")); exit; } else { $_GET['m'] = 'start'; } } $moduleController = new Module($_GET['m']); if (!Request::isAjaxRequest() && !$moduleController->isActive()) { new PageNotFound(); } elseif ($moduleController->isValid()) { $classname = $moduleController->getClassName(); new $classname(); } else { new PageNotFound(); } }
/** * */ public static function loginRequired() { if (!self::loggedIn()) { $res = self::checkAutoLogin(false); if ($res !== false && $res instanceof User) { $res->setLogin(true); header("Location:" . Url::convertUrl("index.php?m=profile")); } elseif (!isset($_GET['m']) || $_GET['m'] != "start") { if (!Request::isAjaxRequest()) { header("Location:" . Url::convertUrl("index.php?m=start")); } else { $view = new View(false); $view->addData(["session" => 0]); $view->sendResponse(); } } exit; } else { return; } }