#!/bin/perl ############################################################################ # File: today.cgi Version 1.4 # Purpose: Create HTML with Today In History Data # Author: The Puppet Master # Created: 5/17/98 # Copyright 1998 The Puppet Master - All Rights Reserved # Modifications: 8/7/1999 added age to the famous birthdays. # 1/2/2000 and 1/9/2000 - Added corrections for Y2K and Leap Year. ############################################################################ # Set up colors. Set $bg to 1 if you want a background image. $bg = 1; # 1 = Yes / 0 = No (Set the next 2 variables accordingly) # set $bgpic to the location of your background image if $bg above is set to 1 $bgpic = "http://www.lakewood-wa.com/images/logowm.gif"; # set $bgcolor to the background color you want if $bg above is set to 0 $bgcolor = "white"; # set your text, link, vlink and alink colors below $tcolor = "black"; # Text color $lcolor = "blue"; # Link color $vlink = "teal"; # Visited link color $alink = "maroon"; # Active link color # set the font face and font size you want below $fface = "ARIAL"; $fsize = "4"; # Set some other miscellaneous colors (You just have to play with them) $fdcolor = "purple"; # full date line color $bdcolor = "green"; # birthday title color $ecolor = "blue"; # event title color $remcolor = "red"; # reminder title color # Set your $basedir to the location of the today.dat encyclopedia file. $basedir = '/usr/local/etc/httpd/cgi-bin'; # Set your return_link and return_page. $return_link = "http://www.websitegenie.net"; $return_page = "WebsiteGenie.Net"; # Done ############################################################################ # DO NOT MODIFY ANYTHING BELOW THIS LINE UNLESS YOU KNOW WHAT YOU ARE DOING! ############################################################################ # The formdate.cgi is a subroutine found in Matt's and Craigs book # The CGI/Perl Cookbook. It is under their copyright and may only be # used with this program. if (! -e 'formdate.pl') { print "Content-type: text/html \n\n"; print "Can't Find/Open File FormDate.pl - Cause: $!"; exit; } require 'formdate.pl'; # Thanks to Matt Wright & Craig Patchett $file = 'today.dat'; $spacer="     "; $space = " "; $b_date_format = 'B<0m><0d>'; $s_date_format = 'S<0m><0d>'; $r_date_format = 'R<0m><0d>'; $full_date_format = ' - '; $dow_format = ''; $julian_format = '<0yd>'; # Y2K Fix! $yearformat = ''; # Fix for leap years. $year = &format_date(time,$yearformat); if ($year % 4 != 0 || ($year % 100 == 0 && $year % 400 != 0)) { $ydays = 365; } else { $ydays = 366; } $b_date = &format_date(time,$b_date_format); $s_date = &format_date(time,$s_date_format); $r_date = &format_date(time,$r_date_format); $full_date = &format_date(time,$full_date_format); $dow = &format_date(time,$dow_format); $dow=$dow+1; $julian = &format_date(time,$julian_format); $julian=$julian+1; $days_left = $ydays-$julian; # open file and read it into memory. if (!open(TODAY,"$basedir/$file")) { print "Content-type: text/html\n\n"; print "Can't Open $basedir/$file - Cause: $!"; exit; } @lines = ; close(TODAY); # For each line in @lines compare to our date variables. print "Content-type: text/html\n\n"; print "Today In History - A Perl script by The Puppet Master\n"; if ($bg eq '1') { print "\n"; } else { print "\n"; } print "

Today In History

A Perl Script By The Puppet Master
\n"; print "\n"; print "$spacer $spacer Here is what happened on $full_date...
\n"; print "$spacer $spacer It is day $julian of the year $year, and there are $days_left days left...

\n"; print "$spacer Famous People Born On This Day In History...

\n"; print "\n"; print "\n"; foreach $line(@lines) { if ($line =~ m|$b_date|) { chop($line); $lyear=substr($line,5,4); $line=substr($line,10); $age=$year-$lyear; print "\n"; } } print "
$spacer $spacer $lyear,$line\n"; if ($age ne $year) { print "
$spacerToday, this person is/would be $age years old.\n"; } print "
\n"; print "

\n"; print "$spacer Events On This Day In History...

\n"; print "\n"; print "\n"; foreach $line(@lines) { if ($line =~ m|$s_date|) { chop($line); $lyear=substr($line,5,4); $line=substr($line,10); print "\n"; } } print "
$spacer $spacer $lyear,$line
\n"; print "

\n"; $remind = 0; foreach $line(@lines) { if ($line =~ m|$r_date|) { chop($line); $value=substr($line,9,1); if ($value ne $space && $value ne $dow) { } else { $remind = 1; } } } if ($remind eq '1') { print "$spacer And Don't Forget...

\n"; print "\n"; foreach $line(@lines) { if ($line =~ m|$r_date|) { chop($line); $value=substr($line,9,1); if ($value eq $space) { $line=substr($line,10); print "\n"; } if ($value eq $dow) { $line=substr($line,10); print "\n"; } } } print "
$spacer $spacer $spacer $spacer $line
$spacer $spacer $line
\n"; } &HTML_Foot; sub HTML_Foot { print "

$return_page

\n"; print "

© Copyright 1998 - The Puppet Master
\n"; print "
Formdate.pl Subroutine © Copyright Craig Patchett & Matt Wright
\n"; print "
\n"; exit; }