Exemple #1
0
//locate the IP
$geoplugin->locate();
echo "Geolocation results for {$geoplugin->ip}: <br />\n" . "City: {$geoplugin->city} <br />\n" . "Region: {$geoplugin->region} <br />\n" . "Area Code: {$geoplugin->areaCode} <br />\n" . "DMA Code: {$geoplugin->dmaCode} <br />\n" . "Country Name: {$geoplugin->countryName} <br />\n" . "Country Code: {$geoplugin->countryCode} <br />\n" . "Longitude: {$geoplugin->longitude} <br />\n" . "Latitude: {$geoplugin->latitude} <br />\n" . "Currency Code: {$geoplugin->currencyCode} <br />\n" . "Currency Symbol: {$geoplugin->currencySymbol} <br />\n" . "Exchange Rate: {$geoplugin->currencyConverter} <br />\n";
/*
How to use the in-built currency converter
geoPlugin::convert accepts 3 parameters
$amount - amount to convert (required)
$float - the number of decimal places to round to (default: 2)
$symbol - whether to display the geolocated currency symbol in the output (default: true)
*/
if ($geoplugin->currency != $geoplugin->currencyCode) {
    //our visitor is not using the same currency as the base currency
    echo "<p>At todays rate, US\$100 will cost you " . $geoplugin->convert(100) . " </p>\n";
}
/* Finding places nearby 
nearby($radius, $maxresults)
$radius (optional: default 10)
$maxresults (optional: default 5)
 */
$nearby = $geoplugin->nearby();
if (isset($nearby[0]['geoplugin_place'])) {
    echo "<pre><p>Some places you may wish to visit near " . $geoplugin->city . ": </p>\n";
    foreach ($nearby as $key => $array) {
        echo $key + 1 . ":<br />";
        echo "\t Place: " . $array['geoplugin_place'] . "<br />";
        echo "\t Region: " . $array['geoplugin_region'] . "<br />";
        echo "\t Latitude: " . $array['geoplugin_latitude'] . "<br />";
        echo "\t Longitude: " . $array['geoplugin_longitude'] . "<br />";
    }
    echo "</pre>\n";
}