/****************************************************************************************************************/
/* Description: This snippet is provide simple way to show user on how to lookup for a proxy record. */
/* suggestions for different city locations across the country. */
/* There are 1 steps in this snippet. For information, please visit IP2Location tutorial page at: */
/*https://www.ip2location.com/tutorials/how-to-lookup-for-proxy-record-using-php-and-mysql */
/****************************************************************************************************************/
/* You can obtain to setup the proxy database for IPv4 at: */
/* https://lite.ip2location.com/database/px4-ip-proxytype-country-region-city-isp */
<?php
//Open connection to mysql server
$mysqli = new mysqli('localhost', 'root', '', 'ip2location');
//Check connection
if ($mysqli->connect_errno) {
printf("Connect failed: %s\n", $mysqli->connect_error);
exit();
}
//Check if the IP address is a proxy address
$ip_address = '4.0.0.37';
$result = $mysqli->query('SELECT * FROM ip2proxy_px4 WHERE inet_aton("' . $ip_address . '") between ip_from AND ip_to LIMIT 1');
if ($result->num_rows > 0){
//proxy
$row = $result->fetch_assoc();
echo 'IP Address: ' . $ip_address . '<br>';
echo 'Proxy Type: ' . $row['proxy_type'] . '<br>';
echo 'Country Code: ' . $row['country_code'] . '<br>';
echo 'Country Name: ' . $row['country_name'] . '<br>';
echo 'Region Name: ' . $row['region_name'] . '<br>';
echo 'City Name: ' . $row['city_name'] . '<br>';
echo 'ISP: ' . $row['isp'] . '<br>';
}
else{
//non-proxy
echo $ip_address . ' is not a proxy<br>';
}
?>
Comments