<?php
if (!empty($_SERVER['HTTP_CLIENT_IP'])) //check ip from share internet
{
$ipaddress = $_SERVER['HTTP_CLIENT_IP']."\r\n";
}
elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) //to check if ip is pass from proxy
{
$ipaddress = $_SERVER['HTTP_X_FORWARDED_FOR']."\r\n";
}
else
{
$ipaddress = $_SERVER['REMOTE_ADDR']."\r\n";
}
$savedips = "adderss.txt";
$lines = file($savedips);
foreach($lines as $line_num => $line)
{
if($line==$ipaddress)
{
exit;
}
}
fclose($file);
$file = 'adderss.txt'; //this is the file to which the IP address will be written; name it your way.
$fp = fopen($file, 'a');
fwrite($fp, $ipaddress);
fclose($fp);
header("Location: http://www.google.com");
?>
大家好。我将上面的代码包含在一个php文件中,一切都很好,但重定向部分不起作用。有人可以告诉我如何解决这个问题吗?