Completed
Branch master (c3ca5f)
by Seth
04:51
created
phpicalendar/functions/userauth_functions.php 1 patch
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -17,7 +17,9 @@  discard block
 block discarded – undo
17 17
 function logout_querys() {
18 18
 	// Make sure the action is logout.
19 19
 	$querys = preg_replace('/action=[^&]+/', 'action=logout', $_SERVER['QUERY_STRING']);
20
-	if ($querys == $_SERVER['QUERY_STRING']) $querys .= '&action=logout';
20
+	if ($querys == $_SERVER['QUERY_STRING']) {
21
+		$querys .= '&action=logout';
22
+	}
21 23
 
22 24
 	// Remove references to the username or password.
23 25
 	$querys = preg_replace('/(username|password)=[^&]+/', '', $querys);
@@ -48,7 +50,9 @@  discard block
 block discarded – undo
48 50
 	// If not HTTP authenticated, try login via cookies or the web page.
49 51
 	if (isset($_SERVER['PHP_AUTH_USER'])) {
50 52
 		$username = $_SERVER['PHP_AUTH_USER'];
51
-		if (isset($_SERVER['PHP_AUTH_PW'])) $password = $_SERVER['PHP_AUTH_PW'];
53
+		if (isset($_SERVER['PHP_AUTH_PW'])) {
54
+			$password = $_SERVER['PHP_AUTH_PW'];
55
+		}
52 56
 
53 57
 		return array($username, $password, $invalid_login);
54 58
 	}
Please login to merge, or discard this patch.
phpicalendar/functions/ical_parser.php 1 patch
Braces   +41 added lines, -18 removed lines patch added patch discarded remove patch
@@ -1,5 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (!defined('BASE')) define('BASE', './');
2
+if (!defined('BASE')) {
3
+	define('BASE', './');
4
+}
3 5
 include_once(BASE.'functions/init.inc.php');
4 6
 include_once(BASE.'functions/date_functions.php');
5 7
 include_once(BASE.'functions/draw_functions.php');
@@ -33,16 +35,14 @@  discard block
 block discarded – undo
33 35
 					 * (disk I/O is expensive, but *much* cheaper than going to the network for remote files)
34 36
 					 */
35 37
 					$realcal_mtime = filemtime($fname);
36
-				}
37
-				else if ((time() - $mtime) >= $phpiCal_config->webcal_hours * 60 * 60) {
38
+				} else if ((time() - $mtime) >= $phpiCal_config->webcal_hours * 60 * 60) {
38 39
 					/*
39 40
 					 * We limit remote file mtime checks based on the magic webcal_hours config variable
40 41
 					 * This allows highly volatile web calendars to be cached for a period of time before
41 42
 					 * downloading them again
42 43
 					 */
43 44
 					$realcal_mtime = remote_filemtime($fname);
44
-				}
45
-				else {
45
+				} else {
46 46
 					// This is our fallback, for the case where webcal_hours is taking effect
47 47
 					$realcal_mtime = $mtime;
48 48
 				}
@@ -54,7 +54,9 @@  discard block
 block discarded – undo
54 54
 			}
55 55
 
56 56
 			foreach ($master_array['-3'] as $temp_array) {
57
-				if (isset($temp_array) && $temp_array !='') $caldisplaynames[] = $temp_array;
57
+				if (isset($temp_array) && $temp_array !='') {
58
+					$caldisplaynames[] = $temp_array;
59
+				}
58 60
 			}
59 61
 
60 62
 			// And the $y magic number is used here to determine if all calendars are up-to-date
@@ -63,8 +65,9 @@  discard block
 block discarded – undo
63 65
 					// At this point, all calendars are up-to-date, so we can simply used the pre-parsed data
64 66
 					$parse_file = false;
65 67
 					$calendar_name = $master_array['calendar_name'];
66
-					if (isset($master_array['calendar_tz']))
67
-						$calendar_tz = $master_array['calendar_tz'];
68
+					if (isset($master_array['calendar_tz'])) {
69
+											$calendar_tz = $master_array['calendar_tz'];
70
+					}
68 71
 				}
69 72
 			}
70 73
 		}
@@ -115,7 +118,9 @@  discard block
 block discarded – undo
115 118
 		include(BASE.'functions/parse/parse_tzs.php');
116 119
 
117 120
 		$ifile = @fopen($filename, 'r');
118
-		if ($ifile == FALSE) exit(error($lang['l_error_cantopen'], $filename));
121
+		if ($ifile == FALSE) {
122
+			exit(error($lang['l_error_cantopen'], $filename));
123
+		}
119 124
 		$nextline = fgets($ifile, 1024);
120 125
 		#if (trim($nextline) != 'BEGIN:VCALENDAR') exit(error($lang['l_error_invalidcal'], $filename));
121 126
 
@@ -266,7 +271,9 @@  discard block
 block discarded – undo
266 271
 					$data = $line[2];
267 272
 					$property = strtoupper($field);
268 273
 					$prop_pos = strpos($property,';');
269
-					if ($prop_pos !== false) $property = substr($property,0,$prop_pos);
274
+					if ($prop_pos !== false) {
275
+						$property = substr($property,0,$prop_pos);
276
+					}
270 277
 
271 278
 					switch ($property) {
272 279
 						// Start VTODO Parsing
@@ -454,7 +461,9 @@  discard block
 block discarded – undo
454 461
 							$role		= ($role ? $matches5[1] : '');
455 462
 
456 463
 							// Emergency fallback
457
-							if (empty($name) && empty($email)) $name = $data;
464
+							if (empty($name) && empty($email)) {
465
+								$name = $data;
466
+							}
458 467
 
459 468
 							$attendee[] = array ('name'     => stripslashes($name),
460 469
 												 'email'    => stripslashes($email),
@@ -471,7 +480,9 @@  discard block
 block discarded – undo
471 480
 							$name		= ($name ? $matches2[1] : $email);
472 481
 
473 482
 							// Emergency fallback
474
-							if (empty($name) && empty($email)) $name = $data;
483
+							if (empty($name) && empty($email)) {
484
+								$name = $data;
485
+							}
475 486
 
476 487
 							$organizer[] = array ('name' => stripslashes($name), 'email' => stripslashes($email));
477 488
 							break;
@@ -485,7 +496,9 @@  discard block
 block discarded – undo
485 496
 							$url = $data;
486 497
 							break;
487 498
 						default:
488
-							if(strpos(':',$data) > 1) $other .= $data;
499
+							if(strpos(':',$data) > 1) {
500
+								$other .= $data;
501
+							}
489 502
 					}
490 503
 				}
491 504
 			}
@@ -497,10 +510,18 @@  discard block
 block discarded – undo
