From 9c705dc135dff435c0cb59dec4ebf3d0d1620d2c Mon Sep 17 00:00:00 2001 From: Jim Hu Date: Thu, 11 Dec 2008 21:54:52 +0000 Subject: update lots of files --- admin/index.php | 89 ++++++------ day.php | 14 +- default_config.php | 173 ++++++++++++---------- error.php | 7 +- functions/admin_functions.php | 42 +++--- functions/calendar_functions.php | 22 +-- functions/draw_functions.php | 4 +- functions/ical_parser.php | 28 +--- functions/init.inc.php | 108 ++------------ functions/template.php | 128 ++++++++-------- functions/userauth_functions.php | 6 +- index.php | 26 ++-- month.php | 12 +- rss/index.php | 4 +- rss/rss.php | 303 ++++++++------------------------------ rss/rss1.0.php | 305 ++++++++------------------------------- rss/rss2.0.php | 283 +++++++----------------------------- templates/default/admin.tpl | 8 +- week.php | 12 +- year.php | 12 +- 20 files changed, 484 insertions(+), 1102 deletions(-) diff --git a/admin/index.php b/admin/index.php index 11108cc..ef85465 100644 --- a/admin/index.php +++ b/admin/index.php @@ -5,14 +5,14 @@ require_once(BASE.'functions/ical_parser.php'); require_once(BASE.'functions/template.php'); header("Content-Type: text/html; charset=$charset"); -if (empty($default_path)) { +if (empty($phpiCal_config->default_path)) { if (isset($_SERVER['HTTPS']) || strtolower($_SERVER['HTTPS']) == 'on' ) { $default_path = 'https://'.$_SERVER['SERVER_NAME'].':'.$_SERVER['SERVER_PORT'].substr($_SERVER['PHP_SELF'],0,strpos($_SERVER['PHP_SELF'],'/admin/')); } else { $default_path = 'http://'.$_SERVER['SERVER_NAME'].':'.$_SERVER['SERVER_PORT'].substr($_SERVER['PHP_SELF'],0,strpos($_SERVER['PHP_SELF'],'/admin/')); } } -if ($allow_admin != 'yes') { +if ($phpiCal_config->allow_admin != 'yes') { exit(error('The administration menu has been turned off.', $cal, '../')); } @@ -48,74 +48,75 @@ if ($auth_method == 'server') { $login_good = ($is_loged_in) ? '' : 'oops'; $login_bad = ((!$is_loged_in) && ($_GET['action'] == 'login')) ? 'oops' : ''; - -// Delete a calendar -// Not at all secure - need to strip out path info if used by users besides admin in the future -$delete_msg = ''; -if ($_POST['action'] == 'delete') { - foreach ($delete_calendar as $filename) { - if (!delete_cal(urldecode($filename))) { - $delete_msg = $delete_msg . '' . $lang['l_delete_error'] . ' ' . urldecode(substr($filename,0,-4)) . '
'; - } else { - $delete_msg = $delete_msg . '' . urldecode(substr($filename,0,-4)) . ' ' . $lang['l_delete_success'] . '
'; +if(is_loggedin()){ + // Delete a calendar + // Not at all secure - need to strip out path info if used by users besides admin in the future + $delete_msg = ''; + if ($_POST['action'] == 'delete') { + foreach ($delete_calendar as $filename) { + if (!delete_cal(urldecode($filename))) { + $delete_msg = $delete_msg . '' . $lang['l_delete_error'] . ' ' . urldecode(substr($filename,0,-4)) . '
'; + } else { + $delete_msg = $delete_msg . '' . urldecode(substr($filename,0,-4)) . ' ' . $lang['l_delete_success'] . '
'; + } } } -} - -// Add or Update a calendar -$addupdate_msg = ''; -if ((isset($_POST['action'])) && ($_POST['action'] == 'addupdate')) { - for ($filenumber = 1; $filenumber < 6; $filenumber++) { - $file = $_FILES['calfile']; - $addupdate_success = FALSE; - - if (!is_uploaded_file_v4($file['tmp_name'][$filenumber])) { - $upload_error = get_upload_error($file['error'][$filenumber]); - } elseif (!is_uploaded_ics($file['name'][$filenumber])) { - $upload_error = $upload_error_type_lang; - } elseif (!copy_cal($file['tmp_name'][$filenumber], $file['name'][$filenumber])) { - $upload_error = $copy_error_lang . " " . $file['tmp_name'][$filenumber] . " - " . $calendar_path . "/" . $file['name'][$filenumber]; - } else { - $addupdate_success = TRUE; - } - - if ($addupdate_success == TRUE) { - $addupdate_msg = $addupdate_msg . ''.$lang['l_cal_file'].' #'.$filenumber.': '.$lang['l_action_success'].'
'; - } else { - $addupdate_msg = $addupdate_msg . ''.$lang['l_cal_file'].' #'.$filenumber.': '.$lang['l_upload_error'].'
'; + + // Add or Update a calendar + $addupdate_msg = ''; + if ((isset($_POST['action'])) && ($_POST['action'] == 'addupdate')) { + for ($filenumber = 1; $filenumber < 6; $filenumber++) { + $file = $_FILES['calfile']; + $addupdate_success = FALSE; + + if (!is_uploaded_file_v4($file['tmp_name'][$filenumber])) { + $upload_error = get_upload_error($file['error'][$filenumber]); + } elseif (!is_uploaded_ics($file['name'][$filenumber])) { + $upload_error = $upload_error_type_lang; + } elseif (!copy_cal($file['tmp_name'][$filenumber], $file['name'][$filenumber])) { + $upload_error = $copy_error_lang . " " . $file['tmp_name'][$filenumber] . " - " . $calendar_path . "/" . $file['name'][$filenumber]; + } else { + $addupdate_success = TRUE; + } + + if ($addupdate_success == TRUE) { + $addupdate_msg = $addupdate_msg . ''.$lang['l_cal_file'].' #'.$filenumber.': '.$lang['l_action_success'].'
'; + } else { + $addupdate_msg = $addupdate_msg . ''.$lang['l_cal_file'].' #'.$filenumber.': '.$lang['l_upload_error'].'
'; + } } } } $calendar_name = $lang['l_admin_header']; -$page = new Page(BASE.'templates/'.$template.'/admin.tpl'); +$page = new Page(BASE.'templates/'.$phpiCal_config->template.'/admin.tpl'); $page->replace_files(array( - 'header' => BASE.'templates/'.$template.'/header.tpl', - 'footer' => BASE.'templates/'.$template.'/footer.tpl' + 'header' => BASE.'templates/'.$phpiCal_config->template.'/header.tpl', + 'footer' => BASE.'templates/'.$phpiCal_config->template.'/footer.tpl' )); $page->replace_tags(array( - 'version' => $phpicalendar_version, + 'version' => $phpiCal_config->phpicalendar_version, 'event_js' => '', - 'charset' => $charset, - 'default_path' => $default_path.'/', - 'template' => $template, + 'charset' => $phpiCal_config->charset, + 'default_path' => "../".$phpiCal_config->default_path, + 'template' => $phpiCal_config->template, 'cal' => $cal, 'getdate' => $getdate, 'calendar_name' => $calendar_name, 'display_date' => $display_date, 'current_view' => $current_view, 'sidebar_date' => $sidebar_date, - 'rss_powered' => $rss_powered, + 'rss_powered' => $phpiCal_config->rss_powered, 'rss_available' => '', 'rss_valid' => '', 'show_search' => '', 'login_error' => $login_bad, 'display_login' => $login_good, 'delete_msg' => $delete_msg, - 'addupdate_msg' => $addupdate_msg, + 'addupdate_msg' => $addupdate_msg, 'l_day' => $lang['l_day'], 'l_week' => $lang['l_week'], 'l_month' => $lang['l_month'], diff --git a/day.php b/day.php index a6079b0..8f45cab 100644 --- a/day.php +++ b/day.php @@ -7,8 +7,8 @@ if (isset($_GET['jumpto_day'])) { $getdate = date('Ymd', $jumpto_day_time); } } -define('BASE', './'); $current_view = 'day'; +if (!defined('BASE')) define('BASE', './'); require_once(BASE.'functions/ical_parser.php'); require_once(BASE.'functions/list_functions.php'); require_once(BASE.'functions/template.php'); @@ -28,13 +28,13 @@ $start_week_time = strtotime(dateOfWeek($getdate, $week_start_day)); // select for calendars -$list_icals = display_ical_list(availableCalendars($username, $password, $ALL_CALENDARS_COMBINED)); +$list_icals = display_ical_list(availableCalendars($username, $password, $phpiCal_config->ALL_CALENDARS_COMBINED)); $list_years = list_years(); $list_months = list_months(); $list_weeks = list_weeks(); $list_jumps = list_jumps(); $list_calcolors = list_calcolors(); -$list_icals_pick = display_ical_list(availableCalendars($username, $password, $ALL_CALENDARS_COMBINED), TRUE); +$list_icals_pick = display_ical_list(availableCalendars($username, $password, $phpiCal_config->ALL_CALENDARS_COMBINED), TRUE); // login/logout $is_logged_in = ($username != '' && !$invalid_login) ? true : false; @@ -42,7 +42,7 @@ $show_user_login = (!$is_logged_in && $allow_login == 'yes'); $login_querys = login_querys(); $logout_querys = logout_querys(); -$page = new Page(BASE.'templates/'.$template.'/day.tpl'); +$page = new Page(BASE.'templates/'.$phpiCal_config->template.'/day.tpl'); $page->replace_files(array( 'header' => BASE.'templates/'.$template.'/header.tpl', @@ -53,10 +53,10 @@ $page->replace_files(array( )); $page->replace_tags(array( - 'version' => $phpicalendar_version, - 'charset' => $charset, + 'version' => $phpiCal_config->phpicalendar_version, + 'charset' => $phpiCal_config->charset, 'default_path' => '', - 'template' => $template, + 'template' => $phpiCal_config->template, 'cal' => $cal, 'getdate' => $getdate, 'getcpath' => "&cpath=$cpath", diff --git a/default_config.php b/default_config.php index 89fad1c..6c56f6e 100644 --- a/default_config.php +++ b/default_config.php @@ -1,77 +1,104 @@ phpicalendar_version = '2.3rc1'; + // Configuration file for PHP iCalendar 2.25rc1 + // + // To set values, change the text between the single quotes + // Follow instructions to the right for detailed information +#=================Initialize global variables================================= +// Define some magic strings. + $this->ALL_CALENDARS_COMBINED = 'all_calendars_combined971'; + $this->template = 'default'; // Template support + $this->default_view = 'day'; // Default view for calendars = 'day', 'week', 'month', 'year' + $this->minical_view = 'current'; // Where do the mini-calendars go when clicked? = 'day', 'week', 'month', 'current' + $this->default_cal = $this->ALL_CALENDARS_COMBINED; // Exact filename of calendar without .ics. Or set to $this->ALL_CALENDARS_COMBINED to open all calenders combined into one. + #$this->default_cal = 'Other_racing'; // Exact filename of calendar without .ics. Or set to $this->ALL_CALENDARS_COMBINED to open all calenders combined into one. + $this->language = 'English'; // Language support - 'English', 'Polish', 'German', 'French', 'Dutch', 'Danish', 'Italian', 'Japanese', 'Norwegian', 'Spanish', 'Swedish', 'Portuguese', 'Catalan', 'Traditional_Chinese', 'Esperanto', 'Korean' + $this->week_start_day = 'Sunday'; // Day of the week your week starts on + $this->week_length = '7'; // Number of days to display in the week view + $this->day_start = '0600'; // Start time for day grid + $this->day_end = '2000'; // End time for day grid + $this->gridLength = '15'; // Grid distance in minutes for day view, multiples of 15 preferred + $this->num_years = '1'; // Number of years (up and back) to display in 'Jump to' + $this->month_event_lines = '1'; // Number of lines to wrap each event title in month view, 0 means display all lines. + $this->tomorrows_events_lines = '1'; // Number of lines to wrap each event title in the 'Tommorrow's events' box, 0 means display all lines. + $this->allday_week_lines = '1'; // Number of lines to wrap each event title in all-day events in week view, 0 means display all lines. + $this->week_events_lines = '1'; // Number of lines to wrap each event title in the 'Tommorrow's events' box, 0 means display all lines. + $this->timezone = ''; // Set timezone. Read TIMEZONES file for more information + $this->calendar_path = ''; // Leave this blank on most installs, place your full FILE SYSTEM PATH to calendars if they are outside the phpicalendar folder. + $this->second_offset = ''; // The time in seconds between your time and your server's time. + $this->bleed_time = '-1'; // This allows events past midnight to just be displayed on the starting date, only good up to 24 hours. Range from '0000' to '2359', or '-1' for no bleed time. + $this->cookie_uri = ''; // The HTTP URL to the PHP iCalendar directory, ie. http://www.example.com/phpicalendar -- AUTO SETTING -- Only set if you are having cookie issues. + $this->download_uri = ''; // The HTTP URL to your calendars directory, ie. http://www.example.com/phpicalendar/calendars -- AUTO SETTING -- Only set if you are having subscribe issues. + $this->default_path = ''; // The HTTP URL to the PHP iCalendar directory, ie. http://www.example.com/phpicalendar + $this->charset = 'UTF-8'; // Character set your calendar is in, suggested UTF-8, or iso-8859-1 for most languages. + + // Yes/No questions --- 'yes' means Yes, anything else means no. 'yes' must be lowercase. + $this->allow_webcals = 'no'; // Allow http:// and webcal:// prefixed URLs to be used as the $this->cal for remote viewing of "subscribe-able" calendars. This does not have to be enabled to allow specific ones below. + $this->this_months_events = 'yes'; // Display "This month's events" at the bottom off the month page. + $this->enable_rss = 'yes'; // Enable RSS access to your calendars (good thing). + $this->rss_link_to_event = ''; // Set to yes to have links in the feed popup an event window. Default is to link to day.php + $this->show_search = 'no'; // Show the search box in the sidebar. + $this->allow_preferences = 'no'; // Allow visitors to change various preferences via cookies. + $this->printview_default = 'no'; // Set print view as the default view. day, week, and month only supported views for $this->default_view (listed well above). + $this->show_todos = 'yes'; // Show your todo list on the side of day and week view. + $this->show_completed = 'yes'; // Show completed todos on your todo list. + $this->allow_login = 'no'; // Set to yes to prompt for login to unlock calendars. + $this->login_cookies = 'no'; // Set to yes to store authentication information via (unencrypted) cookies. Set to no to use sessions. + $this->support_ical = 'no'; // Set to yes to support the Apple iCal calendar database structure. + $this->recursive_path = 'no'; // Set to yes to recurse into subdirectories of the calendar path. + + // Calendar Caching (decreases page load times) + $this->save_parsed_cals = 'no'; // Saves a copy of the cal in /tmp after it's been parsed. Improves performance. + $this->tmp_dir = '/tmp'; // The temporary directory on your system (/tmp is fine for UNIXes including Mac OS X). Any php-writable folder works. + $this->webcal_hours = '24'; // Number of hours to cache webcals. Setting to '0' will always re-parse webcals. + + // Webdav style publishing + $this->phpicalendar_publishing = '0'; // Set to '1' to enable remote webdav style publish. See 'calendars/publish.php' for complete information; + + // Administration settings (/admin/) + $this->allow_admin = 'no'; // Set to yes to allow the admin page - remember to change the default password if using 'internal' as the $this->auth_method + $this->auth_method = 'internal'; // Valid values are: 'ftp', 'internal', or 'none'. 'ftp' uses the ftp server's username and password as well as ftp commands to delete and copy files. 'internal' uses $this->auth_internal_username and $this->auth_internal_password defined below - CHANGE the password. 'none' uses NO authentication - meant to be used with another form of authentication such as http basic. + $this->auth_internal_username = 'admin'; // Only used if $this->auth_method='internal'. The username for the administrator. + $this->auth_internal_password = 'admin'; // Only used if $this->auth_method='internal'. The password for the administrator. + $this->ftp_server = 'localhost'; // Only used if $this->auth_method='ftp'. The ftp server name. 'localhost' will work for most servers. + $this->ftp_port = '21'; // Only used if $this->auth_method='ftp'. The ftp port. '21' is the default for ftp servers. + $this->ftp_calendar_path = ''; // Only used if $this->auth_method='ftp'. The full path to the calendar directory on the ftp server. If = '', will attempt to deduce the path based on $this->calendar_path, but may not be accurate depending on ftp server config. + + // Calendar colors + // + // You can increase the number of unique colors by adding additional images (monthdot_n.gif) + // and in the css file (default.css) classes .alldaybg_n, .eventbg_n and .eventbg2_n + // Colors will repeat from the beginning for calendars past $this->unique_colors (7 by default), with no limit. + $this->unique_colors = '7'; + + $this->blacklisted_cals = array(); + $this->list_webcals = array(); + $this->locked_cals = array(); + $this->locked_map = array(); + $this->verbose_errors = false; + return true; + } + + public static function getInstance(){ + if (empty(self::$instance)){ + self::$instance = new Configs; + } + return self::$instance; + } + + # val can be an array + public function setProperty($key,$val){ + $this->$key = $val; + return; + } + public function getProperty($key){ + return $this->$key; + } +} -// Configuration file for PHP iCalendar 2.23rc1 -// -// To set values, change the text between the single quotes -// Follow instructions to the right for detailed information - -$template = 'default'; // Template support -$default_view = 'day'; // Default view for calendars = 'day', 'week', 'month', 'year' -$minical_view = 'current'; // Where do the mini-calendars go when clicked? = 'day', 'week', 'month', 'current' -$default_cal = "$ALL_CALENDARS_COMBINED"; // Exact filename of calendar without .ics. Or set to $ALL_CALENDARS_COMBINED to open all calenders combined into one. -#$default_cal = 'Other_racing'; // Exact filename of calendar without .ics. Or set to $ALL_CALENDARS_COMBINED to open all calenders combined into one. -$language = 'English'; // Language support - 'English', 'Polish', 'German', 'French', 'Dutch', 'Danish', 'Italian', 'Japanese', 'Norwegian', 'Spanish', 'Swedish', 'Portuguese', 'Catalan', 'Traditional_Chinese', 'Esperanto', 'Korean' -$week_start_day = 'Sunday'; // Day of the week your week starts on -$week_length = '7'; // Number of days to display in the week view -$day_start = '0600'; // Start time for day grid -$day_end = '2000'; // End time for day grid -$gridLength = '15'; // Grid distance in minutes for day view, multiples of 15 preferred -$num_years = '1'; // Number of years (up and back) to display in 'Jump to' -$month_event_lines = '1'; // Number of lines to wrap each event title in month view, 0 means display all lines. -$tomorrows_events_lines = '1'; // Number of lines to wrap each event title in the 'Tommorrow's events' box, 0 means display all lines. -$allday_week_lines = '1'; // Number of lines to wrap each event title in all-day events in week view, 0 means display all lines. -$week_events_lines = '1'; // Number of lines to wrap each event title in the 'Tommorrow's events' box, 0 means display all lines. -$timezone = ''; // Set timezone. Read TIMEZONES file for more information -$calendar_path = ''; // Leave this blank on most installs, place your full FILE SYSTEM PATH to calendars if they are outside the phpicalendar folder. -$second_offset = ''; // The time in seconds between your time and your server's time. -$bleed_time = '-1'; // This allows events past midnight to just be displayed on the starting date, only good up to 24 hours. Range from '0000' to '2359', or '-1' for no bleed time. -$cookie_uri = ''; // The HTTP URL to the PHP iCalendar directory, ie. http://www.example.com/phpicalendar -- AUTO SETTING -- Only set if you are having cookie issues. -$download_uri = ''; // The HTTP URL to your calendars directory, ie. http://www.example.com/phpicalendar/calendars -- AUTO SETTING -- Only set if you are having subscribe issues. -$default_path = ''; // The HTTP URL to the PHP iCalendar directory, ie. http://www.example.com/phpicalendar -$charset = 'UTF-8'; // Character set your calendar is in, suggested UTF-8, or iso-8859-1 for most languages. - -// Yes/No questions --- 'yes' means Yes, anything else means no. 'yes' must be lowercase. -$allow_webcals = 'no'; // Allow http:// and webcal:// prefixed URLs to be used as the $cal for remote viewing of "subscribe-able" calendars. This does not have to be enabled to allow specific ones below. -$this_months_events = 'yes'; // Display "This month's events" at the bottom off the month page. -$enable_rss = 'yes'; // Enable RSS access to your calendars (good thing). -$rss_link_to_event = ''; // Set to yes to have links in the feed popup an event window. Default is to link to day.php -$show_search = 'no'; // Show the search box in the sidebar. -$allow_preferences = 'no'; // Allow visitors to change various preferences via cookies. -$printview_default = 'no'; // Set print view as the default view. day, week, and month only supported views for $default_view (listed well above). -$show_todos = 'yes'; // Show your todo list on the side of day and week view. -$show_completed = 'yes'; // Show completed todos on your todo list. -$allow_login = 'no'; // Set to yes to prompt for login to unlock calendars. -$login_cookies = 'no'; // Set to yes to store authentication information via (unencrypted) cookies. Set to no to use sessions. -$support_ical = 'no'; // Set to yes to support the Apple iCal calendar database structure. -$recursive_path = 'no'; // Set to yes to recurse into subdirectories of the calendar path. - -// Calendar Caching (decreases page load times) -$save_parsed_cals = 'no'; // Saves a copy of the cal in /tmp after it's been parsed. Improves performance. -$tmp_dir = '/tmp'; // The temporary directory on your system (/tmp is fine for UNIXes including Mac OS X). Any php-writable folder works. -$webcal_hours = '24'; // Number of hours to cache webcals. Setting to '0' will always re-parse webcals. - -// Webdav style publishing -$phpicalendar_publishing = '0'; // Set to '1' to enable remote webdav style publish. See 'calendars/publish.php' for complete information; - -// Administration settings (/admin/) -$allow_admin = 'no'; // Set to yes to allow the admin page - remember to change the default password if using 'internal' as the $auth_method -$auth_method = 'internal'; // Valid values are: 'ftp', 'internal', or 'none'. 'ftp' uses the ftp server's username and password as well as ftp commands to delete and copy files. 'internal' uses $auth_internal_username and $auth_internal_password defined below - CHANGE the password. 'none' uses NO authentication - meant to be used with another form of authentication such as http basic. -$auth_internal_username = 'admin'; // Only used if $auth_method='internal'. The username for the administrator. -$auth_internal_password = 'admin'; // Only used if $auth_method='internal'. The password for the administrator. -$ftp_server = 'localhost'; // Only used if $auth_method='ftp'. The ftp server name. 'localhost' will work for most servers. -$ftp_port = '21'; // Only used if $auth_method='ftp'. The ftp port. '21' is the default for ftp servers. -$ftp_calendar_path = ''; // Only used if $auth_method='ftp'. The full path to the calendar directory on the ftp server. If = '', will attempt to deduce the path based on $calendar_path, but may not be accurate depending on ftp server config. - -// Calendar colors -// -// You can increase the number of unique colors by adding additional images (monthdot_n.gif) -// and in the css file (default.css) classes .alldaybg_n, .eventbg_n and .eventbg2_n -// Colors will repeat from the beginning for calendars past $unique_colors (7 by default), with no limit. -$unique_colors = '7'; - -$blacklisted_cals = array(); -$list_webcals = array(); -$locked_cals = array(); -$locked_map = array(); +$phpiCal_config = Configs::getInstance(); ?> diff --git a/error.php b/error.php index dbf7026..35e9e19 100644 --- a/error.php +++ b/error.php @@ -4,8 +4,8 @@ require_once(BASE.'functions/template.php'); function error($error_msg='There was an error processing the request.', $file='NONE', $error_base='./') { - global $template, $language, $enable_rss, $lang, $charset, $default_path; - if (!isset($template)) $template = 'default'; + global $language, $enable_rss, $lang, $charset, $phpiCal_config; + if (!isset($template)) $template = $phpiCal_config->template; if (!isset($lang['l_powered_by'])) $lang['l_powered_by'] = 'Powered by'; if (!isset($lang['l_error_title'])) $lang['l_error_title'] = 'Error!'; if (!isset($lang['l_error_window'])) $lang['l_error_window'] = 'There was an error!'; @@ -19,7 +19,8 @@ function error($error_msg='There was an error processing the request.', $file='N $display_date = $lang['l_error_title']; $calendar_name = $lang['l_error_title']; - if (empty($default_path)) { + $default_path = $phpiCal_config->default_path; + if (empty($phpiCal_config->default_path)) { if (isset($_SERVER['HTTPS']) || strtolower($_SERVER['HTTPS']) == 'on' ) { $default_path = 'https://'.$_SERVER['SERVER_NAME'].':'.$_SERVER['SERVER_PORT'].substr($_SERVER['PHP_SELF'],0,strpos($_SERVER['PHP_SELF'],'/rss/')); } else { diff --git a/functions/admin_functions.php b/functions/admin_functions.php index 6182d18..f396a28 100644 --- a/functions/admin_functions.php +++ b/functions/admin_functions.php @@ -18,9 +18,9 @@ function is_loggedin () { // returns boolean was the login successful function login ($username, $password) { global $_SESSION; - global $auth_method; + global $phpiCal_config; - switch ($auth_method) { + switch ($phpiCal_config->auth_method) { case 'ftp': $loggedin = login_ftp($username, $password); break; @@ -72,10 +72,9 @@ function login_ftp ($username, $password) { // arg1: string password // returns boolean was login successful function login_internal ($username, $password) { - global $auth_internal_username; - global $auth_internal_password; + global $phpiCal_config; - if ($auth_internal_username == $username && $auth_internal_password == $password) + if ($phpiCal_config->auth_internal_username == $username && $phpiCal_config->auth_internal_password == $password) return TRUE; else return FALSE; @@ -87,16 +86,14 @@ function login_internal ($username, $password) { // returns boolean was delete successful function delete_cal ($filename) { global $_SESSION; - global $auth_method; - global $ftp_server; + global $phpiCal_config; global $calendar_path; - global $ftp_calendar_path; - if ($auth_method == 'ftp') { + if ($phpiCal_config->auth_method == 'ftp') { $filename = get_ftp_calendar_path() . "/" . $filename; // set up basic connection - $conn_id = @ftp_connect($ftp_server); + $conn_id = @ftp_connect($phpiCal_config->ftp_server); // login with username and password $login_result = @ftp_login($conn_id, $_SESSION['phpical_username'], $_SESSION['phpical_password']); @@ -117,18 +114,18 @@ function delete_cal ($filename) { return TRUE; } else { - $filename = $calendar_path . "/" . $filename; + #$filename = $calendar_path . "/" . $filename; - $delete = @unlink($filename); + $delete = unlink($filename); clearstatcache(); if (@file_exists($filename)) { $filesys = eregi_replace("/","\\", $filename); - $delete = @system("del $filesys"); + $delete = system("del $filesys"); clearstatcache(); if (@file_exists($filename)) { - $delete = @chmod ($filename, 0775); - $delete = @unlink($filename); - $delete = @system("del $filesys"); + $delete = chmod ($filename, 0775); + $delete = unlink($filename); + $delete = system("del $filesys"); } } clearstatcache(); @@ -150,16 +147,15 @@ function delete_cal ($filename) { // returns boolean was copy successful function copy_cal ($source, $destination) { global $_SESSION; - global $auth_method; - global $ftp_server; + global $phpiCal_config; global $calendar_path; - if ($auth_method == 'ftp') { + if ($phpiCal_config->auth_method == 'ftp') { $destination = get_ftp_calendar_path() . "/" . basename($destination); $destination = str_replace ("\\", "/", realpath($destination)); // set up basic connection - $conn_id = ftp_connect($ftp_server); + $conn_id = ftp_connect($phpiCal_config->ftp_server); // login with username and password $login_result = ftp_login($conn_id, $_SESSION['phpical_username'], $_SESSION['phpical_password']); @@ -198,11 +194,11 @@ function copy_cal ($source, $destination) { // // return string path to calendar directory for ftp operations function get_ftp_calendar_path() { - global $ftp_calendar_path; + global $phpiCal_config; global $calendar_path; - if ($ftp_calendar_path != '') - return $ftp_calendar_path; + if ($phpiCal_config->ftp_calendar_path != '') + return $phpiCal_config->ftp_calendar_path; else { return str_replace ("\\", "/", realpath($calendar_path)); } diff --git a/functions/calendar_functions.php b/functions/calendar_functions.php index d48713d..f4e7a81 100644 --- a/functions/calendar_functions.php +++ b/functions/calendar_functions.php @@ -14,7 +14,7 @@ // returned. function availableCalendars($username, $password, $cal_filename, $admin = false) { // Import globals. - global $allow_webcals, $allow_login, $calendar_path, $recursive_path, $support_ical, $blacklisted_cals, $list_webcals, $locked_cals, $locked_map, $apache_map, $lang, $ALL_CALENDARS_COMBINED, $_SERVER; + global $allow_webcals, $allow_login, $calendar_path, $recursive_path, $support_ical, $locked_map, $apache_map, $lang, $_SERVER, $phpiCal_config; // Create the list of available calendars. $calendars = array(); @@ -41,12 +41,12 @@ function availableCalendars($username, $password, $cal_filename, $admin = false) $calendars = array(); // This array keeps track of paths we need to search. - $search_paths = array($calendar_path); + $search_paths = array($phpiCal_config->calendar_path); // Add web calendars. - if ($cal_filename_local[0] == $ALL_CALENDARS_COMBINED || $admin) { + if ($cal_filename_local[0] == $phpiCal_config->ALL_CALENDARS_COMBINED || $admin) { if (!isset($http_user) && !$admin) { - foreach ($list_webcals as $file) { + foreach ($phpiCal_config->list_webcals as $file) { // Make sure the URL ends with .ics. if (!preg_match("/.ics$/i", $file)) continue; @@ -57,7 +57,7 @@ function availableCalendars($username, $password, $cal_filename, $admin = false) } // Set some booleans that will dictate our search. - $find_all = ($cal_filename_local[0] == $ALL_CALENDARS_COMBINED || $admin); + $find_all = ($cal_filename_local[0] == $phpiCal_config->ALL_CALENDARS_COMBINED || $admin); // Process all search paths. while (!empty($search_paths)) { @@ -114,18 +114,18 @@ function availableCalendars($username, $password, $cal_filename, $admin = false) // Make sure this is not a blacklisted calendar. $cal_name = getCalendarName($file); - if (in_array($cal_name, $blacklisted_cals)) continue; + if (in_array($cal_name, $phpiCal_config->blacklisted_cals)) continue; // If HTTP authenticated, make sure this calendar is available // to the user. if (isset($http_user)) { - if (!in_array($cal_name, $apache_map[$http_user])) continue; + if (!in_array($cal_name, $phpiCal_config->apache_map[$http_user])) continue; } // Make sure this calendar is not locked. if (!$admin && - in_array($cal_name, $locked_cals) && - !in_array($cal_name, $unlocked_cals)) + in_array($cal_name, $phpiCal_config->locked_cals) && + !in_array($cal_name, $phpiCal_config->unlocked_cals)) { continue; } @@ -205,7 +205,7 @@ function getCalendarName($cal_path) { // // $cals = The calendars (entire path, e.g. from availableCalendars). function display_ical_list($cals, $pick=FALSE) { - global $cal, $ALL_CALENDARS_COMBINED, $current_view, $getdate, $calendar_lang, $all_cal_comb_lang, $cal_filelist, $cal_displaynames; + global $cal, $current_view, $getdate, $calendar_lang, $all_cal_comb_lang, $cal_filelist, $cal_displaynames, $phpiCal_config; // Print each calendar option. $return = ''; foreach ($cals as $cal_tmp) { @@ -287,7 +287,7 @@ function display_ical_list($cals, $pick=FALSE) { // option to open all (non-web) calenders together if (!$pick) { - if ($cal == $ALL_CALENDARS_COMBINED) { + if ($cal == $phpiCal_config->ALL_CALENDARS_COMBINED) { $return .= ""; } else { $return .= ""; diff --git a/functions/draw_functions.php b/functions/draw_functions.php index 2df0f37..20938a9 100644 --- a/functions/draw_functions.php +++ b/functions/draw_functions.php @@ -2,8 +2,8 @@ // function returns starttime and endtime and event length for drawing into a grid function drawEventTimes ($start, $end) { - global $gridLength; - + global $phpiCal_config; + $gridLength = $phpiCal_config->gridLength; preg_match ('/([0-9]{2})([0-9]{2})/', $start, $time); $sta_h = $time[1]; $sta_min = $time[2]; diff --git a/functions/ical_parser.php b/functions/ical_parser.php index 42e576a..f64d4c8 100644 --- a/functions/ical_parser.php +++ b/functions/ical_parser.php @@ -1,29 +1,11 @@ $filename) { $actual_mtime = @filemtime($filename); } - include(BASE.'functions/parse_tzs.php'); + include(BASE.'functions/parse/parse_tzs.php'); $ifile = @fopen($filename, "r"); @@ -171,7 +153,7 @@ foreach ($cal_filelist as $cal_key=>$filename) { break; case 'END:VEVENT': - include BASE."functions/end_vevent.php"; + include BASE."functions/parse/end_vevent.php"; break; case 'END:VTODO': if ((!$vtodo_priority) && ($status == 'COMPLETED')) { @@ -459,7 +441,7 @@ $template_started = getmicrotime(); //If you want to see the values in the arrays, uncomment below. -//print '
';
+#print '
';
 //print_r($master_array);
 //print_r($overlap_array);
 //print_r($day_array);
@@ -467,5 +449,5 @@ $template_started = getmicrotime();
 //print_r($recurrence_delete);
 //print_r($cal_displaynames);
 //print_r($cal_filelist);
-//print '
'; +#print '
'; ?> diff --git a/functions/init.inc.php b/functions/init.inc.php index 1a0007f..fee5d72 100644 --- a/functions/init.inc.php +++ b/functions/init.inc.php @@ -1,70 +1,17 @@ ALL_CALENDARS_COMBINED) { + $calcheck = $phpiCal_config->calendar_path.'/'.$default_cal_check.'.ics'; $calcheckopen = @fopen($calcheck, "r"); if ($calcheckopen == FALSE) { $cal_filenames = explode(',',$default_cal); @@ -127,15 +50,16 @@ if (isset($_GET['cal'])) { $cal_filenames[0] = $default_cal_check; } } else { - $cal_filenames[0] = $ALL_CALENDARS_COMBINED; + $cal_filenames[0] = $phpiCal_config->ALL_CALENDARS_COMBINED; } } else { - $cal_filenames = explode(',',$default_cal); + $cal_filenames = explode(',',$phpiCal_config->default_cal); } } + //load cal_filenames if $ALL_CALENDARS_COMBINED -if ($cal_filenames[0] == $ALL_CALENDARS_COMBINED){ - $cal_filenames = availableCalendars($username, $password, $ALL_CALENDARS_COMBINED); +if ($cal_filenames[0] == $phpiCal_config->ALL_CALENDARS_COMBINED){ + $cal_filenames = availableCalendars($username, $password, $phpiCal_config->ALL_CALENDARS_COMBINED); } // Separate the calendar identifiers into web calendars and local // calendars. @@ -158,7 +82,7 @@ foreach ($cal_filenames as $cal_filename) { // Otherwise it is a local calendar. else { // Check blacklisted. - if (in_array($cal_filename, $blacklisted_cals) && $cal_filename !='') { + if (in_array($cal_filename, $phpiCal_config->blacklisted_cals) && $cal_filename !='') { exit(error($lang['l_error_restrictedcal'], $cal_filename)); } $local_cals[] = urldecode(str_replace(".ics", '', basename($cal_filename))); @@ -254,7 +178,7 @@ $cal = implode(',', $cals); asort($cal_displaynames); $cal_displayname = implode(', ', $cal_displaynames); -$rss_powered = ($enable_rss == 'yes') ? 'yes' : ''; +$rss_powered = ($phpiCal_config->enable_rss == 'yes') ? 'yes' : ''; function getmicrotime() { list($usec, $sec) = explode(' ',microtime()); diff --git a/functions/template.php b/functions/template.php index e5aab05..c47d2a6 100644 --- a/functions/template.php +++ b/functions/template.php @@ -5,7 +5,7 @@ class Page { var $page; function draw_subscribe($template_p) { - global $template, $getdate, $cal, $ALL_CALENDARS_COMBINED, $subscribe_path, $download_filename; + global $phpiCal_config, $getdate, $cal, $ALL_CALENDARS_COMBINED, $subscribe_path, $download_filename; if ($cal != $ALL_CALENDARS_COMBINED && $subscribe_path != '' && $download_filename != '') { $this->page = str_replace('{SUBSCRIBE_PATH}', $subscribe_path, $this->page); $this->page = str_replace('{DOWNLOAD_FILENAME}', $download_filename, $this->page); @@ -15,7 +15,7 @@ class Page { } function draw_admin() { - global $template, $getdate, $cal, $master_array, $is_loged_in; + global $phpiCal_config, $getdate, $cal, $master_array, $is_loged_in; if ($is_loged_in == TRUE) { // Print Calendar Checkboxes @@ -55,7 +55,7 @@ class Page { } function draw_print($template_p) { - global $template, $getdate, $cal, $master_array, $daysofweek_lang, $week_start_day, $printview, $dateFormat_day, $timeFormat, $week_start, $week_end, $lang; + global $phpiCal_config, $getdate, $cal, $master_array, $printview, $dateFormat_day, $timeFormat, $week_start, $week_end, $lang; preg_match("!<\!-- loop events on -->(.*)<\!-- loop events off -->!is", $this->page, $match1); preg_match("!<\!-- switch some_events on -->(.*)<\!-- loop events on -->!is", $this->page, $match3); $loop_event = trim($match1[1]); @@ -132,7 +132,7 @@ class Page { } function draw_search($template_p) { - global $template, $getdate, $cal, $the_arr, $daysofweek_lang, $week_start_day, $printview, $dateFormat_day, $timeFormat, $week_start, $week_end, $lang; + global $phpiCal_config, $getdate, $cal, $the_arr, $printview, $dateFormat_day, $timeFormat, $week_start, $week_end, $lang; preg_match("!<\!-- switch results on -->(.*)<\!-- switch results off -->!is", $this->page, $match1); preg_match("!<\!-- switch recur on -->(.*)<\!-- loop recur off -->!is", $this->page, $match2); @@ -246,7 +246,7 @@ class Page { }#end draw_search function draw_week($template_p) { - global $unique_colors, $start_week_time, $template, $getdate, $cal, $master_array, $daysofweek_lang, $week_start_day, $dateFormat_week_list, $current_view, $day_array, $timeFormat, $gridLength, $timeFormat_small, $day_start, $week_length; + global $phpiCal_config, $start_week_time, $getdate, $cal, $master_array, $dateFormat_week_list, $current_view, $day_array, $timeFormat, $timeFormat_small, $week_length; // Figure out colspans $dayborder = 0; @@ -287,7 +287,7 @@ class Page { if (is_array($master_array[$get_date]['-1']) && !empty($master_array[$get_date]['-1']) ) { foreach ($master_array[$get_date]['-1'] as $uid => $allday) { $event_calno = $allday['calnumber']; - $event_calno = (($event_calno - 1) % $unique_colors) + 1; + $event_calno = (($event_calno - 1) % $phpiCal_config->unique_colors) + 1; $event = openevent($get_date, -1, $uid, $allday, 1, 11, 'psf'); $loop_tmp = str_replace('{ALLDAY}', $event, $loop_ad); $loop_tmp = str_replace('{CALNO}', $event_calno, $loop_tmp); @@ -302,13 +302,13 @@ class Page { // Replaces the daysofweek preg_match("!<\!-- loop daysofweek on -->(.*)<\!-- loop daysofweek off -->!is", $this->page, $match1); $loop_dof = trim($match1[1]); - $start_wt = strtotime(dateOfWeek($getdate, $week_start_day)); - $start_day = strtotime($week_start_day); + $start_wt = strtotime(dateOfWeek($getdate, $phpiCal_config->week_start_day)); + $start_day = strtotime($phpiCal_config->week_start_day); for ($i=0; $i<$week_length; $i++) { $day_num = date("w", $start_day); $daylink = date('Ymd', $start_wt); if ($current_view == 'day') { - $weekday = $daysofweek_lang[$day_num]; + $weekday = $phpiCal_config->daysofweek_lang[$day_num]; } else { $weekday = localizeDate($dateFormat_week_list, strtotime($daylink)); } @@ -359,16 +359,16 @@ class Page { if (ereg("([0-9]{1,2}):00", $key)) { $weekdisplay .= ''; - $weekdisplay .= ''.$key.''; - $weekdisplay .= ''; - } elseif ($cal_time == $day_start) { + $weekdisplay .= ''.$key.''; + $weekdisplay .= ''; + } elseif ($cal_time == $phpiCal_config->day_start) { $size_tmp = 60 - (int)substr($cal_time,2,2); $weekdisplay .= ''; - $weekdisplay .= ''.$key.''; - $weekdisplay .= ''; + $weekdisplay .= ''.$key.''; + $weekdisplay .= ''; } else { $weekdisplay .= ''; - $weekdisplay .= ''; + $weekdisplay .= ''; } // initialize $thisdate again @@ -380,7 +380,7 @@ class Page { $dayborder = 0; unset($this_time_arr); - if ($day_start == $cal_time && isset($master_array[$thisday]) && is_array($master_array[$thisday])) { + if ($phpiCal_config->day_start == $cal_time && isset($master_array[$thisday]) && is_array($master_array[$thisday])) { foreach($master_array[$thisday] as $time_key => $time_arr) { if ((int)$time_key <= (int)$cal_time) { if (is_array($time_arr) && $time_key != '-1') { @@ -411,13 +411,13 @@ class Page { $j = 0; while (isset($event_length[$thisday][$j])) { if ($event_length[$thisday][$j]["state"] == "ended") { - $event_length[$thisday][$j] = array ("length" => ($drawEvent["draw_length"] / $gridLength), "key" => $eventKey, "overlap" => $loopevent["event_overlap"],"state" => "begin"); + $event_length[$thisday][$j] = array ("length" => ($drawEvent["draw_length"] / $phpiCal_config->gridLength), "key" => $eventKey, "overlap" => $loopevent["event_overlap"],"state" => "begin"); break; } $j++; } if ($j == sizeof($event_length[$thisday])) { - array_push ($event_length[$thisday], array ("length" => ($drawEvent["draw_length"] / $gridLength), "key" => $eventKey, "overlap" => $loopevent["event_overlap"],"state" => "begin")); + array_push ($event_length[$thisday], array ("length" => ($drawEvent["draw_length"] / $phpiCal_config->gridLength), "key" => $eventKey, "overlap" => $loopevent["event_overlap"],"state" => "begin")); } } } @@ -456,7 +456,7 @@ class Page { $event_calno = $this_time_arr[$uid]['calnumber']; $event_status = strtolower($this_time_arr[$uid]['status']); $event_recur = $this_time_arr[$uid]['recur']; - $event_calno = (($event_calno - 1) % $unique_colors) + 1; + $event_calno = (($event_calno - 1) % $phpiCal_config->unique_colors) + 1; $confirmed = ''; if (is_array($event_recur)) $confirmed .= ' '; if ($event_status != '') { @@ -512,16 +512,15 @@ class Page { } function draw_day($template_p) { - global $template, $getdate, $cal, $master_array, $unique_colors, $daysofweek_lang, $week_start_day, $dateFormat_week_list, $current_view, $day_array, $timeFormat, $gridLength, $day_start; - + global $getdate, $cal, $master_array, $dateFormat_week_list, $current_view, $day_array, $timeFormat, $phpiCal_config; // Replaces the allday events - $replace = ''; + $replace = ''; if (is_array($master_array[$getdate]['-1'])) { preg_match("!<\!-- loop allday on -->(.*)<\!-- loop allday off -->!is", $this->page, $match1); $loop_ad = trim($match1[1]); foreach ($master_array[$getdate]['-1'] as $uid => $allday) { $event_calno = $allday['calnumber']; - $event_calno = (($event_calno - 1) % $unique_colors) + 1; + $event_calno = (($event_calno - 1) % $phpiCal_config->unique_colors) + 1; $event = openevent($getdate, -1, $uid, $allday); $loop_tmp = str_replace('{ALLDAY}', $event, $loop_ad); $loop_tmp = str_replace('{CALNO}', $event_calno, $loop_tmp); @@ -533,8 +532,8 @@ class Page { // Replaces the daysofweek preg_match("!<\!-- loop daysofweek on -->(.*)<\!-- loop daysofweek off -->!is", $this->page, $match1); $loop_dof = trim($match1[1]); - $start_wt = strtotime(dateOfWeek($getdate, $week_start_day)); - $start_day = strtotime(dateOfWeek($getdate, $week_start_day)); + $start_wt = strtotime(dateOfWeek($getdate, $phpiCal_config->week_start_day)); + $start_day = strtotime(dateOfWeek($getdate, $phpiCal_config->week_start_day)); for ($i=0; $i<7; $i++) { $day_num = date("w", $start_day); $daylink = date('Ymd', $start_wt); @@ -584,7 +583,7 @@ class Page { preg_match('/([0-9]{4})([0-9]{2})([0-9]{2})/', $getdate, $day_array2); $this_day = $day_array2[3]; $this_month = $day_array2[2]; - $this_year = $day_array2[1]; + $this_year = $day_array2[1]; foreach ($day_array as $key) { preg_match('/([0-9]{2})([0-9]{2})/', $key, $regs_tmp); $cal_time = $key; @@ -592,8 +591,8 @@ class Page { $key = date ($timeFormat, $key); unset($this_time_arr); - // add events that overlap $day_start instead of cutting them out completely - if (($day_start == $cal_time) && (isset($master_array[$getdate]))) { + // add events that overlap $phpiCal_config->day_start instead of cutting them out completely + if (($phpiCal_config->day_start == $cal_time) && (isset($master_array[$getdate]))) { foreach($master_array[$getdate] as $time_key => $time_arr) { if ((int)$time_key <= (int)$cal_time) { if (is_array($time_arr) && $time_key != '-1') { @@ -621,28 +620,28 @@ class Page { $j = 0; while (isset($event_length[$j])) { if ($event_length[$j]['state'] == 'ended') { - $event_length[$j] = array ('length' => ($drawEvent['draw_length'] / $gridLength), 'key' => $eventKey, 'overlap' => $loopevent['event_overlap'],'state' => 'begin'); + $event_length[$j] = array ('length' => ($drawEvent['draw_length'] / $phpiCal_config->gridLength), 'key' => $eventKey, 'overlap' => $loopevent['event_overlap'],'state' => 'begin'); break; } $j++; } if ($j == sizeof($event_length)) { - array_push ($event_length, array ('length' => ($drawEvent['draw_length'] / $gridLength), 'key' => $eventKey, 'overlap' => $loopevent['event_overlap'],'state' => 'begin')); + array_push ($event_length, array ('length' => ($drawEvent['draw_length'] / $phpiCal_config->gridLength), 'key' => $eventKey, 'overlap' => $loopevent['event_overlap'],'state' => 'begin')); } } } if (preg_match('/([0-9]{1,2}):00/', $key)) { $daydisplay .= ''."\n"; - $daydisplay .= ''.$key.''."\n"; - $daydisplay .= ''."\n"; - } elseif($cal_time == $day_start) { + $daydisplay .= ''.$key.''."\n"; + $daydisplay .= ''."\n"; + } elseif($cal_time == $phpiCal_config->day_start) { $size_tmp = 60 - (int)substr($cal_time,2,2); $daydisplay .= ''."\n"; - $daydisplay .= "$key\n"; - $daydisplay .= ''."\n"; + $daydisplay .= "gridLength) . "\" align=\"center\" valign=\"top\" width=\"60\" class=\"timeborder\">$key\n"; + $daydisplay .= ''."\n"; } else { $daydisplay .= ''."\n"; - $daydisplay .= ''."\n"; + $daydisplay .= ''."\n"; } if ($dayborder == 0) { $class = ' class="dayborder"'; @@ -677,7 +676,7 @@ class Page { $event_calno = $this_time_arr[$uid]['calnumber']; $event_recur = $this_time_arr[$uid]['recur']; $event_status = strtolower($this_time_arr[$uid]['status']); - $event_calno = (($event_calno - 1) % $unique_colors) + 1; + $event_calno = (($event_calno - 1) % $phpiCal_config->unique_colors) + 1; $confirmed = ''; if (is_array($event_recur)) $confirmed .= ' '; if ($event_status != '') $confirmed .= ' '; @@ -724,16 +723,15 @@ class Page { } } - $daydisplay .= ''."\n"; - } - + $daydisplay .= ''."\n"; + } $this->page = preg_replace('!<\!-- loop row on -->(.*)<\!-- loop event off -->!is', $daydisplay, $this->page); } function tomorrows_events() { - global $template, $getdate, $master_array, $next_day, $timeFormat, $tomorrows_events_lines; + global $phpiCal_config, $getdate, $master_array, $next_day, $timeFormat, $tomorrows_events_lines; preg_match("!<\!-- switch t_allday on -->(.*)<\!-- switch t_allday off -->!is", $this->page, $match1); preg_match("!<\!-- switch t_event on -->(.*)<\!-- switch t_event off -->!is", $this->page, $match2); @@ -770,7 +768,7 @@ class Page { } function get_vtodo() { - global $template, $getdate, $master_array, $next_day, $timeFormat, $tomorrows_events_lines, $show_completed, $show_todos; + global $phpiCal_config, $getdate, $master_array, $next_day, $timeFormat, $tomorrows_events_lines, $show_completed, $show_todos; preg_match("!<\!-- switch show_completed on -->(.*)<\!-- switch show_completed off -->!is", $this->page, $match1); preg_match("!<\!-- switch show_important on -->(.*)<\!-- switch show_important off -->!is", $this->page, $match2); @@ -855,7 +853,7 @@ class Page { } function draw_month($template_p, $offset = '+0', $type) { - global $template, $getdate, $master_array, $this_year, $this_month, $unique_colors, $dateFormat_month, $week_start_day, $cal, $minical_view, $month_event_lines, $daysofweekreallyshort_lang, $daysofweekshort_lang, $daysofweek_lang, $timeFormat_small, $timeFormat; + global $phpiCal_config, $getdate, $master_array, $this_year, $this_month, $dateFormat_month, $cal, $minical_view, $month_event_lines, $daysofweekreallyshort_lang, $daysofweekshort_lang, $timeFormat_small, $timeFormat; preg_match("!<\!-- loop weekday on -->(.*)<\!-- loop weekday off -->!is", $template_p, $match1); preg_match("!<\!-- loop monthdays on -->(.*)<\!-- loop monthdays off -->!is", $template_p, $match2); preg_match("!<\!-- switch notthismonth on -->(.*)<\!-- switch notthismonth off -->!is", $template_p, $match3); @@ -887,8 +885,8 @@ class Page { $dateFormat_month_local = str_replace("%B", "%B", $dateFormat_month); $dateFormat_month_local = str_replace("%Y", "%Y", $dateFormat_month_local); - //$start_day = strtotime($week_start_day); - $start_day = strtotime(dateOfWeek($getdate, $week_start_day)); + //$start_day = strtotime($phpiCal_config->week_start_day); + $start_day = strtotime(dateOfWeek($getdate, $phpiCal_config->week_start_day)); $month_title = localizeDate ($dateFormat_month_local, $fake_getdate_time); $month_date = date ('Ymd', $fake_getdate_time); @@ -897,7 +895,7 @@ class Page { } elseif ($type == 'medium') { $langtype = $daysofweekshort_lang; } elseif ($type == 'large') { - $langtype = $daysofweek_lang; + $langtype = $phpiCal_config->daysofweek_lang; } $weekday_loop = ''; @@ -910,7 +908,7 @@ class Page { $weekday_loop .= $loop_tmp; } - $start_day = strtotime(dateOfWeek($first_of_month, $week_start_day)); + $start_day = strtotime(dateOfWeek($first_of_month, $phpiCal_config->week_start_day)); $i = 0; $whole_month = TRUE; @@ -934,25 +932,25 @@ class Page { foreach ($master_array[$daylink] as $cal_time => $event_times) { foreach ($event_times as $uid => $val) { $event_calno = $val['calnumber']; - $event_calno = (($event_calno - 1) % $unique_colors) + 1; + $event_calno = (($event_calno - 1) % $phpiCal_config->unique_colors) + 1; if (!isset($val['event_start'])) { if ($type == 'large') { - $switch['ALLDAY'] .= '
'; + $switch['ALLDAY'] .= '
'; $switch['ALLDAY'] .= openevent($daylink, $cal_time, $uid, $val, $month_event_lines, 15, 'psf'); $switch['ALLDAY'] .= (isset($val['location']) && $val['location'] != '') ? $val['location']."
" : ''; $switch['ALLDAY'] .= '
'; } else { - $switch['ALLDAY'] .= ' '; + $switch['ALLDAY'] .= ' '; } } else { $start2 = date($timeFormat_small, $val['start_unixtime']); if ($type == 'large') { - $switch['EVENT'] .= '
'; + $switch['EVENT'] .= '
'; $switch['EVENT'] .= openevent($daylink, $cal_time, $uid, $val, $month_event_lines, 10, 'ps3', "$start2 ").''; $switch['EVENT'] .= (isset($val['location']) && $val['location'] != '') ? "
".$val['location']."
" : ''; $switch['EVENT'] .= '
'; } else { - $switch['EVENT'] = ' '; + $switch['EVENT'] = ' '; } } } @@ -997,7 +995,7 @@ class Page { } function monthbottom() { - global $template, $getdate, $master_array, $this_year, $this_month, $cal, $timeFormat, $timeFormat_small, $dateFormat_week_list, $lang; + global $phpiCal_config, $getdate, $master_array, $this_year, $this_month, $cal, $timeFormat, $timeFormat_small, $dateFormat_week_list, $lang; preg_match("!<\!-- loop showbottomevents_odd on -->(.*)<\!-- loop showbottomevents_odd off -->!is", $this->page, $match1); preg_match("!<\!-- loop showbottomevents_even on -->(.*)<\!-- loop showbottomevents_even off -->!is", $this->page, $match2); @@ -1059,21 +1057,21 @@ class Page { } function Page($file = 'std.tpl') { - global $template; + global $phpiCal_config; if (!file_exists($file)){ #look for it in default if not found - $file = str_replace("templates/$template","templates/default",$file); + $file = str_replace("templates/$phpiCal_config->template","templates/default",$file); if (!file_exists($file)) die("Template file $file not found."); } $this->page = join('', file($file)); } function parse($file) { - global $template; $lang; - if (basename(dirname($file)) == "$template" || $file =='./functions/event.js'){ + global $phpiCal_config; $lang; + if (basename(dirname($file)) == "$phpiCal_config->template" || $file =='./functions/event.js'){ if (!is_file($file)){ #look for it in default if not found - $file = str_replace("templates/$template","templates/default",$file); + $file = str_replace("templates/$phpiCal_config->template","templates/default",$file); } if (!is_file($file)){ exit(error($lang['l_error_path'], $file)); @@ -1124,7 +1122,7 @@ class Page { } function output() { - global $template, $php_started, $lang, $enable_rss, $template_started, $cpath; + global $phpiCal_config, $php_started, $lang, $template_started, $cpath; // Looks for {MONTH} before sending page out preg_match_all ('!\{MONTH_([A-Z]*)\|?([+|-])([0-9]{1,2})\}!is', $this->page, $match); @@ -1132,19 +1130,19 @@ class Page { $i=0; foreach ($match[1] as $key => $val) { if ($match[1][$i] == 'SMALL') { - $template_file = $this->parse(BASE.'templates/'.$template.'/month_small.tpl'); + $phpiCal_config->template_file = $this->parse(BASE.'templates/'.$phpiCal_config->template.'/month_small.tpl'); $type = 'small'; $offset = $match[2][$i].$match[3][$i]; } elseif ($match[1][$i] == 'MEDIUM') { - $template_file = $this->parse(BASE.'templates/'.$template.'/month_medium.tpl'); + $phpiCal_config->template_file = $this->parse(BASE.'templates/'.$phpiCal_config->template.'/month_medium.tpl'); $type = 'medium'; $offset = $match[3][$i]; } else { - $template_file = $this->parse(BASE.'templates/'.$template.'/month_large.tpl'); + $phpiCal_config->template_file = $this->parse(BASE.'templates/'.$phpiCal_config->template.'/month_large.tpl'); $type = 'large'; $offset = $match[2][$i].$match[3][$i]; } - $data = $this->draw_month($template_file, $offset, $type); + $data = $this->draw_month($phpiCal_config->template_file, $offset, $type); $this->page = str_replace($match[0][$i], $data, $this->page); $i++; } @@ -1152,10 +1150,10 @@ class Page { $php_ended = @getmicrotime(); $generated1 = number_format(($php_ended-$php_started),3); - $generated2 = number_format(($php_ended-$template_started),3); + $generated2 = number_format(($php_ended-$phpiCal_config->template_started),3); $this->page = str_replace('{GENERATED1}', $generated1, $this->page); $this->page = str_replace('{GENERATED2}', $generated2, $this->page); - if ($enable_rss != 'yes') { + if ($phpiCal_config->enable_rss != 'yes') { $this->page = preg_replace('!<\!-- switch rss_powered on -->(.*)<\!-- switch rss_powered off -->!is', '', $this->page); } else { $this->page = str_replace('{BASE}', BASE, $this->page); diff --git a/functions/userauth_functions.php b/functions/userauth_functions.php index 017841e..3808653 100644 --- a/functions/userauth_functions.php +++ b/functions/userauth_functions.php @@ -43,7 +43,7 @@ function logout_querys() { // if no valid login is found. Returns a boolean invalid_login to // indicate that the login is invalid. function user_login() { - global $_COOKIE, $_GET, $_POST, $_SERVER; + global $_COOKIE, $_GET, $_POST, $_SERVER, $phpiCal_config; global $login_cookies, $cookie_uri, $locked_map; // Initialize return values. @@ -96,7 +96,7 @@ function user_login() { } // Check to make sure the username and password is valid. - if (!array_key_exists("$username:$password", $locked_map)) { + if (!array_key_exists("$username:$password", $phpiCal_config->locked_map)) { // Remember the invalid login, because we may want to display // a message elsewhere or check validity. return array($username, $password, true); @@ -120,7 +120,7 @@ function user_login() { // // Returns an empty username and password. function user_logout() { - global $login_cookies, $cookie_uri; + global $login_cookies, $cookie_uri, $phpiCal_config; // Clear the login cookie or session authentication values. if ($login_cookies == 'yes') { diff --git a/index.php b/index.php index bac4eab..a865512 100644 --- a/index.php +++ b/index.php @@ -1,27 +1,21 @@ printview_default == 'yes') { + $printview = $phpiCal_config->default_view; + $phpiCal_config->setProperty('default_view', "print.php"); } else { $check = array ('day', 'week', 'month', 'year'); - if (in_array($default_view, $check)) { - $default_view = $default_view . '.php'; + if (in_array($phpiCal_config->default_view, $check)) { + $phpiCal_config->setProperty('default_view', $phpiCal_config->default_view . '.php'); } else { - die; + die('illegal view'); } } if(isset($_GET['cpath'])){ - $default_view .= '?cpath='.$_GET['cpath']; + $phpiCal_config->default_view .= '?cpath='.$_GET['cpath']; } -header("Location: $default_view"); +header("Location: $phpiCal_config->default_view"); ?> diff --git a/month.php b/month.php index f817a0b..0a018aa 100644 --- a/month.php +++ b/month.php @@ -38,13 +38,13 @@ $thisday2 = localizeDate($dateFormat_week_list, $unix_time); $num_of_events2 = 0; // select for calendars -$list_icals = display_ical_list(availableCalendars($username, $password, $ALL_CALENDARS_COMBINED)); +$list_icals = display_ical_list(availableCalendars($username, $password, $phpiCal_config->ALL_CALENDARS_COMBINED)); $list_years = list_years(); $list_months = list_months(); $list_weeks = list_weeks(); $list_jumps = list_jumps(); $list_calcolors = list_calcolors(); -$list_icals_pick = display_ical_list(availableCalendars($username, $password, $ALL_CALENDARS_COMBINED), TRUE); +$list_icals_pick = display_ical_list(availableCalendars($username, $password, $phpiCal_config->ALL_CALENDARS_COMBINED), TRUE); $page = new Page(BASE.'templates/'.$template.'/month.tpl'); @@ -57,16 +57,16 @@ $page->replace_files(array( )); $page->replace_tags(array( - 'version' => $phpicalendar_version, - 'charset' => $charset, - 'template' => $template, + 'version' => $phpiCal_config->phpicalendar_version, + 'charset' => $phpiCal_config->charset, + 'template' => $phpiCal_config->template, 'cal' => $cal, 'getdate' => $getdate, 'getcpath' => "&cpath=$cpath", 'cpath' => $cpath, 'calendar_name' => $cal_displayname, 'display_date' => $display_date, - 'rss_powered' => $rss_powered, + 'rss_powered' => $phpiCal_config->rss_powered, 'default_path' => '', 'rss_available' => '', 'rss_valid' => '', diff --git a/rss/index.php b/rss/index.php index be435b1..1d265db 100644 --- a/rss/index.php +++ b/rss/index.php @@ -7,7 +7,7 @@ define('BASE','../'); require_once(BASE.'functions/ical_parser.php'); require_once(BASE.'functions/calendar_functions.php'); -if ($enable_rss != 'yes') { +if ($phpiCal_config->enable_rss != 'yes') { exit(error($lang['l_rss_notenabled'], $cal, '../')); } @@ -25,7 +25,7 @@ $display_date = "RSS Info"; $rss_list = "\n"; $xml_icon ="xml"; -$filelist = availableCalendars($username, $password, $ALL_CALENDARS_COMBINED); +$filelist = availableCalendars($username, $password, $phpiCal_config->ALL_CALENDARS_COMBINED); foreach ($filelist as $file) { // $cal_filename is the filename of the calendar without .ics // $cal is a urlencoded version of $cal_filename diff --git a/rss/rss.php b/rss/rss.php index 65d669c..e6942a4 100644 --- a/rss/rss.php +++ b/rss/rss.php @@ -1,257 +1,78 @@ '."\n"; + +require(BASE.'rss/rss_common.php'); + +function rss_top(){ + global $cal_displayname, $theview, $default_path, $cpath, $lang, $rss_link, $rss_language; + $rss = ""."\n"; + $rss .= ''."\n"; + $rss .= ''."\n"; + $rss .= ''."\n"; + $rss .= ''.$cal_displayname; + if ($theview !=""){$rss .= ' - '.$theview;} + $rss .= "\n"; + + $rss .= ''.htmlspecialchars("$default_path").''."\n"; + if (isset($cpath) && $cpath !='') $rss_link.="?cpath=$cpath"; + $rss .= "$rss_link\n"; + + $rss .= ''.$cal_displayname.' '.$lang['l_calendar'].' - '.$theview.''."\n"; + $rss .= ''.$rss_language.''."\n"; + $rss .= 'Copyright '.date(Y).', '.htmlspecialchars ("$default_path").''."\n"; + return $rss; } -include_once(BASE.'functions/date_functions.php'); - - -//set the range of days to return based on the view chosen -$rssview = $_GET['rssview']; -if (isset($_GET['getdate']) && $_GET['getdate'] !=''){ - $getdate = $_GET['getdate']; -}else{ - $getdate = date("Ymd"); +function rss_li($rss_link, $uid){ + $return = ""; } -# for all views, $fromdate is the first day to be shown and $todate should be the last day. -switch ($rssview){ - case 'day': - $fromdate = $getdate; - $todate = $getdate; - $theview = $lang['l_day']; - break; - case 'week': - $fromdate = dateOfWeek($getdate, 'Sunday'); - $todate = date("Ymd", strtotime($fromdate) + 6*24*60*60); - $theview = $lang['l_week']." of ".date('n/d/Y',strtotime($fromdate)); - break; - case 'month': - $parse_month = date ("Ym", strtotime($getdate)); - $fromdate = ($parse_month *100) + 1; - $todate = ($parse_month *100) + date("t",strtotime($getdate)); - $theview = date('M Y',strtotime($fromdate)); - break; - case 'year': - if(isset($_GET['year'])){ - $theyear = $_GET['year']; - }else{ - $theyear = substr($getdate,0,4); - } - $fromdate = ($theyear*10000)+101; - $todate = date("Ymd", strtotime($theyear*10000+1231)); - $theview = $theyear; - break; - case 'daysfrom': - $fromdate = $getdate; - $todate = date("Ymd", strtotime($getdate) + $_GET['days']*60*60*24); - $theview = $_GET['days']." days from ".date('n/d/Y',strtotime($fromdate)); - break; - case 'daysto': - $todate = $getdate; - $fromdate = date("Ymd", strtotime($getdate) - $_GET['days']*60*60*24); - $theview = $_GET['days']." days before ".date('n/d/Y',strtotime($todate)); - break; - case 'range': - if(isset($_GET['from'])){ - $fromdate = $_GET['from']; - }else{ - $fromdate = $getdate; - } - $todate = $_GET['to']; - $theview = date('n/d/Y',strtotime($fromdate)).'-'.date('n/d/Y',strtotime($todate)); - break; - default: - #default to week - $fromdate = dateOfWeek($getdate, 'Sunday'); - $todate = date("Ymd", strtotime($fromdate) + 6*24*60*60); - $theview = ""; +function enclose_items($rss_items){ + return $rss_items; } -#need to give ical_parser the most distant date to correctly set up master_array. -$getdate = $todate; -#echo "from:$fromdate to:$todate"; - -#Note that ical_parser supplies cal_displayname. -include(BASE.'functions/ical_parser.php'); - -$events_count = 0; -// calculate a value for Last Modified and ETag -$cal = implode(",",$cals); - -//get filemtime from master array -$filemod = 0; #default to start of unix era, overwrite with most recent mtime from master array -foreach ($master_array['-4'] as $calinfo){ - if ($calinfo['mtime'] > $filemod) $filemod = $calinfo['mtime']; -} -$filemodtime = date("r", $filemod); - -//send relevant headers -header ("Last-Modified: $filemodtime"); -header ("ETag:\"$filemodtime\""); - -// checks the user agents headers to see if they kept track of our -// stuff, if so be nice and send back a 304 and exit. - -if ( ($_SERVER['HTTP_IF_MODIFIED_SINCE'] == $filemodtime) || ($_SERVER['HTTP_IF_NONE_MATCH'] == $filemodtime)){ - header ("HTTP/1.1 304 Not Modified"); - exit; +function rss_item(){ + global $uid,$event_start,$rss_title,$rss_link, $dayofweek, $event_text, $rss_description, $val; + $rss .= ''."\n"; + $rss .= ''.$uid.''."\n"; + $rss .= ''.$event_start.''."\n"; + $rss .= ''.$rss_title.''."\n"; + /* custom stuff for Jim Hu's RSS feeds. Deprecated + $rss .= ''.$dayofweek.''."\n"; + $rss .= ''.$event_text.''."\n"; + $rss .= ''.$description.''."\n"; + $rss .= ''.$val["description"].''."\n"; + $rss .= ''.$val['attendee'].''."\n"; + $rss .= ''.$val['organizer'].''."\n"; + $rss .= ''.$val['status'].''."\n"; + */ + $rss .= ''.$rss_link.''."\n"; + $rss .= ''.$rss_description.''."\n"; + if (isset($val['location']) && $val['location'] !=''){ + $location = str_replace('&','&',$val['location']); + $location = str_replace('&amp;','&',$location); + $rss .= ''.$location."\n"; + } + $rss .= ''."\n"; + return $rss; } - -/* Change languages to ISO 639-1 to validate RSS without changing long version in config.inc.php */ -$user_language = array ("english", "polish", "german", "french", "dutch", "italian", "japanese", "norwegian", "spanish", "swedish", "portuguese", "catalan", "traditional_chinese", "esperanto", "korean"); -$iso_language = array ("en", "pl", "de", "fr", "nl", "da", "it", "ja", "no", "es", "sv", "pt", "ca", "zh-tw", "eo", "ko"); -$rss_language = str_replace($user_language, $iso_language, $language); -/* End language modification */ - -$rss = ""."\n"; -$rss .= ''."\n"; -$rss .= ''."\n"; -$rss .= ''."\n"; -$rss .= ''.$cal_displayname; -if ($theview !=""){$rss .= ' - '.$theview;} -$rss .= "\n"; - -$rss .= ''.htmlspecialchars("$default_path").''."\n"; -if (isset($cpath) && $cpath !='') $rss_link.="?cpath=$cpath"; -$rss .= "$rss_link\n"; - -$rss .= ''.$cal_displayname.' '.$lang['l_calendar'].' - '.$theview.''."\n"; -$rss .= ''.$rss_language.''."\n"; -$rss .= 'Copyright '.date(Y).', '.htmlspecialchars ("$default_path").''."\n"; - -//generate the items -$numdays = round((strtotime($todate) - strtotime($fromdate))/(60*60*24))+1; -$thisdate = $fromdate; # start at beginning of date range, - # note that usage of $thisdate is different from distribution - # I use it as a date, dist uses it as a time -$thistime = strtotime($thisdate); -$i = 1; #day counter -$uid_arr = array(); - do { - $thisdate=date('Ymd', $thistime); -# echo "Date: $thisdate\ti:$i\tnumdays:$numdays
\n"; - $dayofweek = localizeDate ("%a %b %e %Y", strtotime($thisdate)); - if (isset($master_array[($thisdate)]) && sizeof($master_array[($thisdate)]) > 0) { - foreach ($master_array[("$thisdate")] as $event_times) { - foreach ($event_times as $uid=>$val) { - #handle multiday all day events - if(!$val["event_start"]){ - if (isset($uid_arr[$uid])){ - $uid_arr[$uid] .= "+$dayofweek" ; - continue; - }else{ - $uid_arr[$uid] = "$dayofweek" ; - } - $event_start = $lang['l_all_day']; - }else{ - $event_start = @$val["event_start"]; - $event_start = date ($timeFormat, @strtotime ("$event_start")); - } - $event_text = stripslashes(urldecode($val["event_text"])); - $event_text = strip_tags($event_text, ''); - $event_text = str_replace('&','&',$event_text); - $event_text = str_replace('&amp;','&',$event_text); - # $event_text = urlencode($event_text); - #uncomment for shorter event text with ... - # $event_text = word_wrap($event_text, 21, $tomorrows_events_lines); - $description = stripslashes(urldecode($val["description"])); - $description = strip_tags($description, ''); - $description = str_replace('&','&',$description); - $description = str_replace('&amp;','&',$description); - - - $rss_title = urldecode ("$dayofweek: $event_text"); - - $urlcal = rawurlencode ("$cal"); - if (isset($rss_link_to_event) && $rss_link_to_event == 'yes'){ - $event_data = urlencode(serialize($val)); - $rss_link = "$default_path/includes/event.php?getdate=$thisdate&cal=$cal&event_data=$event_data"; - }else{ - $rss_link = ("$default_path/day.php?getdate=$thisdate&cal=$urlcal"); - - } - if (isset($cpath) && $cpath !='') $rss_link.="&cpath=$cpath"; - - $rss_description = htmlspecialchars ("$dayofweek $event_start: $description"); - - $rss .= ''."\n"; - $rss .= ''.$uid.''."\n"; - $rss .= ''.$event_start.''."\n"; - $rss .= ''.$rss_title.''."\n"; - /* custom stuff for Jim Hu's RSS feeds. Deprecated - $rss .= ''.$dayofweek.''."\n"; - $rss .= ''.$event_text.''."\n"; - $rss .= ''.$description.''."\n"; - $rss .= ''.$val["description"].''."\n"; - $rss .= ''.$val['attendee'].''."\n"; - $rss .= ''.$val['organizer'].''."\n"; - $rss .= ''.$val['status'].''."\n"; - */ - $rss .= ''.$rss_link.''."\n"; - $rss .= ''.$rss_description.''."\n"; - if (isset($val['location']) && $val['location'] !=''){ - $location = str_replace('&','&',$val['location']); - $location = str_replace('&amp;','&',$location); - $rss .= ''.$location."\n"; - } - $rss .= ''."\n"; - $events_count++; - } - } - } - if (($events_count < 1) && ($i == $numdays)) { - $rss .= ''."\n"; - $rss .= 'No events found'."\n"; - $rss .= ''.htmlspecialchars ("$default_path").''."\n"; - $rss .= ''."\n"; - } - $thistime = $thistime+(60*60*24); # echo "$thisdate: ".strtotime($thisdate)."->$thistime
\n"; - $i++; - } while ($i <= $numdays); - -$rss .= '
'."\n"; -$rss .= '
'."\n"; - -foreach ($uid_arr as $uid=>$date_range){ - #echo "date_range:$date_range
"; - - if(strpos($date_range,"+")>0){ - #echo "+ in date_range
"; - $temp = explode("+",$date_range); - $date_range = $temp[0].'-'.array_pop($temp); - } - $rss = str_replace("$uid\n".$lang['l_all_day']."","$uid\n$date_range", $rss); - +function rss_noitems(){ + global $default_path; + $rss .= ''."\n"; + $rss .= 'No events found'."\n"; + $rss .= ''.htmlspecialchars ("$default_path").''."\n"; + $rss .= ''."\n"; + return $rss; } -header ("Content-Type: text/xml"); - -echo "$rss"; +function rss_close(){ + return "
\n
\n"; +} ?> diff --git a/rss/rss1.0.php b/rss/rss1.0.php index 9e2a550..265c8ab 100755 --- a/rss/rss1.0.php +++ b/rss/rss1.0.php @@ -1,263 +1,76 @@ "."\n"; + + /* Use 1.0 and strip encoding, use rss_language */ + $rss .= ''."\n"; + + $rss .= ''."\n"; + $rss .= ''.$cal_displayname.' '.$lang['l_calendar'].' - '.$theview.''."\n"; + #$rss .= ''.$rss_language.''."\n"; + return $rss; } - -include_once(BASE.'functions/date_functions.php'); - - -//set the range of days to return based on the view chosen -$rssview = $_GET['rssview']; -if (isset($_GET['getdate']) && $_GET['getdate'] !=''){ - $getdate = $_GET['getdate']; -}else{ - $getdate = date("Ymd"); +function rss_li($rss_link, $uid){ + return ''."\n"; } -# for all views, $fromdate is the first day to be shown and $todate should be the last day. -switch ($rssview){ - case 'day': - $fromdate = $getdate; - $todate = $getdate; - $theview = $lang['l_day']; - break; - case 'week': - $fromdate = dateOfWeek($getdate, 'Sunday'); - $todate = $fromdate + 6; - $theview = $lang['l_week']." of ".date('n/d/Y',strtotime($fromdate)); - break; - case 'month': - $parse_month = date ("Ym", strtotime($getdate)); - $fromdate = ($parse_month *100) + 1; - $todate = ($parse_month *100) + date("t",strtotime($getdate)); - $theview = date('M Y',strtotime($fromdate)); - break; - case 'year': - if(isset($_GET['year'])){ - $theyear = $_GET['year']; - }else{ - $theyear = substr($getdate,0,4); - } - $fromdate = ($theyear*10000)+101; - $todate = date("Ymd", strtotime($theyear*10000+1231)); - $theview = $theyear; - break; - case 'daysfrom': - $fromdate = $getdate; - $todate = date("Ymd", strtotime($getdate) + $_GET['days']*60*60*24); - $theview = $_GET['days']." days from ".date('n/d/Y',strtotime($fromdate)); - break; - case 'daysto': - $todate = $getdate; - $fromdate = date("Ymd", strtotime($getdate) - $_GET['days']*60*60*24); - $theview = $_GET['days']." days before ".date('n/d/Y',strtotime($todate)); - break; - case 'range': - if(isset($_GET['from'])){ - $fromdate = $_GET['from']; - }else{ - $fromdate = $getdate; - } - $todate = $_GET['to']; - $theview = date('n/d/Y',strtotime($fromdate)).'-'.date('n/d/Y',strtotime($todate)); - break; - default: - #default to week - $fromdate = dateOfWeek($getdate, 'Sunday'); - $todate = $fromdate + 6; - $theview = ""; +function enclose_items($rss_items){ + return "\n\n".$rss_items."\n\n\n"; } -#need to give ical_parser the most distant date to correctly set up master_array. -$getdate = $todate; -#echo "from:$fromdate to:$todate"; - -#Note that ical_parser supplies cal_displayname. -include(BASE.'functions/ical_parser.php'); - -$events_count = 0; - -// calculate a value for Last Modified and ETag -$cal = implode(",",$cals); - -//get filemtime from master array -$filemod = 0; #default to start of unix era, overwrite with most recent mtime from master array -foreach ($master_array['-4'] as $calinfo){ - if ($calinfo['mtime'] > $filemod) $filemod = $calinfo['mtime']; -} -$filemodtime = date("r", $filemod); -//send relevant headers -header ("Last-Modified: $filemodtime"); -header ("ETag:\"$filemodtime\""); - -// checks the user agents headers to see if they kept track of our -// stuff, if so be nice and send back a 304 and exit. - -if ( ($_SERVER['HTTP_IF_MODIFIED_SINCE'] == $filemodtime) || ($_SERVER['HTTP_IF_NONE_MATCH'] == $filemodtime)){ - header ("HTTP/1.1 304 Not Modified"); - exit; +function rss_item(){ + global $uid,$event_start,$rss_title,$rss_link, $dayofweek, $event_text, $rss_description, $val; + $rss_item = ''."\n"; + + /* Create guid, and use uid to make link unique */ +# $rss .= ''.$rss_link.$uid.''."\n"; + /* End guid modification */ + $rss_item .= ''.$rss_title.''."\n"; + $rss_item .= ''.date("Y-m-d", strtotime($thisdate)).'T'.date("h:m:s",$val["event_start"]).''."\n"; + $rss_item .= ''.date("Y-m-d", strtotime($thisdate)).'T'.date("h:m:s",$val["event_start"]).''."\n"; + + $rss_item .= ''.$rss_link.''."\n"; + $rss_item .= ''.$rss_description.''."\n"; + if (isset($val['location']) && $val['location'] !=''){ + $location = str_replace('&','&',$val['location']); + $location = str_replace('&amp;','&',$location); + $rss_item .= ''.$location."\n"; + } + $rss_item .= ''."\n"; + return $rss_item; } -/* Change languages to ISO 639-1 to validate RSS without changing long version in config.inc.php */ -$user_language = array ("english", "polish", "german", "french", "dutch", "italian", "japanese", "norwegian", "spanish", "swedish", "portuguese", "catalan", "traditional_chinese", "esperanto", "korean"); -$iso_language = array ("en", "pl", "de", "fr", "nl", "da", "it", "ja", "no", "es", "sv", "pt", "ca", "zh-tw", "eo", "ko"); -$rss_language = str_replace($user_language, $iso_language, $language); -/* End language modification */ - -$rss = ""."\n"; - -/* Use 1.0 and strip encoding, use rss_language */ -$rss .= ''."\n"; - -$rss .= ''."\n"; -$rss .= ''.$cal_displayname.' '.$lang['l_calendar'].' - '.$theview.''."\n"; -#$rss .= ''.$rss_language.''."\n"; - - -//generate the items -$numdays = round((strtotime($todate) - strtotime($fromdate))/(60*60*24))+1; -$thisdate = $fromdate; # start at beginning of date range, - # note that usage of $thisdate is different from distribution - # I use it as a date, dist uses it as a time -$i = 1; #day counter - -$rss .= "\n\n"; -$rss_items =''; -$uid_arr = array(); - do { - $thisdate=date('Ymd', strtotime($thisdate)); - #echo "Date: $thisdate
\n"; - $dayofweek = localizeDate ("%a %b %e %Y", strtotime($thisdate)); - if (isset($master_array[($thisdate)]) && sizeof($master_array[($thisdate)]) > 0) { - foreach ($master_array[("$thisdate")] as $event_times) { - foreach ($event_times as $uid=>$val) { - #handle multiday all day events - if(!$val["event_start"]){ - if (isset($uid_arr[$uid])){ - $uid_arr[$uid] .= "+$dayofweek" ; - continue; - }else{ - $uid_arr[$uid] = "$dayofweek" ; - } - $event_start = $lang['l_all_day']; - }else{ - $event_start = @$val["event_start"]; - $event_start = date ($timeFormat, @strtotime ("$event_start")); - } - $event_text = stripslashes(urldecode($val["event_text"])); - $event_text = strip_tags($event_text, ''); - # $event_text = urlencode($event_text); - #uncomment for shorter event text with ... - # $event_text = word_wrap($event_text, 21, $tomorrows_events_lines); - $description = stripslashes(urldecode($val["description"])); - $description = strip_tags($description, ''); - - $rss_title = htmlspecialchars ("$dayofweek: $event_text"); - /* original link, not valid url coding - $rss_link = htmlspecialchars ("$default_path/day.php?getdate=$thisdate&cal=$cal&cpath=$cpath"); - */ - /* Add %20's for spaces for the calendar links to make them valid url's */ - $urlcal = rawurlencode ("$cal"); - - if (isset($rss_link_to_event) && $$rss_link_to_event == 'yes'){ - $event_data = urlencode(serialize($val)); - $rss_link = "$default_path/includes/event.php?getdate=$thisdate&cal=$cal&event_data=$event_data"; - }else{ - $rss_link = ("$default_path/day.php?getdate=$thisdate&cal=$urlcal"); - - } - if (isset($cpath) && $cpath !='') $rss_link.="&cpath=$cpath"; - /* End link modification */ - - $rss_description = htmlspecialchars ("$dayofweek $event_start: $description"); - - $rss .= ''."\n"; - $rss_items .= ''."\n"; - - /* Create guid, and use uid to make link unique */ - # $rss .= ''.$rss_link.$uid.''."\n"; - /* End guid modification */ - $rss_items .= ''.$rss_title.''."\n"; - $rss_items .= ''.date("Y-m-d", strtotime($thisdate)).'T'.date("h:m:s",$val["event_start"]).''."\n"; - $rss_items .= ''.date("Y-m-d", strtotime($thisdate)).'T'.date("h:m:s",$val["event_start"]).''."\n"; - - $rss_items .= ''.$rss_link.''."\n"; - $rss_items .= ''.$rss_description.''."\n"; - if (isset($val['location']) && $val['location'] !=''){ - $location = str_replace('&','&',$val['location']); - $location = str_replace('&amp;','&',$location); - $rss_items .= ''.$location."\n"; - } - $rss_items .= ''."\n"; - $events_count++; - } - } - } - if (($events_count < 1) && ($i == $numdays)) { - $rss_items .= '\n"; - $rss_items .= 'No events found'."\n"; - $rss_items .= ''.htmlspecialchars ("$default_path").''."\n"; - $rss_items .= ''."\n"; - } - $thisdate++; - $i++; - } while ($i <= $numdays); - -$rss .= "
\n
\n"; -$rss .= "
\n"; -$rss .= $rss_items.'
'."\n"; - -foreach ($uid_arr as $uid=>$date_range){ - #echo "date_range:$date_range
"; - - if(strpos($date_range,"+")>0){ - #echo "+ in date_range
"; - $temp = explode("+",$date_range); - $date_range = $temp[0].'-'.array_pop($temp); - } - $rss = str_replace("$uid\n".$lang['l_all_day']."","$uid\n$date_range", $rss); - +function rss_noitems(){ + $rss_item = '\n"; + $rss_item .= 'No events found'."\n"; + $rss_item .= ''.htmlspecialchars ("$default_path").''."\n"; + $rss_item .= ''."\n"; + return $rss_item; } -header ("Content-Type: text/xml"); - -echo "$rss"; +function rss_close(){ + return "
\n"; +} ?> diff --git a/rss/rss2.0.php b/rss/rss2.0.php index 76d6a59..cd63ad0 100644 --- a/rss/rss2.0.php +++ b/rss/rss2.0.php @@ -22,243 +22,68 @@ */ define('BASE', '../'); -require(BASE.'functions/init.inc.php'); - -if ($enable_rss != 'yes') { - die ("RSS feeds are not enabled on this site."); +require(BASE.'rss/rss_common.php'); +function rss_top(){ + global $cal_displayname, $theview, $default_path, $cpath, $lang, $rss_link, $rss_language; + + $rss = ""."\n"; + /* Use 2.0 and strip encoding, use rss_language */ + $rss .= ''."\n"; + $rss .= ''.$rss_language.''."\n"; + return $rss; } -include_once(BASE.'functions/date_functions.php'); - - -//set the range of days to return based on the view chosen -$rssview = $_GET['rssview']; -if (isset($_GET['getdate']) && $_GET['getdate'] !=''){ - $getdate = $_GET['getdate']; -}else{ - $getdate = date("Ymd"); +function rss_li($rss_link, $uid){ + $return = ""; } -# for all views, $fromdate is the first day to be shown and $todate should be the last day. -switch ($rssview){ - case 'day': - $fromdate = $getdate; - $todate = $getdate; - $theview = $lang['l_day']; - break; - case 'week': - $fromdate = dateOfWeek($getdate, 'Sunday'); - $todate = $fromdate + 6; - $theview = $lang['l_week']." of ".date('n/d/Y',strtotime($fromdate)); - break; - case 'month': - $parse_month = date ("Ym", strtotime($getdate)); - $fromdate = ($parse_month *100) + 1; - $todate = ($parse_month *100) + date("t",strtotime($getdate)); - $theview = date('M Y',strtotime($fromdate)); - break; - case 'year': - if(isset($_GET['year'])){ - $theyear = $_GET['year']; - }else{ - $theyear = substr($getdate,0,4); - } - $fromdate = ($theyear*10000)+101; - $todate = date("Ymd", strtotime($theyear*10000+1231)); - $theview = $theyear; - break; - case 'daysfrom': - $fromdate = $getdate; - $todate = date("Ymd", strtotime($getdate) + $_GET['days']*60*60*24); - $theview = $_GET['days']." days from ".date('n/d/Y',strtotime($fromdate)); - break; - case 'daysto': - $todate = $getdate; - $fromdate = date("Ymd", strtotime($getdate) - $_GET['days']*60*60*24); - $theview = $_GET['days']." days before ".date('n/d/Y',strtotime($todate)); - break; - case 'range': - if(isset($_GET['from'])){ - $fromdate = $_GET['from']; - }else{ - $fromdate = $getdate; - } - $todate = $_GET['to']; - $theview = date('n/d/Y',strtotime($fromdate)).'-'.date('n/d/Y',strtotime($todate)); - break; - default: - #default to week - $fromdate = dateOfWeek($getdate, 'Sunday'); - $todate = $fromdate + 6; - $theview = ""; +function enclose_items($rss_items){ + return $rss_items; } -#need to give ical_parser the most distant date to correctly set up master_array. -$getdate = $todate; -#echo "from:$fromdate to:$todate"; - -#Note that ical_parser supplies cal_displayname. -include(BASE.'functions/ical_parser.php'); - -$events_count = 0; - -// calculate a value for Last Modified and ETag -$cal = implode(",",$cals); - -//get filemtime from master array -$filemod = 0; #default to start of unix era, overwrite with most recent mtime from master array -foreach ($master_array['-4'] as $calinfo){ - if ($calinfo['mtime'] > $filemod) $filemod = $calinfo['mtime']; -} -$filemodtime = date("r", $filemod); -//send relevant headers -header ("Last-Modified: $filemodtime"); -header ("ETag:\"$filemodtime\""); - -// checks the user agents headers to see if they kept track of our -// stuff, if so be nice and send back a 304 and exit. - -if ( ($_SERVER['HTTP_IF_MODIFIED_SINCE'] == $filemodtime) || ($_SERVER['HTTP_IF_NONE_MATCH'] == $filemodtime)) -{ -# header ("HTTP/1.1 304 Not Modified"); -# exit; +function rss_item(){ + global $uid,$event_start,$rss_title,$rss_link, $dayofweek, $event_text, $rss_description, $val, $thisdate; + $rss = ''."\n"; + /* Create guid, and use uid to make link unique */ + $rss .= ''.$rss_link.'&uid='.$uid.''."\n"; + /* End guid modification */ + $rss .= ''.$rss_title.''."\n"; + $rss .= ''.date("Y-m-d", strtotime($thisdate)).'T'.date("h:m:s",$val["event_start"]).''."\n"; + $rss .= ''.date("Y-m-d", strtotime($thisdate)).'T'.date("h:m:s",$val["event_start"]).''."\n"; + + $rss .= ''.$rss_link.''."\n"; + $rss .= ''.$rss_description.''."\n"; + if (isset($val['location']) && $val['location'] !=''){ + $location = str_replace('&','&',$val['location']); + $location = str_replace('&amp;','&',$location); + $rss .= ''.$location."\n"; + } + $rss .= ''."\n"; + return $rss; } -/* Change languages to ISO 639-1 to validate RSS without changing long version in config.inc.php */ -$user_language = array ("english", "polish", "german", "french", "dutch", "italian", "japanese", "norwegian", "spanish", "swedish", "portuguese", "catalan", "traditional_chinese", "esperanto", "korean"); -$iso_language = array ("en", "pl", "de", "fr", "nl", "da", "it", "ja", "no", "es", "sv", "pt", "ca", "zh-tw", "eo", "ko"); -$rss_language = str_replace($user_language, $iso_language, $language); -/* End language modification */ - -$rss = ""."\n"; -#$rss .= ''."\n"; - -/* Use 2.0 and strip encoding, use rss_language */ -$rss .= ''."\n"; -$rss .= ''.$rss_language.''."\n"; - - -/* End rss 2.0 modification */ - - -//generate the items -$numdays = round((strtotime($todate) - strtotime($fromdate))/(60*60*24))+1; -$thisdate = $fromdate; # start at beginning of date range, - # note that usage of $thisdate is different from distribution - # I use it as a date, dist uses it as a time -$i = 1; #day counter - -#$rss .= "\n\n"; -$uid_arr = array(); - do { - $thisdate=date('Ymd', strtotime($thisdate)); - #echo "Date: $thisdate
\n"; - $dayofweek = localizeDate ("%a %b %e %Y", strtotime($thisdate)); - if (isset($master_array[($thisdate)]) && sizeof($master_array[($thisdate)]) > 0) { - foreach ($master_array[("$thisdate")] as $event_times) { - foreach ($event_times as $uid=>$val) { - #handle multiday all day events - if(!$val["event_start"]){ - if (isset($uid_arr[$uid])){ - $uid_arr[$uid] .= "+$dayofweek" ; - continue; - }else{ - $uid_arr[$uid] = "$dayofweek" ; - } - $event_start = $lang['l_all_day']; - }else{ - $event_start = @$val["event_start"]; - $event_start = date ($timeFormat, @strtotime ("$event_start")); - } - $event_text = stripslashes(urldecode($val["event_text"])); - $event_text = strip_tags($event_text, ''); - # $event_text = urlencode($event_text); - #uncomment for shorter event text with ... - # $event_text = word_wrap($event_text, 21, $tomorrows_events_lines); - $description = stripslashes(urldecode($val["description"])); - $description = strip_tags($description, ''); - - $rss_title = htmlspecialchars ("$dayofweek: $event_text"); - /* original link, not valid url coding - $rss_link = htmlspecialchars ("$default_path/day.php?getdate=$thisdate&cal=$cal&cpath=$cpath"); - */ - /* Add %20's for spaces for the calendar links to make them valid url's */ - $urlcal = rawurlencode ("$cal"); - if (isset($rss_link_to_event) && $$rss_link_to_event == 'yes'){ - $event_data = urlencode(serialize($val)); - $rss_link = "$default_path/includes/event.php?getdate=$thisdate&cal=$cal&event_data=$event_data"; - }else{ - $rss_link = ("$default_path/day.php?getdate=$thisdate&cal=$urlcal"); - - } - if (isset($cpath) && $cpath !='') $rss_link.="&cpath=$cpath"; - /* End link modification */ - $rss_description = htmlspecialchars ("$dayofweek $event_start: $description"); - - #$rss .= ''."\n"; - $rss .= ''."\n"; - - /* Create guid, and use uid to make link unique */ - $rss .= ''.$rss_link.'&uid='.$uid.''."\n"; - /* End guid modification */ - $rss .= ''.$rss_title.''."\n"; - $rss .= ''.date("Y-m-d", strtotime($thisdate)).'T'.date("h:m:s",$val["event_start"]).''."\n"; - $rss .= ''.date("Y-m-d", strtotime($thisdate)).'T'.date("h:m:s",$val["event_start"]).''."\n"; - - $rss .= ''.$rss_link.''."\n"; - $rss .= ''.$rss_description.''."\n"; - if (isset($val['location']) && $val['location'] !=''){ - $location = str_replace('&','&',$val['location']); - $location = str_replace('&amp;','&',$location); - $rss .= ''.$location."\n"; - } - $rss .= ''."\n"; - $events_count++; - } - } - } - if (($events_count < 1) && ($i == $numdays)) { - $rss .= ''."\n"; - $rss .= ''.$default_path.'&uid='.$thisdate.''."\n"; - $rss .= 'No events found'."\n"; - $rss .= ''.htmlspecialchars ("$default_path").''."\n"; - $rss .= ''."\n"; - } - $thisdate++; - $i++; - } while ($i <= $numdays); - -#$rss .= "
\n
\n"; -$rss .= "\n\n
\n"; - -foreach ($uid_arr as $uid=>$date_range){ - #echo "date_range:$date_range
"; - - if(strpos($date_range,"+")>0){ - #echo "+ in date_range
"; - $temp = explode("+",$date_range); - $date_range = $temp[0].'-'.array_pop($temp); - } - $rss = str_replace("$uid\n".$lang['l_all_day']."","$uid\n$date_range", $rss); - +function rss_noitems(){ + $rss = ''."\n"; + $rss .= ''.$default_path.'&uid='.$thisdate.''."\n"; + $rss .= 'No events found'."\n"; + $rss .= ''.htmlspecialchars ("$default_path").''."\n"; + $rss .= ''."\n"; + return $rss; } -header ("Content-Type: text/xml"); - -echo "$rss"; +function rss_close(){ + return "\n\n
\n"; +} ?> diff --git a/templates/default/admin.tpl b/templates/default/admin.tpl index b83860b..fbbe6b8 100644 --- a/templates/default/admin.tpl +++ b/templates/default/admin.tpl @@ -23,7 +23,7 @@
- +
@@ -122,9 +122,9 @@
- - - + + +
{FOOTER} diff --git a/week.php b/week.php index 7d86fea..e1250c2 100644 --- a/week.php +++ b/week.php @@ -29,13 +29,13 @@ $this_month = $day_array2[2]; $this_year = $day_array2[1]; // select for calendars -$list_icals = display_ical_list(availableCalendars($username, $password, $ALL_CALENDARS_COMBINED)); +$list_icals = display_ical_list(availableCalendars($username, $password, $phpiCal_config->ALL_CALENDARS_COMBINED)); $list_years = list_years(); $list_months = list_months(); $list_weeks = list_weeks(); $list_jumps = list_jumps(); $list_calcolors = list_calcolors(); -$list_icals_pick = display_ical_list(availableCalendars($username, $password, $ALL_CALENDARS_COMBINED), TRUE); +$list_icals_pick = display_ical_list(availableCalendars($username, $password, $phpiCal_config->ALL_CALENDARS_COMBINED), TRUE); // login/logout $is_logged_in = ($username != '' && !$invalid_login) ? true : false; @@ -54,10 +54,10 @@ $page->replace_files(array( )); $page->replace_tags(array( - 'version' => $phpicalendar_version, - 'charset' => $charset, + 'version' => $phpiCal_config->phpicalendar_version, + 'charset' => $phpiCal_config->charset, 'default_path' => '', - 'template' => $template, + 'template' => $phpiCal_config->template, 'cal' => $cal, 'getdate' => $getdate, 'getcpath' => "&cpath=$cpath", @@ -66,7 +66,7 @@ $page->replace_tags(array( 'display_date' => $display_date, 'current_view' => $current_view, 'sidebar_date' => $sidebar_date, - 'rss_powered' => $rss_powered, + 'rss_powered' => $phpiCal_config->rss_powered, 'rss_available' => '', 'rss_valid' => '', 'show_search' => $show_search, diff --git a/year.php b/year.php index d723046..22a47ba 100644 --- a/year.php +++ b/year.php @@ -24,7 +24,7 @@ $this_month = $day_array2[2]; $this_year = $day_array2[1]; // select for calendars -$list_icals = display_ical_list(availableCalendars($username, $password, $ALL_CALENDARS_COMBINED)); +$list_icals = display_ical_list(availableCalendars($username, $password, $phpiCal_config->ALL_CALENDARS_COMBINED)); $list_years = list_years(); $list_months = list_months(); $list_weeks = list_weeks(); @@ -32,7 +32,7 @@ $list_jumps = list_jumps(); $list_calcolors = ' '.$lang['l_all_day'].'
 '.$lang['l_event']."
"; ; -$list_icals_pick = display_ical_list(availableCalendars($username, $password, $ALL_CALENDARS_COMBINED), TRUE); +$list_icals_pick = display_ical_list(availableCalendars($username, $password, $phpiCal_config->ALL_CALENDARS_COMBINED), TRUE); // login/logout $is_logged_in = ($username != '' && !$invalid_login) ? true : false; @@ -52,11 +52,11 @@ $page->replace_files(array( )); $page->replace_tags(array( - 'version' => $phpicalendar_version, + 'version' => $phpiCal_config->phpicalendar_version, 'event_js' => '', 'current_view' => $current_view, - 'template' => $template, - 'charset' => $charset, + 'template' => $phpiCal_config->template, + 'charset' => $phpiCal_config->charset, 'default_path' => '', 'cal' => $cal, 'getcpath' => "&cpath=$cpath", @@ -65,7 +65,7 @@ $page->replace_tags(array( 'calendar_name' => $cal_displayname, 'display_date' => $this_year, 'sidebar_date' => $sidebar_date, - 'rss_powered' => $rss_powered, + 'rss_powered' => $phpiCal_config->rss_powered, 'rss_available' => '', 'rss_valid' => '', 'todo_available' => '', -- cgit v1.2.3