diff --git a/.gitattributes b/.gitattributes index 7b3b107..5b1e827 100644 --- a/.gitattributes +++ b/.gitattributes @@ -15,11 +15,8 @@ copy_this/modules/d3/d3geoip/picture.png -text copy_this/modules/d3/d3geoip/views/admin/de/d3_geoip_lang.php -text copy_this/modules/d3/d3geoip/views/admin/tpl/d3_cfg_geoipset_main.tpl -text copy_this/modules/d3/d3geoip/views/admin/tpl/d3_country_geoip.tpl -text -setup+doku/EE/install.sql -text -setup+doku/EE/update.sql -text setup+doku/Installation.pdf -text -setup+doku/PE/install.sql -text -setup+doku/PE/update.sql -text +setup+doku/d3precheck.php -text setup+doku/geoip-Data_2011-10-13.sql -text setup+doku/geoip-Struktur.sql -text setup+doku/geoip_data_parts/1.sql -text diff --git a/copy_this/modules/d3/d3geoip/controllers/admin/d3_cfg_geoipset_main.php b/copy_this/modules/d3/d3geoip/controllers/admin/d3_cfg_geoipset_main.php index da02493..f5cf3ca 100644 --- a/copy_this/modules/d3/d3geoip/controllers/admin/d3_cfg_geoipset_main.php +++ b/copy_this/modules/d3/d3geoip/controllers/admin/d3_cfg_geoipset_main.php @@ -1,66 +1,90 @@ - +/** + * 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 + * @link http://www.oxidmodule.com + */ class d3_cfg_geoipset_main extends d3_cfg_mod_main { protected $_sModId = 'd3_geoip'; - protected $_sThisTemplate = "d3_cfg_geoipset_main.tpl"; + protected $_blHasDebugSwitch = TRUE; + protected $_sDebugHelpTextIdent = 'D3_GEOIP_SET_DEBUG_DESC'; + /** + * @param $sIP + * @return string + */ public function getIpCountry($sIP) { + startProfile(__METHOD__); + + /** @var $oD3GeoIP d3geoip */ $oD3GeoIP = oxNew('d3geoip'); $oCountry = $oD3GeoIP->getUserLocationCountryObject($sIP); if ($oCountry->getId()) + { $sTitle = $oCountry->getFieldData('oxtitle'); + } else - $sTitle = oxLang::getInstance()->translateString('D3_GEOIP_SET_IP_CHECKIP_NOTSET'); + { + $sTitle = oxRegistry::getLang()->translateString('D3_GEOIP_SET_IP_CHECKIP_NOTSET'); + } + + stopProfile(__METHOD__); return $sTitle; } + /** + * @return oxcountrylist + */ public function getCountryList() { + startProfile(__METHOD__); + + /** @var $oCountryList oxcountrylist */ $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); + stopProfile(__METHOD__); + return $oCountryList; } + /** + * @return oxcountrylist + */ public function getIPCountryList() { + startProfile(__METHOD__); + + /** @var $oGeoIp d3geoip */ $oGeoIp = oxNew('d3geoip'); + /** @var $oCountryList oxcountrylist */ $oCountryList = oxNew('oxcountrylist'); - if ($oCountryList->getBaseObject()->isMultilang()) - { - $oCountryList->getBaseObject()->setLanguage(oxLang::getInstance()->getTplLanguage()); - } $oListObject = $oCountryList->getBaseObject(); $sFieldList = $oListObject->getSelectFields(); $sQ = "select (SELECT d3startip FROM ".$oGeoIp->getViewName()." WHERE D3ISO = " .$oListObject->getViewName(). ".oxisoalpha2 LIMIT 1) as IP, $sFieldList from " . $oListObject->getViewName(); $oCountryList->selectString($sQ); + stopProfile(__METHOD__); + return $oCountryList; } } \ No newline at end of file diff --git a/copy_this/modules/d3/d3geoip/controllers/admin/d3_country_geoip.php b/copy_this/modules/d3/d3geoip/controllers/admin/d3_country_geoip.php index ce143ae..3c33d68 100644 --- a/copy_this/modules/d3/d3geoip/controllers/admin/d3_country_geoip.php +++ b/copy_this/modules/d3/d3geoip/controllers/admin/d3_country_geoip.php @@ -1,85 +1,118 @@ + * @link http://www.oxidmodule.com + */ + class d3_country_geoip extends oxAdminView { protected $_sDefSort = 'sort'; - + protected $_sDefSortOrder = 'asc'; protected $_sThisTemplate = 'd3_country_geoip.tpl'; - - private $_oSet; - private $_sModId = 'd3_geoip'; + /** @var oxcountry */ + public $oCountry; + /** @var oxshoplist */ + public $oShopList; + /** + * @return string + */ public function render() { - $this->_oSet = d3_cfg_mod::get($this->_sModId); - - $myConfig = $this->getConfig(); - - if ( !$myConfig->getConfigParam( 'blAllowSharedEdit' ) ) - $this->_aViewData['readonly'] = true; + if ( !oxRegistry::getConfig()->getConfigParam( 'blAllowSharedEdit' ) ) + { + $this->addTplParam('readonly', TRUE); + } $ret = parent::render(); - $soxId = oxConfig::getParameter( "oxid"); + $soxId = oxRegistry::getConfig()->getRequestParameter("oxid"); // check if we right now saved a new entry - $sSavedID = oxConfig::getParameter( "saved_oxid"); - if ( ($soxId == "-1" || !isset( $soxId)) && isset( $sSavedID) ) { + $sSavedID = oxRegistry::getConfig()->getRequestParameter("saved_oxid"); + if ( ($soxId == "-1" || !isset( $soxId)) && isset( $sSavedID) ) + { $soxId = $sSavedID; - oxSession::deleteVar( "saved_oxid"); - $this->_aViewData["oxid"] = $soxId; + oxRegistry::getSession()->deleteVariable("saved_oxid"); + $this->addTplParam("oxid",$soxId); // for reloading upper frame - $this->_aViewData["updatelist"] = "1"; + $this->addTplParam("updatelist", "1"); } - if ( $soxId != "-1" && isset( $soxId)) { + if ( $soxId != "-1" && isset( $soxId)) + { // load object + /** @var $oCountry oxcountry */ $oCountry = oxNew( "oxcountry" ); $oCountry->loadInLang( $this->_iEditLang, $soxId ); - if ($oCountry->isForeignCountry()) { - $this->_aViewData["blForeignCountry"] = true; - } else { - $this->_aViewData["blForeignCountry"] = false; + if ($oCountry->isForeignCountry()) + { + $this->addTplParam("blForeignCountry", TRUE); + } + else + { + $this->addTplParam("blForeignCountry", FALSE); } $oOtherLang = $oCountry->getAvailableInLangs(); - if (!isset($oOtherLang[$this->_iEditLang])) { - // echo "language entry doesn't exist! using: ".key($oOtherLang); + if (!isset($oOtherLang[$this->_iEditLang])) + { $oCountry->loadInLang( key($oOtherLang), $soxId ); } - $this->_aViewData["edit"] = $this->oCountry = $oCountry; + + $this->oCountry = $oCountry; + $this->addTplParam("edit", $oCountry); // remove already created languages - $aLang = array_diff (oxLang::getInstance()->getLanguageNames(), $oOtherLang ); - if ( count( $aLang)) - $this->_aViewData["posslang"] = $aLang; + $aLang = array_diff (oxRegistry::getLang()->getLanguageNames(), $oOtherLang ); - foreach ( $oOtherLang as $id => $language) { - $oLang= new oxStdClass(); + if ( count( $aLang)) + { + $this->addTplParam("posslang", $aLang); + } + + foreach ( $oOtherLang as $id => $language) + { + $oLang= new stdClass(); $oLang->sLangDesc = $language; $oLang->selected = ($id == $this->_iEditLang); $this->_aViewData["otherlang"][$id] = clone $oLang; } - } else { - $this->_aViewData["blForeignCountry"] = true; + } + else + { + $this->addTplParam("blForeignCountry", TRUE); } - $this->oShopList = &oxNew('oxshoplist'); - $oShop = &oxNew('oxshop'); + $this->oShopList = oxNew('oxshoplist'); + /** @var $oShop oxshop */ + $oShop = oxNew('oxshop'); $sSelect = "SELECT * FROM ".$oShop->getViewName()." WHERE ".$oShop->getSqlActiveSnippet(); - $this->oShopList->selectString($sSelect); - $this->getLangList(); return $ret; } + /** + * @param $sIdent + * @return mixed + */ public function getModCfgValue($sIdent) { - $this->_oSet = d3_cfg_mod::get($this->_sModId); - return $this->_oSet->getValue($sIdent); + return d3_cfg_mod::get($this->_sModId)->getValue($sIdent); } public function saveshop() @@ -94,42 +127,53 @@ class d3_country_geoip extends oxAdminView public function save() { - $myConfig = $this->getConfig(); - //allow malladmin only to perform this action - if ( !$myConfig->getConfigParam( 'blAllowSharedEdit' ) ) + if ( !oxRegistry::getConfig()->getConfigParam( 'blAllowSharedEdit' ) ) + { return; - - $soxId = oxConfig::getParameter( "oxid"); - $aParams = oxConfig::getParameter( "editval" ); - - $oCountry = oxNew( "oxcountry" ); - - if ( $soxId != "-1") { - $oCountry->loadInLang( $this->_iEditLang, $soxId ); - } else { - $aParams['oxcountry__oxid'] = null; } - //$aParams = $oCountry->ConvertNameArray2Idx( $aParams); + $soxId = oxRegistry::getConfig()->getRequestParameter("oxid"); + $aParams = oxRegistry::getConfig()->getRequestParameter("editval" ); + + /** @var $oCountry oxcountry */ + $oCountry = oxNew( "oxcountry" ); + + if ( $soxId != "-1") + { + $oCountry->loadInLang( $this->_iEditLang, $soxId ); + } + else + { + $aParams['oxcountry__oxid'] = NULL; + } + $oCountry->setLanguage(0); $oCountry->assign( $aParams ); $oCountry->setLanguage($this->_iEditLang); - $oCountry = oxUtilsFile::getInstance()->processFiles( $oCountry ); + $oCountry = oxRegistry::get('oxUtilsFile')->processFiles( $oCountry ); $oCountry->save(); - $this->_aViewData["updatelist"] = "1"; + $this->addTplParam("updatelist", "1"); // set oxid if inserted if ( $soxId == "-1") - oxSession::setVar( "saved_oxid", $oCountry->oxcountry__oxid->value); + { + oxRegistry::getSession()->setVariable( "saved_oxid", $oCountry->getId()); + } } + /** + * @return oxshoplist + */ public function getShopList() { return $this->oShopList; } + /** + * @return array + */ public function getCurList() { $aCurrencies = array(); @@ -140,12 +184,13 @@ class d3_country_geoip extends oxAdminView } else { - $sShopId = $this->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'"; - $sCurs = oxDb::getDb(2)->getOne($sQ); + $sCurs = oxDb::getDb(oxDb::FETCH_MODE_ASSOC)->getOne($sQ); + foreach (unserialize($sCurs) as $sKey => $sValue) { $aFields = explode('@', $sValue); @@ -157,6 +202,10 @@ class d3_country_geoip extends oxAdminView return $aCurrencies; } + /** + * ToDo: has to be refactored + * @return array + */ public function getLangList() { if ($this->getModCfgValue('blChangeShop') && $this->oCountry->getFieldData('d3geoipshop')) @@ -165,45 +214,56 @@ class d3_country_geoip extends oxAdminView } else { - $sShopId = $this->getConfig()->getActiveView()->getViewConfig()->getActiveShopId(); + $sShopId = oxRegistry::getConfig()->getActiveView()->getViewConfig()->getActiveShopId(); } $aLanguages = array(); - $aLangParams = $this->getConfig()->getShopConfVar('aLanguageParams', $sShopId); - $aConfLanguages = $this->getConfig()->getShopConfVar('aLanguages', $sShopId); + $aLangParams = oxRegistry::getConfig()->getShopConfVar('aLanguageParams', $sShopId); + $aConfLanguages = oxRegistry::getConfig()->getShopConfVar('aLanguages', $sShopId); - if ( is_array( $aConfLanguages ) ) { + if ( is_array( $aConfLanguages ) ) + { $i = 0; reset( $aConfLanguages ); - while ( list( $key, $val ) = each( $aConfLanguages ) ) { - - if ( $blOnlyActive && is_array($aLangParams) ) { + while ( list( $key, $val ) = each( $aConfLanguages ) ) + { + if (is_array($aLangParams) ) + { //skipping non active languages - if ( !$aLangParams[$key]['active'] ) { + if ( !$aLangParams[$key]['active'] ) + { $i++; continue; } } - if ( $val) { - $oLang = new oxStdClass(); - if ( isset($aLangParams[$key]['baseId']) ) { + if ( $val) + { + $oLang = new stdClass(); + if ( isset($aLangParams[$key]['baseId']) ) + { $oLang->id = $aLangParams[$key]['baseId']; - } else { + } + else + { $oLang->id = $i; } $oLang->oxid = $key; $oLang->abbr = $key; $oLang->name = $val; - if ( is_array($aLangParams) ) { + if ( is_array($aLangParams) ) + { $oLang->active = $aLangParams[$key]['active']; $oLang->sort = $aLangParams[$key]['sort']; } - if ( isset( $iLanguage ) && $oLang->id == $iLanguage ) { + if ( isset( $iLanguage ) && $oLang->id == $iLanguage ) + { $oLang->selected = 1; - } else { + } + else + { $oLang->selected = 0; } if ($oLang->active) @@ -213,22 +273,30 @@ class d3_country_geoip extends oxAdminView } } - if ( $blSort && is_array($aLangParams) ) { + if (is_array($aLangParams) ) { uasort( $aLanguages, array($this, '_sortLanguagesCallback') ); } return $aLanguages; } + /** + * @param $oLang1 + * @param $oLang2 + * @return int + */ protected function _sortLanguagesCallback( $oLang1, $oLang2 ) { $sSortParam = $this->_sDefSort; $sVal1 = is_string($oLang1->$sSortParam) ? strtolower( $oLang1->$sSortParam ) : $oLang1->$sSortParam; $sVal2 = is_string($oLang2->$sSortParam) ? strtolower( $oLang2->$sSortParam ) : $oLang2->$sSortParam; - if ( $this->_sDefSortOrder == 'asc' ) { + if ( $this->_sDefSortOrder == 'asc' ) + { return ($sVal1 < $sVal2) ? -1 : 1; - } else { + } + else + { return ($sVal1 > $sVal2) ? -1 : 1; } } diff --git a/copy_this/modules/d3/d3geoip/models/d3geoip.php b/copy_this/modules/d3/d3geoip/models/d3geoip.php index 4ffe108..b336537 100644 --- a/copy_this/modules/d3/d3geoip/models/d3geoip.php +++ b/copy_this/modules/d3/d3geoip/models/d3geoip.php @@ -1,38 +1,29 @@ +/** + * 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 + * @link http://www.oxidmodule.com + */ class d3GeoIP extends oxI18n { - /** - * Current class name - * - * @var string - */ protected $_sClassName = 'd3geoip'; - - /** - * ModCfg ID - * - * @var string - */ private $_sModId = 'd3_geoip'; + public $oCountry; + public $oD3Log; /** * Class constructor, initiates parent constructor (parent::oxI18n()). - * - * @return null */ public function __construct() { @@ -44,26 +35,28 @@ class d3GeoIP extends oxI18n * get oxcountry object by given IP address (optional) * * @param string $sIP optional - * @return object + * @return oxcountry */ - public function getUserLocationCountryObject($sIP = false) + public function getUserLocationCountryObject($sIP = null) { if (!$this->oCountry) { if (!$sIP) + { $sIP = $this->getIP(); + } $iIPNum = $this->_getNumIp($sIP); $sISOAlpha = $this->LoadByIPNum($iIPNum); if (!$sISOAlpha) { - $this->_getLog()->setLog('error', __CLASS__, __FUNCTION__, __LINE__, 'get ISO by IP failed', $sIP); + $this->_getLog()->log('error', __CLASS__, __FUNCTION__, __LINE__, 'get ISO by IP failed', $sIP); $this->oCountry = $this->getCountryFallBackObject(); } else { - $this->_getLog()->setLog('info', __CLASS__, __FUNCTION__, __LINE__, 'get ISO by IP', $sIP." => ".$sISOAlpha); + $this->_getLog()->log('info', __CLASS__, __FUNCTION__, __LINE__, 'get ISO by IP', $sIP." => ".$sISOAlpha); $this->oCountry = $this->getCountryObject($sISOAlpha); } } @@ -79,11 +72,17 @@ class d3GeoIP extends oxI18n public function getIP() { if ($this->_getModConfig()->getValue('blUseTestIp') && $this->_getModConfig()->getValue('sTestIp')) + { return $this->_getModConfig()->getValue('sTestIp'); + } elseif ($this->_getModConfig()->getValue('blUseTestCountry') && $this->_getModConfig()->getValue('sTestCountryIp')) + { return $this->_getModConfig()->getValue('sTestCountryIp'); + } else + { return $_SERVER['REMOTE_ADDR']; + } } /** @@ -115,7 +114,7 @@ class d3GeoIP extends oxI18n * get oxcountry object by ISO alpha 2 ID * * @param string $sISOAlpha - * @return object + * @return oxcountry */ public function getCountryObject($sISOAlpha) { @@ -144,21 +143,6 @@ class d3GeoIP extends oxI18n return $oCountry; } -/* - 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; - } -*/ - /** * check module active state and set user country specific language * @@ -168,17 +152,17 @@ class d3GeoIP extends oxI18n $this->performURLSwitch(); $this->performShopSwitch(); - if (!$this->_getModConfig()->getFieldData('oxactive') || !$this->_getModConfig()->getValue('blChangeLang')) + if (!$this->_getModConfig()->isActive() || !$this->_getModConfig()->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() && oxRegistry::getUtils()->isSearchEngine() === false && oxRegistry::getSession()->getVariable('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); + $this->_getLog()->log('info', __CLASS__, __FUNCTION__, __LINE__, 'set language', $this->getIP().' => '.$oCountry->getFieldData('d3geoiplang')); + oxRegistry::getLang()->setTplLanguage((int) $oCountry->getFieldData('d3geoiplang')); + oxRegistry::getLang()->setBaseLanguage((int) $oCountry->getFieldData('d3geoiplang')); + oxRegistry::getSession()->setVariable('d3isSetLang', true); } } @@ -188,16 +172,16 @@ class d3GeoIP extends oxI18n */ public function setCountryCurrency() { - if (!$this->_getModConfig()->getFieldData('oxactive') || !$this->_getModConfig()->getValue('blChangeCurr')) + if (!$this->_getModConfig()->isActive() || !$this->_getModConfig()->getValue('blChangeCurr')) return; $oCountry = $this->getUserLocationCountryObject(); - if (!$this->isAdmin() && oxUtils::getInstance()->isSearchEngine() === false && !$this->getSession()->getVar('d3isSetCurr') && $oCountry->getId() && $oCountry->getFieldData('d3geoipcur') > -1) + if (!$this->isAdmin() && oxRegistry::getUtils()->isSearchEngine() === false && !oxRegistry::getSession()->getVariable('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); + $this->_getLog()->log('info', __CLASS__, __FUNCTION__, __LINE__, 'set currency', $this->getIP().' => '.$oCountry->getFieldData('d3geoipcur')); + oxRegistry::getConfig()->setActShopCurrency((int) $oCountry->getFieldData('d3geoipcur')); + oxRegistry::getSession()->setVariable('d3isSetCurr', true); } } @@ -207,16 +191,14 @@ class d3GeoIP extends oxI18n */ public function performShopSwitch() { - if (!$this->_getModConfig()->getFieldData('oxactive') || !$this->_getModConfig()->getValue('blChangeShop')) + if (!$this->_getModConfig()->isActive() || !$this->_getModConfig()->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()) + if (!$this->isAdmin() && oxRegistry::getUtils()->isSearchEngine() === false && $oCountry->getId() && $this->getConfig()->isMall() && $iNewShop > -1 && $iNewShop != $this->getConfig()->getShopId()) { $oNewConf = new oxConfig(); $oNewConf->setShopId($iNewShop); @@ -224,12 +206,16 @@ class d3GeoIP extends oxI18n $this->getConfig()->onShopChange(); - if (!$this->getSession()->getVar('d3isSetLang') && $oCountry->getFieldData('d3geoiplang') > -1) + if (!oxRegistry::getSession()->getVariable('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)); + $this->_getLog()->log('info', __CLASS__, __FUNCTION__, __LINE__, 'change shop', $this->getIP().' => '.$oNewConf->getShopHomeUrl($sLangId)); header("Location: ".$oNewConf->getShopHomeUrl($sLangId)); exit(); @@ -242,16 +228,18 @@ class d3GeoIP extends oxI18n */ public function performURLSwitch() { - if (!$this->_getModConfig()->getFieldData('oxactive') || !$this->_getModConfig()->getValue('blChangeURL')) + if (!$this->_getModConfig()->isActive() || !$this->_getModConfig()->getValue('blChangeURL')) + { return; + } $oCountry = $this->getUserLocationCountryObject(); - if (!$this->isAdmin() && oxUtils::getInstance()->isSearchEngine() === false && $oCountry->getId() && $oCountry->getFieldData('d3geoipurl') && strlen(trim($oCountry->getFieldData('d3geoipurl'))) > 0) + if (!$this->isAdmin() && oxRegistry::getUtils()->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')); + $this->_getLog()->log('info', __CLASS__, __FUNCTION__, __LINE__, 'change url', $this->getIP().' => '.$oCountry->getFieldData('d3geoipurl')); header("Location: ".$sNewUrl); exit(); @@ -268,7 +256,8 @@ class d3GeoIP extends oxI18n $oShoplist = oxNew( 'oxshoplist' ); $oShoplist->getList(); $aShopUrls = array(); - foreach ( $oShoplist as $sId => $oShop ) { + foreach ( $oShoplist as $sId => $oShop ) + { $aShopUrls[$sId] = $this->getConfig()->getShopConfVar( 'sMallShopURL', $sId ); } @@ -278,7 +267,7 @@ class d3GeoIP extends oxI18n /** * get modcfg instance * - * @return object + * @return d3_cfg_mod */ protected function _getModConfig() { @@ -288,12 +277,14 @@ class d3GeoIP extends oxI18n /** * get d3log instance * - * @return object + * @return d3log */ protected function _getLog() { if (!$this->oD3Log) - $this->oD3Log = $this->_getModConfig()->getLogInstance(); + { + $this->oD3Log = $this->_getModConfig()->getLog(); + } return $this->oD3Log; } diff --git a/copy_this/modules/d3/d3geoip/models/d3geoip_update.php b/copy_this/modules/d3/d3geoip/models/d3geoip_update.php index 86fb951..6d27c36 100644 --- a/copy_this/modules/d3/d3geoip/models/d3geoip_update.php +++ b/copy_this/modules/d3/d3geoip/models/d3geoip_update.php @@ -38,6 +38,8 @@ nc9'; 'do' => 'updateModCfgItemExist'), array('check' => 'checkFields', 'do' => 'fixFields'), + array('check' => 'checkIndizes', + 'do' => 'fixIndizes'), array('check' => 'checkModCfgSameRevision', 'do' => 'updateModCfgSameRevision'), ); @@ -149,6 +151,23 @@ nc9'; ); public $aIndizes = array( + 'IPNUM' => array( + 'sTableName' => 'd3geoip', + 'sType' => 'INDEX', + 'sName' => 'IPNUM', + 'aFields' => array( + 'D3STARTIPNUM' => 'D3STARTIPNUM', + 'D3ENDIPNUM' => 'D3ENDIPNUM', + ), + ), + 'D3ISO' => array( + 'sTableName' => 'd3geoip', + 'sType' => 'INDEX', + 'sName' => 'D3ISO', + 'aFields' => array( + 'D3ISO' => 'D3ISO', + ), + ), ); /** diff --git a/copy_this/modules/d3/d3geoip/modules/components/d3_oxcmp_cur_geoip.php b/copy_this/modules/d3/d3geoip/modules/components/d3_oxcmp_cur_geoip.php index 718b402..2f088d2 100644 --- a/copy_this/modules/d3/d3geoip/modules/components/d3_oxcmp_cur_geoip.php +++ b/copy_this/modules/d3/d3geoip/modules/components/d3_oxcmp_cur_geoip.php @@ -1,20 +1,41 @@ + * @link http://www.oxidmodule.com + */ class d3_oxcmp_cur_geoip extends d3_oxcmp_cur_geoip_parent { private $_sModId = 'd3_geoip'; + /** + * @return null + */ public function init() { - if (d3_cfg_mod::get($this->_sModId)->getValue('blDebugmodeGlobal')) + if (d3_cfg_mod::get($this->_sModId)->isActive()) { - $oGeoIp = oxNew('d3geoip'); - echo $oGeoIp->getIP(); - } + if (d3_cfg_mod::get($this->_sModId)->hasDebugMode()) + { + /** @var $oGeoIp d3geoip */ + $oGeoIp = oxNew('d3geoip'); + echo $oGeoIp->getIP(); + } - $oLocation = oxNew('d3geoip'); - //$oLocation->setUserCountry(); - $oLocation->setCountryCurrency(); + /** @var $oLocation d3geoip */ + $oLocation = oxNew('d3geoip'); + $oLocation->setCountryCurrency(); + } return parent::init(); } diff --git a/copy_this/modules/d3/d3geoip/modules/components/d3_oxcmp_lang_geoip.php b/copy_this/modules/d3/d3geoip/modules/components/d3_oxcmp_lang_geoip.php index 929670a..b585a5b 100644 --- a/copy_this/modules/d3/d3geoip/modules/components/d3_oxcmp_lang_geoip.php +++ b/copy_this/modules/d3/d3geoip/modules/components/d3_oxcmp_lang_geoip.php @@ -1,12 +1,34 @@ + * @link http://www.oxidmodule.com + */ class d3_oxcmp_lang_geoip extends d3_oxcmp_lang_geoip_parent { + private $_sModId = "d3_geoip"; + + /** + * @return null + */ public function init() { - $oLocation = oxNew('d3geoip'); - //$oLocation->setUserCountry(); - $oLocation->setCountryLanguage(); + if (d3_cfg_mod::get($this->_sModId)->isActive()) + { + /** @var $oLocation d3geoip */ + $oLocation = oxNew('d3geoip'); + $oLocation->setCountryLanguage(); + } return parent::init(); } diff --git a/copy_this/modules/d3/d3geoip/views/admin/tpl/d3_cfg_geoipset_main.tpl b/copy_this/modules/d3/d3geoip/views/admin/tpl/d3_cfg_geoipset_main.tpl index df40a90..98f6cc7 100644 --- a/copy_this/modules/d3/d3geoip/views/admin/tpl/d3_cfg_geoipset_main.tpl +++ b/copy_this/modules/d3/d3geoip/views/admin/tpl/d3_cfg_geoipset_main.tpl @@ -1,7 +1,5 @@ [{include file="headitem.tpl" title="GENERAL_ADMIN_TITLE"|oxmultilangassign}] - -