This commit is contained in:
Daniel Seifert 2009-12-15 08:52:22 +00:00
bovenliggende 429c6cd8c5
commit e9235b0073
7 gewijzigde bestanden met toevoegingen van 107744 en 0 verwijderingen

6
.gitattributes vendored
Bestand weergeven

@ -1 +1,7 @@
* text=auto !eol
copy_this/core/d3geoip.php -text
copy_this/modules/d3_geoip/views/d3_oxcmp_cur_geoip.php -text
copy_this/modules/d3_geoip/views/d3_oxcmp_lang_geoip.php -text
setup+doku/install.sql -text
setup+doku/install.txt -text
setup+doku/licence.txt -text

107
copy_this/core/d3geoip.php Normal file
Bestand weergeven

@ -0,0 +1,107 @@
<?php
class d3GeoIP extends oxI18n
{
/**
* Current class name
*
* @var string
*/
protected $_sClassName = 'd3geoip';
/**
* Class constructor, initiates parent constructor (parent::oxI18n()).
*
* @return null
*/
public function __construct()
{
parent::__construct();
$this->init('d3geoip');
}
public function getUserLocationCountryObject()
{
if (!$this->oCountry)
{
$sIP = $_SERVER['REMOTE_ADDR'];
/*
$sIP = '62.4.77.32';
$sIP = '62.4.77.48';
$sIP = '41.188.100.127';
*/
$iIPNum = $this->_getNumIp($sIP);
$sISOAlpha = $this->LoadByIPNum($iIPNum);
$this->oCountry = $this->getCountryObject($sISOAlpha);
}
return $this->oCountry;
}
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."'";
$oCountry->load(oxDb::getDb()->getOne($sSelect));
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;
}
public function setCountryLanguage()
{
$oCountry = $this->getUserLocationCountryObject();
$aCountryLangs = $this->getConfig()->getConfigParam('aCountryLangs');
if (!$this->getSession()->getVar('d3isSetLang') && $aCountryLangs && $oCountry->getFieldData('oxisoalpha2') && isset($aCountryLangs[$oCountry->getFieldData('oxisoalpha2')]))
{
$iNewLanguage = $aCountryLangs[$oCountry->getFieldData('oxisoalpha2')];
oxLang::getInstance()->setTplLanguage((int) $iNewLanguage);
oxLang::getInstance()->setBaseLanguage((int) $iNewLanguage);
$this->getSession()->setVar('d3isSetLang', true);
}
}
public function setCountryCurrency()
{
$oCountry = $this->getUserLocationCountryObject();
$aCountryCurrs = $this->getConfig()->getConfigParam('aCountryCurrs');
if (!$this->getSession()->getVar('d3isSetCurr') && $aCountryCurrs && $oCountry->getFieldData('oxisoalpha2') && isset($aCountryCurrs[$oCountry->getFieldData('oxisoalpha2')]))
{
$iNewCurrency = $aCountryCurrs[$oCountry->getFieldData('oxisoalpha2')];
$this->getConfig()->setActShopCurrency((int) $iNewCurrency );
$this->getSession()->setVar('d3isSetCurr', true);
}
}
}

Bestand weergeven

@ -0,0 +1,16 @@
<?
class d3_oxcmp_cur_geoip extends d3_oxcmp_cur_geoip_parent
{
public function init()
{
$oLocation = &oxNew('d3geoip');
$oLocation->setUserCountry();
$oLocation->setCountryCurrency();
return parent::init();
}
}

Bestand weergeven

@ -0,0 +1,13 @@
<?
class d3_oxcmp_lang_geoip extends d3_oxcmp_lang_geoip_parent
{
public function init()
{
$oLocation = &oxNew('d3geoip');
$oLocation->setUserCountry();
$oLocation->setCountryLanguage();
return parent::init();
}
}

107579
setup+doku/install.sql Normal file

Diff onderdrukt omdat het te groot bestand Laad Diff

17
setup+doku/install.txt Normal file
Bestand weergeven

@ -0,0 +1,17 @@
oxcmp_cur => d3_geoip/views/d3_oxcmp_cur_geoip
oxcmp_lang => d3_geoip/views/d3_oxcmp_lang_geoip
config.inc.php:
// Key ist ISO-Alpha2-Code in Großbuchstaben (analog Datenbank) // Value ist ID der Sprache (beginnend bei 0)
$this->aCountryLangs = array();
$this->aCountryLangs['DE'] = 0;
$this->aCountryLangs['EN'] = 1;
$this->aCountryLangs['MR'] = 1;
// Key ist ISO-Alpha2-Code in Großbuchstaben (analog Datenbank) // Value ist ID der Währung (beginnend bei 0)
$this->aCountryCurrs = array();
$this->aCountryCurrs['DE'] = 0;
$this->aCountryCurrs['EN'] = 1;
$this->aCountryCurrs['MR'] = 1;

6
setup+doku/licence.txt Normal file
Bestand weergeven

@ -0,0 +1,6 @@
GeoIP Country light
GeoIp-Data based on GeoIp Country Light by Maxmind (July 2009).
These database will be published under GPL3 by Maxmind. Please see www.maxmind.com for updates.
Maxmind offers more accuracy data for cash. More informations about this you'll find on www.maxmind.com.