Skip to content

Commit d6405b9

Browse files
author
Jim Hu
committed
kill admin.php; misc other changes; bump rc num
1 parent bbfbcfc commit d6405b9

15 files changed

+60
-71
lines changed

admin/index.php

+21-24
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
<?php
22
define('BASE', '../');
3+
$current_view = 'admin';
4+
require_once(BASE.'functions/init.inc.php');
35
require_once(BASE.'functions/admin_functions.php');
4-
require_once(BASE.'functions/ical_parser.php');
56
require_once(BASE.'functions/template.php');
6-
header("Content-Type: text/html; charset=$charset");
7+
8+
#echo "<pre>";print_r($_REQUEST);
79

810
if (empty($phpiCal_config->default_path)) {
911
if (isset($_SERVER['HTTPS']) || strtolower($_SERVER['HTTPS']) == 'on' ) {
@@ -12,13 +14,9 @@
1214
$default_path = 'http://'.$_SERVER['SERVER_NAME'].':'.$_SERVER['SERVER_PORT'].substr($_SERVER['PHP_SELF'],0,strpos($_SERVER['PHP_SELF'],'/admin/'));
1315
}
1416
}
15-
if ($phpiCal_config->allow_admin != 'yes') {
16-
exit(error('The administration menu has been turned off.', $cal, '../'));
17-
}
18-
19-
// Load variables from forms and query strings into local scope
20-
if($_POST) {extract($_POST, EXTR_PREFIX_SAME, "post_");}
21-
if($_GET) {extract($_GET, EXTR_PREFIX_SAME, "get_");}
17+
#if ($phpiCal_config->allow_admin != 'yes') {
18+
exit(error('The administration menu has been turned off.', '', '/..'));
19+
#}
2220

2321
// Logout by clearing session variables
2422
if ((isset($_GET['action'])) && ($_GET['action'] == 'logout')) {
@@ -27,12 +25,11 @@
2725
unset($_SESSION['phpical_password']);
2826
}
2927

30-
3128
// if $auth_method == 'server', don't do any authentication
32-
$username = $_POST['username'];
33-
$password = $_POST['password'];
29+
$username = @$_POST['username'];
30+
$password = @$_POST['password'];
3431

