From 9d2eafe2e806a86b5617ed98040fd8667066f852 Mon Sep 17 00:00:00 2001 From: jwangen Date: Fri, 4 Oct 2002 07:41:57 +0000 Subject: added blacklisting of local calendars and the ability to view remote calendars --- README | 118 ++++++++++++++++++++++++++++------------------- config.inc.php | 24 ++++++++-- day.php | 2 +- functions/init.inc.php | 61 +++++++++++++++--------- functions/list_icals.php | 28 ++++++++--- month_bottom.php | 6 +-- sidebar.php | 12 ++--- week.php | 2 +- 8 files changed, 161 insertions(+), 92 deletions(-) diff --git a/README b/README index 77f5ae9..25887db 100644 --- a/README +++ b/README @@ -1,5 +1,7 @@ -PHP iCalendar -http://phpicalendar.sourceforge.net/ + ______________________________________ + | PHP iCalendar | + | http://phpicalendar.sourceforge.net/ | + |______________________________________| Introduction: ------------- @@ -15,13 +17,23 @@ phpicalendar-devel@lists.sourceforge.net Installation: ------------- - Put PHP iCalendar into your Sites folder (or another web directory) -- Edit the file "config.inc.php" +- Edit the file "config.inc.php" and see section below called "Configuration" - Put your iCal files into the directory you specify in config.inc.php (default is "calendars") - Turn on Web sharing (if not already on) - View calendars in your web browser If it is in your Sites folder, the URL would be: - http://localhost/~username/phpicalendar + + +Configuration: +-------------- +View config.inc.php. The comments behind each variable definition will +tell you what each setting does. Change the values between the quotation +marks to change the setting of that variable. If there are restrictions +as to what that variable can be set to, the comment behind will specify +them. If you have difficulty with your configuration, you can ask the +developers and other PHP iCalendar users at the PHP iCalendar forums +(get the link from our home page). Licensing: ---------- @@ -32,55 +44,65 @@ Changes: -------- 0.6 - -Better CSS support, coloring not hard-coded - -HTML bug fixes specific to Windows browsers - -All-day and Regular recurring event both support all types - -Bottom of month view updated - -Localization update - -Bug fixes + -Better CSS support, coloring not hard-coded + -HTML bug fixes specific to Windows browsers + -All-day and Regular recurring event both support all types + -Bottom of month view updated + -Localization update + -Localized dates and times work with Mac OS X as well as + other *nixes. + -Almost all text has been translated for supported languages + -Added ability to turn off the pop-up menu calendar list + -Added "black-listing" of specific local calendars + -Added remote calendar support + -Subscribe to calendars hosted remotely and have them show + up in your popup + -Allow any URL of a calendar to be parsed by your server + -Added custom error page for user-friendly error messages. + -Bug fixes 0.5 - -Improved recurring event support - -All-day and Regular recurring events now obey ending dates and counts - -Regular recurring events for monthly - -New UI - -Mini-calendars in all views - -Jump-to pop-ups for Weeks and Months - -Subsribe works properly - -Color coding on month view - -Week view colors the length of the time like day - -Support for event notes/descriptions - -More language support - -Danish - -Dutch - -Italian - -Japanese - -Norwegian - -Bug fixes - + -Improved recurring event support + -All-day and Regular recurring events now obey ending dates and counts + -Regular recurring events for monthly + -New UI + -Mini-calendars in all views + -Jump-to pop-ups for Weeks and Months + -Subsribe works properly + -Color coding on month view + -Week view colors the length of the time like day + -Support for event notes/descriptions + -More language support + -Danish + -Dutch + -Italian + -Japanese + -Norwegian + -Bug fixes + 0.4 - -Improved recurring event support - -All-day recurring for all types - -Regular recurring events for daily, weekly - -Event pop-ups - -More style sheets - -Multiple language support - -English - -French - -German - -Polish - -24-hour clock support - -Bug fixes + -Improved recurring event support + -All-day recurring for all types + -Regular recurring events for daily, weekly + -Event pop-ups + -More style sheets + -Multiple language support + -English + -French + -German + -Polish + -24-hour clock support + -Bug fixes 0.3 - -Calendar list popup - -All-day yearly recurring support - -Bug fixes - + -Calendar list popup + -All-day yearly recurring support + -Bug fixes + 0.2 - -All-day event support - -Added month and week views - -Bug fixes + -All-day event support + -Added month and week views + -Bug fixes 0.1 - -Initial Release \ No newline at end of file + -Initial Release \ No newline at end of file diff --git a/config.inc.php b/config.inc.php index 782bd34..46a4f8a 100644 --- a/config.inc.php +++ b/config.inc.php @@ -6,9 +6,25 @@ $default_view = 'day'; // default view for calendars = 'day', 'week', 'month $default_cal = 'Home'; // exact filename of calendar without .ics $language = 'english'; // Language support - 'English', 'Polish', 'German', 'French', 'Dutch', 'Danish', 'Italian', 'Japanese', 'Norwegian' $week_start_day = 'sunday'; // Day of the week your week starts on -$use_sessions = 'yes'; // For speedy performance on web servers, not good for localhost use. $day_start = '0700'; // Start time for day grid -$gridLength = '15'; // grid distance in minutes for day view -$display_custom_goto = ''; // in the 'Jump To' box, display the custom 'go to day' box. 'yes' means Yes, anything else means no. 'yes' must be lowercase. -$display_ical_list = 'yes'; // in the 'Jump To' box, display the pop-up menu with the list of all calendars in the $calendar_path directory. 'yes' means Yes, anything else means no. 'yes' must be lowercase. +$gridLength = '15'; // grid distance in minutes for day view, multiples of 15 preferred + +// Yes/No questions --- 'yes' means Yes, anything else means no. 'yes' must be lowercase. +$use_sessions = 'yes'; // For speedy performance on web servers, not good for localhost use. This has not yet been implemented. +$display_custom_goto = 'no'; // in the 'Jump To' box, display the custom 'go to day' box. +$display_ical_list = 'yes'; // in the 'Jump To' box, display the pop-up menu with the list of all calendars in the $calendar_path directory. +$allow_webcals = 'yes'; // 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. + +$blacklisted_cals[] = ''; // fill in between the quotes the name of the calendars +$blacklisted_cals[] = ''; // you wish to 'blacklist' or that you don't want to show up in your calendar +$blacklisted_cals[] = ''; // list. This should be the exact calendar filename without .ics +$blacklisted_cals[] = ''; // The parser will *not* parse any cal that is in this list (it will not be Web accessible) +// add more lines as necessary + +$list_webcals[] = ''; // fill in between the quotes exact URL of a calendar that you wish +$list_webcals[] = ''; // to show up in your calendar list. You must prefix the URL with http:// +$list_webcals[] = ''; // or webcal:// and the filename should contain the .ics suffix +$list_webcals[] = ''; // $allow_webcals does *not* need to be "yes" for these to show up and work +// add more lines as necessary + ?> \ No newline at end of file diff --git a/day.php b/day.php index b8a5e59..75cfb3a 100644 --- a/day.php +++ b/day.php @@ -112,7 +112,7 @@ if ($master_array[($getdate)]) { \n'; + echo ''."\n"; echo ''."\n"; echo ''."\n"; foreach($master_array[($getdate)]['-1'] as $allday) { diff --git a/functions/init.inc.php b/functions/init.inc.php index 330b2d4..c5f3a60 100644 --- a/functions/init.inc.php +++ b/functions/init.inc.php @@ -1,17 +1,22 @@ = '4.2.0') { extract($HTTP_GET_VARS); extract($HTTP_POST_VARS); } - +*/ include('./config.inc.php'); include('./functions/error.php'); // subscribe link prefix, doesn't need to be user configureable -$fullpath = 'webcal://'.$HTTP_SERVER_VARS['SERVER_NAME'].dirname($HTTP_SERVER_VARS['PHP_SELF']).'/'.$calendar_path.'/'; + // language support @@ -21,10 +26,7 @@ $lang_file = './languages/'.$language.'.inc.php'; if (file_exists($lang_file)) { include($lang_file); } else { -// Not sure if we should print this warning or not. It would inform the user -// why the language isn't working. - print 'File "'.$lang_file.'" does not exist, defaulting to English

