#!/usr/local/perl/bin/perl use CGI::Carp qw(fatalsToBrowser); # #--------------------------------------------------------------------------- # uReserve Gold Online Schedule Manager # Copyright (c) 2000 - 2006, Microburst Technologies, Inc. # All rights reserved. # # ureserve.pl $version = "4.17"; # Gold # # See the uReserve Gold User's Guide for installation and instructions for use. # # Also, visit our website at http://www.uburst.com # #--------------------------------------------------------------------------- #--------------------------------------------------------------------------- # Start Of Configuration Questions #--------------------------------------------------------------------------- # 1. What is the path to Perl? # This value is specified on the very first line of this file. # 2. What is your uReserve Gold License Number? $license_number = "URG89165313"; # 3. What is your company's/organization's name? $company_name = "University Of Colorado"; # 4. What is your website URL? $website = "http://euclid.colorado.edu"; # 5. What is the URL of this script on your website? $script_url = "http://euclid.colorado.edu/ureserve/ureserve_gold.cgi"; # 6. What is the full or relative path to your data directory? # ***** NOTE: Create 4 subdirectories under this data directory ***** # ***** with the following names: ***** # ***** 10min ***** # ***** 15min ***** # ***** 30min ***** # ***** 60min ***** # ***** ...and give each directory read/write permissions ***** $data_directory = "./data_gold/"; # 7. What is the name of the settings files? $settings_file = $data_directory . "ureserve-settings.txt"; # DO NOT MODIFY $reservation_fields_file = $data_directory . "reservation-fields.txt"; # DO NOT MODIFY # 8. What would you like to be the start time of your reservation schedule? $gtime_range_start = "8"; # 0 - 23 # 9. What would you like to be the end time of your reservation schedule? $gtime_range_stop = "18"; # 1 - 24 (must be greater than start time) # 10. What image would you like at the top of your schedule pages? $gpage_image = "NONE"; # Must be the full URL of the image or set to "NONE". # 11. What is the administrator's password? $gen_admin_login_password = "admin"; # 12. What is the name of the uReserve language file? require "languages-gold.pl"; # DO NOT MODIFY # 13. What columns would you like to have? @column_names = ('Period 1','Period 2','Period 3','Period 4','Period 5','Period 6','Period 7','End of Day'); # 14. What is the full or relative path to your default image directory? $default_image_dir = "/usr/local/apache/htdocs/ureserve/images/"; # 15. What is the URL of your default image directory (to the directory specified above in #14)? $default_image_dir_url = "http://euclid.colorado.edu/ureserve/images/"; #--------------------------------------------------------------------------- # End Of Configuration Questions #--------------------------------------------------------------------------- # Do not modify below this line. # Global variables. $gdebugmode = 0; $gtime_range_stop = &strip_letters($gtime_range_stop); $gresource_file_old = $data_directory . "resource-data.txt"; $gresource_file = $data_directory . "resources.txt"; $gresource_file_reorder = $data_directory . "reorder-r.txt"; $gresource_file_categorize = $data_directory . "resourcecat-copy.txt"; $gcategory_file = $data_directory . "categories.txt"; $gcategory_file_reorder = $data_directory . "reorder-c.txt"; $gauthorized_users_file = $data_directory . "ureserve-users.txt"; $gauthorized_users_temp_file = $data_directory . "ureserve-users.tmp"; $gblocked_users_file = $data_directory . "blocked.txt"; $gblocked_users_temp_file = $data_directory . "blocked.tmp"; $gblackout_dates_file = $data_directory . "blackout-dates.txt"; $gblackout_dates_temp_file = $data_directory . "blackout-dates.tmp"; $gadmin_log_file = $data_directory . "admin-log.txt"; $greservation_log_file = $data_directory . "reservation-log.txt"; $gupgrade_log_file = $data_directory . "upgrade-log.txt"; $greminder_log_file = $data_directory . "reminder-log.txt"; $ghelp_file = $data_directory . "help-gold.txt"; $gcolor_file = $data_directory . "colors.txt"; $gfont_file = $data_directory . "fonts.txt"; # 4.09 change from extract.xls to extract.txt $gextract_file = "extract.txt"; $gdownload_extract_log_file = $data_directory . "extract-download.log"; # v4.11 add debugging $gdebug_log_file = $data_directory . "debug-log.txt"; @sun_days = ('','Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'); @mon_days = ('','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'); @sun_days_short = ('','Sun','Mon','Tue','Wed','Thu','Fri','Sat'); @mon_days_short = ('','Mon','Tue','Wed','Thu','Fri','Sat','Sun'); @month_names = ('','January','February','March','April','May','June','July','August','September','October','November','December'); $SECONDS_PER_DAY = 86400; $MINUTES_PER_DAY = 1440; $SECONDS_PER_YEAR = 31557600; $SECONDS_2K = 946728000; $SECONDS_2100 = 4102488000; $g_seconds = $SECONDS_2K; $g_wday = 0; $g_mon = 0; $g_year = ""; $gMax_upload_size = 1024 * 100; # 100 K $ADMIN = $gadmin_log_file; $RESV = $greservation_log_file; $UPGRADE = $gupgrade_log_file; $REMIND = $greminder_log_file; # v4.11 add debug $DEBUG = $gdebug_log_file; $GEN_USER = 1; # can only make/edit/delete their own reservation $REPORTS_ADMIN = 2; #(LESS THAN 2) - can do #1 plus can run reports $RESOURCE_ADMIN = 3; #(LESS PRIV) - can do #1, #2, plus can manage pending reservations, some auth users, and override reservations $SYSTEM_ADMIN = 4; # (ALL PRIV) - can access all functions $ANY_RESERVE_ANY_RECURRING = 1; # 1 = Anyone can make reservations and recurring events. $ANY_RESERVE_AUTH_RECURRING = 2; # 2 = Anyone can make reservations but only authorized users can make recurring events. $AUTH_RESERVE_AUTH_RECURRING = 3; # 3 = Only authorized users can make reservations/recurring events. $ANY_RESERVE_NO_RECURRING = 4; # 4 = Anyone can make reservations but no one can make recurring events. $AUTH_RESERVE_NO_RECURRING = 5; # 5 = Only authorized users can make reservations and no one can make recurring events. $REPORT_TYPE_RESOURCE = "Resource"; $REPORT_TYPE_PERIOD = "Period"; $REPORT_TYPE_USAGE = "Usage"; $REPORT_PERIOD_DAILY = "Daily"; $REPORT_PERIOD_RANGE = "Range"; $REPORT_PERIOD_MONTHLY = "Monthly"; #use Socket; # <-- #$AF_INET = AF_INET; # Use these 3 lines for UNIX servers. #$SOCK_STREAM = SOCK_STREAM; # <-- $AF_INET = 2; # Use these 2 settings for NT servers. $SOCK_STREAM = 1; # <-- if ($gtime_range_stop == 0) { $gtime_range_stop = $#column_names; } $settings_already_read = 0; $settings_size = 4; @settings = ($settings_size); # v4.0 $reservation_fields_already_read = 0; @fields = (); #END# &parse_form_data(*form_text); if ($ENV{'CONTENT_TYPE'} =~ /^multipart\/form-data/) { &new_parse_form_data(*form_text); } $pCommand = $form_text{'command'}; $username = $form_text{'username'}; $password = $form_text{'password'}; $pFile = $form_text{'file'}; $pConfirm = $form_text{'confirm'}; $pView = $form_text{'schedule_view'}; $pSeconds = $form_text{'seconds'}; $pShowWeek = $form_text{'show_week'}; &default_settings(); &initialize_settings(); &default_reservation_fields(); &initialize_reservation_fields(); if ($pShowWeek =~ /\S/) { $pSeconds = &get_date_seconds($pShowWeek); } if ($pCommand eq "login") { &create_admin_control_panel("NONE"); } elsif ($pCommand eq "cp_general_settings") { &create_general_settings_form("NONE"); } elsif ($pCommand eq "gs_display_preferences") { &create_display_preferences_form(); } elsif ($pCommand eq "save_display_preferences") { &save_display_preferences(); } elsif ($pCommand eq "gs_report_preferences") { &create_report_preferences_form(); } elsif ($pCommand eq "save_report_preferences") { &save_report_preferences(); } elsif ($pCommand eq "gs_email_settings") { &create_email_settings_form(); } elsif ($pCommand eq "save_email_settings") { &save_email_settings(); } elsif ($pCommand eq "gs_colors_fonts_settings") { &create_colors_fonts_settings_form("NONE"); } elsif ($pCommand eq "save_colors_fonts_settings") { &save_colors_fonts_settings(); } elsif ($pCommand eq "save_resource_fields_settings") { &save_resource_fields_settings(); } elsif ($pCommand eq "gs_reservation_fields_settings") { &create_reservation_field_config_form("NONE"); } elsif ($pCommand eq "save_reservation_fields_settings") { &save_reservation_fields_settings(); } elsif ($pCommand eq $lang_back) { &create_admin_control_panel(); } elsif ($pCommand eq "show_color_chart") { &display_color_chart(); } elsif ($pCommand eq "show_font_chart") { &display_font_chart(); } elsif ($pCommand eq "help") { $view_topic = $form_text{'topic'}; &display_help($view_topic); } elsif ($pCommand eq "cp_manage_categories") { &create_manage_categories_form(); } elsif ($pCommand eq "mc_add_category") { &create_add_edit_category_form("ADD"); } elsif ($pCommand eq "add_category") { &add_new_category(); } elsif ($pCommand eq "mc_edit_category") { &create_category_selection_form("edit_category_form"); } elsif ($pCommand eq "edit_category_form") { &create_add_edit_category_form("EDIT"); } elsif ($pCommand eq "edit_category") { &edit_category(); } elsif ($pCommand eq "mc_delete_category") { &create_category_selection_form("delete_category_confirmation"); } elsif ($pCommand eq "delete_category_confirmation") { &create_delete_category_confirmation_form(); } elsif ($pCommand eq "delete_category") { $category_key = $form_text{'category_key'}; $category_name = &get_category_name($category_key); if ($pConfirm eq $lang_yes) { if (&delete_category($category_key) == 1) { &log_info($ADMIN,"$category_name was DELETED by $username."); &create_manage_categories_form("$category_name was deleted."); } else { &create_manage_categories_form("Error: $category_name was NOT deleted."); } } else { &create_manage_categories_form("$category_name was NOT deleted."); } } elsif ($pCommand eq "mc_copy_category") { &create_category_selection_form("copy_category_form"); } elsif ($pCommand eq "copy_category_form") { &create_add_edit_category_form("COPY"); } elsif ($pCommand eq "copy_category") { ©_category(); } elsif ($pCommand eq "mc_reorder_categories") { &create_reorder_categories_form("NONE"); } elsif ($pCommand eq "mc_exit_reorder_categories") { unlink($gcategory_file_reorder); &create_manage_categories_form(); } elsif ($pCommand eq "mc_categorize_resources") { if (!(-e $gcategory_file)) { &create_categorize_resources_form("There are no categories to assign resources to. Select BACK and then add at least one category."); } else { &create_categorize_resources_form("NONE"); } } elsif ($pCommand eq "mc_exit_categorize") { unlink($gresource_file_categorize); &create_manage_categories_form(); } elsif ($pCommand eq "cp_manage_resources") { &create_manage_resources_form(); } elsif ($pCommand eq "mr_resource_fields_settings") { &create_resource_fields_settings_form("NONE"); } elsif ($pCommand eq "mr_add_resource") { &create_add_edit_resource_form("ADD"); } elsif ($pCommand eq "add_resource") { &add_new_resource(); } elsif ($pCommand eq "mr_edit_resource") { &create_resource_selection_form("edit_resource_form"); } elsif ($pCommand eq "edit_resource_form") { &create_add_edit_resource_form("EDIT"); } elsif ($pCommand eq "edit_resource") { &edit_resource(); } elsif ($pCommand eq "list_resource_admins") { &create_popup_list_resource_admins(); } elsif ($pCommand eq "mr_delete_resource") { &create_resource_selection_form("delete_resource_confirmation"); } elsif ($pCommand eq "delete_resource_confirmation") { &create_delete_resource_confirmation_form(); } elsif ($pCommand eq "delete_resource") { $resource_to_delete = $form_text{'resource_key'}; if ($pConfirm eq $lang_yes) { if (&delete_resource($resource_to_delete) == 1) { &create_manage_resources_form("The resource $res_to_delete was deleted."); } else { &create_manage_resources_form("Error: The resource $res_to_delete was NOT deleted."); } } else { &create_manage_resources_form("The resource $res_to_delete was NOT deleted."); } } elsif ($pCommand eq "mr_reorder_resources") { &create_reorder_resources_form("NONE"); } elsif ($pCommand eq "mr_exit_reorder_resources") { unlink($gresource_file_reorder); &create_manage_resources_form(); } elsif ($pCommand eq "mr_blackout_dates") { &create_manage_blackout_dates_form("NONE"); } elsif ($pCommand eq "mr_add_blackout") { &create_add_blackout_date_form(); } elsif ($pCommand eq "add_new_blackout") { &add_new_blackout_date(); } elsif ($pCommand eq "mr_delete_blackout") { $blackout_detail = $form_text{'blackout_detail'}; if (($blackout_detail eq "") || (!($blackout_detail =~ /\S/))) { &missing_input("Missing Input","You must select a blackout date to delete."); } &create_delete_blackout_date_confirmation_form(); } elsif ($pCommand eq "delete_blackout") { if ($pConfirm eq $lang_yes) { $blackout_delete_count = 0; $blackout_delete_count = &delete_blackout_date(); if ($blackout_delete_count > 0) { &create_manage_blackout_dates_form("$blackout_delete_count blackout dates were deleted."); } else { &create_manage_blackout_dates_form("Error: Blackout dates were NOT deleted. Contact system admin if problem persists."); } } else { &create_manage_blackout_dates_form("No blackout dates were deleted."); } } elsif ($pCommand eq "gr_generate_report") { $report_period = $form_text{'report_period'}; # daily, range, or monthly $report_type = $form_text{'report_type'}; # resource, period or usage $report_date_1 = $form_text{'report_date_1'}; $report_date_2 = $form_text{'report_date_2'}; $report_date_3 = $form_text{'report_date_3'}; $report_month = $form_text{'report_month'}; $report_start_time = $form_text{'report_start_time'}; # CUSTOM $report_end_time = $form_text{'report_end_time'}; # CUSTOM $run_all = $form_text{'report_on_all'}; # report on all resources or not $resource_list = $form_text{'resource_list'}; $print_empty = $form_text{'print_empty'}; $email_1 = $form_text{'email_primary'}; $email_2 = $form_text{'email_secondary'}; $print_file = $form_text{'print_to_file'}; $print_screen = $form_text{'print_to_screen'}; if ( (($settings[2] =~ /\S/) && ($email_1 =~ /NO/i)) && (($settings[3] =~ /\S/) && ($email_2 =~ /NO/i)) && ($print_file =~ /NO/i) && ($print_screen =~ /NO/i) ) { &missing_input("Missing Input","You must select to e-mail the report, print to the screen, or print to a file."); } elsif ( (!($settings[2] =~ /\S/)) && (!($settings[3] =~ /\S/)) && ($print_file =~ /NO/i) && ($print_screen =~ /NO/i)) { &missing_input("Missing Input","You must select to print the report to the screen, or print it to a file."); } elsif ( (($resource_list eq "") || (!($resource_list =~ /\S/))) && ($run_all eq $lang_no) ) { &missing_input("Missing Input","You must select at least one resource for the report."); } elsif ($report_type eq $REPORT_TYPE_RESOURCE) { &generate_report_by_resource($report_period, $report_type, $report_date_1, $report_date_2, $report_date_3, $report_month, $run_all, $resource_list, $email_1, $email_2, $print_file, $print_screen, $print_empty); } elsif ($report_type eq $REPORT_TYPE_PERIOD) { &generate_report_by_period($report_period, $report_type, $report_date_1, $report_date_2, $report_date_3, $report_month, $report_start_time, $report_end_time, $run_all, $resource_list, $email_1, $email_2, $print_file, $print_screen, $print_empty); } elsif ($report_type eq $REPORT_TYPE_USAGE) { &generate_report_by_usage($report_period, $report_type, $report_date_1, $report_date_2, $report_date_3, $report_month, $run_all, $resource_list, $email_1, $email_2, $print_file, $print_screen, $print_empty); } else { &missing_input("Data Error","Invalid Report Type Selection"); } } elsif ($pCommand eq "cp_manage_users") { &create_manage_users_form(); } elsif ($pCommand eq "cp_manage_pending") { $present_week = &get_week_name(time); # MM-DD-YYYY &create_manage_pending_reservations_form(); } elsif ($pCommand eq "mp_view_pending") { $pending_detail_list = $form_text{'pending_detail_list'}; if (($pending_detail_list eq "") || (!($pending_detail_list =~ /\S/))) { &missing_input("Missing Input","You must select at least one pending reservation."); } $subcommand = $form_text{'pending_subcommand'}; if ($subcommand eq $lang_authorize) { $result_message = &authorize_pending_reservations(1, 0, 0); # 1=approve, 0=no passthru multi-select list, 0=email user if ($result_message != -1) { &create_manage_pending_reservations_form($result_message); } } elsif ($subcommand eq $lang_reject) { $result_message = &authorize_pending_reservations(0, 0, 0); # 0=reject, 0=no passthru multi-select list, 0=email user if ($result_message != -1) { &create_manage_pending_reservations_form($result_message); } } else { &create_advanced_view_pending_form(); } } elsif ($pCommand eq "mp_manage_pending") { $next_command = $form_text{'next_command'}; if ($next_command eq $lang_authorize) { $result_message = &authorize_pending_reservations(1, 1, 0); # 1=approve, 1=passthru multi-select list, 0=email user if ($result_message != -1) { &create_manage_pending_reservations_form($result_message); } } elsif ($next_command eq $lang_reject) { $result_message = &authorize_pending_reservations(0, 1, 0); # 0=reject, 1=passthru multi-select list, 0=email user if ($result_message != -1) { &create_manage_pending_reservations_form($result_message); } } elsif ($next_command eq $lang_dontemail) { $result_message = &authorize_pending_reservations(0, 1, 1); # 0=reject, 1=passthru multi-select list, 1=dont email user if ($result_message != -1) { &create_manage_pending_reservations_form($result_message); } } } elsif ($pCommand eq "authorize_pending") { $subcommand = $form_text{'pending_subcommand'}; if ($subcommand =~ /$lang_authorize/i) { $result_message = &authorize_pending_recurring_reservation(1); # 1=approve &create_manage_pending_reservations_form($result_message); } else { &email_pending_reservation_result(1); $present_week = &get_week_name(time); # MM-DD-YYYY &create_manage_pending_reservations_form("The reservation was $lang_activated."); } } elsif ($pCommand eq "cancel_pending") { $subcommand = $form_text{'pending_subcommand'}; if ($subcommand =~ /$lang_reject/i) { $result_message = &authorize_pending_recurring_reservation(0); # 0=reject &create_manage_pending_reservations_form($result_message); } else { &email_pending_reservation_result(0); $present_week = &get_week_name(time); # MM-DD-YYYY &create_manage_pending_reservations_form("The reservation was $lang_cancelled."); } } elsif ($pCommand eq "mu_add_user") { &create_add_edit_user_form("ADD"); } elsif ($pCommand eq "add_user") { &add_user(0, $username, $password); } elsif ($pCommand eq "mu_edit_user") { &create_user_selection_form("edit_user_form"); } elsif ($pCommand eq "edit_user_form") { &create_add_edit_user_form("EDIT"); } elsif ($pCommand eq "edit_user") { &edit_user(); } elsif ($pCommand eq "mu_delete_user") { &create_user_selection_form("delete_user_confirmation"); } elsif ($pCommand eq "delete_user_confirmation") { &create_delete_user_confirmation_form(); } elsif ($pCommand eq "delete_user") { $user_to_delete = $form_text{'auth_user_name'}; $auth_user_full_name = $form_text{'auth_user_full_name'}; if ($pConfirm eq $lang_yes) { if (&delete_user($user_to_delete, 0) == 1) { &create_manage_users_form("The user $auth_user_full_name ($user_to_delete) was deleted."); } else { &create_manage_users_form("Error: The user $auth_user_full_name ($user_to_delete) was NOT deleted."); } } else { &create_manage_users_form("The user $auth_user_full_name ($user_to_delete) was NOT deleted."); } } elsif ($pCommand eq "change_pswd") { &create_change_pswd_form(); } elsif ($pCommand eq "update_pswd") { &change_auth_user_pswd(); } elsif ($pCommand eq "mu_manage_blocked_users") { &create_manage_blocked_users_form(); } elsif ($pCommand eq "mu_blocked_user") { $subcommand = $form_text{'next_command'}; if ($subcommand eq $lang_block_user) { &add_blocked_user($username, $password); } elsif ($subcommand eq $lang_remove_from_list) { $blocked_user_detail = $form_text{'blocked_user_detail'}; if (($blocked_user_detail eq "") || (!($blocked_user_detail =~ /\S/))) { &create_manage_blocked_users_form("Select a blocked user to delete."); } $blocked_delete_count = 0; $blocked_delete_count = &delete_blocked_user(); if ($blocked_delete_count > 0) { &create_manage_blocked_users_form("$blocked_delete_count blocked user e-mails were removed from the list."); } else { &create_manage_blocked_users_form("Error: Blocked users were NOT deleted. Contact system admin if problem persists."); } } else { &create_manage_blocked_users_form(); } } elsif ($pCommand eq "cp_generate_reports") { &create_report_details_form($username, $password, ""); } elsif ($pCommand eq "cp_view_schedule") { if ((!($pSeconds =~ /\S/)) && ($settings[94] =~ /\S/)) { $pSeconds = &get_date_seconds($settings[94]); } elsif (!($pSeconds =~ /\S/)) { $pSeconds = time; } if ((-e $gcategory_file) && ($settings[131] eq "2")) # && ($pView =~ /MENU/i)) { &display_category_menu($pSeconds); } else { if ($pView eq "") { $pView = $settings[1]; } $view_category = 0; if ((-e $gcategory_file) && (($settings[131] eq "2") || ($settings[131] eq "3"))) { $view_category = $form_text{'category_key'}; } if ($pView =~ /DAILY/i) { &display_schedule_daily($pSeconds, 0, $view_category); } elsif ($pView =~ /MONTHLY/i) { &display_schedule_monthly($pSeconds, $view_category); } else { &display_schedule_weekly($pSeconds, $view_category); } } } elsif ($pCommand eq "user_view_schedule") { if ((!($pSeconds =~ /\S/)) && ($settings[94] =~ /\S/)) { $pSeconds = &get_date_seconds($settings[94]); } elsif (!($pSeconds =~ /\S/)) { $pSeconds = time; } if ((-e $gcategory_file) && ($settings[131] eq "2") && ($pView =~ /MENU/i)) { &display_category_menu($pSeconds); } else { $view_category = 0; if ((-e $gcategory_file) && (($settings[131] eq "2") || ($settings[131] eq "3"))) { $view_category = $form_text{'category_key'}; $pView = &get_default_category_view($view_category); } if ($pView eq "") { $pView = $settings[1]; } if ($pView =~ /DAILY/i) { &display_schedule_daily($pSeconds, 0, $view_category); } elsif ($pView =~ /MONTHLY/i) { &display_schedule_monthly($pSeconds, $view_category); } else { &display_schedule_weekly($pSeconds, $view_category); } } } elsif ($pCommand eq "cp_view_day_of_month") { $view_resource_key = $form_text{'resource_key'}; $view_seconds = $form_text{'cumulative_seconds'}; $view_category = 0; if ((-e $gcategory_file) && (($settings[131] eq "2") || ($settings[131] eq "3"))) { $view_category = $form_text{'category_key'}; } &display_schedule_daily_one($view_seconds, $view_resource_key, $view_category); } elsif ($pCommand eq "cp_reference") { print "Location: http://www.uburst.com/uReserve/reference.html", "\n\n"; } elsif ($pCommand eq "goto_previous_day") { $view_resource_key = $form_text{'resource_key'}; $view_category = 0; if ((-e $gcategory_file) && (($settings[131] eq "2") || ($settings[131] eq "3"))) { $view_category = $form_text{'category_key'}; } if (int($view_resource_key) > 0) { &display_schedule_daily_one($pSeconds, $view_resource_key, $view_category); } else { &display_schedule_daily($pSeconds, 0, $view_category); } } elsif ($pCommand eq "goto_next_day") { $view_resource_key = $form_text{'resource_key'}; $view_category = 0; if ((-e $gcategory_file) && (($settings[131] eq "2") || ($settings[131] eq "3"))) { $view_category = $form_text{'category_key'}; } if (int($view_resource_key) > 0) { &display_schedule_daily_one($pSeconds, $view_resource_key, $view_category); } else { &display_schedule_daily($pSeconds, 0, $view_category); } } elsif ($pCommand eq "goto_previous_week") { $view_category = 0; if ((-e $gcategory_file) && (($settings[131] eq "2") || ($settings[131] eq "3"))) { $view_category = $form_text{'category_key'}; } &display_schedule_weekly($pSeconds, $view_category); } elsif ($pCommand eq "goto_next_week") { $view_category = 0; if ((-e $gcategory_file) && (($settings[131] eq "2") || ($settings[131] eq "3"))) { $view_category = $form_text{'category_key'}; } &display_schedule_weekly($pSeconds, $view_category); } elsif ($pCommand eq "goto_previous_month") { $view_category = 0; if ((-e $gcategory_file) && (($settings[131] eq "2") || ($settings[131] eq "3"))) { $view_category = $form_text{'category_key'}; } &display_schedule_monthly($pSeconds, $view_category); } elsif ($pCommand eq "goto_next_month") { $view_category = 0; if ((-e $gcategory_file) && (($settings[131] eq "2") || ($settings[131] eq "3"))) { $view_category = $form_text{'category_key'}; } &display_schedule_monthly($pSeconds, $view_category); } elsif ($pCommand eq "goto_month") { $goto_month = $form_text{'month'}; # MM/YYYY $month = substr($goto_month,0,2); $year = substr($goto_month,3,4); if ($settings[5] =~ /US/i) { $start_month_string = sprintf("%02d/%02d/%04d",$month,1,$year); #MM/DD/YYYY } else { $start_month_string = sprintf("%02d/%02d/%04d",1,$month,$year); #DD/MM/YYYY } $goto_seconds = &get_date_seconds($start_month_string); $view_category = 0; if ((-e $gcategory_file) && (($settings[131] eq "2") || ($settings[131] eq "3"))) { $view_category = $form_text{'category_key'}; } &display_schedule_monthly($goto_seconds, $view_category); } elsif ($pCommand eq "goto_previous_next_report_month") { &create_report_details_form($username, $password, ""); } elsif ($pCommand eq "goto_report_month") { &create_report_details_form($username, $password, ""); } elsif ($pCommand eq "goto_date") { $goto_date = $form_text{'date'}; $goto_seconds = &get_date_seconds($goto_date); $view_category = 0; if ((-e $gcategory_file) && (($settings[131] eq "2") || ($settings[131] eq "3"))) { $view_category = $form_text{'category_key'}; } if ($pView =~ /DAILY/i) { &display_schedule_daily($goto_seconds, 0, $view_category); } elsif ($pView =~ /WEEKLY/i) { &display_schedule_weekly($goto_seconds, $view_category); } else { &display_schedule_monthly($goto_seconds, $view_category); } } elsif ($pCommand eq "goto_date_from_monthly") { $goto_date = $form_text{'date'}; $goto_seconds = &get_date_seconds($goto_date); $view_resource_key = $form_text{'resource_key'}; $view_category = 0; if ((-e $gcategory_file) && (($settings[131] eq "2") || ($settings[131] eq "3"))) { $view_category = $form_text{'category_key'}; } &display_schedule_daily_one($goto_seconds, $view_resource_key, $view_category); } elsif ($pCommand eq "resource") { &create_add_reservation_form(); } elsif ($pCommand eq "reserve") { &reserve_resource(); } elsif ($pCommand eq "create_modify_form") { &create_modify_or_delete_reservation_form(); } elsif ($pCommand eq "modify") { $subcommand = $form_text{'modify_subcommand'}; if ($subcommand eq "Modify") { &modify_reservation(); } $subcommand = $form_text{'modify_recurring_subcommand'}; if ($subcommand eq "Modify Recurring") { &modify_recurring_reservation(1); } elsif ($subcommand eq "$lang_no") { &modify_recurring_reservation(0); } $subcommand = $form_text{'delete_subcommand'}; if ($subcommand eq "Delete") { &delete_reservation(); } $subcommand = $form_text{'delete_recurring_subcommand'}; if ($subcommand eq "Delete Recurring") { &delete_recurring_reservation(1); } elsif ($subcommand eq "$lang_no") { &delete_recurring_reservation(0); } } elsif ($pCommand eq "who") { &view_reservation(); } elsif ($pCommand eq "cp_utilities") { &create_utilities_form(); } elsif ($pCommand eq "ut_upgrade") { &create_upgrade_form(""); } elsif ($pCommand eq "Upgrade Data Files") { &upgrade_data(); } elsif ($pCommand eq "ut_purge_data") { &create_purge_form("NONE"); } elsif ($pCommand eq "Purge Data") { &purge_data(); } elsif ($pCommand eq "ut_send_reminders") { &create_reminder_utility_form(""); } elsif ($pCommand eq "Send Reminders") { &process_reminders(); } elsif ($pCommand eq "Clear Reminders") { &clear_log_file($greminder_log_file); &create_reminder_utility_form("Log file cleared."); } elsif ($pCommand eq "ut_manage_images") { &create_image_file_form("NONE"); } elsif ($pCommand eq "upload_image") { $pUploadData = $form_text{'upload_data'}; $pUploadFile = $form_text{'upload_file_name'}; &upload_image_file(); } elsif ($pCommand eq "delete_image") { if ($pFile ne "NONE") { &create_delete_image_file_confirmation_form($pFile,"delete_image_file"); } else { &create_image_file_form("No image file was selected to delete."); } } elsif ($pCommand eq "delete_image_file") { if ($pConfirm eq $lang_yes) { $dfile = $default_image_dir . $pFile; unlink($dfile); &create_image_file_form("The file " . $pFile . " was successfully deleted."); } else { &create_image_file_form("The file was Not deleted."); } } elsif ($pCommand eq "ut_view_logs") { &create_view_logs_form("$pFile", "NONE"); } elsif ($pCommand eq "ut_export_data") { &create_export_data_form(""); } elsif ($pCommand eq "process_data_extraction") { &make_extract_file(); &download_extract_file(); } elsif ($pCommand eq "cp_security") { &create_security_settings_form("NONE"); } elsif ($pCommand eq "save_security_settings") { &save_security_settings(); } elsif ($pCommand eq "cp_logout") { $password = ""; $username = ""; &create_admin_control_panel("NONE"); } else # default to attempting to display the schedule { if ($settings[127] =~ /YES/i) { &create_schedule("NONE"); } $view_category = 0; if (($pSeconds eq "") || ($pShowWeek eq "")) { $pSeconds = time; if ($settings[94] =~ /\S/) { $pSeconds = &get_date_seconds($settings[94]); } } if ((-e $gcategory_file) && ($settings[131] eq "2")) { &display_category_menu($pSeconds); } else { if ($pView eq "") { $pView = $settings[1]; } if ($pView =~ /DAILY/i) { &display_schedule_daily($pSeconds, 0, $view_category); } elsif ($pView =~ /MONTHLY/i) { &display_schedule_monthly($pSeconds, $view_category); } else { &display_schedule_weekly($pSeconds, $view_category); } } } exit; sub create_admin_login_form { print "Content-type: text/html\n\n"; print "\n"; print "\n"; print "\n\n"; print "uReserve Login"; print ""; print "



"; print "
"; print ""; print "
"; print ""; print ""; print "
"; print ""; print "
ADMINISTRATIVE LOGIN

"; print "
"; print ""; print "$lang_username:

"; print "$lang_password:

"; print ""; print "
"; print "
"; print "
"; print "
"; print ""; exit; } sub create_schedule_login_form { print "Content-type: text/html\n\n"; print "\n"; print "\n"; print "\n\n"; print "uReserve Login"; print ""; print "



"; print "
"; print ""; print "
"; print ""; print ""; print "
"; print ""; print "
LOG IN TO VIEW THE SCHEDULE

"; print "
"; print "$lang_username:

"; print "$lang_password:

"; print ""; print "
"; print "
"; print "
"; print "
"; print ""; exit; } sub create_admin_control_panel { local ($message) = @_; local ( $resource_admin_access, $reports_admin_access, $user_auth); $resource_admin_access = 1; $reports_admin_access = 1; &validate_admin($username, $password, $resource_admin_access, $reports_admin_access); $user_auth = &get_user_group($username, $password); $user_auth = int($user_auth); print "Content-type: text/html\n\n"; print "\n"; print "\n"; print "\n\n"; print "uReserve"; print ""; print "



"; if (($message =~ /\S/) && ($message ne "NONE")) { print "
"; print ""; print $message; print ""; print "
"; print "
"; } print "
"; print ""; print "
"; print ""; if ($user_auth == $SYSTEM_ADMIN) { &print_button('M',"$lang_general_settings", "cp_general_settings", $password, $username); &print_button('M',"$lang_manage_categories", "cp_manage_categories", $password, $username); } if (($user_auth == $SYSTEM_ADMIN) || ($user_auth == $RESOURCE_ADMIN)) { &print_button('M',"$lang_manage_resources", "cp_manage_resources", $password, $username); &print_button('M',"$lang_manage_users", "cp_manage_users", $password, $username); &print_button('M',"$lang_pending", "cp_manage_pending", $password, $username); } if (($user_auth == $SYSTEM_ADMIN) || ($user_auth == $RESOURCE_ADMIN) || ($user_auth == $REPORTS_ADMIN)) { &print_button('M',"$lang_reports", "cp_generate_reports", $password, $username); } if ($user_auth == $SYSTEM_ADMIN) { &print_button('M',"$lang_utilities", "cp_utilities", $password, $username); &print_button('M',"$lang_security_settings", "cp_security", $password, $username); } &print_button('M',"$lang_logout", "cp_logout", $password, $username); print "
"; print "
"; print "
"; print ""; print "

"; print ""; print "


"; print "uReserve
TM Gold"; print "
"; print ""; print "Online Schedule Manager"; print ""; print "
"; print ""; print "version $version"; print ""; print "
"; print ""; print "
Copyright (c) 2000 - 2006
Microburst Technologies, Inc."; print "
"; print "


"; print "
"; if ((-e $gresource_file) || (-e $gresource_file_old)) { if (!(-e $gresource_file)) { print ""; if ($user_auth == $SYSTEM_ADMIN) { print "Your data files need to be upgraded from version 3. Select Utilities and then select Upgrade Data Files"; } else { print "Your data files need to be upgraded from version 3. Someone with SYSTEM ADMIN authorization needs to do this prior to you using the system. Please contact your system adminstrator."; } exit; } else { print ""; print "This product is licensed to:

"; print "$company_name
"; print "$website

"; print "License Number: $license_number

"; } } else { print ""; print "Welcome to the uReserveTM Gold Online Schedule Manager! Since "; print "this is your first time using uReserve, begin by configuring the General Settings "; print "and then add some resources using Manage Resources."; } print ""; print "
"; print ""; print "
"; &print_button('S',"$lang_goto_schedule", "cp_view_schedule", $password, $username); print "   "; &print_button('S',"$lang_online_reference", "cp_reference", $password, $username); print "
"; print "
"; print "
"; print "
"; print ""; exit; } sub create_schedule { local ($user_auth); $user_auth = &get_user_group($username, $password); if ($user_auth == -1) { &create_schedule_login_form("Enter a valid username and password."); } return; } sub display_category_menu { local ($view_seconds) = @_; local (@categories); if (!(-e $gcategory_file)) { return; } else { @categories = (); @categories = &get_category_file($view_seconds); } print "Content-type: text/html\n\n"; print "\n"; print "\n"; print "\n\n"; print "$g_formatted_date"; print ""; print ""; &print_current_date_header($username, $password); if (($settings[125] =~ /top/i) || ($settings[125] =~ /both/i) ) { &print_admin_hyperlink(); } &print_optional_page_image($gpage_image); print "
"; &print_category_menu($view_seconds, @categories); print "
"; print "
"; print "$website"; print ""; exit; } sub print_category_menu { local ( $view_seconds, @categories) = @_; local ($i, $category_key, $category_name, $category_description, @cat_value_pairs); if (-e $gcategory_file) { print "
"; print ""; for ($i=0; $i<=$#categories; $i++) { @cat_value_pairs = (); $category_key = ""; $category_name = ""; $category_description = ""; @cat_value_pairs = split (/\|/, $categories[$i]); $category_key = $cat_value_pairs[0]; $category_name = $cat_value_pairs[1]; $category_description = $cat_value_pairs[4]; print ""; } print "
"; print "$category_name"; if ($category_description =~ /\S/) { print " - $category_description"; } print "




"; } return; } sub display_schedule_daily { local ( $seconds_date, $monthly_view_flag, $view_category) = @_; local ( $week_name, $file_name, $date_string, $num_seconds, $current_seconds, $total_columns, $index, $looper, $day_index, $blackout_index, @resources, $resource_index, $line_index, @key_value_pairs, $resource_name, $current_line, $sday, $eday, $time_header_html, $placeholder_field_number, $placeholder_max_chars, $category_image, $category_settings, @reservation_data, @resources, @category_value_pairs); $week_name = &get_week_name($seconds_date); # MM-DD-YYYY &analyze_seconds($seconds_date); $file_name = $data_directory . $week_name . ".txt"; $date_string = sprintf("%02d-%02d-%04d",substr($g_file_date,4,2),substr($g_file_date,6,2),substr($g_file_date,0,4)); if ($settings[5] =~ /US/i) { $date_string =~ s/-/\//g; } else { @key_value_pairs = split (/-/, $date_string); $date_string = sprintf("%02d/%02d/%04d",$key_value_pairs[1],$key_value_pairs[0],$key_value_pairs[2]); } @reservation_data = &get_reservation_data_file($file_name); @resources = &get_resources($view_category, $seconds_date); $background_color = $settings[17]; $font_face = $settings[18]; $font_size = $settings[19]; $font_color = $settings[20]; $link_color = $settings[21]; $vlink_color = $settings[22]; $alink_color = $settings[23]; $title_bar_color = $settings[24]; if ((-e $gcategory_file) && (int($view_category) > 0) && ($settings[131] eq "2")) { $category_settings = &get_category_settings($view_category); @category_value_pairs = split (/\|/, $category_settings); if ($category_value_pairs[6] =~ /\S/) { $title_bar_color = $category_value_pairs[6]; } if ($category_value_pairs[7] =~ /\S/) { $font_color = $category_value_pairs[7]; } if ($category_value_pairs[8] =~ /\S/) { $font_face = $category_value_pairs[8]; } if ($category_value_pairs[9] =~ /\S/) { $font_size = $category_value_pairs[9]; } } print "Content-type: text/html\n\n"; print "\n"; print "\n"; print "\n\n"; print "$g_formatted_date"; print ""; &print_body($background_color, $font_color, $link_color, $vlink_color, $alink_color); &print_current_date_header($username, $password); &print_optional_links("TOP", $view_category, "DAILY", $seconds_date); $category_image = ""; if ((-e $gcategory_file) && (int($view_category) > 0) && ($settings[131] eq "2")) { $category_image = &get_category_image($view_category); &print_optional_page_image($category_image); } else { &print_optional_page_image($gpage_image); } &print_page_title($font_size, $font_face, $font_color, $page_title_daily, $g_formatted_date, $file_name); if (($settings[146] =~ /TOP/i) || ($settings[146] =~ /BOTH/i )) { &print_navigation_buttons( "DAILY", $week_name, $seconds_date, $monthly_view_flag, 0, 0, 0, $view_category); } print "
"; $current_seconds = $g_seconds; $sday = $g_wday; $total_columns = &get_total_columns(); $settings[34] = &strip_letters($settings[34]); $day_index = $sday; #equal to g_wday print " "; $settings[34] = ($settings[34] * ($total_columns - 1)) + 200; print ""; $settings[34] = ($settings[34] - 200) / ($total_columns - 1); print ""; print ""; print ""; print "
"; print ""; &print_title_html("D",$g_wday,0,$title_bar_color); &print_column_header_html($title_bar_color); &print_header_spacer_html($title_bar_color); $last_category = 0; $looper = &get_looper(); for ($resource_index = 0; $resource_index <= $#resources; $resource_index++) { @key_value_pairs = split (/\|/, $resources[$resource_index]); $resource_key = $key_value_pairs[0]; $this_category = $key_value_pairs[1]; $resource_name = $key_value_pairs[5]; $row_html = ""; $line_index = 0; $current_line = ""; if ($settings[6] =~ /SUN/i) { $temp_day_index = $day_index + 1; } else { if ($day_index == 0) { $temp_day_index = 7; } else { $temp_day_index = $day_index; } } if ($#reservation_data > 0) { while ((!($reservation_data[$line_index] =~ /^#$temp_day_index/i)) && ($line_index <= $#reservation_data)) { $line_index++; } while ((!($reservation_data[$line_index] =~ /^#END/i)) && ($line_index <= $#reservation_data)) { @key_value_pairs = split (/\|/, $reservation_data[$line_index]); $current_resource_key = $key_value_pairs[0]; if (int($current_resource_key) == int($resource_key)) { if ($#key_value_pairs > 6) { $current_line = $reservation_data[$line_index]; } } $line_index++; } } @blackout_timeslots = &get_blackout_timeslots($resource_key, $seconds_date, $temp_day_index); $blackout_status = $blackout_timeslots[0]; $placeholder_field_number = 0; $placeholder_max_chars = ""; $resource_settings = &get_resource_settings($resource_key); @resource_value_pairs = split (/\|/, $resource_settings); $placeholder_field_number = &get_placeholder_field_number(@resource_value_pairs); $placeholder_max_chars = &get_placeholder_max_chars(@resource_value_pairs); $row_html = &get_row_html( $resource_key, $week_name, $temp_day_index, $current_seconds, $blackout_status, $total_columns, $looper, $current_line, $placeholder_field_number, $placeholder_max_chars, @blackout_timeslots); if ((-e $gcategory_file) && ($settings[131] eq "3") && ($this_category ne $last_category)) { $divider_row_color = "#000000"; $divider_row_font_color = "#FFFFFF"; $divider_row_font_face = "Arial"; $divider_row_font_size = "2"; if ($settings[136] =~ /\S/) { $divider_row_color = $settings[136]; } if ($settings[137] =~ /\S/) { $divider_row_font_color = $settings[137]; } if ($settings[138] =~ /\S/) { $divider_row_font_face = $settings[138]; } if ($settings[139] =~ /\S/) { $divider_row_font_size = $settings[139]; } print ""; print ""; print ""; $last_category = $this_category; } print ""; print ""; print $row_html; print ""; } print "
"; print ""; $category_name = &get_category_name($this_category); print $category_name; print ""; print "
"; print ""; if ($blackout_status == -1) { print $resource_name . " (unavailable)"; } else { print "$resource_name"; } print ""; print "
"; print "
"; print ""; print "$settings[56]"; # reservation instructions print "


"; print "
"; if (($settings[146] =~ /BOTTOM/i) || ($settings[146] =~ /BOTH/i )) { &print_navigation_buttons( "DAILY", $week_name, $seconds_date, $monthly_view_flag, 0, 0, 0, $view_category); } &print_optional_links("BOTTOM", $view_category, "DAILY", $seconds_date); print "
"; print "$website"; print ""; exit; } sub display_schedule_daily_one { local ( $seconds_date, $view_resource_key, $view_category) = @_; local ( $week_name, $file_name, $date_string, $num_seconds, $current_seconds, $total_columns, $index, $looper, $day_index, $blackout_index, $resource_index, $line_index, $resource_name, $current_line, $sday, $eday, $time_header_html, $placeholder_field_number, $placeholder_max_chars, $category_image, $category_settings, @resources, @reservation_data, @key_value_pairs, @name_value_pairs, @category_value_pairs ); &analyze_seconds($seconds_date); $week_name = &get_week_name($seconds_date); $monthly_view_flag = 1; $orig_seconds_date = $seconds_date; $orig_week_name = $week_name; $file_name = $data_directory . $week_name . ".txt"; $date_string = sprintf("%02d-%02d-%04d",substr($g_file_date,4,2),substr($g_file_date,6,2),substr($g_file_date,0,4)); if ($settings[5] =~ /US/i) { $date_string =~ s/-/\//g; } else { @key_value_pairs = split (/-/, $date_string); $date_string = sprintf("%02d/%02d/%04d",$key_value_pairs[1],$key_value_pairs[0],$key_value_pairs[2]); } @reservation_data = &get_reservation_data_file($file_name); $line_index = 0; @resources = &get_resources($view_category, $seconds_date); $background_color = $settings[17]; $font_face = $settings[18]; $font_size = $settings[19]; $font_color = $settings[20]; $link_color = $settings[21]; $vlink_color = $settings[22]; $alink_color = $settings[23]; $title_bar_color = $settings[24]; if ((-e $gcategory_file) && (int($view_category) > 0) && ($settings[131] eq "2")) { $category_settings = &get_category_settings($view_category); @category_value_pairs = split (/\|/, $category_settings); if ($category_value_pairs[6] =~ /\S/) { $title_bar_color = $category_value_pairs[6]; } if ($category_value_pairs[7] =~ /\S/) { $font_color = $category_value_pairs[7]; } if ($category_value_pairs[8] =~ /\S/) { $font_face = $category_value_pairs[8]; } if ($category_value_pairs[9] =~ /\S/) { $font_size = $category_value_pairs[9]; } } print "Content-type: text/html\n\n"; print "\n"; print "\n"; print "\n\n"; print "$g_formatted_date"; print ""; &print_body($background_color, $font_color, $link_color, $vlink_color, $alink_color); &print_current_date_header($username, $password); $category_image = ""; if ((-e $gcategory_file) && (int($view_category) > 0) && ($settings[131] eq "2")) { $category_image = &get_category_image($view_category); &print_optional_page_image($category_image); } else { &print_optional_page_image($gpage_image); } &print_page_title($font_size, $font_face, $font_color, $page_title_daily, $g_formatted_date, $file_name); if (($settings[146] =~ /TOP/i) || ($settings[146] =~ /BOTH/i )) { &print_navigation_buttons( "DAILY", $week_name, $seconds_date, $monthly_view_flag, $view_resource_key, 0, 0, $view_category); } print "
"; $current_seconds = $g_seconds; $sday = $g_wday; $total_columns = &get_total_columns(); $settings[34] = &strip_letters($settings[34]); $day_index = $sday; #equal to g_wday print " "; $settings[34] = ($settings[34] * ($total_columns - 1)) + 200; print ""; $settings[34] = ($settings[34] - 200) / ($total_columns - 1); print ""; print ""; print ""; print "
"; print ""; &print_title_html("D",$g_wday,0,$title_bar_color); &print_column_header_html($title_bar_color); &print_header_spacer_html($title_bar_color); $looper = &get_looper(); for ($resource_index = 0; $resource_index <= $#resources; $resource_index++) { @key_value_pairs = split (/\|/, $resources[$resource_index]); $current_resource_key = $key_value_pairs[0]; $resource_name = $key_value_pairs[5]; if (int($current_resource_key) == int($view_resource_key)) { $row_html = ""; $line_index = 0; $current_line = ""; if ($settings[6] =~ /SUN/i) { $temp_day_index = $day_index + 1; } else { if ($day_index == 0) { $temp_day_index = 7; } else { $temp_day_index = $day_index; } } if ($#reservation_data > 0) { while ((!($reservation_data[$line_index] =~ /^#$temp_day_index/i)) && ($line_index <= $#reservation_data)) { $line_index++; } while ((!($reservation_data[$line_index] =~ /^#END/i)) && ($reservation_data <= $#reservation_data)) { @name_value_pairs = split (/\|/, $reservation_data[$line_index]); $reservation_key = $name_value_pairs[0]; if (int($reservation_key) == int($view_resource_key)) { if ($#key_value_pairs > 6) { $current_line = $reservation_data[$line_index]; } } $line_index++; } } @blackout_timeslots = &get_blackout_timeslots($view_resource_key, $seconds_date, $temp_day_index); $blackout_status = $blackout_timeslots[0]; $placeholder_field_number = 0; $placeholder_max_chars = ""; $resource_settings = &get_resource_settings($view_resource_key); @resource_value_pairs = split (/\|/, $resource_settings); $placeholder_field_number = &get_placeholder_field_number(@resource_value_pairs); $placeholder_max_chars = &get_placeholder_max_chars(@resource_value_pairs); $row_html = &get_row_html( $view_resource_key, $week_name, $temp_day_index, $current_seconds, $blackout_status, $total_columns, $looper, $current_line, $placeholder_field_number, $placeholder_max_chars, @blackout_timeslots); print ""; print ""; print $row_html; print ""; } # end if ($resource_name eq $view_resource) } print "
"; print ""; if ($blackout_status == -1) { print "$resource_name (unavailable)"; } else { print "$resource_name"; } print ""; print "
"; print "
"; print ""; print "$settings[56]"; # reservation instructions print "


"; print "
"; if (($settings[146] =~ /BOTTOM/i) || ($settings[146] =~ /BOTH/i )) { &print_navigation_buttons( "DAILY", $week_name, $seconds_date, $monthly_view_flag, $view_resource_key, 0, 0, $view_category); } print ""; print "
"; print "
"; print ""; print "
"; print "
"; print "$website"; print ""; exit; } sub display_schedule_weekly { local ( $week_seconds, $view_category) = @_; local ($week_name, $file_name, $date_string, $num_seconds, $current_seconds, $total_columns, $index, $day_index, $resource_index, $line_index, $resource_key, $resource_name, $current_line, $sday, $eday, $placeholder_field_number, $placeholder_max_chars, $display_resource_name, $category_settings, @resources, @reservation_data, @key_value_pairs, @category_value_pairs ); $week_name = &get_week_name($week_seconds); $file_name = $data_directory . $week_name . ".txt"; $date_string = $week_name; if ($settings[5] =~ /US/i) { $date_string =~ s/-/\//g; } else { @key_value_pairs = split (/-/, $date_string); $date_string = sprintf("%02d/%02d/%04d",$key_value_pairs[1],$key_value_pairs[0],$key_value_pairs[2]); } $line_index = 0; @reservation_data = &get_reservation_data_file($file_name); @resources = &get_resources($view_category, $week_seconds); $background_color = $settings[17]; $font_face = $settings[18]; $font_size = $settings[19]; $font_color = $settings[20]; $link_color = $settings[21]; $vlink_color = $settings[22]; $alink_color = $settings[23]; $title_bar_color = $settings[24]; if ((-e $gcategory_file) && (int($view_category) > 0) && ($settings[131] eq "2")) { $category_settings = &get_category_settings($view_category); @category_value_pairs = split (/\|/, $category_settings); if ($category_value_pairs[6] =~ /\S/) { $title_bar_color = $category_value_pairs[6]; } if ($category_value_pairs[7] =~ /\S/) { $font_color = $category_value_pairs[7]; } if ($category_value_pairs[8] =~ /\S/) { $font_face = $category_value_pairs[8]; } if ($category_value_pairs[9] =~ /\S/) { $font_size = $category_value_pairs[9]; } } print "Content-type: text/html\n\n"; print "\n"; print "\n"; print "\n\n"; print "$date_string"; print ""; &print_body($background_color, $font_color, $link_color, $vlink_color, $alink_color); &print_current_date_header($username, $password); &print_optional_links("TOP", $view_category, "WEEKLY", $week_seconds); $category_image = ""; if ((-e $gcategory_file) && (int($view_category) > 0) && ($settings[131] eq "2")) { $category_image = &get_category_image($view_category); &print_optional_page_image($category_image); } else { &print_optional_page_image($gpage_image); } &print_page_title($font_size, $font_face, $font_color, $page_title_weekly, $date_string, $file_name); if (($settings[146] =~ /TOP/i) || ($settings[146] =~ /BOTH/i)) { &print_navigation_buttons( "WEEKLY", $week_name, $seconds_date, 0, 0, 0, 0, $view_category); } print "
"; $current_seconds = &get_week_seconds($week_name); $sday = 1; $eday = 8; if ($settings[7] =~ /NO/i) { if ($settings[6] =~ /SUN/i) { $current_seconds += $SECONDS_PER_DAY; $sday = 2; $eday = 7; } else { $eday = 6; } } $total_columns = &get_total_columns(); $settings[34] = &strip_letters($settings[34]); for ($day_index = $sday; $day_index < $eday; $day_index++) { print " "; $settings[34] = ($settings[34] * ($total_columns - 1)) + 200; print ""; $settings[34] = ($settings[34] - 200) / ($total_columns - 1); print ""; print ""; print ""; print "
"; print ""; &print_title_html("W", $day_index, $current_seconds, $title_bar_color); &print_column_header_html($title_bar_color); &print_header_spacer_html($title_bar_color); $last_category = 0; $looper = &get_looper(); for ($resource_index = 0; $resource_index <= $#resources; $resource_index++) { @key_value_pairs = split (/\|/, $resources[$resource_index]); $resource_key = $key_value_pairs[0]; $this_category = $key_value_pairs[1]; $resource_name = $key_value_pairs[5]; $row_html = ""; $line_index = 0; $current_line = ""; if ($settings[6] =~ /SUN/i) { $temp_day_index = $day_index; } else { if ($day_index == 0) { $temp_day_index = 7; } else { $temp_day_index = $day_index; } } if ($#reservation_data > 0) { while ((!($reservation_data[$line_index] =~ /^#$temp_day_index/i)) && ($line_index <= $#reservation_data)) { $line_index++; } while ((!($reservation_data[$line_index] =~ /^#END/i)) && ($line_index <= $#reservation_data)) { @key_value_pairs = split (/\|/, $reservation_data[$line_index]); $current_resource_key = $key_value_pairs[0]; if (int($current_resource_key) == int($resource_key)) { if ($#key_value_pairs > 6) { $current_line = $reservation_data[$line_index]; } } $line_index++; } } @blackout_timeslots = &get_blackout_timeslots($resource_key, $current_seconds, $temp_day_index); $blackout_status = $blackout_timeslots[0]; $placeholder_field_number = 0; $placeholder_max_chars = ""; $resource_settings = &get_resource_settings($resource_key); @resource_value_pairs = split (/\|/, $resource_settings); $placeholder_field_number = &get_placeholder_field_number(@resource_value_pairs); $placeholder_max_chars = &get_placeholder_max_chars(@resource_value_pairs); $row_html = &get_row_html( $resource_key, $week_name, $temp_day_index, $current_seconds, $blackout_status, $total_columns, $looper, $current_line, $placeholder_field_number, $placeholder_max_chars, @blackout_timeslots); if ((-e $gcategory_file) && ($settings[131] eq "3") && ($this_category ne $last_category)) { $divider_row_color = "#000000"; $divider_row_font_color = "#FFFFFF"; $divider_row_font_face = "Arial"; $divider_row_font_size = "2"; if ($settings[136] =~ /\S/) { $divider_row_color = $settings[136]; } if ($settings[137] =~ /\S/) { $divider_row_font_color = $settings[137]; } if ($settings[138] =~ /\S/) { $divider_row_font_face = $settings[138]; } if ($settings[139] =~ /\S/) { $divider_row_font_size = $settings[139]; } print ""; print ""; print ""; $last_category = $this_category; } print ""; print ""; print $row_html; print ""; } # End of resource loop. print "
"; print ""; $category_name = &get_category_name($this_category); print $category_name; print ""; print "
"; print ""; if ($blackout_status == -1) { print $resource_name . " (unavailable)"; } else { print ""; print $resource_name; print ""; } print ""; print "
"; print "
"; print ""; print "$settings[56]"; # reservation instructions print "


"; $current_seconds += ($SECONDS_PER_DAY + 10); } print "
"; if (($settings[146] =~ /BOTTOM/i) || ($settings[146] =~ /BOTH/i )) { &print_navigation_buttons( "WEEKLY", $week_name, $seconds_date, 0, 0, 0, 0, $view_category); } &print_optional_links("BOTTOM", $view_category, "WEEKLY", $week_seconds); print "
"; print "$website"; print ""; exit; } sub display_schedule_monthly { local ($seconds_date, $view_category) = @_; local ( $week_name, $file_name, $date_string, $num_seconds, $current_seconds, $total_columns, $index, $day_index, $resource_index, $line_index, $resource_name, $current_line, $sday, $eday, $td_html, $cell_width, $category_settings, @reservation_data, @resources, @key_value_pairs, @category_value_pairs ); $week_name = &get_week_name($seconds_date); &analyze_seconds($seconds_date); $file_name = $data_directory . $week_name . ".txt"; $date_string = $week_name; if ($settings[5] =~ /US/i) { $date_string =~ s/-/\//g; } else { @key_value_pairs = split (/-/, $date_string); $date_string = sprintf("%02d/%02d/%04d",$key_value_pairs[1],$key_value_pairs[0],$key_value_pairs[2]); } @resources = &get_resources($view_category, $seconds_date); $background_color = $settings[17]; $category_color = ""; $font_face = $settings[18]; $font_size = $settings[19]; $font_color = $settings[20]; $link_color = $settings[21]; $vlink_color = $settings[22]; $alink_color = $settings[23]; $title_bar_color = $settings[24]; if ((-e $gcategory_file) && (int($view_category) > 0) && ($settings[131] eq "2")) { $category_settings = &get_category_settings($view_category); @category_value_pairs = split (/\|/, $category_settings); if ($category_value_pairs[6] =~ /\S/) { $category_color = $category_value_pairs[6]; } if ($category_value_pairs[7] =~ /\S/) { $font_color = $category_value_pairs[7]; } if ($category_value_pairs[8] =~ /\S/) { $font_face = $category_value_pairs[8]; } if ($category_value_pairs[9] =~ /\S/) { $font_size = $category_value_pairs[9]; } } print "Content-type: text/html\n\n"; print "\n"; print "\n"; print "\n\n"; print "$month_names[$g_mon] $g_year"; print ""; &print_body($background_color, $font_color, $link_color, $vlink_color, $alink_color); &print_current_date_header($username, $password); &print_optional_links("TOP", $view_category, "MONTHLY", $seconds_date); $category_image = ""; if ((-e $gcategory_file) && (int($view_category) > 0) && ($settings[131] eq "2")) { $category_image = &get_category_image($view_category); &print_optional_page_image($category_image); } else { &print_optional_page_image($gpage_image); } &print_optional_monthly_hyperlinks(@resources); $save_g_mon = $g_mon; #save off this month for checking when the month changes $save_g_year = $g_year; #save off this year for help starting each calendar shown $g_mon_for_nav_buttons = $g_mon; #save off this month for the navigation buttons $g_year_for_nav_buttons = $g_year; #save off this year for the navigation buttons if (($settings[146] =~ /TOP/i) || ($settings[146] =~ /BOTH/i )) { &print_navigation_buttons( "MONTHLY", $week_name, 0, 0, 0, $g_mon_for_nav_buttons, $g_year_for_nav_buttons, $view_category); } $save_g_mon = $g_mon_for_nav_buttons; $save_g_year = $g_year_for_nav_buttons; if ($#resources >= 0) { for ($resource_index = 0; $resource_index <= $#resources; $resource_index++) { print "
"; $settings[19] = &strip_letters($settings[19]); $settings[19] += 2; print ""; $settings[19] -= 2; @key_value_pairs = split (/\|/, $resources[$resource_index]); $resource_key = $key_value_pairs[0]; $resource_name = $key_value_pairs[5]; print ""; print "$page_title_monthly $resource_name"; $form_name = "monthly_create_" . $resource_index; print "
"; print ""; print ""; print ""; print ""; print "
"; if ($settings[83] =~ /YES/i) # if show hyperlinks to each calendar { print "   "; print ""; print "[ top ]"; } if ($settings[5] =~ /US/i) { $start_month_string = sprintf("%02d/%02d/%04d",$save_g_mon,1,$save_g_year); } else { $start_month_string = sprintf("%02d/%02d/%04d",1,$save_g_mon,$save_g_year); } $goto_seconds = &get_date_seconds($start_month_string); &analyze_seconds($goto_seconds); $first_time = "T"; $col_index = 1; $cumulative_seconds = $goto_seconds; print ""; print "

"; $total_columns = 7; $cell_width = &strip_letters($settings[35]); print " "; $cell_width = ($cell_width * ($total_columns - 1)) + 200; print ""; print ""; # page background color print ""; print ""; print "
"; print ""; if ($category_color ne "") { print ""; # category color } else { print ""; } print ""; print ""; $day_font_size = &strip_letters($settings[29]); if ($day_font_size > 1) { $day_font_size -= 1; } $short_flag = 1; $week_days_html = &get_days_of_week_html($day_font_size, $short_flag); print $week_days_html; print ""; print ""; $formatted_string = sprintf("%02d-%02d-%04d",$save_g_mon,1,$save_g_year); $goto_seconds = &get_week_seconds($formatted_string); # MM-DD-YYYY $week_name = &get_week_name($goto_seconds); $file_name = $data_directory . $week_name . ".txt"; $line_index = 0; @reservation_data = &get_reservation_data_file($file_name); for ($index=1; $index<32; $index++) { if ($first_time eq "T") { if ($settings[6] =~ /SUN/i) { $start_day_modifier=1; } else { $start_day_modifier=0; } if ( ($col_index == ($g_wday + $start_day_modifier)) || (($col_index==7) && (($g_wday + $start_day_modifier)==0)) ) # fix 3.22 Monday start day problem { if ($#reservation_data > 0) { while ((!($reservation_data[$line_index] =~ /^#$col_index/i)) && ($line_index <= $#reservation_data)) { $line_index++; } $found = 0; $save_line = ""; while ((!($reservation_data[$line_index] =~ /^#END/i)) && ($line_index <= $#reservation_data)) { @key_value_pairs = split (/\|/, $reservation_data[$line_index]); $current_resource_key = $key_value_pairs[0]; if (int($current_resource_key) == int($resource_key)) { if (&check_real_reservation($reservation_data[$line_index])) { $save_line = $reservation_data[$line_index]; $line_index = $#reservation_data; # will force us to exit the while loop $found = 1; } } $line_index++; } $td_html = &get_monthly_calendar_cell_html($cumulative_seconds, $week_name, $resource_key, $col_index, $index, $found, $save_line, $category_key, $username, $password); } else { $td_html = &get_monthly_calendar_cell_html($cumulative_seconds, $week_name, $resource_key, $col_index, $index, 0, "", $category_key, $username, $password); } print $td_html; $first_time = "F"; $cumulative_seconds += $SECONDS_PER_DAY; } else { print ""; if ($col_index == 7) { print ""; print ""; $col_index = 1; $formatted_string = sprintf("%02d-%02d-%04d",$save_g_mon,($index+1),$save_g_year); $goto_seconds = &get_week_seconds($formatted_string); # MM-DD-YYYY $week_name = &get_week_name($goto_seconds); $file_name = $data_directory . $week_name . ".txt"; @reservation_data = &get_reservation_data_file($file_name); @resources = &get_resources($view_category, $seconds_date); } else { $col_index++; } } # end for loop if (($col_index < 7) && ($col_index != 1)) { while ($col_index <= 7) { print ""; $col_index++; } } print ""; print "
"; $settings[29] = &strip_letters($settings[29]); $settings[29] += 1; print ""; $settings[29] -= 1; print "$resource_name
$month_names[$g_mon] $g_year
"; print "
"; print " "; $index--; } } else { $line_index = 0; if ($#reservation_data > 0) { while ((!($reservation_data[$line_index] =~ /^#$col_index/i)) && ($line_index <= $#reservation_data)) { $line_index++; } $found =0; $save_line = ""; while ((!($reservation_data[$line_index] =~ /^#END/i)) && ($line_index <= $#reservation_data)) { @key_value_pairs = split (/\|/, $reservation_data[$line_index]); $current_resource_key = $key_value_pairs[0]; if (int($current_resource_key) == int($resource_key)) { if (&check_real_reservation($reservation_data[$line_index])) { $save_line = $reservation_data[$line_index]; $line_index = $#reservation_data; # will force us to exit the while loop $found = 1; } } $line_index++; } $td_html = &get_monthly_calendar_cell_html($cumulative_seconds, $week_name, $resource_key, $col_index, $index, $found, $save_line, $category_key, $username, $password); } else { $td_html = &get_monthly_calendar_cell_html($cumulative_seconds, $week_name, $resource_key, $col_index, $index, 0, "", $category_key, $username, $password); } print $td_html; $cumulative_seconds += $SECONDS_PER_DAY; &analyze_seconds($cumulative_seconds); if ($g_mon ne $save_g_mon) { $index = 32; } } print ""; print "
"; print " $col_index
"; print "
"; print "$settings[57]"; print "


"; $current_seconds += ($SECONDS_PER_DAY + 10); print "
"; if (($settings[146] =~ /BOTTOM/i) || ($settings[146] =~ /BOTH/i )) { &print_navigation_buttons( "MONTHLY", $week_name, $cumulative_seconds, 0, 0, $g_mon_for_nav_buttons, $g_year_for_nav_buttons, $view_category); } } # end resource loop } # end else if there are no resources else { print "
"; print "

There are currently no resources to schedule in this category.



"; } &print_optional_links("BOTTOM", $view_category, "MONTHLY", $seconds_date); print "
"; print "$website"; print ""; exit; } sub get_monthly_calendar_cell_html { local ($cumulative_seconds, $week_name, $resource_name, $col_index, $index, $found, $save_line, $category_key, $username, $password) = @_; local ($cell_html, $blackout_status, $field1, $pending_status, $this_timeslot_seconds, $i, $looper, $resv_start, $resv_stop, $num_available_timeslots, $num_blackout_timeslots, @key_value_pairs ); $cell_html = ""; $looper = &get_looper(); $num_available_timeslots = 0; $num_blackout_timeslots = 0; @blackout_timeslots = &get_blackout_timeslots($resource_key, $cumulative_seconds, $col_index); $blackout_status = $blackout_timeslots[0]; if (($settings[7] =~ /NO/i) && ( ($col_index == 1) || ($col_index == 7)) && ($settings[6] =~ /SUN/i)) { $cell_html .= ""; $cell_html .= ""; $cell_html .= "$index"; } elsif (($settings[7] =~ /NO/i) && ( ($col_index == 6) || ($col_index == 7)) && ($settings[6] =~ /MON/i)) { $cell_html .= ""; $cell_html .= ""; $cell_html .= "$index"; } elsif ($blackout_status == -1) # this is an all-day blackout { $cell_html .= ""; $cell_html .= ""; $cell_html .= "$index"; } else # allow weekend reservations { if ($found == 1) { $num_reservations = 0; $total_reserved_and_pending_slots = 0; if ($save_line =~ /\S/) { @key_value_pairs = split (/\|/, $save_line); for ($data_index = 1; $data_index < $#key_value_pairs; $data_index += 25) { $field1 = $key_value_pairs[$data_index]; $pending_status = &check_pending_field($field1); $resv_start = $key_value_pairs[$data_index + 5]; $resv_stop = $key_value_pairs[$data_index + 6]; if ($pending_status != 1) { $num_reservations++; } $total_reserved_and_pending_slots += (($resv_stop - $resv_start) * (1/ $looper)); # fix 4.0 } } $num_available_timeslots = (($gtime_range_stop - $gtime_range_start) * (1 / $looper)); # fix 4.0 if ($settings[82] =~ /YES/i) # if only show full days (no open timeslots), display differently { if (($total_reserved_and_pending_slots + $blackout_status) < $num_available_timeslots) { $cell_html .= ""; $cell_html .= ""; $cell_html .= "$index"; } else { if ($settings[88] =~ /\S/) # if a monthly reserved image was specified, show it { $cell_html .= ""; $cell_html .= ""; $cell_html .= "$index"; $cell_html .= "
\"$settings[89]\"
"; } else # otherwise just show the cell in the reserved color if all timeslots taken { $cell_html .= ""; $cell_html .= ""; $cell_html .= "$index"; } } } elsif ($num_reservations > 0) # if there is one reservation, we cant show the pending color { if ($total_reserved_and_pending_slots >= $num_available_timeslots) # all reservations are full on this day { if ($settings[92] =~ /\S/) # if a monthly full day reserved image was specified, show it { $cell_html .= ""; $cell_html .= ""; $cell_html .= "$index"; $cell_html .= "
\"$settings[93]\"
"; } elsif ($settings[88] =~ /\S/) # if a monthly reserved image was specified, show it { $cell_html .= ""; $cell_html .= ""; $cell_html .= "$index"; $cell_html .= "
\"$settings[89]\"
"; } else { $cell_html .= ""; $cell_html .= ""; $cell_html .= "$index"; } } elsif ($settings[88] =~ /\S/) # if a monthly reserved image was specified, show it { $cell_html .= ""; $cell_html .= ""; $cell_html .= "$index"; $cell_html .= "
\"$settings[89]\"
"; } else { $cell_html .= ""; $cell_html .= ""; $cell_html .= "$index"; } } else # show the pending color { if ($settings[90] =~ /\S/) # if a monthly pending image was specified, show it { $cell_html .= ""; $cell_html .= ""; $cell_html .= "$index"; $cell_html .= "
\"$settings[91]\"
"; } else { $cell_html .= ""; $cell_html .= ""; $cell_html .= "$index"; } } } else { $cell_html .= ""; $cell_html .= ""; $cell_html .= "$index"; } } return $cell_html; } sub get_time_header_html { local ( $index, $temp_string, $temp_cols, $col_width, $time_header_html); $time_header_html = ""; $col_width = $settings[34]; if ((!($settings[34] =~ /\S/)) || ($settings[34] < 1)) { $col_width = "20"; # default to the daily/weekly cell width } if ($settings[0] eq "10") { $col_width = $col_width * 6; # 10 min version } elsif ($settings[0] eq "15") { $col_width = $col_width * 4; # 15 min version } elsif ($settings[0] eq "60") { $col_width = $col_width * 1; # 60 min version } else { $col_width = $col_width * 2; # default to 30 min version } for ($index = $gtime_range_start; $index < $gtime_range_stop; $index++) { if ($settings[0] eq "10") { $time_header_html .= ""; # 10 min version } elsif ($settings[0] eq "15") { $time_header_html .= ""; # 15 min version } elsif ($settings[0] eq "60") { $time_header_html .= ""; # 60 min version } else { $time_header_html .= ""; # default to 30 min version } $time_header_html .= ""; if ($settings[8] =~ /MIL/i) { if ($index > 23) # MOD { # MOD $temp_string = sprintf("%02d:00",$index - 24); # MOD } # MOD else # MOD { # MOD $temp_string = sprintf("%02d:00",$index); # MOD } # MOD } else { if ($index > 24) # MOD { # MOD $temp_string = sprintf("%02d:00",($index - 24)); # MOD } # MOD elsif ($index > 12) # MOD { $temp_string = sprintf("%02d:00",($index - 12)); } elsif ($index > 0) { $temp_string = sprintf("%02d:00",$index); } else { $temp_string = "12:00"; } } $time_header_html .= $temp_string; $time_header_html .= ""; $time_header_html .= ""; } return $time_header_html; } sub get_config_header_html { local ( $index, $col_width, $config_header_html); $config_header_html = ""; $col_width = $settings[34]; if ((!($settings[34] =~ /\S/)) || ($settings[34] < 1)) { $col_width = "20"; # default to the daily/weekly cell width } for ($index = $gtime_range_start; $index < $gtime_range_stop; $index++) { $config_header_html .= ""; $config_header_html .= ""; $config_header_html .= "$column_names[$index]"; $config_header_html .= ""; } return $config_header_html; } sub get_week_name { local ($number_of_seconds) = @_; local ($formatted_string, $sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst, $desday); if ($number_of_seconds <= $SECONDS_PER_DAY) { $number_of_seconds = time; } ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($number_of_seconds); if ($settings[6] =~ /SUN/i) { $desday = 0; } else { $desday = 1; } while ($wday != $desday) { $number_of_seconds -= $SECONDS_PER_DAY; ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($number_of_seconds); } $mon += 1; $year += 1900; $formatted_string = sprintf("%02d-%02d-%04d",$mon,$mday,$year); return $formatted_string; } sub make_date_YYYYMMDD { local ($date_string) = @_; local ($formatted_string); if ($settings[5] =~ /US/i) { $formatted_string = sprintf("%04d%02d%02d",substr($date_string,6,4),substr($date_string,0,2),substr($date_string,3,2)); } else { $formatted_string = sprintf("%04d%02d%02d",substr($date_string,6,4),substr($date_string,3,2),substr($date_string,0,2)); } return $formatted_string; } sub make_US_date_YYYYMMDD { local ($date_string) = @_; local ($formatted_string); $formatted_string = sprintf("%04d%02d%02d",substr($date_string,6,4),substr($date_string,0,2),substr($date_string,3,2)); return $formatted_string; } sub make_date_DDMMYYYY { local ($date_string) = @_; local ($formatted_string); if ($settings[5] =~ /US/i) { $formatted_string = sprintf("%02d/%02d/%04d",substr($date_string,0,2),substr($date_string,3,2),substr($date_string,6,4)); } else { $formatted_string = sprintf("%02d/%02d/%04d",substr($date_string,3,2),substr($date_string,0,2),substr($date_string,6,4)); } return $formatted_string; } sub add_escapes { local ($user_string) = @_; local ($formatted_string); $formatted_string = $user_string; $formatted_string =~ s/\(/\\(/g; # escape a left parenthesis $formatted_string =~ s/\)/\\)/g; # escape a right parenthesis $formatted_string =~ s/\{/\\{/g; # escape a left brace { $formatted_string =~ s/\}/\\}/g; # escape a right brace } $formatted_string =~ s/\!/\\!/g; # escape a ! $formatted_string =~ s/\@/\\@/g; # escape a @ $formatted_string =~ s/\%/\\%/g; # escape a % $formatted_string =~ s/\*/\\*/g; # escape a * $formatted_string =~ s/\&/\\&/g; # escape a & return $formatted_string; } sub remove_escapes { local ($user_string) = @_; local ($formatted_string); $formatted_string = $user_string; $formatted_string =~ s/\\\(/(/g; # escape a left parenthesis $formatted_string =~ s/\\\)/)/g; # escape a right parenthesis $formatted_string =~ s/\\\{/{/g; # escape a left brace { $formatted_string =~ s/\\\}/}/g; # escape a right brace } $formatted_string =~ s/\\\!/!/g; # escape a ! $formatted_string =~ s/\\\@/@/g; # escape a @ $formatted_string =~ s/\\\%/%/g; # escape a % $formatted_string =~ s/\\\*/*/g; # escape a * $formatted_string =~ s/\\\&/&/g; # escape a & return $formatted_string; } sub make_blackout_data_line { local ($resource_key, $start_seconds, $end_seconds, $start_time, $end_time, $days_list) = @_; local ($resource_name, $data_line, $start_date, $end_date, $days_formatted, $sday, $eday); $data_line = ""; $days_formatted = ""; $start_date = &get_exact_date($start_seconds); $end_date = &get_exact_date($end_seconds); $start_date = make_date_DDMMYYYY($start_date); $end_date = make_date_DDMMYYYY($end_date); $resource_name = &get_resource_name($resource_key); if ($settings[0] eq "CONFIG") { $start_time_formatted = $column_names[$start_time]; $end_time_formatted = $column_names[$end_time]; } else { $start_time_formatted = &format_time($start_time); $end_time_formatted = &format_time($end_time); } if (($start_seconds > 0) && ($end_seconds > 0)) { if ($settings[0] eq "CONFIG") { $data_line = sprintf("%s from %s to %s %s until %s",$resource_name,$start_date,$end_date,$start_time_formatted,$end_time_formatted); } else { $data_line = sprintf("%s from %s %s to %s %s",$resource_name,$start_date,$start_time_formatted,$end_date,$end_time_formatted); } } else { $sday = 1; $eday = 7; for ($day_index = $sday; $day_index <= $eday; $day_index++) { if ($days_list =~ $day_index) { if ($days_formatted =~ /\S/) { $days_formatted .= ", "; } if ($settings[6] =~ /SUN/i) { $days_formatted .= $sun_days_short[$day_index]; } else { $days_formatted .= $mon_days_short[$day_index]; } } } if ($settings[0] eq "CONFIG") { $data_line = sprintf("%s on %s from %s until %s",$resource_name,$days_formatted,$start_time_formatted,$end_time_formatted); } else { $data_line = sprintf("%s on %s from %s to %s",$resource_name,$days_formatted,$start_time_formatted,$end_time_formatted); } } return $data_line; } sub check_blackout_day { local ($resource_key, $start_date_seconds, $day_of_week) = @_; local ($blackout_status, $blackout_index, $current_resource_name, @blackout_dates, @key_value_pairs); $blackout_status = 0; if (-e $gblackout_dates_file) { open (BLACKOUT_FILE, $gblackout_dates_file) || &return_error("File Error","Unable to open " . $gblackout_dates_file); @blackout_dates = ; close(BLACKOUT_FILE); for ($blackout_index = 0; $blackout_index <= $#blackout_dates; $blackout_index++) { @key_value_pairs = split (/\|/, $blackout_dates[$blackout_index]); $current_resource_key = $key_value_pairs[0]; if (int($current_resource_key) == int($resource_key)) { if (($key_value_pairs[1] > 0) && ($key_value_pairs[2] > 0)) { } else { if ((&compare_eq($key_value_pairs[3], $gtime_range_start)) && (&compare_eq($key_value_pairs[4], $gtime_range_stop))) # v3.25 fix { if ($key_value_pairs[5] =~ /$day_of_week/g) { $blackout_status = 1; } } } } } } else { } return $blackout_status; } # end check_blackout_day sub get_blackout_timeslots { local ($resource_key, $start_date_seconds, $day_of_week) = @_; local ( $i, $looper, $index, $blackout_file_index, $array_size, $blackout_timeslots_index, $current_resource_name, $start_date, $end_date, $current_date, $timeslot, @blackout_dates, @blackout_timeslots, @sorted_blackout_timeslots, @key_value_pairs, @timeslots_to_sort); $blackout_timeslots[0] = 0; $i = 1; if (-e $gblackout_dates_file) { open (BLACKOUT_FILE, $gblackout_dates_file) || &return_error("File Error","Unable to open " . $gblackout_dates_file); @blackout_dates = ; close(BLACKOUT_FILE); $looper = &get_looper(); for ($blackout_file_index = 0; $blackout_file_index <= $#blackout_dates; $blackout_file_index++) { @key_value_pairs = split (/\|/, $blackout_dates[$blackout_file_index]); $current_resource_key = $key_value_pairs[0]; if (int($current_resource_key) == int($resource_key)) { if (($key_value_pairs[1] > 0) && ($key_value_pairs[2] > 0)) { $current_date = &get_exact_date($start_date_seconds); # Will return the date in the format MM/DD/YYYY or DD/MM/YYYY $current_date = &make_date_YYYYMMDD($current_date); # considers euro vs US $start_date = &get_exact_date($key_value_pairs[1]); # Will return the date in the format MM/DD/YYYY or DD/MM/YYYY $start_date = &make_date_YYYYMMDD($start_date); # considers euro vs US $end_date = &get_exact_date($key_value_pairs[2]); # Will return the date in the format MM/DD/YYYY or DD/MM/YYYY $end_date = &make_date_YYYYMMDD($end_date); # considers euro vs US if (($current_date >= $start_date) && ($current_date <= $end_date)) { if ((&compare_eq($key_value_pairs[3], $gtime_range_start)) && (&compare_eq($key_value_pairs[4], $gtime_range_stop))) # v3.25 fix { $blackout_timeslots[0] = -1; # set the whole day as blackout color $blackout_file_index = ($#blackout_dates + 1); # force exit loop } else { for ($index = $key_value_pairs[3]; (sprintf('%2.3f',$index)) < (sprintf('%2.3f',$key_value_pairs[4])); $index += $looper) # fix v4.0 { $blackout_timeslots[$i] = $index; $i++; } $blackout_timeslots[0] = ($i - 1); #capture number of array elements } } else { } } else { if ((&compare_eq($key_value_pairs[3], $gtime_range_start)) && (&compare_eq($key_value_pairs[4], $gtime_range_stop))) # v3.24 fix { if ($key_value_pairs[5] =~ /$day_of_week/g) { $blackout_timeslots[0] = -1; $blackout_file_index = ($#blackout_dates + 1); } } else { if ($key_value_pairs[5] =~ /$day_of_week/g) { if ($settings[0] eq "CONFIG") { for ($index = $key_value_pairs[3]; $index <= $key_value_pairs[4]; $index += $looper) { $blackout_timeslots[$i] = $index; $i++; } } else { for ($index = $key_value_pairs[3]; (sprintf('%2.3f',$index)) < (sprintf('%2.3f',$key_value_pairs[4])); $index += $looper) # fix v4.0 { $blackout_timeslots[$i] = $index; $i++; } } $blackout_timeslots[0] = ($i - 1); #capture number of array elements } } } } } } else { $blackout_timeslots[0] = 0; } if ($blackout_timeslots[0] > 1) { $array_size = $blackout_timeslots[0]; $blackout_timeslots[0] *= -1; @timeslots_to_sort = sort {$a <=> $b} @blackout_timeslots; $j=1; for ($i=1; $i < $array_size; $i++) { if ($timeslots_to_sort[$i] == $timeslots_to_sort[$i+1]) { } else { $sorted_blackout_timeslots[$j] = $timeslots_to_sort[$i]; $j++; } } if ($timeslots_to_sort[$i] != $timeslots_to_sort[$i-1]) { $sorted_blackout_timeslots[$j] = $timeslots_to_sort[$i]; $j++; } $sorted_blackout_timeslots[0] = --$j; return @sorted_blackout_timeslots; } else { return @blackout_timeslots; } } # end get_blackout_timeslots() sub get_exact_date { local ($number_of_seconds) = @_; local ($formatted_string, $sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst); if ($number_of_seconds <= $SECONDS_PER_DAY) { $number_of_seconds = time; } ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($number_of_seconds); $mon += 1; $year += 1900; if ($settings[5] =~ /US/i) { $formatted_string = sprintf("%02d/%02d/%04d",$mon,$mday,$year); } else { $formatted_string = sprintf("%02d/%02d/%04d",$mday,$mon,$year); } return $formatted_string; } sub get_week_seconds { local ($week_string) = @_; local ($formatted_string, @key_value_pairs, $desired_mon, $desired_mday, $desired_year, $sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst, $current_seconds); @key_value_pairs = split (/-/, $week_string); $desired_mon = $key_value_pairs[0]; $desired_mday = $key_value_pairs[1]; $desired_year = $key_value_pairs[2]; $current_seconds = time; ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($current_seconds); $mon += 1; $year += 1900; while ($desired_year != $year) { if ($desired_year > $year) { $current_seconds += $SECONDS_PER_YEAR; } else { $current_seconds -= ($SECONDS_PER_YEAR * 2); } ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($current_seconds); $mon += 1; $year += 1900; } $current_seconds -= $SECONDS_PER_YEAR; ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($current_seconds); $mon += 1; $year += 1900; while ((!(($desired_year == $year) && ($desired_mon == $mon) && ($desired_mday == $mday))) && ($desired_year >= $year)) { $current_seconds += $SECONDS_PER_DAY; ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($current_seconds); $mon += 1; $year += 1900; } return $current_seconds; } sub get_midnite_seconds { local ($now_seconds, $week_string, $seconds_past_midnite) = @_; local ($formatted_string, @key_value_pairs, $desired_mon, $desired_mday, $desired_year, $sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst); if ($now_seconds <= $SECONDS_PER_DAY) { $now_seconds = time; } @key_value_pairs = split (/-/, $week_string); $desired_mon = $key_value_pairs[0]; $desired_mday = $key_value_pairs[1]; $desired_year = $key_value_pairs[2]; ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($now_seconds); $mon += 1; $year += 1900; while ($desired_year != $year) { if ($desired_year > $year) { $now_seconds += $SECONDS_PER_YEAR; } else { $now_seconds -= ($SECONDS_PER_YEAR * 2); } ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($now_seconds); $mon += 1; $year += 1900; } $now_seconds -= $SECONDS_PER_YEAR; ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($now_seconds); $mon += 1; $year += 1900; while ((!(($desired_year == $year) && ($desired_mon == $mon) && ($desired_mday == $mday))) && ($desired_year >= $year)) { $now_seconds += $SECONDS_PER_DAY; ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($now_seconds); $mon += 1; $year += 1900; } $now_seconds -= $seconds_past_midnite; ($sec2,$min2,$hour2,$mday2,$mon2,$year2,$wday2,$yday2,$isdst2) = gmtime($now_seconds); $gm_offset = $hour2 - $hour; $now_seconds += ($gm_offset * 3600); return $now_seconds; } sub get_date_seconds { local ($date_string) = @_; local ($formatted_string, @key_pairs, $desired_mon, $desired_mday, $desired_year, $sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst, $current_seconds, $num_slashes); $num_slashes = ($date_string =~ tr/\///); if ($num_slashes == 2) { @key_pairs = split (/\//, $date_string); if ($settings[5] =~ /US/i) { $desired_mon = $key_pairs[0]; $desired_mday = $key_pairs[1]; } else { $desired_mon = $key_pairs[1]; $desired_mday = $key_pairs[0]; } $desired_year = $key_pairs[2]; $desired_mon = &strip_letters($desired_mon); $desired_mday = &strip_letters($desired_mday); $desired_year = &strip_letters($desired_year); if (($desired_year > 2100) || ($desired_year < 1972)) { &missing_input("Invalid Year","Please enter a year between 1972 and 2100"); } if (!( (($desired_mon > 0) && ($desired_mon < 13)) && (($desired_mday > 0) && ($desired_mday < 32)) && (($desired_year > 1971) && ($desired_year < 2100)) )) { if ($settings[5] =~ /US/i) { &missing_input("Invalid Date Format ($date_string)","Please enter the date in the format MM/DD/YYYY."); } else { &missing_input("Invalid Date Format ($date_string)","Please enter the date in the format DD/MM/YYYY."); } } } else { if ($settings[5] =~ /US/i) { &missing_input("Invalid Date Format ($date_string)","Please enter the date in the format MM/DD/YYYY."); } else { &missing_input("Invalid Date Format ($date_string)","Please enter the date in the format DD/MM/YYYY."); } } $current_seconds = time; ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($current_seconds); $mon += 1; $year += 1900; while ($desired_year != $year) { if ($desired_year > $year) { $current_seconds += $SECONDS_PER_YEAR; } else { $current_seconds -= ($SECONDS_PER_YEAR * 2); } ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($current_seconds); $mon += 1; $year += 1900; } $current_seconds -= $SECONDS_PER_YEAR; ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($current_seconds); $mon += 1; $year += 1900; while ((!(($desired_year == $year) && ($desired_mon == $mon) && ($desired_mday == $mday))) && ($desired_year >= $year)) { $current_seconds += $SECONDS_PER_DAY; ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($current_seconds); $mon += 1; $year += 1900; } return $current_seconds; } sub get_column_multiplier { local ($column_multiplier); $column_multiplier = 1; if (($settings[0] eq "CONFIG") || ($settings[0] eq "60")) { $column_multiplier = 1; # 60 min version or config columns version } elsif ($settings[0] eq "10") { $column_multiplier = 6; # 10 min version } elsif ($settings[0] eq "15") { $column_multiplier = 4; # 15 min version } else { $column_multiplier = 2; # default to 30 min version } return $column_multiplier; } sub get_open_time_selections { local ( $week_name, $day_index, $resource_key, $cur_begin_time, $cur_end_time) = @_; local ( $temp_float, $float_increment, $time_selections_html, $start_time_selections, $end_time_selections, $seconds_date); if ($settings[0] eq "CONFIG") { $gtime_range_start = 0; $gtime_range_stop = $#column_names; } $start_time = $gtime_range_start; $end_time = $gtime_range_stop; $time_selections_html = ""; $start_time_selections = ""; $end_time_selections = ""; $temp_float = $start_time; $float_increment = &get_looper(); # get float increment $seconds_date = &get_week_seconds($week_name); if ($day_index > 1) { $seconds_date += ($SECONDS_PER_DAY*($day_index-1)); } @blackout_timeslots = &get_blackout_timeslots($resource_key, $seconds_date, $day_index); $blackout_status = $blackout_timeslots[0]; while ($temp_float < $end_time) { $found = 0; if ($blackout_timeslots[0] > 0 ) { for ($index=1; $index <= $blackout_timeslots[0]; $index++) { if (&compare_eq($temp_float, $blackout_timeslots[$index])) # v3.25 fix { $found = 1; } } } if ($found == 0) { if ($settings[0] eq "CONFIG") { $temp_string = $column_names[$temp_float]; } else { $temp_string = &format_time($temp_float); } if ( ($cur_begin_time > 0) && (&compare_eq($cur_begin_time, $temp_float)) ) # v3.25 fix { $start_time_selections .= ""; } else { $start_time_selections .= ""; } $temp_val = $temp_float + $float_increment; if ($settings[0] eq "CONFIG") { $temp_string = $column_names[$temp_val]; } else { $temp_string = &format_time($temp_val); } if ( ($cur_end_time > 0) && (&compare_eq($cur_end_time, $temp_val)) ) # v3.25 fix { $end_time_selections .= ""; } else { $end_time_selections .= ""; } } $temp_float += $float_increment; } $time_selections_html .= $settings[98]; #"From: "; $time_selections_html .= " "; $time_selections_html .= "  "; $time_selections_html .= $settings[99]; $time_selections_html .= " "; return $time_selections_html; } # end get_open_time_selections() sub get_fixed_open_time_selections { local ( $week_name, $day_index, $resource_key, $fixed_hours, $fixed_minutes, $cur_begin_time, $cur_end_time) = @_; local ( $temp_float, $float_increment, $time_selections_html, $start_time_selections, $end_time_selections, $seconds_date, $start_time_label, $end_time_label, $fixed_time_label); if ($settings[0] eq "CONFIG") { $gtime_range_start = 0; $gtime_range_stop = $#column_names; } $start_time = $gtime_range_start; $end_time = $gtime_range_stop; $time_selections_html = ""; $start_time_selections = ""; $end_time_selections = ""; $start_time_label = $settings[98]; $end_time_label = $settings[99]; $fixed_time_label = $settings[100]; $temp_float = $start_time; $float_increment = &get_looper(); # get float increment $seconds_date = &get_week_seconds($week_name); if ($day_index > 1) { $seconds_date += ($SECONDS_PER_DAY*($day_index-1)); } if ($fixed_minutes == 10) { $fixed_minutes = 0.1666666666667; } elsif ($fixed_minutes == 15) { $fixed_minutes = 0.25; } elsif ($fixed_minutes == 30) { $fixed_minutes = 0.5; } elsif ($fixed_minutes == 45) { $fixed_minutes = 0.75; } $fixed_res_size = $fixed_hours + $fixed_minutes; @blackout_timeslots = &get_blackout_timeslots($resource_key, $seconds_date, $day_index); $blackout_status = $blackout_timeslots[0]; while (($temp_float + $fixed_res_size) <= $end_time) { $found = 0; if ($blackout_timeslots[0] > 0 ) { for ($j = 0; $j < $fixed_res_size; $j+=$float_increment) { for ($index=1; $index <= $blackout_timeslots[0]; $index++) { if (&compare_eq(($temp_float + $j), $blackout_timeslots[$index])) # v4.0 fix { $found = 1; } } } } if ($found == 0) { $end_float = $temp_float; $end_float = $temp_float + $fixed_res_size; if ($settings[0] eq "CONFIG") { $start_string = $column_names[$temp_float]; $end_string = $column_names[$end_float]; } else { $start_string = &format_time($temp_float); $end_string = &format_time($end_float); } $temp_val = $temp_float . "?" . $end_float; if (($cur_begin_time > 0) && ($cur_begin_time == $temp_val)) { if ($settings[0] eq "CONFIG") { if ($fixed_res_size == 1) { $start_time_selections .= ""; } else { $start_time_selections .= ""; } } else { $start_time_selections .= ""; } } else { if ($settings[0] eq "CONFIG") { if ($fixed_res_size == 1) { $start_time_selections .= ""; } else { $start_time_selections .= ""; } } else { $start_time_selections .= ""; } } } else # FIX 3.24 { $temp_float = $temp_float + $float_increment; } if ($found == 1) { } else { $temp_float += $fixed_res_size; } # END FIX 3.24 } $time_selections_html .= &get_fixed_time_label(); # "Time: "; # v4.0 $time_selections_html .= " "; return $time_selections_html; } # end get_fixed_open_time_selections() sub get_report_time_selections { local ( $start_time, $end_time) = @_; local ( $temp_float, $float_increment, $time_selections_html, $start_time_selections, $end_time_selections, $seconds_date); $time_selections_html = ""; $start_time_selections = ""; $end_time_selections = ""; $temp_float = $start_time; $float_increment = &get_looper(); # get float increment while (&compare_lt($temp_float, $end_time)) { if ($settings[0] eq "CONFIG") { $temp_string = $column_names[$temp_float]; } else { $temp_string = &format_time($temp_float); } $start_time_selections .= ""; $temp_val = $temp_float + $float_increment; if ($settings[0] eq "CONFIG") { $temp_string = $column_names[$temp_val]; } else { $temp_string = &format_time($temp_val); } $end_time_selections .= ""; $temp_float += $float_increment; } $time_selections_html .= "From: "; $time_selections_html .= ""; $time_selections_html .= "  "; if ($settings[0] eq "CONFIG") { $time_selections_html .= "Until: "; } else { $time_selections_html .= "To: "; } $time_selections_html .= ""; return $time_selections_html; } # end get_report_time_selections() sub get_time_selections_daily { local ( $res_start_date, $res_end_date) = @_; local ( $recurring_start_seconds, $recurring_end_seconds, $num_days, $full_num, $time_selections_html, $example); if ($settings[5] =~ /US/i) { $example = "MM/DD/YYYY"; } else { $example = "DD/MM/YYYY"; } if ($settings[102] =~ /\S/) { $time_selections_html = "$settings[102]: "; # i.e. "Start Date: "; } else { $time_selections_html = "Start Date: "; # default } $time_selections_html .= "   "; $time_selections_html .= $example; $time_selections_html .= "
"; if ($settings[101] =~ /\S/) { $time_selections_html .= "$settings[101]: "; # i.e. "Number of Nights: "; } else { $time_selections_html = "Number of Nights: "; # default } $num_days = 0; $full_num = 0.0; $recurring_start_seconds = &get_date_seconds($res_start_date); if ($res_end_date ne "0") { $recurring_end_seconds = &get_date_seconds($res_end_date); $num_days = int(($recurring_end_seconds - $recurring_start_seconds) / $SECONDS_PER_DAY); $full_num = ($recurring_end_seconds - $recurring_start_seconds) / $SECONDS_PER_DAY; if (($full_num - $num_days) > 0) { $num_days++; } } if ($num_days == 0) { $time_selections_html .= " "; } else { $time_selections_html .= " "; } return $time_selections_html; } # end get_time_selections_daily() sub get_time_selections_date_range { local ( $res_start_date, $res_end_date) = @_; local ( $time_selections_html, $example); if ($settings[5] =~ /US/i) { $example = "MM/DD/YYYY"; } else { $example = "DD/MM/YYYY"; } if ($settings[102] =~ /\S/) { $time_selections_html = "$settings[102]: "; # i.e. "Start Date: "; } else { $time_selections_html = "Start Date: "; # default } $time_selections_html .= "   "; $time_selections_html .= $example; $time_selections_html .= "
"; if ($settings[103] =~ /\S/) { $time_selections_html .= "$settings[103]: "; # i.e. "End Date: "; } else { $time_selections_html .= "End Date: "; # default } if ($res_end_date eq "0") { $time_selections_html .= "   "; } else { $time_selections_html .= "   "; } $time_selections_html .= $example; return $time_selections_html; } # end get_time_selections_date_range() sub create_add_reservation_form { local ( $resource_key, $resource_name, $week_name, $day_index, $days_seconds, $resource_field1, $resource_field2, $resource_field3, $resource_field4, $resource_field5, $resv_form_username, $resv_form_password, $resv_form_recurring, $resource_image, $permission_level, $line, $i, $reservation_form_field, $field_count, $field_name, $field_name_prefix, $found_flag, $date_string, $temp_float, $float_increment, $time_selections, $first_time, $options_list, $lead_days, $lead_hours, $lead_minutes, $min_daily_recur, $max_daily_recur, $min_weekly_recur, $max_weekly_recur, $min_biweekly_recur, $max_biweekly_recur, $min_monthly_recur, $max_monthly_recur, @key_value_pairs, @resource_value_pairs, @options_list_values, @fields); &validate_referral_page($script_url); $resource_name = ""; $resource_field2 = ""; $resource_field3 = ""; $resource_field4 = ""; $resource_field5 = ""; $resource_key = $form_text{'resource_key'}; $resource_name = &get_resource_name($resource_key); $week_name = $form_text{'week'}; $day_index = $form_text{'day'}; $days_seconds = $form_text{'seconds'}; $empty_flag = ""; $empty_flag = $form_text{'empty'}; # if this is set to 1, then we are adding the first reservation for this day! $found_flag = 0; $date_string = &get_exact_date($days_seconds); $resv_form_username = ""; $resv_form_password = ""; $resv_form_recurring = ""; $resource_image = ""; $resource_settings = &get_resource_settings($resource_key); @resource_value_pairs = split (/\|/, $resource_settings); $resource_field2 = $resource_value_pairs[6]; $resource_field3 = $resource_value_pairs[7]; $resource_field4 = $resource_value_pairs[8]; $resource_field5 = $resource_value_pairs[9]; $resource_image = &get_resource_image(@resource_value_pairs); if (-e $reservation_fields_file) { open (FIELDS_FILE, $reservation_fields_file) || &return_error("File Error","Unable to open " . $reservation_fields_file); @fields = ; close(FIELDS_FILE); } else { &upgrade_reservation_fields_file(); &initialize_reservation_fields(); } $lead_days = &get_lead_time_create_days(@resource_value_pairs); # lead seconds create days $lead_hours = &get_lead_time_create_hours(@resource_value_pairs); # lead seconds create hours $lead_minutes = &get_lead_time_create_minutes(@resource_value_pairs); # lead seconds create minutes $expired_flag = &check_expired( $resource_key, $days_seconds, 0, $lead_days, $lead_hours, $lead_minutes, 0, $username, $password); $permission_level = &get_resource_permission_level(@resource_value_pairs); if ((int($permission_level) == 0) || (!($permission_level =~ /\S/)) ) { $permission_level = $settings[10]; # use the general settings permission level } $fixed_hours = &get_fixed_reservation_hours(@resource_value_pairs); $fixed_minutes = &get_fixed_reservation_minutes(@resource_value_pairs); print "Content-type: text/html\n\n"; print "\n"; print "\n"; print "\n\n"; print "uReserve"; print ""; print ""; print "
"; if ($resource_image =~ /\S/) { print "
"; } print ""; print "$settings[39]: $resource_name"; if ($expired_flag == 1) { print ""; print "
($lang_read_only - $lang_timeslot_passed)
"; } elsif ($expired_flag == 2) { print ""; print "
($lang_read_only - $lang_insuff_lead_time)
"; } print "

"; print ""; if ($settings[40] =~ /\S/) { print "$settings[40]: $resource_field2
"; } if ($settings[41] =~ /\S/) { print "$settings[41]: $resource_field3
"; } if ($settings[42] =~ /\S/) { print "$settings[42]: $resource_field4
"; } if ($settings[43] =~ /\S/) { print "$settings[43]: $resource_field5
"; } print "
"; print "
"; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; if ($expired_flag == 0) { print "$settings[37]

"; $gtime_range_start = &strip_letters($gtime_range_start); $gtime_range_stop = &strip_letters($gtime_range_stop); if ($settings[97] =~ /DAILY/i) { $time_selections_html = &get_time_selections_daily($date_string, 0); } elsif ($settings[97] =~ /DATE_RANGE/i) { $time_selections_html = &get_time_selections_date_range($date_string, 0); } else { print "Date: $date_string    "; if (($fixed_hours > 0) || ($fixed_minutes > 0)) { $time_selections_html = &get_fixed_open_time_selections($week_name, $day_index, $resource_key, $fixed_hours, $fixed_minutes, 0, 0); } else { $time_selections_html = &get_open_time_selections($week_name, $day_index, $resource_key, 0, 0); } } print $time_selections_html; if ((int($permission_level) != $ANY_RESERVE_NO_RECURRING) && (int($permission_level) != $AUTH_RESERVE_NO_RECURRING) && ($settings[97] =~ /STANDARD/i) ) { print "

$settings[38]

"; if ($settings[108] =~ /freeform/i) { if ($settings[109] =~ /on/i) { $min_daily_recur = int($settings[110]); $max_daily_recur = int($settings[111]); if (($min_daily_recur > 0) && ($max_daily_recur > $min_daily_recur)) { print ""; print "days ($min_daily_recur to $max_daily_recur)
"; } } if ($settings[112] =~ /on/i) { $min_weekly_recur = int($settings[113]); $max_weekly_recur = int($settings[114]); if (($min_weekly_recur > 0) && ($max_weekly_recur > $min_weekly_recur)) { print ""; print "weeks ($min_weekly_recur to $max_weekly_recur)
"; } } if ($settings[115] =~ /on/i) { $min_biweekly_recur = int($settings[116]); $max_biweekly_recur = int($settings[117]); if (($min_biweekly_recur > 0) && ($max_biweekly_recur > $min_biweekly_recur)) { print ""; print "bi-weekly ($min_biweekly_recur to $max_biweekly_recur)
"; } } if ($settings[118] =~ /on/i) { $min_monthly_recur = int($settings[119]); $max_monthly_recur = int($settings[120]); if (($min_monthly_recur > 0) && ($max_monthly_recur > $min_monthly_recur)) { print ""; print "months ($min_monthly_recur to $max_monthly_recur)
"; } } } else { print ""; } } # end if standard format print "

$settings[44]

"; print ""; $field_count = 1; for ($i=1; $i <= 22; $i++) { if ($fields[$field_count] =~ /\S/) { if (!($fields[($field_count + 1)] =~ /DISABLED/i)) { print ""; print ""; print ""; print ""; } } else { $resv_form_fields[($i)] = ""; } $field_count += 6; } print "
"; if (!($fields[($field_count + 3)] =~ /HIDELABEL/i)) { print ""; print $fields[$field_count]; print ""; } print ""; print ""; $show_reservation_form_field = &get_new_reservation_form_field($i, $field_count); print $show_reservation_form_field; print ""; print "
"; print "
"; if ($settings[127] =~ /NO/i) { if ((int($permission_level) == $ANY_RESERVE_ANY_RECURRING) || (int($permission_level) == $ANY_RESERVE_NO_RECURRING)) { print "$settings[49]"; } elsif ((int($permission_level) == $AUTH_RESERVE_AUTH_RECURRING) || (int($permission_level) == $AUTH_RESERVE_NO_RECURRING)) { print "$settings[50]"; } else { print "$settings[51]"; } } print "

"; if ($settings[127] =~ /NO/i) { print ""; if ((int($permission_level) == $ANY_RESERVE_AUTH_RECURRING) || (int($permission_level) == $AUTH_RESERVE_AUTH_RECURRING) || (int($permission_level) == $AUTH_RESERVE_NO_RECURRING)) { print ""; print ""; print ""; print ""; } print ""; print ""; print ""; print ""; print "
"; print ""; print "$lang_username: "; print ""; print ""; print ""; print ""; print ""; print "
"; print ""; print "$settings[52]: "; print ""; print ""; print ""; print ""; print ""; print "
"; } } print "
"; print "
"; if ($expired_flag == 0) { print ""; print "     "; print ""; } else { print ""; } print "
"; print "
"; print "
"; print "
"; print ""; exit; } sub reserve_resource { local ( $resource_key, $resource_name, $week_name, $day_index, $current_seconds, $res_start_time, $res_end_time, $resv_form_username, $resv_form_password, $resv_form_recurring, $fixed_hours, $fixed_minutes, $fixed_res_size, $date_string, $results, $success_list, $conflict_list, $email_message, $iterations, $full_num, $increment, $day_increment, $counter, $user_auth, $resource_settings, $max_reservation_minutes, $temp_max_reservation_minutes, $max_reservation_hours, $field_count, $field_name_prefix, $field_name, $looper, $pending_flag, $field5_recurring, $field5_recurring_start_key, $buffer_periods, $buffer_hours, $buffer_minutes, $num_successes, $monthly_recurring, $orig_date_string, $res_start_date, $save_month, $resource_end_date, $end_availability_seconds, $temp_day_index, $email_in, $email_out, $user_email, @resource_value_pairs, @resv_form_fields); &validate_referral_page($script_url); $username = $form_text{'username'}; $password = $form_text{'password'}; $resource_key = $form_text{'resource_key'}; $resource_name = &get_resource_name($resource_key); $week_name = $form_text{'week'}; $day_index = $form_text{'day'}; $day_index = &strip_letters($day_index); $current_seconds = $form_text{'seconds'}; $current_seconds = &strip_letters($current_seconds); $res_start_time = $form_text{'start_time'}; $res_end_time = $form_text{'end_time'}; $res_start_date = $form_text{'res_start_date'}; $res_end_date = $form_text{'res_end_date'}; $looper = &get_looper(); if ($settings[97] =~ /DATE_RANGE/i) { if (!($res_start_date =~ /\S/)) { &missing_input("Start Date Required","A Start Date must be specified."); } $current_seconds = &get_date_seconds($res_start_date); &analyze_seconds($current_seconds); $day_index = $g_wday; if ($settings[6] =~ /SUN/i) { $temp_day_index = $day_index + 1; } else { if ($day_index == 0) { $temp_day_index = 7; } else { $temp_day_index = $day_index; } } $day_index = $temp_day_index; $week_name = &get_week_name($current_seconds); # MM-DD-YYYY if (!($res_end_date =~ /\S/)) { &missing_input("End Date Required","An End Date must be specified."); } $res_end_seconds = &get_date_seconds($res_end_date); if ($res_end_seconds <= $current_seconds) { &missing_input("Invalid End Date","Invalid reservation date range."); } $iterations = 0; $full_num = 0.0; $iterations = int(($res_end_seconds - $current_seconds) / $SECONDS_PER_DAY); $full_num = ($res_end_seconds - $current_seconds) / $SECONDS_PER_DAY; if (($full_num - $iterations) > 0) { $iterations++; } $res_start_time = $gtime_range_start; $res_end_time = $gtime_range_stop; $day_increment = 1; } elsif ($settings[97] =~ /DAILY/i) { if (!($res_start_date =~ /\S/)) { &missing_input("Start Date Required","A Start Date must be specified."); } $current_seconds = &get_date_seconds($res_start_date); &analyze_seconds($current_seconds); $day_index = $g_wday; if ($settings[6] =~ /SUN/i) { $temp_day_index = $day_index + 1; } else { if ($day_index == 0) { $temp_day_index = 7; } else { $temp_day_index = $day_index; } } $day_index = $temp_day_index; $week_name = &get_week_name($current_seconds); # MM-DD-YYYY $res_num_days = $form_text{'res_num_days'}; if (int($res_num_days) < 1) { &missing_input("Missing Input","Number of Days/Nights must be specified."); } $res_end_seconds = $current_seconds + ($res_num_days * $SECONDS_PER_DAY); $res_end_date = &get_exact_date($res_end_seconds); $iterations = $res_num_days; $res_start_time = $gtime_range_start; $res_end_time = $gtime_range_stop; $day_increment = 1; } else { if (!($res_end_time =~ /\S/)) { @time_pairs = split (/\?/, $res_start_time); if (($time_pairs[0] > 0) && ($time_pairs[1] > 0)) { $res_start_time = $time_pairs[0]; $res_end_time = $time_pairs[1]; } elsif (($settings[0] eq "CONFIG") && ($time_pairs[0] >= 0) && ($time_pairs[1] > 0)) { $res_start_time = $time_pairs[0]; $res_end_time = $time_pairs[1]; } else { $res_start_time = &strip_letters($res_start_time); } } else { $res_start_time = &strip_letters($res_start_time); } } $orig_seconds_date = $current_seconds; $orig_date_string = &get_exact_date($orig_seconds_date); $empty_flag = ""; $empty_flag = $form_text{'empty'}; # if this is set to 1, then we are adding the first reservation for this day! $goto_month_string = sprintf("%02d/%04d",substr($orig_date_string,0,2),substr($orig_date_string,6,4)); if ($settings[127] =~ /NO/i) { $resv_form_password = $form_text{'resv_form_password'}; # password, if filled in $resv_form_field5 $resv_form_password = &validate_string($resv_form_password); $resv_form_username = $form_text{'resv_form_username'}; # username, if filled in $resv_form_field6 $resv_form_username = &validate_string($resv_form_username); } else { $resv_form_password = $password; $resv_form_username = $username; } if ($settings[148] =~ /on/) { if (!($resv_form_password =~ /\S/)) { &missing_input("Password Required","You must enter a password to protect your reservation from unauthorized changes."); } } $increment = $SECONDS_PER_DAY; if ($settings[97] =~ /STANDARD/i) { $iterations = 0; $day_increment = 0; $monthly_recurring = 0; if ($settings[108] =~ /freeform/i) { $res_num_days = $form_text{'res_num_days'}; $res_num_weeks = $form_text{'res_num_weeks'}; $res_num_biweeks = $form_text{'res_num_biweeks'}; $res_num_months = $form_text{'res_num_months'}; if ( ($settings[109] =~ /on/i) && (int($res_num_days) > 0) ) { if ( (int($res_num_days) < $settings[110]) || (int($res_num_days) > $settings[111]) ) { &missing_input("Invalid Entry","Enter number of days between $settings[110] and $settings[111]."); } $increment = $SECONDS_PER_DAY; $iterations = int($res_num_days); $day_increment = 1; } elsif ( ($settings[112] =~ /on/i) && (int($res_num_weeks) > 0) ) { if ( (int($res_num_weeks) < $settings[113]) || (int($res_num_weeks) > $settings[114]) ) { &missing_input("Invalid Entry","Enter number of weeks between $settings[113] and $settings[114]."); } $increment = $SECONDS_PER_DAY * 7; $iterations = int($res_num_weeks); } elsif ( ($settings[115] =~ /on/i) && (int($res_num_biweeks) > 0) ) { if ( (int($res_num_biweeks) < $settings[116]) || (int($res_num_biweeks) > $settings[117]) ) { &missing_input("Invalid Entry","Enter number of bi-weekly weeks between $settings[116] and $settings[117]."); } $increment = $SECONDS_PER_DAY * 14; $iterations = int($res_num_biweeks); } elsif ( ($settings[118] =~ /on/i) && (int($res_num_months) > 0) ) { if ( (int($res_num_months) < $settings[119]) || (int($res_num_months) > $settings[120]) ) { &missing_input("Invalid Entry","Enter number of months between $settings[119] and $settings[120]."); } $monthly_recurring = 1; $increment = $SECONDS_PER_DAY * 30; # just a rough estimate, used for building field5_recurring, not exact $iterations = int($res_num_months); } } else { $resv_form_recurring = $form_text{'resv_form_recurring'}; # number of occurrences of the reservation; 1 is not recurring if ($resv_form_recurring =~ /^d/) { $resv_form_recurring =~ s/d//g; $increment = $SECONDS_PER_DAY; $iterations = int($resv_form_recurring); $day_increment = 1; } elsif ($resv_form_recurring =~ /^w/) { $resv_form_recurring =~ s/w//g; $increment = $SECONDS_PER_DAY * 7; $iterations = int($resv_form_recurring); } elsif ($resv_form_recurring =~ /^b/) { $resv_form_recurring =~ s/b//g; $increment = $SECONDS_PER_DAY * 14; $iterations = int($resv_form_recurring); } elsif ($resv_form_recurring =~ /^m/) { $monthly_recurring = 1; $increment = $SECONDS_PER_DAY * 30; # just a rough estimate, used for building field5_recurring, not exact $resv_form_recurring =~ s/m//g; $iterations = int($resv_form_recurring); } } } $field_count = 1; $field_name_prefix = "resv_form_field"; for ($i=1; $i <= 22; $i++) { if ($fields[$field_count] =~ /\S/) { if (!($fields[($field_count + 1)] =~ /DISABLED/i)) { if ($fields[$field_count + 4] =~ /on/i) { $field_name = $field_name_prefix . $i; $nra = $form_text{"$field_name"}; if (!($nra =~ /\S/)) { &missing_input("Missing Input","Please enter $fields[$field_count]."); } } if ($fields[$field_count + 1] =~ /EMAIL/i) { $field_name = $field_name_prefix . $i; $email_in = $form_text{"$field_name"}; if ($email_in =~ /\S/) { $email_out = &validate_email($email_in); if (($email_in ne $email_out) || (!($email_in =~ /\@/g))) { &missing_input("E-Mail Address Invalid ($email_in)","Please enter a valid e-mail address for $fields[$field_count]."); } } } } } $field_count += 6 ; } @resv_form_fields = (); for ($i=0; $i < 22; $i++) { $x = $i + 1; $field_name = $field_name_prefix . $x; $resv_form_fields[$i] = $form_text{"$field_name"}; } $user_email = ""; $user_email = &find_user_email(@resv_form_fields); if (&check_email_blocked($user_email) == -1) { &missing_input("Reservation Denied","You have been blocked from making any reservations at this time."); } if ($res_start_time >= $res_end_time) { &missing_input("Invalid Time Range","The ending time must be greater than the starting time."); } $compliance_results = ""; # reset the compliance results $compliance_results = &check_resource_compliance("ADD", $resource_key, $resv_form_password, $resv_form_username, $iterations, $current_seconds, $res_end_time, $res_start_time, 0, 0, $username, $password); @compliance_pairs = split (/\|/, $compliance_results); if ($compliance_pairs[0] ne "NONE") # if there was a compliance violation, show the error message { &missing_input($compliance_pairs[0],$compliance_pairs[1]); #display error message and quit } $resource_settings = &get_resource_settings($resource_key); @resource_value_pairs = split (/\|/, $resource_settings); $pending_flag = &get_pending_flag(@resource_value_pairs); # on or off $buffer_periods = &get_buffer_periods_between(@resource_value_pairs); # resource buffer periods after a reservation $buffer_hours = &get_buffer_hours_between(@resource_value_pairs); # resource buffer hours after a reservation $buffer_minutes = &get_buffer_minutes_between(@resource_value_pairs); # resource buffer days after a reservation $field5_recurring = $resv_form_password . "?" . $resv_form_username; # ALWAYS print password?username to reservation file if ( ($iterations > 1) || ( ($settings[97] =~ /DAILY/i) || ($settings[97] =~ /DATE_RANGE/i) ) ) { $field5_recurring_start_key = $current_seconds + int($res_start_time); $field5_recurring .= "?" . $field5_recurring_start_key; # beginning reservation seconds } $results = ""; $email_message = ""; $prevalidate_flag = 0; if ($iterations < 1) # not a recurring reservation { &apply_reservation( $resource_key, $week_name, $day_index, $current_seconds, $res_start_time, $res_end_time, $field5_recurring, $buffer_periods, $buffer_hours, $buffer_minutes, $prevalidate_flag, @resv_form_fields); $results = &get_reservation_result( $current_seconds, $resource_key, $res_start_time, $res_end_time, 0, 0, 0, 0, # recurring_flag @resv_form_fields); $num_successes = 1; if ($pending_flag =~ /on/i) # if pending flag is set for the resource { $email_message = "The following reservation is PENDING:\n\n$results"; } else { $email_message = "The following reservation has been created:\n\n$results"; } } else { $results = ""; $success_list = ""; $conflict_list = ""; $num_successes = 0; $counter = 0; if ($monthly_recurring) { $save_month = ""; $recurring_end_seconds = $current_seconds + ($iterations * $increment); $field5_recurring .= "?" . $recurring_end_seconds; do { $date_string = &get_exact_date($current_seconds); $end_availability_seconds = 0; $resource_end_date = &get_resource_end_date(@resource_value_pairs); if ($resource_end_date =~ /\S/) { $end_availability_seconds = &get_date_seconds($resource_end_date); } if ( ($end_availability_seconds > 0) && ($current_seconds > $end_availability_seconds) ) { $conflict_list .= "$date_string ($lang_beyond_limit)
"; } else { if (1 == &apply_reservation($resource_key, # The key of the resource. $week_name, # Always in the format: MM-DD-YYYY $day_index, # Day index of week: 1 - 7 $current_seconds, # Number of seconds of this day $res_start_time, # 0 - 23.5 $res_end_time, # 0 - 23.5 $field5_recurring, # Password?Username?RecurringStartSeconds?RecurringEndSeconds $buffer_periods, $buffer_hours, $buffer_minutes, $prevalidate_flag, @resv_form_fields)) { $conflict_list .= "$date_string
"; } else { $success_list .= "$date_string
"; $num_successes++; } } if ($settings[5] =~ /US/i) { $month_day = sprintf("%02d",substr($date_string,3,2)); } else { $month_day = sprintf("%02d",substr($date_string,0,2)); } &analyze_seconds($current_seconds); $g_mon += 1; if ($g_mon > 12) { $g_mon = 1; $g_year = int($g_year) + 1; } if ($settings[5] =~ /US/i) { $next_month_date_string = sprintf("%02d/%02d/%04d",$g_mon,$month_day,$g_year); #MM/DD/YYYY } else { $next_month_date_string = sprintf("%02d/%02d/%04d",$month_day,$g_mon,$g_year); #DD/MM/YYYY } $current_seconds = &get_date_seconds($next_month_date_string); &analyze_seconds($current_seconds); $day_index = $g_wday; if ($settings[6] =~ /SUN/i) { $temp_day_index = $day_index + 1; } else { if ($day_index == 0) { $temp_day_index = 7; } else { $temp_day_index = $day_index; } } $day_index = $temp_day_index; $week_name = &get_week_name($current_seconds); $counter++; } while ($counter < $iterations); } else { $recurring_end_seconds = $current_seconds + ($iterations * $increment); $field5_recurring .= "?" . $recurring_end_seconds; do { $date_string = &get_exact_date($current_seconds); $end_availability_seconds = 0; $resource_end_date = &get_resource_end_date(@resource_value_pairs); if ($resource_end_date =~ /\S/) { $end_availability_seconds = &get_date_seconds($resource_end_date); } if ( ($end_availability_seconds > 0) && ($current_seconds > $end_availability_seconds) ) { $conflict_list .= "$date_string ($lang_beyond_limit)
"; } else { if (1 == &apply_reservation($resource_key, # The key of the resource. $week_name, # Always in the format: MM-DD-YYYY $day_index, # Day index of week: 1 - 7 $current_seconds, # Number of seconds of this day $res_start_time, # 0 - 23.5 $res_end_time, # 0 - 23.5 $field5_recurring, # Password?Username?RecurringStartSeconds?RecurringEndSeconds $buffer_periods, $buffer_hours, $buffer_minutes, $prevalidate_flag, @resv_form_fields)) { if (($settings[97] =~ /DATE_RANGE/i) || ($settings[97] =~ /DAILY/i)) { &missing_input("Schedule Conflict","There is a schedule conflict in this date range."); } else { $conflict_list .= "$date_string
"; } } else { if (($settings[97] =~ /DATE_RANGE/i) || ($settings[97] =~ /DAILY/i)) { $success_list = "$res_start_date - $res_end_date
"; } else { $success_list .= "$date_string
"; } $num_successes++; } } $current_seconds += $increment; $day_index += $day_increment; if ($day_index > 7) { $day_index -= 7; } $week_name = &get_week_name($current_seconds); $counter++; } while ($counter < $iterations); } # end if $results = &get_recurring_reservation_result($resource_key, $pending_flag, $success_list, $conflict_list, $res_start_time, $res_end_time, $res_start_date, $res_end_date, @resv_form_fields); $email_message = "$results"; } print "Content-type: text/html\n\n"; print "\n"; print "\n"; print "\n\n"; print "uReserve"; print ""; print "
"; print ""; if ($pending_flag =~ /on/i) # if pending flag is set for the resource { if ($num_successes == 0) { print "
$lang_declined_reserve_info

"; } else { print "
$lang_pending_reserve_results

"; } } else { print "
$lang_reserve_results

"; } print ""; print "
"; print ""; print $results; print ""; print "
"; print "

"; print "$refresh_message"; print "


"; print "
"; print ""; print "
"; print "
"; print ""; $user_email = &find_user_email(@resv_form_fields); &send_email_notifications($email_message,$resource_key,$user_email,"ADD", ""); exit; } sub apply_reservation { local ($resource_key, $week_name, # Always in the format: MM-DD-YYYY $day_index, # Day index of week: 1 - 7 $current_seconds, # Number of seconds of this day $res_start_time, # 0 - 23.5 $res_end_time, # 0 - 23.5 $field5_recurring, # Field 5 = Password?Username?RecurringStartSeconds?RecurringEndSeconds $buffer_periods, $buffer_hours, $buffer_minutes, $prevalidate_flag, @resv_form_fields) = @_; local ($file_name, $date_string, $line_index, $current_line, $data_index, $begin_time, $end_time, $available, $formatted_line, $inserted, $temp_res_field1, $index, $found_flag, $resource_settings, $pending_flag, $action_string, $total_buffer_time, $next_resv_begin_time, $t, $temp_file, $sub_name, $status, $random_number, @resource_value_pairs, @lines, @reservation_data_pairs, @cur_fields, @next_resv_cur_fields, @raw_resv_form_fields ); $sub_name = "apply_reservation"; @raw_resv_form_fields = @resv_form_fields; @blackout_timeslots = &get_blackout_timeslots($resource_key, $current_seconds, $day_index); $looper = &get_looper(); if (($settings[97] =~ /DAILY/i) || ($settings[97] =~ /DATE_RANGE/i)) { if ($blackout_timeslots[0] == -1) { return 1; # schedule conflict! } } # fix 09/04/06 else { for ($i=$res_start_time; (sprintf('%2.3f',$i)) < (sprintf('%2.3f',$res_end_time)); $i+=$looper) # fix v4.0 { $blackout_end_index = &check_timeslot_in_blackout_list($i, @blackout_timeslots); if ($blackout_end_index > 0) { $i = $res_end_time + 1; # force exit loop if ($resv_form_recurring <= 1) { if ($prevalidate_flag != 1) { &missing_input("Invalid Reservation Span","There are unavailable timeslots between your requested start and end time. You are not allowed to make a reservation that spans timeslots marked as unavailable.

Contact your system administrator if you need further help."); } else { return 1; } } else { return 1; } } } } # end fix 09/04/06 $file_name = $data_directory . $week_name . ".txt"; $formatted_line = "$resource_key"; $resource_settings = &get_resource_settings($resource_key); @resource_value_pairs = split (/\|/, $resource_settings); $pending_flag = &get_pending_flag(@resource_value_pairs); # on or off $inserted = 0; $available = 1; @lines = &get_reservation_data_file($file_name); $current_line = ""; if ($#lines > 0) { $current_line = &get_reservation_data_by_resource_and_day($resource_key, $day_index, @lines); } if ($current_line =~ /\S/) { if ($settings[0] eq "CONFIG") { $buffer_periods = &strip_letters($buffer_periods); $total_buffer_time = $buffer_periods; } else { $buffer_hours = &strip_letters($buffer_hours); $buffer_minutes = &strip_letters($buffer_minutes); $total_buffer_time = ($buffer_hours * 3600) + ($buffer_minutes * 60); # note: lead mins is fraction of hours, 30 mins=.5 } @reservation_data_pairs = split (/\|/, $current_line); $current_key = $reservation_data_pairs[0]; $buffer_checked = 0; $no_more_resv_on_this_day = 0; for ($data_index = 1; $data_index < $#reservation_data_pairs; $data_index += 25) { if (($data_index + 25) >= $#reservation_data_pairs) { $no_more_resv_on_this_day = 1; } else { $next_resv_begin_time = 0; @next_resv_cur_fields = (); @next_resv_cur_fields = &get_current_fields(($data_index + 25), @reservation_data_pairs); $next_resv_begin_time = $next_resv_cur_fields[6]; $next_resv_begin_time = &strip_letters($next_resv_begin_time); } @cur_fields = &get_current_fields($data_index, @reservation_data_pairs); $begin_time = $cur_fields[6]; $begin_time = &strip_letters($begin_time); $end_time = $cur_fields[7]; $end_time = &strip_letters($end_time); if ( (&compare_ge($res_start_time, $begin_time)) && (&compare_lt($res_start_time, $end_time)) ) # v3.24 fix { $available = 0; } elsif ((&compare_gt($res_end_time, $begin_time)) && (&compare_le($res_end_time, $end_time))) # v3.24 fix { $available = 0; } elsif ((&compare_le($res_start_time, $begin_time)) && (&compare_gt($res_end_time, $begin_time))) # v3.24 fix { $available = 0; } elsif ($inserted == 0) { if ($total_buffer_time > 0) { if (!($buffer_checked)) { if (&compare_le($res_end_time, $begin_time)) { $buffer_checked = 1; if (&compare_gt($res_end_time, ($begin_time - $total_buffer_time))) { $available = 0; # not enough buffer time } } } if (!($buffer_checked)) { if ( (&compare_ge($res_begin_time, ($end_time + $total_buffer_time))) && (&compare_le($res_end_time, $next_resv_begin_time)) ) { $buffer_checked = 1; if (&compare_gt($res_end_time, ($next_resv_begin_time - $total_buffer_time))) { $available = 0; # not enough buffer time } } } if (!($buffer_checked)) { if ( (&compare_ge($res_begin_time, $end_time)) && ($no_more_resv_on_this_day) ) { $buffer_checked = 1; if (&compare_gt($res_end_time, ($next_resv_begin_time - $total_buffer_time))) { $available = 0; # not enough buffer time } } } } if ($available == 1) { if ((&compare_lt($res_start_time, $begin_time))) # v3.24 fix { @resv_form_fields = &prep_resv_form_fields(@resv_form_fields); $formatted_line .= (&prep_resv_form_fields_line_for_reservation_file($res_start_time, $res_end_time, $field5_recurring, $pending_flag, @resv_form_fields)); $inserted = 1; } } } $formatted_line .= (&prep_cur_fields_line_for_reservation_file(0, @cur_fields)); #0=dont remove pending indr } } if ($available == 0) { if ($resv_form_recurring <= 1) { if ($prevalidate_flag != 1) { &missing_input("Invalid Time Range","There is a scheduling conflict with the time range that you chose."); } else { return 1; } } else { return 1; } } if ($inserted == 0) { @resv_form_fields = &prep_resv_form_fields(@resv_form_fields); $formatted_line .= (&prep_resv_form_fields_line_for_reservation_file($res_start_time, $res_end_time, $field5_recurring, $pending_flag, @resv_form_fields)); } if ($prevalidate_flag != 1) { if (!(-e $file_name)) { open(SCHEDULE_DATA_FILE,">>$file_name") || &return_error("File Error","Unable to open " . $file_name); &log_info($DEBUG,"TEMP FILE: $file_name was created in sub apply_reservation."); for ($index = 1; $index < 8; $index++) { print SCHEDULE_DATA_FILE "#$index\n"; if ($index == $day_index) { print SCHEDULE_DATA_FILE "$formatted_line\n"; } print SCHEDULE_DATA_FILE "#END$index\n"; } close(SCHEDULE_DATA_FILE); chmod(0777, $file_name); } else { srand(time|$$); $random_number = int(rand(10000000)); $temp_file = $data_directory . "ureserve" . $random_number . ".tmp"; if (-e $temp_file) { $random_number++; $temp_file = $data_directory . "ureserve" . $random_number . ".tmp"; } if (!(open(TEMP_DATA_FILE, ">" . $temp_file))) { &return_error("File Error","Unable to open " . $temp_file); } else { &log_info($DEBUG,"TEMP FILE: $temp_file was created in sub apply_reservation."); } $found_flag = 0; $inserted = 0; for ($line_index = 0; $line_index <= $#lines; $line_index++) { if ($lines[$line_index] =~ /^#$day_index/i) { $found_flag = 1; print TEMP_DATA_FILE $lines[$line_index]; } elsif (($found_flag == 1) && ($inserted == 0)) { if (($lines[$line_index] =~ /^#END$day_index/i) && ($inserted == 0)) { print TEMP_DATA_FILE "$formatted_line\n"; $inserted = 1; print TEMP_DATA_FILE $lines[$line_index]; } else { @reservation_data_pairs = split (/\|/, $lines[$line_index]); $current_resource_key = $reservation_data_pairs[0]; if (int($current_resource_key) == int($resource_key)) { print TEMP_DATA_FILE "$formatted_line\n"; $inserted = 1; } else { print TEMP_DATA_FILE $lines[$line_index]; } } } else { print TEMP_DATA_FILE $lines[$line_index]; } } close(TEMP_DATA_FILE); $status = 0; $status = &safe_swap($file_name, $temp_file, $sub_name); if ($status == -1) { &return_error("SERVER TIMEOUT","Unable to add reservations in " . $week_name . ". Please resubmit."); } } if ($settings[9] =~ /YES/i) { $action_string = "ADD"; if ($pending_flag =~ /on/i) { $action_string .= "-PENDING"; } &update_reservation_log($action_string, $resource_key, $current_seconds, $res_start_time, $res_end_time, @raw_resv_form_fields); } } # end if prevalidation_flag != 1 return 0; } sub view_reservation { local ( $resource_key, $resource_name, $week_name, $day_index, $start_time, $current_seconds, $viewing_password, $viewing_username, $file_name, $line_index, $found_flag, $current_line, $data_index, $cur_begin_time, $cur_end_time, $date_string, $expired_flag, $pending_status, $lead_days, $lead_hours, $lead_minutes, $user_auth, $resv_password, $resv_username, $permission_level, $recurring_flag, $username_flag, @resv_form_fields, @reservation_data_pairs, @lines, @cur_fields, @string_value_pairs ); $password = $form_text{'password'}; $username = $form_text{'username'}; $resource_key = $form_text{'resource_key'}; $resource_name = &get_resource_name($resource_key); $week_name = $form_text{'week'}; $day_index = $form_text{'day'}; $day_index = &strip_letters($day_index); $start_time = $form_text{'begin'}; $start_time = &strip_letters($start_time); $current_seconds = $form_text{'seconds'}; $current_seconds = &strip_letters($current_seconds); $viewing_password = $form_text{'viewing_password'}; $viewing_username = $form_text{'viewing_username'}; $file_name = $data_directory . $week_name . ".txt"; $line_index = 0; $found_flag = 0; $expired_flag = 0; @lines = &get_reservation_data_file($file_name); $current_line = ""; if ($#lines > 0) { $current_line = &get_reservation_data_by_resource_and_day($resource_key, $day_index, @lines); } @resv_form_fields = (); if ($current_line =~ /\S/) { @reservation_data_pairs = split (/\|/, $current_line); for ($data_index = 1; $data_index < $#reservation_data_pairs; $data_index += 25) { if ($found_flag == 0) { $cur_begin_time = $reservation_data_pairs[$data_index + 5]; $cur_end_time = $reservation_data_pairs[$data_index + 6]; if (&compare_eq($cur_begin_time, $start_time)) { @cur_fields = &get_current_fields($data_index, @reservation_data_pairs); @pending_value_pairs = split (/\?/, $cur_fields[1]); $pending_status = 0; if ($pending_value_pairs[1] =~ /PENDING/i) { $pending_status = 1; } @resv_form_fields = &prep_resv_form_fields_array($data_index, @reservation_data_pairs); $found_flag = 1; } } } } $resource_settings = &get_resource_settings($resource_key); @resource_value_pairs = split (/\|/, $resource_settings); $lead_days = &get_lead_time_cancel_days(@resource_value_pairs); # resource lead time cancel days $lead_hours = &get_lead_time_cancel_hours(@resource_value_pairs); # resource lead time cancel hours $lead_minutes = &get_lead_time_cancel_minutes(@resource_value_pairs); # resource lead time cancel minutes if ( ($username =~ /\S/) && ($password =~ /\S/) ) { $viewing_username = $username; $viewing_password = $password; } $expired_flag = &check_expired( $resource_key, $current_seconds, $start_time, $lead_days, $lead_hours, $lead_minutes, 1, $viewing_username, $viewing_password); print "Content-type: text/html\n\n"; print "\n"; print "\n"; print "\n\n"; print "uReserve"; print ""; print "
"; print ""; if ($pending_status == 1) { print "
$lang_pending_reserve_info

"; } else { print "
$lang_reserve_info

"; } $resv_password = &get_original_password($cur_fields[5]); $resv_username = &get_original_username($cur_fields[5]); $permission_level = &get_resource_permission_level(@resource_value_pairs); $recurring_flag = 0; @string_value_pairs = split (/\?/, $cur_fields[5]); if ($string_value_pairs[2] =~ /\S/) { $recurring_flag = 1; } $username_flag = 0; if ($resv_username =~ /\S/) { $username_flag = 1; } $user_auth = -1; if ($settings[80] =~ /YES/i) { $user_auth = &check_if_user_is_admin_or_reservee( $resource_key, $permission_level, $resv_username, $resv_password, $viewing_username, $viewing_password); } # end if $settings[80] =~ /YES/ elsif ($settings[127] =~ /YES/i) { $user_auth = &check_if_user_is_admin_or_reservee( $resource_key, $permission_level, $resv_username, $resv_password, $username, $password); } if (($settings[80] =~ /YES/i) && ($user_auth == -1)) { print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print "
"; print ""; if (int($permission_level) == $ANY_RESERVE_AUTH_RECURRING) { if ( ($recurring_flag) || ( (!$recurring_flag) && ($resv_username =~ /\S/) ) ) { print "$lang_username: "; print "

"; } } elsif ( (int($permission_level) == $AUTH_RESERVE_AUTH_RECURRING) || (int($permission_level) == $AUTH_RESERVE_NO_RECURRING) ) { print "$lang_username: "; print "

"; } print "$lang_password: "; print "

"; print "
"; print "
"; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print "     "; print ""; print ""; print "
"; } else { if ($expired_flag == 1) { print ""; print "($lang_read_only - $lang_timeslot_passed)"; } elsif (($expired_flag == 2) || ($expired_flag == 3)) { print ""; print "($lang_read_only - $lang_lead_time)"; } print "

"; print ""; print "
"; print ""; print "
$settings[39]: $resource_name
"; if ($settings[97] =~ /STANDARD/i) { $date_string = &get_exact_date($current_seconds); print "Date: $date_string
"; } else { $res_start_date = &get_res_start_date($cur_fields[5]); $res_end_date = &get_res_end_date($cur_fields[5]); if ($res_start_date eq $res_end_date) { print "Date: $res_start_date
"; } else { print "Dates: $res_start_date - $res_end_date
"; } } if ($settings[97] =~ /STANDARD/i) { if ($settings[0] eq "CONFIG") { $looper = &get_looper(); $fixed_res_size = 0; $fixed_hours = &get_fixed_reservation_hours(@resource_value_pairs); $fixed_minutes = &get_fixed_reservation_minutes(@resource_value_pairs); $fixed_res_size = $fixed_hours + $fixed_minutes; if ($fixed_res_size > 0) { if (&compare_eq($fixed_res_size, $looper)) { print $settings[100] . " " . $column_names[$cur_begin_time]; } else { print $settings[100] . " " . $column_names[$cur_begin_time]; print " - " . $column_names[$cur_end_time]; } } # end custom MVA put in baseline else { print "From: "; print $column_names[$cur_begin_time]; print " - "; print $column_names[$cur_end_time]; } } else { print "Time: "; print &format_time($cur_begin_time); print " - "; print &format_time($cur_end_time); } } print "

"; $field_count = 1; $results = ""; $reservation_form_field = ""; for ($i=1; $i <= 22; $i++) { if ($fields[$field_count] =~ /\S/) { if (!($fields[($field_count + 1)] =~ /DISABLED/i)) { if ( (!($fields[($field_count + 3)] =~ /HIDDEN/i)) || (($fields[($field_count + 3)] =~ /HIDDEN/i) && ($user_auth != -1)) ) { $reservation_form_field = &get_current_reservation_field($field_count, @resv_form_fields); $results .= $reservation_form_field; } } } $field_count += 6 ; } print $results; print "
"; print "
"; print "
"; print "
"; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; if ($expired_flag == 0) { print ""; print "     "; } print ""; print "
"; } print "
"; print ""; exit; } sub create_modify_or_delete_reservation_form { local ( $resource_name, $resource_key, $permission_level, $week_name, $day_index, $days_seconds, $cur_begin_time, $cur_end_time, $line, $found_flag, $date_string, $temp_float, $time_selections, $time_selections_html, $looper, $pending_status, $data_index, $viewing_password, $viewing_username, $user_auth, $user_logged_in, $recurring_flag, @resource_value_pairs, @pending_value_pairs, @resv_form_fields); &validate_referral_page($script_url); $resource_key = $form_text{'resource_key'}; $week_name = $form_text{'week'}; $day_index = $form_text{'day'}; $days_seconds = $form_text{'seconds'}; $days_seconds = &strip_letters($days_seconds); $cur_begin_time = $form_text{'begin_time'}; $cur_begin_time = &strip_letters($cur_begin_time); $cur_end_time = $form_text{'end_time'}; $cur_end_time = &strip_letters($cur_end_time); @resv_form_fields = &get_posted_reservation_data(); @pending_value_pairs = split (/\?/, $resv_form_fields[0]); $res_start_date = $form_text{'res_start_date'}; $res_end_date = $form_text{'res_end_date'}; $viewing_password = $form_text{'viewing_password'}; $viewing_username = $form_text{'viewing_username'}; $user_auth = $form_text{'user_auth'}; # 1 indicates sysadmin or resource admin, 2 indicates reservee himself $recurring_flag = $form_text{'recurring_flag'}; # 1 indicates the reservation was made as a recurring reservation $username_flag = $form_text{'username_flag'}; # 1 indicates the reservation was made with a username $resource_name = &get_resource_name($resource_key); $date_string = &get_exact_date($days_seconds); $looper = &get_looper(); $resource_settings = &get_resource_settings($resource_key); @resource_value_pairs = split (/\|/, $resource_settings); $fixed_hours = &get_fixed_reservation_hours(@resource_value_pairs); $fixed_minutes = &get_fixed_reservation_minutes(@resource_value_pairs); $permission_level = &get_resource_permission_level(@resource_value_pairs); if ((int($permission_level) == 0) || (!($permission_level =~ /\S/)) ) { $permission_level = $settings[10]; # use the general settings permission level } print "Content-type: text/html\n\n"; print "\n"; print "\n"; print "\n\n"; print "uReserve"; print ""; print "
"; print "
"; print ""; $pending_status = &check_pending_field($resv_form_fields[0]); if ($pending_status == 1) { print "
$lang_pending_reserve_modify

"; } else { print "
$reserve_modify

"; } print ""; print "
"; print ""; print "
$settings[39]: $resource_name
"; $gtime_range_start = &strip_letters($gtime_range_start); $gtime_range_stop = &strip_letters($gtime_range_stop); if ($settings[97] =~ /STANDARD/i) { $date_string = &get_exact_date($days_seconds); print "Date: $date_string

"; } else { if ($settings[97] =~ /DATE_RANGE/i) { $time_selections_html = &get_time_selections_date_range($res_start_date, $res_end_date); print $time_selections_html; } else { $time_selections_html = &get_time_selections_daily($res_start_date, $res_end_date); print $time_selections_html; } } if ($settings[97] =~ /STANDARD/i) { if (($fixed_hours > 0) || ($fixed_minutes > 0)) { $time_selections_html = &get_fixed_open_time_selections($week_name, $day_index, $resource_key, $fixed_hours, $fixed_minutes, $cur_begin_time, $cur_end_time); } else { $time_selections_html = &get_open_time_selections( $week_name, $day_index, $resource_key, $cur_begin_time, $cur_end_time); } print $time_selections_html; } print "

"; print ""; $field_count = 1; for ($i=1; $i <= 22; $i++) { if ($fields[$field_count] =~ /\S/) { if (!($fields[($field_count + 1)] =~ /DISABLED/i)) { print ""; print ""; print ""; print ""; } } $field_count += 6; } $user_logged_in = 0; if (($username =~ /\S/) && ($password =~ /\S/)) { $user_logged_in = 1; } if ($settings[80] =~ /NO/i) { if (($user_logged_in) && ($user_auth == 1)) { } elsif (($user_logged_in) && ($user_auth == 2)) { } else { print "
"; if (!($fields[($field_count + 3)] =~ /HIDELABEL/i)) { print ""; print $fields[$field_count]; print ""; } print ""; print ""; $show_reservation_form_field = &get_reservation_form_field_for_modify($i, $field_count, $resv_form_fields[$i-1]); print $show_reservation_form_field; print ""; print "
"; if (int($permission_level) == $ANY_RESERVE_AUTH_RECURRING) { if ( ($recurring_flag) || ( (!$recurring_flag) && ($username_flag) ) ) { print ""; print ""; print ""; print ""; } } elsif ( (int($permission_level) == $AUTH_RESERVE_AUTH_RECURRING) || (int($permission_level) == $AUTH_RESERVE_NO_RECURRING) ) { print ""; print ""; print ""; print ""; } print ""; print ""; print ""; print ""; print "
"; print ""; print "$lang_username: "; print ""; print ""; print ""; print ""; print ""; print "
"; print ""; print "$lang_username: "; print ""; print ""; print ""; print ""; print ""; print "
"; print ""; print "$settings[52]: "; print ""; print ""; print ""; print ""; print ""; print "
"; if ((int($permission_level) != $ANY_RESERVE_AUTH_RECURRING) && (int($permission_level) != $AUTH_RESERVE_AUTH_RECURRING) && (int($permission_level) != $AUTH_RESERVE_NO_RECURRING)) { print "$settings[53]
"; # a password is required for all modifications } } } else { print ""; print ""; } print "
"; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print "
"; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print "
"; print "
"; print ""; exit; } sub modify_reservation { local ( $resource_name, $week_name, $day_index, $current_seconds, $orig_res_start_date, $orig_res_end_date, $res_num_days, $org_start_time, $org_end_time, $org_password, $org_username, $res_start_time, $res_end_time, $field5_recurring, $org_field5, $field5_prepped_flag, $file_name, $date_string, $line_index, $current_line, $data_index, $data_index2, $begin_time, $begin_time2, $end_time, $available, $formatted_line, $inserted, $index, $found_flag, $email_message, $resource_settings, $pending_flag, $max_reservation_minutes, $temp_max_reservation_minutes, $max_reservation_hours, $resv_form_password, $resv_form_username, $permission_level, $user_auth, $recurring_flag, $looper, $blackout_end_index, $i, $save_org_password, $save_org_username, $temp_file, $sub_name, $status, $random_number, @lines, @cur_fields, @cur_fields2, @reservation_data_pairs, @resource_value_pairs, @resv_form_fields, @raw_resv_form_fields, @blackout_timeslots); $sub_name = "modify_reservation"; &validate_referral_page($script_url); $resource_key = $form_text{'resource_key'}; $resource_name = &get_resource_name($resource_key); $week_name = $form_text{'week'}; $day_index = $form_text{'day'}; $day_index = &strip_letters($day_index); $current_seconds = $form_text{'seconds'}; $current_seconds = &strip_letters($current_seconds); $org_start_time = $form_text{'original_begin_time'}; $org_start_time = &strip_letters($org_start_time); $org_end_time = $form_text{'original_end_time'}; $org_end_time = &strip_letters($org_end_time); $res_start_time = $form_text{'start_time'}; $res_end_time = $form_text{'end_time'}; $res_end_time = &strip_letters($res_end_time); $resv_form_password = $form_text{'resv_form_password'}; # might be blank if user logged in $resv_form_username = $form_text{'resv_form_username'}; # might be blank if user logged in $user_auth = $form_text{'user_auth'}; # 1 indicates sysadmin or resource admin, 2 indicates reservee himself $user_logged_in = $form_text{'user_logged_in'}; $recurring_flag = $form_text{'recurring_flag'}; # 1 indicates the reservation was made as a recurring reservation $org_recurring_start_seconds = 0; $org_recurring_end_seconds = 0; $recurring_start_seconds = 0; $recurring_end_seconds = 0; $org_field5 = ""; $field5_prepped_flag = 0; $save_org_password = ""; $save_org_username = ""; if (($settings[97] =~ /DAILY/i) || ($settings[97] =~ /DATE_RANGE/i)) { $res_start_time = $gtime_range_start; $res_end_time = $gtime_range_stop; $res_start_date = $form_text{'res_start_date'}; $res_end_date = $form_text{'res_end_date'}; $orig_res_start_date = $form_text{'original_res_start_date'}; $orig_res_end_date = $form_text{'original_res_end_date'}; $res_num_days = $form_text{'res_num_days'}; if (!($res_start_date =~ /\S/)) { &missing_input("Missing Input","A Start Date must be specified."); } if ($settings[97] =~ /DATE_RANGE/i) { if (!($res_end_date =~ /\S/)) { &missing_input("Missing Input","An End Date must be specified."); } } else { if (int($res_num_days) < 1) { &missing_input("Missing Input","Number of Days/Nights must be specified."); } } if ($settings[97] =~ /DAILY/i) { $current_seconds = &get_date_seconds($res_start_date); $res_end_date = &get_exact_date(($current_seconds + ($res_num_days * $SECONDS_PER_DAY))); } $current_seconds = &get_date_seconds($orig_res_start_date); $res_start_seconds = &get_date_seconds($res_start_date); $res_end_seconds = &get_date_seconds($res_end_date); if ($res_end_seconds < $res_start_seconds) { &missing_input("Invalid Date Range","The end date ($res_end_date) can not be before the start date ($res_start_date)."); } $week_name = &get_week_name($current_seconds); &analyze_seconds($current_seconds); $day_index = $g_wday; if ($settings[6] =~ /SUN/i) { $temp_day_index = $day_index + 1; } else { if ($day_index == 0) { $temp_day_index = 7; } else { $temp_day_index = $day_index; } } $day_index = $temp_day_index; } else { if (!($res_end_time =~ /\S/)) { @time_pairs = split (/\?/, $res_start_time); if (($time_pairs[0] > 0) && ($time_pairs[1] > 0)) { $res_start_time = $time_pairs[0]; $res_end_time = $time_pairs[1]; } elsif (($settings[0] eq "CONFIG") && ($time_pairs[0] >= 0) && ($time_pairs[1] > 0)) { $res_start_time = $time_pairs[0]; $res_end_time = $time_pairs[1]; } else { $res_start_time = &strip_letters($res_start_time); } } else { $res_start_time = &strip_letters($res_start_time); } } @resv_form_fields = &get_posted_reservation_data(); @raw_resv_form_fields = @resv_form_fields; $field_count = 1; $field_name_prefix = "resv_form_field"; for ($i=1; $i <= 22; $i++) { if ($fields[$field_count] =~ /\S/) { if (!($fields[($field_count + 1)] =~ /DISABLED/i)) { if ($fields[$field_count + 4] =~ /on/i) { $field_name = $field_name_prefix . $i; $nra = $form_text{"$field_name"}; if (!($nra =~ /\S/)) { &missing_input("Missing Input","Please enter $fields[$field_count]."); } } } } $field_count += 6 ; } if ( (!($settings[97] =~ /DAILY/i)) && (!($settings[97] =~ /DATE_RANGE/i)) ) { if (&compare_ge($res_start_time, $res_end_time)) # v3.24 fix { &missing_input("Invalid Time Range","The ending ($res_end_time) time must be greater than the starting time ($res_start_time)."); } } @blackout_timeslots = &get_blackout_timeslots($resource_key, $current_seconds, $day_index); $looper = &get_looper(); for ($i=$res_start_time; (sprintf('%2.3f',$i)) < (sprintf('%2.3f',$res_end_time)); $i+=$looper) # fix v4.0 { $blackout_end_index = &check_timeslot_in_blackout_list($i, @blackout_timeslots); if ($blackout_end_index > 0) { &missing_input("Invalid Reservation Span","There are unavailable timeslots between your requested start and end time. You are not allowed to make a reservation that spans timeslots marked as unavailable.

Contact your system administrator if you need further help."); } } $resource_settings = &get_resource_settings($resource_key); @resource_value_pairs = split (/\|/, $resource_settings); $permission_level = &get_resource_permission_level(@resource_value_pairs); if ((int($permission_level) == 0) || (!($permission_level =~ /\S/)) ) { $permission_level = $settings[10]; # use the general settings permission level } $compliance_results = ""; # reset the compliance results if ($user_logged_in) { $compliance_results = &check_resource_compliance("MOD", $resource_key, $password, $username, $current_seconds, $res_end_time, $res_start_time, $org_end_time, $org_start_time, $username, $password); } else { $compliance_results = &check_resource_compliance("MOD", $resource_key, $resv_form_password, $resv_form_username, $current_seconds, $res_end_time, $res_start_time, $org_end_time, $org_start_time, $username, $password); } @compliance_pairs = split (/\|/, $compliance_results); if ($compliance_pairs[0] ne "NONE") # if there was a compliance violation, show the error message { &missing_input($compliance_pairs[0],$compliance_pairs[1]); #display error message and quit } $buffer_periods = &get_buffer_periods_between(@resource_value_pairs); # resource buffer days after a reservation $buffer_hours = &get_buffer_hours_between(@resource_value_pairs); # resource buffer hours after a reservation $buffer_minutes = &get_buffer_minutes_between(@resource_value_pairs); # resource buffer days after a reservation $file_name = $data_directory . $week_name . ".txt"; $line_index = 0; $formatted_line = "$resource_key"; $pending_flag = &get_pending_flag(@resource_value_pairs); # on or off $inserted = 0; $available = 1; $org_password = ""; @lines = &get_reservation_data_file($file_name); $current_line = ""; if ($#lines > 0) { $current_line = &get_reservation_data_by_resource_and_day($resource_key, $day_index, @lines); } if ($current_line =~ /\S/) { @reservation_data_pairs = split (/\|/, $current_line); for ($data_index = 1; $data_index < $#reservation_data_pairs; $data_index += 25) { @cur_fields = &get_current_fields($data_index, @reservation_data_pairs); $field5_recurring = $cur_fields[5]; $org_password = &get_original_password($cur_fields[5]); $org_username = &get_original_username($cur_fields[5]); $begin_time = $cur_fields[6]; $begin_time = &strip_letters($begin_time); $end_time = $cur_fields[7]; $end_time = &strip_letters($end_time); if (&compare_eq($begin_time, $org_start_time)) { @string_value_pairs = split (/\?/, $field5_recurring); if ($string_value_pairs[2] =~ /\S/) { $recurring_start_seconds = $string_value_pairs[2]; $recurring_end_seconds = $string_value_pairs[3]; } $org_recurring_start_seconds = $recurring_start_seconds; # save this off!!! $org_recurring_end_seconds = $recurring_end_seconds; # save this off!!! $save_org_password = $org_password; $save_org_username = $org_username; $org_field5 = &prep_field5_recurring($org_password, $org_username, $user_auth, $resv_form_username, $field5_recurring); $field5_prepped_flag = 1; } else { if ((&compare_ge($res_start_time, $begin_time)) && (&compare_lt($res_start_time, $end_time))) # v3.24 fix { $available = 0; } elsif ((&compare_gt($res_end_time, $begin_time)) && (&compare_le($res_end_time, $end_time))) # v3.24 fix { $available = 0; } elsif ((&compare_le($res_start_time, $begin_time)) && (&compare_gt($res_end_time, $begin_time))) # v3.24 fix { $available = 0; } elsif ($inserted == 0) { if ((&compare_lt($res_start_time, $begin_time))) # v3.24 fix { @resv_form_fields = &prep_resv_form_fields(@resv_form_fields); if ($field5_prepped_flag) { $formatted_line .= (&prep_resv_form_fields_line_for_reservation_file($res_start_time, $res_end_time, $org_field5, $pending_flag, @resv_form_fields)); } else { for ($data_index2 = 1; $data_index2 < $#reservation_data_pairs; $data_index2 += 25) { @cur_fields2 = &get_current_fields($data_index2, @reservation_data_pairs); $begin_time2 = $cur_fields2[6]; $begin_time2 = &strip_letters($begin_time2); if (&compare_eq($begin_time2, $org_start_time)) { $org_field5 = $cur_fields2[5]; $data_index2 = $#reservation_data_pairs; # force loop exit } } $formatted_line .= (&prep_resv_form_fields_line_for_reservation_file($res_start_time, $res_end_time, $org_field5, $pending_flag, @resv_form_fields)); } $inserted = 1; } } $formatted_line .= (&prep_cur_fields_line_for_reservation_file(0, @cur_fields)); # 0=dont remove pending indr } } } if ($available == 0) { &missing_input("Invalid Time Range","There is a scheduling conflict with the time range that you chose."); } if ($inserted == 0) { @resv_form_fields = &prep_resv_form_fields(@resv_form_fields); if ($field5_prepped_flag) { $formatted_line .= (&prep_resv_form_fields_line_for_reservation_file($res_start_time, $res_end_time, $org_field5, $pending_flag, @resv_form_fields)); } else { for ($data_index2 = 1; $data_index2 < $#reservation_data_pairs; $data_index2 += 25) { @cur_fields2 = &get_current_fields($data_index2, @reservation_data_pairs); $begin_time2 = $cur_fields[6]; $begin_time2 = &strip_letters($begin_time2); if (&compare_eq($begin_time2, $org_start_time)) { $org_field5 = $cur_fields[5]; $data_index2 = $#reservation_data_pairs; # force loop exit } } $formatted_line .= (&prep_resv_form_fields_line_for_reservation_file($res_start_time, $res_end_time, $org_field5, $pending_flag, @resv_form_fields)); } $inserted = 1; } if (($save_org_password =~ /\S/) || ($field5_prepped_flag)) { $org_password = $save_org_password; } if (($save_org_username =~ /\S/) || ($field5_prepped_flag)) { $org_username = $save_org_username; } if ((int($user_auth) != 1) && (int($user_auth) != 2)) { &check_if_user_authorized_to_modify_or_cancel( $username, $password, $resource_key, $org_password, $org_username, $resv_form_password, $resv_form_username, $permission_level, $recurring_flag); } if ($settings[97] =~ /STANDARD/i) { if (!(-e $file_name)) { open(SCHEDULE_DATA_FILE,">>$file_name") || &return_error("File Error","Unable to open " . $file_name); for ($index = 1; $index < 8; $index++) { print SCHEDULE_DATA_FILE "#$index\n"; if ($index == $day_index) { print SCHEDULE_DATA_FILE "$formatted_line\n"; } print SCHEDULE_DATA_FILE "#END$index\n"; } close(SCHEDULE_DATA_FILE); chmod(0777, $file_name); } else { srand(time|$$); $random_number = int(rand(10000000)); $temp_file = $data_directory . "ureserve" . $random_number . ".tmp"; if (-e $temp_file) { $random_number++; $temp_file = $data_directory . "ureserve" . $random_number . ".tmp"; } if (!(open(TEMP_DATA_FILE, ">" . $temp_file))) { &return_error("File Error","Unable to open " . $temp_file); } else { &log_info($DEBUG,"TEMP FILE: $temp_file was created in sub modify_reservation."); } $found_flag = 0; $inserted = 0; for ($line_index = 0; $line_index <= $#lines; $line_index++) { if ($lines[$line_index] =~ /^#$day_index/i) { $found_flag = 1; print TEMP_DATA_FILE $lines[$line_index]; } elsif (($found_flag == 1) && ($inserted == 0)) { if (($lines[$line_index] =~ /^#END$day_index/i) && ($inserted == 0)) { print TEMP_DATA_FILE "$formatted_line\n"; $inserted = 1; print TEMP_DATA_FILE $lines[$line_index]; } else { @reservation_data_pairs = split (/\|/, $lines[$line_index]); $current_resource_key = $reservation_data_pairs[0]; if (int($current_resource_key) == int($resource_key)) { print TEMP_DATA_FILE "$formatted_line\n"; $inserted = 1; } else { print TEMP_DATA_FILE $lines[$line_index]; } } } else { print TEMP_DATA_FILE $lines[$line_index]; } } close(TEMP_DATA_FILE); $status = 0; $status = &safe_swap($file_name, $temp_file, $sub_name); if ($status == -1) { &return_error("SERVER TIMEOUT","Unable to process modifications in " . $week_name . ". Please resubmit."); } } } # end if ($settings[97] =~ /STANDARD/i) if (($org_recurring_start_seconds > 0) && ($settings[97] =~ /STANDARD/i)) { if ($settings[9] =~ /YES/i) { $action_string = "MOD"; if ($pending_flag =~ /on/i) { $action_string .= "-PENDING"; } &update_reservation_log($action_string, $resource_key, $current_seconds, $res_start_time, $res_end_time, @raw_resv_form_fields); } $result_message = "
This reservation was created as a recurring reservation. Do you also want to modify all other occurrences from this date forward?
"; print "Content-type: text/html\n\n"; print "\n"; print "\n"; print "\n\n"; print "uReserve"; print ""; print "
"; print ""; print "
$modify_results

"; print ""; print "

"; print "$result_message"; print "

"; print "
"; print ""; print ""; print "    "; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print "
"; print "
"; print ""; } # end if ($recurring_start_seconds > 0) else { if (($settings[97] =~ /DAILY/i) || ($settings[97] =~ /DATE_RANGE/i)) { &auto_modify_recurring_reservations( $resource_key, $week_name, $day_index, $current_seconds, $org_recurring_start_seconds, $org_recurring_end_seconds, $res_start_date, $res_end_date, $org_username, $org_password, $resv_form_username, $resv_form_password, $user_auth, $user_logged_in, @resv_form_fields); } else { print "Content-type: text/html\n\n"; print "\n"; print "\n"; print "\n\n"; print "uReserve"; print ""; print "
"; print ""; if ($pending_flag =~ /on/i) { print "
$lang_pending_modify_results

"; } else { print "
$modify_results

"; } print ""; print "
"; print ""; $results .= &get_reservation_result($current_seconds, $resource_key, $res_start_time, $res_end_time, 0, 0, 0, 0, #recurring_flag @raw_resv_form_fields); print $results; print ""; print "
"; print "

"; print "
"; print "$refresh_message"; print "

"; if (!($settings[1] =~ /MONTHLY/i)) { print ""; } else { print ""; } print "
"; print "
"; print ""; $action_string = "MOD"; if ($pending_flag =~ /on/i) { $action_string .= "-PENDING"; } if ($settings[9] =~ /YES/i) { &update_reservation_log($action_string, $resource_key, $current_seconds, $res_start_time, $res_end_time, @raw_resv_form_fields); } if ($pending_flag =~ /on/i) { $email_message = "The following PENDING reservation has been MODIFIED:\n\n"; } else { $email_message = "The following reservation has been MODIFIED:\n\n"; } $email_message .= $results; $user_email = &find_user_email(@resv_form_fields); &send_email_notifications($email_message,$resource_key,$user_email,"MOD", ""); } # end if STANDARD format } exit; } sub modify_recurring_reservation { local ($modify_recurring_flag) = @_; local ( $resource_name, $week_name, $day_index, $current_seconds, $res_start_time, $res_end_time, $res_password, $file_name, $date_string, $line_index, $current_line, $data_index, $begin_time, $end_time, $formatted_line, $inserted, $inserted2, $index, $found_flag, $end_week_name, $end_file_name, $recurring_start_seconds, $recurring_end_seconds, $start_seconds_to_compare, $cumulative_seconds, $result_message, $date_message, $email_message, $first_time, $recurring_count, $recurring_conflict_count, $recurring_dates, $recurring_conflicts, $routine_name, $resv_form_password, $resv_form_username, $user_auth, $org_field5, @recurring_data); $routine_name = "MODIFY_RECURRING_RESERVATION"; &validate_referral_page($script_url); $resource_key = $form_text{'resource_key'}; $resource_name = &get_resource_name($resource_key); $week_name = $form_text{'week'}; $day_index = $form_text{'day'}; $day_index = &strip_letters($day_index); $current_seconds = $form_text{'seconds'}; $current_seconds = &strip_letters($current_seconds); $recurring_start_seconds = $form_text{'recurring_start_seconds'}; $recurring_end_seconds = $form_text{'recurring_end_seconds'}; $res_start_time = $form_text{'res_start_time'}; $res_end_time = $form_text{'res_end_time'}; $res_end_time = &strip_letters($res_end_time); @resv_form_fields = &get_posted_reservation_data(); @raw_resv_form_fields = @resv_form_fields; $resv_form_password = $form_text{'resv_form_password'}; # password $res_password = &get_original_password($resv_form_password); $resv_form_username = $form_text{'resv_form_username'}; # username $user_auth = $form_text{'user_auth'}; # 1=sysadmin or resource admin, 2=reservee $org_field5 = $form_text{'org_field5'}; @recurring_data = (); $recurring_count = 1; $recurring_conflict_count = 0; $recurring_dates = ""; $recurring_conflicts = ""; if ($modify_recurring_flag == 1) { $end_week_name = &get_week_name($recurring_end_seconds); # in the form MM-DD-YYYY $end_file_name = $data_directory . $end_week_name; $end_file_name .= ".txt"; $start_seconds_to_compare = $recurring_start_seconds; $cumulative_seconds = &get_week_seconds($week_name); $week_name = &get_week_name($cumulative_seconds); # in the form MM-DD-YYYY $file_name = $data_directory . $week_name; $file_name .= ".txt"; if ($cumulative_seconds > $recurring_end_seconds) { &log_error($routine_name, "DATA FILE ERROR: A problem with recurring reservation data in $file_name was encountered. Details: resource=$resource_key, week=$week_name, day=$day_index, recurring=$recurring_start_seconds?$recurring_end_seconds, times=$res_start_time - $res_end_time."); &return_error("Data File Error","Invalid reservation data was encountered and has been logged. Recurring reservations were NOT modified. Contact your system admin for help."); } if ($file_name ne $end_file_name) { $recurring_count = 1; $first_time = 0; $end_week_name = &get_week_name(($recurring_end_seconds + ($SECONDS_PER_DAY * 7))); # in the form MM-DD-YYYY $end_file_name = $data_directory . $end_week_name; $end_file_name .= ".txt"; while ($file_name ne $end_file_name) { if (-e $file_name) { if ($first_time == 0) { @recurring_data = &modify_recurring_in_file($week_name, $file_name, $cumulative_seconds, ($day_index+1), $resource_key, $recurring_start_seconds, $current_seconds, $date_string, $res_start_time, $res_end_time, $resv_form_username, $resv_form_password, $user_auth, $org_field5, @resv_form_fields); $recurring_count += $recurring_data[0]; $recurring_dates .= $recurring_data[1]; $recurring_conflict_count += $recurring_data[2]; $recurring_conflicts .= $recurring_data[3]; $first_time = 1; } else { @recurring_data = &modify_recurring_in_file($week_name, $file_name, $cumulative_seconds, 0, $resource_key, $recurring_start_seconds, $current_seconds, $date_string, $res_start_time, $res_end_time, $resv_form_username, $resv_form_password, $user_auth, $org_field5, @resv_form_fields); $recurring_count += $recurring_data[0]; $recurring_dates .= $recurring_data[1]; $recurring_conflict_count += $recurring_data[2]; $recurring_conflicts .= $recurring_data[3]; } } # end if -e $file_name - its okay if it doesnt exist! $cumulative_seconds += ($SECONDS_PER_DAY * 7); $week_name = &get_week_name($cumulative_seconds); # in the form MM-DD-YYYY $file_name = $data_directory . $week_name; $file_name .= ".txt"; } # end while ($file_name ne $end_file_name) } # end if $file_name ne $end_file_name else { $day_index++; @recurring_data = &modify_recurring_in_file($week_name, $file_name, $cumulative_seconds, $day_index, $resource_key, $recurring_start_seconds, $current_seconds, $date_string, $res_start_time, $res_end_time, $resv_form_username, $resv_form_password, $user_auth, $org_field5, @resv_form_fields); $recurring_count += $recurring_data[0]; $recurring_dates .= $recurring_data[1]; $recurring_conflict_count += $recurring_data[2]; $recurring_conflicts .= $recurring_data[3]; } # end else if $file_name ne $end_file_name } else { } $date_string = &get_exact_date($current_seconds); $result_message = "
" . $recurring_count; if ($recurring_count <= 1) { $more_text = " was"; } else { $more_text = "s were"; } $result_message .= " reservation" . $more_text . " MODIFIED"; $date_message = ""; if ($recurring_count > 1) { $result_message .= " for the following dates:
"; $date_message .= "$date_string
"; # the first one that was modified $date_string = ""; for ($i=0; $i<($recurring_count-1); $i++) { @data_value_pairs = split (/\|/, $recurring_dates); $date_string = $data_value_pairs[$i]; $date_message .= "$date_string
"; } } else { $date_message .= ".
"; } if ($recurring_conflict_count > 0) { $date_message .= "

Reservations were NOT MODIFIED on the following dates due to scheduling conflicts:
"; $date_string = ""; for ($i=0; $i<$recurring_conflict_count; $i++) { @data_value_pairs = split (/\|/, $recurring_conflicts); $date_string = $data_value_pairs[$i]; $date_message .= "$date_string
"; } } $result_message .= $date_message; print "Content-type: text/html\n\n"; print "\n"; print "\n"; print "\n\n"; print "uReserve"; print ""; print "
"; print ""; print "
$modify_results

"; print ""; print "

"; print "$result_message"; print "

"; print "$refresh_message"; print "

"; print "

"; print "
"; print ""; print "
"; print "
"; print ""; $date_string = &get_exact_date($current_seconds); $email_message = "The following "; if ($recurring_count <= 1) { $email_message .= "reservation was MODIFIED:\n\n"; $email_message .= &get_reservation_result( $current_seconds, $resource_key, $res_start_time, $res_end_time, 0, 0, 0, 0, #recurring_flag @raw_resv_form_fields); } else { $email_message .= "recurring reservations were MODIFIED:\n\n"; $email_message .= &get_reservation_result( $current_seconds, $resource_key, $res_start_time, $res_end_time, 0, 0, 0, 1, #recurring_flag @raw_resv_form_fields); $email_message .= "for the following dates:\n"; $email_message .= "$date_message\n"; } $user_email = &find_user_email(@resv_form_fields); &send_email_notifications($email_message,$resource_key,$user_email,"MOD", ""); exit; } sub auto_modify_recurring_reservations { local ( $resource_key, $week_name, $day_index, $current_seconds, $recurring_start_seconds, $recurring_end_seconds, $res_start_date, $res_end_date, $orig_username, $orig_password, $resv_form_username, $resv_form_password, $user_auth, $user_logged_in, @resv_form_fields) = @_; local ( $resource_name, $res_start_time, $res_end_time, $res_password, $file_name, $date_string, $line_index, $current_line, $data_index, $begin_time, $end_time, $formatted_line, $inserted, $inserted2, $index, $found_flag, $modify_flag, $end_week_name, $end_file_name, $cumulative_seconds, $email_message, $first_time, $recurring_count, $recurring_conflict_count, $recurring_dates, $recurring_conflicts, $routine_name, $num_days, $full_num, $orig_file_name, $orig_end_file_name, $resource_settings, $end_availability_seconds, $new_field5_recurring, $field5_recurring_start_key, $buffer_periods, $buffer_hours, $buffer_minutes, $temp_day_index, @orig_resv_form_fields, @resource_value_pairs, @recurring_data); $routine_name = "AUTO_MODIFY_RECURRING_RESERVATIONS"; $resource_name = &get_resource_name($resource_key); @raw_resv_form_fields = @resv_form_fields; $res_start_time = $gtime_range_start; $res_end_time = $gtime_range_stop; $new_recurring_start_seconds = &get_date_seconds($res_start_date); $new_recurring_end_seconds = &get_date_seconds($res_end_date); $orig_week_name = &get_week_name($recurring_start_seconds); $orig_day_index = $day_index; $orig_current_seconds = $current_seconds; $modify_flag = 1; $send_notification_flag = 0; @orig_resv_form_fields = &auto_delete_recurring_reservations( $resource_key, $orig_week_name, $orig_day_index, $orig_current_seconds, $recurring_start_seconds, $recurring_end_seconds, $modify_flag, $send_notification_flag, @resv_form_fields); if ($user_auth == 1) { $new_field5_recurring = $orig_password . "?" . $orig_username; # password?username } elsif ($user_auth == 2) { if ($user_logged_in) { $new_field5_recurring = $password . "?" . $username; # password?username } else { $new_field5_recurring = $resv_form_password . "?" . $resv_form_username; # password?username } } else { $new_field5_recurring = $resv_form_password . "?" . $resv_form_username; # password?username } $field5_recurring_start_key = $new_recurring_start_seconds + int($res_start_time); $new_field5_recurring .= "?" . $field5_recurring_start_key; $num_days = 0; $full_num = 0.0; $num_days = int(($new_recurring_end_seconds - $new_recurring_start_seconds) / $SECONDS_PER_DAY); $full_num = ($new_recurring_end_seconds - $new_recurring_start_seconds) / $SECONDS_PER_DAY; $current_seconds = $new_recurring_start_seconds; if (($full_num - $num_days) > 0) { $num_days++; } $iterations = $num_days; $counter = 0; $increment = $SECONDS_PER_DAY; $day_increment = 1; $week_name = &get_week_name($new_recurring_start_seconds); # MM-DD-YYYY $current_seconds = $new_recurring_start_seconds; &analyze_seconds($current_seconds); $day_index = $g_wday; if ($settings[6] =~ /SUN/i) { $temp_day_index = $day_index + 1; } else { if ($day_index == 0) { $temp_day_index = 7; } else { $temp_day_index = $day_index; } } $day_index = $temp_day_index; $new_day_index = $day_index; # save this off for actually adding the new reservation $failed_update = 0; $prevalidate_flag = 1; do { $date_string = &get_exact_date($current_seconds); if (1 == &apply_reservation($resource_key, # The key of the resource. $week_name, # Always in the format: MM-DD-YYYY $day_index, # Day index of week: 1 - 7 $current_seconds, # Number of seconds of this day $res_start_time, # 0 - 23.5 $res_end_time, # 0 - 23.5 $new_field5_recurring, # Password?Username?RecurringStartSeconds?RecurringEndSeconds $buffer_periods, $buffer_hours, $buffer_minutes, $prevalidate_flag, @resv_form_fields)) { $failed_update = 1; } else { } $current_seconds += $increment; $day_index += $day_increment; if ($day_index > 7) { $day_index -= 7; } $week_name = &get_week_name($current_seconds); $counter++; } while ($counter < $iterations); $prevalidate_flag = 0; if ($failed_update) { $orig_num_days = 0; $full_num = 0.0; $orig_num_days = int(($recurring_end_seconds - $recurring_start_seconds) / $SECONDS_PER_DAY); $full_num = ($recurring_end_seconds - $recurring_start_seconds) / $SECONDS_PER_DAY; $current_seconds = $orig_current_seconds; if (($full_num - $orig_num_days) > 0) { $orig_num_days++; } $iterations = $orig_num_days; $counter = 0; $increment = $SECONDS_PER_DAY; $day_increment = 1; $day_index = $orig_day_index; $week_name = $orig_week_name; $orig_field5_recurring = $orig_password . "?" . $orig_username; # password?username $orig_field5_recurring .= "?" . $recurring_start_seconds; # original beginning reservation seconds - dont do the v4.15 change here! $orig_field5_recurring .= "?" . $recurring_end_seconds; do { $date_string = &get_exact_date($current_seconds); if (1 == &apply_reservation($resource_key, # The key of the resource. $week_name, # Always in the format: MM-DD-YYYY $day_index, # Day index of week: 1 - 7 $current_seconds, # Number of seconds of this day $res_start_time, # 0 - 23.5 $res_end_time, # 0 - 23.5 $orig_field5_recurring, # Password?Username?RecurringStartSeconds?RecurringEndSeconds $buffer_periods, $buffer_hours, $buffer_minutes, $prevalidate_flag, @orig_resv_form_fields)) { } $current_seconds += $increment; $day_index += $day_increment; if ($day_index > 7) { $day_index -= 7; } $week_name = &get_week_name($current_seconds); $counter++; } while ($counter < $iterations); } else { $iterations = $num_days; $counter = 0; $increment = $SECONDS_PER_DAY; $day_increment = 1; $day_index = $new_day_index; $week_name = &get_week_name($new_recurring_start_seconds); # MM-DD-YYYY $current_seconds = $new_recurring_start_seconds; do { if (1 == &apply_reservation($resource_key, # The key of the resource. $week_name, # Always in the format: MM-DD-YYYY $day_index, # Day index of week: 1 - 7 $current_seconds, # Number of seconds of this day $res_start_time, # 0 - 23.5 $res_end_time, # 0 - 23.5 $new_field5_recurring, # Password?Username?RecurringStartSeconds?RecurringEndSeconds $buffer_periods, $buffer_hours, $buffer_minutes, $prevalidate_flag, @resv_form_fields)) { } $current_seconds += $increment; $day_index += $day_increment; if ($day_index > 7) { $day_index -= 7; } $week_name = &get_week_name($current_seconds); $counter++; } while ($counter < $iterations); } if ($failed_update) { $result_message = "
Reservation was NOT MODIFIED due to a scheduling conflict. Either cancel the reservation, or change the new reservation dates.
"; } else { $result_message = "
Reservation has been MODIFIED.
"; } print "Content-type: text/html\n\n"; print "\n"; print "\n"; print "\n\n"; print "uReserve"; print ""; print "
"; print ""; print "
$modify_results

"; print ""; print "

"; print "$result_message"; print "

"; print "$refresh_message"; print "

"; print "

"; print "
"; print ""; print "
"; print "
"; print ""; if ($failed_update == 0) { $email_message = "Reservation was MODIFIED. New reservation is:\n\n"; $email_message .= &get_reservation_result( $current_seconds, $resource_key, $res_start_time, $res_end_time, $num_days, $new_recurring_start_seconds, $new_recurring_end_seconds, 0, #recurring_flag @resv_form_fields); $user_email = &find_user_email(@resv_form_fields); &send_email_notifications($email_message,$resource_key,$user_email,"MOD", ""); } exit; } sub modify_recurring_in_file { local ( $week_name, $file_name, $cumulative_seconds, $day_index, $resource_key, $recurring_start_seconds, $current_seconds, $date_string, $res_start_time, $res_end_time, $resv_form_username, $resv_form_password, $user_auth, $org_field5, @resv_form_fields) = @_; local ( $random_number, $temp_file, $line_index, $current_line, $found_flag, $inserted2, $formatted_line, $data_index, $begin_time, $end_time, $this_recurring_start_seconds, $this_recurring_end_seconds, $recurring_date, $recurring_conflict, $recurring_count, $recurring_conflict_count, $recorded_conflict_date, $resource_settings, $pending_flag, $prev_field1, $prev_field5, $prev_begin_time, $prev_end_time, $org_password, $org_username, $admin_user, $sub_name, $status, @reservation_data_pairs, @resource_value_pairs, @lines, @pending_value_pairs, @string_value_pairs, @cur_fields, @prev_fields, @recurring_data ); $sub_name = "modify_recurring_in_file"; @recurring_data = (); $recurring_count = 0; $recurring_conflict_count = 0; $recurring_date = ""; $recurring_conflict = ""; $resource_settings = &get_resource_settings($resource_key); @resource_value_pairs = split (/\|/, $resource_settings); $pending_flag = &get_pending_flag(@resource_value_pairs); # on or off @lines = &get_reservation_data_file($file_name); while ($day_index < 8) { $line_index = 0; $current_line = ""; $found_flag = 0; $inserted2 = 0; $formatted_line = $resource_key; $recorded_conflict_date = 0; $date_string = &get_exact_date(($cumulative_seconds + (($day_index-1) * $SECONDS_PER_DAY))); if ($#lines > 0) { $current_line = &get_reservation_data_by_resource_and_day($resource_key, $day_index, @lines); } if ($current_line =~ /\S/) { @reservation_data_pairs = split (/\|/, $current_line); for ($data_index = 1; $data_index < $#reservation_data_pairs; $data_index += 25) { @cur_fields = &get_current_fields($data_index, @reservation_data_pairs); $field5_recurring = $cur_fields[5]; # recurring username password recurring dates $begin_time = $cur_fields[6]; $begin_time = &strip_letters($begin_time); $end_time = $cur_fields[7]; $end_time = &strip_letters($end_time); $org_password = &get_original_password($field5_recurring); $org_username = &get_original_username($field5_recurring); $this_recurring_start_seconds = 0; $this_recurring_end_seconds = 0; @string_value_pairs = split (/\?/, $cur_fields[5]); if ($string_value_pairs[2] =~ /\S/) { $this_recurring_start_seconds = $string_value_pairs[2]; $this_recurring_end_seconds = $string_value_pairs[3]; } if ($this_recurring_start_seconds == $recurring_start_seconds) { $prev_field1 = $cur_fields[1]; $prev_field5 = $field5_recurring; $prev_begin_time = $begin_time; $prev_end_time = $end_time; $field5_recurring = $org_field5; @prev_fields = (); @prev_fields = @cur_fields; $recorded_conflict_date = 1; } else { if ((&compare_ge($res_start_time, $begin_time)) && (&compare_lt($res_start_time, $end_time)) && ($inserted2 == 0)) # v3.25 fix { @resv_form_fields = &prep_resv_form_fields_array(1, @prev_fields); @resv_form_fields = &prep_resv_form_fields(@resv_form_fields); $formatted_line .= (&prep_resv_form_fields_line_for_reservation_file($prev_begin_time, $prev_end_time, $prev_field5, $pending_flag, @resv_form_fields)); $inserted2 = 1; if (($found_flag == 1) && ($recorded_conflict_date == 1)) { $recurring_conflict_count++; $recurring_conflict .= $date_string . "|"; $recorded_conflict_date = 0; } } elsif ((&compare_gt($res_end_time, $begin_time)) && (&compare_le($res_end_time, $end_time)) && ($inserted2 == 0)) # v3.25 fix { @resv_form_fields = &prep_resv_form_fields_array(1, @prev_fields); @resv_form_fields = &prep_resv_form_fields(@resv_form_fields); $formatted_line .= (&prep_resv_form_fields_line_for_reservation_file($prev_begin_time, $prev_end_time, $prev_field5, $pending_flag, @resv_form_fields)); $inserted2 = 1; if (($found_flag == 1) && ($recorded_conflict_date == 1)) { $recurring_conflict_count++; $recurring_conflict .= $date_string . "|"; $recorded_conflict_date = 0; } } elsif ((&compare_le($res_start_time, $begin_time)) && (&compare_gt($res_end_time, $begin_time)) && ($inserted2 == 0)) # v3.25 fix { @resv_form_fields = &prep_resv_form_fields_array(1, @prev_fields); @resv_form_fields = &prep_resv_form_fields(@resv_form_fields); $formatted_line .= (&prep_resv_form_fields_line_for_reservation_file($prev_begin_time, $prev_end_time, $prev_field5, $pending_flag, @resv_form_fields)); $inserted2 = 1; if (($found_flag == 1) && ($recorded_conflict_date == 1)) { $recurring_conflict_count++; $recurring_conflict .= $date_string . "|"; $recorded_conflict_date = 0; } } elsif ($inserted2 == 0) { $found_flag = 1; if (&compare_lt($res_start_time, $begin_time)) # v3.24 fix { @resv_form_fields = &prep_resv_form_fields(@resv_form_fields); $formatted_line .= (&prep_resv_form_fields_line_for_reservation_file($res_start_time, $res_end_time, $org_field5, $pending_flag, @resv_form_fields)); $inserted2 = 1; $recurring_date .= $date_string . "|"; $recurring_count++; if ($settings[9] =~ /YES/i) { $action_string = "MOD"; if ($pending_flag == 1) { $action_string .= "-PENDING"; } &update_reservation_log($action_string, $resource_key, $cumulative_seconds, $res_start_time, $res_end_time, @resv_form_fields); } } } $formatted_line .= (&prep_cur_fields_line_for_reservation_file(0, @cur_fields)); # 0=dont remove pending indr } } if ($inserted2 == 0) { $found_flag = 1; $inserted2 = 1; @resv_form_fields = &prep_resv_form_fields(@resv_form_fields); $formatted_line .= (&prep_resv_form_fields_line_for_reservation_file($res_start_time, $res_end_time, $org_field5, $pending_flag, @resv_form_fields)); $recurring_count++; $recurring_date .= $date_string . "|"; if ($settings[9] =~ /YES/i) { $action_string = "MOD"; if ($pending_flag == 1) { $action_string .= "-PENDING"; } &update_reservation_log($action_string, $resource_key, $cumulative_seconds, $res_start_time, $res_end_time, @resv_form_fields); } } } # end if ($current_line =~ /\S/) if ($prevalidate_flag == 0) { if ($found_flag == 1) { if (!(-e $file_name)) { open(SCHEDULE_DATA_FILE,">>$file_name") || &return_error("File Error","Unable to open " . $file_name); for ($index = 1; $index < 8; $index++) { print SCHEDULE_DATA_FILE "#$index\n"; if ($index == $day_index) { print SCHEDULE_DATA_FILE "$formatted_line\n"; } print SCHEDULE_DATA_FILE "#END$index\n"; } close(SCHEDULE_DATA_FILE); chmod(0777, $file_name); } else { srand(time|$$); $random_number = int(rand(10000000)); $temp_file = $data_directory . "ureserve" . $random_number . ".tmp"; if (-e $temp_file) { $random_number++; $temp_file = $data_directory . "ureserve" . $random_number . ".tmp"; } if (!(open(TEMP_DATA_FILE, ">" . $temp_file))) { &return_error("File Error","Unable to open " . $temp_file); } else { &log_info($DEBUG,"TEMP FILE: $temp_file was created in sub modify_recurring_in_file."); } $found_flag = 0; $inserted2 = 0; for ($line_index = 0; $line_index <= $#lines; $line_index++) { if ($lines[$line_index] =~ /^#$day_index/i) { $found_flag = 1; print TEMP_DATA_FILE $lines[$line_index]; } elsif (($found_flag == 1) && ($inserted2 == 0)) { if (($lines[$line_index] =~ /^#END$day_index/i) && ($inserted2 == 0)) { print TEMP_DATA_FILE "$formatted_line\n"; $inserted2 = 1; print TEMP_DATA_FILE $lines[$line_index]; } else { @reservation_data_pairs = split (/\|/, $lines[$line_index]); $current_key = $reservation_data_pairs[0]; if (int($current_key) == int($resource_key)) { print TEMP_DATA_FILE "$formatted_line\n"; $inserted2 = 1; } else { print TEMP_DATA_FILE $lines[$line_index]; } } } else { print TEMP_DATA_FILE $lines[$line_index]; } } # end for ($line_index = 0; $line_index <= $#lines; $line_index++) close(TEMP_DATA_FILE); $status = 0; $status = &safe_swap($file_name, $temp_file, $sub_name); if ($status == -1) { &return_error("SERVER TIMEOUT","Unable to process reservations in " . $week_name . ".
SOME reservations may have been placed!
EXAMINE results and resubmit additional requests as needed."); } } } # end if $found_flag == 1 else { print TEMP_DATA_FILE $lines[$line_index]; } } # end if prevalidate_flag == 0 $day_index++; open (SCHEDULE_FILE, $file_name) || &return_error("File Error","Unable to open " . $file_name); @lines = ; close(SCHEDULE_FILE); } # end while (($day_index < 8)) && ($line_index <= $#lines)) $recurring_data[0] = $recurring_count; $recurring_data[1] = $recurring_date; $recurring_data[2] = $recurring_conflict_count; $recurring_data[3] = $recurring_conflict; return @recurring_data; } # end modify_recurring_in_file sub delete_reservation { local ($resource_key, $week_name, $day_index, $current_seconds, $org_password, $org_username, $temp_org_password, $res_start_time, $res_end_time, $res_password, $file_name, $date_string, $line_index, $current_line, $data_index, $begin_time, $end_time, $formatted_line, $inserted, $inserted2, $index, $found_flag, $recurring_start_seconds, $org_recurring_start_seconds, $recurring_end_seconds, $org_recurring_end_seconds, $email_message, $resource_settings, $permission_level, $recurring_flag, $temp_file, $sub_name, $status, $random_number, @lines, @reservation_data_pairs, @resource_value_pairs, @resv_form_fields, @orig_resv_form_fields, @cur_fields ); $sub_name = "delete_reservation"; &validate_referral_page($script_url); $resource_key = $form_text{'resource_key'}; $resource_name = &get_resource_name($resource_key); $week_name = $form_text{'week'}; $day_index = $form_text{'day'}; $day_index = &strip_letters($day_index); $current_seconds = $form_text{'seconds'}; $current_seconds = &strip_letters($current_seconds); $res_start_time = $form_text{'original_begin_time'}; $res_start_time = &strip_letters($res_start_time); $res_end_time = $form_text{'original_end_time'}; $res_end_time = &strip_letters($res_end_time); $resv_form_password = $form_text{'resv_form_password'}; # password, if filled in $resv_form_field5 $resv_form_username = $form_text{'resv_form_username'}; # username, if filled in $resv_form_field6 $user_auth = $form_text{'user_auth'}; # 1 indicates sysadmin or resource admin, 2 indicates reservee himself $user_logged_in = $form_text{'user_logged_in'}; $recurring_flag = $form_text{'recurring_flag'}; # 1 indicates the reservation was made as a recurring reservation @resv_form_fields = &get_posted_reservation_data(); @orig_resv_form_fields = (); $org_recurring_start_seconds = 0; $org_recurring_end_seconds = 0; $org_password = ""; $org_username = ""; if (($settings[97] =~ /DAILY/i) || ($settings[97] =~ /DATE_RANGE/i)) { $res_start_time = $gtime_range_start; $res_end_time = $gtime_range_stop; $res_start_date = $form_text{'res_start_date'}; $res_end_date = $form_text{'res_end_date'}; $current_seconds = &get_date_seconds($res_start_date); # modify the FIRST recurring reservation first! $week_name = &get_week_name($current_seconds); &analyze_seconds($current_seconds); $day_index = $g_wday; if ($settings[6] =~ /SUN/i) { $temp_day_index = $day_index + 1; } else { if ($day_index == 0) { $temp_day_index = 7; } else { $temp_day_index = $day_index; } } $day_index = $temp_day_index; } $file_name = $data_directory . $week_name . ".txt"; # from v2.0 $line_index = 0; $found_flag = 0; $formatted_line = $resource_key; @lines = &get_reservation_data_file($file_name); if ($#lines < 1) { &missing_input("No Data File","No data file for this week was found."); } $current_line = ""; if ($#lines > 0) { $current_line = &get_reservation_data_by_resource_and_day($resource_key, $day_index, @lines); } $resource_settings = &get_resource_settings($resource_key); @resource_value_pairs = split (/\|/, $resource_settings); $permission_level = &get_resource_permission_level(@resource_value_pairs); if ((int($permission_level) == 0) || (!($permission_level =~ /\S/)) ) { $permission_level = $settings[10]; # use the general settings permission level } if ($current_line =~ /\S/) { @reservation_data_pairs = split (/\|/, $current_line); for ($data_index = 1; $data_index < $#reservation_data_pairs; $data_index += 25) { @cur_fields = &get_current_fields($data_index, @reservation_data_pairs); $begin_time = $cur_fields[6]; $begin_time = &strip_letters($begin_time); $end_time = $cur_fields[7]; $end_time = &strip_letters($end_time); $recurring_start_seconds = 0; $recurring_end_seconds = 0; @string_value_pairs = split (/\?/, $cur_fields[5]); if ($string_value_pairs[2] =~ /\S/) { $recurring_start_seconds = $string_value_pairs[2]; $recurring_end_seconds = $string_value_pairs[3]; } if ($res_start_time == $begin_time) { $org_password = &get_original_password($string_value_pairs[0]); $org_username = $string_value_pairs[1]; $org_recurring_start_seconds = $recurring_start_seconds; # save this off!!! $org_recurring_end_seconds = $recurring_end_seconds; # save this off!!! @pending_value_pairs = split (/\?/, $cur_fields[1]); $found_flag = 1; } else { $formatted_line .= (&prep_cur_fields_line_for_reservation_file(0, @cur_fields)); # 0=dont remove pending indr } } } if (($found_flag == 0) && ($org_recurring_start_seconds == 0)) { &missing_input("Error","The specified reservation was not found."); } if ((int($user_auth) != 1) && (int($user_auth) != 2)) { &check_if_user_authorized_to_modify_or_cancel( $username, $password, $resource_key, $org_password, $org_username, $resv_form_password, $resv_form_username, $permission_level, $recurring_flag); } srand(time|$$); $random_number = int(rand(10000000)); $temp_file = $data_directory . "ureserve" . $random_number . ".tmp"; if (-e $temp_file) { $random_number++; $temp_file = $data_directory . "ureserve" . $random_number . ".tmp"; } if (!(open(TEMP_DATA_FILE, ">" . $temp_file))) { &return_error("File Error","Unable to open " . $temp_file); } else { &log_info($DEBUG,"TEMP FILE: $temp_file was created in sub delete_reservation."); } $found_flag = 0; $inserted = 0; for ($line_index = 0; $line_index <= $#lines; $line_index++) { if ($lines[$line_index] =~ /^#$day_index/i) { $found_flag = 1; print TEMP_DATA_FILE $lines[$line_index]; } elsif (($found_flag == 1) && ($inserted == 0)) { if (($lines[$line_index] =~ /^#END$day_index/i) && ($inserted == 0)) { print TEMP_DATA_FILE "$formatted_line\n"; $inserted = 1; print TEMP_DATA_FILE $lines[$line_index]; } else { @reservation_data_pairs = split (/\|/, $lines[$line_index]); $current_key = $reservation_data_pairs[0]; if (int($current_key) == int($resource_key)) { print TEMP_DATA_FILE "$formatted_line\n"; $inserted = 1; } else { print TEMP_DATA_FILE $lines[$line_index]; } } } else { print TEMP_DATA_FILE $lines[$line_index]; } } # end for ($line_index = 0; $line_index <= $#lines; $line_index++) close(TEMP_DATA_FILE); $status = 0; $status = &safe_swap($file_name, $temp_file, $sub_name); if ($status == -1) { &return_error("SERVER TIMEOUT","Unable to delete reservations in " . $week_name . ".
Examine results and resubmit as needed."); } if (($org_recurring_start_seconds > 0) && ($settings[97] =~ /STANDARD/i)) { if ($settings[9] =~ /YES/i) { $action_string = "DEL"; if ($pending_value_pairs[1] =~ /PENDING/i) { $action_string .= "-PENDING"; } &update_reservation_log($action_string, $resource_key, $current_seconds, $res_start_time, $res_end_time, @resv_form_fields); } $result_message = "
This reservation was created as a recurring reservation. Do you also want to delete all other occurrences from this date forward?
"; print "Content-type: text/html\n\n"; print "\n"; print "\n"; print "\n\n"; print "uReserve"; print ""; print "
"; print ""; print "
$delete_results

"; print ""; print "

"; print "$result_message"; print "

"; print "
"; print ""; print ""; print "    "; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print "
"; print "
"; print ""; } # end if ($recurring_start_seconds > 0) else { if (($settings[97] =~ /DAILY/i) || ($settings[97] =~ /DATE_RANGE/i)) { $modify_flag = 0; $send_notification_flag = 1; @orig_resv_form_fields = &auto_delete_recurring_reservations( $resource_key, $week_name, $day_index, $current_seconds, $org_recurring_start_seconds, $org_recurring_end_seconds, $modify_flag, $send_notification_flag, @resv_form_fields); } else { if ($inserted != 1) { &missing_input("Reservation Not Found","The specified reservation was not found."); } print "Content-type: text/html\n\n"; print "\n"; print "\n"; print "\n\n"; print "uReserve"; print ""; print "
"; print ""; print "
$delete_results

"; print ""; print "

"; print "$result_message"; print "

"; print "$refresh_message"; print "

"; print "
"; if (!($settings[1] =~ /MONTHLY/i)) { print ""; } else { print ""; } print "
"; print "
"; print ""; if ($settings[9] =~ /YES/i) { &update_reservation_log("DEL", $resource_key, $current_seconds, $res_start_time, $res_end_time, @resv_form_fields); } $pending_status = 0; if ($pending_value_pairs[1] =~ /PENDING/i) { $pending_status = 1; } if ($pending_status == 1) { $email_message = "The following PENDING reservation was CANCELLED:\n\n"; } else { $email_message = "The following reservation was CANCELLED:\n\n"; } $email_message .= &get_reservation_result( $current_seconds, $resource_key, $res_start_time, $res_end_time, 0, 0, 0, 0, #recurring_flag @resv_form_fields); $user_email = &find_user_email(@resv_form_fields); &send_email_notifications($email_message,$resource_key,$user_email,"DEL", ""); } } exit; } sub delete_recurring_reservation { local ($delete_recurring_flag) = @_; local ($resource_name, $week_name, $day_index, $current_seconds, $res_start_time, $res_end_time, $res_password, $file_name, $date_string, $line_index, $current_line, $data_index, $begin_time, $end_time, $formatted_line, $inserted, $inserted2, $index, $found_flag, $end_week_name, $end_file_name, $recurring_start_seconds, $recurring_end_seconds, $start_seconds_to_compare, $cumulative_seconds, $recurring_count, $email_message, $first_time, $recurring_dates, @lines, @recurring_data, @resv_form_fields, @cur_fields); &validate_referral_page($script_url); $resource_key = $form_text{'resource_key'}; $resource_name = &get_resource_name($resource_key); $week_name = $form_text{'week'}; $day_index = $form_text{'day'}; $day_index = &strip_letters($day_index); $current_seconds = $form_text{'seconds'}; $current_seconds = &strip_letters($current_seconds); $recurring_start_seconds = $form_text{'recurring_start_seconds'}; $recurring_end_seconds = $form_text{'recurring_end_seconds'}; $res_start_time = $form_text{'res_start_time'}; $res_start_time = &strip_letters($res_start_time); $res_end_time = $form_text{'res_end_time'}; $res_end_time = &strip_letters($res_end_time); @resv_form_fields = &get_posted_reservation_data(); $recurring_count = 1; if ($delete_recurring_flag == 1) { $end_week_name = &get_week_name($recurring_end_seconds); # in the form MM-DD-YYYY $end_file_name = $data_directory . $end_week_name; $end_file_name .= ".txt"; $start_seconds_to_compare = $recurring_start_seconds; $cumulative_seconds = &get_week_seconds($week_name); $week_name = &get_week_name($cumulative_seconds); # in the form MM-DD-YYYY $file_name = $data_directory . $week_name; $file_name .= ".txt"; if ($file_name ne $end_file_name) # if all recurring reservations are not in the same (one) file { $recurring_count = 1; $first_time = 0; $end_week_name = &get_week_name(($recurring_end_seconds + ($SECONDS_PER_DAY * 7))); # in the form MM-DD-YYYY $end_file_name = $data_directory . $end_week_name; $end_file_name .= ".txt"; while ($file_name ne $end_file_name) { if (-e $file_name) { if ($first_time == 0) { @recurring_data = &delete_recurring_in_file($week_name, $file_name, $cumulative_seconds, ($day_index+1), $resource_key, $recurring_start_seconds, $res_start_time, $res_end_time, $current_seconds, $date_string); $recurring_count += $recurring_data[0]; $recurring_dates .= $recurring_data[1]; $first_time = 1; } else { @recurring_data = &delete_recurring_in_file($week_name, $file_name, $cumulative_seconds, 0, $resource_key, $recurring_start_seconds, $res_start_time, $res_end_time, $current_seconds, $date_string); $recurring_count += $recurring_data[0]; $recurring_dates .= $recurring_data[1]; } } # end if -e $file_name - its okay if it doesnt exist! $cumulative_seconds += ($SECONDS_PER_DAY * 7); $week_name = &get_week_name($cumulative_seconds); # in the form MM-DD-YYYY $file_name = $data_directory . $week_name; $file_name .= ".txt"; } # end while ($file_name ne $end_file_name) } # end if $file_name ne $end_file_name else { $day_index++; @recurring_data = &delete_recurring_in_file($week_name, $file_name, $cumulative_seconds, $day_index, $resource_key, $recurring_start_seconds, $res_start_time, $res_end_time, $current_seconds, $date_string); $recurring_count += $recurring_data[0]; $recurring_dates .= $recurring_data[1]; } # end else if $file_name ne $end_file_name } else { } $result_message = "
" . $recurring_count; if ($recurring_count <= 1) { $more_text = " was"; } else { $more_text = "s were"; } $result_message .= " reservation" . $more_text . " CANCELLED.

"; print "Content-type: text/html\n\n"; print "\n"; print "\n"; print "\n\n"; print "uReserve"; print ""; print "
"; print ""; print "
$delete_results

"; print ""; print "

"; print "$result_message"; print "

"; print "$refresh_message"; print "

"; print "

"; print "
"; print ""; print "
"; print "
"; print ""; $date_string = &get_exact_date($current_seconds); $email_message = "The following "; if ($recurring_count <= 1) { $email_message .= "reservation was CANCELLED:\n\n"; $email_message .= &get_reservation_result( $current_seconds, $resource_key, $res_start_time, $res_end_time, 0, 0, 0, 0, #recurring_flag @raw_resv_form_fields); } else { $email_message .= "recurring reservations were CANCELLED:\n\n"; $email_message .= &get_reservation_result( $current_seconds, $resource_key, $res_start_time, $res_end_time, 0, 0, 0, 1, #recurring_flag @raw_resv_form_fields); $email_message .= "for the following dates:\n"; $email_message .= "$date_string\n"; $date_string = ""; for ($i=0; $i<($recurring_count-1); $i++) { @data_value_pairs = split (/\|/, $recurring_dates); $date_string = $data_value_pairs[$i]; $email_message .= "$date_string\n"; } $email_message .= "\n"; } $user_email = &find_user_email(@resv_form_fields); &send_email_notifications($email_message,$resource_key,$user_email,"DEL", ""); exit; } sub auto_delete_recurring_reservations { local ( $resource_key, $week_name, $day_index, $current_seconds, $recurring_start_seconds, $recurring_end_seconds, $modify_flag, $send_notification_flag, @resv_form_fields) = @_; local ($resource_name, $res_start_time, $res_end_time, $file_name, $date_string, $line_index, $current_line, $data_index, $begin_time, $end_time, $formatted_line, $inserted, $inserted2, $index, $found_flag, $first_day_index, $first_time, $end_week_name, $end_file_name, $cumulative_seconds, $recurring_count, $email_message, $recurring_dates, @lines, @recurring_data, @cur_fields, @orig_resv_form_fields); $resource_name = &get_resource_name($resource_key); @resv_form_fields = &get_posted_reservation_data(); $res_start_time = $gtime_range_start; $res_end_time = $gtime_range_stop; $recurring_count = 1; @orig_resv_form_fields = (); $end_week_name = &get_week_name($recurring_end_seconds); # in the form MM-DD-YYYY $end_file_name = $data_directory . $end_week_name; $end_file_name .= ".txt"; $cumulative_seconds = $recurring_start_seconds; $week_name = &get_week_name($recurring_start_seconds); # in the form MM-DD-YYYY $file_name = $data_directory . $week_name; $file_name .= ".txt"; if ($file_name ne $end_file_name) # if all recurring reservations are not in the same (one) file { $recurring_count = 1; $first_time = 0; $end_week_name = &get_week_name(($recurring_end_seconds + ($SECONDS_PER_DAY * 7))); # in the form MM-DD-YYYY $end_file_name = $data_directory . $end_week_name; $end_file_name .= ".txt"; while ($file_name ne $end_file_name) { if (-e $file_name) { if ($first_time == 0) { if ($modify_flag) { $first_day_index = $day_index; } else { $first_day_index = $day_index + 1; } @recurring_data = &delete_recurring_in_file($week_name, $file_name, $cumulative_seconds, $fist_day_index, $resource_key, $recurring_start_seconds, $res_start_time, $res_end_time, $current_seconds, $date_string); $recurring_count += $recurring_data[0]; $recurring_dates .= $recurring_data[1]; if ($#orig_resv_form_fields <= 1) { @orig_resv_form_fields = $recurring_data[4]; } $first_time = 1; } else { @recurring_data = &delete_recurring_in_file($week_name, $file_name, $cumulative_seconds, 0, $resource_key, $recurring_start_seconds, $res_start_time, $res_end_time, $current_seconds, $date_string); $recurring_count += $recurring_data[0]; $recurring_dates .= $recurring_data[1]; if ($#orig_resv_form_fields <= 1) { @orig_resv_form_fields = $recurring_data[4]; } } } # end if -e $file_name - its okay if it doesnt exist! $cumulative_seconds += ($SECONDS_PER_DAY * 7); $week_name = &get_week_name($cumulative_seconds); # in the form MM-DD-YYYY $file_name = $data_directory . $week_name; $file_name .= ".txt"; } # end while ($file_name ne $end_file_name) } # end if $file_name ne $end_file_name else { if ($modify_flag) { $first_day_index = $day_index; } else { $day_index++; } @recurring_data = &delete_recurring_in_file($week_name, $file_name, $cumulative_seconds, $day_index, $resource_key, $recurring_start_seconds, $res_start_time, $res_end_time, $current_seconds, $date_string); $recurring_count += $recurring_data[0]; $recurring_dates .= $recurring_data[1]; if ($#orig_resv_form_fields <= 1) { @orig_resv_form_fields = $recurring_data[4]; } } # end else if $file_name ne $end_file_name if ($send_notification_flag == 1) { $result_message = "
Reservation was CANCELLED.

"; print "Content-type: text/html\n\n"; print "\n"; print "\n"; print "\n\n"; print "uReserve"; print ""; print "
"; print ""; print "
$delete_results

"; print ""; print "

"; print "$result_message"; print "

"; print "$refresh_message"; print "

"; print "

"; print "
"; print ""; print "
"; print "
"; print ""; $date_string = &get_exact_date($current_seconds); $num_days = 0; $full_num = 0.0; $num_days = int(($recurring_end_seconds - $recurring_start_seconds) / $SECONDS_PER_DAY); $full_num = ($recurring_end_seconds - $recurring_start_seconds) / $SECONDS_PER_DAY; if (($full_num - $num_days) > 0) { $num_days++; } $email_message = "The following reservation was CANCELLED:\n\n"; $email_message .= &get_reservation_result( $current_seconds, $resource_key, $res_start_time, $res_end_time, $num_days, $recurring_start_seconds, $recurring_end_seconds, 0, #recurring_flag @resv_form_fields); $user_email = &find_user_email(@resv_form_fields); &send_email_notifications($email_message,$resource_key,$user_email,"DEL", ""); } # end if send_notification_flag == 1 return @orig_resv_form_fields; } sub delete_recurring_in_file { local ($week_name, $file_name, $cumulative_seconds, $day_index, $resource_key, $recurring_start_seconds, $res_start_time, $res_end_time, $current_seconds, $date_string) = @_; local ( $random_number, $temp_file, $line_index, $current_line, $found_flag, $inserted2, $formatted_line, $data_index, $begin_time, $end_time, $this_recurring_start_seconds, $this_recurring_end_seconds, $org_password, $deletion_details, $recurring_date, $recurring_count, $sub_name, $status, @lines, @reservation_data_pairs, @string_value_pairs, @pending_value_pairs, @cur_fields, @resv_form_fields); $sub_name = "delete_recurring_in_file"; $recurring_count = 0; $recurring_date = ""; @resv_form_fields = (); @lines = &get_reservation_data_file($file_name); while ($day_index < 8) { $line_index = 0; $found_flag = 0; $inserted2 = 0; $formatted_line = $resource_key; $current_line = ""; if ($#lines > 0) { $current_line = &get_reservation_data_by_resource_and_day($resource_key, $day_index, @lines); } if ($current_line =~ /\S/) { @reservation_data_pairs = split (/\|/, $current_line); for ($data_index = 1; $data_index < $#reservation_data_pairs; $data_index += 25) { @cur_fields = &get_current_fields($data_index, @reservation_data_pairs); $begin_time = $cur_fields[6]; $begin_time = &strip_letters($begin_time); $end_time = $cur_fields[7]; $end_time = &strip_letters($end_time); $this_recurring_start_seconds = 0; $this_recurring_end_seconds = 0; @string_value_pairs = split (/\?/, $cur_fields[5]); if ($string_value_pairs[2] =~ /\S/) { $this_recurring_start_seconds = $string_value_pairs[2]; $this_recurring_end_seconds = $string_value_pairs[3]; } if ($this_recurring_start_seconds == $recurring_start_seconds) { $org_password = &get_original_password($string_value_pairs[0]); $found_flag = 1; $recurring_count++; $log_seconds = $cumulative_seconds + (($day_index-1) * $SECONDS_PER_DAY); $date_string = &get_exact_date($log_seconds); $recurring_date .= $date_string . "|"; if ($settings[9] =~ /YES/i) { $action_string = "DEL"; if ($pending_value_pairs[1] =~ /PENDING/i) { $action_string .= "-PENDING"; } @resv_form_fields = &prep_resv_form_fields_array($data_index, @reservation_data_pairs); &update_reservation_log($action_string, $resource_key, $log_seconds, $begin_time, $end_time, @resv_form_fields); } @orig_resv_form_fields = @reservation_data_pairs; } else { $formatted_line .= (&prep_cur_fields_line_for_reservation_file(0, @cur_fields)); # 0=dont remove pending indr } } } # end if ($current_line =~ /\S/) if ($found_flag == 1) { srand(time|$$); $random_number = int(rand(10000000)); $temp_file = $data_directory . "ureserve" . $random_number . ".tmp"; if (-e $temp_file) { $random_number++; $temp_file = $data_directory . "ureserve" . $random_number . ".tmp"; } if (!(open(TEMP_DATA_FILE, ">" . $temp_file))) { &return_error("File Error","Unable to open " . $temp_file); } else { &log_info($DEBUG,"TEMP FILE: $temp_file was created in sub delete_recurring_in_file."); } $found_flag = 0; $inserted2 = 0; for ($line_index = 0; $line_index <= $#lines; $line_index++) { if ($lines[$line_index] =~ /^#$day_index/i) { $found_flag = 1; print TEMP_DATA_FILE $lines[$line_index]; } elsif (($found_flag == 1) && ($inserted2 == 0)) { if (($lines[$line_index] =~ /^#END$day_index/i) && ($inserted2 == 0)) { print TEMP_DATA_FILE "$formatted_line\n"; $inserted2 = 1; print TEMP_DATA_FILE $lines[$line_index]; } else { @reservation_data_pairs = split (/\|/, $lines[$line_index]); $current_key = $reservation_data_pairs[0]; if (int($current_key) == int($resource_key)) { print TEMP_DATA_FILE "$formatted_line\n"; $inserted2 = 1; } else { print TEMP_DATA_FILE $lines[$line_index]; } } } else { print TEMP_DATA_FILE $lines[$line_index]; } } # end for ($line_index = 0; $line_index <= $#lines; $line_index++) close(TEMP_DATA_FILE); $status = 0; $status = &safe_swap($file_name, $temp_file, $sub_name); if ($status == -1) { &return_error("SERVER TIMEOUT","Unable to process recurring deletes in " . $week_name . ".
Examine results and resubmit as needed."); } } # end if $found_flag == 1 $day_index++; open (SCHEDULE_FILE, $file_name) || &return_error("File Error","Unable to open " . $file_name); @lines = ; close(SCHEDULE_FILE); } # end while (($day_index < 8)) && ($line_index <= $#lines)) $recurring_data[0] = $recurring_count; $recurring_data[1] = $recurring_date; $recurring_data[2] = ""; $recurring_data[3] = ""; $recurring_data[4] = @orig_resv_form_fields; return @recurring_data; } # end delete_recurring_in_file sub authorize_pending_reservations { local ($approve_flag, $passthru, $skip_email) = @_; local ( $file_date, $week_name, $day_index, $current_seconds, $cumulative_seconds, $org_start_time, $org_end_time, $res_start_time, $res_end_time, $resv_form_password, $file_name, $formatted_date, $line_index, $current_line, $data_index, $begin_time, $end_time, $cur_begin_time, $cur_end_time, $formatted_line, $start_time_formatted, $pending_modified, $index, $found_flag, $action, $action_string, $msg_action, $resource_name, $mode, $email_message, $resource_settings, $first_date_seconds, $recurring_start_seconds, $recurring_end_seconds, $org_recurring_start_seconds, $org_recurring_end_seconds, $recurring_action, $pending_detail, $pending_detail_list, $pending_note, $error_list, $num_errors, $user_auth, $temp_file, $sub_name, $status, $random_number, @pending_detail_choices, @lines, @reservation_data_pairs, @pending_value_pairs, @resource_value_pairs, @cur_fields, @resv_form_fields); $sub_name = "authorize_pending_reservations"; &validate_referral_page($script_url); $pending_detail_list = $form_text{'pending_detail_list'}; $result_message = ""; $pending_note = ""; $pending_note = $form_text{'pending_note'}; if ($passthru) { @pending_detail_choices=split(/~~/,$pending_detail_list); } else { @pending_detail_choices=split(/\0/,$pending_detail_list); } $user_auth = &get_user_group($username, $password); $user_auth = int($user_auth); if ($user_auth == $RESOURCE_ADMIN) { $num_errors = 0; $error_list = ""; foreach $pending_detail (@pending_detail_choices) { $resource_key = ""; @pending_value_pairs = (); @pending_value_pairs = split (/\^/, $pending_detail); # fix v4.0 $resource_key = $pending_value_pairs[3]; if (&validate_resource_admin($username, $password, $resource_key) == 0) { $error_list .= &get_resource_name($resource_key); $error_list .= "
"; $num_errors++; } } # end foreach if ($num_errors > 0) { &missing_input("Not Authorized","You are not authorized to manage pending reservations for the following resources:

$error_list"); } } foreach $pending_detail (@pending_detail_choices) { $file_date = ""; $week_name = ""; $day_index = ""; $begin_time = ""; $end_time = ""; $res_start_seconds = 0; $res_end_seconds = 0; $res_num_days = 0; @pending_value_pairs = (); @pending_value_pairs = split (/\^/, $pending_detail); # fix v4.0 $file_date = $pending_value_pairs[0]; $week_name = $pending_value_pairs[1]; $day_index = $pending_value_pairs[2]; $resource_key = $pending_value_pairs[3]; $begin_time = $pending_value_pairs[4]; $end_time = $pending_value_pairs[5]; $res_start_seconds = $pending_value_pairs[6]; $res_end_seconds = $pending_value_pairs[7]; $num_days = 0; $full_num = 0.0; $num_days = int(($res_end_seconds - $res_start_seconds) / $SECONDS_PER_DAY); $full_num = ($res_end_seconds - $res_start_seconds) / $SECONDS_PER_DAY; if (($full_num - $num_days) > 0) { $num_days++; } $org_recurring_start_seconds = 0; $org_recurring_end_seconds = 0; $recurring_start_seconds = 0; $recurring_end_seconds = 0; $cumulative_seconds = &get_week_seconds($week_name); if ($day_index > 1) { $cumulative_seconds += ($SECONDS_PER_DAY*($day_index-1)); } $formatted_date = &get_exact_date($cumulative_seconds); $first_date_seconds = $cumulative_seconds; $file_name = $data_directory . $week_name . ".txt"; $line_index = 0; $formatted_line = "$resource_key"; $pending_modified = 0; @lines = (); $current_line = ""; if (-e $file_name) { @lines = &get_reservation_data_file($file_name); if ($#lines > 0) { $current_line = &get_reservation_data_by_resource_and_day($resource_key, $day_index, @lines); } if ($current_line =~ /\S/) { @reservation_data_pairs = split (/\|/, $current_line); for ($data_index = 1; $data_index < $#reservation_data_pairs; $data_index += 25) { @cur_fields = &get_current_fields($data_index, @reservation_data_pairs); $cur_begin_time = $cur_fields[6]; $cur_begin_time = &strip_letters($cur_begin_time); $cur_end_time = $cur_fields[7]; $cur_end_time = &strip_letters($cur_end_time); if (($cur_begin_time == $begin_time) && ($cur_end_time == $end_time)) { @string_value_pairs = split (/\?/, $cur_fields[5]); if ($string_value_pairs[2] =~ /\S/) { $recurring_start_seconds = $string_value_pairs[2]; $recurring_end_seconds = $string_value_pairs[3]; } $org_recurring_start_seconds = $recurring_start_seconds; # save this off!!! $org_recurring_end_seconds = $recurring_end_seconds; # save this off!!! } if (($cur_begin_time == $begin_time) && ($cur_end_time == $end_time)) { $pending_modified = 1; if ($approve_flag) { $formatted_line .= (&prep_cur_fields_line_for_reservation_file(1, @cur_fields)); # 1=remove pending indr $action_string = "AUTH-PENDING"; $action = $lang_accepted; $mode = "AUTH"; $msg_action = $lang_activated; } else { $action_string = "REJ-PENDING"; $action = $lang_rejected; $mode = "REJ"; $msg_action = $lang_cancelled; } @resv_form_fields = &prep_resv_form_fields_array($data_index, @reservation_data_pairs); if ($settings[9] =~ /YES/i) { &update_reservation_log($action_string, $resource_key, $cumulative_seconds, $begin_time, $end_time, @resv_form_fields); } $resource_name = &get_resource_name($resource_key); $start_time_formatted = &format_time($begin_time); &log_info($ADMIN,"$username $mag_action reservation: $formatted_date $resource_name at $start_time_formatted."); $email_message = "The following reservation has been $action:\n\n"; $email_message .= &get_reservation_result( $cumulative_seconds, $resource_key, $begin_time, $end_time, $num_days, $org_recurring_start_seconds, $org_recurring_end_seconds, 0, @resv_form_fields); $user_email = &find_user_email(@resv_form_fields); if ($skip_email == 0) { &send_email_notifications($email_message, $resource_key, $user_email, $mode, $pending_note); } } else { $formatted_line .= (&prep_cur_fields_line_for_reservation_file(0, @cur_fields)); # 0=dont remove pending indr } } # end for ($data_index = 1; $data_index < $#reservation_data_pairs; $data_index += 25) } # end if current_line if ($pending_modified == 1) { srand(time|$$); $random_number = int(rand(10000000)); $temp_file = $data_directory . "ureserve" . $random_number . ".tmp"; if (-e $temp_file) { $random_number++; $temp_file = $data_directory . "ureserve" . $random_number . ".tmp"; } if (!(open(TEMP_DATA_FILE, ">" . $temp_file))) { &return_error("File Error","Unable to open " . $temp_file); } else { &log_info($DEBUG,"TEMP FILE: $temp_file was created in sub authorize_pending_reservations."); } $found_flag = 0; $pending_modified = 0; for ($line_index = 0; $line_index <= $#lines; $line_index++) { if ($lines[$line_index] =~ /^#$day_index/i) { $found_flag = 1; print TEMP_DATA_FILE $lines[$line_index]; } elsif (($found_flag == 1) && ($pending_modified == 0)) { if (($lines[$line_index] =~ /^#END$day_index/i) && ($pending_modified == 0)) { print TEMP_DATA_FILE "$formatted_line\n"; $pending_modified = 1; print TEMP_DATA_FILE $lines[$line_index]; } else { @reservation_data_pairs = split (/\|/, $lines[$line_index]); $current_key = $reservation_data_pairs[0]; if (int($current_key) == int($resource_key)) { print TEMP_DATA_FILE "$formatted_line\n"; $pending_modified = 1; } else { print TEMP_DATA_FILE $lines[$line_index]; } } } else { print TEMP_DATA_FILE $lines[$line_index]; } } close(TEMP_DATA_FILE); $status = 0; $status = &safe_swap($file_name, $temp_file, $sub_name); if ($status == -1) { &return_error("SERVER TIMEOUT","Unable to update pending reservations in " . $week_name . ".
Examine results and resubmit request as needed."); } if (($#pending_detail_choices == 0) && ($org_recurring_start_seconds > 0) && ($settings[97] =~ /STANDARD/i)) { if ($approve_flag) { $recurring_action = $lang_authorize; } else { $recurring_action = $lang_reject; } $result_message = "
This reservation is part of a recurring reservation. Do you also want to $recurring_action all related reservations?
"; print "Content-type: text/html\n\n"; print "\n"; print "\n"; print "\n\n"; print "uReserve"; print ""; print "
"; print ""; print "
$recurring_action Pending Reservations

"; print ""; print "

"; print "$result_message"; print "

"; print "
"; if ($approve_flag) { print ""; } else { print ""; } print ""; print ""; print ""; print "    "; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print "
"; print "
"; print ""; return -1; } # end if (($#pending_detail_choices == 0) && ($org_recurring_start_seconds > 0) && ($settings[97] =~ /STANDARD/i)) else { if (($#pending_detail_choices > 0) && ($org_recurring_start_seconds > 0) && ($settings[97] =~ /STANDARD/i)) { } elsif ( ($org_recurring_start_seconds > 0) && (($settings[97] =~ /DAILY/i) || ($settings[97] =~ /DATE_RANGE/i)) ) { &auto_authorize_pending_recurring_reservations( $approve_flag, $pending_note, $resource_key, $day_index, $current_seconds, $org_recurring_start_seconds, $org_recurring_end_seconds, $resv_form_username, $resv_form_password, @resv_form_fields); } } } # end if pending_modified == 1 } # end if (-e $file_name) else { } } # end foreach pending_detail_choices $adj_number_modified = $#pending_detail_choices + 1; if ($pending_modified == 1) { if ($#pending_detail_choices > 0) { $result_message = "$adj_number_modified reservations were $msg_action."; } else { $result_message = "The reservation was $msg_action."; } } else { $result_message = "No reservations were $msg_action."; } return $result_message; } sub authorize_pending_recurring_reservation { local ($approve_flag) = @_; local ($resource_name, $week_name, $day_index, $current_seconds, $res_start_time, $res_end_time, $res_start_date, $res_end_date, $full_num, $num_days, $res_password, $file_name, $date_string, $line_index, $current_line, $data_index, $begin_time, $end_time, $formatted_line, $inserted, $index, $found_flag, $end_week_name, $end_file_name, $recurring_start_seconds, $recurring_end_seconds, $start_seconds_to_compare, $cumulative_seconds, $recurring_count, $email_message, $first_time, $recurring_dates, $first_date_seconds, @recurring_data, @lines, @resv_form_fields, @cur_fields); &validate_referral_page($script_url); $resource_key = $form_text{'resource_key'}; $week_name = $form_text{'week'}; $day_index = $form_text{'day'}; $day_index = &strip_letters($day_index); $current_seconds = $form_text{'seconds'}; $current_seconds = &strip_letters($current_seconds); $recurring_start_seconds = $form_text{'recurring_start_seconds'}; $recurring_end_seconds = $form_text{'recurring_end_seconds'}; $first_date_seconds = $form_text{'first_date_seconds'}; $res_start_time = $form_text{'res_start_time'}; $res_start_time = &strip_letters($res_start_time); $res_end_time = $form_text{'res_end_time'}; $res_end_time = &strip_letters($res_end_time); $num_days = 0; $full_num = 0.0; $num_days = int(($recurring_end_seconds - $recurring_start_seconds) / $SECONDS_PER_DAY); $full_num = ($recurring_end_seconds - $recurring_start_seconds) / $SECONDS_PER_DAY; if (($full_num - $num_days) > 0) { $num_days++; } @resv_form_fields = &get_posted_reservation_data(); $recurring_count = 1; $recurring_dates = ""; $end_week_name = &get_week_name($recurring_end_seconds); # in the form MM-DD-YYYY $end_file_name = $data_directory . $end_week_name; $end_file_name .= ".txt"; $start_seconds_to_compare = $recurring_start_seconds; $cumulative_seconds = &get_week_seconds($week_name); $week_name = &get_week_name($cumulative_seconds); # in the form MM-DD-YYYY $file_name = $data_directory . $week_name; $file_name .= ".txt"; if ($file_name ne $end_file_name) # if all recurring reservations are not in the same (one) file { $recurring_count = 1; $first_time = 0; $end_week_name = &get_week_name(($recurring_end_seconds + ($SECONDS_PER_DAY * 7))); # in the form MM-DD-YYYY $end_file_name = $data_directory . $end_week_name; $end_file_name .= ".txt"; while ($file_name ne $end_file_name) { if (-e $file_name) { if ($first_time == 0) { @recurring_data = &authorize_pending_recurring_in_file($approve_flag, $week_name, $file_name, $cumulative_seconds, ($day_index+1), $resource_key, $recurring_start_seconds, $current_seconds, $date_string, $res_start_time, $res_end_time, @resv_form_fields); $recurring_count += $recurring_data[0]; $recurring_dates .= $recurring_data[1]; $first_time = 1; } else { @recurring_data = &authorize_pending_recurring_in_file($approve_flag, $week_name, $file_name, $cumulative_seconds, 0, $resource_key, $recurring_start_seconds, $current_seconds, $date_string, $res_start_time, $res_end_time, @resv_form_fields); $recurring_count += $recurring_data[0]; $recurring_dates .= $recurring_data[1]; } } # end if -e $file_name - its okay if it doesnt exist! $cumulative_seconds += ($SECONDS_PER_DAY * 7); $week_name = &get_week_name($cumulative_seconds); # in the form MM-DD-YYYY $file_name = $data_directory . $week_name; $file_name .= ".txt"; } # end while ($file_name ne $end_file_name) } # end if $file_name ne $end_file_name else { $day_index++; @recurring_data = &authorize_pending_recurring_in_file($approve_flag, $week_name, $file_name, $cumulative_seconds, $day_index, $resource_key, $recurring_start_seconds, $current_seconds, $date_string, $res_start_time, $res_end_time, @resv_form_fields); $recurring_count += $recurring_data[0]; $recurring_dates .= $recurring_data[1]; } # end else if $file_name ne $end_file_name $result_message = "
" . $recurring_count; if ($recurring_count <= 1) { $more_text = " was"; } else { $more_text = "s were"; } if ($approve_flag) { $result_message .= " reservation" . $more_text . " activated.

"; } else { $result_message .= " reservation" . $more_text . " cancelled.

"; } $email_message = "The following "; if ($recurring_count <= 1) { $date_string = &get_exact_date($current_seconds); if ($approve_flag) { $email_message .= "reservation was AUTHORIZED:\n\n"; } else { $email_message .= "reservation was REJECTED:\n\n"; } $email_message .= &get_reservation_result( $current_seconds, $resource_key, $res_start_time, $res_end_time, $num_days, $recurring_start_seconds, $recurring_end_seconds, 0, #recurring_flag @resv_form_fields); } else { $date_string = &get_exact_date($first_date_seconds); if ($approve_flag) { $email_message .= "recurring reservations were AUTHORIZED:\n\nDates:\n"; } else { $email_message .= "recurring reservations were REJECTED:\n\nDates:\n"; } $email_message .= "$date_string\n"; $date_string = ""; for ($i=0; $i<($recurring_count-1); $i++) { @data_value_pairs = split (/\|/, $recurring_dates); $date_string = $data_value_pairs[$i]; $email_message .= "$date_string\n"; } $email_message .= "\n"; $email_message .= &get_reservation_result( $current_seconds, $resource_key, $res_start_time, $res_end_time, $num_days, $recurring_start_seconds, $recurring_end_seconds, 1, #recurring_flag @resv_form_fields); } $user_email = &find_user_email(@resv_form_fields); if ($approve_flag) { &send_email_notifications($email_message,$resource_key,$user_email,"AUTH", ""); } else { &send_email_notifications($email_message,$resource_key,$user_email,"REJ", ""); } return ($result_message); } sub auto_authorize_pending_recurring_reservations { local ( $approve_flag, $pending_note, $resource_key, $day_index, $current_seconds, $recurring_start_seconds, $recurring_end_seconds, $resv_form_username, $resv_form_password, @resv_form_fields) = @_; local ($resource_name, $week_name, $res_start_time, $res_end_time, $res_password, $file_name, $date_string, $line_index, $current_line, $data_index, $begin_time, $end_time, $formatted_line, $inserted, $index, $found_flag, $end_week_name, $end_file_name, $start_seconds_to_compare, $cumulative_seconds, $recurring_count, $email_message, $first_time, $recurring_dates, @recurring_data, @lines, @cur_fields); $res_start_time = $gtime_range_start; $res_end_time = $gtime_range_stop; $recurring_count = 1; $recurring_dates = ""; $end_week_name = &get_week_name($recurring_end_seconds); # in the form MM-DD-YYYY $end_file_name = $data_directory . $end_week_name; $end_file_name .= ".txt"; $start_seconds_to_compare = $recurring_start_seconds; $cumulative_seconds = $recurring_start_seconds; $week_name = &get_week_name($cumulative_seconds); # in the form MM-DD-YYYY $file_name = $data_directory . $week_name; $file_name .= ".txt"; if ($file_name ne $end_file_name) # if all recurring reservations are not in the same (one) file { $recurring_count = 1; $first_time = 0; $end_week_name = &get_week_name(($recurring_end_seconds + ($SECONDS_PER_DAY * 7))); # in the form MM-DD-YYYY $end_file_name = $data_directory . $end_week_name; $end_file_name .= ".txt"; while ($file_name ne $end_file_name) { if (-e $file_name) { if ($first_time == 0) { @recurring_data = &authorize_pending_recurring_in_file($approve_flag, $week_name, $file_name, $cumulative_seconds, ($day_index+1), $resource_key, $recurring_start_seconds, $current_seconds, $date_string, $res_start_time, $res_end_time, @resv_form_fields); $recurring_count += $recurring_data[0]; $recurring_dates .= $recurring_data[1]; $first_time = 1; } else { @recurring_data = &authorize_pending_recurring_in_file($approve_flag, $week_name, $file_name, $cumulative_seconds, 0, $resource_key, $recurring_start_seconds, $current_seconds, $date_string, $res_start_time, $res_end_time, @resv_form_fields); $recurring_count += $recurring_data[0]; $recurring_dates .= $recurring_data[1]; } } # end if -e $file_name - its okay if it doesnt exist! $cumulative_seconds += ($SECONDS_PER_DAY * 7); $week_name = &get_week_name($cumulative_seconds); # in the form MM-DD-YYYY $file_name = $data_directory . $week_name; $file_name .= ".txt"; } # end while ($file_name ne $end_file_name) } # end if $file_name ne $end_file_name else { $day_index++; @recurring_data = &authorize_pending_recurring_in_file($approve_flag, $week_name, $file_name, $cumulative_seconds, $day_index, $resource_key, $recurring_start_seconds, $current_seconds, $date_string, $res_start_time, $res_end_time, @resv_form_fields); $recurring_count += $recurring_data[0]; $recurring_dates .= $recurring_data[1]; } # end else if $file_name ne $end_file_name if ($approve_flag) { $result_message = "
The reservation was activated.

"; } else { $result_message = "
The reservation was cancelled.

"; } return ($result_message); } sub authorize_pending_recurring_in_file { local ( $approve_flag, $week_name, $file_name, $cumulative_seconds, $day_index, $resource_key, $recurring_start_seconds, $current_seconds, $date_string, $res_start_time, $res_end_time, @resv_form_fields) = @_; local ( $random_number, $temp_file, $line_index, $current_line, $found_flag, $inserted2, $formatted_line, $data_index, $begin_time, $end_time, $this_recurring_start_seconds, $this_recurring_end_seconds, $org_password, $temp_res_start_time, $temp_res_end_time, $recurring_date, $recurring_count, $action_string, $action, $mode, $msg_action, $sub_name, $status, @reservation_data_pairs, @lines, @string_value_pairs, @cur_fields); $sub_name = "authorize_pending_recurring_in_file"; $recurring_count = 0; $recurring_date = ""; $start_day_index = $day_index; # Save this off! @lines = &get_reservation_data_file($file_name); while ($day_index < 8) { $line_index = 0; $found_flag = 0; $inserted2 = 0; $formatted_line = $resource_key; $current_line = ""; if ($#lines > 0) { $current_line = &get_reservation_data_by_resource_and_day($resource_key, $day_index, @lines); } if ($current_line =~ /\S/) { @reservation_data_pairs = split (/\|/, $current_line); for ($data_index = 1; $data_index < $#reservation_data_pairs; $data_index += 25) { @cur_fields = &get_current_fields($data_index, @reservation_data_pairs); $this_recurring_start_seconds = 0; $this_recurring_end_seconds = 0; @string_value_pairs = split (/\?/, $cur_fields[5]); if ($string_value_pairs[2] =~ /\S/) { $this_recurring_start_seconds = $string_value_pairs[2]; $this_recurring_end_seconds = $string_value_pairs[3]; } if (($this_recurring_start_seconds == $recurring_start_seconds) && ($cur_fields[1] =~ /PENDING/i)) { $org_password = &get_original_password($string_value_pairs[0]); $found_flag = 1; $recurring_count++; $log_seconds = $cumulative_seconds + (($day_index-1) * $SECONDS_PER_DAY); $date_string = &get_exact_date($log_seconds); $recurring_date .= $date_string . "|"; if ($settings[9] =~ /YES/i) { if ($approve_flag) { $action_string = "AUTH-PENDING-RECURRING"; $action = $lang_accepted; $mode = "AUTH"; $msg_action = $lang_activated; } else { $action_string = "REJ-PENDING-RECURRING"; $action = $lang_rejected; $mode = "REJ"; $msg_action = $lang_cancelled; } &update_reservation_log($action_string, $resource_key, $log_seconds, $res_start_time, $res_end_time, @resv_form_fields); } $resource_name = &get_resource_name($resource_key); $start_time_formatted = &format_time($res_start_time); &log_info($ADMIN,"$username $mag_action reservation: $date_string $resource_name at $start_time_formatted."); } else { if ((&compare_lt($res_start_time, $begin_time))) # v3.24 fix { if ($approve_flag) { $formatted_line .= (&prep_cur_fields_line_for_reservation_file(1, @cur_fields)); # 1=remove pending indr } else { } $inserted2 = 1; } $formatted_line .= (&prep_cur_fields_line_for_reservation_file(0, @cur_fields)); # 0=dont remove pending indr } } if ($inserted2 == 0) { if ($approve_flag) { $formatted_line .= (&prep_cur_fields_line_for_reservation_file(1, @cur_fields)); # 1= remove pending indr } else { } } } # end if ($current_line =~ /\S/) if ($found_flag == 1) { if (!(-e $file_name)) { open(SCHEDULE_DATA_FILE,">>$file_name") || &return_error("File Error","Unable to open " . $file_name); for ($index = 1; $index < 8; $index++) { print SCHEDULE_DATA_FILE "#$index\n"; if ($index == $day_index) { print SCHEDULE_DATA_FILE "$formatted_line\n"; } print SCHEDULE_DATA_FILE "#END$index\n"; } close(SCHEDULE_DATA_FILE); chmod(0777, $file_name); } else { srand(time|$$); $random_number = int(rand(10000000)); $temp_file = $data_directory . "ureserve" . $random_number . ".tmp"; if (-e $temp_file) { $random_number++; $temp_file = $data_directory . "ureserve" . $random_number . ".tmp"; } if (!(open(TEMP_DATA_FILE, ">" . $temp_file))) { &return_error("File Error","Unable to open " . $temp_file); } else { &log_info($DEBUG,"TEMP FILE: $temp_file was created in sub authorize_pending_recurring_in_file."); } $found_flag = 0; $inserted2 = 0; for ($line_index = 0; $line_index <= $#lines; $line_index++) { if ($lines[$line_index] =~ /^#$day_index/i) { $found_flag = 1; print TEMP_DATA_FILE $lines[$line_index]; } elsif (($found_flag == 1) && ($inserted2 == 0)) { if (($lines[$line_index] =~ /^#END$day_index/i) && ($inserted2 == 0)) { print TEMP_DATA_FILE "$formatted_line\n"; $inserted2 = 1; print TEMP_DATA_FILE $lines[$line_index]; } else { @reservation_data_pairs = split (/\|/, $lines[$line_index]); $current_key = $reservation_data_pairs[0]; if (int($current_key) == int($resource_key)) { print TEMP_DATA_FILE "$formatted_line\n"; $inserted2 = 1; } else { print TEMP_DATA_FILE $lines[$line_index]; } } } else { print TEMP_DATA_FILE $lines[$line_index]; } } # end for ($line_index = 0; $line_index <= $#lines; $line_index++) close(TEMP_DATA_FILE); $status = 0; $status = &safe_swap($file_name, $temp_file, $sub_name); if ($status == -1) { &return_error("SERVER TIMEOUT","Unable to process recurring pending reservations in " . $week_name . ".
Examine results and resubmit requests as needed."); } } } # end if $found_flag == 1 else { print TEMP_DATA_FILE $lines[$line_index]; } $day_index++; open (SCHEDULE_FILE, $file_name) || &return_error("File Error","Unable to open " . $file_name); @lines = ; close(SCHEDULE_FILE); } # end while (($day_index < 8)) && ($line_index <= $#lines)) $recurring_data[0] = $recurring_count; $recurring_data[1] = $recurring_date; return @recurring_data; } # end authorize_pending_recurring_in_file sub update_reservation_log { local ($log_action, $log_resource_key, $log_seconds, $log_start_time, $log_end_time, @log_fields) = @_; local ( $current_time, $sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst, $log_resource_name); $log_resource_name = &get_resource_name($log_resource_key); ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(); $year += 1900; $mon += 1; if ($settings[5] =~ /US/i) { $current_time = sprintf("%02d/%02d/%04d %02d:%02d",$mon,$mday,$year,$hour,$min); } else { $current_time = sprintf("%02d/%02d/%04d %02d:%02d",$mday,$mon,$year,$hour,$min); } if ($settings[0] eq "CONFIG") { $temp_res_start_time = $column_names[$log_start_time]; $temp_res_end_time = $column_names[$log_end_time]; } else { $temp_res_start_time = &format_time($log_start_time); $temp_res_end_time = &format_time($log_end_time); } $log_date_string = &get_exact_date($log_seconds); if (open(RES_LOG, ">>" . $greservation_log_file)) { print RES_LOG $current_time . "|"; print RES_LOG $log_action . "|"; print RES_LOG $log_resource_name . "|"; print RES_LOG $log_date_string . "|"; print RES_LOG $temp_res_start_time . "|"; print RES_LOG $temp_res_end_time . "|"; @pending_value_pairs = split (/\?/, $log_fields[0]); print RES_LOG $pending_value_pairs[1] . "|"; for ($j=1; $j < ($#log_fields - 1); $j++) { print RES_LOG $log_fields[$j] . "|"; } print RES_LOG $log_fields[$#log_fields - 1] . "\n"; close(RES_LOG); chmod(0777, $greservation_log_file); } } sub create_add_edit_resource_form { local ($mode) = @_; local ($resource_key, $resource_field1, $resource_field2, $resource_field3, $resource_field4, $resource_field5, $resource_field_img, $resource_category_key, $resource_start_date, $resource_end_date, $permission_level, $placeholder_field, $fixed_reservation_hours, $fixed_reservation_minutes, $max_reservation_hours, $max_reservation_minutes, $lead_time_create_days, $lead_time_create_hours, $lead_time_create_minutes, $lead_time_cancel_days, $lead_time_cancel_hours, $lead_time_cancel_minutes, $resource_email_text, $pending_flag, $pending_email_text, $placeholder_max_chars, $buffer_periods_between, $buffer_hours_between, $buffer_minutes_between, $max_advance_days, $line, $resource_name, $user_auth, $placeholder_select_html, @resource_data_pairs, $found_flag); &validate_referral_page($script_url); $found_flag = 0; $resource_field1 = ""; $resource_field2 = ""; $resource_field3 = ""; $resource_field4 = ""; $resource_field5 = ""; $permission_level = ""; $placeholder_field = ""; $fixed_reservation_hours = ""; $fixed_reservation_minutes = ""; $max_reservation_hours = ""; $max_reservation_minutes = ""; $lead_time_create_days = ""; $lead_time_create_hours = ""; $lead_time_create_minutes = ""; $lead_time_cancel_days = ""; $lead_time_cancel_hours = ""; $lead_time_cancel_minutes = ""; $buffer_periods_between = ""; $buffer_hours_between = ""; $buffer_minutes_between = ""; $resource_email_text = ""; $pending_flag = ""; $pending_email_text = ""; $placeholder_max_chars = ""; $resource_field_img = ""; $resource_category_key = ""; $resource_start_date = ""; $resource_end_date = ""; $max_advance_days = ""; if ($mode eq "EDIT") { $resource_key = $form_text{'resource_key'}; $user_auth = &get_user_group($username, $password); $user_auth = int($user_auth); if ($user_auth == $RESOURCE_ADMIN) { if (&validate_resource_admin($username, $password, $resource_key) == 0) { $resource_name = &get_resource_name($resource_key); &missing_input("Not Authorized", "You are not authorized to EDIT this resource ($resource_name)"); } } } if (open (RESOURCE_FILE, $gresource_file)) { while () { $line = $_; chop($line); @resource_data_pairs = split (/\|/, $line); $current_key = $resource_data_pairs[0]; if (($found_flag == 0) && (int($current_key) == int($resource_key))) { $resource_category_key = &get_resource_category_key(@resource_data_pairs); $resource_start_date = &get_resource_start_date(@resource_data_pairs); $resource_end_date= &get_resource_end_date(@resource_data_pairs); $resource_field1 = $resource_data_pairs[5]; $resource_field2 = $resource_data_pairs[6]; $resource_field3 = $resource_data_pairs[7]; $resource_field4 = $resource_data_pairs[8]; $resource_field5 = $resource_data_pairs[9]; $resource_field5 =~ s/\/\n/g; $permission_level = &get_resource_permission_level(@resource_data_pairs); $placeholder_field_number = 0; $placeholder_field = &get_placeholder_field_number(@resource_data_pairs); $fixed_reservation_hours = &get_fixed_reservation_hours(@resource_data_pairs); $fixed_reservation_minutes = &get_fixed_reservation_minutes(@resource_data_pairs); $max_reservation_hours = &get_max_reservation_hours(@resource_data_pairs); $max_reservation_minutes = &get_max_reservation_minutes(@resource_data_pairs); # this is in fractions of the hour! $lead_time_create_days = &get_lead_time_create_days(@resource_data_pairs); $lead_time_create_hours = &get_lead_time_create_hours(@resource_data_pairs); $lead_time_create_minutes = &get_lead_time_create_minutes(@resource_data_pairs); $lead_time_cancel_days = &get_lead_time_cancel_days(@resource_data_pairs); $lead_time_cancel_hours = &get_lead_time_cancel_hours(@resource_data_pairs); $lead_time_cancel_minutes = &get_lead_time_cancel_minutes(@resource_data_pairs); $buffer_periods_between = &get_buffer_periods_between(@resource_data_pairs); $buffer_hours_between = &get_buffer_hours_between(@resource_data_pairs); $buffer_minutes_between = &get_buffer_minutes_between(@resource_data_pairs); $resource_email_text = &get_resource_email_text(@resource_data_pairs); $pending_flag = &get_pending_flag(@resource_data_pairs); $override_username = ""; # OBSOLETE $pending_email_text = &get_pending_email_text(@resource_data_pairs); $placeholder_max_chars = &get_placeholder_max_chars(@resource_data_pairs); $resource_field_img = &get_resource_image(@resource_data_pairs); $max_advance_days = &get_max_advance_days(@resource_data_pairs); $found_flag = 1; } } # end while close(RESOURCE_FILE); } else { if (!(-e $gauthorized_users_file)) { if (!(open(NEW_USERS_FILE, ">" . $gauthorized_users_file))) { &return_error("File Create Error", "Unable to create $gauthorized_users_file"); } else { print NEW_USERS_FILE $gen_admin_login_password . "|" . $gen_admin_login_password . "|SYSTEM ADMIN|" . "|" . $SYSTEM_ADMIN . "|\n"; } } } print "Content-type: text/html\n\n"; print "\n"; print "\n"; print "\n\n"; print "uReserve"; print ""; print "


"; print "
"; print ""; if ($mode eq "EDIT") { print "Edit $settings[36] Form

"; } else { print "Add $settings[36] Form

"; } print "
"; print "
"; print ""; print "
"; print ""; print ""; if ($mode eq "EDIT") { print ""; print ""; } else { print ""; } print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; $ghelp_file_key_string = "resourcedaterange"; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; if (-e $gcategory_file) { $category_html = &get_category_selections($resource_category_key); print ""; print ""; print ""; print ""; } $ghelp_file_key_string = "permissionlevel"; print ""; print ""; print ""; print ""; if (-e $gauthorized_users_file) { $ghelp_file_key_string = "authusers"; print ""; print ""; print ""; print ""; } $ghelp_file_key_string = "placeholderfield"; $max_chars_selection_html = &get_max_chars_selection_html("placeholder_max_chars", $placeholder_max_chars, ""); print ""; print ""; print ""; print ""; $ghelp_file_key_string = "fixedreservationlength"; if ($settings[0] eq "CONFIG") { $config_columns_selection_html = &get_config_columns_selection_html("fixed_reservation_hours", $fixed_reservation_hours, $lang_num_timeslots, 0); } else { $hours_selection_html = &get_hours_selection_html("fixed_reservation_hours", $fixed_reservation_hours, $lang_hours); $minutes_selection_html = &get_minutes_selection_html("fixed_reservation_minutes", $fixed_reservation_minutes); } print ""; print ""; print ""; print ""; $ghelp_file_key_string = "maxreservationlength"; if ($settings[0] eq "CONFIG") { $config_columns_selection_html = &get_config_columns_selection_html("max_reservation_hours", $max_reservation_hours, $lang_num_timeslots, 0); } else { $hours_selection_html = &get_hours_selection_html("max_reservation_hours", $max_reservation_hours, $lang_hours); $minutes_selection_html = &get_minutes_selection_html("max_reservation_minutes", $max_reservation_minutes); } print ""; print ""; print ""; print ""; $ghelp_file_key_string = "leadtimecreate"; $days_selection_html = &get_days_selection_html("lead_time_create_days", $lead_time_create_days); if (!($settings[0] eq "CONFIG")) { $hours_selection_html = &get_all_hours_selection_html("lead_time_create_hours", $lead_time_create_hours); $minutes_selection_html = &get_all_minutes_selection_html("lead_time_create_minutes", $lead_time_create_minutes); } print ""; print ""; print ""; print ""; $ghelp_file_key_string = "leadtimecancel"; $days_selection_html = &get_days_selection_html("lead_time_cancel_days", $lead_time_cancel_days); if (!($settings[0] eq "CONFIG")) { $hours_selection_html = &get_all_hours_selection_html("lead_time_cancel_hours", $lead_time_cancel_hours); $minutes_selection_html = &get_all_minutes_selection_html("lead_time_cancel_minutes", $lead_time_cancel_minutes); } print ""; print ""; print ""; print ""; $ghelp_file_key_string = "maxadvancedays"; $days_selection_html = &get_days_selection_html("max_advance_days", $max_advance_days); print ""; print ""; print ""; print ""; $ghelp_file_key_string = "resourceemailtext"; print ""; print ""; print ""; print ""; $ghelp_file_key_string = "pendingflag"; print ""; print ""; print ""; print ""; $ghelp_file_key_string = "pendingemailtext"; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print "

$settings[39]: "; print "$lang_resource_admin_info"; print "
Optional Availability Date Range: "; if ($settings[5] =~ /US/i) { print "MM/DD/YY"; } else { print "DD/MM/YY"; } print " to "; print ""; if ($settings[5] =~ /US/i) { print "MM/DD/YYYY"; } else { print "DD/MM/YYYY"; } print "$lang_resource_date_range_info  "; print "$lang_help_string"; print "
$settings[40]:
$settings[41]:
$settings[42]:
$settings[43]:
$lang_image:
$lang_category: $category_html
$lang_permission_level:"; print "$lang_resource_permission_level_info  "; print "$lang_help_string"; print "
"; if ($mode eq "EDIT") { print "Give Authorization to All Authorized Users
"; print "Remove Authorization from All Authorized Users
"; } else { print "Give Authorization to All Authorized Users"; } print "
$lang_authusers_info  "; print "$lang_help_string"; print "
$lang_reservation_placeholder_field:"; $placeholder_select_html = ""; print $placeholder_select_html; print "   "; print "$lang_reservation_placeholder_max_chars"; print $max_chars_selection_html; print "$lang_resource_placeholder_field_info  "; print "$lang_help_string"; print "
$lang_fixed_reservation_length:"; if ($settings[0] eq "CONFIG") { print $config_columns_selection_html; } else { print $hours_selection_html; print "   "; print $minutes_selection_html; } print "$lang_fixed_reservation_length_info  "; print "$lang_help_string"; print "
$lang_max_reservation_length: "; if ($settings[0] eq "CONFIG") { print $config_columns_selection_html; } else { print $hours_selection_html; print "   "; print $minutes_selection_html; } print "$lang_max_reservation_length_info  "; print "$lang_help_string"; print "
$lang_reservation_lead_time_create: "; print $days_selection_html; print "   "; if (!($settings[0] eq "CONFIG")) { print $hours_selection_html; print "   "; print $minutes_selection_html; } print "$lang_reservation_lead_time_create_info  "; print "$lang_help_string"; print "
$lang_reservation_lead_time_cancel: "; print $days_selection_html; print "   "; if (!($settings[0] eq "CONFIG")) { print $hours_selection_html; print "   "; print $minutes_selection_html; } print "$lang_reservation_lead_time_cancel_info  "; print "$lang_help_string"; print "
$lang_reservation_max_advance_days: "; print $days_selection_html; print "   "; print "$lang_reservation_max_advance_days_info  "; print "$lang_help_string"; print "
$lang_resource_email_text: $lang_resource_email_text_info  "; print "$lang_help_string"; print "
$lang_pending_flag: "; } else { print ">"; } print "$lang_pending_flag_info  "; print "$lang_help_string"; print "
$lang_pending_email_text: $lang_pending_email_text_info  "; print "$lang_help_string"; print "
"; print ""; print "
"; print ""; print ""; print ""; print "
"; print "
"; print "


"; print ""; exit; } sub get_days_selection_html { local ( $select_name, $resource_days) = @_; local ( $days_selection_html, $i); $days_selection_html = "$lang_days "; print ""; print ""; print $resource_options; print "

"; print ""; print ""; print ""; print ""; print ""; print "
"; print ""; print ""; print ""; print "
"; print ""; print ""; print ""; print ""; exit; } sub get_resource_selections { local ($resource_selection_html, $line, @resource_data_pairs, $current_key, $current_name); $counter = 0; $resource_selection_html = ""; if ($counter < 1) { $resource_selection_html = "NONE"; } return ($resource_selection_html); } sub get_original_password { local ($pass_string) = @_; local ($original_password, @password_value_pairs); @password_value_pairs = split (/\?/, $pass_string); $original_password = $password_value_pairs[0]; return $original_password; } sub get_original_username { local ($pass_string) = @_; local ($original_username, @password_value_pairs); @password_value_pairs = split (/\?/, $pass_string); $original_username = $password_value_pairs[1]; return $original_username; } sub get_res_start_date { local ($pass_string) = @_; local ($res_start_date, @key_value_pairs); @key_value_pairs = split (/\?/, $pass_string); $res_start_date = &get_exact_date($key_value_pairs[2]); return $res_start_date; } sub get_res_end_date { local ($pass_string) = @_; local ($res_end_date, @key_value_pairs); @key_value_pairs = split (/\?/, $pass_string); $res_end_date = &get_exact_date($key_value_pairs[3]); return $res_end_date; } sub get_looper { local ($looper); if (($settings[0] eq "60") || ($settings[0] eq "CONFIG")) { $looper = 1.0; } elsif ($settings[0] eq "10") { $looper = 0.1666666666667; } elsif ($settings[0] eq "15") { $looper = 0.25; } else { $looper = 0.5; } return $looper; } sub get_prefix { local ($idx) = @_; local ($prefix); if ($settings[0] eq "CONFIG") { $prefix = $idx; } elsif ($settings[8] =~ /MIL/i) { $prefix = $idx; } else { if ($idx >= 13) { $prefix = $idx - 12; } elsif ($idx >= 1) { $prefix = $idx; } else { $prefix = 12; } } return $prefix; } sub get_suffix { local ($idx) = @_; local ($suffix); if ($settings[0] eq "CONFIG") { $suffix = ""; } else { if ($settings[0] eq "10") { if ($idx =~ /\.16/) { $suffix = ":10"; } elsif ($idx =~ /\.33/) { $suffix = ":20"; } elsif ($idx =~ /\.5/) # fix 4.0 { $suffix = ":30"; } elsif ($idx =~ /\.66/) { $suffix = ":40"; } elsif ($idx =~ /\.83/) { $suffix = ":50"; } else { $suffix = ":00"; } } elsif ($settings[0] eq "15") { if ($idx =~ /\.25/) { $suffix = ":15"; } elsif ($idx =~ /\.5/) { $suffix = ":30"; } elsif ($idx =~ /\.75/) { $suffix = ":45"; } else { $suffix = ":00"; } } elsif ($settings[0] eq "60") { $suffix = ":00"; } else { if ($idx =~ /\.5/) { $suffix = ":30"; } else { $suffix = ":00"; } } if ($settings[65] =~ /YES/i) # if am pm should print on report { if ($settings[8] =~ /STD/i) { if ($idx >= 12) { $suffix .= " pm"; } else { $suffix .= " am"; } } } } return $suffix; } sub check_resource_compliance { local ( $comp_action, $comp_resource_key, $comp_resv_password, $comp_resv_user_name, $comp_resv_form_recurring, $comp_current_seconds, $comp_res_end_time, $comp_res_start_time, $org_end_time, $org_start_time, $username, $password ) = @_; local ( $expired_flag, $comp_results, $comp_resource_name, $formatted_time, $sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst, $fixed_reservation_hours, $fixed_reservation_minutes, $max_reservation_hours, $max_reservation_minutes, $temp_max_reservation_hours, $temp_max_reservation_minutes, $temp_string, $resource_permission_level, $comp_lead_days, $comp_lead_hours, $comp_lead_minutes, $max_advance_days, $advance_flag, $user_auth, $user_authorized, $string1, $string2 ); $comp_results = "NONE||"; $comp_resource_name = &get_resource_name($comp_resource_key); $comp_resource_settings = &get_resource_settings($comp_resource_key); @comp_resource_value_pairs = split (/\|/, $comp_resource_settings); if ($comp_action eq "ADD") { $comp_lead_days = &get_lead_time_create_days(@comp_resource_value_pairs); # resource lead time create days $comp_lead_hours = &get_lead_time_create_hours(@comp_resource_value_pairs); # resource lead time create hours $comp_lead_minutes = &get_lead_time_create_minutes(@comp_resource_value_pairs); # resource lead time create minutes } else { $comp_lead_days = &get_lead_time_cancel_days(@comp_resource_value_pairs); # resource lead time mod/cancel days $comp_lead_hours = &get_lead_time_cancel_hours(@comp_resource_value_pairs); # resource lead time mod/cancel hours $comp_lead_minutes = &get_lead_time_cancel_minutes(@comp_resource_value_pairs); # resource lead time mod/cancel minutes } $user_auth = &get_user_group($username, $password); $user_auth = int($user_auth); if ($comp_action eq "ADD") { $expired_flag = &check_expired( $comp_resource_key, $comp_current_seconds, $comp_res_start_time, $comp_lead_days, $comp_lead_hours, $comp_lead_minutes, 1, $username, $password); if ($expired_flag == 1) { ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); $formatted_time = sprintf("%02d:%02d:%02d",$hour,$min,$sec); $comp_results = "Timeslot has passed.|You cannot reserve a timeslot which has passed.
The current server time is $formatted_time.|"; return ($comp_results); } elsif ($expired_flag == 2) { if ($settings[135] =~ /YES/i) { if ( ($user_auth == $SYSTEM_ADMIN) || (&validate_resource_admin($username, $password, $comp_resource_key) == 1) ) { } else { $comp_results = "Insufficient Lead Time.|There is not enough lead time to reserve this resource at the time you requested.|"; return ($comp_results); } } else { $comp_results = "Insufficient Lead Time.|There is not enough lead time to reserve this resource at the time you requested.|"; return ($comp_results); } } } $max_advance_days = &get_max_advance_days(@comp_resource_value_pairs); if ($max_advance_days > 0) { $advance_flag = 0; $advance_flag = &check_advance_days($comp_current_seconds, $max_advance_days); if ($advance_flag) { if ($settings[135] =~ /YES/i) { if ( ($user_auth == $SYSTEM_ADMIN) || (&validate_resource_admin($username, $password, $comp_resource_key) == 1) ) { } else { $comp_results = "Advance Days Exceeded.|This resource cannot be reserved more than $max_advance_days days in advance.|"; return ($comp_results); } } else { $comp_results = "Advance Days Exceeded.|This resource cannot be reserved more than $max_advance_days days in advance.|"; return ($comp_results); } } } $max_reservation_hours = &get_max_reservation_hours(@comp_resource_value_pairs); $max_reservation_minutes = &get_max_reservation_minutes(@comp_resource_value_pairs); #NOTE! THIS VALUE IS IN FRACTIONS OF THE HOUR SO MULTIPLY BY 3600 TO GET SECONDS!!! $fixed_reservation_hours = &get_fixed_reservation_hours(@comp_resource_value_pairs); # fix v4.0 $fixed_reservation_minutes = &get_fixed_reservation_minutes(@comp_resource_value_pairs); # fix v4.0 if (($fixed_reservation_hours <=0) && ($fixed_reservation_minutes <= 0)) { if (($max_reservation_hours > 0) || ($max_reservation_minutes > 0)) { $string1 = ($comp_res_end_time - $comp_res_start_time) * 3600; $string2 = ($max_reservation_hours * 3600) + ($max_reservation_minutes * 3600); if (sprintf('%2.3f', $string1) > sprintf('%2.3f', $string2)) # v4.0 fix { if ($settings[0] eq "CONFIG") { $comp_results = "Invalid Reservation Length.|Your reservation can not exceed the max reservation length ($max_reservation_hours).|"; return ($comp_results); } else { $temp_max_reservation_minutes = $max_reservation_minutes * 60; $temp_string = $max_reservation_hours . " hours " . $temp_max_reservation_minutes . " minutes "; $comp_results = "Invalid Reservation Length.|Your reservation can not exceed the max reservation length ($temp_string).|"; return ($comp_results); } } } } if ($comp_action eq "MOD") { return ($comp_results); # returns "NONE||" } if ($user_auth == $SYSTEM_ADMIN) { return ($comp_results); # returns "NONE||" } $resource_permission_level = &get_resource_permission_level(@comp_resource_value_pairs); if ((int($resource_permission_level) == 0) || (!($resource_permission_level =~ /\S/)) ) { $resource_permission_level = $settings[10]; } if ( ((int($resource_permission_level) == $AUTH_RESERVE_AUTH_RECURRING) || (int($resource_permission_level) == $AUTH_RESERVE_NO_RECURRING) ) || ( ($comp_resv_form_recurring > 1) && (int($resource_permission_level) == $ANY_RESERVE_AUTH_RECURRING)) ) { if ( (!($comp_resv_user_name =~ /\S/)) || (!($comp_resv_password =~ /\S/)) ) { $temp_string = $settings[50]; # A user name and password is required. $temp_string =~ s/://; $temp_string .= " when reserving $comp_resource_name."; $comp_results = "Missing Input|$temp_string|"; return ($comp_results); } if ($user_auth == $RESOURCE_ADMIN) { if (&validate_resource_admin($comp_resv_user_name, $comp_resv_password, $resource_key) == 0) { $user_authorized = &validate_user($comp_resource_key, $comp_resv_user_name, $comp_resv_password); if ($user_authorized == -1) # Returns -1 if bad user/password { $comp_results = "Not Authorized|Invalid user name and password.|"; return ($comp_results); } elsif ($user_authorized == 0) # Returns 0 if good user/password but user not authorized for this resource { $comp_results = "Not Authorized|You are not authorized to reserve $comp_resource_name.|"; return ($comp_results); } } } else { $user_authorized = &validate_user($comp_resource_key, $comp_resv_user_name, $comp_resv_password); if ($user_authorized == -1) # Returns -1 if bad user/password { $comp_results = "Not Authorized|Invalid user name and password.|"; return ($comp_results); } elsif ($user_authorized == 0) # Returns 0 if good user/password but user not authorized for this resource { $comp_results = "Not Authorized|You are not authorized to reserve $comp_resource_name.|"; return ($comp_results); } } } return $comp_results; } # End of check_resource_compliance() sub check_expired { local ( $resource_key, $current_seconds, $res_start_time, $lead_days, $lead_hours, $lead_minutes, $precision_flag, $username, $password) = @_; local ( $expired_flag, $now_seconds, $date_str1, $date_str2, $new_date_str1, $new_date_str2, $total_lead_seconds, $reservation_date, $reservation_seconds, $fmt_date, $formatted_time, $midnite_seconds, $user_auth); $expired_flag = 0; $now_seconds = time; $user_auth = -1; if ( ($settings[140] != 0) && ($settings[140] > -24) && ($settings[140] < 24) ) { $now_seconds += ($settings[140] * 3600); } $date_str1 = &get_exact_date($current_seconds); # Will return the date in the format MM/DD/YYYY or DD/MM/YYYY $date_str2 = &get_exact_date($now_seconds); # Will return the date in the format MM/DD/YYYY or DD/MM/YYYY ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($now_seconds); $seconds_past_midnite = $sec + ($min * 60) + ($hour * 3600); $formatted_time = sprintf("%02d:%02d:%02d",$hour,$min,$sec); if ($settings[5] =~ /US/i) { $new_date_str1 = $date_str1; $new_date_str2 = $date_str2; } else { $new_date_str1 = sprintf("%02d/%02d/%04d",substr($date_str1,3,2),substr($date_str1,0,2),substr($date_str1,6,4)); $new_date_str2 = sprintf("%02d/%02d/%04d",substr($date_str2,3,2),substr($date_str2,0,2),substr($date_str2,6,4)); } $fmt_date = sprintf("%02d-%02d-%04d",substr($new_date_str1,0,2),substr($new_date_str1,3,2),substr($new_date_str1,6,4)); if ($res_start_time > 0) { if ($new_date_str1 eq $new_date_str2) # this is the current day { $midnite_seconds = &get_midnite_seconds($now_seconds, $fmt_date, $seconds_past_midnite); # must be in MM-DD-YYYY format } else { $midnite_seconds = &get_midnite_seconds($current_seconds, $fmt_date, $seconds_past_midnite); # must be in MM-DD-YYYY format } $reservation_seconds = $midnite_seconds + ($res_start_time * 3600); } else { $reservation_seconds = $current_seconds; } $lead_days = &strip_letters($lead_days); $lead_hours = &strip_letters($lead_hours); $lead_minutes = &strip_letters($lead_minutes); $total_lead_seconds = ($lead_days * $SECONDS_PER_DAY) + ($lead_hours * 3600) + ($lead_minutes * 60); # note: lead mins is fraction of hours, 30 mins=.5 $compare_date_str1 = make_date_YYYYMMDD($date_str1); # considers EURO vs US $compare_date_str2 = make_date_YYYYMMDD($date_str2); # considers EURO vs US if ($compare_date_str1 eq $compare_date_str2) # this is the current day { if (!($settings[0] eq "CONFIG")) # bypass this check if using config columns version { if ($precision_flag == 1) { if ( ($res_start_time * 3600) < $seconds_past_midnite ) { $expired_flag = 1; } elsif ( ($res_start_time * 3600) < ($seconds_past_midnite + $total_lead_seconds) ) { $expired_flag = 2; } } } else { if ($total_lead_seconds > 0) # in config columns version - if reservation on same day and lead seconds > 0, then lead time (for cancel or create!) is exceeded { $expired_flag = 2; } } } elsif ($compare_date_str1 lt $compare_date_str2) # force comparison on US formatted dates, even if European mode { $expired_flag = 1; } elsif ($compare_date_str1 gt $compare_date_str2) # force comparison on US formatted dates, even if European mode { if ($reservation_seconds < ($now_seconds + $total_lead_seconds)) { $expired_flag = 2; } } if ( ($username =~ /\S/) && ($password =~ /\S/) ) { $user_auth = &get_user_group($username, $password); $user_auth = int($user_auth); } if ($expired_flag == 1) { if ($settings[121] =~ /NO/i) { return 0; } else { if ($settings[129] =~ /YES/i) { if ($user_auth == $SYSTEM_ADMIN) { return 0; } elsif ($user_auth == $RESOURCE_ADMIN) { if (&validate_resource_admin($username, $password, $resource_key) == 1) { return 0; } } } } } if ( ($expired_flag == 2) && ($settings[135] =~ /YES/i) ) { if ($user_auth == $SYSTEM_ADMIN) { return 0; } elsif ($user_auth == $RESOURCE_ADMIN) { if (&validate_resource_admin($username, $password, $resource_key) == 1) { return 0; } } } return $expired_flag; } # end check_expired() sub check_advance_days { local ($reservation_seconds, $advance_days) = @_; local ( $now_seconds, $user_auth); $now_seconds = time; if ( ($settings[140] != 0) && ($settings[140] > -24) && ($settings[140] < 24) ) { $now_seconds += ($settings[140] * 3600); } $total_advance_days_seconds = ($max_advance_days * $SECONDS_PER_DAY); if ($reservation_seconds > ($now_seconds + $total_advance_days_seconds)) { return 1; # requested reservation time violates the max advance days setting } else { return 0; } } # end check_advance_days() sub create_delete_resource_confirmation_form { local ( $resource_field1, $number_reservations, $resource_key ); &validate_referral_page($script_url); $resource_key = $form_text{'resource_key'}; $resource_name = &get_resource_name($resource_key); $number_reservations = &get_num_reservations_for_this_resource(); print "Content-type: text/html\n\n"; print "\n"; print "\n"; print "\n\n"; print "uReserve"; print ""; print "




"; print ""; print "
"; print ""; print ""; print ""; print "
"; print ""; print "
Are you sure you want to delete:
" . $resource_name . " ?
"; if ($number_reservations > 0) { print "

There are $number_reservations reservations associated with this resource. If you proceed, these reservations will be permanently deleted."; } print "


"; print "
"; print "
"; print ""; print ""; print ""; print ""; print ""; print ""; print "
"; print "
"; print "
"; print ""; print ""; print ""; print ""; print ""; print ""; print "
"; print "
"; print "
"; print "
"; print ""; exit; } sub delete_resource { local ($resource_key) = @_; local ($line, $current_key, $status, $found_flag, $random_number, $temp_file, $resource_name, @resource_data_pairs); &validate_referral_page($script_url); $found_flag = 0; $resource_name = &get_resource_name($resource_key); srand(time|$$); $random_number = int(rand(10000000)); $temp_file = $data_directory . "ureserve" . $random_number . ".tmp"; open (DEL_DATA_FILE, $gresource_file) || &return_error("File Error","Unable to open " . $gresource_file); if (!(open(DEL_TEMP_FILE, ">" . $temp_file))) { close(DEL_DATA_FILE); &return_error("File Error","Unable to open " . $temp_file); } while () { $line = $_; @resource_data_pairs = split (/\|/, $line); $current_key = $resource_data_pairs[0]; if (($found_flag == 0) && ($current_key == $resource_key)) { $found_flag = 1; } else { print DEL_TEMP_FILE $line; } } close(DEL_DATA_FILE); close(DEL_TEMP_FILE); unlink($gresource_file); rename($temp_file,$gresource_file); chmod(0777, $gresource_file); if ($found_flag == 1) { &log_info($ADMIN,"Resource $resource_name was deleted by $username."); $number_reservations = &get_num_reservations_for_this_resource($resource_key); if ($number_reservations > 0) { $status = 0; $status = &delete_reservations_against_resource_being_deleted($resource_key); if ($status > 0) { &log_info($ADMIN,"$num_deleted reservations were deleted when resource $resource_name was deleted by $username."); } } $status = 0; $status = &delete_blackout_dates_for_resource_being_deleted($resource_key); if ($status > 0) { &log_info($ADMIN,"$num_deleted blackout-dates were deleted when resource $resource_name was deleted by $username."); } $status = 0; $status = &unassign_auth_users_from_resource_being_deleted($resource_key); if ($status > 0) { &log_info($ADMIN,"$num_deleted authorized users were unassigned from resource $resource_name because it was deleted by $username."); } } return $found_flag; } sub check_duplicate_resource_name { local ( $new_name ) = @_; local ( $current_name, $string1, $string2, $i, @resource_data_pairs, @resource_lines, $found_flag ); $found_flag = 0; if (!(-e $gresource_file)) { return 0; } if (open (RESOURCE_FILE, $gresource_file)) { @resource_lines = ; close(RESOURCE_FILE); for ($i=0; $i <= $#resource_lines; $i++) { $string1 = quotemeta(uc($new_name)); if ($found_flag == 0) { @resource_data_pairs = split (/\|/, $resource_lines[$i]); $current_name = ""; $current_name = $resource_data_pairs[5]; $string2 = quotemeta(uc($current_name)); if ($string2 eq $string1) { $found_flag = 1; $i = $#resource_lines + 1; } } } close(RESOURCE_FILE); } else { &return_error("File Error","Unable to open " . $gresource_file); } return $found_flag; } sub parse_form_data { local (*FORM_DATA) = @_; local ( $request_method, $content_type, $query_string, @key_value_pairs, $key_value, $key, $value); $request_method = $ENV{'REQUEST_METHOD'}; if ($request_method eq "GET") { $query_string = $ENV{'QUERY_STRING'}; } elsif ($request_method eq "POST") { $content_type = $ENV{'CONTENT_TYPE'}; if ($content_type =~ /^multipart\/form-data/) { return; } read (STDIN, $query_string, $ENV{'CONTENT_LENGTH'}); } else { &return_error ("Unsupported Method","Server must use GET or POST."); } @key_value_pairs = split (/&/, $query_string); foreach $key_value (@key_value_pairs) { ($key, $value) = split (/=/, $key_value); $value =~ tr/+/ /; $value =~ s/%([\dA-Fa-f][\dA-Fa-f])/pack ("C", hex ($1))/eg; if (defined($FORM_DATA{$key})) { $FORM_DATA{$key} = join ("\0", $FORM_DATA{$key}, $value); } else { $FORM_DATA{$key} = $value; } } } sub new_parse_form_data { local (*FORM_DATA) = @_; local ( $request_method, $content_type, $query_string, $separator, $section, @sections, $filename, $temp, @key_value_pairs, $key_value, $key, $value); $request_method = $ENV{'REQUEST_METHOD'}; if ($request_method eq "GET") { $query_string = $ENV{'QUERY_STRING'}; } elsif ($request_method eq "POST") { $content_type = $ENV{'CONTENT_TYPE'}; if ($content_type =~ /^multipart\/form-data/) { read(STDIN, $query_string, $ENV{'CONTENT_LENGTH'}); $query_string =~ /^(.+)\r\n/; $separator = $1; @sections = split(/$separator/,$query_string); foreach $section (@sections) { if ($section =~ /^\r\nContent/) { ($key, $value) = split (/\r\n\r\n/, $section); $value =~ s/\r\n$//; $key =~ s/\r\nContent-Disposition: form-data; name=\"//; if ($key =~ /Content-Type/) { ($temp, $filename) = split (/filename=/, $key); ($filename, $temp) = split (/Content-Type/, $filename); $filename =~ s/\r\n//; $filename =~ s/\"//g; $filename =~ s/\//\|/g; $filename =~ s/\\/\|/g; @key_value_pairs = split (/\|/, $filename); $filename = $key_value_pairs[-1]; $key = "upload_file_name"; $FORM_DATA{$key} = $filename; $key = "upload_data"; $FORM_DATA{$key} = $value; } else { chop($key); $FORM_DATA{$key} = $value; } } } return; } else { read (STDIN, $query_string, $ENV{'CONTENT_LENGTH'}); } } else { &return_error ("Unsupported Method","Server must use GET or POST."); } @key_value_pairs = split (/&/, $query_string); foreach $key_value (@key_value_pairs) { ($key, $value) = split (/=/, $key_value); $value =~ tr/+/ /; $value =~ s/%([\dA-Fa-f][\dA-Fa-f])/pack ("C", hex ($1))/eg; if (defined($FORM_DATA{$key})) { $FORM_DATA{$key} = join ("\0", $FORM_DATA{$key}, $value); } else { $FORM_DATA{$key} = $value; } } @key_value_pairs = split (/&/, $query_string); foreach $key_value (@key_value_pairs) { ($key, $value) = split (/=/, $key_value); $value =~ tr/+/ /; $value =~ s/%([\dA-Fa-f][\dA-Fa-f])/pack ("C", hex ($1))/eg; $FORM_DATA{$key} = $value; } } sub return_error { local ($title, $message) = @_; print "Content-type: text/html\n\n"; print "\n"; print "\n"; print "\n\n"; print "" . $title . ""; print "
"; print "

"; print $title; print "

"; print "
"; print $message; print "
"; print "
"; print ""; exit; } sub missing_input { local ($title, $message) = @_; print "Content-type: text/html\n\n"; print "\n"; print "\n"; print "\n\n"; print "" . $title . ""; print "
"; print "

"; print $title; print "

"; print "
"; print $message; print "
"; print "
"; print "Click HERE To Go Back"; print "
"; print ""; exit; } sub display_message { local ($title, $message) = @_; print "Content-type: text/html\n\n"; print "\n"; print "\n"; print "\n\n"; print "" . $title . ""; print "
"; print "

"; print $title; print "

"; print "
"; print ""; print $message; print ""; print "
"; print "
"; print ""; exit; } sub strip_letters { local ($vstring) = @_; $vstring =~ s/[^0-9.]//g; $vstring =~ tr/-/ /; return $vstring; } sub validate_string { local ($vstring) = @_; $vstring =~ s/\n/ /g; $vstring =~ s/\"/'/g; $vstring =~ s/[\`\\\|\<\>\^\[\]\{\}\r]//g; return $vstring; } sub validate_description { local ($vstring) = @_; $vstring =~ s/\"/'/g; $vstring =~ s/[\`\\\|\^\[\]\{\}\r]//g; $vstring =~ s/\n/
/g; return $vstring; } sub validate_admin { local ( $uname, $upassword, $resource_admin_access, $reports_admin_access) = @_; local ( $i, $cname, $cpassword, $user_group, @lines, @user_value_pairs); $uname = &validate_string($uname); $upassword = &validate_string($upassword); if (!(-e $gresource_file)) { if (($uname eq $gen_admin_login_password) || ($upassword eq $gen_admin_login_password)) { return; } } if (-e $gauthorized_users_file) { open (USERS_FILE, $gauthorized_users_file) || &return_error("File Error","Unable to open Authorized Users Database."); @lines = ; close(USERS_FILE); for ($i = 0; $i <= $#lines; $i++) { chop($lines[$i]); @user_value_pairs = split (/\|/, $lines[$i]); $cname = $user_value_pairs[0]; $cpassword = $user_value_pairs[1]; $user_group = $user_value_pairs[4]; if ($cname eq $uname) { if ($cpassword eq $upassword) { if (int($user_group) == $SYSTEM_ADMIN) { return; # user is authorized } if ($resource_admin_access) { if (int($user_group) == $RESOURCE_ADMIN) { return; # user is authorized } } if ($reports_admin_access) { if (int($user_group) == $REPORTS_ADMIN) { return; # user is authorized } } &create_admin_login_form(); } else { &create_admin_login_form(); } } } } &create_admin_login_form(); } sub validate_resource_admin { local ( $uname, $upassword, $resource_key) = @_; local ( $user_auth, $found, $resource_settings, @choices, @user_value_pairs); $user_auth = &get_user_group($uname, $upassword); $user_auth = int($user_auth); $found = 0; if ($user_auth == $RESOURCE_ADMIN) { if ($resource_key != 0) { @user_value_pairs = &get_user_info($uname); @choices=split(/\?/,$user_value_pairs[3]); foreach $comp_resource_key (@choices) { if ( (int($comp_resource_key)) == (int($resource_key)) ) { $found = 1; last; } } } } return $found; } sub validate_referral_page() { local ($expected_referrer) = @_; local ($referrer_string); if ($settings[128] =~ /NO/i) { $referrer_string = $ENV{'HTTP_REFERER'}; if (!($referrer_string =~ /^$expected_referrer/i)) { &missing_input("Illegal Referrer Page","The referring page did not meet security requirements."); } } } sub format_time { local ($ptime) = @_; local ($ret_string,$suffix,$temp_string); if ($settings[0] eq "CONFIG") { return $column_names[$ptime]; } elsif ($settings[0] eq "10") { $temp_string = "$ptime"; if ($temp_string =~ /\.16/) { $suffix = ":10"; } elsif ($temp_string =~ /\.33/) { $suffix = ":20"; } elsif ($temp_string =~ /\.5/) # fix 4.0 { $suffix = ":30"; } elsif ($temp_string =~ /\.66/) { $suffix = ":40"; } elsif ($temp_string =~ /\.83/) { $suffix = ":50"; } else { $suffix = ":00"; } $ptime = int($ptime); } elsif ($settings[0] eq "15") { $temp_string = "$ptime"; if ($temp_string =~ /\.25/) { $suffix = ":15"; } elsif ($temp_string =~ /\.5/) { $suffix = ":30"; } elsif ($temp_string =~ /\.75/) { $suffix = ":45"; } else { $suffix = ":00"; } $ptime = int($ptime); } else { if ($ptime == int($ptime)) { $suffix = ":00"; } else { $ptime = int($ptime); $suffix = ":30"; } } if ($ptime > 23) { $ptime -= 24; } if ($settings[8] =~ /STD/i) { if ($ptime >= 12) { $ptime = $ptime - 12; $suffix .= " pm"; } else { $suffix .= " am"; } if ($ptime < 1) { $ptime = 12; } } $ret_string = sprintf("%02d$suffix",$ptime); return $ret_string; } sub get_row_html { local ( $resource_key, $week_name, $day_index, $current_seconds, $blackout_status, $total_columns, $looper, $current_line, $placeholder_field_number, $placeholder_max_chars, @blackout_timeslots) = @_; local ( $row_html, $resource_name, @reservation_data_pairs, $timeslot, $blackout_end_index, $cur_cols, $found_flag, $data_index, $begin_time, $end_time, $found_flag); $resource_name = &get_resource_name($resource_key); if ($blackout_status == -1) # the entire day is blacked out { $total_columns -= 1; $row_html .= ""; $total_columns += 1; $row_html .= ""; $row_html .= " "; $row_html .= ""; } elsif ($current_line =~ /\S/) # there are some reservations and possibly some blackouts on this day { @reservation_data_pairs = split (/\|/, $current_line); for ($timeslot = $gtime_range_start; $timeslot < $gtime_range_stop; $timeslot += $looper) { $blackout_end_index = &check_timeslot_in_blackout_list($timeslot, @blackout_timeslots); if ($blackout_end_index > 0) { $cur_cols = $blackout_end_index; $row_html .= ""; $row_html .= ""; $row_html .= " "; $row_html .= ""; $timeslot += (($cur_cols-1) * $looper); } else { $found_flag=0; for ($data_index = 6; $data_index <= $#reservation_data_pairs; $data_index += 25) { $begin_time = $reservation_data_pairs[$data_index]; # reservation start time $begin_time = &strip_letters($begin_time); $end_time = $reservation_data_pairs[$data_index + 1]; # reservation end time $end_time = &strip_letters($end_time); $pending_flag = ""; @pending_key_pairs = split (/\?/, $reservation_data_pairs[$data_index-5]); $pending_status = $pending_key_pairs[1]; if (&compare_ge($timeslot, $begin_time)) # v3.24 fix { if ( (&compare_lt($timeslot, $end_time)) || (($begin_time == $end_time) && (&compare_eq($timeslot, $end_time)) && ($settings[0] eq "CONFIG"))) # v3.25 fix { $cur_cols = 1; $found_flag = 1; if ($end_time > $begin_time) { $cur_cols = ($end_time - $begin_time) / $looper; $cur_cols = sprintf('%2.0f', $cur_cols); } if ($pending_status =~ /PENDING/i) { $row_html .= ""; } else { $row_html .= ""; } if ($cur_cols > 1) { $timeslot += (($cur_cols-1) * $looper); } $row_html .= ""; $row_html .= ""; if (int($placeholder_field_number) != 0) { if (int($placeholder_field_number < 5)) { $display_field = $reservation_data_pairs[$data_index - (5 - ($placeholder_field_number - 1))]; $display_field =~ s/\?PENDING//i; } else { $display_field = $reservation_data_pairs[$data_index + ($placeholder_field_number - 3)]; } if (!($display_field =~ /\S/)) { if ($settings[31] =~ /\S/) { $row_html .= "$settings[31]"; } else { $row_html .= "R"; } } else { if (length($display_field) > $placeholder_max_chars) { $display_field = substr($display_field,0,$placeholder_max_chars); } $row_html .= "$display_field"; } } elsif ($settings[32] =~ /\S/) { $row_html .= "\"$settings[33]\""; } else { if ($settings[31] =~ /\S/) { $row_html .= "$settings[31]"; } else { $row_html .= "R"; } } $row_html .= ""; $data_index = ($#reservation_data_pairs+1); # force exit loop } } } # end for ($data_index = 6; $data_index <= $#reservation_data_pairs; $data_index += 22) if ($found_flag == 0) { $cur_cols = 1; $row_html .= ""; $row_html .= ""; $row_html .= " "; $row_html .= ""; } } } # end for ($timeslot = $gtime_range_start; $timeslot <= $gtime_range_stop; $timeslot += $looper) } else # else there are no reservations on this day { if ($blackout_status > 0) # there are no reservations but some blacked out timeslots on this day { for ($timeslot = $gtime_range_start; $timeslot < $gtime_range_stop; $timeslot += $looper) { $blackout_end_index = &check_timeslot_in_blackout_list($timeslot, @blackout_timeslots); if ($blackout_end_index > 0) { $cur_cols = $blackout_end_index; $row_html .= ""; $row_html .= ""; $row_html .= " "; $row_html .= ""; $timeslot += (($cur_cols-1) * $looper); } else #($blackout_index == 0) { $cur_cols = 1; $row_html .= ""; $row_html .= ""; $row_html .= " "; $row_html .= ""; } } # end for ($timeslot = $gtime_range_start; $timeslot <= $gtime_range_stop; $timeslot += $looper) } else # there are no reservations and no blacked out timeslots on this day { $total_columns -= 1; $row_html .= ""; $total_columns += 1; $row_html .= ""; $row_html .= " "; $row_html .= ""; } } return $row_html; } sub check_timeslot_in_blackout_list { local ($timeslot, @blackout_timeslots) = @_; local ( $index, $looper, $found_blackout, $starting_blackout_index, $blackout_end_index, $blackout_index); $blackout_end_index = 0; $starting_blackout_index = 0; for ($index = 1; $index <= $blackout_timeslots[0]; $index++) { if (&compare_eq($timeslot, $blackout_timeslots[$index])) # v3.25 fix { $starting_blackout_index = $index; $index = $blackout_timeslots[0] + 1; # force exit loop } } if ($starting_blackout_index > 0) { $looper = &get_looper(); $blackout_end_index = 1; # the blackout spans at least one timeslot, we have verified this much for ($index = $starting_blackout_index; $index < ($blackout_timeslots[0]); $index++) { $next_blackout_timeslot = $blackout_timeslots[$index] + $looper; if (&compare_eq($next_blackout_timeslot, $blackout_timeslots[$index+1])) # v3.25 fix { $blackout_end_index++; } else { $index = $blackout_timeslots[0]; # force exit loop } } } return $blackout_end_index; } sub create_add_edit_user_form { local ($mode) = @_; local ($temp_auth_user_name, $auth_user_name, $auth_user_full_name, $auth_user_password, $auth_user_email, $user_resource_list, $user_group, $line, $not_auth, $current_auth_user_name, $choice, $resource_name, $resource_key, $resource_index, $found_flag, @user_value_pairs, @resource_data, @resource_lines, @choices); &validate_referral_page($script_url); $found_flag = 0; $auth_user_name = ""; $auth_user_full_name = ""; $auth_user_password = ""; $auth_user_email = ""; $user_resource_list = ""; $user_group = ""; $last_user_group = ""; if ($mode eq "EDIT") { $temp_auth_user_name = $form_text{'auth_user_name'}; @user_value_pairs = split (/\|/, $temp_auth_user_name); $auth_user_name = $user_value_pairs[0]; $auth_user_full_name = $user_value_pairs[1]; if (open (USER_FILE, $gauthorized_users_file)) { while () { $line = $_; chop($line); @key_value_pairs = split (/\|/, $line); $current_auth_user_name = $key_value_pairs[0]; if (($found_flag == 0) && ($current_auth_user_name eq $auth_user_name)) { $auth_user_password = $key_value_pairs[1]; $auth_user_email = $key_value_pairs[5]; $user_resource_list = $key_value_pairs[3]; if (int($key_value_pairs[4]) > 0) { $user_group = $key_value_pairs[4]; } else { $user_group = $GEN_USER; # default to general user } $last_user_group = $user_group; $found_flag = 1; } } close(USER_FILE); } else { &return_error("File Error","Unable to open " . $gauthorized_users_file); } } else { if (!(-e $gresource_file)) { &return_error("No Resources Defined Yet","Define at least one resource before attempting to add users."); } } print "Content-type: text/html\n\n"; print "\n"; print "\n"; print "\n\n"; print "uReserve"; print ""; print "


"; print "
"; print ""; if ($mode eq "EDIT") { print "$lang_edit_user_form

"; } else { print "$lang_add_user_form

"; } print "
"; print "
"; print ""; print "
"; print ""; print ""; if ($mode eq "EDIT") { print ""; print ""; } else { print ""; } print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; $ghelp_file_key_string = "usergroups"; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print "

Full Name:
$lang_usergroup: "; if (int($user_group) == $SYSTEM_ADMIN) { print "$lang_gen_user
"; print "$lang_reports_admin
"; print "$lang_resource_admin
"; print "$lang_system_admin
"; } elsif (int($user_group) == $RESOURCE_ADMIN) { print "$lang_gen_user
"; print "$lang_reports_admin
"; print "$lang_resource_admin
"; print "$lang_system_admin
"; } elsif (int($user_group) == $REPORTS_ADMIN) { print "$lang_gen_user
"; print "$lang_reports_admin
"; print "$lang_resource_admin
"; print "$lang_system_admin
"; } else { print "$lang_gen_user
"; print "$lang_reports_admin
"; print "$lang_resource_admin
"; print "$lang_system_admin
"; } print "
$lang_usergroup_info  "; print "$lang_help_string"; print "
$lang_username:
$lang_password:
$lang_email:
$lang_authorized_resources: "; @resource_data = &get_resource_file_all_records(); print ""; print "
"; print ""; print ""; print "
"; print ""; print ""; print ""; print "
"; print "
"; print "


"; print ""; exit; } sub create_user_selection_form { local ($next_command) = @_; local ($user_options); $user_options = &get_user_selections(); if ($user_options eq "NONE") { &missing_input("No Authorized Users","No authorized users have been created yet."); } print "Content-type: text/html\n\n"; print "\n"; print "\n"; print "\n\n"; print "uReserve"; print ""; print "




"; print ""; print "
"; print ""; print ""; print ""; print ""; print ""; print "
"; print ""; if ($next_command =~ /edit/) { print "
Select Authorized User To Edit:

"; } elsif ($next_command =~ /delete/) { print "
Select Authorized User to Delete:
"; } else { print "
Select Authorized User:
"; } print "
"; print "
"; print ""; print ""; print ""; print $user_options; print "

"; print "
"; print ""; print ""; print "
"; print ""; print ""; print ""; print "
"; print "
"; print "
"; print ""; exit; } sub get_user_selections { local ( $user_selection_html, $line, $auth_user_name, $current_full_name, $counter, @full_names, @sorted_names, @user_value_pairs); $counter = 0; $user_selection_html = ""; if ($counter < 1) { $user_selection_html = "NONE"; } return ($user_selection_html); } sub add_user { local ($modify_flag, $username, $password) = @_; local ( $auth_user_name, $auth_user_password, $auth_user_full_name, $auth_user_email, $user_resource_list, $user_group, $line, $resource_key, $new_resource_list, $num_errors, $error_html, @user_value_pairs, @choices); &validate_referral_page($script_url); $prev_name = $form_text{'prev_name'}; $user_resource_list = $form_text{'user_resource_list'}; $auth_user_full_name = $form_text{'auth_user_full_name'}; $auth_user_full_name = &validate_string($auth_user_full_name); $auth_user_name = $form_text{'auth_user_name'}; $auth_user_name = &validate_string($auth_user_name); $auth_user_password = $form_text{'auth_user_password'}; $auth_user_password = &validate_string($auth_user_password); $auth_user_email = $form_text{'auth_user_email'}; $email_out = &validate_email($auth_user_email); if (($auth_user_email ne $email_out) || (!($auth_user_email =~ /\@/g))) { &missing_input("E-Mail Address Invalid ($auth_user_email)","Please enter a valid e-mail address"); } $user_group = $form_text{'user_group'}; if (!($auth_user_full_name =~ /\S/)) { &missing_input("Missing Input","Please enter the user full name."); } if (!($auth_user_name =~ /\S/)) { &missing_input("Missing Input","Please enter a user name."); } if (!($auth_user_password =~ /\S/)) { &missing_input("Missing Input","Please enter a password for the user."); } if ((!($user_resource_list =~ /\S/)) && ($user_group != $SYSTEM_ADMIN)) { &missing_input("Missing Input","Please select at least one resource for the user to access."); } $user_auth = &get_user_group($username, $password); $user_auth = int($user_auth); if ( $user_auth == $RESOURCE_ADMIN ) { if ( $user_group == $SYSTEM_ADMIN ) { &missing_input("Not Authorized","You are not authorized to add a user with this user group."); } } if ( $user_auth == $RESOURCE_ADMIN ) { $num_errors = 0; $error_html = ""; @choices=split(/\0/,$user_resource_list); foreach $resource_key (@choices) { if (&validate_resource_admin($username, $password, $resource_key) == 0) { $resource_name = &get_resource_name($resource_key); $error_html .= $resource_name; $error_html .= "
"; $num_errors++; } } if ($num_errors > 0) { &missing_input("Not Authorized", "You are not authorized to give a user access to the following resources:

$error_html"); } } if (-e $gauthorized_users_file) { if (open(USERS_FILE, $gauthorized_users_file)) { while () { $line = $_; if (($line =~ /\S/) && ($line ne "\n")) { @user_value_pairs = split (/\|/, $line); if ($user_value_pairs[0] eq $auth_user_name) { close(USERS_FILE); &missing_input("Duplicate User Name","The user name $auth_user_name already exists."); } } } close(USERS_FILE); } else { &return_error("File Error","Unable to open $gauthorized_users_file"); } } if (int($modify_flag) == 1) { &delete_user($prev_name, 1); } $new_resource_list = &prep_resource_list($user_resource_list); if (open(USERS_FILE, ">>" . $gauthorized_users_file)) { print USERS_FILE $auth_user_name . "|" . $auth_user_password . "|" . $auth_user_full_name . "|" . $new_resource_list . "|" . $user_group . "|" . $auth_user_email . "|\n"; close(USERS_FILE); chmod(0777, $gauthorized_users_file); &auto_remove_blocked_user($auth_user_email); } else { &return_error("File Error","Unable to open $gauthorized_users_file"); } if (!$modify_flag) { &log_info($ADMIN,"Authorized User $auth_user_full_name was added by $username."); } &create_manage_users_form("The new user $auth_user_full_name ($auth_user_name) has been added."); } sub edit_user { local ( $prev_name, $prev_resource_list, $temp_auth_user_name, $auth_user_name, $auth_user_full_name, $auth_user_password, $auth_user_email, $user_resource_list, $user_group, $user_auth, $resource_admin_access, $reports_admin_access, $line, $current_auth_user_name, $num_errors, $error_html, $msg_html, $found_flag, $random_number, $temp_file, $resource_name, $resource_key, $prev_resource_key, $found, $email_out, @prev_resources, @choices, @user_value_pairs); &validate_referral_page($script_url); $prev_name = $form_text{'prev_name'}; $auth_user_name = $form_text{'auth_user_name'}; $auth_user_full_name = $form_text{'auth_user_full_name'}; $auth_user_password = $form_text{'auth_user_password'}; $auth_user_email = $form_text{'auth_user_email'}; $user_resource_list = $form_text{'user_resource_list'}; $user_group = $form_text{'user_group'}; $last_user_group = $form_text{'last_user_group'}; $auth_user_name = &validate_string($auth_user_name); $auth_user_full_name = &validate_string($auth_user_full_name); $auth_user_password = &validate_string($auth_user_password); $email_out = &validate_email($auth_user_email); if (($auth_user_email ne $email_out) || (!($auth_user_email =~ /\@/g))) { &missing_input("E-Mail Address Invalid ($auth_user_email)","Please enter a valid e-mail address"); } $user_auth = &get_user_group($username, $password); $user_auth = int($user_auth); if (($user_auth != $SYSTEM_ADMIN) && ($user_group == $SYSTEM_ADMIN) && ($last_user_group != $SYSTEM_ADMIN)) { &missing_input("Not Authorized","You are not authorized to give a user System Admin privilege."); } if (($last_user_group == $SYSTEM_ADMIN) && ($user_auth != $SYSTEM_ADMIN)) { &missing_input("Not Authorized","You are not authorized to modify the data of a System Admin."); } if (($auth_user_name eq $username) && ($last_user_group == $RESOURCE_ADMIN) && ($user_auth != $RESOURCE_ADMIN)) { &missing_input("Not Authorized","You are not permitted to change your own user group. Contact the System Admin for help."); } if ($prev_name ne $auth_user_name) { if ($user_auth == $SYSTEM_ADMIN) { if (!($auth_user_name =~ /\S/)) { &missing_input("Missing Input","Please enter the user name."); } if (&check_duplicate_user_name($auth_user_name) == 1) { &missing_input("Duplicate User Name","Please enter a unique User Name."); } &add_user(1, $username, $password); } elsif ($user_auth == $RESOURCE_ADMIN) { &missing_input("Not Authorized","You are not authorized to modify User Name."); } } else { $prev_resource_list = ""; $prev_resource_list = &get_user_resource_list($prev_name); $msg_html = ""; if ( $user_auth == $RESOURCE_ADMIN ) { $num_errors = 0; $error_html = ""; @choices=split(/\0/,$user_resource_list); foreach $resource_key (@choices) { if (&validate_resource_admin($username, $password, $resource_key) == 0) { @prev_resources = (); @prev_resources = split(/\?/,$prev_resource_list); $found = 0; foreach $prev_resource_key (@prev_resources) { if (int($prev_resource_key) == int($resource_key)) { $found = 1; last; } } if (!$found) { $resource_name = &get_resource_name($resource_key); $error_html .= $resource_name; $error_html .= "
"; $num_errors++; } } } if ($num_errors > 0) { &missing_input("Not Authorized", "You are not authorized to give a user access to the following resources:

$error_html"); } @prev_resources = (); @prev_resources = split(/\?/,$prev_resource_list); $error_html = ""; foreach $prev_resource_key (@prev_resources) { $found = 0; foreach $resource_key (@choices) { if (int($prev_resource_key) == int($resource_key)) { $found = 1; last; } } if (!$found) { if (&validate_resource_admin($username, $password, $prev_resource_key) == 0) { $resource_name = &get_resource_name($prev_resource_key); $error_html .= $resource_name; $error_html .= "
"; $num_errors++; } } } if ($num_errors > 0) { &missing_input("Not Authorized", "You are not authorized to remove user access to the following resources:

$error_html"); } } # end if ( $user_auth == $RESOURCE_ADMIN ) $found_flag = 0; $new_resource_list = &prep_resource_list($user_resource_list); if (!(-e $gauthorized_users_file)) { open(EDIT_DATA_FILE,">>$gauthorized_users_file") || &return_error("File Error","Unable to open " . $gauthorized_users_file); print EDIT_DATA_FILE $auth_user_name . "|" . $auth_user_password . "|" . $auth_user_full_name . "|" . $new_resource_list . "|" . $user_group . "|" . $auth_user_email . "|\n"; close(EDIT_DATA_FILE); chmod(0777, $gauthorized_users_file); } else { srand(time|$$); $random_number = int(rand(10000000)); $temp_file = $data_directory . "ureserve" . $random_number . ".tmp"; open (EDIT_DATA_FILE, $gauthorized_users_file) || &return_error("File Error","Unable to open " . $gauthorized_users_file); if (!(open(EDIT_TEMP_FILE, ">" . $temp_file))) { close(EDIT_DATA_FILE); &return_error("File Error","Unable to open " . $temp_file); } while () { $line = $_; @user_value_pairs = split (/\|/, $line); $current_auth_user_name = $user_value_pairs[0]; if (($found_flag == 0) && ($current_auth_user_name eq $auth_user_name)) { print EDIT_TEMP_FILE $auth_user_name . "|" . $auth_user_password . "|" . $auth_user_full_name . "|" . $new_resource_list . "|" . $user_group . "|" . $auth_user_email . "|\n"; $found_flag = 1; } else { print EDIT_TEMP_FILE $line; } } if ($found_flag == 0) { close($temp_file); unlink($temp_file); &return_error("File Error","Unable to locate " . $auth_user_full_name); } close(EDIT_DATA_FILE); close(EDIT_TEMP_FILE); unlink($gauthorized_users_file); rename($temp_file,$gauthorized_users_file); chmod(0777, $gauthorized_users_file); } } &log_info($ADMIN,"Authorized User $auth_user_full_name was modified by $username."); &create_manage_users_form("$auth_user_full_name ($auth_user_name) has been updated."); } sub delete_user { local ($auth_user_name, $modify_flag) = @_; local ($line, $current_auth_user_name, $found_flag, $random_number, $temp_file, $prev_name, $user_resource_list, $resource_name, $num_errors, $error_html, @user_value_pairs); &validate_referral_page($script_url); $found_flag = 0; srand(time|$$); $random_number = int(rand(10000000)); $temp_file = $data_directory . "ureserve" . $random_number . ".tmp"; open (DEL_DATA_FILE, $gauthorized_users_file) || &return_error("File Error","Unable to open " . $gauthorized_users_file); if (!(open(DEL_TEMP_FILE, ">" . $temp_file))) { close(DEL_DATA_FILE); &return_error("File Error","Unable to open " . $temp_file); } while () { $line = $_; @user_value_pairs = split (/\|/, $line); $current_auth_user_name = $user_value_pairs[0]; if (($found_flag == 0) && ($current_auth_user_name eq $auth_user_name)) { $found_flag = 1; } else { print DEL_TEMP_FILE $line; } } close(DEL_DATA_FILE); close(DEL_TEMP_FILE); unlink($gauthorized_users_file); rename($temp_file,$gauthorized_users_file); chmod(0777, $gauthorized_users_file); if (!$modify_flag) { &log_info($ADMIN,"Authorized User $auth_user_full_name was deleted by $username."); } return $found_flag; } sub validate_user { local ($resource_key, $auth_user_name, $auth_user_password) = @_; local ($line, $i, $cname, $cpassword, $resource_list, $temp_resource_list, $choice, @lines, @user_value_pairs, @choices); &validate_referral_page($script_url); $auth_user_name = &validate_string($auth_user_name); $auth_user_password = &validate_string($auth_user_password); if (-e $gauthorized_users_file) { open (USERS_FILE, $gauthorized_users_file) || &return_error("File Error","Unable to open Authorized Users Database."); @lines = ; close(USERS_FILE); for ($i = 0; $i <= $#lines; $i++) { @user_value_pairs = split (/\|/, $lines[$i]); $cname = $user_value_pairs[0]; $cpassword = $user_value_pairs[1]; $resource_list = $user_value_pairs[3]; if ($cname eq $auth_user_name) { if ($cpassword eq $auth_user_password) { @choices=split(/\?/,$resource_list); foreach $choice (@choices) { if (int($resource_key) == int($choice)) { return 1; # user is authorized } } return 0; } else { return -1; # bad password } } } } return -1; } sub get_user_group { local ($uname, $upassword) = @_; local ($line, $i, $cname, $cpassword, $user_group, @lines, @user_value_pairs); if ( (!($uname =~ /\S/)) || (!($upassword =~ /\S/))) { return -1; } &validate_referral_page($script_url); if (!(-e $gresource_file)) { if (($uname eq $gen_admin_login_password) || ($upassword eq $gen_admin_login_password)) { return $SYSTEM_ADMIN; } } @lines = (); if (-e $gauthorized_users_file) { open (USERS_FILE, $gauthorized_users_file) || &return_error("File Error","Unable to open Authorized Users Database."); @lines = ; close(USERS_FILE); for ($i = 0; $i <= $#lines; $i++) { chop($lines[$i]); @user_value_pairs = split (/\|/, $lines[$i]); $cname = $user_value_pairs[0]; $cpassword = $user_value_pairs[1]; $user_group = $user_value_pairs[4]; if ($cname eq $uname) { if ($cpassword eq $upassword) { if (int($user_group) > 0) { return $user_group; } } else { return -1; # bad password } } } } return -1; } sub get_user_info { local ($uname) = @_; local ($line, $i, $cname, $cpassword, $user_group, @lines, @user_value_pairs); &validate_referral_page($script_url); @lines = (); @user_value_pairs = (); if (-e $gauthorized_users_file) { open (USERS_FILE, $gauthorized_users_file) || &return_error("File Error","Unable to open Authorized Users Database."); @lines = ; close(USERS_FILE); for ($i = 0; $i <= $#lines; $i++) { chop($lines[$i]); @user_value_pairs = split (/\|/, $lines[$i]); $cname = $user_value_pairs[0]; if ($cname eq $uname) { return @user_value_pairs; } } } return @user_value_pairs; } sub get_user_resource_list { local ($uname) = @_; local ($line, $i, $cname, $resource_list, @lines, @key_value_pairs); &validate_referral_page($script_url); @lines = (); @key_value_pairs = (); $resource_list = ""; if (-e $gauthorized_users_file) { open (USERS_FILE, $gauthorized_users_file) || &return_error("File Error","Unable to open Authorized Users Database."); @lines = ; close(USERS_FILE); for ($i = 0; $i <= $#lines; $i++) { chop($lines[$i]); @key_value_pairs = split (/\|/, $lines[$i]); $cname = $key_value_pairs[0]; if ($cname eq $uname) { return $key_value_pairs[3]; } } } return $resource_list; } sub create_delete_user_confirmation_form { local ( $temp_user_name, $temp_user_name2, $auth_user_name, $auth_user_password, $auth_user_full_name, $user_auth, $user_to_delete_auth, $resource_admin_access, $reports_admin_access, $resource_key, $resource_name, @choices, @key_value_pairs, @user_value_pairs ); &validate_referral_page($script_url); $temp_user_name = $form_text{'auth_user_name'}; @user_value_pairs = split (/\|/, $temp_user_name); $temp_user_name2 = $user_value_pairs[0]; @key_value_pairs = &get_user_info($temp_user_name2); $auth_user_name = $key_value_pairs[0]; $auth_user_password = $key_value_pairs[1]; $auth_user_full_name = $key_value_pairs[2]; $user_to_delete_auth = &get_user_group($auth_user_name, $auth_user_password); $user_to_delete_auth = int($user_to_delete_auth); if ($user_to_delete_auth == $SYSTEM_ADMIN) { &missing_input("Not Authorized","You are not authorized to delete a user with System Admin privilege."); } $user_auth = &get_user_group($username, $password); $user_auth = int($user_auth); $num_errors = 0; $error_html = ""; if ( $user_auth == $RESOURCE_ADMIN ) { @user_value_pairs = &get_user_info($auth_user_name); $num_errors = 0; $error_html = ""; @choices=split(/\?/,$user_value_pairs[3]); foreach $resource_key (@choices) { if (&validate_resource_admin($username, $password, $resource_key) == 0) { $resource_name = &get_resource_name($resource_key); $error_html .= $resource_name; $error_html .= "
"; $num_errors++; } } if ($num_errors > 0) { &missing_input("Not Authorized", "You are not authorized to delete this user who also has access to the following resources:

$error_html"); } } print "Content-type: text/html\n\n"; print "\n"; print "\n"; print "\n\n"; print "uReserve"; print ""; print "




"; print ""; print "
"; print ""; print ""; print ""; print "
"; print ""; print "
Are you sure you want to delete:
" . $auth_user_full_name . " (" . $auth_user_name . ")?


"; print "
"; print "
"; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print "
"; print "
"; print "
"; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print "
"; print "
"; print "
"; print "
"; print ""; exit; } sub send_mail { local ($sendfrom, $sendto, $messagesubject, $messagebody) = @_; local ($mail_program); &validate_referral_page($script_url); $mail_program = $settings[14] . " -t"; $messagebody =~ s/\ \;/ /g; $messagebody =~ s/\/\n/g; $messagebody =~ s/\//g; $messagebody =~ s/\<\/b\>//g; $messagebody =~ s/\^/\n/g; open (MAIL, "|$mail_program") || &return_error("Email Error","Unable to open sendmail."); print MAIL "To: " . $sendto . "\n"; print MAIL "From: " . $sendfrom . "\n"; print MAIL "Subject: " . $messagesubject . "\n\n"; print MAIL $messagebody . "\n"; close (MAIL); &update_reservation_log_w_email($sendto, $sendfrom); } sub send_mail_sockets { local ($from, $to, $subject, $message) = @_; local ($replyaddr) = $from; local ($proto, $port); &validate_referral_page($script_url); if (!$to) { return; } $proto = (getprotobyname('tcp'))[2]; $port = 25; $smtpaddr = ($settings[15] =~ /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/) ? pack('C4',$1,$2,$3,$4) : (gethostbyname($smtp_address))[4]; if (!defined($smtpaddr)) { &return_error("Configuration Error","No SMTP address specified"); } if (!socket(S, $AF_INET, $SOCK_STREAM, $proto)) { &return_error("Configuration Error","Unable to create socket"); } if (!connect(S, pack('Sna4x8', $AF_INET, $port, $smtpaddr))) { &return_error("Configuration Error","Unable to connect to socket"); } local($oldfh) = select(S); $| = 1; select($oldfh); $_ = ; if (/^[45]/) { close S; return; } print S "helo localhost\r\n"; $_ = ; if (/^[45]/) { close S; return; } print S "mail from: $from\r\n"; $_ = ; if (/^[45]/) { close S; return; } print S "rcpt to: $to\r\n"; $_ = ; if (/^[45]/) { close S; return; } print S "data\r\n"; $_ = ; if (/^[45]/) { close S; return; } print S "X-Mailer: Sendmail \r\n"; print S "Mime-Version: 1.0\r\n"; print S "Content-Type: text/plain; charset=us-ascii\r\n"; print S "To: $to\r\n"; print S "From: $from\r\n"; print S "Reply-to: $replyaddr\r\n" if $replyaddr; print S "Subject: $subject\r\n\r\n"; $message =~ s/\ \;/ /g; $message =~ s/\/\n/g; print S "$message"; print S "\r\n.\r\n"; $_ = ; if (/^[45]/) { close S; return; } print S "quit\r\n"; $_ = ; close S; &update_reservation_log_w_email($to, $from); } sub custom_email_method { local ($from_address,$to_address,$subject,$message) = @_; &validate_referral_page($script_url); $message =~ s/\ \;/ /g; $message =~ s/\/\n/g; } sub create_general_settings_form { local ($message) = @_; local ($resource_admin_access, $reports_admin_access, $user_auth); &validate_referral_page($script_url); $resource_admin_access = 0; $reports_admin_access = 0; &validate_admin($username, $password, $resource_admin_access, $reports_admin_access); $user_auth = &get_user_group($username, $password); $user_auth = int($user_auth); print "Content-type: text/html\n\n"; print "\n"; print "\n"; print "\n\n"; print "uReserve"; print ""; print "



"; print "
"; print ""; print "

"; print ""; print "
"; print "
"; print ""; print "$lang_general_settings

"; print "
"; print ""; if (($message =~ /\S/) && ($message ne "NONE")) { print $message; } else { print $lang_general_settings_text; } print ""; print "
"; print "
"; print "
"; print ""; if ($user_auth == $SYSTEM_ADMIN) { &print_button('M',"$lang_gs_display_preferences", "gs_display_preferences", $password, $username); &print_button('M',"$lang_gs_reservation_fields_settings", "gs_reservation_fields_settings", $password, $username); &print_button('M',"$lang_gs_email_settings", "gs_email_settings", $password, $username); } if (($user_auth == $SYSTEM_ADMIN) || ($user_auth == $RESOURCE_ADMIN) || ($user_auth == $REPORTS_ADMIN)) { &print_button('M',"$lang_gs_report_preferences", "gs_report_preferences", $password, $username); } if ($user_auth == $SYSTEM_ADMIN) { &print_button('M',"$lang_gs_colors_fonts_settings", "gs_colors_fonts_settings", $password, $username); } &print_button('M',"$lang_goto_schedule", "cp_view_schedule", $password, $username); &print_button('M',"$lang_back", "login", $password, $username); print "
"; print "
"; print "
"; print ""; exit; } sub create_display_preferences_form { local ($message) = @_; &validate_referral_page($script_url); $resource_admin_access = 0; $reports_admin_access = 0; &validate_admin($username, $password, $resource_admin_access, $reports_admin_access); print "Content-type: text/html\n\n"; print "\n"; print "\n"; print "\n\n"; print "uReserve"; print ""; print "


"; print "
"; print ""; print "$lang_gs_display_preferences

"; print "
"; print "
"; print "
"; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; $ghelp_file_key_string = "timeslotsize"; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; $ghelp_file_key_string = "schedstart"; print ""; print ""; print ""; print ""; $ghelp_file_key_string = "showcategorylinks"; print ""; print ""; print ""; print ""; $ghelp_file_key_string = "showcatmenulink"; print ""; print ""; print ""; print ""; # end new 04/14/06 $ghelp_file_key_string = "adminlink"; print ""; print ""; print ""; print ""; $ghelp_file_key_string = "togglelink"; print ""; print ""; print ""; print ""; $ghelp_file_key_string = "navbar"; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; $ghelp_file_key_string = "servertimezone"; $timezone_adjustment_html = &get_timezone_adjustment_html(); print ""; print ""; print ""; print ""; $ghelp_file_key_string = "startday"; print ""; print ""; print ""; print ""; $ghelp_file_key_string = "showweekends"; print ""; print ""; print ""; print ""; $ghelp_file_key_string = "maintainlog"; print ""; print ""; print ""; print ""; $ghelp_file_key_string = "permissionlevel"; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; $ghelp_file_key_string = "onlyshowfull"; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; $ghelp_file_key_string = "showlinks"; print ""; print ""; print ""; print ""; $ghelp_file_key_string = "showlinkscolumns"; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print "


$lang_timeslot_size:"; print "$lang_timeslot_change_warning  "; print "$lang_help_string"; print "
$lang_display_format:"; print "
$lang_sched_start:"; print ""; if ($settings[5] =~ /US/i) { print "MM/DD/YYYY"; } else { print "DD/MM/YYYY"; } print "$lang_sched_start_info  "; print "$lang_help_string"; print "
$lang_show_category_links:"; print "$lang_show_category_links_info  "; print "$lang_help_string"; print "
$lang_show_category_menu_hyperlink"; if ($settings[149] =~ /NO/i) { print "$lang_yes"; print "$lang_no"; } else { print "$lang_yes"; print "$lang_no"; } print "$lang_show_category_menu_hyperlink_info  "; print "$lang_help_string"; print "
$lang_show_admin_link"; print ""; print ""; print "$lang_show_admin_link_info  "; print "$lang_help_string"; print "
$lang_show_toggle_link"; print ""; print ""; print "$lang_show_toggle_link_info  "; print "$lang_help_string"; print "
$lang_show_navbar"; print ""; print ""; print "$lang_show_navbar_info  "; print "$lang_help_string"; print "
$lang_date_format:"; if ($settings[5] eq "US") { print "$lang_US
"; print "$lang_european"; } else { print "$lang_US
"; print "$lang_european"; } print "
$lang_time_format:"; if ($settings[8] =~ /STD/i) { print "$lang_time_format_std"; print "
$lang_time_format_mil"; } else { print "$lang_time_format_std"; print "
$lang_time_format_mil"; } print "
$lang_server_timezone_adjust:"; print $timezone_adjustment_html; print "$lang_server_timezone_adjust_info  "; print "$lang_help_string"; print "
$lang_start_day:"; if ($settings[6] =~ /SUN/i) { print "$lang_Sunday"; print "$lang_Monday"; } else { print "$lang_Sunday"; print "$lang_Monday"; } print "$lang_start_day_change_warning  "; print "$lang_help_string"; print "
$lang_show_weekends:"; if ($settings[7] =~ /YES/i) { print "$lang_yes"; print "$lang_no"; } else { print "$lang_yes"; print "$lang_no"; } print "$lang_show_weekends_info  "; print "$lang_help_string"; print "
$lang_maintain_log:"; if ($settings[9] =~ /YES/i) { print "$lang_yes"; print "$lang_no"; } else { print "$lang_yes"; print "$lang_no"; } print "$lang_maintain_log_info  "; print "$lang_help_string"; print "
$lang_permission_level:"; if (int($settings[10]) == $ANY_RESERVE_ANY_RECURRING) { print "1  "; print "2  "; print "3  "; print "4  "; print "5  "; } elsif (int($settings[10]) == $AUTH_RESERVE_AUTH_RECURRING) { print "1  "; print "2  "; print "3  "; print "4  "; print "5  "; } elsif (int($settings[10]) == $ANY_RESERVE_NO_RECURRING) { print "1  "; print "2  "; print "3  "; print "4  "; print "5  "; } elsif (int($settings[10]) == $AUTH_RESERVE_NO_RECURRING) { print "1  "; print "2  "; print "3  "; print "4  "; print "5  "; } else { print "1  "; print "2  "; print "3  "; print "4  "; print "5  "; } print "$lang_permission_level_info  "; print "$lang_help_string"; print "
$lang_reserve_char_prompt:"; print ""; print "
$lang_reserve_image_prompt:"; print ""; print "
$lang_reserve_image_alt_prompt:"; print ""; print "
$lang_daily_cell_prompt:"; print "$lang_width_prompt: "; print "     "; print "$lang_height_prompt: "; print "
$lang_reserve_instructions_prompt:"; print ""; print "
$lang_monthly_cell_prompt:"; print "$lang_width_prompt: "; print "     "; print "$lang_height_prompt: "; print "
$lang_reserve_monthly_instructions_prompt:"; print ""; print "
$lang_only_show_full:"; if ($settings[82] =~ /YES/i) { print "$lang_yes"; print "$lang_no"; } else { print "$lang_yes"; print "$lang_no"; } print "$lang_only_show_full_info  "; print "$lang_help_string"; print "
$lang_monthly_reserve_image_prompt:"; print ""; print "
$lang_monthly_reserve_image_alt_prompt:"; print ""; print "
$lang_monthly_pending_image_prompt:"; print ""; print "
$lang_monthly_pending_image_alt_prompt:"; print ""; print "
$lang_monthly_fullday_image_prompt:"; print ""; print "
$lang_monthly_fullday_image_alt_prompt:"; print ""; print "
$lang_show_links:"; if ($settings[83] =~ /YES/i) { print "$lang_yes"; print "$lang_no"; } else { print "$lang_yes"; print "$lang_no"; } print "$lang_show_links_info  "; print "$lang_help_string"; print "
$lang_show_links_columns:"; print "$lang_show_links_columns_info  "; print "$lang_help_string"; print "
$lang_show_links_background_color:"; print ""; print " $lang_color_chart"; print ""; print "
$lang_show_links_font_size:"; print ""; print "
$lang_show_links_font_face:"; print ""; print " $lang_font_chart"; print ""; print "
"; print "
"; print ""; print ""; print ""; print ""; print "
"; print "
"; print "
"; print "


"; print ""; exit; } sub save_display_preferences { local ($temp_string); &validate_referral_page($script_url); $temp_string = $form_text{'timeslot_size'}; #15min, 30min or 60min version $temp_string = &validate_string($temp_string); $settings[0] = $temp_string; $temp_string = $form_text{'display_format'}; # Daily, Weekly or Monthly $temp_string = &validate_string($temp_string); $settings[1] = $temp_string; $temp_string = $form_text{'date_style_format'}; # date format US or EUROPEAN $temp_string = &validate_string($temp_string); $settings[5] = $temp_string; $temp_string = $form_text{'start_day'}; # start day SUN or MON $temp_string = &validate_string($temp_string); $settings[6] = $temp_string; $temp_string = $form_text{'show_weekends'}; # option (Yes/No) to show weekends $temp_string = &validate_string($temp_string); $settings[7] = $temp_string; $temp_string = $form_text{'time_format'}; # time format STD or MIL $temp_string = &validate_string($temp_string); $settings[8] = $temp_string; $temp_string = $form_text{'maintain_log'}; #$gen_maintain_log (Yes/No) $temp_string = &validate_string($temp_string); $settings[9] = $temp_string; $temp_string = $form_text{'permission_level'}; # default user permission level $temp_string = &validate_string($temp_string); $settings[10] = $temp_string; $temp_string = $form_text{'reserve_char'}; # reservation character placeholder $temp_string = &validate_string($temp_string); $settings[31] = $temp_string; $temp_string = $form_text{'reserve_image'}; # reservation image $temp_string = &validate_string($temp_string); $settings[32] = $temp_string; $temp_string = $form_text{'reserve_image_alt'}; # reservation image alt text $temp_string = &validate_string($temp_string); $settings[33] = $temp_string; $temp_string = $form_text{'cell_width'}; # cell width $temp_string = &validate_string($temp_string); $settings[34] = $temp_string; $temp_string = $form_text{'monthly_cell_width'}; # monthly cell width $temp_string = &validate_string($temp_string); $settings[35] = $temp_string; $temp_string = $form_text{'reserve_instructions'}; # daily/weekly reservation instructions $temp_string = &validate_string($temp_string); $settings[56] = $temp_string; $temp_string = $form_text{'cell_height'}; # cell height $temp_string = &validate_string($temp_string); $settings[67] = $temp_string; $temp_string = $form_text{'monthly_cell_height'}; # monthly cell height $temp_string = &validate_string($temp_string); $settings[68] = $temp_string; $temp_string = $form_text{'reserve_monthly_instructions'}; # monthly reservation instructions $temp_string = &validate_string($temp_string); $settings[57] = $temp_string; $temp_string = $form_text{'only_show_full'}; # only show monthly timeslots as reserved if all slots filled $temp_string = &validate_string($temp_string); $settings[82] = $temp_string; $temp_string = $form_text{'show_links'}; # (monthly) show hyperlinks to each calendar $temp_string = &validate_string($temp_string); $settings[83] = $temp_string; $temp_string = $form_text{'show_links_columns'}; # (monthly) number of hyperlinks columns $temp_string = &validate_string($temp_string); $settings[84] = $temp_string; $temp_string = $form_text{'show_links_background_color'}; # ($monthly) hyperlinks table color $temp_string = &validate_string($temp_string); $settings[85] = $temp_string; $temp_string = $form_text{'show_links_font_size'}; # hyperlinks Font Size $temp_string = &validate_string($temp_string); $settings[86] = $temp_string; $temp_string = $form_text{'show_links_font_face'}; # hyperlinks Font Face $temp_string = &validate_string($temp_string); $settings[87] = $temp_string; $temp_string = $form_text{'monthly_reserve_image'}; # monthly reserve image $temp_string = &validate_string($temp_string); $settings[88] = $temp_string; $temp_string = $form_text{'monthly_reserve_image_alt'}; # monthly reserve image alt $temp_string = &validate_string($temp_string); $settings[89] = $temp_string; $temp_string = $form_text{'monthly_pending_image'}; # monthly pending image $temp_string = &validate_string($temp_string); $settings[90] = $temp_string; $temp_string = $form_text{'monthly_pending_image_alt'}; # monthly pending image alt $temp_string = &validate_string($temp_string); $settings[91] = $temp_string; $temp_string = $form_text{'monthly_fullday_image'}; # monthly full day image $temp_string = &validate_string($temp_string); $settings[92] = $temp_string; $temp_string = $form_text{'monthly_fullday_image_alt'}; # monthly full day image alt $temp_string = &validate_string($temp_string); $settings[93] = $temp_string; $temp_string = $form_text{'sched_start'}; # monthly full day image alt if ($temp_string =~ /\S/) { $validate_date_seconds = &get_date_seconds($temp_string); } $settings[94] = $temp_string; $temp_string = $form_text{'show_admin_link'}; # admin control panel hyperlink $settings[95] = $temp_string; $temp_string = $form_text{'show_toggle_link'}; # hyperlink to toggle schedule view $settings[122] = $temp_string; $temp_string = $form_text{'toggle_vloc'}; # toggle schedule hyperlink vertical pos $settings[123] = $temp_string; $temp_string = $form_text{'toggle_hloc'}; # toggle schedule hyperlink horizontal pos $settings[124] = $temp_string; $temp_string = $form_text{'admin_vloc'}; # admin control panel schedule hyperlink vertical pos $settings[125] = $temp_string; $temp_string = $form_text{'admin_hloc'}; # admin control panel hyperlink horizontal pos $settings[126] = $temp_string; $temp_string = $form_text{'show_category_links'}; # category links on one page $settings[131] = $temp_string; $temp_string = $form_text{'show_cat_menu_hyperlink'}; # show category menu hyperlink $settings[149] = $temp_string; $temp_string = $form_text{'timezone_adjustment'}; # timezone adjustment if ( ($temp_string > -24) && ($temp_string < 24) ) { $settings[140] = int($temp_string); } else { &missing_input("Invalid Timezone Adjustment Setting","Valid values are integers from -23 to 23"); } $temp_string = $form_text{'show_navbar'}; # navigation bar $settings[145] = $temp_string; $temp_string = $form_text{'navbar_vloc'}; # navigation bar vertical pos $settings[146] = $temp_string; $temp_string = $form_text{'navbar_hloc'}; # navigation bar horizontal pos $settings[147] = $temp_string; &save_settings(); &log_info($ADMIN,"$username updated Display Preferences."); &create_general_settings_form("$lang_gs_display_preferences have been saved."); } sub create_report_preferences_form { local ($message) = @_; &validate_referral_page($script_url); $resource_admin_access = 1; $reports_admin_access = 0; &validate_admin($username, $password, $resource_admin_access, $reports_admin_access); print "Content-type: text/html\n\n"; print "\n"; print "\n"; print "\n\n"; print "uReserve"; print ""; print "


"; print "
"; print ""; print "$lang_report_preferences

"; print "
"; print "
"; print "
"; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; $ghelp_file_key_string = "daterangestart"; print ""; print ""; print ""; print ""; $ghelp_file_key_string = "daterangeend"; print ""; print ""; print ""; print ""; $ghelp_file_key_string = "printempty"; print ""; print ""; print ""; print ""; $ghelp_file_key_string = "printampm"; print ""; print ""; print ""; print ""; $ghelp_file_key_string = "printdouble"; print ""; print ""; print ""; print ""; $ghelp_file_key_string = "reportonall"; print ""; print ""; print ""; print ""; $ghelp_file_key_string = "emailprimary"; print ""; print ""; print ""; print ""; $ghelp_file_key_string = "emailsecondary"; print ""; print ""; print ""; print ""; $ghelp_file_key_string = "printtoscreen"; print ""; print ""; print ""; print ""; $ghelp_file_key_string = "printtofile"; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print "


$lang_default_start_date:"; print "$lang_default_start_date_info  "; print "$lang_help_string"; print "
$lang_default_end_date:"; print "$lang_date_range_end_info  "; print "$lang_help_string"; print "
$lang_print_empty_timeslots:"; if ($settings[81] =~ /YES/i) { print "$lang_yes"; print "$lang_no"; } else { print "$lang_yes"; print "$lang_no"; } print "$lang_print_empty_timeslots_info  "; print "$lang_help_string"; print "
$lang_print_am_pm:"; if ($settings[65] =~ /YES/i) # print am/pm on report { print "$lang_yes"; print "$lang_no"; } else { print "$lang_yes"; print "$lang_no"; } print "$lang_print_am_pm_info  "; print "$lang_help_string"; print "
$lang_print_double:"; if ($settings[66] =~ /YES/i) # double space the report { print "$lang_yes"; print "$lang_no"; } else { print "$lang_yes"; print "$lang_no"; } print "$lang_print_double_info  "; print "$lang_help_string"; print "
$lang_run_for_all_resources:"; if ($settings[60] =~ /YES/i) # run report for all resources { print "$lang_yes"; print "$lang_no"; } else { print "$lang_yes"; print "$lang_no"; } print "$lang_run_for_all_resources_info  "; print "$lang_help_string"; print "
$lang_email_report_to_primary:"; if ($settings[61] =~ /YES/i) # email primary admin { print "$lang_yes"; print "$lang_no"; } else { print "$lang_yes"; print "$lang_no"; } print "$lang_email_report_to_primary_info  "; print "$lang_help_string"; print "
$lang_email_report_to_secondary:"; if ($settings[62] =~ /YES/i) # email secondary admin { print "$lang_yes"; print "$lang_no"; } else { print "$lang_yes"; print "$lang_no"; } print "$lang_email_report_to_secondary_info  "; print "$lang_help_string"; print "
$lang_print_to_screen:"; if ($settings[63] =~ /YES/i) # print report to screen { print "$lang_yes"; print "$lang_no"; } else { print "$lang_yes"; print "$lang_no"; } print "$lang_print_to_screen_info  "; print "$lang_help_string"; print "
$lang_print_to_file:"; if ($settings[64] =~ /YES/i) # print report to file { print "$lang_yes"; print "$lang_no"; } else { print "$lang_yes"; print "$lang_no"; } print "$lang_print_to_file_info  "; print "$lang_help_string"; print "
"; print "
"; print ""; print ""; print ""; print ""; print "
"; print "
"; print "
"; print "


"; print ""; exit; } sub save_report_preferences { local ($temp_string); &validate_referral_page($script_url); $temp_string = $form_text{'start_date_range'}; # date range report default start date $temp_string = &validate_string($temp_string); $settings[58] = $temp_string; $temp_string = $form_text{'end_date_range'}; # date range report default end date (# of days from start date) $temp_string = &validate_string($temp_string); $settings[59] = $temp_string; $temp_string = $form_text{'print_empty'}; # whether to print open timeslots on the report $temp_string = &validate_string($temp_string); $settings[81] = $temp_string; $temp_string = $form_text{'report_on_all'}; # default run report for all resources $temp_string = &validate_string($temp_string); $settings[60] = $temp_string; $temp_string = $form_text{'email_primary'}; # default to email the primary admin a resource report $temp_string = &validate_string($temp_string); $settings[61] = $temp_string; $temp_string = $form_text{'email_secondary'}; # default to email the secondary admin a resource report $temp_string = &validate_string($temp_string); $settings[62] = $temp_string; $temp_string = $form_text{'print_to_screen'}; # default to print report to the screen $temp_string = &validate_string($temp_string); $settings[63] = $temp_string; $temp_string = $form_text{'print_to_file'}; # default to print report to a file $temp_string = &validate_string($temp_string); $settings[64] = $temp_string; $temp_string = $form_text{'print_am_pm'}; # default to show am/pm on report $temp_string = &validate_string($temp_string); $settings[65] = $temp_string; $temp_string = $form_text{'print_double'}; # default to double-space report $temp_string = &validate_string($temp_string); $settings[66] = $temp_string; &save_settings(); &log_info($ADMIN,"$username updated Report Preferences."); &create_general_settings_form("$lang_report_preferences have been saved."); } sub create_security_settings_form { local ($message) = @_; &validate_referral_page($script_url); $resource_admin_access = 0; $reports_admin_access = 0; &validate_admin($username, $password, $resource_admin_access, $reports_admin_access); print "Content-type: text/html\n\n"; print "\n"; print "\n"; print "\n\n"; print "uReserve"; print ""; print "


"; print "
"; print ""; print "$lang_security_settings

"; print "
"; print "
"; print "
"; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; $ghelp_file_key_string = "passwordprotect"; print ""; print ""; print ""; print ""; $ghelp_file_key_string = "restrictviewing"; print ""; print ""; print ""; print ""; $ghelp_file_key_string = "disablereferrer"; print ""; print ""; print ""; print ""; $ghelp_file_key_string = "passedtimeslots"; print ""; print ""; print ""; print ""; $ghelp_file_key_string = "overrideexpired"; print ""; print ""; print ""; print ""; $ghelp_file_key_string = "ignorelockout"; print ""; print ""; print ""; print ""; $ghelp_file_key_string = "userschangepswd"; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print "


$lang_pass_protect_schedule:"; if ($settings[127] =~ /YES/i) { print "Yes"; print "No"; } else { print "Yes"; print "No"; } print "$lang_pass_protect_schedule_info  "; print "$lang_help_string"; print "
$lang_restrict_viewing:"; if ($settings[80] =~ /YES/i) { print "Yes"; print "No"; } else { print "Yes"; print "No"; } print "$lang_restrict_viewing_info  "; print "$lang_help_string"; print "
$lang_disable_referrer:"; if ($settings[128] =~ /YES/i) { print "Yes"; print "No"; } else { print "Yes"; print "No"; } print "$lang_disable_referrer_info  "; print "$lang_help_string"; print "
$lang_passed_timeslot_check:"; if ($settings[121] =~ /YES/i) { print "Yes"; print "No"; } else { print "Yes"; print "No"; } print "$lang_passed_timeslot_check_info  "; print "$lang_help_string"; print "
$lang_override_expired:"; if ($settings[129] =~ /YES/i) { print "Yes"; print "No"; } else { print "Yes"; print "No"; } print "$lang_override_expired_info  "; print "$lang_help_string"; print "
$lang_ignore_lockout:"; if ($settings[135] =~ /YES/i) { print "Yes"; print "No"; } else { print "Yes"; print "No"; } print "$lang_ignore_lockout_info  "; print "$lang_help_string"; print "
$lang_auth_users_change_pswd:"; if ($settings[150] =~ /YES/i) { print "Yes"; print "No"; } else { print "Yes"; print "No"; } print "$lang_auth_users_change_pswd_info  "; print "$lang_help_string"; print "
  
"; print "
"; print ""; print ""; print ""; print ""; print "
"; print "
"; print "
"; print "


"; print ""; exit; } sub save_security_settings { local ($temp_string); &validate_referral_page($script_url); $temp_string = $form_text{'password_protect'}; # password protect the entire calendar $temp_string = &validate_string($temp_string); $settings[127] = $temp_string; $temp_string = $form_text{'restrict_viewing'}; # restrict reservation detail viewing $temp_string = &validate_string($temp_string); $settings[80] = $temp_string; $temp_string = $form_text{'passed_timeslot_check'}; # prevent reservations during passed timeslots $temp_string = &validate_string($temp_string); $settings[121] = $temp_string; $temp_string = $form_text{'disable_referrer'}; # disable illegal referrer check $temp_string = &validate_string($temp_string); $settings[128] = $temp_string; $temp_string = $form_text{'override_expired'}; # allow the admin to override the expired timeslot check $temp_string = &validate_string($temp_string); $settings[129] = $temp_string; $temp_string = $form_text{'ignore_lockout'}; # allow admin to add/del reservations during resource lockout period $temp_string = &validate_string($temp_string); $settings[135] = $temp_string; $temp_string = $form_text{'users_change_pswd'}; # allow auth users to modify their own password $temp_string = &validate_string($temp_string); $settings[150] = $temp_string; &save_settings(); &log_info($ADMIN,"$username updated Security Settings."); &create_admin_control_panel("$lang_security_settings have been saved."); } # End of save_security_settings() sub create_email_settings_form { local ($message) = @_; &validate_referral_page($script_url); $resource_admin_access = 0; $reports_admin_access = 0; &validate_admin($username, $password, $resource_admin_access, $reports_admin_access); print "Content-type: text/html\n\n"; print "\n"; print "\n"; print "\n\n"; print "uReserve"; print ""; print "


"; print "
"; print ""; print "$lang_email_settings

"; print "
"; print "
"; print "
"; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print "
"; print "
 $lang_general_email_settings:

$lang_primary_email_prompt:"; if ($settings[2] =~ /\S/) { print ""; } else { print ""; } print "
$lang_secondary_email_prompt:"; if ($settings[3] =~ /\S/) { print ""; } else { print ""; } print "
$lang_user_email_prompt:"; if ($settings[4] =~ /YES/i) { print "$lang_yes"; print "$lang_no"; } else { print "$lang_yes"; print "$lang_no"; } print "

"; print "
 $lang_admin_email_subjects:

$lang_admin_add_email_subject_prompt:"; if ($settings[11] =~ /\S/) { print ""; } else { print ""; } print "
$lang_admin_pending_email_subject_prompt:"; if ($settings[78] =~ /\S/) { print ""; } else { print ""; } print "
$lang_admin_mod_email_subject_prompt:"; if ($settings[69] =~ /\S/) { print ""; } else { print ""; } print "
$lang_admin_del_email_subject_prompt:"; if ($settings[70] =~ /\S/) { print ""; } else { print ""; } print "
$lang_admin_pending_auth_email_subject_prompt:"; if ($settings[141] =~ /\S/) { print ""; } else { print ""; } print "
$lang_admin_pending_rej_email_subject_prompt:"; if ($settings[142] =~ /\S/) { print ""; } else { print ""; } print "

"; print "
 $lang_user_email_subjects:

$lang_user_add_email_subject_prompt:"; if ($settings[12] =~ /\S/) { print ""; } else { print ""; } print "
$lang_user_pending_email_subject_prompt:"; if ($settings[79] =~ /\S/) { print ""; } else { print ""; } print "
$lang_user_mod_email_subject_prompt:"; if ($settings[71] =~ /\S/) { print ""; } else { print ""; } print "
$lang_user_del_email_subject_prompt:"; if ($settings[72] =~ /\S/) { print ""; } else { print ""; } print "
$lang_user_pending_auth_email_subject_prompt:"; if ($settings[143] =~ /\S/) { print ""; } else { print ""; } print "
$lang_user_pending_rej_email_subject_prompt:"; if ($settings[144] =~ /\S/) { print ""; } else { print ""; } print "

"; print "
 $lang_email_transport:

$lang_email_method:"; print "
$lang_sendmail_path_prompt:"; if ($settings[14] =~ /\S/) { print ""; } else { print ""; } print "
$lang_smtp_address_prompt:"; if ($settings[15] =~ /\S/) { print ""; } else { print ""; } print "
"; print "
"; print ""; print ""; print ""; print "
"; print "
"; print "


"; print ""; exit; } sub save_email_settings { local ($temp_string); &validate_referral_page($script_url); $temp_string = $form_text{'primary_email'}; # primary admin notification e-mail if ($temp_string =~ /\S/) { $email_out = &validate_email($temp_string); if (($temp_string ne $email_out) || (!($temp_string =~ /\@/g))) { &missing_input("Primary E-Mail Address Invalid ($temp_string)","Please enter a valid e-mail address for the Primary Admin, or leave blank."); } } $settings[2] = $temp_string; &auto_remove_blocked_user($temp_string); $temp_string = $form_text{'secondary_email'}; # secondary admin notification e-mail if ($temp_string =~ /\S/) { $email_out = &validate_email($temp_string); if (($temp_string ne $email_out) || (!($temp_string =~ /\@/g))) { &missing_input("Secondary E-Mail Address Invalid ($temp_string)","Please enter a valid e-mail address for the Secondary Admin, or leave blank."); } } $settings[3] = $temp_string; &auto_remove_blocked_user($temp_string); $temp_string = $form_text{'email_user'}; # option (Yes/No) to send user a notification e-mail $temp_string = &validate_string($temp_string); $settings[4] = $temp_string; $temp_string = $form_text{'admin_email_subject1'}; # admin email subject for reservations creations $temp_string = &validate_string($temp_string); $settings[11] = $temp_string; $temp_string = $form_text{'user_email_subject1'}; # user email subject for reservation creations $temp_string = &validate_string($temp_string); $settings[12] = $temp_string; $temp_string = $form_text{'email_method'}; # email method "SENDMAIL" for Unix servers or "SOCKETS" for NT servers. $temp_string = &validate_string($temp_string); $settings[13] = $temp_string; $temp_string = $form_text{'sendmail_path'}; # secondary admin notification e-mail $temp_string = &validate_string($temp_string); $settings[14] = $temp_string; $temp_string = $form_text{'smtp_address'}; # For "SOCKETS" email method - otherwise not used. $temp_string = &validate_string($temp_string); $settings[15] = $temp_string; $temp_string = $form_text{'admin_email_subject2'}; # admin email subject for modified reservations $temp_string = &validate_string($temp_string); $settings[69] = $temp_string; $temp_string = $form_text{'admin_email_subject3'}; # admin email subject for reservation cancellations $temp_string = &validate_string($temp_string); $settings[70] = $temp_string; $temp_string = $form_text{'admin_email_subject4'}; # admin email subject for reservation pending $temp_string = &validate_string($temp_string); $settings[78] = $temp_string; $temp_string = $form_text{'admin_email_subject5'}; # admin email subject for pending reservation accepted $temp_string = &validate_string($temp_string); $settings[141] = $temp_string; $temp_string = $form_text{'admin_email_subject6'}; # admin email subject for pending reservation rejected $temp_string = &validate_string($temp_string); $settings[142] = $temp_string; $temp_string = $form_text{'user_email_subject2'}; # user email subject for reservation mods $temp_string = &validate_string($temp_string); $settings[71] = $temp_string; $temp_string = $form_text{'user_email_subject3'}; # user email subject for reservation cancellations $temp_string = &validate_string($temp_string); $settings[72] = $temp_string; $temp_string = $form_text{'user_email_subject4'}; # user email subject for reservation pending $temp_string = &validate_string($temp_string); $settings[79] = $temp_string; $temp_string = $form_text{'user_email_subject5'}; # user email subject for pending reservation accepted $temp_string = &validate_string($temp_string); $settings[143] = $temp_string; $temp_string = $form_text{'user_email_subject6'}; # user email subject for pending reservation rejected $temp_string = &validate_string($temp_string); $settings[144] = $temp_string; &save_settings(); &log_info($ADMIN,"$username updated E-Mail Settings."); &create_general_settings_form("$lang_email_settings have been saved."); } sub create_colors_fonts_settings_form { local ($message) = @_; &validate_referral_page($script_url); $resource_admin_access = 0; $reports_admin_access = 0; &validate_admin($username, $password, $resource_admin_access, $reports_admin_access); print "Content-type: text/html\n\n"; print "\n"; print "\n"; print "\n\n"; print "uReserve"; print ""; print "


"; print "
"; print ""; print "$lang_color_settings

"; print "
"; print "
"; print "
"; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; $ghelp_file_key_string = "reservedcolor"; print ""; print ""; print ""; print ""; print ""; print ""; $ghelp_file_key_string = "pendingcolor"; print ""; print ""; print ""; print ""; print ""; print ""; $ghelp_file_key_string = "blockedcolor"; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print "


$lang_page_background_image_prompt:"; print ""; print "
$lang_page_background_color_prompt:"; print ""; print ""; print " $lang_color_chart"; print ""; print "
$lang_schedule_title_color_prompt:"; print ""; print " $lang_color_chart"; print "
$lang_page_font_face_prompt:"; print ""; print ""; print " $lang_font_chart"; print ""; print "
$lang_page_font_size_prompt:"; print ""; print "
$lang_page_font_color_prompt:"; print ""; print " $lang_color_chart"; print "
$lang_graph_font_face_prompt:"; print ""; print " $lang_font_chart"; print "
$lang_graph_font_size_prompt:"; print ""; print "
$lang_graph_font_color_prompt:"; print ""; print " $lang_color_chart"; print "
$lang_page_link_color_prompt:"; print ""; print " $lang_color_chart"; print "
$lang_page_vlink_color_prompt:"; print ""; print " $lang_color_chart"; print "
$lang_page_alink_color_prompt:"; print ""; print " $lang_color_chart"; print "
$lang_graph_open_color_prompt:"; print ""; print " $lang_color_chart"; print "
$lang_graph_reserved_color_prompt:"; print ""; print " $lang_color_chart"; print ""; print "$lang_graph_reserved_color_info  "; print "$lang_help_string"; print "
$lang_graph_pending_color_prompt:"; print ""; print " $lang_color_chart"; print "$lang_graph_pending_color_info  "; print "$lang_help_string"; print "
$lang_graph_blocked_color_prompt:"; print ""; print " $lang_color_chart"; print "$lang_graph_blocked_color_info  "; print "$lang_help_string"; print "
$lang_category_menu_font_face_prompt:"; print ""; print " $lang_font_chart"; print "
$lang_category_menu_font_size_prompt:"; print ""; print "
$lang_category_menu_font_color_prompt:"; print ""; print " $lang_color_chart"; print "
$lang_category_divider_line_color_prompt:"; print ""; print " $lang_color_chart"; print "
$lang_category_divider_font_color_prompt:"; print ""; print " $lang_color_chart"; print "
$lang_category_divider_font_face_prompt:"; print ""; print " $lang_font_chart"; print "
$lang_category_divider_font_size_prompt:"; print ""; print "
"; print "
"; print ""; print ""; print ""; print "
"; print "
"; print "


"; print ""; exit; } sub save_colors_fonts_settings { local ($temp_string); &validate_referral_page($script_url); $temp_string = $form_text{'page_background_image'}; # page background image $temp_string = &validate_string($temp_string); $settings[16] = $temp_string; $temp_string = $form_text{'page_background_color'}; # page background color $temp_string = &validate_string($temp_string); $settings[17] = $temp_string; $temp_string = $form_text{'page_font_face'}; # page font face $temp_string = &validate_string($temp_string); $settings[18] = $temp_string; $temp_string = $form_text{'page_font_size'}; # page font size $temp_string = &validate_string($temp_string); $settings[19] = $temp_string; $temp_string = $form_text{'page_font_color'}; # page font color $temp_string = &validate_string($temp_string); $settings[20] = $temp_string; $temp_string = $form_text{'page_link_color'}; # page link color $temp_string = &validate_string($temp_string); $settings[21] = $temp_string; $temp_string = $form_text{'page_vlink_color'}; # page visited link color $temp_string = &validate_string($temp_string); $settings[22] = $temp_string; $temp_string = $form_text{'page_alink_color'}; # page active link color $temp_string = &validate_string($temp_string); $settings[23] = $temp_string; $temp_string = $form_text{'schedule_title_color'}; # graph title color $temp_string = &validate_string($temp_string); $settings[24] = $temp_string; $temp_string = $form_text{'graph_open_color'}; # open timeslot color $temp_string = &validate_string($temp_string); $settings[25] = $temp_string; $temp_string = $form_text{'graph_reserved_color'}; # reserved timeslot color $temp_string = &validate_string($temp_string); $settings[26] = $temp_string; $temp_string = $form_text{'graph_pending_color'}; # pending reservation color $temp_string = &validate_string($temp_string); $settings[73] = $temp_string; $temp_string = $form_text{'graph_blocked_color'}; # unavailable timeslot color $temp_string = &validate_string($temp_string); $settings[27] = $temp_string; $temp_string = $form_text{'graph_font_face'}; # graphical schedule font face $temp_string = &validate_string($temp_string); $settings[28] = $temp_string; $temp_string = $form_text{'graph_font_size'}; # graphical schedule font size $temp_string = &validate_string($temp_string); $settings[29] = $temp_string; $temp_string = $form_text{'graph_font_color'}; # graphical schedule font color $temp_string = &validate_string($temp_string); $settings[30] = $temp_string; $temp_string = $form_text{'category_menu_font_face'}; # category menu font face $temp_string = &validate_string($temp_string); $settings[132] = $temp_string; $temp_string = $form_text{'category_menu_font_size'}; # category menu font size $temp_string = &validate_string($temp_string); $settings[133] = $temp_string; $temp_string = $form_text{'category_menu_font_color'}; # category menu font color $temp_string = &validate_string($temp_string); $settings[134] = $temp_string; $temp_string = $form_text{'category_divider_line_color'}; # category divider line color $temp_string = &validate_string($temp_string); $settings[136] = $temp_string; $temp_string = $form_text{'category_divider_font_color'}; # category divider line font color $temp_string = &validate_string($temp_string); $settings[137] = $temp_string; $temp_string = $form_text{'category_divider_font_face'}; # category divider line font face $temp_string = &validate_string($temp_string); $settings[138] = $temp_string; $temp_string = $form_text{'category_divider_font_size'}; # category divider line font size $temp_string = &validate_string($temp_string); $settings[139] = $temp_string; &save_settings(); &log_info($ADMIN,"$username updated Colors and Fonts Settings."); &create_general_settings_form("$lang_color_settings have been saved."); } sub create_resource_fields_settings_form { local ($message) = @_; &validate_referral_page($script_url); $resource_admin_access = 1; $reports_admin_access = 0; &validate_admin($username, $password, $resource_admin_access, $reports_admin_access); print "Content-type: text/html\n\n"; print "\n"; print "\n"; print "\n\n"; print "uReserve"; print ""; print "


"; print "
"; print ""; print "$lang_resource_fields_settings

"; print "
"; print "
"; print "
"; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print "
 
$lang_resource_title_prompt:"; print ""; print "
$lang_resource_prompt_prompt:"; print ""; print "
$lang_recurring_prompt_prompt:"; print ""; print "
$lang_resource_field1_prompt:"; print ""; print "
$lang_resource_field2_prompt:"; print ""; print "
$lang_resource_field3_prompt:"; print ""; print "
$lang_resource_field4_prompt:"; print ""; print "
$lang_resource_field5_prompt:"; print ""; print "
 
"; print ""; print ""; print ""; print "
"; print "
"; print "
"; print "


"; print ""; exit; } sub save_resource_fields_settings { local ($temp_string); &validate_referral_page($script_url); $temp_string = $form_text{'resource_title'}; # resource title $temp_string = &validate_string($temp_string); $settings[36] = $temp_string; $temp_string = $form_text{'resource_prompt'}; # resource_prompt $temp_string = &validate_string($temp_string); $settings[37] = $temp_string; $temp_string = $form_text{'recurring_prompt'}; # recurring prompt $temp_string = &validate_string($temp_string); $settings[38] = $temp_string; $temp_string = $form_text{'resource_field1'}; # resource field 1 $temp_string = &validate_string($temp_string); $settings[39] = $temp_string; $temp_string = $form_text{'resource_field2'}; # resource field 2 $temp_string = &validate_string($temp_string); $settings[40] = $temp_string; $temp_string = $form_text{'resource_field3'}; # resource field 3 $temp_string = &validate_string($temp_string); $settings[41] = $temp_string; $temp_string = $form_text{'resource_field4'}; # resource field 4 $temp_string = &validate_string($temp_string); $settings[42] = $temp_string; $temp_string = $form_text{'resource_field5'}; # resource field 5 $temp_string = &validate_string($temp_string); $settings[43] = $temp_string; &save_settings(); &log_info($ADMIN,"$username updated Resource Fields Settings."); &create_manage_resources_form("$lang_resource_fields_settings have been saved."); } sub create_reservation_field_config_form { local ($message) = @_; local ($i, $fields_line_index, $cur_field, $fixed_hours, $fixed_minutes, $temp_html); &validate_referral_page($script_url); $resource_admin_access = 0; $reports_admin_access = 0; &validate_admin($username, $password, $resource_admin_access, $reports_admin_access); print "Content-type: text/html\n\n"; print "\n"; print "\n"; print "\n\n"; print "uReserve"; print ""; print "


"; print "
"; print ""; print "$lang_reservation_form_config

"; print "
"; print "
"; print "
"; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; $ghelp_file_key_string = "forcepassword"; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print "
 
"; print "$lang_reservation_window_size
"; print "
"; print "$lang_reservation_window_size_info"; print "

"; print "$lang_reserve_window_height_prompt:"; print ""; print "    "; print "$lang_reserve_window_width_prompt:"; print ""; print "
"; print "

"; print "$lang_reservation_form_prompts

"; print "
"; print "$lang_reserve_prompt:  
"; print "$lang_reserve_password1_prompt:  
"; print "$lang_reserve_password2_prompt:  
"; print "$lang_reserve_password3_prompt:  
"; print "$lang_password_prompt:  
"; print "$lang_password_required_prompt:  
"; print "
"; if ($settings[148] =~ /on/i) { print ""; } else { print ""; } print "Force Password Required?"; print "$lang_help_string"; print "

"; print "$lang_reservation_fields_config
"; print ""; print "$lang_reservation_fields_config_info"; print "

"; print "
    "; print "
  • $lang_reservation_fields_config2"; print "
  • $lang_reservation_fields_config3"; print "
  • $lang_reservation_fields_config4"; print "
  • $lang_reservation_fields_config5"; print "
"; print "
"; print "
"; print ""; $fields_line_index = -1; for ($i = 1; $i <= 22; $i++) { if ($i < 10) { $cur_field = "FIELD0" . $i . "_NAME"; } else { $cur_field = "FIELD" . $i . "_NAME"; } print " "; print ""; print ""; print ""; print ""; } # end for $i <= 22 print ""; print "
"; print ""; print "Field " . $i . ":"; print ""; print ""; print ""; print "Field Label:
"; $fields_line_index += 2; if ($fields[$fields_line_index] =~ /\S/) { print ""; } else { print ""; } print "
"; print ""; print "     Type:"; print ""; print "
"; ++$fields_line_index; print "*Options:
"; if ($fields[$fields_line_index] =~ /\S/) { print ""; } else { print ""; } print "
"; print ""; print "  Display:"; print ""; print ""; print ""; print " required:"; print ""; } else { print ">"; } print "
"; print "
"; print "

"; print "$lang_reservation_booking_format"; print "
"; print "$lang_reservation_booking_format_info"; print "

"; if ($settings[97] =~ /STANDARD/i) { print "Standard Format"; } else { print "Standard Format"; } print "
    Start Time Label: "; print ""; print "   End Time Label: "; print ""; print "
    Fixed-length Reservation Label: "; print ""; print "
"; print ""; $time_selections_html = &get_open_time_selections(&get_week_name(time()), 1, 0, 0, 0); # DO NOT USE resource_name here!! print ""; print ""; $fixed_hours = 0; $fixed_minutes = 0; if (($settings[0] eq "CONFIG") || ($settings[0] eq "60")) { $fixed_hours = 1; } elsif ($settings[0] eq "15") { $fixed_minutes = 15; } elsif ($settings[0] eq "10") { $fixed_minutes = 10; } else { $fixed_minutes = 30; } print ""; print ""; print "
    Examples:" . $time_selections_html . "
"; $time_selections_html = &get_fixed_open_time_selections(&get_week_name(time()), 1, 0, $fixed_hours, $fixed_minutes, 0, 0); print $time_selections_html . "
"; if ($settings[97] =~ /DAILY/i) { print "Daily Format
"; } else { print "Daily Format
"; } print "    Label: "; print "
"; print "    Example:    $settings[101]: "; print "

"; if ($settings[97] =~ /DATE_RANGE/i) { print "Date Range Format
"; } else { print "Date Range Format
"; } print "    Start Date Label: "; print ""; print "    End Date Label: "; print "
"; print "    Example:    $settings[102]: "; if ($settings[5] =~ /US/i) { print ""; } else { print ""; } print "    $settings[103]: "; if ($settings[5] =~ /US/i) { print ""; } else { print ""; } print "

"; print "
"; print "

"; print "$lang_recurring_reservation_options (ONLY APPLICABLE WITH STANDARD RESERVATION FORMAT)"; print "
"; print "$lang_recurring_reservations_options_info"; print "

"; print ""; print ""; print ""; } else { print "Free-form"; print "Fixed"; } print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print "
"; if ($settings[108] =~ /freeform/i) { print "Free-form"; print "Fixed
"; if ($settings[109] =~ /on/i) { print ""; } else { print ""; } print "Daily for n daysMin. Value:Max. Value:
"; if ($settings[112] =~ /on/i) { print ""; } else { print ""; } print "Weekly for n weeksMin. Value:Max. Value:
"; if ($settings[115] =~ /on/i) { print ""; } else { print ""; } print "Bi-Weekly for n weeksMin. Value:Max. Value:
"; if ($settings[118] =~ /on/i) { print ""; } else { print ""; } print "Monthly for n monthsMin. Value:Max. Value:
"; print "
"; print "
"; print ""; print "
"; print ""; print ""; print ""; print "
"; print "
"; print ""; print ""; print ""; print "
"; print "
"; print "
"; print ""; print ""; exit; } sub save_reservation_fields_settings { local ($temp_string, $field_name, $i, $settings_index); &validate_referral_page($script_url); $temp_string = $form_text{'reserve_prompt'}; # reserve prompt i.e. Please Enter your contact information below $temp_string = &validate_string($temp_string); $settings[44] = $temp_string; $temp_string = $form_text{'password_prompt1'}; # password prompt 1 $temp_string = &validate_string($temp_string); $settings[49] = $temp_string; $temp_string = $form_text{'password_prompt2'}; # password prompt 2 $temp_string = &validate_string($temp_string); $settings[50] = $temp_string; $temp_string = $form_text{'password_prompt3'}; # password prompt 3 $temp_string = &validate_string($temp_string); $settings[51] = $temp_string; $temp_string = $form_text{'reserve_field5'}; # password field prompt $temp_string = &validate_string($temp_string); $settings[52] = $temp_string; $temp_string = $form_text{'reserve_password'}; # password required prompt $temp_string = &validate_string($temp_string); $settings[53] = $temp_string; $temp_string = $form_text{'force_password'}; # force password required checkbox $settings[148] = $temp_string; $temp_string = $form_text{'reserve_window_height1'}; # reservation window height $temp_string = &validate_string($temp_string); $settings[54] = $temp_string; $temp_string = $form_text{'reserve_window_height2'}; # reservation window width $temp_string = &validate_string($temp_string); $settings[55] = $temp_string; $temp_string = $form_text{'multi_schedule'}; # multi-resource scheduling checkbox $settings[96] = $temp_string; # yes/no $temp_string = $form_text{'reservation_frequency'}; # reservation format $settings[97] = $temp_string; $temp_string = $form_text{'start_time_label'}; # start time label, i.e. From $settings[98] = $temp_string; $temp_string = $form_text{'end_time_label'}; # end time label, i.e. To $settings[99] = $temp_string; $temp_string = $form_text{'fixed_time_label'}; # fixed time label, i.e. During $settings[100] = $temp_string; $temp_string = $form_text{'daily_label'}; # daily label, i.e. During $settings[101] = $temp_string; $temp_string = $form_text{'start_date_range_label'}; # start date range label, i.e. Start Date $settings[102] = $temp_string; $temp_string = $form_text{'end_date_range_label'}; # end date range label, i.e. End Date $settings[103] = $temp_string; $settings[104] = ""; $settings[105] = ""; $settings[106] = ""; $settings[107] = ""; $temp_string = $form_text{'daily_recurring'}; # daily recurring $settings[109] = $temp_string; $temp_string = $form_text{'min_daily_recurring'}; # min value daily recurring $settings[110] = int($temp_string); $temp_string = $form_text{'max_daily_recurring'}; # max value daily recurring $settings[111] = int($temp_string); if ($settings[109] =~ /on/) { if (int($settings[110] <= 1)) { &missing_input("Invalid Minimum","Daily Recurring Minimum value must be greater than or equal to 2."); } if (int($settings[111] <= 1)) { &missing_input("Invalid Maximum","Daily Recurring Maximum value must be greater than 2."); } if ($settings[111] <= $settings[110]) { &missing_input("Invalid Min-Max","Daily Recurring Max value must be greater than Daily Recurring Min value."); } if (($settings[110] > 99) || ($settings[111] > 100)) { &missing_input("Invalid Min-Max","Daily Recurring Min-Max values must not exceed 100."); } } $temp_string = $form_text{'weekly_recurring'}; # weekly recurring $settings[112] = $temp_string; $temp_string = $form_text{'min_weekly_recurring'}; # min value weekly recurring $settings[113] = int($temp_string); $temp_string = $form_text{'max_weekly_recurring'}; # max value weekly recurring $settings[114] = int($temp_string); if ($settings[112] =~ /on/) { if (int($settings[113] <= 1)) { &missing_input("Invalid Minimum","Weekly Recurring Minimum value must be greater than or equal to 2."); } if (int($settings[114] <= 1)) { &missing_input("Invalid Maximum","Weekly Recurring Maximum value must be greater than 2."); } if ($settings[114] <= $settings[113]) { &missing_input("Invalid Min-Max","Weekly Recurring Max value must be greater than Weekly Recurring Min value."); } if (($settings[113] > 99) || ($settings[114] > 100)) { &missing_input("Invalid Min-Max","Weekly Recurring Min-Max values must not exceed 100."); } } $temp_string = $form_text{'biweekly_recurring'}; # biweekly recurring $settings[115] = $temp_string; $temp_string = $form_text{'min_biweekly_recurring'}; # min value biweekly recurring $settings[116] = int($temp_string); $temp_string = $form_text{'max_biweekly_recurring'}; # max value biweekly recurring $settings[117] = int($temp_string); if ($settings[115] =~ /on/) { if (int($settings[116] <= 1)) { &missing_input("Invalid Minimum","Bi-Weekly Recurring Minimum value must be greater than or equal to 2."); } if (int($settings[117] <= 1)) { &missing_input("Invalid Maximum","Bi-Weekly Recurring Maximum value must be greater than 2."); } if ($settings[117] <= $settings[116]) { &missing_input("Invalid Min-Max","Bi-Weekly Recurring Max value must be greater than Bi-Weekly Recurring Min value."); } if (($settings[116] > 99) || ($settings[117] > 100)) { &missing_input("Invalid Min-Max","Bi-Weekly Recurring Min-Max values must not exceed 100."); } } $temp_string = $form_text{'monthly_recurring'}; # monthly recurring $settings[118] = $temp_string; $temp_string = $form_text{'min_monthly_recurring'}; # min value monthly recurring $settings[119] = int($temp_string); $temp_string = $form_text{'max_monthly_recurring'}; # max value monthly recurring $settings[120] = int($temp_string); if ($settings[118] =~ /on/) { if (int($settings[119] <= 1)) { &missing_input("Invalid Minimum","Monthly Recurring Minimum value must be greater than or equal to 2."); } if (int($settings[120] <= 1)) { &missing_input("Invalid Maximum","Monthly Recurring Maximum value must be greater than 2."); } if ($settings[120] <= $settings[119]) { &missing_input("Invalid Min-Max","Monthly Recurring Max value must be greater than Monthly Recurring Min value."); } if (($settings[119] > 99) || ($settings[120] > 100)) { &missing_input("Invalid Min-Max","Monthly Recurring Min-Max values must not exceed 100."); } } $temp_string = $form_text{'recurring_format'}; # freeform or fixed recurring format if ($temp_string =~ /freeform/i) { if ( (!($settings[109] =~ /on/i)) && (!($settings[112] =~ /on/i)) && (!( $settings[115] =~ /on/i)) && (!($settings[118] =~ /on/i)) ) { &missing_input("Missing Input","When using freeform recurring reservations, you must choose at least one option - Daily, Weekly, Bi-Weekly, or Monthly."); } } $settings[108] = $temp_string; &save_settings(); $fields_index = -1; for ($i=1; $i <= 22; $i++) { if ($i < 10) { $field_name = "FIELD0" . $i; } else { $field_name = "FIELD" . $i; } $field_name .= "_NAME"; $field_type = $field_name . "_TYPE"; $field_options = $field_name . "_OPTIONS"; $field_display = $field_name . "_DISPLAY"; $field_required = $field_name . "_REQUIRED"; $fields[++$fields_index] = "$field_name"; $temp_string = $form_text{"$field_name"}; # reserve field name $temp_string = &validate_string($temp_string); $fields[++$fields_index] = $temp_string; $temp_string = $form_text{"$field_type"}; # reserve field type $fields[++$fields_index] = $temp_string; $temp_string = $form_text{"$field_options"}; # reserve field options $fields[++$fields_index] = $temp_string; $temp_string = $form_text{"$field_display"}; # reserve field display type $fields[++$fields_index] = $temp_string; $temp_string = $form_text{"$field_required"}; # reserve field required flag $fields[++$fields_index] = $temp_string; } &save_fields(); &log_info($ADMIN,"$username updated Reservation Fields Settings."); &create_general_settings_form("$lang_reservation_fields_settings have been saved."); } sub initialize_settings { local ($idx); if ($settings_already_read != 0) { return; } if (open (SETTINGS_FILE, $settings_file)) { @settings = ; close(SETTINGS_FILE); for ($idx = 0; $idx <= $#settings; $idx++) { chop($settings[$idx]); } $settings_already_read = 1; if ($settings[0] eq "10") { $data_directory = $data_directory . "10min/"; } elsif ($settings[0] eq "15") { $data_directory = $data_directory . "15min/"; } elsif (($settings[0] eq "60") || ($settings[0] eq "CONFIG")) { $data_directory = $data_directory . "60min/"; } else { $data_directory = $data_directory . "30min/"; } } } sub initialize_reservation_fields { local ($idx); if ($reservation_fields_already_read != 0) { return; } if (open (FIELDS_FILE, $reservation_fields_file)) { @fields = ; close(FIELDS_FILE); for ($idx = 0; $idx <= $#fields; $idx++) { chop($fields[$idx]); } $reservation_fields_already_read = 1; } } sub create_manage_resources_form { local ($message) = @_; local ($resource_admin_access, $reports_admin_access, $user_auth); &validate_referral_page($script_url); $resource_admin_access = 1; $reports_admin_access = 0; &validate_admin($username, $password, $resource_admin_access, $reports_admin_access); $user_auth = &get_user_group($username, $password); $user_auth = int($user_auth); print "Content-type: text/html\n\n"; print "\n"; print "\n"; print "\n\n"; print "uReserve"; print ""; print "



"; print "
"; print ""; print "

"; print ""; print "
"; print "
"; print ""; print "$lang_manage_resources

"; print "
"; print ""; if (($message =~ /\S/) && ($message ne "NONE")) { print $message; } else { print $lang_manage_resources_text; } print ""; print "
"; print "
"; print "
"; print ""; if ($user_auth == $SYSTEM_ADMIN) { &print_button('M',"$lang_mr_resource_fields_settings", "mr_resource_fields_settings", $password, $username); &print_button('M',"$lang_mr_add_resource", "mr_add_resource", $password, $username); } if (($user_auth == $SYSTEM_ADMIN) || ($user_auth == $RESOURCE_ADMIN)) { &print_button('M',"$lang_mr_edit_resource", "mr_edit_resource", $password, $username); } if ($user_auth == $SYSTEM_ADMIN) { &print_button('M',"$lang_mr_delete_resource", "mr_delete_resource", $password, $username); } if (($user_auth == $SYSTEM_ADMIN) || ($user_auth == $RESOURCE_ADMIN)) { &print_button('M',"$lang_mr_reorder_resources", "mr_reorder_resources", $password, $username); &print_button('M',"$lang_mr_blackout_dates", "mr_blackout_dates", $password, $username); } &print_button('M',"$lang_goto_schedule", "cp_view_schedule", $password, $username); &print_button('M',"$lang_back", "login", $password, $username); print "
"; print "
"; print "
"; print ""; exit; } sub create_reorder_resources_form { local ($message) = @_; local ($file_name, $date_string, $current_seconds, $start_seconds, $end_seconds, $blackout_data_line, $index, $day_index, @blackout_dates, $blackout_date_index, @lines, $line_index, @key_value_pairs, $resource_name, $current_line, $data_index, $start_time, $end_time); &validate_referral_page($script_url); $resource_admin_access = 1; $reports_admin_access = 0; &validate_admin($username, $password, $resource_admin_access, $reports_admin_access); $move_resource = ""; $move_action = ""; $message = $form_text{'message'}; $move_resource = $form_text{'resource_to_move'}; $move_action = $form_text{'move_command'}; $last_move_resource = $move_resource; if (-e $gresource_file) { open (RESOURCE_FILE, $gresource_file) || &return_error("File Error","Unable to open " . $gresource_file); @resources = ; close(RESOURCE_FILE); } else { &create_manage_resources_form("There are no resources defined yet."); } if (-e $gresource_file_reorder) { open (TEMP_RESOURCE_FILE, $gresource_file_reorder) || &return_error("File Error","Unable to open " . $gresource_file_reorder); @resources = ; close(TEMP_RESOURCE_FILE); } else { if (!(open(TEMP_RESOURCE_FILE, ">" . $gresource_file_reorder))) { &return_error("File Error","Unable to create " . $gresource_file_reorder); } for ($resource_index = 0; $resource_index <= $#resources; $resource_index++) { $line_to_write = $resources[$resource_index]; print TEMP_RESOURCE_FILE $line_to_write; } close(TEMP_RESOURCE_FILE); } for ($resource_index = 0; $resource_index <= $#resources; $resource_index++) { @key_value_pairs = split (/\|/, $resources[$resource_index]); if (-e $gcategory_file) { $resource_category_name = ""; $resource_category_name = &get_category_name($key_value_pairs[0]); if ($resource_category_name eq "") { $resource_category_name = "Not Assigned"; } $resource_array[$resource_index] = $key_value_pairs[0]; # . " (CATEGORY: " . $resource_category_name . ")"; } else { $resource_array[$resource_index] = $key_value_pairs[0]; } $full_resource_array_lines[$resource_index] = $resources[$resource_index]; } if ($move_action eq $lang_undo_changes) { unlink($gresource_file_reorder); open (RESOURCE_FILE, $gresource_file) || &return_error("File Error","Unable to open " . $gresource_file); @resources = ; close(RESOURCE_FILE); if (!(open(TEMP_RESOURCE_FILE, ">" . $gresource_file_reorder))) { &return_error("File Error","Unable to create " . $gresource_file_reorder); } for ($resource_index = 0; $resource_index <= $#resources; $resource_index++) { $line_to_write = $resources[$resource_index]; print TEMP_RESOURCE_FILE $line_to_write; } close(TEMP_RESOURCE_FILE); for ($resource_index = 0; $resource_index <= $#resources; $resource_index++) { @key_value_pairs = split (/\|/, $resources[$resource_index]); $resource_array[$resource_index] = $key_value_pairs[0]; $full_resource_array_lines[$resource_index] = $resources[$resource_index]; } } elsif ($move_action eq $lang_save_changes) { unlink($gresource_file); rename($gresource_file_reorder, $gresource_file); chmod(0777, $gresource_file); } elsif ($move_action eq $lang_move_up) { if ($move_resource =~ /\S/) { $swapped = 0; for ($resource_index = 0; $resource_index <= $#resources; $resource_index++) { if ($resource_array[$resource_index] =~ /$move_resource/i) { if ($resource_index > 0) { $temp = $resource_array[$resource_index]; $temp2 = $full_resource_array_lines[$resource_index]; $resource_array[$resource_index] = $resource_array[$resource_index - 1]; $full_resource_array_lines[$resource_index] = $full_resource_array_lines[$resource_index - 1]; $resource_array[$resource_index - 1] = $temp; $full_resource_array_lines[$resource_index - 1] = $temp2; $swapped = 1; $resource_index = $#resources + 1; # force loop exit } else { } } } if ($swapped == 1) { unlink($gresource_file_reorder); if (!(open(NEW_TEMP_RESOURCE_FILE, ">" . $gresource_file_reorder))) { &return_error("File Error","Unable to create " . $gresource_file_reorder); } for ($resource_index = 0; $resource_index <= $#resources; $resource_index++) { $line_to_write = $full_resource_array_lines[$resource_index]; print NEW_TEMP_RESOURCE_FILE $line_to_write; } close(NEW_TEMP_RESOURCE_FILE); chmod(0777, $gresource_file_reorder); } } $move_resource = ""; $move_action = ""; } elsif ($move_action eq $lang_move_down) { if ($move_resource =~ /\S/) { $swapped = 0; for ($resource_index = 0; $resource_index <= $#resources; $resource_index++) { if ($resource_index < $#resources) { if ($resource_array[$resource_index] =~ /$move_resource/i) { $temp = $resource_array[$resource_index]; $temp2 = $full_resource_array_lines[$resource_index]; $resource_array[$resource_index] = $resource_array[$resource_index + 1]; $full_resource_array_lines[$resource_index] = $full_resource_array_lines[$resource_index + 1]; $resource_array[$resource_index + 1] = $temp; $full_resource_array_lines[$resource_index + 1] = $temp2; $swapped = 1; $resource_index = $#resources + 1; # force loop exit } } else { } } if ($swapped == 1) { unlink($gresource_file_reorder); if (!(open(NEW_TEMP_RESOURCE_FILE, ">" . $gresource_file_reorder))) { &return_error("File Error","Unable to create " . $gresource_file_reorder); } for ($resource_index = 0; $resource_index <= $#resources; $resource_index++) { $line_to_write = $full_resource_array_lines[$resource_index]; print NEW_TEMP_RESOURCE_FILE $line_to_write; } close(NEW_TEMP_RESOURCE_FILE); chmod(0777, $gresource_file_reorder); } } $move_resource = ""; $move_action = ""; } $line_index = 0; print "Content-type: text/html\n\n"; print "\n"; print "\n"; print "\n\n"; print "$lang_reorder_resources"; print ""; print ""; print "
"; print ""; print ""; if (($message =~ /\S/) && ($message ne "NONE")) { print ""; } else { print ""; } print ""; $resource_to_move = ""; print ""; print "
"; print ""; print "$lang_reorder_resources

"; print "
"; print "
"; print ""; print "$message"; print "
"; print ""; print " "; print "
"; print ""; print ""; print ""; print "
"; print "$lang_reorder_resources_instructions"; print "
"; print "
"; print ""; print ""; print ""; print ""; print "
"; print "
"; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print "
"; print ""; print ""; print ""; print "



"; print ""; print "
"; print "
"; print ""; print ""; print ""; print ""; print ""; print ""; print "
"; print "
"; print ""; print ""; print ""; print ""; print ""; print "
"; print "
"; print ""; print ""; print ""; print ""; print ""; print "
"; print "
"; print ""; print ""; print ""; print ""; print "
"; print "
"; print "
"; print "
"; print ""; exit; } sub create_categorize_resources_form { local ($message) = @_; local ($resource_list, $action, $category_key, $index, $choice, $line_index, $resource_name, $resource_category_name, $data_index, $found, @choices, @lines, @key_value_pairs, @resource_value_pairs, @resources, @resource_array, @full_resource_array_lines); &validate_referral_page($script_url); $resource_admin_access = 1; $reports_admin_access = 0; &validate_admin($username, $password, $resource_admin_access, $reports_admin_access); $resource_list = ""; $action = ""; @resources = (); @resource_value_pairs = (); $message = $form_text{'message'}; $resource_list = $form_text{'resource_list'}; $action = $form_text{'action'}; # either save, cancel or nothing $category_key = $form_text{'category_key'}; @resources = &get_resource_file_all_records(); if ($#resources < 1) { &create_manage_resources_form("There are no resources defined yet."); } for ($resource_index = 0; $resource_index <= $#resources; $resource_index++) { @key_value_pairs = split (/\|/, $resources[$resource_index]); if (-e $gcategory_file) { $resource_category_name = ""; $resource_category_name = &get_category_name($key_value_pairs[0]); if ($resource_category_name eq "") { $resource_category_name = "Not Assigned"; } $resource_array[$resource_index] = $key_value_pairs[0]; # . " (CATEGORY: " . $resource_category_name . ")"; } else { $resource_array[$resource_index] = $key_value_pairs[0]; } $full_resource_array_lines[$resource_index] = $resources[$resource_index]; } if (!(-e $gcategory_file)) { $message = "There are no categories defined. Category assignments can not be made until categories are defined."; } elsif ($action eq "save") { my $file_handle = &open_file_for_writing($gresource_file_categorize); if ($file_handle == -1) { &return_error("File Open Error","Failed to open $gresource_file_categorize."); } @choices=split(/\0/,$resource_list); $recs_written = 0; for ($resource_index = 0; $resource_index <= $#resources; $resource_index++) { @resource_value_pairs = split (/\|/, $resources[$resource_index]); $resource_key = $resource_value_pairs[0]; $new_record = ""; $found = 0; foreach $choice (@choices) { if ((int($choice)) == (int($resource_key))) { @resource_value_pairs[1] = $category_key; &write_record_to_resource_file($file_handle, @resource_value_pairs); $recs_written++; $found = 1; } } if ($found == 0) { &write_record_to_resource_file($file_handle, @resource_value_pairs); $recs_written++; } } close($file_handle); if ($recs_written > $#resources) { unlink($gresource_file); rename($gresource_file_categorize, $gresource_file); chmod(0777, $gresource_file); } else { unlink($gresource_file); $message = "Assignments failed, try resubmitting. If error persists, contact Microburst for assistance."; } $action = ""; $resource_list = ""; } $line_index = 0; print "Content-type: text/html\n\n"; print "\n"; print "\n"; print "\n\n"; print "$lang_mc_categorize_resources"; print ""; print ""; print "
"; print ""; print ""; if (($message =~ /\S/) && ($message ne "NONE")) { print ""; } print ""; print ""; print "
"; print ""; print "$lang_mc_categorize_resources

"; print "
"; print "
"; print ""; print "$message"; print "
"; print ""; print ""; print ""; print "
"; print "$lang_categorize_instructions"; print "
"; print "
"; print ""; print ""; print ""; print ""; print "
"; print "
"; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print "
Select category assignment:  "; $category_html = &get_category_selections($resource_category_key); print "$category_html"; print "
"; print ""; print "
"; print "
"; print ""; print ""; print ""; print ""; print ""; print ""; print "
"; print ""; print ""; print ""; print "
"; print ""; print ""; print ""; print ""; print "
"; print "
"; print "
"; print "
"; print ""; exit; } sub create_manage_blackout_dates_form { local ($message) = @_; local ($file_name, $current_seconds, $start_seconds, $end_seconds, $blackout_data_line, $index, $day_index, $temp_string, @blackout_dates, $blackout_date_index, @lines, $line_index, @key_value_pairs, $resource_name, $current_line, $data_index, $start_time, $end_time); &validate_referral_page($script_url); $resource_admin_access = 1; $reports_admin_access = 0; &validate_admin($username, $password, $resource_admin_access, $reports_admin_access); $select_html = ""; $blackout_detail = ""; $resource_name = ""; $start_seconds = ""; $start_time = ""; $end_seconds = ""; $end_time = ""; @resources = &get_resource_file_all_records(); $line_index = 0; print "Content-type: text/html\n\n"; print "\n"; print "\n"; print "\n\n"; print "$lang_manage_blackout_dates"; print ""; print ""; print "
"; print ""; print ""; if (($message =~ /\S/) && ($message ne "NONE")) { print ""; } else { print ""; } print ""; if (-e $gblackout_dates_file) { open (BLACKOUT_FILE, $gblackout_dates_file) || &return_error("File Error","Unable to open " . $gblackout_dates_file); @blackout_dates = ; close(BLACKOUT_FILE); @blackout_dates_sorted = sort {$a cmp $b} @blackout_dates; $select_html = ""; } else { $select_html = "$lang_no_blackout_dates"; } print ""; print "
"; print ""; print "$lang_manage_blackout_dates

"; print "
"; print "
"; print ""; print "$message"; print "
"; print ""; print " "; print "
"; print ""; print ""; print ""; print "
"; print "$lang_blackout_instructions"; print "
"; print "
"; print ""; print ""; print ""; print ""; print "
"; print "
"; print ""; print ""; print "
"; print "
$lang_blackout_dates


"; print $select_html; print "

"; print ""; print ""; print ""; print "
"; print ""; print ""; print ""; print ""; print ""; print ""; print "
"; if (-e $gblackout_dates_file) { print ""; } print ""; print "
"; print ""; print ""; print ""; print ""; print "
"; print "
"; print ""; print ""; print ""; print ""; print "
"; print "
"; print "
"; print "
"; print ""; exit; } sub create_add_blackout_date_form { local ($resource_name, $resource_index, $week_name, $day_index, $line, @key_value_pairs, @resources, $found_flag, $date_string, $temp_float, $float_increment, $temp_string, $time_selections, $sday, $eday); &validate_referral_page($script_url); $found_flag = 0; $date_string = &get_exact_date($days_seconds); $resource_list = ""; $blackout_from_date = ""; $blackout_to_date = ""; $start_time = ""; $end_time = ""; $days_list = ""; @resources = &get_resource_file_all_records(); print "Content-type: text/html\n\n"; print "\n"; print "\n"; print "\n\n"; print "uReserve"; print ""; print "


"; print "
"; print ""; print "$lang_mr_add_blackout_date Form

"; print "
"; print "
"; print ""; print "
"; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; $gtime_range_start = &strip_letters($gtime_range_start); $gtime_range_stop = &strip_letters($gtime_range_stop); $temp_float = $gtime_range_start; $float_increment = &get_looper(); # get float increment $time_selections = ""; while ($temp_float < $gtime_range_stop) { if ($settings[0] eq "CONFIG") { $temp_string = $column_names[$temp_float]; } else { $temp_string = &format_time($temp_float); } $time_selections .= ""; $temp_float += $float_increment; } print ""; if ($settings[0] eq "CONFIG") { print ""; } else { print ""; } print ""; print ""; print ""; if ($settings[0] eq "CONFIG") { print ""; } else { print ""; } print ""; print ""; print ""; print ""; print ""; print ""; print "

$lang_select $settings[39](s):

$lang_add_blackout_instructions:

$lang_blackout_from_date:"; print "
$lang_blackout_to_date:"; print "
$lang_select_days:
Blackout From:$lang_blackout_from_time:"; print "
Blackout Until:$lang_blackout_to_time:"; print "
"; print "
"; print ""; print "

"; print "
"; print ""; print ""; print ""; print ""; print "
"; print "
"; print "
"; print "


"; print ""; exit; } sub add_new_blackout_date { local ($resource_list, $days_list, $blackout_from_date, $blackout_to_date, $start_time, $end_time, $start_date_seconds, $end_date_seconds, $expired_flag, $expired_flag2, $num_blackout_dates_added, $choice, $resource_name, @key_value_pairs, @resources, @choices); &validate_referral_page($script_url); $resource_list = ""; $days_list = ""; $blackout_from_date = ""; $blackout_to_date = ""; $start_time = ""; $end_time = ""; $resource_list = $form_text{'resource_list'}; $days_list = $form_text{'days_list'}; $blackout_from_date = $form_text{'blackout_from_date'}; $blackout_to_date = $form_text{'blackout_to_date'}; $start_time = $form_text{'start_time'}; $start_time = &strip_letters($start_time); $end_time = $form_text{'end_time'}; $end_time = &strip_letters($end_time); $valid_options = 0; if (($blackout_from_date =~ /\S/) && ($blackout_to_date =~ /\S/)) { $start_date_seconds = &get_date_seconds($blackout_from_date); $end_date_seconds = &get_date_seconds($blackout_to_date); if ($end_date_seconds <= $start_date_seconds) { if ($end_date_seconds == $start_date_seconds) { if (!($settings[0] eq "CONFIG")) { if ($start_time >= $end_time) { &missing_input("Invalid Time Range","The ending time must be greater than the starting time."); } } } else { &missing_input("Configuration Error","You must configure an end date later than the start date."); } } $days_list = 0; # if any days were selected, ignore them, the date range takes precedence $valid_options = 1; } if ($valid_options == 0) { if ($days_list == 0) { &missing_input("Configuration Error","You must specify a date range or select at least one day of the week."); } else { $valid_options = 2; } } if ($resource_list eq "") { &missing_input("Missing Input","You must select at least one resource."); } @resources = &get_resource_file_all_records(); $num_blackout_dates_added = 0; for ($resource_index = 0; $resource_index <= $#resources; $resource_index++) { @key_value_pairs = split (/\|/, $resources[$resource_index]); $resource_key = $key_value_pairs[0]; @choices=split(/\0/,$resource_list); foreach $choice (@choices) { if (int($resource_key) == int($choice)) { &add_blackout_date($resource_key, $start_date_seconds, $end_date_seconds, $start_time, $end_time, $days_list); $num_blackout_dates_added++; $resource_name = &get_resource_name($resource_key); &log_info($ADMIN,"Blackout Date ADDED by $username for $resource_name|$start_date_seconds|$end_date_seconds|$start_time|$end_time|$days_list"); } } } if ($num_blackout_dates_added == 1) { &create_manage_blackout_dates_form("The blackout date was successfully added."); } elsif ($num_blackout_dates_added > 1) { &create_manage_blackout_dates_form("The blackout dates were successfully added."); } else { &create_manage_blackout_dates_form("System error. No blackout dates were added."); } } sub add_blackout_date { local ($resource_key, $start_date_seconds, $end_date_seconds, $start_time, $end_time, $days_list) = @_; local ( $line, $resource_name, $current_name, $current_start_seconds, $current_end_seconds, $resource_index, @key_value_pairs, @day_value_pairs, $new_days_list, $index, $found_flag, $random_number, $temp_file); $found_flag = 0; $new_days_list = &prep_days_list($days_list); $resource_name = &get_resource_name($resource_key); if (!(-e $gblackout_dates_file)) { open(ADD_DATA_FILE,">>$gblackout_dates_file") || &return_error("File Error","Unable to open " . $gblackout_dates_file); print ADD_DATA_FILE $resource_key . "|" . $start_date_seconds . "|" . $end_date_seconds . "|" . $start_time . "|" . $end_time . "|" . $new_days_list . "\n"; close(ADD_DATA_FILE); chmod(0777, $gblackout_dates_file); } else { srand(time|$$); $random_number = int(rand(10000000)); $temp_file = $data_directory . "ureserve" . $random_number . ".tmp"; open (ADD_DATA_FILE, $gblackout_dates_file) || &return_error("File Error","Unable to open " . $gblackout_dates_file); if (!(open(ADD_TEMP_FILE, ">" . $temp_file))) { close(ADD_DATA_FILE); &return_error("File Error","Unable to open " . $temp_file); } while () { $line = $_; @key_value_pairs = split (/\|/, $line); $current_name = $key_value_pairs[5]; $current_start_seconds = $key_value_pairs[1]; if (($found_flag == 0) && (($current_name gt $resource_name) || ( ($current_name eq $resource_name) && ($current_start_seconds gt $start_date_seconds) ))) { print ADD_TEMP_FILE $resource_key . "|" . $start_date_seconds . "|" . $end_date_seconds . "|" . $start_time . "|" . $end_time . "|" . $new_days_list . "\n"; $found_flag = 1; } print ADD_TEMP_FILE $line; } # end while if ($found_flag == 0) { print ADD_TEMP_FILE $resource_key . "|" . $start_date_seconds . "|" . $end_date_seconds . "|" . $start_time . "|" . $end_time . "|" . $new_days_list . "\n"; } close(ADD_DATA_FILE); close(ADD_TEMP_FILE); unlink($gblackout_dates_file); rename($temp_file,$gblackout_dates_file); chmod(0777, $gblackout_dates_file); } # end if (!(-e $gblackout_dates_file)) } sub create_delete_blackout_date_confirmation_form { local ( $resource_name, $days_list, $start_seconds, $end_seconds, $start_time, $end_time, $start_time_formatted, $end_time_formatted, $start_date, $end_date, $blackout_detail, $blackout_data_line, $choices, @key_value_pairs, @blackout_detail_choices); &validate_referral_page($script_url); $blackout_detail = $form_text{'blackout_detail'}; @blackout_detail_choices=split(/\0/,$blackout_detail); $blackout_data_line = "
    "; $choices = ""; foreach $blackout_detail_choice (@blackout_detail_choices) { $choices .= $blackout_detail_choice . "?"; @key_value_pairs = split (/\|/, $blackout_detail_choice); $resource_key = $key_value_pairs[0]; $black_date = $key_value_pairs[1]; # YYYY-MM-DD $start_seconds = $key_value_pairs[1]; $end_seconds = $key_value_pairs[2]; $start_time = $key_value_pairs[3]; $end_time = $key_value_pairs[4]; $days_list = $key_value_pairs[5]; $blackout_data_line .= "
  • "; $blackout_data_line .= &make_blackout_data_line($resource_key, $start_seconds, $end_seconds, $start_time, $end_time, $days_list); $blackout_data_line .= "

  • "; } $blackout_data_line .= "
"; print "Content-type: text/html\n\n"; print "\n"; print "\n"; print "\n\n"; print "uReserve"; print ""; print "




"; print ""; print "
"; print ""; print ""; print "
"; print ""; print "
Are you sure you want to delete the following:
" . $blackout_data_line . "


"; print "
"; print "
"; print ""; print ""; print ""; print ""; print ""; print ""; print "
"; print "
"; print "
"; print ""; print ""; print ""; print ""; print ""; print ""; print "
"; print "
"; print "
"; print "
"; print ""; exit; } sub delete_blackout_date { local ($line, $current_resource_key, $current_start_date_seconds, $current_start_time, $blackout_detail_choice, $detail_resource_key, $detail_resource_name, $detail_start_date_seconds, $detail_start_time, $found_flag, $random_number, $temp_file, $num_deleted, @key_value_pairs, @blackout_detail_choices, @copy_blackout_detail_choices, @detail_value_pairs, @new_lines); &validate_referral_page($script_url); $blackout_detail = $form_text{'blackout_detail'}; $num_deleted = 0; srand(time|$$); $random_number = int(rand(10000000)); $temp_file = $data_directory . "ureserve" . $random_number . ".tmp"; open (DEL_DATA_FILE, $gblackout_dates_file) || &return_error("File Error","Unable to open " . $gblackout_dates_file); if (!(open(DEL_TEMP_FILE, ">" . $temp_file))) { close(DEL_DATA_FILE); &return_error("File Error","Unable to open " . $temp_file); } @blackout_detail_choices=split(/\?/,$blackout_detail); while () { $line = $_; if ($num_deleted <= $#blackout_detail_choices) { @key_value_pairs = split (/\|/, $line); $current_resource_key = $key_value_pairs[0]; $current_start_date_seconds = int($key_value_pairs[1]); $current_start_time = $key_value_pairs[3]; $current_days_list = $key_value_pairs[5]; # i.e. 1234567 means mon-tues-wed-...sun $found_flag = 0; foreach $blackout_detail_choice (@blackout_detail_choices) { @detail_value_pairs = split (/\|/, $blackout_detail_choice); $detail_resource_key = $detail_value_pairs[0]; $detail_resource_name = &get_resource_name($detail_resource_key); $detail_start_date_seconds = int($detail_value_pairs[1]); $detail_start_time = $detail_value_pairs[3]; $detail_days_list = $detail_value_pairs[5]; # i.e. 1234567 means mon-tues-wed-...sun if (int($current_start_date_seconds) > 0) { if ( ($found_flag == 0) && (int($current_resource_key) == int($detail_resource_key)) && ($current_start_date_seconds == $detail_start_date_seconds) && ($current_start_time == $detail_start_time) ) { $found_flag = 1; $num_deleted++; &log_info($ADMIN,"Blackout Date DELETED by $username for $detail_resource_name|$detail_start_date_seconds|$detail_start_time|"); } else { } } else { if ( ($found_flag == 0) && (int($current_resource_key) == int($detail_resource_key)) && ($current_days_list == $detail_days_list) && ($current_start_time == $detail_start_time) ) { $found_flag = 1; $num_deleted++; &log_info($ADMIN,"Blackout Date DELETED by $username for $detail_resource_name|$detail_days_list|$detail_start_time|"); } } } if ($found_flag == 1) { } else { print DEL_TEMP_FILE $line; } } # end if ($num_deleted <= $#blackout_detail_choices) else { print DEL_TEMP_FILE $line; } } # end while close(DEL_DATA_FILE); close(DEL_TEMP_FILE); unlink($gblackout_dates_file); rename($temp_file,$gblackout_dates_file); chmod(0777, $gblackout_dates_file); my ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, $atime, $mtime, $ctime, $blksize, $blocks) = stat $gblackout_dates_file; if ($size == 0) { unlink($gblackout_dates_file); } return $num_deleted; } sub create_manage_users_form { local ($message) = @_; local ($resource_admin_access, $reports_admin_access, $user_auth); &validate_referral_page($script_url); $resource_admin_access = 1; $reports_admin_access = 0; &validate_admin($username, $password, $resource_admin_access, $reports_admin_access); $user_auth = &get_user_group($username, $password); $user_auth = int($user_auth); print "Content-type: text/html\n\n"; print "\n"; print "\n"; print "\n\n"; print "uReserve"; print ""; print "



"; print "
"; print ""; print "

"; print ""; print "
"; print "
"; print ""; print "$lang_manage_users

"; print "
"; print ""; if (($message =~ /\S/) && ($message ne "NONE")) { print $message; } else { print $lang_manage_users_text; } print ""; print "
"; print "
"; print "
"; print ""; if (($user_auth == $SYSTEM_ADMIN) || ($user_auth == $RESOURCE_ADMIN) ) { &print_button('M',"$lang_mu_add_user", "mu_add_user", $password, $username); &print_button('M',"$lang_mu_edit_user", "mu_edit_user", $password, $username); &print_button('M',"$lang_mu_delete_user", "mu_delete_user", $password, $username); &print_button('M',"$lang_mu_block_user", "mu_manage_blocked_users", $password, $username); } &print_button('M',"$lang_goto_schedule", "cp_view_schedule", $password, $username); &print_button('M',"$lang_back", "login", $password, $username); print "
"; print "
"; print "
"; print ""; exit; } # end create_manage_users_form sub create_manage_pending_reservations_form { local ($message) = @_; local ( $week_name, $current_week, $file, $number_of_files, $file_date, $temp_file_date, $file_name, $date_string, $current_seconds, $start_seconds, $end_seconds, $pending_data_select_option, $index, $day_index, $pending_date_index, $current_line, $data_index, $start_time, $end_time, $i, $j, @files, @lines, @key_value_pairs, @resources, @cur_fields, @pending_array, @pending_array_sorted, @pending_array_for_sorting, @new_pending_array_sorted ); &validate_referral_page($script_url); $resource_admin_access = 1; $reports_admin_access = 0; &validate_admin($username, $password, $resource_admin_access, $reports_admin_access); $select_html = ""; $pending_detail_list = ""; $resource_name = ""; $start_seconds = ""; $start_time = ""; $end_seconds = ""; $end_time = ""; @resources = &get_resource_file_all_records(); &analyze_seconds(time); $week_name = &get_week_name($g_seconds); # always returned in the form MM-DD-YYYY $current_week = &make_US_date_YYYYMMDD($week_name); # must pass US date MM-DD-YYYY $line_index = 0; $day_index_today = $g_wday + 1; $first_pass = 1; $first_file_found = 0; print "Content-type: text/html\n\n"; print "\n"; print "\n"; print "\n\n"; print "$lang_manage_pending"; print ""; print ""; print "
"; print ""; print ""; if (($message =~ /\S/) && ($message ne "NONE")) { print ""; } print ""; $num_pending = 0; $select_html = ""; $number_of_files = 0; if (opendir(DATA_DIR,$data_directory)) { @files = readdir(DATA_DIR); closedir(DATA_DIR); foreach $file (@files) { $week_name = substr($file,0,10); $temp_file_date = substr($file,0,10); # MM-DD-YYYY $file_date = &make_US_date_YYYYMMDD($temp_file_date); # must pass US format date if (($file =~ /.txt$/) && (length($file) == 14)) { $full_file_name = $data_directory . $file; @lines = &get_reservation_data_file($full_file_name); $first_file_found = 1; for ($resource_index = 0; $resource_index <= $#resources; $resource_index++) { @resource_value_pairs = split (/\|/, $resources[$resource_index]); $resource_key = $resource_value_pairs[0]; $pending_date_index = 0; $line_index = 0; $starting_day_index_in_file = 1; for ($day_index = $starting_day_index_in_file; $day_index < 8; $day_index++) { $current_line = ""; if ($#lines > 0) { $current_line = &get_reservation_data_by_resource_and_day($resource_key, $day_index, @lines); } @reservation_data_pairs = (); if ($current_line =~ /\S/) { @reservation_data_pairs = split (/\|/, $current_line); for ($data_index = 1; $data_index < $#reservation_data_pairs; $data_index += 25) { @pending_value_pairs = split (/\?/, $reservation_data_pairs[$data_index]); if ($reservation_data_pairs[$data_index] =~ /PENDING/i) { $pending_data_select_option = &get_pending_data_select_option($file_date, $week_name, $day_index, $resource_key, $data_index, @reservation_data_pairs); $pending_array[$num_pending] = $pending_data_select_option; $pending_array_for_sorting[$num_pending] = $reservation_data_pairs[$data_index + 4]; $num_pending++; } } # end for ($data_index = 1; $ } # end if ($current_line =~ /\S/) } # end for ($day_index = 1; $day_index < 8; $day_index++) } # end resource loop } # end if (($file =~ /.txt$/) && (length($file) == 14) && (... if ($first_file_found == 1) { $first_pass = 0; } } # foreach $file (@files) if (($settings[97] =~ /DAILY/) || ($settings[97] =~ /DATE_RANGE/i)) { @new_pending_array_sorted = (); $j=0; $new_pending_array_sorted[$j] = $pending_array[0]; for ($i=0; $i < $#pending_array_for_sorting; $i++) { $string1 = $pending_array_for_sorting[$i+1]; $string2 = $pending_array_for_sorting[$i]; if ( $string1 ne $string2 ) { $j++; $new_pending_array_sorted[$j] = $pending_array[$i+1]; } } @pending_array_sorted = @new_pending_array_sorted; } else { @pending_array_sorted = sort {$a cmp $b} @pending_array; } $select_html = ""; foreach $pending_res (@pending_array_sorted) { $select_html .= $pending_res; } $start_select_html = ""; } # end if (opendir(DATA_DIR,$data_directory)) else { &return_error("Misconfiguration Error","Unable to open directory " . $data_directory); } if ($num_pending == 0) { $start_select_html = "



$lang_no_pending_reservations



"; } print ""; print "
"; print ""; print "$lang_manage_pending

"; print "
"; print "
"; print ""; print "$message"; print "
"; print ""; print ""; print ""; print "
"; print ""; if (($settings[97] =~ /DAILY/i) || ($settings[97] =~ /DATE_RANGE/i)) { print $lang_pending_instructions_daily; } else { print $lang_pending_instructions_standard; } print ""; print "
"; print "
"; print ""; print ""; print ""; print ""; print "
"; print "
"; print ""; print ""; print "
"; print "
$lang_pending


"; print $start_select_html; print "

"; print ""; print ""; print ""; print "
"; print ""; print ""; print ""; print ""; print ""; print "
"; if ($num_pending > 0) { print ""; print "    "; print ""; print "    "; print "    "; print ""; } else { print " "; } print ""; print "
"; print ""; print ""; print ""; print ""; print "
"; print "
"; print "
"; print "
"; print ""; exit; } # End of create_manage_pending_reservations_form sub create_advanced_view_pending_form { local ($resource_name, $week_name, $day_index, $days_seconds, $resource_field1, $resource_field2, $resource_field3, $resource_field4, $line, $found_flag, $date_string, $temp_float, $float_increment, $time_selections, $field1, $field2, $field3, $field4, $pending_detail, $pending_details_html, $pending_detail_list, $passthru_pending_detail_list, $file_date, @pending_detail_choices, @key_value_pairs, @reservation_data_line, @resv_form_fields ); &validate_referral_page($script_url); $resource_admin_access = 1; $reports_admin_access = 0; &validate_admin($username, $password, $resource_admin_access, $reports_admin_access); @cur_fields = (); $pending_details_html = ""; $pending_detail_list = $form_text{'pending_detail_list'}; @pending_detail_choices=split(/\0/,$pending_detail_list); $passthru_pending_detail_list = ""; foreach $pending_detail (@pending_detail_choices) { $passthru_pending_detail_list .= $pending_detail; $passthru_pending_detail_list .= "~~"; } foreach $pending_detail (@pending_detail_choices) { @key_value_pairs = split (/\^/, $pending_detail); # fix v4.0 $file_date = $key_value_pairs[0]; $week_name = $key_value_pairs[1]; $day_index = $key_value_pairs[2]; $resource_key = $key_value_pairs[3]; $begin_time = $key_value_pairs[4]; $end_time = $key_value_pairs[5]; @reservation_data_line = &get_reservation_data_by_resource_and_day_and_time($week_name, $day_index, $resource_key, $begin_time); $resource_name = &get_resource_name($resource_key); $pending_details_html .= "
$settings[39]: $resource_name
"; @resv_form_fields = &prep_resv_form_fields_array(1, @reservation_data_line); if (($settings[97] =~ /DAILY/i) || ($settings[97] =~ /DATE_RANGE/i)) { $res_start_date = &get_exact_date($key_value_pairs[7]); $res_end_date = &get_exact_date($key_value_pairs[8]); if ($res_start_date ne $res_end_date) { $pending_details_html .= "Dates: $res_start_date - $res_end_date
"; } else { $pending_details_html .= "Date: $res_start_date
"; } } else { if ($settings[0] eq "CONFIG") { $start_time_formatted = $column_names[$begin_time]; $end_time_formatted = $column_names[$end_time]; } else { $start_time_formatted = &format_time($begin_time); $end_time_formatted = &format_time($end_time); } $cumulative_seconds = &get_week_seconds($week_name); if ($day_index > 1) { $cumulative_seconds += ($SECONDS_PER_DAY*($day_index-1)); } $formatted_date = &get_exact_date($cumulative_seconds); $pending_details_html .= "Date: $formatted_date
"; if ($settings[0] eq "CONFIG") { $pending_details_html .= "From: $start_time_formatted - $end_time_formatted
"; } else { $pending_details_html .= "Time: $start_time_formatted - $end_time_formatted
"; } } $pending_details_html .= "
"; $field_count = 1; $results = ""; $reservation_form_field = ""; for ($i=1; $i <= 22; $i++) { if ($fields[$field_count] =~ /\S/) { if (!($fields[($field_count + 1)] =~ /DISABLED/i)) { $reservation_form_field = &get_current_reservation_field($field_count, @resv_form_fields); $results .= $reservation_form_field; } } $field_count += 6 ; } $pending_details_html .= $results; if ($#pending_detail_choices > 1) { $pending_details_html .= "

-------------------------------------
"; } } # end foreach print "Content-type: text/html\n\n"; print "\n"; print "\n"; print "\n\n"; print "$lang_view_pending"; print ""; print "
"; print ""; print "
$lang_pending_reserve_info

"; print "

"; print ""; print ""; print ""; print "
"; print ""; print $pending_details_html; print ""; print "
"; print "
"; print ""; print ""; print ""; print "
"; print "
"; print ""; print ""; print ""; print ""; print "$lang_pending_note:
"; print "

"; print ""; print "   "; print ""; print "   "; print ""; print "
"; print "
"; print ""; print ""; print ""; print ""; print "
"; print "
"; print ""; exit; } sub get_pending_data_select_option { local ( $file_date, #YYYYMMDD needed for sorting correctly later! $week_name, $day_index, $resource_key, $data_index, @reservation_data_line) = @_; local ( $resource_name, $cumulative_seconds, $data_line, $start_time_formatted, $end_time_formatted, $res_start_time, $res_end_time, $first_field, $recurring_start_seconds, $recurring_end_seconds, $res_start_date, $res_end_date, @string_value_pairs); $data_line = ""; $select_option = ""; $first_field = $reservation_data_line[$data_index]; $first_field =~ s/\?PENDING//; $resource_name = &get_resource_name($resource_key); if (($settings[97] =~ /DAILY/i) || ($settings[97] =~ /DATE_RANGE/i)) { $field5_recurring = $reservation_data_line[$data_index + 4]; @string_value_pairs = split (/\?/, $field5_recurring); if ($string_value_pairs[2] =~ /\S/) { $recurring_start_seconds = $string_value_pairs[2]; $recurring_end_seconds = $string_value_pairs[3]; $res_start_date = &get_exact_date($recurring_start_seconds); $res_end_date = &get_exact_date($recurring_end_seconds); if ($res_start_date ne $res_end_date) { $data_line = sprintf("%s: %s - %s --> %s", $resource_name, $res_start_date, $res_end_date, $first_field); } else { $data_line = sprintf("%s: %s --> %s", $resource_name, $res_start_date, $first_field); } $option_value = $file_date . "^" . $week_name . "^" . $day_index . "^" . $resource_key . "^" . $gtime_range_start . "^" . $gtime_range_stop . "^" . $recurring_start_seconds . "^" . $recurring_end_seconds; $select_option = ""; } } else { $res_start_time = $reservation_data_line[$data_index + 5]; $res_end_time = $reservation_data_line[$data_index + 6]; if ($settings[0] eq "CONFIG") { $start_time_formatted = $column_names[$res_start_time]; $end_time_formatted = $column_names[$res_end_time]; } else { $start_time_formatted = &format_time($res_start_time); $end_time_formatted = &format_time($res_end_time); } $cumulative_seconds = &get_week_seconds($week_name); if ($day_index > 1) { $cumulative_seconds += ($SECONDS_PER_DAY*($day_index-1)); } $formatted_date = &get_exact_date($cumulative_seconds); $data_line = sprintf("%s: %s %s - %s --> %s", $resource_name, $formatted_date, $start_time_formatted, $end_time_formatted, $first_field); $option_value = $file_date . "^" . $week_name . "^" . $day_index . "^" . $resource_key . "^" . $res_start_time . "^" . $res_end_time; $select_option = ""; } return $select_option; } # end get_pending_data_select_option() sub get_days_of_week_html { local ($font_size, $short_flag) = @_; local ($week_days_html, $day_name_index); $week_days_html = ""; for ($day_name_index=1; $day_name_index < 8; $day_name_index++) { $week_days_html .= ""; $week_days_html .= ""; if ($settings[6] =~ /SUN/i) { if ($short_flag == 1) { $week_days_html .= "$sun_days_short[$day_name_index]"; } else { $week_days_html .= "$sun_days[$day_name_index]"; } } else { if ($short_flag == 1) { $week_days_html .= "$mon_days_short[$day_name_index]"; } else { $week_days_html .= "$mon_days[$day_name_index]"; } } $week_days_html .= ""; } return $week_days_html; } # end get_days_of_week_html sub save_settings { local ($idx); if (open(SETTINGS_FILE, ">" . $settings_file)) { for ($idx = 0; $idx <= $#settings; $idx++) { print SETTINGS_FILE $settings[$idx] . "\n"; } close(SETTINGS_FILE); chmod(0777, $settings_file); } else { &return_error("File Error","Unable to open " . $settings_file); } } sub save_fields { local ($idx); if (open(FIELDS_FILE, ">" . $reservation_fields_file)) { for ($idx = 0; $idx <= $#fields; $idx++) { print FIELDS_FILE $fields[$idx] . "\n"; } close(FIELDS_FILE); chmod(0777, $reservation_fields_file); } else { &return_error("File Error","Unable to open " . $reservation_fields_file); } } sub default_settings { $settings[0] = "30"; # default timeslot size to 30 minutes $settings[1] = "WEEKLY"; # default schedule view to weekly $settings[2] = ""; # primary email notification $settings[3] = ""; # secondary email notification $settings[4] = "YES"; # default option to email user to YES $settings[5] = "US"; # default date format to US (MM-DD-YYYY) $settings[6] = "SUN"; # default start_day to "SUN" (Sunday) ** CAUSES DATA FORMAT CHANGE ** $settings[7] = "YES"; # default show_weekends to YES $settings[8] = "STD"; # default time format to STD $settings[9] = "YES"; # maintain log default to Yes $settings[10] = "2"; # default user permission level default to 2 - Anyone can make reservations but only authorized users can make recurring events. $settings[11] = "Reservation Notification"; # admin email subject when reservations are created $settings[12] = "Reservation Receipt"; # user email subject $settings[13] = "SENDMAIL"; # email method $settings[14] = "/usr/sbin/sendmail"; # sendmail path $settings[15] = "000.000.000.0"; # smtp address $settings[16] = "NONE"; # page background image $settings[17] = "#FFFFFF"; # page background color $settings[18] = "Verdana,Arial,Helvetica"; # page font face $settings[19] = "2"; # page font size $settings[20] = "#000000"; # page font color $settings[21] = "#0000FF"; # page link color $settings[22] = "#0000FF"; # page visited link color $settings[23] = "#0000FF"; # page active link color $settings[24] = "#F0F0F0"; # graph title color $settings[25] = "#FFFFFF"; # graph open color $settings[26] = "#FFCECE"; # graph reserved color $settings[27] = "#C0C0C0"; # graph blocked color $settings[28] = "Verdana,Arial,Helvetica"; # graph font face $settings[29] = "2"; # graph font size $settings[30] = "#000000"; # graph font color $settings[31] = "R"; # reservation character placeholder $settings[32] = ""; # reservation image $settings[33] = "Reserved"; # reservation image alt text $settings[34] = "20"; # daily/weekly cell width $settings[35] = "60"; # monthly cell width $settings[36] = "Resource"; # resource_title $settings[37] = "At what time would you like to reserve this resource?"; # resource_prompt $settings[38] = "Is this a recurring event?"; # recurring prompt $settings[39] = "Resource Name"; # resource_field1 $settings[40] = "Location"; # resource_field2 $settings[41] = "Capacity"; # resource_field3 $settings[42] = "Phone"; # resource_field4 $settings[43] = "Notes"; # resource_field5 $settings[44] = "Please enter your contact information below:"; # reservation prompt $settings[45] = "Name"; # reservation field 1 $settings[46] = "Phone"; # reservation field 2 $settings[47] = "Email"; # reservation field 3 $settings[48] = "Notes"; # reservation field 4 $settings[49] = "Enter a password to protect your reservation: (Optional)"; # password prompt 1 $settings[50] = "An authorized user name and password is required: "; # password prompt 2 $settings[51] = "A user name and password is required for recurring events: "; # password prompt 3 $settings[52] = "Password"; # reservation field 5 $settings[53] = "*A password is required for all modifications."; # reserve password informational $settings[54] = "600"; # reservation window height $settings[55] = "400"; # reservation window width $settings[56] = "*To reserve a resource, click on the resource's name."; # reserve instructions for daily or weekly calendar $settings[57] = "*To reserve a resource, click on the calendar date."; # monthly format reserve instructions $settings[58] = "CURRENT"; # default date range report start date $settings[59] = "7"; # default date range report end date (number of days from start date) $settings[60] = "NO"; # default run report for all resources $settings[61] = "YES"; # default to email the primary admin a resource report $settings[62] = "NO"; # default to email the secondary admin a resource report $settings[63] = "YES"; # default print to screen $settings[64] = "NO"; # default print to file $settings[65] = "NO"; # print am/pm on reports $settings[66] = "NO"; # double-space reports $settings[67] = "20"; # daily/weekly cell height $settings[68] = "60"; # monthly cell height $settings[69] = "Reservation Modified"; # admin email subject for reservation mods $settings[70] = "Reservation Cancellation"; # admin email subject for reservation cancellations $settings[71] = "Reservation Modified Receipt"; # user email subject for reservation mods $settings[72] = "Reservation Cancellation Receipt"; # user email subject for reservation cancellations $settings[73] = "#FFD700"; # graph pending color $settings[74] = "on"; # reservation field 1 required $settings[75] = "off"; # reservation field 2 not required $settings[76] = "off"; # reservation field 3 not required $settings[77] = "off"; # reservation field 4 not required $settings[78] = "Reservation Pending"; # admin email subject for reservation pending $settings[79] = "Reservation Pending Receipt"; # user email subject for reservation pending $settings[80] = "NO"; # restrict viewing of reservation details $settings[81] = "NO"; # print open timeslots on reports $settings[82] = "NO"; # (monthly) only show completely full timeslots in the reserved color? $settings[83] = "YES"; # (monthly) show hyperlinks to each calendar $settings[84] = "4"; # (monthly) number of hyperlinks columns $settings[85] = "#FFFFFF"; # ($monthly) hyperlinks table color $settings[86] = "1"; # hyperlinks Font Size $settings[87] = "Verdana,Arial,Helvetica"; # hyperlinks Font Face $settings[88] = ""; # monthly reserve image $settings[89] = "Reservations"; # monthly reserve image alt $settings[90] = ""; # monthly pending image $settings[91] = "Pending Reservations"; # monthly pending image alt $settings[92] = ""; # monthly full day image $settings[93] = "No Timeslots Available"; # monthly full day image alt $settings[94] = ""; # optional schedule start date $settings[95] = "NO"; # default to showing admin hyperlink on schedule $settings[96] = "NO"; # NOT IMPLEMENTED $settings[97] = "STANDARD"; # reservation frequency $settings[98] = "From:"; # reservation start time label $settings[99] = "To:"; # reservation end time label $settings[100] = "During:"; # reservation fixed time label $settings[101] = "Number of Nights:"; # daily label $settings[102] = "Start Date:"; # date range start label $settings[103] = "End Date:"; # date range end label $settings[104] = "Start Date:"; # NOT IMPLEMENTED $settings[105] = "Start Time:"; # NOT IMPLEMENTED $settings[106] = "End Date:"; # NOT IMPLEMENTED $settings[107] = "End Time:"; # NOT IMPLEMENTED $settings[108] = "FIXED"; # recurring reservation format, freeform or fixed $settings[109] = "on"; # daily recurring options enabled $settings[110] = 2; # min daily recurring $settings[111] = 14; # max daily recurring $settings[112] = "on"; # weekly recurring options enabled $settings[113] = 2; # min weekly recurring $settings[114] = 16; # max weekly recurring $settings[115] = "on"; # biweekly recurring options enabled $settings[116] = 2; # min biweekly recurring $settings[117] = 16; # max biweekly recurring $settings[118] = "on"; # monthly recurring options enabled $settings[119] = 2; # min monthly recurring $settings[120] = 12; # max monthly recurring $settings[121] = "YES"; # passed timeslot check $settings[122] = "toggle"; # show toggle schedule view hyperlink $settings[123] = "top"; # show toggle hyperlink at the top $settings[124] = "right"; # show toggle hyperlink at the right $settings[125] = "top"; # show admin control panel hyperlink at the top $settings[126] = "right"; # show admin control panel hyperlink at the right $settings[127] = "NO"; # password protect the entire calendar $settings[128] = "NO"; # disable illegal referrer check $settings[129] = "YES"; # allow admin to override the expired timeslot check $settings[130] = "NO"; # NOT IMPLEMENTED $settings[131] = "1"; # option for specifying how categories are shown 1=dont use, 2=menu 3=all $settings[132] = "Verdana,Arial,Helvetica"; # category menu font face $settings[133] = "2"; # category menu font size $settings[134] = "#000000"; # category menu font color $settings[135] = "YES"; # allow admin or resource admin to add/edit/del resv during lockout $settings[136] = "#000000"; # category divider line color, defaults to black $settings[137] = "#FFFFFF"; # category divider line font color $settings[138] = "Verdana,Arial,Helvitica"; # category divider line font face $settings[139] = "2"; # category divider line font size $settings[140] = "0"; # timezone adjustment factor $settings[141] = "Pending Reservation Accepted"; # admin email subject for pending reservation authorized $settings[142] = "Pending Reservation Rejected"; # admin email subject for pending reservation rejected $settings[143] = "Pending Reservation Accepted"; # user email subject for pending reservation authorized $settings[144] = "Pending Reservation Rejected"; # user email subject for pending reservation rejected $settings[145] = "YES"; # show navigation bar $settings[146] = "bottom"; # show navigation bar at the bottom $settings[147] = "center"; # show navigation bar in the center $settings[148] = "off"; # force password to be required when not using auth users $settings[149] = "YES"; # show category menu hyperlink $settings[150] = "YES"; # allow auth users to modify their own password } sub default_reservation_fields { local ($field_name_index, $field_line_index, $field_name, $i); $fields[0] = "FIELD01"; if ($settings[45] =~ /\S/) { $fields[1] = $settings[45]; # read from the ureserve-settings file, in case of upgrade } else { $fields[1] = "Name"; } $fields[2] = "TEXT"; $fields[3] = ""; $fields[4] = "STANDARD"; if ($settings[74] =~ /off/i) { $fields[5] = "off"; } else { $fields[5] = "on"; } $fields[6] = "FIELD02"; if ($settings[46] =~ /\S/) { $fields[7] = $settings[46]; # read from the ureserve-settings file, in case of upgrade } else { $fields[7] = "Phone"; } $fields[8] = "TEXT"; $fields[9] = ""; $fields[10] = "STANDARD"; if ($settings[75] =~ /off/i) { $fields[11] = "off"; } else { $fields[11] = "on"; } $fields[12] = "FIELD03"; if ($settings[47] =~ /\S/) { $fields[13] = $settings[47]; # read from the ureserve-settings file, in case of upgrade } else { $fields[13] = "E-Mail"; } $fields[14] = "EMAIL"; $fields[15] = ""; $fields[16] = "STANDARD"; if ($settings[76] =~ /off/i) { $fields[17] = "off"; } else { $fields[17] = "on"; } $fields[18] = "FIELD04"; if ($settings[48] =~ /\S/) { $fields[19] = $settings[48]; # read from the ureserve-settings file, in case of upgrade } else { $fields[19] = "Notes"; } $fields[20] = "TEXTAREA"; $fields[21] = ""; $fields[22] = "STANDARD"; if ($settings[77] =~ /on/i) { $fields[23] = "on"; } else { $fields[23] = "off"; } $field_name_index = 5; $field_line_index = 23; for ($i = $field_name_index; $i <= 22; $i++) { if ($i < 10) { $field_name = "0" . $i; } else { $field_name = $i; } $fields[++$field_line_index] = "FIELD" . $field_name; $fields[++$field_line_index] = ""; $fields[++$field_line_index] = "DISABLED"; $fields[++$field_line_index] = ""; $fields[++$field_line_index] = "STANDARD"; $fields[++$field_line_index] = "off"; } } sub analyze_seconds { local ($num_seconds) = @_; local ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst); $num_seconds = &strip_letters($num_seconds); if (($num_seconds < $SECONDS_2K) || ($num_seconds > $SECONDS_2100)) { $num_seconds = $SECONDS_2K; } $g_seconds = $num_seconds; ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($num_seconds); $mon += 1; $year += 1900; $g_file_date = sprintf("%04d%02d%02d",$year,$mon,$mday); if ($settings[5] =~ /US/i) { $g_formatted_date = sprintf("%s %02d/%02d/%04d",$sun_days[$wday + 1],$mon,$mday,$year); } else { $g_formatted_date = sprintf("%s %02d/%02d/%04d",$sun_days[$wday + 1],$mday,$mon,$year); } $g_wday = $wday; # save global weekday number $g_mon = $mon; # save global month number $g_year = sprintf("%04d",$year); # save global year number if (($wday == 0) || ($wday == 6)) { $g_weekend = 1; } else { $g_weekend = 0; } } sub get_day_of_week { local ($seconds_date) = @_; local ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst); if (($seconds_date < $SECONDS_2K) || ($seconds_date > $SECONDS_2100)) { $seconds_date = $SECONDS_2K; } ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($seconds_date); return $wday; } sub create_report_details_form { local ( $username, $password, $msg) = @_; local ( $resource_name, $week_name, $day_index, $current_seconds, $res_start_time, $res_end_time, $date_string, $results, $email_message, $iterations, $increment, $day_increment, $counter, $report_day, $example_date, $report_type, $report_date_1, $report_date_2, $report_seconds, $report_week_name, $default_start_date, $default_start_date_seconds, $default_end_date, $default_month, @key_value_pairs, @resources); &validate_referral_page($script_url); if (!(-e $gresource_file)) { &warn_no_resources_defined(); exit; } if ($settings[5] =~ /US/i) { $example_date = "MM/DD/YYYY"; } else { $example_date = "DD/MM/YYYY"; } print "Content-type: text/html\n\n"; print "\n"; print "\n"; print "\n\n"; print "uReserve"; print ""; print "


"; print ""; if ($msg =~ /\S/) { print ""; } else { print ""; } print "
"; print ""; print "$lang_generate_reports

"; print "
"; print "
$msg
 
"; print ""; print "
"; print "
"; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; $now = time(); if ($settings[58] =~ /WEEK/i) { $default_start_week = &get_week_name($now); # returns name in the format MM-DD-YYYY ... regardless of the configured date format $default_start_week_seconds = &get_week_seconds($default_start_week); $default_start_date = &get_exact_date($default_start_week_seconds); } else { $default_start_date = &get_exact_date($now); } print ""; print ""; print ""; print ""; $end_seconds = $now + ($settings[59] * $SECONDS_PER_DAY); &analyze_seconds($end_seconds); if ($settings[5] =~ /US/i) { $default_end_date = sprintf("%02d/%02d/%04d",substr($g_file_date,4,2),substr($g_file_date,6,2),substr($g_file_date,0,4)); } else { $default_end_date = sprintf("%02d/%02d/%04d",substr($g_file_date,6,2),substr($g_file_date,4,2),substr($g_file_date,0,4)); } print ""; print ""; print ""; print ""; &analyze_seconds($now); if ($settings[5] =~ /US/i) { $default_month = sprintf("%02d/%04d",substr($g_file_date,4,2),substr($g_file_date,0,4)); } else { $default_month = sprintf("%02d/%04d",substr($g_file_date,4,2),substr($g_file_date,0,4)); } print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; if ($settings[2] =~ /\S/) { print ""; print ""; } if ($settings[3] =~ /\S/) { print ""; print ""; } print ""; print ""; print ""; print ""; print ""; print ""; print "
"; print "Choose Report Type:
"; print "Reservations By Resource"; print "
By resource, then by date and time
$resv_by_resource_report_desc
"; print "Reservations By Time Period"; print "
By date and time, across resources
"; print "
$resv_by_time_period_report_desc
"; print "Resource Usage"; print "
Usage Statistics
$resource_usage_report_desc
"; print "Choose Report Period:
Daily Report  ($example_date)
Date Range Report"; print "From Date: "; print "  ($example_date)   "; print "
To Date: "; print "    ($example_date)  
Monthly Report  (MM/YYYY)
"; print "Choose Time Range: (for Reservations By Time Period Report Only)
"; $time_range_start = &strip_letters($gtime_range_start); $time_range_stop = &strip_letters($gtime_range_stop); $time_selections_html = &get_report_time_selections($gtime_range_start, $gtime_range_stop); print $time_selections_html; print "
"; print ""; @resources = &get_resource_file_all_records(); print "$lang_run_for_all_resources?"; if ($settings[60] =~ /YES/i) { print "Yes"; print "No"; } else { print "Yes"; print "No"; } print "
"; print "Optionally Choose Specific Resource(s):"; print ""; print "
"; print "$lang_print_empty_timeslots?
"; print "Does NOT apply to Reservations By Time Period Report"; print "
"; if ($settings[81] =~ /YES/i) { print "Yes"; print "No"; } else { print "Yes"; print "No"; } print "
"; print "Email Report to Primary Admin ($settings[2])?"; if ($settings[61] =~ /YES/i) { print "Yes"; print "No"; } else { print "Yes"; print "No"; } print "
"; print "Email Report to Secondary Admin ($settings[3])?"; if ($settings[62] =~ /YES/i) { print "Yes"; print "No"; } else { print "Yes"; print "No"; } print "
"; print "Print To Screen?"; if ($settings[63] =~ /YES/i) { print "Yes"; print "No"; } else { print "Yes"; print "No"; } print "
"; print "Print to File?"; if ($settings[64] =~ /YES/i) { print "Yes"; print "No"; } else { print "Yes"; print "No"; } print "
"; print ""; print ""; print ""; print ""; print "
"; print ""; print ""; print ""; print ""; print "
"; print "
"; print "
"; print "
"; print ""; exit; } sub generate_report_by_resource { local ( $report_period, $report_type, $report_date_1, $report_date_2, $report_date_3, $report_month, $run_all, $resource_list, $email_1, $email_2, $print_file, $print_screen, $print_empty) = @_; local ( $report_start_seconds, $report_end_seconds, $report_start_week_name, $report_end_week_name, $line_index, $looper, $resource_key, $resource_name, $include_in_report, $current_line, $reservation_field1, $reservation_field2, $reservation_field3, $reservation_field4, $begin_time, $end_time, $temp_string, $data_index, $index, $suffix, $prefix, $ttime, $report_file, $report_file_date, $report, $report_subject, $file_name, $end_file_name, $save_start_file_name, $day_index, $report_start_day_index, $report_end_day_index, $resource_index, $current_seconds, $within_date_range, $corrected_time_range_stop, $choice, @choices, @resources, @lines, @key_value_pairs, @reservation_value_pairs); &validate_referral_page($script_url); $gtime_range_start = &strip_letters($gtime_range_start); $gtime_range_stop = &strip_letters($gtime_range_stop); if ($report_period eq $REPORT_PERIOD_DAILY) { $report_start_date = $report_date_1; $report_end_date = $report_date_1; } elsif ($report_period eq $REPORT_PERIOD_RANGE) { $report_start_date = $report_date_2; $report_end_date = $report_date_3; } elsif ($report_period eq $REPORT_PERIOD_MONTHLY) { if ($settings[5] =~ /US/i) { $report_start_date = sprintf("%02d/%02d/%04d",substr($report_month,0,2),1,substr($report_month,3,4)); } else { $report_start_date = sprintf("%02d/%02d/%04d",1,substr($report_month,0,2),substr($report_month,3,4)); } $report_secs = sprintf("%02d-%02d-%04d",substr($report_month,0,2),1,substr($report_month,3,4)); $cumulative_seconds = &get_week_seconds($report_secs); $save_month = substr($report_month,0,2); for ($index=1; $index<32; $index++) { $cumulative_seconds += $SECONDS_PER_DAY; &analyze_seconds($cumulative_seconds); if ($g_mon != $save_month) { $cumulative_seconds -= $SECONDS_PER_DAY; &analyze_seconds($cumulative_seconds); $index = 32; } } $report_end_date = &get_exact_date($cumulative_seconds); } $report_start_seconds = &get_date_seconds($report_start_date); $report_end_seconds = &get_date_seconds($report_end_date); if ($report_end_seconds < $report_start_seconds) { &missing_input("Configuration Error", "Select an End Date that is later than the Start Date."); } &analyze_seconds($report_end_seconds); $report_end_day_index = $g_wday; if ($settings[6] =~ /SUN/i) { $report_end_day_index = $g_wday + 1; } if ($report_period eq $REPORT_PERIOD_DAILY) { $report_end_day_index++; } $report_week_name = &get_week_name($report_start_seconds); &analyze_seconds($report_start_seconds); $report_start_day_index = $g_wday; $looper = &get_looper(); $report_start_week_name = &get_week_name($report_start_seconds); #MM-DD-YYYY $start_file_name = $data_directory . $report_start_week_name; $start_file_name .= ".txt"; $file_name = $start_file_name; $report_end_week_name = &get_week_name($report_end_seconds); #MM-DD-YYYY $end_file_name = $data_directory . $report_end_week_name; $end_file_name .= ".txt"; $report_end_week_name2 = &get_week_name(($report_end_seconds + ($SECONDS_PER_DAY * 7))); #MM-DD-YYYY $end_file_name2 = $data_directory . $report_end_week_name2; $end_file_name2 .= ".txt"; $save_end_file_name = $end_file_name; $save_end_file_name2 = $end_file_name2; $save_start_file_name = $start_file_name; $save_report_start_seconds = $report_start_seconds; if ($report_period eq $REPORT_PERIOD_DAILY) { $report_subject = " uReserve Daily Report for $report_start_date\n"; $report = $report_subject; $report .= " Prepared " . localtime() . "\n"; } else { $report_subject = " uReserve $report_period Report for "; if ($report_period eq $REPORT_PERIOD_RANGE) { $report_subject .= "($report_start_date) to ($report_end_date)\n"; } else { $report_subject .= "$month_names[$g_mon] $g_year\n"; } $report = $report_subject; $report .= " Prepared " . localtime() . "\n"; } if (-e $gresource_file) { open (RESOURCE_FILE, $gresource_file) || &return_error("File Error","Unable to open " . $gresource_file); @resources = ; close(RESOURCE_FILE); for ($resource_index = 0; $resource_index <= $#resources; $resource_index++) { @key_value_pairs = split (/\|/, $resources[$resource_index]); $resource_key = $key_value_pairs[0]; $include_in_report = 0; if ($run_all =~ /YES/i) { $include_in_report = 1; } else { @choices=split(/\0/,$resource_list); REPORT_CHOICE: foreach $choice (@choices) { if (int($choice) == int($resource_key)) { $include_in_report = 1; last REPORT_CHOICE; } } } if ($include_in_report == 1) { $data_found = 0; while ($file_name ne $end_file_name2) { if ($print_empty eq $lang_no) { if (-e $file_name) { open (SCHEDULE_FILE, $file_name) || &return_error("File Error","Unable to open $file_name"); @lines = ; close(SCHEDULE_FILE); $line_index = 0; while ($line_index <= $#lines) { if (!($lines[$line_index] =~ /^#END/i)) { if ($lines[$line_index] =~ /^#/) { $day_index = $lines[$line_index]; chop($day_index); # remove the carriage return $day_index =~ s/#//g; } else { @reservation_value_pairs = split (/\|/, $lines[$line_index]); $current_key = $reservation_value_pairs[0]; if (int($current_key) == int($resource_key)) { if (&check_real_reservation($lines[$line_index])) { $done = 0; $resource_name = &get_resource_name($resource_key); $within_date_range = &check_within_date_range( $file_name, $end_file_name, $save_start_file_name, $day_index, $report_start_day_index, $report_end_day_index); if ($within_date_range == 1) { $data_found = 1; $day_seconds = &get_week_seconds($report_week_name); $day_seconds += (($day_index-1) * $SECONDS_PER_DAY); $printed_date = &get_exact_date($day_seconds); $report .= "\n\n---------------------------------------------------------------------------\n"; &analyze_seconds($day_seconds); $report_day = substr($g_file_date,6,2); $report .= "$resource_name Reservations\n"; $report .= "$month_names[$g_mon] $report_day, $g_year ($printed_date)\n\n"; for ($index = $gtime_range_start; $index < $gtime_range_stop; $index += $looper) { if ($done == 0) { for ($data_index = 1; $data_index < $#reservation_value_pairs; $data_index += 25) { $done = 1; $begin_time = &strip_letters($reservation_value_pairs[$data_index + 5]); $end_time = &strip_letters($reservation_value_pairs[$data_index + 6]); @resv_form_fields = &prep_resv_form_fields_array($data_index, @reservation_value_pairs); while ((sprintf('%2.3f',$index)) < (sprintf('%2.3f',$begin_time))) { $index += $looper; } $prefix = $index; $prefix = &get_prefix($index); $suffix = &get_suffix($index); if (!($settings[0] eq "CONFIG")) { $ttime = sprintf("%02d%s",$prefix,$suffix); } else { $ttime = $column_names[$prefix]; } if ($settings[66] =~ /YES/i) # if report should be double-spaced { $report .= "\n"; } $report .= $ttime; if (!($settings[0] eq "CONFIG")) { $report .= " - "; $end_prefix = &get_prefix($end_time); $end_suffix = &get_suffix($end_time); $ttime2 = sprintf("%02d%s",$end_prefix,$end_suffix); $report .= $ttime2; } $report .= "\n"; $length_rtime = 2; $field_count = 1; $results = ""; $reservation_form_field = ""; for ($i=1; $i <= 22; $i++) { if ($fields[$field_count] =~ /\S/) { if (!($fields[($field_count + 1)] =~ /DISABLED/i)) { $reservation_form_field = &get_current_reservation_field($field_count, @resv_form_fields); $results .= "  "; $results .= $reservation_form_field; $results =~ s/\n/\/g; $results =~ s/\?PENDING/ - PENDING/g; } } $field_count += 6 ; } $report .= $results; } # end for ($data_index = 6; $data_index ... } # end if $done == 0 else { $index = $gtime_range_stop; $prefix = $index; $prefix = &get_prefix($index); $suffix = &get_suffix($index); } } # end for ($index = $gtime_range_start; $index < $gtime_range_stop; $index++) } # end if ($within_date_range == 1) } # end if check_real_reservation } # end if ($current_name eq $resource_key) } # end if ($lines[$line_index] =~ /^#/) $line_index++; } # end if (!($lines[$line_index] =~ /^#END/i)) else { $line_index++; } } # end while (($line_index <= $#lines) } # end if -e $file_name } # end if print_empty =~ NO else # MARYLAND DMV - we are printing empty timeslots, go ahead and print all days in the week regardless { $end_loop = 7; if ($settings[6] =~ /SUN/i) { $end_loop = 8; } if ($file_name eq $end_file_name) { if ($save_start_file_name eq $end_file_name) { if ($settings[6] =~ /SUN/i) { $day_index = $report_start_day_index + 1; } else { $day_index = $report_start_day_index; } } else { if ($settings[6] =~ /SUN/i) { $day_index = 1; } else { $day_index = 0; } } $end_loop = $report_end_day_index; } elsif ($file_name eq $save_start_file_name) { if ($settings[6] =~ /SUN/i) { $day_index = $report_start_day_index + 1; } else { $day_index = $report_start_day_index; } } else { if ($settings[6] =~ /SUN/i) { $day_index = 1; } else { $day_index = 0; } } if (-e $file_name) { open (SCHEDULE_FILE, $file_name) || &return_error("File Error","Unable to open $file_name"); @lines = ; close(SCHEDULE_FILE); } if ( (($report_period eq $REPORT_PERIOD_DAILY) || ($report_start_date eq $report_end_date)) || (($save_start_file_name ne $end_file_name) && ($report_period ne $REPORT_PERIOD_DAILY)) ) { $end_loop += 1; } while ($day_index < $end_loop) { $done = 1; $within_date_range = &check_within_date_range( $file_name, $end_file_name, $save_start_file_name, $day_index, $report_start_day_index, $report_end_day_index); if ($within_date_range == 1) { if (-e $file_name) { $line_index = 0; $current_line = ""; $this_day_index = ""; while ($line_index <= $#lines) { if (!($lines[$line_index] =~ /^#END/i)) { if ($lines[$line_index] =~ /^#/) { $this_day_index = $lines[$line_index]; chop($this_day_index); # remove the carriage return $this_day_index =~ s/#//g; } else { if (int($this_day_index) == int($day_index)) { @reservation_value_pairs = split (/\|/, $lines[$line_index]); $current_key = $reservation_value_pairs[0]; if (int($current_key) == int($resource_key)) { if (&check_real_reservation($lines[$line_index])) { $current_line = $lines[$line_index]; $line_index = $#lines; $done = 0; } } } } } $line_index++; } #end while ($line_index <= $#lines) } # end if -e file_name $data_found = 1; $resource_name = &get_resource_name($resource_key); $day_seconds = &get_week_seconds($report_week_name); $day_seconds += (($day_index-1) * $SECONDS_PER_DAY); $printed_date = &get_exact_date($day_seconds); $report .= "\n\n---------------------------------------------------------------------------\n"; &analyze_seconds($day_seconds); $report_day = substr($g_file_date,6,2); $report .= "$resource_name Reservations\n"; $report .= "$month_names[$g_mon] $report_day, $g_year ($printed_date)\n\n"; $corrected_time_range_stop = $gtime_range_stop; if ($settings[0] eq "CONFIG") { $corrected_time_range_stop = $gtime_range_stop - $looper; } if ($current_line =~ /\S/) { @reservation_value_pairs = (); @reservation_value_pairs = split (/\|/, $current_line); if ($reservation_value_pairs[1]) { for ($index = $gtime_range_start; $index <= $corrected_time_range_stop; $index += $looper) { for ($data_index = 1; $data_index <= $#reservation_value_pairs; $data_index += 25) { $begin_time = &strip_letters($reservation_value_pairs[$data_index + 5]); $end_time = &strip_letters($reservation_value_pairs[$data_index + 6]); @resv_form_fields = &prep_resv_form_fields_array($data_index, @reservation_value_pairs); $prefix = $index; $prefix = &get_prefix($index); $suffix = &get_suffix($index); while ((sprintf('%2.3f',$index)) < (sprintf('%2.3f',$begin_time))) { $prefix = $index; $prefix = &get_prefix($index); $suffix = &get_suffix($index); if (!($settings[0] eq "CONFIG")) { $ttime = sprintf("%02d%s",$prefix,$suffix); } else { $ttime = $column_names[$prefix]; } if ($settings[66] =~ /YES/i) # if report should be double-spaced { $report .= "\n"; } $report .= $ttime; $adj_day_index = $day_index; if ($settings[6] =~ /SUN/i) # fix 4.0 - blackout days are always 1-7, never 0-6 { } else { if ($adj_day_index == 0) { $adj_day_index = 7; } } @blackout_timeslots = &get_blackout_timeslots($resource_key, $day_seconds, $adj_day_index); if ($blackout_timeslots[0] == -1) { $report .= " [ " . $lang_unavailable . " ]"; } else { $blackout_end_index = &check_timeslot_in_blackout_list($index, @blackout_timeslots); if ($blackout_end_index > 0) { $report .= " [ " . $lang_unavailable . " ]"; } } $report .= "\n"; $index += $looper; } # end while ($index < $begin_time) $prefix = $begin_time; $prefix = &get_prefix($begin_time); $suffix = &get_suffix($begin_time); if (!($settings[0] eq "CONFIG")) { $ttime = sprintf("%02d%s",$prefix,$suffix); } else { $ttime = $column_names[$prefix]; } if ($settings[66] =~ /YES/i) # if report should be double-spaced { $report .= "\n"; } $report .= $ttime; $report .= "\n"; $length_rtime = length($ttime) + 2; $field_count = 1; $results = ""; $reservation_form_field = ""; for ($i=1; $i <= 22; $i++) { if ($fields[$field_count] =~ /\S/) { if (!($fields[($field_count + 1)] =~ /DISABLED/i)) { $reservation_form_field = &get_current_reservation_field($field_count, @resv_form_fields); $results .= "  "; $results .= $reservation_form_field; $results =~ s/\n/\/g; $results =~ s/\?PENDING/ - PENDING/g; } } $field_count += 6 ; } $report .= $results; while ((sprintf('%2.3f',$index)) < (sprintf('%2.3f',$end_time))) { $prefix = $index; $prefix = &get_prefix($index); $suffix = &get_suffix($index); if (!($settings[0] eq "CONFIG")) { $ttime = sprintf("%02d%s",$prefix,$suffix); } else { $ttime = $column_names[$prefix]; } if ($settings[66] =~ /YES/i) # if report should be double-spaced { $report .= "\n"; } $report .= $ttime; if ((sprintf('%2.3f',$index)) < (sprintf('%2.3f',$end_time))) { $report .= "  [ "; $report .= $resv_form_fields[1]; $report .= " ]"; } $report .= "\n"; $index += $looper; } # end while } # end for ($data_index = 6; $data_index ... while ($index <= $corrected_time_range_stop) { $prefix = $index; $prefix = &get_prefix($index); $suffix = &get_suffix($index); if (!($settings[0] eq "CONFIG")) { $ttime = sprintf("%02d%s",$prefix,$suffix); } else { $ttime = $column_names[$prefix]; } if ($settings[66] =~ /YES/i) # if report should be double-spaced { $report .= "\n"; } $report .= $ttime; $adj_day_index = $day_index; if ($settings[6] =~ /SUN/i) # fix 4.0 - blackout days are always 1-7, never 0-6 { } else { if ($adj_day_index == 0) { $adj_day_index = 7; } } @blackout_timeslots = &get_blackout_timeslots($resource_key, $day_seconds, $adj_day_index); if ($blackout_timeslots[0] == -1) { $report .= " [ " . $lang_unavailable . " ]"; } else { $blackout_end_index = &check_timeslot_in_blackout_list($index, @blackout_timeslots); if ($blackout_end_index > 0) { $report .= " [ " . $lang_unavailable . " ]"; } } $report .= "\n"; $index += $looper; } } # end for ($index = $gtime_range_start; $index < $gtime_range_stop; $index++) } # end if $reservation_value_pairs[1] } # end if ($current_line =~ /\S/) else { for ($index2 = $gtime_range_start; $index2 <= $corrected_time_range_stop; $index2 += $looper) { $prefix = $index2; $prefix = &get_prefix($index2); $suffix = &get_suffix($index2); if (!($settings[0] eq "CONFIG")) { $ttime = sprintf("%02d%s",$prefix,$suffix); } else { $ttime = $column_names[$prefix]; } if ($settings[66] =~ /YES/i) # if report should be double-spaced { $report .= "\n"; } $report .= $ttime; $adj_day_index = $day_index; if ($settings[6] =~ /SUN/i) # fix 4.0 - blackout days are always 1-7, never 0-6 { } else { if ($adj_day_index == 0) { $adj_day_index = 7; } } @blackout_timeslots = &get_blackout_timeslots($resource_key, $day_seconds, $adj_day_index); if ($blackout_timeslots[0] == -1) { $report .= " [ " . $lang_unavailable . " ]"; } else { $blackout_end_index = &check_timeslot_in_blackout_list($index2, @blackout_timeslots); if ($blackout_end_index > 0) { $report .= " [ " . $lang_unavailable . " ]"; } } $report .= "\n"; } # end for ($index = $gtime_range_start; $index <= $corrected_time_range_stop; $index += $looper) } # end # end if (!($current_line =~ /\S/)) } # end if ($within_date_range == 1) $day_index++; } # end while day_index < $end_loop } $report_start_seconds += ($SECONDS_PER_DAY * 7); $report_week_name = &get_week_name($report_start_seconds); &analyze_seconds($report_start_seconds); $file_name = $data_directory . $report_week_name; $file_name .= ".txt"; } # end while $file_name ne $end_file_name2 $file_name = $save_start_file_name; $report_start_seconds = $save_report_start_seconds; $report_week_name = &get_week_name($report_start_seconds); # v3.22 fix $resource_name = &get_resource_name($resource_key); if ($data_found == 0) { $report .= "\n\n---------------------------------------------------------------------------\n"; $report .= "$resource_name Reservations\n\n"; $report .= "**** No reservations were found for $resource_name. ****

"; } } # end if include_in_report == 1 } # End of resource loop. $report .= "\n\n--------------------------- END OF REPORT ---------------------------------\n\n"; if ($print_screen =~ /YES/i) { print "Content-type: text/html\n\n"; print "\n"; print "\n"; print "\n\n"; print "uReserve Date Range Resource Report"; print ""; print "
" . $report . "
"; print "

"; print "
"; print ""; print ""; print ""; print ""; print "
"; print "
"; print "$website"; print ""; } if ($email_1 =~ /YES/i) { $report =~ s/ / /g; &email_report($settings[2], $report, $report_subject); } if ($email_2 =~ /YES/i) { $report =~ s/ / /g; &email_report($settings[3], $report, $report_subject); } if ($print_file =~ /YES/i) { if ($settings[5] =~ /US/i) { $report_file_date_string = $g_file_date; } else { $report_file_date_string = sprintf("%04d%02d%02d",substr($g_file_date,0,4),substr($g_file_date,6,2),substr($g_file_date,4,2)); } $report_file = $data_directory . $report_file_date_string . "_daterange_rpt.txt"; if (open(REPORT_FILE, ">" . $report_file)) { print REPORT_FILE $report; close(REPORT_FILE); } } # end if $print_file if ($print_screen =~ /NO/i) { $present_week = &get_week_name(time); # MM-DD-YYYY &create_report_details_form($username, $password, $lang_report_submitted); } } else # else a resource data file does not exist { $report .= "---------------------------------------------------------------------------\n\n"; $report .= "Error - Resource Data File does not exist.\n\n"; print "Content-type: text/html\n\n"; print "\n"; print "\n"; print "\n\n"; print "uReserve $report_period Resource Report"; print ""; print "
" . $report . "
"; print "


"; print "
"; print ""; print ""; print ""; print ""; print "
"; print "
"; print "$website"; print ""; } } sub generate_report_by_period { local ( $report_period, $report_type, $report_date_1, $report_date_2, $report_date_3, $report_month, $report_start_time, $report_end_time, $run_all, $resource_list, $email_1, $email_2, $print_file, $print_screen, $print_empty) = @_; local ( $report_start_seconds, $report_end_seconds, $report_start_week_name, $report_end_week_name, $line_index, $looper, $resource_key, $resource_name, $include_in_report, $current_line, $reservation_field1, $reservation_field2, $reservation_field3, $reservation_field4, $begin_time, $end_time, $temp_string, $data_index, $index, $suffix, $prefix, $ttime, $report_file, $report_file_date, $report, $report_subject, $file_name, $end_file_name, $save_start_file_name, $day_index, $report_start_day_index, $report_end_day_index, $resource_index, $current_seconds, $within_date_range, $corrected_time_range_stop, $choice, $i, $x, @choices, @resources, @lines, @key_value_pairs, @reservation_value_pairs); &validate_referral_page($script_url); $gtime_range_start = &strip_letters($gtime_range_start); $gtime_range_stop = &strip_letters($gtime_range_stop); if ($report_period eq $REPORT_PERIOD_DAILY) { $report_start_date = $report_date_1; $report_end_date = $report_date_1; } elsif ($report_period eq $REPORT_PERIOD_RANGE) { $report_start_date = $report_date_2; $report_end_date = $report_date_3; } elsif ($report_period eq $REPORT_PERIOD_MONTHLY) { if ($settings[5] =~ /US/i) { $report_start_date = sprintf("%02d/%02d/%04d",substr($report_month,0,2),1,substr($report_month,3,4)); } else { $report_start_date = sprintf("%02d/%02d/%04d",1,substr($report_month,0,2),substr($report_month,3,4)); } $report_secs = sprintf("%02d-%02d-%04d",substr($report_month,0,2),1,substr($report_month,3,4)); $cumulative_seconds = &get_week_seconds($report_secs); $save_month = substr($report_month,0,2); for ($index=1; $index<32; $index++) { $cumulative_seconds += $SECONDS_PER_DAY; &analyze_seconds($cumulative_seconds); if ($g_mon != $save_month) { $cumulative_seconds -= $SECONDS_PER_DAY; &analyze_seconds($cumulative_seconds); $index = 32; } } $report_end_date = &get_exact_date($cumulative_seconds); } $report_start_seconds = &get_date_seconds($report_start_date); $report_end_seconds = &get_date_seconds($report_end_date); if ($report_end_seconds < $report_start_seconds) { &missing_input("Configuration Error", "Select an End Date that is later than the Start Date."); } &analyze_seconds($report_end_seconds); $report_end_day_index = $g_wday + 1; $report_week_name = &get_week_name($report_start_seconds); &analyze_seconds($report_start_seconds); $report_start_day_index = $g_wday; $looper = &get_looper(); $report_start_week_name = &get_week_name($report_start_seconds); #MM-DD-YYYY $start_file_name = $data_directory . $report_start_week_name; $start_file_name .= ".txt"; $file_name = $start_file_name; $report_end_week_name = &get_week_name($report_end_seconds); #MM-DD-YYYY $end_file_name = $data_directory . $report_end_week_name; $end_file_name .= ".txt"; $report_end_week_name2 = &get_week_name(($report_end_seconds + ($SECONDS_PER_DAY * 7))); #MM-DD-YYYY $end_file_name2 = $data_directory . $report_end_week_name2; $end_file_name2 .= ".txt"; $save_end_file_name = $end_file_name; $save_end_file_name2 = $end_file_name2; $save_start_file_name = $start_file_name; $save_report_start_seconds = $report_start_seconds; $report_array_index = 0; @res_array = (); if ($report_period eq $REPORT_PERIOD_DAILY) { $report_subject = " uReserve Daily Report for $report_start_date\n"; $report = $report_subject; $report .= " Prepared " . localtime() . "\n"; } else { $report_subject = " uReserve $report_period Report for "; if ($report_period eq $REPORT_PERIOD_RANGE) { $report_subject .= "($report_start_date) to ($report_end_date)\n"; } else { $report_subject .= "$month_names[$g_mon] $g_year\n"; } $report = $report_subject; $report .= " Prepared " . localtime() . "\n"; } if (-e $gresource_file) { open (RESOURCE_FILE, $gresource_file) || &return_error("File Error","Unable to open " . $gresource_file); @resources = ; close(RESOURCE_FILE); for ($resource_index = 0; $resource_index <= $#resources; $resource_index++) { @key_value_pairs = split (/\|/, $resources[$resource_index]); $resource_key = $key_value_pairs[0]; $include_in_report = 0; if ($run_all =~ /YES/i) { $include_in_report = 1; } else { @choices=split(/\0/,$resource_list); REPORT_CHOICE: foreach $choice (@choices) { if (int($choice) == int($resource_key)) { $include_in_report = 1; last REPORT_CHOICE; } } } if ($include_in_report == 1) { $data_found = 0; while ($file_name ne $end_file_name2) { if (-e $file_name) { open (SCHEDULE_FILE, $file_name) || &return_error("File Error","Unable to open $file_name"); @lines = ; close(SCHEDULE_FILE); $line_index = 0; while ($line_index <= $#lines) { if (!($lines[$line_index] =~ /^#END/i)) { if ($lines[$line_index] =~ /^#/) { $day_index = $lines[$line_index]; chop($day_index); # remove the carriage return $day_index =~ s/#//g; } else { @reservation_value_pairs = split (/\|/, $lines[$line_index]); $current_key = $reservation_value_pairs[0]; if (&check_real_reservation($lines[$line_index])) { if (int($current_key) == int($resource_key)) { $done = 0; $resource_name = &get_resource_name($resource_key); $within_date_range = &check_within_date_range( $file_name, $end_file_name, $save_start_file_name, $day_index, $report_start_day_index, $report_end_day_index); if ($within_date_range == 1) { $data_found = 1; for ($index = $gtime_range_start; $index < $gtime_range_stop; $index += $looper) { if ($done == 0) { for ($data_index = 1; $data_index < $#reservation_value_pairs; $data_index += 25) { $done = 1; $begin_time = &strip_letters($reservation_value_pairs[$data_index + 5]); $end_time = &strip_letters($reservation_value_pairs[$data_index + 6]); @resv_form_fields = &prep_resv_form_fields_array($data_index, @reservation_value_pairs); $array_sort_key = $report_start_seconds; $array_sort_key += (($day_index-1) * $SECONDS_PER_DAY); $array_sort_key += $begin_time; $data_line = $array_sort_key . "|" . $begin_time . "|" . $end_time . "|" . $resource_key . "|" . $day_index . "|" . $report_week_name; $data_line .= "|" . $resv_form_fields[0] . "|" . $resv_form_fields[1] . "|" . $resv_form_fields[2] . "|" . $resv_form_fields[3]; $data_line .= "|" . $resv_form_fields[4] . "|" . $resv_form_fields[5] . "|" . $resv_form_fields[6] . "|" . $resv_form_fields[7]; $data_line .= "|" . $resv_form_fields[8] . "|" . $resv_form_fields[9] . "|" . $resv_form_fields[10] . "|" . $resv_form_fields[11]; $data_line .= "|" . $resv_form_fields[12] . "|" . $resv_form_fields[13] . "|" . $resv_form_fields[14] . "|" . $resv_form_fields[15]; $data_line .= "|" . $resv_form_fields[16] . "|" . $resv_form_fields[17] . "|" . $resv_form_fields[18] . "|" . $resv_form_fields[19]; $data_line .= "|" . $resv_form_fields[20] . "|" . $resv_form_fields[21]; $res_array[$report_array_index] = $data_line; $report_array_index++; } # end for ($data_index = 6; $data_index ... } # end if $done == 0 else { $index = $gtime_range_stop; $prefix = $index; $prefix = &get_prefix($index); $suffix = &get_suffix($index); } } # end for ($index = $gtime_range_start; $index < $gtime_range_stop; $index++) } # end if ($within_date_range == 1) } # end if ($current_name eq $resource_key) } # if real reservation } # end if ($lines[$line_index] =~ /^#/) $line_index++; } # end if (!($lines[$line_index] =~ /^#END/i)) else { $line_index++; } } # end while (($line_index <= $#lines) } # end if -e $file_name $report_start_seconds += ($SECONDS_PER_DAY * 7); $report_week_name = &get_week_name($report_start_seconds); &analyze_seconds($report_start_seconds); $file_name = $data_directory . $report_week_name; $file_name .= ".txt"; } # end while $file_name ne $end_file_name2 $file_name = $save_start_file_name; $report_start_seconds = $save_report_start_seconds; $report_week_name = &get_week_name($report_start_seconds); # v3.22 fix } # end if include_in_report == 1 } # End of resource loop. $last_date_shown = ""; $data_found = 0; if ($#res_array > 0) { @res_array = sort {$a <=> $b} @res_array; } $data_found = 0; if ($#res_array >= 0) { for ($x=0; $x <= $#res_array; $x++) { @resv_form_fields = (); @key_value_pairs = (); @key_value_pairs = split (/\|/, $res_array[$x]); $cur_start_time = $key_value_pairs[1]; $cur_end_time = $key_value_pairs[2]; $cur_resource_key = $key_value_pairs[3]; $cur_day_index = $key_value_pairs[4]; $cur_report_week_name = $key_value_pairs[5]; for ($j=0; $j < 22; $j++) { $resv_form_fields[$j] = $key_value_pairs[($j + 6)]; } $reservation_within_report_time = 0; if ( (&compare_ge($cur_start_time, $report_start_time)) && (&compare_lt($cur_start_time, $report_end_time)) ) { $reservation_within_report_time = 1; $data_found++; } if ($reservation_within_report_time) { $reservation_within_report_time = 0; $prefix = &get_prefix($cur_start_time); $suffix = &get_suffix($cur_start_time); $day_seconds = &get_week_seconds($cur_report_week_name); $day_seconds += (($cur_day_index-1) * $SECONDS_PER_DAY); $printed_date = &get_exact_date($day_seconds); &analyze_seconds($day_seconds); $report_day = substr($g_file_date,6,2); if ($settings[6] =~ /SUN/i) { $date_to_show = "$sun_days[$cur_day_index]"; } else { $date_to_show = "$mon_days[$cur_day_index]"; } if ($printed_date ne $last_printed_date) { $last_printed_date = $printed_date; $report .= "\n\n---------------------------------------------------------------------------\n"; $report .= $date_to_show; $report .= ", $month_names[$g_mon] $report_day, $g_year ($printed_date)\n\n"; } if (!($settings[0] eq "CONFIG")) { $ttime = sprintf("%02d%s",$prefix,$suffix); } else { $ttime = $column_names[$prefix]; } if ($settings[66] =~ /YES/i) # if report should be double-spaced { $report .= "\n"; } $report .= $ttime; if (!($settings[0] eq "CONFIG")) { $report .= " - "; $end_prefix = &get_prefix($cur_end_time); $end_suffix = &get_suffix($cur_end_time); $ttime2 = sprintf("%02d%s",$end_prefix,$end_suffix); $report .= $ttime2; } $report .= " "; $length_rtime = 2; $report .= &get_resource_name($cur_resource_key); $report .= "\n"; $field_count = 1; $results = ""; $reservation_form_field = ""; for ($i=1; $i <= 22; $i++) { if ($fields[$field_count] =~ /\S/) { if (!($fields[($field_count + 1)] =~ /DISABLED/i)) { $reservation_form_field = &get_current_reservation_field($field_count, @resv_form_fields); $results .= "  "; $results .= $reservation_form_field; $results =~ s/\n/\/g; $results =~ s/\?PENDING/ - PENDING/g; } } $field_count += 6 ; } $report .= $results; } # end if ($reservation_within_report_time) } # end for ($x=0; $x <= $#res_array; $x++) } # end if ($#res_array >= 0) if ($data_found == 0) { $resource_name = &get_resource_name($resource_key); $report .= "\n\n---------------------------------------------------------------------------\n"; if ($report_period eq $REPORT_PERIOD_DAILY) { $report .= "**** No reservations were found on $report_start_date. ****\n\n"; } else { $report .= "**** No reservations were found during $report_start_date - $report_end_date. ****\n\n"; } } $report .= "\n\n--------------------------- END OF REPORT ---------------------------------\n\n"; if ($print_screen =~ /YES/i) { print "Content-type: text/html\n\n"; print "\n"; print "\n"; print "\n\n"; print "uReserve Date Range Resource Report"; print ""; print "
" . $report . "
"; print "

"; print "
"; print ""; print ""; print ""; print ""; print "
"; print "
"; print "$website"; print ""; } if ($email_1 =~ /YES/i) { $report =~ s/ / /g; &email_report($settings[2], $report, $report_subject); } if ($email_2 =~ /YES/i) { $report =~ s/ / /g; &email_report($settings[3], $report, $report_subject); } if ($print_file =~ /YES/i) { if ($settings[5] =~ /US/i) { $report_file_date_string = $g_file_date; } else { $report_file_date_string = sprintf("%04d%02d%02d",substr($g_file_date,0,4),substr($g_file_date,6,2),substr($g_file_date,4,2)); } $report_file = $data_directory . $report_file_date_string . "_daterange_rpt.txt"; if (open(REPORT_FILE, ">" . $report_file)) { print REPORT_FILE $report; close(REPORT_FILE); } } # end if $print_file if ($print_screen =~ /NO/i) { $present_week = &get_week_name(time); # MM-DD-YYYY &create_report_details_form($username, $password, $lang_report_submitted); } } else # else a resource data file does not exist { $report .= "---------------------------------------------------------------------------\n\n"; $report .= "Error - Resource Data File does not exist.\n\n"; print "Content-type: text/html\n\n"; print "\n"; print "\n"; print "\n\n"; print "uReserve $report_period Resource Report"; print ""; print "
" . $report . "
"; print "


"; print "
"; print ""; print ""; print ""; print ""; print "
"; print "
"; print "$website"; print ""; } } sub generate_report_by_usage { local ( $report_period, $report_type, $report_date_1, $report_date_2, $report_date_3, $report_month, $run_all, $resource_list, $email_1, $email_2, $print_file, $print_screen, $print_empty) = @_; local ( $report_start_seconds, $report_end_seconds, $report_start_week_name, $report_end_week_name, $line_index, $looper, $resource_key, $resource_name, $include_in_report, $current_line, $reservation_field1, $reservation_field2, $reservation_field3, $reservation_field4, $begin_time, $end_time, $temp_string, $data_index, $index, $suffix, $prefix, $ttime, $report_file, $report_file_date, $report, $report_subject, $file_name, $end_file_name, $save_start_file_name, $day_index, $report_start_day_index, $report_end_day_index, $resource_index, $current_seconds, $within_date_range, $corrected_time_range_stop, $choice, $resource_array_index, @choices, @resources, @lines, @key_value_pairs, @reservation_value_pairs); &validate_referral_page($script_url); $gtime_range_start = &strip_letters($gtime_range_start); $gtime_range_stop = &strip_letters($gtime_range_stop); if ($report_period eq $REPORT_PERIOD_DAILY) { $report_start_date = $report_date_1; $report_end_date = $report_date_1; } elsif ($report_period eq $REPORT_PERIOD_RANGE) { $report_start_date = $report_date_2; $report_end_date = $report_date_3; } elsif ($report_period eq $REPORT_PERIOD_MONTHLY) { if ($settings[5] =~ /US/i) { $report_start_date = sprintf("%02d/%02d/%04d",substr($report_month,0,2),1,substr($report_month,3,4)); } else { $report_start_date = sprintf("%02d/%02d/%04d",1,substr($report_month,0,2),substr($report_month,3,4)); } $report_secs = sprintf("%02d-%02d-%04d",substr($report_month,0,2),1,substr($report_month,3,4)); $cumulative_seconds = &get_week_seconds($report_secs); $save_month = substr($report_month,0,2); for ($index=1; $index<32; $index++) { $cumulative_seconds += $SECONDS_PER_DAY; &analyze_seconds($cumulative_seconds); if ($g_mon != $save_month) { $cumulative_seconds -= $SECONDS_PER_DAY; &analyze_seconds($cumulative_seconds); $index = 32; } } $report_end_date = &get_exact_date($cumulative_seconds); } $report_start_seconds = &get_date_seconds($report_start_date); $report_end_seconds = &get_date_seconds($report_end_date); if ($report_end_seconds < $report_start_seconds) { &missing_input("Configuration Error", "Select an End Date that is later than the Start Date."); } &analyze_seconds($report_end_seconds); $report_end_day_index = $g_wday + 1; $report_week_name = &get_week_name($report_start_seconds); &analyze_seconds($report_start_seconds); $report_start_day_index = $g_wday; $looper = &get_looper(); $report_start_week_name = &get_week_name($report_start_seconds); #MM-DD-YYYY $start_file_name = $data_directory . $report_start_week_name; $start_file_name .= ".txt"; $file_name = $start_file_name; $report_end_week_name = &get_week_name($report_end_seconds); #MM-DD-YYYY $end_file_name = $data_directory . $report_end_week_name; $end_file_name .= ".txt"; $report_end_week_name2 = &get_week_name(($report_end_seconds + ($SECONDS_PER_DAY * 7))); #MM-DD-YYYY $end_file_name2 = $data_directory . $report_end_week_name2; $end_file_name2 .= ".txt"; $save_end_file_name = $end_file_name; $save_end_file_name2 = $end_file_name2; $save_start_file_name = $start_file_name; $save_report_start_seconds = $report_start_seconds; if ($report_period eq $REPORT_PERIOD_DAILY) { $report_subject = " uReserve Daily Usage Report for $report_start_date\n"; $report = $report_subject; $report .= " Prepared " . localtime() . "\n"; } else { $report_subject = " uReserve $report_period Usage Report for "; if ($report_period eq $REPORT_PERIOD_RANGE) { $report_subject .= "($report_start_date) to ($report_end_date)\n"; } else { $report_subject .= "$month_names[$g_mon] $g_year\n"; } $report = $report_subject; $report .= " Prepared " . localtime() . "\n"; } if (-e $gresource_file) { open (RESOURCE_FILE, $gresource_file) || &return_error("File Error","Unable to open " . $gresource_file); @resources = ; close(RESOURCE_FILE); $resource_array_index = -1; for ($resource_index = 0; $resource_index <= $#resources; $resource_index++) { @key_value_pairs = split (/\|/, $resources[$resource_index]); $resource_key = $key_value_pairs[0]; $include_in_report = 0; if ($run_all =~ /YES/i) { $include_in_report = 1; } else { @choices=split(/\0/,$resource_list); REPORT_CHOICE: foreach $choice (@choices) { if (int($choice) == int($resource_key)) { $include_in_report = 1; last REPORT_CHOICE; } } } if ($include_in_report == 1) { $resource_array_index++; $resource_schedule_count_key[$resource_array_index] = $resource_key; $resource_schedule_count[$resource_array_index] = 0; while ($file_name ne $end_file_name2) { if (-e $file_name) { open (SCHEDULE_FILE, $file_name) || &return_error("File Error","Unable to open $file_name"); @lines = ; close(SCHEDULE_FILE); $line_index = 0; while ($line_index <= $#lines) { if (!($lines[$line_index] =~ /^#END/i)) { if ($lines[$line_index] =~ /^#/) { $day_index = $lines[$line_index]; chop($day_index); # remove the carriage return $day_index =~ s/#//g; } else { @reservation_value_pairs = split (/\|/, $lines[$line_index]); $current_key = $reservation_value_pairs[0]; if (&check_real_reservation($lines[$line_index])) { if (int($current_key) == int($resource_key)) { $done = 0; $resource_name = &get_resource_name($resource_key); $within_date_range = &check_within_date_range( $file_name, $end_file_name, $save_start_file_name, $day_index, $report_start_day_index, $report_end_day_index); if ($within_date_range == 1) { $day_seconds = &get_week_seconds($report_week_name); $day_seconds += (($day_index-1) * $SECONDS_PER_DAY); $printed_date = &get_exact_date($day_seconds); &analyze_seconds($day_seconds); $report_day = substr($g_file_date,6,2); for ($index = $gtime_range_start; $index < $gtime_range_stop; $index += $looper) { if ($done == 0) { for ($data_index = 1; $data_index < $#reservation_value_pairs; $data_index += 25) { $done = 1; $resource_schedule_count[$resource_array_index] += 1; } # end for ($data_index = 6; $data_index ... } # end if $done == 0 } # end for ($index = $gtime_range_start; $index < $gtime_range_stop; $index++) } # end if ($within_date_range == 1) } # end if ($current_name eq $resource_key) } # end if real reservation } # end if ($lines[$line_index] =~ /^#/) $line_index++; } # end if (!($lines[$line_index] =~ /^#END/i)) else { $line_index++; } } # end while (($line_index <= $#lines) } # end if -e $file_name $report_start_seconds += ($SECONDS_PER_DAY * 7); $report_week_name = &get_week_name($report_start_seconds); &analyze_seconds($report_start_seconds); $file_name = $data_directory . $report_week_name; $file_name .= ".txt"; } # end while $file_name ne $end_file_name2 $file_name = $save_start_file_name; $report_start_seconds = $save_report_start_seconds; $report_week_name = &get_week_name($report_start_seconds); # v3.22 fix $resource_name = &get_resource_name($resource_key); } # end if include_in_report == 1 } # End of resource loop. $report .= "\n\nUsage Statistics\n\n"; $report .= $settings[39]; for ($h=0; $h<38; $h++) { $report .= " "; } $report .= "Number of Times Reserved\n"; $report .= "___________________________________________"; for ($h=0; $h<8; $h++) { $report .= " "; } $report .= "________________________\n"; for ($x=0; $x <=$resource_array_index; $x++) { $printed_resource_name = &get_resource_name($resource_schedule_count_key[$x]); if (length($printed_resource_name) > 38) { $print_res_name = substr($printed_resource_name,0,38); } else { $print_res_name = $printed_resource_name; } $report .= $print_res_name; for ($h=0; $h<(63-(length($print_res_name))-(length($resource_schedule_count[$x]))); $h++) { $report .= " "; } $report .= $resource_schedule_count[$x]; $report .= "\n"; } $report .= "\n\n\n\n\n--------------------------- END OF REPORT ---------------------------------\n\n"; if ($print_screen =~ /YES/i) { print "Content-type: text/html\n\n"; print "\n"; print "\n"; print "\n\n"; print "uReserve Date Range Resource Report"; print ""; print "
" . $report . "
"; print "

"; print "
"; print ""; print ""; print ""; print ""; print "
"; print "
"; print "$website"; print ""; } if ($email_1 =~ /YES/i) { $report =~ s/ / /g; &email_report($settings[2], $report, $report_subject); } if ($email_2 =~ /YES/i) { $report =~ s/ / /g; &email_report($settings[3], $report, $report_subject); } if ($print_file =~ /YES/i) { if ($settings[5] =~ /US/i) { $report_file_date_string = $g_file_date; } else { $report_file_date_string = sprintf("%04d%02d%02d",substr($g_file_date,0,4),substr($g_file_date,6,2),substr($g_file_date,4,2)); } $report_file = $data_directory . $report_file_date_string . "_daterange_rpt.txt"; if (open(REPORT_FILE, ">" . $report_file)) { print REPORT_FILE $report; close(REPORT_FILE); } } # end if $print_file if ($print_screen =~ /NO/i) { $present_week = &get_week_name(time); # MM-DD-YYYY &create_report_details_form($username, $password, $lang_report_submitted); } } else # else a resource data file does not exist { $report .= "---------------------------------------------------------------------------\n\n"; $report .= "Error - Resource Data File does not exist.\n\n"; print "Content-type: text/html\n\n"; print "\n"; print "\n"; print "\n\n"; print "uReserve $report_period Resource Report"; print ""; print "
" . $report . "
"; print "


"; print "
"; print ""; print ""; print ""; print ""; print "
"; print "
"; print "$website"; print ""; } } # end generate_report_by_usage sub create_utilities_form { local ($message) = @_; local ($resource_admin_access, $reports_admin_access, $user_auth); &validate_referral_page($script_url); $resource_admin_access = 0; $reports_admin_access = 0; &validate_admin($username, $password, $resource_admin_access, $reports_admin_access); $user_auth = &get_user_group($username, $password); $user_auth = int($user_auth); print "Content-type: text/html\n\n"; print "\n"; print "\n"; print "\n\n"; print "uReserve"; print ""; print "



"; print "
"; print ""; print "

"; print ""; print "
"; print "
"; print ""; print "$lang_utilities

"; print "
"; print ""; if (($message =~ /\S/) && ($message ne "NONE")) { print $message; } else { print $lang_utilities_text; } print ""; print "
"; print "
"; print "
"; print ""; if ($user_auth == $SYSTEM_ADMIN) { &print_button('M',"$lang_send_reminders", "ut_send_reminders", $password, $username); &print_button('M',"$lang_manage_images", "ut_manage_images", $password, $username); &print_button('M',"$lang_view_logs", "ut_view_logs", $password, $username); &print_button('M',"$lang_export_data", "ut_export_data", $password, $username); &print_button('M',"$lang_purge", "ut_purge_data", $password, $username); &print_button('M',"$lang_upgrade", "ut_upgrade", $password, $username); } &print_button('M',"$lang_goto_schedule", "cp_view_schedule", $password, $username); &print_button('M',"$lang_back", "login", $password, $username); print "
"; print "
"; print "
"; print ""; exit; } sub create_upgrade_form { local ($message) = @_; local ($week_name, $current_week, @files, $file, $number_of_files, $temp_file_date, $file_date); &validate_referral_page($script_url); $resource_admin_access = 0; $reports_admin_access = 0; &validate_admin($username, $password, $resource_admin_access, $reports_admin_access); &analyze_seconds(time); $week_name = &get_week_name($g_seconds); # in the form MM-DD-YYYY $current_week = &make_US_date_YYYYMMDD($week_name); # must pass US format date $number_of_files = 0; if (opendir(DATA_DIR,$data_directory)) { @files = readdir(DATA_DIR); closedir(DATA_DIR); foreach $file (@files) { $temp_file_date = substr($file,0,10); # MM-DD-YYYY $file_date = &make_US_date_YYYYMMDD($temp_file_date); # must pass US format date if (($file =~ /.txt$/) && (length($file) == 14) && ($file_date lt $current_week)) { $number_of_files++; } } } else { &return_error("Misconfiguration Error","Unable to open directory " . $data_directory); } print "Content-type: text/html\n\n"; print "\n"; print "\n"; print "\n\n"; print "uReserve $lang_upgrade"; print ""; print "
"; print ""; print ""; $message .= " "; print ""; print ""; print ""; print ""; print "
"; print ""; print "$lang_upgrade

"; print "
"; print "
"; print ""; print "$message"; print "
"; print ""; print ""; print ""; print "
"; print "$lang_upgrade_instructions"; print "
"; print "
"; print ""; print ""; print "
"; print "
"; print ""; print ""; print ""; } } else { print ""; print ""; } print ""; print "
"; $log_file = $gupgrade_log_file; if (-e ($log_file)) { $open_status = open(LOG_FILE, $log_file); if ($open_status == 0) { &return_error("File Error","Unable to open " . $log_file); } else { @log_file_lines = ; close(LOG_FILE); print "
"; $show_text = ""; for ($i=0; $i <= $#log_file_lines; $i++) { $log_file_lines[$i] =~ s/\\n/
/g; $show_text .= $log_file_lines[$i]; } print ""; print "
"; $show_text = "Upgrade log file is empty.\n\n\n\n\n\n\n\n\n\n\n"; print ""; print "
"; print "
"; print "
"; print ""; print ""; print ""; print ""; print ""; print "
"; print ""; print ""; print ""; if (!(-e $gresource_file)) { print ""; } print "
"; print ""; print ""; print ""; print ""; print "
"; print "
"; print ""; print ""; print ""; print ""; print "
"; print "
"; print "
"; print "
"; print ""; exit; } sub upgrade_data { local ($routine_name, $num_errs); &validate_referral_page($script_url); $routine_name = "UPGRADE DATA"; $num_errs = 0; if (-e $gresource_file_old) { &log_info($gupgrade_log_file,"***** Upgrade Beginning *****"); &upgrade_resource_data_file(); if (-e $gresource_file) { $num_errs += &upgrade_blackout_dates(); $num_errs += &upgrade_authorized_users(); $num_errs += &upgrade_reservation_files(); $num_errs += &upgrade_reservation_fields_file(); $num_errs += &upgrade_settings_file(); &log_info($gupgrade_log_file,"***** Upgrade Ended *****"); if ($num_errs == 0) { &log_info($ADMIN,"Upgrade performed by $username."); &create_upgrade_form("Upgrade completed successfully."); } else { &create_upgrade_form("Upgrade complete. There were " . $num_errs . " errors. Check the log."); } } } else { &create_upgrade_form("There are no version 3 files to upgrade."); } } sub upgrade_resource_data_file { local ($routine_name, $errs, $resource_name, $key, $i, @resource_value_pairs, @resource_lines); &validate_referral_page($script_url); $routine_name = "UPGRADE_RESOURCE_DATA_FILE"; if (-e $gresource_file) { &log_info($gupgrade_log_file,"Resource data file was previously upgraded."); } else { $open_status = open(RESOURCE_DATA_FILE, $gresource_file_old); if ($open_status == 0) { &log_info($gupgrade_log_file,"Resource Data File Read Error - $gresource_file_old could not be read. Upgrade aborted."); &return_error("Resource Data File Read Error","$gresource_file_old could not be read. Upgrade aborted."); } else { &log_info($gupgrade_log_file,"Upgrade resource-data file beginning."); @resource_lines = ; close(RESOURCE_DATA_FILE); open(NEW_RESOURCE_DATA_FILE,">$gresource_file") || &return_error("File Error","Unable to create " . $gresource_file . ". Upgrade aborted."); for ($i=0; $i <= $#resource_lines; $i++) { $key = $i + 1; if ($resource_lines[$i] =~ /\S/) { print NEW_RESOURCE_DATA_FILE $key . "|||||" . $resource_lines[$i]; $resource_name = ""; @resource_value_pairs = split (/\|/, $resource_lines[$i]); $resource_name = $resource_value_pairs[0]; &log_info($gupgrade_log_file,"$resource_name has been upgraded."); } } close(NEW_RESOURCE_DATA_FILE); chmod(0777, $gresource_file); &log_info($gupgrade_log_file,"Resource data file was upgraded."); &log_info($ADMIN,"Resource data file was upgraded by $username."); } } return; } sub upgrade_blackout_dates { local ( $routine_name, $errs, $resource_name, $key, $i, $debug_detail, @resource_value_pairs, @blackout_value_pairs, @resource_lines, @blackout_data_lines); &validate_referral_page($script_url); $routine_name = "UPGRADE_BLACKOUT_DATES"; $errs = 0; $already_upgraded = 0; if (!(-e $gblackout_dates_file)) { &log_info($gupgrade_log_file,"There was no blackout-dates file to upgrade."); return $errs; } $copy_file_name = $gblackout_dates_file . ".bak"; if (-e $copy_file_name) { srand(time|$$); $random_number = int(rand(10000000)); $new_copy_file_name = $gblackout_dates_file . ".$random_number"; rename($copy_file_name,$new_copy_file_name); unlink($copy_file_name); $already_upgraded = 1; } $copy_status = &make_file_copy($gblackout_dates_file, $copy_file_name); if ($copy_status == 0) { $errs++; &log_info($gupgrade_log_file,"Blackout-Dates File Copy Error - $gblackout_dates_file could not be backed up. Blackout-dates file was not upgraded."); } else { &log_info($gupgrade_log_file,"Upgrade blackout-dates file beginning."); $open_status = open(BLACKOUT_DATES_FILE, $gblackout_dates_file); if ($open_status == 0) { $errs++; &log_info($gupgrade_log_file,"Blackout Dates File Read Error - $gblackout_dates_file could not be read. Blackout dates file was not upgraded."); } else { @blackout_data_lines = ; close(BLACKOUT_DATES_FILE); open(NEW_BLACKOUT_DATES_FILE,">$gblackout_dates_temp_file") || &return_error("Blackout Dates File Upgrade Error","Unable to create " . $gblackout_dates_temp_file . ". Upgrade aborted."); $resource_name = ""; for ($i=0; $i <= $#blackout_data_lines; $i++) { @blackout_value_pairs = split (/\|/, $blackout_data_lines[$i]); $resource_name = $blackout_value_pairs[0]; if (($already_upgraded == 1) && (int($resource_name))) { print NEW_BLACKOUT_DATES_FILE $blackout_data_lines[$i]; } else { if ($blackout_data_lines[$i] =~ /\S/) { $key = &get_resource_key($resource_name); if (int($key) > 0) { print NEW_BLACKOUT_DATES_FILE $key . "|"; for ($j=1; $j < $#blackout_value_pairs; $j++) { print NEW_BLACKOUT_DATES_FILE $blackout_value_pairs[$j] . "|"; } print NEW_BLACKOUT_DATES_FILE $blackout_value_pairs[$j]; } else { if ((int($resource_name)) && (-e $gresource_file)) { print NEW_BLACKOUT_DATES_FILE $blackout_data_lines[$i]; } else { $errs++; $debug_detail = ""; $debug_detail = chomp($blackout_data_lines[$i]); &log_info($gupgrade_log_file,"Blackout Dates Resource Not Found. Blackout Date for " . $resource_name . " will be orphaned."); &log_info($gupgrade_log_file,"-->Orphaned data detail: $debug_detail"); } } } } } close(NEW_BLACKOUT_DATES_FILE); unlink($gblackout_dates_file); rename($gblackout_dates_temp_file,$gblackout_dates_file); chmod(0777, $gblackout_dates_file); &log_info($gupgrade_log_file,"Blackout-dates file was upgraded."); &log_info($ADMIN,"Blackout-dates file was upgraded by $username."); } } return $errs; } sub upgrade_authorized_users { local ($week_name, $current_week, @files, $file, $number_of_files, $resource_name, $key, $i, $j, $k, $admin_defined_flag, $all_resources_string, $already_upgraded, $resource, $debug_detail, @resources, @auth_resource_value_pairs, @resource_lines, @user_data_lines, @user_value_pairs, @resource_value_pairs, $routine_name, $errs); &validate_referral_page($script_url); $routine_name = "UPGRADE_AUTHORIZED_USERS"; $errs = 0; $already_upgraded = 0; if (!(-e $gauthorized_users_file)) { if (!(open(NEW_USERS_FILE, ">" . $gauthorized_users_file))) { &log_info($gupgrade_log_file,"Unable to create " . $gauthorized_users_file . ". Resolve folder permissions, then rerun upgrade."); return 1; } $all_resources_string = ""; $notfirst = 0; @resources = &get_resource_file_all_records(); foreach $resource (@resources) { @resource_value_pairs = split (/\|/, $resource); if ($notfirst) { $all_resources_string .= "?"; } else { $notfirst = 1; } $all_resources_string .= $resource_value_pairs[0]; } print NEW_USERS_FILE $gen_admin_login_password . "|" . $gen_admin_login_password . "|SYSTEM ADMIN|" . $all_resources_string . "|" . $SYSTEM_ADMIN . "|\n"; return 0; } $copy_file_name = $gauthorized_users_file . ".bak"; if (-e $copy_file_name) { srand(time|$$); $random_number = int(rand(10000000)); $new_copy_file_name = $gauthorized_users_file . ".$random_number"; rename($copy_file_name,$new_copy_file_name); unlink($copy_file_name); $already_upgraded = 1; } $copy_file_name = $gauthorized_users_file . ".bak"; $copy_status = &make_file_copy($gauthorized_users_file, $copy_file_name); if ($copy_status == 0) { $errs++; &log_info($gupgrade_log_file,"Authorized Users file could not be backed up. Authorized users were not upgraded."); } else { $open_status = open(USERS_FILE, $gauthorized_users_file); if ($open_status == 0) { $errs++; &log_info($gupgrade_log_file,"Authorized Users file could not be read. Authorized users were not upgraded."); } else { &log_info($gupgrade_log_file,"Upgrade authorized-users file beginning."); @user_data_lines = ; close(USERS_FILE); open(NEW_USERS_FILE,">$gauthorized_users_temp_file") || &return_error("Authorized Users File Upgrade Error","Unable to create " . $gauthorized_users_temp_file . ". Upgrade aborted."); $resource_name = ""; $new_user_line = ""; $auth_resources_string = ""; $admin_defined_flag = 0; for ($i=0; $i <= $#user_data_lines; $i++) { if ($user_data_lines[$i] =~ /\S/) { @user_value_pairs = split (/\|/, $user_data_lines[$i]); if (int($user_value_pairs[4]) == $SYSTEM_ADMIN) { next; } if (($user_value_pairs[0] eq $gen_admin_login_password) && ($user_value_pairs[1] eq $gen_admin_login_password)) { $admin_defined_flag = 1; } $new_user_line = $user_value_pairs[0] . "|" . $user_value_pairs[1] . "|" . $user_value_pairs[2] . "|"; $auth_resources = $user_value_pairs[3]; $auth_resources_string = ""; @auth_resource_value_pairs = split (/\?/, $auth_resources); for ($j=0; $j < $#auth_resource_value_pairs; $j++) { $resource_name = $auth_resource_value_pairs[$j]; if (($already_upgraded == 1) && (int($resource_name))) { $auth_resources_string .= $resource_name . "?"; } else { $key = &get_resource_key($resource_name); if (int($key) > 0) { $auth_resources_string .= $key . "?"; } else { $errs++; $auth_resources_string .= $resource_name . "?"; $debug_detail = ""; $debug_detail = chomp($user_data_lines[$i]); &log_info($gupgrade_log_file,"Authorized User resource named $resource_name was not found. Permission to use " . $resource_name . " will be obsolete."); &log_info($gupgrade_log_file,"-->Orphaned data detail: $debug_detail"); } } } print NEW_USERS_FILE $new_user_line . $auth_resources_string; print NEW_USERS_FILE "|" . $GEN_USER . "||\n"; # default everyone to general user AND EMPTY EMAIL } } # end for if ($admin_defined_flag == 0) { $all_resources_string = ""; $notfirst = 0; @resources = &get_resource_file_all_records(); foreach $resource (@resources) { @resource_value_pairs = split (/\|/, $resource); if ($notfirst) { $all_resources_string .= "?"; } else { $notfirst = 1; } $all_resources_string .= $resource_value_pairs[0]; } print NEW_USERS_FILE $gen_admin_login_password . "|" . $gen_admin_login_password . "|SYSTEM ADMIN|" . $all_resources_string . "|" . $SYSTEM_ADMIN . "|\n"; } close(NEW_USERS_FILE); unlink($gauthorized_users_file); rename($gauthorized_users_temp_file,$gauthorized_users_file); chmod(0777, $gauthorized_users_temp_file); &log_info($gupgrade_log_file,"Authorized-users file was upgraded."); &log_info($ADMIN,"Authorized-users file was upgraded by $username."); } } return $errs; } sub upgrade_reservation_files { local ($week_name, $current_week, @files, $file, $number_of_files, $resource_name, $key, $i, $j, $k, $debug_detail, $logdata, @resource_value_pairs, @reservation_file_lines, @resource_lines, @reservation_file_value_pairs, $routine_name, $errs); &validate_referral_page($script_url); $errs = 0; $routine_name = "UPGRADE_RESERVATION_FILES"; if (opendir(DATA_DIR,$data_directory)) { &log_info($gupgrade_log_file,"Upgrade reservation data files beginning."); @files = readdir(DATA_DIR); closedir(DATA_DIR); foreach $file (@files) { if (($file =~ /.txt$/) && (length($file) == 14)) { $full_file_name = $data_directory . $file; $copy_file_name = $full_file_name . ".bak"; $copy_status = &make_file_copy($full_file_name, $copy_file_name); if ($copy_status == 0) { } else { $open_status = open(RESERVATION_FILE, $full_file_name); if ($open_status == 0) { &return_error("Reservation File Read Error","$full_file_name could not be read. Upgrade aborted."); } else { @reservation_file_lines = ; close(RESERVATION_FILE); $new_file = $full_file_name . ".new"; open(NEW_RESERVATION_FILE,">$new_file") || &return_error("Reservation Data File Upgrade Error","Unable to create " . $new_file . ". Upgrade aborted."); for ($i=0; $i <= $#reservation_file_lines; $i++) { if (!($reservation_file_lines[$i] =~ /^#/)) { @reservation_file_value_pairs = split (/\|/, $reservation_file_lines[$i]); if ($#reservation_file_value_pairs > 1) { $resource_name = ""; $resource_name = $reservation_file_value_pairs[0]; $key = &get_resource_key($resource_name); if (int($key) > 0) { print NEW_RESERVATION_FILE $key; } else { print NEW_RESERVATION_FILE $resource_name; $errs++; $debug_detail = ""; $debug_detail = chomp($reservation_file_lines[$i]); &log_info($gupgrade_log_file,"Reservation resource called $resource_name was not found. Reservations for " . $resource_name . " will be orphaned."); &log_info($gupgrade_log_file,"-->Orphaned data detail: $debug_detail"); } print NEW_RESERVATION_FILE "|"; $y = 1; for ($k=1; $k <= $#reservation_file_value_pairs; $k++) { print NEW_RESERVATION_FILE $reservation_file_value_pairs[$k]; print NEW_RESERVATION_FILE "|"; $y++; if ($y == 7) { $k++; $last_resv_field = $reservation_file_value_pairs[$k]; $last_resv_field =~ s/\n//g; $last_resv_field =~ s/\r//g; print NEW_RESERVATION_FILE ($last_resv_field); $y = 1; chomp($reservation_file_value_pairs[$k]); $logdata = ""; $logdata = "|" . $reservation_file_value_pairs[$k-6] . "|" . $reservation_file_value_pairs[$k-5] . "|" . $reservation_file_value_pairs[$k-4] . "|" . $reservation_file_value_pairs[$k-3] . "|" . $reservation_file_value_pairs[$k-2] . "|" . $reservation_file_value_pairs[$k-1] . "|" . $reservation_file_value_pairs[$k] . "|"; &log_info($gupgrade_log_file,"-->Processed $full_file_name $resource_name reservation fields $logdata"); for ($z=7; $z <= 25; $z++) { print NEW_RESERVATION_FILE "|"; } } } print NEW_RESERVATION_FILE "\n"; } } else { print NEW_RESERVATION_FILE $reservation_file_lines[$i]; } } # end for ($i=0; ... close(NEW_RESERVATION_FILE); unlink($full_file_name); rename($new_file,$full_file_name); chmod(0777, $full_file_name); } # end else if open_status } # end else file already upgraded } # end if (($file =~ /.txt$/) && (length($file) == 14)) } # end foreach &log_info($gupgrade_log_file,"Reservation data files were upgraded."); &log_info($ADMIN,"Reservation data files were upgraded by $username."); } else { $errs++; &log_info($gupgrade_log_file,"Unable to upgrade reservation files. Unable to open data directory " . $data_directory); } return $errs; } sub upgrade_reservation_fields_file { if (!(-e $reservation_fields_file)) { if (!(open(FIELDS_FILE, ">" . $reservation_fields_file))) { &log_info($gupgrade_log_file,"Unable to create " . $reservation_fields_file . ". Resolve folder permissions, then rerun upgrade."); return 1; } print FIELDS_FILE "FIELD01_NAME\n"; print FIELDS_FILE $settings[45] . "\n"; print FIELDS_FILE "TEXT\n"; print FIELDS_FILE "\n"; print FIELDS_FILE "STANDARD\n"; print FIELDS_FILE "on\n"; print FIELDS_FILE "FIELD02_NAME\n"; print FIELDS_FILE $settings[46] . "\n"; print FIELDS_FILE "TEXT\n"; print FIELDS_FILE "\n"; print FIELDS_FILE "STANDARD\n"; print FIELDS_FILE "on\n"; print FIELDS_FILE "FIELD03_NAME\n"; print FIELDS_FILE $settings[47] . "\n"; print FIELDS_FILE "TEXT\n"; print FIELDS_FILE "\n"; print FIELDS_FILE "STANDARD\n"; print FIELDS_FILE "on\n"; print FIELDS_FILE "FIELD04_NAME\n"; print FIELDS_FILE $settings[48] . "\n"; print FIELDS_FILE "TEXT\n"; print FIELDS_FILE "\n"; print FIELDS_FILE "STANDARD\n"; print FIELDS_FILE "on\n"; close(FIELDS_FILE); } return 0; } sub upgrade_settings_file { local ( $idx, $copy_file_name, $copy_status, $open_status, $random_number, $temp_file, $errs); $errs = 0; if (-e $settings_file) { $copy_file_name = $settings_file . ".bak"; $copy_status = &make_file_copy($settings_file, $copy_file_name); if ($copy_status == 0) { $errs++; &log_info($gupgrade_log_file,"General Settings file could not be backed up. General Settings file was not upgraded."); } else { $open_status = open(SETTINGS_FILE, $settings_file); if ($open_status == 0) { $errs++; &log_info($gupgrade_log_file,"General Settings file could not be read. General Settings file was not upgraded."); } else { @settings = ; close(SETTINGS_FILE); for ($idx = 0; $idx <= $#settings; $idx++) { chop($settings[$idx]); } if (!($settings[94] =~ /\S/)) { $settings[94] = ""; } $settings[95] = "NO"; # default to showing admin hyperlink on schedule $settings[96] = "NO"; # NOT IMPLEMENTED $settings[97] = "STANDARD"; # reservation frequency $settings[98] = "From:"; # reservation start time label $settings[99] = "To:"; # reservation end time label $settings[100] = "During:"; # reservation fixed time label $settings[101] = "Number of Nights:"; # daily label $settings[102] = "Start Date:"; # date range start label $settings[103] = "End Date:"; # date range end label $settings[104] = "Start Date:"; # NOT IMPLEMENTED $settings[105] = "Start Time:"; # NOT IMPLEMENTED $settings[106] = "End Date:"; # NOT IMPLEMENTED $settings[107] = "End Time:"; # NOT IMPLEMENTED $settings[108] = "FIXED"; # recurring reservation format, freeform or fixed $settings[109] = "on"; # daily recurring options enabled $settings[110] = 2; # min daily recurring $settings[111] = 14; # max daily recurring $settings[112] = "on"; # weekly recurring options enabled $settings[113] = 2; # min weekly recurring $settings[114] = 16; # max weekly recurring $settings[115] = "on"; # biweekly recurring options enabled $settings[116] = 2; # min biweekly recurring $settings[117] = 16; # max biweekly recurring $settings[118] = "on"; # monthly recurring options enabled $settings[119] = 2; # min monthly recurring $settings[120] = 12; # max monthly recurring $settings[121] = "YES"; # passed timeslot check $settings[122] = "toggle"; # show toggle schedule view hyperlink $settings[123] = "top"; # show toggle hyperlink at the top $settings[124] = "right"; # show toggle hyperlink at the right $settings[125] = "top"; # show admin control panel hyperlink at the top $settings[126] = "right"; # show admin control panel hyperlink at the right $settings[127] = "NO"; # password protect the entire calendar $settings[128] = "NO"; # disable illegal referrer check $settings[129] = "YES"; # allow admin to override the expired timeslot check $settings[130] = "NO"; # NOT IMPLEMENTED $settings[131] = "1"; # option for specifying how categories are shown 1=dont use, 2=menu 3=all $settings[132] = "Verdana,Arial,Helvetica"; # category menu font face $settings[133] = "2"; # category menu font size $settings[134] = "#000000"; # category menu font color $settings[135] = "YES"; # allow admin or resource admin to add/edit/del resv during lockout $settings[136] = "#000000"; # category divider line color, defaults to black $settings[137] = "#FFFFFF"; # category divider line font color $settings[138] = "Verdana,Arial,Helvitica"; # category divider line font face $settings[139] = "2"; # category divider line font size $settings[140] = "0"; # timezone adjustment factor $settings[141] = "Pending Reservation Accepted"; # admin email subject for pending reservation authorized $settings[142] = "Pending Reservation Rejected"; # admin email subject for pending reservation rejected $settings[143] = "Pending Reservation Accepted"; # user email subject for pending reservation authorized $settings[144] = "Pending Reservation Rejected"; # user email subject for pending reservation rejected $settings[145] = "YES"; # show navigation bar $settings[146] = "bottom"; # show navigation bar at the bottom $settings[147] = "center"; # show navigation bar in the center $settings[148] = "off"; # force password to be required when not using auth users $settings[149] = "YES"; # show category menu hyperlink $settings[150] = "YES"; # allow auth users to modify their own password srand(time|$$); $random_number = int(rand(10000000)); $temp_file = $data_directory . "settings" . $random_number . ".tmp"; if (!(open(TEMP_DATA_FILE, ">" . $temp_file))) { &log_info($gupgrade_log_file,"Unable to create " . $temp_file . ". Resolve folder permissions, then rerun upgrade."); return 1; } else { for ($idx = 0; $idx <= 147; $idx++) { print TEMP_DATA_FILE $settings[$idx] . "\n"; } close(TEMP_DATA_FILE); unlink($settings_file); rename($temp_file,$settings_file); chmod(0777, $settings_file); } } } } # end if gen settings file already exists return $errs; } sub create_purge_form { local ($message) = @_; local ($week_name, $current_week, @files, $file, $number_of_files, $temp_file_date, $file_date); &validate_referral_page($script_url); $resource_admin_access = 0; $reports_admin_access = 0; &validate_admin($username, $password, $resource_admin_access, $reports_admin_access); &analyze_seconds(time); $week_name = &get_week_name($g_seconds); # in the form MM-DD-YYYY $current_week = &make_US_date_YYYYMMDD($week_name); # must pass US format date $number_of_files = 0; if (opendir(DATA_DIR,$data_directory)) { @files = readdir(DATA_DIR); closedir(DATA_DIR); foreach $file (@files) { $temp_file_date = substr($file,0,10); # MM-DD-YYYY $file_date = &make_US_date_YYYYMMDD($temp_file_date); # must pass US format date if (($file =~ /.txt$/) && (length($file) == 14) && ($file_date lt $current_week)) { $number_of_files++; } } } else { &return_error("Misconfiguration Error","Unable to open directory " . $data_directory); } print "Content-type: text/html\n\n"; print "\n"; print "\n"; print "\n\n"; print "uReserve"; print ""; print "
"; print ""; print ""; if (($message =~ /\S/) && ($message ne "NONE")) { print ""; } print ""; print ""; print ""; print "
"; print ""; print "$lang_purge

"; print "
"; print "
"; print ""; print "$message"; print "
"; print ""; print ""; print ""; print "
"; print "$lang_purge_instructions"; print "
"; print "
"; print ""; print ""; print "
"; print "
"; print ""; print ""; print "
"; print ""; print "


"; print "There are currently $number_of_files old reservation data files "; print "on your server that can be purged."; print "




"; print "
"; print "
"; print "
"; print ""; print ""; print ""; print ""; print "
"; print ""; print ""; print ""; print ""; print "
"; print ""; print ""; print ""; print ""; print "
"; print "
"; print "
"; print "
"; print ""; exit; } sub purge_data { local ($week_name, $current_week, @files, $file, $number_of_files, $file_date, $temp_file_date); &validate_referral_page($script_url); &analyze_seconds(time); $week_name = &get_week_name($g_seconds); # in the form MM-DD-YYYY $current_week = &make_US_date_YYYYMMDD($week_name); # must pass US format date $number_of_files = 0; if (opendir(DATA_DIR,$data_directory)) { @files = readdir(DATA_DIR); closedir(DATA_DIR); foreach $file (@files) { $temp_file_date = substr($file,0,10); # MM-DD-YYYY $file_date = &make_US_date_YYYYMMDD($temp_file_date); # must pass US format date if (($file =~ /.txt$/) && (length($file) == 14) && ($file_date lt $current_week)) { unlink($data_directory . $file); $number_of_files++; } } } else { &return_error("Misconfiguration Error","Unable to open directory " . $data_directory); } if ($number_of_files > 0) { &log_info($ADMIN,"$number_of_files reservation data files were purged by $username."); &create_purge_form("$number_of_files reservation data files were purged."); } else { &create_purge_form("The were no old reservation data files to purge."); } } sub send_email_notifications { local ( $msg, $resource_key, $user_email, $mode, $pending_note) = @_; local ( $admin_email_subject, $user_email_subject, $resource_settings, $pending_flag, $special_email_text, $pending_email_text, $from_name, $email_out, @resource_value_pairs, @resource_admin_emails); &validate_referral_page($script_url); $resource_name = &get_resource_name($resource_key); if ($settings[4] =~ /YES/i) { if ($user_email =~ /\@/) { } else { $user_email = $settings[2]; } } else { $user_email = $settings[2]; } $resource_settings = &get_resource_settings($resource_key); @resource_value_pairs = split (/\|/, $resource_settings); if ($mode eq "ADD") { $pending_flag = &get_pending_flag(@resource_value_pairs); if ($pending_flag =~ /on/i) { $admin_email_subject = $settings[78]; # subject for reservation pending $user_email_subject = $settings[79]; $pending_email_text = &get_pending_email_text(@resource_value_pairs); $msg .= $pending_email_text; } else { $admin_email_subject = $settings[11]; #default subject for reservation creation $user_email_subject = $settings[12]; $special_email_text = &get_resource_email_text(@resource_value_pairs); $msg .= $special_email_text; } } elsif ($mode eq "MOD") { $admin_email_subject = $settings[69]; # subject for reservation modification $user_email_subject = $settings[71]; $special_email_text = &get_resource_email_text(@resource_value_pairs); $msg .= $special_email_text; } elsif ($mode eq "AUTH") { $admin_email_subject = $settings[141]; # admin email subject for pending reservation approved $user_email_subject = $settings[143]; # user email subject for pending reservation approved $special_email_text = &get_resource_email_text(@resource_value_pairs); $msg .= $special_email_text; if ($pending_note =~ /\S/) { $msg .= "\n\n$pending_note"; } } elsif ($mode eq "REJ") { $admin_email_subject = $settings[142]; # admin email subject for pending reservation rejected $user_email_subject = $settings[144]; # user email subject for pending reservation rejected if ($pending_note =~ /\S/) { $msg .= "\n\n$pending_note"; } } elsif ($mode eq "DEL") { $admin_email_subject = $settings[70]; # subject for reservation cancellation $user_email_subject = $settings[72]; } if ($settings[2] =~ /\@/) { if ($user_email =~ /\@/) { } else { $user_email = $settings[2]; } if ($settings[13] =~ /SENDMAIL/i) { &send_mail($user_email,$settings[2],$admin_email_subject,$msg); } elsif ($settings[13] =~ /SOCKETS/i) { &send_mail_sockets($user_email,$settings[2],$admin_email_subject,$msg); } elsif ($settings[13] =~ /CUSTOM/i) { &custom_email_method($user_email,$settings[2],$admin_email_subject,$msg); } } if ($settings[3] =~ /\@/) { if ($user_email =~ /\@/) { } else { $user_email = $settings[3]; } if ($settings[13] =~ /SENDMAIL/i) { &send_mail($user_email,$settings[3],$admin_email_subject,$msg); } elsif ($settings[13] =~ /SOCKETS/i) { &send_mail_sockets($user_email,$settings[3],$admin_email_subject,$msg); } elsif ($settings[13] =~ /CUSTOM/i) { &custom_email_method($user_email,$settings[3],$admin_email_subject,$msg); } } @resource_admin_emails = &get_resource_admin_emails($resource_key); if ($#resource_admin_emails >= 0) { foreach $resource_admin_email (@resource_admin_emails) { if ($user_email =~ /\@/) { } else { $user_email = $resource_admin_email; } if ($settings[13] =~ /SENDMAIL/i) { &send_mail($user_email,$resource_admin_email,$admin_email_subject,$msg); } elsif ($settings[13] =~ /SOCKETS/i) { &send_mail_sockets($user_email,$resource_admin_email,$admin_email_subject,$msg); } elsif ($settings[13] =~ /CUSTOM/i) { &custom_email_method($user_email,$resource_admin_email,$user_email_subject,$msg); } } } if (($settings[4] =~ /YES/i) && ($user_email =~ /\@/)) { $from_name = $settings[2]; if (!($from_name =~ /\@/)) # if a primary admin was not specified, try the resource admin { $from_name = &get_resource_admin_emails(@resource_value_pairs); if (!($from_name =~ /\@/)) # if a resource admin was not specified, try the secondary admin { $from_name = $settings[3]; if (!($from_name =~ /\@/)) # if a resource admin was not specified, try the secondary admin { $from_name = "Reservation System"; # force from name } } } $email_out = &validate_email($user_email); if (($user_email ne $email_out) || (!($user_email =~ /\@/g))) { } else { if ($settings[13] =~ /SENDMAIL/i) { &send_mail($from_name,$user_email,$user_email_subject,$msg); } elsif ($settings[13] =~ /SOCKETS/i) { &send_mail_sockets($from_name,$user_email,$user_email_subject,$msg); } elsif ($settings[13] =~ /CUSTOM/i) { &custom_email_method($from_name,$user_email,$user_email_subject,$msg); } } } } sub get_resource_settings { local ($resource_key) = @_; local ( @resources, $resource_index, @key_value_pairs); if ((-e $gresource_file) || (-e $gresource_file_old)) { if (!(-e $gresource_file)) { &warn_upgrade_required(); } else { open (RESOURCE_FILE, $gresource_file) || &return_error("File Error","Unable to open " . $gresource_file); @resources = ; close(RESOURCE_FILE); for ($resource_index = 0; $resource_index <= $#resources; $resource_index++) { @key_value_pairs = split (/\|/, $resources[$resource_index]); $current_key = $key_value_pairs[0]; if (int($current_key) == int($resource_key)) { chop($resources[$resource_index]); return $resources[$resource_index]; } } } } else { &display_message("uReserve Online Resource Management System","Copyright 2000 - 2006; Microburst Technologies, Inc.


You must first define the resources being scheduled.

Log in to the Administrative Control Panel at

$script_url?command=login



"); } return ""; } # end get_resource_settings() sub get_category_settings { local ($category_key) = @_; local ( $category_index, @categories, @category_value_pairs); if ((-e $gresource_file) || (-e $gresource_file_old)) { if (!(-e $gresource_file)) { &warn_upgrade_required(); } else { open (CATEGORY_FILE, $gcategory_file) || &return_error("File Error","Unable to open " . $gcategory_file); @categories = ; close(CATEGORY_FILE); for ($category_index = 0; $category_index <= $#categories; $category_index++) { @category_value_pairs = split (/\|/, $categories[$category_index]); $current_key = $category_value_pairs[0]; if (int($current_key) == int($category_key)) { chop($categories[$category_index]); return $categories[$category_index]; } } } } else { &display_message("uReserve Online Resource Management System","Copyright 2000 - 2006; Microburst Technologies, Inc.


You must first define the resources being scheduled.

Log in to the Administrative Control Panel at

$script_url?command=login



"); } return; } # end get_category_settings() sub check_pending_field { local ($field1) = @_; local ($pending_status, @pending_value_pairs); $pending_status = 0; @pending_value_pairs = split (/\?/, $field1); if ($pending_value_pairs[1] =~ /PENDING/i) { $pending_status = 1; } else { $pending_status = 0; } return $pending_status; } sub email_report { local ($user_email, $report, $subject) = @_; if ($settings[13] =~ /SENDMAIL/i) { &send_mail($settings[2],$user_email,$subject,$report); } elsif ($settings[13] =~ /SOCKETS/i) { &send_mail_sockets($settings[2],$user_email,$subject,$report); } elsif ($settings[13] =~ /CUSTOM/i) { &custom_email_method($settings[2],$user_email,$subject,$report); } } sub display_help { local ($view_topic) = @_; local ($topic_help, $line, $current_topic, $topic_help, @key_value_pairs, $found_flag); $found_flag = 0; $topic_help = ""; if (open (HELP_FILE, $ghelp_file)) { while () { $line = $_; chop($line); @key_value_pairs = split (/\|/, $line); $current_topic = $key_value_pairs[0]; if (($found_flag == 0) && ($view_topic eq $current_topic)) { $found_flag = 1; $topic_help = $key_value_pairs[1]; } } close(HELP_FILE); } else { &return_error("File Error","Unable to open " . $ghelp_file); } if ($found_flag == 0) { &return_error("Unknown Help Topic","Unable to locate help information for this topic."); } print "Content-type: text/html\n\n"; print "\n"; print "\n"; print "\n\n"; print "uReserve Online Help"; print ""; print "
"; print ""; print "$lang_topic: $view_topic

"; print ""; print "$topic_help
"; print "


"; print "
"; print "
"; print ""; print "
"; print "
"; print "
"; print "
"; print ""; exit; } sub display_color_chart { local ($line, $color_select_html, $i, $formname, $fieldname, $strip_color, $hex_color); $formname = $form_text{'formname'}; $fieldname = $form_text{'fieldname'}; if (open (COLOR_FILE, $gcolor_file)) { $color_select_html = ""; $i = 0; while () { $line = $_; chop($line); $strip_color = $line; $hex_color = "\#" . $line; if ($i == 0) { $color_select_html .= ""; } $color_select_html .= ""; $color_select_html .= ""; $i++; if ($i == 5) { $color_select_html .= ""; $i = 0 ; } } close(COLOR_FILE); while ($i < 5) { $color_select_html .= ""; $i++; if ($i == 6) { $color_select_html .= ""; } } $color_select_html .= "
     $hex_color"; $color_select_html .= "
"; } else { &return_error("File Error","Unable to open " . $gcolor_file); } print "Content-type: text/html\n\n"; print "\n"; print "\n"; print "\n\n"; print "uReserve Online Color Chart"; print ""; print "
"; print ""; print "Browser-Safe Color Chart

"; print "
"; print "

"; print ""; print $color_select_html; print ""; print "

"; print ""; print ""; print ""; print "
"; print "
"; print "
"; print ""; exit; } sub display_font_chart { local ($line, $font_select_html, $i, $formname, $fieldname, $font_name, $font_support, @key_value_pairs); $formname = $form_text{'formname'}; $fieldname = $form_text{'fieldname'}; if (open (FONT_FILE, $gfont_file)) { $font_select_html = ""; $font_select_html = ""; while () { $line = $_; chop($line); @key_value_pairs = split (/\|/, $line); $font_name = $key_value_pairs[0]; $font_support = $key_value_pairs[1]; $font_select_html .= ""; $font_select_html .= ""; $font_select_html .= ""; $font_select_html .= ""; } close(FONT_FILE); $font_select_html .= "
Font NameBrowser Platform Support
$font_name$font_support
"; } else { &return_error("File Error","Unable to open " . $gfont_file); } print "Content-type: text/html\n\n"; print "\n"; print "\n"; print "\n\n"; print "uReserve Online Font Reference"; print ""; print ""; print "
"; print ""; print "Font Reference
"; print "

"; print ""; print $font_select_html; print ""; print "

"; print ""; print ""; print ""; print "
"; print "
"; print "
"; print ""; exit; } sub prep_days_list { local ($days_list) = @_; local ($new_days_list); $new_days_list = ""; if ($days_list =~ /1/) {$new_days_list .= "1"; } if ($days_list =~ /2/) {$new_days_list .= "2"; } if ($days_list =~ /3/) {$new_days_list .= "3"; } if ($days_list =~ /4/) {$new_days_list .= "4"; } if ($days_list =~ /5/) {$new_days_list .= "5"; } if ($days_list =~ /6/) {$new_days_list .= "6"; } if ($days_list =~ /7/) {$new_days_list .= "7"; } if ($days_list =~ /8/) {$new_days_list .= "8"; } return $new_days_list; } sub prep_resource_list { local ($resource_list) = @_; local ($new_resource_list, $temp_resource_list, $temp_resource_name, $resource_key, @resources, @key_value_pairs, $resource_index); $new_resource_list = ""; @resources = &get_resource_file_all_records(); for ($resource_index = 0; $resource_index <= $#resources; $resource_index++) { @key_value_pairs = split (/\|/, $resources[$resource_index]); $resource_key = $key_value_pairs[0]; @choices=split(/\0/,$user_resource_list); foreach $choice (@choices) { if (int($resource_key) == int($choice)) { $new_resource_list .= $resource_key . "?"; } } } return $new_resource_list; } # end sub prep_resource_list() sub print_current_date_header { local ($uname, $pword) = @_; local ($date_size, $sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst, $show_year); $date_size = $settings[86] + 1; print ""; print "
"; print ""; if (($uname =~ /\S/) && ($pword =~ /\S/) ) { print ""; } else { if ($settings[150] =~ /YES/i) { print ""; } } print "
"; print ""; ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); print "$sun_days[$wday+1] "; $show_year = $year + 1900; if ($settings[5] =~ /US/i) { print "$month_names[$mon+1] $mday, $show_year"; } else { print "$mday $month_names[$mon+1] $show_year"; } print "
"; print "$lang_logout"; if ($settings[150] =~ /YES/i) { print " | "; print "$lang_change_password"; } print "
"; print "$lang_change_password"; print "

"; return; } sub print_navigation_buttons { local ( $schedule_view, $week_name, $seconds_date, $monthly_view_flag, $resource_key, $g_mon_for_nav_buttons, $g_year_for_nav_buttons, $view_category) = @_; local ($day_of_week); if ($settings[145] =~ /NO/i) { return; } if ($settings[147] =~ /LEFT/i) { $talign = "LEFT"; } elsif ($settings[147] =~ /RIGHT/i) { $talign = "RIGHT"; } else { $talign = "CENTER"; } print "
"; print ""; $num_seconds = &get_week_seconds($week_name); if ($schedule_view =~ /DAILY/i) { $temp_seconds = $seconds_date - $SECONDS_PER_DAY; $day_of_week = &get_day_of_week($temp_seconds); if (($day_of_week == 0) && ($settings[7] =~ /NO/i)) { $temp_seconds -= ($SECONDS_PER_DAY*2); } print ""; $temp_seconds = $seconds_date + $SECONDS_PER_DAY; $day_of_week = &get_day_of_week($temp_seconds); if (($day_of_week == 6) && ($settings[7] =~ /NO/i)) { $temp_seconds += ($SECONDS_PER_DAY*2); } print ""; $seconds_date -= ($SECONDS_PER_DAY); print ""; } elsif ($schedule_view =~ /WEEKLY/i) { $num_seconds -= ($SECONDS_PER_DAY * 7); print ""; $num_seconds += ($SECONDS_PER_DAY * 14); print ""; $num_seconds -= ($SECONDS_PER_DAY * 7); print ""; } elsif ($schedule_view =~ /MONTHLY/i) { $previous_month = $g_mon_for_nav_buttons - 1; if ($previous_month == 0) { $previous_month=12; --$g_year_for_nav_buttons; } if ($settings[5] =~ /US/i) { $start_month_string = sprintf("%02d/%02d/%04d",$previous_month,1,$g_year_for_nav_buttons); } else { $start_month_string = sprintf("%02d/%02d/%04d",1,$previous_month,$g_year_for_nav_buttons); } $goto_seconds = &get_date_seconds($start_month_string); print ""; if ($previous_month == 12) { ++$g_year_for_nav_buttons; $next_month=2; } else { $next_month = $g_mon_for_nav_buttons + 1; if ($next_month == 13) { $next_month=1; # fix 12/24/2004 ++$g_year_for_nav_buttons; } } if ($settings[5] =~ /US/i) { $next_month_string = sprintf("%02d/%02d/%04d",$next_month,1,$g_year_for_nav_buttons); } else { $next_month_string = sprintf("%02d/%02d/%04d",1,$next_month,$g_year_for_nav_buttons); } $next_month_seconds = &get_date_seconds($next_month_string); print ""; print ""; } print "
"; print "
"; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print "
"; print "
"; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print "
"; print "
"; print ""; print $lang_page_date_entry; if ($settings[5] =~ /US/i) { print ""; } else { print ""; } if ($monthly_view_flag eq "1") { print ""; } else { print ""; } print ""; print ""; print ""; print ""; print ""; print ""; print "  "; print ""; print ""; print "
"; print "
"; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print "
"; print "
"; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print "
"; print "
"; print ""; print $lang_page_date_entry; if ($settings[5] =~ /US/i) { print ""; } else { print ""; } print ""; print ""; print ""; print ""; print ""; print ""; print ""; print "  "; print ""; print ""; print "
"; print "
"; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print "
"; print "
"; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print "
"; print "
"; print ""; print $page_month_entry; print ""; print ""; print ""; print ""; print ""; print ""; print "  "; print ""; print ""; print "
"; print "
"; } sub print_optional_links { local ($vposition, $category_key, $schedule_view, $view_seconds) = @_; if ($vposition =~ /MENU/i) { $vposition = "TOP"; } if ($settings[95] =~ /YES/i) { if ($vposition =~ /TOP/i) { if (($settings[125] =~ /top/i) || ($settings[125] =~ /both/i) ) { &print_admin_hyperlink(); } } elsif ($vposition =~ /BOTTOM/i) { if (($settings[125] =~ /bottom/i) || ($settings[125] =~ /both/i) ) { &print_admin_hyperlink(); } } } if ($settings[122] =~ /toggle/i) { if ($vposition =~ /TOP/i) { if (($settings[123] =~ /top/i) || ($settings[123] =~ /both/i) ) { &print_toggle_hyperlink($category_key, $schedule_view, $view_seconds); } } elsif ($vposition =~ /BOTTOM/i) { if (($settings[123] =~ /bottom/i) || ($settings[123] =~ /both/i) ) { &print_toggle_hyperlink($category_key, $schedule_view, $view_seconds); } } } else { if ((-e $gcategory_file) && ($settings[131] eq "2")) { if (!($settings[149] =~ /NO/i)) { &print_category_menu_hyperlink($view_seconds); } } } } sub print_optional_page_image { local($image_to_show) = @_; if (($image_to_show =~ /\S/) && ($image_to_show ne "NONE") && ($image_to_show =~ /^http/i)) { print "
"; print "

"; print "
"; } } sub print_optional_monthly_hyperlinks { local (@resources) = @_; local ($num_cols, $col_ct, $resource_index, @key_value_pairs, $resource_name); if ($settings[83] =~ /YES/i) { print "
"; print ""; $num_cols = $settings[84]; $col_ct = 0; for ($resource_index = 0; $resource_index <= $#resources; $resource_index++) { @key_value_pairs = split (/\|/, $resources[$resource_index]); $resource_name = $key_value_pairs[5]; if ($col_ct == 0) { print ""; } if ($col_ct < $num_cols) { print ""; $col_ct++; } if ($col_ct == $num_cols) { print ""; $col_ct=0; } } if (($col_ct < $num_cols) && ($col_ct != 0)) { while ($col_ct < $num_cols) { print ""; $col_ct++; } print ""; } print "
"; print "$resource_name
 
"; print "
"; print "
"; } return; } sub print_admin_hyperlink { print "
"; print ""; print "
"; print ""; print "Administrator"; print "

"; return; } sub print_toggle_hyperlink { local ($view_category, $schedule_view, $view_seconds) = @_; print "
"; print ""; print "
"; print ""; $show_date = &get_exact_date($view_seconds); print "Daily View"; print " | "; print "Weekly View"; print " | "; print "Monthly View"; if ((-e $gcategory_file) && ($settings[131] eq "2")) { if (!($settings[149] =~ /NO/i)) { print " | "; print "Category Menu"; } } print ""; print "

"; return; } sub print_category_menu_hyperlink { local ($view_seconds) = @_; print "
"; print ""; print "
"; print ""; print "Category Menu"; print "

"; return; } sub get_start_time_label { return $settings[98]; # i.e. From } sub get_end_time_label { return $settings[99]; # i.e. To or Until } sub get_fixed_time_label { return $settings[100]; # i.e. During } sub get_time_selections { local ( $cur_begin_time, $cur_end_time) = @_; local ( $temp_float, $float_increment, $time_selections_html, $start_time_selections, $end_time_selections, $seconds_date); if ($settings[0] eq "CONFIG") { $gtime_range_start = 0; $gtime_range_stop = $#column_names; } $start_time = $gtime_range_start; $end_time = $gtime_range_stop; $time_selections_html = ""; $start_time_selections = ""; $end_time_selections = ""; $temp_float = $start_time; $float_increment = &get_looper(); # get float increment $seconds_date = time(); while ($temp_float < $end_time) { if ($settings[0] eq "CONFIG") { $temp_string = $column_names[$temp_float]; } else { $temp_string = &format_time($temp_float); } if ( ($cur_begin_time > 0) && (&compare_eq($cur_begin_time, $temp_float)) ) { $start_time_selections .= ""; } else { $start_time_selections .= ""; } $temp_float += $float_increment; } $time_selections_html .= ""; return $time_selections_html; } sub safe_display { local ($string_name) = @_; local ($safe_string); $safe_string = quotemeta($string_name); return $safe_string; } sub get_total_columns { local ($total_columns); $gtime_range_start = &strip_letters($gtime_range_start); $gtime_range_stop = &strip_letters($gtime_range_stop); $total_columns = $gtime_range_stop - $gtime_range_start; if (($settings[0] eq "CONFIG") || ($settings[0] eq "60")) { $total_columns *= 1; # 60 min or config columns } elsif ($settings[0] eq "10") { $total_columns *= 6; # 10MIN version } elsif ($settings[0] eq "15") { $total_columns *= 4; # 15MIN version } else { $total_columns *= 2; # default to 30 minute version } $total_columns += 1; return $total_columns; } sub get_resources { local ($view_category, $view_seconds) = @_; local (@resource_lines); @resource_lines = (); if ((-e $gcategory_file) && (int($view_category) > 0) && ($settings[131] eq "2")) { @resource_lines = &get_resource_file_for_one_category($view_category, $view_seconds); } else { if ((-e $gcategory_file) && ($settings[131] eq "3")) { @resource_lines = &get_resource_file_grouped_by_category($view_seconds); } else { @resource_lines = &get_resource_file_all_records(); } } return @resource_lines; } sub get_resource_file_all_records { local (@resource_lines); @resource_lines = (); if ((-e $gresource_file) || (-e $gresource_file_old)) { if (!(-e $gresource_file)) { &warn_upgrade_required(); } else { open (RESOURCE_FILE, $gresource_file) || &return_error("File Error","Unable to open " . $gresource_file); @resource_lines = ; close(RESOURCE_FILE); } } else { &display_message("uReserve Online Resource Management System","Copyright 2000 - 2006; Microburst Technologies, Inc.


You must first define the resources being scheduled.

Log in to the Administrative Control Panel at

$script_url?command=login



"); } return @resource_lines; } sub get_resource_file_grouped_by_category { local ($view_seconds) = @_; local ( $swapped, $safety, $str1, $str2, $temp, @str1_value_pairs, @str2_value_pairs, @resource_lines ); @resource_lines = &get_resource_file_all_records(); if (-e $gcategory_file) { $swapped = 0; $safety = 0; while (($swapped == 0) && ($safety < 1000)) { $swapped = 1; for ($i=0; $i < $#resource_lines; $i++) { @str1_value_pairs = split (/\|/, $resource_lines[$i]); $str1 = $str1_value_pairs[1]; @str2_value_pairs = split (/\|/, $resource_lines[$i+1]); $str2 = $str2_value_pairs[1]; if ($str1 > $str2) { $temp = $resource_lines[$i]; $resource_lines[$i] = $resource_lines[$i+1]; $resource_lines[$i+1] = $temp; $swapped = 0; } $safety++; } } } @resource_lines = &filter_resources_by_start_end_dates($view_seconds, @resource_lines); return @resource_lines; } sub get_resource_file_for_one_category { local ($view_category_key, $view_seconds) = @_; local ( $i, $j, $line, $now_seconds, $resource_category_key, $category_start_date, $category_end_date, $category_start_seconds, $category_end_seconds, $seconds_past_midnite, $start_date, $end_date, $sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst, @resource_value_pairs, @all_resource_lines, @resource_lines, @return_resources); @resource_lines = (); @all_resource_lines = (); @resource_value_pairs = (); @return_resources = (); if ((-e $gresource_file) || (-e $gresource_file_old)) { if (!(-e $gresource_file)) { &warn_upgrade_required(); } else { open (RESOURCE_FILE, $gresource_file) || &return_error("File Error","Unable to open " . $gresource_file); $j = 0; while () { $line = $_; @resource_value_pairs = split (/\|/, $line); $resource_category_key = &get_resource_category_key(@resource_value_pairs); if (int($resource_category_key) == int($view_category_key)) { @resource_lines[$j] = $line; #@all_resource_lines[$i]; $j++; } } close(RESOURCE_FILE); } } else { &display_message("uReserve Online Resource Management System","Copyright 2000 - 2006; Microburst Technologies, Inc.


You must first define the resources being scheduled.

Log in to the Administrative Control Panel at

$script_url?command=login



"); } @return_resources = &filter_resources_by_start_end_dates($view_seconds, @resource_lines); return @return_resources; } sub filter_resources_by_start_end_dates { local ($view_seconds, @resource_lines) = @_; local ( $i, $j, $now_seconds, $category_start_date, $category_end_date, $category_start_seconds, $category_end_seconds, $seconds_past_midnite, $start_date, $end_date, $sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst, @resource_value_pairs, @return_resources); @resource_value_pairs = (); @return_resources = (); $now_seconds = $view_seconds; ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($now_seconds); $seconds_past_midnite = $sec + ($min * 60) + ($hour * 3600); $j = 0; for ($i=0; $i <= $#resource_lines; $i++) { @resource_value_pairs = split (/\|/, $resource_lines[$i]); $resource_start_date = &get_resource_start_date(@resource_value_pairs); # MM/DD/YYYY always $resource_end_date = &get_resource_end_date(@resource_value_pairs); # MM/DD/YYYY always $resource_start_seconds = 0; $resource_end_seconds = 0; if ($resource_start_date =~ /\S/) { $start_date = $resource_start_date; $start_date =~ s/\//-/g; # date must be in MM-DD-YYYY formate for get_midnite_seconds $resource_start_seconds = &get_midnite_seconds($now_seconds, $start_date, $seconds_past_midnite); if ($resource_end_date =~ /\S/) { $end_date = $resource_end_date; $end_date =~ s/\//-/g; $resource_end_seconds = &get_midnite_seconds($now_seconds, $end_date, $seconds_past_midnite); } if ($resource_start_seconds <= $now_seconds) { if ($resource_end_seconds > 0) { if ($resource_end_seconds >= $now_seconds) { $return_resources[$j] = $resource_lines[$i]; $j++; } } else { $return_resources[$j] = $resource_lines[$i]; $j++; } } } elsif ($resource_end_date =~ /\S/) { if ($resource_end_date =~ /\S/) { $end_date = $resource_end_date; $end_date =~ s/\//-/g; $resource_end_seconds = &get_midnite_seconds($now_seconds, $end_date, $seconds_past_midnite); } if ($resource_end_seconds > 0) { if ($resource_end_seconds >= $now_seconds) { $return_resources[$j] = $resource_lines[$i]; $j++; } } else { $return_resources[$j] = $resource_lines[$i]; $j++; } } else { $return_resources[$j] = $resource_lines[$i]; $j++; } } return (@return_resources); } sub get_category_file { local ($view_seconds) = @_; local ( @categories, @category_lines, @category_value_pairs, $i, $j, $now_seconds, $category_start_date, $category_end_date, $category_start_seconds, $category_end_seconds, $seconds_past_midnite, $start_date, $end_date, $sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst); @category_lines = (); @categories = (); @category_value_pairs = (); if (-e $gcategory_file) { open (CATEGORY_FILE, $gcategory_file) || &return_error("File Error","Unable to open " . $gcategory_file); @category_lines = ; close(CATEGORY_FILE); } else { &return_error("File Open Error","Could not open category file $gcategory_file"); } $now_seconds = $view_seconds; ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($now_seconds); $seconds_past_midnite = $sec + ($min * 60) + ($hour * 3600); $j = 0; for ($i=0; $i <= $#category_lines; $i++) { @category_value_pairs = split (/\|/, $category_lines[$i]); $category_start_date = $category_value_pairs[2]; # MM/DD/YYYY always $category_end_date = $category_value_pairs[3]; # MM/DD/YYYY always $category_start_seconds = 0; $category_end_seconds = 0; if ($category_start_date =~ /\S/) { $start_date = $category_start_date; $start_date =~ s/\//-/g; # date must be in MM-DD-YYYY formate for get_midnite_seconds $category_start_seconds = &get_midnite_seconds($now_seconds, $start_date, $seconds_past_midnite); if ($category_end_date =~ /\S/) { $end_date = $category_end_date; $end_date =~ s/\//-/g; $category_end_seconds = &get_midnite_seconds($now_seconds, $end_date, $seconds_past_midnite); } if ($category_start_seconds <= $now_seconds) { if ($category_end_seconds > 0) { if ($category_end_seconds >= $now_seconds) { $categories[$j] = $category_lines[$i]; $j++; } } else { $categories[$j] = $category_lines[$i]; $j++; } } } elsif ($category_end_date =~ /\S/) { if ($category_end_date =~ /\S/) { $end_date = $category_end_date; $end_date =~ s/\//-/g; $category_end_seconds = &get_midnite_seconds($now_seconds, $end_date, $seconds_past_midnite); } if ($category_end_seconds > 0) { if ($category_end_seconds >= $now_seconds) { $categories[$j] = $category_lines[$i]; $j++; } } else { $categories[$j] = $category_lines[$i]; $j++; } } else { $categories[$j] = $category_lines[$i]; $j++; } } return @categories; } sub get_reservation_data_file { local ($file_name) = @_; local (@reservation_file_lines); @reservation_file_lines = (); if (-e $file_name) { open (SCHEDULE_FILE, $file_name) || &return_error("File Error","Unable to open $file_name"); @reservation_file_lines = ; close(SCHEDULE_FILE); } return @reservation_file_lines; } sub get_reservation_data_by_resource_and_day { local ( $resource_key, $day_index, @lines) = @_; local ( $line_index, $current_line, $current_resource_key, @key_value_pairs); $current_line = ""; $line_index = 0; while ((!($lines[$line_index] =~ /^#$day_index/i)) && ($line_index <= $#lines)) { $line_index++; } while ((!($lines[$line_index] =~ /^#END/i)) && ($line_index <= $#lines)) { @key_value_pairs = split (/\|/, $lines[$line_index]); $current_resource_key = $key_value_pairs[0]; if (int($current_resource_key) == int($resource_key)) { if (&check_real_reservation($lines[$line_index])) { $current_line = $lines[$line_index]; return $current_line; } } $line_index++; } return $current_line; } sub get_reservation_data_by_resource_and_day_and_time { local ( $week_name, $day_index, $resource_key, $begin_time) = @_; local ( $file_name, $line_index, $current_line, $current_resource_key, @lines, @key_value_pairs, @cur_fields); @key_value_pairs = (); @cur_fields = (); $file_name = $data_directory . $week_name . ".txt"; @lines = &get_reservation_data_file($file_name); $current_line = ""; $line_index = 0; while ((!($lines[$line_index] =~ /^#$day_index/i)) && ($line_index <= $#lines)) { $line_index++; } while ((!($lines[$line_index] =~ /^#END/i)) && ($line_index <= $#lines)) { @key_value_pairs = split (/\|/, $lines[$line_index]); $current_resource_key = $key_value_pairs[0]; if (int($current_resource_key) == int($resource_key)) { if (&check_real_reservation($lines[$line_index])) { $current_line = $lines[$line_index]; $line_index = $#lines + 1; # force exit loop } } $line_index++; } @key_value_pairs = (); if ($current_line =~ /\S/) { @key_value_pairs = split (/\|/, $current_line); $current_key = $key_value_pairs[0]; for ($data_index = 1; $data_index < $#key_value_pairs; $data_index += 25) { @cur_fields = &get_current_fields($data_index, @key_value_pairs); $res_start_time = $cur_fields[6]; if (&compare_eq($res_start_time, $begin_time)) { $data_index = $#key_value_pairs + 1; # force exit loop } else { @cur_fields = (); } } } return @cur_fields; } sub print_title_html { local ($display_format, $weekday_index, $current_seconds, $title_color) = @_; print ""; print ""; $settings[29] = &strip_letters($settings[29]); $settings[29] += 1; print ""; $settings[29] -= 1; print " "; if ($display_format eq "D") { print "$sun_days[$weekday_index+1]"; # note: in the daily schedule, we do not care if we start on SUN or MON print ", $date_string"; } elsif ($display_format eq "W") { if ($settings[6] =~ /SUN/i) { print "$sun_days[$day_index]"; } else { print "$mon_days[$day_index]"; } print ", " . &get_exact_date($current_seconds); } print ""; print ""; print ""; print ""; return; } sub print_column_header_html { local ($title_bar_color) = @_; print ""; if (($settings[0] eq "60") || ($settings[0] eq "CONFIG")) { print ""; # 60 min version or config columns version } else { print ""; # 10, 15 or 30 min version } print ""; print ""; print "
"; print ""; print "$settings[39]"; print ""; print "
"; print ""; if ($settings[0] eq "CONFIG") { $config_header_html = &get_config_header_html(); print $config_header_html; } else { $time_header_html = &get_time_header_html(); print $time_header_html; } print ""; } sub print_header_spacer_html { local ($title_bar_color) = @_; if ($settings[0] eq "10") { print ""; for ($index = $gtime_range_start; $index < $gtime_range_stop; $index++) { print " "; print " "; print " "; # MOD 10MIN print " "; # MOD 10MIN print " "; # MOD 10MIN print " "; # MOD 10MIN } print ""; } elsif ($settings[0] eq "15") { print ""; for ($index = $gtime_range_start; $index < $gtime_range_stop; $index++) { print " "; print " "; print " "; # MOD 15MIN print " "; # MOD 15MIN } print ""; } elsif (($settings[0] eq "60") || ($settings[0] eq "CONFIG")) { } else { print ""; for ($index = $gtime_range_start; $index < $gtime_range_stop; $index++) { print " "; print " "; } print ""; } } sub print_button { local ($button_size, $button_name, $button_command) = @_; print ""; print ""; print "
"; print ""; print ""; print ""; if ($button_size eq "S") { print ""; } else { print ""; } print "
"; print ""; print ""; return; } sub create_delete_image_file_confirmation_form { local ($file_to_delete,$next_command) = @_; &validate_referral_page($script_url); print "Content-type: text/html\n\n"; print "\n"; print "\n"; print "\n\n"; print "Confirm Deletion?"; print ""; print "



"; print "
"; print ""; print "
"; print ""; print ""; print ""; print "
"; print ""; print "
Are you sure you want to delete the file
" . $file_to_delete . " ?


"; print "
"; print "
"; print ""; print ""; print ""; print ""; print ""; print ""; print "
"; print "
"; print "
"; print ""; print ""; print ""; print ""; print ""; print ""; print "
"; print "
"; print "
"; print "
"; print ""; exit; } sub create_image_file_form { local ($message) = @_; local (@files, $file, $file_selections, $number_of_files, $additional_files); &validate_referral_page($script_url); if (opendir(DATA_DIR,$default_image_dir)) { @files = readdir(DATA_DIR); closedir(DATA_DIR); } else { &return_error("Misconfiguration Error","Unable to open directory " . $default_image_dir); } $number_of_files = 0; $additional_files = 0; $file_selections = ""; print "Content-type: text/html\n\n"; print "\n"; print "\n"; print "\n\n"; print "uReserve $lang_manage_images"; print ""; print "
"; print ""; print ""; if (($message =~ /\S/) && ($message ne "NONE")) { print ""; } print ""; print ""; print ""; print ""; print "
"; print ""; print "$lang_manage_images

"; print "
"; print "
"; print ""; print "$message"; print "
"; print ""; print ""; print ""; print "
"; print "$lang_manage_images_instructions"; print "
"; print "
"; print ""; print "
"; print "Current Image Directory: " . $default_image_dir_url . "
"; print "Current Number Of Images: " . $number_of_files; print "
"; print "
"; print ""; print "
"; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print "
"; print "Upload Image To Server

"; print "
"; print "Select Image: "; print "

"; print ""; print "


"; print "
"; print "
"; print ""; print "
"; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print "
"; print "Delete Image From Server

"; print "
"; print "Select Image: "; print $file_selections ."

"; print ""; print "


"; print "
"; print "
"; print ""; print "
"; print "
"; print ""; print ""; print ""; print ""; print "
"; print "
"; print "
"; print "
"; print ""; exit; } sub upload_image_file { local ($pUploadData, $pUploadFile); $pUploadData = $form_text{'upload_data'}; $pUploadFile = $form_text{'upload_file_name'}; &validate_referral_page($script_url); if (!($pUploadFile =~ /\S/)) { &missing_input("Missing Input","You must specify a file name."); } if (!(($pUploadFile =~ /.gif$/) || ($pUploadFile =~ /.jpg$/) || ($pUploadFile =~ /.jpeg$/) || ($pUploadFile =~ /.bmp$/))) { &missing_input("Invalid File Type","The image uploader is limited to files of type .gif, .jpg, .jpeg and .bmp"); } if (length($pUploadData) > $gMax_upload_size) { &missing_input("Max Upload Size Exceeded","The file you choose to upload (" . length($pUploadData) . " bytes) is larger than the max upload allowance (" . $gMax_upload_size . " bytes)."); } elsif (length($pUploadData) < 1) { &missing_input("No File Data","The file you choose to upload has no data."); } else { open(REAL,">$default_image_dir$pUploadFile") || &return_error("File Error","Unable to upload " . $pUploadFile . ". Check the permissions on your images folder, make sure it is writable."); binmode REAL; print REAL $pUploadData; close(REAL); } &log_info($ADMIN,"The file $pUploadFile was uploaded by $username."); &create_image_file_form("The file " . $pUploadFile . " has been uploaded (" . length($pUploadData) . " bytes)"); } sub validate_email { local ($vstring) = @_; $vstring =~ s/[^-._\@A-z0-9]//g; return $vstring; } sub get_resource_key { local ($find_resource_name) = @_; local ($key, $i, $file_resource_name, $resource_value_pairs, @resource_lines); $key = -1; $open_status = open(RESOURCE_DATA_FILE, $gresource_file); if ($open_status == 0) { return $key; } else { @resource_lines = ; close(RESOURCE_DATA_FILE); for ($i=0; $i <= $#resource_lines; $i++) { @resource_value_pairs = split (/\|/, $resource_lines[$i]); $file_resource_name = $resource_value_pairs[5]; $string1 = quotemeta($file_resource_name); $string2 = quotemeta($find_resource_name); if ($string1 eq $string2) { return $resource_value_pairs[0]; } } } return $key; } sub create_view_logs_form { local ($log_file, $message) = @_; local ($i, @log_file_lines); &validate_referral_page($script_url); if (!($log_file =~ /\S/)) { $log_file = $ADMIN; # default log file to show } print "Content-type: text/html\n\n"; print "\n"; print "\n"; print "\n\n"; print "uReserve $lang_view_logs"; print ""; print "
"; print ""; print ""; if (($message =~ /\S/) && ($message ne "NONE")) { print ""; } @log_file_lines = (); if (-e $log_file) { $open_status = open(LOG_FILE, $log_file); if ($open_status == 0) { &return_error("File Error","Unable to open " . $log_file); } else { @log_file_lines = ; close(LOG_FILE); } } print ""; print ""; print ""; print "
"; print ""; print "$lang_view_logs

"; print "
"; print "
"; print ""; print "$message"; print "
"; print ""; print ""; print ""; print "
"; print ""; print "
"; print "Select log file to view:   "; print ""; print ""; print ""; print ""; print ""; print "
"; print "
"; print "
"; print "
"; print ""; print ""; print "
"; print "
"; print ""; print ""; print ""; } elsif ($#log_file_lines < 1) { print ""; print ""; } else { print ""; print ""; } print ""; print "
"; if (($log_file eq $ADMIN) && (!(-e $log_file))) { print "
"; $show_text = ""; print ""; print "
"; $show_text = "Log file is empty.\n\n\n\n\n\n\n\n\n\n\n"; print ""; print "
"; $show_text = ""; for ($i=0; $i <= $#log_file_lines; $i++) { $log_file_lines[$i] =~ s/\\n/
/g; $show_text .= $log_file_lines[$i]; } print ""; print "
"; print "
"; print "
"; print ""; print ""; print ""; print ""; print ""; print "
"; print ""; print ""; print ""; print ""; print ""; print ""; print "
"; print ""; print ""; print ""; print ""; print "
"; print "
"; print "
"; print "
"; print ""; return; } sub log_info { local ( $log_file, $message) = @_; local ($current_time,$sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst); if (($log_file eq $DEBUG) && ($gdebugmode == 0)) { return; } ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(); $year += 1900; $mon += 1; $current_time = sprintf("%02d/%02d/%04d %02d:%02d",$mon,$mday,$year,$hour,$min); if (open(LOG_FILE, ">>" . $log_file)) { print LOG_FILE $current_time . " "; print LOG_FILE $message . "\n"; close(LOG_FILE); chmod(0777, $log_file); } else { } return; } sub log_error { local ($subroutine, $message) = @_; local ($current_time,$sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst); ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(); $year += 1900; $mon += 1; $current_time = sprintf("%02d/%02d/%04d %02d:%02d",$mon,$mday,$year,$hour,$min); $log_file = $ADMIN; if (open(LOG_FILE, ">>" . $log_file)) { print LOG_FILE $current_time . " "; print LOG_FILE $subroutine . ": "; print LOG_FILE $message . "\n"; close(LOG_FILE); chmod(0777, $log_file); } else { } return; } sub create_manage_categories_form { local ($message) = @_; local ($resource_admin_access, $reports_admin_access, $user_auth); &validate_referral_page($script_url); $resource_admin_access = 0; $reports_admin_access = 0; &validate_admin($username, $password, $resource_admin_access, $reports_admin_access); $user_auth = &get_user_group($username, $password); $user_auth = int($user_auth); print "Content-type: text/html\n\n"; print "\n"; print "\n"; print "\n\n"; print "uReserve"; print ""; print "



"; print "
"; print ""; print "

"; print ""; print "
"; print "
"; print ""; print "$lang_manage_categories

"; print "
"; print ""; if (($message =~ /\S/) && ($message ne "NONE")) { print $message; } else { print $lang_manage_categories_text; } print ""; print "
"; print "
"; print "
"; print ""; if ($user_auth == $SYSTEM_ADMIN) { &print_button('M',"$lang_mc_add_category", "mc_add_category", $password, $username); &print_button('M',"$lang_mc_edit_category", "mc_edit_category", $password, $username); &print_button('M',"$lang_mc_delete_category", "mc_delete_category", $password, $username); &print_button('M',"$lang_mc_copy_category", "mc_copy_category", $password, $username); &print_button('M',"$lang_mc_reorder_categories", "mc_reorder_categories", $password, $username); &print_button('M',"$lang_mc_categorize_resources", "mc_categorize_resources", $password, $username); } &print_button('M',"$lang_goto_schedule", "cp_view_schedule", $password, $username); &print_button('M',"$lang_back", "login", $password, $username); print "
"; print "
"; print "
"; print ""; exit; } sub create_add_edit_category_form { local ($mode) = @_; local ($category_name, $category_start_date, $category_end_date, $category_description, $category_image, $category_background_color, $category_font_color, $category_font_face, $category_font_size, $category_key, $line, @key_value_pairs, $found_flag); &validate_referral_page($script_url); $found_flag = 0; $category_name = ""; $category_start_date = ""; $category_end_date = ""; $category_description = ""; $category_image = ""; $category_background_color = ""; $category_font_color = ""; $category_font_face = ""; $category_font_size = ""; if (($mode eq "EDIT") || ($mode eq "COPY")) { $category_key = $form_text{'category_key'}; if (open (CATEGORY_FILE, $gcategory_file)) { while () { $line = $_; chop($line); # remove the carriage return from the line read from the file @key_value_pairs = split (/\|/, $line); $current_key = $key_value_pairs[0]; if (($found_flag == 0) && ($current_key == $category_key)) { $category_name = $key_value_pairs[1]; $category_start_date = $key_value_pairs[2]; $category_end_date = $key_value_pairs[3]; $category_description = $key_value_pairs[4]; $category_description =~ s/\/\n/g; $category_image = $key_value_pairs[5]; $category_background_color = $key_value_pairs[6]; $category_font_color = $key_value_pairs[7]; $category_font_face = $key_value_pairs[8]; $category_font_size = $key_value_pairs[9]; $category_display_format = $key_value_pairs[10]; $found_flag = 1; } } close(CATEGORY_FILE); } else { &return_error("File Error","Unable to open " . $gcategory_file); } } print "Content-type: text/html\n\n"; print "\n"; print "\n"; print "\n\n"; print "uReserve"; print ""; print "


"; print "
"; print ""; if ($mode eq "EDIT") { print "Edit Category Form

"; } elsif ($mode eq "COPY") { print "Copy Category Form

"; } else { print "Add Category Form

"; } print "
"; print "
"; print ""; print "
"; print ""; print ""; if ($mode eq "EDIT") { print ""; print ""; } elsif ($mode eq "COPY") { print ""; print ""; } else { print ""; } print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; $ghelp_file_key_string = "categorydaterange"; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; $ghelp_file_key_string = "displayformat"; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print "

Category Name:
Optional Availability Date Range: "; if ($settings[5] =~ /US/i) { print "MM/DD/YYYY"; } else { print "DD/MM/YYYY"; } print " to "; print ""; if ($settings[5] =~ /US/i) { print "MM/DD/YY"; } else { print "DD/MM/YY"; } print "$lang_cat_date_range_info  "; print "$lang_help_string"; print "
Category Description:
Category Image:
Category Background Color: "; print " $lang_color_chart"; print "
Category Font Color: "; print " $lang_color_chart"; print "
Category Font Face: "; print " $lang_font_chart"; print "
Category Font Size:
Category Default Display Format: $lang_display_format_info  "; print "$lang_help_string"; print "
"; print "
"; print ""; print ""; print ""; print "
"; print "
"; print "
"; print "


"; print ""; exit; } sub add_new_category { local ($category_name, $category_start_date, $category_end_date, $category_description, $category_image, $category_background_color, $category_font_color, $category_font_face, $category_font_size, $category_display_format, $category_key, $line, $found_flag, $random_number, $temp_file); &validate_referral_page($script_url); $category_name = $form_text{'category_name'}; $category_start_date = $form_text{'category_start_date'}; $category_end_date = $form_text{'category_end_date'}; $category_description = $form_text{'category_description'}; $category_image = $form_text{'category_image'}; $category_background_color = $form_text{'category_background_color'}; $category_font_color = $form_text{'category_font_color'}; $category_font_face = $form_text{'category_font_face'}; $category_font_size = $form_text{'category_font_size'}; $category_display_format = $form_text{'category_display_format'}; if ($category_start_date =~ /\S/) { $start_seconds = &get_date_seconds($category_start_date); } if ($category_end_date =~ /\S/) { $end_seconds = &get_date_seconds($category_end_date); } if (($category_start_date =~ /\S/) && ($category_end_date =~ /\S/)) { if ($end_seconds <= $start_seconds) { &missing_input("Configuration Error", "Select an End Date that is later than the Start Date."); } } $category_name = &validate_string($category_name); $category_description = &validate_string($category_description); $category_image = &validate_string($category_image); $category_background_color = &validate_string($category_background_color); $category_font_color = &validate_string($category_font_color); $category_font_face = &validate_string($category_font_face); $category_font_size = &validate_string($category_font_size); if (!($category_name =~ /\S/)) { &missing_input("Missing Input","Please enter the Category Name."); } if (&check_duplicate_category_name($category_name) == 1) { &missing_input("Duplicate Category","Please enter a unique Category Name."); } &add_category($category_name, $category_start_date, $category_end_date, $category_description, $category_image, $category_background_color, $category_font_color, $category_font_face, $category_font_size, $category_display_format); &log_info($ADMIN,"$category_name was ADDED by $username."); &create_manage_categories_form("$category_name was added."); } sub create_category_selection_form { local ($next_command) = @_; local ($category_options); $num_categories = 0; $num_categories = &get_num_categories(); if ($num_categories == 0) { &create_manage_categories_form("There are no categories defined yet."); } $category_options = &get_category_selections("NONE"); print "Content-type: text/html\n\n"; print "\n"; print "\n"; print "\n\n"; print "uReserve"; print ""; print "




"; print ""; print "
"; print ""; print ""; print ""; print ""; print "
"; print ""; if ($next_command =~ /edit/) { print "
Select Category To Edit:

"; } elsif ($next_command =~ /delete/) { print "
Select Category to Delete:
"; } elsif ($next_command =~ /copy/) { print "
Select Category to Copy:
"; } else { print "
Select Category:
"; } print "
"; print "
"; print ""; print ""; print ""; print $category_options; print "

"; print ""; print ""; print "
"; print ""; print ""; print ""; print "
"; print "
"; print "
"; print "
"; print ""; exit; } sub get_num_categories { local ($category_selection_html, $line, @key_value_pairs, $counter); $counter = 0; if (open(CATEGORY_FILE, $gcategory_file)) { while () { $line = $_; @key_value_pairs = split (/\|/, $line); $category_key = $key_value_pairs[0]; if (int($category_key) > 0) { $counter++; } } close(CATEGORY_FILE); } return ($counter); } sub get_category_selections { local ($selected_category_key) = @_; local ($category_selection_html, $line, @key_value_pairs, $counter); $counter = 0; $category_selection_html = ""; if ($counter < 1) { $category_selection_html = "NONE"; } return ($category_selection_html); } sub edit_category { local ($category_name, $category_start_date, $category_end_date, $category_description, $category_image, $category_background_color, $category_font_color, $category_font_face, $category_font_size, $category_display_category, $line, @key_value_pairs, $random_number, $temp_file, $category_key); &validate_referral_page($script_url); $category_key = $form_text{'category_key'}; $category_name = $form_text{'category_name'}; $category_start_date = $form_text{'category_start_date'}; $category_end_date = $form_text{'category_end_date'}; $category_description = $form_text{'category_description'}; $category_image = $form_text{'category_image'}; $category_background_color = $form_text{'category_background_color'}; $category_font_color = $form_text{'category_font_color'}; $category_font_face = $form_text{'category_font_face'}; $category_font_size = $form_text{'category_font_size'}; $category_display_format = $form_text{'category_display_format'}; if ($category_start_date =~ /\S/) { $start_seconds = &get_date_seconds($category_start_date); } if ($category_end_date =~ /\S/) { $end_seconds = &get_date_seconds($category_end_date); } if (($category_start_date =~ /\S/) && ($category_end_date =~ /\S/)) { if ($end_seconds <= $start_seconds) { &missing_input("Configuration Error", "Select an End Date that is later than the Start Date."); } } $category_name = &validate_string($category_name); $category_description = &validate_string($category_description); $category_image = &validate_string($category_image); $category_background_color = &validate_string($category_background_color); $category_font_color = &validate_string($category_font_color); $category_font_face = &validate_string($category_font_face); $category_font_size = &validate_string($category_font_size); if (!($category_name =~ /\S/)) { &missing_input("Missing Input","Please enter the Category Name."); } if ((int($category_key) > 0) && (-e $gcategory_file)) { &modify_category($category_key, $category_name, $category_start_date, $category_end_date, $category_description, $category_image, $category_background_color, $category_font_color, $category_font_face, $category_font_size, $category_display_format); &log_info($ADMIN,"$category_name was MODIFIED by $username."); } else { if (&check_duplicate_category_name($category_name) == 1) { &missing_input("Duplicate Category","Please enter a unique Category Name."); } &add_category($category_name, $category_start_date, $category_end_date, $category_description, $category_image, $category_background_color, $category_font_color, $category_font_face, $category_font_size, $category_display_format); &log_info($ADMIN,"$category_name was ADDED by $username."); } &create_manage_categories_form("$category_name has been updated."); } sub create_delete_category_confirmation_form { local ( $category_key, $category_name, $number_resources_in_category ); &validate_referral_page($script_url); $category_key = $form_text{'category_key'}; $category_name = &get_category_name($category_key); $number_resources_in_category = &get_number_resources_in_category($category_key); print "Content-type: text/html\n\n"; print "\n"; print "\n"; print "\n\n"; print "uReserve"; print ""; print "




"; print ""; print "
"; print ""; print ""; print ""; print "
"; print ""; print "
Are you sure you want to delete:
" . $category_name . " ?
"; if ($number_resources_in_category > 0) { print "

There are $number_resources_in_category resources in this category. If you proceed, these resources will no longer be in ANY category."; } print "


"; print "
"; print "
"; print ""; print ""; print ""; print ""; print ""; print ""; print "
"; print "
"; print "
"; print ""; print ""; print ""; print ""; print ""; print ""; print "
"; print "
"; print "
"; print "
"; print ""; exit; } sub copy_category { local ($category_name, $category_start_date, $category_end_date, $category_description, $category_image, $category_background_color, $category_font_color, $category_font_face, $category_font_size, $category_display_category, $line, @key_value_pairs, $random_number, $temp_file, $category_key); &validate_referral_page($script_url); $category_key = $form_text{'category_key'}; $category_name = $form_text{'category_name'}; $category_start_date = $form_text{'category_start_date'}; $category_end_date = $form_text{'category_end_date'}; $category_description = $form_text{'category_description'}; $category_image = $form_text{'category_image'}; $category_background_color = $form_text{'category_background_color'}; $category_font_color = $form_text{'category_font_color'}; $category_font_face = $form_text{'category_font_face'}; $category_font_size = $form_text{'category_font_size'}; $category_display_format = $form_text{'category_display_format'}; if ($category_start_date =~ /\S/) { $start_seconds = &get_date_seconds($category_start_date); } if ($category_end_date =~ /\S/) { $end_seconds = &get_date_seconds($category_end_date); } if (($category_start_date =~ /\S/) && ($category_end_date =~ /\S/)) { if ($end_seconds <= $start_seconds) { &missing_input("Configuration Error", "Select an End Date that is later than the Start Date."); } } $category_name = &validate_string($category_name); $category_description = &validate_string($category_description); $category_image = &validate_string($category_image); $category_background_color = &validate_string($category_background_color); $category_font_color = &validate_string($category_font_color); $category_font_face = &validate_string($category_font_face); $category_font_size = &validate_string($category_font_size); if (!($category_name =~ /\S/)) { &missing_input("Missing Input","Please enter the Category Name."); } if ((int($category_key) > 0) && (-e $gcategory_file)) { &make_category_copy( $category_name, $category_start_date, $category_end_date, $category_description, $category_image, $category_background_color, $category_font_color, $category_font_face, $category_font_size, $category_display_format); &log_info($ADMIN,"$category_name was ADDED by $username."); } else { if (&check_duplicate_category_name($category_name) == 1) { &missing_input("Duplicate Category","Please enter a unique Category Name."); } &add_category($category_name, $category_start_date, $category_end_date, $category_description, $category_image, $category_background_color, $category_font_color, $category_font_face, $category_font_size, $category_display_format); &log_info($ADMIN,"$category_name was ADDED by $username."); } &create_manage_categories_form("$category_name has been added."); } sub add_category { local ($category_name, $category_start_date, $category_end_date, $category_description, $category_image, $category_background_color, $category_font_color, $category_font_face, $category_font_size, $category_display_format) = @_; local ($line, $key, $current_key, $high_key, @key_value_pairs, $random_number, $temp_file); &validate_referral_page($script_url); if (!(-e $gcategory_file)) { open(ADD_DATA_FILE,">>$gcategory_file") || &return_error("File Error","Unable to open " . $gcategory_file); $key = 1; # the first time we add a category, give it a key id of 1 print ADD_DATA_FILE $key . "|" . $category_name . "|" . $category_start_date . "|" . $category_end_date . "|" . $category_description . "|" . $category_image . "|" . $category_background_color . "|" . $category_font_color . "|" . $category_font_face . "|" . $category_font_size . "|" . $category_display_format . "|\n"; close(ADD_DATA_FILE); chmod(0777, $gcategory_file); } else { open (ADD_DATA_FILE, $gcategory_file) || &return_error("File Error","Unable to open " . $gcategory_file); $high_key = 1; while () { $line = $_; @key_value_pairs = split (/\|/, $line); $current_key = $key_value_pairs[0]; # create a unique category key id if (int($current_key) > $high_key) { $high_key = $current_key; } } close(ADD_DATA_FILE); $key = $high_key + 1; srand(time|$$); $random_number = int(rand(10000000)); $temp_file = $data_directory . "ureserve" . $random_number . ".tmp"; open (ADD_DATA_FILE, $gcategory_file) || &return_error("File Error","Unable to open " . $gcategory_file); if (!(open(ADD_TEMP_FILE, ">" . $temp_file))) { &return_error("File Error","Unable to open " . $temp_file); } while () { $line = $_; print ADD_TEMP_FILE $line; } print ADD_TEMP_FILE $key . "|" . $category_name . "|" . $category_start_date . "|" . $category_end_date . "|" . $category_description . "|" . $category_image . "|" . $category_background_color . "|" . $category_font_color . "|" . $category_font_face . "|" . $category_font_size . "|" . $category_display_format . "|\n"; close(ADD_DATA_FILE); close(ADD_TEMP_FILE); unlink($gcategory_file); rename($temp_file,$gcategory_file); chmod(0777, $gcategory_file); } } sub modify_category { local ($category_key, $category_name, $category_start_date, $category_end_date, $category_description, $category_image, $category_background_color, $category_font_color, $category_font_face, $category_font_size, $category_display_format) = @_; local ($string1, $string2, $random_number, $temp_file, $found_flag); &validate_referral_page($script_url); srand(time|$$); $random_number = int(rand(10000000)); $temp_file = $data_directory . "ureserve" . $random_number . ".tmp"; open (EDIT_DATA_FILE, $gcategory_file) || &return_error("File Error","Unable to open " . $gcategory_file); if (!(open(EDIT_TEMP_FILE, ">" . $temp_file))) { close(EDIT_DATA_FILE); &return_error("File Error","Unable to open " . $temp_file); } $found_flag = 0; while () { $line = $_; @key_value_pairs = split (/\|/, $line); $current_key = $key_value_pairs[0]; $current_category_name = $key_value_pairs[1]; if (($found_flag == 0) && ($current_key == $category_key)) { $string1 = quotemeta($current_category_name); $string2 = quotemeta($category_name); if ($string1 ne $string2) { if (&check_duplicate_category_name($category_name) == 1) { close($temp_file); unlink($temp_file); &missing_input("Duplicate Category","Please enter a unique Category Name."); } } print EDIT_TEMP_FILE $category_key . "|" . $category_name . "|" . $category_start_date . "|" . $category_end_date . "|" . $category_description . "|" . $category_image . "|" . $category_background_color . "|" . $category_font_color . "|" . $category_font_face . "|" . $category_font_size . "|" . $category_display_format . "|\n"; $found_flag = 1; } else { print EDIT_TEMP_FILE $line; } } close(EDIT_DATA_FILE); close(EDIT_TEMP_FILE); if ($found_flag == 0) { &add_category($category_name, $category_start_date, $category_end_date, $category_description, $category_image, $category_background_color, $category_font_color, $category_font_face, $category_font_size, $category_display_format); close($temp_file); unlink($temp_file); &log_info($ADMIN,"$category_name was ADDED by $username."); } else { unlink($gcategory_file); rename($temp_file,$gcategory_file); chmod(0777, $gcategory_file); } } sub delete_category { local ($category_key) = @_; local ($line, $category_name, $current_key, @key_value_pairs, $found_flag, $num_found, $random_number, $temp_file, $number_resources_in_category); &validate_referral_page($script_url); $found_flag = 0; $category_name = &get_category_name($category_key); srand(time|$$); $random_number = int(rand(10000000)); $temp_file = $data_directory . "ureserve" . $random_number . ".tmp"; open (DEL_DATA_FILE, $gcategory_file) || &return_error("File Error","Unable to open " . $gcategory_file); if (!(open(DEL_TEMP_FILE, ">" . $temp_file))) { close(DEL_DATA_FILE); &return_error("File Error","Unable to open " . $temp_file); } while () { $line = $_; @key_value_pairs = split (/\|/, $line); $current_key = $key_value_pairs[0]; if (($found_flag == 0) && ($current_key == $category_key)) { $found_flag = 1; } else { print DEL_TEMP_FILE $line; } } close(DEL_DATA_FILE); close(DEL_TEMP_FILE); unlink($gcategory_file); rename($temp_file,$gcategory_file); chmod(0777, $gcategory_file); if ($found_flag == 1) { &log_info($ADMIN,"Category $category_name was deleted by $username."); $number_resources_in_category = &get_number_resources_in_category($category_key); if ($number_resources_in_category > 0) { $num_found = &remove_category_associated_with_resources($category_key); if ($num_found > 0) { &log_info($ADMIN,"$num_found resources were unassigned from category $category_name by $username."); } } } my ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, $atime, $mtime, $ctime, $blksize, $blocks) = stat $gcategory_file; if ($size == 0) { unlink($gcategory_file); } return $found_flag; } sub make_category_copy { local ( $category_name, $category_start_date, $category_end_date, $category_description, $category_image, $category_background_color, $category_font_color, $category_font_face, $category_font_size, $category_display_format) = @_; local ($key, $string1, $string2, $random_number, $temp_file, $found_flag); &validate_referral_page($script_url); if (&check_duplicate_category_name($category_name) == 1) { &missing_input("Duplicate Category","Please enter a unique Category Name."); } open (ADD_DATA_FILE, $gcategory_file) || &return_error("File Error","Unable to open " . $gcategory_file); $high_key = 1; while () { $line = $_; @key_value_pairs = split (/\|/, $line); $current_key = $key_value_pairs[0]; # create a unique category key id if (int($current_key) > $high_key) { $high_key = $current_key; } } close(ADD_DATA_FILE); $key = $high_key + 1; srand(time|$$); $random_number = int(rand(10000000)); $temp_file = $data_directory . "ureserve" . $random_number . ".tmp"; open (EDIT_DATA_FILE, $gcategory_file) || &return_error("File Error","Unable to open " . $gcategory_file); if (!(open(EDIT_TEMP_FILE, ">" . $temp_file))) { close(EDIT_DATA_FILE); &return_error("File Error","Unable to open " . $temp_file); } $found_flag = 0; while () { $line = $_; print EDIT_TEMP_FILE $line; } print EDIT_TEMP_FILE $key . "|" . $category_name . "|" . $category_start_date . "|" . $category_end_date . "|" . $category_description . "|" . $category_image . "|" . $category_background_color . "|" . $category_font_color . "|" . $category_font_face . "|" . $category_font_size . "|" . $category_display_format . "|\n"; close(EDIT_DATA_FILE); close(EDIT_TEMP_FILE); unlink($gcategory_file); rename($temp_file,$gcategory_file); chmod(0777, $gcategory_file); } # end make_category_copy() sub remove_category_associated_with_resources { local ($category_key) = @_; local ($random_number, $num_found, $line, $temp_file, $resource_category_key, @resource_value_pairs); $num_found = 0; if (!(-e $gresource_file)) { return $num_found; } else { srand(time|$$); $random_number = int(rand(10000000)); $temp_file = $data_directory . "ureserve" . $random_number . ".tmp"; open (EDIT_DATA_FILE, $gresource_file) || &return_error("File Error","Unable to open " . $gresource_file); my $file_handle = &open_file_for_writing($temp_file); if ($file_handle == -1) { close(EDIT_DATA_FILE); &return_error("Temp File Open Error
$temp_file","Failed to remove category from associated resources."); } else { while () { $line = $_; @resource_value_pairs = split (/\|/, $line); $resource_category_key = $resource_value_pairs[1]; if ($resource_category_key == $category_key) { $num_found++; $resource_value_pairs[1] = ""; # blank out the category key $resource_value_pairs[2] = ""; # blank out resource available start date $resource_value_pairs[3] = ""; # blank out resource available end date $resource_value_pairs[4] = ""; # blank out extra3 &write_record_to_resource_file($file_handle, @resource_value_pairs); } else { print $file_handle $line; } } # end while close(EDIT_DATA_FILE); close $file_handle; unlink($gresource_file); rename($temp_file,$gresource_file); chmod(0777, $gresource_file); } } return $num_found; } sub create_reorder_categories_form { local ($message) = @_; local ($file_name, $date_string, $current_seconds, $start_seconds, $end_seconds, $blackout_data_line, $index, $day_index, $temp_string, $blackout_date_index, $line_index, $category_name, $current_line, $data_index, $start_time, $end_time, @lines, @blackout_dates, @key_value_pairs, @categories); &validate_referral_page($script_url); $move_category = ""; $move_action = ""; $message = $form_text{'message'}; $move_category = $form_text{'category_to_move'}; $move_action = $form_text{'move_command'}; $last_move_category = $move_category; if (-e $gcategory_file) { open (CATEGORY_FILE, $gcategory_file) || &return_error("File Error","Unable to open " . $gcategory_file); @categories = ; close(CATEGORY_FILE); } else { &create_manage_categories_form("There are no categories defined yet."); } if (-e $gcategory_file_reorder) { open (TEMP_CATEGORY_FILE, $gcategory_file_reorder) || &return_error("File Error","Unable to open " . $gcategory_file_reorder); @categories = ; close(TEMP_CATEGORY_FILE); } else { if (!(open(TEMP_CATEGORY_FILE, ">" . $gcategory_file_reorder))) { &return_error("File Error","Unable to create " . $gcategory_file_reorder); } for ($category_index = 0; $category_index <= $#categories; $category_index++) { $line_to_write = $categories[$category_index]; print TEMP_CATEGORY_FILE $line_to_write; } close(TEMP_CATEGORY_FILE); } for ($category_index = 0; $category_index <= $#categories; $category_index++) { @key_value_pairs = split (/\|/, $categories[$category_index]); if (-e $gcategory_file) { $category_category_name = ""; $category_category_name = &get_category_name($key_value_pairs[0]); if ($category_category_name eq "") { $category_category_name = "Not Assigned"; } $category_array[$category_index] = $key_value_pairs[0]; } else { $category_array[$category_index] = $key_value_pairs[0]; } $full_category_array_lines[$category_index] = $categories[$category_index]; } if ($move_action eq $lang_undo_changes) { unlink($gcategory_file_reorder); open (CATEGORY_FILE, $gcategory_file) || &return_error("File Error","Unable to open " . $gcategory_file); @categories = ; close(CATEGORY_FILE); if (!(open(TEMP_CATEGORY_FILE, ">" . $gcategory_file_reorder))) { &return_error("File Error","Unable to create " . $gcategory_file_reorder); } for ($category_index = 0; $category_index <= $#categories; $category_index++) { $line_to_write = $categories[$category_index]; print TEMP_CATEGORY_FILE $line_to_write; } close(TEMP_CATEGORY_FILE); for ($category_index = 0; $category_index <= $#categories; $category_index++) { @key_value_pairs = split (/\|/, $categories[$category_index]); $category_array[$category_index] = $key_value_pairs[0]; $full_category_array_lines[$category_index] = $categories[$category_index]; } } elsif ($move_action eq $lang_save_changes) { unlink($gcategory_file); rename($gcategory_file_reorder, $gcategory_file); chmod(0777, $gcategory_file); } elsif ($move_action eq $lang_move_up) { if ($move_category =~ /\S/) { $swapped = 0; for ($category_index = 0; $category_index <= $#categories; $category_index++) { if ($category_array[$category_index] =~ /$move_category/i) { if ($category_index > 0) { $temp = $category_array[$category_index]; $temp2 = $full_category_array_lines[$category_index]; $category_array[$category_index] = $category_array[$category_index - 1]; $full_category_array_lines[$category_index] = $full_category_array_lines[$category_index - 1]; $category_array[$category_index - 1] = $temp; $full_category_array_lines[$category_index - 1] = $temp2; $swapped = 1; $category_index = $#categories + 1; # force loop exit } else { } } } if ($swapped == 1) { unlink($gcategory_file_reorder); if (!(open(NEW_TEMP_CATEGORY_FILE, ">" . $gcategory_file_reorder))) { &return_error("File Error","Unable to create " . $gcategory_file_reorder); } for ($category_index = 0; $category_index <= $#categories; $category_index++) { $line_to_write = $full_category_array_lines[$category_index]; print NEW_TEMP_CATEGORY_FILE $line_to_write; } close(NEW_TEMP_CATEGORY_FILE); chmod(0777, $gcategory_file_reorder); } } $move_category = ""; $move_action = ""; } elsif ($move_action eq $lang_move_down) { if ($move_category =~ /\S/) { $swapped = 0; for ($category_index = 0; $category_index <= $#categories; $category_index++) { if ($category_index < $#categories) { if ($category_array[$category_index] =~ /$move_category/i) { $temp = $category_array[$category_index]; $temp2 = $full_category_array_lines[$category_index]; $category_array[$category_index] = $category_array[$category_index + 1]; $full_category_array_lines[$category_index] = $full_category_array_lines[$category_index + 1]; $category_array[$category_index + 1] = $temp; $full_category_array_lines[$category_index + 1] = $temp2; $swapped = 1; $category_index = $#categories + 1; # force loop exit } } else { } } if ($swapped == 1) { unlink($gcategory_file_reorder); if (!(open(NEW_TEMP_CATEGORY_FILE, ">" . $gcategory_file_reorder))) { &return_error("File Error","Unable to create " . $gcategory_file_reorder); } for ($category_index = 0; $category_index <= $#categories; $category_index++) { $line_to_write = $full_category_array_lines[$category_index]; print NEW_TEMP_CATEGORY_FILE $line_to_write; } close(NEW_TEMP_CATEGORY_FILE); chmod(0777, $gcategory_file_reorder); } } $move_category = ""; $move_action = ""; } $line_index = 0; print "Content-type: text/html\n\n"; print "\n"; print "\n"; print "\n\n"; print "$lang_reorder_categories"; print ""; print ""; print "
"; print ""; print ""; if (($message =~ /\S/) && ($message ne "NONE")) { print ""; } else { print ""; } print ""; $category_to_move = ""; print ""; print "
"; print ""; print "$lang_reorder_categories

"; print "
"; print "
"; print ""; print "$message"; print "
"; print ""; print " "; print "
"; print ""; print ""; print ""; print "
"; print "$lang_reorder_categories_instructions"; print "
"; print "
"; print ""; print ""; print ""; print ""; print "
"; print "
"; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print "
"; print ""; print ""; print ""; print "



"; print ""; print "
"; print "
"; print ""; print ""; print ""; print ""; print ""; print ""; print "
"; print "
"; print ""; print ""; print ""; print ""; print ""; print "
"; print "
"; print ""; print ""; print ""; print ""; print ""; print "
"; print "
"; print ""; print ""; print ""; print ""; print "
"; print "
"; print "
"; print "
"; print ""; exit; } sub open_file_for_reading { local ($file_name) = @_; local (*FH) ; if (!(open(FH, "<$file_name"))) { return -1; # will tell the caller that this failed } else { return *FH ; } } sub open_file_for_writing { local ($file_name) = @_; local (*FH) ; if (!(open(FH, ">$file_name"))) { return -1; # will tell the caller that this failed } else { return *FH ; } } sub open_file_for_appending { local ($file_name) = @_; local (*FH) ; if (!(open(FH, ">>$file_name"))) { return -1; # will tell the caller that this failed } else { return *FH ; } } sub write_record_to_resource_file { local ($file_handle, @resource_fields) = @_; local ($i); for ($i=0; $i < $#resource_fields; $i++) { print $file_handle $resource_fields[$i] . "|" ; } $resource_fields[$#resource_fields] =~ s/\n//g; $resource_fields[$#resource_fields] =~ s/\r//g; print $file_handle $resource_fields[$#resource_fields]; print $file_handle "|\n"; return; } sub check_duplicate_category_name { local ($new_name) = @_; local ($string1, $string2, $line, @key_value_pairs, $found_flag); $found_flag = 0; if (!(-e $gcategory_file)) { return 0; } if (open (CHECK_DATA_FILE, $gcategory_file)) { while () { $line = $_; @key_value_pairs = split (/\|/, $line); $string1 = quotemeta($key_value_pairs[1]); $string2 = quotemeta($new_name); if (($found_flag == 0) && ($string1 eq $string2)) { $found_flag = 1; } } close(CHECK_DATA_FILE); } else { &return_error("File Error","Unable to open " . $gcategory_file); } return $found_flag; } sub check_duplicate_user_name { local ($new_name) = @_; local ($string1, $string2, $line, @key_value_pairs, $found_flag); $found_flag = 0; if (!(-e $gauthorized_users_file)) { return 0; } if (open (USERS_FILE, $gauthorized_users_file)) { while () { $line = $_; @key_value_pairs = split (/\|/, $line); $string1 = $key_value_pairs[0]; $string2 = $new_name; if (($found_flag == 0) && ($string1 eq $string2)) { $found_flag = 1; } } close(USERS_FILE); } else { &return_error("File Error","Unable to open " . $gauthorized_users_file); } return $found_flag; } sub get_category_name { local ($category_key) = @_; local ($current_name, $string1, $string2, $line, @key_value_pairs, $found_flag); $found_flag = 0; if (!(-e $gcategory_file)) { &return_error("File Error","$gcategory_file was not found."); } if (open (CATEGORY_FILE, $gcategory_file)) { while () { $line = $_; @key_value_pairs = split (/\|/, $line); $current_key = $key_value_pairs[0]; $current_name = $key_value_pairs[1]; if ($current_key == $category_key) { close(CATEGORY_FILE); return $current_name; } } close(CATEGORY_FILE); return ""; } else { &return_error("File Error","Unable to open " . $gcategory_file); } } sub get_category_image { local ($category_key) = @_; local ($image_name, $current_name, $string1, $string2, $line, @key_value_pairs, $found_flag); $image_name = ""; $found_flag = 0; if (!(-e $gcategory_file)) { return $image_name; } if (open (CATEGORY_FILE, $gcategory_file)) { while () { $line = $_; @key_value_pairs = split (/\|/, $line); $current_key = $key_value_pairs[0]; $current_image = $key_value_pairs[5]; if ($current_key == $category_key) { close(CATEGORY_FILE); return $current_image; } } close(CATEGORY_FILE); return $image_name; } else { &return_error("File Error","Unable to open " . $gcategory_file); } } sub get_resource_name { local ($resource_key) = @_; local ($current_name, $string1, $string2, $line, @key_value_pairs, $found_flag); $found_flag = 0; if (!(-e $gresource_file)) { &return_error("File Error","$gresource_file was not found."); } if (open (RESOURCE_FILE, $gresource_file)) { while () { $line = $_; @key_value_pairs = split (/\|/, $line); $current_key = $key_value_pairs[0]; $current_name = $key_value_pairs[5]; if ($current_key == $resource_key) { close(RESOURCE_FILE); return $current_name; } } close(RESOURCE_FILE); return ""; } else { &return_error("File Error","Unable to open " . $gresource_file); } } sub get_resource_category_assignment { local ($resource_key) = @_; local ($current_category, $category_name, $string1, $string2, $line, @key_value_pairs, $found_flag); $found_flag = 0; if (!(-e $gresource_file)) { &return_error("File Error","$gresource_file was not found."); } if (open (RESOURCE_FILE, $gresource_file)) { if (! (-e $gcategory_file)) { close(RESOURCE_FILE); return $lang_unassigned; } else { while () { $line = $_; @key_value_pairs = split (/\|/, $line); $current_key = $key_value_pairs[0]; $current_category = $key_value_pairs[1]; $current_name = ""; if ( (int($current_key)) == (int($resource_key)) ) { close(RESOURCE_FILE); $current_name = &get_category_name($current_category); } } } close(RESOURCE_FILE); if ($current_name eq "") { return $lang_unassigned; } else { return $current_name; } } else { &return_error("File Error","Unable to open " . $gresource_file); } } sub get_number_resources_in_category { local ($category_key) = @_; local ($num_found, $line, @key_value_pairs, $current_key); if (!(-e $gresource_file)) { return 0; # there are no resources defined, just return 0 } else { $num_found = 0; if (open (RESOURCE_FILE, $gresource_file)) { while () { $line = $_; @key_value_pairs = split (/\|/, $line); $resource_category_key = $key_value_pairs[1]; if ($resource_category_key == $category_key) { $num_found++; } } close(RESOURCE_FILE); } } return $num_found; } sub get_num_reservations_for_this_resource { local ($resource_key) = @_; local ($num_found, $open_status, $full_file_name, $current_resource_key, @files, @reservation_file_lines, @reservation_file_value_pairs); $num_found = 0; if (opendir(DATA_DIR,$data_directory)) { @files = readdir(DATA_DIR); closedir(DATA_DIR); foreach $file (@files) { if (($file =~ /.txt$/) && (length($file) == 14)) { $full_file_name = $data_directory . $file; $open_status = open(RESERVATION_FILE, $full_file_name); if ($open_status == 0) { &return_error("Reservation File Read Error","$full_file_name could not be read."); } else { @reservation_file_lines = ; close(RESERVATION_FILE); for ($i=0; $i <= $#reservation_file_lines; $i++) { if (!($reservation_file_lines[$i] =~ /^#/)) { @reservation_file_value_pairs = split (/\|/, $reservation_file_lines[$i]); if ($#reservation_file_value_pairs > 1) { $current_resource_key = $reservation_file_value_pairs[0]; if ((int($current_resource_key) > 0) && ($current_resource_key == $resource_key)) { $num_found++; } } } } # end for ($i=0; ... } # end else if open_status } # end if (($file =~ /.txt$/) && (length($file) == 14)) } # end foreach } else { &return_error("Data Directory Read Error","Unable to open data directory " . $data_directory); } return $num_found; } sub delete_reservations_against_resource_being_deleted { local ($resource_key) = @_; local ($num_deleted, $open_status, $full_file_name, $current_resource_key, $temp_file, $status, $sub_name, $random_number, @files, @reservation_file_lines, @reservation_file_value_pairs); $sub_name = "delete_reservations_against_resource_being_deleted"; $num_deleted = 0; if (opendir(DATA_DIR,$data_directory)) { @files = readdir(DATA_DIR); closedir(DATA_DIR); foreach $file (@files) { if (($file =~ /.txt$/) && (length($file) == 14)) { $full_file_name = $data_directory . $file; $open_status = open(RESERVATION_FILE, $full_file_name); if ($open_status == 0) { } else { srand(time|$$); $random_number = int(rand(10000000)); $temp_file = $data_directory . "ureserve" . $random_number . ".tmp"; if (-e $temp_file) { $random_number++; $temp_file = $data_directory . "ureserve" . $random_number . ".tmp"; } if (!(open(NEW_RESERVATION_FILE, ">" . $temp_file))) { } else { &log_info($DEBUG,"TEMP FILE: $temp_file was created in sub delete_reservations_against."); @reservation_file_lines = ; close(RESERVATION_FILE); for ($i=0; $i <= $#reservation_file_lines; $i++) { if (!($reservation_file_lines[$i] =~ /^#/)) { @reservation_file_value_pairs = split (/\|/, $reservation_file_lines[$i]); if ($#reservation_file_value_pairs > 1) { $current_resource_key = $reservation_file_value_pairs[0]; if ($current_resource_key != $resource_key) { print NEW_RESERVATION_FILE $reservation_file_lines[$i]; } } } else { print NEW_RESERVATION_FILE $reservation_file_lines[$i]; } } # end for ($i=0; ... close(NEW_RESERVATION_FILE); $status = 0; $status = &safe_swap($full_file_name, $temp_file, $sub_name); if ($status == -1) { &log_info($ADMIN,"SERVER ERROR: Could not delete reservations when resource $resource_name was deleted by $username."); } } # end else if open } # end else if open_status } # end if (($file =~ /.txt$/) && (length($file) == 14)) } # end foreach } else { &log_info($ADMIN,"SERVER ERROR: Could not open $data_directory to delete reservations when resource $resource_name was deleted by $username."); } return $num_deleted; } sub delete_blackout_dates_for_resource_being_deleted { local ($resource_key) = @_; local ($routine_name, $num_deleted, $resource_name, $current_resource_key, @blackout_value_pairs, @blackout_data_lines); $routine_name = "DELETE_BLACKOUT_DATES_FOR_RESOURCE_BEING_DELETED"; $num_deleted = 0; if (!(-e $gblackout_dates_file)) { return 0; } $open_status = open(BLACKOUT_DATES_FILE, $gblackout_dates_file); if ($open_status == 0) { &log_info($ADMIN,"Blackout Dates File Read Error - $gblackout_dates_file could not be updated to reflect delete of $resource_name by $username."); } else { @blackout_data_lines = ; close(BLACKOUT_DATES_FILE); open(NEW_BLACKOUT_DATES_FILE,">$gblackout_dates_temp_file") || &return_error("Blackout Dates Update Error","Unable to create " . $gblackout_dates_temp_file . " for updating blackout-dates file to reflect delete of " . $resource_name . "."); $current_resource_key = ""; for ($i=0; $i <= $#blackout_data_lines; $i++) { if ($blackout_data_lines[$i] =~ /\S/) { @blackout_value_pairs = split (/\|/, $blackout_data_lines[$i]); $current_resource_key = $blackout_value_pairs[0]; if ($current_resource_key != $resource_key) { print NEW_BLACKOUT_DATES_FILE $blackout_data_lines[$i]; } else { $num_deleted++; } } } close(NEW_BLACKOUT_DATES_FILE); unlink($gblackout_dates_file); rename($gblackout_dates_temp_file,$gblackout_dates_file); chmod(0777, $gblackout_dates_file); } return $num_deleted; } sub unassign_auth_users_from_resource_being_deleted { local ($resource_key) = @_; local ($num_deleted); if (!(-e $gauthorized_users_file)) { return 0; } $num_deleted = 0; $resource_name = &get_resource_name($resource_key); $open_status = open(USERS_FILE, $gauthorized_users_file); if ($open_status == 0) { &log_info($gupgrade_log_file,"Authorized Users file could not be read. Authorized users could not be unassigned from resource $resource_name."); } else { @user_data_lines = ; close(USERS_FILE); open(NEW_USERS_FILE,">$gauthorized_users_temp_file") || &return_error("Authorized Users File Error","Unable to create " . $gauthorized_users_temp_file . ". Authorized users could not be unassigned from resource $resource_name."); $current_resource_key = ""; $new_user_line = ""; $auth_resources_string = ""; for ($i=0; $i <= $#user_data_lines; $i++) { if ($user_data_lines[$i] =~ /\S/) { chomp($user_data_lines[$i]); @user_value_pairs = split (/\|/, $user_data_lines[$i]); $new_user_line = $user_value_pairs[0] . "|" . $user_value_pairs[1] . "|" . $user_value_pairs[2] . "|"; $auth_resources = $user_value_pairs[3]; $auth_resources_string = ""; @auth_resource_value_pairs = split (/\?/, $auth_resources); for ($j=0; $j < $#auth_resource_value_pairs; $j++) { $current_resource_key = $auth_resource_value_pairs[$j]; if ($current_resource_key != $resource_key) { $auth_resources_string .= $current_resource_key . "?"; $num_deleted++; } } if (int($user_value_pairs[4]) <= 0) { $user_group = $GEN_USER; # default to general user } else { $user_group = $user_value_pairs[4]; } print NEW_USERS_FILE $new_user_line . $auth_resources_string; print NEW_USERS_FILE "|$user_group|$user_value_pairs[5]|\n"; } } # end for close(NEW_USERS_FILE); unlink($gauthorized_users_file); rename($gauthorized_users_temp_file,$gauthorized_users_file); chmod(0777, $gauthorized_users_temp_file); } return $num_deleted; } sub create_reminder_utility_form { local ( $message ) = @_; local ($now_seconds, $todays_date, $sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst, $seconds_past_midnite, $today_midnite, $yest_midnite, $yest_day_end, $yestdays_date, $day_start, $reminder_seconds, $reminder_week_name, $reminder_date, $temp_msg, $file_name, $line_index, $data_index, $current_resource_name, $current_user_phone, $current_user_email, $current_user_notes, $current_res_begin_time, $current_res_end_time, $show_begin_time, @lines, @key_value_pairs); &validate_referral_page($script_url); print "Content-type: text/html\n\n"; print "\n"; print "\n"; print "\n\n"; print "uReserve E-Mail Reminder Utility"; print ""; print "
"; print ""; print ""; $message .= " "; print ""; print ""; print ""; print ""; print ""; print "
"; print ""; print "$lang_reminder_utility

"; print "
"; print "
"; print ""; print "$message"; print "
"; print ""; print ""; print ""; print "
"; print "$lang_reminder_utility_instructions"; print "
"; print "
"; print ""; print ""; print ""; print ""; print ""; print ""; print "
"; print "
"; print "Enter number of days: "; print "

"; print ""; print ""; print "
"; print "
"; print "
"; print ""; print ""; print "
"; print "
"; print ""; print ""; print ""; } } else { print ""; print ""; } print ""; print "
"; $log_file = $greminder_log_file; if (-e ($log_file)) { $open_status = open(LOG_FILE, $log_file); if ($open_status == 0) { &return_error("File Error","Unable to open " . $log_file); } else { @log_file_lines = ; close(LOG_FILE); print "
"; $show_text = ""; for ($i=0; $i <= $#log_file_lines; $i++) { $log_file_lines[$i] =~ s/\\n/
/g; $show_text .= $log_file_lines[$i]; } print ""; print "
"; $show_text = "Reminder log file is empty.\n\n\n\n\n\n\n\n\n\n\n"; print ""; print "
"; print "
"; print "
"; print ""; print ""; print ""; print ""; print ""; print ""; print "
"; print ""; print ""; print ""; print ""; print ""; print "
"; print ""; print ""; print ""; print ""; print "
"; print "
"; print "
"; print "
"; print ""; return; } sub clear_log_file { local ($log_file) = @_; if (-e $log_file) { unlink $log_file; } &log_info($ADMIN,"Log file was cleared by $username."); return; } sub process_reminders { local ($now_seconds, $todays_date, $sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst, $seconds_past_midnite, $today_midnite, $yest_midnite, $yest_day_end, $yestdays_date, $day_start, $reminder_seconds, $reminder_week_name, $reminder_date, $temp_msg, $file_name, $line_index, $data_index, $current_resource_name, $current_user_phone, $current_user_email, $current_user_notes, $current_res_begin_time, $current_res_end_time, $show_begin_time, @lines, @key_value_pairs); $num_days_before_remind = $form_text {'num_days'}; $num_days_before_remind = &strip_letters($num_days_before_remind); if (!(int($num_days_before_remind))) { &missing_input("Input Error","Number of days must be between 1 and 120."); } if (($num_days_before_remind < 1) || ($num_days_before_remind > 120)) { &missing_input("Input Error","Number of days must be between 1 and 120."); } if (!($settings[2] =~ /\@/)) { &missing_input("Configuration Error","You must configure the Primary Notification E-mail before reminders can be sent out.

From General Settings, choose E-mail Settings and then enter a
Primary Notification E-mail.

"); } $now_seconds = time; $todays_date = &get_exact_date($now_seconds); ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($now_seconds); $seconds_past_midnite = $sec + ($min * 60) + ($hour * 3600); $today_midnite = $now_seconds - $seconds_past_midnite + 5; # today midnite plus 5 seconds $yest_midnite = $today_midnite - 86400; $yest_day_end = $today_midnite - 1; # today's midnite - 1 second $yestdays_date = &get_exact_date($yest_midnite); &log_info($greminder_log_file,"***** E-mail Reminder Service Beginning *****"); $day_start = $settings[6]; # SUN OR MON $reminder_dates_list = ""; $num_seconds_before_remind = $SECONDS_PER_DAY; # start emailing from 1 day out $count_emails = 0; for ($reminder_day_counter = 0; $reminder_day_counter < $num_days_before_remind; $reminder_day_counter++) { $reminder_seconds = time + ($time_zone_adjuster * 3600) + $num_seconds_before_remind; $reminder_week_name = &get_week_name($reminder_seconds, $day_start); $file_name = $data_directory . $reminder_week_name . ".txt"; $reminder_date = &get_exact_date($reminder_seconds); $temp_msg = "Sending reminders for " . $reminder_date; &log_info($greminder_log_file,$temp_msg); $found = 0; $reminder_dates_list .= $reminder_date . "
"; $day_index = &get_day_index($reminder_seconds, $day_start); if (-e $file_name) { open (SCHEDULE_FILE, $file_name) || &return_error("File Error","Unable to open $file_name"); @lines = ; close(SCHEDULE_FILE); $line_index = 0; while ((!($lines[$line_index] =~ /^#$day_index/i)) && ($line_index <= $#lines)) { $line_index++; } $data_index = 0; while ((!($lines[$line_index] =~ /^#END/i)) && ($line_index <= $#lines)) { if (!($lines[$line_index] =~ /^#END/i)) { if ($lines[$line_index] =~ /^#/) { } else { $found = 1; @key_value_pairs = split (/\|/, $lines[$line_index]); $current_resource_key = $key_value_pairs[0]; $current_resource_name = &get_resource_name($current_resource_key); for ($data_index = 1; $data_index < $#key_value_pairs; $data_index += 25) { @cur_fields = &get_current_fields($data_index, @key_value_pairs); &send_reminder_email( $current_resource_key, $reminder_seconds, @cur_fields); $count_emails++; } } } $line_index++; } } if (!($found)) { &log_info($greminder_log_file,"-- No reservations were found for $reminder_date."); } $num_seconds_before_remind += $SECONDS_PER_DAY; } # end for reminder_day_counter &log_info($greminder_log_file,"***** Finished E-mail Reminder Service *****"); $count_results = $count_emails . " reminder e-mails were sent."; &create_reminder_utility_form($count_results); } sub send_reminder_email { local ( $resource_key, $current_seconds, @cur_fields) = @_; local ( $i, $msg, $temp_msg, $date_string, $email_subject, $resource_name, $res_start_time, $res_end_time, $f_begin_time, $f_end_time, @resv_form_fields); @resv_form_fields = &prep_resv_form_fields_array(1, @cur_fields); $res_start_time = $cur_fields[6]; $res_end_time = $cur_fields[7]; $show_begin_time = &format_time($res_start_time); $user_email = &find_user_email(@resv_form_fields); $date_string = &get_exact_date($current_seconds); $email_subject = "Reservation Reminder"; $resource_name = &get_resource_name($resource_key); if ($settings[0] eq "CONFIG") { $f_begin_time = $column_names[$res_start_time]; $f_end_time = $column_names[$res_end_time]; } else { $f_begin_time = &format_time($res_start_time); $f_end_time = &format_time($res_end_time); } $msg = "** Reservation Reminder **\n\n\n"; $results = &get_reservation_result( $current_seconds, $resource_key, $res_start_time, $res_end_time, 0, 0, 0, 0, #recurring_flag @resv_form_fields); $results =~ s/\/\n/g; $msg .= $results; $from_email = $settings[2]; $user_email = &find_user_email(@resv_form_fields); if ($user_email =~ /\@/) { if ($settings[13] =~ /SENDMAIL/i) { &send_mail($from_email,$user_email,$email_subject,$msg); } elsif ($settings[13] =~ /SOCKETS/i) { &send_mail_sockets($from_email,$user_email,$email_subject,$msg); } $temp_msg = "E-mail sent to $user_email for $current_resource_name on $date_string at $f_begin_time."; &log_info($greminder_log_file,$temp_msg); } else { $temp_msg = "Unable to locate user e-mail address within reservation data record. No reservation reminder sent for $current_resource_name on $date_string at $f_begin_time."; &log_info($greminder_log_file,$temp_msg); } } sub get_day_index { local ($num_seconds, $day_start) = @_; local ($dsec, $dmin, $dhour, $dmday, $dmon, $dyear, $dwday, $dyday, $disdst, $didx); if (($num_seconds < $SECONDS_2K) || ($num_seconds > $SECONDS_2100)) { $num_seconds = $SECONDS_2K; } ($dsec,$dmin,$dhour,$dmday,$dmon,$dyear,$didx,$dyday,$disdst) = localtime($num_seconds); if ($day_start eq "SUN") { $didx++; } return $didx; } sub warn_upgrade_required { &display_message("uReserve Online Resource Management System","Copyright 2000 - 2006; Microburst Technologies, Inc.


Your data files need to be upgraded from version 3.

Log in to the Administrative Control Panel at

$script_url?command=login

and select Utilities-->Upgrade Data Files




"); } sub warn_no_resources_defined { &display_message("uReserve Online Resource Management System","Copyright 2000 - 2006; Microburst Technologies, Inc.


You have no resources to report on at this time.



"); } sub create_export_data_form { local ($message) = @_; local ($last_update_date, $last_update_seconds, $temp); &validate_referral_page($script_url); $resource_admin_access = 0; $reports_admin_access = 0; &validate_admin($username, $password, $resource_admin_access, $reports_admin_access); print "Content-type: text/html\n\n"; print "uReserve Data Extract Utility"; print ""; print "
"; print ""; print ""; $message .= " "; print ""; print ""; print ""; print "
"; print ""; print "$lang_extract_utility

"; print "
"; print "
"; print ""; print "$message"; print "
"; print ""; print ""; print ""; print "
"; print "$lang_extract_utility_instructions"; print "
"; print "
"; print ""; print ""; print ""; print ""; print ""; print ""; print "
"; print "
"; print ""; print ""; print ""; print ""; print "
"; print ""; print ""; print ""; print ""; print "
"; print "
"; print "
"; print "
"; print ""; return; } sub make_extract_file { local ($day_index, $file, $file_week_seconds, $reservation_bdate_seconds, $reservation_bdate, $reservation_bdate_YYYYMMDD, $recurring_string, $reservation_edate_seconds, $reservation_edate, $reservation_edate_YYYYMMDD, $begin_time, $end_time, $j, $t, $routine_name, $temp_file_date, @cur_fields, @recurring_fields, @files, @lines, @reservation_lines, @key_value_pairs, @data_value_pairs); $routine_name = "MAKE_EXTRACT_FILE"; &validate_referral_page($script_url); if (!(open(EXTRACT_FILE, ">" . $gextract_file))) { &return_error("File Write Error","Unable to create " . $gextract_file); } else { if (opendir(DATA_DIR,$data_directory)) { @files = readdir(DATA_DIR); closedir(DATA_DIR); foreach $file (@files) { $temp_file_date = substr($file,0,10); # MM-DD-YYYY $file_date = &make_US_date_YYYYMMDD($temp_file_date); # must pass US format date if (($file =~ /.txt$/) && (length($file) == 14)) { $temp_data_directory = $data_directory . "/" . $file; if (!(open(RESERVATION_FILE, $temp_data_directory))) { &log_error($routine_name, "FILE ERROR: Unable to open $temp_data_directory"); } else { @reservation_lines = ; close(RESERVATION_FILE); $reservation_lines_index = 0; $day_index = 1; while ($reservation_lines_index <= $#reservation_lines) { if ($reservation_lines[$reservation_lines_index] =~ /^#/) { if (!($reservation_lines[$reservation_lines_index] =~ /^#END/)) { $day_index = &strip_letters($reservation_lines[$reservation_lines_index]); } } elsif (!($reservation_lines[$reservation_lines_index] =~ /^#/)) { $file_week_seconds = &get_week_seconds($temp_file_date); # always in MM-DD-YYYY $reservation_bdate_seconds = (($day_index-1) * $SECONDS_PER_DAY) + $file_week_seconds; $reservation_bdate = &get_exact_date($reservation_bdate_seconds); $reservation_bdate_YYYYMMDD = &make_date_YYYYMMDD($reservation_bdate); @cur_fields = split (/\|/, $reservation_lines[$reservation_lines_index]); $resource_key = $cur_fields[0]; $resource_name = &get_resource_name($resource_key); $resource_category_name = &get_resource_category_assignment($resource_key); if ($resource_category_name eq $lang_unassigned) { $resource_category_name = ""; } for ($data_index = 1; $data_index < $#cur_fields; $data_index += 25) { print EXTRACT_FILE $resource_name . "|"; print EXTRACT_FILE $resource_category_name . "|"; print EXTRACT_FILE $reservation_bdate_YYYYMMDD . "|"; print EXTRACT_FILE $reservation_bdate . "|"; $recurring_string = $cur_fields[$data_index + 4]; @recurring_fields = (); @recurring_fields = split (/\?/, $recurring_string); if ( ($settings[97] =~ /DAILY/i) || ($settings[97] =~ /DATE_RANGE/i) ) { $reservation_edate_seconds = $recurring_fields[3]; # ending reservation seconds $reservation_edate = &get_exact_date($reservation_edate_seconds); $reservation_edate_YYYYMMDD = &make_date_YYYYMMDD($reservation_edate); print EXTRACT_FILE $reservation_edate_YYYYMMDD . "|"; print EXTRACT_FILE $reservation_edate . "|"; } else { print EXTRACT_FILE $reservation_bdate_YYYYMMDD . "|"; print EXTRACT_FILE $reservation_bdate . "|"; } $begin_time = $cur_fields[$data_index + 5]; if ($settings[0] eq "CONFIG") { print EXTRACT_FILE $column_names[$begin_time] . "|"; } else { print EXTRACT_FILE &format_time($begin_time) . "|"; } $end_time = $cur_fields[$data_index + 6]; if ($settings[0] eq "CONFIG") { print EXTRACT_FILE $column_names[$end_time] . "|"; } else { print EXTRACT_FILE &format_time($end_time) . "|"; } for ($j=0; $j<24; $j++) { if (($j == 4) || ($j == 5) || ($j == 6)) { } # end fix 06-23-06 else { $t = $cur_fields[$data_index + $j]; if (chomp($t) > 0) { print EXTRACT_FILE chomp($cur_fields[$data_index + $j]) . "|"; } else { print EXTRACT_FILE $cur_fields[$data_index + $j] . "|"; } } } # end for $j print EXTRACT_FILE "|\n"; } # end for $data_index loop } # end if ((!($reservation_lines[$reservation_lines_index] =~ /^#1/i)) && ... $reservation_lines_index++; } # end while ((!($reservation_lines[$reservation_lines_index] =~ /^#END/i)) &&... } # end if (!(open(RESERVATION_FILE, $file))) } # end if (($file =~ /.txt$/) && (length($file) == 14)) } # end foreach } # end if opendir else { &log_error($routine_name, "FILE ERROR: Unable to open $dir_name for data extraction."); } } # end if comment line close(EXTRACT_FILE); chmod(0777, $gextract_file); &update_extract_log("$gextract_file was created."); &update_extract_log("*** END OF DATA EXTRACTION PROCESS ***"); return; } sub download_extract_file { local ( $download_file, $download_info, $found_flag, $buf, $len, $date_string, $formatted_string, $sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst); &validate_referral_page($script_url); $download_file = $gextract_file; $download_info = $download_file . " was downloaded.\n\n"; $download_info .= "FILE NAME: " . $download_file . "\n"; $download_info .= "BROWSER TYPE IS " . $ENV{'HTTP_USER_AGENT'} . "\n"; $download_info .= "BROWSER TYPE IS " . $ENV{'HTTP_USER_AGENT'} . "\n"; $download_info .= "REMOTE_HOST = " . $ENV{'REMOTE_HOST'} . "\n"; $download_info .= "REMOTE_ADDR = " . $ENV{'REMOTE_ADDR'} . "\n"; $download_info .= "REMOTE_USER = " . $ENV{'REMOTE_USER'} . "\n\n"; ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(); if ($year > 99) { $year = $year - 100; } $date_string = sprintf("%02d/%02d/%04d %02d:%02d",$mon+1,$mday,$year + 2000,$hour,$min); $formatted_string = $date_string . "|" . $download_info . "\n"; if (!(-e $gdownload_extract_log_file)) { if (open(FILE, ">" . $gdownload_extract_log_file)) { print FILE $formatted_string; close(FILE); } else { } } else { if (open(FILE, ">>" . $gdownload_extract_log_file)) { print FILE $formatted_string; close(FILE); } else { } } $temp = $download_file; $buf = ""; $len = 0; open(FILE, $temp); $len = (stat($temp))[7]; print "Content-Type: application/octet-stream\n"; print "Content-Disposition: attachment; filename=$download_file\n"; print "Content-length: $len\n\n"; read(FILE, $buf, $len); print $buf; close(FILE); exit; } sub update_extract_log { local ( $action_string ) = @_; local ($current_time,$sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst); ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(); $year += 1900; $mon += 1; $current_time = sprintf("%02d/%02d/%04d %02d:%02d",$mon,$mday,$year,$hour,$min); if (open(BATCH_LOG, ">>" . $gdownload_extract_log_file)) { print BATCH_LOG $current_time . " "; print BATCH_LOG $action_string . "\n"; close(BATCH_LOG); chmod(0777, $gdownload_extract_log_file); } else { } return; } sub get_resource_category_key { local (@resource_fields) = @_; return $resource_fields[1]; } sub get_resource_start_date { local (@resource_fields) = @_; return $resource_fields[2]; } sub get_resource_end_date { local (@resource_fields) = @_; return $resource_fields[3]; } sub get_resource_permission_level { local (@resource_fields) = @_; return $resource_fields[10]; # resource_permission_level } sub get_placeholder_field_number { local (@resource_fields) = @_; return $resource_fields[11]; # placeholder_field number } sub get_fixed_reservation_hours { local (@resource_fields) = @_; local ($fixed_hours); $fixed_hours = &strip_letters($resource_fields[12]); return $fixed_hours; } sub get_fixed_reservation_minutes { local (@resource_fields) = @_; local ($fixed_minutes); $fixed_minutes = &strip_letters($resource_fields[13]); return $fixed_minutes; } sub get_max_reservation_hours { local (@resource_fields) = @_; return $resource_fields[14]; } sub get_max_reservation_minutes { local (@resource_fields) = @_; return $resource_fields[15]; } sub get_lead_time_create_days { local (@resource_fields) = @_; return $resource_fields[16]; } sub get_lead_time_create_hours { local (@resource_fields) = @_; return $resource_fields[17]; } sub get_lead_time_create_minutes { local (@resource_fields) = @_; return $resource_fields[18]; } sub get_lead_time_cancel_days { local (@resource_fields) = @_; return $resource_fields[19]; } sub get_lead_time_cancel_hours { local (@resource_fields) = @_; return $resource_fields[20]; } sub get_lead_time_cancel_minutes { local (@resource_fields) = @_; return $resource_fields[21]; } sub get_buffer_periods_between { local (@resource_fields) = @_; return 0; # $resource_fields[31]; } sub get_buffer_hours_between { local (@resource_fields) = @_; return 0; # $resource_fields[32]; } sub get_buffer_minutes_between { local (@resource_fields) = @_; return 0; # $resource_fields[33]; } sub get_max_advance_days { local (@resource_fields) = @_; return $resource_fields[34]; } sub get_resource_admin_emails { local ( $resource_key) = @_; local ( $auth_user_email, $auth_list, $line, $j, @user_value_pairs, @resource_list_pairs, @resource_admin_emails); @resource_admin_emails = (); $j = 0; if (open(USERS_FILE, $gauthorized_users_file)) { while () { $line = $_; @user_value_pairs = (); @resource_list_pairs = (); @user_value_pairs = split (/\|/, $line); $auth_list = $user_value_pairs[3]; @resource_list_pairs = split (/\?/, $auth_list); $user_group = $user_value_pairs[4]; if (int($user_group) != $RESOURCE_ADMIN) { next; } else { $user_auth = 0; foreach $auth_key (@resource_list_pairs) { if (int($auth_key) == int($resource_key)) { $user_auth = 1; } } if ($user_auth) { $auth_user_email = $user_value_pairs[5]; @resource_admin_emails[$j] = $auth_user_email; $j++; } } } close(USERS_FILE); } return @resource_admin_emails; } sub get_resource_email_text { local (@resource_fields) = @_; local ($field_data); $field_data = $resource_fields[23]; $field_data =~ s/\/\n/g; return $field_data; } sub get_pending_flag { local (@resource_fields) = @_; return $resource_fields[24]; } sub get_pending_email_text { local (@resource_fields) = @_; local ($field_data); $field_data = $resource_fields[26]; $field_data =~ s/\/\n/g; return $field_data; } sub get_placeholder_max_chars { local (@resource_fields) = @_; return $resource_fields[27]; # placeholder_max_chars } sub get_resource_image { local (@resource_fields) = @_; return $resource_fields[28]; } sub check_within_date_range { local ($file_name, $end_file_name, $save_start_file_name, $day_index, $report_start_day_index, $report_end_day_index) = @_; local ($within_date_range); $within_date_range = 0; if ($file_name eq $end_file_name) { $within_date_range = 0; if ($save_start_file_name eq $end_file_name) { if ($settings[6] =~ /SUN/i) # v3.22 fix { if (($day_index > $report_start_day_index) && ($day_index <= $report_end_day_index)) { $within_date_range = 1; } } else { if (($day_index >= $report_start_day_index) && ($day_index < $report_end_day_index)) # v3.22 fix { $within_date_range = 1; } } } else { if ($settings[6] =~ /SUN/i) # v3.22 fix { if ($day_index <= $report_end_day_index) { $within_date_range = 1; } } else { if ($day_index < $report_end_day_index) #v3.22 fix { $within_date_range = 1; } } } } elsif ($file_name eq $save_start_file_name) { $within_date_range = 0; if ($settings[6] =~ /SUN/i) # v3.22 fix { if ($day_index > $report_start_day_index) { $within_date_range = 1; } } else { if ($day_index >= $report_start_day_index) # v3.22 fix { $within_date_range = 1; } } } else { $within_date_range = 1; } return $within_date_range; } sub compare_eq { local ($num1, $num2) = @_; local ($result); $result = 0; # means FALSE if (sprintf('%2.3f',$num1) == sprintf('%2.3f', $num2)) { $result = 1; # TRUE, these numbers are EQUAL } return $result; } sub compare_ne { local ($num1, $num2) = @_; local ($result); $result = 0; # means FALSE if (sprintf('%2.3f',$num1) != sprintf('%2.3f', $num2)) { $result = 1; # TRUE, these numbers are NOT EQUAL } return $result; } sub compare_lt { local ($num1, $num2) = @_; local ($result); $result = 0; # means FALSE if (sprintf('%2.3f',$num1) < sprintf('%2.3f', $num2)) { $result = 1; # TRUE, the first number is less than the second number } return $result; } sub compare_gt { local ($num1, $num2) = @_; local ($result); $result = 0; # means FALSE if (sprintf('%2.3f',$num1) > sprintf('%2.3f', $num2)) { $result = 1; # TRUE, the first number is greater than the second number } return $result; } sub compare_ge { local ($num1, $num2) = @_; local ($result); $result = 0; # means FALSE if (sprintf('%2.3f',$num1) >= sprintf('%2.3f', $num2)) { $result = 1; # TRUE, the first number is >= to the second number } return $result; } sub compare_le { local ($num1, $num2) = @_; local ($result); $result = 0; # means FALSE if (sprintf('%2.3f',$num1) <= sprintf('%2.3f', $num2)) { $result = 1; # TRUE, the first number is <= to the second number } return $result; } sub get_reservation_result { local ($current_seconds, $resource_key, $res_start_time, $res_end_time, $res_num_days, $res_start_seconds, $res_end_seconds, $recurring_flag, @resv_form_fields) = @_; local ( $field_count, $looper, $z, $return_string, $options_list, $multi_list, $checkbox_list, $resource_settings, $res_start_date, $res_end_date, @resource_value_pairs, @options_list_values, @multi_list_values, @checkbox_list); if ($res_start_seconds > 0) { $res_start_date = &get_exact_date($res_start_seconds); # MM/DD/YYYY or DD/MM/YYYY } else { $res_start_date = ""; } if ($res_end_seconds > 0) { $res_end_date = &get_exact_date($res_end_seconds); # MM/DD/YYYY or DD/MM/YYYY } else { $res_end_date = ""; } $date_string = &get_exact_date($current_seconds); $resource_name = &get_resource_name($resource_key); $resource_settings = &get_resource_settings($resource_key); @resource_value_pairs = split (/\|/, $resource_settings); $return_string = "$settings[39]: $resource_name
"; if ($settings[97] =~ /STANDARD/i) { if ($recurring_flag == 0) { $return_string .= "Date: $date_string
"; } $return_string .= &get_time_string_formatted( $res_start_time, $res_end_time, $res_num_days, $res_start_date, $res_end_date, @resource_value_pairs); } else { if ($res_start_date eq $res_end_date) { $return_string .= "Date: $res_start_date
"; } else { $return_string .= "Dates: $res_start_date - $res_end_date
"; } } $return_string .= "

"; $field_count = 1; for ($i=1; $i <= 22; $i++) { if ($fields[$field_count] =~ /\S/) { if (!($fields[($field_count + 1)] =~ /DISABLED/i)) { if ($fields[$field_count + 1] =~ /TEXTAREA/i) { if (!($fields[($field_count + 3)] =~ /HIDELABEL/i)) { $return_string .= "$fields[$field_count] "; } $return_string .= $resv_form_fields[($i-1)] . "
"; } elsif ($fields[$field_count + 1] =~ /CHECKBOX/i) { if (!($fields[($field_count + 3)] =~ /HIDELABEL/i)) { $return_string .= "$fields[$field_count]
"; } $checkbox_list = $resv_form_fields[($i-1)]; # contains checkbox list @checkbox_list_values = split (/\0/, $checkbox_list); for ($z=0; $z <= $#checkbox_list_values; $z++) { $return_string .= "  $checkbox_list_values[$z]
"; } } elsif ($fields[$field_count + 1] =~ /RADIO/i) { if (!($fields[($field_count + 3)] =~ /HIDELABEL/i)) { $return_string .= "$fields[$field_count] "; } $return_string .= $resv_form_fields[($i-1)] . "
"; } elsif ($fields[$field_count + 1] =~ /SINGLE/i) { if (!($fields[($field_count + 3)] =~ /HIDELABEL/i)) { $return_string .= "$fields[$field_count] "; } $return_string .= $resv_form_fields[($i-1)] . "
"; } elsif ($fields[$field_count + 1] =~ /MULTI/i) { if (!($fields[($field_count + 3)] =~ /HIDELABEL/i)) { $return_string .= "$fields[$field_count]
"; } $multi_list = $resv_form_fields[($i-1)]; # contains multi list @multi_list_values = split (/\0/, $multi_list); for ($z=0; $z <= $#multi_list_values; $z++) { $return_string .= "  $multi_list_values[$z]
"; } } else { if (!($fields[($field_count + 3)] =~ /HIDELABEL/i)) { $return_string .= "$fields[$field_count] "; } $return_string .= $resv_form_fields[($i-1)] . "
"; } } } $field_count += 6 ; } $return_string .= "
"; return $return_string; } sub get_recurring_reservation_result { local ( $resource_key, $pending_flag, $success_list, $conflict_list, $res_start_time, $res_end_time, $res_start_date, $res_end_date, @resv_form_fields) = @_; local ( $field_count, $z, $return_string, $options_list, $multi_list, $checkbox_list, @options_list_values, @multi_list_values, @checkbox_list); $resource_name = &get_resource_name($resource_key); $return_string = "The following reservation:

"; $return_string .= "$settings[39]: $resource_name
"; if ($settings[0] eq "CONFIG") { if ($settings[97] =~ /STANDARD/i) { $fixed_hours = &get_fixed_reservation_hours(@resource_value_pairs); $fixed_minutes = &get_fixed_reservation_minutes(@resource_value_pairs); $fixed_res_size = $fixed_hours + $fixed_minutes; if ($fixed_res_size > 0) { if (&compare_eq($fixed_res_size, $looper)) { $return_string .= $settings[100] . $column_names[$res_start_time]; } else { $return_string .= $settings[100] . $column_names[$res_start_time]; $return_string .= " - " . $column_names[$res_end_time]; } } else { } } else { $return_string .= "From: " . $column_names[$res_start_time]; $return_string .= " - " . $column_names[$res_end_time]; } } else { } $return_string .= "
"; $field_count = 1; for ($i=1; $i <= 22; $i++) { if ($fields[$field_count] =~ /\S/) { if (!($fields[($field_count + 1)] =~ /DISABLED/i)) { if ($fields[$field_count + 1] =~ /TEXTAREA/i) { $return_string .= "$fields[$field_count] $resv_form_fields[($i-1)]
"; } elsif ($fields[$field_count + 1] =~ /CHECKBOX/i) { $return_string .= "$fields[$field_count]
"; $checkbox_list = $resv_form_fields[($i-1)]; # contains checkbox list @checkbox_list_values = split (/\0/, $checkbox_list); for ($z=0; $z <= $#checkbox_list_values; $z++) { $return_string .= "  $checkbox_list_values[$z]
"; } } elsif ($fields[$field_count + 1] =~ /RADIO/i) { $return_string .= "$fields[$field_count] $resv_form_fields[($i-1)]
"; } elsif ($fields[$field_count + 1] =~ /SINGLE/i) { $return_string .= "$fields[$field_count] $resv_form_fields[($i-1)]
"; } elsif ($fields[$field_count + 1] =~ /MULTI/i) { $return_string .= "$fields[$field_count]
"; $multi_list = $resv_form_fields[($i-1)]; # contains multi list @multi_list_values = split (/\0/, $multi_list); for ($z=0; $z <= $#multi_list_values; $z++) { $return_string .= "  $multi_list_values[$z]
"; } } else { $return_string .= "$fields[$field_count] $resv_form_fields[($i-1)]
"; } } } $field_count += 6 ; } $return_string .= "
"; if ($pending_flag =~ /on/i) # if pending flag is set for the resource { if ($success_list =~ /\S/) { $return_string .= "Is PENDING for the following dates:
"; $return_string .= "$success_list
"; } } else { if ($success_list =~ /\S/) { $return_string .= "Was successfully placed on the following dates:
"; $return_string .= "$success_list
"; } } if ($conflict_list =~ /\S/) { $return_string .= "
Was NOT placed on the following dates due to scheduling conflicts:
"; $return_string .= "$conflict_list
"; } return $return_string; } sub get_new_reservation_form_field { local ($field_index, $field_count) = @_; local ( $field_name, $return_string, $options_list, @options_list_values); $return_string = ""; $field_name = "resv_form_field" . $field_index; if ($fields[$field_count + 1] =~ /TEXTAREA/i) { $return_string .= ""; } elsif ($fields[$field_count + 1] =~ /CHECKBOX/i) { $options_list = $fields[$field_count + 2]; # contains options list @options_list_values = split (/,/, $options_list); foreach $options_list_value (@options_list_values) { chomp($options_list_value); $return_string .= "$options_list_value"; } } elsif ($fields[$field_count + 1] =~ /RADIO/i) { $options_list = $fields[$field_count + 2]; # contains options list @options_list_values = split (/,/, $options_list); $first_time = 0; foreach $options_list_value (@options_list_values) { chomp($options_list_value); if ($first_time == 0) { $first_time = 1; $return_string .= "$options_list_value"; } else { $return_string .= "$options_list_value"; } } } elsif ($fields[$field_count + 1] =~ /SINGLE/i) { $return_string .= ""; } elsif ($fields[$field_count + 1] =~ /MULTI/i) { $return_string .= ""; } else # default to type text if TEXT, EMAIL or URL { $return_string .= ""; } return $return_string; } sub get_current_reservation_field { local ($field_count, @resv_form_fields) = @_; local ( $return_string, $options_list, $multi_list, $z, @options_list_values, @multi_list_values); $return_string = ""; if ($fields[$field_count + 1] =~ /TEXTAREA/i) { $return_string .= "$fields[$field_count] $resv_form_fields[($i-1)]
"; } elsif ($fields[$field_count + 1] =~ /CHECKBOX/i) { $return_string .= "$fields[$field_count]
"; $checkbox_list = $resv_form_fields[($i-1)]; # contains checkbox list @checkbox_list_values = split (/\^/, $checkbox_list); for ($z=0; $z <= $#checkbox_list_values; $z++) { $return_string .= "  $checkbox_list_values[$z]
"; } } elsif ($fields[$field_count + 1] =~ /RADIO/i) { $return_string .= "$fields[$field_count] $resv_form_fields[($i-1)]
"; } elsif ($fields[$field_count + 1] =~ /SINGLE/i) { $return_string .= "$fields[$field_count] $resv_form_fields[($i-1)]
"; } elsif ($fields[$field_count + 1] =~ /MULTI/i) { $return_string .= "$fields[$field_count]
"; $multi_list = $resv_form_fields[($i-1)]; # contains multi list @multi_list_values = split (/\^/, $multi_list); for ($z=0; $z <= $#multi_list_values; $z++) { $return_string .= "  $multi_list_values[$z]
"; } } else { $return_string .= "$fields[$field_count] $resv_form_fields[($i-1)]
"; } return $return_string; } sub get_reservation_form_field_for_modify { local ($field_index, $field_count, $cur_field_value) = @_; local ( $field_name, $return_string, $options_list, @options_list_values); $return_string = ""; $field_name = "resv_form_field" . $field_index; if ($fields[$field_count + 1] =~ /TEXTAREA/i) { $cur_field_value =~ s/\/\n/g; $return_string .= ""; } elsif ($fields[$field_count + 1] =~ /CHECKBOX/i) { $options_list = $fields[$field_count + 2]; # contains options list @options_list_values = split (/,/, $options_list); foreach $options_list_value (@options_list_values) { $found = 0; $checkbox_list = $cur_field_value; # contains checkboxes actually checked @checkbox_list_values = split (/\^/, $checkbox_list); foreach $checkbox_list_value (@checkbox_list_values) { if ($checkbox_list_value eq $options_list_value) { $found = 1; } } if ($found == 1) { $return_string .= "$options_list_value"; } else { $return_string .= "$options_list_value"; } } } elsif ($fields[$field_count + 1] =~ /RADIO/i) { $options_list = $fields[$field_count + 2]; # contains options list @options_list_values = split (/,/, $options_list); $first_time = 0; foreach $options_list_value (@options_list_values) { if ($cur_field_value eq $options_list_value) { $return_string .= "$options_list_value"; } else { $return_string .= "$options_list_value"; } } } elsif ($fields[$field_count + 1] =~ /SINGLE/i) { $return_string .= ""; } elsif ($fields[$field_count + 1] =~ /MULTI/i) { $return_string .= ""; } else # default to type text if TEXT, EMAIL or URL { $return_string .= ""; } return $return_string; } sub prep_resv_form_fields_array { local ($data_index, @key_value_pairs) = @_; local (@resv_form_fields, @pending_value_pairs); @resv_form_fields = (); @pending_value_pairs = split (/\?/, $key_value_pairs[$data_index]); $resv_form_fields[0] = $pending_value_pairs[0]; $resv_form_fields[1] = $key_value_pairs[$data_index + 1]; $resv_form_fields[2] = $key_value_pairs[$data_index + 2]; $resv_form_fields[3] = $key_value_pairs[$data_index + 3]; $resv_form_fields[4] = $key_value_pairs[$data_index + 7]; $resv_form_fields[5] = $key_value_pairs[$data_index + 8]; $resv_form_fields[6] = $key_value_pairs[$data_index + 9]; $resv_form_fields[7] = $key_value_pairs[$data_index + 10]; $resv_form_fields[8] = $key_value_pairs[$data_index + 11]; $resv_form_fields[9] = $key_value_pairs[$data_index + 12]; $resv_form_fields[10] = $key_value_pairs[$data_index + 13]; $resv_form_fields[11] = $key_value_pairs[$data_index + 14]; $resv_form_fields[12] = $key_value_pairs[$data_index + 15]; $resv_form_fields[13] = $key_value_pairs[$data_index + 16]; $resv_form_fields[14] = $key_value_pairs[$data_index + 17]; $resv_form_fields[15] = $key_value_pairs[$data_index + 18]; $resv_form_fields[16] = $key_value_pairs[$data_index + 19]; $resv_form_fields[17] = $key_value_pairs[$data_index + 20]; $resv_form_fields[18] = $key_value_pairs[$data_index + 21]; $resv_form_fields[19] = $key_value_pairs[$data_index + 22]; $resv_form_fields[20] = $key_value_pairs[$data_index + 23]; $resv_form_fields[21] = $key_value_pairs[$data_index + 24]; return @resv_form_fields; } sub prep_resv_form_fields { local (@resv_fields) = @_; local ($x, $substituted_field, $choice, @choices); for ($x=0; $x < $#resv_fields; $x++) { if (($fields[($x*6) + 2] =~ /CHECKBOX/i) || ($fields[($x*6) + 2] =~ /MULTI/i)) { chomp($resv_fields[$x]); $substituted_field = ""; @choices=split(/\0/,$resv_fields[$x]); foreach $choice (@choices) { $substituted_field .= $choice; $substituted_field .= "^"; } $substituted_field = substr($substituted_field, 0, -1); $resv_fields[$x] = $substituted_field; } else { chomp($resv_fields[$x]); $resv_fields[$x] =~ s/\r//g; $resv_fields[$x] =~ s/\n/
/g; } } return @resv_fields; } sub prep_resv_form_fields_line_for_reservation_file { local ( $res_start_time, $res_end_time, $field5_recurring, $pending_flag, @resv_form_fields) = @_; local ($formatted_string, $temp_res_field1); $formatted_string = ""; $temp_res_field1 = $resv_form_fields[0]; if ($pending_flag =~ /on/i) { $temp_res_field1 .= "?PENDING"; } else { $temp_res_field1 =~ s/\?PENDING//i; } $formatted_string .= "|$temp_res_field1|$resv_form_fields[1]|$resv_form_fields[2]|$resv_form_fields[3]|$field5_recurring|$res_start_time|$res_end_time|$resv_form_fields[4]|$resv_form_fields[5]|$resv_form_fields[6]|$resv_form_fields[7]|$resv_form_fields[8]|$resv_form_fields[9]|$resv_form_fields[10]|$resv_form_fields[11]|$resv_form_fields[12]|$resv_form_fields[13]|$resv_form_fields[14]|$resv_form_fields[15]|$resv_form_fields[16]|$resv_form_fields[17]|$resv_form_fields[18]|$resv_form_fields[19]|$resv_form_fields[20]|$resv_form_fields[21]"; return $formatted_string; } sub get_current_fields { local ($data_index, @key_value_pairs) = @_; local ($j, $begin_time, $end_time, @cur_fields); @cur_fields = (); $cur_fields[0] = ""; for ($j=1; $j<=25; $j++) { $t = $key_value_pairs[$data_index + ($j-1)]; if (chomp($t) > 0) { $cur_fields[$j] = chomp($key_value_pairs[$data_index + ($j-1)]); } else { $cur_fields[$j] = $key_value_pairs[$data_index + ($j-1)]; } } # end for $j return @cur_fields; } sub prep_cur_fields_line_for_reservation_file { local ($remove_pending_indr, @cur_fields) = @_; local ($formatted_string); $formatted_string = ""; if ($remove_pending_indr) { $cur_fields[1] =~ s/\?PENDING//i; } $formatted_string = "|$cur_fields[1]|$cur_fields[2]|$cur_fields[3]|$cur_fields[4]|$cur_fields[5]|$cur_fields[6]|$cur_fields[7]|$cur_fields[8]|$cur_fields[9]|$cur_fields[10]|$cur_fields[11]|$cur_fields[12]|$cur_fields[13]|$cur_fields[14]|$cur_fields[15]|$cur_fields[16]|$cur_fields[17]|$cur_fields[18]|$cur_fields[19]|$cur_fields[20]|$cur_fields[21]|$cur_fields[22]|$cur_fields[23]|$cur_fields[24]|$cur_fields[25]"; return $formatted_string; } sub find_user_email { local (@resv_form_fields) = @_; local ($user_email); $user_email = ""; $field_count = 1; for ($i=1; $i <= 22; $i++) { if ($fields[$field_count] =~ /\S/) { if (!($fields[($field_count + 1)] =~ /DISABLED/i)) { if ($fields[$field_count + 1] =~ /EMAIL/i) { $user_email = "$resv_form_fields[$i-1]"; $i = 23; # force exit loop } } } $field_count += 6 ; } return $user_email; } sub print_page_title { local ( $font_size, $font_face, $font_color, $page_title, $formatted_date, $fname) = @_; local ($num_seconds); $font_size += 2; print ""; $font_size -= 2; print "$page_title $formatted_date
"; print ""; if ( ((stat($fname))[9]) > 0) { $num_seconds = (stat($fname))[9]; print "(Last Updated: " . &get_exact_date($num_seconds) . ")
"; } print "


"; } sub print_body { local ($background_color, $font_color, $link_color, $vlink_color, $alink_color) = @_; print ""; } sub get_time_string_formatted { local( $res_start_time, $res_end_time, $num_days, $res_start_date, $res_end_date, @resource_value_pairs) = @_; local ( $time_string, $looper, $fixed_hours, $fixed_minutes, $fixed_res_size); $time_string = ""; $looper = &get_looper(); if ($settings[97] =~ /DAILY/i) { $time_string .= $settings[101] . ":" . $num_days; } elsif ($settings[97] =~ /DATE_RANGE/i) { $time_string .= $settings[102] . ":" . $res_start_date; $time_string .= "   "; $time_string .= $settings[103] . ":" . $res_end_date; } else { if ($settings[0] eq "CONFIG") { $fixed_hours = &get_fixed_reservation_hours(@resource_value_pairs); $fixed_minutes = &get_fixed_reservation_minutes(@resource_value_pairs); $fixed_res_size = $fixed_hours + $fixed_minutes; if ($fixed_res_size > 0) { if (&compare_eq($fixed_res_size, $looper)) { $time_string .= $settings[100] . " " . $column_names[$res_start_time]; } else { $time_string .= $settings[100] . $column_names[$res_start_time]; $time_string .= " - " . $column_names[$res_end_time]; } } else { $time_string .= "$settings[98] " . $column_names[$res_start_time]; $time_string .= " $settings[99] " . $column_names[$res_end_time]; } } else { $fixed_hours = &get_fixed_reservation_hours(@resource_value_pairs); $fixed_minutes = &get_fixed_reservation_minutes(@resource_value_pairs); $fixed_res_size = $fixed_hours + $fixed_minutes; if ($fixed_res_size > 0) { if (&compare_eq($fixed_res_size, $looper)) { $time_string .= $settings[100] . " "; $time_string .= &format_time($res_start_time); } else { $time_string .= $settings[100]; # ie. During or From $time_string .= " "; $time_string .= &format_time($res_start_time); $time_string .= " - "; $time_string .= &format_time($res_end_time); } } else { $time_string .= $settings[98]; # ie. From $time_string .= " "; $time_string .= &format_time($res_start_time); $time_string .= "
"; $time_string .= $settings[99]; # ie. To $time_string .= " "; $time_string .= &format_time($res_end_time); } } } return $time_string; } sub check_real_reservation { local ($reservation_data) = @_; local (@resv_value_pairs); @resv_value_pairs = split (/\|/, $reservation_data); if ($#resv_value_pairs > 6) { return 1; } return 0; } sub create_manage_blocked_users_form { local ($message) = @_; local ($file_name, $blocked_user_index, $current_line, $val, $i, @blocked_users, @lines, @key_value_pairs ); &validate_referral_page($script_url); $resource_admin_access = 1; $reports_admin_access = 0; &validate_admin($username, $password, $resource_admin_access, $reports_admin_access); $list_box_spacer = ""; for ($i=0; $i < 190; $i++) { $list_box_spacer .= " "; } print "Content-type: text/html\n\n"; print "\n"; print "\n"; print "\n\n"; print "$lang_manage_blocked_users"; print ""; print ""; print "
"; print ""; print ""; if (($message =~ /\S/) && ($message ne "NONE")) { print ""; } else { print ""; } print ""; my ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, $atime, $mtime, $ctime, $blksize, $blocks) = stat $gblocked_users_file; if ((-e $gblocked_users_file) && ($size > 0)) { open (BLOCKED_USER_FILE, $gblocked_users_file) || &return_error("File Error","Unable to open " . $gblocked_users_file); @blocked_users = ; close(BLOCKED_USER_FILE); @blocked_users_sorted = sort {$a cmp $b} @blocked_users; $select_html = ""; } else { $select_html = "


$lang_no_blocked_users


"; } print "
"; print "
"; print ""; print "$lang_manage_blocked_users"; print ""; print "
"; print ""; print "$message"; print "
"; print ""; print " "; print "
"; print ""; print ""; print ""; print "
"; print "$lang_blocked_user_instructions"; print "
"; print "
"; print ""; print ""; print ""; print ""; print "
"; print "
"; print ""; print ""; print ""; print ""; print ""; print "
"; print $select_html; print "
"; print ""; print ""; print ""; print "
"; print "$lang_blocked_username:
"; print "$lang_blocked_email:"; print "  
"; print "
"; print ""; print ""; print ""; print ""; print ""; print "
"; if (-e $gblocked_users_file) { print ""; } print ""; print "
"; print ""; print ""; print ""; print ""; print "
"; print "
"; print "
"; print "
"; print ""; exit; } sub add_blocked_user { local ($username, $password) = @_; local ( $blocked_user_name, $blocked_user_email, $email_out, $line, $resource_key, $new_resource_list, $num_errors, $error_html, @user_value_pairs, @choices); &validate_referral_page($script_url); $blocked_user_name = $form_text{'blocked_user'}; $blocked_user_name = &validate_string($blocked_user_name); $blocked_user_email = $form_text{'blocked_email'}; $blocked_user_email = &validate_email($blocked_user_email); if (!($blocked_user_email =~ /\S/)) { &create_manage_blocked_users_form("E-mail address to block is required."); } if (!($blocked_user_name =~ /\S/)) { &create_manage_blocked_users_form("A name for this user is required."); } $email_out = &validate_email($blocked_user_email); if ($blocked_user_email ne $email_out) { &create_manage_blocked_users_form("Enter a valid e-mail address to block."); } if ( (uc($blocked_user_email) eq uc($settings[2])) || (uc($blocked_user_email) eq uc($settings[3])) ) { &create_manage_blocked_users_form("You can not block the Primary Admin or Secondary Admin e-mail address."); } if (&check_email_belongs_to_auth_user($blocked_user_email) == -1) { &create_manage_blocked_users_form("You can not block an authorized user e-mail. If necessary, update the authorized user and remove resource permissions."); } if (-e $gblocked_users_file) { if (open(BLOCKED_USER_FILE, $gblocked_users_file)) { while () { $line = $_; if (($line =~ /\S/) && ($line ne "\n")) { @user_value_pairs = split (/\|/, $line); if ($user_value_pairs[1] eq $blocked_user_email) { close(BLOCKED_USER_FILE); &create_manage_blocked_users_form("The user e-mail address $blocked_user_email is already defined."); } } } close(BLOCKED_USER_FILE); } else { &return_error("File Error","Unable to open $gblocked_users_file"); } } if (open(BLOCKED_USER_FILE, ">>" . $gblocked_users_file)) { print BLOCKED_USER_FILE $blocked_user_name . "|" . $blocked_user_email . "|\n"; close(BLOCKED_USER_FILE); chmod(0777, $gblocked_users_file); } else { &return_error("File Error","Unable to open $gblocked_users_file"); } &log_info($ADMIN,"Blocked User $blocked_user_email ($blocked_user_name) was added by $username."); &create_manage_blocked_users_form("$blocked_user_email ($blocked_user_name) has been added."); } sub delete_blocked_user { local ($line, $current_user_name, $current_user_email, $blocked_user_choice, $detail_user_name, $detail_user_email, $found_flag, $random_number, $temp_file, $num_deleted, @key_value_pairs, @blocked_user_choices, @detail_value_pairs); &validate_referral_page($script_url); $blocked_user_detail = $form_text{'blocked_user_detail'}; $num_deleted = 0; srand(time|$$); $random_number = int(rand(10000000)); $temp_file = $data_directory . "ureserve" . $random_number . ".tmp"; open (DEL_DATA_FILE, $gblocked_users_file) || &return_error("File Error","Unable to open " . $gblocked_users_file); if (!(open(DEL_TEMP_FILE, ">" . $temp_file))) { close(DEL_DATA_FILE); &return_error("File Error","Unable to open " . $temp_file); } @blocked_user_choices=split(/\0/,$blocked_user_detail); while () { $line = $_; if ($num_deleted <= $#blocked_user_choices) { @key_value_pairs = split (/\|/, $line); $current_user_name = $key_value_pairs[0]; $current_user_email = $key_value_pairs[1]; $found_flag = 0; foreach $blocked_user_choice (@blocked_user_choices) { @detail_value_pairs = split (/\|/, $blocked_user_choice); $detail_user_name = $detail_value_pairs[0]; $detail_user_email = $detail_value_pairs[1]; if ( ($found_flag == 0) && ($current_user_name eq $detail_user_name) && ($current_user_email eq $detail_user_email) ) { $found_flag = 1; $num_deleted++; &log_info($ADMIN,"Blocked user e-mail $current_user_email ($current_user_name) DELETED by $username."); } else { } } if ($found_flag == 1) { } else { print DEL_TEMP_FILE $line; } } # end if ($num_deleted <= $#blocked_user_choices) else { print DEL_TEMP_FILE $line; } } # end while close(DEL_DATA_FILE); close(DEL_TEMP_FILE); unlink($gblocked_users_file); rename($temp_file,$gblocked_users_file); chmod(0777, $gblocked_users_file); my ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, $atime, $mtime, $ctime, $blksize, $blocks) = stat $gblocked_users_file; if ($size == 0) { unlink($gblocked_users_file); } return $num_deleted; } sub auto_remove_blocked_user { local ($email_to_auto_remove) = @_; local ( $line, $current_user_name, $current_user_email, $blocked_user_choice, $detail_user_name, $detail_user_email, $found_flag, $random_number, $temp_file, $num_deleted, @key_value_pairs, @blocked_user_choices, @detail_value_pairs); if (!(-e $gblocked_users_file)) { return; } if (&check_email_blocked($email_to_auto_remove) != -1) { return; } $num_deleted = 0; srand(time|$$); $random_number = int(rand(10000000)); $temp_file = $data_directory . "ureserve" . $random_number . ".tmp"; open (DEL_DATA_FILE, $gblocked_users_file) || &return_error("File Error","Unable to open " . $gblocked_users_file); if (!(open(DEL_TEMP_FILE, ">" . $temp_file))) { close(DEL_DATA_FILE); &return_error("File Error","Unable to open " . $temp_file); } while () { $line = $_; @key_value_pairs = split (/\|/, $line); $current_user_email = $key_value_pairs[1]; $found_flag = 0; if ( ($found_flag == 0) && (uc($current_user_email) eq uc($email_to_auto_remove)) ) { $found_flag = 1; $num_deleted++; &log_info($ADMIN,"Blocked user e-mail $current_user_email ($current_user_name) AUTO-DELETED by $username."); } if ($found_flag == 1) { } else { print DEL_TEMP_FILE $line; } } # end while close(DEL_DATA_FILE); close(DEL_TEMP_FILE); unlink($gblocked_users_file); rename($temp_file,$gblocked_users_file); chmod(0777, $gblocked_users_file); my ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, $atime, $mtime, $ctime, $blksize, $blocks) = stat $gblocked_users_file; if ($size == 0) { unlink($gblocked_users_file); } return; } sub check_email_belongs_to_auth_user { local ($user_email) = @_; local ( $line, $i, $current_user_email, @lines, @user_value_pairs); &validate_referral_page($script_url); @lines = (); if (-e $gauthorized_users_file) { open (USERS_FILE, $gauthorized_users_file) || &return_error("File Error","Unable to open Authorized Users Database."); @lines = ; close(USERS_FILE); for ($i = 0; $i <= $#lines; $i++) { chop($lines[$i]); @user_value_pairs = split (/\|/, $lines[$i]); $current_user_email = $user_value_pairs[5]; if (uc($user_email) eq uc($current_user_email)) { return -1; } } } return 0; } sub check_email_blocked { local ($user_email) = @_; local ( $line, $i, $current_user_email, @lines, @user_value_pairs); @lines = (); if (-e $gblocked_users_file) { open (BLOCKED_USERS_FILE, $gblocked_users_file) || &return_error("File Error","Unable to open Blocked Users file."); @lines = ; close(BLOCKED_USERS_FILE); for ($i = 0; $i <= $#lines; $i++) { chop($lines[$i]); @user_value_pairs = split (/\|/, $lines[$i]); $current_user_email = $user_value_pairs[1]; if (uc($user_email) eq uc($current_user_email)) { return -1; } } } return 0; } sub check_if_user_authorized_to_modify_or_cancel { local ( $username, $password, $resource_key, $org_password, $org_username, $resv_form_password, $resv_form_username, $permission_level, $recurring_flag) = @_; local ($user_auth, $resource_admin_flag); $user_auth = ""; if (($settings[127] =~ /NO/i) && ((!($username =~ /\S/)) && (!($password =~ /\S/))) ) { $user_auth = &get_user_group($resv_form_username, $resv_form_password); } elsif ( ( ($username =~ /\S/) && ($password =~ /\S/) ) && ( ($resv_form_username =~ /\S/) && ($resv_form_password =~ /\S/) ) ) { $user_auth = &get_user_group($resv_form_username, $resv_form_password); } else { $user_auth = &get_user_group($username, $password); } $user_auth = int($user_auth); if ($user_auth != $SYSTEM_ADMIN) { if ($user_auth == $RESOURCE_ADMIN) { $resource_admin_flag = 0; if ($settings[127] =~ /NO/i) { if ( ($username =~ /\S/) && ($password =~ /\S/) ) { if ( (!($resv_form_username =~ /\S/)) && (!($resv_form_password =~ /\S/)) ) { $resource_admin_flag = &validate_resource_admin($username, $password, $resource_key); } else { $resource_admin_flag = &validate_resource_admin($resv_form_username, $resv_form_password, $resource_key); } } else { $resource_admin_flag = &validate_resource_admin($resv_form_username, $resv_form_password, $resource_key); } } elsif ( ( ($username =~ /\S/) && ($password =~ /\S/) ) && ( ($resv_form_username =~ /\S/) && ($resv_form_password =~ /\S/) ) ) { $resource_admin_flag = &validate_resource_admin($resv_form_username, $resv_form_password, $resource_key); } else { $resource_admin_flag = &validate_resource_admin($username, $password, $resource_key); } if ($resource_admin_flag == 0) { if ($org_password =~ /\S/) { if (!($resv_form_password =~ /\S/)) # if no password was entered { &missing_input("Missing Input","The $settings[52] is required."); } elsif ( (!($resv_form_username =~ /\S/)) && (int($permission_level) == $ANY_RESERVE_AUTH_RECURRING) ) { if (($recurring_flag) || ($org_username =~ /\S/)) { &missing_input("Missing Input","Username is required."); } } elsif ( (!($resv_form_username =~ /\S/)) && ( (int($permission_level) == $AUTH_RESERVE_AUTH_RECURRING) || (int($permission_level) == $AUTH_RESERVE_NO_RECURRING) ) ) { &missing_input("Missing Input","Username is required."); } elsif ( ($resv_form_username ne $org_username) && ($org_username =~ /\S/)) { &missing_input("Invalid Username","The username that you entered is invalid for this reservation."); } else { if ($resv_form_password ne $org_password) { &missing_input("Invalid $settings[52]","The $settings[52] that you entered is invalid."); } } } } } # end if user_auth == $RESOURCE_ADMIN else { if ($org_password =~ /\S/) { if (!($resv_form_password =~ /\S/)) # if no password was entered { &missing_input("Missing Input","The $settings[52] is required."); } elsif ( (!($resv_form_username =~ /\S/)) && (int($permission_level) == $ANY_RESERVE_AUTH_RECURRING) ) { if (($recurring_flag) || ($org_username =~ /\S/)) { &missing_input("Missing Input","Username is required."); } elsif ($resv_form_password ne $org_password) { &missing_input("Invalid $settings[52]","The $settings[52] that you entered is invalid."); } } elsif ( (!($resv_form_username =~ /\S/)) && ( (int($permission_level) == $AUTH_RESERVE_AUTH_RECURRING) || (int($permission_level) == $AUTH_RESERVE_NO_RECURRING) ) ) { &missing_input("Missing Input","Username is required."); } elsif ( ($resv_form_username ne $org_username) && ($org_username =~ /\S/)) { &missing_input("Invalid Username","The username that you entered is invalid for this reservation."); } else { if ($resv_form_password ne $org_password) { &missing_input("Invalid $settings[52]","The $settings[52] that you entered is invalid."); } } } } # # end if user_auth == $RESOURCE_ADMIN } # end if user_auth != $SYSTEM_ADMIN return; } sub email_pending_reservation_result { local ($approve_flag) = @_; local ($action_string, $action, $mode, $msg_action, $resource_key, $first_date_seconds, $res_start_time, $res_end_time, $num_days, $recurring_start_seconds, $recurring_end_seconds, $pending_note, $skip_email, $email_message, $user_email, @resv_form_fields); if ($approve_flag) { $action_string = "AUTH-PENDING"; $action = $lang_accepted; $mode = "AUTH"; $msg_action = $lang_activated; } else { $action_string = "REJ-PENDING"; $action = $lang_rejected; $mode = "REJ"; $msg_action = $lang_cancelled; } $resource_key = $form_text{'resource_key'}; $first_date_seconds = $form_text{'first_date_seconds'}; $res_start_time = $form_text{'res_start_time'}; $res_end_time = $form_text{'res_end_time'}; $num_days = $form_text{'num_days'}; $recurring_start_seconds = $form_text{'recurring_start_seconds'}; $recurring_end_seconds = $form_text{'recurring_end_seconds'}; $pending_note = ""; $pending_note = $form_text{'pending_note'}; $skip_email = $form_text{'skip_email'}; @resv_form_fields = (); @resv_form_fields = &get_posted_reservation_data(); $email_message = "The following reservation has been $action:\n\n"; $email_message .= &get_reservation_result( $first_date_seconds, $resource_key, $res_start_time, $res_end_time, $num_days, $recurring_start_seconds, $recurring_end_seconds, 0, #recurring_flag @resv_form_fields); $user_email = &find_user_email(@resv_form_fields); if ($skip_email == 0) { &send_email_notifications($email_message, $resource_key, $user_email, $mode, $pending_note); } } sub get_default_category_view { local ($cat_key ) = @_; local ($cat_view, $category_settings, @category_value_pairs); $cat_view = ""; $category_settings = &get_category_settings($cat_key); @category_value_pairs = split (/\|/, $category_settings); $cat_view = $category_value_pairs[10]; # category default display format return $cat_view; } sub make_file_copy { local ($orig_file, $copy_file) = @_; local ($line); if (!(open (ORIGINAL_FILE, $orig_file))) { return 0; } if (!(open(COPY_FILE, ">" . $copy_file))) { close(ORIGINAL_FILE); return 0; } while () { $line = $_; print COPY_FILE $line; } close(ORIGINAL_FILE); close(COPY_FILE); return 1; } # end make_file_copy() sub get_all_resource_admin_info { local ($resource_key) = @_; local ($auth_user_email, $auth_list, $line, $j, @user_value_pairs, @resource_list_pairs, @resource_admin_info); @resource_admin_info = (); $j = 0; if (open(USERS_FILE, $gauthorized_users_file)) { while () { $line = $_; @user_value_pairs = (); @resource_list_pairs = (); @user_value_pairs = split (/\|/, $line); $auth_list = $user_value_pairs[3]; @resource_list_pairs = split (/\?/, $auth_list); $user_group = $user_value_pairs[4]; if (int($user_group) != $RESOURCE_ADMIN) { next; } else { $user_auth = 0; foreach $auth_key (@resource_list_pairs) { if (int($auth_key) == int($resource_key)) { $user_auth = 1; } } if ($user_auth) { @resource_admin_info[$j] = $line; $j++; } } } close(USERS_FILE); } return @resource_admin_info; } # end get_all_resource_admin_info() sub create_popup_list_resource_admins { local ($resource_key, $resource_name, $resource_admin_detail, $x, @resource_admin_info, @user_value_pairs); $resource_key = $form_text{'rkey'}; $resource_name = &get_resource_name($resource_key); @resource_admin_info = &get_all_resource_admin_info($resource_key); $x = 1; print "Content-type: text/html\n\n"; print "\n"; print "\n"; print "\n\n"; print "uReserve Resource Admins"; print ""; print ""; print "
"; print ""; print "
"; print ""; print ""; if ($#resource_admin_info >= 0) { print ""; foreach $resource_admin_detail (@resource_admin_info) { @user_value_pairs = split (/\|/, $resource_admin_detail); print ""; print ""; print ""; $x++; } print ""; } else { print ""; print ""; } print "
The following Authorized Users have been configured as
Resource Admins for "; print "$resource_name:


"; print "$x. $user_value_pairs[5] ($user_value_pairs[2])


Each of these users will receive an e-mail"; print " notification
for every reservation of $resource_name.


"; print "
There are no Resource Admins configured
for $resource_name.

"; print "


If you want additional users to receive an e-mail"; print " notification
for every reservation of $resource_name,
use the Authorized Users function to set them up.


"; print "

"; print ""; print ""; print "
"; print "
"; print ""; } # end create_popup_list_resource_admins() sub update_reservation_log_w_email { local ($log_emailto, $log_emailfrom) = @_; local ( $current_time, $sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst, $log_resource_name); $log_action = "EMAIL"; ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(); $year += 1900; $mon += 1; if ($settings[5] =~ /US/i) { $current_time = sprintf("%02d/%02d/%04d %02d:%02d",$mon,$mday,$year,$hour,$min); } else { $current_time = sprintf("%02d/%02d/%04d %02d:%02d",$mday,$mon,$year,$hour,$min); } if (open(RES_LOG, ">>" . $greservation_log_file)) { print RES_LOG $current_time . "|"; print RES_LOG $log_action . "|To:"; print RES_LOG $log_emailto . "|From:"; print RES_LOG $log_emailfrom . "\n"; close(RES_LOG); chmod(0777, $greservation_log_file); } } sub show_field_name_list { local ($placeholder_field) = @_; local ($select_html, $fields_line_index, $i, $cur_field); $select_html = ""; $fields_line_index = -1; for ($i = 1; $i <= 22; $i++) { $fields_line_index += 2; if ($fields[$fields_line_index] =~ /\S/) { ++$fields_line_index; if ( ($fields[$fields_line_index] eq "TEXT") || ($fields[$fields_line_index] eq "TEXTAREA") ) { if (int($placeholder_field) == $i) { $select_html .= ""; } else { $select_html .= ""; } } } $fields_line_index += 3; } # end for $i <= 22 return $select_html; } sub check_if_user_is_admin_or_reservee { local ($resource_key, $permission_level, $resv_username, $resv_password, $viewing_username, $viewing_password) = @_; local ($user_auth, $user_logged_in); $user_auth = -1; $user_logged_in = 0; if (($username =~ /\S/) && ($password =~ /\S/)) { $user_logged_in = 1; } if ($user_logged_in) { $user_auth = &get_user_group($username, $password); $user_auth = int($user_auth); if (($user_auth == $SYSTEM_ADMIN) || ($user_auth == $RESOURCE_ADMIN)) { if ($user_auth == $RESOURCE_ADMIN) { if (&validate_resource_admin($viewing_username, $viewing_password, $resource_key) == 0) { if (&validate_resource_admin($username, $password, $resource_key) == 0) { } else { $user_auth = 1; } } else { $user_auth = 1; } } else { $user_auth = 1; } } else { $user_auth = -1; # set this way so that we will continue below } } if ($user_auth == -1) { if ( ($permission_level == $ANY_RESERVE_AUTH_RECURRING) || ($permission_level == $AUTH_RESERVE_AUTH_RECURRING)|| ($permission_level == $AUTH_RESERVE_NO_RECURRING) ) { if ( (($viewing_password eq $resv_password) && ($resv_password =~ /\S/)) || ( ($user_logged_in) && ($password eq $resv_password) && ($resv_password =~ /\S/) ) ) { if ( ( uc($viewing_username) eq uc($resv_username) ) || ( uc($username) eq uc($resv_username) ) ) { $user_auth = 2; } else { if ( !($resv_username =~ /\S/) ) { if (&validate_user($resource_key, $viewing_username, $viewing_password) == 1) { $user_auth = 2; } elsif ($user_logged_in) { $user_auth = 2; } } else { if ( ( uc($viewing_username) eq uc($resv_username) ) || ( uc($username) eq uc($resv_username) ) ) { $user_auth = 2; } } } } if (($user_auth != 1) && ($user_auth != 2)) { $user_auth = &get_user_group($viewing_username, $viewing_password); $user_auth = int($user_auth); if (($user_auth == $GEN_USER) || ($user_auth == $REPORTS_ADMIN)) { $user_auth = -1; } elsif (($user_auth == $SYSTEM_ADMIN) || ($user_auth == $RESOURCE_ADMIN)) { if ($user_auth == $RESOURCE_ADMIN) { if (&validate_resource_admin($viewing_username, $viewing_password, $resource_key) == 0) { $user_auth = -1; } else { $user_auth = 1; } } else { $user_auth = 1; } } } } else { if ( (($viewing_password eq $resv_password) && ($resv_password =~ /\S/) ) || ( ($user_logged_in) && ($password eq $resv_password) && ($resv_password =~ /\S/) ) ) { $user_auth = 2; } } } return $user_auth; } sub prep_field5_recurring { local ($org_password, $org_username, $user_auth, $resv_form_username, $field5_recurring) = @_; local ( $org_field5, $recurring_start_seconds, $recurring_end_seconds, @string_value_pairs); $org_field5 = ""; $recurring_start_seconds = 0; $recurring_end_seconds = 0; $org_field5 = $org_password . "?"; if ( (!($org_username =~ /\S/)) && ($user_auth == 1) ) { $org_field5 .= $org_username; } elsif ((!($org_username =~ /\S/)) && ($user_auth == 2)) { $org_field5 .= $resv_form_username; } else { $org_field5 .= $org_username; } @string_value_pairs = split (/\?/, $field5_recurring); if ($string_value_pairs[2] =~ /\S/) { $recurring_start_seconds = $string_value_pairs[2]; $recurring_end_seconds = $string_value_pairs[3]; $org_field5 .= "?"; $org_field5 .= $recurring_start_seconds; $org_field5 .= "?"; $org_field5 .= $recurring_end_seconds; } return $org_field5; } sub safe_swap { local ( $orig_file_name, $temp_file, $sub_name) = @_; local ( $i, $copy_file_name, $status, $random_number, $retry); srand(time|$$); $random_number = int(rand(10000000)); $copy_file_name = $data_directory . "ureserve" . $random_number . ".sav"; if (-e $copy_file_name) { $random_number++; $copy_file_name = $data_directory . "ureserve" . $random_number . ".sav"; } $status = -1; for ($i = 0; $i < 10; $i++) { if (rename($orig_file_name, $copy_file_name)) { &log_info($DEBUG,"ORIG FILE COPY: $orig_file_name renamed $copy_file_name in sub $sub_name."); $i = 11; $status = 1; } else { &log_info($DEBUG,"FILE COPY ERROR: retry=$i $orig_file_name COULD NOT BE renamed $copy_file_name in sub $sub_name."); }; }; if ($status == 1) { $status = -1; for ($i = 0; $i < 10; $i++) { if (rename($temp_file,$orig_file_name)) { chmod(0777, $orig_file_name); &log_info($DEBUG,"TEMP FILE: $temp_file renamed $orig_file_name in sub $sub_name."); $i = 11; $status = 1; if (unlink($copy_file_name)) { &log_info($DEBUG,"COPY FILE: $copy_file_name was deleted in sub $sub_name."); } else { &log_info($DEBUG,"COPY FILE ERROR: $copy_file_name COULD NOT BE deleted in sub $sub_name."); }; } else { &log_info($DEBUG,"FILE ERROR: retry=$i $temp_file COULD NOT BE renamed $orig_file_name in sub $sub_name."); }; } if ($status == -1) { for ($i = 0; $i < 10; $i++) { if (rename($copy_file_name, $orig_file_name)) { chmod(0777, $orig_file_name); &log_info($DEBUG,"ROLLBACK COPY FILE: $copy_file_name renamed $orig_file_name in sub $sub_name."); $i = 11; $status = 1; } else { &log_info($DEBUG,"COPY FILE ERROR: retry=$i $copy_file_name COULD NOT BE ROLLED BACK to $orig_file_name in sub $sub_name."); }; } } } return $status; } sub create_change_pswd_form { local ( $auth_user_username, $auth_user_orig_pswd, $auth_user_new_pswd, $auth_user_confirm_new_pswd); &validate_referral_page($script_url); $auth_user_username = ""; $auth_user_orig_pswd = ""; $auth_user_new_pswd = ""; $auth_user_confirm_new_pswd = ""; if (!(-e $gauthorized_users_file)) { &return_error("No Authorized Users", "No authorized users have been defined yet. At least one authorized user must be defined prior to attempting to change a user password."); } print "Content-type: text/html\n\n"; print "\n"; print "\n"; print "\n\n"; print "uReserve"; print ""; print ""; print "
"; print "
"; print "
"; print ""; print ""; print "
Change Password



"; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print "
"; print ""; print "$lang_username: "; print ""; print ""; print ""; print ""; print ""; print "
"; print ""; print "$lang_current_password: "; print ""; print ""; print ""; print ""; print ""; print "
"; print ""; print "$lang_new_password: "; print ""; print ""; print ""; print ""; print ""; print "
"; print ""; print "$lang_confirm_new_password: "; print ""; print ""; print ""; print ""; print ""; print "
"; print "
"; print "
"; print ""; print "     "; print ""; print "
"; print "
"; print ""; print "
"; print ""; exit; } sub change_auth_user_pswd { local ( $auth_user_username, $auth_user_orig_pswd, $auth_user_new_pswd, $auth_user_confirm_new_pswd, $current_auth_user_name, $auth_user_pswd, $auth_user_full_name, $user_resource_list, $user_group, $auth_user_email, $line, $found_flag, $random_number, $temp_file, @key_value_pairs, @user_value_pairs); &validate_referral_page($script_url); @key_value_pairs = (); @user_value_pairs = (); $line = ""; $found_flag = 0; $auth_user_username = ""; $auth_user_orig_pswd = ""; $auth_user_new_pswd = ""; $auth_user_confirm_new_pswd = ""; $current_auth_user_name = ""; $auth_user_email = ""; $user_group = ""; $user_resource_list = ""; $auth_user_username = $form_text{'auth_user_username'}; $auth_user_orig_pswd = $form_text{'auth_user_orig_pswd'}; $auth_user_new_pswd = $form_text{'auth_user_new_pswd'}; $auth_user_confirm_new_pswd = $form_text{'auth_user_confirm_new_pswd'}; if (!($auth_user_username =~ /\S/)) { &missing_input("Username Required","You must enter the username for which you want to change the password."); } if (!($auth_user_orig_pswd =~ /\S/)) { &missing_input("Original Password Required","You must enter the password on file for the username entered."); } if (!($auth_user_new_pswd =~ /\S/)) { &missing_input("New Password Required","You must enter a new password before it can be changed."); } if (!($auth_user_confirm_new_pswd =~ /\S/)) { &missing_input("New Password Confirmation Required","You must confirm the new password before it can be changed."); } if (open (USER_FILE, $gauthorized_users_file)) { while () { $line = $_; chop($line); @key_value_pairs = split (/\|/, $line); $current_auth_user_name = $key_value_pairs[0]; if (($found_flag == 0) && ($current_auth_user_name eq $auth_user_username)) { $auth_user_pswd = $key_value_pairs[1]; $auth_user_full_name = $user_value_pairs[2]; $user_resource_list = $key_value_pairs[3]; if (int($key_value_pairs[4]) > 0) { $user_group = $key_value_pairs[4]; } else { $user_group = $GEN_USER; # default to general user } $auth_user_email = $key_value_pairs[5]; $found_flag = 1; } } close(USER_FILE); } else { &return_error("File Error","Unable to open " . $gauthorized_users_file); } if ($found_flag == 0) { &missing_input("User Unknown","Unable to locate a record for username $auth_user_username."); } if ($auth_user_orig_pswd ne $auth_user_pswd) { &missing_input("Not Authorized","The password entered does not match the one on file for $auth_user_username."); } if ($auth_user_new_pswd ne $auth_user_confirm_new_pswd) { &missing_input("Password Confirmation Failed","You must confirm the new password successfully before it can be changed."); } if ($auth_user_new_pswd eq $auth_user_pswd) { &missing_input("Password Unchanged","No changes made. New password was same as current password."); } srand(time|$$); $random_number = int(rand(10000000)); $temp_file = $data_directory . "ureserve" . $random_number . ".tmp"; open (EDIT_DATA_FILE, $gauthorized_users_file) || &return_error("File Error","Unable to open " . $gauthorized_users_file); if (!(open(EDIT_TEMP_FILE, ">" . $temp_file))) { close(EDIT_DATA_FILE); &return_error("File Error","Unable to open " . $temp_file); } $found_flag = 0; while () { $line = $_; @user_value_pairs = split (/\|/, $line); $current_auth_user_name = $user_value_pairs[0]; if (($found_flag == 0) && ($current_auth_user_name eq $auth_user_username)) { print EDIT_TEMP_FILE $current_auth_user_name . "|" . $auth_user_new_pswd . "|" . $auth_user_full_name . "|" . $user_resource_list . "|" . $user_group . "|" . $auth_user_email . "|\n"; $found_flag = 1; } else { print EDIT_TEMP_FILE $line; } } close(EDIT_DATA_FILE); close(EDIT_TEMP_FILE); unlink($gauthorized_users_file); rename($temp_file,$gauthorized_users_file); chmod(0777, $gauthorized_users_file); &log_info($ADMIN,"Authorized User $auth_user_full_name password was modified."); print "Content-type: text/html\n\n"; print "\n"; print "\n"; print "\n\n"; print "uReserve"; print ""; print "
"; print ""; print "
Password Updated

"; print ""; print "
"; print ""; print "
Password was successfully updated.
"; print "
"; print "
"; print "



"; print "
"; print ""; print "
"; print "
"; print ""; exit; }