Viewing file: hitslogger.cgi (2.5 KB) -rwxr-xr-x Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
#!/usr/bin/perl
$date=`/bin/date +"%T (%Z) %D"`;
chomp $date;
$date_hits=`/bin/date \+\"\%m\-\%d\-\%y\"`;
chomp $date_hits;
$mailprog="/usr/bin/sendmail";
$log_file="/home/mnnews/public_html/hits/hits.shtml";
$data_file="/home/mnnews/public_html/hits/data/$date_hits.dat";
if(!-f "$log_file") {
open(FILE, ">$log_file");
print FILE <<EOT;
<html>
<head>
<title>Website Hits Logger</title>
</head>
<body bgcolor="#ffffff" text="#000000" link="blue" vlink="blue" alink="red">
<center>
<table width=80%>
<tr><td width=100%>
<center><font face="Verdana" size=2>
<font size=5 color="#074B85"><b>Website Hits Logger</b></font>
</center>
<br>
<font size=2><b>This system was created on: 04:40:12 (CDT) 08/26/01</b></font>
</center>
<br>
<hr size=1>
<br>
<!--edit-->
<br>
<br>
</td></tr>
</table>
</body>
</html>
EOT
close(FILE);
$newfile=1;
}
open (FILE,"$data_file");
$NUMB=<FILE>;
$NUMB++;
close (FILE);
open (FILE,">$data_file");
print FILE "$NUMB";
close (FILE);
open (FILE,"$log_file");
@LINES=<FILE>;
close(FILE);
if ($ENV{REMOTE_USER} eq "") {
$ENV{REMOTE_USER} = "Not Available";
}
open (LOG,">$log_file");
for (my $i=0; $i <= $#LINES;$i++) {
if ($LINES[$i] =~ /<!--edit-->/) {
print LOG <<EOT;
<!--edit-->
<table width=80%>
<tr>
<td width=23%>
<font face="$$CustomConfig{'BodyFontFace'}" size=2>
<b>Date:</b></td>
<td width=77%>
<font face=arial size=2>
$date</td>
</tr>
<tr>
<td>
<font face="$$CustomConfig{'BodyFontFace'}" size=2>
<b>Requested Page:</b></td>
<td>
<font face=arial size=2>
$ENV{'REQUEST_URI'}</td>
</tr>
<tr>
<td>
<font face=arial size=2>
<b>IP Address:</b></td>
<td>
<font face=arial size=2>
$ENV{'REMOTE_ADDR'}</td>
</tr>
<tr>
<td>
<font face=arial size=2>
<b>Browser/OS:</b></td>
<td>
<font face=arial size=2>
$ENV{'HTTP_USER_AGENT'}</td>
</tr>
<tr>
<td>
<font face=arial size=2>
<b>From:</b></td>
<td>
<font face=arial size=2>
EOT
if ($ENV{'HTTP_REFERER'} eq "") {
print LOG <<EOT;
Not Available
EOT
} else {
print LOG <<EOT;
<a href="http://www.$ENV{'HTTP_REFERER'}">$ENV{'HTTP_REFERER'}</a>
EOT
}
print LOG <<EOT;
</td>
</tr>
<tr>
<td>
<font face=arial size=2>
<b>Who:</b></td>
<td>
<font face=arial size=2>
$ENV{REMOTE_USER}</td>
</tr>
</table>
<hr size=1>
EOT
} else {
print LOG $LINES[$i];
}
}
close (LOG);
|