My first PHP script
/* the above "" signals that the PHP script has begun */
$remote = getenv("HTTP_HOST");
$file = "redirect.txt";
if (is_file($file))
{
echo $file, " is a file", "
";
}
else
{
echo $file, " is not a file", "
";
}
$fp = fopen("redirect.txt", "r");
if ($fp == FALSE)
{
echo "File not opened", "
";
}
else
{
echo "File opened", "
";
}
while (!feof($fp)):
$line = fgets($fp,1800);
$line_list = explode("|",$line);
echo "$line", "
";
$url1 = $line_list[0];
$url2 = $line_list[1];
$redirect = $line_list[2];
if ($url1 == $remote or $url2 == $remote):
Header("Location:$redirect");
break;
endif;
endwhile;
$closefp = fclose($fp);
$today = date("Y-m-d");
PRINT "Today is: $today.";
phpinfo();
# the following "?>" closes the script
?>