Completed
Pull Request — release-2.1 (#4447)
by Martyn
25:10 queued 13:13
created
Sources/tasks/MemberReportReply-Notify.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@
 block discarded – undo
20 20
 class MemberReportReply_Notify_Background extends SMF_BackgroundTask
21 21
 {
22 22
 	/**
23
-     * This executes the task - loads up the information, puts the email in the queue and inserts alerts as needed.
23
+	 * This executes the task - loads up the information, puts the email in the queue and inserts alerts as needed.
24 24
 	 * @return bool Always returns true.
25 25
 	 */
26 26
 	public function execute()
Please login to merge, or discard this patch.
Braces   +15 added lines, -10 removed lines patch added patch discarded remove patch
@@ -40,8 +40,9 @@  discard block
 block discarded – undo
40 40
 				'last_comment' => $this->_details['comment_id'],
41 41
 			)
42 42
 		);
43
-		while ($row = $smcFunc['db_fetch_row']($request))
44
-			$possible_members[] = $row[0];
43
+		while ($row = $smcFunc['db_fetch_row']($request)) {
44
+					$possible_members[] = $row[0];
45
+		}
45 46
 		$smcFunc['db_free_result']($request);
46 47
 
47 48
 		// Presumably, there are some people?
@@ -50,8 +51,9 @@  discard block
 block discarded – undo
50 51
 			$possible_members = array_flip(array_flip($possible_members));
51 52
 			$possible_members = array_diff($possible_members, array($this->_details['sender_id']));
52 53
 		}
53
-		if (empty($possible_members))
54
-			return true;
54
+		if (empty($possible_members)) {
55
+					return true;
56
+		}
55 57
 
56 58
 		// We need to know who can moderate this board - and therefore who can see this report.
57 59
 		// First up, people who have moderate_board in the board this topic was in.
@@ -73,8 +75,9 @@  discard block
 block discarded – undo
73 75
 		{
74 76
 			foreach ($alert_bits as $type => $bitvalue)
75 77
 			{
76
-				if ($pref_option['member_report_reply'] & $bitvalue)
77
-					$notifies[$type][] = $member;
78
+				if ($pref_option['member_report_reply'] & $bitvalue) {
79
+									$notifies[$type][] = $member;
80
+				}
78 81
 			}
79 82
 		}
80 83
 
@@ -136,8 +139,9 @@  discard block
 block discarded – undo
136 139
 			);
137 140
 			while ($row = $smcFunc['db_fetch_assoc']($request))
138 141
 			{
139
-				if (empty($row['lngfile']))
140
-					$row['lngfile'] = $language;
142
+				if (empty($row['lngfile'])) {
143
+									$row['lngfile'] = $language;
144
+				}
141 145
 				$emails[$row['lngfile']][$row['id_member']] = $row['email_address'];
142 146
 			}
143 147
 			$smcFunc['db_free_result']($request);
@@ -155,8 +159,9 @@  discard block
 block discarded – undo
155 159
 				$emaildata = loadEmailTemplate('reply_to_user_reports', $replacements, empty($modSettings['userLanguage']) ? $language : $this_lang);
156 160
 
157 161
 				// And do the actual sending...
158
-				foreach ($recipients as $id_member => $email_address)
159
-					sendmail($email_address, $emaildata['subject'], $emaildata['body'], null, 'urptrpy' . $this->_details['comment_id'], $emaildata['is_html'], 3);
162
+				foreach ($recipients as $id_member => $email_address) {
163
+									sendmail($email_address, $emaildata['subject'], $emaildata['body'], null, 'urptrpy' . $this->_details['comment_id'], $emaildata['is_html'], 3);
164
+				}
160 165
 			}
161 166
 		}
162 167
 
Please login to merge, or discard this patch.
Sources/tasks/ApproveReply-Notify.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@
 block discarded – undo
18 18
 class ApproveReply_Notify_Background extends SMF_BackgroundTask
19 19
 {
20 20
 	/**
21
-     * This executes the task - loads up the information, puts the email in the queue and inserts alerts.
21
+	 * This executes the task - loads up the information, puts the email in the queue and inserts alerts.
22 22
 	 * @return bool Always returns true.
23 23
 	 */
24 24
 	public function execute()
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -96,14 +96,15 @@
 block discarded – undo
96 96
 		}
97 97
 
98 98
 		// Insert the alerts if any
99
-		if (!empty($alert_rows))
100
-			$smcFunc['db_insert']('',
99
+		if (!empty($alert_rows)) {
100
+					$smcFunc['db_insert']('',
101 101
 				'{db_prefix}user_alerts',
102 102
 				array('alert_time' => 'int', 'id_member' => 'int', 'id_member_started' => 'int', 'member_name' => 'string',
103 103
 					'content_type' => 'string', 'content_id' => 'int', 'content_action' => 'string', 'is_read' => 'int', 'extra' => 'string'),
104 104
 				$alert_rows,
105 105
 				array()
106 106
 			);
107
+		}
107 108
 
108 109
 		return true;
109 110
 	}
Please login to merge, or discard this patch.
Sources/tasks/GroupReq-Notify.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@
 block discarded – undo
20 20
 class GroupReq_Notify_Background extends SMF_BackgroundTask
21 21
 {
22 22
 	/**
23
-     * This executes the task - loads up the information, puts the email in the queue and inserts any alerts as needed.
23
+	 * This executes the task - loads up the information, puts the email in the queue and inserts any alerts as needed.
24 24
 	 * @return bool Always returns true.
25 25
 	 */
26 26
 	public function execute()
Please login to merge, or discard this patch.
Braces   +9 added lines, -6 removed lines patch added patch discarded remove patch
@@ -37,8 +37,9 @@  discard block
 block discarded – undo
37 37
 			)
38 38
 		);
39 39
 		$moderators = array();
40
-		while ($row = $smcFunc['db_fetch_assoc']($request))
41
-			$moderators[] = $row['id_member'];
40
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
41
+					$moderators[] = $row['id_member'];
42
+		}
42 43
 		$smcFunc['db_free_result']($request);
43 44
 
44 45
 		require_once($sourcedir . '/Subs-Members.php');
@@ -59,11 +60,13 @@  discard block
 block discarded – undo
59 60
 			{
60 61
 				if (!empty($prefs[$mod]['request_group']))
61 62
 				{
62
-					if ($prefs[$mod]['request_group'] & 0x01)
63
-						$data['alert'][] = $mod;
63
+					if ($prefs[$mod]['request_group'] & 0x01) {
64
+											$data['alert'][] = $mod;
65
+					}
64 66
 
65
-					if ($prefs[$mod]['request_group'] & 0x02)
66
-						$data['email'][] = $mod;
67
+					if ($prefs[$mod]['request_group'] & 0x02) {
68
+											$data['email'][] = $mod;
69
+					}
67 70
 				}
68 71
 			}
69 72
 
Please login to merge, or discard this patch.
Sources/Calendar.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -240,8 +240,8 @@
 block discarded – undo
240 240
 		$time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]);
241 241
 
242 242
 	$js_time_string = str_replace(
243
-		array('%H', '%k', '%I', '%l', '%M', '%p', '%P', '%r',      '%R',  '%S', '%T',    '%X'),
244
-		array('H',  'G',  'h',  'g',  'i',  'A',  'a',  'h:i:s A', 'H:i', 's',  'H:i:s', 'H:i:s'),
243
+		array('%H', '%k', '%I', '%l', '%M', '%p', '%P', '%r', '%R', '%S', '%T', '%X'),
244
+		array('H', 'G', 'h', 'g', 'i', 'A', 'a', 'h:i:s A', 'H:i', 's', 'H:i:s', 'H:i:s'),
245 245
 		$time_string
246 246
 	);
247 247
 
Please login to merge, or discard this patch.
Braces   +122 added lines, -97 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
  * Show the calendar.
@@ -47,12 +48,14 @@  discard block
 block discarded – undo
47 48
 		'post' => 'CalendarPost',
48 49
 	);
49 50
 
50
-	if (isset($_GET['sa']) && isset($subActions[$_GET['sa']]))
51
-		return call_helper($subActions[$_GET['sa']]);
51
+	if (isset($_GET['sa']) && isset($subActions[$_GET['sa']])) {
52
+			return call_helper($subActions[$_GET['sa']]);
53
+	}
52 54
 
53 55
 	// You can't do anything if the calendar is off.
54
-	if (empty($modSettings['cal_enabled']))
55
-		fatal_lang_error('calendar_off', false);
56
+	if (empty($modSettings['cal_enabled'])) {
57
+			fatal_lang_error('calendar_off', false);
58
+	}
56 59
 
57 60
 	// This is gonna be needed...
58 61
 	loadTemplate('Calendar');
@@ -88,22 +91,25 @@  discard block
 block discarded – undo
88 91
 	$context['page_title'] = $txt['calendar'];
89 92
 
90 93
 	// Ensure a default view is defined
91
-	if (empty($modSettings['calendar_default_view']))
92
-		$modSettings['calendar_default_view'] = 'viewlist';
94
+	if (empty($modSettings['calendar_default_view'])) {
95
+			$modSettings['calendar_default_view'] = 'viewlist';
96
+	}
93 97
 
94 98
 	// What view do we want?
95
-	if (isset($_GET['viewweek']))
96
-		$context['calendar_view'] = 'viewweek';
97
-	elseif (isset($_GET['viewmonth']))
98
-		$context['calendar_view'] = 'viewmonth';
99
-	elseif (isset($_GET['viewlist']))
100
-		$context['calendar_view'] = 'viewlist';
101
-	else
102
-		$context['calendar_view'] = $modSettings['calendar_default_view'];
99
+	if (isset($_GET['viewweek'])) {
100
+			$context['calendar_view'] = 'viewweek';
101
+	} elseif (isset($_GET['viewmonth'])) {
102
+			$context['calendar_view'] = 'viewmonth';
103
+	} elseif (isset($_GET['viewlist'])) {
104
+			$context['calendar_view'] = 'viewlist';
105
+	} else {
106
+			$context['calendar_view'] = $modSettings['calendar_default_view'];
107
+	}
103 108
 
104 109
 	// Don't let search engines index the non-default calendar pages
105
-	if ($context['calendar_view'] !== $modSettings['calendar_default_view'])
106
-		$context['robot_no_index'] = true;
110
+	if ($context['calendar_view'] !== $modSettings['calendar_default_view']) {
111
+			$context['robot_no_index'] = true;
112
+	}
107 113
 
108 114
 	// Get the current day of month...
109 115
 	require_once($sourcedir . '/Subs-Calendar.php');
@@ -164,16 +170,19 @@  discard block
 block discarded – undo
164 170
 	);
165 171
 
166 172
 	// Make sure the year and month are in valid ranges.
167
-	if ($curPage['month'] < 1 || $curPage['month'] > 12)
168
-		fatal_lang_error('invalid_month', false);
169
-	if ($curPage['year'] < $modSettings['cal_minyear'] || $curPage['year'] > $modSettings['cal_maxyear'])
170
-		fatal_lang_error('invalid_year', false);
173
+	if ($curPage['month'] < 1 || $curPage['month'] > 12) {
174
+			fatal_lang_error('invalid_month', false);
175
+	}
176
+	if ($curPage['year'] < $modSettings['cal_minyear'] || $curPage['year'] > $modSettings['cal_maxyear']) {
177
+			fatal_lang_error('invalid_year', false);
178
+	}
171 179
 	// If we have a day clean that too.
172 180
 	if ($context['calendar_view'] != 'viewmonth')
173 181
 	{
174 182
 		$isValid = checkdate($curPage['month'], $curPage['day'], $curPage['year']);
175
-		if (!$isValid)
176
-			fatal_lang_error('invalid_day', false);
183
+		if (!$isValid) {
184
+					fatal_lang_error('invalid_day', false);
185
+		}
177 186
 	}
178 187
 
179 188
 	// Load all the context information needed to show the calendar grid.
@@ -195,23 +204,26 @@  discard block
 block discarded – undo
195 204
 	);
196 205
 
197 206
 	// Load up the main view.
198
-	if ($context['calendar_view'] == 'viewlist')
199
-		$context['calendar_grid_main'] = getCalendarList($curPage['start_date'], $curPage['end_date'], $calendarOptions);
200
-	elseif ($context['calendar_view'] == 'viewweek')
201
-		$context['calendar_grid_main'] = getCalendarWeek($curPage['month'], $curPage['year'], $curPage['day'], $calendarOptions);
202
-	else
203
-		$context['calendar_grid_main'] = getCalendarGrid($curPage['month'], $curPage['year'], $calendarOptions);
207
+	if ($context['calendar_view'] == 'viewlist') {
208
+			$context['calendar_grid_main'] = getCalendarList($curPage['start_date'], $curPage['end_date'], $calendarOptions);
209
+	} elseif ($context['calendar_view'] == 'viewweek') {
210
+			$context['calendar_grid_main'] = getCalendarWeek($curPage['month'], $curPage['year'], $curPage['day'], $calendarOptions);
211
+	} else {
212
+			$context['calendar_grid_main'] = getCalendarGrid($curPage['month'], $curPage['year'], $calendarOptions);
213
+	}
204 214
 
205 215
 	// Load up the previous and next months.
206 216
 	$context['calendar_grid_current'] = getCalendarGrid($curPage['month'], $curPage['year'], $calendarOptions);
207 217
 
208 218
 	// Only show previous month if it isn't pre-January of the min-year
209
-	if ($context['calendar_grid_current']['previous_calendar']['year'] > $modSettings['cal_minyear'] || $curPage['month'] != 1)
210
-		$context['calendar_grid_prev'] = getCalendarGrid($context['calendar_grid_current']['previous_calendar']['month'], $context['calendar_grid_current']['previous_calendar']['year'], $calendarOptions, true);
219
+	if ($context['calendar_grid_current']['previous_calendar']['year'] > $modSettings['cal_minyear'] || $curPage['month'] != 1) {
220
+			$context['calendar_grid_prev'] = getCalendarGrid($context['calendar_grid_current']['previous_calendar']['month'], $context['calendar_grid_current']['previous_calendar']['year'], $calendarOptions, true);
221
+	}
211 222
 
212 223
 	// Only show next month if it isn't post-December of the max-year
213
-	if ($context['calendar_grid_current']['next_calendar']['year'] < $modSettings['cal_maxyear'] || $curPage['month'] != 12)
214
-		$context['calendar_grid_next'] = getCalendarGrid($context['calendar_grid_current']['next_calendar']['month'], $context['calendar_grid_current']['next_calendar']['year'], $calendarOptions);
224
+	if ($context['calendar_grid_current']['next_calendar']['year'] < $modSettings['cal_maxyear'] || $curPage['month'] != 12) {
225
+			$context['calendar_grid_next'] = getCalendarGrid($context['calendar_grid_current']['next_calendar']['month'], $context['calendar_grid_current']['next_calendar']['year'], $calendarOptions);
226
+	}
215 227
 
216 228
 	// Basic template stuff.
217 229
 	$context['allow_calendar_event'] = allowedTo('calendar_post');
@@ -231,8 +243,9 @@  discard block
 block discarded – undo
231 243
 	$context['blocks_disabled'] = !empty($modSettings['cal_disable_prev_next']) ? 1 : 0;
232 244
 
233 245
 	// Set the page title to mention the month or week, too
234
-	if ($context['calendar_view'] != 'viewlist')
235
-		$context['page_title'] .= ' - ' . ($context['calendar_view'] == 'viewweek' ? $context['calendar_grid_main']['week_title'] : $txt['months'][$context['current_month']] . ' ' . $context['current_year']);
246
+	if ($context['calendar_view'] != 'viewlist') {
247
+			$context['page_title'] .= ' - ' . ($context['calendar_view'] == 'viewweek' ? $context['calendar_grid_main']['week_title'] : $txt['months'][$context['current_month']] . ' ' . $context['current_year']);
248
+	}
236 249
 
237 250
 	// Load up the linktree!
238 251
 	$context['linktree'][] = array(
@@ -245,17 +258,19 @@  discard block
 block discarded – undo
245 258
 		'name' => $txt['months'][$context['current_month']] . ' ' . $context['current_year']
246 259
 	);
247 260
 	// If applicable, add the current week to the linktree.
248
-	if ($context['calendar_view'] == 'viewweek')
249
-		$context['linktree'][] = array(
261
+	if ($context['calendar_view'] == 'viewweek') {
262
+			$context['linktree'][] = array(
250 263
 			'url' => $scripturl . '?action=calendar;viewweek;year=' . $context['current_year'] . ';month=' . $context['current_month'] . ';day=' . $context['current_day'],
251 264
 			'name' => $context['calendar_grid_main']['week_title'],
252 265
 		);
266
+	}
253 267
 
254 268
 	// Build the calendar button array.
255 269
 	$context['calendar_buttons'] = array();
256 270
 
257
-	if ($context['can_post'])
258
-		$context['calendar_buttons']['post_event'] = array('text' => 'calendar_post_event', 'image' => 'calendarpe.png', 'url' => $scripturl . '?action=calendar;sa=post;month=' . $context['current_month'] . ';year=' . $context['current_year'] . ';' . $context['session_var'] . '=' . $context['session_id']);
271
+	if ($context['can_post']) {
272
+			$context['calendar_buttons']['post_event'] = array('text' => 'calendar_post_event', 'image' => 'calendarpe.png', 'url' => $scripturl . '?action=calendar;sa=post;month=' . $context['current_month'] . ';year=' . $context['current_year'] . ';' . $context['session_var'] . '=' . $context['session_id']);
273
+	}
259 274
 
260 275
 	// Allow mods to add additional buttons here
261 276
 	call_integration_hook('integrate_calendar_buttons');
@@ -284,14 +299,16 @@  discard block
 block discarded – undo
284 299
 	require_once($sourcedir . '/Subs.php');
285 300
 
286 301
 	// Cast this for safety...
287
-	if (isset($_REQUEST['eventid']))
288
-		$_REQUEST['eventid'] = (int) $_REQUEST['eventid'];
302
+	if (isset($_REQUEST['eventid'])) {
303
+			$_REQUEST['eventid'] = (int) $_REQUEST['eventid'];
304
+	}
289 305
 
290 306
 	// We want a fairly compact version of the time, but as close as possible to the user's settings.
291
-	if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0]))
292
-		$time_string = '%k:%M';
293
-	else
294
-		$time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]);
307
+	if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) {
308
+			$time_string = '%k:%M';
309
+	} else {
310
+			$time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]);
311
+	}
295 312
 
296 313
 	$js_time_string = str_replace(
297 314
 		array('%H', '%k', '%I', '%l', '%M', '%p', '%P', '%r',      '%R',  '%S', '%T',    '%X'),
@@ -305,12 +322,14 @@  discard block
 block discarded – undo
305 322
 		checkSession();
306 323
 
307 324
 		// Validate the post...
308
-		if (!isset($_POST['link_to_board']))
309
-			validateEventPost();
325
+		if (!isset($_POST['link_to_board'])) {
326
+					validateEventPost();
327
+		}
310 328
 
311 329
 		// If you're not allowed to edit any events, you have to be the poster.
312
-		if ($_REQUEST['eventid'] > 0 && !allowedTo('calendar_edit_any'))
313
-			isAllowedTo('calendar_edit_' . (!empty($user_info['id']) && getEventPoster($_REQUEST['eventid']) == $user_info['id'] ? 'own' : 'any'));
330
+		if ($_REQUEST['eventid'] > 0 && !allowedTo('calendar_edit_any')) {
331
+					isAllowedTo('calendar_edit_' . (!empty($user_info['id']) && getEventPoster($_REQUEST['eventid']) == $user_info['id'] ? 'own' : 'any'));
332
+		}
314 333
 
315 334
 		// New - and directing?
316 335
 		if (isset($_POST['link_to_board']) || empty($modSettings['cal_allow_unlinked']))
@@ -333,8 +352,9 @@  discard block
 block discarded – undo
333 352
 		}
334 353
 
335 354
 		// Deleting...
336
-		elseif (isset($_REQUEST['deleteevent']))
337
-			removeEvent($_REQUEST['eventid']);
355
+		elseif (isset($_REQUEST['deleteevent'])) {
356
+					removeEvent($_REQUEST['eventid']);
357
+		}
338 358
 
339 359
 		// ... or just update it?
340 360
 		else
@@ -357,15 +377,13 @@  discard block
 block discarded – undo
357 377
 			$year = $d['year'];
358 378
 			$month = $d['month'];
359 379
 			$day = $d['day'];
360
-		}
361
-		elseif (isset($_POST['start_datetime']))
380
+		} elseif (isset($_POST['start_datetime']))
362 381
 		{
363 382
 			$d = date_parse($_POST['start_datetime']);
364 383
 			$year = $d['year'];
365 384
 			$month = $d['month'];
366 385
 			$day = $d['day'];
367
-		}
368
-		else
386
+		} else
369 387
 		{
370 388
 			$today = getdate();
371 389
 			$year = isset($_POST['year']) ? $_POST['year'] : $today['year'];
@@ -399,13 +417,13 @@  discard block
 block discarded – undo
399 417
 		$context['event'] = array_merge($context['event'], $eventDatetimes);
400 418
 
401 419
 		$context['event']['last_day'] = (int) strftime('%d', mktime(0, 0, 0, $context['event']['month'] == 12 ? 1 : $context['event']['month'] + 1, 0, $context['event']['month'] == 12 ? $context['event']['year'] + 1 : $context['event']['year']));
402
-	}
403
-	else
420
+	} else
404 421
 	{
405 422
 		$context['event'] = getEventProperties($_REQUEST['eventid']);
406 423
 
407
-		if ($context['event'] === false)
408
-			fatal_lang_error('no_access', false);
424
+		if ($context['event'] === false) {
425
+					fatal_lang_error('no_access', false);
426
+		}
409 427
 
410 428
 		// If it has a board, then they should be editing it within the topic.
411 429
 		if (!empty($context['event']['topic']['id']) && !empty($context['event']['topic']['first_msg']))
@@ -416,10 +434,11 @@  discard block
 block discarded – undo
416 434
 		}
417 435
 
418 436
 		// Make sure the user is allowed to edit this event.
419
-		if ($context['event']['member'] != $user_info['id'])
420
-			isAllowedTo('calendar_edit_any');
421
-		elseif (!allowedTo('calendar_edit_any'))
422
-			isAllowedTo('calendar_edit_own');
437
+		if ($context['event']['member'] != $user_info['id']) {
438
+					isAllowedTo('calendar_edit_any');
439
+		} elseif (!allowedTo('calendar_edit_any')) {
440
+					isAllowedTo('calendar_edit_own');
441
+		}
423 442
 	}
424 443
 
425 444
 	// An all day event? Set up some nice defaults in case the user wants to change that
@@ -453,8 +472,7 @@  discard block
 block discarded – undo
