Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /home/zhenxiangba/zhenxiangba.com/public_html/phproxy-improved-master/index.php on line 456
PHP: GeoIP - Manual
[go: Go Back, main page]

PHP
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

geoip_country_code_by_name" width="11" height="7"/> <unregister_tick_function
Last updated: Sun, 25 Nov 2007

view this page in

GeoIP 関数

導入

GeoIP 拡張モジュールを使用すると、IP アドレスの場所を探すことができます。 市、州、国、経度、緯度そして ISP や接続方式などの情報が GeoIP を用いて取得できます。

要件

この拡張モジュールを使用するには、GeoIP C ライブラリのバージョン 1.4.0 以降がインストールされていなければなりません。最新のバージョンは » http://www.maxmind.com/app/c から取得できるので、これをコンパイルします。

デフォルトでは、Free GeoIP Country データベースあるいは GeoLite City データベースにしかアクセスできません。 しかし、それ以外のデータベースを使用することも可能です。その場合には » Maxmind から商用ライセンスを購入しなければなりません。

インストール手順

この » PECL 拡張 モジュールは PHP にバンドルされていません。

この PECL 拡張モジュールをインストールする方法は、 マニュアルの PECL 拡張モジュールのインストール という章にあります。 新規リリース・ダウンロード・ソースファイル・管理者情報・CHANGELOG といった関連する情報については、次の場所にあります。 » http://pecl.php.net/package/geoip.

リソース型

リソース型は定義されていません。

定義済み定数

以下の定数が定義されています。 この関数の拡張モジュールが PHP 組み込みでコンパイルされているか、 実行時に動的にロードされている場合のみ使用可能です。

GEOIP_COUNTRY_EDITION (integer)
GEOIP_REGION_EDITION_REV0 (integer)
GEOIP_CITY_EDITION_REV0 (integer)
GEOIP_ORG_EDITION (integer)
GEOIP_ISP_EDITION (integer)
GEOIP_CITY_EDITION_REV1 (integer)
GEOIP_REGION_EDITION_REV1 (integer)
GEOIP_PROXY_EDITION (integer)
GEOIP_ASNUM_EDITION (integer)
GEOIP_NETSPEED_EDITION (integer)
GEOIP_DOMAIN_EDITION (integer)

以下の定数は、ネット接続のスピードを表します。

GEOIP_UNKNOWN_SPEED (integer)
GEOIP_DIALUP_SPEED (integer)
GEOIP_CABLEDSL_SPEED (integer)
GEOIP_CORPORATE_SPEED (integer)

目次



add a note add a note User Contributed Notes
GeoIP
kapouer at melix dot org
02-Mar-2008 12:26
For Debian etch users : libgeoip is in version 1.4 so get the source from lenny (apt-get build-dep libgeoip;apt-get source libgeoip), compile it on etch (dpkg-buildpackage -rfakeroot in source folder) and install resulting libgeoip1 and libgeo-dev packages (dpkg -i)... Together with php5-dev this package is easy to install (phpize5;./configure --enable-geoip;make;make install)... Then check your install in php with :
<?php
   
echo geoip_database_info(GEOIP_COUNTRY_EDITION);
    echo
$_SERVER['REMOTE_ADDR'];
    echo
geoip_country_code3_by_name($_SERVER['REMOTE_ADDR']);
?>

please note free .dat is in /usr/share/GeoIP/GeoIP.dat
Use geoip-bin package to schedule automatic updates (configure /etc/geoip.default.conf and copy to /etc/geoip.conf, then add a crontab to make the updates...)
hope this helps
eddieREMOVETHIS at yarr dot ca
08-Jul-2007 02:06
Try renaming GeoLiteCity.dat to GeoIPCity.dat.
php dot comment dot addition at gmail dot com
11-Jun-2007 12:57
Just to clarify the other comments, the maxmind post seems to be out of date / incorrect. 

This module fails to work (ie: resolve cities) with the GeoLite City database from here:
http://www.maxmind.com/app/geolitecity

The error occurs when calling the function geoip_record_by_name(), which states incorrectly that the required database is not available.  I have tested it with the very latest database, for which geoip_database_info() returns  the version:
GEO-533LITE 20070601 Build 1 Copyright (c) 2007 MaxMind LLC All Rights Reserved

It does, however, resolve countries OK via the GeoLite Country database, which you can grab here: http://www.maxmind.com/app/geoip_country
I tested with the version:

GEO-106FREE 20070601 Build 1 Copyright (c) 2007 MaxMind LLC All Rights Reserved
tjmather at maxmind dot com
27-Feb-2007 01:09
The geoip_country_*_by_name functions only work with GeoIP Country.  The geoip_record_by_name function works with GeoIP City.  geoip_region_by_name works with GeoIP Region.  So the API should work with all of the GeoIP databases, as long as you call the correct function.
27-Jan-2007 10:23
I couldn't get it to work with the DMA code database (product ID 137).  It seems to only work with the country database.  The documentation should contain a warning that this code (as of 0.2.0) is incomplete and that Net_GeoIP should be used for non-country databases.
judas dot iscariote at gmail dot com
17-Nov-2006 12:59
If you want to use this extension in SUSE/openSUSE, it is available here:

http://repos.opensuse.org/server:/php:/extensions/
Christian
13-Sep-2006 09:45
Both, Ubuntu and Debian itself make usage of version 1.3.x of the c libraries, so installation can't be done with the debian packages, because configure stops with:
 
== configure: error: You need version 1.4.0 or higher of the C API ==

so you must download it from maxmind.
Matt
09-Sep-2006 05:34
If you are a Debian or Ubuntu user, instead of building it from source, you can:
aptitude install libgeoip-dev libgeoip1

 
show source | credits | sitemap | contact | advertising | mirror sites