Pop\Geo\Geo::getGeoIpHostInfo PHP Method

getGeoIpHostInfo() protected method

Get GeoIp host information
protected getGeoIpHostInfo ( ) : void
return void
    protected function getGeoIpHostInfo()
    {
        if (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);
            }
        }
    }