#!/usr/bin/perl # enter your perlbot logs directory here my $directory = 'logs/'; use strict; use CGI qw/-compile :standard :html3 :netscape/; use HTML::CalendarMonth; use HTML::Element; print header; print start_html(-bgcolor=>'white',-text=>'black',-title=>'IRC logs', -style=>'A:link {text-decoration: none}'); opendir(DIRLIST, $directory); my @diritems = readdir(DIRLIST); #for readability closedir(DIRLIST); my $chan; my $year; if(!param()) { print img({-src=>'logsearch.jpg'}), br; print "

Logs for channels:

\n"; print "

\n"; print "


\n"; print "

\n"; print "

\n"; } else { $chan = param('chan'); $year = param('year'); if(!opendir(LOGLIST, "$directory$chan")) { print "No logs for channel: $chan\n"; exit 1; } my @tmpfiles = readdir(LOGLIST); my @logfiles = sort(@tmpfiles); close LOGLIST; my @years; foreach my $logfile (@logfiles) { if (!($logfile =~ /^\.\.?$/)) { my ($tmpyear) = $logfile =~ /^(\d+)\./; if(!grep { /$tmpyear/ } @years) { push(@years, $tmpyear); } } } if(!$year) { print "

Logs for $chan in:

\n"; print "

\n"; print "


\n"; print "

\n"; print "

\n"; } else { print "

Logs for channel: $chan

"; print "


"; # foreach my $year (@years) { print "

$year

\n"; print "\n \n"; foreach my $month ((1..12)) { print " \n"; if($month % 4 == 0) { print " \n \n"; } } print "
\n"; $month = sprintf("%02d", $month); my $cal = HTML::CalendarMonth->new(year => $year, month => $month); foreach my $day ((1..31)) { my $paddedday = sprintf("%02d", $day); my $filename = "$year.$month.$paddedday"; if(grep { /\Q$filename\E/ } @logfiles) { $cal->item($day)->wrap_content(HTML::Element->new('a', href => "plog.pl?$chan/$filename")); } } print $cal->as_HTML(); print "
\n"; # } # print " \n"; } } print hr, br; if (param()) { if($year) { print "Return to the list of years for $chan\n", br; } print 'Return to the list of channels', br; } print 'Search the logs', end_html;