Example #1
0
 /**
  * @return bool|string
  */
 public function getContinentCode()
 {
     try {
         return geoip_continent_code_by_name($this->host);
     } catch (\Exception $e) {
         return false;
     }
 }
Example #2
0
//=======================================================================
// Nothing to change below this point
//=======================================================================
// Remote IP as provided by WebClient to Server
$IPArray = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']);
$IP_tocheck = str_replace(' ', '', $IPArray[count($IPArray) - 1]);
// Checking validity of IP
// Will remove reserved IP's -> local loopback
if (strlen($IP_tocheck) > 0) {
    if (filter_var($IP_tocheck, FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE)) {
        $IP['valid'] = htmlentities("{$IP_tocheck}", ENT_QUOTES, 'UTF-8');
        if ("{$DEBUG}" == "yes") {
            print ">>> Valid REMOTE IP {$IP['valid']} found<br />";
        }
        // Compute Continent out of IP.
        $continent = geoip_continent_code_by_name($IP['valid']);
    } else {
        $IP['invalid'] = htmlentities("{$IP_tocheck}", ENT_QUOTES, 'UTF-8');
        $continent = '';
        if ("{$DEBUG}" == "yes") {
            print "*** Invalid REMOTE IP {$IP['invalid']} found.<br />";
        }
    }
}
// Has to be set while developing - as RFC1918 or Reserved IP's won't return a continent
// $continent = 'EU';
$downloadurl = array();
$active = array();
$name = array();
$speed = array();
$cont = array();
Example #3
0
 /**
  * Get GeoIp host information
  *
  * @return void
  */
 protected function getGeoIpHostInfo()
 {
     if (function_exists('geoip_db_get_all_info') && null !== $this->host && $this->host != '127.0.0.1' && $this->host != 'localhost') {
         // Get base info by city
         if ($this->databases['city']) {
             $data = geoip_record_by_name($this->host);
             $this->hostInfo['areaCode'] = $data['area_code'];
             $this->hostInfo['city'] = $data['city'];
             $this->hostInfo['continentCode'] = $data['continent_code'];
             $this->hostInfo['country'] = $data['country_name'];
             $this->hostInfo['countryCode'] = $data['country_code'];
             $this->hostInfo['countryCode3'] = $data['country_code3'];
             $this->hostInfo['dmaCode'] = $data['dma_code'];
             $this->hostInfo['latitude'] = $data['latitude'];
             $this->hostInfo['longitude'] = $data['longitude'];
             $this->hostInfo['postalCode'] = $data['postal_code'];
             $this->hostInfo['region'] = $data['region'];
             // Else, get base info by country
         } else {
             if ($this->databases['country']) {
                 $this->hostInfo['continentCode'] = geoip_continent_code_by_name($this->host);
                 $this->hostInfo['country'] = geoip_country_name_by_name($this->host);
                 $this->hostInfo['countryCode'] = geoip_country_code_by_name($this->host);
                 $this->hostInfo['countryCode3'] = geoip_country_code3_by_name($this->host);
             }
         }
         // If available, get ISP name
         if ($this->databases['isp']) {
             $this->hostInfo['isp'] = geoip_isp_by_name($this->host);
         }
         // If available, get internet connection speed
         if ($this->databases['netspeed']) {
             $netspeed = geoip_id_by_name($this->host);
             switch ($netspeed) {
                 case GEOIP_DIALUP_SPEED:
                     $this->hostInfo['netspeed'] = 'Dial-Up';
                     break;
                 case GEOIP_CABLEDSL_SPEED:
                     $this->hostInfo['netspeed'] = 'Cable/DSL';
                     break;
                 case GEOIP_CORPORATE_SPEED:
                     $this->hostInfo['netspeed'] = 'Corporate';
                     break;
                 default:
                     $this->hostInfo['netspeed'] = 'Unknown';
             }
         }
         // If available, get Organization name
         if ($this->databases['org']) {
             $this->hostInfo['org'] = geoip_org_by_name($this->host);
         }
     }
 }
 /**
  * Get two-letter continent code.
  *
  * @return string|false Continent code or FALSE on failure
  */
 public function getContinentCode()
 {
     return geoip_continent_code_by_name($this->ip);
 }
 /**
  * Construct a new request from the specified data.
  * @param string method        Usually $_GET superglobal.
  * @param string uri           Usually $_GET superglobal.
  * @param array  options       Usually $_GET superglobal.
  * @param array  data          Usually $_POST superglobal.
  * @param array  cookies       Usually $_COOKIES superglobal.
  * @param array  files         Usually $_FILES superglobal.
  * @param array  headers       Usually $_SERVER superglobal.
  * @param array  environment   Usually $_SERVER superglobal.
  */
 public function __construct($method, $uri, array $options, array $data, array $cookies, array $files, array $headers, array $environment)
 {
     $this->method = strtoupper($method);
     if (isset($headers['x-http-method-override']) && $headers['x-http-method-override']) {
         $this->method = $headers['x-http-method-override'];
     }
     // split uri into url and query string parts
     list($this->uri, $this->query_string) = explode('?', urldecode($uri)) + array('', '');
     $this->uri = rtrim($this->uri, '/');
     if ($this->query_string) {
         $this->query_string = "?{$this->query_string}";
     }
     $this->messages = array();
     if (isset($cookies['YOLK_MESSAGES'])) {
         $this->messages = unserialize(base64_decode($cookies['YOLK_MESSAGES']));
         unset($cookies['YOLK_MESSAGES']);
     }
     $this->options = $options;
     $this->data = $data;
     $this->cookies = $cookies;
     $this->files = $files;
     $this->headers = $headers;
     $this->environment = $environment;
     $this->ip = $this->getIP();
     $this->country_code = '';
     $this->continent = '';
     $this->extra = [];
     $this->uri_prefix = [];
     // do geo-ip stuff if we have a valid IP that isn't part of a private network
     if ($this->ip) {
         $this->country_code = function_exists('geoip_country_code_by_name') ? geoip_country_code_by_name($this->ip) : '';
         $this->continent = function_exists('geoip_continent_code_by_name') ? geoip_continent_code_by_name($this->ip) : '';
     }
 }
Example #6
0
 /**
  * getContinentCode
  * 
  * Continent shortform code of set IP.
  * 
  * @access protected
  * @static
  * @return string
  */
 protected static function getContinentCode()
 {
     return geoip_continent_code_by_name(self::_getIP());
 }
Example #7
0
<?php

$continent = geoip_continent_code_by_name('www.example.com');
if ($continent) {
    echo 'Cet hôte est situé en : ' . $continent;
}