453 472
 	{
454 473
 		// You can post new events but can't link them to anything...
455 474
 		$context['event']['categories'] = array();
456
-	}
457
-	else
475
+	} else
458 476
 	{
459 477
 		// Load the list of boards and categories in the context.
460 478
 		require_once($sourcedir . '/Subs-MessageIndex.php');
@@ -541,12 +559,14 @@  discard block
 block discarded – undo
541 559
 	global $smcFunc, $sourcedir, $forum_version, $modSettings, $webmaster_email, $mbname;
542 560
 
543 561
 	// You can't export if the calendar export feature is off.
544
-	if (empty($modSettings['cal_export']))
545
-		fatal_lang_error('calendar_export_off', false);
562
+	if (empty($modSettings['cal_export'])) {
563
+			fatal_lang_error('calendar_export_off', false);
564
+	}
546 565
 
547 566
 	// Goes without saying that this is required.
548
-	if (!isset($_REQUEST['eventid']))
549
-		fatal_lang_error('no_access', false);
567
+	if (!isset($_REQUEST['eventid'])) {
568
+			fatal_lang_error('no_access', false);
569
+	}
550 570
 
551 571
 	// This is kinda wanted.
552 572
 	require_once($sourcedir . '/Subs-Calendar.php');
@@ -554,15 +574,17 @@  discard block
 block discarded – undo
554 574
 	// Load up the event in question and check it exists.
555 575
 	$event = getEventProperties($_REQUEST['eventid']);
556 576
 
557
-	if ($event === false)
558
-		fatal_lang_error('no_access', false);
577
+	if ($event === false) {
578
+			fatal_lang_error('no_access', false);
579
+	}
559 580
 
560 581
 	// Check the title isn't too long - iCal requires some formatting if so.
561 582
 	$title = str_split($event['title'], 30);
562 583
 	foreach ($title as $id => $line)
563 584
 	{
564
-		if ($id != 0)
565
-			$title[$id] = ' ' . $title[$id];
585
+		if ($id != 0) {
586
+					$title[$id] = ' ' . $title[$id];
587
+		}
566 588
 		$title[$id] .= "\n";
567 589
 	}
568 590
 
@@ -575,8 +597,7 @@  discard block
 block discarded – undo
575 597
 	{
576 598
 		$datestart = date_format($start_date, 'Ymd\THis');
577 599
 		$dateend = date_format($end_date, 'Ymd\THis');
578
-	}
579
-	else
600
+	} else
580 601
 	{
581 602
 		$datestart = date_format($start_date, 'Ymd');
582 603
 
@@ -597,15 +618,18 @@  discard block
 block discarded – undo
597 618
 	$filecontents .= 'DTSTART' . (!empty($event['start_time']) ? ';TZID=' . $event['tz'] : ';VALUE=DATE') . ':' . $datestart . "\n";
598 619
 
599 620
 	// event has a duration
600
-	if ($event['start_iso_gmdate'] != $event['end_iso_gmdate'])
601
-		$filecontents .= 'DTEND' . (!empty($event['end_time']) ? ';TZID=' . $event['tz'] : ';VALUE=DATE') . ':' . $dateend . "\n";
621
+	if ($event['start_iso_gmdate'] != $event['end_iso_gmdate']) {
622
+			$filecontents .= 'DTEND' . (!empty($event['end_time']) ? ';TZID=' . $event['tz'] : ';VALUE=DATE') . ':' . $dateend . "\n";
623
+	}
602 624
 
603 625
 	// event has changed? advance the sequence for this UID
604
-	if ($event['sequence'] > 0)
605
-		$filecontents .= 'SEQUENCE:' . $event['sequence'] . "\n";
626
+	if ($event['sequence'] > 0) {
627
+			$filecontents .= 'SEQUENCE:' . $event['sequence'] . "\n";
628
+	}
606 629
 
607
-	if (!empty($event['location']))
608
-		$filecontents .= 'LOCATION:' . str_replace(',', '\,', $event['location']) . "\n";
630
+	if (!empty($event['location'])) {
631
+			$filecontents .= 'LOCATION:' . str_replace(',', '\,', $event['location']) . "\n";
632
+	}
609 633
 
610 634
 	$filecontents .= 'SUMMARY:' . implode('', $title);
611 635
 	$filecontents .= 'UID:' . $event['eventid'] . '@' . str_replace(' ', '-', $mbname) . "\n";
@@ -614,23 +638,26 @@  discard block
 block discarded – undo
614 638
 
615 639
 	// Send some standard headers.
616 640
 	ob_end_clean();
617
-	if (!empty($modSettings['enableCompressedOutput']))
618
-		@ob_start('ob_gzhandler');
619
-	else
620
-		ob_start();
641
+	if (!empty($modSettings['enableCompressedOutput'])) {
642
+			@ob_start('ob_gzhandler');
643
+	} else {
644
+			ob_start();
645
+	}
621 646
 
622 647
 	// Send the file headers
623 648
 	header('Pragma: ');
624 649
 	header('Cache-Control: no-cache');
625
-	if (!isBrowser('gecko'))
626
-		header('Content-Transfer-Encoding: binary');
650
+	if (!isBrowser('gecko')) {
651
+			header('Content-Transfer-Encoding: binary');
652
+	}
627 653
 	header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 525600 * 60) . ' GMT');
628 654
 	header('Last-Modified: ' . gmdate('D, d M Y H:i:s', time()) . 'GMT');
629 655
 	header('Accept-Ranges: bytes');
630 656
 	header('Connection: close');
631 657
 	header('Content-Disposition: attachment; filename="' . $event['title'] . '.ics"');
632
-	if (empty($modSettings['enableCompressedOutput']))
633
-		header('Content-Length: ' . $smcFunc['strlen']($filecontents));
658
+	if (empty($modSettings['enableCompressedOutput'])) {
659
+			header('Content-Length: ' . $smcFunc['strlen']($filecontents));
660
+	}
634 661
 
635 662
 	// This is a calendar item!
636 663
 	header('Content-Type: text/calendar');
@@ -669,20 +696,17 @@  discard block
 block discarded – undo
669 696
 		$context['sub_template'] = 'bcd';
670 697
 		$context['linktree'][] = array('url' => $scripturl . '?action=clock;bcd', 'name' => 'BCD');
671 698
 		$context['clockicons'] = $smcFunc['json_decode'](base64_decode('eyJoMSI6WzIsMV0sImgyIjpbOCw0LDIsMV0sIm0xIjpbNCwyLDFdLCJtMiI6WzgsNCwyLDFdLCJzMSI6WzQsMiwxXSwiczIiOls4LDQsMiwxXX0='), true);
672
-	}
673
-	elseif (!$omfg && !isset($_REQUEST['time']))
699
+	} elseif (!$omfg && !isset($_REQUEST['time']))
674 700
 	{
675 701
 		$context['sub_template'] = 'hms';
676 702
 		$context['linktree'][] = array('url' => $scripturl . '?action=clock', 'name' => 'Binary');
677 703
 		$context['clockicons'] = $smcFunc['json_decode'](base64_decode('eyJoIjpbMTYsOCw0LDIsMV0sIm0iOlszMiwxNiw4LDQsMiwxXSwicyI6WzMyLDE2LDgsNCwyLDFdfQ'), true);
678
-	}
679
-	elseif ($omfg)
704
+	} elseif ($omfg)
680 705
 	{
681 706
 		$context['sub_template'] = 'omfg';
682 707
 		$context['linktree'][] = array('url' => $scripturl . '?action=clock;omfg', 'name' => 'OMFG');
683 708
 		$context['clockicons'] = $smcFunc['json_decode'](base64_decode('eyJ5ZWFyIjpbNjQsMzIsMTYsOCw0LDIsMV0sIm1vbnRoIjpbOCw0LDIsMV0sImRheSI6WzE2LDgsNCwyLDFdLCJob3VyIjpbMTYsOCw0LDIsMV0sIm1pbiI6WzMyLDE2LDgsNCwyLDFdLCJzZWMiOlszMiwxNiw4LDQsMiwxXX0='), true);
684
-	}
685
-	elseif (isset($_REQUEST['time']))
709
+	} elseif (isset($_REQUEST['time']))
686 710
 	{
687 711
 		$context['sub_template'] = 'thetime';
688 712
 		$time = getdate($_REQUEST['time'] == 'now' ? time() : (int) $_REQUEST['time']);
@@ -736,12 +760,13 @@  discard block
 block discarded – undo
736 760
 			),
737 761
 		);
738 762
 
739
-		foreach ($context['clockicons'] as $t => $vs)
740
-			foreach ($vs as $v => $dumb)
763
+		foreach ($context['clockicons'] as $t => $vs) {
764
+					foreach ($vs as $v => $dumb)
741 765
 			{
742 766
 				if ($$t >= $v)
743 767
 				{
744 768
 					$$t -= $v;
769
+		}
745 770
 					$context['clockicons'][$t][$v] = true;
746 771
 				}
747 772
 			}
Please login to merge, or discard this patch.
other/install.php 2 patches
Spacing   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1622,8 +1622,7 @@
 block discarded – undo
1622 1622
 	updateStats('topic');
1623 1623
 
1624 1624
 	// This function is needed to do the updateStats('subject') call.
1625
-	$smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' :
1626
-		function($string){
1625
+	$smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' : function($string) {
1627 1626
 			global $sourcedir;
1628 1627
 			if (function_exists('mb_strtolower'))
1629 1628
 				return mb_strtolower($string, 'UTF-8');
Please login to merge, or discard this patch.
Braces   +462 added lines, -344 removed lines patch added patch discarded remove patch
@@ -20,8 +20,9 @@  discard block
 block discarded – undo
20 20
 // ><html dir="ltr"><head><title>Error!</title></head><body>Sorry, this installer requires PHP!<div style="display: none;">
21 21
 
22 22
 // Let's pull in useful classes
23
-if (!defined('SMF'))
23
+if (!defined('SMF')) {
24 24
 	define('SMF', 1);
25
+}
25 26
 
26 27
 require_once('Sources/Class-Package.php');
27 28
 
@@ -63,10 +64,11 @@  discard block
 block discarded – undo
63 64
 
64 65
 			list ($charcode) = pg_fetch_row($request);
65 66
 
66
-			if ($charcode == 'UTF8')
67
-				return true;
68
-			else
69
-				return false;
67
+			if ($charcode == 'UTF8') {
68
+							return true;
69
+			} else {
70
+							return false;
71
+			}
70 72
 		},
71 73
 		'utf8_version' => '8.0',
72 74
 		'utf8_version_check' => '$request = pg_query(\'SELECT version()\'); list ($version) = pg_fetch_row($request); list($pgl, $version) = explode(" ", $version); return $version;',
@@ -76,12 +78,14 @@  discard block
 block discarded – undo
76 78
 			$value = preg_replace('~[^A-Za-z0-9_\$]~', '', $value);
77 79
 
78 80
 			// Is it reserved?
79
-			if ($value == 'pg_')
80
-				return $txt['error_db_prefix_reserved'];
81
+			if ($value == 'pg_') {
82
+							return $txt['error_db_prefix_reserved'];
83
+			}
81 84
 
82 85
 			// Is the prefix numeric?
83
-			if (preg_match('~^\d~', $value))
84
-				return $txt['error_db_prefix_numeric'];
86
+			if (preg_match('~^\d~', $value)) {
87
+							return $txt['error_db_prefix_numeric'];
88
+			}
85 89
 
86 90
 			return true;
87 91
 		},
@@ -128,10 +132,11 @@  discard block
 block discarded – undo
128 132
 		$incontext['skip'] = false;
129 133
 
130 134
 		// Call the step and if it returns false that means pause!
131
-		if (function_exists($step[2]) && $step[2]() === false)
132
-			break;
133
-		elseif (function_exists($step[2]))
134
-			$incontext['current_step']++;
135
+		if (function_exists($step[2]) && $step[2]() === false) {
136
+					break;
137
+		} elseif (function_exists($step[2])) {
138
+					$incontext['current_step']++;
139
+		}
135 140
 
136 141
 		// No warnings pass on.
137 142
 		$incontext['warning'] = '';
@@ -147,8 +152,9 @@  discard block
 block discarded – undo
147 152
 	global $databases;
148 153
 
149 154
 	// Just so people using older versions of PHP aren't left in the cold.
150
-	if (!isset($_SERVER['PHP_SELF']))
151
-		$_SERVER['PHP_SELF'] = isset($GLOBALS['HTTP_SERVER_VARS']['PHP_SELF']) ? $GLOBALS['HTTP_SERVER_VARS']['PHP_SELF'] : 'install.php';
155
+	if (!isset($_SERVER['PHP_SELF'])) {
156
+			$_SERVER['PHP_SELF'] = isset($GLOBALS['HTTP_SERVER_VARS']['PHP_SELF']) ? $GLOBALS['HTTP_SERVER_VARS']['PHP_SELF'] : 'install.php';
157
+	}
152 158
 
153 159
 	// Enable error reporting for fatal errors.
154 160
 	error_reporting(E_ERROR | E_PARSE);
@@ -164,21 +170,23 @@  discard block
 block discarded – undo
164 170
 	{
165 171
 		ob_start();
166 172
 
167
-		if (ini_get('session.save_handler') == 'user')
168
-			@ini_set('session.save_handler', 'files');
169
-		if (function_exists('session_start'))
170
-			@session_start();
171
-	}
172
-	else
173
+		if (ini_get('session.save_handler') == 'user') {
174
+					@ini_set('session.save_handler', 'files');
175
+		}
176
+		if (function_exists('session_start')) {
177
+					@session_start();
178
+		}
179
+	} else
173 180
 	{
174 181
 		ob_start('ob_gzhandler');
175 182
 
176
-		if (ini_get('session.save_handler') == 'user')
177
-			@ini_set('session.save_handler', 'files');
183
+		if (ini_get('session.save_handler') == 'user') {
184
+					@ini_set('session.save_handler', 'files');
185
+		}
178 186
 		session_start();
179 187
 
180
-		if (!headers_sent())
181
-			echo '<!DOCTYPE html>
188
+		if (!headers_sent()) {
189
+					echo '<!DOCTYPE html>
182 190
 <html>
183 191
 	<head>
184 192
 		<title>', htmlspecialchars($_GET['pass_string']), '</title>
@@ -187,14 +195,16 @@  discard block
 block discarded – undo
187 195
 		<strong>', htmlspecialchars($_GET['pass_string']), '</strong>
188 196
 	</body>
189 197
 </html>';
198
+		}
190 199
 		exit;
191 200
 	}
192 201
 
193 202
 	// Add slashes, as long as they aren't already being added.
194
-	if (!function_exists('get_magic_quotes_gpc') || @get_magic_quotes_gpc() == 0)
195
-		foreach ($_POST as $k => $v)
203
+	if (!function_exists('get_magic_quotes_gpc') || @get_magic_quotes_gpc() == 0) {
204
+			foreach ($_POST as $k => $v)
196 205
 			if (strpos($k, 'password') === false && strpos($k, 'db_passwd') === false)
197 206
 				$_POST[$k] = addslashes($v);
207
+	}
198 208
 
199 209
 	// This is really quite simple; if ?delete is on the URL, delete the installer...
200 210
 	if (isset($_GET['delete']))
@@ -215,8 +225,7 @@  discard block
 block discarded – undo
215 225
 			$ftp->close();
216 226
 
217 227
 			unset($_SESSION['installer_temp_ftp']);
218
-		}
219
-		else
228
+		} else
220 229
 		{
221 230
 			@unlink(__FILE__);
222 231
 
@@ -230,10 +239,11 @@  discard block
 block discarded – undo
230 239
 		// Now just redirect to a blank.png...
231 240
 		$secure = false;
232 241
 
233
-		if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') 
234
-			$secure = true;
235
-		elseif (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on') 
236
-			$secure = true;
242
+		if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') {
243
+					$secure = true;
244
+		} elseif (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on') {
245
+					$secure = true;
246
+		}
237 247
 
238 248
 		header('Location: http' . ($secure ? 's' : '') . '://' . (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME'] . ':' . $_SERVER['SERVER_PORT']) . dirname($_SERVER['PHP_SELF']) . '/Themes/default/images/blank.png');
239 249
 		exit;
@@ -244,10 +254,11 @@  discard block
 block discarded – undo
244 254
 	{
245 255
 		// Get PHP's default timezone, if set
246 256
 		$ini_tz = ini_get('date.timezone');
247
-		if (!empty($ini_tz))
248
-			$timezone_id = $ini_tz;
249
-		else
250
-			$timezone_id = '';
257
+		if (!empty($ini_tz)) {
258
+					$timezone_id = $ini_tz;
259
+		} else {
260
+					$timezone_id = '';
261
+		}
251 262
 
252 263
 		// If date.timezone is unset, invalid, or just plain weird, make a best guess
253 264
 		if (!in_array($timezone_id, timezone_identifiers_list()))
@@ -277,8 +288,9 @@  discard block
 block discarded – undo
277 288
 		$dir = dir(dirname(__FILE__) . '/Themes/default/languages');
278 289
 		while ($entry = $dir->read())
279 290
 		{
280
-			if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php')
281
-				$incontext['detected_languages'][$entry] = ucfirst(substr($entry, 8, strlen($entry) - 12));
291
+			if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php') {
292
+							$incontext['detected_languages'][$entry] = ucfirst(substr($entry, 8, strlen($entry) - 12));
293
+			}
282 294
 		}
283 295
 		$dir->close();
284 296
 	}
@@ -313,10 +325,11 @@  discard block
 block discarded – undo
313 325
 	}
314 326
 
315 327
 	// Override the language file?
316
-	if (isset($_GET['lang_file']))
317
-		$_SESSION['installer_temp_lang'] = $_GET['lang_file'];
318
-	elseif (isset($GLOBALS['HTTP_GET_VARS']['lang_file']))
319
-		$_SESSION['installer_temp_lang'] = $GLOBALS['HTTP_GET_VARS']['lang_file'];
328
+	if (isset($_GET['lang_file'])) {
329
+			$_SESSION['installer_temp_lang'] = $_GET['lang_file'];
330
+	} elseif (isset($GLOBALS['HTTP_GET_VARS']['lang_file'])) {
331
+			$_SESSION['installer_temp_lang'] = $GLOBALS['HTTP_GET_VARS']['lang_file'];
332
+	}
320 333
 
321 334
 	// Make sure it exists, if it doesn't reset it.
322 335
 	if (!isset($_SESSION['installer_temp_lang']) || preg_match('~[^\\w_\\-.]~', $_SESSION['installer_temp_lang']) === 1 || !file_exists(dirname(__FILE__) . '/Themes/default/languages/' . $_SESSION['installer_temp_lang']))
@@ -325,8 +338,9 @@  discard block
 block discarded – undo
325 338
 		list ($_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']);
326 339
 
327 340
 		// If we have english and some other language, use the other language.  We Americans hate english :P.
328
-		if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1)
329
-			list (, $_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']);
341
+		if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1) {
342
+					list (, $_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']);
343
+		}
330 344
 	}
331 345
 
332 346
 	// And now include the actual language file itself.
@@ -343,15 +357,18 @@  discard block
 block discarded – undo
343 357
 	global $db_prefix, $db_connection, $sourcedir, $smcFunc, $modSettings;
344 358
 	global $db_server, $db_passwd, $db_type, $db_name, $db_user, $db_persist;
345 359
 
346
-	if (empty($sourcedir))
347
-		$sourcedir = dirname(__FILE__) . '/Sources';
360
+	if (empty($sourcedir)) {
361
+			$sourcedir = dirname(__FILE__) . '/Sources';
362
+	}
348 363
 
349 364
 	// Need this to check whether we need the database password.
350 365
 	require(dirname(__FILE__) . '/Settings.php');
351
-	if (!defined('SMF'))
352
-		define('SMF', 1);
353
-	if (empty($smcFunc))
354
-		$smcFunc = array();
366
+	if (!defined('SMF')) {
367
+			define('SMF', 1);
368
+	}
369
+	if (empty($smcFunc)) {
370
+			$smcFunc = array();
371
+	}
355 372
 
356 373
 	$modSettings['disableQueryCheck'] = true;
357 374
 
@@ -359,8 +376,9 @@  discard block
 block discarded – undo
359 376
 	if (!$db_connection)
360 377
 	{
361 378
 		require_once($sourcedir . '/Subs-Db-' . $db_type . '.php');
362
-		if (version_compare(PHP_VERSION, '5', '<'))
363
-			require_once($sourcedir . '/Subs-Compat.php');
379
+		if (version_compare(PHP_VERSION, '5', '<')) {
380
+					require_once($sourcedir . '/Subs-Compat.php');
381
+		}
364 382
 
365 383
 		$db_options = array('persist' => $db_persist);
366 384
 		$port = '';
@@ -371,19 +389,20 @@  discard block
 block discarded – undo
371 389
 			if ($db_type == 'mysql')
372 390
 			{
373 391
 				$port = ((int) $_POST['db_port'] == ini_get($db_type . 'default_port')) ? '' : (int) $_POST['db_port'];
374
-			}
375
-			elseif ($db_type == 'postgresql')
392
+			} elseif ($db_type == 'postgresql')
376 393
 			{
377 394
 				// PostgreSQL doesn't have a default port setting in php.ini, so just check against the default
378 395
 				$port = ((int) $_POST['db_port'] == 5432) ? '' : (int) $_POST['db_port'];
379 396
 			}
380 397
 		}
381 398
 
382
-		if (!empty($port))
383
-			$db_options['port'] = $port;
399
+		if (!empty($port)) {
400
+					$db_options['port'] = $port;
401
+		}
384 402
 
385
-		if (!$db_connection)
386
-			$db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, $db_options);
403
+		if (!$db_connection) {
404
+					$db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, $db_options);
405
+		}
387 406
 	}
388 407
 }
389 408
 
@@ -411,8 +430,9 @@  discard block
 block discarded – undo
411 430
 		// @todo REMOVE THIS!!
412 431
 		else
413 432
 		{
414
-			if (function_exists('doStep' . $_GET['step']))
415
-				call_user_func('doStep' . $_GET['step']);
433
+			if (function_exists('doStep' . $_GET['step'])) {
434
+							call_user_func('doStep' . $_GET['step']);
435
+			}
416 436
 		}
417 437
 		// Show the footer.
418 438
 		template_install_below();
@@ -430,8 +450,9 @@  discard block
 block discarded – undo
430 450
 	$incontext['sub_template'] = 'welcome_message';
431 451
 
432 452
 	// Done the submission?
433
-	if (isset($_POST['contbutt']))
434
-		return true;
453
+	if (isset($_POST['contbutt'])) {
454
+			return true;
455
+	}
435 456
 
436 457
 	// See if we think they have already installed it?
437 458
 	if (is_readable(dirname(__FILE__) . '/Settings.php'))
@@ -439,14 +460,17 @@  discard block
 block discarded – undo
439 460
 		$probably_installed = 0;
440 461
 		foreach (file(dirname(__FILE__) . '/Settings.php') as $line)
441 462
 		{
442
-			if (preg_match('~^\$db_passwd\s=\s\'([^\']+)\';$~', $line))
443
-				$probably_installed++;
444
-			if (preg_match('~^\$boardurl\s=\s\'([^\']+)\';~', $line) && !preg_match('~^\$boardurl\s=\s\'http://127\.0\.0\.1/smf\';~', $line))
445
-				$probably_installed++;
463
+			if (preg_match('~^\$db_passwd\s=\s\'([^\']+)\';$~', $line)) {
464
+							$probably_installed++;
465
+			}
466
+			if (preg_match('~^\$boardurl\s=\s\'([^\']+)\';~', $line) && !preg_match('~^\$boardurl\s=\s\'http://127\.0\.0\.1/smf\';~', $line)) {
467
+							$probably_installed++;
468
+			}
446 469
 		}
447 470
 
448
-		if ($probably_installed == 2)
449
-			$incontext['warning'] = $txt['error_already_installed'];
471
+		if ($probably_installed == 2) {
472
+					$incontext['warning'] = $txt['error_already_installed'];
473
+		}
450 474
 	}
451 475
 
452 476
 	// Is some database support even compiled in?
@@ -461,45 +485,54 @@  discard block
 block discarded – undo
461 485
 				$databases[$key]['supported'] = false;
462 486
 				$notFoundSQLFile = true;
463 487
 				$txt['error_db_script_missing'] = sprintf($txt['error_db_script_missing'], 'install_' . $GLOBALS['db_script_version'] . '_' . $type . '.sql');
488
+			} else {
489
+							$incontext['supported_databases'][] = $db;
464 490
 			}
465
-			else
466
-				$incontext['supported_databases'][] = $db;
467 491
 		}
468 492
 	}
469 493
 
470 494
 	// Check the PHP version.
471
-	if ((!function_exists('version_compare') || version_compare($GLOBALS['required_php_version'], PHP_VERSION, '>=')))
472
-		$error = 'error_php_too_low';
495
+	if ((!function_exists('version_compare') || version_compare($GLOBALS['required_php_version'], PHP_VERSION, '>='))) {
496
+			$error = 'error_php_too_low';
497
+	}
473 498
 	// Make sure we have a supported database
474
-	elseif (empty($incontext['supported_databases']))
475
-		$error = empty($notFoundSQLFile) ? 'error_db_missing' : 'error_db_script_missing';
499
+	elseif (empty($incontext['supported_databases'])) {
500
+			$error = empty($notFoundSQLFile) ? 'error_db_missing' : 'error_db_script_missing';
501
+	}
476 502
 	// How about session support?  Some crazy sysadmin remove it?
477
-	elseif (!function_exists('session_start'))
478
-		$error = 'error_session_missing';
503
+	elseif (!function_exists('session_start')) {
504
+			$error = 'error_session_missing';
505
+	}
479 506
 	// Make sure they uploaded all the files.
480
-	elseif (!file_exists(dirname(__FILE__) . '/index.php'))
481
-		$error = 'error_missing_files';
507
+	elseif (!file_exists(dirname(__FILE__) . '/index.php')) {
508
+			$error = 'error_missing_files';
509
+	}
482 510
 	// Very simple check on the session.save_path for Windows.
483 511
 	// @todo Move this down later if they don't use database-driven sessions?
484
-	elseif (@ini_get('session.save_path') == '/tmp' && substr(__FILE__, 1, 2) == ':\\')
485
-		$error = 'error_session_save_path';
512
+	elseif (@ini_get('session.save_path') == '/tmp' && substr(__FILE__, 1, 2) == ':\\') {
513
+			$error = 'error_session_save_path';
514
+	}
486 515
 
487 516
 	// Since each of the three messages would look the same, anyway...
488
-	if (isset($error))
489
-		$incontext['error'] = $txt[$error];
517
+	if (isset($error)) {
518
+			$incontext['error'] = $txt[$error];
519
+	}
490 520
 
491 521
 	// Mod_security blocks everything that smells funny. Let SMF handle security.
492
-	if (!fixModSecurity() && !isset($_GET['overmodsecurity']))
493
-		$incontext['error'] = $txt['error_mod_security'] . '<br><br><a href="' . $installurl . '?overmodsecurity=true">' . $txt['error_message_click'] . '</a> ' . $txt['error_message_bad_try_again'];
522
+	if (!fixModSecurity() && !isset($_GET['overmodsecurity'])) {
523
+			$incontext['error'] = $txt['error_mod_security'] . '<br><br><a href="' . $installurl . '?overmodsecurity=true">' . $txt['error_message_click'] . '</a> ' . $txt['error_message_bad_try_again'];
524
+	}
494 525
 
