#!/usr/bin/perl use CGI::Carp qw(fatalsToBrowser); # # csCalendar - v2 - 082503 # $basepath = './'; ##################################################################### # # # Copyright © 1999-2001 CGISCRIPT.NET - All Rights Reserved # # # ##################################################################### # # # THIS COPYRIGHT INFORMATION MUST REMAIN INTACT # # AND MAY NOT BE MODIFIED IN ANY WAY # # # ##################################################################### # # When you downloaded this script you agreed to accept the terms # of this Agreement. This Agreement is a legal contract, which # specifies the terms of the license and warranty limitation between # you and CGISCRIPT.NET. You should carefully read the following # terms and conditions before installing or using this software. # Unless you have a different license agreement obtained from # CGISCRIPT.NET, installation or use of this software indicates # your acceptance of the license and warranty limitation terms # contained in this Agreement. If you do not agree to the terms of this # Agreement, promptly delete and destroy all copies of the Software. # # Versions of the Software # Only one copy of the registered version of CGISCRIPT.NET # may used on one web site. # # License to Redistribute # Distributing the software and/or documentation with other products # (commercial or otherwise) or by other than electronic means without # CGISCRIPT.NET's prior written permission is forbidden. # All rights to the CGISCRIPT.NET software and documentation not expressly # granted under this Agreement are reserved to CGISCRIPT.NET. # # Disclaimer of Warranty # THIS SOFTWARE AND ACCOMPANYING DOCUMENTATION ARE PROVIDED "AS IS" AND # WITHOUT WARRANTIES AS TO PERFORMANCE OF MERCHANTABILITY OR ANY OTHER # WARRANTIES WHETHER EXPRESSED OR IMPLIED. BECAUSE OF THE VARIOUS HARDWARE # AND SOFTWARE ENVIRONMENTS INTO WHICH CGISCRIPT.NET MAY BE USED, NO WARRANTY # OF FITNESS FOR A PARTICULAR PURPOSE IS OFFERED. THE USER MUST ASSUME THE # ENTIRE RISK OF USING THIS PROGRAM. ANY LIABILITY OF CGISCRIPT.NET WILL BE # LIMITED EXCLUSIVELY TO PRODUCT REPLACEMENT OR REFUND OF PURCHASE PRICE. # IN NO CASE SHALL CGISCRIPT.NET BE LIABLE FOR ANY INCIDENTAL, SPECIAL OR # CONSEQUENTIAL DAMAGES OR LOSS, INCLUDING, WITHOUT LIMITATION, LOST PROFITS # OR THE INABILITY TO USE EQUIPMENT OR ACCESS DATA, WHETHER SUCH DAMAGES ARE # BASED UPON A BREACH OF EXPRESS OR IMPLIED WARRANTIES, BREACH OF CONTRACT, # NEGLIGENCE, STRICT TORT, OR ANY OTHER LEGAL THEORY. THIS IS TRUE EVEN IF # CGISCRIPT.NET IS ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. IN NO CASE WILL # CGISCRIPT.NET' LIABILITY EXCEED THE AMOUNT OF THE LICENSE FEE ACTUALLY PAID # BY LICENSEE TO CGISCRIPT.NET. # # Credits: # Andy Angrick - Programmer - angrick@cgiscript.net # Mike Barone - Design - mbarone@cgiscript.net # # For information about this script or other scripts see # http://www.cgiscript.net # # Thank you for trying out our script. # If you have any suggestions or ideas for a new innovative script # please direct them to suggest@cgiscript.net. Thanks. # ######################################################################## # Config Variables # ######################################################################## ##set today's color $todaycolor = 'aqua'; $eventcolor = 'silver'; $eventtodaycolor = 'orange'; $vdefault = 'month'; @bad = ('badword1','badword2','badword3','badword3'); #word to replace the bad words with $rw = '&^#$%'; $flock=1; $in{'cinfo'} = '
Powered by: CGIScript.net){ $buff .= $_; } close DB; if($^O !~ /win/i){ $encpass = crypt($in{'mpassword'},'CS'); } else{ $encpass = $in{'mpassword'}; } $buff =~ s/\$username\s*=\s*'.*'/\$username='$in{'musername'}'/; $buff =~ s/\$password\s*=\s*'.*'/\$password='$encpass'/; open(DB,">$basepath/setup.cgi"); print DB $buff; close DB; print <<"EOF"; EOF exit; } sub SaveComment{ &GetConfig($in{'calid'}); if(!$in{'acomments'}){ &PError("Error. Comments are not allowed on this calendar"); exit; } (!$in{'comment'})&&(&PError("Please enter a comment")); (!$in{'name'})&&(&PError("Please enter a your name")); foreach my $i (@bad){ $in{'comments'} =~ s/$i/$rw/gi; $in{'name'} =~ s/$i/$rw/gi; } my(@e) = localtime(time); $e[4] = $e[4]+1; $e[5] = $e[5]+1900; my($date); if($in{'DateFormat'} eq 'English'){ $date = sprintf("%.2d%s%.2d%s%.4d %.2d:%.2d:%.2d",$e[4],$in{'Separator'},$e[3],$in{'Separator'},$e[5],$e[3],$e[2],$e[1]); } else{ $date = sprintf("%.2d%s%.2d%s%.4d %.2d:%.2d:%.2d",$e[3],$in{'Separator'},$e[4],$in{'Separator'},$e[5],$e[3],$e[2],$e[1]); } if(-e "$datapath/$in{'id'}-comments.cgi"){ $in{'comment'} =~ s/&#(\d+);/pack("c",$1)/ge; $in{'name'} =~ s/&#(\d+);/pack("c",$1)/ge; my($file) = &CheckSafe("$datapath/$in{'id'}-comments.cgi"); open(CMT,"+<$file"); ($flock)&&(flock(CMT,2)); my(@l); while(){ push(@l,$_); } seek(CMT,0,0); print CMT "$date-$in{'name'}: $in{'comment'}\n\n"; foreach my $i (@l){ print CMT $i; } truncate(CMT, tell(CMT)); ($flock)&&(flock(CMT,8)); close CMT; } if(! -e "$datapath/$in{'id'}-comments.cgi"){ $in{'comment'} =~ s/&#(\d+);/pack("c",$1)/ge; $in{'name'} =~ s/&#(\d+);/pack("c",$1)/ge; my($file) = &CheckSafe("$datapath/$in{'id'}-comments.cgi"); open(CMT,">$file"); ($flock)&&(flock(CMT,2)); print CMT "$date-$in{'name'}: $in{'comment'}\n\n"; ($flock)&&(flock(CMT,8)); close CMT; } &Redirect($in{'cgiurl'} . "?command=view&id=$in{'id'}&calid=$in{'calid'}&m=$in{'m'}&y=$in{'y'}&d=$in{'d'}","Comment Added"); exit; } sub MoreComments{ $/="\n\n"; open(CMT,"<$datapath/$in{'id'}-comments.cgi")||print "$!: $$datapath/$in{'id'}-comments.cgi"; ($flock)&&(flock(CMT,2)); my($c); while(){ $c++; $_ =~ s/([^\w\s\:\-])/'&#'.ord($1).';'/ge; $_ =~ s/^(.*?): /$1: <\/b>/g; $_ =~ s/\r*\n/
\n/g; $in{'comments'} .= $_; } close CMT; undef $/; $in{'comments'} =~ s/\n\n/\n
\n/g; (!$in{'comments'})&&($in{'comments'} ='No comments'); &PageOut("$cgipath/t_comments.htm"); exit; } sub AddEvent{ &CheckVars; &GetConfig($in{'calid'}); if(($in{'atype'} ne 'admin')&&($in{'puid'} ne $in{'UserName'})){ &PError("Error. Permission denied"); } my($id) = &GetID; &GetOutVars(1,$id,$in{'calid'}); my($file) = &CheckSafe("$datapath/$in{'calid'}.cgi"); open(DB,">>$file"); ($flock)&&(flock(DB,2)); print DB "$newentry\n"; close DB; ($flock)&&(flock(DB,8)); print DB &Redirect($in{'cgiurl'} . "?command=modify&cid=$in{'cid'}&calid=$in{'calid'}","Event Added"); exit; } sub SaveEventChanges{ &CheckVars; &GetConfig($in{'calid'}); if(($in{'atype'} ne 'admin')&&($in{'puid'} ne $in{'UserName'})){ &PError("Error. Permission denied"); } &GetOutVars($in{'approve'},$in{'id'},$in{'calid'}); my $sfile = &CheckSafe("$datapath/$in{'calid'}.cgi"); open(DB,"+<$sfile"); while(){ @f = split("\t",$_); ($f[0] ne $in{'id'})?(push(@l,$_)):(push(@l,"$newentry\n")); } seek(DB,0,0); foreach $i (@l){ print DB $i; } truncate(DB, tell(DB)); if($in{'acomments'}){ $in{'comments'} =~ s/&#(\d+);/pack("c",$1)/ge; my($file) = &CheckSafe("$datapath/$in{'id'}-comments.cgi"); open(CMT,">$file"); print CMT $in{'comments'}; close CMT; } &Redirect($in{'cgiurl'} . "?command=modify&cid=$in{'cid'}&calid=$in{'calid'}","Event Changed"); } sub DeleteEvent{ &GetConfig($in{'calid'}); if(($in{'atype'} ne 'admin')&&($in{'puid'} ne $in{'UserName'})){ &PError("Error. Permission denied"); } my $sfile = &CheckSafe("$datapath/$in{'calid'}.cgi"); open(DB,"+<$sfile"); while(){ @f = split("\t",$_); ($f[0] ne $in{'id'})&&(push(@l,$_)); } seek(DB,0,0); foreach $i (@l){ print DB $i; } truncate(DB, tell(DB)); &Redirect($in{'cgiurl'} . "?command=modify&cid=$in{'cid'}&calid=$in{'calid'}","Event Removed"); } sub PopCal{ &GetConfig($in{'calid'}); &ViewCalendarSub; &PageOut("$cgipath/t_popcal.htm"); exit; } sub ShowAddEvent{ $in{'command'} = 'adde'; (!$in{'CalName'})&&(&PError("Error. Please enter a name for your calendar before adding events")); (!$in{'calid'})&&(&SaveNewCalendar); &GetConfig($in{'calid'}); if($in{'dateformat'} eq 'European'){ $in{'df'} = 'DD-MM-YYYY'; } else{ $in{'df'} = 'MM-DD-YYYY'; } foreach my $i (1..10){ next if ($in{'c'.$i} lt '0'); $in{'cfields'} .= qq| $in{'c'.$i}: |; } $in{'approve1'} = 'selected'; $in{'etypesingle'} = 'checked'; $in{'cancelbutton'} = qq||; &PageOut("$cgipath/t_add_event.htm"); exit; } sub SaveConfig{ ($in{'cpp'} =~ /[^\d]/)&&(&PError("Error. Comments per page has to be a number")); ($in{'pd'} eq '1')&&($in{'pw'} =~ /[^\d]/)&&(&PError("Error. Popup width has to be a number")); ($in{'ph'} eq '1')&&($in{'ph'} =~ /[^\d]/)&&(&PError("Error. Popup height has to be a number")); if(!$in{'calid'}){ &PError("Error. Please save the calendar before changing the configuration"); } else{ my(@p); my($file) = &CheckSafe("$datapath/calendars.cgi"); open(DB,"+<$file"); ($flock)&&(flock(DB,2)); while(){ chomp; my(@f) = split("\t",$_); if($f[0] eq $in{'calid'}){ $f[5] = $in{'dateformat'}; $f[6] = $in{'separator'}; $f[7] = $in{'allowpub'}; $f[8] = $in{'requireapproval'}; $f[9] = $in{'emailnotify'}; ($in{'emailnotify'})&&(!$in{'approveremail'})&&(&PError("Please enter an email address to send the approvals to")); ($in{'approveremail'})&&($in{'approveremail'} !~ /\S+\@\S+/)&&(&PError("Error. Invalid approval email address")); $in{'approveremail'} =~ s/&#(\d+);/pack("c",$1)/ge; $in{'approveremail'} =~ s/([^\w\s\n])/'&#'.ord($1).';'/ge; $f[10] = $in{'approveremail'}; $f[11] = $in{'allowreminders'}; ($in{'allowreminders'})&&(!$in{'senderemail'})&&(&PError("Please enter an email address for where the reminders are being sent from")); ($in{'senderemail'})&&($in{'senderemail'} !~ /\S+\@\S+/)&&(&PError("Error. Invalid sender email address")); $in{'senderemail'} =~ s/&#(\d+);/pack("c",$1)/ge; $in{'senderemail'} =~ s/([^\w\s\n])/'&#'.ord($1).';'/ge; $f[12] = $in{'senderemail'}; $f[13] = $in{'acomments'}; $f[14] = $in{'cpp'}; $f[14] = $in{'cpp'}; $f[15] = $in{'sdefault'}; for my $c (1..10){ $in{'c'.$c} =~ s/&#(\d+);/pack("c",$1)/ge; $in{'c'.$c} =~ s/([^\w\s\n])/'&#'.ord($1).';'/ge; $f[15+$c] = $in{'c'.$c} } $f[26] = $in{'wstart'}; $f[27] = $in{'pd'}; $f[28] = $in{'pw'}; $f[29] = $in{'ph'}; $f[30] = $in{'cs1'}; $f[31] = $in{'cs2'}; $f[32] = $in{'cs3'}; $f[33] = $in{'cs4'}; $f[34] = $in{'cs5'}; $f[35] = $in{'cs6'}; $f[36] = $in{'cs7'}; $f[37] = $in{'cs8'}; $f[38] = $in{'cs9'}; $f[39] = $in{'cs10'}; my($nv) = join("\t",@f); push(@p,$nv); } else{ push(@p,$_); } } seek(DB,0,0); foreach my $i (@p){ print DB "$i\n"; } truncate(DB, tell(DB)); ($flock)&&(flock(DB,8)); close DB; } &Redirect($in{'cgiurl'} . "?command=manage&cid=$in{'cid'}","Configuration Updated"); exit; } sub GetConfig{ my($id) = @_; my($file) = &CheckSafe("$datapath/calendars.cgi"); open(DB,"<$file"); while(){ chomp; my(@f) = split("\t",$_); if ($id == $f[0]){ $in{'puid'} = $f[1]; $in{'CalName'} = $f[3]; $in{'CalName'} =~ s/&#(\d+);/pack("c",$1)/ge; $in{'CalName'} =~ s/([^\w\s\n])/'&#'.ord($1).';'/ge; $in{'CalDesc'} = $f[4]; $in{'CalDesc'} =~ s/&#(\d+);/pack("c",$1)/ge; $in{'CalDesc'} =~ s/([^\w\s\n])/'&#'.ord($1).';'/ge; $in{'dateformat'.$f[5]} = 'checked'; $in{'DateFormat'} = $f[5]; $in{'separator'.$f[6]} = 'checked'; ($f[6] eq 'Slash')&&($in{'Separator'} = '/'); ($f[6] eq 'Hyphen')&&($in{'Separator'} = '-'); ($f[6] eq 'Period')&&($in{'Separator'} = '.'); $in{'allowpub'} = $f[7]; $in{'requireapproval'} = $f[8]; $in{'emailnotify'} = $f[9]; $in{'approveremail'} = $f[10]; $in{'approveremail'} =~ s/&#(\d+);/pack("c",$1)/ge; $in{'approveremail'} =~ s/([^\w\s\n])/'&#'.ord($1).';'/ge; $in{'allowreminders'} = $f[11]; $in{'senderemail'} = $f[12]; $in{'senderemail'} =~ s/&#(\d+);/pack("c",$1)/ge; $in{'senderemail'} =~ s/([^\w\s\n])/'&#'.ord($1).';'/ge; $in{'acomments'} = $f[13]; $in{'cpp'} = $f[14]; $in{'sdefault'} = $f[15]; $in{'wstart'} = $f[26]; $in{'wstart'.$f[26]} = 'selected'; $in{'pd'} = $f[27]; $in{'pd'.$f[27]} = 'checked'; $in{'pw'} = $f[28]; $in{'ph'} = $f[29]; $in{'cs1'} = $f[30]; $in{'cs2'} = $f[31]; $in{'cs3'} = $f[32]; $in{'cs4'} = $f[33]; $in{'cs5'} = $f[34]; $in{'cs6'} = $f[35]; $in{'cs7'} = $f[36]; $in{'cs8'} = $f[37]; $in{'cs9'} = $f[38]; $in{'cs10'} = $f[39]; for my $c (1..10){ $in{'c'.$c} = $f[15+$c]; $in{'c'.$c} =~ s/&#(\d+);/pack("c",$1)/ge; $in{'c'.$c} =~ s/([^\w\s\n])/'&#'.ord($1).';'/ge; } } } close DB; } sub ShowConfig{ if(!$in{'calid'}){ &PError("Error. Please save the calendar before changing the configuration"); } $in{'categoryname'} = &GetCatName($in{'cid'}); &GetConfig($in{'calid'}); &PageOut("$cgipath/t_config.htm"); exit; } sub ShowModifyCal{ $in{'categoryname'} = &GetCatName($in{'cid'}); &GetConfig($in{'calid'}); my($file) = &CheckSafe("$datapath/calendars.cgi"); open(DB,"<$file"); while(){ my($id,$uid,$cid,$calName,$calDesc,@rest) = split("\t",$_); ($module)&&($in{'atype'} ne 'admin')&&($uid ne $in{'UserName'})&&(next); if ($id == $in{'calid'}){ $in{'CalName'} = $calName; $in{'CalDesc'} = $calDesc; $in{'CalDesc'} =~ s/&#(\d+);/pack("c",$1)/ge;$in{'CalDesc'} =~ s/\\n/\n/g; $in{'calid'} = $id; } } close DB; &ManageView($in{'calid'}); &PageOut("$cgipath/t_add_edit_calendar.htm"); exit; } sub GetCatName{ my($cid) =@_; my($id,$uid,$name,@rest,$name); my($file) = &CheckSafe("$datapath/categories.cgi"); open(DB,"<$file"); while(){ chomp; ($id,$uid,$name,@rest) = split("\t",$_); last if ($id == $cid); } close DB; return $name; } sub ShowAddCalendar{ (!$in{'cid'})&&(&PError("Error. Please create a category first.")); $in{'categoryname'} = &GetCatName($in{'cid'}); &ManageView; $in{'command'} = 'savcal'; &PageOut("$cgipath/t_add_edit_calendar.htm"); exit; } sub ShowLinksWizard{ my($catId) = $in{'cid'}; my($selected,%calendars); my($file) = &CheckSafe("$datapath/categories.cgi"); open(DB,"<$file"); while(){ chomp; my($id,$uid,$catname) = split("\t",$_); ($module)&&($in{'atype'} ne 'admin')&&($uid ne $in{'UserName'})&&(next); (!$in{'cid'})&&($in{'cid'} = $id)&&($catId = $id); if ($id == $catId) { $selected = 'selected'; $in{"CatName"} = $catname; } else{ $selected = ''; } $in{'categories'} .= qq|\n|; } close DB; (!$in{'categories'})&&($in{'categories'} = ''); my($file) = &CheckSafe("$datapath/calendars.cgi"); open(DB,"<$file"); while(){ chomp; my($id,$uid,$cid,$calName,@rest) = split("\t",$_); (!$in{'calid'})&&($in{'calid'} = $id); ($module)&&($in{'atype'} ne 'admin')&&($uid ne $in{'UserName'})&&(next); if ($id == $in{'calid'}) { $selected = 'selected'; } else{ $selected = ''; } $calendars{$calName.'-'.$id} = qq~ ~ unless ($cid != $catId); } close DB; foreach my $i (sort keys %calendars){ $in{'calendars'} .= $calendars{$i}; } (!$in{'calendars'})&&($in{'calendars'} = qq||); if($in{'filter'}){ $in{'filter'} =~ s/([^\w])/'%'.sprintf("%.2x",ord($1))/ge; $filter = "\&filter=$in{'filter'}"; } $in{'smalljs'} = qq||; $in{'largejs'} = qq||; $in{'initjs'} = qq||; ($myurl) = $in{'cgiurl'} =~ /http:\/\/.*?(\/.*)/i; $in{'small'} = qq||; $in{'large'} = qq||; $in{'init'} = qq||; if($module){ &PageOut("$cgipath/t_show_links_mod.htm"); } else{ &PageOut("$cgipath/t_show_links.htm"); } exit; } sub ViewInit{ if(!$in{'mday'}){ &ctime(time); $in{'mday'} = $in{'myday'}; } &GetConfig($in{'calid'}); &ViewCalendarSub; if($in{'CalDesc'}){ $in{'description'} = "
$in{'CalDesc'}"; } ($in{'o'} eq 'j')?(&PageOutJS("$cgipath/t_view_init.htm")):(&PageOut("$cgipath/t_view_init.htm")); exit; } sub SubmitForApproval{ &GetConfig($in{'calid'}); &CheckVars; $id = &GetID; my($havetoapprove); ($in{'requireapproval'})?($havetoapprove=0):($havetoapprove=1); &GetOutVars($havetoapprove,$id,$in{'calid'}); if($in{'emailnotify'}){ &SendEmailNotify; } my $sfile = &CheckSafe("$datapath/$in{'calid'}.cgi"); open(DB,">>$sfile"); ($flock)&&(flock(DB,2)); print DB "$newentry\n"; close DB; ($flock)&&(flock(DB,8)); print <<"EOF"; EOF exit; } sub SendEmailNotify{ ($in{'c1'})&&($in{'cf'} .= "$in{'c1'}: $in{'cv1'}\r\n"); ($in{'c2'})&&($in{'cf'} .= "$in{'c2'}: $in{'cv2'}\r\n"); ($in{'c3'})&&($in{'cf'} .= "$in{'c3'}: $in{'cv3'}\r\n"); ($in{'c4'})&&($in{'cf'} .= "$in{'c4'}: $in{'cv4'}\r\n"); ($in{'c5'})&&($in{'cf'} .= "$in{'c5'}: $in{'cv5'}\r\n"); ($in{'c6'})&&($in{'cf'} .= "$in{'c6'}: $in{'cv6'}\r\n"); ($in{'c7'})&&($in{'cf'} .= "$in{'c7'}: $in{'cv7'}\r\n"); ($in{'c8'})&&($in{'cf'} .= "$in{'c8'}: $in{'cv8'}\r\n"); ($in{'c9'})&&($in{'cf'} .= "$in{'c9'}: $in{'cv9'}\r\n"); ($in{'c10'})&&($in{'cf'} .= "$in{'c10'}: $in{'cv10'}\r\n"); my(@f) = split("\t",$newentry); if($f[22] eq 'single'){ $when = "$f[23]"; if($f[15] eq 'checked'){ $when .= " from $f[16]:$f[17] $f[18] to $f[19]:$f[20] $f[21]"; } } elsif($f[22] eq "multiple"){ $when = "$f[24] to $f[25]"; if($f[15] eq 'checked'){ $when .= " from $f[16]:$f[17] $f[18] to $f[19]:$f[20] $f[21]"; } } else{ $when = "starting on $f[26]"; if($f[28] == 2){ $when .= " ending after $f[29] occurences"; } if($f[28] == 3){ $when .= " ending on $f[27]"; } if($f[30] == 1){ $when .= " repeating every $f[31] day(s)"; } if($f[30] == 2){ undef(@d); ($f[33])&&(push(@d,"Sunday")); ($f[34])&&(push(@d,"Monday")); ($f[35])&&(push(@d,"Tuesday")); ($f[36])&&(push(@d,"Wednesday")); ($f[37])&&(push(@d,"Thursday")); ($f[38])&&(push(@d,"Friday")); ($f[39])&&(push(@d,"Saturday")); $dw = join(", ",@d); $when .= " repeating every $f[32] week(s) on $dw"; } if($f[30] == 3){ if($f[40] == 1){ $when = " repeating day $f[41] of every $f[42] month(s)"; } else{ $when = " repeating the $f[43] $f[44] of every $f[45] month(s)"; } } if($f[30] == 4){ if($f[46] == 1){ $when = " repeating every $f[47] $f[48]"; } else{ $when = " repeating the $f[49] $f[50] of $f[51]"; } } } my($mess); if($in{'requireapproval'}){ $mess = 'The follow event has been submitted for your approval'; } else{ $mess = 'The follow event has been submitted'; } (!$in{'email'})&&($in{'approveremail'}); $in{'approveremail'}=~ s/&#(\d+);/pack("c",$1)/ge; $in{'title'} =~ s/&#(\d+);/pack("c",$1)/ge; $in{'body'} =~ s/&#(\d+);/pack("c",$1)/ge; $in{'cf'} =~ s/&#(\d+);/pack("c",$1)/ge; $message = qq| $mess Calendar ---------------- $in{'CalName'} Event Date ---------------- $when Event Name: $in{'title'} $in{'cf'} Event Description ----------------- $in{'body'} $in{'cgiurl'}?command=modify&calid=$in{'calid'} |; if($sendmail){ my $sfile = &CheckSafe("$sendmail"); open(MAIL,"|$sfile -t"); print MAIL<<"EOF"; To: $in{'approveremail'} From: $in{'email'} Subject: Calendar Submission $message EOF close MAIL; } if($mailserver){ require("$basepath/sendmail.cgi"); &SendMail($in{'approveremail'},$in{'email'},"Calendar Submission",$message,$mailserver); } } sub ShowSubmit{ &GetConfig($in{'calid'}); if($in{'requireapproval'}){ $in{'em'} = qq| Your Email: |; } $in{'command'} = 'submitforapproval'; foreach my $i (1..10){ next if ($in{'c'.$i} lt '0'); $in{'cfields'} .= qq| $in{'c'.$i}: |; } $in{'etypesingle'} = 'checked'; $in{'cancelbutton'} = qq||; &PageOut("$cgipath/t_add_event.htm"); exit; } sub ViewSmall{ &GetConfig($in{'calid'}); &ViewCalendarSub; if($in{'allowpub'}){ $in{'submitentry'} = qq||; } if($in{'CalDesc'}){ $in{'description'} = "
$in{'CalDesc'}"; } if($in{'e'} eq '1'){ ($in{'o'} eq 'j')?(&PageOutJS("$cgipath/t_events.htm")):(&PageOut("$cgipath/t_events.htm")); } else{ ($in{'o'} eq 'j')?(&PageOutJS("$cgipath/t_view_small.htm")):(&PageOut("$cgipath/t_view_small.htm")); } exit; } sub ViewLarge{ &GetConfig($in{'calid'}); &ViewCalendarSub; if($in{'allowpub'}){ $in{'submitentry'} = qq||; } $in{'ydate'} = $MoY[$in{'mymonth'}-1] . ' ' . $in{'myyear'}; if($in{'CalDesc'}){ $in{'description'} = "
$in{'CalDesc'}"; } ($in{'o'} eq 'j')?(&PageOutJS("$cgipath/t_view_large.htm")):(&PageOut("$cgipath/t_view_large.htm")); exit; } sub View{ &GetConfig($in{'calid'}); my $sfile = &CheckSafe("$datapath/$in{'calid'}.cgi"); open(DB,"$sfile"); while(){ chomp; @f = split("\t",$_); if($f[0] eq $in{'id'}){ $in{'id'} = $f[0]; $in{'calid'} = $f[1]; $in{'cid'} = $f[2]; $in{'title'} = $f[3]; $in{'cv1'} = $f[4]; $in{'cv2'} = $f[5]; $in{'cv3'} = $f[6]; $in{'cv4'} = $f[7]; $in{'cv5'} = $f[8]; $in{'cv6'} = $f[9]; $in{'cv7'} = $f[10]; $in{'cv8'} = $f[11]; $in{'cv9'} = $f[12]; $in{'cv10'} = $f[13]; $in{'body'} = $f[14]; $in{'body'} =~ s/&#(\d+);/pack("c",$1)/ge; $in{'body'} =~ s/\\n/
\n/g; $in{'showtimes'} = $f[15]; $in{'sthour'.$f[16]} = 'selected'; $in{'stmin'.$f[17]} = 'selected'; $in{'stsuf'.$f[18]} = 'selected'; $in{'ethour'.$f[19]} = 'selected'; $in{'etmin'.$f[20]} = 'selected'; $in{'etsuf'.$f[21]} = 'selected'; $in{'etype'.$f[22]} = 'checked'; $in{'sedate'} = $f[23]; $in{'sdate'} = $f[24]; $in{'edate'} = $f[25]; $in{'srdate'} = $f[26]; $in{'erdate'} = $f[27]; $in{'ed'.$f[28]} = 'checked'; $in{'oc'} = $f[29]; $in{'pattern'.$f[30]} = 'checked'; $in{'pdaily'} = $f[31]; $in{'pweekly'} = $f[32]; $in{'wd0'} = $f[33]; $in{'wd1'} = $f[34]; $in{'wd2'} = $f[35]; $in{'wd3'} = $f[36]; $in{'wd4'} = $f[37]; $in{'wd5'} = $f[38]; $in{'wd6'} = $f[39]; $in{'monthlytype'.$f[40]} = 'checked'; $in{'m1'} = $f[41]; $in{'m2'} = $f[42]; $in{'m3'.$f[43]} = 'selected'; $in{'m4'.$f[44]} = 'selected'; $in{'m5'} = $f[45]; $in{'yearlytype'.$f[46]} = 'checked'; $in{'y1'.$f[47]} = 'selected'; $in{'y2'} = $f[48]; $in{'y3'.$f[49]} = 'selected'; $in{'y4'.$f[50]} = 'selected'; $in{'y5'.$f[51]} = 'selected'; $in{'approve'} = $f[52]; last; } } close DB; foreach my $i (1..10){ next if ($in{'c'.$i} lt '0'); $in{'cfields'} .= qq| $in{'c'.$i}: $in{'cv'.$i} |; } if(($f[22] eq 'multiple')&&(!$set{$f[0]})&&($f[25])){ my($sm,$sd,$sy) = $f[24] =~ /(\d*)[^\d](\d*)[^\d](\d*)/; my($em,$ed,$ey) = $f[25] =~ /(\d*)[^\d](\d*)[^\d](\d*)/; if($f[15] eq 'checked'){ if(($f[16])&&($f[17])&&($f[18])){ $timestart= "$f[16]:$f[17] $f[18]"; } if(($f[19])&&($f[20])&&($f[21])){ $timeend = "$f[19]:$f[20] $f[21]"; } } $in{'fulldate'} = "$sm$in{'Separator'}$sd$in{'Separator'}$sy $timestart to $em$in{'Separator'}$ed$in{'Separator'}$ey $timeend"; } else{ $in{'fulldate'} = &ctime(timelocal(0,0,0,$in{'d'},$in{'m'}-1,$in{'y'})); chomp $in{'fulldate'}; } if(($f[15] eq 'checked')&&($f[22] ne 'multiple')){ $in{'fulltime'} .= "
$f[16]:$f[17] $f[18] - $f[19]:$f[20] $f[21]"; } if($in{'acomments'}){ (!$in{'cpp'})&&($in{'cpp'} = 5); $/="\n\n"; open(CMT,"<$datapath/$in{'id'}-comments.cgi"); ($flock)&&(flock(CMT,2)); my($c); while(){ chomp; $_ =~ s/\r//g; $c++; last if ($c > $in{'cpp'}); $_ =~ s/([^\w\s\:\-])/'&#'.ord($1).';'/ge; $_ =~ s/^(.*?): /$1: <\/b>/g; $_ =~ s/\n/
\n/g; $in{'comments'} .= $_."\n
\n"; } close CMT; undef $/; if($in{'comments'}){ $in{'comments'} = qq|

Comments


$in{'comments'}|; } else{ $in{'comments'} = qq|

No comments submitted

|; } $in{'cform'} = qq|
Add Comment

