Esempio n. 1
0
 /**
  * Request only using online services with too low timeout
  * Should lead to exception
  * @expectedException \GeoServices\GeoException
  */
 public function testServiceTimeout()
 {
     $this->object->setRequestTimeout(1);
     $this->object->maxmind = false;
     $this->object->maxmindold = false;
     $this->object->freegeoip = 3;
     $this->object->geobytes = 4;
     $this->object->ipgeobase = 5;
     $this->object->ipinfo = 5;
     $this->object->ipapi = 1;
     $this->object->isCountryCodeRequired = true;
     $this->object->isCityRequired = true;
     $this->object->isZipRequired = true;
     $data = $this->object->lookup('31.30.31.30');
 }
Esempio n. 2
0
 function __construct()
 {
     global $BASE;
     $geoipfile = dirname($BASE) . Config::get('geodatabase');
     // DiscoUtils::log('Loading GeoService', false);
     if (!class_exists('GeoIp2\\Database\\Reader')) {
         throw new Exception("Not properly loaded GeoIP library through composer.phar.");
     }
     if (!file_exists($geoipfile)) {
         throw new Exception("Cannot find configured GeoIP database :");
     }
     try {
         if (self::$reader === null) {
             self::$reader = new GeoIp2\Database\Reader($geoipfile);
             // 'var/GeoIP2-City.mmdb');
         }
     } catch (Exception $e) {
         error_log("Error reading geo IP database. [" . $geoipfile . "]");
         print_r($e);
     }
 }
Esempio n. 3
0
     exit;
 }
 $store = new DiscoStore();
 $logostore = new DiscoStoreLogos();
 if (DiscoUtils::route('get', '^/$', $parameters, $body)) {
     header('Content-Type: text/plain; charset=utf-8');
     echo "Welcome to DiscoJuice API\n" . "Consult documentation for details about using the API.\n" . "http://discojuice.org";
     exit;
 } else {
     if (DiscoUtils::route('get', '^/feeds$', $parameters, $body)) {
         $list = $store->getFeedList();
         $response = Feed::toJSONlist($list);
         // $response = $list;
     } else {
         if (DiscoUtils::route('get', '^/geo$', $parameters, $body)) {
             $geoservice = new GeoService();
             $data = array();
             $clientIP = $_SERVER['REMOTE_ADDR'];
             $data['country'] = $geoservice->countryFromIP($clientIP);
             $data['geo'] = $geoservice->geoFromIP($clientIP);
             $response = $data;
         } else {
             if (DiscoUtils::route('get', '^/pipe/([a-z0-9\\-_]+)$', $parameters, $body)) {
                 $response = $store->getPipe($parameters[1]);
                 unset($response['_id']);
             } else {
                 if (DiscoUtils::route('get', '^/pipe/([a-z0-9\\-_]+)/disco$', $parameters, $body)) {
                     $c = $store->getPipe($parameters[1]);
                     if ($c === null) {
                         echo "not found pipe " . $parameters[1];
                     }