Completed
Push — release-2.1 ( 1c80d3...447e69 )
by Colin
09:55
created
Sources/Subs-Themes.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -425,7 +425,7 @@
 block discarded – undo
425 425
  *
426 426
  * This is a recursive function, it will call itself if there are subdirs inside the main directory.
427 427
  * @param string $path The absolute path to the directory to be removed
428
- * @return bool true when success, false on error.
428
+ * @return false|null true when success, false on error.
429 429
  */
430 430
 function remove_dir($path)
431 431
 {
Please login to merge, or discard this patch.
Braces   +67 added lines, -46 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 4
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 /**
20 21
  * Gets a single theme's info.
@@ -27,8 +28,9 @@  discard block
 block discarded – undo
27 28
 	global $smcFunc, $modSettings;
28 29
 
29 30
 	// No data, no fun!
30
-	if (empty($id))
31
-		return false;
31
+	if (empty($id)) {
32
+			return false;
33
+	}
32 34
 
33 35
 	// Make sure $id is an int.
34 36
 	$id = (int) $id;
@@ -171,8 +173,9 @@  discard block
 block discarded – undo
171 173
 	global $smcFunc, $sourcedir, $forum_version, $txt, $scripturl, $context;
172 174
 	global $explicit_images;
173 175
 
174
-	if (empty($path))
175
-		return false;
176
+	if (empty($path)) {
177
+			return false;
178
+	}
176 179
 
177 180
 	$xml_data = array();
178 181
 	$explicit_images = false;
@@ -229,9 +232,10 @@  discard block
 block discarded – undo
229 232
 	);
230 233
 
231 234
 	// Assign the values to be stored.
232
-	foreach ($xml_elements as $var => $name)
233
-		if (!empty($theme_info_xml[$name]))
235
+	foreach ($xml_elements as $var => $name) {
236
+			if (!empty($theme_info_xml[$name]))
234 237
 			$xml_data[$var] = $theme_info_xml[$name];
238
+	}
235 239
 
236 240
 	// Add the supported versions.
237 241
 	$xml_data['install_for'] = $install_versions;
@@ -243,8 +247,9 @@  discard block
 block discarded – undo
243 247
 		$explicit_images = true;
244 248
 	}
245 249
 
246
-	if (!empty($theme_info_xml['extra']))
247
-		$xml_data += $smcFunc['json_decode']($theme_info_xml['extra'], true);
250
+	if (!empty($theme_info_xml['extra'])) {
251
+			$xml_data += $smcFunc['json_decode']($theme_info_xml['extra'], true);
252
+	}
248 253
 
249 254
 	return $xml_data;
250 255
 }
@@ -262,12 +267,14 @@  discard block
 block discarded – undo
262 267
 	global $settings, $explicit_images;
263 268
 
264 269
 	// External use? no problem!
265
-	if ($to_install)
266
-		$context['to_install'] = $to_install;
270
+	if ($to_install) {
271
+			$context['to_install'] = $to_install;
272
+	}
267 273
 
268 274
 	// One last check.
269
-	if (empty($context['to_install']['theme_dir']) || basename($context['to_install']['theme_dir']) == 'Themes')
270
-		fatal_lang_error('theme_install_invalid_dir', false);
275
+	if (empty($context['to_install']['theme_dir']) || basename($context['to_install']['theme_dir']) == 'Themes') {
276
+			fatal_lang_error('theme_install_invalid_dir', false);
277
+	}
271 278
 
272 279
 	// OK, is this a newer version of an already installed theme?
273 280
 	if (!empty($context['to_install']['version']))
@@ -291,8 +298,8 @@  discard block
 block discarded – undo
291 298
 		$smcFunc['db_free_result']($request);
292 299
 
293 300
 		// Got something, lets figure it out what to do next.
294
-		if (!empty($to_update) && !empty($to_update['version']))
295
-			switch (compareVersions($context['to_install']['version'], $to_update['version']))
301
+		if (!empty($to_update) && !empty($to_update['version'])) {
302
+					switch (compareVersions($context['to_install']['version'], $to_update['version']))
296 303
 			{
297 304
 				case 1: // Got a newer version, update the old entry.
298 305
 					$smcFunc['db_query']('', '
@@ -306,6 +313,7 @@  discard block
 block discarded – undo
306 313
 							'id_theme' => $to_update['id_theme'],
307 314
 						)
308 315
 					);
316
+		}
309 317
 
310 318
 					// Done with the update, tell the user about it.
311 319
 					$context['to_install']['updated'] = true;
@@ -371,13 +379,15 @@  discard block
 block discarded – undo
371 379
 				$context['to_install']['base_theme_url'] = $temp['theme_url'];
372 380
 				$context['to_install']['base_theme_dir'] = $temp['theme_dir'];
373 381
 
374
-				if (empty($explicit_images) && !empty($context['to_install']['base_theme_url']))
375
-					$context['to_install']['theme_url'] = $context['to_install']['base_theme_url'];
382
+				if (empty($explicit_images) && !empty($context['to_install']['base_theme_url'])) {
383
+									$context['to_install']['theme_url'] = $context['to_install']['base_theme_url'];
384
+				}
376 385
 			}
377 386
 
378 387
 			// Nope, sorry, couldn't find any theme already installed.
379
-			else
380
-				fatal_lang_error('package_get_error_theme_no_based_on_found', false, $context['to_install']['based_on']);
388
+			else {
389
+							fatal_lang_error('package_get_error_theme_no_based_on_found', false, $context['to_install']['based_on']);
390
+			}
381 391
 		}
382 392
 
383 393
 		unset($context['to_install']['based_on']);
@@ -400,16 +410,18 @@  discard block
 block discarded – undo
400 410
 	call_integration_hook('integrate_theme_install', array(&$context['to_install'], $id_theme));
401 411
 
402 412
 	$inserts = array();
403
-	foreach ($context['to_install'] as $var => $val)
404
-		$inserts[] = array($id_theme, $var, $val);
413
+	foreach ($context['to_install'] as $var => $val) {
414
+			$inserts[] = array($id_theme, $var, $val);
415
+	}
405 416
 
406
-	if (!empty($inserts))
407
-		$smcFunc['db_insert']('insert',
417
+	if (!empty($inserts)) {
418
+			$smcFunc['db_insert']('insert',
408 419
 			'{db_prefix}themes',
409 420
 			array('id_theme' => 'int', 'variable' => 'string-255', 'value' => 'string-65534'),
410 421
 			$inserts,
411 422
 			array('id_theme', 'variable')
412 423
 		);
424
+	}
413 425
 
414 426
 	// Update the known and enable Theme's settings.
415 427
 	$known = strtr($modSettings['knownThemes'] . ',' . $id_theme, array(',,' => ','));
@@ -428,21 +440,24 @@  discard block
 block discarded – undo
428 440
  */
429 441
 function remove_dir($path)
430 442
 {
431
-	if (empty($path))
432
-		return false;
443
+	if (empty($path)) {
444
+			return false;
445
+	}
433 446
 
434 447
 	if (is_dir($path))
435 448
 	{
436 449
 		$objects = scandir($path);
437 450
 
438
-		foreach ($objects as $object)
439
-			if ($object != '.' && $object != '..')
451
+		foreach ($objects as $object) {
452
+					if ($object != '.' && $object != '..')
440 453
 			{
441 454
 				if (filetype($path . '/' . $object) == 'dir')
442 455
 					remove_dir($path . '/' . $object);
456
+		}
443 457
 
444
-				else
445
-					unlink($path . '/' . $object);
458
+				else {
459
+									unlink($path . '/' . $object);
460
+				}
446 461
 			}
447 462
 	}
448 463
 
@@ -461,8 +476,9 @@  discard block
 block discarded – undo
461 476
 	global $smcFunc, $modSettings;
462 477
 
463 478
 	// Can't delete the default theme, sorry!
464
-	if (empty($themeID) || $themeID == 1)
465
-		return false;
479
+	if (empty($themeID) || $themeID == 1) {
480
+			return false;
481
+	}
466 482
 
467 483
 	$known = explode(',', $modSettings['knownThemes']);
468 484
 	$enable = explode(',', $modSettings['enableThemes']);
@@ -512,8 +528,9 @@  discard block
 block discarded – undo
512 528
 	updateSettings(array('enableThemes' => $enable, 'knownThemes' => $known));
513 529
 
514 530
 	// Fix it if the theme was the overall default theme.
515
-	if ($modSettings['theme_guests'] == $themeID)
516
-		updateSettings(array('theme_guests' => '1'));
531
+	if ($modSettings['theme_guests'] == $themeID) {
532
+			updateSettings(array('theme_guests' => '1'));
533
+	}
517 534
 
518 535
 	return true;
519 536
 }
@@ -530,13 +547,15 @@  discard block
 block discarded – undo
530 547
 	global $scripturl, $txt, $context;
531 548
 
532 549
 	// Is it even a directory?
533
-	if (!is_dir($path))
534
-		fatal_lang_error('error_invalid_dir', 'critical');
550
+	if (!is_dir($path)) {
551
+			fatal_lang_error('error_invalid_dir', 'critical');
552
+	}
535 553
 
536 554
 	$dir = dir($path);
537 555
 	$entries = array();
538
-	while ($entry = $dir->read())
539
-		$entries[] = $entry;
556
+	while ($entry = $dir->read()) {
557
+			$entries[] = $entry;
558
+	}
540 559
 	$dir->close();
541 560
 
542 561
 	natcasesort($entries);
@@ -547,11 +566,12 @@  discard block
 block discarded – undo
547 566
 	foreach ($entries as $entry)
548 567
 	{
549 568
 		// Skip all dot files, including .htaccess.
550
-		if (substr($entry, 0, 1) == '.' || $entry == 'CVS')
551
-			continue;
569
+		if (substr($entry, 0, 1) == '.' || $entry == 'CVS') {
570
+					continue;
571
+		}
552 572
 
553
-		if (is_dir($path . '/' . $entry))
554
-			$listing1[] = array(
573
+		if (is_dir($path . '/' . $entry)) {
574
+					$listing1[] = array(
555 575
 				'filename' => $entry,
556 576
 				'is_writable' => is_writable($path . '/' . $entry),
557 577
 				'is_directory' => true,
@@ -561,13 +581,14 @@  discard block
 block discarded – undo
561 581
 				'href' => $scripturl . '?action=admin;area=theme;th=' . $_GET['th'] . ';' . $context['session_var'] . '=' . $context['session_id'] . ';sa=edit;directory=' . $relative . $entry,
562 582
 				'size' => '',
563 583
 			);
564
-		else
584
+		} else
565 585
 		{
566 586
 			$size = filesize($path . '/' . $entry);
567
-			if ($size > 2048 || $size == 1024)
568
-				$size = comma_format($size / 1024) . ' ' . $txt['themeadmin_edit_kilobytes'];
569
-			else
570
-				$size = comma_format($size) . ' ' . $txt['themeadmin_edit_bytes'];
587
+			if ($size > 2048 || $size == 1024) {
588
+							$size = comma_format($size / 1024) . ' ' . $txt['themeadmin_edit_kilobytes'];
589
+			} else {
590
+							$size = comma_format($size) . ' ' . $txt['themeadmin_edit_bytes'];
591
+			}
571 592
 
572 593
 			$listing2[] = array(
573 594
 				'filename' => $entry,
Please login to merge, or discard this patch.
Sources/Subscriptions-PayPal.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -402,7 +402,7 @@
 block discarded – undo
402 402
 	 * A private function to find out the subscription details.
403 403
 	 *
404 404
 	 * @access private
405
-	 * @return boolean|void False on failure, otherwise just sets $_POST['item_number']
405
+	 * @return false|null False on failure, otherwise just sets $_POST['item_number']
406 406
 	 */
407 407
 	private function _findSubscription()
408 408
 	{
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -236,7 +236,7 @@
 block discarded – undo
236 236
 			$header = 'POST /cgi-bin/webscr HTTP/1.1' . "\r\n";
237 237
 			$header .= 'content-type: application/x-www-form-urlencoded' . "\r\n";
238 238
 			$header .= 'Host: www.' . (!empty($modSettings['paidsubs_test']) ? 'sandbox.' : '') . 'paypal.com' . "\r\n";
239
-			$header .= 'content-length: ' . strlen ($requestString) . "\r\n";
239
+			$header .= 'content-length: ' . strlen($requestString) . "\r\n";
240 240
 			$header .= 'connection: close' . "\r\n\r\n";
241 241
 
242 242
 			// Open the connection.
Please login to merge, or discard this patch.
Braces   +83 added lines, -61 removed lines patch added patch discarded remove patch
@@ -14,8 +14,9 @@  discard block
 block discarded – undo
14 14
 // This won't be dedicated without this - this must exist in each gateway!
15 15
 // SMF Payment Gateway: paypal
16 16
 
17
-if (!defined('SMF'))
17
+if (!defined('SMF')) {
18 18
 	die('No direct access...');
19
+}
19 20
 
20 21
 /**
21 22
  * Class for returning available form data for this gateway
@@ -118,8 +119,7 @@  discard block
 block discarded – undo
118 119
 		{
119 120
 			$return_data['hidden']['p3'] = 1;
120 121
 			$return_data['hidden']['t3'] = strtoupper(substr($period, 0, 1));
121
-		}
122
-		else
122
+		} else
123 123
 		{
124 124
 			preg_match('~(\d*)(\w)~', $sub_data['real_length'], $match);
125 125
 			$unit = $match[1];
@@ -130,14 +130,15 @@  discard block
 block discarded – undo
130 130
 		}
131 131
 
132 132
 		// If it's repeatable do some javascript to respect this idea.
133
-		if (!empty($sub_data['repeatable']))
134
-			$return_data['javascript'] = '
133
+		if (!empty($sub_data['repeatable'])) {
134
+					$return_data['javascript'] = '
135 135
 				document.write(\'<label for="do_paypal_recur"><input type="checkbox" name="do_paypal_recur" id="do_paypal_recur" checked onclick="switchPaypalRecur();">' . $txt['paid_make_recurring'] . '</label><br>\');
136 136
 
137 137
 				function switchPaypalRecur()
138 138
 				{
139 139
 					document.getElementById("paypal_cmd").value = document.getElementById("do_paypal_recur").checked ? "_xclick-subscriptions" : "_xclick";
140 140
 				}';
141
+		}
141 142
 
142 143
 		return $return_data;
143 144
 	}
@@ -160,20 +161,24 @@  discard block
 block discarded – undo
160 161
 		global $modSettings;
161 162
 
162 163
 		// Has the user set up an email address?
163
-		if ((empty($modSettings['paidsubs_test']) && empty($modSettings['paypal_email'])) || (!empty($modSettings['paidsubs_test']) && empty($modSettings['paypal_sandbox_email'])))
164
-			return false;
164
+		if ((empty($modSettings['paidsubs_test']) && empty($modSettings['paypal_email'])) || (!empty($modSettings['paidsubs_test']) && empty($modSettings['paypal_sandbox_email']))) {
165
+					return false;
166
+		}
165 167
 		// Check the correct transaction types are even here.
166
-		if ((!isset($_POST['txn_type']) && !isset($_POST['payment_status'])) || (!isset($_POST['business']) && !isset($_POST['receiver_email'])))
167
-			return false;
168
+		if ((!isset($_POST['txn_type']) && !isset($_POST['payment_status'])) || (!isset($_POST['business']) && !isset($_POST['receiver_email']))) {
169
+					return false;
170
+		}
168 171
 		// Correct email address?
169
-		if (!isset($_POST['business']))
170
-			$_POST['business'] = $_POST['receiver_email'];
172
+		if (!isset($_POST['business'])) {
173
+					$_POST['business'] = $_POST['receiver_email'];
174
+		}
171 175
 
172 176
 		// Are we testing?
173
-		if (empty($modSettings['paidsubs_test']) && strtolower($modSettings['paypal_sandbox_email']) != strtolower($_POST['business']) && (empty($modSettings['paypal_additional_emails']) || !in_array(strtolower($_POST['business']), explode(',', strtolower($modSettings['paypal_additional_emails'])))))
174
-			return false;
175
-		elseif (strtolower($modSettings['paypal_email']) != strtolower($_POST['business']) && (empty($modSettings['paypal_additional_emails']) || !in_array(strtolower($_POST['business']), explode(',', $modSettings['paypal_additional_emails']))))
176
-			return false;
177
+		if (empty($modSettings['paidsubs_test']) && strtolower($modSettings['paypal_sandbox_email']) != strtolower($_POST['business']) && (empty($modSettings['paypal_additional_emails']) || !in_array(strtolower($_POST['business']), explode(',', strtolower($modSettings['paypal_additional_emails']))))) {
178
+					return false;
179
+		} elseif (strtolower($modSettings['paypal_email']) != strtolower($_POST['business']) && (empty($modSettings['paypal_additional_emails']) || !in_array(strtolower($_POST['business']), explode(',', $modSettings['paypal_additional_emails'])))) {
180
+					return false;
181
+		}
177 182
 		return true;
178 183
 	}
179 184
 
@@ -192,15 +197,17 @@  discard block
 block discarded – undo
192 197
 		global $modSettings, $txt;
193 198
 
194 199
 		// Put this to some default value.
195
-		if (!isset($_POST['txn_type']))
196
-			$_POST['txn_type'] = '';
200
+		if (!isset($_POST['txn_type'])) {
201
+					$_POST['txn_type'] = '';
202
+		}
197 203
 
198 204
 		// Build the request string - starting with the minimum requirement.
199 205
 		$requestString = 'cmd=_notify-validate';
200 206
 
201 207
 		// Now my dear, add all the posted bits in the order we got them
202
-		foreach ($_POST as $k => $v)
203
-			$requestString .= '&' . $k . '=' . urlencode($v);
208
+		foreach ($_POST as $k => $v) {
209
+					$requestString .= '&' . $k . '=' . urlencode($v);
210
+		}
204 211
 
205 212
 		// Can we use curl?
206 213
 		if (function_exists('curl_init') && $curl = curl_init((!empty($modSettings['paidsubs_test']) ? 'https://www.sandbox.' : 'https://www.') . 'paypal.com/cgi-bin/webscr'))
@@ -240,14 +247,16 @@  discard block
 block discarded – undo
240 247
 			$header .= 'connection: close' . "\r\n\r\n";
241 248
 
242 249
 			// Open the connection.
243
-			if (!empty($modSettings['paidsubs_test']))
244
-				$fp = fsockopen('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30);
245
-			else
246
-				$fp = fsockopen('www.paypal.com', 80, $errno, $errstr, 30);
250
+			if (!empty($modSettings['paidsubs_test'])) {
251
+							$fp = fsockopen('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30);
252
+			} else {
253
+							$fp = fsockopen('www.paypal.com', 80, $errno, $errstr, 30);
254
+			}
247 255
 
248 256
 			// Did it work?
249
-			if (!$fp)
250
-				generateSubscriptionError($txt['paypal_could_not_connect']);
257
+			if (!$fp) {
258
+							generateSubscriptionError($txt['paypal_could_not_connect']);
259
+			}
251 260
 
252 261
 			// Put the data to the port.
253 262
 			fputs($fp, $header . $requestString);
@@ -256,8 +265,9 @@  discard block
 block discarded – undo
256 265
 			while (!feof($fp))
257 266
 			{
258 267
 				$this->return_data = fgets($fp, 1024);
259
-				if (strcmp(trim($this->return_data), 'VERIFIED') === 0)
260
-					break;
268
+				if (strcmp(trim($this->return_data), 'VERIFIED') === 0) {
269
+									break;
270
+				}
261 271
 			}
262 272
 
263 273
 			// Clean up.
@@ -265,28 +275,34 @@  discard block
 block discarded – undo
265 275
 		}
266 276
 
267 277
 		// If this isn't verified then give up...
268
-		if (strcmp(trim($this->return_data), 'VERIFIED') !== 0)
269
-			exit;
278
+		if (strcmp(trim($this->return_data), 'VERIFIED') !== 0) {
279
+					exit;
280
+		}
270 281
 
271 282
 		// Check that this is intended for us.
272
-		if (strtolower($modSettings['paypal_email']) != strtolower($_POST['business']) && (empty($modSettings['paypal_additional_emails']) || !in_array(strtolower($_POST['business']), explode(',', strtolower($modSettings['paypal_additional_emails'])))))
273
-			exit;
283
+		if (strtolower($modSettings['paypal_email']) != strtolower($_POST['business']) && (empty($modSettings['paypal_additional_emails']) || !in_array(strtolower($_POST['business']), explode(',', strtolower($modSettings['paypal_additional_emails']))))) {
284
+					exit;
285
+		}
274 286
 
275 287
 		// Is this a subscription - and if so is it a secondary payment that we need to process?
276 288
 		// If so, make sure we get it in the expected format. Seems PayPal sometimes sends it without urlencoding.
277
-		if (!empty($_POST['item_number']) && strpos($_POST['item_number'], ' ') !== false)
278
-			$_POST['item_number'] = str_replace(' ', '+', $_POST['item_number']);
279
-		if ($this->isSubscription() && (empty($_POST['item_number']) || strpos($_POST['item_number'], '+') === false))
280
-			// Calculate the subscription it relates to!
289
+		if (!empty($_POST['item_number']) && strpos($_POST['item_number'], ' ') !== false) {
290
+					$_POST['item_number'] = str_replace(' ', '+', $_POST['item_number']);
291
+		}
292
+		if ($this->isSubscription() && (empty($_POST['item_number']) || strpos($_POST['item_number'], '+') === false)) {
293
+					// Calculate the subscription it relates to!
281 294
 			$this->_findSubscription();
295
+		}
282 296
 
283 297
 		// Verify the currency!
284
-		if (strtolower($_POST['mc_currency']) !== strtolower($modSettings['paid_currency_code']))
285
-			exit;
298
+		if (strtolower($_POST['mc_currency']) !== strtolower($modSettings['paid_currency_code'])) {
299
+					exit;
300
+		}
286 301
 
287 302
 		// Can't exist if it doesn't contain anything.
288
-		if (empty($_POST['item_number']))
289
-			exit;
303
+		if (empty($_POST['item_number'])) {
304
+					exit;
305
+		}
290 306
 
291 307
 		// Return the id_sub and id_member
292 308
 		return explode('+', $_POST['item_number']);
@@ -299,10 +315,11 @@  discard block
 block discarded – undo
299 315
 	 */
300 316
 	public function isRefund()
301 317
 	{
302
-		if ($_POST['payment_status'] === 'Refunded' || $_POST['payment_status'] === 'Reversed' || $_POST['txn_type'] === 'Refunded' || ($_POST['txn_type'] === 'reversal' && $_POST['payment_status'] === 'Completed'))
303
-			return true;
304
-		else
305
-			return false;
318
+		if ($_POST['payment_status'] === 'Refunded' || $_POST['payment_status'] === 'Reversed' || $_POST['txn_type'] === 'Refunded' || ($_POST['txn_type'] === 'reversal' && $_POST['payment_status'] === 'Completed')) {
319
+					return true;
320
+		} else {
321
+					return false;
322
+		}
306 323
 	}
307 324
 
308 325
 	/**
@@ -312,10 +329,11 @@  discard block
 block discarded – undo
312 329
 	 */
313 330
 	public function isSubscription()
314 331
 	{
315
-		if (substr($_POST['txn_type'], 0, 14) === 'subscr_payment' && $_POST['payment_status'] === 'Completed')
316
-			return true;
317
-		else
318
-			return false;
332
+		if (substr($_POST['txn_type'], 0, 14) === 'subscr_payment' && $_POST['payment_status'] === 'Completed') {
333
+					return true;
334
+		} else {
335
+					return false;
336
+		}
319 337
 	}
320 338
 
321 339
 	/**
@@ -325,10 +343,11 @@  discard block
 block discarded – undo
325 343
 	 */
326 344
 	public function isPayment()
327 345
 	{
328
-		if ($_POST['payment_status'] === 'Completed' && $_POST['txn_type'] === 'web_accept')
329
-			return true;
330
-		else
331
-			return false;
346
+		if ($_POST['payment_status'] === 'Completed' && $_POST['txn_type'] === 'web_accept') {
347
+					return true;
348
+		} else {
349
+					return false;
350
+		}
332 351
 	}
333 352
 
334 353
 	/**
@@ -341,10 +360,11 @@  discard block
 block discarded – undo
341 360
 		// subscr_cancel is sent when the user cancels, subscr_eot is sent when the subscription reaches final payment
342 361
 		// Neither require us to *do* anything as per performCancel().
343 362
 		// subscr_eot, if sent, indicates an end of payments term.
344
-		if (substr($_POST['txn_type'], 0, 13) === 'subscr_cancel' || substr($_POST['txn_type'], 0, 10) === 'subscr_eot')
345
-			return true;
346
-		else
347
-			return false;
363
+		if (substr($_POST['txn_type'], 0, 13) === 'subscr_cancel' || substr($_POST['txn_type'], 0, 10) === 'subscr_eot') {
364
+					return true;
365
+		} else {
366
+					return false;
367
+		}
348 368
 	}
349 369
 
350 370
 	/**
@@ -408,8 +428,9 @@  discard block
 block discarded – undo
408 428
 		global $smcFunc;
409 429
 
410 430
 		// Assume we have this?
411
-		if (empty($_POST['subscr_id']))
412
-			return false;
431
+		if (empty($_POST['subscr_id'])) {
432
+					return false;
433
+		}
413 434
 
414 435
 		// Do we have this in the database?
415 436
 		$request = $smcFunc['db_query']('', '
@@ -438,11 +459,12 @@  discard block
 block discarded – undo
438 459
 						'payer_email' => $_POST['payer_email'],
439 460
 					)
440 461
 				);
441
-				if ($smcFunc['db_num_rows']($request) === 0)
442
-					return false;
462
+				if ($smcFunc['db_num_rows']($request) === 0) {
463
+									return false;
464
+				}
465
+			} else {
466
+							return false;
443 467
 			}
444
-			else
445
-				return false;
446 468
 		}
447 469
 		list ($member_id, $subscription_id) = $smcFunc['db_fetch_row']($request);
448 470
 		$_POST['item_number'] = $member_id . '+' . $subscription_id;
Please login to merge, or discard this patch.
Sources/Xml.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -80,7 +80,7 @@
 block discarded – undo
80 80
 /**
81 81
  * Handles retrieving previews of news items, newsletters, signatures and warnings.
82 82
  * Calls the appropriate function based on $_POST['item']
83
- * @return void|bool Returns false if $_POST['item'] isn't set or isn't valid
83
+ * @return false|null Returns false if $_POST['item'] isn't set or isn't valid
84 84
  */
85 85
 function RetrievePreview()
86 86
 {
Please login to merge, or discard this patch.
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -272,13 +272,13 @@
 block discarded – undo
272 272
 				$context['post_error']['messages'][] = $txt['mc_warning_template_error_no_body'];
273 273
 			// Add in few replacements.
274 274
 			/**
275
-			* These are the defaults:
276
-			* - {MEMBER} - Member Name. => current user for review
277
-			* - {MESSAGE} - Link to Offending Post. (If Applicable) => not applicable here, so not replaced
278
-			* - {FORUMNAME} - Forum Name.
279
-			* - {SCRIPTURL} - Web address of forum.
280
-			* - {REGARDS} - Standard email sign-off.
281
-			*/
275
+			 * These are the defaults:
276
+			 * - {MEMBER} - Member Name. => current user for review
277
+			 * - {MESSAGE} - Link to Offending Post. (If Applicable) => not applicable here, so not replaced
278
+			 * - {FORUMNAME} - Forum Name.
279
+			 * - {SCRIPTURL} - Web address of forum.
280
+			 * - {REGARDS} - Standard email sign-off.
281
+			 */
282 282
 			$find = array(
283 283
 				'{MEMBER}',
284 284
 				'{FORUMNAME}',
Please login to merge, or discard this patch.
Braces   +55 added lines, -42 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 4
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 /**
20 21
  * The main handler and designator for AJAX stuff - jumpto, message icons and previews
@@ -32,8 +33,9 @@  discard block
 block discarded – undo
32 33
 	// Easy adding of sub actions.
33 34
 	call_integration_hook('integrate_XMLhttpMain_subActions', array(&$subActions));
34 35
 
35
-	if (!isset($_REQUEST['sa'], $subActions[$_REQUEST['sa']]))
36
-		fatal_lang_error('no_access', false);
36
+	if (!isset($_REQUEST['sa'], $subActions[$_REQUEST['sa']])) {
37
+			fatal_lang_error('no_access', false);
38
+	}
37 39
 
38 40
 	call_helper($subActions[$_REQUEST['sa']]);
39 41
 }
@@ -57,8 +59,9 @@  discard block
 block discarded – undo
57 59
 	foreach ($context['jump_to'] as $id_cat => $cat)
58 60
 	{
59 61
 		$context['jump_to'][$id_cat]['name'] = un_htmlspecialchars(strip_tags($cat['name']));
60
-		foreach ($cat['boards'] as $id_board => $board)
61
-			$context['jump_to'][$id_cat]['boards'][$id_board]['name'] = un_htmlspecialchars(strip_tags($board['name']));
62
+		foreach ($cat['boards'] as $id_board => $board) {
63
+					$context['jump_to'][$id_cat]['boards'][$id_board]['name'] = un_htmlspecialchars(strip_tags($board['name']));
64
+		}
62 65
 	}
63 66
 
64 67
 	$context['sub_template'] = 'jump_to';
@@ -95,8 +98,9 @@  discard block
 block discarded – undo
95 98
 
96 99
 	$context['sub_template'] = 'generic_xml';
97 100
 
98
-	if (!isset($_POST['item']) || !in_array($_POST['item'], $items))
99
-		return false;
101
+	if (!isset($_POST['item']) || !in_array($_POST['item'], $items)) {
102
+			return false;
103
+	}
100 104
 
101 105
 	$_POST['item']();
102 106
 }
@@ -112,10 +116,11 @@  discard block
 block discarded – undo
112 116
 
113 117
 	$errors = array();
114 118
 	$news = !isset($_POST['news']) ? '' : $smcFunc['htmlspecialchars']($_POST['news'], ENT_QUOTES);
115
-	if (empty($news))
116
-		$errors[] = array('value' => 'no_news');
117
-	else
118
-		preparsecode($news);
119
+	if (empty($news)) {
120
+			$errors[] = array('value' => 'no_news');
121
+	} else {
122
+			preparsecode($news);
123
+	}
119 124
 
120 125
 	$context['xml_data'] = array(
121 126
 		'news' => array(
@@ -148,10 +153,12 @@  discard block
 block discarded – undo
148 153
 	$context['send_pm'] = !empty($_POST['send_pm']) ? 1 : 0;
149 154
 	$context['send_html'] = !empty($_POST['send_html']) ? 1 : 0;
150 155
 
151
-	if (empty($_POST['subject']))
152
-		$context['post_error']['messages'][] = $txt['error_no_subject'];
153
-	if (empty($_POST['message']))
154
-		$context['post_error']['messages'][] = $txt['error_no_message'];
156
+	if (empty($_POST['subject'])) {
157
+			$context['post_error']['messages'][] = $txt['error_no_subject'];
158
+	}
159
+	if (empty($_POST['message'])) {
160
+			$context['post_error']['messages'][] = $txt['error_no_message'];
161
+	}
155 162
 
156 163
 	prepareMailingForPreview();
157 164
 
@@ -196,38 +203,41 @@  discard block
 block discarded – undo
196 203
 		$preview_signature = !empty($_POST['signature']) ? $_POST['signature'] : $txt['no_signature_preview'];
197 204
 		$validation = profileValidateSignature($preview_signature);
198 205
 
199
-		if ($validation !== true && $validation !== false)
200
-			$errors[] = array('value' => $txt['profile_error_' . $validation], 'attributes' => array('type' => 'error'));
206
+		if ($validation !== true && $validation !== false) {
207
+					$errors[] = array('value' => $txt['profile_error_' . $validation], 'attributes' => array('type' => 'error'));
208
+		}
201 209
 
202 210
 		censorText($preview_signature);
203 211
 		$preview_signature = parse_bbc($preview_signature, true, 'sig' . $user);
204
-	}
205
-	elseif (!$can_change)
212
+	} elseif (!$can_change)
206 213
 	{
207
-		if ($is_owner)
208
-			$errors[] = array('value' => $txt['cannot_profile_extra_own'], 'attributes' => array('type' => 'error'));
209
-		else
210
-			$errors[] = array('value' => $txt['cannot_profile_extra_any'], 'attributes' => array('type' => 'error'));
214
+		if ($is_owner) {
215
+					$errors[] = array('value' => $txt['cannot_profile_extra_own'], 'attributes' => array('type' => 'error'));
216
+		} else {
217
+					$errors[] = array('value' => $txt['cannot_profile_extra_any'], 'attributes' => array('type' => 'error'));
218
+		}
219
+	} else {
220
+			$errors[] = array('value' => $txt['no_user_selected'], 'attributes' => array('type' => 'error'));
211 221
 	}
212
-	else
213
-		$errors[] = array('value' => $txt['no_user_selected'], 'attributes' => array('type' => 'error'));
214 222
 
215 223
 	$context['xml_data']['signatures'] = array(
216 224
 			'identifier' => 'signature',
217 225
 			'children' => array()
218 226
 		);
219
-	if (isset($current_signature))
220
-		$context['xml_data']['signatures']['children'][] = array(
227
+	if (isset($current_signature)) {
228
+			$context['xml_data']['signatures']['children'][] = array(
221 229
 					'value' => $current_signature,
222 230
 					'attributes' => array('type' => 'current'),
223 231
 				);
224
-	if (isset($preview_signature))
225
-		$context['xml_data']['signatures']['children'][] = array(
232
+	}
233
+	if (isset($preview_signature)) {
234
+			$context['xml_data']['signatures']['children'][] = array(
226 235
 					'value' => $preview_signature,
227 236
 					'attributes' => array('type' => 'preview'),
228 237
 				);
229
-	if (!empty($errors))
230
-		$context['xml_data']['errors'] = array(
238
+	}
239
+	if (!empty($errors)) {
240
+			$context['xml_data']['errors'] = array(
231 241
 			'identifier' => 'error',
232 242
 			'children' => array_merge(
233 243
 				array(
@@ -239,7 +249,8 @@  discard block
 block discarded – undo
239 249
 				$errors
240 250
 			),
241 251
 		);
242
-}
252
+	}
253
+	}
243 254
 
244 255
 /**
245 256
  * Handles previewing user warnings
@@ -259,15 +270,17 @@  discard block
 block discarded – undo
259 270
 		$context['preview_subject'] = !empty($_POST['title']) ? trim($smcFunc['htmlspecialchars']($_POST['title'])) : '';
260 271
 		if (isset($_POST['issuing']))
261 272
 		{
262
-			if (empty($_POST['title']) || empty($_POST['body']))
263
-				$context['post_error']['messages'][] = $txt['warning_notify_blank'];
264
-		}
265
-		else
273
+			if (empty($_POST['title']) || empty($_POST['body'])) {
274
+							$context['post_error']['messages'][] = $txt['warning_notify_blank'];
275
+			}
276
+		} else
266 277
 		{
267
-			if (empty($_POST['title']))
268
-				$context['post_error']['messages'][] = $txt['mc_warning_template_error_no_title'];
269
-			if (empty($_POST['body']))
270
-				$context['post_error']['messages'][] = $txt['mc_warning_template_error_no_body'];
278
+			if (empty($_POST['title'])) {
279
+							$context['post_error']['messages'][] = $txt['mc_warning_template_error_no_title'];
280
+			}
281
+			if (empty($_POST['body'])) {
282
+							$context['post_error']['messages'][] = $txt['mc_warning_template_error_no_body'];
283
+			}
271 284
 			// Add in few replacements.
272 285
 			/**
273 286
 			* These are the defaults:
@@ -298,9 +311,9 @@  discard block
 block discarded – undo
298 311
 			$warning_body = parse_bbc($warning_body, true);
299 312
 		}
300 313
 		$context['preview_message'] = $warning_body;
314
+	} else {
315
+			$context['post_error']['messages'][] = array('value' => $txt['cannot_issue_warning'], 'attributes' => array('type' => 'error'));
301 316
 	}
302
-	else
303
-		$context['post_error']['messages'][] = array('value' => $txt['cannot_issue_warning'], 'attributes' => array('type' => 'error'));
304 317
 
305 318
 	$context['sub_template'] = 'warning';
306 319
 }
Please login to merge, or discard this patch.
SSI.php 3 patches
Doc Comments   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1717,7 +1717,7 @@  discard block
 block discarded – undo
1717 1717
 /**
1718 1718
  * Show today's birthdays.
1719 1719
  * @param string $output_method The output method. If 'echo', displays a list of users, otherwise returns an array of info about them.
1720
- * @return void|array Displays a list of users or returns an array of info about them depending on output_method.
1720
+ * @return null|string Displays a list of users or returns an array of info about them depending on output_method.
1721 1721
  */
1722 1722
 function ssi_todaysBirthdays($output_method = 'echo')
1723 1723
 {
@@ -1746,7 +1746,7 @@  discard block
 block discarded – undo
1746 1746
 /**
1747 1747
  * Shows today's holidays.
1748 1748
  * @param string $output_method The output method. If 'echo', displays a list of holidays, otherwise returns an array of info about them.
1749
- * @return void|array Displays a list of holidays or returns an array of info about them depending on output_method
1749
+ * @return null|string Displays a list of holidays or returns an array of info about them depending on output_method
1750 1750
  */
1751 1751
 function ssi_todaysHolidays($output_method = 'echo')
1752 1752
 {
@@ -1773,7 +1773,7 @@  discard block
 block discarded – undo
1773 1773
 
1774 1774
 /**
1775 1775
  * @param string $output_method The output method. If 'echo', displays a list of events, otherwise returns an array of info about them.
1776
- * @return void|array Displays a list of events or returns an array of info about them depending on output_method
1776
+ * @return null|string Displays a list of events or returns an array of info about them depending on output_method
1777 1777
  */
1778 1778
 function ssi_todaysEvents($output_method = 'echo')
1779 1779
 {
@@ -1807,7 +1807,7 @@  discard block
 block discarded – undo
1807 1807
 /**
1808 1808
  * Shows today's calendar items (events, birthdays and holidays)
1809 1809
  * @param string $output_method The output method. If 'echo', displays a list of calendar items, otherwise returns an array of info about them.
1810
- * @return void|array Displays a list of calendar items or returns an array of info about them depending on output_method
1810
+ * @return null|string Displays a list of calendar items or returns an array of info about them depending on output_method
1811 1811
  */
1812 1812
 function ssi_todaysCalendar($output_method = 'echo')
1813 1813
 {
@@ -2198,7 +2198,7 @@  discard block
 block discarded – undo
2198 2198
  * @param int|string $id The ID or username of a user
2199 2199
  * @param string $password The password to check
2200 2200
  * @param bool $is_username If true, treats $id as a username rather than a user ID
2201
- * @return bool Whether or not the password is correct.
2201
+ * @return null|boolean Whether or not the password is correct.
2202 2202
  */
2203 2203
 function ssi_checkPassword($id = null, $password = null, $is_username = false)
2204 2204
 {
Please login to merge, or discard this patch.
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   +426 added lines, -304 removed lines patch added patch discarded remove patch
@@ -12,8 +12,9 @@  discard block
 block discarded – undo
12 12
  */
13 13
 
14 14
 // Don't do anything if SMF is already loaded.
15
-if (defined('SMF'))
15
+if (defined('SMF')) {
16 16
 	return true;
17
+}
17 18
 
18 19
 define('SMF', 'SSI');
19 20
 
@@ -28,16 +29,18 @@  discard block
 block discarded – undo
28 29
 $time_start = microtime(true);
29 30
 
30 31
 // Just being safe...
31
-foreach (array('db_character_set', 'cachedir') as $variable)
32
+foreach (array('db_character_set', 'cachedir') as $variable) {
32 33
 	if (isset($GLOBALS[$variable]))
33 34
 		unset($GLOBALS[$variable]);
35
+}
34 36
 
35 37
 // Get the forum's settings for database and file paths.
36 38
 require_once(dirname(__FILE__) . '/Settings.php');
37 39
 
38 40
 // Make absolutely sure the cache directory is defined.
39
-if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache'))
41
+if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) {
40 42
 	$cachedir = $boarddir . '/cache';
43
+}
41 44
 
42 45
 $ssi_error_reporting = error_reporting(E_ALL);
43 46
 /* Set this to one of three values depending on what you want to happen in the case of a fatal error.
@@ -48,12 +51,14 @@  discard block
 block discarded – undo
48 51
 $ssi_on_error_method = false;
49 52
 
50 53
 // Don't do john didley if the forum's been shut down completely.
51
-if ($maintenance == 2 && (!isset($ssi_maintenance_off) || $ssi_maintenance_off !== true))
54
+if ($maintenance == 2 && (!isset($ssi_maintenance_off) || $ssi_maintenance_off !== true)) {
52 55
 	die($mmessage);
56
+}
53 57
 
54 58
 // Fix for using the current directory as a path.
55
-if (substr($sourcedir, 0, 1) == '.' && substr($sourcedir, 1, 1) != '.')
59
+if (substr($sourcedir, 0, 1) == '.' && substr($sourcedir, 1, 1) != '.') {
56 60
 	$sourcedir = dirname(__FILE__) . substr($sourcedir, 1);
61
+}
57 62
 
58 63
 // Load the important includes.
59 64
 require_once($sourcedir . '/QueryString.php');
@@ -78,26 +83,30 @@  discard block
 block discarded – undo
78 83
 cleanRequest();
79 84
 
80 85
 // Seed the random generator?
81
-if (empty($modSettings['rand_seed']) || mt_rand(1, 250) == 69)
86
+if (empty($modSettings['rand_seed']) || mt_rand(1, 250) == 69) {
82 87
 	smf_seed_generator();
88
+}
83 89
 
84 90
 // Check on any hacking attempts.
85
-if (isset($_REQUEST['GLOBALS']) || isset($_COOKIE['GLOBALS']))
91
+if (isset($_REQUEST['GLOBALS']) || isset($_COOKIE['GLOBALS'])) {
86 92
 	die('No direct access...');
87
-elseif (isset($_REQUEST['ssi_theme']) && (int) $_REQUEST['ssi_theme'] == (int) $ssi_theme)
93
+} elseif (isset($_REQUEST['ssi_theme']) && (int) $_REQUEST['ssi_theme'] == (int) $ssi_theme) {
88 94
 	die('No direct access...');
89
-elseif (isset($_COOKIE['ssi_theme']) && (int) $_COOKIE['ssi_theme'] == (int) $ssi_theme)
95
+} elseif (isset($_COOKIE['ssi_theme']) && (int) $_COOKIE['ssi_theme'] == (int) $ssi_theme) {
90 96
 	die('No direct access...');
91
-elseif (isset($_REQUEST['ssi_layers'], $ssi_layers) && (@get_magic_quotes_gpc() ? stripslashes($_REQUEST['ssi_layers']) : $_REQUEST['ssi_layers']) == $ssi_layers)
97
+} elseif (isset($_REQUEST['ssi_layers'], $ssi_layers) && (@get_magic_quotes_gpc() ? stripslashes($_REQUEST['ssi_layers']) : $_REQUEST['ssi_layers']) == $ssi_layers) {
92 98
 	die('No direct access...');
93
-if (isset($_REQUEST['context']))
99
+}
100
+if (isset($_REQUEST['context'])) {
94 101
 	die('No direct access...');
102
+}
95 103
 
96 104
 // Gzip output? (because it must be boolean and true, this can't be hacked.)
97
-if (isset($ssi_gzip) && $ssi_gzip === true && ini_get('zlib.output_compression') != '1' && ini_get('output_handler') != 'ob_gzhandler' && version_compare(PHP_VERSION, '4.2.0', '>='))
105
+if (isset($ssi_gzip) && $ssi_gzip === true && ini_get('zlib.output_compression') != '1' && ini_get('output_handler') != 'ob_gzhandler' && version_compare(PHP_VERSION, '4.2.0', '>=')) {
98 106
 	ob_start('ob_gzhandler');
99
-else
107
+} else {
100 108
 	$modSettings['enableCompressedOutput'] = '0';
109
+}
101 110
 
102 111
 /**
103 112
  * An autoloader for certain classes.
@@ -146,9 +155,9 @@  discard block
 block discarded – undo
146 155
 ob_start('ob_sessrewrite');
147 156
 
148 157
 // Start the session... known to scramble SSI includes in cases...
149
-if (!headers_sent())
158
+if (!headers_sent()) {
150 159
 	loadSession();
151
-else
160
+} else
152 161
 {
153 162
 	if (isset($_COOKIE[session_name()]) || isset($_REQUEST[session_name()]))
154 163
 	{
@@ -182,12 +191,14 @@  discard block
 block discarded – undo
182 191
 loadTheme(isset($ssi_theme) ? (int) $ssi_theme : 0);
183 192
 
184 193
 // @todo: probably not the best place, but somewhere it should be set...
185
-if (!headers_sent())
194
+if (!headers_sent()) {
186 195
 	header('content-type: text/html; charset=' . (empty($modSettings['global_character_set']) ? (empty($txt['lang_character_set']) ? 'ISO-8859-1' : $txt['lang_character_set']) : $modSettings['global_character_set']));
196
+}
187 197
 
188 198
 // Take care of any banning that needs to be done.
189
-if (isset($_REQUEST['ssi_ban']) || (isset($ssi_ban) && $ssi_ban === true))
199
+if (isset($_REQUEST['ssi_ban']) || (isset($ssi_ban) && $ssi_ban === true)) {
190 200
 	is_not_banned();
201
+}
191 202
 
192 203
 // Do we allow guests in here?
193 204
 if (empty($ssi_guest_access) && empty($modSettings['allow_guestAccess']) && $user_info['is_guest'] && basename($_SERVER['PHP_SELF']) != 'SSI.php')
@@ -202,17 +213,19 @@  discard block
 block discarded – undo
202 213
 {
203 214
 	$context['template_layers'] = $ssi_layers;
204 215
 	template_header();
205
-}
206
-else
216
+} else {
207 217
 	setupThemeContext();
218
+}
208 219
 
209 220
 // Make sure they didn't muss around with the settings... but only if it's not cli.
210
-if (isset($_SERVER['REMOTE_ADDR']) && !isset($_SERVER['is_cli']) && session_id() == '')
221
+if (isset($_SERVER['REMOTE_ADDR']) && !isset($_SERVER['is_cli']) && session_id() == '') {
211 222
 	trigger_error($txt['ssi_session_broken'], E_USER_NOTICE);
223
+}
212 224
 
213 225
 // Without visiting the forum this session variable might not be set on submit.
214
-if (!isset($_SESSION['USER_AGENT']) && (!isset($_GET['ssi_function']) || $_GET['ssi_function'] !== 'pollVote'))
226
+if (!isset($_SESSION['USER_AGENT']) && (!isset($_GET['ssi_function']) || $_GET['ssi_function'] !== 'pollVote')) {
215 227
 	$_SESSION['USER_AGENT'] = $_SERVER['HTTP_USER_AGENT'];
228
+}
216 229
 
217 230
 // Have the ability to easily add functions to SSI.
218 231
 call_integration_hook('integrate_SSI');
@@ -221,11 +234,13 @@  discard block
 block discarded – undo
221 234
 if (basename($_SERVER['PHP_SELF']) == 'SSI.php')
222 235
 {
223 236
 	// You shouldn't just access SSI.php directly by URL!!
224
-	if (!isset($_GET['ssi_function']))
225
-		die(sprintf($txt['ssi_not_direct'], $user_info['is_admin'] ? '\'' . addslashes(__FILE__) . '\'' : '\'SSI.php\''));
237
+	if (!isset($_GET['ssi_function'])) {
238
+			die(sprintf($txt['ssi_not_direct'], $user_info['is_admin'] ? '\'' . addslashes(__FILE__) . '\'' : '\'SSI.php\''));
239
+	}
226 240
 	// Call a function passed by GET.
227
-	if (function_exists('ssi_' . $_GET['ssi_function']) && (!empty($modSettings['allow_guestAccess']) || !$user_info['is_guest']))
228
-		call_user_func('ssi_' . $_GET['ssi_function']);
241
+	if (function_exists('ssi_' . $_GET['ssi_function']) && (!empty($modSettings['allow_guestAccess']) || !$user_info['is_guest'])) {
242
+			call_user_func('ssi_' . $_GET['ssi_function']);
243
+	}
229 244
 	exit;
230 245
 }
231 246
 
@@ -242,9 +257,10 @@  discard block
 block discarded – undo
242 257
  */
243 258
 function ssi_shutdown()
244 259
 {
245
-	if (!isset($_GET['ssi_function']) || $_GET['ssi_function'] != 'shutdown')
246
-		template_footer();
247
-}
260
+	if (!isset($_GET['ssi_function']) || $_GET['ssi_function'] != 'shutdown') {
261
+			template_footer();
262
+	}
263
+	}
248 264
 
249 265
 /**
250 266
  * Display a welcome message, like: Hey, User, you have 0 messages, 0 are new.
@@ -257,15 +273,17 @@  discard block
 block discarded – undo
257 273
 
258 274
 	if ($output_method == 'echo')
259 275
 	{
260
-		if ($context['user']['is_guest'])
261
-			echo sprintf($txt[$context['can_register'] ? 'welcome_guest_register' : 'welcome_guest'], $txt['guest_title'], $context['forum_name_html_safe'], $scripturl . '?action=login', 'return reqOverlayDiv(this.href, ' . JavaScriptEscape($txt['login']) . ');', $scripturl . '?action=signup');
262
-		else
263
-			echo $txt['hello_member'], ' <strong>', $context['user']['name'], '</strong>', allowedTo('pm_read') ? ', ' . (empty($context['user']['messages']) ? $txt['msg_alert_no_messages'] : (($context['user']['messages'] == 1 ? sprintf($txt['msg_alert_one_message'], $scripturl . '?action=pm') : sprintf($txt['msg_alert_many_message'], $scripturl . '?action=pm', $context['user']['messages'])) . ', ' . ($context['user']['unread_messages'] == 1 ? $txt['msg_alert_one_new'] : sprintf($txt['msg_alert_many_new'], $context['user']['unread_messages'])))) : '';
276
+		if ($context['user']['is_guest']) {
277
+					echo sprintf($txt[$context['can_register'] ? 'welcome_guest_register' : 'welcome_guest'], $txt['guest_title'], $context['forum_name_html_safe'], $scripturl . '?action=login', 'return reqOverlayDiv(this.href, ' . JavaScriptEscape($txt['login']) . ');', $scripturl . '?action=signup');
278
+		} else {
279
+					echo $txt['hello_member'], ' <strong>', $context['user']['name'], '</strong>', allowedTo('pm_read') ? ', ' . (empty($context['user']['messages']) ? $txt['msg_alert_no_messages'] : (($context['user']['messages'] == 1 ? sprintf($txt['msg_alert_one_message'], $scripturl . '?action=pm') : sprintf($txt['msg_alert_many_message'], $scripturl . '?action=pm', $context['user']['messages'])) . ', ' . ($context['user']['unread_messages'] == 1 ? $txt['msg_alert_one_new'] : sprintf($txt['msg_alert_many_new'], $context['user']['unread_messages'])))) : '';
280
+		}
264 281
 	}
265 282
 	// Don't echo... then do what?!
266
-	else
267
-		return $context['user'];
268
-}
283
+	else {
284
+			return $context['user'];
285
+	}
286
+	}
269 287
 
270 288
 /**
271 289
  * Display a menu bar, like is displayed at the top of the forum.
@@ -276,12 +294,14 @@  discard block
 block discarded – undo
276 294
 {
277 295
 	global $context;
278 296
 
279
-	if ($output_method == 'echo')
280
-		template_menu();
297
+	if ($output_method == 'echo') {
298
+			template_menu();
299
+	}
281 300
 	// What else could this do?
282
-	else
283
-		return $context['menu_buttons'];
284
-}
301
+	else {
302
+			return $context['menu_buttons'];
303
+	}
304
+	}
285 305
 
286 306
 /**
287 307
  * Show a logout link.
@@ -293,20 +313,23 @@  discard block
 block discarded – undo
293 313
 {
294 314
 	global $context, $txt, $scripturl;
295 315
 
296
-	if ($redirect_to != '')
297
-		$_SESSION['logout_url'] = $redirect_to;
316
+	if ($redirect_to != '') {
317
+			$_SESSION['logout_url'] = $redirect_to;
318
+	}
298 319
 
299 320
 	// Guests can't log out.
300
-	if ($context['user']['is_guest'])
301
-		return false;
321
+	if ($context['user']['is_guest']) {
322
+			return false;
323
+	}
302 324
 
303 325
 	$link = '<a href="' . $scripturl . '?action=logout;' . $context['session_var'] . '=' . $context['session_id'] . '">' . $txt['logout'] . '</a>';
304 326
 
305
-	if ($output_method == 'echo')
306
-		echo $link;
307
-	else
308
-		return $link;
309
-}
327
+	if ($output_method == 'echo') {
328
+			echo $link;
329
+	} else {
330
+			return $link;
331
+	}
332
+	}
310 333
 
311 334
 /**
312 335
  * Recent post list:   [board] Subject by Poster    Date
@@ -322,17 +345,17 @@  discard block
 block discarded – undo
322 345
 	global $modSettings, $context;
323 346
 
324 347
 	// Excluding certain boards...
325
-	if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0)
326
-		$exclude_boards = array($modSettings['recycle_board']);
327
-	else
328
-		$exclude_boards = empty($exclude_boards) ? array() : (is_array($exclude_boards) ? $exclude_boards : array($exclude_boards));
348
+	if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0) {
349
+			$exclude_boards = array($modSettings['recycle_board']);
350
+	} else {
351
+			$exclude_boards = empty($exclude_boards) ? array() : (is_array($exclude_boards) ? $exclude_boards : array($exclude_boards));
352
+	}
329 353
 
330 354
 	// What about including certain boards - note we do some protection here as pre-2.0 didn't have this parameter.
331 355
 	if (is_array($include_boards) || (int) $include_boards === $include_boards)
332 356
 	{
333 357
 		$include_boards = is_array($include_boards) ? $include_boards : array($include_boards);
334
-	}
335
-	elseif ($include_boards != null)
358
+	} elseif ($include_boards != null)
336 359
 	{
337 360
 		$include_boards = array();
338 361
 	}
@@ -369,8 +392,9 @@  discard block
 block discarded – undo
369 392
 {
370 393
 	global $modSettings;
371 394
 
372
-	if (empty($post_ids))
373
-		return;
395
+	if (empty($post_ids)) {
396
+			return;
397
+	}
374 398
 
375 399
 	// Allow the user to request more than one - why not?
376 400
 	$post_ids = is_array($post_ids) ? $post_ids : array($post_ids);
@@ -405,8 +429,9 @@  discard block
 block discarded – undo
405 429
 	global $scripturl, $txt, $user_info;
406 430
 	global $modSettings, $smcFunc, $context;
407 431
 
408
-	if (!empty($modSettings['enable_likes']))
409
-		$context['can_like'] = allowedTo('likes_like');
432
+	if (!empty($modSettings['enable_likes'])) {
433
+			$context['can_like'] = allowedTo('likes_like');
434
+	}
410 435
 
411 436
 	// Find all the posts. Newer ones will have higher IDs.
412 437
 	$request = $smcFunc['db_query']('substring', '
@@ -472,12 +497,13 @@  discard block
 block discarded – undo
472 497
 		);
473 498
 
474 499
 		// Get the likes for each message.
475
-		if (!empty($modSettings['enable_likes']))
476
-			$posts[$row['id_msg']]['likes'] = array(
500
+		if (!empty($modSettings['enable_likes'])) {
501
+					$posts[$row['id_msg']]['likes'] = array(
477 502
 				'count' => $row['likes'],
478 503
 				'you' => in_array($row['id_msg'], prepareLikesContext($row['id_topic'])),
479 504
 				'can_like' => !$context['user']['is_guest'] && $row['id_member'] != $context['user']['id'] && !empty($context['can_like']),
480 505
 			);
506
+		}
481 507
 	}
482 508
 	$smcFunc['db_free_result']($request);
483 509
 
@@ -485,13 +511,14 @@  discard block
 block discarded – undo
485 511
 	call_integration_hook('integrate_ssi_queryPosts', array(&$posts));
486 512
 
487 513
 	// Just return it.
488
-	if ($output_method != 'echo' || empty($posts))
489
-		return $posts;
514
+	if ($output_method != 'echo' || empty($posts)) {
515
+			return $posts;
516
+	}
490 517
 
491 518
 	echo '
492 519
 		<table style="border: none" class="ssi_table">';
493
-	foreach ($posts as $post)
494
-		echo '
520
+	foreach ($posts as $post) {
521
+			echo '
495 522
 			<tr>
496 523
 				<td style="text-align: right; vertical-align: top; white-space: nowrap">
497 524
 					[', $post['board']['link'], ']
@@ -505,6 +532,7 @@  discard block
 block discarded – undo
505 532
 					', $post['time'], '
506 533
 				</td>
507 534
 			</tr>';
535
+	}
508 536
 	echo '
509 537
 		</table>';
510 538
 }
@@ -522,25 +550,26 @@  discard block
 block discarded – undo
522 550
 	global $settings, $scripturl, $txt, $user_info;
523 551
 	global $modSettings, $smcFunc, $context;
524 552
 
525
-	if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0)
526
-		$exclude_boards = array($modSettings['recycle_board']);
527
-	else
528
-		$exclude_boards = empty($exclude_boards) ? array() : (is_array($exclude_boards) ? $exclude_boards : array($exclude_boards));
553
+	if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0) {
554
+			$exclude_boards = array($modSettings['recycle_board']);
555
+	} else {
556
+			$exclude_boards = empty($exclude_boards) ? array() : (is_array($exclude_boards) ? $exclude_boards : array($exclude_boards));
557
+	}
529 558
 
530 559
 	// Only some boards?.
531 560
 	if (is_array($include_boards) || (int) $include_boards === $include_boards)
532 561
 	{
533 562
 		$include_boards = is_array($include_boards) ? $include_boards : array($include_boards);
534
-	}
535
-	elseif ($include_boards != null)
563
+	} elseif ($include_boards != null)
536 564
 	{
537 565
 		$output_method = $include_boards;
538 566
 		$include_boards = array();
539 567
 	}
540 568
 
541 569
 	$icon_sources = array();
542
-	foreach ($context['stable_icons'] as $icon)
543
-		$icon_sources[$icon] = 'images_url';
570
+	foreach ($context['stable_icons'] as $icon) {
571
+			$icon_sources[$icon] = 'images_url';
572
+	}
544 573
 
545 574
 	// Find all the posts in distinct topics.  Newer ones will have higher IDs.
546 575
 	$request = $smcFunc['db_query']('substring', '
@@ -565,13 +594,15 @@  discard block
 block discarded – undo
565 594
 		)
566 595
 	);
567 596
 	$topics = array();
568
-	while ($row = $smcFunc['db_fetch_assoc']($request))
569
-		$topics[$row['id_topic']] = $row;
597
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
598
+			$topics[$row['id_topic']] = $row;
599
+	}
570 600
 	$smcFunc['db_free_result']($request);
571 601
 
572 602
 	// Did we find anything? If not, bail.
573
-	if (empty($topics))
574
-		return array();
603
+	if (empty($topics)) {
604
+			return array();
605
+	}
575 606
 
576 607
 	$recycle_board = !empty($modSettings['recycle_enable']) && !empty($modSettings['recycle_board']) ? (int) $modSettings['recycle_board'] : 0;
577 608
 
@@ -599,19 +630,22 @@  discard block
 block discarded – undo
599 630
 	while ($row = $smcFunc['db_fetch_assoc']($request))
600 631
 	{
601 632
 		$row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']), array('<br>' => '&#10;')));
602
-		if ($smcFunc['strlen']($row['body']) > 128)
603
-			$row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...';
633
+		if ($smcFunc['strlen']($row['body']) > 128) {
634
+					$row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...';
635
+		}
604 636
 
605 637
 		// Censor the subject.
606 638
 		censorText($row['subject']);
607 639
 		censorText($row['body']);
608 640
 
609 641
 		// Recycled icon
610
-		if (!empty($recycle_board) && $topics[$row['id_topic']]['id_board'])
611
-			$row['icon'] = 'recycled';
642
+		if (!empty($recycle_board) && $topics[$row['id_topic']]['id_board']) {
643
+					$row['icon'] = 'recycled';
644
+		}
612 645
 
613
-		if (!empty($modSettings['messageIconChecks_enable']) && !isset($icon_sources[$row['icon']]))
614
-			$icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.png') ? 'images_url' : 'default_images_url';
646
+		if (!empty($modSettings['messageIconChecks_enable']) && !isset($icon_sources[$row['icon']])) {
647
+					$icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.png') ? 'images_url' : 'default_images_url';
648
+		}
615 649
 
616 650
 		// Build the array.
617 651
 		$posts[] = array(
@@ -650,13 +684,14 @@  discard block
 block discarded – undo
650 684
 	call_integration_hook('integrate_ssi_recentTopics', array(&$posts));
651 685
 
652 686
 	// Just return it.
653
-	if ($output_method != 'echo' || empty($posts))
654
-		return $posts;
687
+	if ($output_method != 'echo' || empty($posts)) {
688
+			return $posts;
689
+	}
655 690
 
656 691
 	echo '
657 692
 		<table style="border: none" class="ssi_table">';
658
-	foreach ($posts as $post)
659
-		echo '
693
+	foreach ($posts as $post) {
694
+			echo '
660 695
 			<tr>
661 696
 				<td style="text-align: right; vertical-align: top; white-space: nowrap">
662 697
 					[', $post['board']['link'], ']
@@ -670,6 +705,7 @@  discard block
 block discarded – undo
670 705
 					', $post['time'], '
671 706
 				</td>
672 707
 			</tr>';
708
+	}
673 709
 	echo '
674 710
 		</table>';
675 711
 }
@@ -694,27 +730,30 @@  discard block
 block discarded – undo
694 730
 		)
695 731
 	);
696 732
 	$return = array();
697
-	while ($row = $smcFunc['db_fetch_assoc']($request))
698
-		$return[] = array(
733
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
734
+			$return[] = array(
699 735
 			'id' => $row['id_member'],
700 736
 			'name' => $row['real_name'],
701 737
 			'href' => $scripturl . '?action=profile;u=' . $row['id_member'],
702 738
 			'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>',
703 739
 			'posts' => $row['posts']
704 740
 		);
741
+	}
705 742
 	$smcFunc['db_free_result']($request);
706 743
 
707 744
 	// If mods want to do somthing with this list of members, let them do that now.
708 745
 	call_integration_hook('integrate_ssi_topPoster', array(&$return));
709 746
 
710 747
 	// Just return all the top posters.
711
-	if ($output_method != 'echo')
712
-		return $return;
748
+	if ($output_method != 'echo') {
749
+			return $return;
750
+	}
713 751
 
714 752
 	// Make a quick array to list the links in.
715 753
 	$temp_array = array();
716
-	foreach ($return as $member)
717
-		$temp_array[] = $member['link'];
754
+	foreach ($return as $member) {
755
+			$temp_array[] = $member['link'];
756
+	}
718 757
 
719 758
 	echo implode(', ', $temp_array);
720 759
 }
@@ -746,8 +785,8 @@  discard block
 block discarded – undo
746 785
 		)
747 786
 	);
748 787
 	$boards = array();
749
-	while ($row = $smcFunc['db_fetch_assoc']($request))
750
-		$boards[] = array(
788
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
789
+			$boards[] = array(
751 790
 			'id' => $row['id_board'],
752 791
 			'num_posts' => $row['num_posts'],
753 792
 			'num_topics' => $row['num_topics'],
@@ -756,14 +795,16 @@  discard block
 block discarded – undo
756 795
 			'href' => $scripturl . '?board=' . $row['id_board'] . '.0',
757 796
 			'link' => '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'
758 797
 		);
798
+	}
759 799
 	$smcFunc['db_free_result']($request);
760 800
 
761 801
 	// If mods want to do somthing with this list of boards, let them do that now.
762 802
 	call_integration_hook('integrate_ssi_topBoards', array(&$boards));
763 803
 
764 804
 	// If we shouldn't output or have nothing to output, just jump out.
765
-	if ($output_method != 'echo' || empty($boards))
766
-		return $boards;
805
+	if ($output_method != 'echo' || empty($boards)) {
806
+			return $boards;
807
+	}
767 808
 
768 809
 	echo '
769 810
 		<table class="ssi_table">
@@ -772,13 +813,14 @@  discard block
 block discarded – undo
772 813
 				<th style="text-align: left">', $txt['board_topics'], '</th>
773 814
 				<th style="text-align: left">', $txt['posts'], '</th>
774 815
 			</tr>';
775
-	foreach ($boards as $sBoard)
776
-		echo '
816
+	foreach ($boards as $sBoard) {
817
+			echo '
777 818
 			<tr>
778 819
 				<td>', $sBoard['link'], $sBoard['new'] ? ' <a href="' . $sBoard['href'] . '"><span class="new_posts">' . $txt['new'] . '</span></a>' : '', '</td>
779 820
 				<td style="text-align: right">', comma_format($sBoard['num_topics']), '</td>
780 821
 				<td style="text-align: right">', comma_format($sBoard['num_posts']), '</td>
781 822
 			</tr>';
823
+	}
782 824
 	echo '
783 825
 		</table>';
784 826
 }
@@ -811,12 +853,13 @@  discard block
 block discarded – undo
811 853
 			)
812 854
 		);
813 855
 		$topic_ids = array();
814
-		while ($row = $smcFunc['db_fetch_assoc']($request))
815
-			$topic_ids[] = $row['id_topic'];
856
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
857
+					$topic_ids[] = $row['id_topic'];
858
+		}
816 859
 		$smcFunc['db_free_result']($request);
860
+	} else {
861
+			$topic_ids = array();
817 862
 	}
818
-	else
819
-		$topic_ids = array();
820 863
 
821 864
 	$request = $smcFunc['db_query']('', '
822 865
 		SELECT m.subject, m.id_topic, t.num_views, t.num_replies
@@ -855,8 +898,9 @@  discard block
 block discarded – undo
855 898
 	// If mods want to do somthing with this list of topics, let them do that now.
856 899
 	call_integration_hook('integrate_ssi_topTopics', array(&$topics, $type));
857 900
 
858
-	if ($output_method != 'echo' || empty($topics))
859
-		return $topics;
901
+	if ($output_method != 'echo' || empty($topics)) {
902
+			return $topics;
903
+	}
860 904
 
861 905
 	echo '
862 906
 		<table class="ssi_table">
@@ -865,8 +909,8 @@  discard block
 block discarded – undo
865 909
 				<th style="text-align: left">', $txt['views'], '</th>
866 910
 				<th style="text-align: left">', $txt['replies'], '</th>
867 911
 			</tr>';
868
-	foreach ($topics as $sTopic)
869
-		echo '
912
+	foreach ($topics as $sTopic) {
913
+			echo '
870 914
 			<tr>
871 915
 				<td style="text-align: left">
872 916
 					', $sTopic['link'], '
@@ -874,6 +918,7 @@  discard block
 block discarded – undo
874 918
 				<td style="text-align: right">', comma_format($sTopic['num_views']), '</td>
875 919
 				<td style="text-align: right">', comma_format($sTopic['num_replies']), '</td>
876 920
 			</tr>';
921
+	}
877 922
 	echo '
878 923
 		</table>';
879 924
 }
@@ -909,12 +954,13 @@  discard block
 block discarded – undo
909 954
 {
910 955
 	global $txt, $context;
911 956
 
912
-	if ($output_method == 'echo')
913
-		echo '
957
+	if ($output_method == 'echo') {
958
+			echo '
914 959
 	', sprintf($txt['welcome_newest_member'], $context['common_stats']['latest_member']['link']), '<br>';
915
-	else
916
-		return $context['common_stats']['latest_member'];
917
-}
960
+	} else {
961
+			return $context['common_stats']['latest_member'];
962
+	}
963
+	}
918 964
 
919 965
 /**
920 966
  * Fetches a random member.
@@ -963,8 +1009,9 @@  discard block
 block discarded – undo
963 1009
 	}
964 1010
 
965 1011
 	// Just to be sure put the random generator back to something... random.
966
-	if ($random_type != '')
967
-		mt_srand(time());
1012
+	if ($random_type != '') {
1013
+			mt_srand(time());
1014
+	}
968 1015
 
969 1016
 	return $result;
970 1017
 }
@@ -977,8 +1024,9 @@  discard block
 block discarded – undo
977 1024
  */
978 1025
 function ssi_fetchMember($member_ids = array(), $output_method = 'echo')
979 1026
 {
980
-	if (empty($member_ids))
981
-		return;
1027
+	if (empty($member_ids)) {
1028
+			return;
1029
+	}
982 1030
 
983 1031
 	// Can have more than one member if you really want...
984 1032
 	$member_ids = is_array($member_ids) ? $member_ids : array($member_ids);
@@ -1003,8 +1051,9 @@  discard block
 block discarded – undo
1003 1051
  */
1004 1052
 function ssi_fetchGroupMembers($group_id = null, $output_method = 'echo')
1005 1053
 {
1006
-	if ($group_id === null)
1007
-		return;
1054
+	if ($group_id === null) {
1055
+			return;
1056
+	}
1008 1057
 
1009 1058
 	$query_where = '
1010 1059
 		id_group = {int:id_group}
@@ -1031,8 +1080,9 @@  discard block
 block discarded – undo
1031 1080
 {
1032 1081
 	global $smcFunc, $memberContext;
1033 1082
 
1034
-	if ($query_where === null)
1035
-		return;
1083
+	if ($query_where === null) {
1084
+			return;
1085
+	}
1036 1086
 
1037 1087
 	// Fetch the members in question.
1038 1088
 	$request = $smcFunc['db_query']('', '
@@ -1045,12 +1095,14 @@  discard block
 block discarded – undo
1045 1095
 		))
1046 1096
 	);
1047 1097
 	$members = array();
1048
-	while ($row = $smcFunc['db_fetch_assoc']($request))
1049
-		$members[] = $row['id_member'];
1098
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
1099
+			$members[] = $row['id_member'];
1100
+	}
1050 1101
 	$smcFunc['db_free_result']($request);
1051 1102
 
1052
-	if (empty($members))
1053
-		return array();
1103
+	if (empty($members)) {
1104
+			return array();
1105
+	}
1054 1106
 
1055 1107
 	// If mods want to do somthing with this list of members, let them do that now.
1056 1108
 	call_integration_hook('integrate_ssi_queryMembers', array(&$members));
@@ -1059,23 +1111,25 @@  discard block
 block discarded – undo
1059 1111
 	loadMemberData($members);
1060 1112
 
1061 1113
 	// Draw the table!
1062
-	if ($output_method == 'echo')
1063
-		echo '
1114
+	if ($output_method == 'echo') {
1115
+			echo '
1064 1116
 		<table style="border: none" class="ssi_table">';
1117
+	}
1065 1118
 
1066 1119
 	$query_members = array();
1067 1120
 	foreach ($members as $member)
1068 1121
 	{
1069 1122
 		// Load their context data.
1070
-		if (!loadMemberContext($member))
1071
-			continue;
1123
+		if (!loadMemberContext($member)) {
1124
+					continue;
1125
+		}
1072 1126
 
1073 1127
 		// Store this member's information.
1074 1128
 		$query_members[$member] = $memberContext[$member];
1075 1129
 
1076 1130
 		// Only do something if we're echo'ing.
1077
-		if ($output_method == 'echo')
1078
-			echo '
1131
+		if ($output_method == 'echo') {
1132
+					echo '
1079 1133
 			<tr>
1080 1134
 				<td style="text-align: right; vertical-align: top; white-space: nowrap">
1081 1135
 					', $query_members[$member]['link'], '
@@ -1083,12 +1137,14 @@  discard block
 block discarded – undo
1083 1137
 					<br>', $query_members[$member]['avatar']['image'], '
1084 1138
 				</td>
1085 1139
 			</tr>';
1140
+		}
1086 1141
 	}
1087 1142
 
1088 1143
 	// End the table if appropriate.
1089
-	if ($output_method == 'echo')
1090
-		echo '
1144
+	if ($output_method == 'echo') {
1145
+			echo '
1091 1146
 		</table>';
1147
+	}
1092 1148
 
1093 1149
 	// Send back the data.
1094 1150
 	return $query_members;
@@ -1103,8 +1159,9 @@  discard block
 block discarded – undo
1103 1159
 {
1104 1160
 	global $txt, $scripturl, $modSettings, $smcFunc;
1105 1161
 
1106
-	if (!allowedTo('view_stats'))
1107
-		return;
1162
+	if (!allowedTo('view_stats')) {
1163
+			return;
1164
+	}
1108 1165
 
1109 1166
 	$totals = array(
1110 1167
 		'members' => $modSettings['totalMembers'],
@@ -1133,8 +1190,9 @@  discard block
 block discarded – undo
1133 1190
 	// If mods want to do somthing with the board stats, let them do that now.
1134 1191
 	call_integration_hook('integrate_ssi_boardStats', array(&$totals));
1135 1192
 
1136
-	if ($output_method != 'echo')
1137
-		return $totals;
1193
+	if ($output_method != 'echo') {
1194
+			return $totals;
1195
+	}
1138 1196
 
1139 1197
 	echo '
1140 1198
 		', $txt['total_members'], ': <a href="', $scripturl . '?action=mlist">', comma_format($totals['members']), '</a><br>
@@ -1163,8 +1221,8 @@  discard block
 block discarded – undo
1163 1221
 	call_integration_hook('integrate_ssi_whosOnline', array(&$return));
1164 1222
 
1165 1223
 	// Add some redundancy for backwards compatibility reasons.
1166
-	if ($output_method != 'echo')
1167
-		return $return + array(
1224
+	if ($output_method != 'echo') {
1225
+			return $return + array(
1168 1226
 			'users' => $return['users_online'],
1169 1227
 			'guests' => $return['num_guests'],
1170 1228
 			'hidden' => $return['num_users_hidden'],
@@ -1172,29 +1230,35 @@  discard block
 block discarded – undo
1172 1230
 			'num_users' => $return['num_users_online'],
1173 1231
 			'total_users' => $return['num_users_online'] + $return['num_guests'],
1174 1232
 		);
1233
+	}
1175 1234
 
1176 1235
 	echo '
1177 1236
 		', comma_format($return['num_guests']), ' ', $return['num_guests'] == 1 ? $txt['guest'] : $txt['guests'], ', ', comma_format($return['num_users_online']), ' ', $return['num_users_online'] == 1 ? $txt['user'] : $txt['users'];
1178 1237
 
1179 1238
 	$bracketList = array();
1180
-	if (!empty($user_info['buddies']))
1181
-		$bracketList[] = comma_format($return['num_buddies']) . ' ' . ($return['num_buddies'] == 1 ? $txt['buddy'] : $txt['buddies']);
1182
-	if (!empty($return['num_spiders']))
1183
-		$bracketList[] = comma_format($return['num_spiders']) . ' ' . ($return['num_spiders'] == 1 ? $txt['spider'] : $txt['spiders']);
1184
-	if (!empty($return['num_users_hidden']))
1185
-		$bracketList[] = comma_format($return['num_users_hidden']) . ' ' . $txt['hidden'];
1239
+	if (!empty($user_info['buddies'])) {
1240
+			$bracketList[] = comma_format($return['num_buddies']) . ' ' . ($return['num_buddies'] == 1 ? $txt['buddy'] : $txt['buddies']);
1241
+	}
1242
+	if (!empty($return['num_spiders'])) {
1243
+			$bracketList[] = comma_format($return['num_spiders']) . ' ' . ($return['num_spiders'] == 1 ? $txt['spider'] : $txt['spiders']);
1244
+	}
1245
+	if (!empty($return['num_users_hidden'])) {
1246
+			$bracketList[] = comma_format($return['num_users_hidden']) . ' ' . $txt['hidden'];
1247
+	}
1186 1248
 
1187
-	if (!empty($bracketList))
1188
-		echo ' (' . implode(', ', $bracketList) . ')';
1249
+	if (!empty($bracketList)) {
1250
+			echo ' (' . implode(', ', $bracketList) . ')';
1251
+	}
1189 1252
 
1190 1253
 	echo '<br>
1191 1254
 			', implode(', ', $return['list_users_online']);
1192 1255
 
1193 1256
 	// Showing membergroups?
1194
-	if (!empty($settings['show_group_key']) && !empty($return['membergroups']))
1195
-		echo '<br>
1257
+	if (!empty($settings['show_group_key']) && !empty($return['membergroups'])) {
1258
+			echo '<br>
1196 1259
 			[' . implode(']&nbsp;&nbsp;[', $return['membergroups']) . ']';
1197
-}
1260
+	}
1261
+	}
1198 1262
 
1199 1263
 /**
1200 1264
  * Just like whosOnline except it also logs the online presence.
@@ -1205,11 +1269,12 @@  discard block
 block discarded – undo
1205 1269
 {
1206 1270
 	writeLog();
1207 1271
 
1208
-	if ($output_method != 'echo')
1209
-		return ssi_whosOnline($output_method);
1210
-	else
1211
-		ssi_whosOnline($output_method);
1212
-}
1272
+	if ($output_method != 'echo') {
1273
+			return ssi_whosOnline($output_method);
1274
+	} else {
1275
+			ssi_whosOnline($output_method);
1276
+	}
1277
+	}
1213 1278
 
1214 1279
 // Shows a login box.
1215 1280
 /**
@@ -1222,11 +1287,13 @@  discard block
 block discarded – undo
1222 1287
 {
1223 1288
 	global $scripturl, $txt, $user_info, $context;
1224 1289
 
1225
-	if ($redirect_to != '')
1226
-		$_SESSION['login_url'] = $redirect_to;
1290
+	if ($redirect_to != '') {
1291
+			$_SESSION['login_url'] = $redirect_to;
1292
+	}
1227 1293
 
1228
-	if ($output_method != 'echo' || !$user_info['is_guest'])
1229
-		return $user_info['is_guest'];
1294
+	if ($output_method != 'echo' || !$user_info['is_guest']) {
1295
+			return $user_info['is_guest'];
1296
+	}
1230 1297
 
1231 1298
 	// Create a login token
1232 1299
 	createToken('login');
@@ -1278,8 +1345,9 @@  discard block
 block discarded – undo
1278 1345
 
1279 1346
 	$boardsAllowed = array_intersect(boardsAllowedTo('poll_view'), boardsAllowedTo('poll_vote'));
1280 1347
 
1281
-	if (empty($boardsAllowed))
1282
-		return array();
1348
+	if (empty($boardsAllowed)) {
1349
+			return array();
1350
+	}
1283 1351
 
1284 1352
 	$request = $smcFunc['db_query']('', '
1285 1353
 		SELECT p.id_poll, p.question, t.id_topic, p.max_votes, p.guest_vote, p.hide_results, p.expire_time
@@ -1312,12 +1380,14 @@  discard block
 block discarded – undo
1312 1380
 	$smcFunc['db_free_result']($request);
1313 1381
 
1314 1382
 	// This user has voted on all the polls.
1315
-	if (empty($row) || !is_array($row))
1316
-		return array();
1383
+	if (empty($row) || !is_array($row)) {
1384
+			return array();
1385
+	}
1317 1386
 
1318 1387
 	// If this is a guest who's voted we'll through ourselves to show poll to show the results.
1319
-	if ($user_info['is_guest'] && (!$row['guest_vote'] || (isset($_COOKIE['guest_poll_vote']) && in_array($row['id_poll'], explode(',', $_COOKIE['guest_poll_vote'])))))
1320
-		return ssi_showPoll($row['id_topic'], $output_method);
1388
+	if ($user_info['is_guest'] && (!$row['guest_vote'] || (isset($_COOKIE['guest_poll_vote']) && in_array($row['id_poll'], explode(',', $_COOKIE['guest_poll_vote']))))) {
1389
+			return ssi_showPoll($row['id_topic'], $output_method);
1390
+	}
1321 1391
 
1322 1392
 	$request = $smcFunc['db_query']('', '
1323 1393
 		SELECT COUNT(DISTINCT id_member)
@@ -1381,8 +1451,9 @@  discard block
 block discarded – undo
1381 1451
 	// If mods want to do somthing with this list of polls, let them do that now.
1382 1452
 	call_integration_hook('integrate_ssi_recentPoll', array(&$return, $topPollInstead));
1383 1453
 
1384
-	if ($output_method != 'echo')
1385
-		return $return;
1454
+	if ($output_method != 'echo') {
1455
+			return $return;
1456
+	}
1386 1457
 
1387 1458
 	if ($allow_view_results)
1388 1459
 	{
@@ -1391,19 +1462,20 @@  discard block
 block discarded – undo
1391 1462
 			<strong>', $return['question'], '</strong><br>
1392 1463
 			', !empty($return['allowed_warning']) ? $return['allowed_warning'] . '<br>' : '';
1393 1464
 
1394
-		foreach ($return['options'] as $option)
1395
-			echo '
1465
+		foreach ($return['options'] as $option) {
1466
+					echo '
1396 1467
 			<label for="', $option['id'], '">', $option['vote_button'], ' ', $option['option'], '</label><br>';
1468
+		}
1397 1469
 
1398 1470
 		echo '
1399 1471
 			<input type="submit" value="', $txt['poll_vote'], '" class="button">
1400 1472
 			<input type="hidden" name="poll" value="', $return['id'], '">
1401 1473
 			<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
1402 1474
 		</form>';
1475
+	} else {
1476
+			echo $txt['poll_cannot_see'];
1477
+	}
1403 1478
 	}
1404
-	else
1405
-		echo $txt['poll_cannot_see'];
1406
-}
1407 1479
 
1408 1480
 /**
1409 1481
  * Shows the poll from the specified topic
@@ -1417,13 +1489,15 @@  discard block
 block discarded – undo
1417 1489
 
1418 1490
 	$boardsAllowed = boardsAllowedTo('poll_view');
1419 1491
 
1420
-	if (empty($boardsAllowed))
1421
-		return array();
1492
+	if (empty($boardsAllowed)) {
1493
+			return array();
1494
+	}
1422 1495
 
1423
-	if ($topic === null && isset($_REQUEST['ssi_topic']))
1424
-		$topic = (int) $_REQUEST['ssi_topic'];
1425
-	else
1426
-		$topic = (int) $topic;
1496
+	if ($topic === null && isset($_REQUEST['ssi_topic'])) {
1497
+			$topic = (int) $_REQUEST['ssi_topic'];
1498
+	} else {
1499
+			$topic = (int) $topic;
1500
+	}
1427 1501
 
1428 1502
 	$request = $smcFunc['db_query']('', '
1429 1503
 		SELECT
@@ -1444,17 +1518,18 @@  discard block
 block discarded – undo
1444 1518
 	);
1445 1519
 
1446 1520
 	// Either this topic has no poll, or the user cannot view it.
1447
-	if ($smcFunc['db_num_rows']($request) == 0)
1448
-		return array();
1521
+	if ($smcFunc['db_num_rows']($request) == 0) {
1522
+			return array();
1523
+	}
1449 1524
 
1450 1525
 	$row = $smcFunc['db_fetch_assoc']($request);
1451 1526
 	$smcFunc['db_free_result']($request);
1452 1527
 
1453 1528
 	// Check if they can vote.
1454 1529
 	$already_voted = false;
1455
-	if (!empty($row['expire_time']) && $row['expire_time'] < time())
1456
-		$allow_vote = false;
1457
-	elseif ($user_info['is_guest'])
1530
+	if (!empty($row['expire_time']) && $row['expire_time'] < time()) {
1531
+			$allow_vote = false;
1532
+	} elseif ($user_info['is_guest'])
1458 1533
 	{
1459 1534
 		// There's a difference between "allowed to vote" and "already voted"...
1460 1535
 		$allow_vote = $row['guest_vote'];
@@ -1464,10 +1539,9 @@  discard block
 block discarded – undo
1464 1539
 		{
1465 1540
 			$already_voted = true;
1466 1541
 		}
1467
-	}
1468
-	elseif (!empty($row['voting_locked']) || !allowedTo('poll_vote', $row['id_board']))
1469
-		$allow_vote = false;
1470
-	else
1542
+	} elseif (!empty($row['voting_locked']) || !allowedTo('poll_vote', $row['id_board'])) {
1543
+			$allow_vote = false;
1544
+	} else
1471 1545
 	{
1472 1546
 		$request = $smcFunc['db_query']('', '
1473 1547
 			SELECT id_member
@@ -1549,8 +1623,9 @@  discard block
 block discarded – undo
1549 1623
 	// If mods want to do somthing with this poll, let them do that now.
1550 1624
 	call_integration_hook('integrate_ssi_showPoll', array(&$return));
1551 1625
 
1552
-	if ($output_method != 'echo')
1553
-		return $return;
1626
+	if ($output_method != 'echo') {
1627
+			return $return;
1628
+	}
1554 1629
 
1555 1630
 	if ($return['allow_vote'])
1556 1631
 	{
@@ -1559,17 +1634,17 @@  discard block
 block discarded – undo
1559 1634
 				<strong>', $return['question'], '</strong><br>
1560 1635
 				', !empty($return['allowed_warning']) ? $return['allowed_warning'] . '<br>' : '';
1561 1636
 
1562
-		foreach ($return['options'] as $option)
1563
-			echo '
1637
+		foreach ($return['options'] as $option) {
1638
+					echo '
1564 1639
 				<label for="', $option['id'], '">', $option['vote_button'], ' ', $option['option'], '</label><br>';
1640
+		}
1565 1641
 
1566 1642
 		echo '
1567 1643
 				<input type="submit" value="', $txt['poll_vote'], '" class="button">
1568 1644
 				<input type="hidden" name="poll" value="', $return['id'], '">
1569 1645
 				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
1570 1646
 			</form>';
1571
-	}
1572
-	else
1647
+	} else
1573 1648
 	{
1574 1649
 		echo '
1575 1650
 			<div class="ssi_poll">
@@ -1649,27 +1724,32 @@  discard block
 block discarded – undo
1649 1724
 			'is_approved' => 1,
1650 1725
 		)
1651 1726
 	);
1652
-	if ($smcFunc['db_num_rows']($request) == 0)
1653
-		die;
1727
+	if ($smcFunc['db_num_rows']($request) == 0) {
1728
+			die;
1729
+	}
1654 1730
 	$row = $smcFunc['db_fetch_assoc']($request);
1655 1731
 	$smcFunc['db_free_result']($request);
1656 1732
 
1657
-	if (!empty($row['voting_locked']) || ($row['selected'] != -1 && !$user_info['is_guest']) || (!empty($row['expire_time']) && time() > $row['expire_time']))
1658
-		redirectexit('topic=' . $row['id_topic'] . '.0');
1733
+	if (!empty($row['voting_locked']) || ($row['selected'] != -1 && !$user_info['is_guest']) || (!empty($row['expire_time']) && time() > $row['expire_time'])) {
1734
+			redirectexit('topic=' . $row['id_topic'] . '.0');
1735
+	}
1659 1736
 
1660 1737
 	// Too many options checked?
1661
-	if (count($_REQUEST['options']) > $row['max_votes'])
1662
-		redirectexit('topic=' . $row['id_topic'] . '.0');
1738
+	if (count($_REQUEST['options']) > $row['max_votes']) {
1739
+			redirectexit('topic=' . $row['id_topic'] . '.0');
1740
+	}
1663 1741
 
1664 1742
 	// It's a guest who has already voted?
1665 1743
 	if ($user_info['is_guest'])
1666 1744
 	{
1667 1745
 		// Guest voting disabled?
1668
-		if (!$row['guest_vote'])
1669
-			redirectexit('topic=' . $row['id_topic'] . '.0');
1746
+		if (!$row['guest_vote']) {
1747
+					redirectexit('topic=' . $row['id_topic'] . '.0');
1748
+		}
1670 1749
 		// Already voted?
1671
-		elseif (isset($_COOKIE['guest_poll_vote']) && in_array($row['id_poll'], explode(',', $_COOKIE['guest_poll_vote'])))
1672
-			redirectexit('topic=' . $row['id_topic'] . '.0');
1750
+		elseif (isset($_COOKIE['guest_poll_vote']) && in_array($row['id_poll'], explode(',', $_COOKIE['guest_poll_vote']))) {
1751
+					redirectexit('topic=' . $row['id_topic'] . '.0');
1752
+		}
1673 1753
 	}
1674 1754
 
1675 1755
 	$sOptions = array();
@@ -1723,11 +1803,13 @@  discard block
 block discarded – undo
1723 1803
 {
1724 1804
 	global $scripturl, $txt, $context;
1725 1805
 
1726
-	if (!allowedTo('search_posts'))
1727
-		return;
1806
+	if (!allowedTo('search_posts')) {
1807
+			return;
1808
+	}
1728 1809
 
1729
-	if ($output_method != 'echo')
1730
-		return $scripturl . '?action=search';
1810
+	if ($output_method != 'echo') {
1811
+			return $scripturl . '?action=search';
1812
+	}
1731 1813
 
1732 1814
 	echo '
1733 1815
 		<form action="', $scripturl, '?action=search2" method="post" accept-charset="', $context['character_set'], '">
@@ -1749,8 +1831,9 @@  discard block
 block discarded – undo
1749 1831
 	// If mods want to do somthing with the news, let them do that now. Don't need to pass the news line itself, since it is already in $context.
1750 1832
 	call_integration_hook('integrate_ssi_news');
1751 1833
 
1752
-	if ($output_method != 'echo')
1753
-		return $context['random_news_line'];
1834
+	if ($output_method != 'echo') {
1835
+			return $context['random_news_line'];
1836
+	}
1754 1837
 
1755 1838
 	echo $context['random_news_line'];
1756 1839
 }
@@ -1764,8 +1847,9 @@  discard block
 block discarded – undo
1764 1847
 {
1765 1848
 	global $scripturl, $modSettings, $user_info;
1766 1849
 
1767
-	if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view') || !allowedTo('profile_view'))
1768
-		return;
1850
+	if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view') || !allowedTo('profile_view')) {
1851
+			return;
1852
+	}
1769 1853
 
1770 1854
 	$eventOptions = array(
1771 1855
 		'include_birthdays' => true,
@@ -1776,13 +1860,15 @@  discard block
 block discarded – undo
1776 1860
 	// The ssi_todaysCalendar variants all use the same hook and just pass on $eventOptions so the hooked code can distinguish different cases if necessary
1777 1861
 	call_integration_hook('integrate_ssi_calendar', array(&$return, $eventOptions));
1778 1862
 
1779
-	if ($output_method != 'echo')
1780
-		return $return['calendar_birthdays'];
1863
+	if ($output_method != 'echo') {
1864
+			return $return['calendar_birthdays'];
1865
+	}
1781 1866
 
1782
-	foreach ($return['calendar_birthdays'] as $member)
1783
-		echo '
1867
+	foreach ($return['calendar_birthdays'] as $member) {
1868
+			echo '
1784 1869
 			<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'] ? ', ' : '');
1785
-}
1870
+	}
1871
+	}
1786 1872
 
1787 1873
 /**
1788 1874
  * Shows today's holidays.
@@ -1793,8 +1879,9 @@  discard block
 block discarded – undo
1793 1879
 {
1794 1880
 	global $modSettings, $user_info;
1795 1881
 
1796
-	if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view'))
1797
-		return;
1882
+	if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) {
1883
+			return;
1884
+	}
1798 1885
 
1799 1886
 	$eventOptions = array(
1800 1887
 		'include_holidays' => true,
@@ -1805,8 +1892,9 @@  discard block
 block discarded – undo
1805 1892
 	// The ssi_todaysCalendar variants all use the same hook and just pass on $eventOptions so the hooked code can distinguish different cases if necessary
1806 1893
 	call_integration_hook('integrate_ssi_calendar', array(&$return, $eventOptions));
1807 1894
 
1808
-	if ($output_method != 'echo')
1809
-		return $return['calendar_holidays'];
1895
+	if ($output_method != 'echo') {
1896
+			return $return['calendar_holidays'];
1897
+	}
1810 1898
 
1811 1899
 	echo '
1812 1900
 		', implode(', ', $return['calendar_holidays']);
@@ -1820,8 +1908,9 @@  discard block
 block discarded – undo
1820 1908
 {
1821 1909
 	global $modSettings, $user_info;
1822 1910
 
1823
-	if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view'))
1824
-		return;
1911
+	if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) {
1912
+			return;
1913
+	}
1825 1914
 
1826 1915
 	$eventOptions = array(
1827 1916
 		'include_events' => true,
@@ -1832,14 +1921,16 @@  discard block
 block discarded – undo
1832 1921
 	// The ssi_todaysCalendar variants all use the same hook and just pass on $eventOptions so the hooked code can distinguish different cases if necessary
1833 1922
 	call_integration_hook('integrate_ssi_calendar', array(&$return, $eventOptions));
1834 1923
 
1835
-	if ($output_method != 'echo')
1836
-		return $return['calendar_events'];
1924
+	if ($output_method != 'echo') {
1925
+			return $return['calendar_events'];
1926
+	}
1837 1927
 
1838 1928
 	foreach ($return['calendar_events'] as $event)
1839 1929
 	{
1840
-		if ($event['can_edit'])
1841
-			echo '
1930
+		if ($event['can_edit']) {
1931
+					echo '
1842 1932
 	<a href="' . $event['modify_href'] . '" style="color: #ff0000;">*</a> ';
1933
+		}
1843 1934
 		echo '
1844 1935
 	' . $event['link'] . (!$event['is_last'] ? ', ' : '');
1845 1936
 	}
@@ -1854,8 +1945,9 @@  discard block
 block discarded – undo
1854 1945
 {
1855 1946
 	global $modSettings, $txt, $scripturl, $user_info;
1856 1947
 
1857
-	if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view'))
1858
-		return;
1948
+	if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) {
1949
+			return;
1950
+	}
1859 1951
 
1860 1952
 	$eventOptions = array(
1861 1953
 		'include_birthdays' => allowedTo('profile_view'),
@@ -1868,19 +1960,22 @@  discard block
 block discarded – undo
1868 1960
 	// The ssi_todaysCalendar variants all use the same hook and just pass on $eventOptions so the hooked code can distinguish different cases if necessary
1869 1961
 	call_integration_hook('integrate_ssi_calendar', array(&$return, $eventOptions));
1870 1962
 
1871
-	if ($output_method != 'echo')
1872
-		return $return;
1963
+	if ($output_method != 'echo') {
1964
+			return $return;
1965
+	}
1873 1966
 
1874
-	if (!empty($return['calendar_holidays']))
1875
-		echo '
1967
+	if (!empty($return['calendar_holidays'])) {
1968
+			echo '
1876 1969
 			<span class="holiday">' . $txt['calendar_prompt'] . ' ' . implode(', ', $return['calendar_holidays']) . '<br></span>';
1970
+	}
1877 1971
 	if (!empty($return['calendar_birthdays']))
1878 1972
 	{
1879 1973
 		echo '
1880 1974
 			<span class="birthday">' . $txt['birthdays_upcoming'] . '</span> ';
1881
-		foreach ($return['calendar_birthdays'] as $member)
1882
-			echo '
1975
+		foreach ($return['calendar_birthdays'] as $member) {
1976
+					echo '
1883 1977
 			<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'] ? ', ' : '';
1978
+		}
1884 1979
 		echo '
1885 1980
 			<br>';
1886 1981
 	}
@@ -1890,9 +1985,10 @@  discard block
 block discarded – undo
1890 1985
 			<span class="event">' . $txt['events_upcoming'] . '</span> ';
1891 1986
 		foreach ($return['calendar_events'] as $event)
1892 1987
 		{
1893
-			if ($event['can_edit'])
1894
-				echo '
1988
+			if ($event['can_edit']) {
1989
+							echo '
1895 1990
 			<a href="' . $event['modify_href'] . '" style="color: #ff0000;">*</a> ';
1991
+			}
1896 1992
 			echo '
1897 1993
 			' . $event['link'] . (!$event['is_last'] ? ', ' : '');
1898 1994
 		}
@@ -1916,25 +2012,29 @@  discard block
 block discarded – undo
1916 2012
 	loadLanguage('Stats');
1917 2013
 
1918 2014
 	// Must be integers....
1919
-	if ($limit === null)
1920
-		$limit = isset($_GET['limit']) ? (int) $_GET['limit'] : 5;
1921
-	else
1922
-		$limit = (int) $limit;
1923
-
1924
-	if ($start === null)
1925
-		$start = isset($_GET['start']) ? (int) $_GET['start'] : 0;
1926
-	else
1927
-		$start = (int) $start;
1928
-
1929
-	if ($board !== null)
1930
-		$board = (int) $board;
1931
-	elseif (isset($_GET['board']))
1932
-		$board = (int) $_GET['board'];
1933
-
1934
-	if ($length === null)
1935
-		$length = isset($_GET['length']) ? (int) $_GET['length'] : 0;
1936
-	else
1937
-		$length = (int) $length;
2015
+	if ($limit === null) {
2016
+			$limit = isset($_GET['limit']) ? (int) $_GET['limit'] : 5;
2017
+	} else {
2018
+			$limit = (int) $limit;
2019
+	}
2020
+
2021
+	if ($start === null) {
2022
+			$start = isset($_GET['start']) ? (int) $_GET['start'] : 0;
2023
+	} else {
2024
+			$start = (int) $start;
2025
+	}
2026
+
2027
+	if ($board !== null) {
2028
+			$board = (int) $board;
2029
+	} elseif (isset($_GET['board'])) {
2030
+			$board = (int) $_GET['board'];
2031
+	}
2032
+
2033
+	if ($length === null) {
2034
+			$length = isset($_GET['length']) ? (int) $_GET['length'] : 0;
2035
+	} else {
2036
+			$length = (int) $length;
2037
+	}
1938 2038
 
1939 2039
 	$limit = max(0, $limit);
1940 2040
 	$start = max(0, $start);
@@ -1952,17 +2052,19 @@  discard block
 block discarded – undo
1952 2052
 	);
1953 2053
 	if ($smcFunc['db_num_rows']($request) == 0)
1954 2054
 	{
1955
-		if ($output_method == 'echo')
1956
-			die($txt['ssi_no_guests']);
1957
-		else
1958
-			return array();
2055
+		if ($output_method == 'echo') {
2056
+					die($txt['ssi_no_guests']);
2057
+		} else {
2058
+					return array();
2059
+		}
1959 2060
 	}
1960 2061
 	list ($board) = $smcFunc['db_fetch_row']($request);
1961 2062
 	$smcFunc['db_free_result']($request);
1962 2063
 
1963 2064
 	$icon_sources = array();
1964
-	foreach ($context['stable_icons'] as $icon)
1965
-		$icon_sources[$icon] = 'images_url';
2065
+	foreach ($context['stable_icons'] as $icon) {
2066
+			$icon_sources[$icon] = 'images_url';
2067
+	}
1966 2068
 
1967 2069
 	if (!empty($modSettings['enable_likes']))
1968 2070
 	{
@@ -1985,12 +2087,14 @@  discard block
 block discarded – undo
1985 2087
 		)
1986 2088
 	);
1987 2089
 	$posts = array();
1988
-	while ($row = $smcFunc['db_fetch_assoc']($request))
1989
-		$posts[] = $row['id_first_msg'];
2090
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
2091
+			$posts[] = $row['id_first_msg'];
2092
+	}
1990 2093
 	$smcFunc['db_free_result']($request);
1991 2094
 
1992
-	if (empty($posts))
1993
-		return array();
2095
+	if (empty($posts)) {
2096
+			return array();
2097
+	}
1994 2098
 
1995 2099
 	// Find the posts.
1996 2100
 	$request = $smcFunc['db_query']('', '
@@ -2020,24 +2124,28 @@  discard block
 block discarded – undo
2020 2124
 			$last_space = strrpos($row['body'], ' ');
2021 2125
 			$last_open = strrpos($row['body'], '<');
2022 2126
 			$last_close = strrpos($row['body'], '>');
2023
-			if (empty($last_space) || ($last_space == $last_open + 3 && (empty($last_close) || (!empty($last_close) && $last_close < $last_open))) || $last_space < $last_open || $last_open == $length - 6)
2024
-				$cutoff = $last_open;
2025
-			elseif (empty($last_close) || $last_close < $last_open)
2026
-				$cutoff = $last_space;
2127
+			if (empty($last_space) || ($last_space == $last_open + 3 && (empty($last_close) || (!empty($last_close) && $last_close < $last_open))) || $last_space < $last_open || $last_open == $length - 6) {
2128
+							$cutoff = $last_open;
2129
+			} elseif (empty($last_close) || $last_close < $last_open) {
2130
+							$cutoff = $last_space;
2131
+			}
2027 2132
 
2028
-			if ($cutoff !== false)
2029
-				$row['body'] = $smcFunc['substr']($row['body'], 0, $cutoff);
2133
+			if ($cutoff !== false) {
2134
+							$row['body'] = $smcFunc['substr']($row['body'], 0, $cutoff);
2135
+			}
2030 2136
 			$row['body'] .= '...';
2031 2137
 		}
2032 2138
 
2033 2139
 		$row['body'] = parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']);
2034 2140
 
2035
-		if (!empty($recycle_board) && $row['id_board'] == $recycle_board)
2036
-			$row['icon'] = 'recycled';
2141
+		if (!empty($recycle_board) && $row['id_board'] == $recycle_board) {
2142
+					$row['icon'] = 'recycled';
2143
+		}
2037 2144
 
2038 2145
 		// Check that this message icon is there...
2039
-		if (!empty($modSettings['messageIconChecks_enable']) && !isset($icon_sources[$row['icon']]))
2040
-			$icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.png') ? 'images_url' : 'default_images_url';
2146
+		if (!empty($modSettings['messageIconChecks_enable']) && !isset($icon_sources[$row['icon']])) {
2147
+					$icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.png') ? 'images_url' : 'default_images_url';
2148
+		}
2041 2149
 
2042 2150
 		censorText($row['subject']);
2043 2151
 		censorText($row['body']);
@@ -2074,16 +2182,18 @@  discard block
 block discarded – undo
2074 2182
 	}
2075 2183
 	$smcFunc['db_free_result']($request);
2076 2184
 
2077
-	if (empty($return))
2078
-		return $return;
2185
+	if (empty($return)) {
2186
+			return $return;
2187
+	}
2079 2188
 
2080 2189
 	$return[count($return) - 1]['is_last'] = true;
2081 2190
 
2082 2191
 	// If mods want to do somthing with this list of posts, let them do that now.
2083 2192
 	call_integration_hook('integrate_ssi_boardNews', array(&$return));
2084 2193
 
2085
-	if ($output_method != 'echo')
2086
-		return $return;
2194
+	if ($output_method != 'echo') {
2195
+			return $return;
2196
+	}
2087 2197
 
2088 2198
 	foreach ($return as $news)
2089 2199
 	{
@@ -2135,9 +2245,10 @@  discard block
 block discarded – undo
2135 2245
 		echo '
2136 2246
 			</div>';
2137 2247
 
2138
-		if (!$news['is_last'])
2139
-			echo '
2248
+		if (!$news['is_last']) {
2249
+					echo '
2140 2250
 			<hr>';
2251
+		}
2141 2252
 	}
2142 2253
 }
2143 2254
 
@@ -2151,8 +2262,9 @@  discard block
 block discarded – undo
2151 2262
 {
2152 2263
 	global $user_info, $scripturl, $modSettings, $txt, $context, $smcFunc;
2153 2264
 
2154
-	if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view'))
2155
-		return;
2265
+	if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) {
2266
+			return;
2267
+	}
2156 2268
 
2157 2269
 	// Find all events which are happening in the near future that the member can see.
2158 2270
 	$request = $smcFunc['db_query']('', '
@@ -2178,20 +2290,23 @@  discard block
 block discarded – undo
2178 2290
 	while ($row = $smcFunc['db_fetch_assoc']($request))
2179 2291
 	{
2180 2292
 		// Check if we've already come by an event linked to this same topic with the same title... and don't display it if we have.
2181
-		if (!empty($duplicates[$row['title'] . $row['id_topic']]))
2182
-			continue;
2293
+		if (!empty($duplicates[$row['title'] . $row['id_topic']])) {
2294
+					continue;
2295
+		}
2183 2296
 
2184 2297
 		// Censor the title.
2185 2298
 		censorText($row['title']);
2186 2299
 
2187
-		if ($row['start_date'] < strftime('%Y-%m-%d', forum_time(false)))
2188
-			$date = strftime('%Y-%m-%d', forum_time(false));
2189
-		else
2190
-			$date = $row['start_date'];
2300
+		if ($row['start_date'] < strftime('%Y-%m-%d', forum_time(false))) {
2301
+					$date = strftime('%Y-%m-%d', forum_time(false));
2302
+		} else {
2303
+					$date = $row['start_date'];
2304
+		}
2191 2305
 
2192 2306
 		// If the topic it is attached to is not approved then don't link it.
2193
-		if (!empty($row['id_first_msg']) && !$row['approved'])
2194
-			$row['id_board'] = $row['id_topic'] = $row['id_first_msg'] = 0;
2307
+		if (!empty($row['id_first_msg']) && !$row['approved']) {
2308
+					$row['id_board'] = $row['id_topic'] = $row['id_first_msg'] = 0;
2309
+		}
2195 2310
 
2196 2311
 		$allday = (empty($row['start_time']) || empty($row['end_time']) || empty($row['timezone']) || !in_array($row['timezone'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) ? true : false;
2197 2312
 
@@ -2217,24 +2332,27 @@  discard block
 block discarded – undo
2217 2332
 	}
2218 2333
 	$smcFunc['db_free_result']($request);
2219 2334
 
2220
-	foreach ($return as $mday => $array)
2221
-		$return[$mday][count($array) - 1]['is_last'] = true;
2335
+	foreach ($return as $mday => $array) {
2336
+			$return[$mday][count($array) - 1]['is_last'] = true;
2337
+	}
2222 2338
 
2223 2339
 	// If mods want to do somthing with this list of events, let them do that now.
2224 2340
 	call_integration_hook('integrate_ssi_recentEvents', array(&$return));
2225 2341
 
2226
-	if ($output_method != 'echo' || empty($return))
2227
-		return $return;
2342
+	if ($output_method != 'echo' || empty($return)) {
2343
+			return $return;
2344
+	}
2228 2345
 
2229 2346
 	// Well the output method is echo.
2230 2347
 	echo '
2231 2348
 			<span class="event">' . $txt['events'] . '</span> ';
2232
-	foreach ($return as $mday => $array)
2233
-		foreach ($array as $event)
2349
+	foreach ($return as $mday => $array) {
2350
+			foreach ($array as $event)
2234 2351
 		{
2235 2352
 			if ($event['can_edit'])
2236 2353
 				echo '
2237 2354
 				<a href="' . $event['modify_href'] . '" style="color: #ff0000;">*</a> ';
2355
+	}
2238 2356
 
2239 2357
 			echo '
2240 2358
 				' . $event['link'] . (!$event['is_last'] ? ', ' : '');
@@ -2253,8 +2371,9 @@  discard block
 block discarded – undo
2253 2371
 	global $smcFunc;
2254 2372
 
2255 2373
 	// If $id is null, this was most likely called from a query string and should do nothing.
2256
-	if ($id === null)
2257
-		return;
2374
+	if ($id === null) {
2375
+			return;
2376
+	}
2258 2377
 
2259 2378
 	$request = $smcFunc['db_query']('', '
2260 2379
 		SELECT passwd, member_name, is_activated
@@ -2286,8 +2405,9 @@  discard block
 block discarded – undo
2286 2405
 	$attachments_boards = boardsAllowedTo('view_attachments');
2287 2406
 
2288 2407
 	// No boards?  Adios amigo.
2289
-	if (empty($attachments_boards))
2290
-		return array();
2408
+	if (empty($attachments_boards)) {
2409
+			return array();
2410
+	}
2291 2411
 
2292 2412
 	// Is it an array?
2293 2413
 	$attachment_ext = (array) $attachment_ext;
@@ -2371,8 +2491,9 @@  discard block
 block discarded – undo
2371 2491
 	call_integration_hook('integrate_ssi_recentAttachments', array(&$attachments));
2372 2492
 
2373 2493
 	// So you just want an array?  Here you can have it.
2374
-	if ($output_method == 'array' || empty($attachments))
2375
-		return $attachments;
2494
+	if ($output_method == 'array' || empty($attachments)) {
2495
+			return $attachments;
2496
+	}
2376 2497
 
2377 2498
 	// Give them the default.
2378 2499
 	echo '
@@ -2383,14 +2504,15 @@  discard block
 block discarded – undo
2383 2504
 				<th style="text-align: left; padding: 2">', $txt['downloads'], '</th>
2384 2505
 				<th style="text-align: left; padding: 2">', $txt['filesize'], '</th>
2385 2506
 			</tr>';
2386
-	foreach ($attachments as $attach)
2387
-		echo '
2507
+	foreach ($attachments as $attach) {
2508
+			echo '
2388 2509
 			<tr>
2389 2510
 				<td>', $attach['file']['link'], '</td>
2390 2511
 				<td>', $attach['member']['link'], '</td>
2391 2512
 				<td style="text-align: center">', $attach['file']['downloads'], '</td>
2392 2513
 				<td>', $attach['file']['filesize'], '</td>
2393 2514
 			</tr>';
2515
+	}
2394 2516
 	echo '
2395 2517
 		</table>';
2396 2518
 }
Please login to merge, or discard this patch.
Themes/default/GenericControls.template.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -227,7 +227,7 @@
 block discarded – undo
227 227
  * @param int|string $verify_id The verification control ID
228 228
  * @param string $display_type What type to display. Can be 'single' to only show one verification option or 'all' to show all of them
229 229
  * @param bool $reset Whether to reset the internal tracking counter
230
- * @return bool False if there's nothing else to show, true if $display_type is 'single', nothing otherwise
230
+ * @return boolean|null False if there's nothing else to show, true if $display_type is 'single', nothing otherwise
231 231
  */
232 232
 function template_control_verification($verify_id, $display_type = 'all', $reset = false)
233 233
 {
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -300,7 +300,7 @@
 block discarded – undo
300 300
 				echo '
301 301
 				<div class="g-recaptcha centertext" data-sitekey="' . $verify_context['recaptcha_site_key'] . '" data-theme="' . $verify_context['recaptcha_theme'] . '"></div>
302 302
 				<br>
303
-				<script type="text/javascript" src="https://www.google.com/recaptcha/api.js?hl='.$lang.'"></script>';
303
+				<script type="text/javascript" src="https://www.google.com/recaptcha/api.js?hl='.$lang . '"></script>';
304 304
 			}
305 305
 		}
306 306
 		else
Please login to merge, or discard this patch.
Braces   +65 added lines, -48 removed lines patch added patch discarded remove patch
@@ -23,11 +23,13 @@  discard block
 block discarded – undo
23 23
 
24 24
 	$editor_context = &$context['controls']['richedit'][$editor_id];
25 25
 
26
-	if ($smileyContainer === null)
27
-		$editor_context['sce_options']['emoticonsEnabled'] = false;
26
+	if ($smileyContainer === null) {
27
+			$editor_context['sce_options']['emoticonsEnabled'] = false;
28
+	}
28 29
 
29
-	if ($bbcContainer === null)
30
-		$editor_context['sce_options']['toolbar'] = '';
30
+	if ($bbcContainer === null) {
31
+			$editor_context['sce_options']['toolbar'] = '';
32
+	}
31 33
 
32 34
 	echo '
33 35
 		<textarea class="editor" name="', $editor_id, '" id="', $editor_id, '" cols="600" onselect="storeCaret(this);" onclick="storeCaret(this);" onkeyup="storeCaret(this);" onchange="storeCaret(this);" tabindex="', $context['tabindex']++, '" style="width: ', $editor_context['width'], '; height: ', $editor_context['height'], ';', isset($context['post_error']['no_message']) || isset($context['post_error']['long_message']) ? 'border: 1px solid red;' : '', '"', !empty($context['editor']['required']) ? ' required' : '', '>', $editor_context['value'], '</textarea>
@@ -77,42 +79,47 @@  discard block
 block discarded – undo
77 79
 
78 80
 	$tempTab = $context['tabindex'];
79 81
 
80
-	if (!empty($context['drafts_pm_save']))
81
-		$tempTab++;
82
-	elseif (!empty($context['drafts_save']))
83
-		$tempTab++;
84
-	elseif ($editor_context['preview_type'])
85
-		$tempTab++;
86
-	elseif ($context['show_spellchecking'])
87
-		$tempTab++;
82
+	if (!empty($context['drafts_pm_save'])) {
83
+			$tempTab++;
84
+	} elseif (!empty($context['drafts_save'])) {
85
+			$tempTab++;
86
+	} elseif ($editor_context['preview_type']) {
87
+			$tempTab++;
88
+	} elseif ($context['show_spellchecking']) {
89
+			$tempTab++;
90
+	}
88 91
 
89 92
 	$tempTab++;
90 93
 	$context['tabindex'] = $tempTab;
91 94
 
92
-	if (!empty($context['drafts_pm_save']))
93
-		echo '
95
+	if (!empty($context['drafts_pm_save'])) {
96
+			echo '
94 97
 		<input type="submit" name="save_draft" value="', $txt['draft_save'], '" tabindex="', --$tempTab, '" onclick="submitThisOnce(this);" accesskey="d" class="button">
95 98
 		<input type="hidden" id="id_pm_draft" name="id_pm_draft" value="', empty($context['id_pm_draft']) ? 0 : $context['id_pm_draft'], '">';
99
+	}
96 100
 
97
-	if (!empty($context['drafts_save']))
98
-		echo '
101
+	if (!empty($context['drafts_save'])) {
102
+			echo '
99 103
 		<input type="submit" name="save_draft" value="', $txt['draft_save'], '" tabindex="', --$tempTab, '" onclick="return confirm(' . JavaScriptEscape($txt['draft_save_note']) . ') && submitThisOnce(this);" accesskey="d" class="button">
100 104
 		<input type="hidden" id="id_draft" name="id_draft" value="', empty($context['id_draft']) ? 0 : $context['id_draft'], '">';
105
+	}
101 106
 
102
-	if ($context['show_spellchecking'])
103
-		echo '
107
+	if ($context['show_spellchecking']) {
108
+			echo '
104 109
 		<input type="button" value="', $txt['spell_check'], '" tabindex="', --$tempTab, '" onclick="oEditorHandle_', $editor_id, '.spellCheckStart();" class="button">';
110
+	}
105 111
 
106
-	if ($editor_context['preview_type'])
107
-		echo '
112
+	if ($editor_context['preview_type']) {
113
+			echo '
108 114
 		<input type="submit" name="preview" value="', isset($editor_context['labels']['preview_button']) ? $editor_context['labels']['preview_button'] : $txt['preview'], '" tabindex="', --$tempTab, '" onclick="', $editor_context['preview_type'] == 2 ? 'return event.ctrlKey || previewPost();' : 'return submitThisOnce(this);', '" accesskey="p" class="button">';
115
+	}
109 116
 
110 117
 	echo '
111 118
 		<input type="submit" value="', isset($editor_context['labels']['post_button']) ? $editor_context['labels']['post_button'] : $txt['post'], '" name="post" tabindex="', --$tempTab, '" onclick="return submitThisOnce(this);" accesskey="s" class="button">';
112 119
 
113 120
 	// Load in the PM autosaver if it's enabled
114
-	if (!empty($context['drafts_pm_save']) && !empty($context['drafts_autosave']))
115
-		echo '
121
+	if (!empty($context['drafts_pm_save']) && !empty($context['drafts_autosave'])) {
122
+			echo '
116 123
 		<span class="righttext padding" style="display: block">
117 124
 			<span id="throbber" style="display:none"><img src="' . $settings['images_url'] . '/loading_sm.gif" alt="" class="centericon"></span>
118 125
 			<span id="draft_lastautosave" ></span>
@@ -130,10 +137,11 @@  discard block
 block discarded – undo
130 137
 				iFreq: ', (empty($modSettings['drafts_autosave_frequency']) ? 60000 : $modSettings['drafts_autosave_frequency'] * 1000), '
131 138
 			});
132 139
 		</script>';
140
+	}
133 141
 
134 142
 	// Start an instance of the auto saver if its enabled
135
-	if (!empty($context['drafts_save']) && !empty($context['drafts_autosave']))
136
-		echo '
143
+	if (!empty($context['drafts_save']) && !empty($context['drafts_autosave'])) {
144
+			echo '
137 145
 		<span class="righttext padding" style="display: block">
138 146
 			<span id="throbber" style="display:none"><img src="', $settings['images_url'], '/loading_sm.gif" alt="" class="centericon"></span>
139 147
 			<span id="draft_lastautosave" ></span>
@@ -150,7 +158,8 @@  discard block
 block discarded – undo
150 158
 				iFreq: ', $context['drafts_autosave_frequency'], '
151 159
 			});
152 160
 		</script>';
153
-}
161
+	}
162
+	}
154 163
 
155 164
 /**
156 165
  * This template displays a verification form
@@ -167,51 +176,57 @@  discard block
 block discarded – undo
167 176
 	$verify_context = &$context['controls']['verification'][$verify_id];
168 177
 
169 178
 	// Keep track of where we are.
170
-	if (empty($verify_context['tracking']) || $reset)
171
-		$verify_context['tracking'] = 0;
179
+	if (empty($verify_context['tracking']) || $reset) {
180
+			$verify_context['tracking'] = 0;
181
+	}
172 182
 
173 183
 	// How many items are there to display in total.
174 184
 	$total_items = count($verify_context['questions']) + ($verify_context['show_visual'] || $verify_context['can_recaptcha'] ? 1 : 0);
175 185
 
176 186
 	// If we've gone too far, stop.
177
-	if ($verify_context['tracking'] > $total_items)
178
-		return false;
187
+	if ($verify_context['tracking'] > $total_items) {
188
+			return false;
189
+	}
179 190
 
180 191
 	// Loop through each item to show them.
181 192
 	for ($i = 0; $i < $total_items; $i++)
182 193
 	{
183 194
 		// If we're after a single item only show it if we're in the right place.
184
-		if ($display_type == 'single' && $verify_context['tracking'] != $i)
185
-			continue;
195
+		if ($display_type == 'single' && $verify_context['tracking'] != $i) {
196
+					continue;
197
+		}
186 198
 
187
-		if ($display_type != 'single')
188
-			echo '
199
+		if ($display_type != 'single') {
200
+					echo '
189 201
 			<div id="verification_control_', $i, '" class="verification_control">';
202
+		}
190 203
 
191 204
 		// Display empty field, but only if we have one, and it's the first time.
192
-		if ($verify_context['empty_field'] && empty($i))
193
-			echo '
205
+		if ($verify_context['empty_field'] && empty($i)) {
206
+					echo '
194 207
 				<div class="smalltext vv_special">
195 208
 					', $txt['visual_verification_hidden'], ':
196 209
 					<input type="text" name="', $_SESSION[$verify_id . '_vv']['empty_field'], '" autocomplete="off" size="30" value="">
197 210
 				</div>';
211
+		}
198 212
 
199 213
 		// Do the actual stuff
200 214
 		if ($i == 0 && ($verify_context['show_visual'] || $verify_context['can_recaptcha']))
201 215
 		{
202 216
 			if ($verify_context['show_visual'])
203 217
 			{
204
-				if ($context['use_graphic_library'])
205
-					echo '
218
+				if ($context['use_graphic_library']) {
219
+									echo '
206 220
 				<img src="', $verify_context['image_href'], '" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '">';
207
-				else
208
-					echo '
221
+				} else {
222
+									echo '
209 223
 				<img src="', $verify_context['image_href'], ';letter=1" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_1">
210 224
 				<img src="', $verify_context['image_href'], ';letter=2" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_2">
211 225
 				<img src="', $verify_context['image_href'], ';letter=3" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_3">
212 226
 				<img src="', $verify_context['image_href'], ';letter=4" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_4">
213 227
 				<img src="', $verify_context['image_href'], ';letter=5" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_5">
214 228
 				<img src="', $verify_context['image_href'], ';letter=6" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_6">';
229
+				}
215 230
 
216 231
 				echo '
217 232
 				<div class="smalltext" style="margin: 4px 0 8px 0;">
@@ -229,8 +244,7 @@  discard block
 block discarded – undo
229 244
 				<br>
230 245
 				<script type="text/javascript" src="https://www.google.com/recaptcha/api.js?hl='.$lang.'"></script>';
231 246
 			}
232
-		}
233
-		else
247
+		} else
234 248
 		{
235 249
 			// Where in the question array is this question?
236 250
 			$qIndex = $verify_context['show_visual'] ? $i - 1 : $i;
@@ -242,21 +256,24 @@  discard block
 block discarded – undo
242 256
 				</div>';
243 257
 		}
244 258
 
245
-		if ($display_type != 'single')
246
-			echo '
259
+		if ($display_type != 'single') {
260
+					echo '
247 261
 			</div><!-- #verification_control_[i] -->';
262
+		}
248 263
 
249 264
 		// If we were displaying just one and we did it, break.
250
-		if ($display_type == 'single' && $verify_context['tracking'] == $i)
251
-			break;
265
+		if ($display_type == 'single' && $verify_context['tracking'] == $i) {
266
+					break;
267
+		}
252 268
 	}
253 269
 
254 270
 	// Assume we found something, always.
255 271
 	$verify_context['tracking']++;
256 272
 
257 273
 	// Tell something displaying piecemeal to keep going.
258
-	if ($display_type == 'single')
259
-		return true;
260
-}
274
+	if ($display_type == 'single') {
275
+			return true;
276
+	}
277
+	}
261 278
 
262 279
 ?>
263 280
\ No newline at end of file
Please login to merge, or discard this patch.
Themes/default/Packages.template.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1096,7 +1096,7 @@
 block discarded – undo
1096 1096
 /**
1097 1097
  * CHMOD control form
1098 1098
  *
1099
- * @return bool False if nothing to do.
1099
+ * @return false|null False if nothing to do.
1100 1100
  */
1101 1101
 function template_control_chmod()
1102 1102
 {
Please login to merge, or discard this patch.
Braces   +175 added lines, -128 removed lines patch added patch discarded remove patch
@@ -31,25 +31,27 @@  discard block
 block discarded – undo
31 31
 		</div>
32 32
 		<div class="information">';
33 33
 
34
-	if ($context['is_installed'])
35
-		echo '
34
+	if ($context['is_installed']) {
35
+			echo '
36 36
 			<strong>', $txt['package_installed_warning1'], '</strong><br>
37 37
 			<br>
38 38
 			', $txt['package_installed_warning2'], '<br>
39 39
 			<br>';
40
+	}
40 41
 
41 42
 	echo $txt['package_installed_warning3'], '
42 43
 		</div>
43 44
 		<br>';
44 45
 
45 46
 	// Do errors exist in the install? If so light them up like a christmas tree.
46
-	if ($context['has_failure'])
47
-		echo '
47
+	if ($context['has_failure']) {
48
+			echo '
48 49
 		<div class="errorbox">
49 50
 			', sprintf($txt['package_will_fail_title'], $txt['package_' . ($context['uninstalling'] ? 'uninstall' : 'install')]), '<br>
50 51
 			', sprintf($txt['package_will_fail_warning'], $txt['package_' . ($context['uninstalling'] ? 'uninstall' : 'install')]),
51 52
 			!empty($context['failure_details']) ? '<br><br><strong>' . $context['failure_details'] . '</strong>' : '', '
52 53
 		</div>';
54
+	}
53 55
 
54 56
 	// Display the package readme if one exists
55 57
 	if (isset($context['package_readme']))
@@ -63,9 +65,10 @@  discard block
 block discarded – undo
63 65
 			<span class="floatright">', $txt['package_available_readme_language'], '
64 66
 				<select name="readme_language" id="readme_language" onchange="if (this.options[this.selectedIndex].value) window.location.href = smf_prepareScriptUrl(smf_scripturl + \'', '?action=admin;area=packages;sa=', $context['uninstalling'] ? 'uninstall' : 'install', ';package=', $context['filename'], ';readme=\' + this.options[this.selectedIndex].value + \';license=\' + get_selected(\'license_language\'));">';
65 67
 
66
-		foreach ($context['readmes'] as $a => $b)
67
-			echo '
68
+		foreach ($context['readmes'] as $a => $b) {
69
+					echo '
68 70
 					<option value="', $b, '"', $a === 'selected' ? ' selected' : '', '>', $b == 'default' ? $txt['package_readme_default'] : ucfirst($b), '</option>';
71
+		}
69 72
 
70 73
 		echo '
71 74
 				</select>
@@ -86,9 +89,10 @@  discard block
 block discarded – undo
86 89
 			<span class="floatright">', $txt['package_available_license_language'], '
87 90
 				<select name="license_language" id="license_language" onchange="if (this.options[this.selectedIndex].value) window.location.href = smf_prepareScriptUrl(smf_scripturl + \'', '?action=admin;area=packages;sa=install', ';package=', $context['filename'], ';license=\' + this.options[this.selectedIndex].value + \';readme=\' + get_selected(\'readme_language\'));">';
88 91
 
89
-		foreach ($context['licenses'] as $a => $b)
90
-			echo '
92
+		foreach ($context['licenses'] as $a => $b) {
93
+					echo '
91 94
 					<option value="', $b, '"', $a === 'selected' ? ' selected' : '', '>', $b == 'default' ? $txt['package_license_default'] : ucfirst($b), '</option>';
95
+		}
92 96
 		echo '
93 97
 				</select>
94 98
 			</span>
@@ -115,9 +119,10 @@  discard block
 block discarded – undo
115 119
 					', $txt['package_db_uninstall_actions'], ':
116 120
 					<ul>';
117 121
 
118
-		foreach ($context['database_changes'] as $change)
119
-			echo '
122
+		foreach ($context['database_changes'] as $change) {
123
+					echo '
120 124
 						<li>', $change, '</li>';
125
+		}
121 126
 
122 127
 		echo '
123 128
 					</ul>
@@ -128,14 +133,14 @@  discard block
 block discarded – undo
128 133
 	echo '
129 134
 			<div class="information">';
130 135
 
131
-	if (empty($context['actions']) && empty($context['database_changes']))
132
-		echo '
136
+	if (empty($context['actions']) && empty($context['database_changes'])) {
137
+			echo '
133 138
 				<br>
134 139
 				<div class="errorbox">
135 140
 					', $txt['corrupt_compatible'], '
136 141
 				</div>
137 142
 			</div><!-- .information -->';
138
-	else
143
+	} else
139 144
 	{
140 145
 		echo '
141 146
 				', $txt['perform_actions'], '
@@ -239,9 +244,10 @@  discard block
 block discarded – undo
239 244
 						<td></td>
240 245
 						<td>';
241 246
 
242
-				if (!empty($context['themes_locked']))
243
-					echo '
247
+				if (!empty($context['themes_locked'])) {
248
+									echo '
244 249
 							<input type="hidden" name="custom_theme[]" value="', $id, '">';
250
+				}
245 251
 				echo '
246 252
 							<input type="checkbox" name="custom_theme[]" id="custom_theme_', $id, '" value="', $id, '" onclick="', (!empty($theme['has_failure']) ? 'if (this.form.custom_theme_' . $id . '.checked && !confirm(\'' . $txt['package_theme_failure_warning'] . '\')) return false;' : ''), 'invertAll(this, this.form, \'dummy_theme_', $id, '\', true);"', !empty($context['themes_locked']) ? ' disabled checked' : '', '>
247 253
 						</td>
@@ -307,21 +313,23 @@  discard block
 block discarded – undo
307 313
 	}
308 314
 
309 315
 	// Are we effectively ready to install?
310
-	if (!$context['ftp_needed'] && (!empty($context['actions']) || !empty($context['database_changes'])))
311
-		echo '
316
+	if (!$context['ftp_needed'] && (!empty($context['actions']) || !empty($context['database_changes']))) {
317
+			echo '
312 318
 			<div class="righttext padding">
313 319
 				<input type="submit" value="', $context['uninstalling'] ? $txt['package_uninstall_now'] : $txt['package_install_now'], '" onclick="return ', !empty($context['has_failure']) ? '(submitThisOnce(this) &amp;&amp; confirm(\'' . ($context['uninstalling'] ? $txt['package_will_fail_popup_uninstall'] : $txt['package_will_fail_popup']) . '\'))' : 'submitThisOnce(this)', ';" class="button">
314 320
 			</div>';
321
+	}
315 322
 
316 323
 	// If we need ftp information then demand it!
317
-	elseif ($context['ftp_needed'])
318
-		echo '
324
+	elseif ($context['ftp_needed']) {
325
+			echo '
319 326
 			<div class="cat_bar">
320 327
 				<h3 class="catbg">', $txt['package_ftp_necessary'], '</h3>
321 328
 			</div>
322 329
 			<div>
323 330
 				', template_control_chmod(), '
324 331
 			</div>';
332
+	}
325 333
 
326 334
 	echo '
327 335
 
@@ -338,8 +346,8 @@  discard block
 block discarded – undo
338 346
 	// Operations.
339 347
 	if (!empty($js_operations))
340 348
 	{
341
-		foreach ($js_operations as $key => $operation)
342
-			echo '
349
+		foreach ($js_operations as $key => $operation) {
350
+					echo '
343 351
 		aOperationElements[', $key, '] = new smc_Toggle({
344 352
 			bToggleEnabled: true,
345 353
 			bNoAnimate: true,
@@ -357,6 +365,7 @@  discard block
 block discarded – undo
357 365
 				}
358 366
 			]
359 367
 		});';
368
+		}
360 369
 	}
361 370
 
362 371
 	echo '
@@ -378,14 +387,15 @@  discard block
 block discarded – undo
378 387
 	</script>';
379 388
 
380 389
 	// And a bit more for database changes.
381
-	if (!empty($context['database_changes']))
382
-		echo '
390
+	if (!empty($context['database_changes'])) {
391
+			echo '
383 392
 	<script>
384 393
 		var database_changes_area = document.getElementById(\'db_changes_div\');
385 394
 		var db_vis = false;
386 395
 		database_changes_area.style.display = "none";
387 396
 	</script>';
388
-}
397
+	}
398
+	}
389 399
 
390 400
 /**
391 401
  * Extract package contents
@@ -394,8 +404,8 @@  discard block
 block discarded – undo
394 404
 {
395 405
 	global $context, $txt, $scripturl;
396 406
 
397
-	if (!empty($context['redirect_url']))
398
-		echo '
407
+	if (!empty($context['redirect_url'])) {
408
+			echo '
399 409
 	<script>
400 410
 		setTimeout("doRedirect();", ', empty($context['redirect_timeout']) ? '5000' : $context['redirect_timeout'], ');
401 411
 
@@ -404,52 +414,51 @@  discard block
 block discarded – undo
404 414
 			window.location = "', $context['redirect_url'], '";
405 415
 		}
406 416
 	</script>';
417
+	}
407 418
 
408 419
 	echo '
409 420
 	<div id="admincenter">';
410 421
 
411
-	if (empty($context['redirect_url']))
412
-		echo '
422
+	if (empty($context['redirect_url'])) {
423
+			echo '
413 424
 		<div class="cat_bar">
414 425
 			<h3 class="catbg">', $context['uninstalling'] ? $txt['uninstall'] : $txt['extracting'], '</h3>
415 426
 		</div>
416 427
 		<div class="information">', $txt['package_installed_extract'], '</div>';
417
-	else
418
-		echo '
428
+	} else {
429
+			echo '
419 430
 		<div class="cat_bar">
420 431
 			<h3 class="catbg">', $txt['package_installed_redirecting'], '</h3>
421 432
 		</div>';
433
+	}
422 434
 
423 435
 	echo '
424 436
 		<div class="windowbg">';
425 437
 
426 438
 	// If we are going to redirect we have a slightly different agenda.
427
-	if (!empty($context['redirect_url']))
428
-		echo '
439
+	if (!empty($context['redirect_url'])) {
440
+			echo '
429 441
 			', $context['redirect_text'], '<br><br>
430 442
 			<a href="', $context['redirect_url'], '">', $txt['package_installed_redirect_go_now'], '</a> | <a href="', $scripturl, '?action=admin;area=packages;sa=browse">', $txt['package_installed_redirect_cancel'], '</a>';
431
-
432
-	elseif ($context['uninstalling'])
433
-		echo '
443
+	} elseif ($context['uninstalling']) {
444
+			echo '
434 445
 			', $txt['package_uninstall_done'];
435
-
436
-	elseif ($context['install_finished'])
446
+	} elseif ($context['install_finished'])
437 447
 	{
438
-		if ($context['extract_type'] == 'avatar')
439
-			echo '
448
+		if ($context['extract_type'] == 'avatar') {
449
+					echo '
440 450
 			', $txt['avatars_extracted'];
441
-
442
-		elseif ($context['extract_type'] == 'language')
443
-			echo '
451
+		} elseif ($context['extract_type'] == 'language') {
452
+					echo '
444 453
 			', $txt['language_extracted'];
445
-
446
-		else
447
-			echo '
454
+		} else {
455
+					echo '
448 456
 			', $txt['package_installed_done'];
449
-	}
450
-	else
451
-		echo '
457
+		}
458
+	} else {
459
+			echo '
452 460
 			', $txt['corrupt_compatible'];
461
+	}
453 462
 
454 463
 	echo '
455 464
 		</div><!-- .windowbg -->';
@@ -483,9 +492,10 @@  discard block
 block discarded – undo
483 492
 		<div class="windowbg">
484 493
 			<ol>';
485 494
 
486
-	foreach ($context['files'] as $fileinfo)
487
-		echo '
495
+	foreach ($context['files'] as $fileinfo) {
496
+			echo '
488 497
 				<li><a href="', $scripturl, '?action=admin;area=packages;sa=examine;package=', $context['filename'], ';file=', $fileinfo['filename'], '" title="', $txt['view'], '">', $fileinfo['filename'], '</a> (', $fileinfo['size'], ' ', $txt['package_bytes'], ')</li>';
498
+	}
489 499
 
490 500
 	echo '
491 501
 			</ol>
@@ -549,9 +559,10 @@  discard block
 block discarded – undo
549 559
 			</script>
550 560
 			<div id="yourVersion" style="display:none">', $context['forum_version'], '</div>';
551 561
 
552
-	if (empty($modSettings['disable_smf_js']))
553
-		echo '
562
+	if (empty($modSettings['disable_smf_js'])) {
563
+			echo '
554 564
 			<script src="', $scripturl, '?action=viewsmfile;filename=latest-news.js"></script>';
565
+	}
555 566
 
556 567
 	// This sets the announcements and current versions themselves ;).
557 568
 	echo '
@@ -590,12 +601,13 @@  discard block
 block discarded – undo
590 601
 		}
591 602
 	}
592 603
 
593
-	if (!$mods_available)
594
-		echo '
604
+	if (!$mods_available) {
605
+			echo '
595 606
 		<div class="noticebox">', $txt['no_packages'], '</div>';
596
-	else
597
-		echo '
607
+	} else {
608
+			echo '
598 609
 		<br>';
610
+	}
599 611
 
600 612
 	// The advanced (emulation) box, collapsed by default
601 613
 	echo '
@@ -622,9 +634,10 @@  discard block
 block discarded – undo
622 634
 							<a id="revert" name="revert"></a>
623 635
 							<select name="version_emulate" id="ve">';
624 636
 
625
-	foreach ($context['emulation_versions'] as $version)
626
-		echo '
637
+	foreach ($context['emulation_versions'] as $version) {
638
+			echo '
627 639
 								<option value="', $version, '"', ($version == $context['selected_version'] ? ' selected="selected"' : ''), '>', $version, '</option>';
640
+	}
628 641
 
629 642
 	echo '
630 643
 							</select>
@@ -680,11 +693,12 @@  discard block
 block discarded – undo
680 693
 {
681 694
 	global $context, $txt, $scripturl;
682 695
 
683
-	if (!empty($context['package_ftp']['error']))
684
-		echo '
696
+	if (!empty($context['package_ftp']['error'])) {
697
+			echo '
685 698
 	<div class="errorbox">
686 699
 		<pre>', $context['package_ftp']['error'], '</pre>
687 700
 	</div>';
701
+	}
688 702
 
689 703
 	echo '
690 704
 	<div id="admin_form_wrapper">
@@ -766,13 +780,14 @@  discard block
 block discarded – undo
766 780
 					<legend>' . $txt['package_servers'] . '</legend>
767 781
 					<ul class="package_servers">';
768 782
 
769
-	foreach ($context['servers'] as $server)
770
-		echo '
783
+	foreach ($context['servers'] as $server) {
784
+			echo '
771 785
 						<li class="flow_auto">
772 786
 							<span class="floatleft">' . $server['name'] . '</span>
773 787
 							<span class="package_server floatright"><a href="' . $scripturl . '?action=admin;area=packages;get;sa=remove;server=' . $server['id'] . ';', $context['session_var'], '=', $context['session_id'], '">[ ' . $txt['delete'] . ' ]</a></span>
774 788
 							<span class="package_server floatright"><a href="' . $scripturl . '?action=admin;area=packages;get;sa=browse;server=' . $server['id'] . '">[ ' . $txt['package_browse'] . ' ]</a></span>
775 789
 						</li>';
790
+	}
776 791
 	echo '
777 792
 					</ul>
778 793
 				</fieldset>
@@ -859,11 +874,12 @@  discard block
 block discarded – undo
859 874
 		<div class="windowbg2">';
860 875
 
861 876
 	// No packages, as yet.
862
-	if (empty($context['package_list']))
863
-		echo '
877
+	if (empty($context['package_list'])) {
878
+			echo '
864 879
 			<ul>
865 880
 				<li>', $txt['no_packages'], '</li>
866 881
 			</ul>';
882
+	}
867 883
 
868 884
 	// List out the packages...
869 885
 	else
@@ -877,11 +893,12 @@  discard block
 block discarded – undo
877 893
 				<li>
878 894
 					<strong><span id="ps_img_', $i, '" class="toggle_up" alt="*" style="display: none;"></span> ', $packageSection['title'], '</strong>';
879 895
 
880
-			if (!empty($packageSection['text']))
881
-				echo '
896
+			if (!empty($packageSection['text'])) {
897
+							echo '
882 898
 					<div class="sub_bar">
883 899
 						<h3 class="subbg">', $packageSection['text'], '</h3>
884 900
 					</div>';
901
+			}
885 902
 
886 903
 			echo '
887 904
 					<', $context['list_type'], ' id="package_section_', $i, '" class="packages">';
@@ -892,24 +909,28 @@  discard block
 block discarded – undo
892 909
 						<li>';
893 910
 
894 911
 				// Textual message. Could be empty just for a blank line...
895
-				if ($package['is_text'])
896
-					echo '
912
+				if ($package['is_text']) {
913
+									echo '
897 914
 							', empty($package['name']) ? '&nbsp;' : $package['name'];
915
+				}
898 916
 
899 917
 				// This is supposed to be a rule..
900
-				elseif ($package['is_line'])
901
-					echo '
918
+				elseif ($package['is_line']) {
919
+									echo '
902 920
 							<hr>';
921
+				}
903 922
 
904 923
 				// A remote link.
905
-				elseif ($package['is_remote'])
906
-					echo '
924
+				elseif ($package['is_remote']) {
925
+									echo '
907 926
 							<strong>', $package['link'], '</strong>';
927
+				}
908 928
 
909 929
 				// A title?
910
-				elseif ($package['is_heading'] || $package['is_title'])
911
-					echo '
930
+				elseif ($package['is_heading'] || $package['is_title']) {
931
+									echo '
912 932
 							<strong>', $package['name'], '</strong>';
933
+				}
913 934
 
914 935
 				// Otherwise, it's a package.
915 936
 				else
@@ -920,32 +941,36 @@  discard block
 block discarded – undo
920 941
 						<ul id="package_section_', $i, '_pkg_', $id, '" class="package_section">';
921 942
 
922 943
 					// Show the mod type?
923
-					if ($package['type'] != '')
924
-						echo '
944
+					if ($package['type'] != '') {
945
+											echo '
925 946
 							<li class="package_section">
926 947
 								', $txt['package_type'], ':&nbsp; ', $smcFunc['ucwords']($smcFunc['strtolower']($package['type'])), '
927 948
 							</li>';
949
+					}
928 950
 
929 951
 					// Show the version number?
930
-					if ($package['version'] != '')
931
-						echo '
952
+					if ($package['version'] != '') {
953
+											echo '
932 954
 							<li class="package_section">
933 955
 								', $txt['mod_version'], ':&nbsp; ', $package['version'], '
934 956
 							</li>';
957
+					}
935 958
 
936 959
 					// How 'bout the author?
937
-					if (!empty($package['author']) && $package['author']['name'] != '' && isset($package['author']['link']))
938
-						echo '
960
+					if (!empty($package['author']) && $package['author']['name'] != '' && isset($package['author']['link'])) {
961
+											echo '
939 962
 							<li class="package_section">
940 963
 								', $txt['mod_author'], ':&nbsp; ', $package['author']['link'], '
941 964
 							</li>';
965
+					}
942 966
 
943 967
 					// The homepage...
944
-					if ($package['author']['website']['link'] != '')
945
-						echo '
968
+					if ($package['author']['website']['link'] != '') {
969
+											echo '
946 970
 							<li class="package_section">
947 971
 								', $txt['author_website'], ':&nbsp; ', $package['author']['website']['link'], '
948 972
 							</li>';
973
+					}
949 974
 
950 975
 					// Description: bleh bleh!
951 976
 					// Location of file: http://someplace/.
@@ -1004,8 +1029,8 @@  discard block
 block discarded – undo
1004 1029
 
1005 1030
 			foreach ($ps['items'] as $id => $package)
1006 1031
 			{
1007
-				if (!$package['is_text'] && !$package['is_line'] && !$package['is_remote'])
1008
-					echo '
1032
+				if (!$package['is_text'] && !$package['is_line'] && !$package['is_remote']) {
1033
+									echo '
1009 1034
 		var oPackageToggle_', $section, '_pkg_', $id, ' = new smc_Toggle({
1010 1035
 			bToggleEnabled: true,
1011 1036
 			bCurrentlyCollapsed: true,
@@ -1020,6 +1045,7 @@  discard block
 block discarded – undo
1020 1045
 				}
1021 1046
 			]
1022 1047
 		});';
1048
+				}
1023 1049
 			}
1024 1050
 		}
1025 1051
 
@@ -1064,9 +1090,10 @@  discard block
 block discarded – undo
1064 1090
 {
1065 1091
 	global $context, $txt, $scripturl;
1066 1092
 
1067
-	if (!empty($context['saved_successful']))
1068
-		echo '
1093
+	if (!empty($context['saved_successful'])) {
1094
+			echo '
1069 1095
 	<div class="infobox">', $txt['settings_saved'], '</div>';
1096
+	}
1070 1097
 
1071 1098
 	echo '
1072 1099
 	<div id="admincenter">
@@ -1128,8 +1155,9 @@  discard block
 block discarded – undo
1128 1155
 	global $context, $txt;
1129 1156
 
1130 1157
 	// Nothing to do? Brilliant!
1131
-	if (empty($context['package_ftp']))
1132
-		return false;
1158
+	if (empty($context['package_ftp'])) {
1159
+			return false;
1160
+	}
1133 1161
 
1134 1162
 	if (empty($context['package_ftp']['form_elements_only']))
1135 1163
 	{
@@ -1139,19 +1167,21 @@  discard block
 block discarded – undo
1139 1167
 					', $txt['package_ftp_why_file_list'], '
1140 1168
 					<ul style="display: inline;">';
1141 1169
 
1142
-		if (!empty($context['notwritable_files']))
1143
-			foreach ($context['notwritable_files'] as $file)
1170
+		if (!empty($context['notwritable_files'])) {
1171
+					foreach ($context['notwritable_files'] as $file)
1144 1172
 				echo '
1145 1173
 						<li>', $file, '</li>';
1174
+		}
1146 1175
 
1147 1176
 		echo '
1148 1177
 					</ul>';
1149 1178
 
1150
-		if (!$context['server']['is_windows'])
1151
-			echo '
1179
+		if (!$context['server']['is_windows']) {
1180
+					echo '
1152 1181
 					<hr>
1153 1182
 					', $txt['package_chmod_linux'], '<br>
1154 1183
 					<tt># chmod a+w ', implode(' ', $context['notwritable_files']), '</tt>';
1184
+		}
1155 1185
 
1156 1186
 		echo '
1157 1187
 				</div><!-- #need_writable_list -->';
@@ -1164,9 +1194,10 @@  discard block
 block discarded – undo
1164 1194
 					</div>
1165 1195
 				</div>';
1166 1196
 
1167
-	if (!empty($context['package_ftp']['destination']))
1168
-		echo '
1197
+	if (!empty($context['package_ftp']['destination'])) {
1198
+			echo '
1169 1199
 				<form action="', $context['package_ftp']['destination'], '" method="post" accept-charset="', $context['character_set'], '">';
1200
+	}
1170 1201
 
1171 1202
 	echo '
1172 1203
 					<fieldset>
@@ -1199,24 +1230,27 @@  discard block
 block discarded – undo
1199 1230
 					</dl>
1200 1231
 					</fieldset>';
1201 1232
 
1202
-	if (empty($context['package_ftp']['form_elements_only']))
1203
-		echo '
1233
+	if (empty($context['package_ftp']['form_elements_only'])) {
1234
+			echo '
1204 1235
 					<div class="righttext" style="margin: 1ex;">
1205 1236
 						<span id="test_ftp_placeholder_full"></span>
1206 1237
 						<input type="submit" value="', $txt['package_proceed'], '" class="button">
1207 1238
 					</div>';
1239
+	}
1208 1240
 
1209
-	if (!empty($context['package_ftp']['destination']))
1210
-		echo '
1241
+	if (!empty($context['package_ftp']['destination'])) {
1242
+			echo '
1211 1243
 					<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
1212 1244
 				</form>';
1245
+	}
1213 1246
 
1214 1247
 	// Hide the details of the list.
1215
-	if (empty($context['package_ftp']['form_elements_only']))
1216
-		echo '
1248
+	if (empty($context['package_ftp']['form_elements_only'])) {
1249
+			echo '
1217 1250
 				<script>
1218 1251
 					document.getElementById(\'need_writable_list\').style.display = \'none\';
1219 1252
 				</script>';
1253
+	}
1220 1254
 
1221 1255
 	// Quick generate the test button.
1222 1256
 	echo '
@@ -1573,9 +1607,10 @@  discard block
 block discarded – undo
1573 1607
 					<td width="30%">
1574 1608
 						<strong>';
1575 1609
 
1576
-		if (!empty($dir['type']) && ($dir['type'] == 'dir' || $dir['type'] == 'dir_recursive'))
1577
-			echo '
1610
+		if (!empty($dir['type']) && ($dir['type'] == 'dir' || $dir['type'] == 'dir_recursive')) {
1611
+					echo '
1578 1612
 							<span class="generic_icons folder"></span>';
1613
+		}
1579 1614
 
1580 1615
 		echo '
1581 1616
 							', $name, '
@@ -1602,8 +1637,9 @@  discard block
 block discarded – undo
1602 1637
 					</td>
1603 1638
 				</tr>';
1604 1639
 
1605
-		if (!empty($dir['contents']))
1606
-			template_permission_show_contents($name, $dir['contents'], 1);
1640
+		if (!empty($dir['contents'])) {
1641
+					template_permission_show_contents($name, $dir['contents'], 1);
1642
+		}
1607 1643
 	}
1608 1644
 
1609 1645
 	echo '
@@ -1639,13 +1675,14 @@  discard block
 block discarded – undo
1639 1675
 			</fieldset>';
1640 1676
 
1641 1677
 	// Likely to need FTP?
1642
-	if (empty($context['ftp_connected']))
1643
-		echo '
1678
+	if (empty($context['ftp_connected'])) {
1679
+			echo '
1644 1680
 			<p>
1645 1681
 				', $txt['package_file_perms_ftp_details'], ':
1646 1682
 			</p>
1647 1683
 			', template_control_chmod(), '
1648 1684
 			<div class="noticebox">', $txt['package_file_perms_ftp_retain'], '</div>';
1685
+	}
1649 1686
 
1650 1687
 	echo '
1651 1688
 			<span id="test_ftp_placeholder_full"></span>
@@ -1654,9 +1691,10 @@  discard block
 block discarded – undo
1654 1691
 		</div><!-- .windowbg2 -->';
1655 1692
 
1656 1693
 	// Any looks fors we've already done?
1657
-	foreach ($context['look_for'] as $path)
1658
-		echo '
1694
+	foreach ($context['look_for'] as $path) {
1695
+			echo '
1659 1696
 		<input type="hidden" name="back_look[]" value="', $path, '">';
1697
+	}
1660 1698
 
1661 1699
 	echo '
1662 1700
 	</form>
@@ -1698,9 +1736,10 @@  discard block
 block discarded – undo
1698 1736
 					<td class="smalltext" width="30%">' . str_repeat('&nbsp;', $level * 5), '
1699 1737
 					', (!empty($dir['type']) && $dir['type'] == 'dir_recursive') || !empty($dir['list_contents']) ? '<a id="link_' . $cur_ident . '" href="' . $scripturl . '?action=admin;area=packages;sa=perms;find=' . base64_encode($ident . '/' . $name) . ';back_look=' . $context['back_look_data'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '#fol_' . $cur_ident . '" onclick="return expandFolder(\'' . $cur_ident . '\', \'' . addcslashes($ident . '/' . $name, "'\\") . '\');">' : '';
1700 1738
 
1701
-			if (!empty($dir['type']) && ($dir['type'] == 'dir' || $dir['type'] == 'dir_recursive'))
1702
-				echo '
1739
+			if (!empty($dir['type']) && ($dir['type'] == 'dir' || $dir['type'] == 'dir_recursive')) {
1740
+							echo '
1703 1741
 						<span class="generic_icons folder"></span>';
1742
+			}
1704 1743
 
1705 1744
 			echo '
1706 1745
 						', $name, '
@@ -1718,34 +1757,38 @@  discard block
 block discarded – undo
1718 1757
 				</tr>
1719 1758
 				<tr id="insert_div_loc_' . $cur_ident . '" style="display: none;"><td></td></tr>';
1720 1759
 
1721
-			if (!empty($dir['contents']))
1722
-				template_permission_show_contents($ident . '/' . $name, $dir['contents'], $level + 1, !empty($dir['more_files']));
1760
+			if (!empty($dir['contents'])) {
1761
+							template_permission_show_contents($ident . '/' . $name, $dir['contents'], $level + 1, !empty($dir['more_files']));
1762
+			}
1723 1763
 		}
1724 1764
 	}
1725 1765
 
1726 1766
 	// We have more files to show?
1727
-	if ($has_more)
1728
-		echo '
1767
+	if ($has_more) {
1768
+			echo '
1729 1769
 				<tr class="windowbg" id="content_', $js_ident, '_more">
1730 1770
 					<td class="smalltext" width="40%">' . str_repeat('&nbsp;', $level * 5), '
1731 1771
 						&#171; <a href="' . $scripturl . '?action=admin;area=packages;sa=perms;find=' . base64_encode($ident) . ';fileoffset=', ($context['file_offset'] + $context['file_limit']), ';' . $context['session_var'] . '=' . $context['session_id'] . '#fol_' . preg_replace('~[^A-Za-z0-9_\-=:]~', ':-:', $ident) . '">', $txt['package_file_perms_more_files'], '</a> &#187;
1732 1772
 					</td>
1733 1773
 					<td colspan="6"></td>
1734 1774
 				</tr>';
1775
+	}
1735 1776
 
1736 1777
 	if ($drawn_div)
1737 1778
 	{
1738 1779
 		// Hide anything too far down the tree.
1739 1780
 		$isFound = false;
1740
-		foreach ($context['look_for'] as $tree)
1741
-			if (substr($tree, 0, strlen($ident)) == $ident)
1781
+		foreach ($context['look_for'] as $tree) {
1782
+					if (substr($tree, 0, strlen($ident)) == $ident)
1742 1783
 				$isFound = true;
1784
+		}
1743 1785
 
1744
-		if ($level > 1 && !$isFound)
1745
-			echo '
1786
+		if ($level > 1 && !$isFound) {
1787
+					echo '
1746 1788
 		<script>
1747 1789
 			expandFolder(\'', $js_ident, '\', \'\');
1748 1790
 		</script>';
1791
+		}
1749 1792
 	}
1750 1793
 }
1751 1794
 
@@ -1765,11 +1808,12 @@  discard block
 block discarded – undo
1765 1808
 				<h3 class="catbg">', $txt['package_file_perms_applying'], '</h3>
1766 1809
 			</div>';
1767 1810
 
1768
-	if (!empty($context['skip_ftp']))
1769
-		echo '
1811
+	if (!empty($context['skip_ftp'])) {
1812
+			echo '
1770 1813
 			<div class="errorbox">
1771 1814
 				', $txt['package_file_perms_skipping_ftp'], '
1772 1815
 			</div>';
1816
+	}
1773 1817
 
1774 1818
 	// How many have we done?
1775 1819
 	$remaining_items = count($context['method'] == 'individual' ? $context['to_process'] : $context['directory_list']);
@@ -1808,28 +1852,31 @@  discard block
 block discarded – undo
1808 1852
 				<br>';
1809 1853
 
1810 1854
 	// Put out the right hidden data.
1811
-	if ($context['method'] == 'individual')
1812
-		echo '
1855
+	if ($context['method'] == 'individual') {
1856
+			echo '
1813 1857
 				<input type="hidden" name="custom_value" value="', $context['custom_value'], '">
1814 1858
 				<input type="hidden" name="totalItems" value="', $context['total_items'], '">
1815 1859
 				<input type="hidden" name="toProcess" value="', $context['to_process_encode'], '">';
1816
-	else
1817
-		echo '
1860
+	} else {
1861
+			echo '
1818 1862
 				<input type="hidden" name="predefined" value="', $context['predefined_type'], '">
1819 1863
 				<input type="hidden" name="fileOffset" value="', $context['file_offset'], '">
1820 1864
 				<input type="hidden" name="totalItems" value="', $context['total_items'], '">
1821 1865
 				<input type="hidden" name="dirList" value="', $context['directory_list_encode'], '">
1822 1866
 				<input type="hidden" name="specialFiles" value="', $context['special_files_encode'], '">';
1867
+	}
1823 1868
 
1824 1869
 	// Are we not using FTP for whatever reason.
1825
-	if (!empty($context['skip_ftp']))
1826
-		echo '
1870
+	if (!empty($context['skip_ftp'])) {
1871
+			echo '
1827 1872
 				<input type="hidden" name="skip_ftp" value="1">';
1873
+	}
1828 1874
 
1829 1875
 	// Retain state.
1830
-	foreach ($context['back_look_data'] as $path)
1831
-		echo '
1876
+	foreach ($context['back_look_data'] as $path) {
1877
+			echo '
1832 1878
 				<input type="hidden" name="back_look[]" value="', $path, '">';
1879
+	}
1833 1880
 
1834 1881
 	echo '
1835 1882
 				<input type="hidden" name="method" value="', $context['method'], '">
Please login to merge, or discard this patch.
Packages/backups/index.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,9 +1,10 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 // Try to handle it with the upper level index.php. (it should know what to do.)
4
-if (file_exists(dirname(dirname(__FILE__)) . '/index.php'))
4
+if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) {
5 5
 	include (dirname(dirname(__FILE__)) . '/index.php');
6
-else
6
+} else {
7 7
 	exit;
8
+}
8 9
 
9 10
 ?>
10 11
\ No newline at end of file
Please login to merge, or discard this patch.
ssi_examples.php 1 patch
Braces   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -583,8 +583,7 @@  discard block
 block discarded – undo
583 583
 	{
584 584
 		$header = '<?php require("' . ($user_info['is_admin'] ? addslashes(realpath($boarddir . '/SSI.php')) : 'SSI.php') . '"); ?>' . "\n" . $header;
585 585
 		return $header . template_homepage_sample1_html() . $footer;
586
-	}
587
-	else
586
+	} else
588 587
 	{
589 588
 		echo $header;
590 589
 		template_homepage_sample1_php();
@@ -599,9 +598,10 @@  discard block
 block discarded – undo
599 598
 
600 599
 	$topics = ssi_recentTopics(8, null, null, 'array');
601 600
 
602
-	foreach ($topics as $topic)
603
-		echo '
601
+	foreach ($topics as $topic) {
602
+			echo '
604 603
 			<li><a href="', $topic['href'], '">', $topic['subject'], '</a> ', $txt['by'], ' ', $topic['poster']['link'], '</li>';
604
+	}
605 605
 
606 606
 	unset($topics);
607 607
 
Please login to merge, or discard this patch.
Themes/default/MoveTopic.template.php 3 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@
 block discarded – undo
39 39
 
40 40
 		foreach ($category['boards'] as $board)
41 41
 			echo '
42
-									<option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', $board['id'] == $context['current_board'] ? ' disabled' : '', '>', $board['child_level'] > 0 ? str_repeat('==', $board['child_level']-1) . '=&gt; ' : '', $board['name'], '</option>';
42
+									<option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', $board['id'] == $context['current_board'] ? ' disabled' : '', '>', $board['child_level'] > 0 ? str_repeat('==', $board['child_level'] - 1) . '=&gt; ' : '', $board['name'], '</option>';
43 43
 		echo '
44 44
 								</optgroup>';
45 45
 	}
Please login to merge, or discard this patch.
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 	// Stick our "create a redirection topic" template in here...
64 64
 	template_redirect_options('move');
65 65
 
66
-    echo '
66
+	echo '
67 67
 					<input type="submit" value="', $txt['move_topic'], '" onclick="return submitThisOnce(this);" accesskey="s" class="button">
68 68
 				</div><!-- .move_topic -->
69 69
 			</div><!-- .windowbg -->';
@@ -86,9 +86,9 @@  discard block
 block discarded – undo
86 86
  */
87 87
 function template_redirect_options($type)
88 88
 {
89
-    global $txt, $context, $modSettings;
89
+	global $txt, $context, $modSettings;
90 90
 
91
-    echo '
91
+	echo '
92 92
 					<label for="postRedirect">
93 93
 						<input type="checkbox" name="postRedirect" id="postRedirect"', $context['is_approved'] ? ' checked' : '', ' onclick="', $context['is_approved'] ? '' : 'if (this.checked && !confirm(\'' . $txt[$type . '_topic_unapproved_js'] . '\')) return false; ', 'document.getElementById(\'reasonArea\').style.display = this.checked ? \'block\' : \'none\';"> ', $txt['post_redirection'], '.
94 94
 					</label>
Please login to merge, or discard this patch.
Braces   +32 added lines, -23 removed lines patch added patch discarded remove patch
@@ -37,9 +37,10 @@  discard block
 block discarded – undo
37 37
 		echo '
38 38
 								<optgroup label="', $category['name'], '">';
39 39
 
40
-		foreach ($category['boards'] as $board)
41
-			echo '
40
+		foreach ($category['boards'] as $board) {
41
+					echo '
42 42
 									<option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', $board['id'] == $context['current_board'] ? ' disabled' : '', '>', $board['child_level'] > 0 ? str_repeat('==', $board['child_level']-1) . '=&gt; ' : '', $board['name'], '</option>';
43
+		}
43 44
 		echo '
44 45
 								</optgroup>';
45 46
 	}
@@ -70,9 +71,10 @@  discard block
 block discarded – undo
70 71
 				</div><!-- .move_topic -->
71 72
 			</div><!-- .windowbg -->';
72 73
 
73
-	if ($context['back_to_topic'])
74
-		echo '
74
+	if ($context['back_to_topic']) {
75
+			echo '
75 76
 			<input type="hidden" name="goback" value="1">';
77
+	}
76 78
 
77 79
 	echo '
78 80
 			<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
@@ -125,10 +127,10 @@  discard block
 block discarded – undo
125 127
 									<option value="86400">', $txt['two_months'], '</option>
126 128
 								</select>
127 129
 							</dd>';
128
-	}
129
-	else
130
-		echo '
130
+	} else {
131
+			echo '
131 132
 							<input type="hidden" name="redirect_expires" value="0">';
133
+	}
132 134
 
133 135
 	echo '
134 136
 						</dl>
@@ -207,9 +209,10 @@  discard block
 block discarded – undo
207 209
 			echo '
208 210
 							<optgroup label="', $cat['name'], '">';
209 211
 
210
-			foreach ($cat['boards'] as $board)
211
-				echo '
212
+			foreach ($cat['boards'] as $board) {
213
+							echo '
212 214
 								<option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', '>', $board['child_level'] > 0 ? str_repeat('==', $board['child_level'] - 1) . '=&gt;' : '', ' ', $board['name'], '</option>';
215
+			}
213 216
 
214 217
 			echo '
215 218
 							</optgroup>';
@@ -219,9 +222,9 @@  discard block
 block discarded – undo
219 222
 						<input type="hidden" name="from" value="' . $context['origin_topic'] . '">
220 223
 						<input type="submit" value="', $txt['go'], '" class="button">
221 224
 					</form>';
225
+	} else {
226
+			echo $txt['target_below'];
222 227
 	}
