I have a php website.I want to restrict users to access rates of my website in a particular city.Like in Jodhpur i want to hide my website rates and rest of the cities it is visible.I am facing an issue like when a user is connected through wifi rates are not accessible but whenever connected through mobile data rates are visible even in jodhpur.How to do it
require 'vendor/autoload.php';
use GeoIp2\Database\Reader;
$databaseFile = 'GeoLite2-City.mmdb';
function isVisitorFromJodhpur($ip, $databaseFile)
{
try {
$reader = new Reader($databaseFile);
$record = $reader->city($ip);
if (
$record->city->name === 'Jodhpur'
) {
return true;
}
} catch (Exception $e) {
return false;
}
return false;
}
<?php
$visitorIp = $_SERVER['REMOTE_ADDR'];
if (isVisitorFromJodhpur($visitorIp, $databaseFile)) {
$msg= "Sorry, access to this section is blocked for visitors from Jodhpur, Rajasthan, India."
?>
<h4></h4>
<?php } else {?>
<h4><i class="fa fa-inr" aria-hidden="true"></i>
<?php echo number_format($price1) ?></h4>
<?php }?>