7 include(
"geoipcity.inc");
8 define(
"GEOIP_COUNTRY_DATABASE",0);
9 define(
"GEOIP_REGION_DATABASE",1);
10 define(
"GEOIP_CITY_DATABASE",2);
13 var
$dbfilename = array(
"/usr/local/share/GeoIP/GeoIP.dat",
"/usr/local/share/GeoIP/GeoIPRegion.dat",
"/usr/local/share/GeoIP/GeoIPCity.dat");
16 for ($a = 0;$a < 4;$a++){
17 if ($a > 0){$result = $result .
".";}
19 $result = $result . $a2;
25 return $a[sec] + ($a[usec]*0.000001);
28 $gi = geoip_open($this->dbfilename[$type],$flags);
30 print
"error: " . $this->dbfilename[$type] .
" does not exist\n" ;
35 for ($i2 = 0;$i2 < $numlookups;$i2++){
37 case GEOIP_COUNTRY_DATABASE:
40 case GEOIP_REGION_DATABASE:
43 case GEOIP_CITY_DATABASE:
51 print $numlookups .
" lookups made in " . $t3 .
" seconds \n";
60 $mainapp->testgeoipdatabase(GEOIP_COUNTRY_DATABASE,GEOIP_STANDARD,
"Geoip Country ",10000);
61 $mainapp->testgeoipdatabase(GEOIP_COUNTRY_DATABASE,GEOIP_MEMORY_CACHE,
"Geoip Country with memory cache",10000);
62 $mainapp->testgeoipdatabase(GEOIP_REGION_DATABASE,GEOIP_STANDARD,
"Geoip Region ",10000);
63 $mainapp->testgeoipdatabase(GEOIP_REGION_DATABASE,GEOIP_MEMORY_CACHE,
"Geoip Region with memory cache",10000);
64 $mainapp->testgeoipdatabase(GEOIP_CITY_DATABASE,GEOIP_STANDARD,
"Geoip City ",10000);
65 $mainapp->testgeoipdatabase(GEOIP_CITY_DATABASE,GEOIP_MEMORY_CACHE,
"Geoip City with memory cache",10000);