I've used the Maxmind geoIP before via package installations on the server, but I'd like to use yours now that it's integrated into Joomla as a plugin. I was about to ask how to use the geoip functions wherever I want when I got it working, so I thought I'd share. But if anyone has a better or more technically sound way please post it.
I added the below to my template and it works fine for me:
<?php
if (!class_exists('AkeebaGeoipProvider')){
if (@file_exists(JPATH_PLUGINS . '/system/akgeoip/lib/akgeoip.php')){
if (@include_once JPATH_PLUGINS . '/system/akgeoip/lib/vendor/autoload.php')
{
@include_once JPATH_PLUGINS . '/system/akgeoip/lib/akgeoip.php';
}
}
}
$geoip = new AkeebaGeoipProvider();
$ip = $_SERVER["REMOTE_ADDR"];
$countryCode2 = $geoip->getCountryCode($ip);
echo 'ip ' . $ip . ' is located in: ' . $countryCode2;
?>
Now, correct me if I'm wrong, but any of the public functions in /plugins/system/akgeoip/lib/akgeoip.php can be called, right? So with very little modification couldn't a standalone PHP file be targeted with CRON to call the updateDatabase() function and auto-update the geoIP database regularly?
Thanks,
Kalin