#!/usr/local/bin/perl # Name: Selena Sol's Groupware Calendar # # Version: 4.0 # # Last Modified: 08-14-96 # # Copyright Info:This application was written by Selena Sol # (selena@eff.org, http://www.eff.org/~erict) having been inspired by # countless other Perl authors. Feel free to copy, cite, reference, # sample, borrow, resell or plagiarize the contents. However, if you # don't mind, please let me know where it goes so that I can at least # watch and take part in the development of the memes. Information wants # to be free, support public domain freware. Donations are appreciated # and will be spent on further upgrades and other public domain scripts. # # Finally, PLEASE SEND WORKING URL's to selena@eff.org. I maintain a list # of implementations around the world. ####################################################################### # Print http Header. # ####################################################################### # First tell Perl to bypass the buffer. Then, print out the HTTP # header. We'll output this quickly so that we # will be able to do some of our debugging from the web and so that in # the case of a bogged down server, we won't get timed-out. $! = 1; print "Content-type: text/html\n\n"; ####################################################################### # Require Libraries. # ####################################################################### # Now require the necessary files with the subroutine at the end of this # script marked by "sub CgiRequire". We use this subroutine so that if # there is a problem with the require, we will get a meaningful error # message. # ($lib is the location of the Library directory where these files # are to be stored. Set $lib = "." if you do not have a Library # directory. This variable must be set in this file AS WELL AS in # calendar.setup!!!) $lib = "."; &CgiRequire("$lib/cgi-lib.pl", "$lib/cgi-lib.sol", "$lib/auth-lib.pl", "$lib/date.pl"); ####################################################################### # Gather Form Data. # ####################################################################### # Now use cgi-lib.pl to parse the incomming form data. We'll pass # cgi-lib.pl (*form_data) so that our variable will come out as # $form_data{'key'} instead of $in{'$key'}. I like to use form_data # because it is easier for me to remember what the variable is. # In the end, we will be able to refernce all of the incoming form data as # $form_data{'variablename'} &ReadParse(*form_data); ####################################################################### # Determine Which Calendar Database to Use. # ####################################################################### # Now we will need to determine which calendar databse to use. If the # admin has set up more than one calendar, each calendar database will be # in a subdirectory. In order to reference these separate databases, the # link to this script must have added ?calenar=Somesubdirectory at the end # of the URL. If we are asking for the main calendar, this variable will # not be equal to anything. if ($form_data{'calendar'} ne "") { $calendar_type = "./$form_data{'calendar'}"; } else { $calendar_type = "./"; } ####################################################################### # Define Variables # ####################################################################### # Now we will define all of our variables by using the define file that # you should have customized for your own site. &CgiRequire("calendar.setup"); # Now we are going to want to make sure that we "remember" the # session_file so that we can continually check for authentication and # keep track of who the current client is. However, if the client has # already logged on, then we will not be going back through the # authentication rouitines but will be getting the $session_file as form # data (the same hidden field we are about to define). So, we need to # rename $form_data{'session_file'} to $session_file so that in both cases # (first time to this point or continuing client) we'll have the # session_id in the same variable name form. if ($form_data{'session_file'} ne "") { $session_file = $form_data{'session_file'}; } # Now rename some other variables with the same idea... if ($form_data{'year'} ne "") { $current_year = "$form_data{'year'}"; } else { $current_year = "$the_current_year"; } if ($form_data{'month'} eq "") { @mymonth = &make_month_array(&today); $current_month_name = &monthname($currentmonth); } else { @mymonth = &make_month_array(&jday($form_data{'month'},1,$current_year)); $current_month_name = &monthname($form_data{'month'}); } ####################################################################### # Print out Generic Header HTML. # ####################################################################### # Okay, so if we got to this line, it means that the client has # successsfully made it past security. So let's print out the basic # header information. You may modify everything between the # "print qq! and the !; but be careful of # illegal characters like @ which must be preceeded by a backslash # (ie: selena\@eff.org) # # Also create the hidden form tags that will pass along the session_file # info and the name of the calendar that we are dealing with. It is # crucial that we make sure to pass this info along through every page so # that this script can keep track of the clients as they wander about. ####################################################################### # Print out Calendar # ####################################################################### # Now let's actually print out the dynamically generated calendar. We'll # need to do this in two cases. Firstly, if we have just logged on and # the client is asking for the very first page ($form_data{'session_file'} # ne "") and secondly, if the client has already been moving through # various pages and has asked to view the calendar again # ($form_data{'change_month_year'} ne ""). The || means "or". Thus, if # either case is true, we will procede. if ($form_data{'change_month_year'} ne "" || $ENV{'REQUEST_METHOD'} eq "GET" && $form_data{'day'} eq "") { # Now print out the HTML calendar &header ("Chemistry 104 Spring 2000: $current_month_name - $current_year"); print qq!
| $day | \n"; } print "
|---|
| \n!;
print qq!$day_number\n!;
# Grab the subject listings for all the entries on that day. Make sure
# also that if we are unable to open the database file, that we send a
# useful message back to us for debugging. We'll do this using the
# open_error subroutine in cgi-lib.sol passing the routine the location of
# the database file.
open (DATABASE, "$database_file") || &CgiDie ("I am sorry, but I
was unable to open the calendar data file in the Create a Table
Cell for Each Day routine. The value I have is $database_file.
Would you please check the path ansd the permissions.");
while ( $subject\n!; } # End of if ($day eq "$day_number" && $month eq ... } # End of while ( | \n";
# If, however, we have reached the end of a week row, we are going to need
# to begin a new table row for the next week. If $weekday is equal to
# zero, then we know that it is time. If not, continue with the row.
# (BTW, here we use == instead of just = because if we used =, perl would
# interpret the part inside the if () to be assigning the value of zero to
# $weekday...which it would do...and evaluate the whole process as true.
# That of course would undercut the whole point of counting with
# $weekday.)
if ($weekday == 0)
{
print "
For day-at-a-glance-calendar, click on the day number on the calendar above.
Or, to see another 2000 month, choose one!; # Create a select box which will allow the client to choose a new month to # view. We'll use the subroutine select_a_month at the end of this # script. &select_a_month; print "Or, to see another year, select one\n"; # Likewise, create a select box which will allow the client to choose a # new year to view. We'll use the subroutine select_a_year at the end # of this script. &select_a_year; print qq!
* Note: This calendar is best viewed by opening your browser window to its maximum size. And, you can only submit a month if the year field is cleared.