#!/usr/bin/perl ############################################ ## ## ## WebCal ## ## by Darryl Burgdorf ## ## (e-mail burgdorf@awsd.com) ## ## ## ## version: 1.00 ## ## last modified: 1/5/98 ## ## copyright (c) 1998 ## ## ## ## latest version is available from ## ## http://awsd.com/scripts/ ## ## ## ############################################ # COPYRIGHT NOTICE: # # Copyright 1998 Darryl C. Burgdorf. All Rights Reserved. # # This program may be used and modified free of charge by anyone, so # long as this copyright notice and the header above remain intact. By # using this program you agree to indemnify Darryl C. Burgdorf from any # liability. # # Selling the code for this program without prior written consent is # expressly forbidden. Obtain permission before redistributing this # program over the Internet or in any other medium. In all cases # copyright and header must remain intact. # VERSION HISTORY: # # 1.00 01/05/98 Initial "public" release $cgiurl = "http://www.elgonquin.com/lunchdates/index.cgi"; $datafile = "/home/elgonquin/WebSite/lunchdates/cal.data"; $bodyspec = "BGCOLOR=#ffffff TEXT=#333300 LINK=#00327E VLINK=#A89453"; $header_file = "header.txt"; $footer_file = "footer.txt"; # NOTHING BELOW THIS LINE NEEDS TO BE ALTERED! @months = (January,February,March,April,May,June, July,August,September,October,November,December); @shortmonths = (Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec); @days = (Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday); @shortdays = (Sun,Mon,Tue,Wed,Thu,Fri,Sat); $version = "1.00"; print "Content-type: text/html\n\n"; read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); @pairs = split(/&/, $buffer); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $INPUT{$name} = $value; } $time = time; ($mday,$month,$year) = (localtime($time))[3,4,5]; $month = $month+1; $year = $year+1900; unless ($INPUT{'Month'}) { $INPUT{'Month'} = $month; } unless ($INPUT{'Year'}) { $INPUT{'Year'} = $year; } unless ($INPUT{'Type'}) { $INPUT{'Type'} = "Table"; } if (($INPUT{'Year'} < 1601) || ($INPUT{'Year'} > 2899)) { &Header("Date Out of Range!"); print "

Date Out of Range!

\n"; print "

The date you provided is out of range."; print "
It must be between 1601 and 2899 A.D.

\n"; &Footer; exit; } open (DATA,$datafile); @data = ; close (DATA); foreach $line (@data) { if ($line =~ /\n$/) { chop ($line); } ($date,$desc,$URL) = split (/\|/, $line); ($dateyear,$datemonth,$dateday) = $date =~ m#(\d\d\d\d)(\d\d)(\d\d)#o; if ((int($dateyear) == int($INPUT{'Year'})) || (int($dateyear) < 1)) { if (int($datemonth) == int($INPUT{'Month'})) { if ($URL) { $Table{int($dateday)} .= "
"; $Table{int($dateday)} .= ""; $Table{int($dateday)} .= "$desc"; $Text{int($dateday)} .= " "; $Text{int($dateday)} .= ""; $Text{int($dateday)} .= "$desc\n"; } else { $Table{int($dateday)} .= "
"; $Table{int($dateday)} .= "$desc"; $Text{int($dateday)} .= " "; $Text{int($dateday)} .= "$desc\n"; } } } $Text{int($dateday)} =~ s/^ //; } &PerpetualCalendar(int($INPUT{'Month'}),1,int($INPUT{'Year'})); $heading = "@months[int($INPUT{'Month'})-1] $INPUT{'Year'}"; &Header("$heading"); if ($INPUT{'Type'} eq "Text") { print "

$heading

\n"; print "

\n";
	foreach $key (1..$perp_eom) {
		if ($key < 10) { print "0"; }
		print "$key ";
		print "@shortmonths[$INPUT{'Month'}-1] ";
		print "$INPUT{'Year'} ";
		$weekday = ($key+$perp_dow)-(int(($key+$perp_dow)/7)*7);
		if ($weekday < 1) { $weekday = 7; }
		print "(@shortdays[$weekday-1])   ";
		if ($Text{$key}) { print "$Text{$key}"; }
		else { print "\n"; }
		if (($weekday == 7) && !($key == $perp_eom)) {
			print "\n                    ---------------\n\n";
		}
	}
	print "

\n"; } else { print "

\n"; print ""; foreach $key (1..7) { print "\n"; if ($perp_dow > 0) { print ""; } foreach $key (1..$perp_eom) { print ""; $weekday = ($key+$perp_dow)-(int(($key+$perp_dow)/7)*7); if (($weekday == 0) && !($key == $perp_eom)) { print "\n\n"; } } if ($weekday > 0) { $leftover = 7-$weekday; print ""; } print "
\n"; print ""; print "\n"; print "
"; $LastYear = int($INPUT{'Year'}); $LastMonth = int($INPUT{'Month'})-1; if ($LastMonth == 0) { $LastMonth = 12; $LastYear -= 1; } print "
"; print ""; print ""; print ""; print ""; print "

$heading

"; $NextYear = int($INPUT{'Year'}); $NextMonth = int($INPUT{'Month'})+1; if ($NextMonth == 13) { $NextMonth = 1; $NextYear += 1; } print "
"; print ""; print ""; print ""; print ""; print "
"; print "@days[$key-1]"; } print "\n
"; print "

 

"; if (($INPUT{'Year'} == $year) && ($INPUT{'Month'} == $month) && ($key == $mday)) { print "

$key"; } else { print "

$key"; } print "($perp_sofar/$perp_togo)"; $perp_sofar++; $perp_togo -= 1; if ($Table{$key}) { print "$Table{$key}"; } else { print "

 "; } print "

"; print "

 

\n"; } &Footer; exit; sub Header { ($title) = @_; print "$title\n"; print "\n"; if ($header_file) { open (HEADER,"$header_file"); @header =
; close (HEADER); foreach $line (@header) { if ($line =~ //i) { &insertadvert($1); } else { print "$line"; } } } } sub Footer { print "
\n"; print "
\n"; print "

Month: "; print "Year: "; print "Type: \n"; print "

\n"; print "

\n"; print "

"; print "Maintained with a modified version of "; print ""; print "WebCal $version.

\n"; if ($footer_file) { open (FOOTER,"$footer_file"); @footer =