GeoIP/src/Application/Controller/Admin/d3_cfg_geoipset_main.php

91 lignes
2.9 KiB
PHP
Brut Vue normale Historique

<?php
2020-04-17 09:29:09 +02:00
namespace D3\GeoIp\Application\Controller\Admin;
use D3\GeoIp\Application\Model\d3geoip;
use D3\ModCfg\Application\Controller\Admin\d3_cfg_mod_main;
use OxidEsales\Eshop\Application\Model\CountryList;
use OxidEsales\Eshop\Core\Registry;
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
2020-04-17 09:29:09 +02:00
* @throws \D3\ModCfg\Application\Model\Exception\d3ShopCompatibilityAdapterException
* @throws \D3\ModCfg\Application\Model\Exception\d3_cfg_mod_exception
* @throws \Doctrine\DBAL\DBALException
* @throws \OxidEsales\Eshop\Core\Exception\DatabaseConnectionException
* @throws \OxidEsales\Eshop\Core\Exception\DatabaseErrorException
* @throws \OxidEsales\Eshop\Core\Exception\StandardException
2013-04-22 11:40:11 +02:00
*/
public function getIpCountry($sIP)
{
2013-04-22 11:40:11 +02:00
startProfile(__METHOD__);
/** @var $oD3GeoIP d3geoip */
2020-04-17 09:29:09 +02:00
$oD3GeoIP = oxNew(d3geoip::class);
$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 {
2020-04-17 09:29:09 +02:00
$sTitle = Registry::getLang()->translateString('D3_GEOIP_SET_IP_CHECKIP_NOTSET');
2013-04-22 11:40:11 +02:00
}
stopProfile(__METHOD__);
return $sTitle;
}
2013-04-22 11:25:27 +02:00
2013-04-22 11:40:11 +02:00
/**
2020-04-17 09:29:09 +02:00
* @return CountryList
2013-04-22 11:40:11 +02:00
*/
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__);
2020-04-17 09:29:09 +02:00
/** @var $oGeoIp d3geoip */
$oGeoIp = oxNew(d3geoip::class);
/** @var $oCountryList CountryList */
$this->oCountryList = oxNew(CountryList::class);
2016-11-21 16:34:21 +01:00
$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();
$sQ.= " ORDER BY oxactive DESC, oxtitle";
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
}