Example #1
0
 /**
  * Initialize the methods of the class.
  *
  * @access protected
  * @return void
  */
 protected function initialize()
 {
     $this->_oRatingModel = new RatingCoreModel();
     $this->_sTable = $this->_oHttpRequest->post('table');
     $this->_iId = (int) $this->_oHttpRequest->post('id');
     if ($this->_sTable == 'Members') {
         $iProfileId = (int) (new Framework\Session\Session())->get('member_id');
         if ($iProfileId === $this->_iId) {
             $this->_iStatus = 0;
             $this->_sTxt = t('You can not vote your own profile!');
             return;
         }
     }
     /**
      * @internal Today's IP address is also easier to change than delete a cookie, so we have chosen the Cookie instead save the IP address in the database.
      */
     $oCookie = new Cookie();
     $sCookieName = 'pHSVoting' . $this->_iId . $this->_sTable;
     if ($oCookie->exists($sCookieName)) {
         $this->_iStatus = 0;
         $this->_sTxt = t('You have already voted!');
         return;
     } else {
         $oCookie->set($sCookieName, 1, 3600 * 24 * 7);
         // A week
     }
     unset($oCookie);
     $this->select();
     $this->update();
     $this->_iStatus = 1;
     $sVoteTxt = static::$_iVotes > 1 ? t('Votes') : t('Vote');
     $this->_sTxt = t('Score: %0% - %2%: %1%', number_format($this->_fScore / static::$_iVotes, 1), static::$_iVotes, $sVoteTxt);
 }
 public function __construct()
 {
     $this->_oConfig = Config::getInstance();
     $oCookie = new Cookie();
     // Check a template name has been entered and if it exceeds the maximum length (49 characters).
     if (!empty($_REQUEST['tpl']) && strlen($_REQUEST['tpl']) < 50) {
         $this->_sUserTpl = $_REQUEST['tpl'];
         $oCookie->set('site_tpl', $this->_sUserTpl, 60 * 60 * 48);
     } else {
         if ($oCookie->exists('site_tpl')) {
             $this->_sUserTpl = $oCookie->get('site_tpl');
         }
     }
     unset($oCookie);
 }
 public function __construct()
 {
     $this->_oConfig = Config::getInstance();
     $oCookie = new Cookie();
     // Check a template name has been entered and if it meets the required length.
     if (!empty($_REQUEST['l']) && strlen($_REQUEST['l']) == 5) {
         $this->_sUserLang = $_REQUEST['l'];
         $oCookie->set(static::COOKIE_NAME, $this->_sUserLang, 60 * 60 * 48);
     } else {
         if ($oCookie->exists(static::COOKIE_NAME)) {
             $this->_sUserLang = $oCookie->get(static::COOKIE_NAME);
         } else {
             $this->_sUserLang = (new \PH7\Framework\Navigation\Browser())->getLanguage();
         }
     }
     unset($oCookie);
 }
 /**
  * @return boolean Return "true" If we believe that this person takes too much request otherwise "false"
  */
 public function cookie()
 {
     $oCookie = new Cookie();
     if (!$oCookie->exists(static::COOKIE_NAME)) {
         $oCookie->set(static::COOKIE_NAME, 1, 60 * 60 * 48);
     } else {
         $oCookie->set(static::COOKIE_NAME, $oCookie->get(static::COOKIE_NAME) + 1);
     }
     if ($oCookie->get(static::COOKIE_NAME) > PH7_DDOS_MAX_COOKIE_PAGE_LOAD) {
         $oCookie->remove(static::COOKIE_NAME);
         // Remove Cookie
         $bStatus = true;
     } else {
         $bStatus = false;
     }
     unset($oCookie);
     return $bStatus;
 }
 /**
  * Set an Affiliate Cookie.
  *
  * @param integer $iAffId
  * @param object \PH7\Framework\Cookie\Cookie $oCookie
  * @return void
  */
 private function _setCookie($iAffId, Cookie $oCookie)
 {
     $oCookie->set(static::COOKIE_NAME, $iAffId, 3600 * 24 * 7);
 }