code syntax improved

This commit is contained in:
Daniel Seifert 2015-06-23 09:29:07 +00:00
parent 475405dbb8
commit 177b6ebce6
13 changed files with 287 additions and 287 deletions

2
.gitattributes vendored
View File

@ -1,12 +1,12 @@
* text=auto !eol * text=auto !eol
/Doxyfile -text /Doxyfile -text
copy_this/.noencode -text copy_this/.noencode -text
copy_this/modules/d3/d3geoip/IntelliSenseHelper.php -text
copy_this/modules/d3/d3geoip/controllers/admin/d3_cfg_geoipset.php -text copy_this/modules/d3/d3geoip/controllers/admin/d3_cfg_geoipset.php -text
copy_this/modules/d3/d3geoip/controllers/admin/d3_cfg_geoipset_licence.php -text copy_this/modules/d3/d3geoip/controllers/admin/d3_cfg_geoipset_licence.php -text
copy_this/modules/d3/d3geoip/controllers/admin/d3_cfg_geoipset_list.php -text copy_this/modules/d3/d3geoip/controllers/admin/d3_cfg_geoipset_list.php -text
copy_this/modules/d3/d3geoip/controllers/admin/d3_cfg_geoipset_main.php -text copy_this/modules/d3/d3geoip/controllers/admin/d3_cfg_geoipset_main.php -text
copy_this/modules/d3/d3geoip/controllers/admin/d3_country_geoip.php -text copy_this/modules/d3/d3geoip/controllers/admin/d3_country_geoip.php -text
copy_this/modules/d3/d3geoip/d3_geoip_stub.php -text
copy_this/modules/d3/d3geoip/menu.xml -text copy_this/modules/d3/d3geoip/menu.xml -text
copy_this/modules/d3/d3geoip/metadata.php -text copy_this/modules/d3/d3geoip/metadata.php -text
copy_this/modules/d3/d3geoip/models/d3geoip.php -text copy_this/modules/d3/d3geoip/models/d3geoip.php -text

View File

