#!/usr/bin/perl
#
# Catch22 (llama@osoal.org.nz)
# One Short Of A Llama [http://web.osoal.org.nz]

use strict;
use OneShortOfALlama;
use DBI;
use POSIX;

#
#
#

sub main
{
	my($dbh, $entries, $id, $buf);

	header('Thought', 'oneshortofallama.png', '/');

	print('<table width="100%" height="70%">
           <tr>
           <td valign="center" align="center">
           <img src="/pics/misc/osoal.jpg" alt="One Short Of A Llama">
           <br>
           <em>Powered by Geeks</em>
           <br>
           <br>
           <br>', "\n\n");

        if ($dbh = DBI->connect("dbi:mysql:$MySQLserver;database=osoal",
                                $MySQLuser, $MySQLpasswd))
	{
		$entries = $dbh->selectrow_array('select count(*) from babble');

		$id      = (rand(1 << 31) % $entries) + 1;
		$buf     = $dbh->selectrow_array("select message from babble where (id = $id)");

		print(quote($buf));

		$dbh->disconnect();
	}

	print('</td>
           </tr>
           </table>');

	footer();
}

main();
