2012-12-15 2 views
0

지역 이름을 얻는 방법에 대해 다소 혼란스럽고 어떤 문서도 찾을 수 없습니다. 나는 'GeoIP.dat'및 'geoip.inc'디렉토리에 '... IP GeoLite \ GeoLite'라는 데이터베이스가 설치되어 있으며 test \ IP GeoLite \ find.php에 대한 PHP 페이지가 있습니다. 'find.php'페이지 내부 코드는 작동하지 않았다된다MaxMind의 GeoLite를 사용하여 지역 이름 가져 오기

<?php 
/* Instead of having to determine the country of the client every time they visit the site we are going to set 
a cookie so that any other script in PHP or Javascript can use the region information. 
The user is also given a menu option to change the region and reset the cookie to a new value. 
Likewise, if it already exists we don't want to change it. 
We start off by checking that the cookie called Region exists. 
If it does, the job is nearly done and we simply set the $Region variable so that we can refresh 
the cookie at the end of the program by recreating it. */ 
if(isset($_COOKIE['Region'])) 
{ 
    $Region = $_COOKIE['Region']; 
} 
else 
/* Only if the cookie isn't set do we do the actions in the else part of the if, 
so this makes the whole thing efficient. 
To make use of the GeoLite code we have to load the include file: */ 
{ 
    $GeoPath= 'GeoLite/'; 
    include($GeoPath.'geoip.inc'); 
} 
    $countrydata = GeoIP_region_name_by_code(gir->country_code, gir->region) ; 
    echo $countrydata ; 
?> 

답변