-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathreadme.txt
53 lines (47 loc) · 1.84 KB
/
readme.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
Installation of the component:
* Extract the release file under `protected/extensions`
* Change main.php configuration file
'components' => array(
...
'geoip' => array(
'class' => 'application.extensions.geoip.CGeoIP',
// specify filename location for the corresponding database
'filename' => 'C:\path\to\GeoIP\GeoLiteCity.dat',
// Choose MEMORY_CACHE or STANDARD mode
'mode' => 'STANDARD',
),
...
),
-----------------------------------------------
Usage instructions:
All methods accept an IP address as an argument.
If no argument is supplied CHttpRequest::getUserHostAddress() is used.
$location = Yii::app()->geoip->lookupLocation();
$countryCode = Yii::app()->geoip->lookupCountryCode();
$countryName = Yii::app()->geoip->lookupCountryName();
$org = Yii::app()->geoip->lookupOrg();
$regionCode = Yii::app()->geoip->lookupRegion();
Location attributes:
$location->countryCode
$location->countryCode3
$location->countryName
$location->region
$location->regionName
$location->city
$location->postalCode
$location->latitude
$location->longitude
$location->areaCode
$location->dmaCode
-----------------------------------------------
How to update Maxmind Free DBs example:
#updateGeoIP.sh
#this script will only download if there is a new version of the database
cd /usr/local/share/GeoIP
wget -N -q http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
wget -N -q http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz
wget -N -q http://geolite.maxmind.com/download/geoip/database/GeoIPv6.dat.gz
gunzip -c GeoLiteCity.dat.gz > GeoLiteCity.dat
gunzip -c GeoIP.dat.gz > GeoIP.dat
gunzip -c GeoIPv6.dat.gz > GeoIPv6.dat
#Setup a cron job to run this script monthly.