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 --- 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 +- 7 files changed, 119 insertions(+), 219 deletions(-) (limited to 'functions') 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') { -- cgit v1.2.3