2013-04-22 11:21:42 +02:00
|
|
|
<?php
|
|
|
|
|
2013-04-22 11:40:11 +02:00
|
|
|
/**
|
|
|
|
* This Software is the property of Data Development and is protected
|
|
|
|
* by copyright law - it is NOT Freeware.
|
|
|
|
*
|
|
|
|
* Any unauthorized use of this software without a valid license
|
|
|
|
* is a violation of the license agreement and will be prosecuted by
|
|
|
|
* civil and criminal law.
|
|
|
|
*
|
|
|
|
* http://www.shopmodule.com
|
|
|
|
*
|
|
|
|
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
|
|
|
|
* @author D3 Data Development - Daniel Seifert <ds@shopmodule.com>
|
|
|
|
* @link http://www.oxidmodule.com
|
|
|
|
*/
|
2012-02-15 14:17:42 +01:00
|
|
|
|
2016-11-21 16:34:05 +01:00
|
|
|
class d3GeoIP extends oxBase
|
2013-04-22 11:21:42 +02:00
|
|
|
{
|
|
|
|
protected $_sClassName = 'd3geoip';
|
|
|
|
private $_sModId = 'd3_geoip';
|
2013-04-22 11:40:11 +02:00
|
|
|
public $oCountry;
|
|
|
|
public $oD3Log;
|
2013-04-22 11:21:42 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Class constructor, initiates parent constructor (parent::oxI18n()).
|
|
|
|
*/
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
parent::__construct();
|
|
|
|
$this->init('d3geoip');
|
|
|
|
}
|
|
|
|
|
2018-01-25 10:51:36 +01:00
|
|
|
/**
|
|
|
|
* get oxcountry object by given IP address (optional)
|
|
|
|
*
|
|
|
|
* @param string $sIP optional
|
|
|
|
*
|
|
|
|
* @return oxcountry
|
|
|
|
* @throws d3_cfg_mod_exception
|
|
|
|
* @throws oxConnectionException
|
|
|
|
* @throws oxSystemComponentException
|
|
|
|
*/
|
2013-04-22 11:40:11 +02:00
|
|
|
public function getUserLocationCountryObject($sIP = null)
|
2013-04-22 11:21:42 +02:00
|
|
|
{
|
2015-06-23 11:29:07 +02:00
|
|
|
if (!$this->oCountry) {
|
2013-04-22 11:48:59 +02:00
|
|
|
startProfile(__METHOD__);
|
|
|
|
|
2015-06-23 11:29:07 +02:00
|
|
|
if (!$sIP) {
|
2013-04-22 11:21:42 +02:00
|
|
|
$sIP = $this->getIP();
|
2013-04-22 11:40:11 +02:00
|
|
|
}
|
2013-04-22 11:21:42 +02:00
|
|
|
|
2018-01-25 10:51:36 +01:00
|
|
|
$sISOAlpha = $this->loadByIP(oxRegistry::getConfig()->checkParamSpecialChars($sIP));
|
2013-04-22 11:21:42 +02:00
|
|
|
|
2015-06-23 11:29:07 +02:00
|
|
|
if (!$sISOAlpha) {
|
|
|
|
$this->_getLog()->log(
|
|
|
|
d3log::ERROR,
|
|
|
|
__CLASS__,
|
|
|
|
__FUNCTION__,
|
|
|
|
__LINE__,
|
|
|
|
'get ISO by IP failed',
|
|
|
|
$sIP
|
|
|
|
);
|
2012-02-15 14:17:42 +01:00
|
|
|
$this->oCountry = $this->getCountryFallBackObject();
|
2015-06-23 11:29:07 +02:00
|
|
|
} else {
|
|
|
|
$this->_getLog()->log(
|
|
|
|
d3log::INFO,
|
|
|
|
__CLASS__,
|
|
|
|
__FUNCTION__,
|
|
|
|
__LINE__,
|
|
|
|
'get ISO by IP',
|
|
|
|
$sIP." => ".$sISOAlpha
|
|
|
|
);
|
2013-04-22 11:21:42 +02:00
|
|
|
$this->oCountry = $this->getCountryObject($sISOAlpha);
|
|
|
|
}
|
2013-04-22 11:48:59 +02:00
|
|
|
|
|
|
|
stopProfile(__METHOD__);
|
2013-04-22 11:21:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return $this->oCountry;
|
|
|
|
}
|
|
|
|
|
2018-01-25 10:51:36 +01:00
|
|
|
/**
|
|
|
|
* get IP address from client or set test IP address
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
* @throws d3_cfg_mod_exception
|
|
|
|
*/
|
2013-04-22 11:21:42 +02:00
|
|
|
public function getIP()
|
|
|
|
{
|
2013-04-22 11:48:59 +02:00
|
|
|
startProfile(__METHOD__);
|
|
|
|
|
2015-06-23 11:29:07 +02:00
|
|
|
if ($this->_getModConfig()->getValue('blUseTestIp')
|
|
|
|
&& $this->_getModConfig()->getValue('sTestIp')
|
|
|
|
) {
|
2013-04-22 11:48:59 +02:00
|
|
|
$sIP = $this->_getModConfig()->getValue('sTestIp');
|
2015-06-23 11:29:07 +02:00
|
|
|
} elseif ($this->_getModConfig()->getValue('blUseTestCountry')
|
|
|
|
&& $this->_getModConfig()->getValue('sTestCountryIp')
|
|
|
|
) {
|
2013-04-22 11:48:59 +02:00
|
|
|
$sIP = $this->_getModConfig()->getValue('sTestCountryIp');
|
2015-06-23 11:29:07 +02:00
|
|
|
} else {
|
2015-07-21 21:12:55 +02:00
|
|
|
if(isset($_SERVER['HTTP_CF_CONNECTING_IP'])) {
|
|
|
|
$sIP = $_SERVER['HTTP_CF_CONNECTING_IP'];
|
|
|
|
} else if (isset($_SERVER['HTTP_X_REAL_IP'])) {
|
|
|
|
$sIP = $_SERVER['HTTP_X_REAL_IP'];
|
|
|
|
} else if (isset($_SERVER['HTTP_CLIENT_IP'])) {
|
|
|
|
$sIP = $_SERVER['HTTP_CLIENT_IP'];
|
|
|
|
} else if(isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
|
|
|
|
$sIP = $_SERVER['HTTP_X_FORWARDED_FOR'];
|
|
|
|
} else if(isset($_SERVER['HTTP_X_FORWARDED'])) {
|
|
|
|
$sIP = $_SERVER['HTTP_X_FORWARDED'];
|
|
|
|
} else if(isset($_SERVER['HTTP_FORWARDED_FOR'])) {
|
|
|
|
$sIP = $_SERVER['HTTP_FORWARDED_FOR'];
|
|
|
|
} else if(isset($_SERVER['HTTP_FORWARDED'])) {
|
|
|
|
$sIP = $_SERVER['HTTP_FORWARDED'];
|
|
|
|
} else if(isset($_SERVER['REMOTE_ADDR'])) {
|
|
|
|
$sIP = $_SERVER['REMOTE_ADDR'];
|
|
|
|
} else {
|
|
|
|
$sIP = 'UNKNOWN';
|
|
|
|
}
|
2013-04-22 11:40:11 +02:00
|
|
|
}
|
2016-11-21 16:34:05 +01:00
|
|
|
$sIP = str_replace(' ', '', $sIP);
|
2013-04-22 11:48:59 +02:00
|
|
|
|
|
|
|
stopProfile(__METHOD__);
|
|
|
|
|
2016-11-21 16:34:05 +01:00
|
|
|
return oxRegistry::getConfig()->checkParamSpecialChars($sIP);
|
2013-04-22 11:21:42 +02:00
|
|
|
}
|
|
|
|
|
2018-01-25 10:51:36 +01:00
|
|
|
/**
|
|
|
|
* get ISO alpha 2 ID by IP address
|
|
|
|
*
|
|
|
|
* @param int $sIP IP address
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
* @throws oxConnectionException
|
|
|
|
*/
|
|
|
|
public function loadByIP($sIP)
|
2013-04-22 11:21:42 +02:00
|
|
|
{
|
2013-04-22 11:48:59 +02:00
|
|
|
startProfile(__METHOD__);
|
|
|
|
|
2018-01-25 10:51:36 +01:00
|
|
|
$sSelect = "
|
|
|
|
SELECT
|
|
|
|
d3iso
|
|
|
|
FROM
|
|
|
|
".$this->_sClassName."
|
|
|
|
WHERE
|
|
|
|
LPAD(
|
|
|
|
BINARY(
|
|
|
|
if(
|
|
|
|
IS_IPV4('" . $sIP . "'),
|
|
|
|
INET_ATON('" . $sIP . "'),
|
|
|
|
INET6_ATON('" . $sIP . "')
|
|
|
|
)
|
|
|
|
),
|
|
|
|
16,
|
|
|
|
0
|
|
|
|
) BETWEEN D3STARTIPBIN AND D3ENDIPBIN";
|
2013-04-22 11:48:59 +02:00
|
|
|
|
|
|
|
$sISO = oxDb::getDb()->getOne($sSelect);
|
|
|
|
|
|
|
|
stopProfile(__METHOD__);
|
|
|
|
|
|
|
|
return $sISO;
|
2013-04-22 11:21:42 +02:00
|
|
|
}
|
|
|
|
|
2018-01-25 10:51:36 +01:00
|
|
|
/**
|
|
|
|
* get oxcountry object by ISO alpha 2 ID
|
|
|
|
*
|
|
|
|
* @param string $sISOAlpha
|
|
|
|
*
|
|
|
|
* @return oxcountry
|
|
|
|
* @throws oxConnectionException
|
|
|
|
* @throws oxSystemComponentException
|
|
|
|
*/
|
2013-04-22 11:21:42 +02:00
|
|
|
public function getCountryObject($sISOAlpha)
|
|
|
|
{
|
2013-04-22 11:48:59 +02:00
|
|
|
startProfile(__METHOD__);
|
|
|
|
|
2012-02-15 14:17:42 +01:00
|
|
|
$oCountry = oxNew('oxcountry');
|
2015-06-23 11:29:07 +02:00
|
|
|
$sSelect = "SELECT oxid FROM ".$oCountry->getViewName().
|
|
|
|
" WHERE OXISOALPHA2 = '".$sISOAlpha."' AND OXACTIVE = '1'";
|
2013-04-22 11:25:27 +02:00
|
|
|
|
2013-04-22 11:21:42 +02:00
|
|
|
$oCountry->load(oxDb::getDb()->getOne($sSelect));
|
|
|
|
|
2013-04-22 11:48:59 +02:00
|
|
|
stopProfile(__METHOD__);
|
|
|
|
|
2013-04-22 11:21:42 +02:00
|
|
|
return $oCountry;
|
|
|
|
}
|
|
|
|
|
2018-01-25 10:51:36 +01:00
|
|
|
/**
|
|
|
|
* get oxcountry object for fallback, if set
|
|
|
|
*
|
|
|
|
* @return oxcountry
|
|
|
|
* @throws d3_cfg_mod_exception
|
|
|
|
* @throws oxSystemComponentException
|
|
|
|
*/
|
2012-02-15 14:17:42 +01:00
|
|
|
public function getCountryFallBackObject()
|
2012-02-15 14:15:28 +01:00
|
|
|
{
|
2013-04-22 11:48:59 +02:00
|
|
|
startProfile(__METHOD__);
|
|
|
|
|
2012-02-15 14:17:42 +01:00
|
|
|
$oCountry = oxNew('oxcountry');
|
2013-04-22 11:21:42 +02:00
|
|
|
|
2015-06-23 11:29:07 +02:00
|
|
|
if ($this->_getModConfig()->getValue('blUseFallback')
|
|
|
|
&& $this->_getModConfig()->getValue('sFallbackCountryId')
|
|
|
|
) {
|
2013-04-22 11:21:42 +02:00
|
|
|
$oCountry->Load($this->_getModConfig()->getValue('sFallbackCountryId'));
|
2012-02-15 14:17:42 +01:00
|
|
|
}
|
2013-04-22 11:21:42 +02:00
|
|
|
|
2013-04-22 11:48:59 +02:00
|
|
|
stopProfile(__METHOD__);
|
|
|
|
|
2012-02-15 14:15:28 +01:00
|
|
|
return $oCountry;
|
|
|
|
}
|
|
|
|
|
2018-01-25 10:51:36 +01:00
|
|
|
/**
|
|
|
|
* check module active state and set user country specific language
|
|
|
|
*
|
|
|
|
* @throws d3_cfg_mod_exception
|
|
|
|
* @throws oxConnectionException
|
|
|
|
* @throws oxSystemComponentException
|
|
|
|
*/
|
2013-04-22 11:21:42 +02:00
|
|
|
public function setCountryLanguage()
|
|
|
|
{
|
2013-04-22 11:48:59 +02:00
|
|
|
startProfile(__METHOD__);
|
|
|
|
|
2013-04-22 11:21:42 +02:00
|
|
|
$this->performURLSwitch();
|
|
|
|
$this->performShopSwitch();
|
|
|
|
|
2015-06-23 11:29:07 +02:00
|
|
|
if (!$this->_getModConfig()->isActive()
|
|
|
|
|| false == $this->_getModConfig()->getValue('blChangeLang')) {
|
2013-04-22 11:48:59 +02:00
|
|
|
stopProfile(__METHOD__);
|
2013-04-22 11:21:42 +02:00
|
|
|
return;
|
2013-04-22 11:48:59 +02:00
|
|
|
}
|
2013-04-22 11:21:42 +02:00
|
|
|
|
|
|
|
$oCountry = $this->getUserLocationCountryObject();
|
|
|
|
|
2015-06-23 11:29:07 +02:00
|
|
|
if (!$this->isAdmin()
|
|
|
|
&& oxRegistry::getUtils()->isSearchEngine() === false
|
2017-03-03 08:55:15 +01:00
|
|
|
&& oxRegistry::getSession()->getId()
|
2015-06-23 11:29:07 +02:00
|
|
|
&& oxRegistry::getSession()->getVariable('d3isSetLang') === null
|
|
|
|
&& $oCountry->getId() && $oCountry->getFieldData('d3geoiplang') > -1
|
|
|
|
) {
|
|
|
|
$this->_getLog()->log(
|
|
|
|
d3log::INFO,
|
|
|
|
__CLASS__,
|
|
|
|
__FUNCTION__,
|
|
|
|
__LINE__,
|
|
|
|
'set language',
|
|
|
|
$this->getIP().' => '.$oCountry->getFieldData('d3geoiplang')
|
|
|
|
);
|
2013-04-22 11:40:11 +02:00
|
|
|
oxRegistry::getLang()->setTplLanguage((int) $oCountry->getFieldData('d3geoiplang'));
|
|
|
|
oxRegistry::getLang()->setBaseLanguage((int) $oCountry->getFieldData('d3geoiplang'));
|
|
|
|
oxRegistry::getSession()->setVariable('d3isSetLang', true);
|
2013-04-22 11:21:42 +02:00
|
|
|
}
|
2013-04-22 11:48:59 +02:00
|
|
|
|
|
|
|
stopProfile(__METHOD__);
|
2013-04-22 11:21:42 +02:00
|
|
|
}
|
|
|
|
|
2018-01-25 10:51:36 +01:00
|
|
|
/**
|
|
|
|
* check module active state and set user country specific currency
|
|
|
|
*
|
|
|
|
* @throws d3_cfg_mod_exception
|
|
|
|
* @throws oxConnectionException
|
|
|
|
* @throws oxSystemComponentException
|
|
|
|
*/
|
2013-04-22 11:21:42 +02:00
|
|
|
public function setCountryCurrency()
|
|
|
|
{
|
2015-06-23 11:29:07 +02:00
|
|
|
if (!$this->_getModConfig()->isActive()
|
|
|
|
|| false == $this->_getModConfig()->getValue('blChangeCurr')
|
|
|
|
) {
|
2013-04-22 11:21:42 +02:00
|
|
|
return;
|
2015-06-23 11:29:07 +02:00
|
|
|
}
|
2013-04-22 11:21:42 +02:00
|
|
|
|
2013-04-22 11:48:59 +02:00
|
|
|
startProfile(__METHOD__);
|
|
|
|
|
2013-04-22 11:21:42 +02:00
|
|
|
$oCountry = $this->getUserLocationCountryObject();
|
|
|
|
|
2015-06-23 11:29:07 +02:00
|
|
|
if (!$this->isAdmin()
|
|
|
|
&& oxRegistry::getUtils()->isSearchEngine() === false
|
|
|
|
&& !oxRegistry::getSession()->getVariable('d3isSetCurr')
|
|
|
|
&& $oCountry->getId()
|
|
|
|
&& $oCountry->getFieldData('d3geoipcur') > -1
|
|
|
|
) {
|
|
|
|
$this->_getLog()->log(
|
|
|
|
d3log::INFO,
|
|
|
|
__CLASS__,
|
|
|
|
__FUNCTION__,
|
|
|
|
__LINE__,
|
|
|
|
'set currency',
|
|
|
|
$this->getIP().' => '.$oCountry->getFieldData('d3geoipcur')
|
|
|
|
);
|
2013-04-22 11:40:11 +02:00
|
|
|
oxRegistry::getConfig()->setActShopCurrency((int) $oCountry->getFieldData('d3geoipcur'));
|
|
|
|
oxRegistry::getSession()->setVariable('d3isSetCurr', true);
|
2013-04-22 11:21:42 +02:00
|
|
|
}
|
2013-04-22 11:48:59 +02:00
|
|
|
|
|
|
|
stopProfile(__METHOD__);
|
2013-04-22 11:21:42 +02:00
|
|
|
}
|
|
|
|
|
2018-01-25 10:51:36 +01:00
|
|
|
/**
|
|
|
|
* @param $oCurr
|
|
|
|
*
|
|
|
|
* @return bool
|
|
|
|
* @throws d3_cfg_mod_exception
|
|
|
|
* @throws oxConnectionException
|
|
|
|
* @throws oxSystemComponentException
|
|
|
|
*/
|
2016-02-25 17:47:32 +01:00
|
|
|
public function hasNotSetCurrency($oCurr)
|
|
|
|
{
|
|
|
|
$oCountry = $this->getUserLocationCountryObject();
|
|
|
|
if ($oCountry->getFieldData('d3geoipcur') > 0
|
|
|
|
&& $oCurr->id != $oCountry->getFieldData('d3geoipcur')
|
|
|
|
) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-01-25 10:51:36 +01:00
|
|
|
/**
|
|
|
|
* check module active state and perform switching to user country specific shop (EE only)
|
|
|
|
*
|
|
|
|
* @throws d3_cfg_mod_exception
|
|
|
|
* @throws oxConnectionException
|
|
|
|
* @throws oxSystemComponentException
|
|
|
|
*/
|
2013-04-22 11:21:42 +02:00
|
|
|
public function performShopSwitch()
|
|
|
|
{
|
2015-06-23 11:29:07 +02:00
|
|
|
if (!$this->_getModConfig()->isActive() || !$this->_getModConfig()->getValue('blChangeShop')) {
|
2013-04-22 11:21:42 +02:00
|
|
|
return;
|
2015-06-23 11:29:07 +02:00
|
|
|
}
|
2013-04-22 11:21:42 +02:00
|
|
|
|
2013-04-22 11:48:59 +02:00
|
|
|
startProfile(__METHOD__);
|
2013-04-22 11:21:42 +02:00
|
|
|
|
2013-04-22 11:48:59 +02:00
|
|
|
$oCountry = $this->getUserLocationCountryObject();
|
2013-04-22 11:21:42 +02:00
|
|
|
$iNewShop = $oCountry->getFieldData('d3geoipshop');
|
|
|
|
|
2015-06-23 11:29:07 +02:00
|
|
|
if (oxRegistry::getConfig()->getRequestParameter('d3redirect') != 1
|
|
|
|
&& false == $this->isAdmin()
|
|
|
|
&& oxRegistry::getUtils()->isSearchEngine() === false
|
|
|
|
&& $oCountry->getId()
|
|
|
|
&& $this->getConfig()->isMall()
|
|
|
|
&& $iNewShop > -1 &&
|
2013-04-22 11:48:59 +02:00
|
|
|
(
|
2015-06-23 11:29:07 +02:00
|
|
|
$iNewShop != $this->getConfig()->getShopId()
|
|
|
|
|| strtolower($this->getConfig()->getActiveView()->getClassName()) == 'mallstart'
|
2013-04-22 11:48:59 +02:00
|
|
|
)
|
2015-06-23 11:29:07 +02:00
|
|
|
) {
|
2013-04-22 11:21:42 +02:00
|
|
|
$oNewConf = new oxConfig();
|
|
|
|
$oNewConf->setShopId($iNewShop);
|
|
|
|
$oNewConf->init();
|
|
|
|
|
|
|
|
$this->getConfig()->onShopChange();
|
|
|
|
|
2015-06-23 11:29:07 +02:00
|
|
|
if (!oxRegistry::getSession()->getVariable('d3isSetLang')
|
|
|
|
&& $this->_getModConfig()->getValue('blChangeLang')
|
|
|
|
&& $oCountry->getFieldData('d3geoiplang') > -1
|
|
|
|
) {
|
2013-04-22 11:21:42 +02:00
|
|
|
$sLangId = $oCountry->getFieldData('d3geoiplang');
|
2015-06-23 11:29:07 +02:00
|
|
|
} else {
|
2013-04-22 11:21:42 +02:00
|
|
|
$sLangId = '';
|
2013-04-22 11:40:11 +02:00
|
|
|
}
|
2013-04-22 11:21:42 +02:00
|
|
|
|
2013-04-22 11:48:59 +02:00
|
|
|
/** @var $oStr d3str */
|
|
|
|
$oStr = oxRegistry::get('d3str');
|
|
|
|
$aParams = array(
|
|
|
|
'd3redirect' => '1',
|
|
|
|
'fnc' => oxRegistry::getConfig()->getRequestParameter('fnc'),
|
|
|
|
'shp' => $iNewShop
|
|
|
|
);
|
2015-06-23 11:29:07 +02:00
|
|
|
$sUrl = str_replace(
|
|
|
|
'&',
|
|
|
|
'&',
|
|
|
|
$oStr->generateParameterUrl($oNewConf->getShopHomeUrl($sLangId), $aParams)
|
|
|
|
);
|
2013-04-22 11:48:59 +02:00
|
|
|
|
2015-06-23 11:29:07 +02:00
|
|
|
$this->_getLog()->log(
|
|
|
|
d3log::INFO,
|
|
|
|
__CLASS__,
|
|
|
|
__FUNCTION__,
|
|
|
|
__LINE__,
|
|
|
|
'change shop',
|
|
|
|
$this->getIP().' => '.$sUrl
|
|
|
|
);
|
2013-04-22 11:21:42 +02:00
|
|
|
|
2013-04-22 11:48:59 +02:00
|
|
|
header("Location: ".$sUrl);
|
2013-04-22 11:21:42 +02:00
|
|
|
exit();
|
|
|
|
}
|
2013-04-22 11:48:59 +02:00
|
|
|
|
|
|
|
stopProfile(__METHOD__);
|
2013-04-22 11:21:42 +02:00
|
|
|
}
|
|
|
|
|
2018-01-25 10:51:36 +01:00
|
|
|
/**
|
|
|
|
* check module active state and perform switching to user country specific url
|
|
|
|
*
|
|
|
|
* @throws d3_cfg_mod_exception
|
|
|
|
* @throws oxConnectionException
|
|
|
|
* @throws oxSystemComponentException
|
|
|
|
*/
|
2013-04-22 11:21:42 +02:00
|
|
|
public function performURLSwitch()
|
|
|
|
{
|
2015-06-23 11:29:07 +02:00
|
|
|
if (!$this->_getModConfig()->isActive()
|
|
|
|
|| false == $this->_getModConfig()->getValue('blChangeURL')) {
|
2013-04-22 11:21:42 +02:00
|
|
|
return;
|
2013-04-22 11:40:11 +02:00
|
|
|
}
|
2013-04-22 11:21:42 +02:00
|
|
|
|
2013-04-22 11:48:59 +02:00
|
|
|
startProfile(__METHOD__);
|
|
|
|
|
2013-04-22 11:21:42 +02:00
|
|
|
$oCountry = $this->getUserLocationCountryObject();
|
|
|
|
|
2015-06-23 11:29:07 +02:00
|
|
|
if (false == $this->isAdmin()
|
|
|
|
&& oxRegistry::getUtils()->isSearchEngine() === false
|
|
|
|
&& $oCountry->getId()
|
|
|
|
&& $oCountry->getFieldData('d3geoipurl')
|
|
|
|
&& strlen(trim($oCountry->getFieldData('d3geoipurl'))) > 0
|
|
|
|
) {
|
2013-04-22 11:21:42 +02:00
|
|
|
$sNewUrl = $oCountry->getFieldData('d3geoipurl');
|
|
|
|
|
2015-06-23 11:29:07 +02:00
|
|
|
$this->_getLog()->log(
|
|
|
|
d3log::INFO,
|
|
|
|
__CLASS__,
|
|
|
|
__FUNCTION__,
|
|
|
|
__LINE__,
|
|
|
|
'change url',
|
|
|
|
$this->getIP().' => '.$oCountry->getFieldData('d3geoipurl')
|
|
|
|
);
|
2013-04-22 11:21:42 +02:00
|
|
|
|
|
|
|
header("Location: ".$sNewUrl);
|
|
|
|
exit();
|
|
|
|
}
|
2013-04-22 11:48:59 +02:00
|
|
|
|
|
|
|
stopProfile(__METHOD__);
|
2013-04-22 11:21:42 +02:00
|
|
|
}
|
|
|
|
|
2018-01-25 10:51:36 +01:00
|
|
|
/**
|
|
|
|
* get all shop urls
|
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
* @throws oxSystemComponentException
|
|
|
|
*/
|
2013-04-22 11:21:42 +02:00
|
|
|
public function getShopUrls()
|
|
|
|
{
|
2013-04-22 11:48:59 +02:00
|
|
|
startProfile(__METHOD__);
|
|
|
|
|
2015-06-23 11:29:07 +02:00
|
|
|
$oShoplist = oxNew('oxshoplist');
|
2013-04-22 11:21:42 +02:00
|
|
|
$oShoplist->getList();
|
|
|
|
$aShopUrls = array();
|
2015-06-23 11:29:07 +02:00
|
|
|
|
2015-07-21 21:12:55 +02:00
|
|
|
foreach ($oShoplist->arrayKeys() as $sId) {
|
2015-06-23 11:29:07 +02:00
|
|
|
$aShopUrls[$sId] = $this->getConfig()->getShopConfVar('sMallShopURL', $sId);
|
2013-04-22 11:21:42 +02:00
|
|
|
}
|
|
|
|
|
2013-04-22 11:48:59 +02:00
|
|
|
stopProfile(__METHOD__);
|
|
|
|
|
2013-04-22 11:21:42 +02:00
|
|
|
return $aShopUrls;
|
|
|
|
}
|
|
|
|
|
2018-01-25 10:51:36 +01:00
|
|
|
/**
|
|
|
|
* get modcfg instance
|
|
|
|
*
|
|
|
|
* @return d3_cfg_mod
|
|
|
|
* @throws d3_cfg_mod_exception
|
|
|
|
*/
|
2013-04-22 11:21:42 +02:00
|
|
|
protected function _getModConfig()
|
|
|
|
{
|
|
|
|
return d3_cfg_mod::get($this->_sModId);
|
|
|
|
}
|
|
|
|
|
2018-01-25 10:51:36 +01:00
|
|
|
/**
|
|
|
|
* get d3log instance
|
|
|
|
*
|
|
|
|
* @return d3log
|
|
|
|
* @throws d3_cfg_mod_exception
|
|
|
|
*/
|
2013-04-22 11:21:42 +02:00
|
|
|
protected function _getLog()
|
|
|
|
{
|
2015-06-23 11:29:07 +02:00
|
|
|
if (!$this->oD3Log) {
|
|
|
|
$this->oD3Log = $this->_getModConfig()->d3getLog();
|
2013-04-22 11:40:11 +02:00
|
|
|
}
|
2013-04-22 11:21:42 +02:00
|
|
|
|
|
|
|
return $this->oD3Log;
|
|
|
|
}
|
2015-06-23 11:29:07 +02:00
|
|
|
}
|