495 526
 	// Confirm mbstring is loaded...
496
-	if (!extension_loaded('mbstring'))
497
-		$incontext['error'] = $txt['install_no_mbstring'];
527
+	if (!extension_loaded('mbstring')) {
528
+			$incontext['error'] = $txt['install_no_mbstring'];
529
+	}
498 530
 
499 531
 	// Check for https stream support.
500 532
 	$supported_streams = stream_get_wrappers();
501
-	if (!in_array('https', $supported_streams))
502
-		$incontext['warning'] = $txt['install_no_https'];
533
+	if (!in_array('https', $supported_streams)) {
534
+			$incontext['warning'] = $txt['install_no_https'];
535
+	}
503 536
 
504 537
 	return false;
505 538
 }
@@ -525,12 +558,14 @@  discard block
 block discarded – undo
525 558
 		'db_last_error.php',
526 559
 	);
527 560
 
528
-	foreach ($incontext['detected_languages'] as $lang => $temp)
529
-		$extra_files[] = 'Themes/default/languages/' . $lang;
561
+	foreach ($incontext['detected_languages'] as $lang => $temp) {
562
+			$extra_files[] = 'Themes/default/languages/' . $lang;
563
+	}
530 564
 
531 565
 	// With mod_security installed, we could attempt to fix it with .htaccess.
532
-	if (function_exists('apache_get_modules') && in_array('mod_security', apache_get_modules()))
533
-		$writable_files[] = file_exists(dirname(__FILE__) . '/.htaccess') ? '.htaccess' : '.';
566
+	if (function_exists('apache_get_modules') && in_array('mod_security', apache_get_modules())) {
567
+			$writable_files[] = file_exists(dirname(__FILE__) . '/.htaccess') ? '.htaccess' : '.';
568
+	}
534 569
 
535 570
 	$failed_files = array();
536 571
 
@@ -542,20 +577,23 @@  discard block
 block discarded – undo
542 577
 		foreach ($writable_files as $file)
543 578
 		{
544 579
 			// Some files won't exist, try to address up front
545
-			if (!file_exists(dirname(__FILE__) . '/' . $file))
546
-				@touch(dirname(__FILE__) . '/' . $file);
580
+			if (!file_exists(dirname(__FILE__) . '/' . $file)) {
581
+							@touch(dirname(__FILE__) . '/' . $file);
582
+			}
547 583
 			// NOW do the writable check...
548 584
 			if (!is_writable(dirname(__FILE__) . '/' . $file))
549 585
 			{
550 586
 				@chmod(dirname(__FILE__) . '/' . $file, 0755);
551 587
 
552 588
 				// Well, 755 hopefully worked... if not, try 777.
553
-				if (!is_writable(dirname(__FILE__) . '/' . $file) && !@chmod(dirname(__FILE__) . '/' . $file, 0777))
554
-					$failed_files[] = $file;
589
+				if (!is_writable(dirname(__FILE__) . '/' . $file) && !@chmod(dirname(__FILE__) . '/' . $file, 0777)) {
590
+									$failed_files[] = $file;
591
+				}
555 592
 			}
556 593
 		}
557
-		foreach ($extra_files as $file)
558
-			@chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777);
594
+		foreach ($extra_files as $file) {
595
+					@chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777);
596
+		}
559 597
 	}
560 598
 	// Windows is trickier.  Let's try opening for r+...
561 599
 	else
@@ -565,30 +603,35 @@  discard block
 block discarded – undo
565 603
 		foreach ($writable_files as $file)
566 604
 		{
567 605
 			// Folders can't be opened for write... but the index.php in them can ;)
568
-			if (is_dir(dirname(__FILE__) . '/' . $file))
569
-				$file .= '/index.php';
606
+			if (is_dir(dirname(__FILE__) . '/' . $file)) {
607
+							$file .= '/index.php';
608
+			}
570 609
 
571 610
 			// Funny enough, chmod actually does do something on windows - it removes the read only attribute.
572 611
 			@chmod(dirname(__FILE__) . '/' . $file, 0777);
573 612
 			$fp = @fopen(dirname(__FILE__) . '/' . $file, 'r+');
574 613
 
575 614
 			// Hmm, okay, try just for write in that case...
576
-			if (!is_resource($fp))
577
-				$fp = @fopen(dirname(__FILE__) . '/' . $file, 'w');
615
+			if (!is_resource($fp)) {
616
+							$fp = @fopen(dirname(__FILE__) . '/' . $file, 'w');
617
+			}
578 618
 
579
-			if (!is_resource($fp))
580
-				$failed_files[] = $file;
619
+			if (!is_resource($fp)) {
620
+							$failed_files[] = $file;
621
+			}
581 622
 
582 623
 			@fclose($fp);
583 624
 		}
584
-		foreach ($extra_files as $file)
585
-			@chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777);
625
+		foreach ($extra_files as $file) {
626
+					@chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777);
627
+		}
586 628
 	}
587 629
 
588 630
 	$failure = count($failed_files) >= 1;
589 631
 
590
-	if (!isset($_SERVER))
591
-		return !$failure;
632
+	if (!isset($_SERVER)) {
633
+			return !$failure;
634
+	}
592 635
 
593 636
 	// Put the list into context.
594 637
 	$incontext['failed_files'] = $failed_files;
@@ -636,19 +679,23 @@  discard block
 block discarded – undo
636 679
 
637 680
 		if (!isset($ftp) || $ftp->error !== false)
638 681
 		{
639
-			if (!isset($ftp))
640
-				$ftp = new ftp_connection(null);
682
+			if (!isset($ftp)) {
683
+							$ftp = new ftp_connection(null);
684
+			}
641 685
 			// Save the error so we can mess with listing...
642
-			elseif ($ftp->error !== false && empty($incontext['ftp_errors']) && !empty($ftp->last_message))
643
-				$incontext['ftp_errors'][] = $ftp->last_message;
686
+			elseif ($ftp->error !== false && empty($incontext['ftp_errors']) && !empty($ftp->last_message)) {
687
+							$incontext['ftp_errors'][] = $ftp->last_message;
688
+			}
644 689
 
645 690
 			list ($username, $detect_path, $found_path) = $ftp->detect_path(dirname(__FILE__));
646 691
 
647
-			if (empty($_POST['ftp_path']) && $found_path)
648
-				$_POST['ftp_path'] = $detect_path;
692
+			if (empty($_POST['ftp_path']) && $found_path) {
693
+							$_POST['ftp_path'] = $detect_path;
694
+			}
649 695
 
650
-			if (!isset($_POST['ftp_username']))
651
-				$_POST['ftp_username'] = $username;
696
+			if (!isset($_POST['ftp_username'])) {
697
+							$_POST['ftp_username'] = $username;
698
+			}
652 699
 
653 700
 			// Set the username etc, into context.
654 701
 			$incontext['ftp'] = array(
@@ -660,8 +707,7 @@  discard block
 block discarded – undo
660 707
 			);
661 708
 
662 709
 			return false;
663
-		}
664
-		else
710
+		} else
665 711
 		{
666 712
 			$_SESSION['installer_temp_ftp'] = array(
667 713
 				'server' => $_POST['ftp_server'],
@@ -675,10 +721,12 @@  discard block
 block discarded – undo
675 721
 
676 722
 			foreach ($failed_files as $file)
677 723
 			{
678
-				if (!is_writable(dirname(__FILE__) . '/' . $file))
679
-					$ftp->chmod($file, 0755);
680
-				if (!is_writable(dirname(__FILE__) . '/' . $file))
681
-					$ftp->chmod($file, 0777);
724
+				if (!is_writable(dirname(__FILE__) . '/' . $file)) {
725
+									$ftp->chmod($file, 0755);
726
+				}
727
+				if (!is_writable(dirname(__FILE__) . '/' . $file)) {
728
+									$ftp->chmod($file, 0777);
729
+				}
682 730
 				if (!is_writable(dirname(__FILE__) . '/' . $file))
683 731
 				{
684 732
 					$failed_files_updated[] = $file;
@@ -734,15 +782,17 @@  discard block
 block discarded – undo
734 782
 
735 783
 			if (!$foundOne)
736 784
 			{
737
-				if (isset($db['default_host']))
738
-					$incontext['db']['server'] = ini_get($db['default_host']) or $incontext['db']['server'] = 'localhost';
785
+				if (isset($db['default_host'])) {
786
+									$incontext['db']['server'] = ini_get($db['default_host']) or $incontext['db']['server'] = 'localhost';
787
+				}
739 788
 				if (isset($db['default_user']))
740 789
 				{
741 790
 					$incontext['db']['user'] = ini_get($db['default_user']);
742 791
 					$incontext['db']['name'] = ini_get($db['default_user']);
743 792
 				}
744
-				if (isset($db['default_password']))
745
-					$incontext['db']['pass'] = ini_get($db['default_password']);
793
+				if (isset($db['default_password'])) {
794
+									$incontext['db']['pass'] = ini_get($db['default_password']);
795
+				}
746 796
 
747 797
 				// For simplicity and less confusion, leave the port blank by default
748 798
 				$incontext['db']['port'] = '';
@@ -761,10 +811,10 @@  discard block
 block discarded – undo
761 811
 		$incontext['db']['server'] = $_POST['db_server'];
762 812
 		$incontext['db']['prefix'] = $_POST['db_prefix'];
763 813
 
764
-		if (!empty($_POST['db_port']))
765
-			$incontext['db']['port'] = $_POST['db_port'];
766
-	}
767
-	else
814
+		if (!empty($_POST['db_port'])) {
815
+					$incontext['db']['port'] = $_POST['db_port'];
816
+		}
817
+	} else
768 818
 	{
769 819
 		$incontext['db']['prefix'] = 'smf_';
770 820
 	}
@@ -800,10 +850,11 @@  discard block
 block discarded – undo
800 850
 		if (!empty($_POST['db_port']))
801 851
 		{
802 852
 			// For MySQL, we can get the "default port" from PHP. PostgreSQL has no such option though.
803
-			if (($db_type == 'mysql' || $db_type == 'mysqli') && $_POST['db_port'] != ini_get($db_type . '.default_port'))
804
-				$vars['db_port'] = (int) $_POST['db_port'];
805
-			elseif ($db_type == 'postgresql' && $_POST['db_port'] != 5432)
806
-				$vars['db_port'] = (int) $_POST['db_port'];
853
+			if (($db_type == 'mysql' || $db_type == 'mysqli') && $_POST['db_port'] != ini_get($db_type . '.default_port')) {
854
+							$vars['db_port'] = (int) $_POST['db_port'];
855
+			} elseif ($db_type == 'postgresql' && $_POST['db_port'] != 5432) {
856
+							$vars['db_port'] = (int) $_POST['db_port'];
857
+			}
807 858
 		}
808 859
 
809 860
 		// God I hope it saved!
@@ -816,8 +867,9 @@  discard block
 block discarded – undo
816 867
 		// Make sure it works.
817 868
 		require(dirname(__FILE__) . '/Settings.php');
818 869
 
819
-		if (empty($sourcedir))
820
-			$sourcedir = dirname(__FILE__) . '/Sources';
870
+		if (empty($sourcedir)) {
871
+					$sourcedir = dirname(__FILE__) . '/Sources';
872
+		}
821 873
 
822 874
 		// Better find the database file!
823 875
 		if (!file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php'))
@@ -827,18 +879,21 @@  discard block
 block discarded – undo
827 879
 		}
828 880
 
829 881
 		// Now include it for database functions!
830
-		if (!defined('SMF'))
831
-			define('SMF', 1);
882
+		if (!defined('SMF')) {
883
+					define('SMF', 1);
884
+		}
832 885
 
833 886
 		$modSettings['disableQueryCheck'] = true;
834
-		if (empty($smcFunc))
835
-			$smcFunc = array();
887
+		if (empty($smcFunc)) {
888
+					$smcFunc = array();
889
+		}
836 890
 
837 891
 			require_once($sourcedir . '/Subs-Db-' . $db_type . '.php');
838 892
 
839 893
 		// What - running PHP4? The shame!
840
-		if (version_compare(PHP_VERSION, '5', '<'))
841
-			require_once($sourcedir . '/Subs-Compat.php');
894
+		if (version_compare(PHP_VERSION, '5', '<')) {
895
+					require_once($sourcedir . '/Subs-Compat.php');
896
+		}
842 897
 
843 898
 		// Attempt a connection.
844 899
 		$needsDB = !empty($databases[$db_type]['always_has_db']);
@@ -926,12 +981,14 @@  discard block
 block discarded – undo
926 981
 	$incontext['page_title'] = $txt['install_settings'];
927 982
 
928 983
 	// Let's see if we got the database type correct.
929
-	if (isset($_POST['db_type'], $databases[$_POST['db_type']]))
930
-		$db_type = $_POST['db_type'];
984
+	if (isset($_POST['db_type'], $databases[$_POST['db_type']])) {
985
+			$db_type = $_POST['db_type'];
986
+	}
931 987
 
932 988
 	// Else we'd better be able to get the connection.
933
-	else
934
-		load_database();
989
+	else {
990
+			load_database();
991
+	}
935 992
 
936 993
 	$db_type = isset($_POST['db_type']) ? $_POST['db_type'] : $db_type;
937 994
 
@@ -940,10 +997,11 @@  discard block
 block discarded – undo
940 997
 
941 998
 		$secure = false;
942 999
 
943
-		if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') 
944
-			$secure = true;
945
-		elseif (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on') 
946
-			$secure = true;
1000
+		if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') {
1001
+					$secure = true;
1002
+		} elseif (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on') {
1003
+					$secure = true;
1004
+		}
947 1005
 
948 1006
 	// Now, to put what we've learned together... and add a path.
949 1007
 	$incontext['detected_url'] = 'http' . ($secure ? 's' : '') . '://' . $host . substr($_SERVER['PHP_SELF'], 0, strrpos($_SERVER['PHP_SELF'], '/'));
@@ -975,18 +1033,21 @@  discard block
 block discarded – undo
975 1033
 	// Submitting?
976 1034
 	if (isset($_POST['boardurl']))
977 1035
 	{
978
-		if (substr($_POST['boardurl'], -10) == '/index.php')
979
-			$_POST['boardurl'] = substr($_POST['boardurl'], 0, -10);
980
-		elseif (substr($_POST['boardurl'], -1) == '/')
981
-			$_POST['boardurl'] = substr($_POST['boardurl'], 0, -1);
982
-		if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://')
983
-			$_POST['boardurl'] = 'http://' . $_POST['boardurl'];
1036
+		if (substr($_POST['boardurl'], -10) == '/index.php') {
1037
+					$_POST['boardurl'] = substr($_POST['boardurl'], 0, -10);
1038
+		} elseif (substr($_POST['boardurl'], -1) == '/') {
1039
+					$_POST['boardurl'] = substr($_POST['boardurl'], 0, -1);
1040
+		}
1041
+		if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://') {
1042
+					$_POST['boardurl'] = 'http://' . $_POST['boardurl'];
1043
+		}
984 1044
 
985 1045
 		//Make sure boardurl is aligned with ssl setting
986
-		if (empty($_POST['force_ssl']))
987
-			$_POST['boardurl'] = strtr($_POST['boardurl'], array('https://' => 'http://'));
988
-		else
989
-			$_POST['boardurl'] = strtr($_POST['boardurl'], array('http://' => 'https://'));		
1046
+		if (empty($_POST['force_ssl'])) {
1047
+					$_POST['boardurl'] = strtr($_POST['boardurl'], array('https://' => 'http://'));
1048
+		} else {
1049
+					$_POST['boardurl'] = strtr($_POST['boardurl'], array('http://' => 'https://'));
1050
+		}
990 1051
 
991 1052
 		// Save these variables.
992 1053
 		$vars = array(
@@ -1025,10 +1086,10 @@  discard block
 block discarded – undo
1025 1086
 			{
1026 1087
 				$incontext['error'] = sprintf($txt['error_utf8_version'], $databases[$db_type]['utf8_version']);
1027 1088
 				return false;
1028
-			}
1029
-			else
1030
-				// Set the character set here.
1089
+			} else {
1090
+							// Set the character set here.
1031 1091
 				updateSettingsFile(array('db_character_set' => 'utf8'));
1092
+			}
1032 1093
 		}
1033 1094
 
1034 1095
 		// Good, skip on.
@@ -1048,8 +1109,9 @@  discard block
 block discarded – undo
1048 1109
 	$incontext['continue'] = 1;
1049 1110
 
1050 1111
 	// Already done?
1051
-	if (isset($_POST['pop_done']))
1052
-		return true;
1112
+	if (isset($_POST['pop_done'])) {
1113
+			return true;
1114
+	}
1053 1115
 
1054 1116
 	// Reload settings.
1055 1117
 	require(dirname(__FILE__) . '/Settings.php');
@@ -1067,8 +1129,9 @@  discard block
 block discarded – undo
1067 1129
 	$modSettings = array();
1068 1130
 	if ($result !== false)
1069 1131
 	{
1070
-		while ($row = $smcFunc['db_fetch_assoc']($result))
1071
-			$modSettings[$row['variable']] = $row['value'];
1132
+		while ($row = $smcFunc['db_fetch_assoc']($result)) {
1133
+					$modSettings[$row['variable']] = $row['value'];
1134
+		}
1072 1135
 		$smcFunc['db_free_result']($result);
1073 1136
 
1074 1137
 		// Do they match?  If so, this is just a refresh so charge on!
@@ -1081,20 +1144,22 @@  discard block
 block discarded – undo
1081 1144
 	$modSettings['disableQueryCheck'] = true;
1082 1145
 
1083 1146
 	// If doing UTF8, select it. PostgreSQL requires passing it as a string...
1084
-	if (!empty($db_character_set) && $db_character_set == 'utf8' && !empty($databases[$db_type]['utf8_support']))
1085
-		$smcFunc['db_query']('', '
1147
+	if (!empty($db_character_set) && $db_character_set == 'utf8' && !empty($databases[$db_type]['utf8_support'])) {
1148
+			$smcFunc['db_query']('', '
1086 1149
 			SET NAMES {string:utf8}',
1087 1150
 			array(
1088 1151
 				'db_error_skip' => true,
1089 1152
 				'utf8' => 'utf8',
1090 1153
 			)
1091 1154
 		);
1155
+	}
1092 1156
 
1093 1157
 	// Windows likes to leave the trailing slash, which yields to C:\path\to\SMF\/attachments...
1094
-	if (substr(__DIR__, -1) == '\\')
1095
-		$attachdir = __DIR__ . 'attachments';
1096
-	else
1097
-		$attachdir = __DIR__ . '/attachments';
1158
+	if (substr(__DIR__, -1) == '\\') {
1159
+			$attachdir = __DIR__ . 'attachments';
1160
+	} else {
1161
+			$attachdir = __DIR__ . '/attachments';
1162
+	}
1098 1163
 
1099 1164
 	$replaces = array(
1100 1165
 		'{$db_prefix}' => $db_prefix,
@@ -1111,8 +1176,9 @@  discard block
 block discarded – undo
1111 1176
 
1112 1177
 	foreach ($txt as $key => $value)
1113 1178
 	{
1114
-		if (substr($key, 0, 8) == 'default_')
1115
-			$replaces['{$' . $key . '}'] = $smcFunc['db_escape_string']($value);
1179
+		if (substr($key, 0, 8) == 'default_') {
1180
+					$replaces['{$' . $key . '}'] = $smcFunc['db_escape_string']($value);
1181
+		}
1116 1182
 	}
1117 1183
 	$replaces['{$default_reserved_names}'] = strtr($replaces['{$default_reserved_names}'], array('\\\\n' => '\\n'));
1118 1184
 
@@ -1127,8 +1193,9 @@  discard block
 block discarded – undo
1127 1193
 
1128 1194
 		while ($row = $smcFunc['db_fetch_assoc']($get_engines))
1129 1195
 		{
1130
-			if ($row['Support'] == 'YES' || $row['Support'] == 'DEFAULT')
1131
-				$engines[] = $row['Engine'];
1196
+			if ($row['Support'] == 'YES' || $row['Support'] == 'DEFAULT') {
1197
+							$engines[] = $row['Engine'];
1198
+			}
1132 1199
 		}
1133 1200
 
1134 1201
 		// Done with this now
@@ -1152,8 +1219,7 @@  discard block
 block discarded – undo
1152 1219
 			$replaces['START TRANSACTION;'] = '';
1153 1220
 			$replaces['COMMIT;'] = '';
1154 1221
 		}
1155
-	}
1156
-	else
1222
+	} else
1157 1223
 	{
1158 1224
 		$has_innodb = false;
1159 1225
 	}
@@ -1175,21 +1241,24 @@  discard block
 block discarded – undo
1175 1241
 	foreach ($sql_lines as $count => $line)
1176 1242
 	{
1177 1243
 		// No comments allowed!
1178
-		if (substr(trim($line), 0, 1) != '#')
1179
-			$current_statement .= "\n" . rtrim($line);
1244
+		if (substr(trim($line), 0, 1) != '#') {
1245
+					$current_statement .= "\n" . rtrim($line);
1246
+		}
1180 1247
 
1181 1248
 		// Is this the end of the query string?
1182
-		if (empty($current_statement) || (preg_match('~;[\s]*$~s', $line) == 0 && $count != count($sql_lines)))
1183
-			continue;
1249
+		if (empty($current_statement) || (preg_match('~;[\s]*$~s', $line) == 0 && $count != count($sql_lines))) {
1250
+					continue;
1251
+		}
1184 1252
 
1185 1253
 		// Does this table already exist?  If so, don't insert more data into it!
1186 1254
 		if (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) != 0 && in_array($match[1], $exists))
1187 1255
 		{
1188 1256
 			preg_match_all('~\)[,;]~', $current_statement, $matches);
1189
-			if (!empty($matches[0]))
1190
-				$incontext['sql_results']['insert_dups'] += count($matches[0]);
1191
-			else
1192
-				$incontext['sql_results']['insert_dups']++;
1257
+			if (!empty($matches[0])) {
1258
+							$incontext['sql_results']['insert_dups'] += count($matches[0]);
1259
+			} else {
1260
+							$incontext['sql_results']['insert_dups']++;
1261
+			}
1193 1262
 
1194 1263
 			$current_statement = '';
1195 1264
 			continue;
@@ -1198,8 +1267,9 @@  discard block
 block discarded – undo
1198 1267
 		if ($smcFunc['db_query']('', $current_statement, array('security_override' => true, 'db_error_skip' => true), $db_connection) === false)
1199 1268
 		{
1200 1269
 			// Use the appropriate function based on the DB type
1201
-			if ($db_type == 'mysql' || $db_type == 'mysqli')
1202
-				$db_errorno = $db_type . '_errno';
1270
+			if ($db_type == 'mysql' || $db_type == 'mysqli') {
1271
+							$db_errorno = $db_type . '_errno';
1272
+			}
1203 1273
 
1204 1274
 			// Error 1050: Table already exists!
1205 1275
 			// @todo Needs to be made better!
@@ -1214,18 +1284,18 @@  discard block
 block discarded – undo
1214 1284
 				// MySQLi requires a connection object. It's optional with MySQL and Postgres
1215 1285
 				$incontext['failures'][$count] = $smcFunc['db_error']($db_connection);
1216 1286
 			}
1217
-		}
1218
-		else
1287
+		} else
1219 1288
 		{
1220
-			if (preg_match('~^\s*CREATE TABLE ([^\s\n\r]+?)~', $current_statement, $match) == 1)
1221
-				$incontext['sql_results']['tables']++;
1222
-			elseif (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) == 1)
1289
+			if (preg_match('~^\s*CREATE TABLE ([^\s\n\r]+?)~', $current_statement, $match) == 1) {
1290
+							$incontext['sql_results']['tables']++;
1291
+			} elseif (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) == 1)
1223 1292
 			{
1224 1293
 				preg_match_all('~\)[,;]~', $current_statement, $matches);
1225
-				if (!empty($matches[0]))
1226
-					$incontext['sql_results']['inserts'] += count($matches[0]);
1227
-				else
1228
-					$incontext['sql_results']['inserts']++;
1294
+				if (!empty($matches[0])) {
1295
+									$incontext['sql_results']['inserts'] += count($matches[0]);
1296
+				} else {
1297
+									$incontext['sql_results']['inserts']++;
1298
+				}
1229 1299
 			}
1230 1300
 		}
1231 1301
 
@@ -1238,15 +1308,17 @@  discard block
 block discarded – undo
1238 1308
 	// Sort out the context for the SQL.
1239 1309
 	foreach ($incontext['sql_results'] as $key => $number)
1240 1310
 	{
1241
-		if ($number == 0)
1242
-			unset($incontext['sql_results'][$key]);
1243
-		else
1244
-			$incontext['sql_results'][$key] = sprintf($txt['db_populate_' . $key], $number);
1311
+		if ($number == 0) {
1312
+					unset($incontext['sql_results'][$key]);
1313
+		} else {
1314
+					$incontext['sql_results'][$key] = sprintf($txt['db_populate_' . $key], $number);
1315
+		}
1245 1316
 	}
