set_include_path(get_include_path() . PATH_SEPARATOR . 'src/main/php/' . PATH_SEPARATOR . '/usr/share/php/' . PATH_SEPARATOR . 'vendor/jwread/lib-allure/src/main/php/'); date_default_timezone_set('Europe/London'); function __autoload($class) { $class = DIRECTORY_SEPARATOR . $class . '.php'; foreach (explode(PATH_SEPARATOR, get_include_path()) as $path) { if (file_exists($path . $class)) { require_once $path . $class; return; } } } require_once 'includes/functions.php'; require_once 'libAllure/Exceptions.php'; require_once 'libAllure/ErrorHandler.php'; require_once 'libAllure/Database.php'; require_once 'libAllure/Form.php'; require_once 'libAllure/Logger.php'; require_once 'libAllure/User.php'; require_once 'libAllure/Inflector.php'; require_once 'libAllure/Session.php'; require_once 'libAllure/AuthBackend.php'; require_once 'libAllure/AuthBackendDatabase.php'; require_once 'libAllure/HtmlLinksCollection.php'; require_once 'config.php'; \libAllure\ErrorHandler::getInstance()->beGreedy(); $db = new \libAllure\Database(CFG_DB_DSN, CFG_DB_USER, CFG_DB_PASS); \libAllure\DatabaseFactory::registerInstance($db); \libAllure\AuthBackend::setBackend(new \libAllure\AuthBackendDatabase()); \libAllure\Session::checkCredentials('SYSTEM', '');
if (Session::isLoggedIn()) { if (isset($_REQUEST['redirect'])) { redirect($_REQUEST['redirect'], 'You are being redirected, hang tight!'); } else { redirect('index.php', 'You are already logged in!'); } require_once 'includes/widgets/footer.php'; } if (isset($_REQUEST['username'])) { $loginForm->getElement('username')->setValue(filter_var($_REQUEST['username'], FILTER_SANITIZE_STRING)); } if ($loginForm->validate()) { $username = $loginForm->getElementValue('username'); $password = $loginForm->getElementValue('password'); try { Session::checkCredentials($username, $password); applyAchievements(); logActivity('Logged in'); redirect('index.php', 'You have sucessfully logged in.'); } catch (\libAllure\UserNotFoundException $e) { $loginForm->setElementError('username', 'User not found.'); } catch (\libAllure\IncorrectPasswordException $e) { $loginForm->setElementError('password', 'Incorrect password.'); } catch (Exception $e) { $loginForm->setGeneralError('Failed to login because of a system problem.'); Logger::messageException($e); } } require_once 'includes/widgets/header.php'; require_once 'includes/widgets/sidebar.php'; ob_end_flush();