223
-	else
224
-		echo $txt['target_below'];
225 228
 
226 229
 	echo '		</h4>
227 230
 			</div><!-- .title_bar -->
@@ -239,12 +242,13 @@  discard block
 block discarded – undo
239 242
 
240 243
 		$merge_button = create_button('merge', 'merge', '');
241 244
 
242
-		foreach ($context['topics'] as $topic)
243
-			echo '
245
+		foreach ($context['topics'] as $topic) {
246
+					echo '
244 247
 						<li>
245 248
 							<a href="', $scripturl, '?action=mergetopics;sa=options;board=', $context['current_board'], '.0;from=', $context['origin_topic'], ';to=', $topic['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $merge_button, '</a>
246 249
 							<a href="', $scripturl, '?topic=', $topic['id'], '.0" target="_blank" rel="noopener">', $topic['subject'], '</a> ', $txt['started_by'], ' ', $topic['poster']['link'], '
247 250
 						</li>';
251
+		}
248 252
 
249 253
 		echo '
250 254
 					</ul>
@@ -255,9 +259,10 @@  discard block
 block discarded – undo
255 259
 				</div>';
256 260
 	}
257 261
 	// Just a nice "There aren't any topics" message
258
-	else
259
-		echo '
262
+	else {
263
+			echo '
260 264
 				<div class="windowbg2">', $txt['topic_alert_none'], '</div>';
265
+	}
261 266
 