1246 1317
 
1247 1318
 	// Make sure UTF will be used globally.
1248
-	if ((!empty($databases[$db_type]['utf8_support']) && !empty($databases[$db_type]['utf8_required'])) || (empty($databases[$db_type]['utf8_required']) && !empty($databases[$db_type]['utf8_support']) && isset($_POST['utf8'])))
1249
-		$newSettings[] = array('global_character_set', 'UTF-8');
1319
+	if ((!empty($databases[$db_type]['utf8_support']) && !empty($databases[$db_type]['utf8_required'])) || (empty($databases[$db_type]['utf8_required']) && !empty($databases[$db_type]['utf8_support']) && isset($_POST['utf8']))) {
1320
+			$newSettings[] = array('global_character_set', 'UTF-8');
1321
+	}
1250 1322
 
1251 1323
 	// Auto-detect local & global cookie settings
1252 1324
 	$url_parts = parse_url($boardurl);
@@ -1275,15 +1347,19 @@  discard block
 block discarded – undo
1275 1347
 
1276 1348
 		// Look for subfolder, if found, set localCookie
1277 1349
 		// Checking for len > 1 ensures you don't have just a slash...
1278
-		if (!empty($url_parts['path']) && strlen($url_parts['path']) > 1)
1279
-			$localCookies = '1';
1350
+		if (!empty($url_parts['path']) && strlen($url_parts['path']) > 1) {
1351
+					$localCookies = '1';
1352
+		}
1280 1353
 
1281
-		if (isset($globalCookies))
1282
-			$newSettings[] = array('globalCookies', $globalCookies);
1283
-		if (isset($globalCookiesDomain))
1284
-			$newSettings[] = array('globalCookiesDomain', $globalCookiesDomain);
1285
-		if (isset($localCookies))
1286
-			$newSettings[] = array('localCookies', $localCookies);
1354
+		if (isset($globalCookies)) {
1355
+					$newSettings[] = array('globalCookies', $globalCookies);
1356
+		}
1357
+		if (isset($globalCookiesDomain)) {
1358
+					$newSettings[] = array('globalCookiesDomain', $globalCookiesDomain);
1359
+		}
1360
+		if (isset($localCookies)) {
1361
+					$newSettings[] = array('localCookies', $localCookies);
1362
+		}
1287 1363
 	}
1288 1364
 
1289 1365
 	// Are we allowing stat collection?
@@ -1301,16 +1377,17 @@  discard block
 block discarded – undo
1301 1377
 			fwrite($fp, $out);
1302 1378
 
1303 1379
 			$return_data = '';
1304
-			while (!feof($fp))
1305
-				$return_data .= fgets($fp, 128);
1380
+			while (!feof($fp)) {
1381
+							$return_data .= fgets($fp, 128);
1382
+			}
1306 1383
 
1307 1384
 			fclose($fp);
1308 1385
 
1309 1386
 			// Get the unique site ID.
1310 1387
 			preg_match('~SITE-ID:\s(\w{10})~', $return_data, $ID);
1311 1388
 
1312
-			if (!empty($ID[1]))
1313
-				$smcFunc['db_insert']('replace',
1389
+			if (!empty($ID[1])) {
1390
+							$smcFunc['db_insert']('replace',
1314 1391
 					$db_prefix . 'settings',
1315 1392
 					array('variable' => 'string', 'value' => 'string'),
1316 1393
 					array(
@@ -1319,11 +1396,12 @@  discard block
 block discarded – undo
1319 1396
 					),
1320 1397
 					array('variable')
1321 1398
 				);
1399
+			}
1322 1400
 		}
1323 1401
 	}
1324 1402
 	// Don't remove stat collection unless we unchecked the box for real, not from the loop.
1325
-	elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats']))
1326
-		$smcFunc['db_query']('', '
1403
+	elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats'])) {
1404
+			$smcFunc['db_query']('', '
1327 1405
 			DELETE FROM {db_prefix}settings
1328 1406
 			WHERE variable = {string:enable_sm_stats}',
1329 1407
 			array(
@@ -1331,20 +1409,23 @@  discard block
 block discarded – undo
1331 1409
 				'db_error_skip' => true,
1332 1410
 			)
1333 1411
 		);
1412
+	}
1334 1413
 
1335 1414
 	// Are we enabling SSL?
1336
-	if (!empty($_POST['force_ssl']))
1337
-		$newSettings[] = array('force_ssl', 2);
1415
+	if (!empty($_POST['force_ssl'])) {
1416
+			$newSettings[] = array('force_ssl', 2);
1417
+	}
1338 1418
 
1339 1419
 	// Setting a timezone is required.
1340 1420
 	if (!isset($modSettings['default_timezone']) && function_exists('date_default_timezone_set'))
1341 1421
 	{
1342 1422
 		// Get PHP's default timezone, if set
1343 1423
 		$ini_tz = ini_get('date.timezone');
1344
-		if (!empty($ini_tz))
1345
-			$timezone_id = $ini_tz;
1346
-		else
1347
-			$timezone_id = '';
1424
+		if (!empty($ini_tz)) {
1425
+					$timezone_id = $ini_tz;
1426
+		} else {
1427
+					$timezone_id = '';
1428
+		}
1348 1429
 
1349 1430
 		// If date.timezone is unset, invalid, or just plain weird, make a best guess
1350 1431
 		if (!in_array($timezone_id, timezone_identifiers_list()))
@@ -1353,8 +1434,9 @@  discard block
 block discarded – undo
1353 1434
 			$timezone_id = timezone_name_from_abbr('', $server_offset, 0);
1354 1435
 		}
1355 1436
 
1356
-		if (date_default_timezone_set($timezone_id))
1357
-			$newSettings[] = array('default_timezone', $timezone_id);
1437
+		if (date_default_timezone_set($timezone_id)) {
1438
+					$newSettings[] = array('default_timezone', $timezone_id);
1439
+		}
1358 1440
 	}
1359 1441
 
1360 1442
 	if (!empty($newSettings))
@@ -1385,16 +1467,18 @@  discard block
 block discarded – undo
1385 1467
 	}
1386 1468
 
1387 1469
 	// MySQL specific stuff
1388
-	if (substr($db_type, 0, 5) != 'mysql')
1389
-		return false;
1470
+	if (substr($db_type, 0, 5) != 'mysql') {
1471
+			return false;
1472
+	}
1390 1473
 
1391 1474
 	// Find database user privileges.
1392 1475
 	$privs = array();
1393 1476
 	$get_privs = $smcFunc['db_query']('', 'SHOW PRIVILEGES', array());
1394 1477
 	while ($row = $smcFunc['db_fetch_assoc']($get_privs))
1395 1478
 	{
1396
-		if ($row['Privilege'] == 'Alter')
1397
-			$privs[] = $row['Privilege'];
1479
+		if ($row['Privilege'] == 'Alter') {
1480
+					$privs[] = $row['Privilege'];
1481
+		}
1398 1482
 	}
1399 1483
 	$smcFunc['db_free_result']($get_privs);
1400 1484
 
@@ -1424,8 +1508,9 @@  discard block
 block discarded – undo
1424 1508
 	$incontext['continue'] = 1;
1425 1509
 
1426 1510
 	// Skipping?
1427
-	if (!empty($_POST['skip']))
1428
-		return true;
1511
+	if (!empty($_POST['skip'])) {
1512
+			return true;
1513
+	}
1429 1514
 
1430 1515
 	// Need this to check whether we need the database password.
1431 1516
 	require(dirname(__FILE__) . '/Settings.php');
@@ -1442,18 +1527,22 @@  discard block
 block discarded – undo
1442 1527
 	// We need this to properly hash the password for Admin
1443 1528
 	$smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' : function($string) {
1444 1529
 			global $sourcedir;
1445
-			if (function_exists('mb_strtolower'))
1446
-				return mb_strtolower($string, 'UTF-8');
1530
+			if (function_exists('mb_strtolower')) {
1531
+							return mb_strtolower($string, 'UTF-8');
1532
+			}
1447 1533
 			require_once($sourcedir . '/Subs-Charset.php');
1448 1534
 			return utf8_strtolower($string);
1449 1535
 		};
1450 1536
 
1451
-	if (!isset($_POST['username']))
1452
-		$_POST['username'] = '';
1453
-	if (!isset($_POST['email']))
1454
-		$_POST['email'] = '';
1455
-	if (!isset($_POST['server_email']))
1456
-		$_POST['server_email'] = '';
1537
+	if (!isset($_POST['username'])) {
1538
+			$_POST['username'] = '';
1539
+	}
1540
+	if (!isset($_POST['email'])) {
1541
+			$_POST['email'] = '';
1542
+	}
1543
+	if (!isset($_POST['server_email'])) {
1544
+			$_POST['server_email'] = '';
1545
+	}
1457 1546
 
1458 1547
 	$incontext['username'] = htmlspecialchars(stripslashes($_POST['username']));
1459 1548
 	$incontext['email'] = htmlspecialchars(stripslashes($_POST['email']));
@@ -1472,8 +1561,9 @@  discard block
 block discarded – undo
1472 1561
 			'admin_group' => 1,
1473 1562
 		)
1474 1563
 	);
1475
-	if ($smcFunc['db_num_rows']($request) != 0)
1476
-		$incontext['skip'] = 1;
1564
+	if ($smcFunc['db_num_rows']($request) != 0) {
1565
+			$incontext['skip'] = 1;
1566
+	}
1477 1567
 	$smcFunc['db_free_result']($request);
1478 1568
 
1479 1569
 	// Trying to create an account?
@@ -1504,8 +1594,9 @@  discard block
 block discarded – undo
1504 1594
 		}
1505 1595
 
1506 1596
 		// Update the webmaster's email?
1507
-		if (!empty($_POST['server_email']) && (empty($webmaster_email) || $webmaster_email == '[email protected]'))
1508
-			updateSettingsFile(array('webmaster_email' => $_POST['server_email']));
1597
+		if (!empty($_POST['server_email']) && (empty($webmaster_email) || $webmaster_email == '[email protected]')) {
1598
+					updateSettingsFile(array('webmaster_email' => $_POST['server_email']));
1599
+		}
1509 1600
 
1510 1601
 		// Work out whether we're going to have dodgy characters and remove them.
1511 1602
 		$invalid_characters = preg_match('~[<>&"\'=\\\]~', $_POST['username']) != 0;
@@ -1528,32 +1619,27 @@  discard block
 block discarded – undo
1528 1619
 			$smcFunc['db_free_result']($result);
1529 1620
 
1530 1621
 			$incontext['account_existed'] = $txt['error_user_settings_taken'];
