public function __get($name) { if ($name == 'tpl') { if (!$this->_templateInitialized) { $this->initTemplate(); } return $this->_template; } if ($name == 'router') { return Router::getInstance(); } if ($name == 'session') { return Session::getInstance(); } if ($name == 'config') { return Config::getInstance(); } if ($name == 'log') { return Logger::getInstance(); } if ($name == 'language') { return Language::getInstance(); } if ($name == 'model') { return Model::getInstance(); } }
public function notify() { // Erase buffer $buffer = ob_get_status(); if (!empty($buffer)) { ob_end_clean(); } if ($this->_observers->count()) { foreach ($this->_observers as $observer) { $observer->update($this); } } // Clear error for avoid multiple call if ($this->_clearErrorAfterSending) { $this->_error = false; } // Show internal server error (500) if (!Application::getDebug()) { Router::getInstance()->show500(); } // Exit script exit; }
public function run() { if ($this->_isRun) { throw new \Exception('Application already runned'); } //Cli if (Cli::isCli()) { throw new \Exception('CLI not yet'); } // Check maitenance mode activated => show503 if (defined('SITE_MAINTENANCE') && SITE_MAINTENANCE) { Router::getInstance()->show503(); } else { // Run router Router::getInstance()->run(); } $this->_isRun = true; }
public function update(\SplSubject $subject, $isException = false) { Router::getInstance()->showDebugger($isException); }
public function isCurrentRoute($routeName) { return Router::getInstance()->getCurrentRoute() == $routeName; }
protected function _check($ip, $userAgent) { if (Http::getQuery($this->_trapName) && !Validate::isGoogleBot()) { $isBadCrawler = false; $isGoodCrawler = false; if ($this->_badCrawlerFile) { $badCrawlerXml = simplexml_load_file($this->_badCrawlerFile); if (is_null($badCrawlerXml) || !$badCrawlerXml) { throw new \Exception('Invalid xml file : "' . $this->_badCrawlerFile . '"'); } } if ($this->_goodCrawlerFile) { $goodCrawlerXml = simplexml_load_file($this->_goodCrawlerFile); if (is_null($goodCrawlerXml) || !$goodCrawlerXml) { throw new \Exception('Invalid xml file : "' . $this->_goodCrawlerFile . '"'); } } if ($badCrawlerXml) { $badCrawlerList = $badCrawlerXml->crawler; foreach ($badCrawlerList as $crawler) { if (isset($crawler->ip) && (string) $crawler->ip == $ip) { $isBadCrawler = true; } if (isset($crawler->userAgent) && strripos((string) $crawler->userAgent, $userAgent) !== false) { $isBadCrawler = true; } if ($isBadCrawler) { $this->_catch($ip, $userAgent, self::CRAWLER_BAD); Session::getInstance()->add(md5($ip . 'badcrawler'), true, true, true); Router::getInstance()->show403(true); break; } } unset($crawler); } if ($goodCrawlerXml) { $goodCrawlerList = $goodCrawlerXml->crawler; foreach ($goodCrawlerList as $crawler) { if (isset($crawler->ip) && (string) $crawler->ip == $ip) { $isGoodCrawler = true; } if (isset($crawler->userAgent) && strripos((string) $crawler->userAgent, $userAgent) !== false) { $isGoodCrawler = true; } if ($isGoodCrawler) { $this->_catch($ip, $userAgent, self::CRAWLER_BAD); break; } } unset($crawler); } // unknown if (!$isBadCrawler && !$isGoodCrawler) { $this->_catch($ip, $userAgent, self::CRAWLER_BAD); } } }