262 267
 	echo '
263 268
 				<br>
@@ -307,8 +312,8 @@  discard block
 block discarded – undo
307 312
 				</thead>
308 313
 				<tbody>';
309 314
 
310
-	foreach ($context['topics'] as $topic)
311
-		echo '
315
+	foreach ($context['topics'] as $topic) {
316
+			echo '
312 317
 					<tr class="windowbg">
313 318
 						<td>
314 319
 							<input type="checkbox" name="topics[]" value="' . $topic['id'] . '" checked>
@@ -328,6 +333,7 @@  discard block
 block discarded – undo
328 333
 							<input type="checkbox" name="notifications[]" value="' . $topic['id'] . '" checked>
329 334
 						</td>
330 335
 					</tr>';
336
+	}
331 337
 	echo '
332 338
 				</tbody>
333 339
 			</table>
@@ -337,9 +343,10 @@  discard block
 block discarded – undo
337 343
 					<legend>', $txt['merge_select_subject'], '</legend>
338 344
 					<select name="subject" onchange="this.form.custom_subject.style.display = (this.options[this.selectedIndex].value != 0) ? \'none\': \'\' ;">';
339 345
 
340
-	foreach ($context['topics'] as $topic)
341
-		echo '
346
+	foreach ($context['topics'] as $topic) {
347
+			echo '
342 348
 						<option value="', $topic['id'], '"' . ($topic['selected'] ? ' selected' : '') . '>', $topic['subject'], '</option>';
349
+	}
343 350
 	echo '
