Esempio n. 1
0
 /**
  * @param $ip
  * @return bool
  */
 public function has($ip)
 {
     if (!$this->ip->isValid($ip)) {
         return false;
     }
     return $this->count($ip) > 0;
 }
Esempio n. 2
0
 /**
  * @return array
  */
 public function locate()
 {
     //
     $ip = $this->ip->get();
     $db = $this->config->get('visitor.maxmind_db_path');
     if (!is_string($db) || !file_exists($db) || !$this->ip->isValid($ip)) {
         return [];
     }
     $this->reader = new Reader($db);
     try {
         $record = $this->reader->city($ip);
         return ['country_code' => $record->country->isoCode, 'country_name' => $record->country->name, 'state_code' => $record->mostSpecificSubdivision->isoCode, 'state' => $record->mostSpecificSubdivision->name, 'city' => $record->city->name, 'postale_code' => $record->postal->code];
     } catch (AddressNotFoundException $e) {
         return [];
     }
 }