#!/usr/bin/perl
# enter your perlbot logs directory here
my $directory = 'logs/';
use strict;
use CGI qw/-compile :standard :html3 :netscape/;
my $arg = shift;
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);
if(!$arg) {
print img({-src=>'logsearch.jpg'}), br;
print "
Logs for channels:
\n";
print " \n";
print "
\n";
print " \n";
print "
\n";
foreach my $diritem (@diritems) {
if (-d "$directory$diritem") {
if (!($diritem =~ /^(\.\.?|msg)$/)) {
print " - $diritem\n";
}
}
}
print "
\n";
} else {
my $chan = $arg;
if(!opendir(LOGLIST, "$directory$chan")) {
print "No logs for channel: $chan\n";
exit 1;
}
my @tmpfiles = readdir(LOGLIST);
my @logfiles = sort(@tmpfiles);
close LOGLIST;
print " \n";
foreach my $logfile (@logfiles) {
if (!($logfile =~ /^\.\.?$/)) {
print " - $logfile\n";
}
}
print "
\n";
}
print hr, br;
if ($arg) {
print 'Return to the list of channels', br;
}
print 'Search the logs', end_html;