#!/usr/bin/perl
be sure the above is the right path to perl
#
creates daily log files in standard NCSA combined format
#
change the value of $logfilepath to the full path of the directory where the log file will be
$logfilepath = "/full/path/to/directory/here/";
($day,$month,$date,$time,$year) = split(/\s+/,gmtime(time),5);
if ($date < 10) { $date = "0$date" };
if ($ENV{'DOCUMENT_URI'} eq "") { $ENV{'DOCUMENT_URI'} = "/" };
if ($ENV{'QUERY_STRING'} ne "") { $ENV{'DOCUMENT_URI'} .= "?$ENV{'QUERY_STRING'}" };
if ($ENV{'HTTP_REFERER'} eq "") { $ENV{'HTTP_REFERER'} = "-" };
if ("@ARGV" eq "") { @ARGV = "-" };
$logentry = "$ENV{'REMOTE_HOST'} - - [$date/$month/$year:$time +0000] \"GET $ENV{'DOCUMENT_URI'} HTTP/1.1\" 200 @ARGV \"$ENV{'HTTP_REFERER'}\" \"$ENV{'HTTP_USER_AGENT'}\"\n";
$logfile = "$logfilepath$date$month$year.log";
open (LOG, ">>$logfile");
flock(LOG, 2);
print LOG "$logentry";
flock(LOG, 8);
close (LOG);
I'd REALLY like to have this script to generate a NCSA compatible log file using PHP. Unfortunately I am not a programmer 🙁
Anybody that can help me out?
Thnx in advance.
Dreas