#!/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 " |
";
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 " | ";
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 "uReserveTM 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 "$category_name";
if ($category_description =~ /\S/)
{
print " - $category_description";
}
print " |
";
}
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_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 "";
$category_name = &get_category_name($this_category);
print $category_name;
print "";
print " | ";
print " ";
$last_category = $this_category;
}
print "";
print "";
print "";
if ($blackout_status == -1)
{
print $resource_name . " (unavailable)";
}
else
{
print "$resource_name";
}
print "";
print " | ";
print $row_html;
print " ";
}
print " ";
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 "