Forum Moderators: coopster
I want to redirect based on a query string, and save the date it was used to a log.
Here's what I have so far (only relavent code, so if it's bug free, I'll post the whole script):
$url = $_GET['url'];
$log = '/path/to/log.txt';
$text = "[" . date ( 'd-m-Y' ) . "] -> " . $_SERVER['REMOTE_ADDR'] . " - " . $url;
$validated['url'] = stripslashes ( $url );
$urlname = $validated['id'];
if ( stristr ( $url, 'http://' ) == true )
{
header ( 'Location: ' . $urlname );
if ( is_writable ( $log ) )
{
if (!$handle = fopen ( $log. 'a' ) )
{
echo "Cannot open file!";
exit();
}
if ( fwrite ( $handle, $text ) === false )
{
echo "Cannot write to file!";
exit();
}
fclose ( $handle );
}
else
{
echo "The file is not writable!";
}
}
I have some security in place, but it worked fine with just /?file=bleh, but now it won't work at all...
EDIT: And it seems the code tags hate me...
It just won't do anything.
Before it would redirect based on the first query (id), but now it won't even do that.
It basically just reloads the default page instead of loading based on the string.
If that still sounds fuzzy, let me try to clarify.
It is supposed to load a page if the query is blank, or missing. Now, though, it loads that page no matter what the query is.