This is another short notes for myself for future use.
Today I have to use some Geo targeting for Friendster Private Profile Viewer so the chat will show on front page only if the user IP address come from Philippines, Indonesia or unknown country.
I decided to use MaxMind GeoLite Country so it doesn't need to call Geo location API from other site.
This is simple instruction how to install and use it.
- Download GeoLite country database from : http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz
- extract/gunzip it
- upload to your site home directory (public_html)
- download geoip.inc from here: http://geolite.maxmind.com/download/geoip/api/php/geoip.inc
- upload geoip.inc in the same folder as GeoIP.dat (result from step 2) on your website home directory
- use it!
this is some code example:
<?phprequire_once("geoip.inc");$gi = geoip_open("./GeoIP.dat",GEOIP_STANDARD);$countrycode=geoip_country_code_by_addr($gi, $_SERVER['REMOTE_ADDR']);if (($countrycode=="PH")||(strlen($countrycode)<2)||($countrycode=="ID")) {//do some geo targeting here}geoip_close($gi);?>



3 komentar:
link anda sudah di pasang di footer blog saya mohon sekiranya untuk link back yah terima kasih :)
nice article bos
thank you, bro..
silakan nitip link
Post a Comment