basic implementation

This commit is contained in:
Daniel Seifert 2013-04-22 09:40:11 +00:00
parent d951ed09c7
commit 5106a4ec0b
13 changed files with 958 additions and 314 deletions

5
.gitattributes vendored
View File

@ -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

View File

@ -1,66 +1,90 @@
<?php
// @copyright © D³ Data Development
//
// 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 key
// is a violation of the license agreement and will be prosecuted by
// civil and criminal law.
//
// http://www.shopmodule.com
// AUTOR Daniel Seifert <ds@shopmodule.com>
/**
* 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 <ds@shopmodule.com>
* @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;
}
}

View File

@ -1,85 +1,118 @@
<?php
/**
* 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 <ds@shopmodule.com>
* @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;
}
}

View File

@ -1,38 +1,29 @@
<?php
// @copyright © D³ Data Development
//
// 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 key
// is a violation of the license agreement and will be prosecuted by
// civil and criminal law.
//
// http://www.shopmodule.com
// AUTOR Daniel Seifert <ds@shopmodule.com>
/**
* 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 <ds@shopmodule.com>
* @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;
}

View File

@ -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',
),
),
);
/**

View File

@ -1,20 +1,41 @@
<?php
/**
* 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 <ds@shopmodule.com>
* @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();
}

View File

@ -1,12 +1,34 @@
<?php
/**
* 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 <ds@shopmodule.com>
* @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();
}

View File

@ -1,7 +1,5 @@
[{include file="headitem.tpl" title="GENERAL_ADMIN_TITLE"|oxmultilangassign}]
<link rel="stylesheet" type="text/css" href="[{$oViewConf->getResourceUrl() }]d3_mod_cfg.css">
<script type="text/javascript">
<!--
[{ if $updatelist == 1}]
@ -137,69 +135,7 @@ td.edittext {
<tr>
<td valign="top" class="edittext">
<table style="width: 100%">
<tr>
<td style="width:50%; border-right: 1px solid #999;">
<table cellspacing="0" cellpadding="0" border="0" width="100%">
<tr>
<td class="edittext ext_edittext">
[{oxmultilang ident="D3_CFG_MOD_GENERAL_MODULEACTIVE"}]
</td>
<td class="edittext ext_edittext">
<input type="hidden" name="editval[d3_cfg_mod__oxactive]" value='0'>
<input class="edittext ext_edittext" type="checkbox" name="editval[d3_cfg_mod__oxactive]" value='1' [{if $edit->d3_cfg_mod__oxactive->value == 1}]checked[{/if}]>
[{oxinputhelp ident="D3_CFG_MOD_GENERAL_MODULEACTIVE_DESC"}]
</td>
</tr>
<tr>
<td class="edittext ext_edittext">
</td>
<td class="edittext ext_edittext">
</td>
</tr>
<tr>
<td class="edittext ext_edittext">
[{if $edit->getValue('blDebugmodeGlobal') == 1}]<span style="font-weight: bold; color: #CD0210;">[{/if}][{oxmultilang ident="D3_CFG_MOD_GENERAL_DEBUGACTIVE"}][{if $edit->getValue('blDebugmodeGlobal') == 1}]</span>[{/if}]&nbsp;
</td>
<td class="edittext ext_edittext">
<input type="hidden" name="value[blDebugmodeGlobal]" value="0">
<input class="edittext ext_edittext" type="checkbox" name="value[blDebugmodeGlobal]" value='1' [{if $edit->getValue('blDebugmodeGlobal') == 1}]checked[{/if}]>
[{oxinputhelp ident="D3_GEOIP_SET_DEBUG_DESC"}]
</td>
</tr>
</table>
</td>
<td>
[{assign var="blD3HasLog" value=$oView->checkD3Log() }]
<table cellspacing="0" cellpadding="0" border="0">
<tr>
<td class="edittext ext_edittext" style="width: 100%;">
[{if $blD3HasLog}]
[{oxmultilang ident="D3_CFG_MOD_GENERAL_MODULELOGGING"}]
[{/if}]
</td>
<td class="edittext ext_edittext" align="left">
[{if $blD3HasLog}]
<select name="editval[d3_cfg_mod__oxismodulelog]" class="edittext">
<option value="0" [{if $edit->d3_cfg_mod__oxismodulelog->value == 0}]selected[{/if}]>[{oxmultilang ident="D3_CFG_MOD_GENERAL_MODULELOGGING_NONE"}]</option>
<option value="1" [{if $edit->d3_cfg_mod__oxismodulelog->value == 1}]selected[{/if}]>[{oxmultilang ident="D3_CFG_MOD_GENERAL_MODULELOGGING_ALL"}]</option>
<option value="2" [{if $edit->d3_cfg_mod__oxismodulelog->value == 2}]selected[{/if}]>[{oxmultilang ident="D3_CFG_MOD_GENERAL_MODULELOGGING_ERRORS"}]</option>
</select>
[{/if}]
</td>
</tr>
<tr>
<td class="edittext ext_edittext" style="width: 100%;">
&nbsp;
</td>
<td class="edittext ext_edittext" align="left">
&nbsp;
</td>
</tr>
</table>
</td>
</tr>
</table>
[{include file="d3_cfg_mod_active.tpl"}]
<div class="groupExp">
<div class="">
@ -339,5 +275,14 @@ td.edittext {
</table>
</form>
[{include file="d3_cfg_mod_inc.tpl"}]
[{include file="bottomitem.tpl"}]
<script type="text/javascript">
if (parent.parent) {
parent.parent.sShopTitle = "[{$actshopobj->oxshops__oxname->getRawValue()|oxaddslashes}]";
parent.parent.sMenuItem = "[{oxmultilang ident="d3mxgeoip"}]";
parent.parent.sMenuSubItem = "[{oxmultilang ident="d3mxgeoip_settings"}]";
parent.parent.sWorkArea = "[{$_act}]";
parent.parent.setTitle();
}
</script>

View File

@ -1,13 +0,0 @@
INSERT INTO `d3_cfg_mod` (`OXID`, `OXSHOPID`, `OXMODID`, `OXNAME`, `OXACTIVE`, `OXSERIAL`, `OXINSTALLDATE`, `OXVERSION`, `OXSHOPVERSION`, `OXISMODULELOG`, `OXREQUIREMENTS`, `OXVALUE`, `OXVALUE_1`, `OXVALUE_2`, `OXNEWREVISION`) VALUES
(MD5(RAND()), 1, 'd3_geoip', 'GeoIP', 1, '', NOW(), '2.1.2', 'EE4', 0, '', '', '', '', 26);
INSERT INTO `d3_cfg_mod` (`OXID`, `OXSHOPID`, `OXMODID`, `OXNAME`, `OXACTIVE`, `OXSERIAL`, `OXINSTALLDATE`, `OXVERSION`, `OXSHOPVERSION`, `OXISMODULELOG`, `OXREQUIREMENTS`, `OXVALUE`, `OXVALUE_1`, `OXVALUE_2`, `OXNEWREVISION`) VALUES
(MD5(RAND()), 2, 'd3_geoip', 'GeoIP', 1, '', NOW(), '2.1.2', 'EE4', 0, '', '', '', '', 26);
INSERT INTO `d3_cfg_mod` (`OXID`, `OXSHOPID`, `OXMODID`, `OXNAME`, `OXACTIVE`, `OXSERIAL`, `OXINSTALLDATE`, `OXVERSION`, `OXSHOPVERSION`, `OXISMODULELOG`, `OXREQUIREMENTS`, `OXVALUE`, `OXVALUE_1`, `OXVALUE_2`, `OXNEWREVISION`) VALUES
(MD5(RAND()), 3, 'd3_geoip', 'GeoIP', 1, '', NOW(), '2.1.2', 'EE4', 0, '', '', '', '', 26);
ALTER TABLE `oxcountry` ADD `D3GEOIPSHOP` VARCHAR( 10 ) NOT NULL DEFAULT '-1',
ADD `D3GEOIPLANG` TINYINT( 2 ) NOT NULL DEFAULT '-1',
ADD `D3GEOIPCUR` TINYINT( 2 ) NOT NULL DEFAULT '-1',
ADD `D3GEOIPURL` VARCHAR( 255 ) NOT NULL;
UPDATE `d3_cfg_mod` SET `OXREVISION` = `OXNEWREVISION` WHERE `OXMODID` = 'd3_geoip';

View File

@ -1,22 +0,0 @@
# ==== 1.0 EE4 => 1.1 EE4 ====
ALTER TABLE `d3geoip` CHANGE `D3STARTIPNUM` `D3STARTIPNUM` INT( 10 ) UNSIGNED NOT NULL ,
CHANGE `D3ENDIPNUM` `D3ENDIPNUM` INT( 10 ) UNSIGNED NOT NULL
# ==== 1.1 EE4 => 2.0.0 EE4 ====
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);
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);
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;
# ==== 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';
# ==== 2.1.0 PE4 => 2.1.1 PE4 ====
UPDATE `d3_cfg_mod` SET `OXVERSION` = '2.1.1', `OXREVISION` = '24', `OXNEWREVISION` = '24' WHERE OXMODID = 'd3_geoip';
# ==== 2.1.1 PE4 => 2.1.2 PE4 ====
UPDATE `d3_cfg_mod` SET `OXVERSION` = '2.1.2', `OXNEWREVISION` = '26' WHERE OXMODID = 'd3_geoip';
UPDATE `d3_cfg_mod` SET `OXREVISION` = `OXNEWREVISION` WHERE `OXMODID` = 'd3_geoip';

View File

@ -1,9 +0,0 @@
INSERT INTO `d3_cfg_mod` (`OXID`, `OXSHOPID`, `OXMODID`, `OXNAME`, `OXACTIVE`, `OXSERIAL`, `OXINSTALLDATE`, `OXVERSION`, `OXSHOPVERSION`, `OXISMODULELOG`, `OXREQUIREMENTS`, `OXVALUE`, `OXVALUE_1`, `OXVALUE_2`, `OXNEWREVISION`) VALUES
(MD5(RAND()), 'oxbaseshop', 'd3_geoip', 'GeoIP', 1, '', NOW(), '2.1.2', 'PE4', 0, '', '', '', '', 26);
ALTER TABLE `oxcountry` ADD `D3GEOIPSHOP` VARCHAR( 10 ) NOT NULL DEFAULT 'oxbaseshop',
ADD `D3GEOIPLANG` TINYINT( 2 ) NOT NULL DEFAULT '-1',
ADD `D3GEOIPCUR` TINYINT( 2 ) NOT NULL DEFAULT '-1',
ADD `D3GEOIPURL` VARCHAR( 255 ) NOT NULL;
UPDATE `d3_cfg_mod` SET `OXREVISION` = `OXNEWREVISION` WHERE `OXMODID` = 'd3_geoip';

View File

@ -1,24 +0,0 @@
# ==== 1.0 PE4 => 1.1 PE4 ====
ALTER TABLE `d3geoip` CHANGE `D3STARTIPNUM` `D3STARTIPNUM` INT( 10 ) UNSIGNED NOT NULL ,
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;
# ==== 2.0.0 PE4 => 2.1.0 PE4 ====
UPDATE `d3_cfg_mod` SET `OXVERSION` = '2.1.0', `OXNEWREVISION` = '18' WHERE OXMODID = 'd3_geoip';
ALTER TABLE `oxcountry` CHANGE `D3GEOIPSHOP` `D3GEOIPSHOP` VARCHAR( 10 ) NOT NULL DEFAULT 'oxbaseshop';
UPDATE `oxcountry` SET `D3GEOIPSHOP` = 'oxbaseshop' WHERE `D3GEOIPSHOP` = '-1';
UPDATE `d3_cfg_mod` SET `OXREVISION` = `OXNEWREVISION` WHERE OXMODID = 'd3_geoip';
# ==== 2.1.0 PE4 => 2.1.1 PE4 ====
UPDATE `d3_cfg_mod` SET `OXVERSION` = '2.1.1', `OXNEWREVISION` = '24' WHERE OXMODID = 'd3_geoip';
ALTER TABLE `oxcountry` CHANGE `D3GEOIPSHOP` `D3GEOIPSHOP` VARCHAR( 10 ) NOT NULL DEFAULT 'oxbaseshop';
UPDATE `oxcountry` SET `D3GEOIPSHOP` = 'oxbaseshop' WHERE `D3GEOIPSHOP` = '-1';
UPDATE `d3_cfg_mod` SET `OXREVISION` = `OXNEWREVISION` WHERE OXMODID = 'd3_geoip';
# ==== 2.1.1 PE4 => 2.1.2 PE4 ====
UPDATE `d3_cfg_mod` SET `OXVERSION` = '2.1.2', `OXNEWREVISION` = '26' WHERE OXMODID = 'd3_geoip';
UPDATE `d3_cfg_mod` SET `OXREVISION` = `OXNEWREVISION` WHERE `OXMODID` = 'd3_geoip';

625
setup+doku/d3precheck.php Normal file

File diff suppressed because one or more lines are too long