#!/usr/bin/perl -wT
use strict;
use CGI qw(:standard);
use CGI::Carp qw(fatalsToBrowser);
use CGI::Cookie;
use POSIX qw(strftime);
use Data::Dumper;
my %cookies = fetch CGI::Cookie;
my $stylesheet;
if ($cookies{'css'} eq undef) { $stylesheet = 'default' } else { $stylesheet = $cookies{'css'}->value }
my $fetchdate = param("date");
sub error {
my($error) = @_;
print qq(Content-type:text/html\n\n
I'm sorry Dave, I'm afraid I can't do that.
back
The scripts have generated an error!
They say: $error
back
);
}
-e "../httpdocs/logs/$fetchdate.log" or &error("The log file you requested does not exist.");
$fetchdate =~ /(\d{4})(\d\d)(\d\d)/;
my($year, $month, $day) = ($1, $2, $3);
my $title = strftime("%d %B %Y",0,0,0,$3,$2-1,$1-1900);
my $oldcomments = "";
my $numcomments = 0;
my $logwords = "";
open(LOGFILE, "logs/$fetchdate.log");
while (my $line = ) { $logwords .= $line }
close(LOGFILE);
while (my $line = ) {
$oldcomments .= $line;
$numcomments += 1;
}
close(COMMENTFILE);
#BEGIN SITE NAVIGATION SUPPORT
opendir(LOGDIR, "../httpdocs/logs");
my $logdirlist;
for my $file (sort grep { $_ !~ /^\./ } readdir(LOGDIR)) { $logdirlist .= $file . "\n" }
closedir(LOGDIR);
my @logs = split("\n", $logdirlist);
my $first;
my $prev;
my $thislog;
my $next;
my $last;
my $lognum = @logs;
for (my $i=0; $i<$lognum; $i++) {
if ($logs[$i] eq "$fetchdate.log") {
$thislog = $logs[$i];
if ($logs[0] ne $thislog) { $first = $logs[0] }
if ($i > 0) { $prev = $logs[$i-1] }
if ($i < $lognum) { $next = $logs[$i+1] }
if ($logs[$lognum-1] ne $thislog) { $last = $logs[$lognum-1] }
} #else { &error("I couldn't find the file! $!") }
}
#END SITE NAVIGATION SUPPORT
print qq(Content-type:text/html\n\n
);
if ($first ne undef) {
$first =~ /(\d{8})/;
$first = $1;
print qq( \n);
}
if ($prev ne undef) {
$prev =~ /(\d{8})/;
$prev = $1;
print qq( \n);
}
if ($next ne undef) {
$next =~ /(\d{8})/;
$next = $1;
print qq( \n);
}
if ($last ne undef) {
$last =~ /(\d{8})/;
$last = $1;
print qq( \n);
}
print qq(
$title
back
$logwords
Check CSS Check XHTML
back
);