public static function run($inContent = '') { $lockoutEngine = LockoutEngine::getInstance(); $lockout = $lockoutEngine->getLockout($_SERVER['REMOTE_ADDR']); if ($lockout === false) { $attempts = $lockoutEngine->getNumberOfAttemptsBeforeLockout(); $lockout = new Lockout($_SERVER['REMOTE_ADDR'], 1, new DateTime(), $attempts); $lockoutEngine->addLockout($lockout); $period = $lockoutEngine->getLockoutPeriod(); $notice = new Notice('warning', "You have {$attempts} attempts left before you're locked out for {$period} minutes."); NoticeEngine::getInstance()->addNotice($notice); return; } $lockout->failedAttemptMade(); $lockoutEngine->setLockout($lockout); $attempts = $lockout->getNumberOfAttemptsLeft(); $period = $lockout->getNumberOfFailedAttempts() * $lockoutEngine->getLockoutPeriod(); if ($attempts === 1) { $notice = new Notice('warning', "You have {$attempts} attempt left before you're locked out for {$period} minutes."); } else { $notice = new Notice('warning', "You have {$attempts} attempts left before you're locked out for {$period} minutes."); } NoticeEngine::getInstance()->addNotice($notice); }
private function showErrorMessage() { $hookEngine = HookEngine::getInstance(); $hookEngine->runAction('userFailedToLogIn'); NoticeEngine::getInstance()->addNotice(new Notice(noticeType::warning, 'I couldn\'t log you in.')); return Response::redirect(new Link("users/login")); }
private function showSuccessMessageForForgotPasswordChange() { NoticeEngine::getInstance()->addNotice(new Notice(noticeType::success, "Your password has been changed.")); }
private static function render(Site $site, Response $response, array $blocks) { $redirectTo = $response->getRedirectTo(); if ($redirectTo !== null) { header("Location: " . $redirectTo, true, 303); die; } $rawContent = $response->getRawContent(); if ($rawContent !== "") { echo $rawContent; return; } require_once EDUCASK_ROOT . "/core/thirdPartyLibraries/twig/lib/Twig/Autoloader.php"; Twig_Autoloader::register(); $theme = EDUCASK_ROOT . '/site/themes/' . $site->getTheme(); str_replace('..', '', $theme); if (!is_dir($theme)) { $theme = EDUCASK_ROOT . '/site/themes/default'; } $loader = new Twig_Loader_Filesystem(array($theme)); $baseThemes = glob(EDUCASK_ROOT . '/core/baseThemes/*'); foreach ($baseThemes as $baseTheme) { $name = explode('/', $baseTheme); $name = end($name); $loader->addPath($baseTheme, $name); } $viewsDirectories = glob(EDUCASK_ROOT . '/site/modules/*/views'); foreach ($viewsDirectories as $viewDirectory) { $name = explode('/', $viewDirectory); $name = $name[count($name) - 2]; $loader->addPath($viewDirectory, $name); } $twig = new Twig_Environment($loader, array('debug' => true)); $twig->addExtension(new Twig_Extension_Debug()); $twig->addExtension(new TwigExtensions()); if ($site->isInMaintenanceMode()) { if (!PermissionEngine::getInstance()->currentUserCanDo('bypasssMaintenanceMode')) { echo $twig->render('maintenance.twig', array('site' => $site)); return; } } $noticeEngine = NoticeEngine::getInstance(); $notices = $noticeEngine->getNotices(); $noticeEngine->removeNotices(); echo $twig->render('index.twig', array('site' => $site, 'model' => $response->getObjectToPassToView(), 'title' => $response->getPageTitle(), 'blocks' => $blocks, 'notices' => $notices, 'response' => $response)); }
public function __construct(Request $request) { if (count($request->getParameters(true)) > 2) { $this->response = Response::fourOhFour(); return; } $currentUser = CurrentUser::getUserSession(); if (!$currentUser->isLoggedIn()) { $this->response = Response::fourOhFour(); return; } $hookEngine = HookEngine::getInstance(); $hookEngine->runAction('userIsLoggingOut'); $currentUser->logOut(); session_regenerate_id(true); $hookEngine->runAction('userLoggedOut'); NoticeEngine::getInstance()->addNotice(new Notice("neutral", "You're now logged out.")); $this->response = Response::redirect(new Link("")); }