add further feature requirements
This commit is contained in:
parent
0fa7393436
commit
224a0a97bf
@ -1,36 +1,36 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
class d3GeoIP extends oxI18n
|
class d3GeoIP extends oxI18n
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Current class name
|
* Current class name
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $_sClassName = 'd3geoip';
|
protected $_sClassName = 'd3geoip';
|
||||||
|
|
||||||
private $_sModId = 'd3_geoip';
|
private $_sModId = 'd3_geoip';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class constructor, initiates parent constructor (parent::oxI18n()).
|
* Class constructor, initiates parent constructor (parent::oxI18n()).
|
||||||
*
|
*
|
||||||
* @return null
|
* @return null
|
||||||
*/
|
*/
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
$this->init('d3geoip');
|
$this->init('d3geoip');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getUserLocationCountryObject($sIP = false)
|
public function getUserLocationCountryObject($sIP = false)
|
||||||
{
|
{
|
||||||
if (!$this->oCountry)
|
if (!$this->oCountry)
|
||||||
{
|
{
|
||||||
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)
|
||||||
{
|
{
|
||||||
@ -42,10 +42,10 @@ class d3GeoIP extends oxI18n
|
|||||||
$this->_getLog()->setLog('info', __CLASS__, __FUNCTION__, __LINE__, 'get ISO by IP', $sIP." => ".$sISOAlpha);
|
$this->_getLog()->setLog('info', __CLASS__, __FUNCTION__, __LINE__, 'get ISO by IP', $sIP." => ".$sISOAlpha);
|
||||||
$this->oCountry = $this->getCountryObject($sISOAlpha);
|
$this->oCountry = $this->getCountryObject($sISOAlpha);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->oCountry;
|
return $this->oCountry;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getIP()
|
public function getIP()
|
||||||
{
|
{
|
||||||
@ -54,108 +54,108 @@ class d3GeoIP extends oxI18n
|
|||||||
else
|
else
|
||||||
return $_SERVER['REMOTE_ADDR'];
|
return $_SERVER['REMOTE_ADDR'];
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function _getNumIp($sIP)
|
protected function _getNumIp($sIP)
|
||||||
{
|
{
|
||||||
$aIP = explode('.',$sIP);
|
$aIP = explode('.',$sIP);
|
||||||
$iIP = ($aIP[0] * 16777216) + ($aIP[1] * 65536) + ($aIP[2] * 256) + ($aIP[3] * 1);
|
$iIP = ($aIP[0] * 16777216) + ($aIP[1] * 65536) + ($aIP[2] * 256) + ($aIP[3] * 1);
|
||||||
return $iIP;
|
return $iIP;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function LoadByIPNum($iIPNum)
|
public function LoadByIPNum($iIPNum)
|
||||||
{
|
{
|
||||||
$sSelect = "SELECT d3iso FROM ".$this->_sClassName." WHERE d3startipnum <= '$iIPNum' AND d3endipnum >= '$iIPNum'";
|
$sSelect = "SELECT d3iso FROM ".$this->_sClassName." WHERE d3startipnum <= '$iIPNum' AND d3endipnum >= '$iIPNum'";
|
||||||
return oxDb::getDb()->getOne($sSelect);
|
return oxDb::getDb()->getOne($sSelect);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCountryObject($sISOAlpha)
|
public function getCountryObject($sISOAlpha)
|
||||||
{
|
{
|
||||||
$oCountry = &oxNew('oxcountry');
|
$oCountry = &oxNew('oxcountry');
|
||||||
$sSelect = "SELECT oxid FROM ".$oCountry->getViewName()." WHERE OXISOALPHA2 = '".$sISOAlpha."' AND OXACTIVE = '1'";
|
$sSelect = "SELECT oxid FROM ".$oCountry->getViewName()." WHERE OXISOALPHA2 = '".$sISOAlpha."' AND OXACTIVE = '1'";
|
||||||
$oCountry->load(oxDb::getDb()->getOne($sSelect));
|
$oCountry->load(oxDb::getDb()->getOne($sSelect));
|
||||||
|
|
||||||
return $oCountry;
|
return $oCountry;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
public function setUserCountry()
|
public function setUserCountry()
|
||||||
{
|
{
|
||||||
if (!$this->getUser()) {
|
if (!$this->getUser()) {
|
||||||
$oCountry = $this->getUserLocationCountryObject();
|
$oCountry = $this->getUserLocationCountryObject();
|
||||||
$oUser = &oxNew('oxuser');
|
$oUser = &oxNew('oxuser');
|
||||||
$oUser->oxuser__oxcountryid = oxNew('oxfield');
|
$oUser->oxuser__oxcountryid = oxNew('oxfield');
|
||||||
$oUser->oxuser__oxcountryid->setValue($oCountry->getId());
|
$oUser->oxuser__oxcountryid->setValue($oCountry->getId());
|
||||||
$this->setUser($oUser);
|
$this->setUser($oUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public function setCountryLanguage()
|
public function setCountryLanguage()
|
||||||
{
|
{
|
||||||
$this->performURLSwitch();
|
$this->performURLSwitch();
|
||||||
$this->performShopSwitch();
|
$this->performShopSwitch();
|
||||||
|
|
||||||
if (!$this->_getConfig()->getFieldData('oxactive') || !$this->_getConfig()->getValue('blChangeLang'))
|
if (!$this->_getConfig()->getFieldData('oxactive') || !$this->_getConfig()->getValue('blChangeLang'))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
$oCountry = $this->getUserLocationCountryObject();
|
$oCountry = $this->getUserLocationCountryObject();
|
||||||
|
|
||||||
if (!$this->isAdmin() && oxUtils::getInstance()->isSearchEngine() === false && $this->getSession()->getVar('d3isSetLang') === null && $oCountry->getId() && $oCountry->getFieldData('d3geoiplang') > -1)
|
if (!$this->isAdmin() && oxUtils::getInstance()->isSearchEngine() === false && $this->getSession()->getVar('d3isSetLang') === null && $oCountry->getId() && $oCountry->getFieldData('d3geoiplang') > -1)
|
||||||
{
|
{
|
||||||
$this->_getLog()->setLog('info', __CLASS__, __FUNCTION__, __LINE__, 'set language', $this->getIP().' => '.$oCountry->getFieldData('d3geoiplang'));
|
$this->_getLog()->setLog('info', __CLASS__, __FUNCTION__, __LINE__, 'set language', $this->getIP().' => '.$oCountry->getFieldData('d3geoiplang'));
|
||||||
oxLang::getInstance()->setTplLanguage((int) $oCountry->getFieldData('d3geoiplang'));
|
oxLang::getInstance()->setTplLanguage((int) $oCountry->getFieldData('d3geoiplang'));
|
||||||
oxLang::getInstance()->setBaseLanguage((int) $oCountry->getFieldData('d3geoiplang'));
|
oxLang::getInstance()->setBaseLanguage((int) $oCountry->getFieldData('d3geoiplang'));
|
||||||
$this->getSession()->setVar('d3isSetLang', true);
|
$this->getSession()->setVar('d3isSetLang', true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setCountryCurrency()
|
public function setCountryCurrency()
|
||||||
{
|
{
|
||||||
if (!$this->_getConfig()->getFieldData('oxactive') || !$this->_getConfig()->getValue('blChangeCurr'))
|
if (!$this->_getConfig()->getFieldData('oxactive') || !$this->_getConfig()->getValue('blChangeCurr'))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
$oCountry = $this->getUserLocationCountryObject();
|
$oCountry = $this->getUserLocationCountryObject();
|
||||||
|
|
||||||
if (!$this->isAdmin() && oxUtils::getInstance()->isSearchEngine() === false && !$this->getSession()->getVar('d3isSetCurr') && $oCountry->getId() && $oCountry->getFieldData('d3geoipcur') > -1)
|
if (!$this->isAdmin() && oxUtils::getInstance()->isSearchEngine() === false && !$this->getSession()->getVar('d3isSetCurr') && $oCountry->getId() && $oCountry->getFieldData('d3geoipcur') > -1)
|
||||||
{
|
{
|
||||||
$this->_getLog()->setLog('info', __CLASS__, __FUNCTION__, __LINE__, 'set currency', $this->getIP().' => '.$oCountry->getFieldData('d3geoipcur'));
|
$this->_getLog()->setLog('info', __CLASS__, __FUNCTION__, __LINE__, 'set currency', $this->getIP().' => '.$oCountry->getFieldData('d3geoipcur'));
|
||||||
$this->getConfig()->setActShopCurrency((int) $oCountry->getFieldData('d3geoipcur'));
|
$this->getConfig()->setActShopCurrency((int) $oCountry->getFieldData('d3geoipcur'));
|
||||||
$this->getSession()->setVar('d3isSetCurr', true);
|
$this->getSession()->setVar('d3isSetCurr', true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function performShopSwitch()
|
public function performShopSwitch()
|
||||||
{
|
{
|
||||||
if (!$this->_getConfig()->getFieldData('oxactive') || !$this->_getConfig()->getValue('blChangeShop'))
|
if (!$this->_getConfig()->getFieldData('oxactive') || !$this->_getConfig()->getValue('blChangeShop'))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
$oCountry = $this->getUserLocationCountryObject();
|
$oCountry = $this->getUserLocationCountryObject();
|
||||||
|
|
||||||
$iNewShop = $oCountry->getFieldData('d3geoipshop');
|
$iNewShop = $oCountry->getFieldData('d3geoipshop');
|
||||||
|
|
||||||
$aShopLinks = $this->getShopUrls();
|
$aShopLinks = $this->getShopUrls();
|
||||||
|
|
||||||
if (!$this->isAdmin() && oxUtils::getInstance()->isSearchEngine() === false && $oCountry->getId() && $this->getConfig()->isMall() && $iNewShop > -1 && $iNewShop != $this->getConfig()->getShopId())
|
if (!$this->isAdmin() && oxUtils::getInstance()->isSearchEngine() === false && $oCountry->getId() && $this->getConfig()->isMall() && $iNewShop > -1 && $iNewShop != $this->getConfig()->getShopId())
|
||||||
{
|
{
|
||||||
$oNewConf = new oxConfig();
|
$oNewConf = new oxConfig();
|
||||||
$oNewConf->setShopId($iNewShop);
|
$oNewConf->setShopId($iNewShop);
|
||||||
$oNewConf->init();
|
$oNewConf->init();
|
||||||
|
|
||||||
$this->getConfig()->onShopChange();
|
$this->getConfig()->onShopChange();
|
||||||
|
|
||||||
if (!$this->getSession()->getVar('d3isSetLang') && $oCountry->getFieldData('d3geoiplang') > -1)
|
if (!$this->getSession()->getVar('d3isSetLang') && $oCountry->getFieldData('d3geoiplang') > -1)
|
||||||
$sLangId = $oCountry->getFieldData('d3geoiplang');
|
$sLangId = $oCountry->getFieldData('d3geoiplang');
|
||||||
else
|
else
|
||||||
$sLangId = '';
|
$sLangId = '';
|
||||||
|
|
||||||
$this->_getLog()->setLog('info', __CLASS__, __FUNCTION__, __LINE__, 'change shop', $this->getIP().' => '.$oNewConf->getShopHomeUrl($sLangId));
|
$this->_getLog()->setLog('info', __CLASS__, __FUNCTION__, __LINE__, 'change shop', $this->getIP().' => '.$oNewConf->getShopHomeUrl($sLangId));
|
||||||
|
|
||||||
header("Location: ".$oNewConf->getShopHomeUrl($sLangId));
|
header("Location: ".$oNewConf->getShopHomeUrl($sLangId));
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function performURLSwitch()
|
public function performURLSwitch()
|
||||||
{
|
{
|
||||||
@ -167,7 +167,7 @@ class d3GeoIP extends oxI18n
|
|||||||
if (!$this->isAdmin() && oxUtils::getInstance()->isSearchEngine() === false && $oCountry->getId() && $oCountry->getFieldData('d3geoipurl') && strlen(trim($oCountry->getFieldData('d3geoipurl'))) > 0)
|
if (!$this->isAdmin() && oxUtils::getInstance()->isSearchEngine() === false && $oCountry->getId() && $oCountry->getFieldData('d3geoipurl') && strlen(trim($oCountry->getFieldData('d3geoipurl'))) > 0)
|
||||||
{
|
{
|
||||||
$sNewUrl = $oCountry->getFieldData('d3geoipurl');
|
$sNewUrl = $oCountry->getFieldData('d3geoipurl');
|
||||||
|
|
||||||
$this->_getLog()->setLog('info', __CLASS__, __FUNCTION__, __LINE__, 'change url', $this->getIP().' => '.$oCountry->getFieldData('d3geoipurl'));
|
$this->_getLog()->setLog('info', __CLASS__, __FUNCTION__, __LINE__, 'change url', $this->getIP().' => '.$oCountry->getFieldData('d3geoipurl'));
|
||||||
|
|
||||||
header("Location: ".$sNewUrl);
|
header("Location: ".$sNewUrl);
|
||||||
@ -175,17 +175,17 @@ class d3GeoIP extends oxI18n
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getShopUrls()
|
public function getShopUrls()
|
||||||
{
|
{
|
||||||
$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 );
|
||||||
}
|
}
|
||||||
|
|
||||||
return $aShopUrls;
|
return $aShopUrls;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function _getConfig()
|
protected function _getConfig()
|
||||||
{
|
{
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
class d3_oxcmp_cur_geoip extends d3_oxcmp_cur_geoip_parent
|
class d3_oxcmp_cur_geoip extends d3_oxcmp_cur_geoip_parent
|
||||||
{
|
{
|
||||||
private $_sModId = 'd3_geoip';
|
private $_sModId = 'd3_geoip';
|
||||||
|
|
||||||
public function init()
|
public function init()
|
||||||
{
|
{
|
||||||
if (d3_cfg_mod::get($this->_sModId)->getValue('blDebugmodeGlobal'))
|
if (d3_cfg_mod::get($this->_sModId)->getValue('blDebugmodeGlobal'))
|
||||||
{
|
{
|
||||||
$oGeoIp = oxNew('d3geoip');
|
$oGeoIp = oxNew('d3geoip');
|
||||||
@ -14,9 +14,9 @@ class d3_oxcmp_cur_geoip extends d3_oxcmp_cur_geoip_parent
|
|||||||
|
|
||||||
$oLocation = oxNew('d3geoip');
|
$oLocation = oxNew('d3geoip');
|
||||||
//$oLocation->setUserCountry();
|
//$oLocation->setUserCountry();
|
||||||
$oLocation->setCountryCurrency();
|
$oLocation->setCountryCurrency();
|
||||||
|
|
||||||
return parent::init();
|
return parent::init();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,13 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
class d3_oxcmp_lang_geoip extends d3_oxcmp_lang_geoip_parent
|
class d3_oxcmp_lang_geoip extends d3_oxcmp_lang_geoip_parent
|
||||||
{
|
{
|
||||||
public function init()
|
public function init()
|
||||||
{
|
{
|
||||||
$oLocation = oxNew('d3geoip');
|
$oLocation = oxNew('d3geoip');
|
||||||
//$oLocation->setUserCountry();
|
//$oLocation->setUserCountry();
|
||||||
$oLocation->setCountryLanguage();
|
$oLocation->setCountryLanguage();
|
||||||
|
|
||||||
return parent::init();
|
return parent::init();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -0,0 +1,3 @@
|
|||||||
|
blForceSessionStart nur bei Anwendung von GeoIP
|
||||||
|
auch nicht aktive Länder konfigurierbar (um auch nicht erlaubte Zugriffe abzufangen)
|
||||||
|
IP-Syntaxcheck bei Eingabe im Admin
|
Loading…
x
Reference in New Issue
Block a user