try { CSRF::check($_POST['CSRF-key']); } catch (Exception $e) { unset($_POST); $_POST = []; } } // --- locale if (Config::getSetting('locale', false)) { setlocale(LC_ALL, Config::getSetting('locale')); } // --- Login if (Clockwork::isModuleLoaded('Login') && !defined('CW_CRON') && !defined('CW_SKIP_LOGIN')) { new Login(); $_loginpage = Config::getSetting('login_loginpage', false, false) ? Config::getSetting('login_loginpage') : 'login/'; $_allowed = Config::getSetting('login_no_login', false, false) ? Config::getSetting('login_no_login') : []; $_allowed[] = $_loginpage; if (!Login::getUser() && !in_array(substr(strpos($_SERVER['REQUEST_URI'], '?') !== false ? stristr($_SERVER['REQUEST_URI'], '?', true) : $_SERVER['REQUEST_URI'], 1), $_allowed)) { redirect($_loginpage); } } // --- app if (!defined('CW_CRON') && !defined('CW_OVERRIDE_TEMPLATE')) { if (Config::getSetting('load_template_engine', false, true) && !isset($template)) { $template = new Template(); include_once APP_DIR . 'index.php'; $template->loadFromURL(); } else { include_once APP_DIR . 'index.php'; } }
/** * Override template engine by loading plugin templates * * @param string $path * * @return void */ public function setupOverrideForPath($path, $lvl = null, $basedir = true) { $template = new Template(['basedir' => $basedir && $basedir === true ? $this->dir() : $basedir, 'useLayoutBasedir' => $basedir === false ? false : true]); $url = $template->getUrl(); $url = $lvl !== null ? implode('/', array_splice($url, 0, $lvl + 1)) : implode('/', $url); if (!is_array($path)) { $path = [$path]; } foreach ($path as $p) { if ($url == $p) { include_once APP_DIR . 'index.php'; include_once $this->dir() . 'index.php'; $template->loadFromURL(false, $basedir && $basedir === true ? true : false); define('CW_OVERRIDE_TEMPLATE', true); break; } } }