I found a code which I need that written in PHP while I need it in ASP
Does anyone here can help me to translate it into ASP code?
Code: Select all
<?PHP
// Check user ip by country
$IPaddress = $_SERVER['REMOTE_ADDR'];
function iptocountry($ip) {
$numbers = preg_split( "/\./", $ip);
include("ip_database.php");
$code=($numbers[0] * 16777216) + ($numbers[1] * 65536) + ($numbers[2] * 256) + ($numbers[3]);
foreach($ranges as $key => $value){
if($key<=$code){
if($ranges[$key][0]>=$code){$two_letter_country_code=$ranges[$key][1];break;}
}
}
if ($two_letter_country_code==""){$two_letter_country_code="unk own";}
return $two_letter_country_code;
}
function check_country() {
global $IPaddress;
$two_letter_country_code = iptocountry($IPaddress);
if ( ($two_letter_country_code=="IL") OR ($two_letter_country_code=="IN") OR ($two_letter_country_code=="TR") OR ($two_letter_country_code=="VN") )
return true;
else
return false;
}
// END - Check user ip by country
?>Code: Select all
<b><?PHP if ( !check_country() ) echo "my test"; ?></b>Code: Select all
<?PHP
$ranges=Array(
"1040187392" => array("1040252927","IL"),
"1048584192" => array("1048592383","IL"),
);
?>