add further ip sources
This commit is contained in:
parent
e810853a4c
commit
8f7344628c
@ -39,25 +39,20 @@ class d3GeoIP extends oxbase
|
|||||||
*/
|
*/
|
||||||
public function getUserLocationCountryObject($sIP = null)
|
public function getUserLocationCountryObject($sIP = null)
|
||||||
{
|
{
|
||||||
if (!$this->oCountry)
|
if (!$this->oCountry) {
|
||||||
{
|
|
||||||
startProfile(__METHOD__);
|
startProfile(__METHOD__);
|
||||||
|
|
||||||
if (!$sIP)
|
if (!$sIP) {
|
||||||
{
|
|
||||||
$sIP = $this->getIP();
|
$sIP = $this->getIP();
|
||||||
}
|
}
|
||||||
|
|
||||||
$iIPNum = $this->_getNumIp($sIP);
|
$iIPNum = $this->_getNumIp($sIP);
|
||||||
$sISOAlpha = $this->LoadByIPNum($iIPNum);
|
$sISOAlpha = $this->LoadByIPNum($iIPNum);
|
||||||
|
|
||||||
if (!$sISOAlpha)
|
if (!$sISOAlpha) {
|
||||||
{
|
|
||||||
$this->_getLog()->log(d3log::ERROR, __CLASS__, __FUNCTION__, __LINE__, 'get ISO by IP failed', $sIP);
|
$this->_getLog()->log(d3log::ERROR, __CLASS__, __FUNCTION__, __LINE__, 'get ISO by IP failed', $sIP);
|
||||||
$this->oCountry = $this->getCountryFallBackObject();
|
$this->oCountry = $this->getCountryFallBackObject();
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$this->_getLog()->log(d3log::INFO, __CLASS__, __FUNCTION__, __LINE__, 'get ISO by IP', $sIP." => ".$sISOAlpha);
|
$this->_getLog()->log(d3log::INFO, __CLASS__, __FUNCTION__, __LINE__, 'get ISO by IP', $sIP." => ".$sISOAlpha);
|
||||||
$this->oCountry = $this->getCountryObject($sISOAlpha);
|
$this->oCountry = $this->getCountryObject($sISOAlpha);
|
||||||
}
|
}
|
||||||
@ -77,18 +72,30 @@ class d3GeoIP extends oxbase
|
|||||||
{
|
{
|
||||||
startProfile(__METHOD__);
|
startProfile(__METHOD__);
|
||||||
|
|
||||||
if ($this->_getModConfig()->getValue('blUseTestIp') && $this->_getModConfig()->getValue('sTestIp'))
|
if ($this->_getModConfig()->getValue('blUseTestIp') && $this->_getModConfig()->getValue('sTestIp')) {
|
||||||
{
|
|
||||||
$sIP = $this->_getModConfig()->getValue('sTestIp');
|
$sIP = $this->_getModConfig()->getValue('sTestIp');
|
||||||
}
|
} elseif ($this->_getModConfig()->getValue('blUseTestCountry') && $this->_getModConfig()->getValue('sTestCountryIp')) {
|
||||||
elseif ($this->_getModConfig()->getValue('blUseTestCountry') && $this->_getModConfig()->getValue('sTestCountryIp'))
|
|
||||||
{
|
|
||||||
$sIP = $this->_getModConfig()->getValue('sTestCountryIp');
|
$sIP = $this->_getModConfig()->getValue('sTestCountryIp');
|
||||||
}
|
} else {
|
||||||
else
|
if(isset($_SERVER['HTTP_CF_CONNECTING_IP'])) {
|
||||||
{
|
$sIP = $_SERVER['HTTP_CF_CONNECTING_IP'];
|
||||||
// ToDo: use $_SERVER['X-Forwared-For'] && Client-IP in case of proxy
|
} else if (isset($_SERVER['HTTP_X_REAL_IP'])) {
|
||||||
$sIP = $_SERVER['REMOTE_ADDR'];
|
$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';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stopProfile(__METHOD__);
|
stopProfile(__METHOD__);
|
||||||
@ -105,33 +112,30 @@ class d3GeoIP extends oxbase
|
|||||||
protected function _getNumIp($sIP)
|
protected function _getNumIp($sIP)
|
||||||
{
|
{
|
||||||
// make sure it is an ip
|
// make sure it is an ip
|
||||||
if (filter_var($sIP, FILTER_VALIDATE_IP) === FALSE)
|
if (filter_var($sIP, FILTER_VALIDATE_IP) === false) {
|
||||||
return FALSE;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
startProfile(__METHOD__);
|
startProfile(__METHOD__);
|
||||||
|
|
||||||
$parts = unpack('N*', inet_pton($sIP));
|
$parts = unpack('N*', inet_pton($sIP));
|
||||||
|
|
||||||
if (strpos($sIP, '.') !== FALSE)
|
if (strpos($sIP, '.') !== false) {
|
||||||
{
|
|
||||||
$parts = array(1=>0, 2=>0, 3=>0, 4=>$parts[1]);
|
$parts = array(1=>0, 2=>0, 3=>0, 4=>$parts[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($parts as &$part)
|
foreach ($parts as &$part) {
|
||||||
{
|
if ($part < 0) {
|
||||||
if ($part < 0)
|
|
||||||
$part += 4294967296;
|
$part += 4294967296;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (function_exists('bcadd'))
|
if (function_exists('bcadd')) {
|
||||||
{
|
|
||||||
$dIP = $parts[4];
|
$dIP = $parts[4];
|
||||||
$dIP = bcadd($dIP, bcmul($parts[3], '4294967296'));
|
$dIP = bcadd($dIP, bcmul($parts[3], '4294967296'));
|
||||||
$dIP = bcadd($dIP, bcmul($parts[2], '18446744073709551616'));
|
$dIP = bcadd($dIP, bcmul($parts[2], '18446744073709551616'));
|
||||||
$dIP = bcadd($dIP, bcmul($parts[1], '79228162514264337593543950336'));
|
$dIP = bcadd($dIP, bcmul($parts[1], '79228162514264337593543950336'));
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new Exception('extension BCMath is required');
|
throw new Exception('extension BCMath is required');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -191,8 +195,7 @@ class d3GeoIP extends oxbase
|
|||||||
|
|
||||||
$oCountry = oxNew('oxcountry');
|
$oCountry = oxNew('oxcountry');
|
||||||
|
|
||||||
if ($this->_getModConfig()->getValue('blUseFallback') && $this->_getModConfig()->getValue('sFallbackCountryId'))
|
if ($this->_getModConfig()->getValue('blUseFallback') && $this->_getModConfig()->getValue('sFallbackCountryId')) {
|
||||||
{
|
|
||||||
$oCountry->Load($this->_getModConfig()->getValue('sFallbackCountryId'));
|
$oCountry->Load($this->_getModConfig()->getValue('sFallbackCountryId'));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -212,16 +215,19 @@ class d3GeoIP extends oxbase
|
|||||||
$this->performURLSwitch();
|
$this->performURLSwitch();
|
||||||
$this->performShopSwitch();
|
$this->performShopSwitch();
|
||||||
|
|
||||||
if (!$this->_getModConfig()->isActive() || !$this->_getModConfig()->getValue('blChangeLang'))
|
if (!$this->_getModConfig()->isActive() || !$this->_getModConfig()->getValue('blChangeLang')) {
|
||||||
{
|
|
||||||
stopProfile(__METHOD__);
|
stopProfile(__METHOD__);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$oCountry = $this->getUserLocationCountryObject();
|
$oCountry = $this->getUserLocationCountryObject();
|
||||||
|
|
||||||
if (!$this->isAdmin() && oxRegistry::getUtils()->isSearchEngine() === false && oxRegistry::getSession()->getVariable('d3isSetLang') === null && $oCountry->getId() && $oCountry->getFieldData('d3geoiplang') > -1)
|
if (!$this->isAdmin()
|
||||||
{
|
&& oxRegistry::getUtils()->isSearchEngine() === false
|
||||||
|
&& 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'));
|
$this->_getLog()->log(d3log::INFO, __CLASS__, __FUNCTION__, __LINE__, 'set language', $this->getIP().' => '.$oCountry->getFieldData('d3geoiplang'));
|
||||||
oxRegistry::getLang()->setTplLanguage((int) $oCountry->getFieldData('d3geoiplang'));
|
oxRegistry::getLang()->setTplLanguage((int) $oCountry->getFieldData('d3geoiplang'));
|
||||||
oxRegistry::getLang()->setBaseLanguage((int) $oCountry->getFieldData('d3geoiplang'));
|
oxRegistry::getLang()->setBaseLanguage((int) $oCountry->getFieldData('d3geoiplang'));
|
||||||
@ -237,15 +243,20 @@ class d3GeoIP extends oxbase
|
|||||||
*/
|
*/
|
||||||
public function setCountryCurrency()
|
public function setCountryCurrency()
|
||||||
{
|
{
|
||||||
if (!$this->_getModConfig()->isActive() || !$this->_getModConfig()->getValue('blChangeCurr'))
|
if (!$this->_getModConfig()->isActive() || !$this->_getModConfig()->getValue('blChangeCurr')) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
startProfile(__METHOD__);
|
startProfile(__METHOD__);
|
||||||
|
|
||||||
$oCountry = $this->getUserLocationCountryObject();
|
$oCountry = $this->getUserLocationCountryObject();
|
||||||
|
|
||||||
if (!$this->isAdmin() && oxRegistry::getUtils()->isSearchEngine() === false && !oxRegistry::getSession()->getVariable('d3isSetCurr') && $oCountry->getId() && $oCountry->getFieldData('d3geoipcur') > -1)
|
if (!$this->isAdmin()
|
||||||
{
|
&& oxRegistry::getUtils()->isSearchEngine() === false
|
||||||
|
&& 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'));
|
$this->_getLog()->log(d3log::INFO, __CLASS__, __FUNCTION__, __LINE__, 'set currency', $this->getIP().' => '.$oCountry->getFieldData('d3geoipcur'));
|
||||||
oxRegistry::getConfig()->setActShopCurrency((int) $oCountry->getFieldData('d3geoipcur'));
|
oxRegistry::getConfig()->setActShopCurrency((int) $oCountry->getFieldData('d3geoipcur'));
|
||||||
oxRegistry::getSession()->setVariable('d3isSetCurr', true);
|
oxRegistry::getSession()->setVariable('d3isSetCurr', true);
|
||||||
@ -260,26 +271,26 @@ class d3GeoIP extends oxbase
|
|||||||
*/
|
*/
|
||||||
public function performShopSwitch()
|
public function performShopSwitch()
|
||||||
{
|
{
|
||||||
if (!$this->_getModConfig()->isActive() || !$this->_getModConfig()->getValue('blChangeShop'))
|
if (!$this->_getModConfig()->isActive() || !$this->_getModConfig()->getValue('blChangeShop')) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
startProfile(__METHOD__);
|
startProfile(__METHOD__);
|
||||||
|
|
||||||
$oCountry = $this->getUserLocationCountryObject();
|
$oCountry = $this->getUserLocationCountryObject();
|
||||||
$iNewShop = $oCountry->getFieldData('d3geoipshop');
|
$iNewShop = $oCountry->getFieldData('d3geoipshop');
|
||||||
|
|
||||||
if (oxRegistry::getConfig()->getRequestParameter('d3redirect') != 1 &&
|
if (oxRegistry::getConfig()->getRequestParameter('d3redirect') != 1
|
||||||
!$this->isAdmin() &&
|
&& false == $this->isAdmin()
|
||||||
oxRegistry::getUtils()->isSearchEngine() === false &&
|
&& oxRegistry::getUtils()->isSearchEngine() === false
|
||||||
$oCountry->getId() &&
|
&& $oCountry->getId()
|
||||||
$this->getConfig()->isMall() &&
|
&& $this->getConfig()->isMall()
|
||||||
$iNewShop > -1 &&
|
&& $iNewShop > -1
|
||||||
(
|
&& (
|
||||||
$iNewShop != $this->getConfig()->getShopId() ||
|
$iNewShop != $this->getConfig()->getShopId()
|
||||||
strtolower($this->getConfig()->getActiveView()->getClassName()) == 'mallstart'
|
|| strtolower($this->getConfig()->getActiveView()->getClassName()) == 'mallstart'
|
||||||
)
|
)
|
||||||
)
|
) {
|
||||||
{
|
|
||||||
$oNewConf = new oxConfig();
|
$oNewConf = new oxConfig();
|
||||||
$oNewConf->setShopId($iNewShop);
|
$oNewConf->setShopId($iNewShop);
|
||||||
$oNewConf->init();
|
$oNewConf->init();
|
||||||
@ -288,12 +299,10 @@ class d3GeoIP extends oxbase
|
|||||||
|
|
||||||
if (!oxRegistry::getSession()->getVariable('d3isSetLang') &&
|
if (!oxRegistry::getSession()->getVariable('d3isSetLang') &&
|
||||||
$this->_getModConfig()->getValue('blChangeLang') &&
|
$this->_getModConfig()->getValue('blChangeLang') &&
|
||||||
$oCountry->getFieldData('d3geoiplang') > -1)
|
$oCountry->getFieldData('d3geoiplang') > -1
|
||||||
{
|
) {
|
||||||
$sLangId = $oCountry->getFieldData('d3geoiplang');
|
$sLangId = $oCountry->getFieldData('d3geoiplang');
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$sLangId = '';
|
$sLangId = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -321,8 +330,7 @@ class d3GeoIP extends oxbase
|
|||||||
*/
|
*/
|
||||||
public function performURLSwitch()
|
public function performURLSwitch()
|
||||||
{
|
{
|
||||||
if (!$this->_getModConfig()->isActive() || !$this->_getModConfig()->getValue('blChangeURL'))
|
if (!$this->_getModConfig()->isActive() || !$this->_getModConfig()->getValue('blChangeURL')) {
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -335,8 +343,7 @@ class d3GeoIP extends oxbase
|
|||||||
$oCountry->getId() &&
|
$oCountry->getId() &&
|
||||||
$oCountry->getFieldData('d3geoipurl') &&
|
$oCountry->getFieldData('d3geoipurl') &&
|
||||||
strlen(trim($oCountry->getFieldData('d3geoipurl'))) > 0
|
strlen(trim($oCountry->getFieldData('d3geoipurl'))) > 0
|
||||||
)
|
) {
|
||||||
{
|
|
||||||
$sNewUrl = $oCountry->getFieldData('d3geoipurl');
|
$sNewUrl = $oCountry->getFieldData('d3geoipurl');
|
||||||
|
|
||||||
$this->_getLog()->log(d3log::INFO, __CLASS__, __FUNCTION__, __LINE__, 'change url', $this->getIP().' => '.$oCountry->getFieldData('d3geoipurl'));
|
$this->_getLog()->log(d3log::INFO, __CLASS__, __FUNCTION__, __LINE__, 'change url', $this->getIP().' => '.$oCountry->getFieldData('d3geoipurl'));
|
||||||
@ -360,8 +367,7 @@ class d3GeoIP extends oxbase
|
|||||||
$oShoplist = oxNew( 'oxshoplist' );
|
$oShoplist = oxNew( 'oxshoplist' );
|
||||||
$oShoplist->getList();
|
$oShoplist->getList();
|
||||||
$aShopUrls = array();
|
$aShopUrls = array();
|
||||||
foreach ( $oShoplist as $sId => $oShop )
|
foreach ($oShoplist as $sId => $oShop) {
|
||||||
{
|
|
||||||
$aShopUrls[$sId] = $this->getConfig()->getShopConfVar( 'sMallShopURL', $sId );
|
$aShopUrls[$sId] = $this->getConfig()->getShopConfVar( 'sMallShopURL', $sId );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -387,8 +393,7 @@ class d3GeoIP extends oxbase
|
|||||||
*/
|
*/
|
||||||
protected function _getLog()
|
protected function _getLog()
|
||||||
{
|
{
|
||||||
if (!$this->oD3Log)
|
if (!$this->oD3Log) {
|
||||||
{
|
|
||||||
$this->oD3Log = $this->_getModConfig()->getLog();
|
$this->oD3Log = $this->_getModConfig()->getLog();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
=> 3.0.1.0
|
||||||
|
- weitere IP-Quellen eingefügt
|
||||||
|
|
||||||
=> 3.0.0.2
|
=> 3.0.0.2
|
||||||
- auf Kompatibilität mit Shopversion 4.8.3 geprüft
|
- auf Kompatibilität mit Shopversion 4.8.3 geprüft
|
||||||
- Modulstruktur aktualisiert
|
- Modulstruktur aktualisiert
|
||||||
|
Loading…
x
Reference in New Issue
Block a user