#! /usr/bin/perl ###################################################################### # Basic Calendar Version 1.01 # # Copyright 1999 Frederic TYNDIUK (FTLS) All Rights Reserved. # # E-Mail: tyndiuk@ftls.org Script License: GPL # # Created 05/30/99 Last Modified 07/15/99 # # Scripts Archive at: http://www.ftls.org/cgi/ # ###################################################################### # Function : # # calentar.cgi : print calendar of current month... # # calendar.cgi?MM-YYYY : print calendar of the MM-YYYY (01-2000) # # You can use this Script as SSI (Server Side Include) or Not, whith # # $SSI var. # # Your can chose size of tabe border with $Border = Size # ###################################################################### ##################### license & copyright header ##################### # # # Copyright (c) 1999 TYNDIUK Frederic # # # # This program is free software; you can redistribute it and/or # # modify it under the terms of the GNU General Public License as # # published by the Free Software Foundation; either version 2 of # # the License, or (at your option) any later version. # # # # This program is distributed in the hope that it will be useful, # # but WITHOUT ANY WARRANTY; without even the implied warranty of # # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # # GNU General Public License for more details. # # # # You should have received a copy of the GNU General Public License # # along with this program in the file 'COPYING'; if not, write to # # the Free Software Foundation, Inc., 59 Temple Place - Suite 330, # # Boston, MA 02111-1307, USA, or contact the author: # # # # TYNDIUK Frederic # # # # # ################### end license & copyright header ################### ###################################################################### # Necessary Variables: # # The following variables should be set to define the locations # # and URLs of various files, as explained in the documentation. # $CalCMD = "/usr/bin/cal"; # En: PATH of cal. # Fr: Chemin de cal. $SSI = 1; # 0 NO SSI (print ...) # 1 SSI (En: print only Calandar / Fr: N'affiche que le calendrier) $Border = 1; # En: Size of table Border. # Fr: Taille des Tables. $Days = "Su Mo Tu We Th Fr Sa"; # En: Days #$Days = "Di Lu Ma Me Je Ve Sa"; # Fr: Jours en Francais # Nothing Below this line needs to be altered! # ###################################################################### $Query_String = $ENV{QUERY_STRING}; $Query_String =~ s/%([0-9A-F][0-9A-F])/pack("C",oct("0x$1"))/ge; $Query_String =~ tr/+/ /; print "Content-type: text/html\n\n"; if (! $SSI) { print "Calendar

Calendar

\n"; } print &RetCal($CalCMD, $Query_String, $Border); if (! $SSI) { print ""; } # En: Sub routine return calendar. # Fr: Sous-routine retournant le calendrier. sub RetCal { my($CalCMD, $Args, $Border) = @_; my($ret, @Result, $Month, $dy, $line, $no); if ( -x "$CalCMD" ) { if (($Args !~ /^\d\d?-\d\d\d\d$/) || ($Args eq "")) { $Args = ""; @date = localtime(time); $Today = $date[3]; } else { $Args =~ s/-/ /g; } open(CAL, "$CalCMD $Args|"); @Result = ; close(CAL); $Month = $Result[0]; shift(@Result); $Month =~ s/\s\s\s*//g; $ret = "\n"; shift(@Result); foreach $dy (split(/ /, $Days)) { $ret .= ""; } $ret .= "\n"; foreach $line (@Result) { $line =~ s/\n//; $line =~ s/ /ccs/g; $line =~ s/ /sc/g; $line =~ s/ /s/g; $line =~ s/^s//g; $line =~ s/ss/s/g; $line =~ s/c//g; $ret .= ""; foreach $no (split(/s/, $line)) { if ($no == $Today) { $ret .= ""; } else { $ret .= ""; } } $ret .= "\n"; } $ret .= "
$Month
$dy
$no$no
\n"; } else { $ret = "Cannot find cal on this system."; } return $ret; }