#!/usr/bin/perl
# Created 8/6/00
# Scripted by TDavid @ http://www.tdscripts.com/
# Freeware, use and modify at your own risk. The author
# takes no responsibility for the use or misuse of this code
print "Content-type: text/html\n\n";
if($ENV{'HTTP_REFERER'} ne "") {
&log_event("$ENV{'HTTP_REFERER'}");
}
open(FILEHANDLE,";
flock(FILEHANDLE, 8);
close(FILEHANDLE);
foreach $each(@contents) {
chomp($each);
($event, $happened) = split(/\|/, $each);
$elapsed = &passing_time($happened);
$minutes = int($elapsed / 60);
$hours = int($elapsed / 3600);
$comparison = 172800;
if($elapsed > $comparison) {
$each = "";
$rebuild = 1;
} else {
if($elapsed > 0) {
print "$event stopped by $elapsed seconds, $minutes minutes and $hours hours ago
";
}
}
}
if($rebuild) { &rebuild_log; }
sub passing_time {
$past = $_[0];
$present = time;
$seconds = int($present - $past);
return($seconds);
}
sub log_event {
open(FILEHANDLE,">>/path/to/timesfile.txt");
flock(FILEHANDLE, 2);
$now = time;
print FILEHANDLE "$_[0]|$now\n";
flock(FILEHANDLE, 8);
close(FILEHANDLE);
}
sub rebuild_log {
open(FILEHANDLE,">/path/to/timesfile.txt");
flock(FILEHANDLE, 2);
foreach $each(@contents) {
chomp($each);
($event, $happened) = split(/\|/, $each);
if($each) { print FILEHANDLE "$event|$happened\n"; }
}
flock(FILEHANDLE, 8);
close(FILEHANDLE);
}