#!/usr/local/bin/perl #You must change this path to the directory where #you wish to keep the database entries. Make sure #you fully specify the path from the leading / #on down. $birthdayPath = "/home/boutell/birthday_data"; #You must change this path to the URL at which #the program has been installed, so it can generate #valid links to itself. $birthdayProgramURL = "/cgi-bin/wbw1.pl"; %monthIndexes = ( "january", 0, "february", 1, "march", 2, "april", 3, "may", 4, "june", 5, "july", 6, "august", 7, "september", 8, "october", 9, "november", 10, "december", 12 ); @monthNames = ( "january", "february", "march", "april", "may", "june", "july", "august", "september", "october", "november", "december" ); #Fetch the PATH_INFO environment variable $pathInfo = $ENV{'PATH_INFO'}; #Break it down into path components @pathComponents = split(/\//,$pathInfo); #Find the month and day, if present. Ignore any #empty-string components in order to tolerate leading #and trailing slashes. $monthKnown = 0; $dayKnown = 0; $month = 0; $day = 0; #First the month $i = 0; while ($i <= $#pathComponents) { # Check for months $m = $monthIndexes{$pathComponents[$i]}; $i++; if ($m ne "") { $monthKnown = 1; $month = $m; last; } } #Now the day. This loop won't even get started if #the month wasn't found, as $i will already be too large. while ($i <= $#pathComponents) { # Check for days. For our purposes, a valid number # either evaluates as nonzero or is the string 0. if (($pathComponents[$i] != 0) || ($pathComponents[$i] eq '0')) { $dayKnown = 1; $day = $pathComponents[$i]; break; } $i++; } print "Content-type: text/html\n\n"; print "
\n"; if ($monthKnown && $dayKnown) { # Generate a page for a single day &OutputDay($month, $day); } elsif ($monthKnown) { # Generate a listing of days &OutputMonth($month); } else { #Generate a page for today local($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = gmtime(time); &OutputDay($mon, $mday); } print "Remember, the Birthday Server"; print "runs on Greenwich Mean Time.\n"; } } sub OutputMonth { local($month) = @_; print "