重定向不在包含文件中

时间:2017-02-13 22:11:31

标签: php

<?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文件中,一切都很好,但重定向部分不起作用。有人可以告诉我如何解决这个问题吗?

0 个答案:

没有答案
相关问题