#!/usr/bin/perl -w

use CGI '*ol';
my $q = new CGI;

require 'ctime.pl';

open (HEADER, "<header.html");
my @header = <HEADER>;
close (HEADER);

my $now = time;
my $x = 0;
foreach $file (sort <*.gif *.png *.jpg>) {
  $objs[$x++] = $file;
  $objs[$x++] = $now - ((-M $file) * 86400);
}

my $total = $x;
my @list;

for ($x = 0; $x < $total; $x += 2) {
  my ($file, $date) = @objs[$x .. $x + 1];
  push(@list, $q->b($file) . $q->br . 'Submitted: ' . ctime($date) . $q->br . $q->img({ -src => $file, -alt => $file }));
}

print	$q->header( -type => 'text/html' ),
	$q->start_html( -title => "CircleMUD Logo Contest: " . $total / 2 . " entries." ),
	$q->h1('CircleMUD Logo Contest'),
	$q->h2('Guidelines'),
	@header,
	$q->h2('Entries thus far'),
	$q->i('in alphabetical order'),
	$q->hr,
	$q->ol( $q->li([ @list ]) ),
	$q->hr,
	'Page generated: ', ctime(time), $q->br,
	$q->a({ -href => 'mailto:cdev@circlemud.org' }, 'The CircleMUD Group'),
	$q->br, 'If you just want to make fun of my Perl code:',
	$q->a({ -href => 'ftp://ftp.circlemud.org/pub/greerga/www/logos/gallery.cgi' }, 'gallery.cgi' ),
	$q->end_html();
