Example #1
0
 public function run()
 {
     if (!isset($this->cronToken)) {
         return;
     }
     if ($this->cronToken === "") {
         return;
     }
     if ($this->cronToken !== Config::getInstance()->getCronToken()) {
         return;
     }
     $database = Database::getInstance();
     if (!$database->isConnected()) {
         return;
     }
     $site = Site::getInstance();
     if (!$site->doesCronNeedToRun()) {
         return;
     }
     if ($site->isCronRunning()) {
         return;
     }
     $site->setCronRunning(true);
     $site->setLastCronRun(new DateTime());
     $hookEngine = HookEngine::getInstance();
     $hookEngine->runAction('cronRun');
     $logger = Logger::getInstance();
     $logger->logIt(new LogEntry(1, logEntryType::info, "Cron ran.", 0, new DateTime()));
     $site->setCronRunning(false);
 }
Example #2
0
 public static function getInstance()
 {
     if (!isset(self::$instance)) {
         self::$instance = new HookEngine();
     }
     return self::$instance;
 }
Example #3
0
 private function getRawCss()
 {
     $hookEngine = HookEngine::getInstance();
     $rawCss = $hookEngine->runFilter('getRawCss', '');
     if ($rawCss === null) {
         return "";
     }
     $toReturn = "";
     foreach ($rawCss as $css) {
         $toReturn .= $this->minifyCssString($css);
     }
     return $toReturn;
 }
 public static function init()
 {
     $hookEngine = HookEngine::getInstance();
     $hookEngine->addAction('userFailedToLogIn', new failedLoginMonitorForLockout());
 }
Example #5
0
 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"));
 }
 public static function init()
 {
     $hookEngine = HookEngine::getInstance();
     $hookEngine->addAction('userLoggingIn', new authenticateWithLDAP());
 }
 public static function init()
 {
     $hookEngine = HookEngine::getInstance();
     $hookEngine->addAction('cronRun', new clearOldForgotPasswords());
 }
Example #8
0
 private static function getVariables()
 {
     ObjectCache::getInstance();
     $site = Site::getInstance();
     define('GUEST_ROLE_ID', (int) $site->getGuestRoleID()->getValue());
     define('SITE_EMAIL', $site->getEmail());
     define('SITE_TITLE', $site->getTitle());
     date_default_timezone_set($site->getTimeZone());
     if ($site->isInMaintenanceMode()) {
         if (!PermissionEngine::getInstance()->currentUserCanDo('bypasssMaintenanceMode')) {
             return;
         }
     }
     $blockEngine = BlockEngine::getInstance();
     $user = CurrentUser::getUserSession();
     $hookEngine = HookEngine::getInstance();
     $router = Router::getInstance();
     $hookEngine->runAction('addStaticRoutes');
     $moduleInCharge = $router->whichModuleHandlesRequest();
     $response = self::getResponse($moduleInCharge);
     http_response_code($response->getResponseCode());
     $headers = $response->getHeaders();
     foreach ($headers as $header => $value) {
         header($header . ": " . $value, true);
     }
     define('PAGE_TYPE', $response->getPageType());
     $blocks = $blockEngine->getBlocks($site->getTheme(), PAGE_TYPE, $user->getRoleID());
     if ($blocks === null) {
         $blocks = array();
     }
     self::render($site, $response, $blocks);
 }
 public static function init()
 {
     $hookEngine = HookEngine::getInstance();
     $hookEngine->addAction('userIsLoggingOut', new failedLoginRemovalOfLockout());
 }
Example #10
0
 private function blockVisible($blockID, $pageType, $roleID)
 {
     if (!is_numeric($blockID)) {
         return false;
     }
     if ($blockID < 1) {
         return false;
     }
     $database = Database::getInstance();
     $database->connect();
     if (!$database->isConnected()) {
         return false;
     }
     $blockID = $database->escapeString($blockID);
     // check to see if it's in the visibility table
     $results = $database->getData('*', 'blockVisibility', 'blockID = ' . $blockID);
     //Default is to display the block unless specified.
     if ($results === null) {
         return true;
     }
     //Query failed. Play it safe and don't display the block.
     if ($results === false) {
         return false;
     }
     $comparators = array('referenceType' => '', 'referenceValue' => '');
     $hookEngine = HookEngine::getInstance();
     $comparators = $hookEngine->runFilter('blockVisibilityComparator', $comparators);
     $comparators[] = array('referenceType' => 'pageType', 'referenceValue' => $pageType);
     $comparators[] = array('referenceType' => 'role', 'referenceValue' => $roleID);
     $finalComparators = array();
     foreach ($comparators as $comparator) {
         if (!isset($comparator['referenceType'])) {
             continue;
         }
         if (!isset($comparator['referenceValue'])) {
             continue;
         }
         if (isset($finalComparators[$comparator['referenceType']])) {
             continue;
         }
         $finalComparators[$comparator['referenceType']] = $comparator['referenceValue'];
     }
     $countOfDoNotDisplays = 0;
     $countOfDoDisplays = 0;
     foreach ($results as $rule) {
         if (!isset($finalComparators[$rule['referenceType']])) {
             continue;
         }
         //If the first character is an !, then negate the operation.
         if ($rule['referenceID'][0] === '!') {
             $vote = $this->blockVisibleNegate($rule, $finalComparators);
             if ($vote === -1) {
                 $countOfDoNotDisplays += 1;
                 continue;
             }
             if ($vote === 1) {
                 $countOfDoDisplays += 1;
                 continue;
             }
             //No vote on any other value.
             continue;
         }
         if ($finalComparators[$rule['referenceType']] != $rule['referenceID']) {
             continue;
         }
         if ((int) $rule['visible'] === 0) {
             $countOfDoNotDisplays += 1;
             continue;
         }
         $countOfDoDisplays += 1;
     }
     if ($countOfDoNotDisplays > $countOfDoDisplays) {
         return false;
     }
     return true;
 }
Example #11
-1
 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(""));
 }