#!/usr/local/bin/perl #Change these to locations appropriate for your system! $birthdayPath = "/home/boutell/birthday_data"; $birthdayProgramUrl = "/~boutell/wbw2.cgi"; require "cgi-lib.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", 11 ); @monthNames = ( "january", "february", "march", "april", "may", "june", "july", "august", "september", "october", "november", "december" ); print "Content-type: text/html\n\n"; print "\n
\n"; #Look for requests for particular days #and submissions of new entries. If #the PATH_INFO indicates neither, #display today's birthdays. In all #three cases, present the user's #next choices afterward. $pathInfo = $ENV{"PATH_INFO"}; #Clobber the leading / , if any $pathInfo =~ s/^\///; #Handles the content type print &PrintHeader; #Fetch the values &ReadParse(*values); if ($pathInfo eq "day") { &DayRequested(); } elsif ($pathInfo eq "submit") { &AcceptSubmission(); } else { &TodayRequested(); } &PresentOptions(); print "\n\n"; exit 0; sub TodayRequested { #Output today's birthdays local($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = gmtime(time); &OutputDay($mon, $mday); } sub DayRequested { local($monthName, $month, $day); $monthName = $values{"month"}; $month = $monthIndexes{$monthName}; $day = $values{"day"}; if ($day < 1) { # Constrain the day to a reasonable value $day = 1; } print $day, " ", $month, "\n"; &OutputDay($month, $day); } sub AcceptSubmission { local($monthName, $month, $day, $name, $url, $email, $path, $out); $monthName = $values{"month"}; $month = $monthIndexes{$monthName}; $day = $values{"day"}; if ($day < 1) { $day = 1; } $name = $values{"name"}; $url = $values{"url"}; $email = $values{"email"}; if ($name eq "") { # Complain. print "Remember, the Birthday Server"; print "runs on Greenwich Mean Time.\n"; } else { print "No birthdays have been entered "; print "for this day.\n"; } } sub PresentOptions { local($i); print "
\n"; print "