#! /usr/bin/perl # vault.pl # lists available Fluble comics in nice hierarchical format # by John Leen created 19 April 1999 modified 22 April 1999 use CGI qw(:standard); # location of comics (relative to http server root) $comicsdir = "/home/fluble/.web/comics/"; $month[1] = "January"; $month[2] = "February"; $month[3] = "March"; $month[4] = "April"; $month[5] = "May"; $month[6] = "June"; $month[7] = "July"; $month[8] = "August"; $month[9] = "September"; $month[10] = "October"; $month[11] = "November"; $month[12] = "December"; # create and sort list of non-dot files opendir(DIR,$comicsdir); @dirlist = sort(grep(length($_) > 2 && (lc(substr($_,-3)) eq "gif" || lc(substr($_,-3)) eq "jpg"), readdir(DIR))); closedir(DIR); $dispdate = param("date"); # if user hasn't selected a date, make it the most recent if (length($dispdate) < 2) { $dispdate = substr($dirlist[$#dirlist],6,8); } $dispyear = substr($dispdate,0,4); $dispmonth = substr($dispdate,4,2); $dispday = substr($dispdate,6,2); # http header crap, meta tags, and table layout print("Content-type: text/html\n\n"); print("\n\nFLUBLE: The Vault ("); printf("%d/%d/%s)\n",$dispmonth, $dispday, substr($dispyear,2,2)); print("\n"); print("\n"); print("\n"); print("\n"); print("\n"); print("\n"); print(""); print("\n"); print("\n"); print("\n"); print("\n"); print("\n"); print("\n\n
\n"); print("       \n"); print("

\n"); print("
"); # got to start somewhere $prevmonth=7; $prevyear=1776; $prevday=4; # main loop: display list of dates for ($thisnum = 0; $thisnum <= $#dirlist; $thisnum++) { $fn = $dirlist[$thisnum]; # extract date from filename $thisdate=substr($fn,6,8); $thisyear=substr($fn,6,4); $thismonth=substr($fn,10,2); $thisday=substr($fn,12,2); # have we enetered a new year? if ($thisyear > $prevyear) { print("
  "); print("\"",$thisyear,"\"
\n"); } # have we entered a new month? if (($thisyear > $prevyear) || (($thisyear == $prevyear) && ($thismonth > $prevmonth))) { # if so, print heading and update variables if ($dispyear == $thisyear) { print("
\n"); print("
  ",uc($month[$thismonth]),"
\n"); print("
\n"); } $prevmonth=$thismonth; $prevyear=$thisyear; } # are we in the selected month? if (($dispmonth == $thismonth) && ($dispyear == $thisyear)) { # if so, list the current date print("   "); if (substr($dispdate,6,2) == $thisday) { $dispnum = $thisnum; $ext = substr($fn,-3); } print(sprintf("%d",$thisday)," ",$month[$thismonth],""); print("
\n"); } } # the comic itself print("
 
"); print(lc($month[$dispmonth])); printf(" %d",$dispday); print(" '",substr($dispyear,2,2)); print(""); print("
\n"); print("
\n"); if ($dispnum > 0) { print("\"Previous\""); # if ($dispnum < $#dirlist) { # print("     "); # } } # next and prev links if ($dispnum < $#dirlist) { print("\"Next\""); } print("

\n"); print("\n"); print("\n"); print("
\n"); print("Story Finder\n"); print("
    \n"); # story finder open(STORIES,"/home/httpd/cgi-bin/fluble/stories"); @storylist = sort(grep(length($_) > 2, )); close(STORIES); foreach $entry (@storylist) { $storydate=substr($entry,0,8); $storyname=substr($entry,9,-1); print("
  • "); print("",$storyname); print("   "); print(sprintf("%d",substr($storydate,6,2))," ",$month[substr($storydate,4,2)]," ",substr($storydate,0,4),""); print("
  • \n"); } print("
\n"); print("
\n\n\n");