function filter($IP) {
$remote=popen(" curl -Ss ipinfo.io/$IP | awk '{print $2}' | awk 'NR==6'");
if($remote==USA){
echo " Welcome";
}
else {
echo "You cant access to this website";
exit();
}
}
filter($_SERVER['REMOTE_ADDR']);
?>
$country = file_get_contents("http://ipinfo.io/{$_SERVER['REMOTE_ADDR']}/country");
if($country != "RO") {
// User isn't in Romania!
// Display an error message, or redirect to another website
}
http://stackoverflow.com/questions/8384421/restrict-website-to-access-specific-country
http://ipinfo.io/213.140.32.1/country
note if you use system() function instead of popen() the command output will be displayed on the browser. this is useful for debugging popurses
No hay comentarios:
Publicar un comentario