diff --git a/changed_full/EE/EE420-EE456/out/admin/de/d3_geoip_lang.php b/changed_full/EE/EE420-EE456/out/admin/de/d3_geoip_lang.php index 0fc0f65..1c224bf 100644 --- a/changed_full/EE/EE420-EE456/out/admin/de/d3_geoip_lang.php +++ b/changed_full/EE/EE420-EE456/out/admin/de/d3_geoip_lang.php @@ -36,6 +36,7 @@ $aLang = array( 'D3_GEOIP_SET_OPTIONS_CHANGECURR' => 'Währung wechseln, wenn eingestellt', 'D3_GEOIP_SET_OPTIONS_CHANGELANG' => 'Sprache wechseln, wenn eingestellt', 'D3_GEOIP_SET_OPTIONS_CHANGEURL' => 'URL wechseln, wenn eingestellt', +'D3_GEOIP_SET_OPTIONS_NOCOUNTRY' => 'Shop verwendet die Einstellung dieses Landes, wenn IP nicht zuzuordnen ist', 'D3_GEOIP_SET_IP' => 'IP-Einstellungen', 'D3_GEOIP_SET_IP_TESTIP' => 'statt Kunden-IP immer diese IP-Adresse verwenden', 'D3_GEOIP_SET_IP_CHECKIP' => 'diese IP-Adresse prüfen', diff --git a/changed_full/EE/EE420-EE456/out/admin/tpl/d3_cfg_geoipset_main.tpl b/changed_full/EE/EE420-EE456/out/admin/tpl/d3_cfg_geoipset_main.tpl index 057ad40..9ad6e15 100644 --- a/changed_full/EE/EE420-EE456/out/admin/tpl/d3_cfg_geoipset_main.tpl +++ b/changed_full/EE/EE420-EE456/out/admin/tpl/d3_cfg_geoipset_main.tpl @@ -252,6 +252,22 @@ td.edittext {
+
+
+ [{oxmultilang ident="D3_GEOIP_SET_OPTIONS_NOCOUNTRY"}] + + getValue('blUseFallback') == 1}]checked[{/if}]> +
+
+ + [{ oxinputhelp ident="D3_GEOIP_SET_OPTIONS_NOCOUNTRY_DESC" }] +
+
+
diff --git a/changed_full/PE/PE420-PE456/out/admin/de/d3_geoip_lang.php b/changed_full/PE/PE420-PE456/out/admin/de/d3_geoip_lang.php index 0fc0f65..1c224bf 100644 --- a/changed_full/PE/PE420-PE456/out/admin/de/d3_geoip_lang.php +++ b/changed_full/PE/PE420-PE456/out/admin/de/d3_geoip_lang.php @@ -36,6 +36,7 @@ $aLang = array( 'D3_GEOIP_SET_OPTIONS_CHANGECURR' => 'Währung wechseln, wenn eingestellt', 'D3_GEOIP_SET_OPTIONS_CHANGELANG' => 'Sprache wechseln, wenn eingestellt', 'D3_GEOIP_SET_OPTIONS_CHANGEURL' => 'URL wechseln, wenn eingestellt', +'D3_GEOIP_SET_OPTIONS_NOCOUNTRY' => 'Shop verwendet die Einstellung dieses Landes, wenn IP nicht zuzuordnen ist', 'D3_GEOIP_SET_IP' => 'IP-Einstellungen', 'D3_GEOIP_SET_IP_TESTIP' => 'statt Kunden-IP immer diese IP-Adresse verwenden', 'D3_GEOIP_SET_IP_CHECKIP' => 'diese IP-Adresse prüfen', diff --git a/changed_full/PE/PE420-PE456/out/admin/tpl/d3_cfg_geoipset_main.tpl b/changed_full/PE/PE420-PE456/out/admin/tpl/d3_cfg_geoipset_main.tpl index 057ad40..9ad6e15 100644 --- a/changed_full/PE/PE420-PE456/out/admin/tpl/d3_cfg_geoipset_main.tpl +++ b/changed_full/PE/PE420-PE456/out/admin/tpl/d3_cfg_geoipset_main.tpl @@ -252,6 +252,22 @@ td.edittext {
+
+
+ [{oxmultilang ident="D3_GEOIP_SET_OPTIONS_NOCOUNTRY"}] + + getValue('blUseFallback') == 1}]checked[{/if}]> +
+
+ + [{ oxinputhelp ident="D3_GEOIP_SET_OPTIONS_NOCOUNTRY_DESC" }] +
+
+
diff --git a/copy_this/admin/d3_cfg_geoipset_main.php b/copy_this/admin/d3_cfg_geoipset_main.php index f37a7aa..ebdb73e 100644 --- a/copy_this/admin/d3_cfg_geoipset_main.php +++ b/copy_this/admin/d3_cfg_geoipset_main.php @@ -31,4 +31,19 @@ class d3_cfg_geoipset_main extends d3_cfg_mod_main return $sTitle; } + + public function getCountryList() + { + $oCountryList = oxNew('oxcountrylist'); + if ($oCountryList->getBaseObject()->isMultilang()) + { + $oCountryList->getBaseObject()->setLanguage(oxLang::getInstance()->getTplLanguage()); + } + $oListObject = $oCountryList->getBaseObject(); + $sFieldList = $oListObject->getSelectFields(); + $sQ = "select $sFieldList from " . $oListObject->getViewName(); + $oCountryList->selectString($sQ); + + return $oCountryList; + } } \ No newline at end of file diff --git a/copy_this/core/d3geoip.php b/copy_this/core/d3geoip.php index dc3cd31..6cf390b 100644 --- a/copy_this/core/d3geoip.php +++ b/copy_this/core/d3geoip.php @@ -1,51 +1,64 @@ - + +class d3GeoIP extends oxI18n +{ + /** + * Current class name + * + * @var string + */ + protected $_sClassName = 'd3geoip'; private $_sModId = 'd3_geoip'; - - /** - * Class constructor, initiates parent constructor (parent::oxI18n()). - * - * @return null - */ - public function __construct() - { - parent::__construct(); - $this->init('d3geoip'); - } - + + /** + * Class constructor, initiates parent constructor (parent::oxI18n()). + * + * @return null + */ + public function __construct() + { + parent::__construct(); + $this->init('d3geoip'); + } + public function getUserLocationCountryObject($sIP = false) - { - if (!$this->oCountry) - { + { + if (!$this->oCountry) + { if (!$sIP) $sIP = $this->getIP(); - $iIPNum = $this->_getNumIp($sIP); - $sISOAlpha = $this->LoadByIPNum($iIPNum); + $iIPNum = $this->_getNumIp($sIP); + $sISOAlpha = $this->LoadByIPNum($iIPNum); if (!$sISOAlpha) { $this->_getLog()->setLog('error', __CLASS__, __FUNCTION__, __LINE__, 'get ISO by IP failed', $sIP); - $this->oCountry = oxNew('oxcountry'); + $this->oCountry = $this->getCountryFallBackObject(); } else { $this->_getLog()->setLog('info', __CLASS__, __FUNCTION__, __LINE__, 'get ISO by IP', $sIP." => ".$sISOAlpha); $this->oCountry = $this->getCountryObject($sISOAlpha); } - } - - return $this->oCountry; - } + } + + return $this->oCountry; + } public function getIP() { @@ -54,108 +67,120 @@ class d3GeoIP extends oxI18n else return $_SERVER['REMOTE_ADDR']; } - - protected function _getNumIp($sIP) + + protected function _getNumIp($sIP) + { + $aIP = explode('.',$sIP); + $iIP = ($aIP[0] * 16777216) + ($aIP[1] * 65536) + ($aIP[2] * 256) + ($aIP[3] * 1); + return $iIP; + } + + public function LoadByIPNum($iIPNum) + { + $sSelect = "SELECT d3iso FROM ".$this->_sClassName." WHERE d3startipnum <= '$iIPNum' AND d3endipnum >= '$iIPNum'"; + return oxDb::getDb()->getOne($sSelect); + } + + public function getCountryObject($sISOAlpha) + { + $oCountry = oxNew('oxcountry'); + $sSelect = "SELECT oxid FROM ".$oCountry->getViewName()." WHERE OXISOALPHA2 = '".$sISOAlpha."' AND OXACTIVE = '1'"; + $oCountry->load(oxDb::getDb()->getOne($sSelect)); + + return $oCountry; + } + + public function getCountryFallBackObject() { - $aIP = explode('.',$sIP); - $iIP = ($aIP[0] * 16777216) + ($aIP[1] * 65536) + ($aIP[2] * 256) + ($aIP[3] * 1); - return $iIP; - } - - public function LoadByIPNum($iIPNum) - { - $sSelect = "SELECT d3iso FROM ".$this->_sClassName." WHERE d3startipnum <= '$iIPNum' AND d3endipnum >= '$iIPNum'"; - return oxDb::getDb()->getOne($sSelect); - } - - public function getCountryObject($sISOAlpha) - { - $oCountry = &oxNew('oxcountry'); - $sSelect = "SELECT oxid FROM ".$oCountry->getViewName()." WHERE OXISOALPHA2 = '".$sISOAlpha."' AND OXACTIVE = '1'"; - $oCountry->load(oxDb::getDb()->getOne($sSelect)); - + $oCountry = oxNew('oxcountry'); + + if ($this->_getConfig()->getValue('blUseFallback') && $this->_getConfig()->getValue('sFallbackCountryId')) + { + $oCountry->Load($this->_getConfig()->getValue('sFallbackCountryId')); + } + return $oCountry; } -/* - public function setUserCountry() - { +/* + public function setUserCountry() + { if (!$this->getUser()) { - $oCountry = $this->getUserLocationCountryObject(); - $oUser = &oxNew('oxuser'); - $oUser->oxuser__oxcountryid = oxNew('oxfield'); - $oUser->oxuser__oxcountryid->setValue($oCountry->getId()); - $this->setUser($oUser); - } - - return; - } -*/ - - public function setCountryLanguage() - { + $oCountry = $this->getUserLocationCountryObject(); + $oUser = &oxNew('oxuser'); + $oUser->oxuser__oxcountryid = oxNew('oxfield'); + $oUser->oxuser__oxcountryid->setValue($oCountry->getId()); + $this->setUser($oUser); + } + + return; + } +*/ + + public function setCountryLanguage() + { $this->performURLSwitch(); - $this->performShopSwitch(); - + $this->performShopSwitch(); + if (!$this->_getConfig()->getFieldData('oxactive') || !$this->_getConfig()->getValue('blChangeLang')) return; $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')); - oxLang::getInstance()->setTplLanguage((int) $oCountry->getFieldData('d3geoiplang')); - oxLang::getInstance()->setBaseLanguage((int) $oCountry->getFieldData('d3geoiplang')); - $this->getSession()->setVar('d3isSetLang', true); - } - } - - public function setCountryCurrency() - { + oxLang::getInstance()->setTplLanguage((int) $oCountry->getFieldData('d3geoiplang')); + oxLang::getInstance()->setBaseLanguage((int) $oCountry->getFieldData('d3geoiplang')); + $this->getSession()->setVar('d3isSetLang', true); + } + } + + public function setCountryCurrency() + { if (!$this->_getConfig()->getFieldData('oxactive') || !$this->_getConfig()->getValue('blChangeCurr')) return; - $oCountry = $this->getUserLocationCountryObject(); - - if (!$this->isAdmin() && oxUtils::getInstance()->isSearchEngine() === false && !$this->getSession()->getVar('d3isSetCurr') && $oCountry->getId() && $oCountry->getFieldData('d3geoipcur') > -1) - { + $oCountry = $this->getUserLocationCountryObject(); + + 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->getConfig()->setActShopCurrency((int) $oCountry->getFieldData('d3geoipcur')); - $this->getSession()->setVar('d3isSetCurr', true); - } - } - - public function performShopSwitch() - { + $this->getConfig()->setActShopCurrency((int) $oCountry->getFieldData('d3geoipcur')); + $this->getSession()->setVar('d3isSetCurr', true); + } + } + + public function performShopSwitch() + { if (!$this->_getConfig()->getFieldData('oxactive') || !$this->_getConfig()->getValue('blChangeShop')) return; - $oCountry = $this->getUserLocationCountryObject(); - - $iNewShop = $oCountry->getFieldData('d3geoipshop'); - - $aShopLinks = $this->getShopUrls(); - - if (!$this->isAdmin() && oxUtils::getInstance()->isSearchEngine() === false && $oCountry->getId() && $this->getConfig()->isMall() && $iNewShop > -1 && $iNewShop != $this->getConfig()->getShopId()) - { + $oCountry = $this->getUserLocationCountryObject(); + + $iNewShop = $oCountry->getFieldData('d3geoipshop'); + + $aShopLinks = $this->getShopUrls(); + + if (!$this->isAdmin() && oxUtils::getInstance()->isSearchEngine() === false && $oCountry->getId() && $this->getConfig()->isMall() && $iNewShop > -1 && $iNewShop != $this->getConfig()->getShopId()) + { $oNewConf = new oxConfig(); $oNewConf->setShopId($iNewShop); $oNewConf->init(); - + $this->getConfig()->onShopChange(); - + if (!$this->getSession()->getVar('d3isSetLang') && $oCountry->getFieldData('d3geoiplang') > -1) $sLangId = $oCountry->getFieldData('d3geoiplang'); else $sLangId = ''; - + $this->_getLog()->setLog('info', __CLASS__, __FUNCTION__, __LINE__, 'change shop', $this->getIP().' => '.$oNewConf->getShopHomeUrl($sLangId)); header("Location: ".$oNewConf->getShopHomeUrl($sLangId)); exit(); - } - } + } + } public function performURLSwitch() { @@ -167,7 +192,7 @@ class d3GeoIP extends oxI18n if (!$this->isAdmin() && oxUtils::getInstance()->isSearchEngine() === false && $oCountry->getId() && $oCountry->getFieldData('d3geoipurl') && strlen(trim($oCountry->getFieldData('d3geoipurl'))) > 0) { $sNewUrl = $oCountry->getFieldData('d3geoipurl'); - + $this->_getLog()->setLog('info', __CLASS__, __FUNCTION__, __LINE__, 'change url', $this->getIP().' => '.$oCountry->getFieldData('d3geoipurl')); header("Location: ".$sNewUrl); @@ -175,17 +200,17 @@ class d3GeoIP extends oxI18n } } - public function getShopUrls() - { - $oShoplist = oxNew( 'oxshoplist' ); - $oShoplist->getList(); - $aShopUrls = array(); - foreach ( $oShoplist as $sId => $oShop ) { - $aShopUrls[$sId] = $this->getConfig()->getShopConfVar( 'sMallShopURL', $sId ); - } - - return $aShopUrls; - } + public function getShopUrls() + { + $oShoplist = oxNew( 'oxshoplist' ); + $oShoplist->getList(); + $aShopUrls = array(); + foreach ( $oShoplist as $sId => $oShop ) { + $aShopUrls[$sId] = $this->getConfig()->getShopConfVar( 'sMallShopURL', $sId ); + } + + return $aShopUrls; + } protected function _getConfig() { diff --git a/setup+doku/EE/install.sql b/setup+doku/EE/install.sql index 47d19e4..686e19c 100644 --- a/setup+doku/EE/install.sql +++ b/setup+doku/EE/install.sql @@ -1,9 +1,9 @@ INSERT INTO `d3_cfg_mod` (`OXID`, `OXSHOPID`, `OXMODID`, `OXNAME`, `OXACTIVE`, `OXSERIAL`, `OXINSTALLDATE`, `OXVERSION`, `OXSHOPVERSION`, `OXISMODULELOG`, `OXREQUIREMENTS`, `OXVALUE`, `OXVALUE_1`, `OXVALUE_2`, `OXREVISION`, `OXNEWREVISION`) VALUES -(MD5(RAND()), 1, 'd3_geoip', 'GeoIP', 1, '', NOW(), '2.0.0', 'EE4', 0, '', '', '', '', 14, 14); +(MD5(RAND()), 1, 'd3_geoip', 'GeoIP', 1, '', NOW(), '2.1.0', 'EE4', 0, '', '', '', '', 18, 18); INSERT INTO `d3_cfg_mod` (`OXID`, `OXSHOPID`, `OXMODID`, `OXNAME`, `OXACTIVE`, `OXSERIAL`, `OXINSTALLDATE`, `OXVERSION`, `OXSHOPVERSION`, `OXISMODULELOG`, `OXREQUIREMENTS`, `OXVALUE`, `OXVALUE_1`, `OXVALUE_2`, `OXREVISION`, `OXNEWREVISION`) VALUES -(MD5(RAND()), 2, 'd3_geoip', 'GeoIP', 1, '', NOW(), '2.0.0', 'EE4', 0, '', '', '', '', 14, 14); +(MD5(RAND()), 2, 'd3_geoip', 'GeoIP', 1, '', NOW(), '2.1.0', 'EE4', 0, '', '', '', '', 18, 18); INSERT INTO `d3_cfg_mod` (`OXID`, `OXSHOPID`, `OXMODID`, `OXNAME`, `OXACTIVE`, `OXSERIAL`, `OXINSTALLDATE`, `OXVERSION`, `OXSHOPVERSION`, `OXISMODULELOG`, `OXREQUIREMENTS`, `OXVALUE`, `OXVALUE_1`, `OXVALUE_2`, `OXREVISION`, `OXNEWREVISION`) VALUES -(MD5(RAND()), 3, 'd3_geoip', 'GeoIP', 1, '', NOW(), '2.0.0', 'EE4', 0, '', '', '', '', 14, 14); +(MD5(RAND()), 3, 'd3_geoip', 'GeoIP', 1, '', NOW(), '2.1.0', 'EE4', 0, '', '', '', '', 18, 18); ALTER TABLE `oxcountry` ADD `D3GEOIPSHOP` VARCHAR( 10 ) NOT NULL DEFAULT '-1', ADD `D3GEOIPLANG` TINYINT( 2 ) NOT NULL DEFAULT '-1', diff --git a/setup+doku/EE/update.sql b/setup+doku/EE/update.sql index 39806e2..276da0e 100644 --- a/setup+doku/EE/update.sql +++ b/setup+doku/EE/update.sql @@ -9,4 +9,7 @@ INSERT INTO `d3_cfg_mod` (`OXID`, `OXSHOPID`, `OXMODID`, `OXNAME`, `OXACTIVE`, ` (MD5(RAND()), 2, 'd3_geoip', 'GeoIP', 1, '', NOW(), '2.0.0', 'EE4', 0, '', '', '', '', 14, 14); INSERT INTO `d3_cfg_mod` (`OXID`, `OXSHOPID`, `OXMODID`, `OXNAME`, `OXACTIVE`, `OXSERIAL`, `OXINSTALLDATE`, `OXVERSION`, `OXSHOPVERSION`, `OXISMODULELOG`, `OXREQUIREMENTS`, `OXVALUE`, `OXVALUE_1`, `OXVALUE_2`, `OXREVISION`, `OXNEWREVISION`) VALUES (MD5(RAND()), 3, 'd3_geoip', 'GeoIP', 1, '', NOW(), '2.0.0', 'EE4', 0, '', '', '', '', 14, 14); -ALTER TABLE `oxcountry` ADD `D3GEOIPURL` VARCHAR( 255 ) NOT NULL; \ No newline at end of file +ALTER TABLE `oxcountry` ADD `D3GEOIPURL` VARCHAR( 255 ) NOT NULL; + +# ==== 2.0.0 PE4 => 2.1.0 PE4 ==== +UPDATE `d3_cfg_mod` SET `OXVERSION` = '2.1.0', `OXREVISION` = '18', `OXNEWREVISION` = '18' WHERE OXMODID = 'd3_geoip'; \ No newline at end of file diff --git a/setup+doku/Installation.pdf b/setup+doku/Installation.pdf index c88e097..ee6b078 100644 Binary files a/setup+doku/Installation.pdf and b/setup+doku/Installation.pdf differ diff --git a/setup+doku/PE/install.sql b/setup+doku/PE/install.sql index e3ba5b2..78f5826 100644 --- a/setup+doku/PE/install.sql +++ b/setup+doku/PE/install.sql @@ -1,5 +1,5 @@ INSERT INTO `d3_cfg_mod` (`OXID`, `OXSHOPID`, `OXMODID`, `OXNAME`, `OXACTIVE`, `OXSERIAL`, `OXINSTALLDATE`, `OXVERSION`, `OXSHOPVERSION`, `OXISMODULELOG`, `OXREQUIREMENTS`, `OXVALUE`, `OXVALUE_1`, `OXVALUE_2`, `OXREVISION`, `OXNEWREVISION`) VALUES -(MD5(RAND()), 'oxbaseshop', 'd3_geoip', 'GeoIP', 1, '', NOW(), '2.0.0', 'PE4', 0, '', '', '', '', 14, 14); +(MD5(RAND()), 'oxbaseshop', 'd3_geoip', 'GeoIP', 1, '', NOW(), '2.1.0', 'PE4', 0, '', '', '', '', 18, 18); ALTER TABLE `oxcountry` ADD `D3GEOIPSHOP` VARCHAR( 10 ) NOT NULL DEFAULT '-1', ADD `D3GEOIPLANG` TINYINT( 2 ) NOT NULL DEFAULT '-1', diff --git a/setup+doku/PE/update.sql b/setup+doku/PE/update.sql index 0f50c3d..3f3190e 100644 --- a/setup+doku/PE/update.sql +++ b/setup+doku/PE/update.sql @@ -5,4 +5,7 @@ CHANGE `D3ENDIPNUM` `D3ENDIPNUM` INT( 10 ) UNSIGNED NOT NULL # ==== 1.1 PE4 => 2.0.0 PE4 ==== INSERT INTO `d3_cfg_mod` (`OXID`, `OXSHOPID`, `OXMODID`, `OXNAME`, `OXACTIVE`, `OXSERIAL`, `OXINSTALLDATE`, `OXVERSION`, `OXSHOPVERSION`, `OXISMODULELOG`, `OXREQUIREMENTS`, `OXVALUE`, `OXVALUE_1`, `OXVALUE_2`, `OXREVISION`, `OXNEWREVISION`) VALUES (MD5(RAND()), 'oxbaseshop', 'd3_geoip', 'GeoIP', 1, '', NOW(), '2.0.0', 'PE4', 0, '', '', '', '', 14, 14); -ALTER TABLE `oxcountry` ADD `D3GEOIPURL` VARCHAR( 255 ) NOT NULL; \ No newline at end of file +ALTER TABLE `oxcountry` ADD `D3GEOIPURL` VARCHAR( 255 ) NOT NULL; + +# ==== 2.0.0 PE4 => 2.1.0 PE4 ==== +UPDATE `d3_cfg_mod` SET `OXVERSION` = '2.1.0', `OXREVISION` = '18', `OXNEWREVISION` = '18' WHERE OXMODID = 'd3_geoip'; \ No newline at end of file diff --git a/sources/GeoIP-Installation.docx b/sources/GeoIP-Installation.docx index 038662b..98be340 100644 Binary files a/sources/GeoIP-Installation.docx and b/sources/GeoIP-Installation.docx differ