'; - include('../languages/english.inc.php'); + exit(error('Requested lanugage "'.$language.'" is not a supported language. Please consult the configuration file to choose a supported language.')); } if (isset($HTTP_GET_VARS['getdate']) && ($HTTP_GET_VARS['getdate'] !== '')) { @@ -33,15 +35,18 @@ if (isset($HTTP_GET_VARS['getdate']) && ($HTTP_GET_VARS['getdate'] !== '')) { $getdate = date('Ymd'); } -// $cal_displayname is $cal_filename with occurrences of '32' replaced with ' ' -// $cal_filename should always be the filename of the calendar without .ics + + $is_webcal = FALSE; if (isset($HTTP_GET_VARS['cal'])) { - if (substr($HTTP_GET_VARS['cal'], 0, 7) == 'http://') { + $cal_decoded = urldecode($HTTP_GET_VARS['cal']); + if (substr($cal_decoded, 0, 7) == 'http://' || substr($cal_decoded, 0, 9) == 'webcal://') { $is_webcal = TRUE; - $cal_filename = $HTTP_GET_VARS['cal']; + $cal_webcalPrefix = str_replace('http://','webcal://',$cal_decoded); + $cal_httpPrefix = str_replace('webcal://','http://',$cal_decoded); + $cal_filename = $cal_httpPrefix; } else { - $cal_filename = stripslashes(urldecode($HTTP_GET_VARS['cal'])); + $cal_filename = stripslashes($cal_decoded); } } else { $cal_filename = $default_cal; @@ -49,24 +54,34 @@ if (isset($HTTP_GET_VARS['cal'])) { if ($is_webcal) { - $cal_displayname = substr(str_replace('32', ' ', basename($cal_filename)), 0, -4); - $cal = $cal_filename; - $filename = $cal; + if ($allow_webcals == 'yes' || in_array($cal_webcalPrefix, $list_webcals) || in_array($cal_httpPrefix, $list_webcals)) { + $cal_displayname = substr(str_replace('32', ' ', basename($cal_filename)), 0, -4); + $cal = urlencode($cal_filename); + $filename = $cal_filename; + $subscribe_path = $cal_webcalPrefix; + } else { + exit(error('Remote calendars are not allowed on this server and the calendar located at '.$HTTP_GET_VARS['cal'].' is not in the list of allowed calendars. Please use the "Back" button to return.')); + } } else { $cal_displayname = str_replace('32', ' ', $cal_filename); $cal = urlencode($cal_filename); - - if (!isset($filename)) { - $filename = $calendar_path.'/'.$cal_filename.'.ics'; - if (!file_exists($filename)) { - $dir_handle = @opendir($calendar_path) or die('Unable to open path: '.$calendar_path); - while ($file = readdir($dir_handle)) { - if (substr($file, -4) == '.ics') { - $filename = $calendar_path.'/'.$file; - break; + if (in_array($cal_filename, $blacklisted_cals)) { + exit(error($cal_filename.' is restricted on this server. Please use the "Back" button to return.')); + } else { + if (!isset($filename)) { + $filename = $calendar_path.'/'.$cal_filename.'.ics'; + if (!file_exists($filename)) { + $dir_handle = @opendir($calendar_path) or die('Unable to open path: '.$calendar_path); + while ($file = readdir($dir_handle)) { + if (substr($file, -4) == '.ics') { + $cal = urlencode(substr($file, 0, -4)); + $filename = $calendar_path.'/'.$file; + break; + } } } } + $subscribe_path = 'webcal://'.$HTTP_SERVER_VARS['SERVER_NAME'].dirname($HTTP_SERVER_VARS['PHP_SELF']).'/'.$filename; } } ?> \ No newline at end of file diff --git a/functions/list_icals.php b/functions/list_icals.php index 8ca60d1..c2635aa 100644 --- a/functions/list_icals.php +++ b/functions/list_icals.php @@ -15,20 +15,36 @@ if ($display_ical_list == "yes") { // build the \n"; - } else { - print "\n"; - } + if (!in_array($cal_filename_tmp, $blacklisted_cals)) { + if ($cal_tmp == $cal) { + print "\n"; + } else { + print "\n"; + } + } } } + foreach($list_webcals as $cal_tmp) { + if ($cal_tmp != '') { + $cal_displayname_tmp = basename($cal_tmp); + $cal_displayname_tmp = str_replace("32", " ", $cal_displayname_tmp); + $cal_displayname_tmp = substr($cal_displayname_tmp,0,-4); + $cal_encoded_tmp = urlencode($cal_tmp); + if ($cal_tmp == $cal_httpPrefix || $cal_tmp == $cal_webcalPrefix) { + print "\n"; + } else { + print "\n"; + } + } + } + // close file closedir($dir_handle); diff --git a/month_bottom.php b/month_bottom.php index f192775..0ab537b 100644 --- a/month_bottom.php +++ b/month_bottom.php @@ -1,6 +1,6 @@ 24) { $cal_displayname2 = substr("$cal_displayname2", 0, 21); $cal_displayname2 = $cal_displayname2 . "..."; @@ -200,9 +200,9 @@ - + - + diff --git a/sidebar.php b/sidebar.php index c0dd39d..851515d 100644 --- a/sidebar.php +++ b/sidebar.php @@ -1,6 +1,6 @@ 24) { $cal_displayname2 = substr("$cal_displayname2", 0, 21); $cal_displayname2 = $cal_displayname2 . "..."; @@ -53,9 +53,9 @@ - + - + @@ -240,7 +240,7 @@ $minical_month = date("m", $minical_time); $minical_year = date("Y", $minical_time); $first_of_month = $minical_year.$minical_month."01"; - $start_day = strtotime(dateOfWeek($first_of_month, $start_week_day)); + $start_day = strtotime(dateOfWeek($first_of_month, $week_start_day)); $i = 0; $whole_month = TRUE; $num_of_events = 0; @@ -320,7 +320,7 @@ $minical_month = date("m", $minical_time); $minical_year = date("Y", $minical_time); $first_of_month = $minical_year.$minical_month."01"; - $start_day = strtotime(dateOfWeek($first_of_month, $start_week_day)); + $start_day = strtotime(dateOfWeek($first_of_month, $week_start_day)); $i = 0; $whole_month = TRUE; $num_of_events = 0; @@ -400,7 +400,7 @@ $minical_month = date("m", $minical_time); $minical_year = date("Y", $minical_time); $first_of_month = $minical_year.$minical_month."01"; - $start_day = strtotime(dateOfWeek($first_of_month, $start_week_day)); + $start_day = strtotime(dateOfWeek($first_of_month, $week_start_day)); $i = 0; $whole_month = TRUE; $num_of_events = 0; diff --git a/week.php b/week.php index 1e81e68..c1f443d 100644 --- a/week.php +++ b/week.php @@ -46,7 +46,7 @@ for ($i=0;$i<7;$i++) { foreach($master_array[($thisday)] as $ovlKey => $ovlValue) { if ($ovlKey != "-1") { foreach($ovlValue as $ovl2Value) { - $nbrGridCols[$thisday] = kgv($nbrGridCols[$thisday], ($ovl2Value["event_overlap"] + 1)); + $nbrGridCols[($thisday)] = kgv($nbrGridCols[($thisday)], ($ovl2Value["event_overlap"] + 1)); } } } -- cgit v1.2.3
\"\""; ?>\"\""; ?> $subscribe_lang"; ?>$subscribe_lang"; ?>
\"\""; ?>\"\""; ?> $subscribe_lang"; ?>$subscribe_lang"; ?>