#!/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 "
\n"; print "

Global Birthday Navigator (GBN)

\n"; for ($i = 0; ($i < 12); $i++) { print "", $monthNames[$i], "\n"; } print "today\n"; print "
\n"; print "\n"; #Now the subprograms sub OutputDay { local($month, $day) = @_; $birthdayCount = 0; print "World Birthday Web (WBW)\n"; print "

\n"; print "World Birthday Web (WBW)

\n"; $filename = $birthdayPath . "/" . ($month + 1) . "/" . $day; open(file, $filename); while (1) { if (!($name = )) { last; } chop $name; if (!($url = )) { last; } chop $url; if (!($email = )) { last; } chop $email; if (!($birthdayCount)) { print "

Birthdays for: ", ($month+1), "/", $day, "

\n"; } $birthdayCount++; print "
  • "; if ($url ne "") { print ""; } print $day, " ", $monthNames[$month], ": "; print "", $name, " "; if ($email ne "") { print "", $email, ""; } if ($url ne "") { print ""; } print "
  • \n"; } if ($birthdayCount) { print "\n"; print "

    Remember, the Birthday Server"; print "runs on Greenwich Mean Time.\n"; } } sub OutputMonth { local($month) = @_; print "World Birthday Web (WBW): ", $monthNames[$month], "\n"; print "\n"; print "

    World Birthday Web (WBW): ", $monthNames[$month], "

    \n"; print "

    Please select a day of the month.

    \n"; print "


    \n"; for ($i=1; ($i < 32); $i++) { print "", $i, "\n"; } }