35-
if ($auth_method == 'server') {
32+
if ($phpiCal_config->auth_method == 'server') {
3633
$is_loged_in = TRUE;
3734
} else {
3835
$is_loged_in = FALSE;
@@ -41,19 +38,20 @@
4138
$is_loged_in = TRUE;
4239
}
4340

44-
if (isset($username) && $_GET['action'] != 'logout') {
41+
if (isset($username) && @$_GET['action'] != 'logout') {
4542
$is_loged_in = login ($username, $password);
4643
}
4744
}
4845

4946
$login_good = ($is_loged_in) ? '' : 'oops';
50-
$login_bad = ((!$is_loged_in) && ($_GET['action'] == 'login')) ? 'oops' : '';
47+
$login_bad = ((!$is_loged_in) && (@$_GET['action'] == 'login')) ? 'oops' : '';
48+
$delete_msg = '';
49+
$addupdate_msg = '';
5150
if(is_loggedin()){
5251
// Delete a calendar
5352
// Not at all secure - need to strip out path info if used by users besides admin in the future
54-
$delete_msg = '';
55-
if ($_POST['action'] == 'delete') {
56-
foreach ($delete_calendar as $filename) {
53+
if (isset($_POST['action']) && $_POST['action'] == 'delete') {
54+
foreach ($_POST['delete_calendar'] as $filename) {
5755
if (!delete_cal(urldecode($filename))) {
5856
$delete_msg = $delete_msg . '<font color="red">' . $lang['l_delete_error'] . ' ' . urldecode(substr($filename,0,-4)) . '</font><br />';
5957
} else {
@@ -63,8 +61,7 @@
6361
}
6462

6563
// Add or Update a calendar
66-
$addupdate_msg = '';
67-
if ((isset($_POST['action'])) && ($_POST['action'] == 'addupdate')) {
64+
if (isset($_POST['action']) && $_POST['action'] == 'addupdate') {
6865
for ($filenumber = 1; $filenumber < 6; $filenumber++) {
6966
$file = $_FILES['calfile'];
7067
$addupdate_success = FALSE;
@@ -101,15 +98,15 @@
10198
'version' => $phpiCal_config->phpicalendar_version,
10299
'event_js' => '',
103100
'charset' => $phpiCal_config->charset,
104-
'default_path' => "../".$phpiCal_config->default_path,
101+
'default_path' => $phpiCal_config->default_path."/..",
105102
'template' => $phpiCal_config->template,
106103
'cal' => $cal,
107104
'getdate' => $getdate,
108105
'calendar_name' => $calendar_name,
109-
'display_date' => $display_date,
106+
'display_date' => '',
110107
'current_view' => $current_view,
111-
'sidebar_date' => $sidebar_date,
112-
'rss_powered' => $phpiCal_config->rss_powered,
108+
# 'sidebar_date' => $sidebar_date,
109+
'rss_powered' => $rss_powered,
113110
'rss_available' => '',
114111
'rss_valid' => '',
115112
'show_search' => '',

calendars/test.ics

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
BEGIN:VCALENDAR
22
VERSION:2.0
3-
X-WR-CALNAME:testing \,comma
3+
X-WR-CALNAME:testing\, comma
44
PRODID:-//Apple Computer\, Inc//iCal 2.0//EN
55
X-WR-RELCALID:E47AF849-67C8-49F0-AA36-9FD7495400FD
66
X-WR-TIMEZONE:US/Pacific

config.inc.php

+3-4
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
# 'cookie_uri' => '',
3030
# 'download_uri' => '',
3131
# 'allow_webcals' => 'yes',
32-
'recursive_path' => 'yes',
32+
# 'recursive_path' => 'yes',
3333

3434
/* ** Timezones **
3535
If timezone is not set, all events show in the local time of the source calendar. This isn't a problem if all your calendars are in the same timezone. If you set a timezone for the server, events in other timezones are shown when they occur at the server's time.
@@ -57,7 +57,6 @@
5757
# 'show_todos' => 'no',
5858
# 'show_completed' => 'no',
5959
'allow_login' => 'yes', // Set to yes to prompt for login to unlock calendars.
60-
# 'allow_admin' => 'yes',
6160
# 'week_start_day' => 'Monday', // Day of the week your week starts on
6261
# 'week_length' => '5', // Number of days to display in the week view
6362
# 'day_start' => '0600', // Start time for day grid
@@ -80,11 +79,11 @@
8079
these arrays provide extra calendar options.
8180
8281
*/
83-
$list_webcals[] = array(
82+
$list_webcals = array(
8483
# 'webcal://dimer.tamu.edu/calendars/seminars/Biochem.ics'
8584
);
8685
$more_webcals['recur_tests'] = array();
87-
$locked_cals[] = array(
86+
$locked_cals = array(
8887

8988
);
9089
/* ========= SPECIAL CALENDARS =========

default_config.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
class Configs{
33
private static $instance;
44
private function __construct(){
5-
$this->phpicalendar_version = '2.3rc1.4';
5+
$this->phpicalendar_version = '2.3rc1.6';
66
// Configuration file for PHP iCalendar 2.25rc1
77
//
88
// To set values, change the text between the single quotes
@@ -33,6 +33,7 @@ private function __construct(){
3333
$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.
3434
$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.
3535
$this->default_path = ''; // The HTTP URL to the PHP iCalendar directory, ie. http://www.example.com/phpicalendar
36+
$this->cpath = ''; // optional subdirectory
3637
$this->charset = 'UTF-8'; // Character set your calendar is in, suggested UTF-8, or iso-8859-1 for most languages.
3738

3839
// Yes/No questions --- 'yes' means Yes, anything else means no. 'yes' must be lowercase.

error.php

+8-15
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,11 @@
33
require_once(BASE.'functions/template.php');
44

55

6-
function error($error_msg='There was an error processing the request.', $file='NONE', $error_base='./') {
7-
global $language, $enable_rss, $lang, $charset, $phpiCal_config;
6+
function error($error_msg='There was an error processing the request.', $file='NONE', $error_base='') {
7+
global $getdate, $rss_powered, $lang, $phpiCal_config, $cal;
88
if (!isset($template)) $template = $phpiCal_config->template;
9-
if (!isset($lang['l_powered_by'])) $lang['l_powered_by'] = 'Powered by';
10-
if (!isset($lang['l_error_title'])) $lang['l_error_title'] = 'Error!';
11-
if (!isset($lang['l_error_window'])) $lang['l_error_window'] = 'There was an error!';
12-
if (!isset($lang['l_error_calendar'])) $lang['l_error_calendar'] = 'The calendar "%s" was being processed when this error occurred.';
13-
if (!isset($lang['l_error_back'])) $lang['l_error_back'] = 'Please use the "Back" button to return.';
14-
if (!isset($lang['l_this_site_is'])) $lang['l_this_site_is'] = 'This site is';
15-
if (!isset($enable_rss)) $enable_rss = 'no';
169

17-
$error_calendar = sprintf($lang['l_error_calendar'], $file);
10+
$error_calendar = sprintf($lang['l_error_calendar'], print_r($file,true));
1811
$current_view = 'error';
1912
$display_date = $lang['l_error_title'];
2013
$calendar_name = $lang['l_error_title'];
@@ -27,7 +20,6 @@ function error($error_msg='There was an error processing the request.', $file='N
2720
$default_path = 'http://'.$_SERVER['SERVER_NAME'].':'.$_SERVER['SERVER_PORT'].substr($_SERVER['PHP_SELF'],0,strpos($_SERVER['PHP_SELF'],'/rss/'));
2821
}
2922
}
30-
3123
$page = new Page(BASE.'templates/'.$template.'/error.tpl');
3224

3325
$page->replace_files(array(
@@ -36,12 +28,12 @@ function error($error_msg='There was an error processing the request.', $file='N
3628
));
3729

3830
$page->replace_tags(array(
39-
'version' => $phpicalendar_version,
40-
'default_path' => $default_path.'/',
31+
'version' => $phpiCal_config->phpicalendar_version,
32+
'default_path' => $phpiCal_config->default_path.$error_base,
4133
'template' => $template,
4234
'cal' => $cal,
4335
'getdate' => $getdate,
44-
'charset' => $charset,
36+
'charset' => $phpiCal_config->charset,
4537
'calendar_name' => $calendar_name,
4638
'display_date' => $display_date,
4739
'rss_powered' => $rss_powered,
@@ -55,7 +47,8 @@ function error($error_msg='There was an error processing the request.', $file='N
5547
'generated' => $generated,
5648
'l_powered_by' => $lang['l_powered_by'],
5749
'l_error_back' => $lang['l_error_back'],
58-
'l_error_window' => $lang['l_error_window']
50+
'l_error_window' => $lang['l_error_window'],
51+
'l_this_site_is' => $lang['l_this_site_is']
5952

6053
));
6154

functions/admin_functions.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ function login ($username, $password) {
4747
// arg1: string password
4848
// returns boolean was login successful
4949
function login_ftp ($username, $password) {
50-
global $ftp_server, $ftp_port;
50+
global $phpiCal_config;
5151

5252
// set up basic connection
53-
$conn_id = @ftp_connect($ftp_server, $ftp_port);
53+
$conn_id = @ftp_connect($phpiCal_config->ftp_server, $phpiCal_config->ftp_port);
5454
if (!$conn_id) exit(error('Cannot connect to FTP server', $filename));
5555
// login with username and password
5656
$login_result = @ftp_login($conn_id, $username, $password);
@@ -88,6 +88,7 @@ function delete_cal ($filename) {
8888
global $_SESSION;
8989
global $phpiCal_config;
9090
global $calendar_path;
91+
echo $filename;
9192

9293
if ($phpiCal_config->auth_method == 'ftp') {
9394
$filename = get_ftp_calendar_path() . "/" . $filename;
@@ -115,12 +116,11 @@ function delete_cal ($filename) {
115116
return TRUE;
116117
} else {
117118
#$filename = $calendar_path . "/" . $filename;
118-
119119
$delete = unlink($filename);
120120
clearstatcache();
121121
if (@file_exists($filename)) {
122122
$filesys = eregi_replace("/","\\", $filename);
123-
$delete = system("del $filesys");
123+
$delete = system("rm -f $filesys");
124124
clearstatcache();
125125
if (@file_exists($filename)) {
126126
$delete = chmod ($filename, 0775);

functions/calendar_functions.php

+10-12
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,17 @@ function availableCalendars($username, $password, $cal_filename, $admin = false)
4141

4242
// This array keeps track of paths we need to search.
4343
$search_paths = array($phpiCal_config->calendar_path);
44-
4544
// Add web calendars.
4645
if ($cal_filename_local[0] == $phpiCal_config->ALL_CALENDARS_COMBINED || $admin) {
4746
if (!isset($http_user) && !$admin) {
4847
foreach ($list_webcals as $file) {
4948
// Make sure the URL ends with .ics.
50-
if (!preg_match("/.ics$/i", $file)) continue;
49+
if (!is_string($file)) continue;
5150
// Add this calendar.
5251
array_push($calendars, $file);
5352
}
5453
}
55-
}
56-
54+
}
5755
// Set some booleans that will dictate our search.
5856
$find_all = ($cal_filename_local[0] == $phpiCal_config->ALL_CALENDARS_COMBINED || $admin);
5957

@@ -74,10 +72,10 @@ function availableCalendars($username, $password, $cal_filename, $admin = false)
7472
// used to identify the calendar filename.
7573
if ($find_all || $phpiCal_config->recursive_path == 'yes' || $phpiCal_config->support_ical == 'yes') {
7674
// Open the directory.
77-
$dir_handle = @opendir($search_path)
78-
or die(error(sprintf($lang['l_error_path'], $search_path), implode(',', $cal_filename)));
75+
$dir_handle = opendir($search_path)
76+
or die(error("cal fn 78:".sprintf($lang['l_error_path'], $search_path), implode(',', $cal_filename)));
7977
if ($dir_handle === false)
80-
die(error(sprintf($lang['l_error_path'], $search_path), implode(',', $cal_filename)));
78+
die(error(" cal fn 80:".sprintf($lang['l_error_path'], $search_path), implode(',', $cal_filename)));
8179

8280
// Add each file in the directory that does not begin with a dot.
8381
while (false !== ($file = readdir($dir_handle))) {
@@ -110,7 +108,7 @@ function availableCalendars($username, $password, $cal_filename, $admin = false)
110108
if (in_array($cal_name, $blacklisted_cals)) continue;
111109
// If HTTP authenticated, make sure this calendar is available
112110
// to the user.
113-
if (isset($http_user) && !in_array($cal_name, $apache_map[$http_user])) continue;
111+
if (isset($http_user) && isset($apache_map[$http_user]) && !in_array($cal_name, $apache_map[$http_user])) continue;
114112

115113
// Make sure this calendar is not locked.
116114
if (!$admin && in_array($cal_name, $locked_cals) && !in_array($cal_name, $unlocked_cals)) continue;
@@ -157,10 +155,10 @@ function availableCalendarNames($username, $password, $cal_filename, $admin = fa
157155
//
158156
// $cal_path = The path to the calendar file.
159157
function getCalendarName($cal_path) {
160-
global $support_ical;
158+
global $phpiCal_config;
161159

162160
// If iCal is supported, check the directory for an Info.plist.
163-
if ($support_ical == 'yes') {
161+
if ($phpiCal_config->support_ical == 'yes') {
164162
// Look for the Info.plist file.
165163
$plist_filename = dirname($cal_path)."/Info.plist";
166164
if (is_file($plist_filename)) {
@@ -186,7 +184,7 @@ function getCalendarName($cal_path) {
186184
//
187185
// $cals = The calendars (entire path, e.g. from availableCalendars).
188186
function display_ical_list($cals, $pick=FALSE) {
189-
global $cal, $current_view, $getdate, $calendar_lang, $all_cal_comb_lang, $cal_filelist, $cal_displaynames, $phpiCal_config;
187+
global $cal, $current_view, $getdate, $lang, $calendar_lang, $all_cal_comb_lang, $cal_filelist, $cal_displaynames, $phpiCal_config;
190188
// Print each calendar option.
191189
$return = '';
192190
foreach ($cals as $cal_tmp) {
@@ -216,7 +214,7 @@ function display_ical_list($cals, $pick=FALSE) {
216214
if ($prop_pos !== false) $property = substr($property,0,$prop_pos);
217215
$property = strtoupper($property);
218216
if ($property == "X-WR-CALNAME"){
219-
$cal_displayname_tmp = $data;
217+
$cal_displayname_tmp = stripslashes($data);
220218
break;
221219
}
222220
}

functions/ical_parser.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@
128128
$line = trim(stripslashes($line));
129129

130130
switch ($line) {
131+
case 'BEGIN:VFREEBUSY':
131132
case 'BEGIN:VEVENT':
132133
// each of these vars were being set to an empty string
133134
unset (
@@ -165,7 +166,7 @@
165166
$organizer = array();
166167

167168
break;
168-
169+
case 'END:VFREEBUSY':
169170
case 'END:VEVENT':
170171
include BASE."functions/parse/end_vevent.php";
171172
break;

functions/init.inc.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,14 @@
7575
substr($cal_filename, 0, 9) == 'webcal://')
7676
{
7777
#jump sends cal url without .ics extension. Add it if needed.
78-
if (substr($cal_filename, -4) != ".ics") $cal_filename .= ".ics";
78+
# if (substr($cal_filename, -4) != ".ics") $cal_filename .= ".ics";
7979
$web_cals[] = $cal_filename;
8080
}
8181

8282
// Otherwise it is a local calendar.
8383
else {
8484
// Check blacklisted.
85-
if (in_array($cal_filename, $phpiCal_config->blacklisted_cals) && $cal_filename !='') {
85+
if (in_array($cal_filename, $blacklisted_cals) && $cal_filename !='') {
8686
exit(error($lang['l_error_restrictedcal'], $cal_filename));
8787
}
8888
$local_cals[] = urldecode(str_replace(".ics", '', basename($cal_filename)));

functions/init/cpaths.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
$template = $user_template["$cpath"];
2727
}
2828
#set up specific webcals for a particular cpath
29-
if (isset($more_webcals) && is_array($more_webcals[$cpath])){
30-
$list_webcals = array_merge($list_webcals, $more_webcals["$cpath"]);
29+
if (isset($more_webcals[$cpath]) && is_array($more_webcals[$cpath])){
30+
foreach ($more_webcals[$cpath] as $wcal)$list_webcals[] = $wcal;
3131
}
3232
$phpiCal_config->setProperty('calendar_path',$calendar_path);

functions/init/date_range.php

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
$mArray_begin = mktime (0,0,0,$start_month,1,($start_year));
3434
$mArray_end = mktime (0,0,0,$end_month,31,($end_year));
3535
break;
36+
case 'admin':
3637
case 'error':
3738
case 'preferences':
3839
$mArray_begin = time();

functions/parse/parse_tzs.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
$ifile = @fopen($filename, "r");
3-
if ($ifile == FALSE) exit(error($lang['l_error_cantopen'], $filename));
3+
if ($ifile == FALSE) exit(error($lang['l_error_cantopen']." parse_tz", $filename));
44
$nextline = fgets($ifile);
55
if (trim($nextline) != 'BEGIN:VCALENDAR') exit(error($lang['l_error_invalidcal'], $filename));
66

functions/parse/recur_functions.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -251,4 +251,4 @@ function dump_times($times){
251251
#var_dump($times);
252252
foreach($times as $time) echo "\ndate:".date("Y-m-d H:i:s",$time);
253253
echo "</pre>";
254-
}
254+
}

0 commit comments

Comments
 (0)