GeoIP/copy_this/modules/d3/d3geoip/controllers/admin/d3_cfg_geoipset_main.php

77 lines
2.2 KiB
PHP
Raw Normal View History

<?php
2013-04-22 11:40:11 +02:00
/**
* 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";
2015-06-23 11:29:07 +02:00
protected $_blHasDebugSwitch = true;
2013-04-22 11:40:11 +02:00
protected $_sDebugHelpTextIdent = 'D3_GEOIP_SET_DEBUG_DESC';
2016-11-21 16:34:21 +01:00
protected $_sMenuItemTitle = 'd3mxgeoip';
protected $_sMenuSubItemTitle = 'd3mxgeoip_settings';
public $oCountryList;
2013-04-22 11:25:27 +02:00
2013-04-22 11:40:11 +02:00
/**
* @param $sIP
* @return string
*/
public function getIpCountry($sIP)
{
2013-04-22 11:40:11 +02:00
startProfile(__METHOD__);
/** @var $oD3GeoIP d3geoip */
$oD3GeoIP = oxNew('d3geoip');
$oCountry = $oD3GeoIP->getUserLocationCountryObject($sIP);
2015-06-23 11:29:07 +02:00
if ($oCountry->getId()) {
$sTitle = $oCountry->getFieldData('oxtitle');
2015-06-23 11:29:07 +02:00
} else {
2013-04-22 11:40:11 +02:00
$sTitle = oxRegistry::getLang()->translateString('D3_GEOIP_SET_IP_CHECKIP_NOTSET');
}
stopProfile(__METHOD__);
return $sTitle;
}
2013-04-22 11:25:27 +02:00
2013-04-22 11:40:11 +02:00
/**
* @return oxcountrylist
*/
2013-04-22 11:25:27 +02:00
public function getIPCountryList()
{
2016-11-21 16:34:21 +01:00
if ($this->oCountryList) {
return $this->oCountryList;
}
2013-04-22 11:40:11 +02:00
2016-11-21 16:34:21 +01:00
startProfile(__METHOD__);
2013-04-22 11:40:11 +02:00
/** @var $oGeoIp d3geoip */
2013-04-22 11:25:27 +02:00
$oGeoIp = oxNew('d3geoip');
2013-04-22 11:40:11 +02:00
/** @var $oCountryList oxcountrylist */
2016-11-21 16:34:21 +01:00
$this->oCountryList = oxNew('oxcountrylist');
$oListObject = $this->oCountryList->getBaseObject();
2013-04-22 11:25:27 +02:00
$sFieldList = $oListObject->getSelectFields();
2015-06-23 11:29:07 +02:00
$sQ = "select (SELECT d3startip FROM ".$oGeoIp->getViewName().
" WHERE D3ISO = " .$oListObject->getViewName(). ".
oxisoalpha2 LIMIT 1) as IP, $sFieldList from " . $oListObject->getViewName();
2013-04-22 11:25:27 +02:00
2016-11-21 16:34:21 +01:00
$this->oCountryList->selectString($sQ);
2013-04-22 11:25:27 +02:00
2013-04-22 11:40:11 +02:00
stopProfile(__METHOD__);
2016-11-21 16:34:21 +01:00
return $this->oCountryList;
2013-04-22 11:25:27 +02:00
}
2015-06-23 11:29:07 +02:00
}