1531
-		}
1532
-		elseif ($_POST['username'] == '' || strlen($_POST['username']) > 25)
1622
+		} elseif ($_POST['username'] == '' || strlen($_POST['username']) > 25)
1533 1623
 		{
1534 1624
 			// Try the previous step again.
1535 1625
 			$incontext['error'] = $_POST['username'] == '' ? $txt['error_username_left_empty'] : $txt['error_username_too_long'];
1536 1626
 			return false;
1537
-		}
1538
-		elseif ($invalid_characters || $_POST['username'] == '_' || $_POST['username'] == '|' || strpos($_POST['username'], '[code') !== false || strpos($_POST['username'], '[/code') !== false)
1627
+		} elseif ($invalid_characters || $_POST['username'] == '_' || $_POST['username'] == '|' || strpos($_POST['username'], '[code') !== false || strpos($_POST['username'], '[/code') !== false)
1539 1628
 		{
1540 1629
 			// Try the previous step again.
1541 1630
 			$incontext['error'] = $txt['error_invalid_characters_username'];
1542 1631
 			return false;
1543
-		}
1544
-		elseif (empty($_POST['email']) || !filter_var(stripslashes($_POST['email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['email'])) > 255)
1632
+		} elseif (empty($_POST['email']) || !filter_var(stripslashes($_POST['email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['email'])) > 255)
1545 1633
 		{
1546 1634
 			// One step back, this time fill out a proper admin email address.
1547 1635
 			$incontext['error'] = sprintf($txt['error_valid_admin_email_needed'], $_POST['username']);
1548 1636
 			return false;
1549
-		}
1550
-		elseif (empty($_POST['server_email']) || !filter_var(stripslashes($_POST['server_email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['server_email'])) > 255)
1637
+		} elseif (empty($_POST['server_email']) || !filter_var(stripslashes($_POST['server_email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['server_email'])) > 255)
1551 1638
 		{
1552 1639
 			// One step back, this time fill out a proper admin email address.
1553 1640
 			$incontext['error'] = $txt['error_valid_server_email_needed'];
1554 1641
 			return false;
1555
-		}
1556
-		elseif ($_POST['username'] != '')
1642
+		} elseif ($_POST['username'] != '')
1557 1643
 		{
1558 1644
 			$incontext['member_salt'] = substr(md5(mt_rand()), 0, 4);
1559 1645
 
@@ -1621,17 +1707,19 @@  discard block
 block discarded – undo
1621 1707
 	reloadSettings();
1622 1708
 
1623 1709
 	// Bring a warning over.
1624
-	if (!empty($incontext['account_existed']))
1625
-		$incontext['warning'] = $incontext['account_existed'];
1710
+	if (!empty($incontext['account_existed'])) {
1711
+			$incontext['warning'] = $incontext['account_existed'];
1712
+	}
1626 1713
 
1627
-	if (!empty($db_character_set) && !empty($databases[$db_type]['utf8_support']))
1628
-		$smcFunc['db_query']('', '
1714
+	if (!empty($db_character_set) && !empty($databases[$db_type]['utf8_support'])) {
1715
+			$smcFunc['db_query']('', '
1629 1716
 			SET NAMES {string:db_character_set}',
1630 1717
 			array(
1631 1718
 				'db_character_set' => $db_character_set,
1632 1719
 				'db_error_skip' => true,
1633 1720
 			)
1634 1721
 		);
1722
+	}
1635 1723
 
1636 1724
 	// As track stats is by default enabled let's add some activity.
1637 1725
 	$smcFunc['db_insert']('ignore',
@@ -1652,14 +1740,16 @@  discard block
 block discarded – undo
1652 1740
 	// Only proceed if we can load the data.
1653 1741
 	if ($request)
1654 1742
 	{
1655
-		while ($row = $smcFunc['db_fetch_row']($request))
1656
-			$modSettings[$row[0]] = $row[1];
1743
+		while ($row = $smcFunc['db_fetch_row']($request)) {
1744
+					$modSettings[$row[0]] = $row[1];
1745
+		}
1657 1746
 		$smcFunc['db_free_result']($request);
1658 1747
 	}
1659 1748
 
1660 1749
 	// Automatically log them in ;)
1661
-	if (isset($incontext['member_id']) && isset($incontext['member_salt']))
1662
-		setLoginCookie(3153600 * 60, $incontext['member_id'], hash_salt($_POST['password1'], $incontext['member_salt']));
1750
+	if (isset($incontext['member_id']) && isset($incontext['member_salt'])) {
1751
+			setLoginCookie(3153600 * 60, $incontext['member_id'], hash_salt($_POST['password1'], $incontext['member_salt']));
1752
+	}
1663 1753
 
1664 1754
 	$result = $smcFunc['db_query']('', '
1665 1755
 		SELECT value
@@ -1670,13 +1760,14 @@  discard block
 block discarded – undo
1670 1760
 			'db_error_skip' => true,
1671 1761
 		)
1672 1762
 	);
1673
-	if ($smcFunc['db_num_rows']($result) != 0)
1674
-		list ($db_sessions) = $smcFunc['db_fetch_row']($result);
1763
+	if ($smcFunc['db_num_rows']($result) != 0) {
1764
+			list ($db_sessions) = $smcFunc['db_fetch_row']($result);
1765
+	}
1675 1766
 	$smcFunc['db_free_result']($result);
1676 1767
 
1677
-	if (empty($db_sessions))
1678
-		$_SESSION['admin_time'] = time();
1679
-	else
1768
+	if (empty($db_sessions)) {
1769
+			$_SESSION['admin_time'] = time();
1770
+	} else
1680 1771
 	{
1681 1772
 		$_SERVER['HTTP_USER_AGENT'] = substr($_SERVER['HTTP_USER_AGENT'], 0, 211);
1682 1773
 
@@ -1700,8 +1791,9 @@  discard block
 block discarded – undo
1700 1791
 	$smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' :
1701 1792
 		function($string){
1702 1793
 			global $sourcedir;
1703
-			if (function_exists('mb_strtolower'))
1704
-				return mb_strtolower($string, 'UTF-8');
1794
+			if (function_exists('mb_strtolower')) {
1795
+							return mb_strtolower($string, 'UTF-8');
1796
+			}
1705 1797
 			require_once($sourcedir . '/Subs-Charset.php');
1706 1798
 			return utf8_strtolower($string);
1707 1799
 		};
@@ -1717,8 +1809,9 @@  discard block
 block discarded – undo
1717 1809
 		)
1718 1810
 	);
1719 1811
 	$context['utf8'] = $db_character_set === 'utf8' || $txt['lang_character_set'] === 'UTF-8';
1720
-	if ($smcFunc['db_num_rows']($request) > 0)
1721
-		updateStats('subject', 1, htmlspecialchars($txt['default_topic_subject']));
1812
+	if ($smcFunc['db_num_rows']($request) > 0) {
1813
+			updateStats('subject', 1, htmlspecialchars($txt['default_topic_subject']));
1814
+	}
1722 1815
 	$smcFunc['db_free_result']($request);
1723 1816
 
1724 1817
 	// Now is the perfect time to fetch the SM files.
@@ -1737,8 +1830,9 @@  discard block
 block discarded – undo
1737 1830
 
1738 1831
 	// Check if we need some stupid MySQL fix.
1739 1832
 	$server_version = $smcFunc['db_server_info']();
1740
-	if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51')))
1741
-		updateSettings(array('db_mysql_group_by_fix' => '1'));
1833
+	if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) {
1834
+			updateSettings(array('db_mysql_group_by_fix' => '1'));
1835
+	}
1742 1836
 
1743 1837
 	// Some final context for the template.
1744 1838
 	$incontext['dir_still_writable'] = is_writable(dirname(__FILE__)) && substr(__FILE__, 1, 2) != ':\\';
@@ -1758,8 +1852,9 @@  discard block
 block discarded – undo
1758 1852
 	$settingsArray = file(dirname(__FILE__) . '/Settings.php');
1759 1853
 
1760 1854
 	// @todo Do we just want to read the file in clean, and split it this way always?
1761
-	if (count($settingsArray) == 1)
1762
-		$settingsArray = preg_split('~[\r\n]~', $settingsArray[0]);
1855
+	if (count($settingsArray) == 1) {
1856
+			$settingsArray = preg_split('~[\r\n]~', $settingsArray[0]);
1857
+	}
1763 1858
 
1764 1859
 	for ($i = 0, $n = count($settingsArray); $i < $n; $i++)
1765 1860
 	{
@@ -1774,19 +1869,22 @@  discard block
 block discarded – undo
1774 1869
 			continue;
1775 1870
 		}
1776 1871
 
1777
-		if (trim($settingsArray[$i]) == '?' . '>')
1778
-			$settingsArray[$i] = '';
1872
+		if (trim($settingsArray[$i]) == '?' . '>') {
1873
+					$settingsArray[$i] = '';
1874
+		}
1779 1875
 
1780 1876
 		// Don't trim or bother with it if it's not a variable.
1781
-		if (substr($settingsArray[$i], 0, 1) != '$')
1782
-			continue;
1877
+		if (substr($settingsArray[$i], 0, 1) != '$') {
1878
+					continue;
1879
+		}
1783 1880
 
1784 1881
 		$settingsArray[$i] = rtrim($settingsArray[$i]) . "\n";
1785 1882
 
1786
-		foreach ($vars as $var => $val)
1787
-			if (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0)
1883
+		foreach ($vars as $var => $val) {
1884
+					if (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0)
1788 1885
 			{
1789 1886
 				$comment = strstr($settingsArray[$i], '#');
1887
+		}
1790 1888
 				$settingsArray[$i] = '$' . $var . ' = \'' . $val . '\';' . ($comment != '' ? "\t\t" . $comment : "\n");
1791 1889
 				unset($vars[$var]);
1792 1890
 			}
@@ -1796,36 +1894,41 @@  discard block
 block discarded – undo
1796 1894
 	if (!empty($vars))
1797 1895
 	{
1798 1896
 		$settingsArray[$i++] = '';
1799
-		foreach ($vars as $var => $val)
1800
-			$settingsArray[$i++] = '$' . $var . ' = \'' . $val . '\';' . "\n";
1897
+		foreach ($vars as $var => $val) {
1898
+					$settingsArray[$i++] = '$' . $var . ' = \'' . $val . '\';' . "\n";
1899
+		}
1801 1900
 	}
1802 1901
 
1803 1902
 	// Blank out the file - done to fix a oddity with some servers.
1804 1903
 	$fp = @fopen(dirname(__FILE__) . '/Settings.php', 'w');
1805
-	if (!$fp)
1806
-		return false;
1904
+	if (!$fp) {
1905
+			return false;
1906
+	}
1807 1907
 	fclose($fp);
1808 1908
 
1809 1909
 	$fp = fopen(dirname(__FILE__) . '/Settings.php', 'r+');
1810 1910
 
1811 1911
 	// Gotta have one of these ;)
1812
-	if (trim($settingsArray[0]) != '<?php')
1813
-		fwrite($fp, "<?php\n");
1912
+	if (trim($settingsArray[0]) != '<?php') {
1913
+			fwrite($fp, "<?php\n");
1914
+	}
1814 1915
 
1815 1916
 	$lines = count($settingsArray);
1816 1917
 	for ($i = 0; $i < $lines - 1; $i++)
1817 1918
 	{
1818 1919
 		// Don't just write a bunch of blank lines.
1819
-		if ($settingsArray[$i] != '' || @$settingsArray[$i - 1] != '')
1820
-			fwrite($fp, strtr($settingsArray[$i], "\r", ''));
1920
+		if ($settingsArray[$i] != '' || @$settingsArray[$i - 1] != '') {
1921
+					fwrite($fp, strtr($settingsArray[$i], "\r", ''));
1922
+		}
1821 1923
 	}
1822 1924
 	fwrite($fp, $settingsArray[$i] . '?' . '>');
1823 1925
 	fclose($fp);
1824 1926
 
1825 1927
 	// Even though on normal installations the filemtime should prevent this being used by the installer incorrectly
1826 1928
 	// it seems that there are times it might not. So let's MAKE it dump the cache.
1827
-	if (function_exists('opcache_invalidate'))
1828
-		opcache_invalidate(dirname(__FILE__) . '/Settings.php', true);
1929
+	if (function_exists('opcache_invalidate')) {
1930
+			opcache_invalidate(dirname(__FILE__) . '/Settings.php', true);
1931
+	}
1829 1932
 
1830 1933
 	return true;
1831 1934
 }
@@ -1850,9 +1953,9 @@  discard block
 block discarded – undo
1850 1953
 	SecFilterScanPOST Off
1851 1954
 </IfModule>';
1852 1955
 
1853
-	if (!function_exists('apache_get_modules') || !in_array('mod_security', apache_get_modules()))
1854
-		return true;
1855
-	elseif (file_exists(dirname(__FILE__) . '/.htaccess') && is_writable(dirname(__FILE__) . '/.htaccess'))
1956
+	if (!function_exists('apache_get_modules') || !in_array('mod_security', apache_get_modules())) {
1957
+			return true;
1958
+	} elseif (file_exists(dirname(__FILE__) . '/.htaccess') && is_writable(dirname(__FILE__) . '/.htaccess'))
1856 1959
 	{
1857 1960
 		$current_htaccess = implode('', file(dirname(__FILE__) . '/.htaccess'));
1858 1961
 
@@ -1864,29 +1967,28 @@  discard block
 block discarded – undo
1864 1967
 				fwrite($ht_handle, $htaccess_addition);
1865 1968
 				fclose($ht_handle);
1866 1969
 				return true;
1970
+			} else {
1971
+							return false;
1867 1972
 			}
1868
-			else
1869
-				return false;
1973
+		} else {
1974
+					return true;
1870 1975
 		}
1871
-		else
1872
-			return true;
1873
-	}
1874
-	elseif (file_exists(dirname(__FILE__) . '/.htaccess'))
1875
-		return strpos(implode('', file(dirname(__FILE__) . '/.htaccess')), '<IfModule mod_security.c>') !== false;
1876
-	elseif (is_writable(dirname(__FILE__)))
1976
+	} elseif (file_exists(dirname(__FILE__) . '/.htaccess')) {
1977
+			return strpos(implode('', file(dirname(__FILE__) . '/.htaccess')), '<IfModule mod_security.c>') !== false;
1978
+	} elseif (is_writable(dirname(__FILE__)))
1877 1979
 	{
1878 1980
 		if ($ht_handle = fopen(dirname(__FILE__) . '/.htaccess', 'w'))
1879 1981
 		{
1880 1982
 			fwrite($ht_handle, $htaccess_addition);
1881 1983
 			fclose($ht_handle);
1882 1984
 			return true;
1985
+		} else {
1986
+					return false;
1883 1987
 		}
1884
-		else
1988
+	} else {
1885 1989
 			return false;
1886 1990
 	}
1887
-	else
1888
-		return false;
1889
-}
1991
+	}
1890 1992
 
1891 1993
 function template_install_above()
1892 1994
 {
@@ -1924,9 +2026,10 @@  discard block
 block discarded – undo
1924 2026
 								<label for="installer_language">', $txt['installer_language'], ':</label>
1925 2027
 								<select id="installer_language" name="lang_file" onchange="location.href = \'', $installurl, '?lang_file=\' + this.options[this.selectedIndex].value;">';
1926 2028
 
1927
-		foreach ($incontext['detected_languages'] as $lang => $name)
1928
-			echo '
2029
+		foreach ($incontext['detected_languages'] as $lang => $name) {
2030
+					echo '
1929 2031
 									<option', isset($_SESSION['installer_temp_lang']) && $_SESSION['installer_temp_lang'] == $lang ? ' selected' : '', ' value="', $lang, '">', $name, '</option>';
2032
+		}
1930 2033
 
1931 2034
 		echo '
1932 2035
 								</select>
@@ -1946,9 +2049,10 @@  discard block
 block discarded – undo
1946 2049
 						<h2>', $txt['upgrade_progress'], '</h2>
1947 2050
 						<ul>';
1948 2051
 
1949
-	foreach ($incontext['steps'] as $num => $step)
1950
-		echo '
2052
+	foreach ($incontext['steps'] as $num => $step) {
2053
+			echo '
1951 2054
 							<li class="', $num < $incontext['current_step'] ? 'stepdone' : ($num == $incontext['current_step'] ? 'stepcurrent' : 'stepwaiting'), '">', $txt['upgrade_step'], ' ', $step[0], ': ', $step[1], '</li>';
2055
+	}
1952 2056
 
1953 2057
 	echo '
1954 2058
 						</ul>
@@ -1973,20 +2077,23 @@  discard block
 block discarded – undo
1973 2077
 		echo '
1974 2078
 								<div class="floatright">';
1975 2079
 
1976
-		if (!empty($incontext['continue']))
1977
-			echo '
2080
+		if (!empty($incontext['continue'])) {
2081
+					echo '
1978 2082
 									<input type="submit" id="contbutt" name="contbutt" value="', $txt['upgrade_continue'], '" onclick="return submitThisOnce(this);" class="button" />';
1979
-		if (!empty($incontext['skip']))
1980
-			echo '
2083
+		}
2084
+		if (!empty($incontext['skip'])) {
2085
+					echo '
1981 2086
 									<input type="submit" id="skip" name="skip" value="', $txt['upgrade_skip'], '" onclick="return submitThisOnce(this);" class="button" />';
2087
+		}
1982 2088
 		echo '
1983 2089
 								</div>';
1984 2090
 	}
1985 2091
 
1986 2092
 	// Show the closing form tag and other data only if not in the last step
1987
-	if (count($incontext['steps']) - 1 !== (int) $incontext['current_step'])
1988
-		echo '
2093
+	if (count($incontext['steps']) - 1 !== (int) $incontext['current_step']) {
2094
+			echo '
1989 2095
 							</form>';
2096
+	}
1990 2097
 
1991 2098
 	echo '
1992 2099
 						</div>
@@ -2021,13 +2128,15 @@  discard block
 block discarded – undo
2021 2128
 		</div>';
2022 2129
 
2023 2130
 	// Show the warnings, or not.
2024
-	if (template_warning_divs())
2025
-		echo '
2131
+	if (template_warning_divs()) {
2132
+			echo '
2026 2133
 		<h3>', $txt['install_all_lovely'], '</h3>';
2134
+	}
2027 2135
 
2028 2136
 	// Say we want the continue button!
2029
-	if (empty($incontext['error']))
2030
-		$incontext['continue'] = 1;
2137
+	if (empty($incontext['error'])) {
2138
+			$incontext['continue'] = 1;
2139
+	}
2031 2140
 
2032 2141
 	// For the latest version stuff.
2033 2142
 	echo '
@@ -2061,8 +2170,8 @@  discard block
 block discarded – undo
2061 2170
 	global $txt, $incontext;
2062 2171
 
2063 2172
 	// Errors are very serious..
2064
-	if (!empty($incontext['error']))
2065
-		echo '
2173
+	if (!empty($incontext['error'])) {
2174
+			echo '
2066 2175
 		<div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;">
2067 2176
 			<div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div>
2068 2177
 			<strong style="text-decoration: underline;">', $txt['upgrade_critical_error'], '</strong><br>
@@ -2070,9 +2179,10 @@  discard block
 block discarded – undo
2070 2179
 				', $incontext['error'], '
2071 2180
 			</div>
2072 2181
 		</div>';
2182
+	}
2073 2183
 	// A warning message?
2074
-	elseif (!empty($incontext['warning']))
2075
-		echo '
2184
+	elseif (!empty($incontext['warning'])) {
2185
+			echo '
2076 2186
 		<div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;">
2077 2187
 			<div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div>
2078 2188
 			<strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br>
@@ -2080,6 +2190,7 @@  discard block
 block discarded – undo
2080 2190
 				', $incontext['warning'], '
2081 2191
 			</div>
2082 2192
 		</div>';
2193
+	}
2083 2194
 
2084 2195
 	return empty($incontext['error']) && empty($incontext['warning']);
2085 2196
 }
@@ -2095,27 +2206,30 @@  discard block
 block discarded – undo
2095 2206
 			<li>', $incontext['failed_files']), '</li>
2096 2207
 		</ul>';
2097 2208
 
2098
-	if (isset($incontext['systemos'], $incontext['detected_path']) && $incontext['systemos'] == 'linux')
2099
-		echo '
2209
+	if (isset($incontext['systemos'], $incontext['detected_path']) && $incontext['systemos'] == 'linux') {
2210
+			echo '
2100 2211
 		<hr>
2101 2212
 		<p>', $txt['chmod_linux_info'], '</p>
2102 2213
 		<tt># chmod a+w ', implode(' ' . $incontext['detected_path'] . '/', $incontext['failed_files']), '</tt>';
2214
+	}
2103 2215
 
2104 2216
 	// This is serious!
2105
-	if (!template_warning_divs())
2106
-		return;
2217
+	if (!template_warning_divs()) {
2218
+			return;
2219
+	}
2107 2220
 
2108 2221
 	echo '
2109 2222
 		<hr>
2110 2223
 		<p>', $txt['ftp_setup_info'], '</p>';
2111 2224
 
2112
-	if (!empty($incontext['ftp_errors']))
2113
-		echo '
2225
+	if (!empty($incontext['ftp_errors'])) {
2226
+			echo '
2114 2227
 		<div class="error_message">
2115 2228
 			', $txt['error_ftp_no_connect'], '<br><br>
2116 2229
 			<code>', implode('<br>', $incontext['ftp_errors']), '</code>
2117 2230
 		</div>
2118 2231
 		<br>';
2232
+	}
2119 2233
 
2120 2234
 	echo '
2121 2235
 		<form action="', $incontext['form_url'], '" method="post">
@@ -2175,17 +2289,17 @@  discard block
 block discarded – undo
2175 2289
 				<td>
2176 2290
 					<select name="db_type" id="db_type_input" onchange="toggleDBInput();">';
2177 2291
 
2178
-	foreach ($incontext['supported_databases'] as $key => $db)
2179
-			echo '
2292
+	foreach ($incontext['supported_databases'] as $key => $db) {
2293
+				echo '
2180 2294
 						<option value="', $key, '"', isset($_POST['db_type']) && $_POST['db_type'] == $key ? ' selected' : '', '>', $db['name'], '</option>';
2295
+	}
2181 2296
 
2182 2297
 	echo '
2183 2298
 					</select>
2184 2299
 					<div class="smalltext block">', $txt['db_settings_type_info'], '</div>
2185 2300
 				</td>
2186 2301
 			</tr>';
2187
-	}
2188
-	else
2302
+	} else
2189 2303
 	{
2190 2304
 		echo '
2191 2305
 			<tr style="display: none;">
@@ -2378,9 +2492,10 @@  discard block
 block discarded – undo
2378 2492
 				<div style="color: red;">', $txt['error_db_queries'], '</div>
2379 2493
 				<ul>';
2380 2494
 
2381
-		foreach ($incontext['failures'] as $line => $fail)
2382
-			echo '
2495
+		foreach ($incontext['failures'] as $line => $fail) {
2496
+					echo '
2383 2497
 						<li><strong>', $txt['error_db_queries_line'], $line + 1, ':</strong> ', nl2br(htmlspecialchars($fail)), '</li>';
2498
+		}
2384 2499
 
2385 2500
 		echo '
2386 2501
 				</ul>';
@@ -2441,15 +2556,16 @@  discard block
 block discarded – undo
2441 2556
 			</tr>
2442 2557
 		</table>';
2443 2558
 
2444
-	if ($incontext['require_db_confirm'])
2445
-		echo '
2559
+	if ($incontext['require_db_confirm']) {
2560
+			echo '
2446 2561
 		<h2>', $txt['user_settings_database'], '</h2>
2447 2562
 		<p>', $txt['user_settings_database_info'], '</p>
2448 2563
 
2449 2564
 		<div style="margin-bottom: 2ex; padding-', $txt['lang_rtl'] == false ? 'left' : 'right', ': 50px;">
2450 2565
 			<input type="password" name="password3" size="30" />
2451 2566
 		</div>';
2452
-}
2567
+	}
2568
+	}
2453 2569
 
2454 2570
 // Tell them it's done, and to delete.
2455 2571
 function template_delete_install()
@@ -2462,14 +2578,15 @@  discard block
 block discarded – undo
2462 2578
 	template_warning_divs();
2463 2579
 
2464 2580
 	// Install directory still writable?
2465
-	if ($incontext['dir_still_writable'])
2466
-		echo '
2581
+	if ($incontext['dir_still_writable']) {
2582
+			echo '
2467 2583
 		<em>', $txt['still_writable'], '</em><br>
2468 2584
 		<br>';
2585
+	}
2469 2586
 
2470 2587
 	// Don't show the box if it's like 99% sure it won't work :P.
2471
-	if ($incontext['probably_delete_install'])
2472
-		echo '
2588
+	if ($incontext['probably_delete_install']) {
2589
+			echo '
2473 2590
 		<div style="margin: 1ex; font-weight: bold;">
2474 2591
 			<label for="delete_self"><input type="checkbox" id="delete_self" onclick="doTheDelete();" /> ', $txt['delete_installer'], !isset($_SESSION['installer_temp_ftp']) ? ' ' . $txt['delete_installer_maybe'] : '', '</label>
2475 2592
 		</div>
@@ -2485,6 +2602,7 @@  discard block
 block discarded – undo
2485 2602
 			}
2486 2603
 		</script>
2487 2604
 		<br>';
2605
+	}
2488 2606
 
2489 2607
 	echo '
2490 2608
 		', sprintf($txt['go_to_your_forum'], $boardurl . '/index.php'), '<br>
Please login to merge, or discard this patch.
Themes/default/Recent.template.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@
 block discarded – undo
21 21
 	<div id="recent" class="main_section">
22 22
 		<div class="cat_bar">
23 23
 			<h3 class="catbg">
24
-				<span class="xx"></span>',$txt['recent_posts'],'
24
+				<span class="xx"></span>',$txt['recent_posts'], '
25 25
 			</h3>
26 26
 		</div>
27 27
 		<div class="pagesection">', $context['page_index'], '</div>';
Please login to merge, or discard this patch.
Braces   +77 added lines, -54 removed lines patch added patch discarded remove patch
@@ -26,9 +26,10 @@  discard block
 block discarded – undo
26 26
 		</div>
27 27
 		<div class="pagesection">', $context['page_index'], '</div>';
28 28
 
29
-	if (empty($context['posts']))
30
-		echo '
29
+	if (empty($context['posts'])) {
30
+			echo '
31 31
 		<div class="windowbg">', $txt['no_messages'], '</div>';
32
+	}
32 33
 
33 34
 	foreach ($context['posts'] as $post)
34 35
 	{
@@ -41,28 +42,33 @@  discard block
 block discarded – undo
41 42
 			</div>
42 43
 			<div class="list_posts">', $post['message'], '</div>';
43 44
 
44
-		if ($post['can_reply'] || $post['can_quote'] || $post['can_delete'])
45
-			echo '
45
+		if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) {
46
+					echo '
46 47
 			<ul class="quickbuttons">';
48
+		}
47 49
 
48 50
 		// If they *can* reply?
49
-		if ($post['can_reply'])
50
-			echo '
51
+		if ($post['can_reply']) {
52
+					echo '
51 53
 				<li><a href="', $scripturl, '?action=post;topic=', $post['topic'], '.', $post['start'], '"><span class="generic_icons reply_button"></span>', $txt['reply'], '</a></li>';
54
+		}
52 55
 
53 56
 		// If they *can* quote?
54
-		if ($post['can_quote'])
55
-			echo '
57
+		if ($post['can_quote']) {
58
+					echo '
56 59
 				<li><a href="', $scripturl, '?action=post;topic=', $post['topic'], '.', $post['start'], ';quote=', $post['id'], '"><span class="generic_icons quote"></span>', $txt['quote_action'], '</a></li>';
60
+		}
57 61
 
58 62
 		// How about... even... remove it entirely?!
59
-		if ($post['can_delete'])
60
-			echo '
63
+		if ($post['can_delete']) {
64
+					echo '
61 65
 				<li><a href="', $scripturl, '?action=deletemsg;msg=', $post['id'], ';topic=', $post['topic'], ';recent;', $context['session_var'], '=', $context['session_id'], '" data-confirm="', $txt['remove_message'], '" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['remove'], '</a></li>';
66
+		}
62 67
 
63
-		if ($post['can_reply'] || $post['can_quote'] || $post['can_delete'])
64
-			echo '
68
+		if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) {
69
+					echo '
65 70
 			</ul>';
71
+		}
66 72
 
67 73
 		echo '
68 74
 		</div><!-- $post[css_class] -->';
@@ -84,12 +90,13 @@  discard block
 block discarded – undo
84 90
 	echo '
85 91
 	<div id="recent" class="main_content">';
86 92
 
87
-	if ($context['showCheckboxes'])
88
-		echo '
93
+	if ($context['showCheckboxes']) {
94
+			echo '
89 95
 		<form action="', $scripturl, '?action=quickmod" method="post" accept-charset="', $context['character_set'], '" name="quickModForm" id="quickModForm">
90 96
 			<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
91 97
 			<input type="hidden" name="qaction" value="markread">
92 98
 			<input type="hidden" name="redirect_url" value="action=unread', (!empty($context['showing_all_topics']) ? ';all' : ''), $context['querystring_board_limits'], '">';
99
+	}
93 100
 
94 101
 	if (!empty($context['topics']))
95 102
 	{
@@ -118,11 +125,12 @@  discard block
 block discarded – undo
118 125
 					</div>';
119 126
 
120 127
 		// Show a "select all" box for quick moderation?
121
-		if ($context['showCheckboxes'])
122
-			echo '
128
+		if ($context['showCheckboxes']) {
129
+					echo '
123 130
 					<div class="moderation">
124 131
 						<input type="checkbox" onclick="invertAll(this, this.form, \'topics[]\');">
125 132
 					</div>';
133
+		}
126 134
 
127 135
 		echo '
128 136
 				</div><!-- #topic_header -->
@@ -142,17 +150,20 @@  discard block
 block discarded – undo
142 150
 			echo '
143 151
 							<div class="icons floatright">';
144 152
 
145
-			if ($topic['is_locked'])
146
-				echo '
153
+			if ($topic['is_locked']) {
154
+							echo '
147 155
 								<span class="generic_icons lock"></span>';
156
+			}
148 157
 
149
-			if ($topic['is_sticky'])
150
-				echo '
158
+			if ($topic['is_sticky']) {
159
+							echo '
151 160
 								<span class="generic_icons sticky"></span>';
161
+			}
152 162
 
153
-			if ($topic['is_poll'])
154
-				echo '
163
+			if ($topic['is_poll']) {
164
+							echo '
155 165
 								<span class="generic_icons poll"></span>';
166
+			}
156 167
 
157 168
 			echo '
158 169
 							</div>';
@@ -178,19 +189,21 @@  discard block
 block discarded – undo
178 189
 							', sprintf($txt['last_post_topic'], '<a href="' . $topic['last_post']['href'] . '">' . $topic['last_post']['time'] . '</a>', $topic['last_post']['member']['link']), '
179 190
 						</div>';
180 191
 
181
-			if ($context['showCheckboxes'])
182
-				echo '
192
+			if ($context['showCheckboxes']) {
193
+							echo '
183 194
 						<div class="moderation">
184 195
 							<input type="checkbox" name="topics[]" value="', $topic['id'], '">
185 196
 						</div>';
197
+			}
186 198
 
187 199
 			echo '
188 200
 					</div><!-- $topic[css_class] -->';
189 201
 		}
190 202
 
191
-		if (empty($context['topics']))
192
-			echo '
203
+		if (empty($context['topics'])) {
204
+					echo '
193 205
 					<div style="display: none;"></div>';
206
+		}
194 207
 
195 208
 		echo '
196 209
 				</div><!-- #topic_container -->
@@ -205,25 +218,27 @@  discard block
 block discarded – undo
205 218
 					', $context['page_index'], '
206 219
 				</div>
207 220
 			</div>';
208
-	}
209
-	else
210
-		echo '
221
+	} else {
222
+			echo '
211 223
 			<div class="cat_bar">
212 224
 				<h3 class="catbg centertext">
213 225
 					', $context['showing_all_topics'] ? $txt['topic_alert_none'] : $txt['unread_topics_visit_none'], '
214 226
 				</h3>
215 227
 			</div>';
228
+	}
216 229
 
217
-	if ($context['showCheckboxes'])
218
-		echo '
230
+	if ($context['showCheckboxes']) {
231
+			echo '
219 232
 		</form>';
233
+	}
220 234
 
221 235
 	echo '
222 236
 	</div><!-- #recent -->';
223 237
 
224
-	if (empty($context['no_topic_listing']))
225
-		template_topic_legend();
226
-}
238
+	if (empty($context['no_topic_listing'])) {
239
+			template_topic_legend();
240
+	}
241
+	}
227 242
 
