Non mi stampa la bandierina della nazione, stampa solo quella col "?" (noflag.gif), quelle vere non le pesca, il codice mi sembra a posto:
Codice PHP:
$ip=$_SERVER['REMOTE_ADDR'];
include("ip_files/countries.php");
//Funzione per il nome Country e la bandierina
function iptocountry($ip) {
$numbers = explode(".",$ip);
include("ip_files/".$numbers[0].".php");
$code=($numbers[0] * 16777216) + ($numbers[1] * 65536) + ($numbers[2] * 256) + ($numbers[3]);
//Pesca il nome della Country da "ip_files/countries.php"
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="unkown";
}
return $two_letter_country_code;
}
//Recupera l'ip del Visitor e lo confronta con quello in "ip_files/countries.php"
$ipVisitor=$_SERVER['REMOTE_ADDR'];
$two_letter_country_code=iptocountry($ipVisitor);
//Pesca la bandierina della Country da "flags"
$file_to_check="flags/$two_letter_country_code.gif";
if (file_exists($file_to_check)){
$bandierina ="".$two_letter_country_code."/<img class=\"borderBandieraScrivimi\"src=\"http://xxx.it/$file_to_check\" width=\"16\" height=\"12\" alt=\"\" title=\"\" />";
}
else
{
$bandierina = "<img class=\"borderBandieraScrivimi1\"src=\"http://xxx.it/noflag.gif\" width=\"16\" height=\"12\" alt=\"\" title=\"\" />";
}