61 public function setOxCookie( $sName, $sValue =
"", $iExpire = 0, $sPath =
'/', $sDomain = null, $blToSession =
true, $blSecure =
false )
68 if ( $blToSession && !$this->
isAdmin() ) {
72 if ( defined(
'OXID_PHP_UNIT')) {
97 if ( $this->_blSaveToSession === null ) {
98 $this->_blSaveToSession =
false;
101 if ( $sSslUrl =
$myConfig->getSslShopUrl() ) {
104 $sHost = parse_url( $sUrl, PHP_URL_HOST );
105 $sSslHost = parse_url( $sSslUrl, PHP_URL_HOST );
108 if ( $sHost != $sSslHost ) {
110 $this->_blSaveToSession = $oUtils->extractDomain( $sHost ) != $oUtils->extractDomain( $sSslHost );
128 $sKey = $blSsl ?
'nossl' :
'ssl';
131 $sKey = $blSsl ?
'ssl' :
'nossl';
151 $aCookieData = array(
'value' => $sValue,
'expire' => $iExpire,
'path' => $sPath,
'domain' => $sDomain );
169 if ( isset( $aSessionCookies[$sKey] ) ) {
171 foreach ( $aSessionCookies[$sKey] as $sName => $aCookieData ) {
172 $this->
setOxCookie( $sName, $aCookieData[
'value'], $aCookieData[
'expire'], $aCookieData[
'path'], $aCookieData[
'domain'],
false );
173 $this->_sSessionCookies[$sName] = $aCookieData[
'value'];
177 unset( $aSessionCookies[$sKey] );
195 if ( $aCookiePaths = $this->
getConfig()->getConfigParam(
'aCookiePaths' ) ) {
197 $sShopId = $this->
getConfig()->getShopId();
198 $sPath = isset( $aCookiePaths[$sShopId] ) ? $aCookiePaths[$sShopId] : $sPath;
202 return $sPath ? $sPath :
"";
217 $sDomain = $sDomain ? $sDomain :
"";
222 if ( $aCookieDomains = $this->
getConfig()->getConfigParam(
'aCookieDomains' ) ) {
224 $sShopId = $this->
getConfig()->getShopId();
225 $sDomain = isset( $aCookieDomains[$sShopId] ) ? $aCookieDomains[$sShopId] : $sDomain;
242 if ( $sName && isset( $_COOKIE[$sName] ) ) {
244 } elseif ( $sName && !isset( $_COOKIE[$sName] ) ) {
245 $sValue = isset( $this->_sSessionCookies[$sName] ) ? $this->_sSessionCookies[$sName] : null;
246 } elseif ( !$sName && isset( $_COOKIE ) ) {
259 if ( isset( $_SERVER[
"HTTP_X_FORWARDED_FOR"] ) ) {
260 $sIP = $_SERVER[
"HTTP_X_FORWARDED_FOR"];
261 $sIP = preg_replace(
'/,.*$/',
'', $sIP);
262 } elseif ( isset( $_SERVER[
"HTTP_CLIENT_IP"] ) ) {
263 $sIP = $_SERVER[
"HTTP_CLIENT_IP"];
265 $sIP = $_SERVER[
"REMOTE_ADDR"];
280 if ( isset( $_SERVER ) ) {
281 if ( $sServVar && isset( $_SERVER[$sServVar] ) ) {
282 $sValue = $_SERVER[$sServVar];
283 } elseif ( !$sServVar ) {
301 public function setUserCookie( $sUser, $sPassword, $sShopId = null, $iTimeout = 31536000, $sSalt =
'ox' )
304 $sShopId = ( !$sShopId ) ?
$myConfig->getShopId() : $sShopId;
306 if (stripos($sSslUrl,
'https') === 0) {
312 $this->_aUserCookie[$sShopId] = $sUser .
'@@@' . crypt( $sPassword, $sSalt );
313 $this->
setOxCookie(
'oxid_' . $sShopId, $this->_aUserCookie[$sShopId],
oxRegistry::get(
"oxUtilsDate")->getTime() + $iTimeout,
'/', null,
true, $blSsl );
314 $this->
setOxCookie(
'oxid_' . $sShopId.
'_autologin',
'1',
oxRegistry::get(
"oxUtilsDate")->getTime() + $iTimeout,
'/', null,
true,
false);
327 $sShopId = ( !$sShopId ) ? $this->
getConfig()->getShopId() : $sShopId;
329 if (stripos($sSslUrl,
'https') === 0) {
335 $this->_aUserCookie[$sShopId] =
'';
337 $this->
setOxCookie(
'oxid_' . $sShopId.
'_autologin',
'0',
oxRegistry::get(
"oxUtilsDate")->getTime() - 3600,
'/', null,
true,
false);
350 $sShopId = ( !$sShopId ) ?
$myConfig->getShopId() : $sShopId;
353 $sSslUrl = rtrim(
$myConfig->getSslShopUrl(),
'/').$_SERVER[
'REQUEST_URI'];
354 if (stripos($sSslUrl,
'https') === 0) {
359 if ( array_key_exists( $sShopId, $this->_aUserCookie ) && $this->_aUserCookie[$sShopId] !== null ) {
360 return $this->_aUserCookie[$sShopId] ? $this->_aUserCookie[$sShopId] : null;
363 return $this->_aUserCookie[$sShopId] = $this->
getOxCookie(
'oxid_'.$sShopId );
375 $aTrustedIPs = ( array ) $this->
getConfig()->getConfigParam(
"aTrustedIPs" );
376 if ( count( $aTrustedIPs ) ) {
393 $sAgent =
getStr()->preg_replace(
"/MSIE(\s)?(\S)*(\s)/",
"", (
string) $sAgent );
408 if ( !$sURL || (strpos( $sURL,
"http" ) !== 0)) {
413 preg_match(
"/^(https?:\/\/)?(www\.)?([^\/]+)/i", $sURL, $matches);
414 $sUrlHost = $matches[3];
417 preg_match(
"/^(https?:\/\/)?(www\.)?([^\/]+)/i", $this->
getServerVar(
'HTTP_HOST' ), $matches);
418 $sRealHost = $matches[3];
420 $sCurrentHost = preg_replace(
'/\/\w*\.php.*/',
'', $this->
getServerVar(
'HTTP_HOST' ) . $this->
getServerVar(
'SCRIPT_NAME' ) );
423 $sCurrentHost = str_replace(
'/',
'', $sCurrentHost );
424 $sURL = str_replace(
'/',
'', $sURL );
427 if ( $sURL && $sCurrentHost && strpos( $sURL, $sCurrentHost ) !==
false ) {
429 if ( $sUrlHost == $sRealHost ) {