228 243
 /**
229 244
  * Template for showing unread replies (eg new replies to topics you've posted in)
@@ -235,12 +250,13 @@  discard block
 block discarded – undo
235 250
 	echo '
236 251
 	<div id="recent">';
237 252
 
238
-	if ($context['showCheckboxes'])
239
-		echo '
253
+	if ($context['showCheckboxes']) {
254
+			echo '
240 255
 		<form action="', $scripturl, '?action=quickmod" method="post" accept-charset="', $context['character_set'], '" name="quickModForm" id="quickModForm">
241 256
 			<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
242 257
 			<input type="hidden" name="qaction" value="markread">
243 258
 			<input type="hidden" name="redirect_url" value="action=unreadreplies', (!empty($context['showing_all_topics']) ? ';all' : ''), $context['querystring_board_limits'], '">';
259
+	}
244 260
 
245 261
 	if (!empty($context['topics']))
246 262
 	{
@@ -269,11 +285,12 @@  discard block
 block discarded – undo
269 285
 					</div>';
270 286
 
271 287
 		// Show a "select all" box for quick moderation?
272
-		if ($context['showCheckboxes'])
273
-			echo '
288
+		if ($context['showCheckboxes']) {
289
+					echo '
274 290
 					<div class="moderation">
275 291
 						<input type="checkbox" onclick="invertAll(this, this.form, \'topics[]\');">
276 292
 					</div>';
293
+		}
277 294
 
278 295
 		echo '
279 296
 				</div><!-- #topic_header -->
@@ -293,17 +310,20 @@  discard block
 block discarded – undo
293 310
 			echo '
294 311
 							<div class="icons floatright">';
295 312
 
296
-			if ($topic['is_locked'])
297
-				echo '
313
+			if ($topic['is_locked']) {
314
+							echo '
298 315
 								<span class="generic_icons lock"></span>';
316
+			}
299 317
 
300
-			if ($topic['is_sticky'])
301
-				echo '
318
+			if ($topic['is_sticky']) {
319
+							echo '
302 320
 								<span class="generic_icons sticky"></span>';
321
+			}
303 322
 
304
-			if ($topic['is_poll'])
305
-				echo '
323
+			if ($topic['is_poll']) {
324
+							echo '
306 325
 								<span class="generic_icons poll"></span>';
326
+			}
307 327
 
308 328
 			echo '
309 329
 							</div>';
@@ -329,11 +349,12 @@  discard block
 block discarded – undo
329 349
 							', sprintf($txt['last_post_topic'], '<a href="' . $topic['last_post']['href'] . '">' . $topic['last_post']['time'] . '</a>', $topic['last_post']['member']['link']), '
330 350
 						</div>';
331 351
 
332
-			if ($context['showCheckboxes'])
333
-				echo '
352
+			if ($context['showCheckboxes']) {
353
+							echo '
334 354
 						<div class="moderation">
335 355
 							<input type="checkbox" name="topics[]" value="', $topic['id'], '">
336 356
 						</div>';
357
+			}
337 358
 
338 359
 			echo '
339 360
 					</div><!-- $topic[css_class] -->';
@@ -350,24 +371,26 @@  discard block
 block discarded – undo
350 371
 					', $context['page_index'], '
351 372
 				</div>
352 373
 			</div>';
353
-	}
354
-	else
355
-		echo '
374
+	} else {
375
+			echo '
356 376
 			<div class="cat_bar">
357 377
 				<h3 class="catbg centertext">
358 378
 					', $context['showing_all_topics'] ? $txt['topic_alert_none'] : $txt['unread_topics_visit_none'], '
359 379
 				</h3>
360 380
 			</div>';
381
+	}
361 382
 
362
-	if ($context['showCheckboxes'])
363
-		echo '
383
+	if ($context['showCheckboxes']) {
384
+			echo '
364 385
 		</form>';
386
+	}
365 387
 
366 388
 	echo '
367 389
 	</div><!-- #recent -->';
368 390
 
369
-	if (empty($context['no_topic_listing']))
370
-		template_topic_legend();
371
-}
391
+	if (empty($context['no_topic_listing'])) {
392
+			template_topic_legend();
393
+	}
394
+	}
372 395
 
373 396
 ?>
374 397
\ No newline at end of file
Please login to merge, or discard this patch.
Sources/Who.php 3 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -673,7 +673,7 @@
 block discarded – undo
673 673
 						'Nikola &quot;Dzonny&quot; Novakovi&cacute;',
674 674
 						// Localizers
675 675
 						'Dr. Deejay',
676
-                        			'd3vcho',
676
+									'd3vcho',
677 677
 						// Former Localizers
678 678
 						'Relyana',
679 679
 					),
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -590,7 +590,7 @@  discard block
 block discarded – undo
590 590
 						'Shitiz &quot;Dragooon&quot; Garg',
591 591
 						'Karl &quot;RegularExpression&quot; Benson',
592 592
 						'Matthew &quot;Labradoodle-360&quot; Kerle',
593
-						$user_info['is_admin'] ? 'Matt &quot;Grudge&quot; Wolf': 'Grudge',
593
+						$user_info['is_admin'] ? 'Matt &quot;Grudge&quot; Wolf' : 'Grudge',
594 594
 						'Michael &quot;Thantos&quot; Miller',
595 595
 						'Norv',
596 596
 						'Peter "Arantor" Spicer',
@@ -814,13 +814,13 @@  discard block
 block discarded – undo
814 814
 			$credit_info = $smcFunc['json_decode']($row['credits'], true);
815 815
 
816 816
 			$copyright = empty($credit_info['copyright']) ? '' : $txt['credits_copyright'] . ' &copy; ' . $smcFunc['htmlspecialchars']($credit_info['copyright']);
817
-			$license = empty($credit_info['license']) ? '' : $txt['credits_license'] . ': ' . (!empty($credit_info['licenseurl']) ? '<a href="'. $smcFunc['htmlspecialchars']($credit_info['licenseurl']) .'">'. $smcFunc['htmlspecialchars']($credit_info['license']) .'</a>' : $smcFunc['htmlspecialchars']($credit_info['license']));
817
+			$license = empty($credit_info['license']) ? '' : $txt['credits_license'] . ': ' . (!empty($credit_info['licenseurl']) ? '<a href="' . $smcFunc['htmlspecialchars']($credit_info['licenseurl']) . '">' . $smcFunc['htmlspecialchars']($credit_info['license']) . '</a>' : $smcFunc['htmlspecialchars']($credit_info['license']));
818 818
 			$version = $txt['credits_version'] . ' ' . $row['version'];
819 819
 			$title = (empty($credit_info['title']) ? $row['name'] : $smcFunc['htmlspecialchars']($credit_info['title'])) . ': ' . $version;
820 820
 
821 821
 			// build this one out and stash it away
822 822
 			$mod_name = empty($credit_info['url']) ? $title : '<a href="' . $credit_info['url'] . '">' . $title . '</a>';
823
-			$mods[] = $mod_name . (!empty($license) ? ' | ' . $license  : '') . (!empty($copyright) ? ' | ' . $copyright  : '');
823
+			$mods[] = $mod_name . (!empty($license) ? ' | ' . $license : '') . (!empty($copyright) ? ' | ' . $copyright : '');
824 824
 		}
825 825
 		cache_put_data('mods_credits', $mods, 86400);
826 826
 	}
Please login to merge, or discard this patch.
Braces   +126 added lines, -95 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
  * Who's online, and what are they doing?
@@ -35,8 +36,9 @@  discard block
 block discarded – undo
35 36
 	isAllowedTo('who_view');
36 37
 
37 38
 	// You can't do anything if this is off.
38
-	if (empty($modSettings['who_enabled']))
39
-		fatal_lang_error('who_off', false);
39
+	if (empty($modSettings['who_enabled'])) {
40
+			fatal_lang_error('who_off', false);
41
+	}
40 42
 
41 43
 	// Load the 'Who' template.
42 44
 	loadTemplate('Who');
@@ -71,9 +73,9 @@  discard block
 block discarded – undo
71 73
 		$show_methods['spiders'] = '(lo.id_member = 0 AND lo.id_spider > 0)';
72 74
 		$show_methods['guests'] = '(lo.id_member = 0 AND lo.id_spider = 0)';
73 75
 		$context['show_methods']['spiders'] = $txt['who_show_spiders_only'];
76
+	} elseif (empty($modSettings['show_spider_online']) && isset($_SESSION['who_online_filter']) && $_SESSION['who_online_filter'] == 'spiders') {
77
+			unset($_SESSION['who_online_filter']);
74 78
 	}
75
-	elseif (empty($modSettings['show_spider_online']) && isset($_SESSION['who_online_filter']) && $_SESSION['who_online_filter'] == 'spiders')
76
-		unset($_SESSION['who_online_filter']);
77 79
 
78 80
 	// Does the user prefer a different sort direction?
79 81
 	if (isset($_REQUEST['sort']) && isset($sort_methods[$_REQUEST['sort']]))
@@ -97,20 +99,24 @@  discard block
 block discarded – undo
97 99
 	$context['sort_direction'] = isset($_REQUEST['asc']) || (isset($_REQUEST['sort_dir']) && $_REQUEST['sort_dir'] == 'asc') ? 'up' : 'down';
98 100
 
99 101
 	$conditions = array();
100
-	if (!allowedTo('moderate_forum'))
101
-		$conditions[] = '(COALESCE(mem.show_online, 1) = 1)';
102
+	if (!allowedTo('moderate_forum')) {
103
+			$conditions[] = '(COALESCE(mem.show_online, 1) = 1)';
104
+	}
102 105
 
103 106
 	// Fallback to top filter?
104
-	if (isset($_REQUEST['submit_top']) && isset($_REQUEST['show_top']))
105
-		$_REQUEST['show'] = $_REQUEST['show_top'];
107
+	if (isset($_REQUEST['submit_top']) && isset($_REQUEST['show_top'])) {
108
+			$_REQUEST['show'] = $_REQUEST['show_top'];
109
+	}
106 110
 	// Does the user wish to apply a filter?
107
-	if (isset($_REQUEST['show']) && isset($show_methods[$_REQUEST['show']]))
108
-		$context['show_by'] = $_SESSION['who_online_filter'] = $_REQUEST['show'];
111
+	if (isset($_REQUEST['show']) && isset($show_methods[$_REQUEST['show']])) {
112
+			$context['show_by'] = $_SESSION['who_online_filter'] = $_REQUEST['show'];
113
+	}
109 114
 	// Perhaps we saved a filter earlier in the session?
110
-	elseif (isset($_SESSION['who_online_filter']))
111
-		$context['show_by'] = $_SESSION['who_online_filter'];
112
-	else
113
-		$context['show_by'] = 'members';
115
+	elseif (isset($_SESSION['who_online_filter'])) {
116
+			$context['show_by'] = $_SESSION['who_online_filter'];
117
+	} else {
118
+			$context['show_by'] = 'members';
119
+	}
114 120
 
115 121
 	$conditions[] = $show_methods[$context['show_by']];
116 122
 
@@ -156,8 +162,9 @@  discard block
 block discarded – undo
156 162
 	while ($row = $smcFunc['db_fetch_assoc']($request))
157 163
 	{
158 164
 		$actions = $smcFunc['json_decode']($row['url'], true);
159
-		if ($actions === false)
160
-			continue;
165
+		if ($actions === false) {
166
+					continue;
167
+		}
161 168
 
162 169
 		// Send the information to the template.
163 170
 		$context['members'][$row['session']] = array(
@@ -195,8 +202,8 @@  discard block
 block discarded – undo
195 202
 	$spiderContext = array();
196 203
 	if (!empty($modSettings['show_spider_online']) && ($modSettings['show_spider_online'] == 2 || allowedTo('admin_forum')) && !empty($modSettings['spider_name_cache']))
197 204
 	{
198
-		foreach ($smcFunc['json_decode']($modSettings['spider_name_cache'], true) as $id => $name)
199
-			$spiderContext[$id] = array(
205
+		foreach ($smcFunc['json_decode']($modSettings['spider_name_cache'], true) as $id => $name) {
206
+					$spiderContext[$id] = array(
200 207
 				'id' => 0,
201 208
 				'name' => $name,
202 209
 				'group' => $txt['spiders'],
@@ -205,6 +212,7 @@  discard block
 block discarded – undo
205 212
 				'email' => $name,
206 213
 				'is_guest' => true
207 214
 			);
215
+		}
208 216
 	}
209 217
 
210 218
 	$url_data = determineActions($url_data);
@@ -219,16 +227,18 @@  discard block
 block discarded – undo
219 227
 	// Put it in the context variables.
220 228
 	foreach ($context['members'] as $i => $member)
221 229
 	{
222
-		if ($member['id'] != 0)
223
-			$member['id'] = loadMemberContext($member['id']) ? $member['id'] : 0;
230
+		if ($member['id'] != 0) {
231
+					$member['id'] = loadMemberContext($member['id']) ? $member['id'] : 0;
232
+		}
224 233
 
225 234
 		// Keep the IP that came from the database.
226 235
 		$memberContext[$member['id']]['ip'] = $member['ip'];
227 236
 		$context['members'][$i]['action'] = isset($url_data[$i]) ? $url_data[$i] : $txt['who_hidden'];
228
-		if ($member['id'] == 0 && isset($spiderContext[$member['id_spider']]))
229
-			$context['members'][$i] += $spiderContext[$member['id_spider']];
230
-		else
231
-			$context['members'][$i] += $memberContext[$member['id']];
237
+		if ($member['id'] == 0 && isset($spiderContext[$member['id_spider']])) {
238
+					$context['members'][$i] += $spiderContext[$member['id_spider']];
239
+		} else {
240
+					$context['members'][$i] += $memberContext[$member['id']];
241
+		}
232 242
 	}
233 243
 
234 244
 	// Some people can't send personal messages...
@@ -263,8 +273,9 @@  discard block
 block discarded – undo
263 273
 {
264 274
 	global $txt, $user_info, $modSettings, $smcFunc;
265 275
 
266
-	if (!allowedTo('who_view'))
267
-		return array();
276
+	if (!allowedTo('who_view')) {
277
+			return array();
278
+	}
268 279
 	loadLanguage('Who');
269 280
 
270 281
 	// Actions that require a specific permission level.
@@ -292,10 +303,11 @@  discard block
 block discarded – undo
292 303
 	);
293 304
 	call_integration_hook('who_allowed', array(&$allowedActions));
294 305
 
295
-	if (!is_array($urls))
296
-		$url_list = array(array($urls, $user_info['id']));
297
-	else
298
-		$url_list = $urls;
306
+	if (!is_array($urls)) {
307
+			$url_list = array(array($urls, $user_info['id']));
308
+	} else {
309
+			$url_list = $urls;
310
+	}
299 311
 
300 312
 	// These are done to later query these in large chunks. (instead of one by one.)
301 313
 	$topic_ids = array();
@@ -307,12 +319,14 @@  discard block
 block discarded – undo
307 319
 	{
308 320
 		// Get the request parameters..
309 321
 		$actions = $smcFunc['json_decode']($url[0], true);
310
-		if ($actions === false)
311
-			continue;
322
+		if ($actions === false) {
323
+					continue;
324
+		}
312 325
 
313 326
 		// If it's the admin or moderation center, and there is an area set, use that instead.
314
-		if (isset($actions['action']) && ($actions['action'] == 'admin' || $actions['action'] == 'moderate') && isset($actions['area']))
315
-			$actions['action'] = $actions['area'];
327
+		if (isset($actions['action']) && ($actions['action'] == 'admin' || $actions['action'] == 'moderate') && isset($actions['area'])) {
328
+					$actions['action'] = $actions['area'];
329
+		}
316 330
 
317 331
 		// Check if there was no action or the action is display.
318 332
 		if (!isset($actions['action']) || $actions['action'] == 'display')
@@ -332,12 +346,14 @@  discard block
 block discarded – undo
332 346
 				$board_ids[$actions['board']][$k] = $txt['who_board'];
333 347
 			}
334 348
 			// It's the board index!!  It must be!
335
-			else
336
-				$data[$k] = $txt['who_index'];
349
+			else {
350
+							$data[$k] = $txt['who_index'];
351
+			}
337 352
 		}
338 353
 		// Probably an error or some goon?
339
-		elseif ($actions['action'] == '')
340
-			$data[$k] = $txt['who_index'];
354
+		elseif ($actions['action'] == '') {
355
+					$data[$k] = $txt['who_index'];
356
+		}
341 357
 		// Some other normal action...?
342 358
 		else
343 359
 		{
@@ -345,23 +361,25 @@  discard block
 block discarded – undo
345 361
 			if ($actions['action'] == 'profile')
346 362
 			{
347 363
 				// Whose?  Their own?
348
-				if (empty($actions['u']))
349
-					$actions['u'] = $url[1];
364
+				if (empty($actions['u'])) {
365
+									$actions['u'] = $url[1];
366
+				}
350 367
 
351 368
 				$data[$k] = $txt['who_hidden'];
352 369
 				$profile_ids[(int) $actions['u']][$k] = $actions['u'] == $url[1] ? $txt['who_viewownprofile'] : $txt['who_viewprofile'];
353
-			}
354
-			elseif (($actions['action'] == 'post' || $actions['action'] == 'post2') && empty($actions['topic']) && isset($actions['board']))
370
+			} elseif (($actions['action'] == 'post' || $actions['action'] == 'post2') && empty($actions['topic']) && isset($actions['board']))
355 371
 			{
356 372
 				$data[$k] = $txt['who_hidden'];
357 373
 				$board_ids[(int) $actions['board']][$k] = isset($actions['poll']) ? $txt['who_poll'] : $txt['who_post'];
358 374
 			}
359 375
 			// A subaction anyone can view... if the language string is there, show it.
360
-			elseif (isset($actions['sa']) && isset($txt['whoall_' . $actions['action'] . '_' . $actions['sa']]))
361
-				$data[$k] = $preferred_prefix && isset($txt[$preferred_prefix . $actions['action'] . '_' . $actions['sa']]) ? $txt[$preferred_prefix . $actions['action'] . '_' . $actions['sa']] : $txt['whoall_' . $actions['action'] . '_' . $actions['sa']];
376
+			elseif (isset($actions['sa']) && isset($txt['whoall_' . $actions['action'] . '_' . $actions['sa']])) {
377
+							$data[$k] = $preferred_prefix && isset($txt[$preferred_prefix . $actions['action'] . '_' . $actions['sa']]) ? $txt[$preferred_prefix . $actions['action'] . '_' . $actions['sa']] : $txt['whoall_' . $actions['action'] . '_' . $actions['sa']];
378
+			}
362 379
 			// An action any old fellow can look at. (if ['whoall_' . $action] exists, we know everyone can see it.)
363
-			elseif (isset($txt['whoall_' . $actions['action']]))
364
-				$data[$k] = $preferred_prefix && isset($txt[$preferred_prefix . $actions['action']]) ? $txt[$preferred_prefix . $actions['action']] : $txt['whoall_' . $actions['action']];
380
+			elseif (isset($txt['whoall_' . $actions['action']])) {
381
+							$data[$k] = $preferred_prefix && isset($txt[$preferred_prefix . $actions['action']]) ? $txt[$preferred_prefix . $actions['action']] : $txt['whoall_' . $actions['action']];
382
+			}
365 383
 			// Viewable if and only if they can see the board...
366 384
 			elseif (isset($txt['whotopic_' . $actions['action']]))
367 385
 			{
@@ -370,8 +388,7 @@  discard block
 block discarded – undo
370 388
 
371 389
 				$data[$k] = $txt['who_hidden'];
372 390
 				$topic_ids[$topic][$k] = $txt['whotopic_' . $actions['action']];
373
-			}
374
-			elseif (isset($txt['whopost_' . $actions['action']]))
391
+			} elseif (isset($txt['whopost_' . $actions['action']]))
375 392
 			{
376 393
 				// Find out what message they are accessing.
377 394
 				$msgid = (int) (isset($actions['msg']) ? $actions['msg'] : (isset($actions['quote']) ? $actions['quote'] : 0));
@@ -394,41 +411,46 @@  discard block
 block discarded – undo
394 411
 				$data[$k] = sprintf($txt['whopost_' . $actions['action']], $id_topic, $subject);
395 412
 				$smcFunc['db_free_result']($result);
396 413
 
397
-				if (empty($id_topic))
398
-					$data[$k] = $txt['who_hidden'];
414
+				if (empty($id_topic)) {
415
+									$data[$k] = $txt['who_hidden'];
416
+				}
399 417
 			}
400 418
 			// Viewable only by administrators.. (if it starts with whoadmin, it's admin only!)
401
-			elseif (allowedTo('moderate_forum') && isset($txt['whoadmin_' . $actions['action']]))
402
-				$data[$k] = $txt['whoadmin_' . $actions['action']];
419
+			elseif (allowedTo('moderate_forum') && isset($txt['whoadmin_' . $actions['action']])) {
420
+							$data[$k] = $txt['whoadmin_' . $actions['action']];
421
+			}
403 422
 			// Viewable by permission level.
404 423
 			elseif (isset($allowedActions[$actions['action']]))
405 424
 			{
406
-				if (allowedTo($allowedActions[$actions['action']]))
407
-					$data[$k] = $txt['whoallow_' . $actions['action']];
408
-				elseif (in_array('moderate_forum', $allowedActions[$actions['action']]))
409
-					$data[$k] = $txt['who_moderate'];
410
-				elseif (in_array('admin_forum', $allowedActions[$actions['action']]))
411
-					$data[$k] = $txt['who_admin'];
412
-				else
413
-					$data[$k] = $txt['who_hidden'];
425
+				if (allowedTo($allowedActions[$actions['action']])) {
426
+									$data[$k] = $txt['whoallow_' . $actions['action']];
427
+				} elseif (in_array('moderate_forum', $allowedActions[$actions['action']])) {
428
+									$data[$k] = $txt['who_moderate'];
429
+				} elseif (in_array('admin_forum', $allowedActions[$actions['action']])) {
430
+									$data[$k] = $txt['who_admin'];
431
+				} else {
432
+									$data[$k] = $txt['who_hidden'];
433
+				}
434
+			} elseif (!empty($actions['action'])) {
435
+							$data[$k] = $txt['who_generic'] . ' ' . $actions['action'];
436
+			} else {
437
+							$data[$k] = $txt['who_unknown'];
414 438
 			}
415
-			elseif (!empty($actions['action']))
416
-				$data[$k] = $txt['who_generic'] . ' ' . $actions['action'];
417
-			else
418
-				$data[$k] = $txt['who_unknown'];
419 439
 		}
420 440
 
421 441
 		if (isset($actions['error']))
422 442
 		{
423
-			if (isset($txt[$actions['error']]))
424
-				$error_message = str_replace('"', '&quot;', empty($actions['who_error_params']) ? $txt[$actions['error']] : vsprintf($txt[$actions['error']], $actions['who_error_params']));
425
-			elseif ($actions['error'] == 'guest_login')
426
-				$error_message = str_replace('"', '&quot;', $txt['who_guest_login']);
427
-			else
428
-				$error_message = str_replace('"', '&quot;', $actions['error']);
429
-
430
-			if (!empty($error_message))
431
-				$data[$k] .= ' <span class="generic_icons error" title="' . $error_message . '"></span>';
443
+			if (isset($txt[$actions['error']])) {
444
+							$error_message = str_replace('"', '&quot;', empty($actions['who_error_params']) ? $txt[$actions['error']] : vsprintf($txt[$actions['error']], $actions['who_error_params']));
445
+			} elseif ($actions['error'] == 'guest_login') {
446
+							$error_message = str_replace('"', '&quot;', $txt['who_guest_login']);
447
+			} else {
448
+							$error_message = str_replace('"', '&quot;', $actions['error']);
449
+			}
450
+
451
+			if (!empty($error_message)) {
452
+							$data[$k] .= ' <span class="generic_icons error" title="' . $error_message . '"></span>';
453
+			}
432 454
 		}
433 455
 
434 456
 		// Maybe the action is integrated into another system?
@@ -439,12 +461,15 @@  discard block
 block discarded – undo
439 461
 				if (!empty($integrate_action))
440 462
 				{
441 463
 					$data[$k] = $integrate_action;
442
-					if (isset($actions['topic']) && isset($topic_ids[(int) $actions['topic']][$k]))
443
-						$topic_ids[(int) $actions['topic']][$k] = $integrate_action;
444
-					if (isset($actions['board']) && isset($board_ids[(int) $actions['board']][$k]))
445
-						$board_ids[(int) $actions['board']][$k] = $integrate_action;
446
-					if (isset($actions['u']) && isset($profile_ids[(int) $actions['u']][$k]))
447
-						$profile_ids[(int) $actions['u']][$k] = $integrate_action;
464
+					if (isset($actions['topic']) && isset($topic_ids[(int) $actions['topic']][$k])) {
465
+											$topic_ids[(int) $actions['topic']][$k] = $integrate_action;
466
+					}
467
+					if (isset($actions['board']) && isset($board_ids[(int) $actions['board']][$k])) {
468
+											$board_ids[(int) $actions['board']][$k] = $integrate_action;
469
+					}
470
+					if (isset($actions['u']) && isset($profile_ids[(int) $actions['u']][$k])) {
471
+											$profile_ids[(int) $actions['u']][$k] = $integrate_action;
472
+					}
448 473
 					break;
449 474
 				}
450 475
 			}
@@ -472,8 +497,9 @@  discard block
 block discarded – undo
472 497
 		while ($row = $smcFunc['db_fetch_assoc']($result))
473 498
 		{
474 499
 			// Show the topic's subject for each of the actions.
475
-			foreach ($topic_ids[$row['id_topic']] as $k => $session_text)
476
-				$data[$k] = sprintf($session_text, $row['id_topic'], censorText($row['subject']));
500
+			foreach ($topic_ids[$row['id_topic']] as $k => $session_text) {
501
+							$data[$k] = sprintf($session_text, $row['id_topic'], censorText($row['subject']));
502
+			}
477 503
 		}
478 504
 		$smcFunc['db_free_result']($result);
479 505
 	}
@@ -495,8 +521,9 @@  discard block
 block discarded – undo
495 521
 		while ($row = $smcFunc['db_fetch_assoc']($result))
496 522
 		{
497 523
 			// Put the board name into the string for each member...
498
-			foreach ($board_ids[$row['id_board']] as $k => $session_text)
499
-				$data[$k] = sprintf($session_text, $row['id_board'], $row['name']);
524
+			foreach ($board_ids[$row['id_board']] as $k => $session_text) {
525
+							$data[$k] = sprintf($session_text, $row['id_board'], $row['name']);
526
+			}
500 527
 		}
501 528
 		$smcFunc['db_free_result']($result);
502 529
 	}
@@ -518,23 +545,26 @@  discard block
 block discarded – undo
518 545
 		while ($row = $smcFunc['db_fetch_assoc']($result))
519 546
 		{
520 547
 			// If they aren't allowed to view this person's profile, skip it.
521
-			if (!$allow_view_any && ($user_info['id'] != $row['id_member']))
522
-				continue;
548
+			if (!$allow_view_any && ($user_info['id'] != $row['id_member'])) {
549
+							continue;
550
+			}
523 551
 
524 552
 			// Set their action on each - session/text to sprintf.
525
-			foreach ($profile_ids[$row['id_member']] as $k => $session_text)
526
-				$data[$k] = sprintf($session_text, $row['id_member'], $row['real_name']);
553
+			foreach ($profile_ids[$row['id_member']] as $k => $session_text) {
554
+							$data[$k] = sprintf($session_text, $row['id_member'], $row['real_name']);
555
+			}
527 556
 		}
528 557
 		$smcFunc['db_free_result']($result);
529 558
 	}
530 559
 
531 560
 	call_integration_hook('whos_online_after', array(&$urls, &$data));
532 561
 
533
-	if (!is_array($urls))
534
-		return isset($data[0]) ? $data[0] : false;
535
-	else
536
-		return $data;
537
-}
562
+	if (!is_array($urls)) {
563
+			return isset($data[0]) ? $data[0] : false;
564
+	} else {
565
+			return $data;
566
+	}
567
+	}
538 568
 
539 569
 /**
540 570
  * It prepares credit and copyright information for the credits page or the admin page
@@ -710,8 +740,8 @@  discard block
 block discarded – undo
710 740
 	);
711 741
 
712 742
 	// Give the translators some credit for their hard work.
713
-	if (!empty($txt['translation_credits']))
714
-		$context['credits'][] = array(
743
+	if (!empty($txt['translation_credits'])) {
744
+			$context['credits'][] = array(
715 745
 			'title' => $txt['credits_groups_translation'],
716 746
 			'groups' => array(
717 747
 				array(
@@ -720,6 +750,7 @@  discard block
 block discarded – undo
720 750
 				),
721 751
 			),
722 752
 		);
753
+	}
723 754
 
724 755
 	$context['credits'][] = array(
725 756
 		'title' => $txt['credits_special'],
Please login to merge, or discard this patch.
index.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -104,7 +104,7 @@
 block discarded – undo
104 104
  *
105 105
  * @param string $class The fully-qualified class name.
106 106
  */
