diff --git a/src/includes/class/ccookie.php b/src/includes/class/ccookie.php index 3590721..ab06dce 100644 --- a/src/includes/class/ccookie.php +++ b/src/includes/class/ccookie.php @@ -1,4 +1,5 @@ m_sName) ) - { + if (filter_has_var(INPUT_COOKIE, $this->m_sName)) { $tabReturn = array(); - list($tabReturn[CCookie::USER],$tabReturn[CCookie::SESSION],$tabReturn[CCookie::LANGUAGE],$tabReturn[CCookie::FORCEDESKTOP]) = @unserialize( $_COOKIE[$this->m_sName] ); - if( ($this->Sanitize($tabReturn[CCookie::USER],GetRegExPatternName())===FALSE) - || ($this->Sanitize($tabReturn[CCookie::SESSION],GetRegExPatternSession())===FALSE) - || ($this->Sanitize($tabReturn[CCookie::LANGUAGE],GetRegExPatternSession())===FALSE) ) - { + list($tabReturn[CCookie::USER], $tabReturn[CCookie::SESSION], $tabReturn[CCookie::LANGUAGE], $tabReturn[CCookie::FORCEDESKTOP]) = @unserialize($_COOKIE[$this->m_sName]); + if (($this->Sanitize($tabReturn[CCookie::USER], GetRegExPatternName()) === FALSE) + || ($this->Sanitize($tabReturn[CCookie::SESSION], GetRegExPatternSession()) === FALSE) + || ($this->Sanitize($tabReturn[CCookie::LANGUAGE], GetRegExPatternSession()) === FALSE) + ) { $tabReturn = FALSE; - } - else - { + } else { // Format force desktop value - if( isset($tabReturn[CCookie::FORCEDESKTOP]) && ($tabReturn[CCookie::FORCEDESKTOP]==1) ) - { - $tabReturn[CCookie::FORCEDESKTOP]=TRUE; - } - else - { - $tabReturn[CCookie::FORCEDESKTOP]=FALSE; - }//Format force desktio value - }//if( ($this->Sanitize(/// - }//if( filter_has_var(/// + if (isset($tabReturn[CCookie::FORCEDESKTOP]) && ($tabReturn[CCookie::FORCEDESKTOP] == 1)) { + $tabReturn[CCookie::FORCEDESKTOP] = TRUE; + } else { + $tabReturn[CCookie::FORCEDESKTOP] = FALSE; + } //Format force desktio value + } //if( ($this->Sanitize(/// + } //if( filter_has_var(/// return $tabReturn; } @@ -257,37 +249,37 @@ public function Read() * update: Olivier JULLIEN - 2010-06-15 - redefine Expire time parameter * add language and force reload parameters */ - public function Write($sUsername, $sSessionId, $sLanguage, $bForceDesk, $iExpire=NULL) + public function Write($sUsername, $sSessionId, $sLanguage, $bForceDesk, $iExpire = NULL) { $bReturn = FALSE; - if( ($this->Sanitize($sUsername,GetRegExPatternName())===TRUE) - && ($this->Sanitize($sSessionId,GetRegExPatternSession())===TRUE) - && ($this->Sanitize($sLanguage,GetRegExPatternSession())===TRUE) - && is_bool($bForceDesk) ) - { + if (($this->Sanitize($sUsername, GetRegExPatternName()) === TRUE) + && ($this->Sanitize($sSessionId, GetRegExPatternSession()) === TRUE) + && ($this->Sanitize($sLanguage, GetRegExPatternSession()) === TRUE) + && is_bool($bForceDesk) + ) { // Default expiration time - if( !is_int($iExpire) ) - { + if (!is_int($iExpire)) { $iExpire = time() + $this->m_iExpire; - } - else - { + } else { $iExpire = time() + $iExpire; - }//if( !is_int($iExpire) ) + } //if( !is_int($iExpire) ) // Force desktop - if( $bForceDesk==TRUE ) - $iForceDesk=1; + if ($bForceDesk == TRUE) + $iForceDesk = 1; else - $iForceDesk=0; + $iForceDesk = 0; // Send cookie - $bReturn = setcookie($this->m_sName - ,@serialize( array( $sUsername, $sSessionId, $sLanguage, $iForceDesk) ) - ,$iExpire - ,$this->m_sPath.'; HttpOnly' - ,$this->m_sDomain - ,$this->m_iSecure); - }// if... + $bReturn = setcookie( + $this->m_sName, + @serialize(array($sUsername, $sSessionId, $sLanguage, $iForceDesk)), + $iExpire, + $this->m_sPath, + $this->m_sDomain, + $this->m_iSecure, + true + ); + } // if... return $bReturn; } @@ -303,7 +295,6 @@ public function Delete() setcookie($this->m_sName); unset($_COOKIE[$this->m_sName]); } - } -define ('PBR_COOKIE_LOADED',1); +define('PBR_COOKIE_LOADED', 1);