Dengan menggunakan geolocation maka informasi pengakses situs dapat diketahui IP nya yang nanti akan dapat memberi informasi tentang pengakses situs tersebut.
Oke tidak panjang lebar lagi menjelaskan. Ada sebuah plugin geolocation yang dinamakan geoplugin. tentunya dengan menggunakan bahasa pemrograman PHP.
untuk menggunakannya anda dapat mendownload plugin class DISINI
Setelah mendownload classnya tinggal copy kan ke notepad dan simpan dengan nama terserah anda. dalam hal ini misalnya : geoplugin.class.php
Kemudian buat file php satu lagi dan copykan file dibawah ini :
<?php require_once('geoplugin.class.php'); $geoplugin = new geoPlugin(); // If we wanted to change the base currency, we would uncomment the following line // $geoplugin->currency = 'EUR'; $geoplugin->locate(); echo "Geolocation results for {$geoplugin->ip}: \n". "City: {$geoplugin->city} \n". "Region: {$geoplugin->region} \n". "Area Code: {$geoplugin->areaCode} \n". "DMA Code: {$geoplugin->dmaCode} \n". "Country Name: {$geoplugin->countryName} \n". "Country Code: {$geoplugin->countryCode} \n". "Longitude: {$geoplugin->longitude} \n". "Latitude: {$geoplugin->latitude} \n". "Currency Code: {$geoplugin->currencyCode} \n". "Currency Symbol: {$geoplugin->currencySymbol} \n". "Exchange Rate: {$geoplugin->currencyConverter} \n"; if ( $geoplugin->currency != $geoplugin->currencyCode ) { //our visitor is not using the same currency as the base currency echo "At todays rate, US$100 will cost you " . $geoplugin->convert(100) ." \n"; } /* find places nearby */ $nearby = $geoplugin->nearby(); if ( isset($nearby[0]['geoplugin_place']) ) { echo "OKE semoga bermanfaat. Sumber referensi : http://www.geoplugin.comSome places you may wish to visit near " . $geoplugin->city . ": \n"; foreach ( $nearby as $key => $array ) { echo ($key + 1) .": "; echo "\t Place: " . $array['geoplugin_place'] . " "; echo "\t Country Code: " . $array['geoplugin_countryCode'] . " "; echo "\t Region: " . $array['geoplugin_region'] . " "; echo "\t County: " . $array['geoplugin_county'] . " "; echo "\t Latitude: " . $array['geoplugin_latitude'] . " "; echo "\t Longitude: " . $array['geoplugin_longitude'] . " "; echo "\t Distance (miles): " . $array['geoplugin_distanceMiles'] . " "; echo "\t Distance (km): " . $array['geoplugin_distanceKilometers'] . " "; } echo "\n"; } ?>
0 komentar:
Post a Comment