43 public function setOxCookie($sName, $sValue =
"", $iExpire = 0, $sPath =
'/', $sDomain = null, $blToSession =
true, $blSecure =
false)
50 if ($blToSession && !$this->
isAdmin()) {
54 if (defined(
'OXID_PHP_UNIT')) {
79 if ($this->_blSaveToSession === null) {
80 $this->_blSaveToSession =
false;
83 if ($sSslUrl =
$myConfig->getSslShopUrl()) {
86 $sHost = parse_url($sUrl, PHP_URL_HOST);
87 $sSslHost = parse_url($sSslUrl, PHP_URL_HOST);
90 if ($sHost != $sSslHost) {
92 $this->_blSaveToSession = $oUtils->extractDomain($sHost) != $oUtils->extractDomain($sSslHost);
110 $sKey = $blSsl ?
'nossl' :
'ssl';
113 $sKey = $blSsl ?
'ssl' :
'nossl';
131 $aCookieData = array(
'value' => $sValue,
'expire' => $iExpire,
'path' => $sPath,
'domain' => $sDomain);
147 if (isset($aSessionCookies[$sKey])) {
149 foreach ($aSessionCookies[$sKey] as $sName => $aCookieData) {
150 $this->
setOxCookie($sName, $aCookieData[
'value'], $aCookieData[
'expire'], $aCookieData[
'path'], $aCookieData[
'domain'],
false);
151 $this->_sSessionCookies[$sName] = $aCookieData[
'value'];
155 unset($aSessionCookies[$sKey]);
173 if ($aCookiePaths = $this->
getConfig()->getConfigParam(
'aCookiePaths')) {
175 $sShopId = $this->
getConfig()->getShopId();
176 $sPath = isset($aCookiePaths[$sShopId]) ? $aCookiePaths[$sShopId] : $sPath;
180 return $sPath ? $sPath :
"";
195 $sDomain = $sDomain ? $sDomain :
"";
200 if ($aCookieDomains = $this->
getConfig()->getConfigParam(
'aCookieDomains')) {
202 $sShopId = $this->
getConfig()->getShopId();
203 $sDomain = isset($aCookieDomains[$sShopId]) ? $aCookieDomains[$sShopId] : $sDomain;
221 if ($sName && isset($_COOKIE[$sName])) {
223 } elseif ($sName && !isset($_COOKIE[$sName])) {
224 $sValue = isset($this->_sSessionCookies[$sName]) ? $this->_sSessionCookies[$sName] : null;
225 } elseif (!$sName && isset($_COOKIE)) {
239 if (isset($_SERVER[
"HTTP_X_FORWARDED_FOR"])) {
240 $sIP = $_SERVER[
"HTTP_X_FORWARDED_FOR"];
241 $sIP = preg_replace(
'/,.*$/',
'', $sIP);
242 } elseif (isset($_SERVER[
"HTTP_CLIENT_IP"])) {
243 $sIP = $_SERVER[
"HTTP_CLIENT_IP"];
245 $sIP = $_SERVER[
"REMOTE_ADDR"];
261 if (isset($_SERVER)) {
262 if ($sServVar && isset($_SERVER[$sServVar])) {
263 $sValue = $_SERVER[$sServVar];
264 } elseif (!$sServVar) {
281 public function setUserCookie($sUser, $sPassword, $sShopId = null, $iTimeout = 31536000, $sSalt =
'ox')
284 $sShopId = (!$sShopId) ?
$myConfig->getShopId() : $sShopId;
286 if (stripos($sSslUrl,
'https') === 0) {
292 $this->_aUserCookie[$sShopId] = $sUser .
'@@@' . crypt($sPassword, $sSalt);
293 $this->
setOxCookie(
'oxid_' . $sShopId, $this->_aUserCookie[$sShopId],
oxRegistry::get(
"oxUtilsDate")->getTime() + $iTimeout,
'/', null,
true, $blSsl);
294 $this->
setOxCookie(
'oxid_' . $sShopId .
'_autologin',
'1',
oxRegistry::get(
"oxUtilsDate")->getTime() + $iTimeout,
'/', null,
true,
false);
305 $sShopId = (!$sShopId) ? $this->
getConfig()->getShopId() : $sShopId;
307 if (stripos($sSslUrl,
'https') === 0) {
313 $this->_aUserCookie[$sShopId] =
'';
315 $this->
setOxCookie(
'oxid_' . $sShopId .
'_autologin',
'0',
oxRegistry::get(
"oxUtilsDate")->getTime() - 3600,
'/', null,
true,
false);
328 $sShopId = (!$sShopId) ?
$myConfig->getShopId() : $sShopId;
331 $sSslUrl = rtrim(
$myConfig->getSslShopUrl(),
'/') . $_SERVER[
'REQUEST_URI'];
332 if (stripos($sSslUrl,
'https') === 0) {
337 if (array_key_exists($sShopId, $this->_aUserCookie) && $this->_aUserCookie[$sShopId] !== null) {
338 return $this->_aUserCookie[$sShopId] ? $this->_aUserCookie[$sShopId] : null;
341 return $this->_aUserCookie[$sShopId] = $this->
getOxCookie(
'oxid_' . $sShopId);
353 $aTrustedIPs = ( array ) $this->
getConfig()->getConfigParam(
"aTrustedIPs");
354 if (count($aTrustedIPs)) {
371 $sAgent =
getStr()->preg_replace(
"/MSIE(\s)?(\S)*(\s)/",
"", (
string) $sAgent);
387 if (!$sURL || (strpos($sURL,
"http") !== 0)) {
393 if (!$blIsCurrentUrl) {
394 $sServerHost = $this->
getServerVar(
'HTTP_X_FORWARDED_HOST');
400 return $blIsCurrentUrl;
414 preg_match(
"/^(https?:\/\/)?(www\.)?([^\/]+)/i", $sURL, $matches);
415 $sUrlHost = $matches[3];
417 preg_match(
"/^(https?:\/\/)?(www\.)?([^\/]+)/i", $sServerHost, $matches);
418 $sRealHost = $matches[3];
421 $sCurrentHost = preg_replace(
'/\/((?:modules|core)\/[\w\/]*)?\w*\.php.*/',
'', $sServerHost . $sScriptName);
423 $sCurrentHost = str_replace(
'/',
'', $sCurrentHost);
424 $sURL = str_replace(
'/',
'', $sURL);
426 if ($sURL && $sCurrentHost && strpos($sURL, $sCurrentHost) !==
false) {
428 if ($sUrlHost == $sRealHost) {