From f1a377b8f764275248ef91fa84a79576efe84136 Mon Sep 17 00:00:00 2001 From: Chad Little Date: Mon, 25 Oct 2004 17:16:07 +0000 Subject: More error messages. Fixed default paths everywhere. --- README | 7 +++++++ admin/index.php | 15 +++++++++------ config.inc.php | 4 ++-- error.php | 17 +++++++++++++---- preferences.php | 4 ++++ rss/index.php | 13 ++++++++++++- rss/rss.php | 11 +++++++++-- 7 files changed, 56 insertions(+), 15 deletions(-) diff --git a/README b/README index 8987238..609d3d5 100644 --- a/README +++ b/README @@ -81,6 +81,13 @@ COPYING for more information about our license. Changes: -------- +2.0 + -Enhanced error messaging. + -Added Afrikaans Language. + -Todos can be turned off again. + -Todos won't show private todos. + -RSS page respects https servers. + 2.0 beta -Updated translations: -Japanese diff --git a/admin/index.php b/admin/index.php index 95f60c7..b2775e8 100644 --- a/admin/index.php +++ b/admin/index.php @@ -5,12 +5,15 @@ require_once(BASE.'functions/ical_parser.php'); require_once(BASE.'functions/template.php'); header("Content-Type: text/html; charset=$charset"); -$default_path = 'http://'.$_SERVER['SERVER_NAME'].':'.$_SERVER['SERVER_PORT'].substr($_SERVER['PHP_SELF'],0,strpos($_SERVER['PHP_SELF'],'/admin/')); - -// Redirect if administration is not allowed -if ($allow_admin != "yes") { - header("Location: index.php"); - die(); +if (empty($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') { + exit(error('The administration menu has been turned off.', $cal, '../')); } // Load variables from forms and query strings into local scope diff --git a/config.inc.php b/config.inc.php index 4c890d6..3c5be86 100644 --- a/config.inc.php +++ b/config.inc.php @@ -25,7 +25,7 @@ $second_offset = ''; // The time in seconds between your time and your serv $bleed_time = ''; // 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. Is automatically set to $day_start if left blank. $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 = 'http://www.example.com/phpicalendar'; // The HTTP URL to the PHP iCalendar directory, ie. http://www.example.com/phpicalendar +$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. @@ -50,7 +50,7 @@ $webcal_hours = '24'; // Number of hours to cache webcals. Setting to '0' w // Webdav style publishing $phpicalendar_publishing = ''; // Set to '1' to enable remote webdav style publish. See 'calendars/publish.php' for complete information; -// Administration settings (admin.php) +// Administration settings (/admin/) $allow_admin = 'yes'; // Set to yes to allow the admin page - remember to change the default password if using 'internal' as the $auth_method $auth_method = 'ftp'; // 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. diff --git a/error.php b/error.php index 845a23e..2ccf76c 100644 --- a/error.php +++ b/error.php @@ -3,8 +3,8 @@ if (!defined('BASE')) define('BASE','./'); require_once(BASE.'functions/template.php'); -function error($error_msg='There was an error processing the request.', $file='NONE') { - global $template, $language, $enable_rss, $lang; +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'; if (!isset($lang['l_powered_by'])) $lang['l_powered_by'] = 'Powered by'; if (!isset($lang['l_error_title'])) $lang['l_error_title'] = 'Error!'; @@ -17,7 +17,15 @@ function error($error_msg='There was an error processing the request.', $file='N $error_calendar = sprintf($lang['l_error_calendar'], $file); $current_view = 'error'; $display_date = $lang['l_error_title']; - $calendar_name = $lang['l_error_title']; + $calendar_name = $lang['l_error_title']; + + if (empty($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 { + $default_path = 'http://'.$_SERVER['SERVER_NAME'].':'.$_SERVER['SERVER_PORT'].substr($_SERVER['PHP_SELF'],0,strpos($_SERVER['PHP_SELF'],'/rss/')); + } + } $page = new Page(BASE.'templates/'.$template.'/error.tpl'); @@ -27,10 +35,11 @@ function error($error_msg='There was an error processing the request.', $file='N )); $page->replace_tags(array( - 'default_path' => '', + 'default_path' => $error_base, 'template' => $template, 'cal' => $cal, 'getdate' => $getdate, + 'charset' => $charset, 'calendar_name' => $calendar_name, 'display_date' => $display_date, 'rss_powered' => $rss_powered, diff --git a/preferences.php b/preferences.php index 9d4685f..c3f75a1 100644 --- a/preferences.php +++ b/preferences.php @@ -6,6 +6,10 @@ require_once(BASE.'functions/template.php'); header("Content-Type: text/html; charset=$charset"); $display_date = $preferences_lang; +if ($allow_preferences != 'yes') { + exit(error('Preferences are not available for this installation.', $cal)); +} + if ($cookie_uri == '') { $cookie_uri = $_SERVER['SERVER_NAME'].substr($_SERVER['PHP_SELF'],0,strpos($_SERVER['PHP_SELF'], '/')); } diff --git a/rss/index.php b/rss/index.php index fed55ea..4357020 100644 --- a/rss/index.php +++ b/rss/index.php @@ -4,7 +4,17 @@ define('BASE','../'); require_once(BASE.'functions/ical_parser.php'); require_once(BASE.'functions/calendar_functions.php'); -$default_path = 'http://'.$_SERVER['SERVER_NAME'].':'.$_SERVER['SERVER_PORT'].substr($_SERVER['PHP_SELF'],0,strpos($_SERVER['PHP_SELF'],'/rss/')); +if ($enable_rss != 'yes') { + exit(error('RSS is not available for this installation.', $cal, '../')); +} + +if (empty($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 { + $default_path = 'http://'.$_SERVER['SERVER_NAME'].':'.$_SERVER['SERVER_PORT'].substr($_SERVER['PHP_SELF'],0,strpos($_SERVER['PHP_SELF'],'/rss/')); + } +} $current_view = "rssindex"; $display_date = "RSS Info"; @@ -44,6 +54,7 @@ $page->replace_tags(array( 'sidebar_date' => $sidebar_date, 'rss_powered' => $rss_powered, 'rss_list' => $rss_list, + 'charset' => $charset, 'rss_available' => '', 'rssdisable' => '', 'rss_valid' => '', diff --git a/rss/rss.php b/rss/rss.php index c604afa..e15c63c 100644 --- a/rss/rss.php +++ b/rss/rss.php @@ -4,10 +4,17 @@ define('BASE', '../'); include(BASE.'functions/ical_parser.php'); if ($enable_rss != 'yes') { - die ("RSS feeds are not enabled on this site."); + exit(error('RSS is not available for this installation.', $cal, '../')); +} + +if (empty($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 { + $default_path = 'http://'.$_SERVER['SERVER_NAME'].':'.$_SERVER['SERVER_PORT'].substr($_SERVER['PHP_SELF'],0,strpos($_SERVER['PHP_SELF'],'/rss/')); + } } -$default_path = 'http://'.$_SERVER['SERVER_NAME'].':'.$_SERVER['SERVER_PORT'].substr($_SERVER['PHP_SELF'],0,strpos($_SERVER['PHP_SELF'],'/rss/')); $start_week_time = strtotime(dateOfWeek($getdate, $week_start_day)); $end_week_time = $start_week_time + (6 * 25 * 60 * 60); $start_week = localizeDate($dateFormat_week, $start_week_time); -- cgit v1.2.3