geoip_db_filename
(PECL geoip:1.0.1)
geoip_db_filename — Returns the filename of the corresponding GeoIP 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.
Список параметров
- database
-
The database type as an integer. You can use the various constants defined with this extension (ie: GEOIP_*_EDITION).
Возвращаемые значения
Returns the filename of the corresponding database, or NULL on error.
Примеры
Пример #1 A geoip_db_filename() example
This will output the filename of the corresponding database.
<?php
print geoip_db_filename(GEOIP_COUNTRY_EDITION);
?>
Результат выполнения данного примера:
/usr/share/GeoIP/GeoIP.dat
- PHP Руководство
- Функции по категориям
- Индекс функций
- Справочник функций
- Другие базовые расширения
- Geo IP Location
- geoip_asnum_by_name
- geoip_continent_code_by_name
- geoip_country_code_by_name
- geoip_country_code3_by_name
- geoip_country_name_by_name
- geoip_database_info
- geoip_db_avail
- geoip_db_filename
- geoip_db_get_all_info
- geoip_domain_by_name
- geoip_id_by_name
- geoip_isp_by_name
- geoip_netspeedcell_by_name
- geoip_org_by_name
- geoip_record_by_name
- geoip_region_by_name
- geoip_region_name_by_code
- geoip_setup_custom_directory
- geoip_time_zone_by_country_and_region
Коментарии
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.