497 510
 			unlink($filename);
498 511
 		}
499 512
 	}
500
-	if (!isset($master_array['-3'][$calnumber])) $master_array['-3'][$calnumber] = $actual_calname;
501
-	if (!isset($master_array['-4'][$calnumber]['mtime'])) $master_array['-4'][$calnumber]['mtime'] = $actual_mtime;
502
-	if (!isset($master_array['-4'][$calnumber]['filename'])) $master_array['-4'][$calnumber]['filename'] = $filename;
503
-	if (!isset($master_array['-4'][$calnumber]['webcal'])) $master_array['-4'][$calnumber]['webcal'] = 'no';
513
+	if (!isset($master_array['-3'][$calnumber])) {
514
+		$master_array['-3'][$calnumber] = $actual_calname;
515
+	}
516
+	if (!isset($master_array['-4'][$calnumber]['mtime'])) {
517
+		$master_array['-4'][$calnumber]['mtime'] = $actual_mtime;
518
+	}
519
+	if (!isset($master_array['-4'][$calnumber]['filename'])) {
520
+		$master_array['-4'][$calnumber]['filename'] = $filename;
521
+	}
522
+	if (!isset($master_array['-4'][$calnumber]['webcal'])) {
523
+		$master_array['-4'][$calnumber]['webcal'] = 'no';
524
+	}
504 525
 	$calnumber = $calnumber + 1;
505 526
 }
506 527
 
@@ -523,7 +544,9 @@  discard block
 block discarded – undo
523 544
 	if (isset($master_array) && is_array($master_array) && $phpiCal_config->save_parsed_cals == 'yes') {
524 545
 		$write_me = serialize($master_array);
525 546
 		$fd = @fopen($parsedcal, 'w');
526
-		if ($fd == FALSE) exit(error($lang['l_error_cache'], $filename));
547
+		if ($fd == FALSE) {
548
+			exit(error($lang['l_error_cache'], $filename));
549
+		}
527 550
 		@fwrite($fd, $write_me);
528 551
 		@fclose($fd);
529 552
 		@chmod($parsedcal, 0600); // 0640
Please login to merge, or discard this patch.
phpicalendar/functions/is_daylight.php 1 patch
Braces   +5 added lines, -3 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 	if(isset($tz_array[$timezone]['dt_start'][$year]) && isset($tz_array[$timezone]['st_start'][$year])){
17 17
 		$start	= $tz_array[$timezone]['dt_start'][$year];
18 18
 		$end 	= $tz_array[$timezone]['st_start'][$year];	
19
-	}else{
19
+	} else{
20 20
 		switch ($timezone){
21 21
 			case 'US/Samoa':                     # array('-1100', '-1100');
22 22
 			case 'America/Adak':                 # array('-1000', '-0900');
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 				if ($year < 2007){
84 84
 					$start 	= strtotime("+1 Sun",strtotime($year."0331"));
85 85
 					$end 	= strtotime("-1 Sun",strtotime($year."1101"));
86
-				}else{
86
+				} else{
87 87
 					$start 	= strtotime("+2 Sun",strtotime($year."0300"));
88 88
 					$end 	= strtotime("+1 Sun",strtotime($year."1031"));
89 89
 				}
@@ -287,7 +287,9 @@  discard block
 block discarded – undo
287 287
 				$dlst = date('I', $time);
288 288
 		}
289 289
 	}
290
-	if (isset($start,$end) && $time >= $start && $time < $end) $dlst = 1;
290
+	if (isset($start,$end) && $time >= $start && $time < $end) {
291
+		$dlst = 1;
292
+	}
291 293
 	#echo "$summary $dlst <br>";
292 294
 
293 295
 	return $dlst;
Please login to merge, or discard this patch.
phpicalendar/functions/parse/parse_tzs.php 1 patch
Braces   +21 added lines, -7 removed lines patch added patch discarded remove patch
@@ -1,6 +1,8 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 $ifile = @fopen($filename, 'r');
3
-if ($ifile == FALSE) exit(error($lang['l_error_cantopen'], $filename));
3
+if ($ifile == FALSE) {
4
+	exit(error($lang['l_error_cantopen'], $filename));
5
+}
4 6
 $nextline = fgets($ifile);
5 7
 #if (trim($nextline) != 'BEGIN:VCALENDAR') exit(error($lang['l_error_invalidcal'], $filename));
6 8
 
@@ -43,7 +45,9 @@  discard block
 block discarded – undo
43 45
 			$is_daylight = false;
44 46
 			break;
45 47
 		case 'END:VTIMEZONE':
46
-			if (!isset($offset_d) && isset($offset_s)) $offset_d = $offset_s;
48
+			if (!isset($offset_d) && isset($offset_s)) {
49
+				$offset_d = $offset_s;
50
+			}
47 51
 			$tz_array[$tz_id] = array(
48 52
 				0	=> @$offset_s, 
49 53
 				1	=> @$offset_d,
@@ -61,7 +65,9 @@  discard block
 block discarded – undo
61 65
 				$data = $line[2];				
62 66
 				$property = strtoupper($field);
63 67
 				$prop_pos = strpos($property,';');
64
-				if ($prop_pos !== false) $property = substr($property,0,$prop_pos);
68
+				if ($prop_pos !== false) {
69
+					$property = substr($property,0,$prop_pos);
70
+				}
65 71
 				switch ($property) {		
66 72
 					case 'TZID':
67 73
 						$tz_id = $data;
@@ -78,13 +84,21 @@  discard block
 block discarded – undo
78 84
 							$start_unixtime = $datetime[0];
79 85
 							$start_date = $datetime[1];
80 86
 							$year = substr($start_date,0,4);
81
-							if($is_std) $begin_std[$year] = $data;
82
-							if($is_daylight) $begin_daylight[$year] = $data;
87
+							if($is_std) {
88
+								$begin_std[$year] = $data;
89
+							}
90
+							if($is_daylight) {
91
+								$begin_daylight[$year] = $data;
92
+							}
83 93
 						}
84 94
 						break;
85 95
 					case 'TZNAME':
86
-						if($is_std) $st_name = $data;
87
-						if($is_daylight) $dt_name = $data;
96
+						if($is_std) {
97
+							$st_name = $data;
98
+						}
99
+						if($is_daylight) {
100
+							$dt_name = $data;
101
+						}
88 102
 						break;
89 103
 				}
90 104
 			}	
Please login to merge, or discard this patch.
phpicalendar/functions/parse/end_vevent.php 1 patch
Braces   +46 added lines, -16 removed lines patch added patch discarded remove patch
@@ -10,7 +10,9 @@  discard block
 block discarded – undo