Name:
Comment:


|; } if($in{'t'} eq '1'){ $in{'viewbutton'} = qq||; } else{ $in{'viewbutton'} = qq||; } &PageOut("$cgipath/t_view.htm"); exit; } sub Approve{ my $sfile = &CheckSafe("$datapath/calendardata.cgi"); open(DB,"+<$sfile"); while(){ @f = split("~",$_); ($f[0] ne $in{'id'})?(push(@l,$_)):(push(@l,"$f[0]~$f[1]~$f[2]~$f[3]~$f[4]~$f[5]~1\n")); } seek(DB,0,0); foreach $i (@l){ print DB $i; } truncate(DB, tell(DB)); print <<"EOF"; EOF exit; } sub ShowEditEvent{ &GetConfig($in{'calid'}); my $sfile = &CheckSafe("$datapath/$in{'calid'}.cgi"); open(DB,"$sfile"); while(){ chomp; @f = split("\t",$_); if($f[0] eq $in{'id'}){ $in{'id'} = $f[0]; $in{'calid'} = $f[1]; $in{'cid'} = $f[2]; $in{'title'} = $f[3]; $in{'cv1'} = $f[4]; $in{'cv2'} = $f[5]; $in{'cv3'} = $f[6]; $in{'cv4'} = $f[7]; $in{'cv5'} = $f[8]; $in{'cv6'} = $f[9]; $in{'cv7'} = $f[10]; $in{'cv8'} = $f[11]; $in{'cv9'} = $f[12]; $in{'cv10'} = $f[13]; $in{'cv1'} =~ s/([^\w\s\n])/'&#'.ord($1).';'/ge; $in{'cv2'} =~ s/([^\w\s\n])/'&#'.ord($1).';'/ge; $in{'cv3'} =~ s/([^\w\s\n])/'&#'.ord($1).';'/ge; $in{'cv4'} =~ s/([^\w\s\n])/'&#'.ord($1).';'/ge; $in{'cv5'} =~ s/([^\w\s\n])/'&#'.ord($1).';'/ge; $in{'cv6'} =~ s/([^\w\s\n])/'&#'.ord($1).';'/ge; $in{'cv7'} =~ s/([^\w\s\n])/'&#'.ord($1).';'/ge; $in{'cv8'} =~ s/([^\w\s\n])/'&#'.ord($1).';'/ge; $in{'cv9'} =~ s/([^\w\s\n])/'&#'.ord($1).';'/ge; $in{'cv10'} =~ s/([^\w\s\n])/'&#'.ord($1).';'/ge; $in{'body'} = $f[14]; $in{'body'} =~ s/\\n/\n/g; $in{'showtimes'} = $f[15]; $in{'sthour'.$f[16]} = 'selected'; $in{'stmin'.$f[17]} = 'selected'; $in{'stsuf'.$f[18]} = 'selected'; $in{'ethour'.$f[19]} = 'selected'; $in{'etmin'.$f[20]} = 'selected'; $in{'etsuf'.$f[21]} = 'selected'; $in{'etype'.$f[22]} = 'checked'; $in{'sedate'} = $f[23]; $in{'sdate'} = $f[24]; $in{'edate'} = $f[25]; $in{'srdate'} = $f[26]; $in{'erdate'} = $f[27]; $in{'ed'.$f[28]} = 'checked'; $in{'oc'} = $f[29]; $in{'pattern'.$f[30]} = 'checked'; $in{'pdaily'} = $f[31]; $in{'pweekly'} = $f[32]; $in{'wd0'} = $f[33]; $in{'wd1'} = $f[34]; $in{'wd2'} = $f[35]; $in{'wd3'} = $f[36]; $in{'wd4'} = $f[37]; $in{'wd5'} = $f[38]; $in{'wd6'} = $f[39]; $in{'monthlytype'.$f[40]} = 'checked'; $in{'m1'} = $f[41]; $in{'m2'} = $f[42]; $in{'m3'.$f[43]} = 'selected'; $in{'m4'.$f[44]} = 'selected'; $in{'m5'} = $f[45]; $in{'yearlytype'.$f[46]} = 'checked'; $in{'y1'.$f[47]} = 'selected'; $in{'y2'} = $f[48]; $in{'y3'.$f[49]} = 'selected'; $in{'y4'.$f[50]} = 'selected'; $in{'y5'.$f[51]} = 'selected'; $in{'approve'} = $f[52]; $in{'approve'.$f[52]} = 'selected'; $in{'color'} = $f[53]; last; } } close DB; foreach my $i (1..10){ next if ($in{'c'.$i} lt '0'); $in{'cfields'} .= qq| $in{'c'.$i}: |; } $in{'command'} = 'sce'; my($comments) = ''; if($in{'acomments'}){ my($file) = &CheckSafe("$datapath/$in{'id'}-comments.cgi"); open(CMT,"<$file"); while(){ $comments .= $_; } close CMT; if($comments){ $comments =~ s/&#(\d+);/pack("c",$1)/ge; $comments =~ s/([^\w\s\n])/'&#'.ord($1).';'/ge; $comments = qq| Comments:
|; } } $in{'appr'} = qq|
Status:
$comments |; if($f[53]){ $in{'color'} = qq|\n|; } &PageOut("$cgipath/t_add_event.htm"); } sub SaveCalendar{ $in{'CalDesc'} =~ s/<\/(.*)>/$1/gi; $in{'CalName'} =~ s/<\/(.*)>/$1/gi; (length($in{'CalName'}) > 50)&&(&PError("Error. Calendar name has to be 50 characters or less")); if(!$in{'calid'}){ &SaveNewCalendar; } else{ my(@p); my($file) = &CheckSafe("$datapath/calendars.cgi"); open(DB,"+<$file"); ($flock)&&(flock(DB,2)); while(){ my(@f) = split("\t",$_); if($f[0] eq $in{'calid'}){ $in{'CalDesc'} =~ s/\r*\n/\\n/g;$in{'CalDesc'} =~ s/([^\w\s\n])/'&#'.ord($1).';'/ge; $f[3] = $in{'CalName'}; $f[4] = $in{'CalDesc'}; my($nv) = join("\t",@f); push(@p,$nv); } else{ push(@p,$_); } } seek(DB,0,0); foreach my $i (@p){ print DB $i; } truncate(DB, tell(DB)); ($flock)&&(flock(DB,8)); close DB; } &Redirect($in{'cgiurl'} . "?command=manage&cid=$in{'cid'}","Calendar Saved"); exit; } sub SaveNewCalendar{ my($id) = &GetID; my($file) = &CheckSafe("$datapath/calendars.cgi"); open(DB,">>$file"); ($flock)&&(flock(DB,2)); $in{'CalDesc'} =~ s/\r*\n/\\n/g;$in{'CalDesc'} =~ s/([^\w\s\n])/'&#'.ord($1).';'/ge; print DB "$id\t$in{'UserName'}\t$in{'cid'}\t$in{'CalName'}\t$in{'CalDesc'}\tEnglish\tHyphen\t\t\t\t\t\t\t\t10\t\t\t\t\t\t\t\t\t\t\t\t0\t1\t500\t600\t\t\t\t\t\t\t\t\t\t\n"; ($flock)&&(flock(DB,8)); close DB; $in{'calid'} = $id; } sub GetOutVars{ my ($approve,$id,$calid) = @_; #id calid cid title c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 body showtimes sthour stmin stsuf ethour etmid suf etype sedate sdate edate srdate erdate ed oc pattern pdaily pweekly wd0 wd1 wd2 wd3 wd4 wd5 wd5 monthlytype m1 m2 m3 m4 m5 yearlytype y1 y2 y3 y4 y5 approve color #0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 42 44 45 46 47 48 49 50 51 52 53 $newentry = "$id\t$calid\t$in{'cid'}\t$in{'title'}\t$in{'cv1'}\t$in{'cv2'}\t$in{'cv3'}\t$in{'cv4'}\t$in{'cv5'}\t$in{'cv6'}\t$in{'cv7'}\t$in{'cv8'}\t$in{'cv9'}\t$in{'cv10'}\t$in{'body'}\t$in{'showtimes'}\t$in{'sthour'}\t$in{'stmin'}\t$in{'stsuf'}\t$in{'ethour'}\t$in{'etmin'}\t$in{'etsuf'}\t$in{'etype'}\t$in{'sedate'}\t$in{'sdate'}\t$in{'edate'}\t$in{'srdate'}\t$in{'erdate'}\t$in{'ed'}\t$in{'oc'}\t$in{'pattern'}\t$in{'pdaily'}\t$in{'pweekly'}\t$in{'wd0'}\t$in{'wd1'}\t$in{'wd2'}\t$in{'wd3'}\t$in{'wd4'}\t$in{'wd5'}\t$in{'wd6'}\t$in{'monthlytype'}\t$in{'m1'}\t$in{'m2'}\t$in{'m3'}\t$in{'m4'}\t$in{'m5'}\t$in{'yearlytype'}\t$in{'y1'}\t$in{'y2'}\t$in{'y3'}\t$in{'y4'}\t$in{'y5'}\t$approve\t$in{'color'}"; } sub ViewCalendarSub{ (!$in{'viewby'})&&($in{'viewby'} = $vdefault); my($tm) = (localtime(time))[4]+1; my($ty) = (localtime(time))[5]+1900; if(($in{'mymonth'})&&(!$in{'mday'})&&(!$in{'e'})){ if($in{'mymonth'} == $tm){ $in{'mday'} = (localtime(time))[3]; } else{ $in{'mday'} = 1; } } if((!$in{'mymonth'})||($in{'e'})){ &GetDateInfo(time); } else{ ($in{'myyear'} != $ty)&&($in{'mday'}=1); &GetDateInfo(timelocal(0,0,0,$in{'mday'},$in{'mymonth'}-1,$in{'myyear'})); } (!$in{'myday'})&&($in{'myday'}='01'); (!$in{'mday'})&&($in{'mday'}=$in{'myday'}); &GetEvents; &CreateCalendar; $in{'mymonth'} = sprintf("%.2d",$in{'mymonth'}); $in{'m'.$in{'mymonth'}} = 'selected'; $in{'y'.$in{'myyear'}} = 'selected'; $in{'fulldate'} = &ctime(timelocal(0,0,0,$in{'mday'},$in{'mymonth'}-1,$in{'myyear'})); ($in{'viewby'} eq 'month')&&($msg = 'month'); ($in{'viewby'} eq 'day')&&($msg = 'day'); ($in{'viewby'} eq 'all')&&($msg = 'calendar'); ($in{'mode'} eq '0')&&($msg = 'queue'); (!$in{'eventline'})&&($in{'eventline'} = qq|No entries for this $msg.|); ($in{'viewby'} eq 'month')&&($in{'vmonth'} = 'selected'); ($in{'viewby'} eq 'day')&&($in{'vday'} = 'selected'); ($in{'viewby'} eq 'all')&&($in{'vall'} = 'selected'); } sub Manage{ my ($catId) = $in{'cid'}; my($selected,%calendars); my($file) = &CheckSafe("$datapath/categories.cgi"); open(DB,"<$file"); while(){ chomp; my($id,$uid,$catname) = split("\t",$_); ($module)&&($in{'atype'} ne 'admin')&&($uid ne $in{'UserName'})&&(next); (!$in{'cid'})&&($in{'cid'} = $id)&&($catId = $id); if ($id == $catId) { $selected = 'selected'; $in{"CatName"} = $catname; } else{ $selected = ''; } $in{'categories'} .= qq|\n|; } close DB; (!$in{'categories'})&&($in{'categories'} = ''); my($file) = &CheckSafe("$datapath/calendars.cgi"); open(DB,"<$file"); while(){ chomp; my($id,$uid,$cid,$calName,@rest) = split("\t",$_); ($module)&&($in{'atype'} ne 'admin')&&($uid ne $in{'UserName'})&&(next); $calendars{$calName.'-'.$id} = qq~   Modify  |  Delete  |  Configure  $calName ~ unless ($cid != $catId); } close DB; foreach my $i (sort keys %calendars){ $in{'calendars'} .= $calendars{$i}; } (!$in{'calendars'})&&($in{'calendars'} = qq|No calendars in this category|); if($in{'atype'} eq 'admin'){ require("$cgipath/t_cp.htm"); } &PageOut("$cgipath/t_manage.htm"); exit; } sub ShowAddCategory{ &PageOut("$cgipath/t_add_edit_category.htm"); exit; } sub AddCategory{ my($id) = &GetID; ($in{'catname'} =~ /([<>])/)&&(&PError("Error. $1 characters are not allowed in category name.")); (length($in{'catname'}) > 50)&&(&PError("Error. Category name has to be 50 characters or less")); my($file) = &CheckSafe("$datapath/categories.cgi"); open(DB,">>$file"); print DB "$id\t$in{'UserName'}\t$in{'catname'}\n"; close DB; print qq| |; exit; } sub GetID{ my($id); open(DB,"<$datapath/_gcount.cgi"); $id = ; close DB; $id++; open(DB,">$datapath/_gcount.cgi"); print DB $id; close DB; return $id; } sub DeleteCategory { my ($catId) = $in{'cid'} || &cgierr("fatal error: DeleteCategory - no id specified"); my(@c,@p); my($file) = &CheckSafe("$datapath/categories.cgi"); open(DB,"+<$file"); ($flock)&&(flock(DB,2)); while(){ my($id,$uid,$name) = split("\t",$_); push(@c,$_) unless ($id eq $catId); } seek(DB,0,0); foreach my $i (@c){ print DB $i; } truncate(DB, tell(DB)); ($flock)&&(flock(DB,8)); close DB; undef(@c); my($file) = &CheckSafe("$datapath/calendars.cgi"); open(DB,"+<$file"); ($flock)&&(flock(DB,2)); while(){ my($id,$uid,$cid,@rest) = split("\t",$_); ($cid eq $catId)?(&DeleteCalendar($id)):(push(@p,$_)); } seek(DB,0,0); foreach my $i (@p){ print DB $i; } truncate(DB, tell(DB)); ($flock)&&(flock(DB,8)); close DB; &Redirect($in{'cgiurl'} . "?command=manage","Category Deleted"); } sub DeleteCalendar{ my($calid) = @_; my($file) = &CheckSafe("$datapath/$calid.cgi"); unlink($file); } sub DeleteCal2 { my(@p,$d); my($file) = &CheckSafe("$datapath/calendars.cgi"); open(DB,"+<$file"); ($flock)&&(flock(DB,2)); while(){ my($id,$uid,$cid,@rest) = split("\t",$_); ($id ne $in{'calid'})&&(push(@p,$_)); } seek(DB,0,0); foreach my $i (@p){ print DB $i; } truncate(DB, tell(DB)); ($flock)&&(flock(DB,8)); close DB; my($file) = &CheckSafe("$datapath/$in{'calid'}.cgi"); unlink($file); &Redirect($in{'cgiurl'} . "?command=manage&cid=$in{'cid'}","Calendar Deleted"); } sub ManageView{ my($calid) = @_; &ViewCalendarSub; my $sfile = &CheckSafe("$datapath/$calid.cgi"); open(DB,"<$sfile"); while(){ chomp; @f = split("\t",$_); if($f[53]){ $f[3] = qq|$f[3]|; } #id calid cid title c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 body showtimes sthour stmin stsuf ethour etmid suf etype sedate sdate edate srdate erdate ed oc pattern pdaily pweekly wd0 wd1 wd2 wd3 wd4 wd5 wd5 monthlytype m1 m2 m3 m4 m5 yearlytype y1 y2 y3 y4 y5 approve #0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 42 44 45 46 47 48 49 50 51 52 if($f[22] eq 'single'){ $when = "$f[23]"; if($f[15] eq 'checked'){ $when .= " from $f[16]:$f[17] $f[18] to $f[19]:$f[20] $f[21]"; } } elsif($f[22] eq "multiple"){ $when = "$f[24] to $f[25]"; if($f[15] eq 'checked'){ $when .= " from $f[16]:$f[17] $f[18] to $f[19]:$f[20] $f[21]"; } } else{ $when = "starting on $f[26]"; if($f[28] == 2){ $when .= " ending after $f[29] occurences"; } if($f[28] == 3){ $when .= " ending on $f[27]"; } if($f[30] == 1){ $when .= " repeating every $f[31] day(s)"; } if($f[30] == 2){ undef(@d); ($f[33])&&(push(@d,"Sunday")); ($f[34])&&(push(@d,"Monday")); ($f[35])&&(push(@d,"Tuesday")); ($f[36])&&(push(@d,"Wednesday")); ($f[37])&&(push(@d,"Thursday")); ($f[38])&&(push(@d,"Friday")); ($f[39])&&(push(@d,"Saturday")); $dw = join(", ",@d); $when .= " repeating every $f[32] week(s) on $dw"; } if($f[30] == 3){ if($f[40] == 1){ $when = " repeating day $f[41] of every $f[42] month(s)"; } else{ $when = " repeating the $f[43] $f[44] of every $f[45] month(s)"; } } if($f[30] == 4){ if($f[46] == 1){ $when = " repeating every $f[47] $f[48]"; } else{ $when = " repeating the $f[49] $f[50] of $f[51]"; } } } if($f[52] == 1){ $in{'line'} .= qq| $when $f[3]   |; } else{ $in{'pline'} .= qq| $when $f[3]   |; } } close DB; (!$in{'pline'})&&($in{'pline'} = 'No events pending approval'); (!$in{'line'})&&($in{'line'} = 'No events entered'); return; } sub DoSingle{ my($line) = @_; if($in{'e'} eq '1'){ $in{'viewby'} = 'all'; } my($m,$d,$y) = $f[23] =~ /(\d*)[^\d](\d*)[^\d](\d*)/; $m = sprintf("%.2d",$m); $d = sprintf("%.2d",$d); $y = sprintf("%.4d",$y); $h{$d.$m.$y}=''; $c{$d.$m.$y}="bgcolor=\"$eventcolor\""; my($h) = $f[16]; if($f[18] eq 'AM'){ ($h == 12)&&($h=0); } else{ ($h < 12)&&($h+=12); } $h = sprintf("%.2d",$h); if($m == $in{'mymonth'}){ my ($when); if($f[15] eq 'checked'){ $when = "
$f[16]:$f[17] $f[18] - $f[19]:$f[20] $f[21]"; } if($f[14]){ if($in{'pd'} ne '1'){ $to{$d.$m.$y.$h.$f[17].$f[0]} .= "» $f[3]$when
"; } else{ $to{$d.$m.$y.$h.$f[17].$f[0]} .= "» $f[3]$when
"; } } else{ $to{$d.$m.$y.$h.$f[17].$f[0]} .= "$f[3]$when
"; } } if($in{'viewby'} eq 'month'){ if(($m == $in{'mymonth'})&&($y == $in{'myyear'})){ $order{"$y$m$d$h$f[17]$f[0]"} = $line; } } elsif($in{'viewby'} eq 'day'){ if(($d == $in{'mday'})&&($m == $in{'mymonth'})&&($y == $in{'myyear'})){ $order{"$y$m$d$h$f[17]$f[0]"} = $line; } } else{ $order{"$y$m$d$h$f[17]$f[0]"} = $line; } } sub DoMultiple{ my($line) = @_; my($m,$d,$y) = $f[24] =~ /(\d*)[^\d](\d*)[^\d](\d*)/; my($me,$de,$ye) = $f[25] =~ /(\d*)[^\d](\d*)[^\d](\d*)/; $m = sprintf("%.2d",$m); $d = sprintf("%.2d",$d); $y = sprintf("%.4d",$y); $me = sprintf("%.2d",$me); $de = sprintf("%.2d",$de); $ye = sprintf("%.4d",$ye); my($h) = $f[16]; if($f[18] eq 'AM'){ ($h == 12)&&($h=0); } else{ ($h < 12)&&($h+=12); } $h = sprintf("%.2d",$h); #get dates in between. my($st) = timelocal(0,0,0,$d,$m-1,$y); my($et) = timelocal(0,59,23,$de,$me-1,$ye); my($nd) = int(($et-$st)/86400); my($found)=0; for my $i (0..$nd){ my($mt) = $st + (86400*$i); my ($mday,$mon,$year) = (localtime($mt))[3,4,5]; $mon = sprintf("%.2d",$mon+1); $mday = sprintf("%.2d",$mday); $year = sprintf("%.4d",$year+1900); if(($mon == $in{'mymonth'})&&($year == $in{'myyear'})){ $c{$mday.$mon.$year}="bgcolor=\"$eventcolor\""; my($when,$timestart,$timeend); #if($f[15] eq 'checked'){ # $when = "
$f[16]:$f[17] $f[18] - $f[19]:$f[20] $f[21]"; #} if($f[15] eq 'checked'){ if(($f[16])&&($f[17])&&($f[18])){ my $mt = $m+0; $timestart= "$mt$in{'Separator'}$d$in{'Separator'}$y $f[16]:$f[17] $f[18]"; } if(($f[19])&&($f[20])&&($f[21])){ my $mt = $me+0; $timeend = "$mt$in{'Separator'}$de$in{'Separator'}$ye $f[19]:$f[20] $f[21]"; } $when = "
$timestart to $timeend"; } if($f[14]){ if($in{'pd'} ne '1'){ $to{$mday.$mon.$year.$h.$f[17].$f[0]} .= "» $f[3]$when
"; } else{ $to{$mday.$mon.$year.$h.$f[17].$f[0]} = "» $f[3]$when
"; } } else{ $to{$mday.$mon.$year.$h.$f[17].$f[0]} .= "$f[3]$when"; } $h{$mday.$mon.$year}=''; } if($in{'viewby'} eq 'month'){ if(($mon == $in{'mymonth'})&&($year == $in{'myyear'})){ $order{"$year$mon$mday$h$f[17]$f[0]"} = $line; $h{$mday.$mon.$year}=''; } } elsif($in{'viewby'} eq 'day'){ if(($mday == $in{'mday'})&&($mon == $in{'mymonth'})&&($year == $in{'myyear'})){ $order{"$year$mon$mday$h$f[17]$f[0]"} = $line; $h{$mday.$mon.$year}=''; } } else{ $order{"$year$mon$mday$h$f[17]$f[0]"} = $line; $h{$mday.$mon.$year}=''; } } } sub DoRecurring{ my($line) = @_; my($m,$d,$y) = $f[26] =~ /(\d*)[^\d](\d*)[^\d](\d*)/; my($me,$de,$ye,$ed); #need to set nc my($nc)=0; $m = sprintf("%.2d",$m); $d = sprintf("%.2d",$d); $y = sprintf("%.4d",$y); if($f[28] == 3){ ($me,$de,$ye) = $f[27] =~ /(\d*)[^\d](\d*)[^\d](\d*)/; $me = sprintf("%.2d",$me); $de = sprintf("%.2d",$de); $ye = sprintf("%.4d",$ye); if(timelocal(0,59,23,$de,$me-1,$ye) < timelocal(0,59,23,1,$in{'mymonth'}-1,$in{'myyear'})){ return; } } my($st) = timelocal(0,0,0,$d,$m-1,$y); if($f[28]==3){ ($ed) = timelocal(0,59,23,$de,$me-1,$ye); } else{ ($ed) = timelocal(0,59,23,1,$in{'mymonth'}-1,$in{'myyear'}) + (86400 * 31); } my($nd) = int(($ed - timelocal(0,59,23,$d,$m-1,$y))/86400); #daily if($f[30] == 1){ for(my $i = 0; $i <= $nd; $i+=$f[31]){ my($mt) = $st + (86400*$i); my ($mday,$mon,$year) = (localtime($mt))[3,4,5]; $mon = sprintf("%.2d",$mon+1); $mday = sprintf("%.2d",$mday); $year = sprintf("%.4d",$year+1900); $nc++; if(($f[29])&&($nc > $f[29])){ next; } &SetDay($mon,$mday,$year,$line); } } #weekly if($f[30] == 2){ #rewind to sunday my ($wd) = (localtime($st))[6]; my($rst) = $st; #$st = $st - ($wd * (86400 - (43200))); $st = $st - ($wd * 86400); $st = $st + 43200; (!$f[32])&&($f[32]=1); for(my $mt = $st; $mt <= $ed; $mt+=((7*86400)*$f[32])){ my ($mday,$mon,$year,$min,$hour) = (localtime($mt))[3,4,5,1,2]; $mon = sprintf("%.2d",$mon+1); $mday = sprintf("%.2d",$mday); $year = sprintf("%.4d",$year+1900); $min = sprintf("%.2d",$min); $hour = sprintf("%.2d",$hour); $nc++; if($f[33]){ my ($mday,$mon,$year) = (localtime($mt))[3,4,5]; $mon = sprintf("%.2d",$mon+1); $mday = sprintf("%.2d",$mday); $year = sprintf("%.4d",$year+1900); if(($f[29])&&($nc > $f[29])){ next; } if($mt >= $ed){ next; } if($mt >= $rst){ &SetDay($mon,$mday,$year,$line); } } if($f[34]){ my ($mday,$mon,$year) = (localtime($mt+(86400*1)))[3,4,5]; $mon = sprintf("%.2d",$mon+1); $mday = sprintf("%.2d",$mday); $year = sprintf("%.4d",$year+1900); if(($f[29])&&($nc > $f[29])){ next; } if(($mt+(86400*1)) >= $ed){ next; } if(($mt+(86400*1)) >= $rst){ &SetDay($mon,$mday,$year,$line); } } if($f[35]){ my ($mday,$mon,$year) = (localtime($mt+(86400*2)))[3,4,5]; $mon = sprintf("%.2d",$mon+1); $mday = sprintf("%.2d",$mday); $year = sprintf("%.4d",$year+1900); if(($f[29])&&($nc > $f[29])){ next; } if(($mt+(86400*2)) >= $ed){ next; } if(($mt+(86400*2)) >= $rst){ &SetDay($mon,$mday,$year,$line); } } if($f[36]){ my ($mday,$mon,$year) = (localtime($mt+(86400*3)))[3,4,5]; $mon = sprintf("%.2d",$mon+1); $mday = sprintf("%.2d",$mday); $year = sprintf("%.4d",$year+1900); if(($f[29])&&($nc > $f[29])){ next; } if(($mt+(86400*3)) >= $ed){ next; } if(($mt+(86400*3)) >= $rst){ &SetDay($mon,$mday,$year,$line); } } if($f[37]){ my ($mday,$mon,$year,$hour,$min,$sec) = (localtime($mt+(86400*4)))[3,4,5,2,1,0]; $mon = sprintf("%.2d",$mon+1); $mday = sprintf("%.2d",$mday); $year = sprintf("%.4d",$year+1900); if(($f[29])&&($nc > $f[29])){ next; } if(($mt+(86400*4)) >= $ed){ next; } if(($mt+(86400*4)) >= $rst){ &SetDay($mon,$mday,$year,$line); } } if($f[38]){ my ($mday,$mon,$year) = (localtime($mt+(86400*5)))[3,4,5]; $mon = sprintf("%.2d",$mon+1); $mday = sprintf("%.2d",$mday); $year = sprintf("%.4d",$year+1900); if(($f[29])&&($nc > $f[29])){ next; } if(($mt+(86400*5)) >= $ed){ next; } if(($mt+(86400*5)) >= $rst){ &SetDay($mon,$mday,$year,$line); } } if($f[39]){ my ($mday,$mon,$year) = (localtime($mt+(86400*6)))[3,4,5]; $mon = sprintf("%.2d",$mon+1); $mday = sprintf("%.2d",$mday); $year = sprintf("%.4d",$year+1900); if(($f[29])&&($nc > $f[29])){ next; } if(($mt+(86400*6)) >= $ed){ next; } if(($mt+(86400*6)) >= $rst){ &SetDay($mon,$mday,$year,$line); } } } } #monthly if($f[30] == 3){ my($z) = ($in{'myyear'} - $y)+1; my($mx) = $m; my($my) = $y; my($nm); if($f[40] == 1){ $nm = $f[42]; } else{ $nm = $f[45]; } (!$nm)&&($nm = 1); for(my $i=0;$i <= (12*$z); $i++){ if($mx > 12){ $mx = $mx - 12; $my++; } $nc++; if(($f[29])&&($nc > $f[29])){ next; } $mx = sprintf("%.2d",$mx); if($f[40] == 1){ $md = sprintf("%.2d",$f[41]); } else{ $md = &GetD($mx,$my,$f[43],$f[44]); } $my = sprintf("%.4d",$my); $md = sprintf("%.2d",$md); $mx = sprintf("%.2d",$mx); &SetDay($mx,$md,$my,$line); $mx += $nm; } } #yearly if($f[30] == 4){ if(($f[29])&&(($in{'myyear'} - $y) > $f[29])){ return; } my($wm); if($f[46] == 1){ ($f[47] eq 'January')&&($wm=1); ($f[47] eq 'February')&&($wm=2); ($f[47] eq 'March')&&($wm=3); ($f[47] eq 'April')&&($wm=4); ($f[47] eq 'May')&&($wm=5); ($f[47] eq 'June')&&($wm=6); ($f[47] eq 'July')&&($wm=7); ($f[47] eq 'August')&&($wm=8); ($f[47] eq 'September')&&($wm=9); ($f[47] eq 'October')&&($wm=10); ($f[47] eq 'November')&&($wm=11); ($f[47] eq 'December')&&($wm=12); $wd = $f[48]; } else{ ($f[51] eq 'January')&&($wm=1); ($f[51] eq 'February')&&($wm=2); ($f[51] eq 'March')&&($wm=3); ($f[51] eq 'April')&&($wm=4); ($f[51] eq 'May')&&($wm=5); ($f[51] eq 'June')&&($wm=6); ($f[51] eq 'July')&&($wm=7); ($f[51] eq 'August')&&($wm=8); ($f[51] eq 'September')&&($wm=9); ($f[51] eq 'October')&&($wm=10); ($f[51] eq 'November')&&($wm=11); ($f[51] eq 'December')&&($wm=12); $wd = &GetD($wm,$in{'myyear'},$f[49],$f[50]); } $in{'myyear'}= sprintf("%.4d",$in{'myyear'}); $wd = sprintf("%.2d",$wd); $wm = sprintf("%.2d",$wm); &SetDay($wm,$wd,$in{'myyear'},$line); } } sub GetD{ my($m,$y,$n,$d) = @_; my(@wd); my($sm) = timelocal(0,59,23,1,$m-1,$y); ($d eq 'Sunday')&&($dt = 0); ($d eq 'Monday')&&($dt = 1); ($d eq 'Tuesday')&&($dt = 2); ($d eq 'Wednesday')&&($dt = 3); ($d eq 'Thursday')&&($dt = 4); ($d eq 'Friday')&&($dt = 5); ($d eq 'Saturday')&&($dt = 6); ($n eq 'First')&&($dn = 0); ($n eq 'Second')&&($dn = 1); ($n eq 'Third')&&($dn = 2); ($n eq 'Fourth')&&($dn = 3); for my $z (0..31){ my(@a) = localtime($sm + (86400 * $z)); if($a[6] == $dt){ push(@wd,$a[3]); } } return($wd[$dn]); } sub SetDay{ my($mon,$mday,$year,$line) = @_; my($h) = $f[16]; if($f[18] eq 'AM'){ ($h == 12)&&($h=0); } else{ ($h < 12)&&($h+=12); } $h = sprintf("%.2d",$h); if(($mon == $in{'mymonth'})&&($year == $in{'myyear'})){ $c{$mday.$mon.$year}="bgcolor=\"$eventcolor\""; my($when); if($f[15] eq 'checked'){ if($f[19]){ $when = "
$f[16]:$f[17] $f[18] - $f[19]:$f[20] $f[21]"; } else{ $when = "
$f[16]:$f[17] $f[18]"; } } if($f[14]){ if($in{'pd'} ne '1'){ $to{$mday.$mon.$year.$h.$f[17].$f[0]} .= "» $f[3]$when
"; } else{ $to{$mday.$mon.$year.$h.$f[17].$f[0]} = "» $f[3]$when
"; } } else{ $to{$mday.$mon.$year.$h.$f[17].$f[0]} .= "$f[3]$when
"; } $h{$mday.$mon.$year}=''; } if($in{'viewby'} eq 'month'){ if(($mon == $in{'mymonth'})&&($year == $in{'myyear'})){ $order{"$year$mon$mday$h$f[17]$f[0]"} = $line; $h{$mday.$mon.$year}=''; } } elsif($in{'viewby'} eq 'day'){ if(($mday == $in{'mday'})&&($mon == $in{'mymonth'})&&($year == $in{'myyear'})){ $order{"$year$mon$mday$h$f[17]$f[0]"} = $line; $h{$mday.$mon.$year}=''; } } else{ if(($mon == $in{'mymonth'})&&($year == $in{'myyear'})){ $order{"$year$mon$mday$h$f[17]$f[0]"} = $line; $h{$mday.$mon.$year}=''; } } } sub GetEvents{ my ($type) = @_; my(@myrec); #highlight today $m[3] = sprintf("%.2d",$in{'mday'}); $m[4] = sprintf("%.2d",$in{'mymonth'}); $m[5] = sprintf("%.2d",$in{'myyear'}); $c{$m[3].$m[4].$m[5]}=qq|bgcolor="$todaycolor"|; my $sfile = &CheckSafe("$datapath/$in{'calid'}.cgi"); open(DB,"<$sfile"); while(){ chomp; @f = split("\t",$_); #id calid cid title c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 body showtimes sthour stmin stsuf ethour etmid suf etype sedate sdate edate srdate erdate ed oc pattern pdaily pweekly wd0 wd1 wd2 wd3 wd4 wd5 wd5 monthlytype m1 m2 m3 m4 m5 yearlytype y1 y2 y3 y4 y5 approve color #0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 42 44 45 46 47 48 49 50 51 52 53 ($f[52] != 1)&&(next); if($in{'filter'}){ $in{'filter'} =~ s/([\\\|\(\)\[\{\}\^\$\*\+\?\.])/\\$1/g; next if ($f[3] !~ /$in{'filter'}/); } #color event if($f[53]){ $f[3] = qq|$f[3]|; } if($f[22] eq 'single'){ &DoSingle($_); } elsif($f[22] eq 'multiple'){ &DoMultiple($_); } else{ &DoRecurring($_); } } close DB; #highlight today $m[3] = sprintf("%.2d",$in{'mday'}); $m[4] = sprintf("%.2d",$in{'mymonth'}); $m[5] = sprintf("%.2d",$in{'myyear'}); if($c{$m[3].$m[4].$m[5]} =~ /$eventcolor/){ $c{$m[3].$m[4].$m[5]}=qq|bgcolor="$eventtodaycolor"|; } else{ $c{$m[3].$m[4].$m[5]}=qq|bgcolor="$todaycolor"|; } foreach $i (sort keys %order){ @f = split("\t",$order{$i}); if($f[53]){ $f[3] = qq|$f[3]|; } ($in{'separator'} eq 'Slash')&&($separator = '/'); ($in{'separator'} eq 'Hyphen')&&($separator = '-'); ($in{'separator'} eq 'Period')&&($separator = '.'); my($y,$m,$d) = $i =~ /^(\d\d\d\d)(\d\d)(\d\d)/; if($in{'DateFormat'} eq 'English'){ $thisdate = "$m$in{'Separator'}$d$in{'Separator'}$y"; } else{ $thisdate = "$d$in{'Separator'}$m$in{'Separator'}$y"; } if($f[15] eq 'checked'){ if($f[19]){ $thisdate .= "
$f[16]:$f[17] $f[18] - $f[19]:$f[20] $f[21]"; } else{ $thisdate .= "
$f[16]:$f[17] $f[18]"; } } if(($f[22] eq 'multiple')){ if((!$set{$f[0]})&&($f[25])){ my($sm,$sd,$sy) = $f[24] =~ /(\d*)[^\d](\d*)[^\d](\d*)/; my($em,$ed,$ey) = $f[25] =~ /(\d*)[^\d](\d*)[^\d](\d*)/; if($f[15] eq 'checked'){ if(($f[16])&&($f[17])&&($f[18])){ $timestart= "$f[16]:$f[17] $f[18]"; } if(($f[19])&&($f[20])&&($f[21])){ $timeend = "$f[19]:$f[20] $f[21]"; } } $thisdate = "$sm$in{'Separator'}$sd$in{'Separator'}$sy $timestart
to
$em$in{'Separator'}$ed$in{'Separator'}$ey $timeend"; $set{$f[0]}=1; } else{ next; } } if($in{'command'} eq 'modify'){ if(($d == $in{'mday'})&&($m == $in{'mymonth'})&&($y == $in{'myyear'})){ $in{'dline'} .= qq| $thisdate $f[3] |; } } if($in{'e'} eq '1'){ my($ed) = timelocal(0,0,0,$d,$m-1,$y); (!$in{'l'})&&($in{'l'} = 1); my $future = time + (86400*$in{'l'}); if(($ed <= time)||($ed >= $future)){ next; } } my($link); if($f[14]){ if($in{'pd'} eq '1'){ $link = qq|javascript:View$in{'calid'}('$f[0]','$y','$m','$d');|; } else{ $link = qq|$in{'cgiurl'}?calid=$in{'calid'}&command=view&t=1&id=$f[0]&m=$m&d=$d&y=$y|; } } my(@ar,$ef); ($in{'cs1'})&&(push(@ar,"$f[4] ")); ($in{'cs2'})&&(push(@ar,"$f[5] ")); ($in{'cs3'})&&(push(@ar,"$f[6] ")); ($in{'cs4'})&&(push(@ar,"$f[7] ")); ($in{'cs5'})&&(push(@ar,"$f[8] ")); ($in{'cs6'})&&(push(@ar,"$f[9] ")); ($in{'cs7'})&&(push(@ar,"$f[10] ")); ($in{'cs8'})&&(push(@ar,"$f[11] ")); ($in{'cs9'})&&(push(@ar,"$f[12] ")); ($in{'cs10'})&&(push(@ar,"$f[13] ")); if(@ar){ $ef = join("\n",@ar); } my($et); if($f[14]){ $et = qq|$f[3]|; } else{ $et = $f[3]; } $in{'eventline'} .= qq~ $thisdate $et $ef $manageline ~; } my(@ar,$ef); ($in{'cs1'})&&(push(@ar,"$in{'c1'} ")); ($in{'cs2'})&&(push(@ar,"$in{'c2'} ")); ($in{'cs3'})&&(push(@ar,"$in{'c3'} ")); ($in{'cs4'})&&(push(@ar,"$in{'c4'} ")); ($in{'cs5'})&&(push(@ar,"$in{'c5'} ")); ($in{'cs6'})&&(push(@ar,"$in{'c6'} ")); ($in{'cs7'})&&(push(@ar,"$in{'c7'} ")); ($in{'cs8'})&&(push(@ar,"$in{'c8'} ")); ($in{'cs9'})&&(push(@ar,"$in{'c9'} ")); ($in{'cs10'})&&(push(@ar,"$in{'c10'} ")); $in{'cols'} = $#ar+3; if(@ar){ $in{'ef'} = join("\n",@ar); } #do large calendar foreach my $i (sort keys %to){ my($d,$m,$y) = $i =~ /^(..)(..)(....)/; if($t{$d.$m.$y}){ $t{$d.$m.$y} .= '
'.$to{$i}; } else{ $t{$d.$m.$y} .= $to{$i}; } } } sub CreateCalendar{ $in{'calendarsmall'} = qq| |; $in{'calendarlarge'} = qq|
$DoW[$fmday[0]] $DoW[$fmday[1]] $DoW[$fmday[2]] $DoW[$fmday[3]] $DoW[$fmday[4]] $DoW[$fmday[5]] $DoW[$fmday[6]]
|; my $day; my $cday; if($in{'command'} ne 'viewlarge'){ for $h (0..6){ $in{'calendarsmall'} .= qq|\n|; for $v (0..6){ $day++; $offday = $day - $fdayoffset; (($offday <= $dim)&&($offday > 0))?($cday = $offday):($cday = ''); ($offday > $dim)&&($te = 1); $today = sprintf("%.2d",$cday).sprintf("%.2d",$in{'mymonth'}).sprintf("%.4d",$in{'myyear'}); if($cday){ $in{'calendarsmall'} .= qq|\n|; } else{ $in{'calendarsmall'} .= qq|\n|; } } $in{'calendarsmall'} .= qq|\n|; ($te)&&(last); } $in{'calendarsmall'} .= qq|
$DoW[$fmday[0]] $DoW[$fmday[1]] $DoW[$fmday[2]] $DoW[$fmday[3]] $DoW[$fmday[4]] $DoW[$fmday[5]] $DoW[$fmday[6]]
$h{$today}$cday 
|; } else{ for $h (0..6){ $in{'calendarlarge'} .= qq|\n|; for $v (0..6){ $day++; $offday = $day - $fdayoffset; (($offday <= $dim)&&($offday > 0))?($cday = $offday):($cday = ''); ($offday > $dim)&&($te = 1); $today = sprintf("%.2d",$cday).sprintf("%.2d",$in{'mymonth'}).sprintf("%.4d",$in{'myyear'}); if($cday){ $in{'calendarlarge'} .= qq|$h{$today}$cday
$t{$today}\n|; } else{ $in{'calendarlarge'} .= qq| \n|; } } $in{'calendarlarge'} .= qq|\n|; ($te)&&(last); } $in{'calendarlarge'} .= qq||; } } sub GetDateInfo{ my ($time) = @_; &ctime($time); $bom = timelocal(0,0,0,1,$in{'mymonth'}-1,$in{'myyear'}); @info = localtime($bom); $fdayoffset = $info[6]-$in{'wstart'}; if($fdayoffset < 0){ $fdayoffset += 7; } for $i ((0+$in{'wstart'})..(6+$in{'wstart'})){ $didx = $fday + $i; ($didx > 6)&&($didx = $didx - 7); $fmday[$i-$in{'wstart'}] = $didx; } for $i (0..32){ @info = localtime($bom + (86400 * $i)); if($info[4] != ($in{'mymonth'}-1)){ last; } $dim = $info[3]; } } sub PageOutJS{ local($file) = @_; my $sfile = &CheckSafe("$file"); open(OUT,"$sfile")||print "$!: $file
"; while(){ $o = $_; $o =~ s/in\((\w+)\)/$in{$1}/g; $o =~ s/\"/\\"/g; $o =~ s/\\n/\\\\n/g; $o =~ s/(scr)(ipt)/$1\"\+\"$2/gsi; @mylines = split(/\r*\n/,$o); foreach $q (@mylines){ print qq|document.write("$q\\n");\n|; } } close OUT; } sub GetLogin{ &GetCookies; $in{'UserName'} = $cookie{'UserName'}; $in{'PassWord'} = $cookie{'PassWord'}; # if no password, then output the login screen if(!$in{'UserName'}){ (!$in{'command'})&&($in{'command'} = 'manage'); &PageOut("$cgipath/t_login.htm"); exit; } if(($^O =~ /win/i)){ if(($in{'UserName'} eq $username)&&($in{'PassWord'} eq $password)){ #good to go. $in{'atype'} = 'admin'; return 1; } } else{ if(($in{'UserName'} eq $username)&&(crypt($in{'PassWord'},'CS') eq $password)){ #good to go. $in{'atype'} = 'admin'; return 1; } } # password failed &PError("Error. Invalid username or password"); } sub Login{ $in{'command'} = 'manage'; &PageOut("$cgipath/t_login.htm"); exit; } sub SaveSetup{ (-e "$basepath/setup.cgi")&&(&PError("Error. Access Denied")); ($ENV{'REQUEST_METHOD'} !~ /post/i)&&(&PError("Error. Access Denied")); (!$in{'cgipath'})&&(&PError("Error. Please enter a cgipath variable")); (!$in{'cgiurl'})&&(&PError("Error. Please enter a cgiurl variable")); (!$in{'datapath'})&&(&PError("Error. Please enter a datapath variable")); (!$in{'imageurl'})&&(&PError("Error. Please enter an imageurl variable")); (!$in{'sendmail'})&&(&PError("Error. Please enter the path to sendmail")); (!$in{'username'})&&(&PError("Error. Please enter a username")); (!$in{'username'})&&(&PError("Error. Please enter a username")); (!$in{'password'})&&(&PError("Error. Please enter a password")); my $sfile = &CheckSafe("$basepath/setup.cgi"); if($^O !~ /win/i){ $in{'password'} = crypt($in{'password'},'CS'); } open(SETUP,">$sfile"); print SETUP <<"EOF"; \$cgipath = '$in{'cgipath'}'; \$cgiurl = '$in{'cgiurl'}'; \$datapath = '$in{'datapath'}'; \$imageurl = '$in{'imageurl'}'; \$sendmail = '$in{'sendmail'}'; \$memail = '$in{'memail'}'; \$username = '$in{'username'}'; \$password = '$in{'password'}'; 1; EOF close SETUP; print <<"EOF"; EOF exit; } sub Setup{ use Cwd; $in{'cgipath'} = Cwd::cwd(); $in{'cgiurl'} = "$ENV{'HTTP_HOST'}/$ENV{'SCRIPT_NAME'}"; $in{'cgiurl'} =~ s/\/\//\//g; $in{'cgiurl'} = "http://".$in{'cgiurl'}; $in{'cgiurl'} =~ s/\/csCalendar\.cgi//i; $in{'datapath'} = $in{'cgipath'}.'/data'; $in{'imageurl'} = $in{'cgiurl'}.'/images'; $in{'sendmail'} = '/usr/sbin/sendmail'; $in{'memail'} = 'you@yourdomain.com'; $in{'username'} = 'demo'; $in{'password'} = 'demo'; $in{'scriptname'} = $scriptname; &PageOut("$basepath/t_setup.htm"); exit; } sub CheckSafe{ my ($file) = @_; ($file =~ /\.\./)&&(&PError("Error. Invalid filename")); ($file =~ /\|/)&&(&PError("Error. Invalid filename")); return $file; } sub PageOut{ my ($file) = @_; if($in{'js'} == 1){ &PageOutJS($file); } open(OUT,"$file")||print "$!: $file
"; while(){ $_ =~ s/in\((\w+)\)/$in{$1}/g; print; } close OUT; } sub DataOutJS{ my($data) = @_; $data =~ s/\r//g; $data =~ s/\"/\\"/g; $data =~ s/\\n/\\\\n/g; $data =~ s/(scr)(ipt)/$1\"\+\"$2/gsi; my @mylines = split(/\r*\n/,$data); foreach my $q (@mylines){ print qq|document.write("$q\\n");\n|; } exit; } sub PageOutJS{ my($file) = @_; open(OUT,"$file")||print "$!: $file
"; while(){ my $o = $_; $o =~ s/\r//g; $o =~ s/in\((\w+)\)/$in{$1}/g; $o =~ s/\"/\\"/g; $o =~ s/\\n/\\\\n/g; $o =~ s/(scr)(ipt)/$1\"\+\"$2/gsi; my @mylines = split(/\r*\n/,$o); foreach my $q (@mylines){ print qq|document.write("$q\\n");\n|; } } close OUT; exit; } sub CheckVars{ ##check for long lines $in{'title'} =~ s/(\S{80,81})/$1 /g; $in{'body'} =~ s/(\S{100,101})/$1 /g; $in{'cv1'} =~ s/(\S{80,81})/$1 /g; $in{'cv2'} =~ s/(\S{80,81})/$1 /g; $in{'cv3'} =~ s/(\S{80,81})/$1 /g; $in{'cv4'} =~ s/(\S{80,81})/$1 /g; $in{'cv5'} =~ s/(\S{80,81})/$1 /g; $in{'cv6'} =~ s/(\S{80,81})/$1 /g; $in{'cv7'} =~ s/(\S{80,81})/$1 /g; $in{'cv8'} =~ s/(\S{80,81})/$1 /g; $in{'cv9'} =~ s/(\S{80,81})/$1 /g; $in{'cv10'} =~ s/(\S{80,81})/$1 /g; ##dhtml if($in{'command'} eq 'submitforapproval'){ $in{'title'} =~ s/\<.*?\>//gs; $in{'body'} =~ s/\<.*?\>//gs; $in{'cv1'} =~ s/\<.*?\>//gs; $in{'cv2'} =~ s/\<.*?\>//gs; $in{'cv3'} =~ s/\<.*?\>//gs; $in{'cv4'} =~ s/\<.*?\>//gs; $in{'cv5'} =~ s/\<.*?\>//gs; $in{'cv6'} =~ s/\<.*?\>//gs; $in{'cv7'} =~ s/\<.*?\>//gs; $in{'cv8'} =~ s/\<.*?\>//gs; $in{'cv9'} =~ s/\<.*?\>//gs; $in{'cv10'} =~ s/\<.*?\>//gs; ($in{'requireapproval'})&&(!$in{'email'})&&(&PError("Please enter your email address")); } $in{'title'} =~ s/&#(\d+);/pack("c",$1)/ge; $in{'body'} =~ s/&#(\d+);/pack("c",$1)/ge; $in{'cv1'} =~ s/&#(\d+);/pack("c",$1)/ge; $in{'cv2'} =~ s/&#(\d+);/pack("c",$1)/ge; $in{'cv3'} =~ s/&#(\d+);/pack("c",$1)/ge; $in{'cv4'} =~ s/&#(\d+);/pack("c",$1)/ge; $in{'cv5'} =~ s/&#(\d+);/pack("c",$1)/ge; $in{'cv6'} =~ s/&#(\d+);/pack("c",$1)/ge; $in{'cv7'} =~ s/&#(\d+);/pack("c",$1)/ge; $in{'cv8'} =~ s/&#(\d+);/pack("c",$1)/ge; $in{'cv9'} =~ s/&#(\d+);/pack("c",$1)/ge; $in{'cv10'} =~ s/&#(\d+);/pack("c",$1)/ge; $in{'title'} =~ s/([^\w\s\n])/'&#'.ord($1).';'/ge; $in{'body'} =~ s/([^\w\s\n])/'&#'.ord($1).';'/ge; $in{'body'} =~ s/\r*\n/\\n/g; $in{'c1'} =~ s/([^\w\s\n])/'&#'.ord($1).';'/ge; $in{'c2'} =~ s/([^\w\s\n])/'&#'.ord($1).';'/ge; $in{'c3'} =~ s/([^\w\s\n])/'&#'.ord($1).';'/ge; $in{'c4'} =~ s/([^\w\s\n])/'&#'.ord($1).';'/ge; $in{'c5'} =~ s/([^\w\s\n])/'&#'.ord($1).';'/ge; $in{'c6'} =~ s/([^\w\s\n])/'&#'.ord($1).';'/ge; $in{'c7'} =~ s/([^\w\s\n])/'&#'.ord($1).';'/ge; $in{'c8'} =~ s/([^\w\s\n])/'&#'.ord($1).';'/ge; $in{'c9'} =~ s/([^\w\s\n])/'&#'.ord($1).';'/ge; $in{'c10'} =~ s/([^\w\s\n])/'&#'.ord($1).';'/ge; (!$in{'title'})&&(&PError("Error. Please enter a title")); if($in{'showtimes'}){ (!$in{'sthour'})&&(!$in{'stmin'})&&(!$in{'stsuf'})&&(&PError("Please enter a start time")); (!$in{'ethour'})&&(!$in{'etmin'})&&(!$in{'etsuf'})&&(&PError("Please enter an end time")); } if($in{'etype'} eq 'single'){ (!$in{'sedate'})&&(&PError("Please enter a date for this event")); ($in{'sedate'} !~ /[\d]{1,2}\-[\d]{1,2}\-[\d]{4}/)&&(&PError("Invalid event date format. Must be MM-DD-YYYY")); } if($in{'etype'} eq 'multiple'){ (!$in{'sdate'})&&(&PError("Please enter a start date for this event")); ($in{'sdate'} !~ /[\d]{1,2}\-[\d]{1,2}\-[\d]{4}/)&&(&PError("Invalid start date format. Must be MM-DD-YYYY")); (!$in{'edate'})&&(&PError("Please enter an end date for this event")); ($in{'edate'} !~ /[\d]{1,2}\-[\d]{1,2}\-[\d]{4}/)&&(&PError("Invalid end date format. Must be MM-DD-YYYY")); } if($in{'etype'} eq 'recurring'){ (!$in{'srdate'})&&(&PError("Please enter a start date")); if($in{'ed'} eq '1'){ $in{'oc'} = ''; $in{'erdate'} = ''; } if($in{'ed'} eq '2'){ (!$in{'oc'})&&(&PError("Please enter the number of occurrences for this event")); $in{'erdate'} = ''; } if($in{'ed'} eq '3'){ (!$in{'erdate'})&&(&PError("Please an end date for this event")); ($in{'erdate'} !~ /[\d]{1,2}\-[\d]{1,2}\-[\d]{4}/)&&(&PError("Invalid end date format. Must be MM-DD-YYYY")); $in{'oc'} = ''; } if($in{'pattern'} eq '1'){ (!$in{'pdaily'})&&(&PError("Please enter the number of days for this event")); } if($in{'pattern'} eq '2'){ (!$in{'pweekly'})&&(&PError("Please enter the number of weeks for this event")); (!$in{'wd0'})&&(!$in{'wd1'})&&(!$in{'wd2'})&&(!$in{'wd3'})&&(!$in{'wd4'})&&(!$in{'wd5'})&&(!$in{'wd6'})&&(&PError("Please select at least one weekday for this event")); } if(($in{'pattern'} eq '3')&&($in{'monthlytype'} eq '1')){ (!$in{'m1'})&&(&PError("Please the day for this event")); (!$in{'m2'})&&(&PError("Please the number of months for this event")); } if(($in{'pattern'} eq '3')&&($in{'monthlytype'} eq '2')){ (!$in{'m3'})&&(&PError("Please select the day for this event")); (!$in{'m4'})&&(&PError("Please select the day for this event")); (!$in{'m5'})&&(&PError("Please select the number of months for this event")); } if(($in{'pattern'} eq '4')&&($in{'yearlytype'} eq '1')){ (!$in{'y1'})&&(&PError("Please the month for this event")); (!$in{'y2'})&&(&PError("Please the year for this event")); } if(($in{'pattern'} eq '4')&&($in{'yearlytype'} eq '2')){ (!$in{'y3'})&&(&PError("Please the day for this event")); (!$in{'y4'})&&(&PError("Please the month for this event")); (!$in{'y5'})&&(&PError("Please the year for this event")); } } ($in{'color'})&&($in{'color'} =~ /[^#0-9A-Za-z]/)&&(&PError("Error. Invalid color specification")); return; }
www.CrestonValley.com

Virtual Designs
Copyright © 98-03