@ -18,7 +18,7 @@ class d3_cfg_geoipset_main extends d3_cfg_mod_main
{ {
protected $_sModId = 'd3_geoip'; protected $_sModId = 'd3_geoip';
protected $_sThisTemplate = "d3_cfg_geoipset_main.tpl"; protected $_sThisTemplate = "d3_cfg_geoipset_main.tpl";
protected $_blHasDebugSwitch = TRUE; protected $_blHasDebugSwitch = true;
protected $_sDebugHelpTextIdent = 'D3_GEOIP_SET_DEBUG_DESC'; protected $_sDebugHelpTextIdent = 'D3_GEOIP_SET_DEBUG_DESC';
/** /**
@ -33,12 +33,9 @@ class d3_cfg_geoipset_main extends d3_cfg_mod_main
$oD3GeoIP = oxNew('d3geoip'); $oD3GeoIP = oxNew('d3geoip');
$oCountry = $oD3GeoIP->getUserLocationCountryObject($sIP); $oCountry = $oD3GeoIP->getUserLocationCountryObject($sIP);
if ($oCountry->getId()) if ($oCountry->getId()) {
{
$sTitle = $oCountry->getFieldData('oxtitle'); $sTitle = $oCountry->getFieldData('oxtitle');
} } else {
else
{
$sTitle = oxRegistry::getLang()->translateString('D3_GEOIP_SET_IP_CHECKIP_NOTSET'); $sTitle = oxRegistry::getLang()->translateString('D3_GEOIP_SET_IP_CHECKIP_NOTSET');
} }
@ -79,7 +76,9 @@ class d3_cfg_geoipset_main extends d3_cfg_mod_main
$oCountryList = oxNew('oxcountrylist'); $oCountryList = oxNew('oxcountrylist');
$oListObject = $oCountryList->getBaseObject(); $oListObject = $oCountryList->getBaseObject();
$sFieldList = $oListObject->getSelectFields(); $sFieldList = $oListObject->getSelectFields();
$sQ = "select (SELECT d3startip FROM ".$oGeoIp->getViewName()." WHERE D3ISO = " .$oListObject->getViewName(). ".oxisoalpha2 LIMIT 1) as IP, $sFieldList from " . $oListObject->getViewName(); $sQ = "select (SELECT d3startip FROM ".$oGeoIp->getViewName().
" WHERE D3ISO = " .$oListObject->getViewName(). ".
oxisoalpha2 LIMIT 1) as IP, $sFieldList from " . $oListObject->getViewName();
$oCountryList->selectString($sQ); $oCountryList->selectString($sQ);

View File

@ -31,9 +31,8 @@ class d3_country_geoip extends oxAdminView
*/ */
public function render() public function render()
{ {
if ( !oxRegistry::getConfig()->getConfigParam( 'blAllowSharedEdit' ) ) if (false == oxRegistry::getConfig()->getConfigParam('blAllowSharedEdit')) {
{ $this->addTplParam('readonly', true);
$this->addTplParam('readonly', TRUE);
} }
$ret = parent::render(); $ret = parent::render();
@ -41,8 +40,7 @@ class d3_country_geoip extends oxAdminView
$soxId = oxRegistry::getConfig()->getRequestParameter("oxid"); $soxId = oxRegistry::getConfig()->getRequestParameter("oxid");
// check if we right now saved a new entry // check if we right now saved a new entry
$sSavedID = oxRegistry::getConfig()->getRequestParameter("saved_oxid"); $sSavedID = oxRegistry::getConfig()->getRequestParameter("saved_oxid");
if ( ($soxId == "-1" || !isset( $soxId)) && isset( $sSavedID) ) if (($soxId == "-1" || !isset($soxId)) && isset($sSavedID)) {
{
$soxId = $sSavedID; $soxId = $sSavedID;
oxRegistry::getSession()->deleteVariable("saved_oxid"); oxRegistry::getSession()->deleteVariable("saved_oxid");
$this->addTplParam("oxid", $soxId); $this->addTplParam("oxid", $soxId);
@ -50,25 +48,20 @@ class d3_country_geoip extends oxAdminView
$this->addTplParam("updatelist", "1"); $this->addTplParam("updatelist", "1");
} }
if ( $soxId != "-1" && isset( $soxId)) if ($soxId != "-1" && isset($soxId)) {
{
// load object // load object
/** @var $oCountry oxcountry */ /** @var $oCountry oxcountry */
$oCountry = oxNew("oxcountry"); $oCountry = oxNew("oxcountry");
$oCountry->loadInLang($this->_iEditLang, $soxId); $oCountry->loadInLang($this->_iEditLang, $soxId);
if ($oCountry->isForeignCountry()) if ($oCountry->isForeignCountry()) {
{ $this->addTplParam("blForeignCountry", true);
$this->addTplParam("blForeignCountry", TRUE); } else {
} $this->addTplParam("blForeignCountry", false);
else
{
$this->addTplParam("blForeignCountry", FALSE);
} }
$oOtherLang = $oCountry->getAvailableInLangs(); $oOtherLang = $oCountry->getAvailableInLangs();
if (!isset($oOtherLang[$this->_iEditLang])) if (!isset($oOtherLang[$this->_iEditLang])) {
{
$oCountry->loadInLang(key($oOtherLang), $soxId); $oCountry->loadInLang(key($oOtherLang), $soxId);
} }
@ -78,22 +71,18 @@ class d3_country_geoip extends oxAdminView
// remove already created languages // remove already created languages
$aLang = array_diff(oxRegistry::getLang()->getLanguageNames(), $oOtherLang); $aLang = array_diff(oxRegistry::getLang()->getLanguageNames(), $oOtherLang);
if ( count( $aLang)) if (count($aLang)) {
{
$this->addTplParam("posslang", $aLang); $this->addTplParam("posslang", $aLang);
} }
foreach ( $oOtherLang as $id => $language) foreach ($oOtherLang as $id => $language) {
{
$oLang= new stdClass(); $oLang= new stdClass();
$oLang->sLangDesc = $language; $oLang->sLangDesc = $language;
$oLang->selected = ($id == $this->_iEditLang); $oLang->selected = ($id == $this->_iEditLang);
$this->_aViewData["otherlang"][$id] = clone $oLang; $this->_aViewData["otherlang"][$id] = clone $oLang;
} }
} } else {
else $this->addTplParam("blForeignCountry", true);
{
$this->addTplParam("blForeignCountry", TRUE);
} }
$this->oShopList = oxNew('oxshoplist'); $this->oShopList = oxNew('oxshoplist');
@ -128,8 +117,7 @@ class d3_country_geoip extends oxAdminView
public function save() public function save()
{ {
//allow malladmin only to perform this action //allow malladmin only to perform this action
if ( !oxRegistry::getConfig()->getConfigParam( 'blAllowSharedEdit' ) ) if (false == oxRegistry::getConfig()->getConfigParam('blAllowSharedEdit')) {
{
return; return;
} }
@ -139,13 +127,10 @@ class d3_country_geoip extends oxAdminView
/** @var $oCountry oxcountry */ /** @var $oCountry oxcountry */
$oCountry = oxNew("oxcountry"); $oCountry = oxNew("oxcountry");
if ( $soxId != "-1") if ($soxId != "-1") {
{
$oCountry->loadInLang($this->_iEditLang, $soxId); $oCountry->loadInLang($this->_iEditLang, $soxId);
} } else {
else $aParams['oxcountry__oxid'] = null;
{
$aParams['oxcountry__oxid'] = NULL;
} }
$oCountry->setLanguage(0); $oCountry->setLanguage(0);
@ -157,8 +142,7 @@ class d3_country_geoip extends oxAdminView
$this->addTplParam("updatelist", "1"); $this->addTplParam("updatelist", "1");
// set oxid if inserted // set oxid if inserted
if ( $soxId == "-1") if ($soxId == "-1") {
{
oxRegistry::getSession()->setVariable("saved_oxid", $oCountry->getId()); oxRegistry::getSession()->setVariable("saved_oxid", $oCountry->getId());
} }
} }
@ -178,23 +162,19 @@ class d3_country_geoip extends oxAdminView
{ {
$aCurrencies = array(); $aCurrencies = array();
if ($this->getModCfgValue('blChangeShop') && $this->oCountry->getFieldData('d3geoipshop')) if ($this->getModCfgValue('blChangeShop') && $this->oCountry->getFieldData('d3geoipshop')) {
{
$sShopId = $this->oCountry->getFieldData('d3geoipshop'); $sShopId = $this->oCountry->getFieldData('d3geoipshop');
} } else {
else
{
$sShopId = oxRegistry::getConfig()->getActiveView()->getViewConfig()->getActiveShopId(); $sShopId = oxRegistry::getConfig()->getActiveView()->getViewConfig()->getActiveShopId();
} }
$sQ = "select DECODE( oxvarvalue, '".$this->getConfig()->getConfigParam( 'sConfigKey' )."') as oxvarvalue from oxconfig where oxshopid = '".$sShopId."' AND oxvarname = 'aCurrencies'"; $sQ = "select DECODE( oxvarvalue, '".oxRegistry::getConfig()->getConfigParam('sConfigKey').
"') as oxvarvalue from oxconfig where oxshopid = '".$sShopId."' AND oxvarname = 'aCurrencies'";
$sCurs = oxDb::getDb(oxDb::FETCH_MODE_ASSOC)->getOne($sQ); $sCurs = oxDb::getDb(oxDb::FETCH_MODE_ASSOC)->getOne($sQ);
if ($sCurs) if ($sCurs) {
{ foreach (unserialize($sCurs) as $sKey => $sValue) {
foreach (unserialize($sCurs) as $sKey => $sValue)
{
$aFields = explode('@', $sValue); $aFields = explode('@', $sValue);
$aCurrencies[$sKey]->id = $sKey; $aCurrencies[$sKey]->id = $sKey;
$aCurrencies[$sKey]->name = $aFields[0]; $aCurrencies[$sKey]->name = $aFields[0];
@ -211,12 +191,9 @@ class d3_country_geoip extends oxAdminView
*/ */
public function getLangList() public function getLangList()
{ {
if ($this->getModCfgValue('blChangeShop') && $this->oCountry->getFieldData('d3geoipshop')) if ($this->getModCfgValue('blChangeShop') && $this->oCountry->getFieldData('d3geoipshop')) {
{
$sShopId = $this->oCountry->getFieldData('d3geoipshop'); $sShopId = $this->oCountry->getFieldData('d3geoipshop');
} } else {
else
{
$sShopId = oxRegistry::getConfig()->getActiveView()->getViewConfig()->getActiveShopId(); $sShopId = oxRegistry::getConfig()->getActiveView()->getViewConfig()->getActiveShopId();
} }
@ -224,54 +201,44 @@ class d3_country_geoip extends oxAdminView
$aLangParams = oxRegistry::getConfig()->getShopConfVar('aLanguageParams', $sShopId); $aLangParams = oxRegistry::getConfig()->getShopConfVar('aLanguageParams', $sShopId);
$aConfLanguages = oxRegistry::getConfig()->getShopConfVar('aLanguages', $sShopId); $aConfLanguages = oxRegistry::getConfig()->getShopConfVar('aLanguages', $sShopId);
if ( is_array( $aConfLanguages ) ) if (is_array($aConfLanguages)) {
{
$i = 0; $i = 0;
reset($aConfLanguages); reset($aConfLanguages);
while ( list( $key, $val ) = each( $aConfLanguages ) ) while ((list($key, $val) = each($aConfLanguages))) {
{ if (is_array($aLangParams)) {
if (is_array($aLangParams) )
{
//skipping non active languages //skipping non active languages
if ( !$aLangParams[$key]['active'] ) if (false == $aLangParams[$key]['active']) {
{
$i++; $i++;
continue; continue;
} }
} }
if ( $val) if ($val) {
{
$oLang = new stdClass(); $oLang = new stdClass();
if ( isset($aLangParams[$key]['baseId']) ) if (isset($aLangParams[$key]['baseId'])) {
{
$oLang->id = $aLangParams[$key]['baseId']; $oLang->id = $aLangParams[$key]['baseId'];
} } else {
else
{
$oLang->id = $i; $oLang->id = $i;
} }
$oLang->oxid = $key; $oLang->oxid = $key;
$oLang->abbr = $key; $oLang->abbr = $key;
$oLang->name = $val; $oLang->name = $val;
if ( is_array($aLangParams) ) if (is_array($aLangParams)) {
{
$oLang->active = $aLangParams[$key]['active']; $oLang->active = $aLangParams[$key]['active'];
$oLang->sort = $aLangParams[$key]['sort']; $oLang->sort = $aLangParams[$key]['sort'];
} }
if ( isset( $iLanguage ) && $oLang->id == $iLanguage ) if (isset($iLanguage) && $oLang->id == $iLanguage) {
{
$oLang->selected = 1; $oLang->selected = 1;
} } else {
else
{
$oLang->selected = 0; $oLang->selected = 0;
} }
if ($oLang->active)
if ($oLang->active) {
$aLanguages[$oLang->id] = $oLang; $aLanguages[$oLang->id] = $oLang;
} }
}
++$i; ++$i;
} }
} }
@ -294,14 +261,10 @@ class d3_country_geoip extends oxAdminView
$sVal1 = is_string($oLang1->$sSortParam) ? strtolower($oLang1->$sSortParam) : $oLang1->$sSortParam; $sVal1 = is_string($oLang1->$sSortParam) ? strtolower($oLang1->$sSortParam) : $oLang1->$sSortParam;
$sVal2 = is_string($oLang2->$sSortParam) ? strtolower($oLang2->$sSortParam) : $oLang2->$sSortParam; $sVal2 = is_string($oLang2->$sSortParam) ? strtolower($oLang2->$sSortParam) : $oLang2->$sSortParam;
if ( $this->_sDefSortOrder == 'asc' ) if ($this->_sDefSortOrder == 'asc') {
{
return ($sVal1 < $sVal2) ? -1 : 1; return ($sVal1 < $sVal2) ? -1 : 1;
} } else {
else
{
return ($sVal1 > $sVal2) ? -1 : 1; return ($sVal1 > $sVal2) ? -1 : 1;
} }
} }
} }

View File

@ -39,12 +39,10 @@ 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();
} }
@ -56,14 +54,25 @@ class d3GeoIP extends oxbase
$sISOAlpha = $this->loadByIPNum($iIPNum); $sISOAlpha = $this->loadByIPNum($iIPNum);
if (!$sISOAlpha) if (!$sISOAlpha) {
{ $this->_getLog()->log(
$this->_getLog()->log(d3log::ERROR, __CLASS__, __FUNCTION__, __LINE__, 'get ISO by IP failed', $sIP); 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,
$this->_getLog()->log(d3log::INFO, __CLASS__, __FUNCTION__, __LINE__, 'get ISO by IP', $sIP." => ".$sISOAlpha); __CLASS__,
__FUNCTION__,
__LINE__,
'get ISO by IP',
$sIP." => ".$sISOAlpha
);
$this->oCountry = $this->getCountryObject($sISOAlpha); $this->oCountry = $this->getCountryObject($sISOAlpha);
} }
@ -82,16 +91,15 @@ 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')
elseif ($this->_getModConfig()->getValue('blUseTestCountry') && $this->_getModConfig()->getValue('sTestCountryIp')) && $this->_getModConfig()->getValue('sTestCountryIp')
{ ) {
$sIP = $this->_getModConfig()->getValue('sTestCountryIp'); $sIP = $this->_getModConfig()->getValue('sTestCountryIp');
} } else {
else
{
// ToDo: use $_SERVER['X-Forwared-For'] && Client-IP in case of proxy // ToDo: use $_SERVER['X-Forwared-For'] && Client-IP in case of proxy
$sIP = $_SERVER['REMOTE_ADDR']; $sIP = $_SERVER['REMOTE_ADDR'];
} }
@ -110,33 +118,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');
} }
@ -153,7 +158,7 @@ class d3GeoIP extends oxbase
* @param int $iIPNum IP number * @param int $iIPNum IP number
* @return string * @return string
*/ */
public function LoadByIPNum($iIPNum) public function loadByIPNum($iIPNum)
{ {
startProfile(__METHOD__); startProfile(__METHOD__);
@ -176,7 +181,8 @@ class d3GeoIP extends oxbase
startProfile(__METHOD__); startProfile(__METHOD__);
$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));
@ -196,8 +202,9 @@ 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'));
} }
@ -217,17 +224,27 @@ class d3GeoIP extends oxbase
$this->performURLSwitch(); $this->performURLSwitch();
$this->performShopSwitch(); $this->performShopSwitch();
if (!$this->_getModConfig()->isActive() || !$this->_getModConfig()->getValue('blChangeLang')) if (!$this->_getModConfig()->isActive()
{ || false == $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
$this->_getLog()->log(d3log::INFO, __CLASS__, __FUNCTION__, __LINE__, 'set language', $this->getIP().' => '.$oCountry->getFieldData('d3geoiplang')); && 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')
);
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'));
oxRegistry::getSession()->setVariable('d3isSetLang', true); oxRegistry::getSession()->setVariable('d3isSetLang', true);
@ -242,16 +259,30 @@ class d3GeoIP extends oxbase
*/ */
public function setCountryCurrency() public function setCountryCurrency()
{ {
if (!$this->_getModConfig()->isActive() || !$this->_getModConfig()->getValue('blChangeCurr')) if (!$this->_getModConfig()->isActive()
|| false == $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
$this->_getLog()->log(d3log::INFO, __CLASS__, __FUNCTION__, __LINE__, 'set currency', $this->getIP().' => '.$oCountry->getFieldData('d3geoipcur')); && !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')
);
oxRegistry::getConfig()->setActShopCurrency((int) $oCountry->getFieldData('d3geoipcur')); oxRegistry::getConfig()->setActShopCurrency((int) $oCountry->getFieldData('d3geoipcur'));
oxRegistry::getSession()->setVariable('d3isSetCurr', true); oxRegistry::getSession()->setVariable('d3isSetCurr', true);
} }
@ -265,40 +296,38 @@ 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();
$this->getConfig()->onShopChange(); $this->getConfig()->onShopChange();
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 = '';
} }
@ -309,9 +338,20 @@ class d3GeoIP extends oxbase
'fnc' => oxRegistry::getConfig()->getRequestParameter('fnc'), 'fnc' => oxRegistry::getConfig()->getRequestParameter('fnc'),
'shp' => $iNewShop 'shp' => $iNewShop
); );
$sUrl = str_replace('&amp;', '&', $oStr->generateParameterUrl($oNewConf->getShopHomeUrl($sLangId), $aParams)); $sUrl = str_replace(
'&amp;',
'&',
$oStr->generateParameterUrl($oNewConf->getShopHomeUrl($sLangId), $aParams)
);
$this->_getLog()->log(d3log::INFO, __CLASS__, __FUNCTION__, __LINE__, 'change shop', $this->getIP().' => '.$sUrl); $this->_getLog()->log(
d3log::INFO,
__CLASS__,
__FUNCTION__,
__LINE__,
'change shop',
$this->getIP().' => '.$sUrl
);
header("Location: ".$sUrl); header("Location: ".$sUrl);
exit(); exit();
@ -326,8 +366,8 @@ class d3GeoIP extends oxbase
*/ */
public function performURLSwitch() public function performURLSwitch()
{ {
if (!$this->_getModConfig()->isActive() || !$this->_getModConfig()->getValue('blChangeURL')) if (!$this->_getModConfig()->isActive()
{ || false == $this->_getModConfig()->getValue('blChangeURL')) {
return; return;
} }
@ -335,16 +375,22 @@ class d3GeoIP extends oxbase
$oCountry = $this->getUserLocationCountryObject(); $oCountry = $this->getUserLocationCountryObject();
if (!$this->isAdmin() && if (false == $this->isAdmin()
oxRegistry::getUtils()->isSearchEngine() === false && && oxRegistry::getUtils()->isSearchEngine() === false
$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')
);
header("Location: ".$sNewUrl); header("Location: ".$sNewUrl);
exit(); exit();
@ -365,8 +411,8 @@ class d3GeoIP extends oxbase
$oShoplist = oxNew('oxshoplist'); $oShoplist = oxNew('oxshoplist');
$oShoplist->getList(); $oShoplist->getList();
$aShopUrls = array(); $aShopUrls = array();
foreach ( $oShoplist as $sId => $oShop )
{ foreach (array_keys($oShoplist) as $sId) {
$aShopUrls[$sId] = $this->getConfig()->getShopConfVar('sMallShopURL', $sId); $aShopUrls[$sId] = $this->getConfig()->getShopConfVar('sMallShopURL', $sId);
} }
@ -392,9 +438,8 @@ class d3GeoIP extends oxbase
*/ */
protected function _getLog() protected function _getLog()
{ {
if (!$this->oD3Log) if (!$this->oD3Log) {
{ $this->oD3Log = $this->_getModConfig()->d3getLog();
$this->oD3Log = $this->_getModConfig()->getLog();
} }
return $this->oD3Log; return $this->oD3Log;

View File

@ -23,10 +23,8 @@ class d3_oxcmp_cur_geoip extends d3_oxcmp_cur_geoip_parent
*/ */
public function init() public function init()
{ {
if (d3_cfg_mod::get($this->_sModId)->isActive()) if (d3_cfg_mod::get($this->_sModId)->isActive()) {
{ if (d3_cfg_mod::get($this->_sModId)->hasDebugMode()) {
if (d3_cfg_mod::get($this->_sModId)->hasDebugMode())
{
/** @var $oGeoIp d3geoip */ /** @var $oGeoIp d3geoip */
$oGeoIp = oxNew('d3geoip'); $oGeoIp = oxNew('d3geoip');
echo $oGeoIp->getIP(); echo $oGeoIp->getIP();
@ -39,5 +37,4 @@ class d3_oxcmp_cur_geoip extends d3_oxcmp_cur_geoip_parent
return parent::init(); return parent::init();
} }
} }

View File

@ -23,8 +23,7 @@ class d3_oxcmp_lang_geoip extends d3_oxcmp_lang_geoip_parent
*/ */
public function init() public function init()
{ {
if (d3_cfg_mod::get($this->_sModId)->isActive()) if (d3_cfg_mod::get($this->_sModId)->isActive()) {
{
/** @var $oLocation d3geoip */ /** @var $oLocation d3geoip */
$oLocation = oxNew('d3geoip'); $oLocation = oxNew('d3geoip');
$oLocation->setCountryLanguage(); $oLocation->setCountryLanguage();

View File

@ -20,7 +20,6 @@ $iLangNr = 0;
// RESOURCE IDENTITFIER = STRING // RESOURCE IDENTITFIER = STRING
// ------------------------------- // -------------------------------
$aLang = array( $aLang = array(
'charset' => 'ISO-8859-15', 'charset' => 'ISO-8859-15',
'd3mxgeoip' => 'GeoIP', 'd3mxgeoip' => 'GeoIP',
'd3mxgeoip_settings' => 'Einstellungen', 'd3mxgeoip_settings' => 'Einstellungen',
@ -59,7 +58,6 @@ $aLang = array(
'D3_GEOIP_METADATA_DESC' => 'Begrüßen Sie Ihre Kunden in seiner Landessprache.', 'D3_GEOIP_METADATA_DESC' => 'Begrüßen Sie Ihre Kunden in seiner Landessprache.',
'D3_GEOIP_UPDATE_ITEMINSTALL' => 'Die umfangreiche IP-Liste kann leider nicht über die automatische Installation eingebunden werden. Bitte installieren Sie diese manuell. '.PHP_EOL.PHP_EOL.'Die erforderlichen Daten finden Sie im Installationspaket des Moduls unter "setup+doku/geoip-Data_IPv4_*.sql" ("setup+doku/geoip-Data_IPv6_*.sql" für IPv6-Adressen) oder als handlichere SQL-Dateien unter "setup+doku/geoip_data_parts/". '.PHP_EOL.PHP_EOL.'Sie benötigen entweder die Komplettdateien oder die Sammlung kleinerer Daten. Führen Sie die SQL-Datei(en) bitte in Ihrer Datenbank aus.', 'D3_GEOIP_UPDATE_ITEMINSTALL' => 'Die umfangreiche IP-Liste kann leider nicht über die automatische Installation eingebunden werden. Bitte installieren Sie diese manuell. '.PHP_EOL.PHP_EOL.'Die erforderlichen Daten finden Sie im Installationspaket des Moduls unter "setup+doku/geoip-Data_IPv4_*.sql" ("setup+doku/geoip-Data_IPv6_*.sql" für IPv6-Adressen) oder als handlichere SQL-Dateien unter "setup+doku/geoip_data_parts/". '.PHP_EOL.PHP_EOL.'Sie benötigen entweder die Komplettdateien oder die Sammlung kleinerer Daten. Führen Sie die SQL-Datei(en) bitte in Ihrer Datenbank aus.',
); );
/* /*

View File

@ -47,11 +47,11 @@ function showFormatSettings(sElemId, visible, blUseOldElem)
sOldSettingElem = sElemId; sOldSettingElem = sElemId;
} }
if (visible == true) if (visible == true) {
document.getElementById(sElemId).style.display = 'block'; document.getElementById(sElemId).style.display = 'block';
else } else {
document.getElementById(sElemId).style.display = 'none'; document.getElementById(sElemId).style.display = 'none';
}
} }
--> -->
@ -259,7 +259,6 @@ td.edittext {
</div> </div>
</div> </div>
<table width="100%"> <table width="100%">
<tr> <tr>
<td class="edittext ext_edittext" align="left"> <td class="edittext ext_edittext" align="left">