344 351
 						<option value="0">', $txt['merge_custom_subject'], ':</option>
345 352
 					</select>
@@ -358,11 +365,12 @@  discard block
 block discarded – undo
358 365
 					<legend>', $txt['merge_select_target_board'], '</legend>
359 366
 					<ul>';
360 367
 
361
-		foreach ($context['boards'] as $board)
362
-			echo '
368
+		foreach ($context['boards'] as $board) {
369
+					echo '
363 370
 						<li>
364 371
 							<input type="radio" name="board" value="' . $board['id'] . '"' . ($board['selected'] ? ' checked' : '') . '> ' . $board['name'] . '
365 372
 						</li>';
373
+		}
366 374
 		echo '
367 375
 					</ul>
368 376
 				</fieldset>';
@@ -374,11 +382,12 @@  discard block
 block discarded – undo
374 382
 					<legend>' . $txt['merge_select_poll'] . '</legend>
375 383
 					<ul>';
376 384
 
377
-		foreach ($context['polls'] as $poll)
378
-			echo '
385
+		foreach ($context['polls'] as $poll) {
386
+					echo '
379 387
 						<li>
380 388
 							<input type="radio" name="poll" value="' . $poll['id'] . '"' . ($poll['selected'] ? ' checked' : '') . '> ' . $poll['question'] . ' (' . $txt['topic'] . ': <a href="' . $scripturl . '?topic=' . $poll['topic']['id'] . '.0" target="_blank" rel="noopener">' . $poll['topic']['subject'] . '</a>)
381 389
 						</li>';
390
+		}
382 391
 		echo '
383 392
 						<li>
384 393
 							<input type="radio" name="poll" value="-1"> (' . $txt['merge_no_poll'] . ')
Please login to merge, or discard this patch.