Directories and filename of script : $_SERVER["SCRIPT_NAME"]
Server addresse (without "http://") : $_SERVER["HTTP_HOST"]
Everything after the "?" : $_SERVER["QUERY_STRING"]
To add a line at the end of a line, use "a+" mode in fopen.
Example with this URL : http://www.phpbuilder.com/forum/read.php3?num=1&id=142989&thread=142989
$SERVER["SCRIPT_NAME"] = /forum/read.php3
$SERVER["HTTP_HOST"] = www.phpbuilder.com
$_SERVER["QUERY_STRING"] = num=1&id=142989&thread=142989
$new_log_line = " User « " . $SERVER["QUERY_STRING"] . " » requested : http://" . $SERVER["HTTP_HOST"] . $_SERVER["SCRIPT_NAME"] . "\n";
$fp = fopen("/path_to_log_file/log_file.log", "a+");
fputs($fp, $new_log_line);
fclose($fp);
This would produce :
User « num=1&id=142989&thread=142989 » requested http://www.phpbuilder.com/forum/read.php3
Hope it helped.
H. L.