#!/usr/bin/perl # before anything else, the script needs to find out its own name # # some servers (notably IIS on windows) don't set the cwd to the script's # directory before executing it. So we get that information # from $0 (the full name & path of the script). BEGIN{($_=$0)=~s![\\/][^\\/]+$!!;push@INC,$_} $name = $0; $name =~ s/.+\/.+\///; # for unix $name =~ s/.+\\.+\\//; # for windows $path = $0; $path =~ s/(.+\/).+/$1/g; # for unix $path =~ s/(.+\\).+/$1/g; # for windows if ($path ne "") { chdir $path; push @INC,$path; } # finished discovering name local $template_html; local $event_details_template; local $list_item_template; local $calendar_item_template; local $upcoming_item_template; my $config_file = "upcoming_events.config"; my $plans_url = ""; # check for required modules. require "includes.pl"; $module_found=0; foreach $temp_path (@INC) { if (-e "$temp_path/JSON") { $module_found=1;} } if ($module_found == 0) { $fatal_error=1; $error_info .= "unable to locate required module JSON!\n"; } else { require "JSON/PP58.pm"; use JSON::PP; } if ($fatal_error == 1) { # print error and bail out &fatal_error(); } use Data::Dumper; # time-related globals $rightnow = time() + 3600 * $current_calendar{gmtime_diff}; @rightnow_array = gmtime $rightnow; $rightnow_year = $rightnow_array[5]+1900; $rightnow_month = $rightnow_array[4]; $rightnow_mday = $rightnow_array[3]; $next_year = $rightnow_year+1; $rightnow_description = formatted_time($rightnow, "hh:mm:ss mn md yy"); @weekday_sequence = @day_names; my $output_file= $options{'upcoming_events'}{'output_filename'}; my @filestats = stat "$output_file"; my $last_modified_timestamp = $filestats[9]; if ( $last_modified_timestamp > $rightnow - $options{'upcoming_events'}{'cache_seconds'} ) { open (FH, $options{'upcoming_events'}{'output_filename'}) || {$debug_info.= "unable to open file $options{'upcoming_events'}{'output_filename'}\n"}; my $contents = join("",); close FH; print < $b} @calendars_to_show) { $event_lists{$cal_id} = &generate_upcoming_events($cal_id); } $list_html .=<
p1 $list_html .=< p1 foreach $cal_id (@calendars_to_show) { $list_html .=<$calendars{$cal_id}{title} p1 } $list_html .=<
p1 foreach $cal_id ( keys %event_lists ) { $list_html .=<