107
-spl_autoload_register(function ($class) use ($sourcedir)
107
+spl_autoload_register(function($class) use ($sourcedir)
108 108
 {
109 109
 	$classMap = array(
110 110
 		'ReCaptcha\\' => 'ReCaptcha/',
Please login to merge, or discard this patch.
Braces   +38 added lines, -26 removed lines patch added patch discarded remove patch
@@ -32,16 +32,18 @@  discard block
 block discarded – undo
32 32
 ob_start();
33 33
 
34 34
 // Do some cleaning, just in case.
35
-foreach (array('db_character_set', 'cachedir') as $variable)
35
+foreach (array('db_character_set', 'cachedir') as $variable) {
36 36
 	if (isset($GLOBALS[$variable]))
37 37
 		unset($GLOBALS[$variable], $GLOBALS[$variable]);
38
+}
38 39
 
39 40
 // Load the settings...
40 41
 require_once(dirname(__FILE__) . '/Settings.php');
41 42
 
42 43
 // Make absolutely sure the cache directory is defined.
43
-if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache'))
44
+if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) {
44 45
 	$cachedir = $boarddir . '/cache';
46
+}
45 47
 
46 48
 // Without those we can't go anywhere
47 49
 require_once($sourcedir . '/QueryString.php');
@@ -51,8 +53,9 @@  discard block
 block discarded – undo
51 53
 require_once($sourcedir . '/Load.php');
52 54
 
53 55
 // If $maintenance is set specifically to 2, then we're upgrading or something.
54
-if (!empty($maintenance) && $maintenance == 2)
56
+if (!empty($maintenance) && $maintenance == 2) {
55 57
 	display_maintenance_message();
58
+}
56 59
 
57 60
 // Create a variable to store some SMF specific functions in.
58 61
 $smcFunc = array();
@@ -67,8 +70,9 @@  discard block
 block discarded – undo
67 70
 cleanRequest();
68 71
 
69 72
 // Seed the random generator.
70
-if (empty($modSettings['rand_seed']) || mt_rand(1, 250) == 69)
73
+if (empty($modSettings['rand_seed']) || mt_rand(1, 250) == 69) {
71 74
 	smf_seed_generator();
75
+}
72 76
 
73 77
 // Before we get carried away, are we doing a scheduled task? If so save CPU cycles by jumping out!
74 78
 if (isset($_GET['scheduled']))
@@ -88,9 +92,9 @@  discard block
 block discarded – undo
88 92
 if (!empty($modSettings['enableCompressedOutput']) && !headers_sent())
89 93
 {
90 94
 	// If zlib is being used, turn off output compression.
91
-	if (ini_get('zlib.output_compression') >= 1 || ini_get('output_handler') == 'ob_gzhandler')
92
-		$modSettings['enableCompressedOutput'] = '0';
93
-	else
95
+	if (ini_get('zlib.output_compression') >= 1 || ini_get('output_handler') == 'ob_gzhandler') {
96
+			$modSettings['enableCompressedOutput'] = '0';
97
+	} else
94 98
 	{
95 99
 		ob_end_clean();
96 100
 		ob_start('ob_gzhandler');
@@ -182,18 +186,21 @@  discard block
 block discarded – undo
182 186
 	loadPermissions();
183 187
 
184 188
 	// Attachments don't require the entire theme to be loaded.
185
-	if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'dlattach')
186
-		detectBrowser();
189
+	if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'dlattach') {
190
+			detectBrowser();
191
+	}
187 192
 	// Load the current theme.  (note that ?theme=1 will also work, may be used for guest theming.)
188
-	else
189
-		loadTheme();
193
+	else {
194
+			loadTheme();
195
+	}
190 196
 
191 197
 	// Check if the user should be disallowed access.
192 198
 	is_not_banned();
193 199
 
194 200
 	// If we are in a topic and don't have permission to approve it then duck out now.
195
-	if (!empty($topic) && empty($board_info['cur_topic_approved']) && !allowedTo('approve_posts') && ($user_info['id'] != $board_info['cur_topic_starter'] || $user_info['is_guest']))
196
-		fatal_lang_error('not_a_topic', false);
201
+	if (!empty($topic) && empty($board_info['cur_topic_approved']) && !allowedTo('approve_posts') && ($user_info['id'] != $board_info['cur_topic_starter'] || $user_info['is_guest'])) {
202
+			fatal_lang_error('not_a_topic', false);
203
+	}
197 204
 
198 205
 	$no_stat_actions = array('clock', 'dlattach', 'findmember', 'jsoption', 'likes', 'loadeditorlocale', 'modifycat', 'requestmembers', 'smstats', 'suggest', 'about:unknown', '.xml', 'xmlhttp', 'verificationcode', 'viewquery', 'viewsmfile');
199 206
 	call_integration_hook('integrate_pre_log_stats', array(&$no_stat_actions));
@@ -204,8 +211,9 @@  discard block
 block discarded – undo
204 211
 		writeLog();
205 212
 
206 213
 		// Track forum statistics and hits...?
207
-		if (!empty($modSettings['hitStats']))
208
-			trackStats(array('hits' => '+'));
214
+		if (!empty($modSettings['hitStats'])) {
215
+					trackStats(array('hits' => '+'));
216
+		}
209 217
 	}
210 218
 	unset($no_stat_actions);
211 219
 
@@ -219,13 +227,14 @@  discard block
 block discarded – undo
219 227
 			return ($_REQUEST['action'] == 'login2' ? 'Login2' : ($_REQUEST['action'] == 'logintfa' ? 'LoginTFA' : 'Logout'));
220 228
 		}
221 229
 		// Don't even try it, sonny.
222
-		else
223
-			return 'InMaintenance';
230
+		else {
231
+					return 'InMaintenance';
232
+		}
224 233
 	}
225 234
 	// If guest access is off, a guest can only do one of the very few following actions.
226
-	elseif (empty($modSettings['allow_guestAccess']) && $user_info['is_guest'] && (!isset($_REQUEST['action']) || !in_array($_REQUEST['action'], array('coppa', 'login', 'login2', 'logintfa', 'reminder', 'activate', 'help', 'helpadmin', 'smstats', 'verificationcode', 'signup', 'signup2'))))
227
-		return 'KickGuest';
228
-	elseif (empty($_REQUEST['action']))
235
+	elseif (empty($modSettings['allow_guestAccess']) && $user_info['is_guest'] && (!isset($_REQUEST['action']) || !in_array($_REQUEST['action'], array('coppa', 'login', 'login2', 'logintfa', 'reminder', 'activate', 'help', 'helpadmin', 'smstats', 'verificationcode', 'signup', 'signup2')))) {
236
+			return 'KickGuest';
237
+	} elseif (empty($_REQUEST['action']))
229 238
 	{
230 239
 		// Action and board are both empty... BoardIndex! Unless someone else wants to do something different.
231 240
 		if (empty($board) && empty($topic))
@@ -239,8 +248,9 @@  discard block
 block discarded – undo
239 248
 
240 249
 				$call = call_helper($defaultAction, true);
241 250
 
242
-				if (!empty($call))
243
-					return $call;
251
+				if (!empty($call)) {
252
+									return $call;
253
+				}
244 254
 			}
245 255
 
246 256
 			// No default action huh? then go to our good old BoardIndex.
@@ -370,8 +380,9 @@  discard block
 block discarded – undo
370 380
 
371 381
 			$call = call_helper($fallbackAction, true);
372 382
 
373
-			if (!empty($call))
374
-				return $call;
383
+			if (!empty($call)) {
384
+							return $call;
385
+			}
375 386
 		}
376 387
 
377 388
 		// No fallback action, huh?
@@ -382,8 +393,9 @@  discard block
 block discarded – undo
382 393
 	}
383 394
 
384 395
 	// Otherwise, it was set - so let's go to that action.
385
-	if (!empty($actionArray[$_REQUEST['action']][0]))
386
-		require_once($sourcedir . '/' . $actionArray[$_REQUEST['action']][0]);
396
+	if (!empty($actionArray[$_REQUEST['action']][0])) {
397
+			require_once($sourcedir . '/' . $actionArray[$_REQUEST['action']][0]);
398
+	}
387 399
 
388 400
 	// Do the right thing.
389 401
 	return call_helper($actionArray[$_REQUEST['action']][1], true);
Please login to merge, or discard this patch.
Themes/default/Calendar.template.php 2 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
  * Display a list of upcoming events, birthdays, and holidays.
69 69
  *
70 70
  * @param string $grid_name The grid name
71
- * @return void|bool Returns false if the grid doesn't exist.
71
+ * @return false|null Returns false if the grid doesn't exist.
72 72
  */
73 73
 function template_show_upcoming_list($grid_name)
74 74
 {
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
  *
239 239
  * @param string $grid_name The grid name
240 240
  * @param bool $is_mini Is this a mini grid?
241
- * @return void|bool Returns false if the grid doesn't exist.
241
+ * @return false|null Returns false if the grid doesn't exist.
242 242
  */
243 243
 function template_show_month_grid($grid_name, $is_mini = false)
244 244
 {
@@ -523,7 +523,7 @@  discard block
 block discarded – undo
523 523
  * Shows a weekly grid
524 524
  *
525 525
  * @param string $grid_name The name of the grid
526
- * @return void|bool Returns false if the grid doesn't exist
526
+ * @return false|null Returns false if the grid doesn't exist
527 527
  */
528 528
 function template_show_week_grid($grid_name)
529 529
 {
Please login to merge, or discard this patch.
Braces   +222 added lines, -162 removed lines patch added patch discarded remove patch
@@ -22,30 +22,32 @@  discard block
 block discarded – undo
22 22
 		<div id="calendar">';
23 23
 
24 24
 	// Show the mini-blocks if they're enabled.
25
-	if (empty($context['blocks_disabled']))
26
-		echo '
25
+	if (empty($context['blocks_disabled'])) {
26
+			echo '
27 27
 			<div id="month_grid">
28 28
 				', template_show_month_grid('prev', true), '
29 29
 				', template_show_month_grid('current', true), '
30 30
 				', template_show_month_grid('next', true), '
31 31
 			</div>';
32
+	}
32 33
 
33 34
 	// What view are we showing?
34
-	if ($context['calendar_view'] == 'viewlist')
35
-		echo '
35
+	if ($context['calendar_view'] == 'viewlist') {
36
+			echo '
36 37
 			<div id="main_grid">
37 38
 				', template_show_upcoming_list('main'), '
38 39
 			</div>';
39
-	elseif ($context['calendar_view'] == 'viewweek')
40
-		echo '
40
+	} elseif ($context['calendar_view'] == 'viewweek') {
41
+			echo '
41 42
 			<div id="main_grid">
42 43
 				', template_show_week_grid('main'), '
43 44
 			</div>';
44
-	else
45
-		echo '
45
+	} else {
46
+			echo '
46 47
 			<div id="main_grid">
47 48
 				', template_show_month_grid('main'), '
48 49
 			</div>';
50
+	}
49 51
 
50 52
 	// Close our wrapper.
51 53
 	echo '
@@ -64,20 +66,22 @@  discard block
 block discarded – undo
64 66
 	global $context, $scripturl, $txt;
65 67
 
66 68
 	// Bail out if we have nothing to work with
67
-	if (!isset($context['calendar_grid_' . $grid_name]))
68
-		return false;
69
+	if (!isset($context['calendar_grid_' . $grid_name])) {
70
+			return false;
71
+	}
69 72
 
70 73
 	// Protect programmer sanity
71 74
 	$calendar_data = &$context['calendar_grid_' . $grid_name];
72 75
 
73 76
 	// Do we want a title?
74
-	if (empty($calendar_data['disable_title']))
75
-		echo '
77
+	if (empty($calendar_data['disable_title'])) {
78
+			echo '
76 79
 			<div class="cat_bar">
77 80
 				<h3 class="catbg centertext largetext">
78 81
 					<a href="', $scripturl, '?action=calendar;viewlist;year=', $calendar_data['start_year'], ';month=', $calendar_data['start_month'], ';day=', $calendar_data['start_day'], '">', $txt['calendar_upcoming'], '</a>
79 82
 				</h3>
80 83
 			</div>';
84
+	}
81 85
 
82 86
 	// Give the user some controls to work with
83 87
 	template_calendar_top($calendar_data);
@@ -100,11 +104,13 @@  discard block
 block discarded – undo
100 104
 					<li class="windowbg">
101 105
 						<strong class="event_title">', $event['link'], '</strong>';
102 106
 
103
-				if ($event['can_edit'])
104
-					echo ' <a href="' . $event['modify_href'] . '"><span class="generic_icons calendar_modify" title="', $txt['calendar_edit'], '"></span></a>';
107
+				if ($event['can_edit']) {
108
+									echo ' <a href="' . $event['modify_href'] . '"><span class="generic_icons calendar_modify" title="', $txt['calendar_edit'], '"></span></a>';
109
+				}
105 110
 
106
-				if ($event['can_export'])
107
-					echo ' <a href="' . $event['export_href'] . '"><span class="generic_icons calendar_export" title="', $txt['calendar_export'], '"></span></a>';
111
+				if ($event['can_export']) {
112
+									echo ' <a href="' . $event['export_href'] . '"><span class="generic_icons calendar_export" title="', $txt['calendar_export'], '"></span></a>';
113
+				}
108 114
 
109 115
 				echo '
110 116
 						<br>';
@@ -112,14 +118,14 @@  discard block
 block discarded – undo
112 118
 				if (!empty($event['allday']))
113 119
 				{
114 120
 					echo '<time datetime="' . $event['start_iso_gmdate'] . '">', trim($event['start_date_local']), '</time>', ($event['start_date'] != $event['end_date']) ? ' &ndash; <time datetime="' . $event['end_iso_gmdate'] . '">' . trim($event['end_date_local']) . '</time>' : '';
115
-				}
116
-				else
121
+				} else
117 122
 				{
118 123
 					// Display event info relative to user's local timezone
119 124
 					echo '<time datetime="' . $event['start_iso_gmdate'] . '">', trim($event['start_date_local']), ', ', trim($event['start_time_local']), '</time> &ndash; <time datetime="' . $event['end_iso_gmdate'] . '">';
120 125
 
121
-					if ($event['start_date_local'] != $event['end_date_local'])
122
-						echo trim($event['end_date_local']) . ', ';
126
+					if ($event['start_date_local'] != $event['end_date_local']) {
127
+											echo trim($event['end_date_local']) . ', ';
128
+					}
123 129
 
124 130
 					echo trim($event['end_time_local']);
125 131
 
@@ -128,23 +134,27 @@  discard block
 block discarded – undo
128 134
 					{
129 135
 						echo '</time> (<time datetime="' . $event['start_iso_gmdate'] . '">';
130 136
 
131
-						if ($event['start_date_orig'] != $event['start_date_local'] || $event['end_date_orig'] != $event['end_date_local'] || $event['start_date_orig'] != $event['end_date_orig'])
132
-							echo trim($event['start_date_orig']), ', ';
137
+						if ($event['start_date_orig'] != $event['start_date_local'] || $event['end_date_orig'] != $event['end_date_local'] || $event['start_date_orig'] != $event['end_date_orig']) {
138
+													echo trim($event['start_date_orig']), ', ';
139
+						}
133 140
 
134 141
 						echo trim($event['start_time_orig']), '</time> &ndash; <time datetime="' . $event['end_iso_gmdate'] . '">';
135 142
 
136
-						if ($event['start_date_orig'] != $event['end_date_orig'])
137
-							echo trim($event['end_date_orig']) . ', ';
143
+						if ($event['start_date_orig'] != $event['end_date_orig']) {
144
+													echo trim($event['end_date_orig']) . ', ';
145
+						}
138 146
 
139 147
 						echo trim($event['end_time_orig']), ' ', $event['tz_abbrev'], '</time>)';
140 148
 					}
141 149
 					// Event is scheduled in the user's own timezone? Let 'em know, just to avoid confusion
142
-					else
143
-						echo ' ', $event['tz_abbrev'], '</time>';
150
+					else {
151
+											echo ' ', $event['tz_abbrev'], '</time>';
152
+					}
144 153
 				}
145 154
 
146
-				if (!empty($event['location']))
147
-					echo '<br>', $event['location'];
155
+				if (!empty($event['location'])) {
156
+									echo '<br>', $event['location'];
157
+				}
148 158
 
149 159
 				echo '
150 160
 					</li>';
@@ -176,8 +186,9 @@  discard block
 block discarded – undo
176 186
 
177 187
 			$birthdays = array();
178 188
 
179
-			foreach ($date as $member)
180
-				$birthdays[] = '<a href="' . $scripturl . '?action=profile;u=' . $member['id'] . '">' . $member['name'] . (isset($member['age']) ? ' (' . $member['age'] . ')' : '') . '</a>';
189
+			foreach ($date as $member) {
190
+							$birthdays[] = '<a href="' . $scripturl . '?action=profile;u=' . $member['id'] . '">' . $member['name'] . (isset($member['age']) ? ' (' . $member['age'] . ')' : '') . '</a>';
191
+			}
181 192
 
182 193
 			echo implode(', ', $birthdays);
183 194
 
@@ -208,8 +219,9 @@  discard block
 block discarded – undo
208 219
 			$date_local = $date['date_local'];
209 220
 			unset($date['date_local']);
210 221
 
211
-			foreach ($date as $holiday)
212
-				$holidays[] = $holiday . ' (' . $date_local . ')';
222
+			foreach ($date as $holiday) {
223
+							$holidays[] = $holiday . ' (' . $date_local . ')';
224
+			}
213 225
 		}
214 226
 
215 227
 		echo implode(', ', $holidays);
@@ -233,17 +245,19 @@  discard block
 block discarded – undo
233 245
 	global $context, $txt, $scripturl, $modSettings;
234 246
 
235 247
 	// If the grid doesn't exist, no point in proceeding.
236
-	if (!isset($context['calendar_grid_' . $grid_name]))
237
-		return false;
248
+	if (!isset($context['calendar_grid_' . $grid_name])) {
249
+			return false;
250
+	}
238 251
 
239 252
 	// A handy little pointer variable.
240 253
 	$calendar_data = &$context['calendar_grid_' . $grid_name];
241 254
 
242 255
 	// Some conditions for whether or not we should show the week links *here*.
243
-	if (isset($calendar_data['show_week_links']) && ($calendar_data['show_week_links'] == 3 || (($calendar_data['show_week_links'] == 1 && $is_mini === true) || $calendar_data['show_week_links'] == 2 && $is_mini === false)))
244
-		$show_week_links = true;
245
-	else
246
-		$show_week_links = false;
256
+	if (isset($calendar_data['show_week_links']) && ($calendar_data['show_week_links'] == 3 || (($calendar_data['show_week_links'] == 1 && $is_mini === true) || $calendar_data['show_week_links'] == 2 && $is_mini === false))) {
257
+			$show_week_links = true;
258
+	} else {
259
+			$show_week_links = false;
260
+	}
247 261
 
248 262
 	// Assuming that we've not disabled it, show the title block!
249 263
 	if (empty($calendar_data['disable_title']))
@@ -253,18 +267,20 @@  discard block
 block discarded – undo
253 267
 				<h3 class="catbg centertext largetext">';
254 268
 
255 269
 		// Previous Link: If we're showing prev / next and it's not a mini-calendar.
256
-		if (empty($calendar_data['previous_calendar']['disabled']) && $calendar_data['show_next_prev'] && $is_mini === false)
257
-			echo '
270
+		if (empty($calendar_data['previous_calendar']['disabled']) && $calendar_data['show_next_prev'] && $is_mini === false) {
271
+					echo '
258 272
 					<span class="floatleft">
259 273
 						<a href="', $calendar_data['previous_calendar']['href'], '">&#171;</a>
260 274
 					</span>';
275
+		}
261 276
 
262 277
 		// Next Link: if we're showing prev / next and it's not a mini-calendar.
263
-		if (empty($calendar_data['next_calendar']['disabled']) && $calendar_data['show_next_prev'] && $is_mini === false)
264
-			echo '
278
+		if (empty($calendar_data['next_calendar']['disabled']) && $calendar_data['show_next_prev'] && $is_mini === false) {
279
+					echo '
265 280
 					<span class="floatright">
266 281
 						<a href="', $calendar_data['next_calendar']['href'], '">&#187;</a>
267 282
 					</span>';
283
+		}
268 284
 
269 285
 		// Arguably the most exciting part, the title!
270 286
 		echo '
@@ -274,8 +290,9 @@  discard block
 block discarded – undo
274 290
 	}
275 291
 
276 292
 	// Show the controls on main grids
277
-	if ($is_mini === false)
278
-		template_calendar_top($calendar_data);
293
+	if ($is_mini === false) {
294
+			template_calendar_top($calendar_data);
295
+	}
279 296
 
280 297
 	// Finally, the main calendar table.
281 298
 	echo '
@@ -288,14 +305,16 @@  discard block
 block discarded – undo
288 305
 				<tr>';
289 306
 
290 307
 		// If we're showing week links, there's an extra column ahead of the week links, so let's think ahead and be prepared!
291
-		if ($show_week_links === true)
292
-			echo '
308
+		if ($show_week_links === true) {
309
+					echo '
293 310
 					<th></th>';
311
+		}
294 312
 
295 313
 		// Now, loop through each actual day of the week.
296
-		foreach ($calendar_data['week_days'] as $day)
297
-			echo '
314
+		foreach ($calendar_data['week_days'] as $day) {
315
+					echo '
298 316
 					<th class="days" scope="col">', !empty($calendar_data['short_day_titles']) || $is_mini === true ? $txt['days_short'][$day] : $txt['days'][$day], '</th>';
317
+		}
299 318
 
300 319
 		echo '
301 320
 				</tr>';
@@ -314,11 +333,12 @@  discard block
 block discarded – undo
314 333
 				<tr class="days_wrapper">';
315 334
 
316 335
 		// This is where we add the actual week link, if enabled on this location.
317
-		if ($show_week_links === true)
318
-			echo '
336
+		if ($show_week_links === true) {
337
+					echo '
319 338
 					<td class="windowbg2 weeks">
320 339
 						<a href="', $scripturl, '?action=calendar;viewweek;year=', $calendar_data['current_year'], ';month=', $calendar_data['current_month'], ';day=', $week['days'][0]['day'], '" title="', $txt['calendar_view_week'], '">&#187;</a>
321 340
 					</td>';
341
+		}
322 342
 
323 343
 		// Now loop through each day in the week we're on.
324 344
 		foreach ($week['days'] as $day)
@@ -335,27 +355,29 @@  discard block
 block discarded – undo
335 355
 				// Additional classes are given for events, holidays, and birthdays.
336 356
 				if (!empty($day['events']) && !empty($calendar_data['highlight']['events']))
337 357
 				{
338
-					if ($is_mini === true && in_array($calendar_data['highlight']['events'], array(1, 3)))
339
-						$classes[] = 'events';
340
-					elseif ($is_mini === false && in_array($calendar_data['highlight']['events'], array(2, 3)))
341
-						$classes[] = 'events';
358
+					if ($is_mini === true && in_array($calendar_data['highlight']['events'], array(1, 3))) {
359
+											$classes[] = 'events';
360
+					} elseif ($is_mini === false && in_array($calendar_data['highlight']['events'], array(2, 3))) {
361
+											$classes[] = 'events';
362
+					}
342 363
 				}
343 364
 				if (!empty($day['holidays']) && !empty($calendar_data['highlight']['holidays']))
344 365
 				{
345
-					if ($is_mini === true && in_array($calendar_data['highlight']['holidays'], array(1, 3)))
346
-						$classes[] = 'holidays';
347
-					elseif ($is_mini === false && in_array($calendar_data['highlight']['holidays'], array(2, 3)))
348
-						$classes[] = 'holidays';
366
+					if ($is_mini === true && in_array($calendar_data['highlight']['holidays'], array(1, 3))) {
367
+											$classes[] = 'holidays';
368
+					} elseif ($is_mini === false && in_array($calendar_data['highlight']['holidays'], array(2, 3))) {
369
+											$classes[] = 'holidays';
370
+					}
349 371
 				}
350 372
 				if (!empty($day['birthdays']) && !empty($calendar_data['highlight']['birthdays']))
351 373
 				{
352
-					if ($is_mini === true && in_array($calendar_data['highlight']['birthdays'], array(1, 3)))
353
-						$classes[] = 'birthdays';
354
-					elseif ($is_mini === false && in_array($calendar_data['highlight']['birthdays'], array(2, 3)))
355
-						$classes[] = 'birthdays';
374
+					if ($is_mini === true && in_array($calendar_data['highlight']['birthdays'], array(1, 3))) {
375
+											$classes[] = 'birthdays';
376
+					} elseif ($is_mini === false && in_array($calendar_data['highlight']['birthdays'], array(2, 3))) {
377
+											$classes[] = 'birthdays';
378
+					}
356 379
 				}
