scripts/mcbot.cgi
author Markus Bröker <mbroeker@largo.dyndns.tv>
Sat, 13 Dec 2008 15:40:28 +0100
changeset 15 f19c1f9b4cd3
parent 0 586472add385
child 25 a0fad312ea30
permissions -rwxr-xr-x
ChangeLog mcbot-0.95-1 * current_channel changed from pointer type to char [41] * many constants added in parse.c and irc.c * codebase reduced committer: Markus Bröker <mbroeker@largo.homelinux.org>

#!/usr/bin/perl -W

use strict;

my $line;
my $a;
my $b;

print "CONTENT-TYPE: text/html\n\n";

print "<html>\n\t<head>\n\t\t<title>Factoids</title>\n\t</head>\n<body>\n";
open(FD, "dbtool -l |") or die("Cannot open file");

foreach $line(<FD>) {
	($a, $b) = split(/:/, $line, 2);
	$a =~ s/^[\t ]+//;					# skip blanks
	$b =~ s/^[\t ]+//;					# skip blanks
	$b =~ s/[\n]+//;					# for html source :)

	if ($b) {
		if($b =~ /^http/ ) {
			print "$a - <a href=\"$b\">$b</a><br>";
		} else {
			print "$a - $b<br>";
		}
	}
}

print "\n<br>$a\n";

print "</body></html>\n";
close(FD);