Beyler, ülkeye göre yönlendirme yapmak istiyorum.
Değerleri country_ips.txt dosyasından okuyacak
Kod da hata var mı?
<?php
function ip_to_country($ip, $which = 0) {
$dot = preg_split("/[.]+/", $ip);
$num = (double) ($dot[0] * 16777216) + ($dot[1] * 65536) + ($dot[2] * 256) + $dot[3];
$country_code = "??";
$country_name = "??";
$fp = fopen("country_ips.txt", "r");
while (!feof($fp)) {
$data = fgetcsv($fp, 8192);
if (empty($data[2]))
continue;
if ($num >= $data[0] && $num <= $data[1]) {
$country_code = $data[2];
$country_name = ucwords(strtolower($data[4]));
}
}
fclose($fp);
if ($which == 0)
return $country_code;
else
return $country_name;
}
if (stristr($country_code, "tr"))
header("Location: tr/index.php");
else if (stristr($country_code, "fr"))
header("Location: fr/index.php");
else if (stristr($country_code, "de"))
header("Location: de/index.php");
?>
Değerleri country_ips.txt dosyasından okuyacak
Kod da hata var mı?
<?php
function ip_to_country($ip, $which = 0) {
$dot = preg_split("/[.]+/", $ip);
$num = (double) ($dot[0] * 16777216) + ($dot[1] * 65536) + ($dot[2] * 256) + $dot[3];
$country_code = "??";
$country_name = "??";
$fp = fopen("country_ips.txt", "r");
while (!feof($fp)) {
$data = fgetcsv($fp, 8192);
if (empty($data[2]))
continue;
if ($num >= $data[0] && $num <= $data[1]) {
$country_code = $data[2];
$country_name = ucwords(strtolower($data[4]));
}
}
fclose($fp);
if ($which == 0)
return $country_code;
else
return $country_name;
}
if (stristr($country_code, "tr"))
header("Location: tr/index.php");
else if (stristr($country_code, "fr"))
header("Location: fr/index.php");
else if (stristr($country_code, "de"))
header("Location: de/index.php");
?>