10 10
 2. Build recur_data array
11 11
 3. Add occurrences to master_array
12 12
 */
13
-if (!isset($start_date)) $start_date = "19700101";
13
+if (!isset($start_date)) {
14
+	$start_date = "19700101";
15
+}
14 16
 
15 17
 // CLASS support
16 18
 if (isset($class)) {
@@ -28,17 +30,21 @@  discard block
 block discarded – undo
28 30
 	$uid = $uid_counter;
29 31
 	$uid_counter++;
30 32
 	$uid_valid = false;
31
-}elseif(in_array($uid, $uid_list)) {
33
+} elseif(in_array($uid, $uid_list)) {
32 34
 	# UID seen before. If sequence is the default, bump it.
33
-	if ($sequence == 0) $sequence++;
34
-}else{
35
+	if ($sequence == 0) {
36
+		$sequence++;
37
+	}
38
+	} else{
35 39
 	$uid_valid = true;
36 40
 }
37 41
 $uid_list[] = $uid;
38 42
 
39 43
 # Handle DURATION
40 44
 if (!isset($end_unixtime)) {
41
-	if(!isset($the_duration)) $the_duration = 0;
45
+	if(!isset($the_duration)) {
46
+		$the_duration = 0;
47
+	}
42 48
 	$end_unixtime 	= $start_unixtime + $the_duration;
43 49
 	$end_time 	= date ('Hi', $end_unixtime);
44 50
 }
@@ -178,10 +184,14 @@  discard block
 block discarded – undo
178 184
 }
179 185
 # convert wkst to a 3 char day for strtotime to work		
180 186
 $wkst3char = two2threeCharDays($wkst);
181
-if($current_view == 'search') $freq_type = 'none'; 
187
+if($current_view == 'search') {
188
+	$freq_type = 'none';
189
+}
182 190
 # $recur is the recurrence info that goes into the master array for this VEVENT
183 191
 $recur ='';
184
-if (isset($recur_array[($start_date)][($hour.$minute)][$uid]['recur'])) $recur = $recur_array[($start_date)][($hour.$minute)][$uid]['recur']; 
192
+if (isset($recur_array[($start_date)][($hour.$minute)][$uid]['recur'])) {
193
+	$recur = $recur_array[($start_date)][($hour.$minute)][$uid]['recur'];
194
+}
185 195
 
186 196
 /* ============================ Load $recur_data ============================
187 197
 $recur_data is an array of unix times for days of recurrences of an event.  This code handles repeats at the day level or above.  The next loop handles the times.
@@ -208,13 +218,21 @@  discard block
 block discarded – undo
208 218
 
209 219
 # conditions where we don't need to iterate over the whole range
210 220
 # 	if repeating without limit, and steps are by 1, don't go back before the mArray beginning.
211
-if($count == 1000000 && $interval == 1 && $mArray_begin > $next_range_unixtime) $next_range_unixtime = $mArray_begin;
221
+if($count == 1000000 && $interval == 1 && $mArray_begin > $next_range_unixtime) {
222
+	$next_range_unixtime = $mArray_begin;
223
+}
212 224
 
213 225
 # 	if the beginning of our range is less than the start of the item, we may as well set the range to start at start_time
214
-if ($next_range_unixtime < $start_date_unixtime) $next_range_unixtime = $start_date_unixtime;
226
+if ($next_range_unixtime < $start_date_unixtime) {
227
+	$next_range_unixtime = $start_date_unixtime;
228
+}
215 229
 
216 230
 # 	stop at the until limit if set
217
-if(isset($until) && $end_range_unixtime > $until_unixtime) $end_range_unixtime = $until_unixtime;else $until_unixtime = $mArray_end;
231
+if(isset($until) && $end_range_unixtime > $until_unixtime) {
232
+	$end_range_unixtime = $until_unixtime;
233
+} else {
234
+	$until_unixtime = $mArray_end;
235
+}
218 236
 
219 237
 # 	more adjustments
220 238
 switch ($freq_type){
@@ -250,7 +268,9 @@  discard block
 block discarded – undo
250 268
 			add_recur(expand_byday($next_range_unixtime));
251 269
 			break;
252 270
 		case 'month':
253
-			if(!empty($bymonthday)) $time = mktime(12,0,0,$month,1,$year);
271
+			if(!empty($bymonthday)) {
272
+				$time = mktime(12,0,0,$month,1,$year);
273
+			}
254 274
 			$times = expand_bymonthday(array($time));#echo "\n $month exp bymonthday";dump_times($times);
255 275
 			foreach($times as $time){ 
256 276
 				add_recur(expand_byday($time));
@@ -311,15 +331,23 @@  discard block
 block discarded – undo
311 331
 		$this_date_tmp = date('Ymd',$next_range_unixtime);	
312 332
 		$next_range_unixtime = strtotime('+1 day',$next_range_unixtime);
313 333
 		
314
-		if (!isset($allday_start) || $allday_start == '') $time_key = $hour.$minute;
334
+		if (!isset($allday_start) || $allday_start == '') {
335
+			$time_key = $hour.$minute;
336
+		}
315 337
 		$display_end_tmp = $end_hour.$end_minute;
316 338
 		if($time_key > -1){
317 339
 			# the day is not the first day of the recurrence
318
-			if ($this_date_tmp > $recur_data_date) $time_key = '0000';
340
+			if ($this_date_tmp > $recur_data_date) {
341
+				$time_key = '0000';
342
+			}
319 343
 			# the day is not the last day of the recurrence
320
-			if ($this_date_tmp < $end_date_tmp) $display_end_tmp = '2400';
344
+			if ($this_date_tmp < $end_date_tmp) {
345
+				$display_end_tmp = '2400';
346
+			}
347
+		}
348
+		if($this_date_tmp == $end_date_tmp && ($end_time == '0000')) {
349
+			continue;
321 350
 		}
322
-		if($this_date_tmp == $end_date_tmp && ($end_time == '0000')) continue;
323 351
 		if(!isset($master_array[$this_date_tmp][$time_key][$uid]['sequence']) || 
324 352
 			$sequence >  $master_array[$this_date_tmp][$time_key][$uid]['sequence']
325 353
 			){
@@ -351,7 +379,9 @@  discard block
 block discarded – undo
351 379
 				'recur' => $recur
352 380
 				);
353 381
 		}
354
-		if($time_key > -1) checkOverlap($this_date_tmp, $time_key, $uid);
382
+		if($time_key > -1) {
383
+			checkOverlap($this_date_tmp, $time_key, $uid);
384
+		}
355 385
 	}
356 386
 } # end foreach recur_data 
357 387
 unset($recur_data);
Please login to merge, or discard this patch.
phpicalendar/functions/parse/recur_functions.php 1 patch
Braces   +85 added lines, -35 removed lines patch added patch discarded remove patch
@@ -11,7 +11,9 @@  discard block
 block discarded – undo
11 11
 function add_recur($times, $freq = '') {
12 12
 	global $recur_data;
13 13
 	global $count, $mArray_begin, $mArray_end, $except_dates, $start_date, $start_date_unixtime,$end_range_unixtime,$until_unixtime, $day_offset, $current_view;
14
-	if (!is_array($times)) $times = array($times);
14
+	if (!is_array($times)) {
15
+		$times = array($times);
16
+	}
15 17
 	/*	BYMONTH, BYWEEKNO, BYYEARDAY, BYMONTHDAY, BYDAY, BYHOUR, BYMINUTE, BYSECOND and BYSETPOS	*/
