#!/usr/bin/perl
require "/cgi-bin/cgi-lib.pl";
&ReadParse(*in);
print &PrintHeader;
$page = $in{'page'};
if ($page eq "")
{
	$page = 0;
}
@game = split(/\//,$ENV{'SCRIPT_NAME'});
$game = $game[2];
$dir = "/www/minis/".$game;
$thumbsdir = "/minis/thumbs";


$icon = $game."icon.jpg";
$titleicon = $game."logo.jpg";

print "<html><head>\n";
print "<title>$game</title>\n";
print "</head><body><center>\n";
print "<table><tr><td><a href=\"../index.html\">To the Index</a></td>\n";
print "<td><img border=0 src=\"$titleicon\"></td>\n";
print "<td><img src=\"$icon\"></td></tr></table><p>\n";
opendir(IMAGES,"$dir");
$i=0;
$curfile = readdir(IMAGES);
$curfile = readdir(IMAGES);
while($curfile ne "")
{
	@fileparts = split(/\./,$curfile);
	$file = @fileparts[0];
	$ext = @fileparts[1];
	if($ext eq "jpg" || $ext eq "JPG" || $ext eq "gif" || $ext eq "GIF" && (-s $dir/$curfile))
	{
		@filestats = stat("$dir/$curfile");
		$size[$i] = $filestats[7];
		@status = split(/\ /,localtime($filestats[10]));
		if ($status[2] ne ""){
		$timestamp[$i] = $status[1]." ".$status[2].", ".$status[4];}
		else{
		$timestamp[$i] = $status[1]." ".$status[3].", ".$status[5];}
		$filename[$i] = $curfile;
		$i++;
	}
	$curfile = readdir(IMAGES);
}
close(IMAGES);
$number_of_files = $i;
print "<table border=2>\n";
$j=1 + ($page * 16);
for($k=1;$k<5;$k++)
{
	print "<tr>";
	$o=0;
	for(;$o<4;$j++)
	{
		@newfile = split(/\./,$filename[$j]);
		$namefile = $newfile[0];
		@krush = split(/\-/,$newfile[0]);
		if($krush[1] ne "") {$caption = $krush[1];}
		else {$caption = $newfile[0];}
		if ($j < $i) {
		print "<td><a href=\"img.cgi?img=$filename[$j]\">";
		print "<img width=96 src=\"$thumbsdir/$namefile.gif\">";
		print "</a><br><a href=\"img.cgi?img=$filename[$j]\">$caption</a> \[";
		$size_mb = $size[$j] / 1048576;
		if ($size_mb > 1) {
		printf("%3.2f MB",$size_mb);
		}
		elsif ( ($size[$j] / 1000) > 0) {
		$size_k = $size[$j] / 1024;
		$size_k = $size_k + 0.5;
		printf("%d K",$size_k);
		}
		else {
			print "$size[$j] bytes";
		}
		print "\]<br>$timestamp[$j]</td>\n";
		}
		$o++;
	}
	print "</tr>";
}
print "</table>";
print "<center><table width=70\%><tr><td width=25\% align=left>";
if ($page != 0)
{
	print "<a href=\"show.cgi?page=".($page-1)."\">Previous Page</a>";
}
print "</td><td align=center width=50\%>";
for($pa=0; $pa <= ($number_of_files/16); $pa++)
{
	if($pa == $page)
	{
		print " <strong><font size=+1>&lt;<a href=\"show.cgi?page=$pa\">".($pa+1)."</a>&gt;</font></strong> \n";
	}
	else
	{
		print " <a href=\"show.cgi?page=$pa\">".($pa+1)."</a> \n";
	}
}
print "</td><td align=right width=25\%>";
if ($j < $number_of_files)
{
	print "<a href=\"show.cgi?page=".($page+1)."\">Next Page</a>";
}
print "</td></table><p>\n";
# print "<a href=\"http://www.osborn.com/~kdevine/cgi-bin/findvars.cgi\">Find Vars</a><br>";
print "<font size=1 face=\"MS Sans Serif\">Some of the images may be from official sites, therefore, they are copyrighted by their respective owners</font></center><br>";
print <<END;
<p align="left"><font size="1" face="MS Sans Serif">
Warhammer, Deathwing, Blood Angels, Dark
Angels, Gorkamorka, Necromunda, Space Wolves, Ultramarines, Warhammer Quest, Blood Bowl,
Eldar, Epic, Tyranid, Genestealer, Man O' War and White Dwarf are trademarks of Games Workshop
Limited, and are used here without permission; no challenge to their status is intended. The
Warhammer 40,000, Warhammer, Battlefleet Gothic, Blood Bowl, Man O' War and Epic40k logos are registered trademarks of Games Workshop, Inc.  The Gorkamorka and Necromunda logos are trademarks of Games Workshop, Inc.  For more information 
on Games Workshop&#146;s intellectual property standards, see:
<a href="http://www.games-workshop.com/ippolicy.html">http://www.games-workshop.com/ippolicy.html</a>.<br>
This website is completely unofficial and in no way endorsed by Games Workshop Limited<br>
All references refering to Clan War are copyrights of <a href="http://www.alderac.com">Alderac Entertainment Group</a>.  The Clan War logo is a trademark of Alderac<br>
All references to Warzone and Chronopia are copyrights of <a href="http://www.target.se">Target Games</a>.  The Warzone and Chronopia logo are trademarks of Target Games.<br>
I do not endorse or receive compensation for these pages, I am not affiliated with Target Games, Alderac Entertainment or Games Workshop.<br>
I am providing these pages as a location to swap painted fig pictures.  If there is any dispute over the copyright of a picture, it will be deleted immediately.  If any problems with copyright arise, please e-mail: <a href="mailto:kdevine\@worldnetoh.com">Kevin Devine</a> immediately and I will fix it.
</font>
END
print &HtmlBot;
exit;
