#!/usr/bin/perl BEGIN { require "/var/www/vhosts/nmoca.org/support/LIB/globals.pl"; } # Prefer our local copies to anything else available use lib $LOC_LIB; use Text::Template; use Utility qw(:CONST); use CGI; use CalEvent; use CalList; use SerialNum; use Error; BEGIN { use CGI::Carp qw(fatalsToBrowser); } #Query handles decoding the FORM data $query = new CGI; # Get the function $fn = $query->param('fn'); &initvars(); # Get the params if we're being called with a filled-in form @params = $query->param(); foreach $item (@params) { $values{$item} = $query->param($item); } # Calevent holds the data for a single item $calevent = new CalEvent; if ($fn eq "home") { $filename = "home.html"; $callist = new CalList; $callist->load_list(); $eventref = $callist->get_calevents(); } else { $filename = "calendar.html"; $callist = new CalList; $callist->load_list(); $eventref = $callist->get_calevents(); } # Template processes the HTML code, filling in blanks $template = new Text::Template (TYPE => FILE, SOURCE => "$LOC_TEMPLATES/$filename" ); if ($fn ne "new") { print $query->header(-expires => '-1d'); } else { print $query->header(); } print emulate_server_includes($template->fill_in(HASH => [ \%editvars, \%globals, \%values, {'itemnum' => $itemnum, 'fn' => $fn, 'assoc' => $values{'assoc'}, 'itemref' => \$calevent, }, $calevent->{CALENDAR_FIELDS}, {events => \$eventref}] )); sub emulate_server_includes { my $text = shift; my $filename; my $includetext; while ($text =~ m//) { #/ $filename = $1; $filename =~ s%^%/var/www/vhosts/nmoca.org/htdocs/%; open(INCFILE,"<$filename") || die ("Can't open $filename as SSI"); $includetext = join("",); close(INCFILE); $text =~ s//$includetext/; #/ } return $text; } sub dump_query { print $query->header(); print $query->dump(); exit; } sub readarray { my($filename) = shift; my(@array); open(CATLIST,$filename) || die("Can't open $filename"); @array=; close(CATLIST); chop(@array); return(@array); } sub initvars { @assoc=&readarray("$LOC_DATADICT/associations.txt"); foreach $item (@assoc) { ($assocname,$assoclink,$assoctarget) = split(/:/,$item,3); push(@associations,$assocname); $assoclinks{$assocname}=$assoclink; $assoctargets{$assocname}=$assoctarget; } %editvars = ( 'associations' => \@associations, 'assoclinks' => \%assoclinks, 'assoctargets' => \%assoctargets ); }