PHP Doku:: Returns the filename of the corresponding GeoIP Database - function.geoip-db-filename.html

Verlauf / Chronik / History: (1) anzeigen

Sie sind hier:
Doku-StartseitePHP-HandbuchFunktionsreferenzSonstige GrunderweiterungenGeo IP LocationGeoIP Funktionengeoip_db_filename

Ein Service von Reinhard Neidl - Webprogrammierung.

GeoIP Funktionen

<<geoip_db_avail

geoip_db_get_all_info>>

geoip_db_filename

(PECL geoip >= 1.0.1)

geoip_db_filenameReturns the filename of the corresponding GeoIP Database

Beschreibung

string geoip_db_filename ( int $database )

The geoip_db_filename() function returns the filename of the corresponding GeoIP Database.

It does not indicate if the file exists or not on disk, only where the library is looking for the database.

Parameter-Liste

database

The database type as an integer. You can use the various constants defined with this extension (ie: GEOIP_*_EDITION).

Rückgabewerte

Returns the filename of the corresponding database, or NULL on error.

Beispiele

Beispiel #1 A geoip_db_filename() example

This will output the filename of the corresponding database.

<?php

print geoip_db_filename(GEOIP_COUNTRY_EDITION);

?>

Das oben gezeigte Beispiel erzeugt folgende Ausgabe:

/usr/share/GeoIP/GeoIP.dat


Ein BenutzerBeitrag:
- Beiträge aktualisieren...
Loc d'Anterroches
18.08.2010 14:50
To quickly know which databases are available on your system:

<?php
$cst
= array(
            
'GEOIP_COUNTRY_EDITION' => GEOIP_COUNTRY_EDITION,
            
'GEOIP_REGION_EDITION_REV0' => GEOIP_REGION_EDITION_REV0,
            
'GEOIP_CITY_EDITION_REV0' => GEOIP_CITY_EDITION_REV0,
            
'GEOIP_ORG_EDITION' => GEOIP_ORG_EDITION,
            
'GEOIP_ISP_EDITION' => GEOIP_ISP_EDITION,
            
'GEOIP_CITY_EDITION_REV1' => GEOIP_CITY_EDITION_REV1,
            
'GEOIP_REGION_EDITION_REV1' => GEOIP_REGION_EDITION_REV1,
            
'GEOIP_PROXY_EDITION' => GEOIP_PROXY_EDITION,
            
'GEOIP_ASNUM_EDITION' => GEOIP_ASNUM_EDITION,
            
'GEOIP_NETSPEED_EDITION' => GEOIP_NETSPEED_EDITION,
            
'GEOIP_DOMAIN_EDITION' => GEOIP_DOMAIN_EDITION,
             );

foreach (
$cst as $k=>$v) {
    echo
$k.': '.geoip_db_filename($v).'  '.(geoip_db_avail($v) ? 'Available':'').'<br>';
}
?>

The only drawback of the PECL extension with respect to a pure PHP implementation is that you cannot select yourself where the database is. So, if you get a new version of the database, you need to put in the standard place and you may need root access to do so.



PHP Powered Diese Seite bei php.net
The PHP manual text and comments are covered by the Creative Commons Attribution 3.0 License © the PHP Documentation Group - Impressum - mail("TO:Reinhard Neidl",...)