I'm an absolute beginner when it comes to php and js and have been pulling my hair out trying to find a workable solution to the following requirement.
I have a Joomla subscription extension with a "subscribe" button using an a href tag.
What I'd like to achieve is, based on geoip location, visitors browsing from outside the UK are denied access to the button click action, but given a message explaining why.
So far all I'm able to achieve is a disabled button, which is still clickable...
The little-bit I've been able to achieve so far is below. Really hoping someone can assist me.
<?php
// Added Geo IP Location Tracking
$user_ip = getenv('REMOTE_ADDR');
// http://www.geoplugin.net/php.gp?ip=$user_ip
$geo = unserialize(file_get_contents("http://www.geoplugin.net/php.gp?ip=$user_ip"));
$city = $geo["geoplugin_city"];
$region = $geo["geoplugin_regionName"];
$country = $geo["geoplugin_countryName"];
$countryCode = $geo["geoplugin_countryCode"];
}
?>
<?php
if ($countryCode == 'CH') {
echo "Unfortunately China is not covered by our service!"."<br>";
}
?>
<p><a class="btn btn-large btn-primary" <?php if ($countryCode == 'CH'){ ?> disabled <?php } ?> href="<?php echo JRoute::_('index.php?option=com_axisubs&view=subscribe&plan='.$item->slug); ?>">
<i class="icon-ok"></i>
<?php if ( $item->hasTrial() ) : ?>
<?php echo JText::_('COM_AXISUBS_START_TRIAL'); ?>
<?php else: ?>
<?php echo JText::_('COM_AXISUBS_SUBSCRIBE_NOW'); ?>
<?php endif; ?>
</a>