#! /usr/bin/perl $location = "/home/dtj/public_html/"; $httploc = "uberh4x0r.org/~dtj"; $theTitle = "UNTITLED"; use FileHandle; use CGI; $cgi = new CGI; ($datafile) = @ARGV; print "Content-type: text/html", "\n\n"; #print "".$datafile."

\n"; $theFile=$location.$datafile; if (-d $theFile) { $theFile=$theFile."/index"; } $preambleShown = 0; $filesInLine = 0; $tableStarted = 0; if (($datafile eq "") || (! -e $theFile)) { print " 

 

 

No Data Found!

\n"; } open(INDEX_FILE,"<$theFile") || die "no index file"; while () { if (/^#/) { next; } #-----------------------# # The Title # #-----------------------# if (/^\%T/) { # new table or starter ($lhs,$rhs) = split(/ /,$_,2); $theTitle = $rhs; next; } #-----------------------# # Literal # #-----------------------# if (/^"/) { print $_; next; } #-----------------------# # New Table # #-----------------------# if (/^\%P/) { # new table or starter if ($tableStarted != 0) { if ($filesInLine > 0) { for ($i = $filesInLine; $i < 3; $i++) { print ""; # bogus items } } EndTable(); # close the table } # open the table ($lhs,$rhs) = split(/ /,$_,2); StartTable($rhs); next; } if (/^\%R/) { # New Row NewRow(); next; } chomp; if ($tableStarted == 0) { # no table yet, so open blank StartTable(); } if ($filesInLine == 0) { # need to start line print " 
\n"; print " \n"; } #-----------------------# # The Image # #-----------------------# print "
"; print ""; print "\n"; print "
\n"; print ""; print "$_
\n"; print "\n"; $filesInLine++; if ($filesInLine >= 3) { NewRow(); } } sub NewRow { if ($filesInLine > 0) { for ($i = $filesInLine; $i < 3; $i++) { print ""; # bogus items } } print "\n"; $filesInLine = 0; } WritePostamble(); sub WritePreamble { print ""; print "\n"; print "".$theTitle."\n"; print "\n"; print "\n"; print "\n"; print "
\n"; print "\n"; print "\n"; print "

".$theTitle."
\n"; print "
 
\n"; } sub WritePostamble { # # Clean up whats left. # EndTable(); print ""; print ""; } sub StartTable { $title = $_[0]; if ($title eq "") { $title = "UNKNOWN"; } if ($preambleShown == 0) { WritePreamble(); $preambleShown = 1; } print "\n"; print "\n"; print ""; $tableStarted = 1; $filesInLine = 0; } sub EndTable { if ($filesInLine > 0) { for ($i = $filesInLine; $i < 3; $i++) { print ""; print "
"; print "$title
"; # bogus items } } if ($tableStarted != 0) { print "
 
"; # close the table $tableStarted = 0; } }