示例#1
0
文件: geo.php 项目: naka211/kkvn
 function getGeo($service)
 {
     if ($this->geo !== null) {
         return $this->geo;
     }
     require_once JPATH_PLUGINS . '/system/nnframework/helpers/functions.php';
     $func = new NNFrameworkFunctions();
     $ip = $_SERVER['REMOTE_ADDR'] == '127.0.0.1' ? '' : $_SERVER['REMOTE_ADDR'];
     switch ($service) {
         case 'geoplugin':
             if (!($geo = json_decode($func->getContents('http://www.geoplugin.net/json.gp?ip=' . $ip)))) {
                 $this->geo = false;
                 return false;
             }
             if (isset($geo->geoplugin_status) && $geo->geoplugin_status == 404) {
                 $this->geo = false;
                 return false;
             }
             $this->geo = (object) array('continent' => isset($geo->geoplugin_continentCode) ? $geo->geoplugin_continentCode : '', 'country' => isset($geo->geoplugin_countryCode) ? $geo->geoplugin_countryCode : '', 'region' => isset($geo->geoplugin_regionCode) ? $geo->geoplugin_regionCode : '');
             break;
         case 'telize':
         default:
             if (!($geo = json_decode($func->getContents('http://www.telize.com/geoip/' . $ip)))) {
                 $this->geo = false;
                 return false;
             }
             if (isset($geo->code)) {
                 $this->geo = false;
                 return false;
             }
             $this->geo = (object) array('continent' => isset($geo->continent_code) ? $geo->continent_code : '', 'country' => isset($geo->country_code) ? $geo->country_code : '', 'region' => isset($geo->region_code) ? $geo->region_code : '');
             break;
     }
     return $this->geo;
 }
示例#2
0
 function getGeo()
 {
     if (!$this->geo) {
         require_once JPATH_PLUGINS . '/system/nnframework/helpers/functions.php';
         $func = new NNFrameworkFunctions();
         $this->geo = json_decode($func->getContents('http://www.geoplugin.net/json.gp?ip=' . $_SERVER['REMOTE_ADDR']));
     }
     return $this->geo;
 }