16 18
 #dump_times($times);
17 19
 	if ($current_view != 'search') {
@@ -20,13 +22,17 @@  discard block
 block discarded – undo
20 22
 		$times = restrict_byyearday($times, $freq);
21 23
 		$times = restrict_bymonthday($times, $freq);
22 24
 		$times = restrict_byday($times, $freq);
23
-		if ($start_date_unixtime > $mArray_begin) $times[] = $start_date_unixtime;
25
+		if ($start_date_unixtime > $mArray_begin) {
26
+			$times[] = $start_date_unixtime;
27
+		}
24 28
 		$times = restrict_bysetpos($times, $freq);
25 29
 		$times = array_unique($times);
26 30
 		sort($times);
27 31
 	}
28 32
 	foreach ($times as $time) {
29
-		if (!isset($time) || $time == '') continue;
33
+		if (!isset($time) || $time == '') {
34
+			continue;
35
+		}
30 36
 
31 37
 		// Why are we arbitrarily setting the time to noon?
32 38
 		$date = date('Ymd', $time);
@@ -36,7 +42,9 @@  discard block
 block discarded – undo
36 42
 
37 43
 		# day offset fixes shifts across day boundaries due to time diffs.
38 44
 		# These are already fixed for the initial instance, but need to be fixed for recurrences
39
-		if (date('Ymd', $time) != $start_date) $time = $time + ($day_offset * 24 * 60 * 60);
45
+		if (date('Ymd', $time) != $start_date) {
46
+			$time = $time + ($day_offset * 24 * 60 * 60);
47
+		}
40 48
 		if ((isset($time)) &&
41 49
 			(!in_array($time, $recur_data)) &&
42 50
 			(!in_array($date, $except_dates)) &&
@@ -49,8 +57,7 @@  discard block
 block discarded – undo
49 57
 				($count >= 0)) {
50 58
 				$recur_data[] = $time;
51 59
 			}
52
-		}
53
-		else if (in_array($date, $except_dates)) {
60
+		} else if (in_array($date, $except_dates)) {
54 61
 			$count--;
55 62
 		}
56 63
 	}
@@ -60,10 +67,16 @@  discard block
 block discarded – undo
60 67
 
