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(); } }
} if (defined('LOGGER_MAIL') && LOGGER_MAIL && defined('LOGGER_MAIL_TO_EMAIL') && defined('LOGGER_MAIL_TO_NAME') && !static::getDebug()) { $mailConfig = array('fromEmail' => ADMIN_EMAIL, 'fromName' => $language->getVar('site_name'), 'toEmail' => LOGGER_MAIL_TO_EMAIL, 'toName' => LOGGER_MAIL_TO_NAME, 'mailSubject' => $language->getVar('site_name') . ' logs'); $log->attach(new Mail($mailConfig)); } if (defined('LOGGER_ERROR') && LOGGER_ERROR) { $exc->attach(new Log()); $err->attach(new Log()); } // Config router host if (!defined('HOSTNAME')) { throw new \Exception('Miss hostname constant'); } Router::setHost(HOSTNAME); // Auto set language, by session $languageLoaded = Language::getInstance()->getLanguage(); $langSession = Session::getInstance()->get('language'); if (!is_null($langSession) && $langSession != $languageLoaded) { $language->setLanguage($langSession); $languageLoaded = $langSession; } // Auto set language, by cookie $langCookie = Cookie::get('language'); if (!is_null($langCookie) && $langCookie != $languageLoaded) { $language->setLanguage($langCookie); $languageLoaded = $langSession; } // Security Security::autorun(); // Clean unset($bench, $globalizer, $language, $exc, $err, $log);
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); } } }
public static function isConnected() { return Session::getInstance()->get('isConnected'); }
protected function _display($captchaType) { $this->create(Session::getInstance()->get($this->getFormName() . 'Captcha'), $captchaType); Header::sentHeader('Cache-Control', 'no-store, no-cache, must-revalidate'); Header::sentHeader('Cache-Control', 'post-check=0, pre-check=0', false); Header::sentHeader('Pragma', 'no-cache'); Header::sentHeader('Expires', 'Mon, 26 Jul 1997 05:00:00 GMT'); if ($captchaType == 'image') { Header::sentHeader('Content-Type', 'image/' . $this->_imageFormat); // display captcha switch ($this->_imageFormat) { case 'png': imagepng($this->_imageContents); break; case 'jpg': imagejpeg($this->_imageContents); break; case 'gif': imagegif($this->_imageContents); break; } } elseif ($captchaType == 'audio') { Header::sentHeader('Content-Type', 'audio/x-wav'); Header::sentHeader('Content-Length', (string) strlen($this->_audioContents)); // display captcha echo $this->_audioContents; } }
public function flush() { Session::getInstance()->delete($this->getFormName() . 'CsrfToken', true); if ($this->_timeValidity > 0) { Session::getInstance()->delete($this->getFormName() . 'CsrfTokenTime', true); } $this->_token = null; }