357
-			}
358
-			else
380
+			} else
359 381
 			{
360 382
 				// Default Classes (either compact or comfortable and disabled).
361 383
 				$classes[] = !empty($calendar_data['size']) && $calendar_data['size'] == 'small' ? 'compact' : 'comfortable';
@@ -374,25 +396,27 @@  discard block
 block discarded – undo
374 396
 				$title_prefix = !empty($day['is_first_of_month']) && $context['current_month'] == $calendar_data['current_month'] && $is_mini === false ? (!empty($calendar_data['short_month_titles']) ? $txt['months_short'][$calendar_data['current_month']] . ' ' : $txt['months_titles'][$calendar_data['current_month']] . ' ') : '';
375 397
 
376 398
 				// The actual day number - be it a link, or just plain old text!
377
-				if (!empty($modSettings['cal_daysaslink']) && $context['can_post'])
378
-					echo '
399
+				if (!empty($modSettings['cal_daysaslink']) && $context['can_post']) {
400
+									echo '
379 401
 						<a href="', $scripturl, '?action=calendar;sa=post;year=', $calendar_data['current_year'], ';month=', $calendar_data['current_month'], ';day=', $day['day'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="day_text">', $title_prefix, $day['day'], '</span></a>';
380
-				elseif ($is_mini)
381
-					echo '
402
+				} elseif ($is_mini) {
403
+									echo '
382 404
 						<a href="', $scripturl, '?action=calendar;', $context['calendar_view'], ';year=', $calendar_data['current_year'], ';month=', $calendar_data['current_month'], ';day=', $day['day'], '"><span class="day_text">', $title_prefix, $day['day'], '</span></a>';
383
-				else
384
-					echo '
405
+				} else {
406
+									echo '
385 407
 						<span class="day_text">', $title_prefix, $day['day'], '</span>';
408
+				}
386 409
 
387 410
 				// A lot of stuff, we're not showing on mini-calendars to conserve space.
388 411
 				if ($is_mini === false)
389 412
 				{
390 413
 					// Holidays are always fun, let's show them!
391
-					if (!empty($day['holidays']))
392
-						echo '
414
+					if (!empty($day['holidays'])) {
415
+											echo '
393 416
 						<div class="smalltext holiday">
394 417
 							<span>', $txt['calendar_prompt'], '</span> ', implode(', ', $day['holidays']), '
395 418
 						</div>';
419
+					}
396 420
 
397 421
 					// Happy Birthday Dear Member!
398 422
 					if (!empty($day['birthdays']))
@@ -410,15 +434,17 @@  discard block
 block discarded – undo
410 434
 							echo '<a href="', $scripturl, '?action=profile;u=', $member['id'], '"><span class="fix_rtl_names">', $member['name'], '</span>', isset($member['age']) ? ' (' . $member['age'] . ')' : '', '</a>', $member['is_last'] || ($count == 10 && $use_js_hide) ? '' : ', ';
411 435
 
412 436
 							// 9...10! Let's stop there.
413
-							if ($birthday_count == 10 && $use_js_hide)
414
-								// !!TODO - Inline CSS and JavaScript should be moved.
437
+							if ($birthday_count == 10 && $use_js_hide) {
438
+															// !!TODO - Inline CSS and JavaScript should be moved.
415 439
 								echo '<span class="hidelink" id="bdhidelink_', $day['day'], '">...<br><a href="', $scripturl, '?action=calendar;month=', $calendar_data['current_month'], ';year=', $calendar_data['current_year'], ';showbd" onclick="document.getElementById(\'bdhide_', $day['day'], '\').style.display = \'\'; document.getElementById(\'bdhidelink_', $day['day'], '\').style.display = \'none\'; return false;">(', sprintf($txt['calendar_click_all'], count($day['birthdays'])), ')</a></span><span id="bdhide_', $day['day'], '" style="display: none;">, ';
440
+							}
416 441
 
417 442
 							++$birthday_count;
418 443
 						}
419
-						if ($use_js_hide)
420
-							echo '
444
+						if ($use_js_hide) {
445
+													echo '
421 446
 							</span>';
447
+						}
422 448
 
423 449
 						echo '
424 450
 						</div><!-- .smalltext -->';
@@ -429,8 +455,9 @@  discard block
 block discarded – undo
429 455
 					{
430 456
 						// Sort events by start time (all day events will be listed first)
431 457
 						uasort($day['events'], function($a, $b) {
432
-							if ($a['start_timestamp'] == $b['start_timestamp'])
433
-								return 0;
458
+							if ($a['start_timestamp'] == $b['start_timestamp']) {
459
+															return 0;
460
+							}
434 461
 
435 462
 							return ($a['start_timestamp'] < $b['start_timestamp']) ? -1 : 1;
436 463
 						});
@@ -450,20 +477,22 @@  discard block
 block discarded – undo
450 477
 								', $event['link'], '<br>
451 478
 								<span class="event_time', empty($event_icons_needed) ? ' floatright' : '', '">';
452 479
 
453
-							if (!empty($event['start_time_local']) && $event['starts_today'] == true)
454
-								echo trim(str_replace(':00 ', ' ', $event['start_time_local']));
455
-							elseif (!empty($event['end_time_local']) && $event['ends_today'] == true)
456
-								echo strtolower($txt['ends']), ' ', trim(str_replace(':00 ', ' ', $event['end_time_local']));
457
-							elseif (!empty($event['allday']))
458
-								echo $txt['calendar_allday'];
480
+							if (!empty($event['start_time_local']) && $event['starts_today'] == true) {
481
+															echo trim(str_replace(':00 ', ' ', $event['start_time_local']));
482
+							} elseif (!empty($event['end_time_local']) && $event['ends_today'] == true) {
483
+															echo strtolower($txt['ends']), ' ', trim(str_replace(':00 ', ' ', $event['end_time_local']));
484
+							} elseif (!empty($event['allday'])) {
485
+															echo $txt['calendar_allday'];
486
+							}
459 487
 
460 488
 							echo '
461 489
 								</span>';
462 490
 
463
-							if (!empty($event['location']))
464
-								echo '
491
+							if (!empty($event['location'])) {
492
+															echo '
465 493
 								<br>
466 494
 								<span class="event_location', empty($event_icons_needed) ? ' floatright' : '', '">' . $event['location'] . '</span>';
495
+							}
467 496
 
468 497
 							if ($event['can_edit'] || $event['can_export'])
469 498
 							{
@@ -471,18 +500,20 @@  discard block
 block discarded – undo
471 500
 								<span class="modify_event_links">';
472 501
 
473 502
 								// If they can edit the event, show an icon they can click on....
474
-								if ($event['can_edit'])
475
-									echo '
503
+								if ($event['can_edit']) {
504
+																	echo '
476 505
 									<a class="modify_event" href="', $event['modify_href'], '">
477 506
 										<span class="generic_icons calendar_modify" title="', $txt['calendar_edit'], '"></span>
478 507
 									</a>';
508
+								}
479 509
 
480 510
 								// Exporting!
481
-								if ($event['can_export'])
482
-									echo '
511
+								if ($event['can_export']) {
512
+																	echo '
483 513
 									<a class="modify_event" href="', $event['export_href'], '">
484 514
 										<span class="generic_icons calendar_export" title="', $txt['calendar_export'], '"></span>
485 515
 									</a>';
516
+								}
486 517
 
487 518
 								echo '
488 519
 								</span><br class="clear">';
@@ -501,10 +532,11 @@  discard block
 block discarded – undo
501 532
 			// Otherwise, assuming it's not a mini-calendar, we can show previous / next month days!
502 533
 			elseif ($is_mini === false)
503 534
 			{
504
-				if (empty($current_month_started) && !empty($context['calendar_grid_prev']))
505
-					echo '<a href="', $scripturl, '?action=calendar;year=', $context['calendar_grid_prev']['current_year'], ';month=', $context['calendar_grid_prev']['current_month'], '">', $context['calendar_grid_prev']['last_of_month'] - $calendar_data['shift']-- +1, '</a>';
506
-				elseif (!empty($current_month_started) && !empty($context['calendar_grid_next']))
507
-					echo '<a href="', $scripturl, '?action=calendar;year=', $context['calendar_grid_next']['current_year'], ';month=', $context['calendar_grid_next']['current_month'], '">', $current_month_started + 1 == $count ? (!empty($calendar_data['short_month_titles']) ? $txt['months_short'][$context['calendar_grid_next']['current_month']] . ' ' : $txt['months_titles'][$context['calendar_grid_next']['current_month']] . ' ') : '', $final_count++, '</a>';
535
+				if (empty($current_month_started) && !empty($context['calendar_grid_prev'])) {
536
+									echo '<a href="', $scripturl, '?action=calendar;year=', $context['calendar_grid_prev']['current_year'], ';month=', $context['calendar_grid_prev']['current_month'], '">', $context['calendar_grid_prev']['last_of_month'] - $calendar_data['shift']-- +1, '</a>';
537
+				} elseif (!empty($current_month_started) && !empty($context['calendar_grid_next'])) {
538
+									echo '<a href="', $scripturl, '?action=calendar;year=', $context['calendar_grid_next']['current_year'], ';month=', $context['calendar_grid_next']['current_month'], '">', $current_month_started + 1 == $count ? (!empty($calendar_data['short_month_titles']) ? $txt['months_short'][$context['calendar_grid_next']['current_month']] . ' ' : $txt['months_titles'][$context['calendar_grid_next']['current_month']] . ' ') : '', $final_count++, '</a>';
539
+				}
508 540
 			}
509 541
 
510 542
 			// Close this day and increase var count.
@@ -534,8 +566,9 @@  discard block
 block discarded – undo
534 566
 	global $context, $txt, $scripturl, $modSettings;
535 567
 
536 568
 	// We might have no reason to proceed, if the variable isn't there.
537
-	if (!isset($context['calendar_grid_' . $grid_name]))
538
-		return false;
569
+	if (!isset($context['calendar_grid_' . $grid_name])) {
570
+			return false;
571
+	}
539 572
 
540 573
 	// Handy pointer.
541 574
 	$calendar_data = &$context['calendar_grid_' . $grid_name];
@@ -552,22 +585,25 @@  discard block
 block discarded – undo
552 585
 					<h3 class="catbg centertext largetext">';
553 586
 
554 587
 			// Previous Week Link...
555
-			if (empty($calendar_data['previous_calendar']['disabled']) && !empty($calendar_data['show_next_prev']))
556
-				echo '
588
+			if (empty($calendar_data['previous_calendar']['disabled']) && !empty($calendar_data['show_next_prev'])) {
589
+							echo '
557 590
 						<span class="floatleft">
558 591
 							<a href="', $calendar_data['previous_week']['href'], '">&#171;</a>
559 592
 						</span>';
593
+			}
560 594
 
561 595
 			// Next Week Link...
562
-			if (empty($calendar_data['next_calendar']['disabled']) && !empty($calendar_data['show_next_prev']))
563
-				echo '
596
+			if (empty($calendar_data['next_calendar']['disabled']) && !empty($calendar_data['show_next_prev'])) {
597
+							echo '
564 598
 						<span class="floatright">
565 599
 							<a href="', $calendar_data['next_week']['href'], '">&#187;</a>
566 600
 						</span>';
601
+			}
567 602
 
568 603
 			// The Month Title + Week Number...
569
-			if (!empty($calendar_data['week_title']))
570
-				echo $calendar_data['week_title'];
604
+			if (!empty($calendar_data['week_title'])) {
605
+							echo $calendar_data['week_title'];
606
+			}
571 607
 
572 608
 			echo '
573 609
 					</h3>
@@ -608,11 +644,12 @@  discard block
 block discarded – undo
608 644
 						<td class="', implode(' ', $classes), ' act_day">';
609 645
 
610 646
 			// Should the day number be a link?
611
-			if (!empty($modSettings['cal_daysaslink']) && $context['can_post'])
612
-				echo '
647
+			if (!empty($modSettings['cal_daysaslink']) && $context['can_post']) {
648
+							echo '
613 649
 							<a href="', $scripturl, '?action=calendar;sa=post;month=', $month_data['current_month'], ';year=', $month_data['current_year'], ';day=', $day['day'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['days'][$day['day_of_week']], ' - ', $day['day'], '</a>';
614
-			else
615
-				echo $txt['days'][$day['day_of_week']], ' - ', $day['day'];
650
+			} else {
651
+							echo $txt['days'][$day['day_of_week']], ' - ', $day['day'];
652
+			}
616 653
 
617 654
 			echo '
618 655
 						</td>
@@ -623,8 +660,9 @@  discard block
 block discarded – undo
623 660
 			{
624 661
 				// Sort events by start time (all day events will be listed first)
625 662
 				uasort($day['events'], function($a, $b) {
626
-					if ($a['start_timestamp'] == $b['start_timestamp'])
627
-						return 0;
663
+					if ($a['start_timestamp'] == $b['start_timestamp']) {
664
+											return 0;
665
+					}
628 666
 					return ($a['start_timestamp'] < $b['start_timestamp']) ? -1 : 1;
629 667
 				});
630 668
 
@@ -638,35 +676,39 @@  discard block
 block discarded – undo
638 676
 					echo $event['link'], '<br>
639 677
 								<span class="event_time', empty($event_icons_needed) ? ' floatright' : '', '">';
640 678
 
641
-					if (!empty($event['start_time_local']))
642
-						echo trim($event['start_time_local']), !empty($event['end_time_local']) ? ' &ndash; ' . trim($event['end_time_local']) : '';
643
-					else
644
-						echo $txt['calendar_allday'];
679
+					if (!empty($event['start_time_local'])) {
680
+											echo trim($event['start_time_local']), !empty($event['end_time_local']) ? ' &ndash; ' . trim($event['end_time_local']) : '';
681
+					} else {
682
+											echo $txt['calendar_allday'];
683
+					}
645 684
 
646 685
 					echo '
647 686
 								</span>';
648 687
 
649
-					if (!empty($event['location']))
650
-						echo '<br>
688
+					if (!empty($event['location'])) {
689
+											echo '<br>
651 690
 								<span class="event_location', empty($event_icons_needed) ? ' floatright' : '', '">' . $event['location'] . '</span>';
691
+					}
652 692
 
653 693
 					if (!empty($event_icons_needed))
654 694
 					{
655 695
 						echo ' <span class="modify_event_links">';
656 696
 
657 697
 						// If they can edit the event, show a star they can click on....
658
-						if (!empty($event['can_edit']))
659
-							echo '
698
+						if (!empty($event['can_edit'])) {
699
+													echo '
660 700
 									<a class="modify_event" href="', $event['modify_href'], '">
661 701
 										<span class="generic_icons calendar_modify" title="', $txt['calendar_edit'], '"></span>
662 702
 									</a>';
703
+						}
663 704
 
664 705
 						// Can we export? Sweet.
665
-						if (!empty($event['can_export']))
666
-							echo '
706
+						if (!empty($event['can_export'])) {
707
+													echo '
667 708
 									<a class="modify_event" href="', $event['export_href'], '">
668 709
 										<span class="generic_icons calendar_export" title="', $txt['calendar_export'], '"></span>
669 710
 									</a>';
711
+						}
670 712
 
671 713
 						echo '
672 714
 								</span><br class="clear">';
@@ -684,22 +726,23 @@  discard block
 block discarded – undo
684 726
 							</div>
685 727
 							<br class="clear">';
686 728
 				}
687
-			}
688
-			else
729
+			} else
689 730
 			{
690
-				if (!empty($context['can_post']))
691
-					echo '
731
+				if (!empty($context['can_post'])) {
732
+									echo '
692 733
 							<div class="week_add_event">
693 734
 								<a href="', $scripturl, '?action=calendar;sa=post;month=', $month_data['current_month'], ';year=', $month_data['current_year'], ';day=', $day['day'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['calendar_post_event'], '</a>
694 735
 							</div>';
736
+				}
695 737
 			}
696 738
 			echo '
697 739
 						</td>
698 740
 						<td class="', implode(' ', $classes), !empty($day['holidays']) ? ' holidays' : ' disabled', ' holiday_col" data-css-prefix="' . $txt['calendar_prompt'] . ' ">';
699 741
 
700 742
 			// Show any holidays!
701
-			if (!empty($day['holidays']))
702
-				echo implode('<br>', $day['holidays']);
743
+			if (!empty($day['holidays'])) {
744
+							echo implode('<br>', $day['holidays']);
745
+			}
703 746
 
704 747
 			echo '
705 748
 						</td>
@@ -708,11 +751,12 @@  discard block
 block discarded – undo
708 751
 			// Show any birthdays...
709 752
 			if (!empty($day['birthdays']))
710 753
 			{
711
-				foreach ($day['birthdays'] as $member)
712
-					echo '
754
+				foreach ($day['birthdays'] as $member) {
755
+									echo '
713 756
 							<a href="', $scripturl, '?action=profile;u=', $member['id'], '">', $member['name'], '</a>
714 757
 							', isset($member['age']) ? ' (' . $member['age'] . ')' : '', '
715 758
 							', $member['is_last'] ? '' : '<br>';
759
+				}
716 760
 			}
717 761
 			echo '
718 762
 						</td>
@@ -758,26 +802,27 @@  discard block
 block discarded – undo
758 802
 				<input type="text" name="end_date" id="end_date" maxlength="10" value="', $calendar_data['end_date'], '" tabindex="', $context['tabindex']++, '" class="date_input end" data-type="date">
759 803
 				<input type="submit" class="button" style="float:none" id="view_button" value="', $txt['view'], '">
760 804
 			</form>';
761
-	}
762
-	else
805
+	} else
763 806
 	{
764 807
 		echo'
765 808
 			<form action="', $scripturl, '?action=calendar" id="calendar_navigation" method="post" accept-charset="', $context['character_set'], '">
766 809
 				<select name="month" id="input_month">';
767 810
 
768 811
 		// Show a select box with all the months.
769
-		foreach ($txt['months_short'] as $number => $month)
770
-			echo '
812
+		foreach ($txt['months_short'] as $number => $month) {
813
+					echo '
771 814
 					<option value="', $number, '"', $number == $context['current_month'] ? ' selected' : '', '>', $month, '</option>';
815
+		}
772 816
 
773 817
 		echo '
774 818
 				</select>
775 819
 				<select name="year">';
776 820
 
777 821
 		// Show a link for every year...
778
-		for ($year = $context['calendar_resources']['min_year']; $year <= $context['calendar_resources']['max_year']; $year++)
779
-			echo '
822
+		for ($year = $context['calendar_resources']['min_year']; $year <= $context['calendar_resources']['max_year']; $year++) {
823
+					echo '
780 824
 					<option value="', $year, '"', $year == $context['current_year'] ? ' selected' : '', '>', $year, '</option>';
825
+		}
781 826
 
782 827
 		echo '
783 828
 				</select>
@@ -799,9 +844,10 @@  discard block
 block discarded – undo
799 844
 	echo '
800 845
 		<form action="', $scripturl, '?action=calendar;sa=post" method="post" name="postevent" accept-charset="', $context['character_set'], '" onsubmit="submitonce(this);">';
801 846
 
802
-	if (!empty($context['event']['new']))
803
-		echo '
847
+	if (!empty($context['event']['new'])) {
848
+			echo '
804 849
 			<input type="hidden" name="eventid" value="', $context['event']['eventid'], '">';
850
+	}
805 851
 
806 852
 	// Start the main table.
807 853
 	echo '
@@ -812,8 +858,8 @@  discard block
 block discarded – undo
812 858
 					</h3>
813 859
 				</div>';
814 860
 
815
-	if (!empty($context['post_error']['messages']))
816
-		echo '
861
+	if (!empty($context['post_error']['messages'])) {
862
+			echo '
817 863
 				<div class="errorbox">
818 864
 					<dl class="event_error">
819 865
 						<dt>
@@ -824,6 +870,7 @@  discard block
 block discarded – undo
824 870
 						</dt>
825 871
 					</dl>
826 872
 				</div>';
873
+	}
827 874
 
828 875
 	echo '
829 876
 				<div class="roundframe noup">
@@ -851,9 +898,10 @@  discard block
 block discarded – undo
851 898
 			echo '
852 899
 									<optgroup label="', $category['name'], '">';
853 900
 
854
-			foreach ($category['boards'] as $board)
855
-				echo '
901
+			foreach ($category['boards'] as $board) {
902
+							echo '
856 903
 										<option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', '>', $board['child_level'] > 0 ? str_repeat('==', $board['child_level'] - 1) . '=&gt;' : '', ' ', $board['name'], '</option>';
904
+			}
857 905
 			echo '
858 906
 									</optgroup>';
859 907
 		}
@@ -889,9 +937,10 @@  discard block
 block discarded – undo
889 937
 								<span class="label">', $txt['calendar_timezone'], '</span>
890 938
 								<select name="tz" id="tz"', !empty($context['event']['allday']) ? ' disabled' : '', '>';
891 939
 
892
-	foreach ($context['all_timezones'] as $tz => $tzname)
893
-		echo '
940
+	foreach ($context['all_timezones'] as $tz => $tzname) {
941
+			echo '
894 942
 									<option value="', $tz, '"', $tz == $context['event']['tz'] ? ' selected' : '', '>', $tzname, '</option>';
943
+	}
895 944
 
896 945
 	echo '
897 946
 								</select>
@@ -907,9 +956,10 @@  discard block
 block discarded – undo
907 956
 					<input type="submit" value="', empty($context['event']['new']) ? $txt['save'] : $txt['post'], '" class="button">';
908 957
 
909 958
 	// Delete button?
910
-	if (empty($context['event']['new']))
911
-		echo '
959
+	if (empty($context['event']['new'])) {
960
+			echo '
912 961
 					<input type="submit" name="deleteevent" value="', $txt['event_delete'], '" data-confirm="', $txt['calendar_confirm_delete'], '" class="button you_sure">';
962
+	}
913 963
 
914 964
 	echo '
915 965
 					<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
@@ -937,9 +987,10 @@  discard block
 block discarded – undo
937 987
 		echo '
938 988
 				<td style="padding-', $alt ? 'right' : 'left', ': 1.5em;">';
939 989
 
940
-		foreach ($v as $i)
941
-			echo '
990
+		foreach ($v as $i) {
991
+					echo '
942 992
 					<img src="', $context['offimg'], '" alt="" id="', $t, '_', $i, '"><br>';
993
+		}
943 994
 
944 995
 		echo '
945 996
 				</td>';
@@ -960,9 +1011,10 @@  discard block
 block discarded – undo
960 1011
 
961 1012
 	foreach ($context['clockicons'] as $t => $v)
962 1013
 	{
963
-		foreach ($v as $i)
964
-			echo '
1014
+		foreach ($v as $i) {
1015
+					echo '
965 1016
 			icons[\'', $t, '_', $i, '\'] = document.getElementById(\'', $t, '_', $i, '\');';
1017
+		}
966 1018
 	}
967 1019
 
968 1020
 	echo '
@@ -987,13 +1039,14 @@  discard block
 block discarded – undo
987 1039
 
988 1040
 	foreach ($context['clockicons'] as $t => $v)
989 1041
 	{
990
-		foreach ($v as $i)
991
-			echo '
1042
+		foreach ($v as $i) {
1043
+					echo '
992 1044
 				if (', $t, ' >= ', $i, ')
993 1045
 				{
994 1046
 					turnon.push("', $t, '_', $i, '");
995 1047
 					', $t, ' -= ', $i, ';
996 1048
 				}';
1049
+		}
997 1050
 	}
998 1051
 
999 1052
 	echo '
@@ -1037,9 +1090,10 @@  discard block
 block discarded – undo
1037 1090
 			<tr class="', $alt ? 'windowbg2' : 'windowbg', '">
1038 1091
 				<td>';
1039 1092
 
1040
-		foreach ($v as $i)
1041
-			echo '
1093
+		foreach ($v as $i) {
1094
+					echo '
1042 1095
 					<img src="', $context['offimg'], '" alt="" id="', $t, '_', $i, '" style="padding: 2px;">';
1096
+		}
1043 1097
 
1044 1098
 		echo '
1045 1099
 				</td>
@@ -1061,9 +1115,10 @@  discard block
 block discarded – undo
1061 1115
 
1062 1116
 	foreach ($context['clockicons'] as $t => $v)
1063 1117
 	{
1064
-		foreach ($v as $i)
1065
-			echo '
1118
+		foreach ($v as $i) {
1119
+					echo '
1066 1120
 			icons[\'', $t, '_', $i, '\'] = document.getElementById(\'', $t, '_', $i, '\');';
1121
+		}
1067 1122
 	}
1068 1123
 
1069 1124
 	echo '
@@ -1080,13 +1135,14 @@  discard block
 block discarded – undo
1080 1135
 
1081 1136
 	foreach ($context['clockicons'] as $t => $v)
1082 1137
 	{
1083
-		foreach ($v as $i)
1084
-			echo '
1138
+		foreach ($v as $i) {
1139
+					echo '
1085 1140
 				if (', $t, ' >= ', $i, ')
1086 1141
 				{
1087 1142
 					turnon.push("', $t, '_', $i, '");
1088 1143
 					', $t, ' -= ', $i, ';
1089 1144
 				}';
1145
+		}
1090 1146
 	}
1091 1147
 
1092 1148
 	echo '
@@ -1130,9 +1186,10 @@  discard block
 block discarded – undo
1130 1186
 			<tr class="', $alt ? 'windowbg2' : 'windowbg', '">
1131 1187
 				<td>';
1132 1188
 
1133
-		foreach ($v as $i)
1134
-			echo '
1189
+		foreach ($v as $i) {
1190
+					echo '
1135 1191
 					<img src="', $context['offimg'], '" alt="" id="', $t, '_', $i, '" style="padding: 2px;">';
1192
+		}
1136 1193
 
1137 1194
 		echo '
1138 1195
 				</td>
@@ -1148,9 +1205,10 @@  discard block
 block discarded – undo
1148 1205
 
1149 1206
 	foreach ($context['clockicons'] as $t => $v)
1150 1207
 	{
1151
-		foreach ($v as $i)
1152
-			echo '
1208
+		foreach ($v as $i) {
1209
+					echo '
1153 1210
 			icons[\'', $t, '_', $i, '\'] = document.getElementById(\'', $t, '_', $i, '\');';
1211
+		}
1154 1212
 	}
1155 1213
 
1156 1214
 	echo '
@@ -1171,13 +1229,14 @@  discard block
 block discarded – undo
1171 1229
 
1172 1230
 	foreach ($context['clockicons'] as $t => $v)
1173 1231
 	{
1174
-		foreach ($v as $i)
1175
-		echo '
1232
+		foreach ($v as $i) {
1233
+				echo '
1176 1234
 				if (', $t, ' >= ', $i, ')
1177 1235
 				{
1178 1236
 					turnon.push("', $t, '_', $i, '");
1179 1237
 					', $t, ' -= ', $i, ';
1180 1238
 				}';
1239
+		}
1181 1240
 	}
1182 1241
 
1183 1242
 	echo '
@@ -1221,9 +1280,10 @@  discard block
 block discarded – undo
1221 1280
 			<tr class="', $alt ? 'windowbg2' : 'windowbg', '">
1222 1281
 				<td>';
1223 1282
 
1224
-		foreach ($v as $i)
1225
-			echo '
1283
+		foreach ($v as $i) {
1284
+					echo '
1226 1285
 					<img src="', $i ? $context['onimg'] : $context['offimg'], '" alt="" style="padding: 2px;">';
1286
+		}
1227 1287
 
1228 1288
 		echo '
1229 1289
 				</td>
Please login to merge, or discard this patch.