public function __construct() { $this->_oSession = new Session(); $oBrowser = new Browser(); $this->_sHttpReferer = $oBrowser->getHttpReferer(); $this->_sUserAgent = $oBrowser->getUserAgent(); unset($oBrowser); }
public function __construct() { $oBrowser = new Browser(); $this->_sUserAgent = $oBrowser->getUserAgent(); $this->_sReferer = $oBrowser->getHttpReferer(); $this->_sUserLang = $oBrowser->getLanguage(); unset($oBrowser); $this->init(); }
/** * Affiliates'levels. * * @return boolean */ public static function auth() { $oSession = new Framework\Session\Session(); $oBrowser = new Framework\Navigation\Browser(); $bIsConnect = (int) $oSession->exists('affiliate_id') && $oSession->get('affiliate_ip') === Framework\Ip\Ip::get() && $oSession->get('affiliate_http_user_agent') === $oBrowser->getUserAgent(); /** Destruction of the object and minimize CPU resources **/ unset($oSession, $oBrowser); return $bIsConnect; }
/** * Users'levels. * * @return boolean */ public static function auth() { $oSession = new Session(); $oBrowser = new Browser(); $bIsConnect = (int) $oSession->exists('member_id') && $oSession->get('member_ip') === Ip::get() && $oSession->get('member_http_user_agent') === $oBrowser->getUserAgent(); /** Destruction of the object and minimize CPU resources **/ unset($oSession, $oBrowser); return $bIsConnect; }
/** * Set Caching. * * @return string The contents. * @throws \PH7\Framework\Layout\Exception If the cache file couldn't be written. */ public function cache() { $this->_checkCacheDir(); /** * Try the cache first to see if the combined files were already generated. */ $oBrowser = new Browser(); $this->_iIfModified = !empty($_SERVER['HTTP_IF_MODIFIED_SINCE']) ? substr($_SERVER['HTTP_IF_MODIFIED_SINCE'], 0, 29) : null; $this->_sCacheDir .= $this->_oHttpRequest->get('t') . PH7_DS; $this->_oFile->createDir($this->_sCacheDir); $sExt = $this->_bIsGzip ? 'gz' : 'cache'; $sCacheFile = md5($this->_sType . $this->_sDir . $this->_sFiles) . PH7_DOT . $sExt; foreach ($this->_aElements as $sElement) { $sPath = realpath($this->_sBase . $sElement); if ($this->_oFile->modificationTime($sPath) > $this->_oFile->modificationTime($this->_sCacheDir . $sCacheFile)) { if (!empty($this->_iIfModified) && $this->_oFile->modificationTime($sPath) > $this->_oFile->modificationTime($this->_iIfModified)) { $oBrowser->noCache(); } // Get contents of the files $this->getContents(); // Store the file in the cache if (!$this->_oFile->putFile($this->_sCacheDir . $sCacheFile, $this->_sContents)) { throw new Exception('Couldn\'t write cache file: \'' . $this->_sCacheDir . $sCacheFile . '\''); } } } if ($this->_oHttpRequest->getMethod() != 'HEAD') { $oBrowser->cache(); //header('Not Modified', true, 304); // Warning: It can causes problems (ERR_FILE_NOT_FOUND) } unset($oBrowser); if (!($this->_sContents = $this->_oFile->getFile($this->_sCacheDir . $sCacheFile))) { throw new Exception('Couldn\'t read cache file: \'' . $this->_sCacheDir . $sCacheFile . '\''); } }
/** * Get favicon from a URL. * * @param string $sUrl * @return void The HTML favicon image. */ public function favicon($sUrl) { $sImg = \PH7\Framework\Navigation\Browser::favicon($sUrl); $sName = \PH7\Framework\Http\Http::getHostName($sUrl); $this->imgTag($sImg, $sName, array('width' => 16, 'height' => 16)); }