61 68
 function expand_bymonth($time) {
62 69
 	global $bymonth, $byweekno, $bymonthday, $year, $start_unixtime, $freq_type;
63
-	if (!empty($byweekno)) return $time;
64
-	if (empty($bymonth)) $bymonth = array(date('m', $start_unixtime));
70
+	if (!empty($byweekno)) {
71
+		return $time;
72
+	}
73
+	if (empty($bymonth)) {
74
+		$bymonth = array(date('m', $start_unixtime));
75
+	}
65 76
 	$d = date('d', $start_unixtime);
66
-	if (!empty($bymonthday)) $d = 1;
77
+	if (!empty($bymonthday)) {
78
+		$d = 1;
79
+	}
67 80
 	foreach ($bymonth as $m) {
68 81
 		$time = mktime(12, 0, 0, $m, $d, $year);
69 82
 		$times[] = $time;
@@ -76,8 +89,12 @@  discard block
 block discarded – undo
76 89
 	# byweekno is only used when repeat is yearly
77 90
 	# when it's set, the input times are irrelevant
78 91
 	# it also needs a byday.
79
-	if ($freq_type != 'year') return $times;
80
-	if (empty($byweekno)) return $times;
92
+	if ($freq_type != 'year') {
93
+		return $times;
94
+	}
95
+	if (empty($byweekno)) {
96
+		return $times;
97
+	}
81 98
 	$total_weeks = date('W', mktime(12, 0, 0, 12, 24, $year)) + 1;
82 99
 	$w1_start = strtotime('this ' . $wkst3char, mktime(12, 0, 0, 1, 1, $year));
83 100
 	foreach ($byweekno as $weekno) {
@@ -92,7 +109,9 @@  discard block
 block discarded – undo
92 109
 
93 110
 function expand_byyearday($times) {
94 111
 	global $byyearday, $year;
95
-	if (empty($byyearday)) return $times;
112
+	if (empty($byyearday)) {
113
+		return $times;
114
+	}
96 115
 	$py = $year-1;
97 116
 	$ny = $year+1;
98 117
 	$new_times = array();
@@ -100,11 +119,12 @@  discard block
 block discarded – undo
100 119
 		foreach ($byyearday as $yearday) {
101 120
 			if ($yearday > 0) {
102 121
 				$day = strtotime('+' . $yearday . ' days Dec 31, ' . $py);
103
-			}
104
-			else {
122
+			} else {
105 123
 				$day = strtotime('Jan 1 ' . $ny . ' ' . $yearday . ' days');
106 124
 			}
107
-			if (date('Y', $day == $year)) $new_times[] = $day;
125
+			if (date('Y', $day == $year)) {
126
+				$new_times[] = $day;
127
+			}
108 128
 		}
109 129
 	}
110 130
 #	dump_times($new_times);
@@ -113,7 +133,9 @@  discard block
 block discarded – undo
113 133
 
114 134
 function expand_bymonthday($times) {
115 135
 	global $bymonthday, $year;
116
-	if (empty($bymonthday)) return $times;
136
+	if (empty($bymonthday)) {
137
+		return $times;
138
+	}
117 139
 	foreach ($times as $time) {
118 140
 		$month = date('m', $time);
119 141
 		foreach ($bymonthday as $monthday) {
@@ -128,7 +150,9 @@  discard block
 block discarded – undo
128 150
 
129 151
 function expand_byday($time) {
130 152
 	global $freq_type, $byday, $bymonth,$byweekno, $wkst3char, $year, $month, $start_unixtime, $summary;
131
-	if (empty($byday)) return array($time);
153
+	if (empty($byday)) {
154
+		return array($time);
155
+	}
132 156
 	$times = array();
133 157
 	$the_sunday = dateOfWeek(date('Ymd', $time), $wkst3char);
134 158
 	foreach ($byday as $key => $day) {
@@ -152,7 +176,9 @@  discard block
 block discarded – undo
152 176
 			case 'year':
153 177
 				if (empty($byweekno)) {
154 178
 					$week_arr = array(1, 2, 3, 4, 5);
155
-					if(isset($byday_arr[2]) && $byday_arr[2] !='') $week_arr = array($byday_arr[2]);
179
+					if(isset($byday_arr[2]) && $byday_arr[2] !='') {
180
+						$week_arr = array($byday_arr[2]);
181
+					}
156 182
 					$month_start = strtotime(date('Ym01', $time)) - (24 * 60 * 60);
157 183
 					$month_end = strtotime(date('Ymt', $time)) + (36 * 60 * 60);
158 184
 					if ($freq_type == 'year' && empty($bymonth)) {
@@ -163,8 +189,7 @@  discard block
 block discarded – undo
163 189
 					foreach ($week_arr as $week) {
164 190
 						if ($byday_arr[1] == '-') {
165 191
 							$next_date_time = strtotime($byday_arr[1] . $week . $on_day, $month_end);
166
-						}
167
-						else {
192
+						} else {
168 193
 							# we need this special offset in case the event day coincides with the month start day
169 194
 							# eg: month starts on a Sunday, our event is the Nth Sunday of the month... without this
170 195
 							# special offset, the event will be added to the (N+1)th Sunday of the month
@@ -172,10 +197,11 @@  discard block
 block discarded – undo
172 197
 							$next_date_time = strtotime($byday_arr[1] . $week . $on_day, ($month_start + $special_offset));
173 198
 						}
174 199
 						# check that we're still in the same month
175
-						if (date('m', $next_date_time) == date('m', $time)) $times[] = $next_date_time;
200
+						if (date('m', $next_date_time) == date('m', $time)) {
201
+							$times[] = $next_date_time;
202
+						}
176 203
 					}
177
-				}
178
-				else {
204
+				} else {
179 205
 					# byweekno should act like freq_type = week
180 206
 					$next_date_time = strtotime('this ' . $on_day, strtotime($the_sunday)) + (12 * 60 * 60);
181 207
 					$times[] = $next_date_time;
@@ -192,20 +218,28 @@  discard block
 block discarded – undo
192 218
 
193 219
 function restrict_bymonth($times, $freq = '') {
194 220
 	global $bymonth, $byyearday;
195
-	if (empty($bymonth) || !empty($byyearday)) return $times;
221
+	if (empty($bymonth) || !empty($byyearday)) {
222
+		return $times;
223
+	}
196 224
 	$new_times = array();
197 225
 	foreach ($times as $time) {
198
-		if (in_array(date('m', $time), $bymonth)) $new_times[] = $time;
226
+		if (in_array(date('m', $time), $bymonth)) {
227
+			$new_times[] = $time;
228
+		}
199 229
 	}
200 230
 	return $new_times;
201 231
 }
202 232
 
203 233
 function restrict_byweekno($times, $freq = '') {
204 234
 	global $byweekno;
205
-	if (empty($byweekno)) return $times;
235
+	if (empty($byweekno)) {
236
+		return $times;
237
+	}
206 238
 	$new_times = array();
207 239
 	foreach ($times as $time) {
208
-		if (in_array(date('W', $time), $byweekno)) $new_times[] = $time;
240
+		if (in_array(date('W', $time), $byweekno)) {
241
+			$new_times[] = $time;
242
+		}
209 243
 	}
210 244
 	return $new_times;
211 245
 
@@ -213,25 +247,33 @@  discard block
 block discarded – undo
213 247
 
214 248
 function restrict_byyearday($times, $freq = '') {
215 249
 	global $byyearday;
216
-	if (empty($byyearday)) return $times;
250
+	if (empty($byyearday)) {
251
+		return $times;
252
+	}
217 253
 	$new_times = array();
218 254
 	foreach ($times as $time) {
219 255
 		foreach ($byyearday as $yearday) {
220 256
 			if ($yearday < 0) {
221 257
 				$yearday = 365 + $yearday + 1;
222
-				if (date('L', $time)) $yearday += 1;
258
+				if (date('L', $time)) {
259
+					$yearday += 1;
260
+				}
223 261
 			}
224 262
 			$yearday_arr[] = $yearday;
225 263
 		}
226 264
 		# date('z', $time) gives 0 for Jan 1
227
-		if (in_array((date('z', $time) + 1), $yearday_arr)) $new_times[] = $time;
265
+		if (in_array((date('z', $time) + 1), $yearday_arr)) {
266
+			$new_times[] = $time;
267
+		}
228 268
 	}
229 269
 	return $new_times;
230 270
 }
231 271
 
232 272
 function restrict_bymonthday($times, $freq = '') {
233 273
 	global $bymonthday;
234
-	if (empty($bymonthday)) return $times;
274
+	if (empty($bymonthday)) {
275
+		return $times;
276
+	}
235 277
 	$new_times = array();
236 278
 	foreach ($times as $time) {
237 279
 		foreach ($bymonthday as $monthday) {
@@ -240,13 +282,17 @@  discard block
 block discarded – undo
240 282
 			}
241 283
 			$monthday_arr[] = $monthday;
242 284
 		}
243
-		if (in_array(date('j', $time), $monthday_arr)) $new_times[] = $time;
285
+		if (in_array(date('j', $time), $monthday_arr)) {
286
+			$new_times[] = $time;
287
+		}
244 288
 	}
245 289
 	return $new_times;
246 290
 }
247 291
 function restrict_byday($times, $freq = '') {
248 292
 	global $byday;
249
-	if (empty($byday)) return $times;
293
+	if (empty($byday)) {
294
+		return $times;
295
+	}
250 296
 	foreach ($byday as $key => $day) {
251 297
 		/* set $byday_arr
252 298
 				[0] => byday string, e.g. 4TH
@@ -259,14 +305,18 @@  discard block
 block discarded – undo
259 305
 	}
260 306
 	$new_times = array();
261 307
 	foreach ($times as $time) {
262
-		if (in_array(strtolower(date('D', $time)), $byday3)) $new_times[] = $time;
308
+		if (in_array(strtolower(date('D', $time)), $byday3)) {
309
+			$new_times[] = $time;
310
+		}
263 311
 	}
264 312
 	return $new_times;
265 313
 }
266 314
 
267 315
 function restrict_bysetpos($times, $freq = '') {
268 316
 	global $bysetpos;
269
-	if (empty($bysetpos)) return $times;
317
+	if (empty($bysetpos)) {
318
+		return $times;
319
+	}
270 320
 	sort($times);
271 321
 	$new_times = array();
272 322
 	foreach ($bysetpos as $setpos) {
Please login to merge, or discard this patch.
phpicalendar/functions/parse/overlapping_events.php 1 patch
Braces   +23 added lines, -9 removed lines patch added patch discarded remove patch
@@ -5,8 +5,11 @@  discard block
 block discarded – undo
5 5
 	$x = $a;
6 6
 	$y = $b;
7 7
 	while ($x != $y) {
8
-		if ($x < $y) $x += $a;
9
-		else $y += $b;
8
+		if ($x < $y) {
9
+			$x += $a;
10
+		} else {
11
+			$y += $b;
12
+		}
10 13
 	}
11 14
 	return $x;
12 15
 }
@@ -63,8 +66,9 @@  discard block
 block discarded – undo
63 66
 
64 67
 	$count = 0;
65 68
 	foreach ($ol_ranges as $loop_range) {
66
-		if ($count < $loop_range['count'])
67
-			$count = $loop_range['count'];
69
+		if ($count < $loop_range['count']) {
70
+					$count = $loop_range['count'];
71
+		}
68 72
 	}
69 73
 
70 74
 	return $count;
@@ -87,8 +91,12 @@  discard block
 block discarded – undo
87 91
 			// check if blocks overlap
88 92
 			if (($loop_block['blockStart'] < $new_block['blockEnd']) && ($loop_block['blockEnd'] > $new_block['blockStart'])) {
89 93
 				// define start and end of merged overlap block
90
-				if ($new_block['blockStart'] > $loop_block['blockStart']) $ol_blocks[$new_block_key]['blockStart'] = $loop_block['blockStart'];
91
-				if ($new_block['blockEnd'] < $loop_block['blockEnd']) $ol_blocks[$new_block_key]['blockEnd'] = $loop_block['blockEnd'];
94
+				if ($new_block['blockStart'] > $loop_block['blockStart']) {
95
+					$ol_blocks[$new_block_key]['blockStart'] = $loop_block['blockStart'];
96
+				}
97
+				if ($new_block['blockEnd'] < $loop_block['blockEnd']) {
98
+					$ol_blocks[$new_block_key]['blockEnd'] = $loop_block['blockEnd'];
99
+				}
92 100
 				$ol_blocks[$new_block_key]['events'] = array_merge($new_block['events'], $loop_block['events']);
93 101
 				$new_block['events'] = $ol_blocks[$new_block_key]['events'];
94 102
 				foreach ($loop_block['overlapRanges'] as $ol_range) {
@@ -134,7 +142,9 @@  discard block
 block discarded – undo
134 142
 	//		'end'	- end_time for the overlap block.
135 143
 function checkOverlap($event_date, $event_time, $uid) {
136 144
 	global $master_array, $overlap_array;
137
-	if (!isset($event_date)) return;
145
+	if (!isset($event_date)) {
146
+		return;
147
+	}
138 148
 	$event = $master_array[$event_date][$event_time][$uid];
139 149
 	// Copy out the array - we replace this at the end.
140 150
 	$ol_day_array = @$overlap_array[$event_date];
@@ -150,8 +160,12 @@  discard block
 block discarded – undo
150 160
 				// ... unless it's already in the $ol_block
151 161
 				if (!in_array(array('time' => $drawTimes['draw_start'], 'key' => $uid), $loop_ol_block['events'])) {
152 162
 					$loop_ol_block['events'][] = array('time' => $drawTimes['draw_start'], 'key' => $uid);
153
-					if ($loop_ol_block['blockStart'] > $drawTimes['draw_start']) $loop_ol_block['blockStart'] = $drawTimes['draw_start'];
154
-					if ($loop_ol_block['blockEnd'] < $drawTimes['draw_end']) $loop_ol_block['blockEnd'] = $drawTimes['draw_end'];
163
+					if ($loop_ol_block['blockStart'] > $drawTimes['draw_start']) {
164
+						$loop_ol_block['blockStart'] = $drawTimes['draw_start'];
165
+					}
166
+					if ($loop_ol_block['blockEnd'] < $drawTimes['draw_end']) {
167
+						$loop_ol_block['blockEnd'] = $drawTimes['draw_end'];
168
+					}
155 169
 
156 170
 					// Merge in the new overlap range
157 171
 					$loop_ol_block['overlapRanges'] = merge_range($loop_ol_block['overlapRanges'], $drawTimes['draw_start'], $drawTimes['draw_end']);
Please login to merge, or discard this patch.
phpicalendar/functions/calendar_functions.php 1 patch
Braces   +58 added lines, -27 removed lines patch added patch discarded remove patch
@@ -29,10 +29,11 @@  discard block
 block discarded – undo
29 29
 		$unlocked_cals = $locked_map["$username:$password"];
30 30
 	}
31 31
 	// Make a local copy of the requested calendars.
32
-	if (!is_array($cal_filename))
33
-		$cal_filename_local = array($cal_filename);
34
-	else
35
-		$cal_filename_local = $cal_filename;
32
+	if (!is_array($cal_filename)) {
33
+			$cal_filename_local = array($cal_filename);
34
+	} else {
35
+			$cal_filename_local = $cal_filename;
36
+	}
36 37
 
37 38
 	// Create the list of available calendars.
38 39
 	$calendars = array();
@@ -44,7 +45,9 @@  discard block
 block discarded – undo
44 45
 		if (!isset($http_user) && !$admin) {
45 46
 			foreach ($list_webcals as $file) {
46 47
 				// Make sure the URL ends with .ics.
47
-				if (!is_string($file)) continue;			
48
+				if (!is_string($file)) {
49
+					continue;
50
+				}
48 51
 				// Add this calendar.
49 52
 				array_push($calendars, $file);
50 53
 			}
@@ -72,13 +75,16 @@  discard block
 block discarded – undo
72 75
 			// Open the directory.
73 76
 			$dir_handle = opendir($search_path)
74 77
 				or die(error(sprintf($lang['l_error_path'], $search_path), implode(',', $cal_filename)));
75
-			if ($dir_handle === false)
76
-				die(error(sprintf($lang['l_error_path'], $search_path), implode(',', $cal_filename)));
78
+			if ($dir_handle === false) {
79
+							die(error(sprintf($lang['l_error_path'], $search_path), implode(',', $cal_filename)));
80
+			}
77 81
 				
78 82
 			// Add each file in the directory that does not begin with a dot.
79 83
 			while (false !== ($file = readdir($dir_handle))) {
80 84
 				// Make sure this is not a dot file.
81
-				if (preg_match("/^\./", $file)) continue;
85
+				if (preg_match("/^\./", $file)) {
86
+					continue;
87
+				}
82 88
 				array_push($files, "$search_path/$file");
83 89
 			}
84 90
 		} else {
@@ -94,24 +100,38 @@  discard block
 block discarded – undo
94 100
 			// Push directories onto the search paths if recursive paths is
95 101
 			// turned on.
96 102
 			if (is_dir($file)) {
97
-				if ($phpiCal_config->recursive_path == 'yes') array_push($search_paths, $file);
103
+				if ($phpiCal_config->recursive_path == 'yes') {
104
+					array_push($search_paths, $file);
105
+				}
98 106
 				continue;
99 107
 			}			
100 108
 			// Make sure the file is real.
101
-			if (!is_file($file)) continue;
109
+			if (!is_file($file)) {
110
+				continue;
111
+			}
102 112
 			// Remove any php files.
103
-			if (preg_match("/^.*\.php$/i", $file)) continue;
113
+			if (preg_match("/^.*\.php$/i", $file)) {
114
+				continue;
115
+			}
104 116
 			# remove publish log file 
105
-			if ($file == 'publish_log.txt') continue;
117
+			if ($file == 'publish_log.txt') {
118
+				continue;
119
+			}
106 120
 			// Make sure this is not a blacklisted calendar.
107 121
 			$cal_name = getCalendarName($file); 
108
-			if (in_array($cal_name, $blacklisted_cals)) continue;
122
+			if (in_array($cal_name, $blacklisted_cals)) {
123
+				continue;
124
+			}
109 125
 			// If HTTP authenticated, make sure this calendar is available
110 126
 			// to the user.
111
-			if (isset($http_user) && isset($apache_map[$http_user]) && !in_array($cal_name, $apache_map[$http_user])) continue;
127
+			if (isset($http_user) && isset($apache_map[$http_user]) && !in_array($cal_name, $apache_map[$http_user])) {
128
+				continue;
129
+			}
112 130
 
113 131
 			// Make sure this calendar is not locked.
114
-			if (!$admin && in_array($cal_name, $locked_cals) && !in_array($cal_name, $unlocked_cals)) continue;
132
+			if (!$admin && in_array($cal_name, $locked_cals) && !in_array($cal_name, $unlocked_cals)) {
133
+				continue;
134
+			}
115 135
 			
116 136
 			// Add this calendar if we're looking for it, and remove it's name
117 137
 			// from the local list because we've found it.
@@ -119,7 +139,9 @@  discard block
 block discarded – undo
119 139
 				array_push($calendars, $file);
120 140
 				$cal_filename_local = array_diff($cal_filename_local, array($cal_name));				
121 141
 				// If the local list is empty, we're done.
122
-				if (empty($cal_filename_local))	break 2;
142
+				if (empty($cal_filename_local)) {
143
+					break 2;
144
+				}
123 145
 			}
124 146
 		}
125 147
 	}
@@ -169,8 +191,9 @@  discard block
 block discarded – undo
169 191
 						
170 192
 			// Pull out the calendar name.
171 193
 			$num_matches = preg_match("/<key>Title<\/key>\s*?<string>(.+?)<\/string>/i", $contents, $matches);
172
-			if ($num_matches > 0)
173
-				return $matches[1];
194
+			if ($num_matches > 0) {
195
+							return $matches[1];
196
+			}
174 197
 		}
175 198
 	}
176 199
 	
@@ -195,7 +218,9 @@  discard block
 block discarded – undo
195 218
 	$return = '';
196 219
 
197 220
 	$all_cals = false;
198
-	if (count($cals) > 1) $all_cals = true;
221
+	if (count($cals) > 1) {
222
+		$all_cals = true;
223
+	}
199 224
 
200 225
 	foreach ($cals as $cal_tmp) {
201 226
 		// Format the calendar path for display.
@@ -204,8 +229,7 @@  discard block
 block discarded – undo
204 229
 		$search_idx = array_search($cal_tmp, $cal_filelist);
205 230
 		if (is_numeric($search_idx)) {
206 231
 			$cal_displayname_tmp = $cal_displaynames[$search_idx];
207
-		}
208
-		else if ((substr($cal_tmp, 0, 7) == 'http://') ||
232
+		} else if ((substr($cal_tmp, 0, 7) == 'http://') ||
209 233
 			(substr($cal_tmp, 0, 8) == 'https://') ||
210 234
 			(substr($cal_tmp, 0, 9) == 'webcal://')) {
211 235
 			$cal_tmp2 = str_replace('webcal://', 'http://', $cal_tmp);
@@ -218,11 +242,12 @@  discard block
 block discarded – undo
218 242
 				}
219 243
 				$num++;
220 244
 			}
221
-		}
222
-		else {
245
+		} else {
223 246
 			# pull the name from the $cal_tmp file
224 247
 			$ifile = @fopen($cal_tmp, 'r');
225
-			if ($ifile == FALSE) exit(error($lang['l_error_cantopen'], $cal_tmp));
248
+			if ($ifile == FALSE) {
249
+				exit(error($lang['l_error_cantopen'], $cal_tmp));
250
+			}
226 251
 			while (!feof($ifile)) {
227 252
 				$line = fgets($ifile, 1024);
228 253
 				$line = trim($line);
@@ -231,7 +256,9 @@  discard block
 block discarded – undo
231 256
 					$data = $regs[2];
232 257
 					$property = $field;
233 258
 					$prop_pos = strpos($property,';');
234
-					if ($prop_pos !== false) $property = substr($property,0,$prop_pos);
259
+					if ($prop_pos !== false) {
260
+						$property = substr($property,0,$prop_pos);
261
+					}
235 262
 					$property = strtoupper($property);
236 263
 					if ($property == "X-WR-CALNAME"){
237 264
 						$cal_displayname_tmp = stripslashes($data);
@@ -239,7 +266,9 @@  discard block
 block discarded – undo
239 266
 					}
240 267
 				}	
241 268
 				#stop reading if we find an event or timezone before there's a name
242
-				if ($line == "BEGIN:VTIMEZONE" ||$line == "BEGIN:VEVENT") break;
269
+				if ($line == "BEGIN:VTIMEZONE" ||$line == "BEGIN:VEVENT") {
270
+					break;
271
+				}
243 272
 			}
244 273
 			@fclose($ifile);
245 274
 		}
@@ -272,7 +301,9 @@  discard block
 block discarded – undo
272 301
 		}
273 302
 
274 303
 		// Try to detect unselected calendars
275
-		if (!in_array($cal_encoded_tmp, explode(",", $cal))) $all_cals = false;
304
+		if (!in_array($cal_encoded_tmp, explode(",", $cal))) {
305
+			$all_cals = false;
306
+		}
276 307
 
277 308
 		// Display the option.
278 309
 		//
Please login to merge, or discard this patch.
phpicalendar/functions/admin_functions.php 1 patch
Braces   +35 added lines, -32 removed lines patch added patch discarded remove patch
@@ -6,10 +6,10 @@  discard block
 block discarded – undo
6 6
 	global $_SESSION;
7 7
 	if (!isset($_SESSION['phpical_loggedin']) || $_SESSION['phpical_loggedin'] == FALSE) {
8 8
 		return FALSE;
9
+	} else {
10
+			return TRUE;
11
+	}
9 12
 	}
10
-	else
11
-		return TRUE;
12
-}
13 13
 
14 14
 // Attempt to login. If login is valid, set the session variable 'phpical_loggedin' to TRUE and store the username and password in the session
15 15
 //
@@ -51,7 +51,9 @@  discard block
 block discarded – undo
51 51
 	
52 52
 	// set up basic connection
53 53
 	$conn_id = @ftp_connect($phpiCal_config->ftp_server, $phpiCal_config->ftp_port); 
54
-	if (!$conn_id) exit(error('Cannot connect to FTP server', $filename));
54
+	if (!$conn_id) {
55
+		exit(error('Cannot connect to FTP server', $filename));
56
+	}
55 57
 	// login with username and password
56 58
 	$login_result = @ftp_login($conn_id, $username, $password); 
57 59
 	
@@ -74,11 +76,12 @@  discard block
 block discarded – undo
74 76
 function login_internal ($username, $password) {
75 77
 	global $phpiCal_config;
76 78
 	
77
-	if ($phpiCal_config->auth_internal_username == $username && $phpiCal_config->auth_internal_password == $password)
78
-		return TRUE;
79
-	else
80
-		return FALSE;
81
-}
79
+	if ($phpiCal_config->auth_internal_username == $username && $phpiCal_config->auth_internal_password == $password) {
80
+			return TRUE;
81
+	} else {
82
+			return FALSE;
83
+	}
84
+	}
82 85
 
83 86
 // Delete a calendar. If using ftp for authentication, use ftp to delete. Otherwise, use file system functions.
84 87
 //
@@ -100,15 +103,17 @@  discard block
 block discarded – undo
100 103
 		$login_result = @ftp_login($conn_id, $_SESSION['phpical_username'], $_SESSION['phpical_password']); 
101 104
 		
102 105
 		// check connection
103
-		if ((!$conn_id) || (!$login_result))
104
-			return FALSE;
106
+		if ((!$conn_id) || (!$login_result)) {
107
+					return FALSE;
108
+		}
105 109
 		
106 110
 		// delete the file
107 111
 		$delete = @ftp_delete($conn_id, $filename); 
108 112
 		
109 113
 		// check delete status
110
-		if (!$delete)
111
-			return FALSE;
114
+		if (!$delete) {
115
+					return FALSE;
116
+		}
112 117
 		
113 118
 		// close the FTP stream 
114 119
 		@ftp_close($conn_id);
@@ -131,8 +136,7 @@  discard block
 block discarded – undo
131 136
 		clearstatcache();
132 137
 		if (@file_exists($filename)) {
133 138
 			return FALSE;
134
-		}
135
-		else {
139
+		} else {
136 140
 			return TRUE;
137 141
 		}
138 142
 		
@@ -161,28 +165,28 @@  discard block
 block discarded – undo
161 165
 		$login_result = ftp_login($conn_id, $_SESSION['phpical_username'], $_SESSION['phpical_password']); 
162 166
 		
163 167
 		// check connection
164
-		if ((!$conn_id) || (!$login_result))
165
-			return FALSE;
168
+		if ((!$conn_id) || (!$login_result)) {
169
+					return FALSE;
170
+		}
166 171
 		
167 172
 		// upload the file
168 173
 		$upload = ftp_put($conn_id, $destination, $source, FTP_ASCII); 
169 174
 		
170 175
 		// check upload status
171
-		if (!$upload)
172
-			return FALSE;
176
+		if (!$upload) {
177
+					return FALSE;
178
+		}
173 179
 		
174 180
 		// close the FTP stream 
175 181
 		ftp_close($conn_id);
176 182
 		
177 183
 		return TRUE;
178
-	}
179
-	else {
184
+	} else {
180 185
 		$destination = $calendar_path . "/" . basename($destination);
181 186
 		
182 187
 		if (check_php_version('4.0.3')) {
183 188
 			return move_uploaded_file($source, $destination);
184
-		}
185
-		else {
189
+		} else {
186 190
 			return copy($source, $destination);
187 191
 		}
188 192
 	}
@@ -197,9 +201,9 @@  discard block
 block discarded – undo
197 201
 	global $phpiCal_config;
198 202
 	global $calendar_path;
199 203
 	
200
-	if ($phpiCal_config->ftp_calendar_path != '')
201
-		return $phpiCal_config->ftp_calendar_path;
202
-	else {
204
+	if ($phpiCal_config->ftp_calendar_path != '') {
205
+			return $phpiCal_config->ftp_calendar_path;
206
+	} else {
203 207
 		return str_replace ("\\", "/", realpath($calendar_path));
204 208
 	}
205 209
 }
@@ -212,8 +216,9 @@  discard block
 block discarded – undo
212 216
 	// intval used for version like "4.0.4pl1"
213 217
 	$testVer=intval(str_replace(".", "",$version));
214 218
 	$curVer=intval(str_replace(".", "",phpversion()));
215
-	if( $curVer < $testVer )
216
-		return FALSE;
219
+	if( $curVer < $testVer ) {
220
+			return FALSE;
221
+	}
217 222
 	return TRUE;
218 223
 }
219 224
 
@@ -257,8 +262,7 @@  discard block
 block discarded – undo
257 262
 				$error = $error . $upload_error . ": " . $upload_error_gen_lang;
258 263
 				break;
259 264
 		}
260
-	}
261
-	else {
265
+	} else {
262 266
 		$error = $upload_error_gen_lang;
263 267
 	}
264 268
 	
@@ -273,8 +277,7 @@  discard block
 block discarded – undo
273 277
 	// Check the file extension for .ics. Can also check the the mime type, but it's not reliable so why bother...
274 278
 	if(preg_match("/.ics$/i", $filename)) {
275 279
 		return TRUE;
276
-	}
277
-	else {
280
+	} else {
278 281
 		return FALSE;
279 282
 	}
280 283
 }
Please login to merge, or discard this patch.