Ejemplo n.º 1
0
 /**
  * The class constructor initializes variables.
  * @param string $ip
  * @final
  */
 public final function __construct($ip = '')
 {
     if (empty($ip) && Http::RealIP()) {
         $ip = Http::RealIP();
     }
     if (empty($ip) === false || Server::PerlRegex() != false || @preg_match(self::REGX, trim($ip)) != false || Server::Json() != false) {
         $geo = @json_decode(@file_get_contents("http://api.2ip.com.ua/geo.json?ip={$ip}"), true);
         if (empty($geo) == false) {
             $this->data = array_merge($this->data, $geo);
         }
         $provider = @json_decode(@file_get_contents("http://api.2ip.com.ua/provider.json?ip={$ip}"), true);
         if (empty($provider) == false) {
             $this->data = array_merge($this->data, $provider);
         }
     }
 }