Completed
Pull Request — release-2.1 (#5028)
by 01
06:01
created
Sources/ManageScheduledTasks.php 1 patch
Braces   +57 added lines, -40 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 4
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 /**
20 21
  * Scheduled tasks management dispatcher. This function checks permissions and delegates
@@ -41,10 +42,11 @@  discard block
 block discarded – undo
41 42
 	);
42 43
 
43 44
 	// We need to find what's the action.
44
-	if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']]))
45
-		$context['sub_action'] = $_REQUEST['sa'];
46
-	else
47
-		$context['sub_action'] = 'tasks';
45
+	if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']])) {
46
+			$context['sub_action'] = $_REQUEST['sa'];
47
+	} else {
48
+			$context['sub_action'] = 'tasks';
49
+	}
48 50
 
49 51
 	// Now for the lovely tabs. That we all love.
50 52
 	$context[$context['admin_menu_name']]['tab_data'] = array(
@@ -94,9 +96,10 @@  discard block
 block discarded – undo
94 96
 
95 97
 		// Enable and disable as required.
96 98
 		$enablers = array(0);
97
-		foreach ($_POST['enable_task'] as $id => $enabled)
98
-			if ($enabled)
99
+		foreach ($_POST['enable_task'] as $id => $enabled) {
100
+					if ($enabled)
99 101
 				$enablers[] = (int) $id;
102
+		}
100 103
 
101 104
 		// Do the update!
102 105
 		$smcFunc['db_query']('', '
@@ -134,8 +137,9 @@  discard block
 block discarded – undo
134 137
 
135 138
 		// Lets figure out which ones they want to run.
136 139
 		$tasks = array();
137
-		foreach ($_POST['run_task'] as $task => $dummy)
138
-			$tasks[] = (int) $task;
140
+		foreach ($_POST['run_task'] as $task => $dummy) {
141
+					$tasks[] = (int) $task;
142
+		}
139 143
 
140 144
 		// Load up the tasks.
141 145
 		$request = $smcFunc['db_query']('', '
@@ -155,36 +159,41 @@  discard block
 block discarded – undo
155 159
 		while ($row = $smcFunc['db_fetch_assoc']($request))
156 160
 		{
157 161
 			// What kind of task are we handling?
158
-			if (!empty($row['callable']))
159
-				$task_string = $row['callable'];
162
+			if (!empty($row['callable'])) {
163
+							$task_string = $row['callable'];
164
+			}
160 165
 
161 166
 			// Default SMF task or old mods?
162
-			elseif (function_exists('scheduled_' . $row['task']))
163
-				$task_string = 'scheduled_' . $row['task'];
167
+			elseif (function_exists('scheduled_' . $row['task'])) {
168
+							$task_string = 'scheduled_' . $row['task'];
169
+			}
164 170
 
165 171
 			// One last resource, the task name.
166
-			elseif (!empty($row['task']))
167
-				$task_string = $row['task'];
172
+			elseif (!empty($row['task'])) {
173
+							$task_string = $row['task'];
174
+			}
168 175
 
169 176
 			$start_time = microtime();
170 177
 			// The functions got to exist for us to use it.
171
-			if (empty($task_string))
172
-				continue;
178
+			if (empty($task_string)) {
179
+							continue;
180
+			}
173 181
 
174 182
 			// Try to stop a timeout, this would be bad...
175 183
 			@set_time_limit(300);
176
-			if (function_exists('apache_reset_timeout'))
177
-				@apache_reset_timeout();
184
+			if (function_exists('apache_reset_timeout')) {
185
+							@apache_reset_timeout();
186
+			}
178 187
 
179 188
 			// Get the callable.
180 189
 			$callable_task = call_helper($task_string, true);
181 190
 
182 191
 			// Perform the task.
183
-			if (!empty($callable_task))
184
-				$completed = call_user_func($callable_task);
185
-
186
-			else
187
-				$completed = false;
192
+			if (!empty($callable_task)) {
193
+							$completed = call_user_func($callable_task);
194
+			} else {
195
+							$completed = false;
196
+			}
188 197
 
189 198
 			// Log that we did it ;)
190 199
 			if ($completed)
@@ -201,8 +210,9 @@  discard block
 block discarded – undo
201 210
 		$smcFunc['db_free_result']($request);
202 211
 
203 212
 		// If we had any errors, push them to session so we can pick them up next time to tell the user.
204
-		if (!empty($context['scheduled_errors']))
205
-			$_SESSION['st_error'] = $context['scheduled_errors'];
213
+		if (!empty($context['scheduled_errors'])) {
214
+					$_SESSION['st_error'] = $context['scheduled_errors'];
215
+		}
206 216
 
207 217
 		redirectexit('action=admin;area=scheduledtasks;done');
208 218
 	}
@@ -374,8 +384,9 @@  discard block
 block discarded – undo
374 384
 	$context['server_time'] = timeformat(time(), false, 'server');
375 385
 
376 386
 	// Cleaning...
377
-	if (!isset($_GET['tid']))
378
-		fatal_lang_error('no_access', false);
387
+	if (!isset($_GET['tid'])) {
388
+			fatal_lang_error('no_access', false);
389
+	}
379 390
 	$_GET['tid'] = (int) $_GET['tid'];
380 391
 
381 392
 	// Saving?
@@ -391,10 +402,12 @@  discard block
 block discarded – undo
391 402
 		preg_match('~(\d{1,2}):(\d{1,2})~', $_POST['offset'], $matches);
392 403
 
393 404
 		// If a half is empty then assume zero offset!
394
-		if (!isset($matches[2]) || $matches[2] > 59)
395
-			$matches[2] = 0;
396
-		if (!isset($matches[1]) || $matches[1] > 23)
397
-			$matches[1] = 0;
405
+		if (!isset($matches[2]) || $matches[2] > 59) {
406
+					$matches[2] = 0;
407
+		}
408
+		if (!isset($matches[1]) || $matches[1] > 23) {
409
+					$matches[1] = 0;
410
+		}
398 411
 
399 412
 		// Now the offset is easy; easy peasy - except we need to offset by a few hours...
400 413
 		$offset = $matches[1] * 3600 + $matches[2] * 60 - date('Z');
@@ -404,8 +417,9 @@  discard block
 block discarded – undo
404 417
 		$unit = in_array(substr($_POST['unit'], 0, 1), array('m', 'h', 'd', 'w')) ? substr($_POST['unit'], 0, 1) : 'd';
405 418
 
406 419
 		// Don't allow one minute intervals.
407
-		if ($interval == 1 && $unit == 'm')
408
-			$interval = 2;
420
+		if ($interval == 1 && $unit == 'm') {
421
+					$interval = 2;
422
+		}
409 423
 
410 424
 		// Is it disabled?
411 425
 		$disabled = !isset($_POST['enabled']) ? 1 : 0;
@@ -443,8 +457,9 @@  discard block
 block discarded – undo
443 457
 	);
444 458
 
445 459
 	// Should never, ever, happen!
446
-	if ($smcFunc['db_num_rows']($request) == 0)
447
-		fatal_lang_error('no_access', false);
460
+	if ($smcFunc['db_num_rows']($request) == 0) {
461
+			fatal_lang_error('no_access', false);
462
+	}
448 463
 
449 464
 	while ($row = $smcFunc['db_fetch_assoc']($request))
450 465
 	{
@@ -602,13 +617,14 @@  discard block
 block discarded – undo
602 617
 		)
603 618
 	);
604 619
 	$log_entries = array();
605
-	while ($row = $smcFunc['db_fetch_assoc']($request))
606
-		$log_entries[] = array(
620
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
621
+			$log_entries[] = array(
607 622
 			'id' => $row['id_log'],
608 623
 			'name' => isset($txt['scheduled_task_' . $row['task']]) ? $txt['scheduled_task_' . $row['task']] : $row['task'],
609 624
 			'time_run' => $row['time_run'],
610 625
 			'time_taken' => $row['time_taken'],
611 626
 		);
627
+	}
612 628
 	$smcFunc['db_free_result']($request);
613 629
 
614 630
 	return $log_entries;
@@ -649,8 +665,9 @@  discard block
 block discarded – undo
649 665
 
650 666
 	call_integration_hook('integrate_scheduled_tasks_settings', array(&$config_vars));
651 667
 
652
-	if ($return_config)
653
-		return $config_vars;
668
+	if ($return_config) {
669
+			return $config_vars;
670
+	}
654 671
 
655 672
 	// Set up the template.
656 673
 	$context['page_title'] = $txt['scheduled_tasks_settings'];
Please login to merge, or discard this patch.
Sources/Subs-Calendar.php 1 patch
Braces   +227 added lines, -165 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 4
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 /**
20 21
  * Get all birthdays within the given time range.
@@ -60,8 +61,7 @@  discard block
 block discarded – undo
60 61
 				'max_year' => $year_high,
61 62
 			)
62 63
 		);
63
-	}
64
-	else
64
+	} else
65 65
 	{
66 66
 		$result = $smcFunc['db_query']('birthday_array', '
67 67
 			SELECT id_member, real_name, YEAR(birthdate) AS birth_year, birthdate
@@ -91,10 +91,11 @@  discard block
 block discarded – undo
91 91
 	$bday = array();
92 92
 	while ($row = $smcFunc['db_fetch_assoc']($result))
93 93
 	{
94
-		if ($year_low != $year_high)
95
-			$age_year = substr($row['birthdate'], 5) < substr($high_date, 5) ? $year_high : $year_low;
96
-		else
97
-			$age_year = $year_low;
94
+		if ($year_low != $year_high) {
95
+					$age_year = substr($row['birthdate'], 5) < substr($high_date, 5) ? $year_high : $year_low;
96
+		} else {
97
+					$age_year = $year_low;
98
+		}
98 99
 
99 100
 		$bday[$age_year . substr($row['birthdate'], 4)][] = array(
100 101
 			'id' => $row['id_member'],
@@ -108,8 +109,9 @@  discard block
 block discarded – undo
108 109
 	ksort($bday);
109 110
 
110 111
 	// Set is_last, so the themes know when to stop placing separators.
111
-	foreach ($bday as $mday => $array)
112
-		$bday[$mday][count($array) - 1]['is_last'] = true;
112
+	foreach ($bday as $mday => $array) {
113
+			$bday[$mday][count($array) - 1]['is_last'] = true;
114
+	}
113 115
 
114 116
 	return $bday;
115 117
 }
@@ -133,8 +135,9 @@  discard block
 block discarded – undo
133 135
 	static $timezone_array = array();
134 136
 	require_once($sourcedir . '/Subs.php');
135 137
 
136
-	if (empty($timezone_array['default']))
137
-		$timezone_array['default'] = timezone_open(date_default_timezone_get());
138
+	if (empty($timezone_array['default'])) {
139
+			$timezone_array['default'] = timezone_open(date_default_timezone_get());
140
+	}
138 141
 
139 142
 	$low_object = date_create($low_date);
140 143
 	$high_object = date_create($high_date);
@@ -161,8 +164,9 @@  discard block
 block discarded – undo
161 164
 	while ($row = $smcFunc['db_fetch_assoc']($result))
162 165
 	{
163 166
 		// If the attached topic is not approved then for the moment pretend it doesn't exist
164
-		if (!empty($row['id_first_msg']) && $modSettings['postmod_active'] && !$row['approved'])
165
-			continue;
167
+		if (!empty($row['id_first_msg']) && $modSettings['postmod_active'] && !$row['approved']) {
168
+					continue;
169
+		}
166 170
 
167 171
 		// Force a censor of the title - as often these are used by others.
168 172
 		censorText($row['title'], $use_permissions ? false : true);
@@ -170,12 +174,14 @@  discard block
 block discarded – undo
170 174
 		// Get the various time and date properties for this event
171 175
 		list($start, $end, $allday, $span, $tz, $tz_abbrev) = buildEventDatetimes($row);
172 176
 
173
-		if (empty($timezone_array[$tz]))
174
-			$timezone_array[$tz] = timezone_open($tz);
177
+		if (empty($timezone_array[$tz])) {
178
+					$timezone_array[$tz] = timezone_open($tz);
179
+		}
175 180
 
176 181
 		// Sanity check
177
-		if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count']))
178
-			continue;
182
+		if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) {
183
+					continue;
184
+		}
179 185
 
180 186
 		// Get set up for the loop
181 187
 		$start_object = date_create($row['start_date'] . (!$allday ? ' ' . $row['start_time'] : ''), $timezone_array[$tz]);
@@ -239,8 +245,8 @@  discard block
 block discarded – undo
239 245
 			);
240 246
 
241 247
 			// If we're using permissions (calendar pages?) then just ouput normal contextual style information.
242
-			if ($use_permissions)
243
-				$events[date_format($cal_date, 'Y-m-d')][] = array_merge($eventProperties, array(
248
+			if ($use_permissions) {
249
+							$events[date_format($cal_date, 'Y-m-d')][] = array_merge($eventProperties, array(
244 250
 					'href' => $row['id_board'] == 0 ? '' : $scripturl . '?topic=' . $row['id_topic'] . '.0',
245 251
 					'link' => $row['id_board'] == 0 ? $row['title'] : '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['title'] . '</a>',
246 252
 					'can_edit' => allowedTo('calendar_edit_any') || ($row['id_member'] == $user_info['id'] && allowedTo('calendar_edit_own')),
@@ -248,9 +254,10 @@  discard block
 block discarded – undo
248 254
 					'can_export' => !empty($modSettings['cal_export']) ? true : false,
249 255
 					'export_href' => $scripturl . '?action=calendar;sa=ical;eventid=' . $row['id_event'] . ';' . $context['session_var'] . '=' . $context['session_id'],
250 256
 				));
257
+			}
251 258
 			// Otherwise, this is going to be cached and the VIEWER'S permissions should apply... just put together some info.
252
-			else
253
-				$events[date_format($cal_date, 'Y-m-d')][] = array_merge($eventProperties, array(
259
+			else {
260
+							$events[date_format($cal_date, 'Y-m-d')][] = array_merge($eventProperties, array(
254 261
 					'href' => $row['id_topic'] == 0 ? '' : $scripturl . '?topic=' . $row['id_topic'] . '.0',
255 262
 					'link' => $row['id_topic'] == 0 ? $row['title'] : '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['title'] . '</a>',
256 263
 					'can_edit' => false,
@@ -260,6 +267,7 @@  discard block
 block discarded – undo
260 267
 					'poster' => $row['id_member'],
261 268
 					'allowed_groups' => explode(',', $row['member_groups']),
262 269
 				));
270
+			}
263 271
 
264 272
 			date_add($cal_date, date_interval_create_from_date_string('1 day'));
265 273
 		}
@@ -269,8 +277,9 @@  discard block
 block discarded – undo
269 277
 	// If we're doing normal contextual data, go through and make things clear to the templates ;).
270 278
 	if ($use_permissions)
271 279
 	{
272
-		foreach ($events as $mday => $array)
273
-			$events[$mday][count($array) - 1]['is_last'] = true;
280
+		foreach ($events as $mday => $array) {
281
+					$events[$mday][count($array) - 1]['is_last'] = true;
282
+		}
274 283
 	}
275 284
 
276 285
 	ksort($events);
@@ -290,11 +299,12 @@  discard block
 block discarded – undo
290 299
 	global $smcFunc;
291 300
 
292 301
 	// Get the lowest and highest dates for "all years".
293
-	if (substr($low_date, 0, 4) != substr($high_date, 0, 4))
294
-		$allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_dec}
302
+	if (substr($low_date, 0, 4) != substr($high_date, 0, 4)) {
303
+			$allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_dec}
295 304
 			OR event_date BETWEEN {date:all_year_jan} AND {date:all_year_high}';
296
-	else
297
-		$allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_high}';
305
+	} else {
306
+			$allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_high}';
307
+	}
298 308
 
299 309
 	// Find some holidays... ;).
300 310
 	$result = $smcFunc['db_query']('', '
@@ -314,10 +324,11 @@  discard block
 block discarded – undo
314 324
 	$holidays = array();
315 325
 	while ($row = $smcFunc['db_fetch_assoc']($result))
316 326
 	{
317
-		if (substr($low_date, 0, 4) != substr($high_date, 0, 4))
318
-			$event_year = substr($row['event_date'], 5) < substr($high_date, 5) ? substr($high_date, 0, 4) : substr($low_date, 0, 4);
319
-		else
320
-			$event_year = substr($low_date, 0, 4);
327
+		if (substr($low_date, 0, 4) != substr($high_date, 0, 4)) {
328
+					$event_year = substr($row['event_date'], 5) < substr($high_date, 5) ? substr($high_date, 0, 4) : substr($low_date, 0, 4);
329
+		} else {
330
+					$event_year = substr($low_date, 0, 4);
331
+		}
321 332
 
322 333
 		$holidays[$event_year . substr($row['event_date'], 4)][] = $row['title'];
323 334
 	}
@@ -343,10 +354,12 @@  discard block
 block discarded – undo
343 354
 	isAllowedTo('calendar_post');
344 355
 
345 356
 	// No board?  No topic?!?
346
-	if (empty($board))
347
-		fatal_lang_error('missing_board_id', false);
348
-	if (empty($topic))
349
-		fatal_lang_error('missing_topic_id', false);
357
+	if (empty($board)) {
358
+			fatal_lang_error('missing_board_id', false);
359
+	}
360
+	if (empty($topic)) {
361
+			fatal_lang_error('missing_topic_id', false);
362
+	}
350 363
 
351 364
 	// Administrator, Moderator, or owner.  Period.
352 365
 	if (!allowedTo('admin_forum') && !allowedTo('moderate_board'))
@@ -364,12 +377,14 @@  discard block
 block discarded – undo
364 377
 		if ($row = $smcFunc['db_fetch_assoc']($result))
365 378
 		{
366 379
 			// Not the owner of the topic.
367
-			if ($row['id_member_started'] != $user_info['id'])
368
-				fatal_lang_error('not_your_topic', 'user');
380
+			if ($row['id_member_started'] != $user_info['id']) {
381
+							fatal_lang_error('not_your_topic', 'user');
382
+			}
369 383
 		}
370 384
 		// Topic/Board doesn't exist.....
371
-		else
372
-			fatal_lang_error('calendar_no_topic', 'general');
385
+		else {
386
+					fatal_lang_error('calendar_no_topic', 'general');
387
+		}
373 388
 		$smcFunc['db_free_result']($result);
374 389
 	}
375 390
 }
@@ -457,14 +472,16 @@  discard block
 block discarded – undo
457 472
 	if (!empty($calendarOptions['start_day']))
458 473
 	{
459 474
 		$nShift -= $calendarOptions['start_day'];
460
-		if ($nShift < 0)
461
-			$nShift = 7 + $nShift;
475
+		if ($nShift < 0) {
476
+					$nShift = 7 + $nShift;
477
+		}
462 478
 	}
463 479
 
464 480
 	// Number of rows required to fit the month.
465 481
 	$nRows = floor(($month_info['last_day']['day_of_month'] + $nShift) / 7);
466
-	if (($month_info['last_day']['day_of_month'] + $nShift) % 7)
467
-		$nRows++;
482
+	if (($month_info['last_day']['day_of_month'] + $nShift) % 7) {
483
+			$nRows++;
484
+	}
468 485
 
469 486
 	// Fetch the arrays for birthdays, posted events, and holidays.
470 487
 	$bday = $calendarOptions['show_birthdays'] ? getBirthdayRange($month_info['first_day']['date'], $month_info['last_day']['date']) : array();
@@ -477,8 +494,9 @@  discard block
 block discarded – undo
477 494
 	{
478 495
 		$calendarGrid['week_days'][] = $count;
479 496
 		$count++;
480
-		if ($count == 7)
481
-			$count = 0;
497
+		if ($count == 7) {
498
+					$count = 0;
499
+		}
482 500
 	}
483 501
 
484 502
 	// Iterate through each week.
@@ -495,8 +513,9 @@  discard block
 block discarded – undo
495 513
 		{
496 514
 			$nDay = ($nRow * 7) + $nCol - $nShift + 1;
497 515
 
498
-			if ($nDay < 1 || $nDay > $month_info['last_day']['day_of_month'])
499
-				$nDay = 0;
516
+			if ($nDay < 1 || $nDay > $month_info['last_day']['day_of_month']) {
517
+							$nDay = 0;
518
+			}
500 519
 
501 520
 			$date = sprintf('%04d-%02d-%02d', $year, $month, $nDay);
502 521
 
@@ -514,8 +533,9 @@  discard block
 block discarded – undo
514 533
 	}
515 534
 
516 535
 	// What is the last day of the month?
517
-	if ($is_previous === true)
518
-		$calendarGrid['last_of_month'] = $month_info['last_day']['day_of_month'];
536
+	if ($is_previous === true) {
537
+			$calendarGrid['last_of_month'] = $month_info['last_day']['day_of_month'];
538
+	}
519 539
 
520 540
 	// We'll use the shift in the template.
521 541
 	$calendarGrid['shift'] = $nShift;
@@ -549,8 +569,9 @@  discard block
 block discarded – undo
549 569
 	{
550 570
 		// Here we offset accordingly to get things to the real start of a week.
551 571
 		$date_diff = $day_of_week - $calendarOptions['start_day'];
552
-		if ($date_diff < 0)
553
-			$date_diff += 7;
572
+		if ($date_diff < 0) {
573
+					$date_diff += 7;
574
+		}
554 575
 		$new_timestamp = mktime(0, 0, 0, $month, $day, $year) - $date_diff * 86400;
555 576
 		$day = (int) strftime('%d', $new_timestamp);
556 577
 		$month = (int) strftime('%m', $new_timestamp);
@@ -680,18 +701,20 @@  discard block
 block discarded – undo
680 701
 	{
681 702
 		foreach ($date_events as $event_key => $event_val)
682 703
 		{
683
-			if (in_array($event_val['id'], $temp))
684
-				unset($calendarGrid['events'][$date][$event_key]);
685
-			else
686
-				$temp[] = $event_val['id'];
704
+			if (in_array($event_val['id'], $temp)) {
705
+							unset($calendarGrid['events'][$date][$event_key]);
706
+			} else {
707
+							$temp[] = $event_val['id'];
708
+			}
687 709
 		}
688 710
 	}
689 711
 
690 712
 	// Give birthdays and holidays a friendly format, without the year
691
-	if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0]))
692
-		$date_format = '%b %d';
693
-	else
694
-		$date_format = str_replace(array('%Y', '%y', '%G', '%g', '%C', '%c', '%D'), array('', '', '', '', '', '%b %d', '%m/%d'), $matches[0]);
713
+	if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) {
714
+			$date_format = '%b %d';
715
+	} else {
716
+			$date_format = str_replace(array('%Y', '%y', '%G', '%g', '%C', '%c', '%D'), array('', '', '', '', '', '%b %d', '%m/%d'), $matches[0]);
717
+	}
695 718
 
696 719
 	foreach (array('birthdays', 'holidays') as $type)
697 720
 	{
@@ -790,8 +813,9 @@  discard block
 block discarded – undo
790 813
 		// Holidays between now and now + days.
791 814
 		for ($i = $now; $i < $now + $days_for_index; $i += 86400)
792 815
 		{
793
-			if (isset($cached_data['holidays'][strftime('%Y-%m-%d', $i)]))
794
-				$return_data['calendar_holidays'] = array_merge($return_data['calendar_holidays'], $cached_data['holidays'][strftime('%Y-%m-%d', $i)]);
816
+			if (isset($cached_data['holidays'][strftime('%Y-%m-%d', $i)])) {
817
+							$return_data['calendar_holidays'] = array_merge($return_data['calendar_holidays'], $cached_data['holidays'][strftime('%Y-%m-%d', $i)]);
818
+			}
795 819
 		}
796 820
 	}
797 821
 
@@ -803,8 +827,9 @@  discard block
 block discarded – undo
803 827
 			$loop_date = strftime('%Y-%m-%d', $i);
804 828
 			if (isset($cached_data['birthdays'][$loop_date]))
805 829
 			{
806
-				foreach ($cached_data['birthdays'][$loop_date] as $index => $dummy)
807
-					$cached_data['birthdays'][strftime('%Y-%m-%d', $i)][$index]['is_today'] = $loop_date === $today['date'];
830
+				foreach ($cached_data['birthdays'][$loop_date] as $index => $dummy) {
831
+									$cached_data['birthdays'][strftime('%Y-%m-%d', $i)][$index]['is_today'] = $loop_date === $today['date'];
832
+				}
808 833
 				$return_data['calendar_birthdays'] = array_merge($return_data['calendar_birthdays'], $cached_data['birthdays'][$loop_date]);
809 834
 			}
810 835
 		}
@@ -819,8 +844,9 @@  discard block
 block discarded – undo
819 844
 			$loop_date = strftime('%Y-%m-%d', $i);
820 845
 
821 846
 			// No events today? Check the next day.
822
-			if (empty($cached_data['events'][$loop_date]))
823
-				continue;
847
+			if (empty($cached_data['events'][$loop_date])) {
848
+							continue;
849
+			}
824 850
 
825 851
 			// Loop through all events to add a few last-minute values.
826 852
 			foreach ($cached_data['events'][$loop_date] as $ev => $event)
@@ -833,9 +859,9 @@  discard block
 block discarded – undo
833 859
 				{
834 860
 					unset($cached_data['events'][$loop_date][$ev]);
835 861
 					continue;
862
+				} else {
863
+									$duplicates[$this_event['topic'] . $this_event['title']] = true;
836 864
 				}
837
-				else
838
-					$duplicates[$this_event['topic'] . $this_event['title']] = true;
839 865
 
840 866
 				// Might be set to true afterwards, depending on the permissions.
841 867
 				$this_event['can_edit'] = false;
@@ -843,16 +869,19 @@  discard block
 block discarded – undo
843 869
 				$this_event['date'] = $loop_date;
844 870
 			}
845 871
 
846
-			if (!empty($cached_data['events'][$loop_date]))
847
-				$return_data['calendar_events'] = array_merge($return_data['calendar_events'], $cached_data['events'][$loop_date]);
872
+			if (!empty($cached_data['events'][$loop_date])) {
873
+							$return_data['calendar_events'] = array_merge($return_data['calendar_events'], $cached_data['events'][$loop_date]);
874
+			}
848 875
 		}
849 876
 	}
850 877
 
851 878
 	// Mark the last item so that a list separator can be used in the template.
852
-	for ($i = 0, $n = count($return_data['calendar_birthdays']); $i < $n; $i++)
853
-		$return_data['calendar_birthdays'][$i]['is_last'] = !isset($return_data['calendar_birthdays'][$i + 1]);
854
-	for ($i = 0, $n = count($return_data['calendar_events']); $i < $n; $i++)
855
-		$return_data['calendar_events'][$i]['is_last'] = !isset($return_data['calendar_events'][$i + 1]);
879
+	for ($i = 0, $n = count($return_data['calendar_birthdays']); $i < $n; $i++) {
880
+			$return_data['calendar_birthdays'][$i]['is_last'] = !isset($return_data['calendar_birthdays'][$i + 1]);
881
+	}
882
+	for ($i = 0, $n = count($return_data['calendar_events']); $i < $n; $i++) {
883
+			$return_data['calendar_events'][$i]['is_last'] = !isset($return_data['calendar_events'][$i + 1]);
884
+	}
856 885
 
857 886
 	return array(
858 887
 		'data' => $return_data,
@@ -900,37 +929,46 @@  discard block
 block discarded – undo
900 929
 		if (isset($_POST['start_date']))
901 930
 		{
902 931
 			$d = date_parse($_POST['start_date']);
903
-			if (!empty($d['error_count']) || !empty($d['warning_count']))
904
-				fatal_lang_error('invalid_date', false);
905
-			if (empty($d['year']))
906
-				fatal_lang_error('event_year_missing', false);
907
-			if (empty($d['month']))
908
-				fatal_lang_error('event_month_missing', false);
909
-		}
910
-		elseif (isset($_POST['start_datetime']))
932
+			if (!empty($d['error_count']) || !empty($d['warning_count'])) {
933
+							fatal_lang_error('invalid_date', false);
934
+			}
935
+			if (empty($d['year'])) {
936
+							fatal_lang_error('event_year_missing', false);
937
+			}
938
+			if (empty($d['month'])) {
939
+							fatal_lang_error('event_month_missing', false);
940
+			}
941
+		} elseif (isset($_POST['start_datetime']))
911 942
 		{
912 943
 			$d = date_parse($_POST['start_datetime']);
913
-			if (!empty($d['error_count']) || !empty($d['warning_count']))
914
-				fatal_lang_error('invalid_date', false);
915
-			if (empty($d['year']))
916
-				fatal_lang_error('event_year_missing', false);
917
-			if (empty($d['month']))
918
-				fatal_lang_error('event_month_missing', false);
944
+			if (!empty($d['error_count']) || !empty($d['warning_count'])) {
945
+							fatal_lang_error('invalid_date', false);
946
+			}
947
+			if (empty($d['year'])) {
948
+							fatal_lang_error('event_year_missing', false);
949
+			}
950
+			if (empty($d['month'])) {
951
+							fatal_lang_error('event_month_missing', false);
952
+			}
919 953
 		}
920 954
 		// The 2.0 way
921 955
 		else
922 956
 		{
923 957
 			// No month?  No year?
924
-			if (!isset($_POST['month']))
925
-				fatal_lang_error('event_month_missing', false);
926
-			if (!isset($_POST['year']))
927
-				fatal_lang_error('event_year_missing', false);
958
+			if (!isset($_POST['month'])) {
959
+							fatal_lang_error('event_month_missing', false);
960
+			}
961
+			if (!isset($_POST['year'])) {
962
+							fatal_lang_error('event_year_missing', false);
963
+			}
928 964
 
929 965
 			// Check the month and year...
930
-			if ($_POST['month'] < 1 || $_POST['month'] > 12)
931
-				fatal_lang_error('invalid_month', false);
932
-			if ($_POST['year'] < $modSettings['cal_minyear'] || $_POST['year'] > $modSettings['cal_maxyear'])
933
-				fatal_lang_error('invalid_year', false);
966
+			if ($_POST['month'] < 1 || $_POST['month'] > 12) {
967
+							fatal_lang_error('invalid_month', false);
968
+			}
969
+			if ($_POST['year'] < $modSettings['cal_minyear'] || $_POST['year'] > $modSettings['cal_maxyear']) {
970
+							fatal_lang_error('invalid_year', false);
971
+			}
934 972
 		}
935 973
 	}
936 974
 
@@ -940,8 +978,9 @@  discard block
 block discarded – undo
940 978
 	// If they want to us to calculate an end date, make sure it will fit in an acceptable range.
941 979
 	if (isset($_POST['span']))
942 980
 	{
943
-		if (($_POST['span'] < 1) || (!empty($modSettings['cal_maxspan']) && $_POST['span'] > $modSettings['cal_maxspan']))
944
-			fatal_lang_error('invalid_days_numb', false);
981
+		if (($_POST['span'] < 1) || (!empty($modSettings['cal_maxspan']) && $_POST['span'] > $modSettings['cal_maxspan'])) {
982
+					fatal_lang_error('invalid_days_numb', false);
983
+		}
945 984
 	}
946 985
 
947 986
 	// There is no need to validate the following values if we are just deleting the event.
@@ -951,24 +990,29 @@  discard block
 block discarded – undo
951 990
 		if (empty($_POST['start_date']) && empty($_POST['start_datetime']))
952 991
 		{
953 992
 			// No day?
954
-			if (!isset($_POST['day']))
955
-				fatal_lang_error('event_day_missing', false);
993
+			if (!isset($_POST['day'])) {
994
+							fatal_lang_error('event_day_missing', false);
995
+			}
956 996
 
957 997
 			// Bad day?
958
-			if (!checkdate($_POST['month'], $_POST['day'], $_POST['year']))
959
-				fatal_lang_error('invalid_date', false);
998
+			if (!checkdate($_POST['month'], $_POST['day'], $_POST['year'])) {
999
+							fatal_lang_error('invalid_date', false);
1000
+			}
960 1001
 		}
961 1002
 
962
-		if (!isset($_POST['evtitle']) && !isset($_POST['subject']))
963
-			fatal_lang_error('event_title_missing', false);
964
-		elseif (!isset($_POST['evtitle']))
965
-			$_POST['evtitle'] = $_POST['subject'];
1003
+		if (!isset($_POST['evtitle']) && !isset($_POST['subject'])) {
1004
+					fatal_lang_error('event_title_missing', false);
1005
+		} elseif (!isset($_POST['evtitle'])) {
1006
+					$_POST['evtitle'] = $_POST['subject'];
1007
+		}
966 1008
 
967 1009
 		// No title?
968
-		if ($smcFunc['htmltrim']($_POST['evtitle']) === '')
969
-			fatal_lang_error('no_event_title', false);
970
-		if ($smcFunc['strlen']($_POST['evtitle']) > 100)
971
-			$_POST['evtitle'] = $smcFunc['substr']($_POST['evtitle'], 0, 100);
1010
+		if ($smcFunc['htmltrim']($_POST['evtitle']) === '') {
1011
+					fatal_lang_error('no_event_title', false);
1012
+		}
1013
+		if ($smcFunc['strlen']($_POST['evtitle']) > 100) {
1014
+					$_POST['evtitle'] = $smcFunc['substr']($_POST['evtitle'], 0, 100);
1015
+		}
972 1016
 		$_POST['evtitle'] = str_replace(';', '', $_POST['evtitle']);
973 1017
 	}
974 1018
 }
@@ -995,8 +1039,9 @@  discard block
 block discarded – undo
995 1039
 	);
996 1040
 
997 1041
 	// No results, return false.
998
-	if ($smcFunc['db_num_rows'] === 0)
999
-		return false;
1042
+	if ($smcFunc['db_num_rows'] === 0) {
1043
+			return false;
1044
+	}
1000 1045
 
1001 1046
 	// Grab the results and return.
1002 1047
 	list ($poster) = $smcFunc['db_fetch_row']($request);
@@ -1130,8 +1175,9 @@  discard block
 block discarded – undo
1130 1175
 	call_integration_hook('integrate_modify_event', array($event_id, &$eventOptions, &$event_columns, &$event_parameters));
1131 1176
 
1132 1177
 	$column_clauses = array();
1133
-	foreach ($event_columns as $col => $crit)
1134
-		$column_clauses[] = $col . ' = ' . $crit;
1178
+	foreach ($event_columns as $col => $crit) {
1179
+			$column_clauses[] = $col . ' = ' . $crit;
1180
+	}
1135 1181
 
1136 1182
 	$smcFunc['db_query']('', '
1137 1183
 		UPDATE {db_prefix}calendar
@@ -1216,8 +1262,9 @@  discard block
 block discarded – undo
1216 1262
 	);
1217 1263
 
1218 1264
 	// If nothing returned, we are in poo, poo.
1219
-	if ($smcFunc['db_num_rows']($request) === 0)
1220
-		return false;
1265
+	if ($smcFunc['db_num_rows']($request) === 0) {
1266
+			return false;
1267
+	}
1221 1268
 
1222 1269
 	$row = $smcFunc['db_fetch_assoc']($request);
1223 1270
 	$smcFunc['db_free_result']($request);
@@ -1225,8 +1272,9 @@  discard block
 block discarded – undo
1225 1272
 	list($start, $end, $allday, $span, $tz, $tz_abbrev) = buildEventDatetimes($row);
1226 1273
 
1227 1274
 	// Sanity check
1228
-	if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count']))
1229
-		return false;
1275
+	if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) {
1276
+			return false;
1277
+	}
1230 1278
 
1231 1279
 	$return_value = array(
1232 1280
 		'boards' => array(),
@@ -1363,24 +1411,27 @@  discard block
 block discarded – undo
1363 1411
 
1364 1412
 	// Set $span, in case we need it
1365 1413
 	$span = isset($eventOptions['span']) ? $eventOptions['span'] : (isset($_POST['span']) ? $_POST['span'] : 0);
1366
-	if ($span > 0)
1367
-		$span = !empty($modSettings['cal_maxspan']) ? min($modSettings['cal_maxspan'], $span - 1) : $span - 1;
1414
+	if ($span > 0) {
1415
+			$span = !empty($modSettings['cal_maxspan']) ? min($modSettings['cal_maxspan'], $span - 1) : $span - 1;
1416
+	}
1368 1417
 
1369 1418
 	// Define the timezone for this event, falling back to the default if not provided
1370
-	if (!empty($eventOptions['tz']) && in_array($eventOptions['tz'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC)))
1371
-		$tz = $eventOptions['tz'];
1372
-	elseif (!empty($_POST['tz']) && in_array($_POST['tz'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC)))
1373
-		$tz = $_POST['tz'];
1374
-	else
1375
-		$tz = getUserTimezone();
1419
+	if (!empty($eventOptions['tz']) && in_array($eventOptions['tz'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) {
1420
+			$tz = $eventOptions['tz'];
1421
+	} elseif (!empty($_POST['tz']) && in_array($_POST['tz'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) {
1422
+			$tz = $_POST['tz'];
1423
+	} else {
1424
+			$tz = getUserTimezone();
1425
+	}
1376 1426
 
1377 1427
 	// Is this supposed to be an all day event, or should it have specific start and end times?
1378
-	if (isset($eventOptions['allday']))
1379
-		$allday = $eventOptions['allday'];
1380
-	elseif (empty($_POST['allday']))
1381
-		$allday = false;
1382
-	else
1383
-		$allday = true;
1428
+	if (isset($eventOptions['allday'])) {
1429
+			$allday = $eventOptions['allday'];
1430
+	} elseif (empty($_POST['allday'])) {
1431
+			$allday = false;
1432
+	} else {
1433
+			$allday = true;
1434
+	}
1384 1435
 
1385 1436
 	// Input might come as individual parameters...
1386 1437
 	$start_year = isset($eventOptions['year']) ? $eventOptions['year'] : (isset($_POST['year']) ? $_POST['year'] : null);
@@ -1407,10 +1458,12 @@  discard block
 block discarded – undo
1407 1458
 	$end_time_string = isset($eventOptions['end_time']) ? $eventOptions['end_time'] : (isset($_POST['end_time']) ? $_POST['end_time'] : null);
1408 1459
 
1409 1460
 	// If the date and time were given in separate strings, combine them
1410
-	if (empty($start_string) && isset($start_date_string))
1411
-		$start_string = $start_date_string . (isset($start_time_string) ? ' ' . $start_time_string : '');
1412
-	if (empty($end_string) && isset($end_date_string))
1413
-		$end_string = $end_date_string . (isset($end_time_string) ? ' ' . $end_time_string : '');
1461
+	if (empty($start_string) && isset($start_date_string)) {
1462
+			$start_string = $start_date_string . (isset($start_time_string) ? ' ' . $start_time_string : '');
1463
+	}
1464
+	if (empty($end_string) && isset($end_date_string)) {
1465
+			$end_string = $end_date_string . (isset($end_time_string) ? ' ' . $end_time_string : '');
1466
+	}
1414 1467
 
1415 1468
 	// If some form of string input was given, override individually defined options with it
1416 1469
 	if (isset($start_string))
@@ -1501,10 +1554,11 @@  discard block
 block discarded – undo
1501 1554
 	if ($start_object >= $end_object)
1502 1555
 	{
1503 1556
 		$end_object = date_create(sprintf('%04d-%02d-%02d %02d:%02d:%02d', $start_year, $start_month, $start_day, $start_hour, $start_minute, $start_second) . ' ' . $tz);
1504
-		if ($span > 0)
1505
-			date_add($end_object, date_interval_create_from_date_string($span . ' days'));
1506
-		else
1507
-			date_add($end_object, date_interval_create_from_date_string('1 hour'));
1557
+		if ($span > 0) {
1558
+					date_add($end_object, date_interval_create_from_date_string($span . ' days'));
1559
+		} else {
1560
+					date_add($end_object, date_interval_create_from_date_string('1 hour'));
1561
+		}
1508 1562
 	}
1509 1563
 
1510 1564
 	// Is $end_object too late?
@@ -1517,9 +1571,9 @@  discard block
 block discarded – undo
1517 1571
 			{
1518 1572
 				$end_object = date_create(sprintf('%04d-%02d-%02d %02d:%02d:%02d', $start_year, $start_month, $start_day, $start_hour, $start_minute, $start_second) . ' ' . $tz);
1519 1573
 				date_add($end_object, date_interval_create_from_date_string($modSettings['cal_maxspan'] . ' days'));
1574
+			} else {
1575
+							$end_object = date_create(sprintf('%04d-%02d-%02d %02d:%02d:%02d', $start_year, $start_month, $start_day, '11', '59', '59') . ' ' . $tz);
1520 1576
 			}
1521
-			else
1522
-				$end_object = date_create(sprintf('%04d-%02d-%02d %02d:%02d:%02d', $start_year, $start_month, $start_day, '11', '59', '59') . ' ' . $tz);
1523 1577
 		}
1524 1578
 	}
1525 1579
 
@@ -1532,8 +1586,7 @@  discard block
 block discarded – undo
1532 1586
 		$start_time = null;
1533 1587
 		$end_time = null;
1534 1588
 		$tz = null;
1535
-	}
1536
-	else
1589
+	} else
1537 1590
 	{
1538 1591
 		$start_time = date_format($start_object, 'H:i:s');
1539 1592
 		$end_time = date_format($end_object, 'H:i:s');
@@ -1561,19 +1614,21 @@  discard block
 block discarded – undo
1561 1614
 	// First, try to create a better date format, ignoring the "time" elements.
1562 1615
 	if (empty($date_format))
1563 1616
 	{
1564
-		if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0]))
1565
-			$date_format = '%F';
1566
-		else
1567
-			$date_format = $matches[0];
1617
+		if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) {
1618
+					$date_format = '%F';
1619
+		} else {
1620
+					$date_format = $matches[0];
1621
+		}
1568 1622
 	}
1569 1623
 
1570 1624
 	// We want a fairly compact version of the time, but as close as possible to the user's settings.
1571 1625
 	if (empty($time_format))
1572 1626
 	{
1573
-		if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0]))
1574
-			$time_format = '%k:%M';
1575
-		else
1576
-			$time_format = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]);
1627
+		if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) {
1628
+					$time_format = '%k:%M';
1629
+		} else {
1630
+					$time_format = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]);
1631
+		}
1577 1632
 	}
1578 1633
 
1579 1634
 	// Should this be an all day event?
@@ -1583,11 +1638,13 @@  discard block
 block discarded – undo
1583 1638
 	$span = 1 + date_interval_format(date_diff(date_create($row['start_date']), date_create($row['end_date'])), '%d');
1584 1639
 
1585 1640
 	// We need to have a defined timezone in the steps below
1586
-	if (empty($row['timezone']))
1587
-		$row['timezone'] = getUserTimezone();
1641
+	if (empty($row['timezone'])) {
1642
+			$row['timezone'] = getUserTimezone();
1643
+	}
1588 1644
 
1589
-	if (empty($timezone_array[$row['timezone']]))
1590
-		$timezone_array[$row['timezone']] = timezone_open($row['timezone']);
1645
+	if (empty($timezone_array[$row['timezone']])) {
1646
+			$timezone_array[$row['timezone']] = timezone_open($row['timezone']);
1647
+	}
1591 1648
 
1592 1649
 	// Get most of the standard date information for the start and end datetimes
1593 1650
 	$start = date_parse($row['start_date'] . (!$allday ? ' ' . $row['start_time'] : ''));
@@ -1622,8 +1679,9 @@  discard block
 block discarded – undo
1622 1679
 	$tz_abbrev = date_format($start_object, 'T');
1623 1680
 
1624 1681
 	// If the abbreviation is just a numerical offset from UTC, make that clear.
1625
-	if (strspn($tz_abbrev, '+-') > 0)
1626
-		$tz_abbrev = 'UTC' . $tz_abbrev;
1682
+	if (strspn($tz_abbrev, '+-') > 0) {
1683
+			$tz_abbrev = 'UTC' . $tz_abbrev;
1684
+	}
1627 1685
 
1628 1686
 	return array($start, $end, $allday, $span, $tz, $tz_abbrev);
1629 1687
 }
@@ -1639,8 +1697,9 @@  discard block
 block discarded – undo
1639 1697
 	global $smcFunc, $context, $user_info, $modSettings, $user_settings;
1640 1698
 	static $member_cache = array();
1641 1699
 
1642
-	if (is_null($id_member) && $user_info['is_guest'] == false)
1643
-		$id_member = $context['user']['id'];
1700
+	if (is_null($id_member) && $user_info['is_guest'] == false) {
1701
+			$id_member = $context['user']['id'];
1702
+	}
1644 1703
 
1645 1704
 	//check if the cache got the data
1646 1705
 	if (isset($id_member) && isset($member_cache[$id_member]))
@@ -1669,11 +1728,13 @@  discard block
 block discarded – undo
1669 1728
 		$smcFunc['db_free_result']($request);
1670 1729
 	}
1671 1730
 
1672
-	if (empty($timezone) || !in_array($timezone, timezone_identifiers_list(DateTimeZone::ALL_WITH_BC)))
1673
-		$timezone = isset($modSettings['default_timezone']) ? $modSettings['default_timezone'] : date_default_timezone_get();
1731
+	if (empty($timezone) || !in_array($timezone, timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) {
1732
+			$timezone = isset($modSettings['default_timezone']) ? $modSettings['default_timezone'] : date_default_timezone_get();
1733
+	}
1674 1734
 
1675
-	if (isset($id_member))
1676
-		$member_cache[$id_member] = $timezone;
1735
+	if (isset($id_member)) {
1736
+			$member_cache[$id_member] = $timezone;
1737
+	}
1677 1738
 
1678 1739
 	return $timezone;
1679 1740
 }
@@ -1702,8 +1763,9 @@  discard block
 block discarded – undo
1702 1763
 		)
1703 1764
 	);
1704 1765
 	$holidays = array();
1705
-	while ($row = $smcFunc['db_fetch_assoc']($request))
1706
-		$holidays[] = $row;
1766
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
1767
+			$holidays[] = $row;
1768
+	}
1707 1769
 	$smcFunc['db_free_result']($request);
1708 1770
 
1709 1771
 	return $holidays;
Please login to merge, or discard this patch.
Sources/SearchAPI-Fulltext.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 	/**
34 34
 	 * @var array Which databases support this method?
35 35
 	 */
36
-	protected $supported_databases = array('mysql','postgresql');
36
+	protected $supported_databases = array('mysql', 'postgresql');
37 37
 
38 38
 	/**
39 39
 	 * The constructor function
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
 		$query_where = array();
177 177
 		$query_params = $search_data['params'];
178 178
 
179
-		if( $smcFunc['db_title'] == "PostgreSQL")
179
+		if ($smcFunc['db_title'] == "PostgreSQL")
180 180
 			$modSettings['search_simple_fulltext'] = true;
181 181
 
182 182
 		if ($query_params['id_search'])
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
 			// if we have bool terms to search, add them in
257 257
 			if ($query_params['boolean_match'])
258 258
 			{
259
-				if($smcFunc['db_title'] == "PostgreSQL")
259
+				if ($smcFunc['db_title'] == "PostgreSQL")
260 260
 				{
261 261
 					$language_ftx = $smcFunc['db_search_language']();
262 262
 
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
 			}
269 269
 		}
270 270
 
271
-		$ignoreRequest = $smcFunc['db_search_query']('insert_into_log_messages_fulltext', ($smcFunc['db_support_ignore'] ? ( '
271
+		$ignoreRequest = $smcFunc['db_search_query']('insert_into_log_messages_fulltext', ($smcFunc['db_support_ignore'] ? ('
272 272
 			INSERT IGNORE INTO {db_prefix}' . $search_data['insert_into'] . '
273 273
 				(' . implode(', ', array_keys($query_select)) . ')') : '') . '
274 274
 			SELECT ' . implode(', ', $query_select) . '
Please login to merge, or discard this patch.
Braces   +53 added lines, -40 removed lines patch added patch discarded remove patch
@@ -11,8 +11,9 @@  discard block
 block discarded – undo
11 11
  * @version 2.1 Beta 4
12 12
  */
13 13
 
14
-if (!defined('SMF'))
14
+if (!defined('SMF')) {
15 15
 	die('No direct access...');
16
+}
16 17
 
17 18
 /**
18 19
  * Class fulltext_search
@@ -75,8 +76,9 @@  discard block
 block discarded – undo
75 76
 		}
76 77
 
77 78
 		// Maybe parent got support
78
-		if (!$return)
79
-			$return = parent::supportsMethod($methodName, $query_params);
79
+		if (!$return) {
80
+					$return = parent::supportsMethod($methodName, $query_params);
81
+		}
80 82
 
81 83
 		return $return;
82 84
 	}
@@ -92,8 +94,9 @@  discard block
 block discarded – undo
92 94
 	{
93 95
 		global $smcFunc, $db_type;
94 96
 
95
-		if ($db_type == 'postgresql')
96
-			return 0;
97
+		if ($db_type == 'postgresql') {
98
+					return 0;
99
+		}
97 100
 		// Try to determine the minimum number of letters for a fulltext search.
98 101
 		$request = $smcFunc['db_search_query']('max_fulltext_length', '
99 102
 			SHOW VARIABLES
@@ -108,8 +111,9 @@  discard block
 block discarded – undo
108 111
 			$smcFunc['db_free_result']($request);
109 112
 		}
110 113
 		// 4 is the MySQL default...
111
-		else
112
-			$min_word_length = 4;
114
+		else {
115
+					$min_word_length = 4;
116
+		}
113 117
 
114 118
 		return $min_word_length;
115 119
 	}
@@ -148,8 +152,7 @@  discard block
 block discarded – undo
148 152
 					$wordsSearch['words'][] = trim($word, "/*- ");
149 153
 					$wordsSearch['complex_words'][] = count($subwords) === 1 ? $word : '"' . $word . '"';
150 154
 				}
151
-			}
152
-			elseif ($smcFunc['strlen'](trim($word, "/*- ")) < $this->min_word_length)
155
+			} elseif ($smcFunc['strlen'](trim($word, "/*- ")) < $this->min_word_length)
153 156
 			{
154 157
 				// short words have feelings too
155 158
 				$wordsSearch['words'][] = trim($word, "/*- ");
@@ -159,8 +162,9 @@  discard block
 block discarded – undo
159 162
 
160 163
 		$fulltextWord = count($subwords) === 1 ? $word : '"' . $word . '"';
161 164
 		$wordsSearch['indexed_words'][] = $fulltextWord;
162
-		if ($isExcluded)
163
-			$wordsExclude[] = $fulltextWord;
165
+		if ($isExcluded) {
166
+					$wordsExclude[] = $fulltextWord;
167
+		}
164 168
 	}
165 169
 
166 170
 	/**
@@ -176,44 +180,54 @@  discard block
 block discarded – undo
176 180
 		$query_where = array();
177 181
 		$query_params = $search_data['params'];
178 182
 
179
-		if( $smcFunc['db_title'] == "PostgreSQL")
180
-			$modSettings['search_simple_fulltext'] = true;
183
+		if( $smcFunc['db_title'] == "PostgreSQL") {
184
+					$modSettings['search_simple_fulltext'] = true;
185
+		}
181 186
 
182
-		if ($query_params['id_search'])
183
-			$query_select['id_search'] = '{int:id_search}';
187
+		if ($query_params['id_search']) {
188
+					$query_select['id_search'] = '{int:id_search}';
189
+		}
184 190
 
185 191
 		$count = 0;
186
-		if (empty($modSettings['search_simple_fulltext']))
187
-			foreach ($words['words'] as $regularWord)
192
+		if (empty($modSettings['search_simple_fulltext'])) {
193
+					foreach ($words['words'] as $regularWord)
188 194
 			{
189 195
 				$query_where[] = 'm.body' . (in_array($regularWord, $query_params['excluded_words']) ? ' NOT' : '') . (empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? ' LIKE ' : 'RLIKE') . '{string:complex_body_' . $count . '}';
196
+		}
190 197
 				$query_params['complex_body_' . $count++] = empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? '%' . strtr($regularWord, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $regularWord), '\\\'') . '[[:>:]]';
191 198
 			}
192 199
 
193
-		if ($query_params['user_query'])
194
-			$query_where[] = '{raw:user_query}';
195
-		if ($query_params['board_query'])
196
-			$query_where[] = 'm.id_board {raw:board_query}';
200
+		if ($query_params['user_query']) {
201
+					$query_where[] = '{raw:user_query}';
202
+		}
203
+		if ($query_params['board_query']) {
204
+					$query_where[] = 'm.id_board {raw:board_query}';
205
+		}
197 206
 
198
-		if ($query_params['topic'])
199
-			$query_where[] = 'm.id_topic = {int:topic}';
200
-		if ($query_params['min_msg_id'])
201
-			$query_where[] = 'm.id_msg >= {int:min_msg_id}';
202
-		if ($query_params['max_msg_id'])
203
-			$query_where[] = 'm.id_msg <= {int:max_msg_id}';
207
+		if ($query_params['topic']) {
208
+					$query_where[] = 'm.id_topic = {int:topic}';
209
+		}
210
+		if ($query_params['min_msg_id']) {
211
+					$query_where[] = 'm.id_msg >= {int:min_msg_id}';
212
+		}
213
+		if ($query_params['max_msg_id']) {
214
+					$query_where[] = 'm.id_msg <= {int:max_msg_id}';
215
+		}
204 216
 
205 217
 		$count = 0;
206
-		if (!empty($query_params['excluded_phrases']) && empty($modSettings['search_force_index']))
207
-			foreach ($query_params['excluded_phrases'] as $phrase)
218
+		if (!empty($query_params['excluded_phrases']) && empty($modSettings['search_force_index'])) {
219
+					foreach ($query_params['excluded_phrases'] as $phrase)
208 220
 			{
209 221
 				$query_where[] = 'subject NOT ' . (empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? ' LIKE ' : 'RLIKE') . '{string:exclude_subject_phrase_' . $count . '}';
222
+		}
210 223
 				$query_params['exclude_subject_phrase_' . $count++] = empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? '%' . strtr($phrase, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $phrase), '\\\'') . '[[:>:]]';
211 224
 			}
212 225
 		$count = 0;
213
-		if (!empty($query_params['excluded_subject_words']) && empty($modSettings['search_force_index']))
214
-			foreach ($query_params['excluded_subject_words'] as $excludedWord)
226
+		if (!empty($query_params['excluded_subject_words']) && empty($modSettings['search_force_index'])) {
227
+					foreach ($query_params['excluded_subject_words'] as $excludedWord)
215 228
 			{
216 229
 				$query_where[] = 'subject NOT ' . (empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? ' LIKE ' : 'RLIKE') . '{string:exclude_subject_words_' . $count . '}';
230
+		}
217 231
 				$query_params['exclude_subject_words_' . $count++] = empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? '%' . strtr($excludedWord, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $excludedWord), '\\\'') . '[[:>:]]';
218 232
 			}
219 233
 
@@ -225,12 +239,11 @@  discard block
 block discarded – undo
225 239
 
226 240
 				$query_where[] = 'to_tsvector({string:language_ftx},body) @@ plainto_tsquery({string:language_ftx},{string:body_match})';
227 241
 				$query_params['language_ftx'] = $language_ftx;
242
+			} else {
243
+							$query_where[] = 'MATCH (body) AGAINST ({string:body_match})';
228 244
 			}
229
-			else
230
-				$query_where[] = 'MATCH (body) AGAINST ({string:body_match})';
231 245
 			$query_params['body_match'] = implode(' ', array_diff($words['indexed_words'], $query_params['excluded_index_words']));
232
-		}
233
-		else
246
+		} else
234 247
 		{
235 248
 			$query_params['boolean_match'] = '';
236 249
 
@@ -246,10 +259,10 @@  discard block
 block discarded – undo
246 259
 					$query_params['boolean_match'] .= (in_array($fulltextWord, $query_params['excluded_index_words']) ? '!' : '') . $fulltextWord . ' ';
247 260
 					$row++;
248 261
 				}
249
-			}
250
-			else
251
-				foreach ($words['indexed_words'] as $fulltextWord)
262
+			} else {
263
+							foreach ($words['indexed_words'] as $fulltextWord)
252 264
 					$query_params['boolean_match'] .= (in_array($fulltextWord, $query_params['excluded_index_words']) ? '-' : '+') . $fulltextWord . ' ';
265
+			}
253 266
 
254 267
 			$query_params['boolean_match'] = substr($query_params['boolean_match'], 0, -1);
255 268
 
@@ -262,9 +275,9 @@  discard block
 block discarded – undo
262 275
 
263 276
 					$query_where[] = 'to_tsvector({string:language_ftx},body) @@ plainto_tsquery({string:language_ftx},{string:boolean_match})';
264 277
 					$query_params['language_ftx'] = $language_ftx;
278
+				} else {
279
+									$query_where[] = 'MATCH (body) AGAINST ({string:boolean_match} IN BOOLEAN MODE)';
265 280
 				}
266
-				else
267
-					$query_where[] = 'MATCH (body) AGAINST ({string:boolean_match} IN BOOLEAN MODE)';
268 281
 			}
269 282
 		}
270 283
 
Please login to merge, or discard this patch.
Sources/SearchAPI-Standard.php 1 patch
Braces   +5 added lines, -3 removed lines patch added patch discarded remove patch
@@ -11,8 +11,9 @@  discard block
 block discarded – undo
11 11
  * @version 2.1 Beta 4
12 12
  */
13 13
 
14
-if (!defined('SMF'))
14
+if (!defined('SMF')) {
15 15
 	die('No direct access...');
16
+}
16 17
 
17 18
 /**
18 19
  * Standard non full index, non custom index search
@@ -27,8 +28,9 @@  discard block
 block discarded – undo
27 28
 		$return = false;
28 29
 
29 30
 		// Maybe parent got support
30
-		if (!$return)
31
-			$return = parent::supportsMethod($methodName, $query_params);
31
+		if (!$return) {
32
+					$return = parent::supportsMethod($methodName, $query_params);
33
+		}
32 34
 
33 35
 		return $return;
34 36
 	}
Please login to merge, or discard this patch.
Sources/SearchAPI-Custom.php 1 patch
Braces   +51 added lines, -36 removed lines patch added patch discarded remove patch
@@ -11,8 +11,9 @@  discard block
 block discarded – undo
11 11
  * @version 2.1 Beta 4
12 12
  */
13 13
 
14
-if (!defined('SMF'))
14
+if (!defined('SMF')) {
15 15
 	die('No direct access...');
16
+}
16 17
 
17 18
 /**
18 19
  * Used for the "custom search index" option
@@ -54,8 +55,9 @@  discard block
 block discarded – undo
54 55
 			return;
55 56
 		}
56 57
 
57
-		if (empty($modSettings['search_custom_index_config']))
58
-			return;
58
+		if (empty($modSettings['search_custom_index_config'])) {
59
+					return;
60
+		}
59 61
 
60 62
 		$this->indexSettings = $smcFunc['json_decode']($modSettings['search_custom_index_config'], true);
61 63
 
@@ -86,8 +88,9 @@  discard block
 block discarded – undo
86 88
 		}
87 89
 
88 90
 		// Maybe parent got support
89
-		if (!$return)
90
-			$return = parent::supportsMethod($methodName, $query_params);
91
+		if (!$return) {
92
+					$return = parent::supportsMethod($methodName, $query_params);
93
+		}
91 94
 
92 95
 		return $return;
93 96
 	}
@@ -124,21 +127,23 @@  discard block
 block discarded – undo
124 127
 
125 128
 		$subwords = text2words($word, $this->min_word_length, true);
126 129
 
127
-		if (empty($modSettings['search_force_index']))
128
-			$wordsSearch['words'][] = $word;
130
+		if (empty($modSettings['search_force_index'])) {
131
+					$wordsSearch['words'][] = $word;
132
+		}
129 133
 
130 134
 		// Excluded phrases don't benefit from being split into subwords.
131
-		if (count($subwords) > 1 && $isExcluded)
132
-			return;
133
-		else
135
+		if (count($subwords) > 1 && $isExcluded) {
136
+					return;
137
+		} else
134 138
 		{
135 139
 			foreach ($subwords as $subword)
136 140
 			{
137 141
 				if ($smcFunc['strlen']($subword) >= $this->min_word_length && !in_array($subword, $this->bannedWords))
138 142
 				{
139 143
 					$wordsSearch['indexed_words'][] = $subword;
140
-					if ($isExcluded)
141
-						$wordsExclude[] = $subword;
144
+					if ($isExcluded) {
145
+											$wordsExclude[] = $subword;
146
+					}
142 147
 				}
143 148
 			}
144 149
 		}
@@ -159,8 +164,9 @@  discard block
 block discarded – undo
159 164
 		$query_where = array();
160 165
 		$query_params = $search_data['params'];
161 166
 
162
-		if ($query_params['id_search'])
163
-			$query_select['id_search'] = '{int:id_search}';
167
+		if ($query_params['id_search']) {
168
+					$query_select['id_search'] = '{int:id_search}';
169
+		}
164 170
 
165 171
 		$count = 0;
166 172
 		foreach ($words['words'] as $regularWord)
@@ -169,30 +175,37 @@  discard block
 block discarded – undo
169 175
 			$query_params['complex_body_' . $count++] = empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? '%' . strtr($regularWord, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $regularWord), '\\\'') . '[[:>:]]';
170 176
 		}
171 177
 
172
-		if ($query_params['user_query'])
173
-			$query_where[] = '{raw:user_query}';
174
-		if ($query_params['board_query'])
175
-			$query_where[] = 'm.id_board {raw:board_query}';
178
+		if ($query_params['user_query']) {
179
+					$query_where[] = '{raw:user_query}';
180
+		}
181
+		if ($query_params['board_query']) {
182
+					$query_where[] = 'm.id_board {raw:board_query}';
183
+		}
176 184
 
177
-		if ($query_params['topic'])
178
-			$query_where[] = 'm.id_topic = {int:topic}';
179
-		if ($query_params['min_msg_id'])
180
-			$query_where[] = 'm.id_msg >= {int:min_msg_id}';
181
-		if ($query_params['max_msg_id'])
182
-			$query_where[] = 'm.id_msg <= {int:max_msg_id}';
185
+		if ($query_params['topic']) {
186
+					$query_where[] = 'm.id_topic = {int:topic}';
187
+		}
188
+		if ($query_params['min_msg_id']) {
189
+					$query_where[] = 'm.id_msg >= {int:min_msg_id}';
190
+		}
191
+		if ($query_params['max_msg_id']) {
192
+					$query_where[] = 'm.id_msg <= {int:max_msg_id}';
193
+		}
183 194
 
184 195
 		$count = 0;
185
-		if (!empty($query_params['excluded_phrases']) && empty($modSettings['search_force_index']))
186
-			foreach ($query_params['excluded_phrases'] as $phrase)
196
+		if (!empty($query_params['excluded_phrases']) && empty($modSettings['search_force_index'])) {
197
+					foreach ($query_params['excluded_phrases'] as $phrase)
187 198
 			{
188 199
 				$query_where[] = 'subject NOT ' . (empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? ' LIKE ' : ' RLIKE ') . '{string:exclude_subject_phrase_' . $count . '}';
200
+		}
189 201
 				$query_params['exclude_subject_phrase_' . $count++] = empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? '%' . strtr($phrase, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $phrase), '\\\'') . '[[:>:]]';
190 202
 			}
191 203
 		$count = 0;
192
-		if (!empty($query_params['excluded_subject_words']) && empty($modSettings['search_force_index']))
193
-			foreach ($query_params['excluded_subject_words'] as $excludedWord)
204
+		if (!empty($query_params['excluded_subject_words']) && empty($modSettings['search_force_index'])) {
205
+					foreach ($query_params['excluded_subject_words'] as $excludedWord)
194 206
 			{
195 207
 				$query_where[] = 'subject NOT ' . (empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? ' LIKE ' : ' RLIKE ') . '{string:exclude_subject_words_' . $count . '}';
208
+		}
196 209
 				$query_params['exclude_subject_words_' . $count++] = empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? '%' . strtr($excludedWord, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $excludedWord), '\\\'') . '[[:>:]]';
197 210
 			}
198 211
 
@@ -205,8 +218,7 @@  discard block
 block discarded – undo
205 218
 			{
206 219
 				$query_left_join[] = '{db_prefix}log_search_words AS lsw' . $numTables . ' ON (lsw' . $numTables . '.id_word = ' . $indexedWord . ' AND lsw' . $numTables . '.id_msg = m.id_msg)';
207 220
 				$query_where[] = '(lsw' . $numTables . '.id_word IS NULL)';
208
-			}
209
-			else
221
+			} else
210 222
 			{
211 223
 				$query_inner_join[] = '{db_prefix}log_search_words AS lsw' . $numTables . ' ON (lsw' . $numTables . '.id_msg = ' . ($prev_join === 0 ? 'm' : 'lsw' . $prev_join) . '.id_msg)';
212 224
 				$query_where[] = 'lsw' . $numTables . '.id_word = ' . $indexedWord;
@@ -242,16 +254,18 @@  discard block
 block discarded – undo
242 254
 		$customIndexSettings = $smcFunc['json_decode']($modSettings['search_custom_index_config'], true);
243 255
 
244 256
 		$inserts = array();
245
-		foreach (text2words($msgOptions['body'], $customIndexSettings['bytes_per_word'], true) as $word)
246
-			$inserts[] = array($word, $msgOptions['id']);
257
+		foreach (text2words($msgOptions['body'], $customIndexSettings['bytes_per_word'], true) as $word) {
258
+					$inserts[] = array($word, $msgOptions['id']);
259
+		}
247 260
 
248
-		if (!empty($inserts))
249
-			$smcFunc['db_insert']('ignore',
261
+		if (!empty($inserts)) {
262
+					$smcFunc['db_insert']('ignore',
250 263
 				'{db_prefix}log_search_words',
251 264
 				array('id_word' => 'int', 'id_msg' => 'int'),
252 265
 				$inserts,
253 266
 				array('id_word', 'id_msg')
254 267
 			);
268
+		}
255 269
 	}
256 270
 
257 271
 	/**
@@ -294,8 +308,9 @@  discard block
 block discarded – undo
294 308
 			if (!empty($inserted_words))
295 309
 			{
296 310
 				$inserts = array();
297
-				foreach ($inserted_words as $word)
298
-					$inserts[] = array($word, $msgOptions['id']);
311
+				foreach ($inserted_words as $word) {
312
+									$inserts[] = array($word, $msgOptions['id']);
313
+				}
299 314
 				$smcFunc['db_insert']('insert',
300 315
 					'{db_prefix}log_search_words',
301 316
 					array('id_word' => 'string', 'id_msg' => 'int'),
Please login to merge, or discard this patch.
Sources/ManageLanguages.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1229,8 +1229,8 @@
 block discarded – undo
1229 1229
 					continue;
1230 1230
 
1231 1231
 				$final_saves[$string_key] = array(
1232
-					'find' => "\n\n?".'>',
1233
-					'replace' => "\n$" . $type . '[\'' . $string_key . '\'] = ' . $string_val['string'] . ';' . "\n\n?".'>',
1232
+					'find' => "\n\n?" . '>',
1233
+					'replace' => "\n$" . $type . '[\'' . $string_key . '\'] = ' . $string_val['string'] . ';' . "\n\n?" . '>',
1234 1234
 				);
1235 1235
 			}
1236 1236
 		}
Please login to merge, or discard this patch.
Braces   +199 added lines, -149 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 4
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 /**
20 21
  * This is the main function for the languages area.
@@ -150,11 +151,11 @@  discard block
 block discarded – undo
150 151
 	$language_list = new xmlArray(fetch_web_data($url), true);
151 152
 
152 153
 	// Check that the site responded and that the language exists.
153
-	if (!$language_list->exists('languages'))
154
-		$context['smf_error'] = 'no_response';
155
-	elseif (!$language_list->exists('languages/language'))
156
-		$context['smf_error'] = 'no_files';
157
-	else
154
+	if (!$language_list->exists('languages')) {
155
+			$context['smf_error'] = 'no_response';
156
+	} elseif (!$language_list->exists('languages/language')) {
157
+			$context['smf_error'] = 'no_files';
158
+	} else
158 159
 	{
159 160
 		$language_list = $language_list->path('languages[0]');
160 161
 		$lang_files = $language_list->set('language');
@@ -162,8 +163,9 @@  discard block
 block discarded – undo
162 163
 		foreach ($lang_files as $file)
163 164
 		{
164 165
 			// Were we searching?
165
-			if (!empty($context['smf_search_term']) && strpos($file->fetch('name'), $smcFunc['strtolower']($context['smf_search_term'])) === false)
166
-				continue;
166
+			if (!empty($context['smf_search_term']) && strpos($file->fetch('name'), $smcFunc['strtolower']($context['smf_search_term'])) === false) {
167
+							continue;
168
+			}
167 169
 
168 170
 			$smf_languages[] = array(
169 171
 				'id' => $file->fetch('id'),
@@ -174,10 +176,11 @@  discard block
 block discarded – undo
174 176
 				'install_link' => '<a href="' . $scripturl . '?action=admin;area=languages;sa=downloadlang;did=' . $file->fetch('id') . ';' . $context['session_var'] . '=' . $context['session_id'] . '">' . $txt['add_language_smf_install'] . '</a>',
175 177
 			);
176 178
 		}
177
-		if (empty($smf_languages))
178
-			$context['smf_error'] = 'no_files';
179
-		else
180
-			return $smf_languages;
179
+		if (empty($smf_languages)) {
180
+					$context['smf_error'] = 'no_files';
181
+		} else {
182
+					return $smf_languages;
183
+		}
181 184
 	}
182 185
 }
183 186
 
@@ -199,8 +202,9 @@  discard block
 block discarded – undo
199 202
 	require_once($sourcedir . '/Subs-Package.php');
200 203
 
201 204
 	// Clearly we need to know what to request.
202
-	if (!isset($_GET['did']))
203
-		fatal_lang_error('no_access', false);
205
+	if (!isset($_GET['did'])) {
206
+			fatal_lang_error('no_access', false);
207
+	}
204 208
 
205 209
 	// Some lovely context.
206 210
 	$context['download_id'] = $_GET['did'];
@@ -220,8 +224,9 @@  discard block
 block discarded – undo
220 224
 		foreach ($_POST['copy_file'] as $file)
221 225
 		{
222 226
 			// Check it's not very bad.
223
-			if (strpos($file, '..') !== false || (strpos($file, 'Themes') !== 0 && !preg_match('~agreement\.[A-Za-z-_0-9]+\.txt$~', $file)))
224
-				fatal_error($txt['languages_download_illegal_paths']);
227
+			if (strpos($file, '..') !== false || (strpos($file, 'Themes') !== 0 && !preg_match('~agreement\.[A-Za-z-_0-9]+\.txt$~', $file))) {
228
+							fatal_error($txt['languages_download_illegal_paths']);
229
+			}
225 230
 
226 231
 			$chmod_files[] = $boarddir . '/' . $file;
227 232
 			$install_files[] = $file;
@@ -232,8 +237,9 @@  discard block
 block discarded – undo
232 237
 		$files_left = $file_status['files']['notwritable'];
233 238
 
234 239
 		// Something not writable?
235
-		if (!empty($files_left))
236
-			$context['error_message'] = $txt['languages_download_not_chmod'];
240
+		if (!empty($files_left)) {
241
+					$context['error_message'] = $txt['languages_download_not_chmod'];
242
+		}
237 243
 		// Otherwise, go go go!
238 244
 		elseif (!empty($install_files))
239 245
 		{
@@ -248,11 +254,13 @@  discard block
 block discarded – undo
248 254
 	}
249 255
 
250 256
 	// Open up the old china.
251
-	if (!isset($archive_content))
252
-		$archive_content = read_tgz_file('https://download.simplemachines.org/fetch_language.php?version=' . urlencode(strtr($forum_version, array('SMF ' => ''))) . ';fetch=' . urlencode($_GET['did']), null);
257
+	if (!isset($archive_content)) {
258
+			$archive_content = read_tgz_file('https://download.simplemachines.org/fetch_language.php?version=' . urlencode(strtr($forum_version, array('SMF ' => ''))) . ';fetch=' . urlencode($_GET['did']), null);
259
+	}
253 260
 
254
-	if (empty($archive_content))
255
-		fatal_error($txt['add_language_error_no_response']);
261
+	if (empty($archive_content)) {
262
+			fatal_error($txt['add_language_error_no_response']);
263
+	}
256 264
 
257 265
 	// Now for each of the files, let's do some *stuff*
258 266
 	$context['files'] = array(
@@ -267,8 +275,9 @@  discard block
 block discarded – undo
267 275
 		$extension = substr($filename, strrpos($filename, '.') + 1);
268 276
 
269 277
 		// Don't do anything with files we don't understand.
270
-		if (!in_array($extension, array('php', 'jpg', 'gif', 'jpeg', 'png', 'txt')))
271
-			continue;
278
+		if (!in_array($extension, array('php', 'jpg', 'gif', 'jpeg', 'png', 'txt'))) {
279
+					continue;
280
+		}
272 281
 
273 282
 		// Basic data.
274 283
 		$context_data = array(
@@ -287,8 +296,9 @@  discard block
 block discarded – undo
287 296
 		// Does the file exist, is it different and can we overwrite?
288 297
 		if (file_exists($boarddir . '/' . $file['filename']))
289 298
 		{
290
-			if (is_writable($boarddir . '/' . $file['filename']))
291
-				$context_data['writable'] = true;
299
+			if (is_writable($boarddir . '/' . $file['filename'])) {
300
+							$context_data['writable'] = true;
301
+			}
292 302
 
293 303
 			// Finally, do we actually think the content has changed?
294 304
 			if ($file['size'] == filesize($boarddir . '/' . $file['filename']) && $file['md5'] == md5_file($boarddir . '/' . $file['filename']))
@@ -301,16 +311,17 @@  discard block
 block discarded – undo
301 311
 			{
302 312
 				$context_data['exists'] = 'same';
303 313
 				$context_data['default_copy'] = false;
314
+			} else {
315
+							$context_data['exists'] = 'different';
304 316
 			}
305
-			else
306
-				$context_data['exists'] = 'different';
307 317
 		}
308 318
 		// No overwrite?
309 319
 		else
310 320
 		{
311 321
 			// Can we at least stick it in the directory...
312
-			if (is_writable($boarddir . '/' . $dirname))
313
-				$context_data['writable'] = true;
322
+			if (is_writable($boarddir . '/' . $dirname)) {
323
+							$context_data['writable'] = true;
324
+			}
314 325
 		}
315 326
 
316 327
 		// I love PHP files, that's why I'm a developer and not an artistic type spending my time drinking absinth and living a life of sin...
@@ -325,8 +336,9 @@  discard block
 block discarded – undo
325 336
 			list ($name, $language) = explode('.', $filename);
326 337
 
327 338
 			// Let's get the new version, I like versions, they tell me that I'm up to date.
328
-			if (preg_match('~\s*Version:\s+(.+?);\s*' . preg_quote($name, '~') . '~i', $file['preview'], $match) == 1)
329
-				$context_data['version'] = $match[1];
339
+			if (preg_match('~\s*Version:\s+(.+?);\s*' . preg_quote($name, '~') . '~i', $file['preview'], $match) == 1) {
340
+							$context_data['version'] = $match[1];
341
+			}
330 342
 
331 343
 			// Now does the old file exist - if so what is it's version?
332 344
 			if (file_exists($boarddir . '/' . $file['filename']))
@@ -342,34 +354,35 @@  discard block
 block discarded – undo
342 354
 					$context_data['cur_version'] = $match[1];
343 355
 
344 356
 					// How does this compare?
345
-					if ($context_data['cur_version'] == $context_data['version'])
346
-						$context_data['version_compare'] = 'same';
347
-					elseif ($context_data['cur_version'] > $context_data['version'])
348
-						$context_data['version_compare'] = 'older';
357
+					if ($context_data['cur_version'] == $context_data['version']) {
358
+											$context_data['version_compare'] = 'same';
359
+					} elseif ($context_data['cur_version'] > $context_data['version']) {
360
+											$context_data['version_compare'] = 'older';
361
+					}
349 362
 
350 363
 					// Don't recommend copying if the version is the same.
351
-					if ($context_data['version_compare'] != 'newer')
352
-						$context_data['default_copy'] = false;
364
+					if ($context_data['version_compare'] != 'newer') {
365
+											$context_data['default_copy'] = false;
366
+					}
353 367
 				}
354 368
 			}
355 369
 
356 370
 			// Add the context data to the main set.
357 371
 			$context['files']['lang'][] = $context_data;
358
-		}
359
-		elseif ($extension == '.txt' && stripos($filename, 'agreement') !== false)
372
+		} elseif ($extension == '.txt' && stripos($filename, 'agreement') !== false)
360 373
 		{
361 374
 			// Registration agreement is a primary file
362 375
 			$context['files']['lang'][] = $context_data;
363
-		}
364
-		else
376
+		} else
365 377
 		{
366 378
 			// There shouldn't be anything else, but load this into "other" in case we decide to handle it in the future
367 379
 			$context['files']['other'][] = $context_data;
368 380
 		}
369 381
 
370 382
 		// Collect together all non-writable areas.
371
-		if (!$context_data['writable'])
372
-			$context['make_writable'][] = $context_data['destination'];
383
+		if (!$context_data['writable']) {
384
+					$context['make_writable'][] = $context_data['destination'];
385
+		}
373 386
 	}
374 387
 
375 388
 	// Before we go to far can we make anything writable, eh, eh?
@@ -384,22 +397,24 @@  discard block
 block discarded – undo
384 397
 		{
385 398
 			if ($type == 'lang')
386 399
 			{
387
-				foreach ($data as $k => $file)
388
-					if (!$file['writable'] && !in_array($file['destination'], $context['still_not_writable']))
400
+				foreach ($data as $k => $file) {
401
+									if (!$file['writable'] && !in_array($file['destination'], $context['still_not_writable']))
389 402
 						$context['files'][$type][$k]['writable'] = true;
390
-			}
391
-			else
403
+				}
404
+			} else
392 405
 			{
393
-				foreach ($data as $theme => $files)
394
-					foreach ($files as $k => $file)
406
+				foreach ($data as $theme => $files) {
407
+									foreach ($files as $k => $file)
395 408
 						if (!$file['writable'] && !in_array($file['destination'], $context['still_not_writable']))
396 409
 							$context['files'][$type][$theme][$k]['writable'] = true;
410
+				}
397 411
 			}
398 412
 		}
399 413
 
400 414
 		// Are we going to need more language stuff?
401
-		if (!empty($context['still_not_writable']))
402
-			loadLanguage('Packages');
415
+		if (!empty($context['still_not_writable'])) {
416
+					loadLanguage('Packages');
417
+		}
403 418
 	}
404 419
 
405 420
 	// This is the list for the main files.
@@ -612,12 +627,13 @@  discard block
 block discarded – undo
612 627
 	highlightSelected("list_language_list_' . ($language == '' ? 'english' : $language) . '");', true);
613 628
 
614 629
 	// Display a warning if we cannot edit the default setting.
615
-	if (!is_writable($boarddir . '/Settings.php'))
616
-		$listOptions['additional_rows'][] = array(
630
+	if (!is_writable($boarddir . '/Settings.php')) {
631
+			$listOptions['additional_rows'][] = array(
617 632
 				'position' => 'after_title',
618 633
 				'value' => $txt['language_settings_writable'],
619 634
 				'class' => 'smalltext alert',
620 635
 			);
636
+	}
621 637
 
622 638
 	require_once($sourcedir . '/Subs-List.php');
623 639
 	createList($listOptions);
@@ -659,10 +675,11 @@  discard block
 block discarded – undo
659 675
 
660 676
 	// Put them back.
661 677
 	$settings['actual_theme_dir'] = $backup_actual_theme_dir;
662
-	if (!empty($backup_base_theme_dir))
663
-		$settings['base_theme_dir'] = $backup_base_theme_dir;
664
-	else
665
-		unset($settings['base_theme_dir']);
678
+	if (!empty($backup_base_theme_dir)) {
679
+			$settings['base_theme_dir'] = $backup_base_theme_dir;
680
+	} else {
681
+			unset($settings['base_theme_dir']);
682
+	}
666 683
 
667 684
 	// Get the language files and data...
668 685
 	foreach ($context['languages'] as $lang)
@@ -691,13 +708,15 @@  discard block
 block discarded – undo
691 708
 	while ($row = $smcFunc['db_fetch_assoc']($request))
692 709
 	{
693 710
 		// Default?
694
-		if (empty($row['lngfile']) || !isset($languages[$row['lngfile']]))
695
-			$row['lngfile'] = $language;
711
+		if (empty($row['lngfile']) || !isset($languages[$row['lngfile']])) {
712
+					$row['lngfile'] = $language;
713
+		}
696 714
 
697
-		if (!isset($languages[$row['lngfile']]) && isset($languages['english']))
698
-			$languages['english']['count'] += $row['num_users'];
699
-		elseif (isset($languages[$row['lngfile']]))
700
-			$languages[$row['lngfile']]['count'] += $row['num_users'];
715
+		if (!isset($languages[$row['lngfile']]) && isset($languages['english'])) {
716
+					$languages['english']['count'] += $row['num_users'];
717
+		} elseif (isset($languages[$row['lngfile']])) {
718
+					$languages[$row['lngfile']]['count'] += $row['num_users'];
719
+		}
701 720
 	}
702 721
 	$smcFunc['db_free_result']($request);
703 722
 
@@ -737,13 +756,15 @@  discard block
 block discarded – undo
737 756
 
738 757
 	call_integration_hook('integrate_language_settings', array(&$config_vars));
739 758
 
740
-	if ($return_config)
741
-		return $config_vars;
759
+	if ($return_config) {
760
+			return $config_vars;
761
+	}
742 762
 
743 763
 	// Get our languages. No cache
744 764
 	getLanguages(false);
745
-	foreach ($context['languages'] as $lang)
746
-		$config_vars['language'][4][$lang['filename']] = array($lang['filename'], $lang['name']);
765
+	foreach ($context['languages'] as $lang) {
766
+			$config_vars['language'][4][$lang['filename']] = array($lang['filename'], $lang['name']);
767
+	}
747 768
 
748 769
 	// Saving settings?
749 770
 	if (isset($_REQUEST['save']))
@@ -753,8 +774,9 @@  discard block
 block discarded – undo
753 774
 		call_integration_hook('integrate_save_language_settings', array(&$config_vars));
754 775
 
755 776
 		saveSettings($config_vars);
756
-		if (!$settings_not_writable && !$settings_backup_fail)
757
-			$_SESSION['adm-save'] = true;
777
+		if (!$settings_not_writable && !$settings_backup_fail) {
778
+					$_SESSION['adm-save'] = true;
779
+		}
758 780
 		redirectexit('action=admin;area=languages;sa=settings');
759 781
 	}
760 782
 
@@ -763,10 +785,11 @@  discard block
 block discarded – undo
763 785
 	$context['settings_title'] = $txt['language_settings'];
764 786
 	$context['save_disabled'] = $settings_not_writable;
765 787
 
766
-	if ($settings_not_writable)
767
-		$context['settings_message'] = '<div class="centertext"><strong>' . $txt['settings_not_writable'] . '</strong></div><br>';
768
-	elseif ($settings_backup_fail)
769
-		$context['settings_message'] = '<div class="centertext"><strong>' . $txt['admin_backup_fail'] . '</strong></div><br>';
788
+	if ($settings_not_writable) {
789
+			$context['settings_message'] = '<div class="centertext"><strong>' . $txt['settings_not_writable'] . '</strong></div><br>';
790
+	} elseif ($settings_backup_fail) {
791
+			$context['settings_message'] = '<div class="centertext"><strong>' . $txt['admin_backup_fail'] . '</strong></div><br>';
792
+	}
770 793
 
771 794
 	// Fill the config array.
772 795
 	prepareServerSettingsContext($config_vars);
@@ -813,8 +836,9 @@  discard block
 block discarded – undo
813 836
 			'theme_dir' => $settings['default_theme_dir'],
814 837
 		),
815 838
 	);
816
-	while ($row = $smcFunc['db_fetch_assoc']($request))
817
-		$themes[$row['id_theme']][$row['variable']] = $row['value'];
839
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
840
+			$themes[$row['id_theme']][$row['variable']] = $row['value'];
841
+	}
818 842
 	$smcFunc['db_free_result']($request);
819 843
 
820 844
 	// This will be where we look
@@ -841,14 +865,16 @@  discard block
 block discarded – undo
841 865
 	// Check we have themes with a path and a name - just in case - and add the path.
842 866
 	foreach ($themes as $id => $data)
843 867
 	{
844
-		if (count($data) != 2)
845
-			unset($themes[$id]);
846
-		elseif (is_dir($data['theme_dir'] . '/languages'))
847
-			$lang_dirs[$id] = $data['theme_dir'] . '/languages';
868
+		if (count($data) != 2) {
869
+					unset($themes[$id]);
870
+		} elseif (is_dir($data['theme_dir'] . '/languages')) {
871
+					$lang_dirs[$id] = $data['theme_dir'] . '/languages';
872
+		}
848 873
 
849 874
 		// How about image directories?
850
-		if (is_dir($data['theme_dir'] . '/images/' . $context['lang_id']))
851
-			$images_dirs[$id] = $data['theme_dir'] . '/images/' . $context['lang_id'];
875
+		if (is_dir($data['theme_dir'] . '/images/' . $context['lang_id'])) {
876
+					$images_dirs[$id] = $data['theme_dir'] . '/images/' . $context['lang_id'];
877
+		}
852 878
 	}
853 879
 
854 880
 	$current_file = $file_id ? $lang_dirs[$theme_id] . '/' . $file_id . '.' . $context['lang_id'] . '.php' : '';
@@ -862,15 +888,17 @@  discard block
 block discarded – undo
862 888
 		while ($entry = $dir->read())
863 889
 		{
864 890
 			// We're only after the files for this language.
865
-			if (preg_match('~^([A-Za-z]+)\.' . $context['lang_id'] . '\.php$~', $entry, $matches) == 0)
866
-				continue;
891
+			if (preg_match('~^([A-Za-z]+)\.' . $context['lang_id'] . '\.php$~', $entry, $matches) == 0) {
892
+							continue;
893
+			}
867 894
 
868
-			if (!isset($context['possible_files'][$theme]))
869
-				$context['possible_files'][$theme] = array(
895
+			if (!isset($context['possible_files'][$theme])) {
896
+							$context['possible_files'][$theme] = array(
870 897
 					'id' => $theme,
871 898
 					'name' => $themes[$theme]['name'],
872 899
 					'files' => array(),
873 900
 				);
901
+			}
874 902
 
875 903
 			$context['possible_files'][$theme]['files'][] = array(
876 904
 				'id' => $matches[1],
@@ -899,31 +927,36 @@  discard block
 block discarded – undo
899 927
 		{
900 928
 			$_SESSION['last_backup_for'] = $context['lang_id'] . '$$$';
901 929
 			$result = package_create_backup('backup_lang_' . $context['lang_id']);
902
-			if (!$result)
903
-				fatal_lang_error('could_not_language_backup', false);
930
+			if (!$result) {
931
+							fatal_lang_error('could_not_language_backup', false);
932
+			}
904 933
 		}
905 934
 
906 935
 		// Second, loop through the array to remove the files.
907 936
 		foreach ($lang_dirs as $curPath)
908 937
 		{
909
-			foreach ($context['possible_files'][1]['files'] as $lang)
910
-				if (file_exists($curPath . '/' . $lang['id'] . '.' . $context['lang_id'] . '.php'))
938
+			foreach ($context['possible_files'][1]['files'] as $lang) {
939
+							if (file_exists($curPath . '/' . $lang['id'] . '.' . $context['lang_id'] . '.php'))
911 940
 					unlink($curPath . '/' . $lang['id'] . '.' . $context['lang_id'] . '.php');
941
+			}
912 942
 
913 943
 			// Check for the email template.
914
-			if (file_exists($curPath . '/EmailTemplates.' . $context['lang_id'] . '.php'))
915
-				unlink($curPath . '/EmailTemplates.' . $context['lang_id'] . '.php');
944
+			if (file_exists($curPath . '/EmailTemplates.' . $context['lang_id'] . '.php')) {
945
+							unlink($curPath . '/EmailTemplates.' . $context['lang_id'] . '.php');
946
+			}
916 947
 		}
917 948
 
918 949
 		// Third, the agreement file.
919
-		if (file_exists($boarddir . '/agreement.' . $context['lang_id'] . '.txt'))
920
-			unlink($boarddir . '/agreement.' . $context['lang_id'] . '.txt');
950
+		if (file_exists($boarddir . '/agreement.' . $context['lang_id'] . '.txt')) {
951
+					unlink($boarddir . '/agreement.' . $context['lang_id'] . '.txt');
952
+		}
921 953
 
922 954
 		// Fourth, a related images folder, if it exists...
923
-		if (!empty($images_dirs))
924
-			foreach ($images_dirs as $curPath)
955
+		if (!empty($images_dirs)) {
956
+					foreach ($images_dirs as $curPath)
925 957
 				if (is_dir($curPath))
926 958
 					deltree($curPath);
959
+		}
927 960
 
928 961
 		// Members can no longer use this language.
929 962
 		$smcFunc['db_query']('', '
@@ -1010,13 +1043,14 @@  discard block
 block discarded – undo
1010 1043
 			foreach ($_POST['edit'] as $k => $v)
1011 1044
 			{
1012 1045
 				// Only try to save if 'edit' was specified and if the string has changed
1013
-				if ($v == 'edit' && isset($_POST['entry'][$k]) && isset($_POST['comp'][$k]) && $_POST['entry'][$k] != $_POST['comp'][$k])
1014
-					$save_strings[$k] = cleanLangString($_POST['entry'][$k], false);
1046
+				if ($v == 'edit' && isset($_POST['entry'][$k]) && isset($_POST['comp'][$k]) && $_POST['entry'][$k] != $_POST['comp'][$k]) {
1047
+									$save_strings[$k] = cleanLangString($_POST['entry'][$k], false);
1048
+				}
1015 1049
 
1016 1050
 				// Record any add or remove requests. We'll decide on them later.
1017
-				elseif ($v == 'remove')
1018
-					$remove_strings[] = $k;
1019
-				elseif ($v == 'add' && isset($_POST['entry'][$k]))
1051
+				elseif ($v == 'remove') {
1052
+									$remove_strings[] = $k;
1053
+				} elseif ($v == 'add' && isset($_POST['entry'][$k]))
1020 1054
 				{
1021 1055
 					$add_strings[$k] = array(
1022 1056
 						'group' => isset($_POST['grp'][$k]) ? $_POST['grp'][$k] : 'txt',
@@ -1056,8 +1090,9 @@  discard block
 block discarded – undo
1056 1090
 				{
1057 1091
 					$group = !empty($special_groups[$file_id][$matches[1]]) ? $special_groups[$file_id][$matches[1]] : $matches[1];
1058 1092
 
1059
-					if (isset($allows_add_remove[$file_id]['add']) && in_array($matches[1], $allows_add_remove[$file_id]['add']))
1060
-						$context['can_add_lang_entry'][$group] = true;
1093
+					if (isset($allows_add_remove[$file_id]['add']) && in_array($matches[1], $allows_add_remove[$file_id]['add'])) {
1094
+											$context['can_add_lang_entry'][$group] = true;
1095
+					}
1061 1096
 
1062 1097
 					$entries[$matches[2]] = array(
1063 1098
 						'type' => $matches[1],
@@ -1079,8 +1114,9 @@  discard block
 block discarded – undo
1079 1114
 			{
1080 1115
 				$group = !empty($special_groups[$file_id][$matches[1]]) ? $special_groups[$file_id][$matches[1]] : $matches[1];
1081 1116
 
1082
-				if (isset($allows_add_remove[$file_id]['add']) && in_array($matches[1], $allows_add_remove[$file_id]['add']))
1083
-					$context['can_add_lang_entry'][$group] = true;
1117
+				if (isset($allows_add_remove[$file_id]['add']) && in_array($matches[1], $allows_add_remove[$file_id]['add'])) {
1118
+									$context['can_add_lang_entry'][$group] = true;
1119
+				}
1084 1120
 
1085 1121
 				$entries[$matches[2]] = array(
1086 1122
 					'type' => $matches[1],
@@ -1100,8 +1136,9 @@  discard block
 block discarded – undo
1100 1136
 		{
1101 1137
 			// Ignore some things we set separately.
1102 1138
 			$ignore_files = array('lang_character_set', 'lang_locale', 'lang_dictionary', 'lang_spelling', 'lang_rtl');
1103
-			if (in_array($entryKey, $ignore_files))
1104
-				continue;
1139
+			if (in_array($entryKey, $ignore_files)) {
1140
+							continue;
1141
+			}
1105 1142
 
1106 1143
 			// These are arrays that need breaking out.
1107 1144
 			$arrays = array('days', 'days_short', 'months', 'months_titles', 'months_short');
@@ -1134,9 +1171,9 @@  discard block
 block discarded – undo
1134 1171
 					{
1135 1172
 						$save_cache['entries'][$cur_index] = strtr($save_strings[$entryKey . '-+- ' . $cur_index], array('\'' => ''));
1136 1173
 						$save_cache['enabled'] = true;
1174
+					} else {
1175
+											$save_cache['entries'][$cur_index] = $subValue;
1137 1176
 					}
1138
-					else
1139
-						$save_cache['entries'][$cur_index] = $subValue;
1140 1177
 
1141 1178
 					$context['file_entries'][$entryValue['group']][] = array(
1142 1179
 						'key' => $entryKey . '-+- ' . $cur_index,
@@ -1159,9 +1196,9 @@  discard block
 block discarded – undo
1159 1196
 						{
1160 1197
 							$items[] = $k2 . ' => \'' . $v2 . '\'';
1161 1198
 							$cur_index = $k2;
1199
+						} else {
1200
+													$items[] = '\'' . $v2 . '\'';
1162 1201
 						}
1163
-						else
1164
-							$items[] = '\'' . $v2 . '\'';
1165 1202
 
1166 1203
 						$cur_index++;
1167 1204
 					}
@@ -1171,15 +1208,15 @@  discard block
 block discarded – undo
1171 1208
 						'replace' => '$' . $entryValue['type'] . '[\'' . $entryKey . '\'] = array(' . implode(', ', $items) . ');',
1172 1209
 					);
1173 1210
 				}
1174
-			}
1175
-			else
1211
+			} else
1176 1212
 			{
1177 1213
 				// Saving?
1178 1214
 				if (isset($save_strings[$entryKey]) && $save_strings[$entryKey] != $entryValue['entry'])
1179 1215
 				{
1180 1216
 					// @todo Fix this properly.
1181
-					if ($save_strings[$entryKey] == '')
1182
-						$save_strings[$entryKey] = '\'\'';
1217
+					if ($save_strings[$entryKey] == '') {
1218
+											$save_strings[$entryKey] = '\'\'';
1219
+					}
1183 1220
 
1184 1221
 					// Set the new value.
1185 1222
 					$entryValue['entry'] = $save_strings[$entryKey];
@@ -1218,8 +1255,9 @@  discard block
 block discarded – undo
1218 1255
 			{
1219 1256
 				$type = isset($special_types[$string_val['group']]) ? $special_types[$string_val['group']] : $string_val['group'];
1220 1257
 
1221
-				if (!in_array($type, $allows_add_remove[$file_id]['add']))
1222
-					continue;
1258
+				if (!in_array($type, $allows_add_remove[$file_id]['add'])) {
1259
+									continue;
1260
+				}
1223 1261
 
1224 1262
 				$final_saves[$string_key] = array(
1225 1263
 					'find' => "\n\n?".'>',
@@ -1234,8 +1272,9 @@  discard block
 block discarded – undo
1234 1272
 			checkSession();
1235 1273
 
1236 1274
 			$file_contents = implode('', file($current_file));
1237
-			foreach ($final_saves as $save)
1238
-				$file_contents = strtr($file_contents, array($save['find'] => $save['replace']));
1275
+			foreach ($final_saves as $save) {
1276
+							$file_contents = strtr($file_contents, array($save['find'] => $save['replace']));
1277
+			}
1239 1278
 
1240 1279
 			// Save the actual changes.
1241 1280
 			$fp = fopen($current_file, 'w+');
@@ -1293,8 +1332,9 @@  discard block
 block discarded – undo
1293 1332
 	}
1294 1333
 
1295 1334
 	// If we saved, redirect.
1296
-	if ($madeSave)
1297
-		redirectexit('action=admin;area=languages;sa=editlang;lid=' . $context['lang_id']);
1335
+	if ($madeSave) {
1336
+			redirectexit('action=admin;area=languages;sa=editlang;lid=' . $context['lang_id']);
1337
+	}
1298 1338
 
1299 1339
 	createToken('admin-mlang');
1300 1340
 }
@@ -1326,8 +1366,9 @@  discard block
 block discarded – undo
1326 1366
 				// Toggle the escape.
1327 1367
 				$is_escape = !$is_escape;
1328 1368
 				// If we're now escaped don't add this string.
1329
-				if ($is_escape)
1330
-					continue;
1369
+				if ($is_escape) {
1370
+									continue;
1371
+				}
1331 1372
 			}
1332 1373
 			// Special case - parsed string with line break etc?
1333 1374
 			elseif (($string{$i} == 'n' || $string{$i} == 't') && $in_string == 2 && $is_escape)
@@ -1344,11 +1385,13 @@  discard block
 block discarded – undo
1344 1385
 				if ($in_string != 2 && ($in_string != 1 || !$is_escape))
1345 1386
 				{
1346 1387
 					// Is it the end of a single quote string?
1347
-					if ($in_string == 1)
1348
-						$in_string = 0;
1388
+					if ($in_string == 1) {
1389
+											$in_string = 0;
1390
+					}
1349 1391
 					// Otherwise it's the start!
1350
-					else
1351
-						$in_string = 1;
1392
+					else {
1393
+											$in_string = 1;
1394
+					}
1352 1395
 
1353 1396
 					// Don't actually include this character!
1354 1397
 					continue;
@@ -1361,19 +1404,22 @@  discard block
 block discarded – undo
1361 1404
 				if ($in_string != 1 && ($in_string != 2 || !$is_escape))
1362 1405
 				{
1363 1406
 					// Is it the end of a double quote string?
1364
-					if ($in_string == 2)
1365
-						$in_string = 0;
1407
+					if ($in_string == 2) {
1408
+											$in_string = 0;
1409
+					}
1366 1410
 					// Otherwise it's the start!
1367
-					else
1368
-						$in_string = 2;
1411
+					else {
1412
+											$in_string = 2;
1413
+					}
1369 1414
 
1370 1415
 					// Don't actually include this character!
1371 1416
 					continue;
1372 1417
 				}
1373 1418
 			}
1374 1419
 			// A join/space outside of a string is simply removed.
1375
-			elseif ($in_string == 0 && (empty($string{$i}) || $string{$i} == '.'))
1376
-				continue;
1420
+			elseif ($in_string == 0 && (empty($string{$i}) || $string{$i} == '.')) {
1421
+							continue;
1422
+			}
1377 1423
 			// Start of a variable?
1378 1424
 			elseif ($in_string == 0 && $string{$i} == '$')
1379 1425
 			{
@@ -1407,8 +1453,7 @@  discard block
 block discarded – undo
1407 1453
 
1408 1454
 		// Unhtml then rehtml the whole thing!
1409 1455
 		$new_string = $smcFunc['htmlspecialchars'](un_htmlspecialchars($new_string));
1410
-	}
1411
-	else
1456
+	} else
1412 1457
 	{
1413 1458
 		// Keep track of what we're doing...
1414 1459
 		$in_string = 0;
@@ -1437,10 +1482,11 @@  discard block
 block discarded – undo
1437 1482
 				preg_match('~\{%([\$A-Za-z0-9\'\[\]_-]+)%\}~', substr($string, $i), $matches);
1438 1483
 				if (!empty($matches[1]))
1439 1484
 				{
1440
-					if ($in_string == 1)
1441
-						$new_string .= '\' . ';
1442
-					elseif ($new_string)
1443
-						$new_string .= ' . ';
1485
+					if ($in_string == 1) {
1486
+											$new_string .= '\' . ';
1487
+					} elseif ($new_string) {
1488
+											$new_string .= ' . ';
1489
+					}
1444 1490
 
1445 1491
 					$new_string .= $matches[1];
1446 1492
 					$i += strlen($matches[1]) + 3;
@@ -1453,8 +1499,9 @@  discard block
 block discarded – undo
1453 1499
 			elseif ($string{$i} == '<')
1454 1500
 			{
1455 1501
 				// Probably HTML?
1456
-				if ($string{$i + 1} != ' ')
1457
-					$in_html = true;
1502
+				if ($string{$i + 1} != ' ') {
1503
+									$in_html = true;
1504
+				}
1458 1505
 				// Assume we need an entity...
1459 1506
 				else
1460 1507
 				{
@@ -1466,8 +1513,9 @@  discard block
 block discarded – undo
1466 1513
 			elseif ($string{$i} == '>')
1467 1514
 			{
1468 1515
 				// Will it be HTML?
1469
-				if ($in_html)
1470
-					$in_html = false;
1516
+				if ($in_html) {
1517
+									$in_html = false;
1518
+				}
1471 1519
 				// Otherwise we need an entity...
1472 1520
 				else
1473 1521
 				{
@@ -1476,8 +1524,9 @@  discard block
 block discarded – undo
1476 1524
 				}
1477 1525
 			}
1478 1526
 			// Is it a slash? If so escape it...
1479
-			if ($string{$i} == '\\')
1480
-				$new_string .= '\\';
1527
+			if ($string{$i} == '\\') {
1528
+							$new_string .= '\\';
1529
+			}
1481 1530
 			// The infamous double quote?
1482 1531
 			elseif ($string{$i} == '"')
1483 1532
 			{
@@ -1500,10 +1549,11 @@  discard block
 block discarded – undo
1500 1549
 		}
1501 1550
 
1502 1551
 		// If we ended as a string then close it off.
1503
-		if ($in_string == 1)
1504
-			$new_string .= '\'';
1505
-		elseif ($in_string == 2)
1506
-			$new_string .= '"';
1552
+		if ($in_string == 1) {
1553
+					$new_string .= '\'';
1554
+		} elseif ($in_string == 2) {
1555
+					$new_string .= '"';
1556
+		}
1507 1557
 	}
1508 1558
 
1509 1559
 	return $new_string;
Please login to merge, or discard this patch.
Themes/default/ManageLanguages.template.php 1 patch
Braces   +26 added lines, -18 removed lines patch added patch discarded remove patch
@@ -36,11 +36,12 @@  discard block
 block discarded – undo
36 36
 	}
37 37
 
38 38
 	// An error?
39
-	if (!empty($context['error_message']))
40
-		echo '
39
+	if (!empty($context['error_message'])) {
40
+			echo '
41 41
 	<div class="errorbox">
42 42
 		', $context['error_message'], '
43 43
 	</div>';
44
+	}
44 45
 
45 46
 	// Provide something of an introduction...
46 47
 	echo '
@@ -67,11 +68,12 @@  discard block
 block discarded – undo
67 68
 	// If the files are not writable, we might!
68 69
 	if (!empty($context['still_not_writable']))
69 70
 	{
70
-		if (!empty($context['package_ftp']['error']))
71
-			echo '
71
+		if (!empty($context['package_ftp']['error'])) {
72
+					echo '
72 73
 			<div class="errorbox">
73 74
 				', $context['package_ftp']['error'], '
74 75
 			</div>';
76
+		}
75 77
 
76 78
 		echo '
77 79
 			<div class="cat_bar">
@@ -150,11 +152,12 @@  discard block
 block discarded – undo
150 152
 			</div>';
151 153
 
152 154
 	// Not writable? Oops, show an error for ya.
153
-	if (!empty($context['lang_file_not_writable_message']))
154
-		echo '
155
+	if (!empty($context['lang_file_not_writable_message'])) {
156
+			echo '
155 157
 			<div class="errorbox">
156 158
 				', $context['lang_file_not_writable_message'], '
157 159
 			</div>';
160
+	}
158 161
 
159 162
 	// Show the language entries
160 163
 	echo '
@@ -199,9 +202,10 @@  discard block
 block discarded – undo
199 202
 				<input type="submit" name="save_main" value="', $txt['save'], '"', $context['lang_file_not_writable_message'] || !empty($context['file_entries']) ? ' disabled' : '', ' class="button">';
200 203
 
201 204
 	// Allow deleting entries. English can't be deleted though.
202
-	if ($context['lang_id'] != 'english')
203
-		echo '
205
+	if ($context['lang_id'] != 'english') {
206
+			echo '
204 207
 				<input type="submit" name="delete_main" value="', $txt['delete'], '"', $context['lang_file_not_writable_message'] || !empty($context['file_entries']) ? ' disabled' : '', ' onclick="confirm(\'', $txt['languages_delete_confirm'], '\');" class="button">';
208
+	}
205 209
 
206 210
 	echo '
207 211
 			</div><!-- .windowbg -->
@@ -224,9 +228,10 @@  discard block
 block discarded – undo
224 228
 		echo '
225 229
 						<optgroup label="', $theme['name'], '">';
226 230
 
227
-		foreach ($theme['files'] as $file)
228
-			echo '
231
+		foreach ($theme['files'] as $file) {
232
+					echo '
229 233
 							<option value="', $id_theme, '+', $file['id'], '"', $file['selected'] ? ' selected' : '', '>', $file['name'], '</option>';
234
+		}
230 235
 
231 236
 		echo '
232 237
 						</optgroup>';
@@ -241,11 +246,12 @@  discard block
 block discarded – undo
241 246
 			</div><!-- .information -->';
242 247
 
243 248
 	// Is it not writable? Show an error.
244
-	if (!empty($context['entries_not_writable_message']))
245
-		echo '
249
+	if (!empty($context['entries_not_writable_message'])) {
250
+			echo '
246 251
 			<div class="errorbox">
247 252
 				', $context['entries_not_writable_message'], '
248 253
 			</div>';
254
+	}
249 255
 
250 256
 	// Already have some file entries?
251 257
 	if (!empty($context['file_entries']))
@@ -274,8 +280,8 @@  discard block
 block discarded – undo
274 280
 						</dt>
275 281
 						<dd id="entry_', $entry_num, '">';
276 282
 
277
-				if ($entry['can_remove'])
278
-					echo '
283
+				if ($entry['can_remove']) {
284
+									echo '
279 285
 							<span style="margin-right: 1ch; white-space: nowrap">
280 286
 								<input id="entry_', $entry_num, '_none" class="entry_toggle" type="radio" name="edit[', $entry['key'], ']" value="" data-target="#entry_', $entry_num, '" checked>
281 287
 								<label for="entry_', $entry_num, '_none">', $txt['no_change'], '</label>
@@ -288,10 +294,11 @@  discard block
 block discarded – undo
288 294
 								<input id="entry_', $entry_num, '_remove" class="entry_toggle" type="radio" name="edit[', $entry['key'], ']" value="remove" data-target="#entry_', $entry_num, '">
289 295
 								<label for="entry_', $entry_num, '_remove">', $txt['remove'], '</label>
290 296
 							</span>';
291
-				else
292
-					echo '
297
+				} else {
298
+									echo '
293 299
 							<input id="entry_', $entry_num, '_edit" class="entry_toggle" type="checkbox" name="edit[', $entry['key'], ']" value="edit" data-target="#entry_', $entry_num, '">
294 300
 							<label for="entry_', $entry_num, '_edit">', $txt['edit'], '</label>';
301
+				}
295 302
 
296 303
 				echo '
297 304
 							</span>
@@ -351,12 +358,13 @@  discard block
 block discarded – undo
351 358
 					<input type="text" name="smf_add" size="40" value="', !empty($context['smf_search_term']) ? $context['smf_search_term'] : '', '">';
352 359
 
353 360
 	// Do we have some errors? Too bad. Display a little error box.
354
-	if (!empty($context['smf_error']))
355
-		echo '
361
+	if (!empty($context['smf_error'])) {
362
+			echo '
356 363
 					<div>
357 364
 						<br>
358 365
 						<p class="errorbox">', $txt['add_language_error_' . $context['smf_error']], '</p>
359 366
 					</div>';
367
+	}
360 368
 
361 369
 	echo '
362 370
 				</fieldset>
Please login to merge, or discard this patch.
Sources/MoveTopic.php 1 patch
Braces   +101 added lines, -72 removed lines patch added patch discarded remove patch
@@ -14,8 +14,9 @@  discard block
 block discarded – undo
14 14
  * @version 2.1 Beta 4
15 15
  */
16 16
 
17
-if (!defined('SMF'))
17
+if (!defined('SMF')) {
18 18
 	die('No direct access...');
19
+}
19 20
 
20 21
 /**
21 22
  * This function allows to move a topic, making sure to ask the moderator
@@ -32,8 +33,9 @@  discard block
 block discarded – undo
32 33
 {
33 34
 	global $txt, $board, $topic, $user_info, $context, $language, $scripturl, $smcFunc, $modSettings, $sourcedir;
34 35
 
35
-	if (empty($topic))
36
-		fatal_lang_error('no_access', false);
36
+	if (empty($topic)) {
37
+			fatal_lang_error('no_access', false);
38
+	}
37 39
 
38 40
 	$request = $smcFunc['db_query']('', '
39 41
 		SELECT t.id_member_started, ms.subject, t.approved
@@ -49,8 +51,9 @@  discard block
 block discarded – undo
49 51
 	$smcFunc['db_free_result']($request);
50 52
 
51 53
 	// Can they see it - if not approved?
52
-	if ($modSettings['postmod_active'] && !$context['is_approved'])
53
-		isAllowedTo('approve_posts');
54
+	if ($modSettings['postmod_active'] && !$context['is_approved']) {
55
+			isAllowedTo('approve_posts');
56
+	}
54 57
 
55 58
 	// Permission check!
56 59
 	// @todo
@@ -59,9 +62,9 @@  discard block
 block discarded – undo
59 62
 		if ($id_member_started == $user_info['id'])
60 63
 		{
61 64
 			isAllowedTo('move_own');
65
+		} else {
66
+					isAllowedTo('move_any');
62 67
 		}
63
-		else
64
-			isAllowedTo('move_any');
65 68
 	}
66 69
 
67 70
 	$context['move_any'] = $user_info['is_admin'] || $modSettings['topic_move_any'];
@@ -83,11 +86,13 @@  discard block
 block discarded – undo
83 86
 		'not_redirection' => true,
84 87
 	);
85 88
 
86
-	if (!empty($_SESSION['move_to_topic']) && $_SESSION['move_to_topic'] != $board)
87
-		$options['selected_board'] = $_SESSION['move_to_topic'];
89
+	if (!empty($_SESSION['move_to_topic']) && $_SESSION['move_to_topic'] != $board) {
90
+			$options['selected_board'] = $_SESSION['move_to_topic'];
91
+	}
88 92
 
89
-	if (!$context['move_any'])
90
-		$options['included_boards'] = $boards;
93
+	if (!$context['move_any']) {
94
+			$options['included_boards'] = $boards;
95
+	}
91 96
 
92 97
 	require_once($sourcedir . '/Subs-MessageIndex.php');
93 98
 	$context['categories'] = getBoardList($options);
@@ -138,12 +143,14 @@  discard block
 block discarded – undo
138 143
 	global $txt, $topic, $scripturl, $sourcedir, $context;
139 144
 	global $board, $language, $user_info, $smcFunc;
140 145
 
141
-	if (empty($topic))
142
-		fatal_lang_error('no_access', false);
146
+	if (empty($topic)) {
147
+			fatal_lang_error('no_access', false);
148
+	}
143 149
 
144 150
 	// You can't choose to have a redirection topic and use an empty reason.
145
-	if (isset($_POST['postRedirect']) && (!isset($_POST['reason']) || trim($_POST['reason']) == ''))
146
-		fatal_lang_error('movetopic_no_reason', false);
151
+	if (isset($_POST['postRedirect']) && (!isset($_POST['reason']) || trim($_POST['reason']) == '')) {
152
+			fatal_lang_error('movetopic_no_reason', false);
153
+	}
147 154
 
148 155
 	moveTopicConcurrence();
149 156
 
@@ -163,16 +170,18 @@  discard block
 block discarded – undo
163 170
 	$smcFunc['db_free_result']($request);
164 171
 
165 172
 	// Can they see it?
166
-	if (!$context['is_approved'])
167
-		isAllowedTo('approve_posts');
173
+	if (!$context['is_approved']) {
174
+			isAllowedTo('approve_posts');
175
+	}
168 176
 
169 177
 	// Can they move topics on this board?
170 178
 	if (!allowedTo('move_any'))
171 179
 	{
172
-		if ($id_member_started == $user_info['id'])
173
-			isAllowedTo('move_own');
174
-		else
175
-			isAllowedTo('move_any');
180
+		if ($id_member_started == $user_info['id']) {
181
+					isAllowedTo('move_own');
182
+		} else {
183
+					isAllowedTo('move_any');
184
+		}
176 185
 	}
177 186
 
178 187
 	checkSession();
@@ -197,8 +206,9 @@  discard block
 block discarded – undo
197 206
 			'blank_redirect' => '',
198 207
 		)
199 208
 	);
200
-	if ($smcFunc['db_num_rows']($request) == 0)
201
-		fatal_lang_error('no_board');
209
+	if ($smcFunc['db_num_rows']($request) == 0) {
210
+			fatal_lang_error('no_board');
211
+	}
202 212
 	list ($pcounter, $board_name, $subject) = $smcFunc['db_fetch_row']($request);
203 213
 	$smcFunc['db_free_result']($request);
204 214
 
@@ -210,8 +220,9 @@  discard block
 block discarded – undo
210 220
 	{
211 221
 		$_POST['custom_subject'] = strtr($smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['custom_subject'])), array("\r" => '', "\n" => '', "\t" => ''));
212 222
 		// Keep checking the length.
213
-		if ($smcFunc['strlen']($_POST['custom_subject']) > 100)
214
-			$_POST['custom_subject'] = $smcFunc['substr']($_POST['custom_subject'], 0, 100);
223
+		if ($smcFunc['strlen']($_POST['custom_subject']) > 100) {
224
+					$_POST['custom_subject'] = $smcFunc['substr']($_POST['custom_subject'], 0, 100);
225
+		}
215 226
 
216 227
 		// If it's still valid move onwards and upwards.
217 228
 		if ($_POST['custom_subject'] != '')
@@ -221,9 +232,9 @@  discard block
 block discarded – undo
221 232
 				// Get a response prefix, but in the forum's default language.
222 233
 				if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix')))
223 234
 				{
224
-					if ($language === $user_info['language'])
225
-						$context['response_prefix'] = $txt['response_prefix'];
226
-					else
235
+					if ($language === $user_info['language']) {
236
+											$context['response_prefix'] = $txt['response_prefix'];
237
+					} else
227 238
 					{
228 239
 						loadLanguage('index', $language, false);
229 240
 						$context['response_prefix'] = $txt['response_prefix'];
@@ -263,8 +274,9 @@  discard block
 block discarded – undo
263 274
 	if (isset($_POST['postRedirect']))
264 275
 	{
265 276
 		// Should be in the boardwide language.
266
-		if ($user_info['language'] != $language)
267
-			loadLanguage('index', $language);
277
+		if ($user_info['language'] != $language) {
278
+					loadLanguage('index', $language);
279
+		}
268 280
 
269 281
 		$_POST['reason'] = $smcFunc['htmlspecialchars']($_POST['reason'], ENT_QUOTES);
270 282
 		preparsecode($_POST['reason']);
@@ -328,8 +340,9 @@  discard block
 block discarded – undo
328 340
 		$posters = array();
329 341
 		while ($row = $smcFunc['db_fetch_assoc']($request))
330 342
 		{
331
-			if (!isset($posters[$row['id_member']]))
332
-				$posters[$row['id_member']] = 0;
343
+			if (!isset($posters[$row['id_member']])) {
344
+							$posters[$row['id_member']] = 0;
345
+			}
333 346
 
334 347
 			$posters[$row['id_member']]++;
335 348
 		}
@@ -338,11 +351,13 @@  discard block
 block discarded – undo
338 351
 		foreach ($posters as $id_member => $posts)
339 352
 		{
340 353
 			// The board we're moving from counted posts, but not to.
341
-			if (empty($pcounter_from))
342
-				updateMemberData($id_member, array('posts' => 'posts - ' . $posts));
354
+			if (empty($pcounter_from)) {
355
+							updateMemberData($id_member, array('posts' => 'posts - ' . $posts));
356
+			}
343 357
 			// The reverse: from didn't, to did.
344
-			else
345
-				updateMemberData($id_member, array('posts' => 'posts + ' . $posts));
358
+			else {
359
+							updateMemberData($id_member, array('posts' => 'posts + ' . $posts));
360
+			}
346 361
 		}
347 362
 	}
348 363
 
@@ -350,19 +365,21 @@  discard block
 block discarded – undo
350 365
 	moveTopics($topic, $_POST['toboard']);
351 366
 
352 367
 	// Log that they moved this topic.
353
-	if (!allowedTo('move_own') || $id_member_started != $user_info['id'])
354
-		logAction('move', array('topic' => $topic, 'board_from' => $board, 'board_to' => $_POST['toboard']));
368
+	if (!allowedTo('move_own') || $id_member_started != $user_info['id']) {
369
+			logAction('move', array('topic' => $topic, 'board_from' => $board, 'board_to' => $_POST['toboard']));
370
+	}
355 371
 	// Notify people that this topic has been moved?
356 372
 	sendNotifications($topic, 'move');
357 373
 	
358 374
 	call_integration_hook('integrate_movetopic2_end');
359 375
 
360 376
 	// Why not go back to the original board in case they want to keep moving?
361
-	if (!isset($_REQUEST['goback']))
362
-		redirectexit('board=' . $board . '.0');
363
-	else
364
-		redirectexit('topic=' . $topic . '.0');
365
-}
377
+	if (!isset($_REQUEST['goback'])) {
378
+			redirectexit('board=' . $board . '.0');
379
+	} else {
380
+			redirectexit('topic=' . $topic . '.0');
381
+	}
382
+	}
366 383
 
367 384
 /**
368 385
  * Moves one or more topics to a specific board. (doesn't check permissions.)
@@ -378,18 +395,21 @@  discard block
 block discarded – undo
378 395
 	global $sourcedir, $user_info, $modSettings, $smcFunc;
379 396
 
380 397
 	// Empty array?
381
-	if (empty($topics))
382
-		return;
398
+	if (empty($topics)) {
399
+			return;
400
+	}
383 401
 
384 402
 	// Only a single topic.
385
-	if (is_numeric($topics))
386
-		$topics = array($topics);
403
+	if (is_numeric($topics)) {
404
+			$topics = array($topics);
405
+	}
387 406
 
388 407
 	$fromBoards = array();
389 408
 
390 409
 	// Destination board empty or equal to 0?
391
-	if (empty($toBoard))
392
-		return;
410
+	if (empty($toBoard)) {
411
+			return;
412
+	}
393 413
 
394 414
 	// Are we moving to the recycle board?
395 415
 	$isRecycleDest = !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] == $toBoard;
@@ -397,8 +417,9 @@  discard block
 block discarded – undo
397 417
 	// Callback for search APIs to do their thing
398 418
 	require_once($sourcedir . '/Search.php');
399 419
 	$searchAPI = findSearchAPI();
400
-	if ($searchAPI->supportsMethod('topicsMoved'))
401
-		$searchAPI->topicsMoved($topics, $toBoard);
420
+	if ($searchAPI->supportsMethod('topicsMoved')) {
421
+			$searchAPI->topicsMoved($topics, $toBoard);
422
+	}
402 423
 
403 424
 	// Determine the source boards...
404 425
 	$request = $smcFunc['db_query']('', '
@@ -412,8 +433,9 @@  discard block
 block discarded – undo
412 433
 		)
413 434
 	);
414 435
 	// Num of rows = 0 -> no topics found. Num of rows > 1 -> topics are on multiple boards.
415
-	if ($smcFunc['db_num_rows']($request) == 0)
416
-		return;
436
+	if ($smcFunc['db_num_rows']($request) == 0) {
437
+			return;
438
+	}
417 439
 	while ($row = $smcFunc['db_fetch_assoc']($request))
418 440
 	{
419 441
 		if (!isset($fromBoards[$row['id_board']]['num_posts']))
@@ -431,10 +453,11 @@  discard block
 block discarded – undo
431 453
 		$fromBoards[$row['id_board']]['unapproved_posts'] += $row['unapproved_posts'];
432 454
 
433 455
 		// Add the topics to the right type.
434
-		if ($row['approved'])
435
-			$fromBoards[$row['id_board']]['num_topics'] += $row['num_topics'];
436
-		else
437
-			$fromBoards[$row['id_board']]['unapproved_topics'] += $row['num_topics'];
456
+		if ($row['approved']) {
457
+					$fromBoards[$row['id_board']]['num_topics'] += $row['num_topics'];
458
+		} else {
459
+					$fromBoards[$row['id_board']]['unapproved_topics'] += $row['num_topics'];
460
+		}
438 461
 	}
439 462
 	$smcFunc['db_free_result']($request);
440 463
 
@@ -560,13 +583,14 @@  discard block
 block discarded – undo
560 583
 			)
561 584
 		);
562 585
 		$approval_msgs = array();
563
-		while ($row = $smcFunc['db_fetch_assoc']($request))
564
-			$approval_msgs[] = $row['id_msg'];
586
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
587
+					$approval_msgs[] = $row['id_msg'];
588
+		}
565 589
 		$smcFunc['db_free_result']($request);
566 590
 
567 591
 		// Empty the approval queue for these, as we're going to approve them next.
568
-		if (!empty($approval_msgs))
569
-			$smcFunc['db_query']('', '
592
+		if (!empty($approval_msgs)) {
593
+					$smcFunc['db_query']('', '
570 594
 				DELETE FROM {db_prefix}approval_queue
571 595
 				WHERE id_msg IN ({array_int:message_list})
572 596
 					AND id_attach = {int:id_attach}',
@@ -575,6 +599,7 @@  discard block
 block discarded – undo
575 599
 					'id_attach' => 0,
576 600
 				)
577 601
 			);
602
+		}
578 603
 
579 604
 		// Get all the current max and mins.
580 605
 		$request = $smcFunc['db_query']('', '
@@ -608,8 +633,8 @@  discard block
 block discarded – undo
608 633
 		while ($row = $smcFunc['db_fetch_assoc']($request))
609 634
 		{
610 635
 			// If not, update.
611
-			if ($row['first_msg'] != $topicMaxMin[$row['id_topic']]['min'] || $row['last_msg'] != $topicMaxMin[$row['id_topic']]['max'])
612
-				$smcFunc['db_query']('', '
636
+			if ($row['first_msg'] != $topicMaxMin[$row['id_topic']]['min'] || $row['last_msg'] != $topicMaxMin[$row['id_topic']]['max']) {
637
+							$smcFunc['db_query']('', '
613 638
 					UPDATE {db_prefix}topics
614 639
 					SET id_first_msg = {int:first_msg}, id_last_msg = {int:last_msg}
615 640
 					WHERE id_topic = {int:selected_topic}',
@@ -619,6 +644,7 @@  discard block
 block discarded – undo
619 644
 						'selected_topic' => $row['id_topic'],
620 645
 					)
621 646
 				);
647
+			}
622 648
 		}
623 649
 		$smcFunc['db_free_result']($request);
624 650
 	}
@@ -677,9 +703,10 @@  discard block
 block discarded – undo
677 703
 	}
678 704
 
679 705
 	// Update the cache?
680
-	if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 3)
681
-		foreach ($topics as $topic_id)
706
+	if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 3) {
707
+			foreach ($topics as $topic_id)
682 708
 			cache_put_data('topic_board-' . $topic_id, null, 120);
709
+	}
683 710
 
684 711
 	require_once($sourcedir . '/Subs-Post.php');
685 712
 
@@ -703,15 +730,17 @@  discard block
 block discarded – undo
703 730
 {
704 731
 	global $board, $topic, $smcFunc, $scripturl;
705 732
 
706
-	if (isset($_GET['current_board']))
707
-		$move_from = (int) $_GET['current_board'];
733
+	if (isset($_GET['current_board'])) {
734
+			$move_from = (int) $_GET['current_board'];
735
+	}
708 736
 
709
-	if (empty($move_from) || empty($board) || empty($topic))
710
-		return true;
737
+	if (empty($move_from) || empty($board) || empty($topic)) {
738
+			return true;
739
+	}
711 740
 
712
-	if ($move_from == $board)
713
-		return true;
714
-	else
741
+	if ($move_from == $board) {
742
+			return true;
743
+	} else
715 744
 	{
716 745
 		$request = $smcFunc['db_query']('', '
717 746
 			SELECT m.subject, b.name
Please login to merge, or discard this patch.
Sources/ManageErrors.php 1 patch
Braces   +52 added lines, -40 removed lines patch added patch discarded remove patch
@@ -14,8 +14,9 @@  discard block
 block discarded – undo
14 14
  * @version 2.1 Beta 4
15 15
  */
16 16
 
17
-if (!defined('SMF'))
17
+if (!defined('SMF')) {
18 18
 	die('No direct access...');
19
+}
19 20
 
20 21
 /**
21 22
  * View the forum's error log.
@@ -30,12 +31,14 @@  discard block
 block discarded – undo
30 31
 	global $scripturl, $txt, $context, $modSettings, $user_profile, $filter, $smcFunc;
31 32
 
32 33
 	// Viewing contents of a file?
33
-	if (isset($_GET['file']))
34
-		return ViewFile();
34
+	if (isset($_GET['file'])) {
35
+			return ViewFile();
36
+	}
35 37
 	
36 38
 	// Viewing contents of a backtrace?
37
-	if (isset($_GET['backtrace']))
38
-		return ViewBacktrace();
39
+	if (isset($_GET['backtrace'])) {
40
+			return ViewBacktrace();
41
+	}
39 42
 
40 43
 	// Check for the administrative permission to do this.
41 44
 	isAllowedTo('admin_forum');
@@ -89,8 +92,8 @@  discard block
 block discarded – undo
89 92
 	);
90 93
 
91 94
 	// Set up the filtering...
92
-	if (isset($_GET['value'], $_GET['filter']) && isset($filters[$_GET['filter']]))
93
-		$filter = array(
95
+	if (isset($_GET['value'], $_GET['filter']) && isset($filters[$_GET['filter']])) {
96
+			$filter = array(
94 97
 			'variable' => $_GET['filter'],
95 98
 			'value' => array(
96 99
 				'sql' => in_array($_GET['filter'], array('message', 'url', 'file')) ? base64_decode(strtr($_GET['value'], array(' ' => '+'))) : $smcFunc['db_escape_wildcard_string']($_GET['value']),
@@ -98,10 +101,12 @@  discard block
 block discarded – undo
98 101
 			'href' => ';filter=' . $_GET['filter'] . ';value=' . $_GET['value'],
99 102
 			'entity' => $filters[$_GET['filter']]['txt']
100 103
 		);
104
+	}
101 105
 
102 106
 	// Deleting, are we?
103
-	if (isset($_POST['delall']) || isset($_POST['delete']))
104
-		deleteErrors();
107
+	if (isset($_POST['delall']) || isset($_POST['delete'])) {
108
+			deleteErrors();
109
+	}
105 110
 
106 111
 	// Just how many errors are there?
107 112
 	$result = $smcFunc['db_query']('', '
@@ -116,12 +121,14 @@  discard block
 block discarded – undo
116 121
 	$smcFunc['db_free_result']($result);
117 122
 
118 123
 	// If this filter is empty...
119
-	if ($num_errors == 0 && isset($filter))
120
-		redirectexit('action=admin;area=logs;sa=errorlog' . (isset($_REQUEST['desc']) ? ';desc' : ''));
124
+	if ($num_errors == 0 && isset($filter)) {
125
+			redirectexit('action=admin;area=logs;sa=errorlog' . (isset($_REQUEST['desc']) ? ';desc' : ''));
126
+	}
121 127
 
122 128
 	// Clean up start.
123
-	if (!isset($_GET['start']) || $_GET['start'] < 0)
124
-		$_GET['start'] = 0;
129
+	if (!isset($_GET['start']) || $_GET['start'] < 0) {
130
+			$_GET['start'] = 0;
131
+	}
125 132
 
126 133
 	// Do we want to reverse error listing?
127 134
 	$context['sort_direction'] = isset($_REQUEST['desc']) ? 'down' : 'up';
@@ -131,9 +138,9 @@  discard block
 block discarded – undo
131 138
 	$context['start'] = $_GET['start'];
132 139
 
133 140
 	// Update the error count
134
-	if (!isset($filter))
135
-		$context['num_errors'] = $num_errors;
136
-	else
141
+	if (!isset($filter)) {
142
+			$context['num_errors'] = $num_errors;
143
+	} else
137 144
 	{
138 145
 		// We want all errors, not just the number of filtered messages...
139 146
 		$query = $smcFunc['db_query']('', '
@@ -165,8 +172,9 @@  discard block
 block discarded – undo
165 172
 	for ($i = 0; $row = $smcFunc['db_fetch_assoc']($request); $i++)
166 173
 	{
167 174
 		$search_message = preg_replace('~&lt;span class=&quot;remove&quot;&gt;(.+?)&lt;/span&gt;~', '%', $smcFunc['db_escape_wildcard_string']($row['message']));
168
-		if ($search_message == $filter['value']['sql'])
169
-			$search_message = $smcFunc['db_escape_wildcard_string']($row['message']);
175
+		if ($search_message == $filter['value']['sql']) {
176
+					$search_message = $smcFunc['db_escape_wildcard_string']($row['message']);
177
+		}
170 178
 		$show_message = strtr(strtr(preg_replace('~&lt;span class=&quot;remove&quot;&gt;(.+?)&lt;/span&gt;~', '$1', $row['message']), array("\r" => '', '<br>' => "\n", '<' => '&lt;', '>' => '&gt;', '"' => '&quot;')), array("\n" => '<br>'));
171 179
 
172 180
 		$context['errors'][$row['id_error']] = array(
@@ -225,8 +233,9 @@  discard block
 block discarded – undo
225 233
 				'members' => count($members),
226 234
 			)
227 235
 		);
228
-		while ($row = $smcFunc['db_fetch_assoc']($request))
229
-			$members[$row['id_member']] = $row;
236
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
237
+					$members[$row['id_member']] = $row;
238
+		}
230 239
 		$smcFunc['db_free_result']($request);
231 240
 
232 241
 		// This is a guest...
@@ -258,20 +267,18 @@  discard block
 block discarded – undo
258 267
 			$id = $filter['value']['sql'];
259 268
 			loadMemberData($id, false, 'minimal');
260 269
 			$context['filter']['value']['html'] = '<a href="' . $scripturl . '?action=profile;u=' . $id . '">' . $user_profile[$id]['real_name'] . '</a>';
261
-		}
262
-		elseif ($filter['variable'] == 'url')
263
-			$context['filter']['value']['html'] = '\'' . strtr($smcFunc['htmlspecialchars']((substr($filter['value']['sql'], 0, 1) == '?' ? $scripturl : '') . $filter['value']['sql']), array('\_' => '_')) . '\'';
264
-		elseif ($filter['variable'] == 'message')
270
+		} elseif ($filter['variable'] == 'url') {
271
+					$context['filter']['value']['html'] = '\'' . strtr($smcFunc['htmlspecialchars']((substr($filter['value']['sql'], 0, 1) == '?' ? $scripturl : '') . $filter['value']['sql']), array('\_' => '_')) . '\'';
272
+		} elseif ($filter['variable'] == 'message')
265 273
 		{
266 274
 			$context['filter']['value']['html'] = '\'' . strtr($smcFunc['htmlspecialchars']($filter['value']['sql']), array("\n" => '<br>', '&lt;br /&gt;' => '<br>', "\t" => '&nbsp;&nbsp;&nbsp;', '\_' => '_', '\\%' => '%', '\\\\' => '\\')) . '\'';
267 275
 			$context['filter']['value']['html'] = preg_replace('~&amp;lt;span class=&amp;quot;remove&amp;quot;&amp;gt;(.+?)&amp;lt;/span&amp;gt;~', '$1', $context['filter']['value']['html']);
268
-		}
269
-		elseif ($filter['variable'] == 'error_type')
276
+		} elseif ($filter['variable'] == 'error_type')
270 277
 		{
271 278
 			$context['filter']['value']['html'] = '\'' . strtr($smcFunc['htmlspecialchars']($filter['value']['sql']), array("\n" => '<br>', '&lt;br /&gt;' => '<br>', "\t" => '&nbsp;&nbsp;&nbsp;', '\_' => '_', '\\%' => '%', '\\\\' => '\\')) . '\'';
279
+		} else {
280
+					$context['filter']['value']['html'] = &$filter['value']['sql'];
272 281
 		}
273
-		else
274
-			$context['filter']['value']['html'] = &$filter['value']['sql'];
275 282
 	}
276 283
 
277 284
 	$context['error_types'] = array();
@@ -312,10 +319,11 @@  discard block
 block discarded – undo
312 319
 	$context['error_types']['all']['label'] .= ' (' . $sum . ')';
313 320
 
314 321
 	// Finally, work out what is the last tab!
315
-	if (isset($context['error_types'][$sum]))
316
-		$context['error_types'][$sum]['is_last'] = true;
317
-	else
318
-		$context['error_types']['all']['is_last'] = true;
322
+	if (isset($context['error_types'][$sum])) {
323
+			$context['error_types'][$sum]['is_last'] = true;
324
+	} else {
325
+			$context['error_types']['all']['is_last'] = true;
326
+	}
319 327
 
320 328
 	// And this is pretty basic ;).
321 329
 	$context['page_title'] = $txt['errlog'];
@@ -341,21 +349,23 @@  discard block
 block discarded – undo
341 349
 	validateToken('admin-el');
342 350
 
343 351
 	// Delete all or just some?
344
-	if (isset($_POST['delall']) && !isset($filter))
345
-		$smcFunc['db_query']('truncate_table', '
352
+	if (isset($_POST['delall']) && !isset($filter)) {
353
+			$smcFunc['db_query']('truncate_table', '
346 354
 			TRUNCATE {db_prefix}log_errors',
347 355
 			array(
348 356
 			)
349 357
 		);
358
+	}
350 359
 	// Deleting all with a filter?
351
-	elseif (isset($_POST['delall']) && isset($filter))
352
-		$smcFunc['db_query']('', '
360
+	elseif (isset($_POST['delall']) && isset($filter)) {
361
+			$smcFunc['db_query']('', '
353 362
 			DELETE FROM {db_prefix}log_errors
354 363
 			WHERE ' . $filter['variable'] . ' LIKE {string:filter}',
355 364
 			array(
356 365
 				'filter' => $filter['value']['sql'],
357 366
 			)
358 367
 		);
368
+	}
359 369
 	// Just specific errors?
360 370
 	elseif (!empty($_POST['delete']))
361 371
 	{
@@ -401,15 +411,17 @@  discard block
 block discarded – undo
401 411
 	$line = isset($_REQUEST['line']) ? (int) $_REQUEST['line'] : 0;
402 412
 
403 413
 	// Make sure the file we are looking for is one they are allowed to look at
404
-	if ($ext != '.php' || (strpos($file, $real_board) === false && strpos($file, $real_source) === false) || ($basename == 'settings.php' || $basename == 'settings_bak.php') || strpos($file, $real_cache) !== false || !is_readable($file))
405
-		fatal_lang_error('error_bad_file', true, array($smcFunc['htmlspecialchars']($file)));
414
+	if ($ext != '.php' || (strpos($file, $real_board) === false && strpos($file, $real_source) === false) || ($basename == 'settings.php' || $basename == 'settings_bak.php') || strpos($file, $real_cache) !== false || !is_readable($file)) {
415
+			fatal_lang_error('error_bad_file', true, array($smcFunc['htmlspecialchars']($file)));
416
+	}
406 417
 
407 418
 	// get the min and max lines
408 419
 	$min = $line - 20 <= 0 ? 1 : $line - 20;
409 420
 	$max = $line + 21; // One additional line to make everything work out correctly
410 421
 
411
-	if ($max <= 0 || $min >= $max)
412
-		fatal_lang_error('error_bad_line');
422
+	if ($max <= 0 || $min >= $max) {
423
+			fatal_lang_error('error_bad_line');
424
+	}
413 425
 
414 426
 	$file_data = explode('<br />', highlight_php_code($smcFunc['htmlspecialchars'](implode('', file($file)))));
415 427
 
Please login to merge, or discard this patch.