getCountryByHost() public static method

Get country information from a hostname or IP address.
public static getCountryByHost ( string $host, string $datafile = null ) : mixed
$host string The hostname or IP address.
$datafile string The datafile for the GeoIP lookup. If not set, will skip this lookup.
return mixed On success, return an array with the following entries: 'code' => Country Code 'name' => Country Name On failure, return false.
Exemplo n.º 1
0
 /**
  * Generate flag image object.
  *
  * @since 2.10.0
  *
  * @param string $host  The hostname.
  *
  * @return array  False if not found, or an array with these keys:
  * <pre>
  *   - name: (string) Country name.
  *   - ob: (Horde_Themes_Image) Image object.
  * </pre>
  */
 public static function getFlagImageObByHost($host)
 {
     global $conf;
     $data = Horde_Nls::getCountryByHost($host, empty($conf['geoip']['datafile']) ? null : $conf['geoip']['datafile']);
     if ($data === false) {
         return false;
     }
     return array('name' => $data['name'], 'ob' => Horde_Themes::img('flags/' . $data['code'] . '.png'));
 }
Exemplo n.º 2
0
 /**
  * Generate flag image object.
  *
  * @since 2.10.0
  *
  * @param string $host  The hostname.
  *
  * @return array  False if not found, or an array with these keys:
  * <pre>
  *   - name: (string) Country name.
  *   - ob: (Horde_Themes_Image) Image object.
  * </pre>
  */
 public static function getFlagImageObByHost($host)
 {
     global $conf, $injector;
     if (!Horde_Nls::$dnsResolver) {
         Horde_Nls::$dnsResolver = $injector->getInstance('Net_DNS2_Resolver');
     }
     $data = Horde_Nls::getCountryByHost($host, empty($conf['geoip']['datafile']) ? null : $conf['geoip']['datafile']);
     if ($data === false) {
         return false;
     }
     return array('name' => $data['name'], 'ob' => Horde_Themes::img('flags/' . $data['code'] . '.png'));
 }