Completed
Pull Request — release-2.1 (#3761)
by Rick
07:38
created
avatars/index.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,8 @@
 block discarded – undo
12 12
 	header('Location: ' . $boardurl);
13 13
 }
14 14
 // Can't find it... just forget it.
15
-else
15
+else {
16 16
 	exit;
17
+}
17 18
 
18 19
 ?>
19 20
\ No newline at end of file
Please login to merge, or discard this patch.
cache/index.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,8 @@
 block discarded – undo
12 12
 	header('Location: ' . $boardurl);
13 13
 }
14 14
 // Can't find it... just forget it.
15
-else
15
+else {
16 16
 	exit;
17
+}
17 18
 
18 19
 ?>
19 20
\ No newline at end of file
Please login to merge, or discard this patch.
attachments/index.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,8 @@
 block discarded – undo
12 12
 	header('Location: ' . $boardurl);
13 13
 }
14 14
 // Can't find it... just forget it.
15
-else
15
+else {
16 16
 	exit;
17
+}
17 18
 
18 19
 ?>
19 20
\ No newline at end of file
Please login to merge, or discard this patch.
Themes/default/Display.template.php 1 patch
Braces   +221 added lines, -151 removed lines patch added patch discarded remove patch
@@ -51,11 +51,13 @@  discard block
 block discarded – undo
51 51
 				<p>';
52 52
 
53 53
 		// Show just numbers...?
54
-		if ($settings['display_who_viewing'] == 1)
55
-				echo count($context['view_members']), ' ', count($context['view_members']) == 1 ? $txt['who_member'] : $txt['members'];
54
+		if ($settings['display_who_viewing'] == 1) {
55
+						echo count($context['view_members']), ' ', count($context['view_members']) == 1 ? $txt['who_member'] : $txt['members'];
56
+		}
56 57
 		// Or show the actual people viewing the topic?
57
-		else
58
-			echo empty($context['view_members_list']) ? '0 ' . $txt['members'] : implode(', ', $context['view_members_list']) . ((empty($context['view_num_hidden']) || $context['can_moderate_forum']) ? '' : ' (+ ' . $context['view_num_hidden'] . ' ' . $txt['hidden'] . ')');
58
+		else {
59
+					echo empty($context['view_members_list']) ? '0 ' . $txt['members'] : implode(', ', $context['view_members_list']) . ((empty($context['view_num_hidden']) || $context['can_moderate_forum']) ? '' : ' (+ ' . $context['view_num_hidden'] . ' ' . $txt['hidden'] . ')');
60
+		}
59 61
 
60 62
 		// Now show how many guests are here too.
61 63
 		echo $txt['who_and'], $context['view_num_guests'], ' ', $context['view_num_guests'] == 1 ? $txt['guest'] : $txt['guests'], $txt['who_viewing_topic'], '
@@ -93,10 +95,11 @@  discard block
 block discarded – undo
93 95
 						<dt class="', $option['voted_this'] ? ' voted' : '', '">', $option['option'], '</dt>
94 96
 						<dd class="statsbar', $option['voted_this'] ? ' voted' : '', '">';
95 97
 
96
-				if ($context['allow_results_view'])
97
-					echo '
98
+				if ($context['allow_results_view']) {
99
+									echo '
98 100
 							', $option['bar_ndt'], '
99 101
 							<span class="percentage">', $option['votes'], ' (', $option['percent'], '%)</span>';
102
+				}
100 103
 
101 104
 				echo '
102 105
 						</dd>';
@@ -105,9 +108,10 @@  discard block
 block discarded – undo
105 108
 			echo '
106 109
 					</dl>';
107 110
 
108
-			if ($context['allow_results_view'])
109
-				echo '
111
+			if ($context['allow_results_view']) {
112
+							echo '
110 113
 						<p><strong>', $txt['poll_total_voters'], ':</strong> ', $context['poll']['total_votes'], '</p>';
114
+			}
111 115
 		}
112 116
 		// They are allowed to vote! Go to it!
113 117
 		else
@@ -116,17 +120,19 @@  discard block
 block discarded – undo
116 120
 						<form action="', $scripturl, '?action=vote;topic=', $context['current_topic'], '.', $context['start'], ';poll=', $context['poll']['id'], '" method="post" accept-charset="', $context['character_set'], '">';
117 121
 
118 122
 			// Show a warning if they are allowed more than one option.
119
-			if ($context['poll']['allowed_warning'])
120
-				echo '
123
+			if ($context['poll']['allowed_warning']) {
124
+							echo '
121 125
 							<p class="smallpadding">', $context['poll']['allowed_warning'], '</p>';
126
+			}
122 127
 
123 128
 			echo '
124 129
 							<ul class="options">';
125 130
 
126 131
 			// Show each option with its button - a radio likely.
127
-			foreach ($context['poll']['options'] as $option)
128
-				echo '
132
+			foreach ($context['poll']['options'] as $option) {
133
+							echo '
129 134
 								<li>', $option['vote_button'], ' <label for="', $option['id'], '">', $option['option'], '</label></li>';
135
+			}
130 136
 
131 137
 			echo '
132 138
 							</ul>
@@ -138,9 +144,10 @@  discard block
 block discarded – undo
138 144
 		}
139 145
 
140 146
 		// Is the clock ticking?
141
-		if (!empty($context['poll']['expire_time']))
142
-			echo '
147
+		if (!empty($context['poll']['expire_time'])) {
148
+					echo '
143 149
 						<p><strong>', ($context['poll']['is_expired'] ? $txt['poll_expired_on'] : $txt['poll_expires_on']), ':</strong> ', $context['poll']['expire_time'], '</p>';
150
+		}
144 151
 
145 152
 		echo '
146 153
 					</div>
@@ -170,11 +177,13 @@  discard block
 block discarded – undo
170 177
 					<li>
171 178
 						<b class="event_title"><a href="', $scripturl, '?action=calendar;event=', $event['id'], '">', $event['title'], '</a></b>';
172 179
 
173
-			if ($event['can_edit'])
174
-				echo ' <a href="' . $event['modify_href'] . '"><span class="generic_icons calendar_modify" title="', $txt['calendar_edit'], '"></span></a>';
180
+			if ($event['can_edit']) {
181
+							echo ' <a href="' . $event['modify_href'] . '"><span class="generic_icons calendar_modify" title="', $txt['calendar_edit'], '"></span></a>';
182
+			}
175 183
 
176
-			if ($event['can_export'])
177
-				echo ' <a href="' . $event['export_href'] . '"><span class="generic_icons calendar_export" title="', $txt['calendar_export'], '"></span></a>';
184
+			if ($event['can_export']) {
185
+							echo ' <a href="' . $event['export_href'] . '"><span class="generic_icons calendar_export" title="', $txt['calendar_export'], '"></span></a>';
186
+			}
178 187
 
179 188
 			echo '
180 189
 						<br>';
@@ -182,14 +191,14 @@  discard block
 block discarded – undo
182 191
 			if (!empty($event['allday']))
183 192
 			{
184 193
 				echo '<time datetime="' . $event['start_iso_gmdate'] . '">', trim($event['start_date_local']), '</time>', ($event['start_date'] != $event['end_date']) ? ' &ndash; <time datetime="' . $event['end_iso_gmdate'] . '">' . trim($event['end_date_local']) . '</time>' : '';
185
-			}
186
-			else
194
+			} else
187 195
 			{
188 196
 				// Display event info relative to user's local timezone
189 197
 				echo '<time datetime="' . $event['start_iso_gmdate'] . '">', trim($event['start_date_local']), ', ', trim($event['start_time_local']), '</time> &ndash; <time datetime="' . $event['end_iso_gmdate'] . '">';
190 198
 
191
-				if ($event['start_date_local'] != $event['end_date_local'])
192
-					echo trim($event['end_date_local']) . ', ';
199
+				if ($event['start_date_local'] != $event['end_date_local']) {
200
+									echo trim($event['end_date_local']) . ', ';
201
+				}
193 202
 
194 203
 				echo trim($event['end_time_local']);
195 204
 
@@ -198,23 +207,27 @@  discard block
 block discarded – undo
198 207
 				{
199 208
 					echo '</time> (<time datetime="' . $event['start_iso_gmdate'] . '">';
200 209
 
201
-					if ($event['start_date_orig'] != $event['start_date_local'] || $event['end_date_orig'] != $event['end_date_local'] || $event['start_date_orig'] != $event['end_date_orig'])
202
-						echo trim($event['start_date_orig']), ', ';
210
+					if ($event['start_date_orig'] != $event['start_date_local'] || $event['end_date_orig'] != $event['end_date_local'] || $event['start_date_orig'] != $event['end_date_orig']) {
211
+											echo trim($event['start_date_orig']), ', ';
212
+					}
203 213
 
204 214
 					echo trim($event['start_time_orig']), '</time> &ndash; <time datetime="' . $event['end_iso_gmdate'] . '">';
205 215
 
206
-					if ($event['start_date_orig'] != $event['end_date_orig'])
207
-						echo trim($event['end_date_orig']) . ', ';
216
+					if ($event['start_date_orig'] != $event['end_date_orig']) {
217
+											echo trim($event['end_date_orig']) . ', ';
218
+					}
208 219
 
209 220
 					echo trim($event['end_time_orig']), ' ', $event['tz_abbrev'], '</time>)';
210 221
 				}
211 222
 				// Event is scheduled in the user's own timezone? Let 'em know, just to avoid confusion
212
-				else
213
-					echo ' ', $event['tz_abbrev'], '</time>';
223
+				else {
224
+									echo ' ', $event['tz_abbrev'], '</time>';
225
+				}
214 226
 			}
215 227
 
216
-			if (!empty($event['location']))
217
-				echo '<br>', $event['location'];
228
+			if (!empty($event['location'])) {
229
+							echo '<br>', $event['location'];
230
+			}
218 231
 
219 232
 			echo '
220 233
 					</li>';
@@ -252,8 +265,9 @@  discard block
 block discarded – undo
252 265
 	$context['removableMessageIDs'] = array();
253 266
 
254 267
 	// Get all the messages...
255
-	while ($message = $context['get_message']())
256
-		template_single_post($message);
268
+	while ($message = $context['get_message']()) {
269
+			template_single_post($message);
270
+	}
257 271
 
258 272
 	echo '
259 273
 				</form>
@@ -290,8 +304,9 @@  discard block
 block discarded – undo
290 304
 			<div id="display_jump_to">&nbsp;</div>';
291 305
 
292 306
 	// Show quickreply
293
-	if ($context['can_reply'])
294
-	template_quickreply();
307
+	if ($context['can_reply']) {
308
+		template_quickreply();
309
+	}
295 310
 
296 311
 	// User action pop on mobile screen (or actually small screen), this uses responsive css does not check mobile device.
297 312
 	echo '
@@ -304,8 +319,8 @@  discard block
 block discarded – undo
304 319
 			</div>';
305 320
 
306 321
 	// Show the moderation button & pop only if user can moderate
307
-	if ($context['can_moderate_forum'] || $context['user']['is_mod'])
308
-		echo '
322
+	if ($context['can_moderate_forum'] || $context['user']['is_mod']) {
323
+			echo '
309 324
 			<div id="mobile_moderation" class="popup_container">
310 325
 				<div class="popup_window description">
311 326
 					<div class="popup_heading">', $txt['mobile_moderation'],'
@@ -315,6 +330,7 @@  discard block
 block discarded – undo
315 330
 					</div>
316 331
 				</div>
317 332
 			</div>';
333
+	}
318 334
 
319 335
 		echo '
320 336
 				<script>';
@@ -438,9 +454,10 @@  discard block
 block discarded – undo
438 454
 						});
439 455
 					}';
440 456
 
441
-	if (!empty($context['ignoredMsgs']))
442
-		echo '
457
+	if (!empty($context['ignoredMsgs'])) {
458
+			echo '
443 459
 					ignore_toggles([', implode(', ', $context['ignoredMsgs']), '], ', JavaScriptEscape($txt['show_ignore_user_post']), ');';
460
+	}
444 461
 
445 462
 	echo '
446 463
 				</script>';
@@ -457,8 +474,9 @@  discard block
 block discarded – undo
457 474
 
458 475
 	$ignoring = false;
459 476
 
460
-	if ($message['can_remove'])
461
-		$context['removableMessageIDs'][] = $message['id'];
477
+	if ($message['can_remove']) {
478
+			$context['removableMessageIDs'][] = $message['id'];
479
+	}
462 480
 
463 481
 	// Are we ignoring this message?
464 482
 	if (!empty($message['is_ignored']))
@@ -484,9 +502,10 @@  discard block
 block discarded – undo
484 502
 							<div class="custom_fields_above_member">
485 503
 								<ul class="nolist">';
486 504
 
487
-		foreach ($message['custom_fields']['above_member'] as $custom)
488
-			echo '
505
+		foreach ($message['custom_fields']['above_member'] as $custom) {
506
+					echo '
489 507
 									<li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>';
508
+		}
490 509
 
491 510
 		echo '
492 511
 								</ul>
@@ -497,9 +516,10 @@  discard block
 block discarded – undo
497 516
 									<h4>';
498 517
 
499 518
 	// Show online and offline buttons?
500
-	if (!empty($modSettings['onlineEnable']) && !$message['member']['is_guest'])
501
-		echo '
519
+	if (!empty($modSettings['onlineEnable']) && !$message['member']['is_guest']) {
520
+			echo '
502 521
 								', $context['can_send_pm'] ? '<a href="' . $message['member']['online']['href'] . '" title="' . $message['member']['online']['label'] . '">' : '', '<span class="' . ($message['member']['online']['is_online'] == 1 ? 'on' : 'off') . '" title="' . $message['member']['online']['text'] . '"></span>', $context['can_send_pm'] ? '</a>' : '';
522
+	}
503 523
 
504 524
 
505 525
 	// Show a link to the member's profile.
@@ -512,51 +532,59 @@  discard block
 block discarded – undo
512 532
 
513 533
 
514 534
 	// Show the user's avatar.
515
-	if (!empty($modSettings['show_user_images']) && empty($options['show_no_avatars']) && !empty($message['member']['avatar']['image']))
516
-		echo '
535
+	if (!empty($modSettings['show_user_images']) && empty($options['show_no_avatars']) && !empty($message['member']['avatar']['image'])) {
536
+			echo '
517 537
 								<li class="avatar">
518 538
 									<a href="', $message['member']['href'], '">', $message['member']['avatar']['image'], '</a>
519 539
 								</li>';
540
+	}
520 541
 
521 542
 	// Are there any custom fields below the avatar?
522
-	if (!empty($message['custom_fields']['below_avatar']))
523
-		foreach ($message['custom_fields']['below_avatar'] as $custom)
543
+	if (!empty($message['custom_fields']['below_avatar'])) {
544
+			foreach ($message['custom_fields']['below_avatar'] as $custom)
524 545
 			echo '
525 546
 								<li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>';
547
+	}
526 548
 
527 549
 	// Show the post group icons, but not for guests.
528
-	if (!$message['member']['is_guest'])
529
-		echo '
550
+	if (!$message['member']['is_guest']) {
551
+			echo '
530 552
 								<li class="icons">', $message['member']['group_icons'], '</li>';
553
+	}
531 554
 
532 555
 	// Show the member's primary group (like 'Administrator') if they have one.
533
-	if (!empty($message['member']['group']))
534
-		echo '
556
+	if (!empty($message['member']['group'])) {
557
+			echo '
535 558
 								<li class="membergroup">', $message['member']['group'], '</li>';
559
+	}
536 560
 
537 561
 	// Show the member's custom title, if they have one.
538
-	if (!empty($message['member']['title']))
539
-		echo '
562
+	if (!empty($message['member']['title'])) {
563
+			echo '
540 564
 								<li class="title">', $message['member']['title'], '</li>';
565
+	}
541 566
 
542 567
 	// Don't show these things for guests.
543 568
 	if (!$message['member']['is_guest'])
544 569
 	{
545 570
 
546 571
 		// Show the post group if and only if they have no other group or the option is on, and they are in a post group.
547
-		if ((empty($modSettings['hide_post_group']) || empty($message['member']['group'])) && !empty($message['member']['post_group']))
548
-			echo '
572
+		if ((empty($modSettings['hide_post_group']) || empty($message['member']['group'])) && !empty($message['member']['post_group'])) {
573
+					echo '
549 574
 								<li class="postgroup">', $message['member']['post_group'], '</li>';
575
+		}
550 576
 
551 577
 		// Show how many posts they have made.
552
-		if (!isset($context['disabled_fields']['posts']))
553
-			echo '
578
+		if (!isset($context['disabled_fields']['posts'])) {
579
+					echo '
554 580
 								<li class="postcount">', $txt['member_postcount'], ': ', $message['member']['posts'], '</li>';
581
+		}
555 582
 
556 583
 		// Show their personal text?
557
-		if (!empty($modSettings['show_blurb']) && !empty($message['member']['blurb']))
558
-			echo '
584
+		if (!empty($modSettings['show_blurb']) && !empty($message['member']['blurb'])) {
585
+					echo '
559 586
 								<li class="blurb">', $message['member']['blurb'], '</li>';
587
+		}
560 588
 
561 589
 		// Any custom fields to show as icons?
562 590
 		if (!empty($message['custom_fields']['icons']))
@@ -565,9 +593,10 @@  discard block
 block discarded – undo
565 593
 								<li class="im_icons">
566 594
 									<ol>';
567 595
 
568
-			foreach ($message['custom_fields']['icons'] as $custom)
569
-				echo '
596
+			foreach ($message['custom_fields']['icons'] as $custom) {
597
+							echo '
570 598
 										<li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>';
599
+			}
571 600
 
572 601
 			echo '
573 602
 									</ol>
@@ -582,19 +611,22 @@  discard block
 block discarded – undo
582 611
 									<ol class="profile_icons">';
583 612
 
584 613
 			// Don't show an icon if they haven't specified a website.
585
-			if (!empty($message['member']['website']['url']) && !isset($context['disabled_fields']['website']))
586
-				echo '
614
+			if (!empty($message['member']['website']['url']) && !isset($context['disabled_fields']['website'])) {
615
+							echo '
587 616
 										<li><a href="', $message['member']['website']['url'], '" title="' . $message['member']['website']['title'] . '" target="_blank" class="new_win">', ($settings['use_image_buttons'] ? '<span class="generic_icons www centericon" title="' . $message['member']['website']['title'] . '"></span>' : $txt['www']), '</a></li>';
617
+			}
588 618
 
589 619
 			// Since we know this person isn't a guest, you *can* message them.
590
-			if ($context['can_send_pm'])
591
-				echo '
620
+			if ($context['can_send_pm']) {
621
+							echo '
592 622
 										<li><a href="', $scripturl, '?action=pm;sa=send;u=', $message['member']['id'], '" title="', $message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline'], '">', $settings['use_image_buttons'] ? '<span class="generic_icons im_' . ($message['member']['online']['is_online'] ? 'on' : 'off') . ' centericon" title="' . ($message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline']) . '"></span> ' : ($message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline']), '</a></li>';
623
+			}
593 624
 
594 625
 			// Show the email if necessary
595
-			if (!empty($message['member']['email']) && $message['member']['show_email'])
596
-				echo '
626
+			if (!empty($message['member']['email']) && $message['member']['show_email']) {
627
+							echo '
597 628
 										<li class="email"><a href="mailto:' . $message['member']['email'] . '" rel="nofollow">', ($settings['use_image_buttons'] ? '<span class="generic_icons mail centericon" title="' . $txt['email'] . '"></span>' : $txt['email']), '</a></li>';
629
+			}
598 630
 
599 631
 				echo '
600 632
 									</ol>
@@ -602,48 +634,56 @@  discard block
 block discarded – undo
602 634
 		}
603 635
 
604 636
 		// Any custom fields for standard placement?
605
-		if (!empty($message['custom_fields']['standard']))
606
-			foreach ($message['custom_fields']['standard'] as $custom)
637
+		if (!empty($message['custom_fields']['standard'])) {
638
+					foreach ($message['custom_fields']['standard'] as $custom)
607 639
 				echo '
608 640
 								<li class="custom ', $custom['col_name'] ,'">', $custom['title'], ': ', $custom['value'], '</li>';
641
+		}
609 642
 
610 643
 	}
611 644
 	// Otherwise, show the guest's email.
612
-	elseif (!empty($message['member']['email']) && $message['member']['show_email'])
613
-		echo '
645
+	elseif (!empty($message['member']['email']) && $message['member']['show_email']) {
646
+			echo '
614 647
 								<li class="email"><a href="mailto:' . $message['member']['email'] . '" rel="nofollow">', ($settings['use_image_buttons'] ? '<span class="generic_icons mail centericon" title="' . $txt['email'] . '"></span>' : $txt['email']), '</a></li>';
648
+	}
615 649
 
616 650
 	// Show the IP to this user for this post - because you can moderate?
617
-	if (!empty($context['can_moderate_forum']) && !empty($message['member']['ip']))
618
-		echo '
651
+	if (!empty($context['can_moderate_forum']) && !empty($message['member']['ip'])) {
652
+			echo '
619 653
 								<li class="poster_ip"><a href="', $scripturl, '?action=', !empty($message['member']['is_guest']) ? 'trackip' : 'profile;area=tracking;sa=ip;u=' . $message['member']['id'], ';searchip=', $message['member']['ip'], '">', $message['member']['ip'], '</a> <a href="', $scripturl, '?action=helpadmin;help=see_admin_ip" onclick="return reqOverlayDiv(this.href);" class="help">(?)</a></li>';
654
+	}
620 655
 
621 656
 	// Or, should we show it because this is you?
622
-	elseif ($message['can_see_ip'])
623
-		echo '
657
+	elseif ($message['can_see_ip']) {
658
+			echo '
624 659
 								<li class="poster_ip"><a href="', $scripturl, '?action=helpadmin;help=see_member_ip" onclick="return reqOverlayDiv(this.href);" class="help">', $message['member']['ip'], '</a></li>';
660
+	}
625 661
 
626 662
 	// Okay, are you at least logged in? Then we can show something about why IPs are logged...
627
-	elseif (!$context['user']['is_guest'])
628
-		echo '
663
+	elseif (!$context['user']['is_guest']) {
664
+			echo '
629 665
 								<li class="poster_ip"><a href="', $scripturl, '?action=helpadmin;help=see_member_ip" onclick="return reqOverlayDiv(this.href);" class="help">', $txt['logged'], '</a></li>';
666
+	}
630 667
 
631 668
 	// Otherwise, you see NOTHING!
632
-	else
633
-		echo '
669
+	else {
670
+			echo '
634 671
 								<li class="poster_ip">', $txt['logged'], '</li>';
672
+	}
635 673
 
636 674
 	// Are we showing the warning status?
637 675
 	// Don't show these things for guests.
638
-	if (!$message['member']['is_guest'] && $message['member']['can_see_warning'])
639
-		echo '
676
+	if (!$message['member']['is_guest'] && $message['member']['can_see_warning']) {
677
+			echo '
640 678
 								<li class="warning">', $context['can_issue_warning'] ? '<a href="' . $scripturl . '?action=profile;area=issuewarning;u=' . $message['member']['id'] . '">' : '', '<span class="generic_icons warning_', $message['member']['warning_status'], '"></span> ', $context['can_issue_warning'] ? '</a>' : '', '<span class="warn_', $message['member']['warning_status'], '">', $txt['warn_' . $message['member']['warning_status']], '</span></li>';
679
+	}
641 680
 
642 681
 	// Are there any custom fields to show at the bottom of the poster info?
643
-	if (!empty($message['custom_fields']['bottom_poster']))
644
-		foreach ($message['custom_fields']['bottom_poster'] as $custom)
682
+	if (!empty($message['custom_fields']['bottom_poster'])) {
683
+			foreach ($message['custom_fields']['bottom_poster'] as $custom)
645 684
 			echo '
646 685
 									<li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>';
686
+	}
647 687
 
648 688
 	// Poster info ends.
649 689
 	echo '
@@ -672,9 +712,10 @@  discard block
 block discarded – undo
672 712
 	echo '
673 713
 									<span class="smalltext modified" id="modified_', $message['id'], '">';
674 714
 
675
-	if (!empty($modSettings['show_modify']) && !empty($message['modified']['name']))
676
-		echo
715
+	if (!empty($modSettings['show_modify']) && !empty($message['modified']['name'])) {
716
+			echo
677 717
 										$message['modified']['last_edit_text'];
718
+	}
678 719
 
679 720
 	echo '
680 721
 									</span>';
@@ -685,22 +726,24 @@  discard block
 block discarded – undo
685 726
 							</div>';
686 727
 
687 728
 	// Ignoring this user? Hide the post.
688
-	if ($ignoring)
689
-		echo '
729
+	if ($ignoring) {
730
+			echo '
690 731
 							<div id="msg_', $message['id'], '_ignored_prompt">
691 732
 								', $txt['ignoring_user'], '
692 733
 								<a href="#" id="msg_', $message['id'], '_ignored_link" style="display: none;">', $txt['show_ignore_user_post'], '</a>
693 734
 							</div>';
735
+	}
694 736
 
695 737
 	// Show the post itself, finally!
696 738
 	echo '
697 739
 							<div class="post">';
698 740
 
699
-	if (!$message['approved'] && $message['member']['id'] != 0 && $message['member']['id'] == $context['user']['id'])
700
-		echo '
741
+	if (!$message['approved'] && $message['member']['id'] != 0 && $message['member']['id'] == $context['user']['id']) {
742
+			echo '
701 743
 								<div class="approve_post">
702 744
 									', $txt['post_awaiting_approval'], '
703 745
 								</div>';
746
+	}
704 747
 	echo '
705 748
 								<div class="inner" data-msgid="', $message['id'], '" id="msg_', $message['id'], '"', $ignoring ? ' style="display:none;"' : '', '>', $message['body'], '</div>
706 749
 							</div>';
@@ -717,9 +760,9 @@  discard block
 block discarded – undo
717 760
 		foreach ($message['attachment'] as $attachment)
718 761
 		{
719 762
 			// Do we want this attachment to not be showed here?
720
-			if (!empty($modSettings['dont_show_attach_under_post']) && !empty($context['show_attach_under_post'][$attachment['id']]))
721
-				continue;
722
-			elseif (!$div_output)
763
+			if (!empty($modSettings['dont_show_attach_under_post']) && !empty($context['show_attach_under_post'][$attachment['id']])) {
764
+							continue;
765
+			} elseif (!$div_output)
723 766
 			{
724 767
 				$div_output = true;
725 768
 
@@ -735,9 +778,10 @@  discard block
 block discarded – undo
735 778
 								<fieldset>
736 779
 									<legend>', $txt['attach_awaiting_approve'];
737 780
 
738
-				if ($context['can_approve'])
739
-					echo '
781
+				if ($context['can_approve']) {
782
+									echo '
740 783
 										&nbsp;[<a href="', $scripturl, '?action=attachapprove;sa=all;mid=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['approve_all'], '</a>]';
784
+				}
741 785
 
742 786
 				echo '
743 787
 									</legend>';
@@ -751,12 +795,13 @@  discard block
 block discarded – undo
751 795
 				echo '
752 796
 										<div class="attachments_top">';
753 797
 
754
-				if ($attachment['thumbnail']['has_thumb'])
755
-					echo '
798
+				if ($attachment['thumbnail']['has_thumb']) {
799
+									echo '
756 800
 											<a href="', $attachment['href'], ';image" id="link_', $attachment['id'], '" onclick="', $attachment['thumbnail']['javascript'], '"><img src="', $attachment['thumbnail']['href'], '" alt="" id="thumb_', $attachment['id'], '" class="atc_img"></a>';
757
-				else
758
-					echo '
801
+				} else {
802
+									echo '
759 803
 											<img src="' . $attachment['href'] . ';image" alt="" width="' . $attachment['width'] . '" height="' . $attachment['height'] . '" class="atc_img">';
804
+				}
760 805
 
761 806
 				echo '
762 807
 										</div>';
@@ -766,9 +811,10 @@  discard block
 block discarded – undo
766 811
 										<div class="attachments_bot">
767 812
 											<a href="' . $attachment['href'] . '"><img src="' . $settings['images_url'] . '/icons/clip.png" class="centericon" alt="*">&nbsp;' . $attachment['name'] . '</a> ';
768 813
 
769
-			if (!$attachment['is_approved'] && $context['can_approve'])
770
-				echo '
814
+			if (!$attachment['is_approved'] && $context['can_approve']) {
815
+							echo '
771 816
 											[<a href="', $scripturl, '?action=attachapprove;sa=approve;aid=', $attachment['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['approve'], '</a>]&nbsp;|&nbsp;[<a href="', $scripturl, '?action=attachapprove;sa=reject;aid=', $attachment['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['delete'], '</a>] ';
817
+			}
772 818
 			echo '
773 819
 											<br>', $attachment['size'], ($attachment['is_image'] ? ', ' . $attachment['real_width'] . 'x' . $attachment['real_height'] . '<br>' . sprintf($txt['attach_viewed'], $attachment['downloads']) : '<br>' . sprintf($txt['attach_downloaded'], $attachment['downloads'])), '
774 820
 										</div>';
@@ -777,33 +823,38 @@  discard block
 block discarded – undo
777 823
 									</div>';
778 824
 
779 825
 			// Next attachment line ?
780
-			if (++$i % $attachments_per_line === 0)
781
-				echo '
826
+			if (++$i % $attachments_per_line === 0) {
827
+							echo '
782 828
 									<br>';
829
+			}
783 830
 		}
784 831
 
785 832
 		// If we had unapproved attachments clean up.
786
-		if ($last_approved_state == 0)
787
-			echo '
833
+		if ($last_approved_state == 0) {
834
+					echo '
788 835
 								</fieldset>';
836
+		}
789 837
 
790 838
 		// Only do this if we output a div above - otherwise it'll break things
791
-		if ($div_output)
792
-			echo '
839
+		if ($div_output) {
840
+					echo '
793 841
 							</div>';
842
+		}
794 843
 	}
795 844
 
796 845
 	// And stuff below the attachments.
797
-	if ($context['can_report_moderator'] || !empty($context['can_see_likes']) || !empty($context['can_like']) || $message['can_approve'] || $message['can_unapprove'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'] || $context['can_quote'])
798
-	echo '
846
+	if ($context['can_report_moderator'] || !empty($context['can_see_likes']) || !empty($context['can_like']) || $message['can_approve'] || $message['can_unapprove'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'] || $context['can_quote']) {
847
+		echo '
799 848
 							<div class="under_message">';
849
+	}
800 850
 
801 851
 	// Maybe they want to report this post to the moderator(s)?
802
-	if ($context['can_report_moderator'])
803
-		echo '
852
+	if ($context['can_report_moderator']) {
853
+			echo '
804 854
 								<ul class="floatright smalltext">
805 855
 									<li class="report_link"><a href="', $scripturl, '?action=reporttm;topic=', $context['current_topic'], '.', $message['counter'], ';msg=', $message['id'], '">', $txt['report_to_mod'], '</a></li>
806 856
 								</ul>';
857
+	}
807 858
 
808 859
 	// What about likes?
809 860
 	if (!empty($modSettings['enable_likes']))
@@ -844,78 +895,91 @@  discard block
 block discarded – undo
844 895
 								<ul class="quickbuttons">';
845 896
 
846 897
 		// Can they quote? if so they can select and quote as well!
847
-		if ($context['can_quote'])
848
-			echo '
898
+		if ($context['can_quote']) {
899
+					echo '
849 900
 									<li><a href="', $scripturl, '?action=post;quote=', $message['id'], ';topic=', $context['current_topic'], '.', $context['start'], ';last_msg=', $context['topic_last_message'], '" onclick="return oQuickReply.quote(', $message['id'], ');"><span class="generic_icons quote"></span>', $txt['quote_action'], '</a></li>
850 901
 									<li style="display:none;" id="quoteSelected_', $message['id'], '"><a href="javascript:void(0)"><span class="generic_icons quote_selected"></span>', $txt['quote_selected_action'] ,'</a></li>';
902
+		}
851 903
 
852 904
 		// Can the user modify the contents of this post? Show the modify inline image.
853
-		if ($message['can_modify'])
854
-			echo '
905
+		if ($message['can_modify']) {
906
+					echo '
855 907
 									<li class="quick_edit"><a title="', $txt['modify_msg'], '" class="modifybutton" id="modify_button_', $message['id'], '" onclick="oQuickModify.modifyMsg(\'', $message['id'], '\', \'', !empty($modSettings['toggle_subject']), '\')"><span class="generic_icons quick_edit_button"></span>', $txt['quick_edit'], '</a></li>';
908
+		}
856 909
 
857
-		if ($message['can_approve'] || $message['can_unapprove'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'])
858
-			echo '
910
+		if ($message['can_approve'] || $message['can_unapprove'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg']) {
911
+					echo '
859 912
 									<li class="post_options">', $txt['post_options'];
913
+		}
860 914
 
861 915
 		echo '
862 916
 										<ul>';
863 917
 
864 918
 		// Can the user modify the contents of this post?
865
-		if ($message['can_modify'])
866
-			echo '
919
+		if ($message['can_modify']) {
920
+					echo '
867 921
 											<li><a href="', $scripturl, '?action=post;msg=', $message['id'], ';topic=', $context['current_topic'], '.', $context['start'], '"><span class="generic_icons modify_button"></span>', $txt['modify'], '</a></li>';
922
+		}
868 923
 
869 924
 		// How about... even... remove it entirely?!
870
-		if ($context['can_delete'] && ($context['topic_first_message'] == $message['id']))
871
-			echo '
925
+		if ($context['can_delete'] && ($context['topic_first_message'] == $message['id'])) {
926
+					echo '
872 927
 											<li><a href="', $scripturl, '?action=removetopic2;topic=', $context['current_topic'], '.', $context['start'], ';', $context['session_var'], '=', $context['session_id'], '" data-confirm="', $txt['are_sure_remove_topic'], '" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['remove_topic'],'</a></li>';
873
-		elseif ($message['can_remove'] && ($context['topic_first_message'] != $message['id']))
874
-			echo '
928
+		} elseif ($message['can_remove'] && ($context['topic_first_message'] != $message['id'])) {
929
+					echo '
875 930
 											<li><a href="', $scripturl, '?action=deletemsg;topic=', $context['current_topic'], '.', $context['start'], ';msg=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '" data-confirm="', $txt['remove_message_question'] ,'" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['remove'], '</a></li>';
931
+		}
876 932
 
877 933
 		// What about splitting it off the rest of the topic?
878
-		if ($context['can_split'] && !empty($context['real_num_replies']))
879
-			echo '
934
+		if ($context['can_split'] && !empty($context['real_num_replies'])) {
935
+					echo '
880 936
 											<li><a href="', $scripturl, '?action=splittopics;topic=', $context['current_topic'], '.0;at=', $message['id'], '"><span class="generic_icons split_button"></span>', $txt['split'], '</a></li>';
937
+		}
881 938
 
882 939
 		// Can we issue a warning because of this post? Remember, we can't give guests warnings.
883
-		if ($context['can_issue_warning'] && !$message['is_message_author'] && !$message['member']['is_guest'])
884
-			echo '
940
+		if ($context['can_issue_warning'] && !$message['is_message_author'] && !$message['member']['is_guest']) {
941
+					echo '
885 942
 											<li><a href="', $scripturl, '?action=profile;area=issuewarning;u=', $message['member']['id'], ';msg=', $message['id'], '"><span class="generic_icons warn_button"></span>', $txt['issue_warning'], '</a></li>';
943
+		}
886 944
 
887 945
 		// Can we restore topics?
888
-		if ($context['can_restore_msg'])
889
-			echo '
946
+		if ($context['can_restore_msg']) {
947
+					echo '
890 948
 											<li><a href="', $scripturl, '?action=restoretopic;msgs=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons restore_button"></span>', $txt['restore_message'], '</a></li>';
949
+		}
891 950
 
892 951
 		// Maybe we can approve it, maybe we should?
893
-		if ($message['can_approve'])
894
-			echo '
952
+		if ($message['can_approve']) {
953
+					echo '
895 954
 											<li><a href="', $scripturl, '?action=moderate;area=postmod;sa=approve;topic=', $context['current_topic'], '.', $context['start'], ';msg=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons approve_button"></span>', $txt['approve'], '</a></li>';
955
+		}
896 956
 
897 957
 		// Maybe we can unapprove it?
898
-		if ($message['can_unapprove'])
899
-			echo '
958
+		if ($message['can_unapprove']) {
959
+					echo '
900 960
 											<li><a href="', $scripturl, '?action=moderate;area=postmod;sa=approve;topic=', $context['current_topic'], '.', $context['start'], ';msg=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons unapprove_button"></span>', $txt['unapprove'], '</a></li>';
961
+		}
901 962
 
902 963
 		echo '
903 964
 										</ul>
904 965
 									</li>';
905 966
 
906 967
 		// Show a checkbox for quick moderation?
907
-		if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && $message['can_remove'])
908
-			echo '
968
+		if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && $message['can_remove']) {
969
+					echo '
909 970
 									<li style="display: none;" id="in_topic_mod_check_', $message['id'], '"></li>';
971
+		}
910 972
 
911
-		if ($message['can_approve'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'])
912
-			echo '
973
+		if ($message['can_approve'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg']) {
974
+					echo '
913 975
 								</ul>';
976
+		}
914 977
 	}
915 978
 
916
-	if ($context['can_report_moderator'] || !empty($context['can_see_likes']) || !empty($context['can_like']) || $message['can_approve'] || $message['can_unapprove'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'] || $context['can_quote'])
917
-	echo '
979
+	if ($context['can_report_moderator'] || !empty($context['can_see_likes']) || !empty($context['can_like']) || $message['can_approve'] || $message['can_unapprove'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'] || $context['can_quote']) {
980
+		echo '
918 981
 							</div>';
982
+	}
919 983
 
920 984
 	echo '
921 985
 						</div>
@@ -928,9 +992,10 @@  discard block
 block discarded – undo
928 992
 							<div class="custom_fields_above_signature">
929 993
 								<ul class="nolist">';
930 994
 
931
-		foreach ($message['custom_fields']['above_signature'] as $custom)
932
-			echo '
995
+		foreach ($message['custom_fields']['above_signature'] as $custom) {
996
+					echo '
933 997
 									<li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>';
998
+		}
934 999
 
935 1000
 		echo '
936 1001
 								</ul>
@@ -938,9 +1003,10 @@  discard block
 block discarded – undo
938 1003
 	}
939 1004
 
940 1005
 	// Show the member's signature?
941
-	if (!empty($message['member']['signature']) && empty($options['show_no_signatures']) && $context['signature_enabled'])
942
-		echo '
1006
+	if (!empty($message['member']['signature']) && empty($options['show_no_signatures']) && $context['signature_enabled']) {
1007
+			echo '
943 1008
 							<div class="signature" id="msg_', $message['id'], '_signature"', $ignoring ? ' style="display:none;"' : '', '>', $message['member']['signature'], '</div>';
1009
+	}
944 1010
 
945 1011
 
946 1012
 	// Are there any custom profile fields for below the signature?
@@ -950,9 +1016,10 @@  discard block
 block discarded – undo
950 1016
 							<div class="custom_fields_below_signature">
951 1017
 								<ul class="nolist">';
952 1018
 
953
-		foreach ($message['custom_fields']['below_signature'] as $custom)
954
-			echo '
1019
+		foreach ($message['custom_fields']['below_signature'] as $custom) {
1020
+					echo '
955 1021
 									<li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>';
1022
+		}
956 1023
 
957 1024
 		echo '
958 1025
 								</ul>
@@ -1000,8 +1067,8 @@  discard block
 block discarded – undo
1000 1067
 						<input type="hidden" name="seqnum" value="', $context['form_sequence_number'], '">';
1001 1068
 
1002 1069
 		// Guests just need more.
1003
-		if ($context['user']['is_guest'])
1004
-			echo '
1070
+		if ($context['user']['is_guest']) {
1071
+					echo '
1005 1072
 						<dl id="post_header">
1006 1073
 							<dt>
1007 1074
 								', $txt['name'], ':
@@ -1016,6 +1083,7 @@  discard block
 block discarded – undo
1016 1083
 								<input type="email" name="email" size="25" value="', $context['email'], '" tabindex="', $context['tabindex']++, '" class="input_text" required>
1017 1084
 							</dd>
1018 1085
 						</dl>';
1086
+		}
1019 1087
 
1020 1088
 		echo '
1021 1089
 						', template_control_richedit($context['post_box_name'], 'smileyBox_message', 'bbcBox_message'), '
@@ -1063,8 +1131,8 @@  discard block
 block discarded – undo
1063 1131
 		<br class="clear">';
1064 1132
 
1065 1133
 	// draft autosave available and the user has it enabled?
1066
-	if (!empty($context['drafts_autosave']))
1067
-		echo '
1134
+	if (!empty($context['drafts_autosave'])) {
1135
+			echo '
1068 1136
 			<script>
1069 1137
 				var oDraftAutoSave = new smf_DraftAutoSave({
1070 1138
 					sSelf: \'oDraftAutoSave\',
@@ -1076,10 +1144,12 @@  discard block
 block discarded – undo
1076 1144
 					iFreq: ', (empty($modSettings['masterAutoSaveDraftsDelay']) ? 60000 : $modSettings['masterAutoSaveDraftsDelay'] * 1000), '
1077 1145
 				});
1078 1146
 			</script>';
1147
+	}
1079 1148
 
1080
-	if ($context['show_spellchecking'])
1081
-		echo '
1149
+	if ($context['show_spellchecking']) {
1150
+			echo '
1082 1151
 			<form action="', $scripturl, '?action=spellcheck" method="post" accept-charset="', $context['character_set'], '" name="spell_form" id="spell_form" target="spellWindow"><input type="hidden" name="spellstring" value=""></form>';
1152
+	}
1083 1153
 
1084 1154
 	echo '
1085 1155
 				<script>
Please login to merge, or discard this patch.
Sources/Calendar.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -240,8 +240,8 @@
 block discarded – undo
240 240
 		$time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]);
241 241
 
242 242
 	$js_time_string = str_replace(
243
-		array('%H', '%k', '%I', '%l', '%M', '%p', '%P', '%r',      '%R',  '%S', '%T',    '%X'),
244
-		array('H',  'G',  'h',  'g',  'i',  'A',  'a',  'h:i:s A', 'H:i', 's',  'H:i:s', 'H:i:s'),
243
+		array('%H', '%k', '%I', '%l', '%M', '%p', '%P', '%r', '%R', '%S', '%T', '%X'),
244
+		array('H', 'G', 'h', 'g', 'i', 'A', 'a', 'h:i:s A', 'H:i', 's', 'H:i:s', 'H:i:s'),
245 245
 		$time_string
246 246
 	);
247 247
 
Please login to merge, or discard this patch.
Braces   +105 added lines, -83 removed lines patch added patch discarded remove patch
@@ -14,8 +14,9 @@  discard block
 block discarded – undo
14 14
  * @version 2.1 Beta 3
15 15
  */
16 16
 
17
-if (!defined('SMF'))
17
+if (!defined('SMF')) {
18 18
 	die('No direct access...');
19
+}
19 20
 
20 21
 /**
21 22
  * Show the calendar.
@@ -47,12 +48,14 @@  discard block
 block discarded – undo
47 48
 		'post' => 'CalendarPost',
48 49
 	);
49 50
 
50
-	if (isset($_GET['sa']) && isset($subActions[$_GET['sa']]))
51
-		return call_helper($subActions[$_GET['sa']]);
51
+	if (isset($_GET['sa']) && isset($subActions[$_GET['sa']])) {
52
+			return call_helper($subActions[$_GET['sa']]);
53
+	}
52 54
 
53 55
 	// You can't do anything if the calendar is off.
54
-	if (empty($modSettings['cal_enabled']))
55
-		fatal_lang_error('calendar_off', false);
56
+	if (empty($modSettings['cal_enabled'])) {
57
+			fatal_lang_error('calendar_off', false);
58
+	}
56 59
 
57 60
 	// This is gonna be needed...
58 61
 	loadTemplate('Calendar');
@@ -97,8 +100,9 @@  discard block
 block discarded – undo
97 100
 	$context['view_week'] = isset($_GET['viewweek']);
98 101
 
99 102
 	// Don't let search engines index weekly calendar pages.
100
-	if ($context['view_week'])
101
-		$context['robot_no_index'] = true;
103
+	if ($context['view_week']) {
104
+			$context['robot_no_index'] = true;
105
+	}
102 106
 
103 107
 	// Get the current day of month...
104 108
 	require_once($sourcedir . '/Subs-Calendar.php');
@@ -112,17 +116,20 @@  discard block
 block discarded – undo
112 116
 	);
113 117
 
114 118
 	// Make sure the year and month are in valid ranges.
115
-	if ($curPage['month'] < 1 || $curPage['month'] > 12)
116
-		fatal_lang_error('invalid_month', false);
117
-	if ($curPage['year'] < $modSettings['cal_minyear'] || $curPage['year'] > $modSettings['cal_maxyear'])
118
-		fatal_lang_error('invalid_year', false);
119
+	if ($curPage['month'] < 1 || $curPage['month'] > 12) {
120
+			fatal_lang_error('invalid_month', false);
121
+	}
122
+	if ($curPage['year'] < $modSettings['cal_minyear'] || $curPage['year'] > $modSettings['cal_maxyear']) {
123
+			fatal_lang_error('invalid_year', false);
124
+	}
119 125
 	// If we have a day clean that too.
120 126
 	if ($context['view_week'])
121 127
 	{
122 128
 		// Note $isValid is -1 < PHP 5.1
123 129
 		$isValid = mktime(0, 0, 0, $curPage['month'], $curPage['day'], $curPage['year']);
124
-		if ($curPage['day'] > 31 || !$isValid || $isValid == -1)
125
-			fatal_lang_error('invalid_day', false);
130
+		if ($curPage['day'] > 31 || !$isValid || $isValid == -1) {
131
+					fatal_lang_error('invalid_day', false);
132
+		}
126 133
 	}
127 134
 
128 135
 	// Load all the context information needed to show the calendar grid.
@@ -144,21 +151,24 @@  discard block
 block discarded – undo
144 151
 	);
145 152
 
146 153
 	// Load up the main view.
147
-	if ($context['view_week'])
148
-		$context['calendar_grid_main'] = getCalendarWeek($curPage['month'], $curPage['year'], $curPage['day'], $calendarOptions);
149
-	else
150
-		$context['calendar_grid_main'] = getCalendarGrid($curPage['month'], $curPage['year'], $calendarOptions);
154
+	if ($context['view_week']) {
155
+			$context['calendar_grid_main'] = getCalendarWeek($curPage['month'], $curPage['year'], $curPage['day'], $calendarOptions);
156
+	} else {
157
+			$context['calendar_grid_main'] = getCalendarGrid($curPage['month'], $curPage['year'], $calendarOptions);
158
+	}
151 159
 
152 160
 	// Load up the previous and next months.
153 161
 	$context['calendar_grid_current'] = getCalendarGrid($curPage['month'], $curPage['year'], $calendarOptions);
154 162
 
155 163
 	// Only show previous month if it isn't pre-January of the min-year
156
-	if ($context['calendar_grid_current']['previous_calendar']['year'] > $modSettings['cal_minyear'] || $curPage['month'] != 1)
157
-		$context['calendar_grid_prev'] = getCalendarGrid($context['calendar_grid_current']['previous_calendar']['month'], $context['calendar_grid_current']['previous_calendar']['year'], $calendarOptions, true);
164
+	if ($context['calendar_grid_current']['previous_calendar']['year'] > $modSettings['cal_minyear'] || $curPage['month'] != 1) {
165
+			$context['calendar_grid_prev'] = getCalendarGrid($context['calendar_grid_current']['previous_calendar']['month'], $context['calendar_grid_current']['previous_calendar']['year'], $calendarOptions, true);
166
+	}
158 167
 
159 168
 	// Only show next month if it isn't post-December of the max-year
160
-	if ($context['calendar_grid_current']['next_calendar']['year'] < $modSettings['cal_maxyear'] || $curPage['month'] != 12)
161
-		$context['calendar_grid_next'] = getCalendarGrid($context['calendar_grid_current']['next_calendar']['month'], $context['calendar_grid_current']['next_calendar']['year'], $calendarOptions);
169
+	if ($context['calendar_grid_current']['next_calendar']['year'] < $modSettings['cal_maxyear'] || $curPage['month'] != 12) {
170
+			$context['calendar_grid_next'] = getCalendarGrid($context['calendar_grid_current']['next_calendar']['month'], $context['calendar_grid_current']['next_calendar']['year'], $calendarOptions);
171
+	}
162 172
 
163 173
 	// Basic template stuff.
164 174
 	$context['allow_calendar_event'] = allowedTo('calendar_post');
@@ -191,17 +201,19 @@  discard block
 block discarded – undo
191 201
 		'name' => $txt['months'][$context['current_month']] . ' ' . $context['current_year']
192 202
 	);
193 203
 	// If applicable, add the current week to the linktree.
194
-	if ($context['view_week'])
195
-		$context['linktree'][] = array(
204
+	if ($context['view_week']) {
205
+			$context['linktree'][] = array(
196 206
 			'url' => $scripturl . '?action=calendar;viewweek;year=' . $context['current_year'] . ';month=' . $context['current_month'] . ';day=' . $context['current_day'],
197 207
 			'name' => $context['calendar_grid_main']['week_title'],
198 208
 		);
209
+	}
199 210
 
200 211
 	// Build the calendar button array.
201 212
 	$context['calendar_buttons'] = array();
202 213
 
203
-	if ($context['can_post'])
204
-		$context['calendar_buttons']['post_event'] = array('text' => 'calendar_post_event', 'image' => 'calendarpe.png', 'url' => $scripturl . '?action=calendar;sa=post;month=' . $context['current_month'] . ';year=' . $context['current_year'] . ';' . $context['session_var'] . '=' . $context['session_id']);
214
+	if ($context['can_post']) {
215
+			$context['calendar_buttons']['post_event'] = array('text' => 'calendar_post_event', 'image' => 'calendarpe.png', 'url' => $scripturl . '?action=calendar;sa=post;month=' . $context['current_month'] . ';year=' . $context['current_year'] . ';' . $context['session_var'] . '=' . $context['session_id']);
216
+	}
205 217
 
206 218
 	// Allow mods to add additional buttons here
207 219
 	call_integration_hook('integrate_calendar_buttons');
@@ -230,14 +242,16 @@  discard block
 block discarded – undo
230 242
 	require_once($sourcedir . '/Subs.php');
231 243
 
232 244
 	// Cast this for safety...
233
-	if (isset($_REQUEST['eventid']))
234
-		$_REQUEST['eventid'] = (int) $_REQUEST['eventid'];
245
+	if (isset($_REQUEST['eventid'])) {
246
+			$_REQUEST['eventid'] = (int) $_REQUEST['eventid'];
247
+	}
235 248
 
236 249
 	// We want a fairly compact version of the time, but as close as possible to the user's settings.
237
-	if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0]))
238
-		$time_string = '%k:%M';
239
-	else
240
-		$time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]);
250
+	if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) {
251
+			$time_string = '%k:%M';
252
+	} else {
253
+			$time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]);
254
+	}
241 255
 
242 256
 	$js_time_string = str_replace(
243 257
 		array('%H', '%k', '%I', '%l', '%M', '%p', '%P', '%r',      '%R',  '%S', '%T',    '%X'),
@@ -251,12 +265,14 @@  discard block
 block discarded – undo
251 265
 		checkSession();
252 266
 
253 267
 		// Validate the post...
254
-		if (!isset($_POST['link_to_board']))
255
-			validateEventPost();
268
+		if (!isset($_POST['link_to_board'])) {
269
+					validateEventPost();
270
+		}
256 271
 
257 272
 		// If you're not allowed to edit any events, you have to be the poster.
258
-		if ($_REQUEST['eventid'] > 0 && !allowedTo('calendar_edit_any'))
259
-			isAllowedTo('calendar_edit_' . (!empty($user_info['id']) && getEventPoster($_REQUEST['eventid']) == $user_info['id'] ? 'own' : 'any'));
273
+		if ($_REQUEST['eventid'] > 0 && !allowedTo('calendar_edit_any')) {
274
+					isAllowedTo('calendar_edit_' . (!empty($user_info['id']) && getEventPoster($_REQUEST['eventid']) == $user_info['id'] ? 'own' : 'any'));
275
+		}
260 276
 
261 277
 		// New - and directing?
262 278
 		if (isset($_POST['link_to_board']) || empty($modSettings['cal_allow_unlinked']))
@@ -279,8 +295,9 @@  discard block
 block discarded – undo
279 295
 		}
280 296
 
281 297
 		// Deleting...
282
-		elseif (isset($_REQUEST['deleteevent']))
283
-			removeEvent($_REQUEST['eventid']);
298
+		elseif (isset($_REQUEST['deleteevent'])) {
299
+					removeEvent($_REQUEST['eventid']);
300
+		}
284 301
 
285 302
 		// ... or just update it?
286 303
 		else
@@ -302,14 +319,12 @@  discard block
 block discarded – undo
302 319
 			$d = date_parse($_POST['start_date']);
303 320
 			$year = $d['year'];
304 321
 			$month = $d['month'];
305
-		}
306
-		elseif (isset($_POST['start_datetime']))
322
+		} elseif (isset($_POST['start_datetime']))
307 323
 		{
308 324
 			$d = date_parse($_POST['start_datetime']);
309 325
 			$year = $d['year'];
310 326
 			$month = $d['month'];
311
-		}
312
-		else
327
+		} else
313 328
 		{
314 329
 			$today = getdate();
315 330
 			$year = isset($_POST['year']) ? $_POST['year'] : $today['year'];
@@ -342,13 +357,13 @@  discard block
 block discarded – undo
342 357
 		$context['event'] = array_merge($context['event'], $eventDatetimes);
343 358
 
344 359
 		$context['event']['last_day'] = (int) strftime('%d', mktime(0, 0, 0, $context['event']['month'] == 12 ? 1 : $context['event']['month'] + 1, 0, $context['event']['month'] == 12 ? $context['event']['year'] + 1 : $context['event']['year']));
345
-	}
346
-	else
360
+	} else
347 361
 	{
348 362
 		$context['event'] = getEventProperties($_REQUEST['eventid']);
349 363
 
350
-		if ($context['event'] === false)
351
-			fatal_lang_error('no_access', false);
364
+		if ($context['event'] === false) {
365
+					fatal_lang_error('no_access', false);
366
+		}
352 367
 
353 368
 		// If it has a board, then they should be editing it within the topic.
354 369
 		if (!empty($context['event']['topic']['id']) && !empty($context['event']['topic']['first_msg']))
@@ -359,10 +374,11 @@  discard block
 block discarded – undo
359 374
 		}
360 375
 
361 376
 		// Make sure the user is allowed to edit this event.
362
-		if ($context['event']['member'] != $user_info['id'])
363
-			isAllowedTo('calendar_edit_any');
364
-		elseif (!allowedTo('calendar_edit_any'))
365
-			isAllowedTo('calendar_edit_own');
377
+		if ($context['event']['member'] != $user_info['id']) {
378
+					isAllowedTo('calendar_edit_any');
379
+		} elseif (!allowedTo('calendar_edit_any')) {
380
+					isAllowedTo('calendar_edit_own');
381
+		}
366 382
 	}
367 383
 
368 384
 	// An all day event? Set up some nice defaults in case the user wants to change that
@@ -396,8 +412,7 @@  discard block
 block discarded – undo
396 412
 	{
397 413
 		// You can post new events but can't link them to anything...
398 414
 		$context['event']['categories'] = array();
399
-	}
400
-	else
415
+	} else
401 416
 	{
402 417
 		// Load the list of boards and categories in the context.
403 418
 		require_once($sourcedir . '/Subs-MessageIndex.php');
@@ -484,12 +499,14 @@  discard block
 block discarded – undo
484 499
 	global $smcFunc, $sourcedir, $forum_version, $modSettings, $webmaster_email, $mbname;
485 500
 
486 501
 	// You can't export if the calendar export feature is off.
487
-	if (empty($modSettings['cal_export']))
488
-		fatal_lang_error('calendar_export_off', false);
502
+	if (empty($modSettings['cal_export'])) {
503
+			fatal_lang_error('calendar_export_off', false);
504
+	}
489 505
 
490 506
 	// Goes without saying that this is required.
491
-	if (!isset($_REQUEST['eventid']))
492
-		fatal_lang_error('no_access', false);
507
+	if (!isset($_REQUEST['eventid'])) {
508
+			fatal_lang_error('no_access', false);
509
+	}
493 510
 
494 511
 	// This is kinda wanted.
495 512
 	require_once($sourcedir . '/Subs-Calendar.php');
@@ -497,15 +514,17 @@  discard block
 block discarded – undo
497 514
 	// Load up the event in question and check it exists.
498 515
 	$event = getEventProperties($_REQUEST['eventid']);
499 516
 
500
-	if ($event === false)
501
-		fatal_lang_error('no_access', false);
517
+	if ($event === false) {
518
+			fatal_lang_error('no_access', false);
519
+	}
502 520
 
503 521
 	// Check the title isn't too long - iCal requires some formatting if so.
504 522
 	$title = str_split($event['title'], 30);
505 523
 	foreach ($title as $id => $line)
506 524
 	{
507
-		if ($id != 0)
508
-			$title[$id] = ' ' . $title[$id];
525
+		if ($id != 0) {
526
+					$title[$id] = ' ' . $title[$id];
527
+		}
509 528
 		$title[$id] .= "\n";
510 529
 	}
511 530
 
@@ -518,8 +537,7 @@  discard block
 block discarded – undo
518 537
 	{
519 538
 		$datestart = date_format($start_date, 'Ymd\THis');
520 539
 		$dateend = date_format($end_date, 'Ymd\THis');
521
-	}
522
-	else
540
+	} else
523 541
 	{
524 542
 		$datestart = date_format($start_date, 'Ymd');
525 543
 
@@ -540,15 +558,18 @@  discard block
 block discarded – undo
540 558
 	$filecontents .= 'DTSTART' . (!empty($event['start_time']) ? ';TZID=' . $event['tz'] : ';VALUE=DATE') . ':' . $datestart . "\n";
541 559
 
542 560
 	// event has a duration
543
-	if ($event['start_iso_gmdate'] != $event['end_iso_gmdate'])
544
-		$filecontents .= 'DTEND' . (!empty($event['end_time']) ? ';TZID=' . $event['tz'] : ';VALUE=DATE') . ':' . $dateend . "\n";
561
+	if ($event['start_iso_gmdate'] != $event['end_iso_gmdate']) {
562
+			$filecontents .= 'DTEND' . (!empty($event['end_time']) ? ';TZID=' . $event['tz'] : ';VALUE=DATE') . ':' . $dateend . "\n";
563
+	}
545 564
 
546 565
 	// event has changed? advance the sequence for this UID
547
-	if ($event['sequence'] > 0)
548
-		$filecontents .= 'SEQUENCE:' . $event['sequence'] . "\n";
566
+	if ($event['sequence'] > 0) {
567
+			$filecontents .= 'SEQUENCE:' . $event['sequence'] . "\n";
568
+	}
549 569
 
550
-	if (!empty($event['location']))
551
-		$filecontents .= 'LOCATION:' . str_replace(',', '\,', $event['location']) . "\n";
570
+	if (!empty($event['location'])) {
571
+			$filecontents .= 'LOCATION:' . str_replace(',', '\,', $event['location']) . "\n";
572
+	}
552 573
 
553 574
 	$filecontents .= 'SUMMARY:' . implode('', $title);
554 575
 	$filecontents .= 'UID:' . $event['eventid'] . '@' . str_replace(' ', '-', $mbname) . "\n";
@@ -557,23 +578,26 @@  discard block
 block discarded – undo
557 578
 
558 579
 	// Send some standard headers.
559 580
 	ob_end_clean();
560
-	if (!empty($modSettings['enableCompressedOutput']))
561
-		@ob_start('ob_gzhandler');
562
-	else
563
-		ob_start();
581
+	if (!empty($modSettings['enableCompressedOutput'])) {
582
+			@ob_start('ob_gzhandler');
583
+	} else {
584
+			ob_start();
585
+	}
564 586
 
565 587
 	// Send the file headers
566 588
 	header('Pragma: ');
567 589
 	header('Cache-Control: no-cache');
568
-	if (!isBrowser('gecko'))
569
-		header('Content-Transfer-Encoding: binary');
590
+	if (!isBrowser('gecko')) {
591
+			header('Content-Transfer-Encoding: binary');
592
+	}
570 593
 	header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 525600 * 60) . ' GMT');
571 594
 	header('Last-Modified: ' . gmdate('D, d M Y H:i:s', time()) . 'GMT');
572 595
 	header('Accept-Ranges: bytes');
573 596
 	header('Connection: close');
574 597
 	header('Content-Disposition: attachment; filename="' . $event['title'] . '.ics"');
575
-	if (empty($modSettings['enableCompressedOutput']))
576
-		header('Content-Length: ' . $smcFunc['strlen']($filecontents));
598
+	if (empty($modSettings['enableCompressedOutput'])) {
599
+			header('Content-Length: ' . $smcFunc['strlen']($filecontents));
600
+	}
577 601
 
578 602
 	// This is a calendar item!
579 603
 	header('Content-Type: text/calendar');
@@ -612,20 +636,17 @@  discard block
 block discarded – undo
612 636
 		$context['sub_template'] = 'bcd';
613 637
 		$context['linktree'][] = array('url' => $scripturl . '?action=clock;bcd', 'name' => 'BCD');
614 638
 		$context['clockicons'] = safe_unserialize(base64_decode('YTo2OntzOjI6ImgxIjthOjI6e2k6MDtpOjI7aToxO2k6MTt9czoyOiJoMiI7YTo0OntpOjA7aTo4O2k6MTtpOjQ7aToyO2k6MjtpOjM7aToxO31zOjI6Im0xIjthOjM6e2k6MDtpOjQ7aToxO2k6MjtpOjI7aToxO31zOjI6Im0yIjthOjQ6e2k6MDtpOjg7aToxO2k6NDtpOjI7aToyO2k6MztpOjE7fXM6MjoiczEiO2E6Mzp7aTowO2k6NDtpOjE7aToyO2k6MjtpOjE7fXM6MjoiczIiO2E6NDp7aTowO2k6ODtpOjE7aTo0O2k6MjtpOjI7aTozO2k6MTt9fQ=='));
615
-	}
616
-	elseif (!$omfg && !isset($_REQUEST['time']))
639
+	} elseif (!$omfg && !isset($_REQUEST['time']))
617 640
 	{
618 641
 		$context['sub_template'] = 'hms';
619 642
 		$context['linktree'][] = array('url' => $scripturl . '?action=clock', 'name' => 'Binary');
620 643
 		$context['clockicons'] = safe_unserialize(base64_decode('YTozOntzOjE6ImgiO2E6NTp7aTowO2k6MTY7aToxO2k6ODtpOjI7aTo0O2k6MztpOjI7aTo0O2k6MTt9czoxOiJtIjthOjY6e2k6MDtpOjMyO2k6MTtpOjE2O2k6MjtpOjg7aTozO2k6NDtpOjQ7aToyO2k6NTtpOjE7fXM6MToicyI7YTo2OntpOjA7aTozMjtpOjE7aToxNjtpOjI7aTo4O2k6MztpOjQ7aTo0O2k6MjtpOjU7aToxO319'));
621
-	}
622
-	elseif ($omfg)
644
+	} elseif ($omfg)
623 645
 	{
624 646
 		$context['sub_template'] = 'omfg';
625 647
 		$context['linktree'][] = array('url' => $scripturl . '?action=clock;omfg', 'name' => 'OMFG');
626 648
 		$context['clockicons'] = safe_unserialize(base64_decode('YTo2OntzOjQ6InllYXIiO2E6Nzp7aTowO2k6NjQ7aToxO2k6MzI7aToyO2k6MTY7aTozO2k6ODtpOjQ7aTo0O2k6NTtpOjI7aTo2O2k6MTt9czo1OiJtb250aCI7YTo0OntpOjA7aTo4O2k6MTtpOjQ7aToyO2k6MjtpOjM7aToxO31zOjM6ImRheSI7YTo1OntpOjA7aToxNjtpOjE7aTo4O2k6MjtpOjQ7aTozO2k6MjtpOjQ7aToxO31zOjQ6ImhvdXIiO2E6NTp7aTowO2k6MTY7aToxO2k6ODtpOjI7aTo0O2k6MztpOjI7aTo0O2k6MTt9czozOiJtaW4iO2E6Njp7aTowO2k6MzI7aToxO2k6MTY7aToyO2k6ODtpOjM7aTo0O2k6NDtpOjI7aTo1O2k6MTt9czozOiJzZWMiO2E6Njp7aTowO2k6MzI7aToxO2k6MTY7aToyO2k6ODtpOjM7aTo0O2k6NDtpOjI7aTo1O2k6MTt9fQ=='));
627
-	}
628
-	elseif (isset($_REQUEST['time']))
649
+	} elseif (isset($_REQUEST['time']))
629 650
 	{
630 651
 		$context['sub_template'] = 'thetime';
631 652
 		$time = getdate($_REQUEST['time'] == 'now' ? time() : (int) $_REQUEST['time']);
@@ -685,12 +706,13 @@  discard block
 block discarded – undo
685 706
 			),
686 707
 		);
687 708
 
688
-		foreach ($context['clockicons'] as $t => $vs)
689
-			foreach ($vs as $v => $dumb)
709
+		foreach ($context['clockicons'] as $t => $vs) {
710
+					foreach ($vs as $v => $dumb)
690 711
 			{
691 712
 				if ($$t >= $v)
692 713
 				{
693 714
 					$$t -= $v;
715
+		}
694 716
 					$context['clockicons'][$t][$v] = true;
695 717
 				}
696 718
 			}
Please login to merge, or discard this patch.
Sources/Subs-Db-mysql.php 1 patch
Braces   +230 added lines, -168 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 3
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
  *  Maps the implementations in this file (smf_db_function_name)
@@ -33,8 +34,8 @@  discard block
 block discarded – undo
33 34
 	global $smcFunc, $mysql_set_mode;
34 35
 
35 36
 	// Map some database specific functions, only do this once.
36
-	if (!isset($smcFunc['db_fetch_assoc']) || $smcFunc['db_fetch_assoc'] != 'mysql_fetch_assoc')
37
-		$smcFunc += array(
37
+	if (!isset($smcFunc['db_fetch_assoc']) || $smcFunc['db_fetch_assoc'] != 'mysql_fetch_assoc') {
38
+			$smcFunc += array(
38 39
 			'db_query' => 'smf_db_query',
39 40
 			'db_quote' => 'smf_db_quote',
40 41
 			'db_fetch_assoc' => 'mysql_fetch_assoc',
@@ -58,36 +59,42 @@  discard block
 block discarded – undo
58 59
 			'db_escape_wildcard_string' => 'smf_db_escape_wildcard_string',
59 60
 			'db_is_resource' => 'is_resource',
60 61
 		);
62
+	}
61 63
 
62
-	if (!empty($db_options['port']))
63
-		$db_server .= ':' . $db_options['port'];
64
+	if (!empty($db_options['port'])) {
65
+			$db_server .= ':' . $db_options['port'];
66
+	}
64 67
 	
65 68
 	$flags = 2; //#define CLIENT_FOUND_ROWS 2 /* Found instead of affected rows */
66 69
 
67
-	if (!empty($db_options['persist']))
68
-		$connection = @mysql_pconnect($db_server, $db_user, $db_passwd, $flags);
69
-	else
70
-		$connection = @mysql_connect($db_server, $db_user, $db_passwd, false, $flags);
70
+	if (!empty($db_options['persist'])) {
71
+			$connection = @mysql_pconnect($db_server, $db_user, $db_passwd, $flags);
72
+	} else {
73
+			$connection = @mysql_connect($db_server, $db_user, $db_passwd, false, $flags);
74
+	}
71 75
 
72 76
 	// Something's wrong, show an error if its fatal (which we assume it is)
73 77
 	if (!$connection)
74 78
 	{
75
-		if (!empty($db_options['non_fatal']))
76
-			return null;
77
-		else
78
-			display_db_error();
79
+		if (!empty($db_options['non_fatal'])) {
80
+					return null;
81
+		} else {
82
+					display_db_error();
83
+		}
79 84
 	}
80 85
 
81 86
 	// Select the database, unless told not to
82
-	if (empty($db_options['dont_select_db']) && !@mysql_select_db($db_name, $connection) && empty($db_options['non_fatal']))
83
-		display_db_error();
87
+	if (empty($db_options['dont_select_db']) && !@mysql_select_db($db_name, $connection) && empty($db_options['non_fatal'])) {
88
+			display_db_error();
89
+	}
84 90
 
85 91
 	// This makes it possible to have SMF automatically change the sql_mode and autocommit if needed.
86
-	if (isset($mysql_set_mode) && $mysql_set_mode === true)
87
-		$smcFunc['db_query']('', 'SET sql_mode = \'\', AUTOCOMMIT = 1',
92
+	if (isset($mysql_set_mode) && $mysql_set_mode === true) {
93
+			$smcFunc['db_query']('', 'SET sql_mode = \'\', AUTOCOMMIT = 1',
88 94
 		array(),
89 95
 		false
90 96
 	);
97
+	}
91 98
 
92 99
 	return $connection;
93 100
 }
@@ -134,37 +141,46 @@  discard block
 block discarded – undo
134 141
 	list ($values, $connection) = $db_callback;
135 142
 
136 143
 	// Connection gone???  This should *never* happen at this point, yet it does :'(
137
-	if (!is_resource($connection))
138
-		display_db_error();
144
+	if (!is_resource($connection)) {
145
+			display_db_error();
146
+	}
139 147
 
140
-	if ($matches[1] === 'db_prefix')
141
-		return $db_prefix;
148
+	if ($matches[1] === 'db_prefix') {
149
+			return $db_prefix;
150
+	}
142 151
 
143
-	if ($matches[1] === 'query_see_board')
144
-		return $user_info['query_see_board'];
152
+	if ($matches[1] === 'query_see_board') {
153
+			return $user_info['query_see_board'];
154
+	}
145 155
 
146
-	if ($matches[1] === 'query_wanna_see_board')
147
-		return $user_info['query_wanna_see_board'];
156
+	if ($matches[1] === 'query_wanna_see_board') {
157
+			return $user_info['query_wanna_see_board'];
158
+	}
148 159
 
149
-	if ($matches[1] === 'empty')
150
-		return '\'\'';
160
+	if ($matches[1] === 'empty') {
161
+			return '\'\'';
162
+	}
151 163
 
152
-	if (!isset($matches[2]))
153
-		smf_db_error_backtrace('Invalid value inserted or no type specified.', '', E_USER_ERROR, __FILE__, __LINE__);
164
+	if (!isset($matches[2])) {
165
+			smf_db_error_backtrace('Invalid value inserted or no type specified.', '', E_USER_ERROR, __FILE__, __LINE__);
166
+	}
154 167
 
155
-	if ($matches[1] === 'literal')
156
-		return '\'' . mysql_real_escape_string($matches[2], $connection) . '\'';
168
+	if ($matches[1] === 'literal') {
169
+			return '\'' . mysql_real_escape_string($matches[2], $connection) . '\'';
170
+	}
157 171
 
158
-	if (!isset($values[$matches[2]]))
159
-		smf_db_error_backtrace('The database value you\'re trying to insert does not exist: ' . (isset($smcFunc['htmlspecialchars']) ? $smcFunc['htmlspecialchars']($matches[2]) : htmlspecialchars($matches[2])), '', E_USER_ERROR, __FILE__, __LINE__);
172
+	if (!isset($values[$matches[2]])) {
173
+			smf_db_error_backtrace('The database value you\'re trying to insert does not exist: ' . (isset($smcFunc['htmlspecialchars']) ? $smcFunc['htmlspecialchars']($matches[2]) : htmlspecialchars($matches[2])), '', E_USER_ERROR, __FILE__, __LINE__);
174
+	}
160 175
 
161 176
 	$replacement = $values[$matches[2]];
162 177
 
163 178
 	switch ($matches[1])
164 179
 	{
165 180
 		case 'int':
166
-			if (!is_numeric($replacement) || (string) $replacement !== (string) (int) $replacement)
167
-				smf_db_error_backtrace('Wrong value type sent to the database. Integer expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
181
+			if (!is_numeric($replacement) || (string) $replacement !== (string) (int) $replacement) {
182
+							smf_db_error_backtrace('Wrong value type sent to the database. Integer expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
183
+			}
168 184
 			return (string) (int) $replacement;
169 185
 		break;
170 186
 
@@ -176,56 +192,63 @@  discard block
 block discarded – undo
176 192
 		case 'array_int':
177 193
 			if (is_array($replacement))
178 194
 			{
179
-				if (empty($replacement))
180
-					smf_db_error_backtrace('Database error, given array of integer values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
195
+				if (empty($replacement)) {
196
+									smf_db_error_backtrace('Database error, given array of integer values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
197
+				}
181 198
 
182 199
 				foreach ($replacement as $key => $value)
183 200
 				{
184
-					if (!is_numeric($value) || (string) $value !== (string) (int) $value)
185
-						smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
201
+					if (!is_numeric($value) || (string) $value !== (string) (int) $value) {
202
+											smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
203
+					}
186 204
 
187 205
 					$replacement[$key] = (string) (int) $value;
188 206
 				}
189 207
 
190 208
 				return implode(', ', $replacement);
209
+			} else {
210
+							smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
191 211
 			}
192
-			else
193
-				smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
194 212
 
195 213
 		break;
196 214
 
197 215
 		case 'array_string':
198 216
 			if (is_array($replacement))
199 217
 			{
200
-				if (empty($replacement))
201
-					smf_db_error_backtrace('Database error, given array of string values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
218
+				if (empty($replacement)) {
219
+									smf_db_error_backtrace('Database error, given array of string values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
220
+				}
202 221
 
203
-				foreach ($replacement as $key => $value)
204
-					$replacement[$key] = sprintf('\'%1$s\'', mysql_real_escape_string($value, $connection));
222
+				foreach ($replacement as $key => $value) {
223
+									$replacement[$key] = sprintf('\'%1$s\'', mysql_real_escape_string($value, $connection));
224
+				}
205 225
 
206 226
 				return implode(', ', $replacement);
227
+			} else {
228
+							smf_db_error_backtrace('Wrong value type sent to the database. Array of strings expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
207 229
 			}
208
-			else
209
-				smf_db_error_backtrace('Wrong value type sent to the database. Array of strings expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
210 230
 		break;
211 231
 
212 232
 		case 'date':
213
-			if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d)$~', $replacement, $date_matches) === 1)
214
-				return sprintf('\'%04d-%02d-%02d\'', $date_matches[1], $date_matches[2], $date_matches[3]);
215
-			else
216
-				smf_db_error_backtrace('Wrong value type sent to the database. Date expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
233
+			if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d)$~', $replacement, $date_matches) === 1) {
234
+							return sprintf('\'%04d-%02d-%02d\'', $date_matches[1], $date_matches[2], $date_matches[3]);
235
+			} else {
236
+							smf_db_error_backtrace('Wrong value type sent to the database. Date expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
237
+			}
217 238
 		break;
218 239
 
219 240
 		case 'time':
220
-			if (preg_match('~^([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $time_matches) === 1)
221
-				return sprintf('\'%02d:%02d:%02d\'', $time_matches[1], $time_matches[2], $time_matches[3]);
222
-			else
223
-				smf_db_error_backtrace('Wrong value type sent to the database. Time expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
241
+			if (preg_match('~^([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $time_matches) === 1) {
242
+							return sprintf('\'%02d:%02d:%02d\'', $time_matches[1], $time_matches[2], $time_matches[3]);
243
+			} else {
244
+							smf_db_error_backtrace('Wrong value type sent to the database. Time expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
245
+			}
224 246
 		break;
225 247
 
226 248
 		case 'float':
227
-			if (!is_numeric($replacement))
228
-				smf_db_error_backtrace('Wrong value type sent to the database. Floating point number expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
249
+			if (!is_numeric($replacement)) {
250
+							smf_db_error_backtrace('Wrong value type sent to the database. Floating point number expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
251
+			}
229 252
 			return (string) (float) $replacement;
230 253
 		break;
231 254
 
@@ -239,32 +262,37 @@  discard block
 block discarded – undo
239 262
 		break;
240 263
 
241 264
 		case 'inet':
242
-			if ($replacement == 'null' || $replacement == '')
243
-				return 'null';
244
-			if (!isValidIP($replacement))
245
-				smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
265
+			if ($replacement == 'null' || $replacement == '') {
266
+							return 'null';
267
+			}
268
+			if (!isValidIP($replacement)) {
269
+							smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
270
+			}
246 271
 			//we don't use the native support of mysql > 5.6.2
247 272
 			return sprintf('unhex(\'%1$s\')', bin2hex(inet_pton($replacement)));
248 273
 
249 274
 		case 'array_inet':
250 275
 			if (is_array($replacement))
251 276
 			{
252
-				if (empty($replacement))
253
-					smf_db_error_backtrace('Database error, given array of IPv4 or IPv6 values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
277
+				if (empty($replacement)) {
278
+									smf_db_error_backtrace('Database error, given array of IPv4 or IPv6 values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
279
+				}
254 280
 
255 281
 				foreach ($replacement as $key => $value)
256 282
 				{
257
-					if ($replacement == 'null' || $replacement == '')
258
-						$replacement[$key] = 'null';
259
-					if (!isValidIP($value))
260
-						smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
283
+					if ($replacement == 'null' || $replacement == '') {
284
+											$replacement[$key] = 'null';
285
+					}
286
+					if (!isValidIP($value)) {
287
+											smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
288
+					}
261 289
 					$replacement[$key] =  sprintf('unhex(\'%1$s\')', bin2hex(inet_pton($value)));
262 290
 				}
263 291
 
264 292
 				return implode(', ', $replacement);
293
+			} else {
294
+							smf_db_error_backtrace('Wrong value type sent to the database. Array of IPv4 or IPv6 expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
265 295
 			}
266
-			else
267
-				smf_db_error_backtrace('Wrong value type sent to the database. Array of IPv4 or IPv6 expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__);
268 296
 		break;
269 297
 
270 298
 		default:
@@ -335,18 +363,20 @@  discard block
 block discarded – undo
335 363
 	// One more query....
336 364
 	$db_count = !isset($db_count) ? 1 : $db_count + 1;
337 365
 
338
-	if (empty($modSettings['disableQueryCheck']) && strpos($db_string, '\'') !== false && empty($db_values['security_override']))
339
-		smf_db_error_backtrace('Hacking attempt...', 'Illegal character (\') used in query...', true, __FILE__, __LINE__);
366
+	if (empty($modSettings['disableQueryCheck']) && strpos($db_string, '\'') !== false && empty($db_values['security_override'])) {
367
+			smf_db_error_backtrace('Hacking attempt...', 'Illegal character (\') used in query...', true, __FILE__, __LINE__);
368
+	}
340 369
 
341 370
 	// Use "ORDER BY null" to prevent Mysql doing filesorts for Group By clauses without an Order By
342 371
 	if (strpos($db_string, 'GROUP BY') !== false && strpos($db_string, 'ORDER BY') === false && preg_match('~^\s+SELECT~i', $db_string))
343 372
 	{
344 373
 		// Add before LIMIT
345
-		if ($pos = strpos($db_string, 'LIMIT '))
346
-			$db_string = substr($db_string, 0, $pos) . "\t\t\tORDER BY null\n" . substr($db_string, $pos, strlen($db_string));
347
-		else
348
-			// Append it.
374
+		if ($pos = strpos($db_string, 'LIMIT ')) {
375
+					$db_string = substr($db_string, 0, $pos) . "\t\t\tORDER BY null\n" . substr($db_string, $pos, strlen($db_string));
376
+		} else {
377
+					// Append it.
349 378
 			$db_string .= "\n\t\t\tORDER BY null";
379
+		}
350 380
 	}
351 381
 
352 382
 	if (empty($db_values['security_override']) && (!empty($db_values) || strpos($db_string, '{db_prefix}') !== false))
@@ -368,8 +398,9 @@  discard block
 block discarded – undo
368 398
 		list ($file, $line) = smf_db_error_backtrace('', '', 'return', __FILE__, __LINE__);
369 399
 
370 400
 		// Initialize $db_cache if not already initialized.
371
-		if (!isset($db_cache))
372
-			$db_cache = array();
401
+		if (!isset($db_cache)) {
402
+					$db_cache = array();
403
+		}
373 404
 
374 405
 		if (!empty($_SESSION['debug_redirect']))
375 406
 		{
@@ -395,17 +426,18 @@  discard block
 block discarded – undo
395 426
 		while (true)
396 427
 		{
397 428
 			$pos = strpos($db_string, '\'', $pos + 1);
398
-			if ($pos === false)
399
-				break;
429
+			if ($pos === false) {
430
+							break;
431
+			}
400 432
 			$clean .= substr($db_string, $old_pos, $pos - $old_pos);
401 433
 
402 434
 			while (true)
403 435
 			{
404 436
 				$pos1 = strpos($db_string, '\'', $pos + 1);
405 437
 				$pos2 = strpos($db_string, '\\', $pos + 1);
406
-				if ($pos1 === false)
407
-					break;
408
-				elseif ($pos2 === false || $pos2 > $pos1)
438
+				if ($pos1 === false) {
439
+									break;
440
+				} elseif ($pos2 === false || $pos2 > $pos1)
409 441
 				{
410 442
 					$pos = $pos1;
411 443
 					break;
@@ -421,29 +453,35 @@  discard block
 block discarded – undo
421 453
 		$clean = trim(strtolower(preg_replace($allowed_comments_from, $allowed_comments_to, $clean)));
422 454
 
423 455
 		// Comments?  We don't use comments in our queries, we leave 'em outside!
424
-		if (strpos($clean, '/*') > 2 || strpos($clean, '--') !== false || strpos($clean, ';') !== false)
425
-			$fail = true;
456
+		if (strpos($clean, '/*') > 2 || strpos($clean, '--') !== false || strpos($clean, ';') !== false) {
457
+					$fail = true;
458
+		}
426 459
 		// Trying to change passwords, slow us down, or something?
427
-		elseif (strpos($clean, 'sleep') !== false && preg_match('~(^|[^a-z])sleep($|[^[_a-z])~s', $clean) != 0)
428
-			$fail = true;
429
-		elseif (strpos($clean, 'benchmark') !== false && preg_match('~(^|[^a-z])benchmark($|[^[a-z])~s', $clean) != 0)
430
-			$fail = true;
460
+		elseif (strpos($clean, 'sleep') !== false && preg_match('~(^|[^a-z])sleep($|[^[_a-z])~s', $clean) != 0) {
461
+					$fail = true;
462
+		} elseif (strpos($clean, 'benchmark') !== false && preg_match('~(^|[^a-z])benchmark($|[^[a-z])~s', $clean) != 0) {
463
+					$fail = true;
464
+		}
431 465
 
432
-		if (!empty($fail) && function_exists('log_error'))
433
-			smf_db_error_backtrace('Hacking attempt...', 'Hacking attempt...' . "\n" . $db_string, E_USER_ERROR, __FILE__, __LINE__);
466
+		if (!empty($fail) && function_exists('log_error')) {
467
+					smf_db_error_backtrace('Hacking attempt...', 'Hacking attempt...' . "\n" . $db_string, E_USER_ERROR, __FILE__, __LINE__);
468
+		}
434 469
 	}
435 470
 
436
-	if (empty($db_unbuffered))
437
-		$ret = @mysql_query($db_string, $connection);
438
-	else
439
-		$ret = @mysql_unbuffered_query($db_string, $connection);
471
+	if (empty($db_unbuffered)) {
472
+			$ret = @mysql_query($db_string, $connection);
473
+	} else {
474
+			$ret = @mysql_unbuffered_query($db_string, $connection);
475
+	}
440 476
 
441
-	if ($ret === false && empty($db_values['db_error_skip']))
442
-		$ret = smf_db_error($db_string, $connection);
477
+	if ($ret === false && empty($db_values['db_error_skip'])) {
478
+			$ret = smf_db_error($db_string, $connection);
479
+	}
443 480
 
444 481
 	// Debugging.
445
-	if (isset($db_show_debug) && $db_show_debug === true)
446
-		$db_cache[$db_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st));
482
+	if (isset($db_show_debug) && $db_show_debug === true) {
483
+			$db_cache[$db_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st));
484
+	}
447 485
 
448 486
 	return $ret;
449 487
 }
@@ -492,12 +530,13 @@  discard block
 block discarded – undo
492 530
 	// Decide which connection to use
493 531
 	$connection = $connection === null ? $db_connection : $connection;
494 532
 
495
-	if ($type == 'begin')
496
-		return @mysql_query('BEGIN', $connection);
497
-	elseif ($type == 'rollback')
498
-		return @mysql_query('ROLLBACK', $connection);
499
-	elseif ($type == 'commit')
500
-		return @mysql_query('COMMIT', $connection);
533
+	if ($type == 'begin') {
534
+			return @mysql_query('BEGIN', $connection);
535
+	} elseif ($type == 'rollback') {
536
+			return @mysql_query('ROLLBACK', $connection);
537
+	} elseif ($type == 'commit') {
538
+			return @mysql_query('COMMIT', $connection);
539
+	}
501 540
 
502 541
 	return false;
503 542
 }
@@ -537,8 +576,9 @@  discard block
 block discarded – undo
537 576
 	//    2013: Lost connection to server during query.
538 577
 
539 578
 	// Log the error.
540
-	if ($query_errno != 1213 && $query_errno != 1205 && function_exists('log_error'))
541
-		log_error($txt['database_error'] . ': ' . $query_error . (!empty($modSettings['enableErrorQueryLogging']) ? "\n\n$db_string" : ''), 'database', $file, $line);
579
+	if ($query_errno != 1213 && $query_errno != 1205 && function_exists('log_error')) {
580
+			log_error($txt['database_error'] . ': ' . $query_error . (!empty($modSettings['enableErrorQueryLogging']) ? "\n\n$db_string" : ''), 'database', $file, $line);
581
+	}
542 582
 
543 583
 	// Database error auto fixing ;).
544 584
 	if (function_exists('cache_get_data') && (!isset($modSettings['autoFixDatabase']) || $modSettings['autoFixDatabase'] == '1'))
@@ -547,8 +587,9 @@  discard block
 block discarded – undo
547 587
 		$old_cache = @$modSettings['cache_enable'];
548 588
 		$modSettings['cache_enable'] = '1';
549 589
 
550
-		if (($temp = cache_get_data('db_last_error', 600)) !== null)
551
-			$db_last_error = max(@$db_last_error, $temp);
590
+		if (($temp = cache_get_data('db_last_error', 600)) !== null) {
591
+					$db_last_error = max(@$db_last_error, $temp);
592
+		}
552 593
 
553 594
 		if (@$db_last_error < time() - 3600 * 24 * 3)
554 595
 		{
@@ -564,8 +605,9 @@  discard block
 block discarded – undo
564 605
 					foreach ($tables as $table)
565 606
 					{
566 607
 						// Now, it's still theoretically possible this could be an injection.  So backtick it!
567
-						if (trim($table) != '')
568
-							$fix_tables[] = '`' . strtr(trim($table), array('`' => '')) . '`';
608
+						if (trim($table) != '') {
609
+													$fix_tables[] = '`' . strtr(trim($table), array('`' => '')) . '`';
610
+						}
569 611
 					}
570 612
 				}
571 613
 
@@ -574,8 +616,9 @@  discard block
 block discarded – undo
574 616
 			// Table crashed.  Let's try to fix it.
575 617
 			elseif ($query_errno == 1016)
576 618
 			{
577
-				if (preg_match('~\'([^\.\']+)~', $query_error, $match) != 0)
578
-					$fix_tables = array('`' . $match[1] . '`');
619
+				if (preg_match('~\'([^\.\']+)~', $query_error, $match) != 0) {
620
+									$fix_tables = array('`' . $match[1] . '`');
621
+				}
579 622
 			}
580 623
 			// Indexes crashed.  Should be easy to fix!
581 624
 			elseif ($query_errno == 1034 || $query_errno == 1035)
@@ -594,13 +637,15 @@  discard block
 block discarded – undo
594 637
 
595 638
 			// Make a note of the REPAIR...
596 639
 			cache_put_data('db_last_error', time(), 600);
597
-			if (($temp = cache_get_data('db_last_error', 600)) === null)
598
-				updateSettingsFile(array('db_last_error' => time()));
640
+			if (($temp = cache_get_data('db_last_error', 600)) === null) {
641
+							updateSettingsFile(array('db_last_error' => time()));
642
+			}
599 643
 
600 644
 			// Attempt to find and repair the broken table.
601
-			foreach ($fix_tables as $table)
602
-				$smcFunc['db_query']('', "
645
+			foreach ($fix_tables as $table) {
646
+							$smcFunc['db_query']('', "
603 647
 					REPAIR TABLE $table", false, false);
648
+			}
604 649
 
605 650
 			// And send off an email!
606 651
 			sendmail($webmaster_email, $txt['database_error'], $txt['tried_to_repair'], null, 'dberror');
@@ -609,11 +654,12 @@  discard block
 block discarded – undo
609 654
 
610 655
 			// Try the query again...?
611 656
 			$ret = $smcFunc['db_query']('', $db_string, false, false);
612
-			if ($ret !== false)
613
-				return $ret;
657
+			if ($ret !== false) {
658
+							return $ret;
659
+			}
660
+		} else {
661
+					$modSettings['cache_enable'] = $old_cache;
614 662
 		}
615
-		else
616
-			$modSettings['cache_enable'] = $old_cache;
617 663
 
618 664
 		// Check for the "lost connection" or "deadlock found" errors - and try it just one more time.
619 665
 		if (in_array($query_errno, array(1205, 1213, 2006, 2013)))
@@ -623,22 +669,25 @@  discard block
 block discarded – undo
623 669
 				// Are we in SSI mode?  If so try that username and password first
624 670
 				if (SMF == 'SSI' && !empty($ssi_db_user) && !empty($ssi_db_passwd))
625 671
 				{
626
-					if (empty($db_persist))
627
-						$db_connection = @mysql_connect($db_server, $ssi_db_user, $ssi_db_passwd);
628
-					else
629
-						$db_connection = @mysql_pconnect($db_server, $ssi_db_user, $ssi_db_passwd);
672
+					if (empty($db_persist)) {
673
+											$db_connection = @mysql_connect($db_server, $ssi_db_user, $ssi_db_passwd);
674
+					} else {
675
+											$db_connection = @mysql_pconnect($db_server, $ssi_db_user, $ssi_db_passwd);
676
+					}
630 677
 				}
631 678
 				// Fall back to the regular username and password if need be
632 679
 				if (!$db_connection)
633 680
 				{
634
-					if (empty($db_persist))
635
-						$db_connection = @mysql_connect($db_server, $db_user, $db_passwd);
636
-					else
637
-						$db_connection = @mysql_pconnect($db_server, $db_user, $db_passwd);
681
+					if (empty($db_persist)) {
682
+											$db_connection = @mysql_connect($db_server, $db_user, $db_passwd);
683
+					} else {
684
+											$db_connection = @mysql_pconnect($db_server, $db_user, $db_passwd);
685
+					}
638 686
 				}
639 687
 
640
-				if (!$db_connection || !@mysql_select_db($db_name, $db_connection))
641
-					$db_connection = false;
688
+				if (!$db_connection || !@mysql_select_db($db_name, $db_connection)) {
689
+									$db_connection = false;
690
+				}
642 691
 			}
643 692
 
644 693
 			if ($db_connection)
@@ -649,24 +698,27 @@  discard block
 block discarded – undo
649 698
 					$ret = $smcFunc['db_query']('', $db_string, false, false);
650 699
 
651 700
 					$new_errno = mysql_errno($db_connection);
652
-					if ($ret !== false || in_array($new_errno, array(1205, 1213)))
653
-						break;
701
+					if ($ret !== false || in_array($new_errno, array(1205, 1213))) {
702
+											break;
703
+					}
654 704
 				}
655 705
 
656 706
 				// If it failed again, shucks to be you... we're not trying it over and over.
657
-				if ($ret !== false)
658
-					return $ret;
707
+				if ($ret !== false) {
708
+									return $ret;
709
+				}
659 710
 			}
660 711
 		}
661 712
 		// Are they out of space, perhaps?
662 713
 		elseif ($query_errno == 1030 && (strpos($query_error, ' -1 ') !== false || strpos($query_error, ' 28 ') !== false || strpos($query_error, ' 12 ') !== false))
663 714
 		{
664
-			if (!isset($txt))
665
-				$query_error .= ' - check database storage space.';
666
-			else
715
+			if (!isset($txt)) {
716
+							$query_error .= ' - check database storage space.';
717
+			} else
667 718
 			{
668
-				if (!isset($txt['mysql_error_space']))
669
-					loadLanguage('Errors');
719
+				if (!isset($txt['mysql_error_space'])) {
720
+									loadLanguage('Errors');
721
+				}
670 722
 
671 723
 				$query_error .= !isset($txt['mysql_error_space']) ? ' - check database storage space.' : $txt['mysql_error_space'];
672 724
 			}
@@ -674,15 +726,17 @@  discard block
 block discarded – undo
674 726
 	}
675 727
 
676 728
 	// Nothing's defined yet... just die with it.
677
-	if (empty($context) || empty($txt))
678
-		die($query_error);
729
+	if (empty($context) || empty($txt)) {
730
+			die($query_error);
731
+	}
679 732
 
680 733
 	// Show an error message, if possible.
681 734
 	$context['error_title'] = $txt['database_error'];
682
-	if (allowedTo('admin_forum'))
683
-		$context['error_message'] = nl2br($query_error) . '<br>' . $txt['file'] . ': ' . $file . '<br>' . $txt['line'] . ': ' . $line;
684
-	else
685
-		$context['error_message'] = $txt['try_again'];
735
+	if (allowedTo('admin_forum')) {
736
+			$context['error_message'] = nl2br($query_error) . '<br>' . $txt['file'] . ': ' . $file . '<br>' . $txt['line'] . ': ' . $line;
737
+	} else {
738
+			$context['error_message'] = $txt['try_again'];
739
+	}
686 740
 
687 741
 	if (allowedTo('admin_forum') && isset($db_show_debug) && $db_show_debug === true)
688 742
 	{
@@ -711,25 +765,28 @@  discard block
 block discarded – undo
711 765
 	$connection = $connection === null ? $db_connection : $connection;
712 766
 
713 767
 	// With nothing to insert, simply return.
714
-	if (empty($data))
715
-		return;
768
+	if (empty($data)) {
769
+			return;
770
+	}
716 771
 
717 772
 	// Replace the prefix holder with the actual prefix.
718 773
 	$table = str_replace('{db_prefix}', $db_prefix, $table);
719 774
 
720 775
 	// Inserting data as a single row can be done as a single array.
721
-	if (!is_array($data[array_rand($data)]))
722
-		$data = array($data);
776
+	if (!is_array($data[array_rand($data)])) {
777
+			$data = array($data);
778
+	}
723 779
 
724 780
 	// Create the mold for a single row insert.
725 781
 	$insertData = '(';
726 782
 	foreach ($columns as $columnName => $type)
727 783
 	{
728 784
 		// Are we restricting the length?
729
-		if (strpos($type, 'string-') !== false)
730
-			$insertData .= sprintf('SUBSTRING({string:%1$s}, 1, ' . substr($type, 7) . '), ', $columnName);
731
-		else
732
-			$insertData .= sprintf('{%1$s:%2$s}, ', $type, $columnName);
785
+		if (strpos($type, 'string-') !== false) {
786
+					$insertData .= sprintf('SUBSTRING({string:%1$s}, 1, ' . substr($type, 7) . '), ', $columnName);
787
+		} else {
788
+					$insertData .= sprintf('{%1$s:%2$s}, ', $type, $columnName);
789
+		}
733 790
 	}
734 791
 	$insertData = substr($insertData, 0, -2) . ')';
735 792
 
@@ -738,8 +795,9 @@  discard block
 block discarded – undo
738 795
 
739 796
 	// Here's where the variables are injected to the query.
740 797
 	$insertRows = array();
741
-	foreach ($data as $dataRow)
742
-		$insertRows[] = smf_db_quote($insertData, array_combine($indexed_columns, $dataRow), $connection);
798
+	foreach ($data as $dataRow) {
799
+			$insertRows[] = smf_db_quote($insertData, array_combine($indexed_columns, $dataRow), $connection);
800
+	}
743 801
 
744 802
 	// Determine the method of insertion.
745 803
 	$queryTitle = $method == 'replace' ? 'REPLACE' : ($method == 'ignore' ? 'INSERT IGNORE' : 'INSERT');
@@ -770,8 +828,9 @@  discard block
 block discarded – undo
770 828
  */
771 829
 function smf_db_error_backtrace($error_message, $log_message = '', $error_type = false, $file = null, $line = null)
772 830
 {
773
-	if (empty($log_message))
774
-		$log_message = $error_message;
831
+	if (empty($log_message)) {
832
+			$log_message = $error_message;
833
+	}
775 834
 
776 835
 	foreach (debug_backtrace() as $step)
777 836
 	{
@@ -790,12 +849,14 @@  discard block
 block discarded – undo
790 849
 	}
791 850
 
792 851
 	// A special case - we want the file and line numbers for debugging.
793
-	if ($error_type == 'return')
794
-		return array($file, $line);
852
+	if ($error_type == 'return') {
853
+			return array($file, $line);
854
+	}
795 855
 
796 856
 	// Is always a critical error.
797
-	if (function_exists('log_error'))
798
-		log_error($log_message, 'critical', $file, $line);
857
+	if (function_exists('log_error')) {
858
+			log_error($log_message, 'critical', $file, $line);
859
+	}
799 860
 
800 861
 	if (function_exists('fatal_error'))
801 862
 	{
@@ -803,12 +864,12 @@  discard block
 block discarded – undo
803 864
 
804 865
 		// Cannot continue...
805 866
 		exit;
867
+	} elseif ($error_type) {
868
+			trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : ''), $error_type);
869
+	} else {
870
+			trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : ''));
871
+	}
806 872
 	}
807
-	elseif ($error_type)
808
-		trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : ''), $error_type);
809
-	else
810
-		trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : ''));
811
-}
812 873
 
813 874
 /**
814 875
  * Escape the LIKE wildcards so that they match the character and not the wildcard.
@@ -825,10 +886,11 @@  discard block
 block discarded – undo
825 886
 		'\\' => '\\\\',
826 887
 	);
827 888
 
828
-	if ($translate_human_wildcards)
829
-		$replacements += array(
889
+	if ($translate_human_wildcards) {
890
+			$replacements += array(
830 891
 			'*' => '%',
831 892
 		);
893
+	}
832 894
 
833 895
 	return strtr($string, $replacements);
834 896
 }
Please login to merge, or discard this patch.
other/install.php 2 patches
Spacing   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1622,8 +1622,7 @@
 block discarded – undo
1622 1622
 	updateStats('topic');
1623 1623
 
1624 1624
 	// This function is needed to do the updateStats('subject') call.
1625
-	$smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' :
1626
-		function($string){
1625
+	$smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' : function($string) {
1627 1626
 			global $sourcedir;
1628 1627
 			if (function_exists('mb_strtolower'))
1629 1628
 				return mb_strtolower($string, 'UTF-8');
Please login to merge, or discard this patch.
Braces   +438 added lines, -326 removed lines patch added patch discarded remove patch
@@ -20,8 +20,9 @@  discard block
 block discarded – undo
20 20
 // ><html dir="ltr"><head><title>Error!</title></head><body>Sorry, this installer requires PHP!<div style="display: none;">
21 21
 
22 22
 // Let's pull in useful classes
23
-if (!defined('SMF'))
23
+if (!defined('SMF')) {
24 24
 	define('SMF', 1);
25
+}
25 26
 
26 27
 require_once('Sources/Class-Package.php');
27 28
 
@@ -83,12 +84,14 @@  discard block
 block discarded – undo
83 84
 			$value = preg_replace('~[^A-Za-z0-9_\$]~', '', $value);
84 85
 
85 86
 			// Is it reserved?
86
-			if ($value == 'pg_')
87
-				return $txt['error_db_prefix_reserved'];
87
+			if ($value == 'pg_') {
88
+							return $txt['error_db_prefix_reserved'];
89
+			}
88 90
 
89 91
 			// Is the prefix numeric?
90
-			if (preg_match('~^\d~', $value))
91
-				return $txt['error_db_prefix_numeric'];
92
+			if (preg_match('~^\d~', $value)) {
93
+							return $txt['error_db_prefix_numeric'];
94
+			}
92 95
 
93 96
 			return true;
94 97
 		},
@@ -135,10 +138,11 @@  discard block
 block discarded – undo
135 138
 		$incontext['skip'] = false;
136 139
 
137 140
 		// Call the step and if it returns false that means pause!
138
-		if (function_exists($step[2]) && $step[2]() === false)
139
-			break;
140
-		elseif (function_exists($step[2]))
141
-			$incontext['current_step']++;
141
+		if (function_exists($step[2]) && $step[2]() === false) {
142
+					break;
143
+		} elseif (function_exists($step[2])) {
144
+					$incontext['current_step']++;
145
+		}
142 146
 
143 147
 		// No warnings pass on.
144 148
 		$incontext['warning'] = '';
@@ -154,12 +158,14 @@  discard block
 block discarded – undo
154 158
 	global $databases, $incontext;
155 159
 
156 160
 	// Just so people using older versions of PHP aren't left in the cold.
157
-	if (!isset($_SERVER['PHP_SELF']))
158
-		$_SERVER['PHP_SELF'] = isset($GLOBALS['HTTP_SERVER_VARS']['PHP_SELF']) ? $GLOBALS['HTTP_SERVER_VARS']['PHP_SELF'] : 'install.php';
161
+	if (!isset($_SERVER['PHP_SELF'])) {
162
+			$_SERVER['PHP_SELF'] = isset($GLOBALS['HTTP_SERVER_VARS']['PHP_SELF']) ? $GLOBALS['HTTP_SERVER_VARS']['PHP_SELF'] : 'install.php';
163
+	}
159 164
 
160 165
 	// Turn off magic quotes runtime and enable error reporting.
161
-	if (function_exists('set_magic_quotes_runtime'))
162
-		@set_magic_quotes_runtime(0);
166
+	if (function_exists('set_magic_quotes_runtime')) {
167
+			@set_magic_quotes_runtime(0);
168
+	}
163 169
 	error_reporting(E_ALL);
164 170
 
165 171
 	// Fun.  Low PHP version...
@@ -173,21 +179,23 @@  discard block
 block discarded – undo
173 179
 	{
174 180
 		ob_start();
175 181
 
176
-		if (ini_get('session.save_handler') == 'user')
177
-			@ini_set('session.save_handler', 'files');
178
-		if (function_exists('session_start'))
179
-			@session_start();
180
-	}
181
-	else
182
+		if (ini_get('session.save_handler') == 'user') {
183
+					@ini_set('session.save_handler', 'files');
184
+		}
185
+		if (function_exists('session_start')) {
186
+					@session_start();
187
+		}
188
+	} else
182 189
 	{
183 190
 		ob_start('ob_gzhandler');
184 191
 
185
-		if (ini_get('session.save_handler') == 'user')
186
-			@ini_set('session.save_handler', 'files');
192
+		if (ini_get('session.save_handler') == 'user') {
193
+					@ini_set('session.save_handler', 'files');
194
+		}
187 195
 		session_start();
188 196
 
189
-		if (!headers_sent())
190
-			echo '<!DOCTYPE html>
197
+		if (!headers_sent()) {
198
+					echo '<!DOCTYPE html>
191 199
 <html>
192 200
 	<head>
193 201
 		<title>', htmlspecialchars($_GET['pass_string']), '</title>
@@ -196,6 +204,7 @@  discard block
 block discarded – undo
196 204
 		<strong>', htmlspecialchars($_GET['pass_string']), '</strong>
197 205
 	</body>
198 206
 </html>';
207
+		}
199 208
 		exit;
200 209
 	}
201 210
 
@@ -204,16 +213,18 @@  discard block
 block discarded – undo
204 213
 	{
205 214
 		$incontext['remote_files_available'] = false;
206 215
 		$test = @fsockopen('www.simplemachines.org', 80, $errno, $errstr, 1);
207
-		if ($test)
208
-			$incontext['remote_files_available'] = true;
216
+		if ($test) {
217
+					$incontext['remote_files_available'] = true;
218
+		}
209 219
 		@fclose($test);
210 220
 	}
211 221
 
212 222
 	// Add slashes, as long as they aren't already being added.
213
-	if (!function_exists('get_magic_quotes_gpc') || @get_magic_quotes_gpc() == 0)
214
-		foreach ($_POST as $k => $v)
223
+	if (!function_exists('get_magic_quotes_gpc') || @get_magic_quotes_gpc() == 0) {
224
+			foreach ($_POST as $k => $v)
215 225
 			if (strpos($k, 'password') === false && strpos($k, 'db_passwd') === false)
216 226
 				$_POST[$k] = addslashes($v);
227
+	}
217 228
 
218 229
 	// This is really quite simple; if ?delete is on the URL, delete the installer...
219 230
 	if (isset($_GET['delete']))
@@ -234,8 +245,7 @@  discard block
 block discarded – undo
234 245
 			$ftp->close();
235 246
 
236 247
 			unset($_SESSION['installer_temp_ftp']);
237
-		}
238
-		else
248
+		} else
239 249
 		{
240 250
 			@unlink(__FILE__);
241 251
 
@@ -256,10 +266,11 @@  discard block
 block discarded – undo
256 266
 	{
257 267
 		// Get PHP's default timezone, if set
258 268
 		$ini_tz = ini_get('date.timezone');
259
-		if (!empty($ini_tz))
260
-			$timezone_id = $ini_tz;
261
-		else
262
-			$timezone_id = '';
269
+		if (!empty($ini_tz)) {
270
+					$timezone_id = $ini_tz;
271
+		} else {
272
+					$timezone_id = '';
273
+		}
263 274
 
264 275
 		// If date.timezone is unset, invalid, or just plain weird, make a best guess
265 276
 		if (!in_array($timezone_id, timezone_identifiers_list()))
@@ -289,8 +300,9 @@  discard block
 block discarded – undo
289 300
 		$dir = dir(dirname(__FILE__) . '/Themes/default/languages');
290 301
 		while ($entry = $dir->read())
291 302
 		{
292
-			if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php')
293
-				$incontext['detected_languages'][$entry] = ucfirst(substr($entry, 8, strlen($entry) - 12));
303
+			if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php') {
304
+							$incontext['detected_languages'][$entry] = ucfirst(substr($entry, 8, strlen($entry) - 12));
305
+			}
294 306
 		}
295 307
 		$dir->close();
296 308
 	}
@@ -325,10 +337,11 @@  discard block
 block discarded – undo
325 337
 	}
326 338
 
327 339
 	// Override the language file?
328
-	if (isset($_GET['lang_file']))
329
-		$_SESSION['installer_temp_lang'] = $_GET['lang_file'];
330
-	elseif (isset($GLOBALS['HTTP_GET_VARS']['lang_file']))
331
-		$_SESSION['installer_temp_lang'] = $GLOBALS['HTTP_GET_VARS']['lang_file'];
340
+	if (isset($_GET['lang_file'])) {
341
+			$_SESSION['installer_temp_lang'] = $_GET['lang_file'];
342
+	} elseif (isset($GLOBALS['HTTP_GET_VARS']['lang_file'])) {
343
+			$_SESSION['installer_temp_lang'] = $GLOBALS['HTTP_GET_VARS']['lang_file'];
344
+	}
332 345
 
333 346
 	// Make sure it exists, if it doesn't reset it.
334 347
 	if (!isset($_SESSION['installer_temp_lang']) || preg_match('~[^\\w_\\-.]~', $_SESSION['installer_temp_lang']) === 1 || !file_exists(dirname(__FILE__) . '/Themes/default/languages/' . $_SESSION['installer_temp_lang']))
@@ -337,8 +350,9 @@  discard block
 block discarded – undo
337 350
 		list ($_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']);
338 351
 
339 352
 		// If we have english and some other language, use the other language.  We Americans hate english :P.
340
-		if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1)
341
-			list (, $_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']);
353
+		if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1) {
354
+					list (, $_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']);
355
+		}
342 356
 	}
343 357
 
344 358
 	// And now include the actual language file itself.
@@ -351,15 +365,18 @@  discard block
 block discarded – undo
351 365
 	global $db_prefix, $db_connection, $sourcedir;
352 366
 	global $smcFunc, $modSettings, $db_type, $db_name, $db_user, $db_persist;
353 367
 
354
-	if (empty($sourcedir))
355
-		$sourcedir = dirname(__FILE__) . '/Sources';
368
+	if (empty($sourcedir)) {
369
+			$sourcedir = dirname(__FILE__) . '/Sources';
370
+	}
356 371
 
357 372
 	// Need this to check whether we need the database password.
358 373
 	require(dirname(__FILE__) . '/Settings.php');
359
-	if (!defined('SMF'))
360
-		define('SMF', 1);
361
-	if (empty($smcFunc))
362
-		$smcFunc = array();
374
+	if (!defined('SMF')) {
375
+			define('SMF', 1);
376
+	}
377
+	if (empty($smcFunc)) {
378
+			$smcFunc = array();
379
+	}
363 380
 
364 381
 	$modSettings['disableQueryCheck'] = true;
365 382
 
@@ -367,8 +384,9 @@  discard block
 block discarded – undo
367 384
 	if (!$db_connection)
368 385
 	{
369 386
 		require_once($sourcedir . '/Subs-Db-' . $db_type . '.php');
370
-		if (version_compare(PHP_VERSION, '5', '<'))
371
-			require_once($sourcedir . '/Subs-Compat.php');
387
+		if (version_compare(PHP_VERSION, '5', '<')) {
388
+					require_once($sourcedir . '/Subs-Compat.php');
389
+		}
372 390
 
373 391
 		$db_options = array('persist' => $db_persist);
374 392
 		$port = '';
@@ -379,19 +397,20 @@  discard block
 block discarded – undo
379 397
 			if ($db_type == 'mysql' || $db_type == 'mysqli')
380 398
 			{
381 399
 				$port = ((int) $_POST['db_port'] == ini_get($db_type . 'default_port')) ? '' : (int) $_POST['db_port'];
382
-			}
383
-			elseif ($db_type == 'postgresql')
400
+			} elseif ($db_type == 'postgresql')
384 401
 			{
385 402
 				// PostgreSQL doesn't have a default port setting in php.ini, so just check against the default
386 403
 				$port = ((int) $_POST['db_port'] == 5432) ? '' : (int) $_POST['db_port'];
387 404
 			}
388 405
 		}
389 406
 
390
-		if (!empty($port))
391
-			$db_options['port'] = $port;
407
+		if (!empty($port)) {
408
+					$db_options['port'] = $port;
409
+		}
392 410
 
393
-		if (!$db_connection)
394
-			$db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, $db_options);
411
+		if (!$db_connection) {
412
+					$db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, $db_options);
413
+		}
395 414
 	}
396 415
 }
397 416
 
@@ -419,8 +438,9 @@  discard block
 block discarded – undo
419 438
 		// @todo REMOVE THIS!!
420 439
 		else
421 440
 		{
422
-			if (function_exists('doStep' . $_GET['step']))
423
-				call_user_func('doStep' . $_GET['step']);
441
+			if (function_exists('doStep' . $_GET['step'])) {
442
+							call_user_func('doStep' . $_GET['step']);
443
+			}
424 444
 		}
425 445
 		// Show the footer.
426 446
 		template_install_below();
@@ -438,8 +458,9 @@  discard block
 block discarded – undo
438 458
 	$incontext['sub_template'] = 'welcome_message';
439 459
 
440 460
 	// Done the submission?
441
-	if (isset($_POST['contbutt']))
442
-		return true;
461
+	if (isset($_POST['contbutt'])) {
462
+			return true;
463
+	}
443 464
 
444 465
 	// See if we think they have already installed it?
445 466
 	if (is_readable(dirname(__FILE__) . '/Settings.php'))
@@ -447,14 +468,17 @@  discard block
 block discarded – undo
447 468
 		$probably_installed = 0;
448 469
 		foreach (file(dirname(__FILE__) . '/Settings.php') as $line)
449 470
 		{
450
-			if (preg_match('~^\$db_passwd\s=\s\'([^\']+)\';$~', $line))
451
-				$probably_installed++;
452
-			if (preg_match('~^\$boardurl\s=\s\'([^\']+)\';~', $line) && !preg_match('~^\$boardurl\s=\s\'http://127\.0\.0\.1/smf\';~', $line))
453
-				$probably_installed++;
471
+			if (preg_match('~^\$db_passwd\s=\s\'([^\']+)\';$~', $line)) {
472
+							$probably_installed++;
473
+			}
474
+			if (preg_match('~^\$boardurl\s=\s\'([^\']+)\';~', $line) && !preg_match('~^\$boardurl\s=\s\'http://127\.0\.0\.1/smf\';~', $line)) {
475
+							$probably_installed++;
476
+			}
454 477
 		}
455 478
 
456
-		if ($probably_installed == 2)
457
-			$incontext['warning'] = $txt['error_already_installed'];
479
+		if ($probably_installed == 2) {
480
+					$incontext['warning'] = $txt['error_already_installed'];
481
+		}
458 482
 	}
459 483
 
460 484
 	// Is some database support even compiled in?
@@ -469,8 +493,7 @@  discard block
 block discarded – undo
469 493
 				$databases[$key]['supported'] = false;
470 494
 				$notFoundSQLFile = true;
471 495
 				$txt['error_db_script_missing'] = sprintf($txt['error_db_script_missing'], 'install_' . $GLOBALS['db_script_version'] . '_' . $type . '.sql');
472
-			}
473
-			else
496
+			} else
474 497
 			{
475 498
 				$db_type = $key;
476 499
 				$incontext['supported_databases'][] = $db;
@@ -479,29 +502,36 @@  discard block
 block discarded – undo
479 502
 	}
480 503
 
481 504
 	// Check the PHP version.
482
-	if ((!function_exists('version_compare') || version_compare($GLOBALS['required_php_version'], PHP_VERSION, '>')))
483
-		$error = 'error_php_too_low';
505
+	if ((!function_exists('version_compare') || version_compare($GLOBALS['required_php_version'], PHP_VERSION, '>'))) {
506
+			$error = 'error_php_too_low';
507
+	}
484 508
 	// Make sure we have a supported database
485
-	elseif (empty($incontext['supported_databases']))
486
-		$error = empty($notFoundSQLFile) ? 'error_db_missing' : 'error_db_script_missing';
509
+	elseif (empty($incontext['supported_databases'])) {
510
+			$error = empty($notFoundSQLFile) ? 'error_db_missing' : 'error_db_script_missing';
511
+	}
487 512
 	// How about session support?  Some crazy sysadmin remove it?
488
-	elseif (!function_exists('session_start'))
489
-		$error = 'error_session_missing';
513
+	elseif (!function_exists('session_start')) {
514
+			$error = 'error_session_missing';
515
+	}
490 516
 	// Make sure they uploaded all the files.
491
-	elseif (!file_exists(dirname(__FILE__) . '/index.php'))
492
-		$error = 'error_missing_files';
517
+	elseif (!file_exists(dirname(__FILE__) . '/index.php')) {
518
+			$error = 'error_missing_files';
519
+	}
493 520
 	// Very simple check on the session.save_path for Windows.
494 521
 	// @todo Move this down later if they don't use database-driven sessions?
495
-	elseif (@ini_get('session.save_path') == '/tmp' && substr(__FILE__, 1, 2) == ':\\')
496
-		$error = 'error_session_save_path';
522
+	elseif (@ini_get('session.save_path') == '/tmp' && substr(__FILE__, 1, 2) == ':\\') {
523
+			$error = 'error_session_save_path';
524
+	}
497 525
 
498 526
 	// Since each of the three messages would look the same, anyway...
499
-	if (isset($error))
500
-		$incontext['error'] = $txt[$error];
527
+	if (isset($error)) {
528
+			$incontext['error'] = $txt[$error];
529
+	}
501 530
 
502 531
 	// Mod_security blocks everything that smells funny. Let SMF handle security.
503
-	if (!fixModSecurity() && !isset($_GET['overmodsecurity']))
504
-		$incontext['error'] = $txt['error_mod_security'] . '<br><br><a href="' . $installurl . '?overmodsecurity=true">' . $txt['error_message_click'] . '</a> ' . $txt['error_message_bad_try_again'];
532
+	if (!fixModSecurity() && !isset($_GET['overmodsecurity'])) {
533
+			$incontext['error'] = $txt['error_mod_security'] . '<br><br><a href="' . $installurl . '?overmodsecurity=true">' . $txt['error_message_click'] . '</a> ' . $txt['error_message_bad_try_again'];
534
+	}
505 535
 
506 536
 	return false;
507 537
 }
@@ -524,15 +554,18 @@  discard block
 block discarded – undo
524 554
 		'agreement.txt',
525 555
 		'Settings.php'
526 556
 	);
527
-	if (file_exists(dirname(__FILE__) . '/Settings_bak.php'))
528
-		$writable_files[] = 'Settings_bak.php';
557
+	if (file_exists(dirname(__FILE__) . '/Settings_bak.php')) {
558
+			$writable_files[] = 'Settings_bak.php';
559
+	}
529 560
 
530
-	foreach ($incontext['detected_languages'] as $lang => $temp)
531
-		$extra_files[] = 'Themes/default/languages/' . $lang;
561
+	foreach ($incontext['detected_languages'] as $lang => $temp) {
562
+			$extra_files[] = 'Themes/default/languages/' . $lang;
563
+	}
532 564
 
533 565
 	// With mod_security installed, we could attempt to fix it with .htaccess.
534
-	if (function_exists('apache_get_modules') && in_array('mod_security', apache_get_modules()))
535
-		$writable_files[] = file_exists(dirname(__FILE__) . '/.htaccess') ? '.htaccess' : '.';
566
+	if (function_exists('apache_get_modules') && in_array('mod_security', apache_get_modules())) {
567
+			$writable_files[] = file_exists(dirname(__FILE__) . '/.htaccess') ? '.htaccess' : '.';
568
+	}
536 569
 
537 570
 	$failed_files = array();
538 571
 
@@ -548,12 +581,14 @@  discard block
 block discarded – undo
548 581
 				@chmod(dirname(__FILE__) . '/' . $file, 0755);
549 582
 
550 583
 				// Well, 755 hopefully worked... if not, try 777.
551
-				if (!is_writable(dirname(__FILE__) . '/' . $file) && !@chmod(dirname(__FILE__) . '/' . $file, 0777))
552
-					$failed_files[] = $file;
584
+				if (!is_writable(dirname(__FILE__) . '/' . $file) && !@chmod(dirname(__FILE__) . '/' . $file, 0777)) {
585
+									$failed_files[] = $file;
586
+				}
553 587
 			}
554 588
 		}
555
-		foreach ($extra_files as $file)
556
-			@chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777);
589
+		foreach ($extra_files as $file) {
590
+					@chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777);
591
+		}
557 592
 	}
558 593
 	// Windows is trickier.  Let's try opening for r+...
559 594
 	else
@@ -563,30 +598,35 @@  discard block
 block discarded – undo
563 598
 		foreach ($writable_files as $file)
564 599
 		{
565 600
 			// Folders can't be opened for write... but the index.php in them can ;)
566
-			if (is_dir(dirname(__FILE__) . '/' . $file))
567
-				$file .= '/index.php';
601
+			if (is_dir(dirname(__FILE__) . '/' . $file)) {
602
+							$file .= '/index.php';
603
+			}
568 604
 
569 605
 			// Funny enough, chmod actually does do something on windows - it removes the read only attribute.
570 606
 			@chmod(dirname(__FILE__) . '/' . $file, 0777);
571 607
 			$fp = @fopen(dirname(__FILE__) . '/' . $file, 'r+');
572 608
 
573 609
 			// Hmm, okay, try just for write in that case...
574
-			if (!is_resource($fp))
575
-				$fp = @fopen(dirname(__FILE__) . '/' . $file, 'w');
610
+			if (!is_resource($fp)) {
611
+							$fp = @fopen(dirname(__FILE__) . '/' . $file, 'w');
612
+			}
576 613
 
577
-			if (!is_resource($fp))
578
-				$failed_files[] = $file;
614
+			if (!is_resource($fp)) {
615
+							$failed_files[] = $file;
616
+			}
579 617
 
580 618
 			@fclose($fp);
581 619
 		}
582
-		foreach ($extra_files as $file)
583
-			@chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777);
620
+		foreach ($extra_files as $file) {
621
+					@chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777);
622
+		}
584 623
 	}
585 624
 
586 625
 	$failure = count($failed_files) >= 1;
587 626
 
588
-	if (!isset($_SERVER))
589
-		return !$failure;
627
+	if (!isset($_SERVER)) {
628
+			return !$failure;
629
+	}
590 630
 
591 631
 	// Put the list into context.
592 632
 	$incontext['failed_files'] = $failed_files;
@@ -634,19 +674,23 @@  discard block
 block discarded – undo
634 674
 
635 675
 		if (!isset($ftp) || $ftp->error !== false)
636 676
 		{
637
-			if (!isset($ftp))
638
-				$ftp = new ftp_connection(null);
677
+			if (!isset($ftp)) {
678
+							$ftp = new ftp_connection(null);
679
+			}
639 680
 			// Save the error so we can mess with listing...
640
-			elseif ($ftp->error !== false && empty($incontext['ftp_errors']) && !empty($ftp->last_message))
641
-				$incontext['ftp_errors'][] = $ftp->last_message;
681
+			elseif ($ftp->error !== false && empty($incontext['ftp_errors']) && !empty($ftp->last_message)) {
682
+							$incontext['ftp_errors'][] = $ftp->last_message;
683
+			}
642 684
 
643 685
 			list ($username, $detect_path, $found_path) = $ftp->detect_path(dirname(__FILE__));
644 686
 
645
-			if (empty($_POST['ftp_path']) && $found_path)
646
-				$_POST['ftp_path'] = $detect_path;
687
+			if (empty($_POST['ftp_path']) && $found_path) {
688
+							$_POST['ftp_path'] = $detect_path;
689
+			}
647 690
 
648
-			if (!isset($_POST['ftp_username']))
649
-				$_POST['ftp_username'] = $username;
691
+			if (!isset($_POST['ftp_username'])) {
692
+							$_POST['ftp_username'] = $username;
693
+			}
650 694
 
651 695
 			// Set the username etc, into context.
652 696
 			$incontext['ftp'] = array(
@@ -658,8 +702,7 @@  discard block
 block discarded – undo
658 702
 			);
659 703
 
660 704
 			return false;
661
-		}
662
-		else
705
+		} else
663 706
 		{
664 707
 			$_SESSION['installer_temp_ftp'] = array(
665 708
 				'server' => $_POST['ftp_server'],
@@ -673,10 +716,12 @@  discard block
 block discarded – undo
673 716
 
674 717
 			foreach ($failed_files as $file)
675 718
 			{
676
-				if (!is_writable(dirname(__FILE__) . '/' . $file))
677
-					$ftp->chmod($file, 0755);
678
-				if (!is_writable(dirname(__FILE__) . '/' . $file))
679
-					$ftp->chmod($file, 0777);
719
+				if (!is_writable(dirname(__FILE__) . '/' . $file)) {
720
+									$ftp->chmod($file, 0755);
721
+				}
722
+				if (!is_writable(dirname(__FILE__) . '/' . $file)) {
723
+									$ftp->chmod($file, 0777);
724
+				}
680 725
 				if (!is_writable(dirname(__FILE__) . '/' . $file))
681 726
 				{
682 727
 					$failed_files_updated[] = $file;
@@ -731,15 +776,17 @@  discard block
 block discarded – undo
731 776
 
732 777
 			if (!$foundOne)
733 778
 			{
734
-				if (isset($db['default_host']))
735
-					$incontext['db']['server'] = ini_get($db['default_host']) or $incontext['db']['server'] = 'localhost';
779
+				if (isset($db['default_host'])) {
780
+									$incontext['db']['server'] = ini_get($db['default_host']) or $incontext['db']['server'] = 'localhost';
781
+				}
736 782
 				if (isset($db['default_user']))
737 783
 				{
738 784
 					$incontext['db']['user'] = ini_get($db['default_user']);
739 785
 					$incontext['db']['name'] = ini_get($db['default_user']);
740 786
 				}
741
-				if (isset($db['default_password']))
742
-					$incontext['db']['pass'] = ini_get($db['default_password']);
787
+				if (isset($db['default_password'])) {
788
+									$incontext['db']['pass'] = ini_get($db['default_password']);
789
+				}
743 790
 
744 791
 				// For simplicity and less confusion, leave the port blank by default
745 792
 				$incontext['db']['port'] = '';
@@ -758,10 +805,10 @@  discard block
 block discarded – undo
758 805
 		$incontext['db']['server'] = $_POST['db_server'];
759 806
 		$incontext['db']['prefix'] = $_POST['db_prefix'];
760 807
 
761
-		if (!empty($_POST['db_port']))
762
-			$incontext['db']['port'] = $_POST['db_port'];
763
-	}
764
-	else
808
+		if (!empty($_POST['db_port'])) {
809
+					$incontext['db']['port'] = $_POST['db_port'];
810
+		}
811
+	} else
765 812
 	{
766 813
 		$incontext['db']['prefix'] = 'smf_';
767 814
 	}
@@ -797,10 +844,11 @@  discard block
 block discarded – undo
797 844
 		if (!empty($_POST['db_port']))
798 845
 		{
799 846
 			// For MySQL, we can get the "default port" from PHP. PostgreSQL has no such option though.
800
-			if (($db_type == 'mysql' || $db_type == 'mysqli') && $_POST['db_port'] != ini_get($db_type . '.default_port'))
801
-				$vars['db_port'] = (int) $_POST['db_port'];
802
-			elseif ($db_type == 'postgresql' && $_POST['db_port'] != 5432)
803
-				$vars['db_port'] = (int) $_POST['db_port'];
847
+			if (($db_type == 'mysql' || $db_type == 'mysqli') && $_POST['db_port'] != ini_get($db_type . '.default_port')) {
848
+							$vars['db_port'] = (int) $_POST['db_port'];
849
+			} elseif ($db_type == 'postgresql' && $_POST['db_port'] != 5432) {
850
+							$vars['db_port'] = (int) $_POST['db_port'];
851
+			}
804 852
 		}
805 853
 
806 854
 		// God I hope it saved!
@@ -813,8 +861,9 @@  discard block
 block discarded – undo
813 861
 		// Make sure it works.
814 862
 		require(dirname(__FILE__) . '/Settings.php');
815 863
 
816
-		if (empty($sourcedir))
817
-			$sourcedir = dirname(__FILE__) . '/Sources';
864
+		if (empty($sourcedir)) {
865
+					$sourcedir = dirname(__FILE__) . '/Sources';
866
+		}
818 867
 
819 868
 		// Better find the database file!
820 869
 		if (!file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php'))
@@ -824,18 +873,21 @@  discard block
 block discarded – undo
824 873
 		}
825 874
 
826 875
 		// Now include it for database functions!
827
-		if (!defined('SMF'))
828
-			define('SMF', 1);
876
+		if (!defined('SMF')) {
877
+					define('SMF', 1);
878
+		}
829 879
 
830 880
 		$modSettings['disableQueryCheck'] = true;
831
-		if (empty($smcFunc))
832
-			$smcFunc = array();
881
+		if (empty($smcFunc)) {
882
+					$smcFunc = array();
883
+		}
833 884
 
834 885
 			require_once($sourcedir . '/Subs-Db-' . $db_type . '.php');
835 886
 
836 887
 		// What - running PHP4? The shame!
837
-		if (version_compare(PHP_VERSION, '5', '<'))
838
-			require_once($sourcedir . '/Subs-Compat.php');
888
+		if (version_compare(PHP_VERSION, '5', '<')) {
889
+					require_once($sourcedir . '/Subs-Compat.php');
890
+		}
839 891
 
840 892
 		// Attempt a connection.
841 893
 		$needsDB = !empty($databases[$db_type]['always_has_db']);
@@ -923,12 +975,14 @@  discard block
 block discarded – undo
923 975
 	$incontext['page_title'] = $txt['install_settings'];
924 976
 
925 977
 	// Let's see if we got the database type correct.
926
-	if (isset($_POST['db_type'], $databases[$_POST['db_type']]))
927
-		$db_type = $_POST['db_type'];
978
+	if (isset($_POST['db_type'], $databases[$_POST['db_type']])) {
979
+			$db_type = $_POST['db_type'];
980
+	}
928 981
 
929 982
 	// Else we'd better be able to get the connection.
930
-	else
931
-		load_database();
983
+	else {
984
+			load_database();
985
+	}
932 986
 
933 987
 	$db_type = isset($_POST['db_type']) ? $_POST['db_type'] : $db_type;
934 988
 
@@ -948,12 +1002,14 @@  discard block
 block discarded – undo
948 1002
 	// Submitting?
949 1003
 	if (isset($_POST['boardurl']))
950 1004
 	{
951
-		if (substr($_POST['boardurl'], -10) == '/index.php')
952
-			$_POST['boardurl'] = substr($_POST['boardurl'], 0, -10);
953
-		elseif (substr($_POST['boardurl'], -1) == '/')
954
-			$_POST['boardurl'] = substr($_POST['boardurl'], 0, -1);
955
-		if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://')
956
-			$_POST['boardurl'] = 'http://' . $_POST['boardurl'];
1005
+		if (substr($_POST['boardurl'], -10) == '/index.php') {
1006
+					$_POST['boardurl'] = substr($_POST['boardurl'], 0, -10);
1007
+		} elseif (substr($_POST['boardurl'], -1) == '/') {
1008
+					$_POST['boardurl'] = substr($_POST['boardurl'], 0, -1);
1009
+		}
1010
+		if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://') {
1011
+					$_POST['boardurl'] = 'http://' . $_POST['boardurl'];
1012
+		}
957 1013
 
958 1014
 		// Save these variables.
959 1015
 		$vars = array(
@@ -984,10 +1040,10 @@  discard block
 block discarded – undo
984 1040
 			{
985 1041
 				$incontext['error'] = sprintf($txt['error_utf8_version'], $databases[$db_type]['utf8_version']);
986 1042
 				return false;
987
-			}
988
-			else
989
-				// Set the character set here.
1043
+			} else {
1044
+							// Set the character set here.
990 1045
 				updateSettingsFile(array('db_character_set' => 'utf8'));
1046
+			}
991 1047
 		}
992 1048
 
993 1049
 		// Good, skip on.
@@ -1007,8 +1063,9 @@  discard block
 block discarded – undo
1007 1063
 	$incontext['continue'] = 1;
1008 1064
 
1009 1065
 	// Already done?
1010
-	if (isset($_POST['pop_done']))
1011
-		return true;
1066
+	if (isset($_POST['pop_done'])) {
1067
+			return true;
1068
+	}
1012 1069
 
1013 1070
 	// Reload settings.
1014 1071
 	require(dirname(__FILE__) . '/Settings.php');
@@ -1026,8 +1083,9 @@  discard block
 block discarded – undo
1026 1083
 	$modSettings = array();
1027 1084
 	if ($result !== false)
1028 1085
 	{
1029
-		while ($row = $smcFunc['db_fetch_assoc']($result))
1030
-			$modSettings[$row['variable']] = $row['value'];
1086
+		while ($row = $smcFunc['db_fetch_assoc']($result)) {
1087
+					$modSettings[$row['variable']] = $row['value'];
1088
+		}
1031 1089
 		$smcFunc['db_free_result']($result);
1032 1090
 
1033 1091
 		// Do they match?  If so, this is just a refresh so charge on!
@@ -1040,20 +1098,22 @@  discard block
 block discarded – undo
1040 1098
 	$modSettings['disableQueryCheck'] = true;
1041 1099
 
1042 1100
 	// If doing UTF8, select it. PostgreSQL requires passing it as a string...
1043
-	if (!empty($db_character_set) && $db_character_set == 'utf8' && !empty($databases[$db_type]['utf8_support']))
1044
-		$smcFunc['db_query']('', '
1101
+	if (!empty($db_character_set) && $db_character_set == 'utf8' && !empty($databases[$db_type]['utf8_support'])) {
1102
+			$smcFunc['db_query']('', '
1045 1103
 			SET NAMES {string:utf8}',
1046 1104
 			array(
1047 1105
 				'db_error_skip' => true,
1048 1106
 				'utf8' => 'utf8',
1049 1107
 			)
1050 1108
 		);
1109
+	}
1051 1110
 
1052 1111
 	// Windows likes to leave the trailing slash, which yields to C:\path\to\SMF\/attachments...
1053
-	if (substr(__DIR__, -1) == '\\')
1054
-		$attachdir = __DIR__ . 'attachments';
1055
-	else
1056
-		$attachdir = __DIR__ . '/attachments';
1112
+	if (substr(__DIR__, -1) == '\\') {
1113
+			$attachdir = __DIR__ . 'attachments';
1114
+	} else {
1115
+			$attachdir = __DIR__ . '/attachments';
1116
+	}
1057 1117
 
1058 1118
 	$replaces = array(
1059 1119
 		'{$db_prefix}' => $db_prefix,
@@ -1070,8 +1130,9 @@  discard block
 block discarded – undo
1070 1130
 
1071 1131
 	foreach ($txt as $key => $value)
1072 1132
 	{
1073
-		if (substr($key, 0, 8) == 'default_')
1074
-			$replaces['{$' . $key . '}'] = $smcFunc['db_escape_string']($value);
1133
+		if (substr($key, 0, 8) == 'default_') {
1134
+					$replaces['{$' . $key . '}'] = $smcFunc['db_escape_string']($value);
1135
+		}
1075 1136
 	}
1076 1137
 	$replaces['{$default_reserved_names}'] = strtr($replaces['{$default_reserved_names}'], array('\\\\n' => '\\n'));
1077 1138
 
@@ -1086,8 +1147,9 @@  discard block
 block discarded – undo
1086 1147
 
1087 1148
 		while ($row = $smcFunc['db_fetch_assoc']($get_engines))
1088 1149
 		{
1089
-			if ($row['Support'] == 'YES' || $row['Support'] == 'DEFAULT')
1090
-				$engines[] = $row['Engine'];
1150
+			if ($row['Support'] == 'YES' || $row['Support'] == 'DEFAULT') {
1151
+							$engines[] = $row['Engine'];
1152
+			}
1091 1153
 		}
1092 1154
 
1093 1155
 		// Done with this now
@@ -1111,8 +1173,7 @@  discard block
 block discarded – undo
1111 1173
 			$replaces['START TRANSACTION;'] = '';
1112 1174
 			$replaces['COMMIT;'] = '';
1113 1175
 		}
1114
-	}
1115
-	else
1176
+	} else
1116 1177
 	{
1117 1178
 		$has_innodb = false;
1118 1179
 	}
@@ -1134,21 +1195,24 @@  discard block
 block discarded – undo
1134 1195
 	foreach ($sql_lines as $count => $line)
1135 1196
 	{
1136 1197
 		// No comments allowed!
1137
-		if (substr(trim($line), 0, 1) != '#')
1138
-			$current_statement .= "\n" . rtrim($line);
1198
+		if (substr(trim($line), 0, 1) != '#') {
1199
+					$current_statement .= "\n" . rtrim($line);
1200
+		}
1139 1201
 
1140 1202
 		// Is this the end of the query string?
1141
-		if (empty($current_statement) || (preg_match('~;[\s]*$~s', $line) == 0 && $count != count($sql_lines)))
1142
-			continue;
1203
+		if (empty($current_statement) || (preg_match('~;[\s]*$~s', $line) == 0 && $count != count($sql_lines))) {
1204
+					continue;
1205
+		}
1143 1206
 
1144 1207
 		// Does this table already exist?  If so, don't insert more data into it!
1145 1208
 		if (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) != 0 && in_array($match[1], $exists))
1146 1209
 		{
1147 1210
 			preg_match_all('~\)[,;]~', $current_statement, $matches);
1148
-			if (!empty($matches[0]))
1149
-				$incontext['sql_results']['insert_dups'] += count($matches[0]);
1150
-			else
1151
-				$incontext['sql_results']['insert_dups']++;
1211
+			if (!empty($matches[0])) {
1212
+							$incontext['sql_results']['insert_dups'] += count($matches[0]);
1213
+			} else {
1214
+							$incontext['sql_results']['insert_dups']++;
1215
+			}
1152 1216
 
1153 1217
 			$current_statement = '';
1154 1218
 			continue;
@@ -1157,8 +1221,9 @@  discard block
 block discarded – undo
1157 1221
 		if ($smcFunc['db_query']('', $current_statement, array('security_override' => true, 'db_error_skip' => true), $db_connection) === false)
1158 1222
 		{
1159 1223
 			// Use the appropriate function based on the DB type
1160
-			if ($db_type == 'mysql' || $db_type == 'mysqli')
1161
-				$db_errorno = $db_type . '_errno';
1224
+			if ($db_type == 'mysql' || $db_type == 'mysqli') {
1225
+							$db_errorno = $db_type . '_errno';
1226
+			}
1162 1227
 
1163 1228
 			// Error 1050: Table already exists!
1164 1229
 			// @todo Needs to be made better!
@@ -1173,18 +1238,18 @@  discard block
 block discarded – undo
1173 1238
 				// MySQLi requires a connection object. It's optional with MySQL and Postgres
1174 1239
 				$incontext['failures'][$count] = $smcFunc['db_error']($db_connection);
1175 1240
 			}
1176
-		}
1177
-		else
1241
+		} else
1178 1242
 		{
1179
-			if (preg_match('~^\s*CREATE TABLE ([^\s\n\r]+?)~', $current_statement, $match) == 1)
1180
-				$incontext['sql_results']['tables']++;
1181
-			elseif (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) == 1)
1243
+			if (preg_match('~^\s*CREATE TABLE ([^\s\n\r]+?)~', $current_statement, $match) == 1) {
1244
+							$incontext['sql_results']['tables']++;
1245
+			} elseif (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) == 1)
1182 1246
 			{
1183 1247
 				preg_match_all('~\)[,;]~', $current_statement, $matches);
1184
-				if (!empty($matches[0]))
1185
-					$incontext['sql_results']['inserts'] += count($matches[0]);
1186
-				else
1187
-					$incontext['sql_results']['inserts']++;
1248
+				if (!empty($matches[0])) {
1249
+									$incontext['sql_results']['inserts'] += count($matches[0]);
1250
+				} else {
1251
+									$incontext['sql_results']['inserts']++;
1252
+				}
1188 1253
 			}
1189 1254
 		}
1190 1255
 
@@ -1197,15 +1262,17 @@  discard block
 block discarded – undo
1197 1262
 	// Sort out the context for the SQL.
1198 1263
 	foreach ($incontext['sql_results'] as $key => $number)
1199 1264
 	{
1200
-		if ($number == 0)
1201
-			unset($incontext['sql_results'][$key]);
1202
-		else
1203
-			$incontext['sql_results'][$key] = sprintf($txt['db_populate_' . $key], $number);
1265
+		if ($number == 0) {
1266
+					unset($incontext['sql_results'][$key]);
1267
+		} else {
1268
+					$incontext['sql_results'][$key] = sprintf($txt['db_populate_' . $key], $number);
1269
+		}
1204 1270
 	}
1205 1271
 
1206 1272
 	// Make sure UTF will be used globally.
1207
-	if ((!empty($databases[$db_type]['utf8_support']) && !empty($databases[$db_type]['utf8_required'])) || (empty($databases[$db_type]['utf8_required']) && !empty($databases[$db_type]['utf8_support']) && isset($_POST['utf8'])))
1208
-		$newSettings[] = array('global_character_set', 'UTF-8');
1273
+	if ((!empty($databases[$db_type]['utf8_support']) && !empty($databases[$db_type]['utf8_required'])) || (empty($databases[$db_type]['utf8_required']) && !empty($databases[$db_type]['utf8_support']) && isset($_POST['utf8']))) {
1274
+			$newSettings[] = array('global_character_set', 'UTF-8');
1275
+	}
1209 1276
 
1210 1277
 	// Maybe we can auto-detect better cookie settings?
1211 1278
 	preg_match('~^http[s]?://([^\.]+?)([^/]*?)(/.*)?$~', $boardurl, $matches);
@@ -1216,16 +1283,20 @@  discard block
 block discarded – undo
1216 1283
 		$globalCookies = false;
1217 1284
 
1218 1285
 		// Okay... let's see.  Using a subdomain other than www.? (not a perfect check.)
1219
-		if ($matches[2] != '' && (strpos(substr($matches[2], 1), '.') === false || in_array($matches[1], array('forum', 'board', 'community', 'forums', 'support', 'chat', 'help', 'talk', 'boards', 'www'))))
1220
-			$globalCookies = true;
1286
+		if ($matches[2] != '' && (strpos(substr($matches[2], 1), '.') === false || in_array($matches[1], array('forum', 'board', 'community', 'forums', 'support', 'chat', 'help', 'talk', 'boards', 'www')))) {
1287
+					$globalCookies = true;
1288
+		}
1221 1289
 		// If there's a / in the middle of the path, or it starts with ~... we want local.
1222
-		if (isset($matches[3]) && strlen($matches[3]) > 3 && (substr($matches[3], 0, 2) == '/~' || strpos(substr($matches[3], 1), '/') !== false))
1223
-			$localCookies = true;
1290
+		if (isset($matches[3]) && strlen($matches[3]) > 3 && (substr($matches[3], 0, 2) == '/~' || strpos(substr($matches[3], 1), '/') !== false)) {
1291
+					$localCookies = true;
1292
+		}
1224 1293
 
1225
-		if ($globalCookies)
1226
-			$newSettings[] = array('globalCookies', '1');
1227
-		if ($localCookies)
1228
-			$newSettings[] = array('localCookies', '1');
1294
+		if ($globalCookies) {
1295
+					$newSettings[] = array('globalCookies', '1');
1296
+		}
1297
+		if ($localCookies) {
1298
+					$newSettings[] = array('localCookies', '1');
1299
+		}
1229 1300
 	}
1230 1301
 
1231 1302
 	// Are we allowing stat collection?
@@ -1241,32 +1312,36 @@  discard block
 block discarded – undo
1241 1312
 			fwrite($fp, $out);
1242 1313
 
1243 1314
 			$return_data = '';
1244
-			while (!feof($fp))
1245
-				$return_data .= fgets($fp, 128);
1315
+			while (!feof($fp)) {
1316
+							$return_data .= fgets($fp, 128);
1317
+			}
1246 1318
 
1247 1319
 			fclose($fp);
1248 1320
 
1249 1321
 			// Get the unique site ID.
1250 1322
 			preg_match('~SITE-ID:\s(\w{10})~', $return_data, $ID);
1251 1323
 
1252
-			if (!empty($ID[1]))
1253
-				$newSettings[] = array('allow_sm_stats', $ID[1]);
1324
+			if (!empty($ID[1])) {
1325
+							$newSettings[] = array('allow_sm_stats', $ID[1]);
1326
+			}
1254 1327
 		}
1255 1328
 	}
1256 1329
 
1257 1330
 	// Are we enabling SSL?
1258
-	if (!empty($_POST['force_ssl']))
1259
-		$newSettings[] = array('force_ssl', 2);
1331
+	if (!empty($_POST['force_ssl'])) {
1332
+			$newSettings[] = array('force_ssl', 2);
1333
+	}
1260 1334
 
1261 1335
 	// Setting a timezone is required.
1262 1336
 	if (!isset($modSettings['default_timezone']) && function_exists('date_default_timezone_set'))
1263 1337
 	{
1264 1338
 		// Get PHP's default timezone, if set
1265 1339
 		$ini_tz = ini_get('date.timezone');
1266
-		if (!empty($ini_tz))
1267
-			$timezone_id = $ini_tz;
1268
-		else
1269
-			$timezone_id = '';
1340
+		if (!empty($ini_tz)) {
1341
+					$timezone_id = $ini_tz;
1342
+		} else {
1343
+					$timezone_id = '';
1344
+		}
1270 1345
 
1271 1346
 		// If date.timezone is unset, invalid, or just plain weird, make a best guess
1272 1347
 		if (!in_array($timezone_id, timezone_identifiers_list()))
@@ -1275,8 +1350,9 @@  discard block
 block discarded – undo
1275 1350
 			$timezone_id = timezone_name_from_abbr('', $server_offset, 0);
1276 1351
 		}
1277 1352
 
1278
-		if (date_default_timezone_set($timezone_id))
1279
-			$newSettings[] = array('default_timezone', $timezone_id);
1353
+		if (date_default_timezone_set($timezone_id)) {
1354
+					$newSettings[] = array('default_timezone', $timezone_id);
1355
+		}
1280 1356
 	}
1281 1357
 
1282 1358
 	if (!empty($newSettings))
@@ -1307,16 +1383,18 @@  discard block
 block discarded – undo
1307 1383
 	}
1308 1384
 
1309 1385
 	// MySQL specific stuff
1310
-	if (substr($db_type, 0, 5) != 'mysql')
1311
-		return false;
1386
+	if (substr($db_type, 0, 5) != 'mysql') {
1387
+			return false;
1388
+	}
1312 1389
 
1313 1390
 	// Find database user privileges.
1314 1391
 	$privs = array();
1315 1392
 	$get_privs = $smcFunc['db_query']('', 'SHOW PRIVILEGES', array());
1316 1393
 	while ($row = $smcFunc['db_fetch_assoc']($get_privs))
1317 1394
 	{
1318
-		if ($row['Privilege'] == 'Alter')
1319
-			$privs[] = $row['Privilege'];
1395
+		if ($row['Privilege'] == 'Alter') {
1396
+					$privs[] = $row['Privilege'];
1397
+		}
1320 1398
 	}
1321 1399
 	$smcFunc['db_free_result']($get_privs);
1322 1400
 
@@ -1346,8 +1424,9 @@  discard block
 block discarded – undo
1346 1424
 	$incontext['continue'] = 1;
1347 1425
 
1348 1426
 	// Skipping?
1349
-	if (!empty($_POST['skip']))
1350
-		return true;
1427
+	if (!empty($_POST['skip'])) {
1428
+			return true;
1429
+	}
1351 1430
 
1352 1431
 	// Need this to check whether we need the database password.
1353 1432
 	require(dirname(__FILE__) . '/Settings.php');
@@ -1360,18 +1439,22 @@  discard block
 block discarded – undo
1360 1439
 	// We need this to properly hash the password for Admin
1361 1440
 	$smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' : function($string) {
1362 1441
 			global $sourcedir;
1363
-			if (function_exists('mb_strtolower'))
1364
-				return mb_strtolower($string, 'UTF-8');
1442
+			if (function_exists('mb_strtolower')) {
1443
+							return mb_strtolower($string, 'UTF-8');
1444
+			}
1365 1445
 			require_once($sourcedir . '/Subs-Charset.php');
1366 1446
 			return utf8_strtolower($string);
1367 1447
 		};
1368 1448
 
1369
-	if (!isset($_POST['username']))
1370
-		$_POST['username'] = '';
1371
-	if (!isset($_POST['email']))
1372
-		$_POST['email'] = '';
1373
-	if (!isset($_POST['server_email']))
1374
-		$_POST['server_email'] = '';
1449
+	if (!isset($_POST['username'])) {
1450
+			$_POST['username'] = '';
1451
+	}
1452
+	if (!isset($_POST['email'])) {
1453
+			$_POST['email'] = '';
1454
+	}
1455
+	if (!isset($_POST['server_email'])) {
1456
+			$_POST['server_email'] = '';
1457
+	}
1375 1458
 
1376 1459
 	$incontext['username'] = htmlspecialchars(stripslashes($_POST['username']));
1377 1460
 	$incontext['email'] = htmlspecialchars(stripslashes($_POST['email']));
@@ -1390,8 +1473,9 @@  discard block
 block discarded – undo
1390 1473
 			'admin_group' => 1,
1391 1474
 		)
1392 1475
 	);
1393
-	if ($smcFunc['db_num_rows']($request) != 0)
1394
-		$incontext['skip'] = 1;
1476
+	if ($smcFunc['db_num_rows']($request) != 0) {
1477
+			$incontext['skip'] = 1;
1478
+	}
1395 1479
 	$smcFunc['db_free_result']($request);
1396 1480
 
1397 1481
 	// Trying to create an account?
@@ -1422,8 +1506,9 @@  discard block
 block discarded – undo
1422 1506
 		}
1423 1507
 
1424 1508
 		// Update the webmaster's email?
1425
-		if (!empty($_POST['server_email']) && (empty($webmaster_email) || $webmaster_email == '[email protected]'))
1426
-			updateSettingsFile(array('webmaster_email' => $_POST['server_email']));
1509
+		if (!empty($_POST['server_email']) && (empty($webmaster_email) || $webmaster_email == '[email protected]')) {
1510
+					updateSettingsFile(array('webmaster_email' => $_POST['server_email']));
1511
+		}
1427 1512
 
1428 1513
 		// Work out whether we're going to have dodgy characters and remove them.
1429 1514
 		$invalid_characters = preg_match('~[<>&"\'=\\\]~', $_POST['username']) != 0;
@@ -1446,32 +1531,27 @@  discard block
 block discarded – undo
1446 1531
 			$smcFunc['db_free_result']($result);
1447 1532
 
1448 1533
 			$incontext['account_existed'] = $txt['error_user_settings_taken'];
1449
-		}
1450
-		elseif ($_POST['username'] == '' || strlen($_POST['username']) > 25)
1534
+		} elseif ($_POST['username'] == '' || strlen($_POST['username']) > 25)
1451 1535
 		{
1452 1536
 			// Try the previous step again.
1453 1537
 			$incontext['error'] = $_POST['username'] == '' ? $txt['error_username_left_empty'] : $txt['error_username_too_long'];
1454 1538
 			return false;
1455
-		}
1456
-		elseif ($invalid_characters || $_POST['username'] == '_' || $_POST['username'] == '|' || strpos($_POST['username'], '[code') !== false || strpos($_POST['username'], '[/code') !== false)
1539
+		} elseif ($invalid_characters || $_POST['username'] == '_' || $_POST['username'] == '|' || strpos($_POST['username'], '[code') !== false || strpos($_POST['username'], '[/code') !== false)
1457 1540
 		{
1458 1541
 			// Try the previous step again.
1459 1542
 			$incontext['error'] = $txt['error_invalid_characters_username'];
1460 1543
 			return false;
1461
-		}
1462
-		elseif (empty($_POST['email']) || !filter_var(stripslashes($_POST['email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['email'])) > 255)
1544
+		} elseif (empty($_POST['email']) || !filter_var(stripslashes($_POST['email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['email'])) > 255)
1463 1545
 		{
1464 1546
 			// One step back, this time fill out a proper admin email address.
1465 1547
 			$incontext['error'] = sprintf($txt['error_valid_admin_email_needed'], $_POST['username']);
1466 1548
 			return false;
1467
-		}
1468
-		elseif (empty($_POST['server_email']) || !filter_var(stripslashes($_POST['server_email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['server_email'])) > 255)
1549
+		} elseif (empty($_POST['server_email']) || !filter_var(stripslashes($_POST['server_email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['server_email'])) > 255)
1469 1550
 		{
1470 1551
 			// One step back, this time fill out a proper admin email address.
1471 1552
 			$incontext['error'] = $txt['error_valid_server_email_needed'];
1472 1553
 			return false;
1473
-		}
1474
-		elseif ($_POST['username'] != '')
1554
+		} elseif ($_POST['username'] != '')
1475 1555
 		{
1476 1556
 			$incontext['member_salt'] = substr(md5(mt_rand()), 0, 4);
1477 1557
 
@@ -1546,17 +1626,19 @@  discard block
 block discarded – undo
1546 1626
 	require_once($sourcedir . '/Subs-Auth.php');
1547 1627
 
1548 1628
 	// Bring a warning over.
1549
-	if (!empty($incontext['account_existed']))
1550
-		$incontext['warning'] = $incontext['account_existed'];
1629
+	if (!empty($incontext['account_existed'])) {
1630
+			$incontext['warning'] = $incontext['account_existed'];
1631
+	}
1551 1632
 
1552
-	if (!empty($db_character_set) && !empty($databases[$db_type]['utf8_support']))
1553
-		$smcFunc['db_query']('', '
1633
+	if (!empty($db_character_set) && !empty($databases[$db_type]['utf8_support'])) {
1634
+			$smcFunc['db_query']('', '
1554 1635
 			SET NAMES {string:db_character_set}',
1555 1636
 			array(
1556 1637
 				'db_character_set' => $db_character_set,
1557 1638
 				'db_error_skip' => true,
1558 1639
 			)
1559 1640
 		);
1641
+	}
1560 1642
 
1561 1643
 	// As track stats is by default enabled let's add some activity.
1562 1644
 	$smcFunc['db_insert']('ignore',
@@ -1577,14 +1659,16 @@  discard block
 block discarded – undo
1577 1659
 	// Only proceed if we can load the data.
1578 1660
 	if ($request)
1579 1661
 	{
1580
-		while ($row = $smcFunc['db_fetch_row']($request))
1581
-			$modSettings[$row[0]] = $row[1];
1662
+		while ($row = $smcFunc['db_fetch_row']($request)) {
1663
+					$modSettings[$row[0]] = $row[1];
1664
+		}
1582 1665
 		$smcFunc['db_free_result']($request);
1583 1666
 	}
1584 1667
 
1585 1668
 	// Automatically log them in ;)
1586
-	if (isset($incontext['member_id']) && isset($incontext['member_salt']))
1587
-		setLoginCookie(3153600 * 60, $incontext['member_id'], hash_salt($_POST['password1'], $incontext['member_salt']));
1669
+	if (isset($incontext['member_id']) && isset($incontext['member_salt'])) {
1670
+			setLoginCookie(3153600 * 60, $incontext['member_id'], hash_salt($_POST['password1'], $incontext['member_salt']));
1671
+	}
1588 1672
 
1589 1673
 	$result = $smcFunc['db_query']('', '
1590 1674
 		SELECT value
@@ -1595,13 +1679,14 @@  discard block
 block discarded – undo
1595 1679
 			'db_error_skip' => true,
1596 1680
 		)
1597 1681
 	);
1598
-	if ($smcFunc['db_num_rows']($result) != 0)
1599
-		list ($db_sessions) = $smcFunc['db_fetch_row']($result);
1682
+	if ($smcFunc['db_num_rows']($result) != 0) {
1683
+			list ($db_sessions) = $smcFunc['db_fetch_row']($result);
1684
+	}
1600 1685
 	$smcFunc['db_free_result']($result);
1601 1686
 
1602
-	if (empty($db_sessions))
1603
-		$_SESSION['admin_time'] = time();
1604
-	else
1687
+	if (empty($db_sessions)) {
1688
+			$_SESSION['admin_time'] = time();
1689
+	} else
1605 1690
 	{
1606 1691
 		$_SERVER['HTTP_USER_AGENT'] = substr($_SERVER['HTTP_USER_AGENT'], 0, 211);
1607 1692
 
@@ -1625,8 +1710,9 @@  discard block
 block discarded – undo
1625 1710
 	$smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' :
1626 1711
 		function($string){
1627 1712
 			global $sourcedir;
1628
-			if (function_exists('mb_strtolower'))
1629
-				return mb_strtolower($string, 'UTF-8');
1713
+			if (function_exists('mb_strtolower')) {
1714
+							return mb_strtolower($string, 'UTF-8');
1715
+			}
1630 1716
 			require_once($sourcedir . '/Subs-Charset.php');
1631 1717
 			return utf8_strtolower($string);
1632 1718
 		};
@@ -1642,8 +1728,9 @@  discard block
 block discarded – undo
1642 1728
 		)
1643 1729
 	);
1644 1730
 	$context['utf8'] = $db_character_set === 'utf8' || $txt['lang_character_set'] === 'UTF-8';
1645
-	if ($smcFunc['db_num_rows']($request) > 0)
1646
-		updateStats('subject', 1, htmlspecialchars($txt['default_topic_subject']));
1731
+	if ($smcFunc['db_num_rows']($request) > 0) {
1732
+			updateStats('subject', 1, htmlspecialchars($txt['default_topic_subject']));
1733
+	}
1647 1734
 	$smcFunc['db_free_result']($request);
1648 1735
 
1649 1736
 	// Now is the perfect time to fetch the SM files.
@@ -1662,8 +1749,9 @@  discard block
 block discarded – undo
1662 1749
 
1663 1750
 	// Check if we need some stupid MySQL fix.
1664 1751
 	$server_version = $smcFunc['db_server_info']();
1665
-	if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51')))
1666
-		updateSettings(array('db_mysql_group_by_fix' => '1'));
1752
+	if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) {
1753
+			updateSettings(array('db_mysql_group_by_fix' => '1'));
1754
+	}
1667 1755
 
1668 1756
 	// Some final context for the template.
1669 1757
 	$incontext['dir_still_writable'] = is_writable(dirname(__FILE__)) && substr(__FILE__, 1, 2) != ':\\';
@@ -1683,8 +1771,9 @@  discard block
 block discarded – undo
1683 1771
 	$settingsArray = file(dirname(__FILE__) . '/Settings.php');
1684 1772
 
1685 1773
 	// @todo Do we just want to read the file in clean, and split it this way always?
1686
-	if (count($settingsArray) == 1)
1687
-		$settingsArray = preg_split('~[\r\n]~', $settingsArray[0]);
1774
+	if (count($settingsArray) == 1) {
1775
+			$settingsArray = preg_split('~[\r\n]~', $settingsArray[0]);
1776
+	}
1688 1777
 
1689 1778
 	for ($i = 0, $n = count($settingsArray); $i < $n; $i++)
1690 1779
 	{
@@ -1699,19 +1788,22 @@  discard block
 block discarded – undo
1699 1788
 			continue;
1700 1789
 		}
1701 1790
 
1702
-		if (trim($settingsArray[$i]) == '?' . '>')
1703
-			$settingsArray[$i] = '';
1791
+		if (trim($settingsArray[$i]) == '?' . '>') {
1792
+					$settingsArray[$i] = '';
1793
+		}
1704 1794
 
1705 1795
 		// Don't trim or bother with it if it's not a variable.
1706
-		if (substr($settingsArray[$i], 0, 1) != '$')
1707
-			continue;
1796
+		if (substr($settingsArray[$i], 0, 1) != '$') {
1797
+					continue;
1798
+		}
1708 1799
 
1709 1800
 		$settingsArray[$i] = rtrim($settingsArray[$i]) . "\n";
1710 1801
 
1711
-		foreach ($vars as $var => $val)
1712
-			if (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0)
1802
+		foreach ($vars as $var => $val) {
1803
+					if (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0)
1713 1804
 			{
1714 1805
 				$comment = strstr($settingsArray[$i], '#');
1806
+		}
1715 1807
 				$settingsArray[$i] = '$' . $var . ' = \'' . $val . '\';' . ($comment != '' ? "\t\t" . $comment : "\n");
1716 1808
 				unset($vars[$var]);
1717 1809
 			}
@@ -1721,36 +1813,41 @@  discard block
 block discarded – undo
1721 1813
 	if (!empty($vars))
1722 1814
 	{
1723 1815
 		$settingsArray[$i++] = '';
1724
-		foreach ($vars as $var => $val)
1725
-			$settingsArray[$i++] = '$' . $var . ' = \'' . $val . '\';' . "\n";
1816
+		foreach ($vars as $var => $val) {
1817
+					$settingsArray[$i++] = '$' . $var . ' = \'' . $val . '\';' . "\n";
1818
+		}
1726 1819
 	}
1727 1820
 
1728 1821
 	// Blank out the file - done to fix a oddity with some servers.
1729 1822
 	$fp = @fopen(dirname(__FILE__) . '/Settings.php', 'w');
1730
-	if (!$fp)
1731
-		return false;
1823
+	if (!$fp) {
1824
+			return false;
1825
+	}
1732 1826
 	fclose($fp);
1733 1827
 
1734 1828
 	$fp = fopen(dirname(__FILE__) . '/Settings.php', 'r+');
1735 1829
 
1736 1830
 	// Gotta have one of these ;)
1737
-	if (trim($settingsArray[0]) != '<?php')
1738
-		fwrite($fp, "<?php\n");
1831
+	if (trim($settingsArray[0]) != '<?php') {
1832
+			fwrite($fp, "<?php\n");
1833
+	}
1739 1834
 
1740 1835
 	$lines = count($settingsArray);
1741 1836
 	for ($i = 0; $i < $lines - 1; $i++)
1742 1837
 	{
1743 1838
 		// Don't just write a bunch of blank lines.
1744
-		if ($settingsArray[$i] != '' || @$settingsArray[$i - 1] != '')
1745
-			fwrite($fp, strtr($settingsArray[$i], "\r", ''));
1839
+		if ($settingsArray[$i] != '' || @$settingsArray[$i - 1] != '') {
1840
+					fwrite($fp, strtr($settingsArray[$i], "\r", ''));
1841
+		}
1746 1842
 	}
1747 1843
 	fwrite($fp, $settingsArray[$i] . '?' . '>');
1748 1844
 	fclose($fp);
1749 1845
 
1750 1846
 	// Even though on normal installations the filemtime should prevent this being used by the installer incorrectly
1751 1847
 	// it seems that there are times it might not. So let's MAKE it dump the cache.
1752
-	if (function_exists('opcache_invalidate'))
1753
-		opcache_invalidate(dirname(__FILE__) . '/Settings.php', true);
1848
+	if (function_exists('opcache_invalidate')) {
1849
+			opcache_invalidate(dirname(__FILE__) . '/Settings.php', true);
1850
+	}
1754 1851
 
1755 1852
 	return true;
1756 1853
 }
@@ -1775,9 +1872,9 @@  discard block
 block discarded – undo
1775 1872
 	SecFilterScanPOST Off
1776 1873
 </IfModule>';
1777 1874
 
1778
-	if (!function_exists('apache_get_modules') || !in_array('mod_security', apache_get_modules()))
1779
-		return true;
1780
-	elseif (file_exists(dirname(__FILE__) . '/.htaccess') && is_writable(dirname(__FILE__) . '/.htaccess'))
1875
+	if (!function_exists('apache_get_modules') || !in_array('mod_security', apache_get_modules())) {
1876
+			return true;
1877
+	} elseif (file_exists(dirname(__FILE__) . '/.htaccess') && is_writable(dirname(__FILE__) . '/.htaccess'))
1781 1878
 	{
1782 1879
 		$current_htaccess = implode('', file(dirname(__FILE__) . '/.htaccess'));
1783 1880
 
@@ -1789,29 +1886,28 @@  discard block
 block discarded – undo
1789 1886
 				fwrite($ht_handle, $htaccess_addition);
1790 1887
 				fclose($ht_handle);
1791 1888
 				return true;
1889
+			} else {
1890
+							return false;
1792 1891
 			}
1793
-			else
1794
-				return false;
1892
+		} else {
1893
+					return true;
1795 1894
 		}
1796
-		else
1797
-			return true;
1798
-	}
1799
-	elseif (file_exists(dirname(__FILE__) . '/.htaccess'))
1800
-		return strpos(implode('', file(dirname(__FILE__) . '/.htaccess')), '<IfModule mod_security.c>') !== false;
1801
-	elseif (is_writable(dirname(__FILE__)))
1895
+	} elseif (file_exists(dirname(__FILE__) . '/.htaccess')) {
1896
+			return strpos(implode('', file(dirname(__FILE__) . '/.htaccess')), '<IfModule mod_security.c>') !== false;
1897
+	} elseif (is_writable(dirname(__FILE__)))
1802 1898
 	{
1803 1899
 		if ($ht_handle = fopen(dirname(__FILE__) . '/.htaccess', 'w'))
1804 1900
 		{
1805 1901
 			fwrite($ht_handle, $htaccess_addition);
1806 1902
 			fclose($ht_handle);
1807 1903
 			return true;
1904
+		} else {
1905
+					return false;
1808 1906
 		}
1809
-		else
1907
+	} else {
1810 1908
 			return false;
1811 1909
 	}
1812
-	else
1813
-		return false;
1814
-}
1910
+	}
1815 1911
 
1816 1912
 function template_install_above()
1817 1913
 {
@@ -1849,9 +1945,10 @@  discard block
 block discarded – undo
1849 1945
 								<label for="installer_language">', $txt['installer_language'], ':</label>
1850 1946
 								<select id="installer_language" name="lang_file" onchange="location.href = \'', $installurl, '?lang_file=\' + this.options[this.selectedIndex].value;">';
1851 1947
 
1852
-		foreach ($incontext['detected_languages'] as $lang => $name)
1853
-			echo '
1948
+		foreach ($incontext['detected_languages'] as $lang => $name) {
1949
+					echo '
1854 1950
 									<option', isset($_SESSION['installer_temp_lang']) && $_SESSION['installer_temp_lang'] == $lang ? ' selected' : '', ' value="', $lang, '">', $name, '</option>';
1951
+		}
1855 1952
 
1856 1953
 		echo '
1857 1954
 								</select>
@@ -1871,9 +1968,10 @@  discard block
 block discarded – undo
1871 1968
 						<h2>', $txt['upgrade_progress'], '</h2>
1872 1969
 						<ul>';
1873 1970
 
1874
-	foreach ($incontext['steps'] as $num => $step)
1875
-		echo '
1971
+	foreach ($incontext['steps'] as $num => $step) {
1972
+			echo '
1876 1973
 							<li class="', $num < $incontext['current_step'] ? 'stepdone' : ($num == $incontext['current_step'] ? 'stepcurrent' : 'stepwaiting'), '">', $txt['upgrade_step'], ' ', $step[0], ': ', $step[1], '</li>';
1974
+	}
1877 1975
 
1878 1976
 	echo '
1879 1977
 						</ul>
@@ -1898,20 +1996,23 @@  discard block
 block discarded – undo
1898 1996
 		echo '
1899 1997
 								<div>';
1900 1998
 
1901
-		if (!empty($incontext['continue']))
1902
-			echo '
1999
+		if (!empty($incontext['continue'])) {
2000
+					echo '
1903 2001
 									<input type="submit" id="contbutt" name="contbutt" value="', $txt['upgrade_continue'], '" onclick="return submitThisOnce(this);" class="button_submit" />';
1904
-		if (!empty($incontext['skip']))
1905
-			echo '
2002
+		}
2003
+		if (!empty($incontext['skip'])) {
2004
+					echo '
1906 2005
 									<input type="submit" id="skip" name="skip" value="', $txt['upgrade_skip'], '" onclick="return submitThisOnce(this);" class="button_submit" />';
2006
+		}
1907 2007
 		echo '
1908 2008
 								</div>';
1909 2009
 	}
1910 2010
 
1911 2011
 	// Show the closing form tag and other data only if not in the last step
1912
-	if (count($incontext['steps']) - 1 !== (int) $incontext['current_step'])
1913
-		echo '
2012
+	if (count($incontext['steps']) - 1 !== (int) $incontext['current_step']) {
2013
+			echo '
1914 2014
 							</form>';
2015
+	}
1915 2016
 
1916 2017
 	echo '
1917 2018
 						</div>
@@ -1946,13 +2047,15 @@  discard block
 block discarded – undo
1946 2047
 		</div>';
1947 2048
 
1948 2049
 	// Show the warnings, or not.
1949
-	if (template_warning_divs())
1950
-		echo '
2050
+	if (template_warning_divs()) {
2051
+			echo '
1951 2052
 		<h3>', $txt['install_all_lovely'], '</h3>';
2053
+	}
1952 2054
 
1953 2055
 	// Say we want the continue button!
1954
-	if (empty($incontext['error']))
1955
-		$incontext['continue'] = 1;
2056
+	if (empty($incontext['error'])) {
2057
+			$incontext['continue'] = 1;
2058
+	}
1956 2059
 
1957 2060
 	// For the latest version stuff.
1958 2061
 	echo '
@@ -1986,8 +2089,8 @@  discard block
 block discarded – undo
1986 2089
 	global $txt, $incontext;
1987 2090
 
1988 2091
 	// Errors are very serious..
1989
-	if (!empty($incontext['error']))
1990
-		echo '
2092
+	if (!empty($incontext['error'])) {
2093
+			echo '
1991 2094
 		<div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;">
1992 2095
 			<div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div>
1993 2096
 			<strong style="text-decoration: underline;">', $txt['upgrade_critical_error'], '</strong><br>
@@ -1995,9 +2098,10 @@  discard block
 block discarded – undo
1995 2098
 				', $incontext['error'], '
1996 2099
 			</div>
1997 2100
 		</div>';
2101
+	}
1998 2102
 	// A warning message?
1999
-	elseif (!empty($incontext['warning']))
2000
-		echo '
2103
+	elseif (!empty($incontext['warning'])) {
2104
+			echo '
2001 2105
 		<div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;">
2002 2106
 			<div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div>
2003 2107
 			<strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br>
@@ -2005,6 +2109,7 @@  discard block
 block discarded – undo
2005 2109
 				', $incontext['warning'], '
2006 2110
 			</div>
2007 2111
 		</div>';
2112
+	}
2008 2113
 
2009 2114
 	return empty($incontext['error']) && empty($incontext['warning']);
2010 2115
 }
@@ -2020,27 +2125,30 @@  discard block
 block discarded – undo
2020 2125
 			<li>', $incontext['failed_files']), '</li>
2021 2126
 		</ul>';
2022 2127
 
2023
-	if (isset($incontext['systemos'], $incontext['detected_path']) && $incontext['systemos'] == 'linux')
2024
-		echo '
2128
+	if (isset($incontext['systemos'], $incontext['detected_path']) && $incontext['systemos'] == 'linux') {
2129
+			echo '
2025 2130
 		<hr>
2026 2131
 		<p>', $txt['chmod_linux_info'], '</p>
2027 2132
 		<tt># chmod a+w ', implode(' ' . $incontext['detected_path'] . '/', $incontext['failed_files']), '</tt>';
2133
+	}
2028 2134
 
2029 2135
 	// This is serious!
2030
-	if (!template_warning_divs())
2031
-		return;
2136
+	if (!template_warning_divs()) {
2137
+			return;
2138
+	}
2032 2139
 
2033 2140
 	echo '
2034 2141
 		<hr>
2035 2142
 		<p>', $txt['ftp_setup_info'], '</p>';
2036 2143
 
2037
-	if (!empty($incontext['ftp_errors']))
2038
-		echo '
2144
+	if (!empty($incontext['ftp_errors'])) {
2145
+			echo '
2039 2146
 		<div class="error_message">
2040 2147
 			', $txt['error_ftp_no_connect'], '<br><br>
2041 2148
 			<code>', implode('<br>', $incontext['ftp_errors']), '</code>
2042 2149
 		</div>
2043 2150
 		<br>';
2151
+	}
2044 2152
 
2045 2153
 	echo '
2046 2154
 		<form action="', $incontext['form_url'], '" method="post">
@@ -2100,17 +2208,17 @@  discard block
 block discarded – undo
2100 2208
 				<td>
2101 2209
 					<select name="db_type" id="db_type_input" onchange="toggleDBInput();">';
2102 2210
 
2103
-	foreach ($incontext['supported_databases'] as $key => $db)
2104
-			echo '
2211
+	foreach ($incontext['supported_databases'] as $key => $db) {
2212
+				echo '
2105 2213
 						<option value="', $key, '"', isset($_POST['db_type']) && $_POST['db_type'] == $key ? ' selected' : '', '>', $db['name'], '</option>';
2214
+	}
2106 2215
 
2107 2216
 	echo '
2108 2217
 					</select>
2109 2218
 					<div class="smalltext block">', $txt['db_settings_type_info'], '</div>
2110 2219
 				</td>
2111 2220
 			</tr>';
2112
-	}
2113
-	else
2221
+	} else
2114 2222
 	{
2115 2223
 		echo '
2116 2224
 			<tr style="display: none;">
@@ -2302,9 +2410,10 @@  discard block
 block discarded – undo
2302 2410
 				<div style="color: red;">', $txt['error_db_queries'], '</div>
2303 2411
 				<ul>';
2304 2412
 
2305
-		foreach ($incontext['failures'] as $line => $fail)
2306
-			echo '
2413
+		foreach ($incontext['failures'] as $line => $fail) {
2414
+					echo '
2307 2415
 						<li><strong>', $txt['error_db_queries_line'], $line + 1, ':</strong> ', nl2br(htmlspecialchars($fail)), '</li>';
2416
+		}
2308 2417
 
2309 2418
 		echo '
2310 2419
 				</ul>';
@@ -2365,15 +2474,16 @@  discard block
 block discarded – undo
2365 2474
 			</tr>
2366 2475
 		</table>';
2367 2476
 
2368
-	if ($incontext['require_db_confirm'])
2369
-		echo '
2477
+	if ($incontext['require_db_confirm']) {
2478
+			echo '
2370 2479
 		<h2>', $txt['user_settings_database'], '</h2>
2371 2480
 		<p>', $txt['user_settings_database_info'], '</p>
2372 2481
 
2373 2482
 		<div style="margin-bottom: 2ex; padding-', $txt['lang_rtl'] == false ? 'left' : 'right', ': 50px;">
2374 2483
 			<input type="password" name="password3" size="30" class="input_password" />
2375 2484
 		</div>';
2376
-}
2485
+	}
2486
+	}
2377 2487
 
2378 2488
 // Tell them it's done, and to delete.
2379 2489
 function template_delete_install()
@@ -2386,14 +2496,15 @@  discard block
 block discarded – undo
2386 2496
 	template_warning_divs();
2387 2497
 
2388 2498
 	// Install directory still writable?
2389
-	if ($incontext['dir_still_writable'])
2390
-		echo '
2499
+	if ($incontext['dir_still_writable']) {
2500
+			echo '
2391 2501
 		<em>', $txt['still_writable'], '</em><br>
2392 2502
 		<br>';
2503
+	}
2393 2504
 
2394 2505
 	// Don't show the box if it's like 99% sure it won't work :P.
2395
-	if ($incontext['probably_delete_install'])
2396
-		echo '
2506
+	if ($incontext['probably_delete_install']) {
2507
+			echo '
2397 2508
 		<div style="margin: 1ex; font-weight: bold;">
2398 2509
 			<label for="delete_self"><input type="checkbox" id="delete_self" onclick="doTheDelete();" class="input_check" /> ', $txt['delete_installer'], !isset($_SESSION['installer_temp_ftp']) ? ' ' . $txt['delete_installer_maybe'] : '', '</label>
2399 2510
 		</div>
@@ -2409,6 +2520,7 @@  discard block
 block discarded – undo
2409 2520
 			}
2410 2521
 		</script>
2411 2522
 		<br>';
2523
+	}
2412 2524
 
2413 2525
 	echo '
2414 2526
 		', sprintf($txt['go_to_your_forum'], $boardurl . '/index.php'), '<br>
Please login to merge, or discard this patch.
index.php 1 patch
Braces   +37 added lines, -25 removed lines patch added patch discarded remove patch
@@ -25,8 +25,9 @@  discard block
 block discarded – undo
25 25
 
26 26
 // Get everything started up...
27 27
 define('SMF', 1);
28
-if (function_exists('set_magic_quotes_runtime') && strnatcmp(phpversion(), '5.3.0') < 0)
28
+if (function_exists('set_magic_quotes_runtime') && strnatcmp(phpversion(), '5.3.0') < 0) {
29 29
 	@set_magic_quotes_runtime(0);
30
+}
30 31
 error_reporting(defined('E_STRICT') ? E_ALL | E_STRICT : E_ALL);
31 32
 $time_start = microtime();
32 33
 
@@ -34,16 +35,18 @@  discard block
 block discarded – undo
34 35
 ob_start();
35 36
 
36 37
 // Do some cleaning, just in case.
37
-foreach (array('db_character_set', 'cachedir') as $variable)
38
+foreach (array('db_character_set', 'cachedir') as $variable) {
38 39
 	if (isset($GLOBALS[$variable]))
39 40
 		unset($GLOBALS[$variable], $GLOBALS[$variable]);
41
+}
40 42
 
41 43
 // Load the settings...
42 44
 require_once(dirname(__FILE__) . '/Settings.php');
43 45
 
44 46
 // Make absolutely sure the cache directory is defined.
45
-if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache'))
47
+if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) {
46 48
 	$cachedir = $boarddir . '/cache';
49
+}
47 50
 
48 51
 // Without those we can't go anywhere
49 52
 require_once($sourcedir . '/QueryString.php');
@@ -53,8 +56,9 @@  discard block
 block discarded – undo
53 56
 require_once($sourcedir . '/Load.php');
54 57
 
55 58
 // If $maintenance is set specifically to 2, then we're upgrading or something.
56
-if (!empty($maintenance) && $maintenance == 2)
59
+if (!empty($maintenance) && $maintenance == 2) {
57 60
 	display_maintenance_message();
61
+}
58 62
 
59 63
 // Create a variable to store some SMF specific functions in.
60 64
 $smcFunc = array();
@@ -69,8 +73,9 @@  discard block
 block discarded – undo
69 73
 cleanRequest();
70 74
 
71 75
 // Seed the random generator.
72
-if (empty($modSettings['rand_seed']) || mt_rand(1, 250) == 69)
76
+if (empty($modSettings['rand_seed']) || mt_rand(1, 250) == 69) {
73 77
 	smf_seed_generator();
78
+}
74 79
 
75 80
 // Before we get carried away, are we doing a scheduled task? If so save CPU cycles by jumping out!
76 81
 if (isset($_GET['scheduled']))
@@ -90,9 +95,9 @@  discard block
 block discarded – undo
90 95
 if (!empty($modSettings['enableCompressedOutput']) && !headers_sent())
91 96
 {
92 97
 	// If zlib is being used, turn off output compression.
93
-	if (ini_get('zlib.output_compression') >= 1 || ini_get('output_handler') == 'ob_gzhandler')
94
-		$modSettings['enableCompressedOutput'] = '0';
95
-	else
98
+	if (ini_get('zlib.output_compression') >= 1 || ini_get('output_handler') == 'ob_gzhandler') {
99
+			$modSettings['enableCompressedOutput'] = '0';
100
+	} else
96 101
 	{
97 102
 		ob_end_clean();
98 103
 		ob_start('ob_gzhandler');
@@ -141,18 +146,21 @@  discard block
 block discarded – undo
141 146
 	loadPermissions();
142 147
 
143 148
 	// Attachments don't require the entire theme to be loaded.
144
-	if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'dlattach')
145
-		detectBrowser();
149
+	if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'dlattach') {
150
+			detectBrowser();
151
+	}
146 152
 	// Load the current theme.  (note that ?theme=1 will also work, may be used for guest theming.)
147
-	else
148
-		loadTheme();
153
+	else {
154
+			loadTheme();
155
+	}
149 156
 
150 157
 	// Check if the user should be disallowed access.
151 158
 	is_not_banned();
152 159
 
153 160
 	// If we are in a topic and don't have permission to approve it then duck out now.
154
-	if (!empty($topic) && empty($board_info['cur_topic_approved']) && !allowedTo('approve_posts') && ($user_info['id'] != $board_info['cur_topic_starter'] || $user_info['is_guest']))
155
-		fatal_lang_error('not_a_topic', false);
161
+	if (!empty($topic) && empty($board_info['cur_topic_approved']) && !allowedTo('approve_posts') && ($user_info['id'] != $board_info['cur_topic_starter'] || $user_info['is_guest'])) {
162
+			fatal_lang_error('not_a_topic', false);
163
+	}
156 164
 
157 165
 	$no_stat_actions = array('clock', 'dlattach', 'findmember', 'jsoption', 'likes', 'loadeditorlocale', 'modifycat', 'requestmembers', 'smstats', 'suggest', 'about:unknown', '.xml', 'xmlhttp', 'verificationcode', 'viewquery', 'viewsmfile');
158 166
 	call_integration_hook('integrate_pre_log_stats', array(&$no_stat_actions));
@@ -163,8 +171,9 @@  discard block
 block discarded – undo
163 171
 		writeLog();
164 172
 
165 173
 		// Track forum statistics and hits...?
166
-		if (!empty($modSettings['hitStats']))
167
-			trackStats(array('hits' => '+'));
174
+		if (!empty($modSettings['hitStats'])) {
175
+					trackStats(array('hits' => '+'));
176
+		}
168 177
 	}
169 178
 	unset($no_stat_actions);
170 179
 
@@ -178,13 +187,14 @@  discard block
 block discarded – undo
178 187
 			return ($_REQUEST['action'] == 'login2' ? 'Login2' : ($_REQUEST['action'] == 'logintfa' ? 'LoginTFA' : 'Logout'));
179 188
 		}
180 189
 		// Don't even try it, sonny.
181
-		else
182
-			return 'InMaintenance';
190
+		else {
191
+					return 'InMaintenance';
192
+		}
183 193
 	}
184 194
 	// If guest access is off, a guest can only do one of the very few following actions.
185
-	elseif (empty($modSettings['allow_guestAccess']) && $user_info['is_guest'] && (!isset($_REQUEST['action']) || !in_array($_REQUEST['action'], array('coppa', 'login', 'login2', 'logintfa', 'reminder', 'activate', 'help', 'helpadmin', 'smstats', 'verificationcode', 'signup', 'signup2'))))
186
-		return 'KickGuest';
187
-	elseif (empty($_REQUEST['action']))
195
+	elseif (empty($modSettings['allow_guestAccess']) && $user_info['is_guest'] && (!isset($_REQUEST['action']) || !in_array($_REQUEST['action'], array('coppa', 'login', 'login2', 'logintfa', 'reminder', 'activate', 'help', 'helpadmin', 'smstats', 'verificationcode', 'signup', 'signup2')))) {
196
+			return 'KickGuest';
197
+	} elseif (empty($_REQUEST['action']))
188 198
 	{
189 199
 		// Action and board are both empty... BoardIndex! Unless someone else wants to do something different.
190 200
 		if (empty($board) && empty($topic))
@@ -200,8 +210,9 @@  discard block
 block discarded – undo
200 210
 
201 211
 				$call = call_helper($defaultAction, true);
202 212
 
203
-				if (!empty($call))
204
-					return $call;
213
+				if (!empty($call)) {
214
+									return $call;
215
+				}
205 216
 			}
206 217
 
207 218
 			// No default action huh? then go to our good old BoardIndex.
@@ -331,8 +342,9 @@  discard block
 block discarded – undo
331 342
 
332 343
 			$call = call_helper($fallbackAction, true);
333 344
 
334
-			if (!empty($call))
335
-				return $call;
345
+			if (!empty($call)) {
346
+							return $call;
347
+			}
336 348
 		}
337 349
 
338 350
 		// No fallback action, huh?
Please login to merge, or discard this patch.
Themes/default/GenericMenu.template.php 1 patch
Braces   +50 added lines, -37 removed lines patch added patch discarded remove patch
@@ -89,8 +89,9 @@  discard block
 block discarded – undo
89 89
 		foreach ($section['areas'] as $i => $area)
90 90
 		{
91 91
 			// Not supposed to be printed?
92
-			if (empty($area['label']))
93
-				continue;
92
+			if (empty($area['label'])) {
93
+							continue;
94
+			}
94 95
 
95 96
 			echo '
96 97
 								<li', !empty($area['subsections']) ? ' class="subsections"' : '', '>';
@@ -99,8 +100,9 @@  discard block
 block discarded – undo
99 100
 									<a class="', $area['icon_class'], !empty($area['selected']) ? ' chosen ' : '', '" href="', (isset($area['url']) ? $area['url'] : $menu_context['base_url'] . ';area=' . $i), $menu_context['extra_parameters'], '">', $area['icon'], $area['label'], '</a>';
100 101
 
101 102
 			// Is this the current area, or just some area?
102
-			if (!empty($area['selected']) && empty($context['tabs']))
103
-					$context['tabs'] = isset($area['subsections']) ? $area['subsections'] : array();
103
+			if (!empty($area['selected']) && empty($context['tabs'])) {
104
+								$context['tabs'] = isset($area['subsections']) ? $area['subsections'] : array();
105
+			}
104 106
 
105 107
 			// Are there any subsections?
106 108
 			if (!empty($area['subsections']))
@@ -110,8 +112,9 @@  discard block
 block discarded – undo
110 112
 
111 113
 				foreach ($area['subsections'] as $sa => $sub)
112 114
 				{
113
-					if (!empty($sub['disabled']))
114
-						continue;
115
+					if (!empty($sub['disabled'])) {
116
+											continue;
117
+					}
115 118
 
116 119
 					$url = isset($sub['url']) ? $sub['url'] : (isset($area['url']) ? $area['url'] : $menu_context['base_url'] . ';area=' . $i) . ';sa=' . $sa;
117 120
 
@@ -158,8 +161,9 @@  discard block
 block discarded – undo
158 161
 							<h3 class="catbg">';
159 162
 
160 163
 		// The function is in Admin.template.php, but since this template is used elsewhere too better check if the function is available
161
-		if (function_exists('template_admin_quick_search'))
162
-			template_admin_quick_search();
164
+		if (function_exists('template_admin_quick_search')) {
165
+					template_admin_quick_search();
166
+		}
163 167
 
164 168
 		// Exactly how many tabs do we have?
165 169
 		if (!empty($context['tabs']))
@@ -174,30 +178,36 @@  discard block
 block discarded – undo
174 178
 				}
175 179
 
176 180
 				// Did this not even exist - or do we not have a label?
177
-				if (!isset($tab_context['tabs'][$id]))
178
-					$tab_context['tabs'][$id] = array('label' => $tab['label']);
179
-				elseif (!isset($tab_context['tabs'][$id]['label']))
180
-					$tab_context['tabs'][$id]['label'] = $tab['label'];
181
+				if (!isset($tab_context['tabs'][$id])) {
182
+									$tab_context['tabs'][$id] = array('label' => $tab['label']);
183
+				} elseif (!isset($tab_context['tabs'][$id]['label'])) {
184
+									$tab_context['tabs'][$id]['label'] = $tab['label'];
185
+				}
181 186
 
182 187
 				// Has a custom URL defined in the main admin structure?
183
-				if (isset($tab['url']) && !isset($tab_context['tabs'][$id]['url']))
184
-					$tab_context['tabs'][$id]['url'] = $tab['url'];
188
+				if (isset($tab['url']) && !isset($tab_context['tabs'][$id]['url'])) {
189
+									$tab_context['tabs'][$id]['url'] = $tab['url'];
190
+				}
185 191
 
186 192
 				// Any additional paramaters for the url?
187
-				if (isset($tab['add_params']) && !isset($tab_context['tabs'][$id]['add_params']))
188
-					$tab_context['tabs'][$id]['add_params'] = $tab['add_params'];
193
+				if (isset($tab['add_params']) && !isset($tab_context['tabs'][$id]['add_params'])) {
194
+									$tab_context['tabs'][$id]['add_params'] = $tab['add_params'];
195
+				}
189 196
 
190 197
 				// Has it been deemed selected?
191
-				if (!empty($tab['is_selected']))
192
-					$tab_context['tabs'][$id]['is_selected'] = true;
198
+				if (!empty($tab['is_selected'])) {
199
+									$tab_context['tabs'][$id]['is_selected'] = true;
200
+				}
193 201
 
194 202
 				// Does it have its own help?
195
-				if (!empty($tab['help']))
196
-					$tab_context['tabs'][$id]['help'] = $tab['help'];
203
+				if (!empty($tab['help'])) {
204
+									$tab_context['tabs'][$id]['help'] = $tab['help'];
205
+				}
197 206
 
198 207
 				// Is this the last one?
199
-				if (!empty($tab['is_last']) && !isset($tab_context['override_last']))
200
-					$tab_context['tabs'][$id]['is_last'] = true;
208
+				if (!empty($tab['is_last']) && !isset($tab_context['override_last'])) {
209
+									$tab_context['tabs'][$id]['is_last'] = true;
210
+				}
201 211
 			}
202 212
 
203 213
 			// Find the selected tab
@@ -214,17 +224,18 @@  discard block
 block discarded – undo
214 224
 		// Show an icon and/or a help item?
215 225
 		if (!empty($selected_tab['icon_class']) || !empty($tab_context['icon_class']) || !empty($selected_tab['icon']) || !empty($tab_context['icon']) || !empty($selected_tab['help']) || !empty($tab_context['help']))
216 226
 		{
217
-			if (!empty($selected_tab['icon_class']) || !empty($tab_context['icon_class']))
218
-				echo '<span class="', !empty($selected_tab['icon_class']) ? $selected_tab['icon_class'] : $tab_context['icon_class'], ' icon"></span>';
219
-			elseif (!empty($selected_tab['icon']) || !empty($tab_context['icon']))
220
-				echo '<img src="', $settings['images_url'], '/icons/', !empty($selected_tab['icon']) ? $selected_tab['icon'] : $tab_context['icon'], '" alt="" class="icon">';
227
+			if (!empty($selected_tab['icon_class']) || !empty($tab_context['icon_class'])) {
228
+							echo '<span class="', !empty($selected_tab['icon_class']) ? $selected_tab['icon_class'] : $tab_context['icon_class'], ' icon"></span>';
229
+			} elseif (!empty($selected_tab['icon']) || !empty($tab_context['icon'])) {
230
+							echo '<img src="', $settings['images_url'], '/icons/', !empty($selected_tab['icon']) ? $selected_tab['icon'] : $tab_context['icon'], '" alt="" class="icon">';
231
+			}
221 232
 
222
-			if (!empty($selected_tab['help']) || !empty($tab_context['help']))
223
-				echo '<a href="', $scripturl, '?action=helpadmin;help=', !empty($selected_tab['help']) ? $selected_tab['help'] : $tab_context['help'], '" onclick="return reqOverlayDiv(this.href);" class="help"><span class="generic_icons help" title="', $txt['help'], '"></span></a>';
233
+			if (!empty($selected_tab['help']) || !empty($tab_context['help'])) {
234
+							echo '<a href="', $scripturl, '?action=helpadmin;help=', !empty($selected_tab['help']) ? $selected_tab['help'] : $tab_context['help'], '" onclick="return reqOverlayDiv(this.href);" class="help"><span class="generic_icons help" title="', $txt['help'], '"></span></a>';
235
+			}
224 236
 
225 237
 			echo $tab_context['title'];
226
-		}
227
-		else
238
+		} else
228 239
 		{
229 240
 			echo '
230 241
 							', $tab_context['title'];
@@ -237,11 +248,12 @@  discard block
 block discarded – undo
237 248
 	}
238 249
 
239 250
 	// Shall we use the tabs? Yes, it's the only known way!
240
-	if (!empty($selected_tab['description']) || !empty($tab_context['description']))
241
-		echo '
251
+	if (!empty($selected_tab['description']) || !empty($tab_context['description'])) {
252
+			echo '
242 253
 					<p class="information">
243 254
 						', !empty($selected_tab['description']) ? $selected_tab['description'] : $tab_context['description'], '
244 255
 					</p>';
256
+	}
245 257
 
246 258
 	// Print out all the items in this tab (if any).
247 259
 	if (!empty($context['tabs']))
@@ -253,8 +265,9 @@  discard block
 block discarded – undo
253 265
 
254 266
 		foreach ($tab_context['tabs'] as $sa => $tab)
255 267
 		{
256
-			if (!empty($tab['disabled']))
257
-				continue;
268
+			if (!empty($tab['disabled'])) {
269
+							continue;
270
+			}
258 271
 
259 272
 			if (!empty($tab['is_selected']))
260 273
 			{
@@ -262,12 +275,12 @@  discard block
 block discarded – undo
262 275
 							<li>
263 276
 								<a class="active" href="', isset($tab['url']) ? $tab['url'] : $menu_context['base_url'] . ';area=' . $menu_context['current_area'] . ';sa=' . $sa, $menu_context['extra_parameters'], isset($tab['add_params']) ? $tab['add_params'] : '', '">', $tab['label'], '</a>
264 277
 							</li>';
265
-			}
266
-			else
267
-				echo '
278
+			} else {
279
+							echo '
268 280
 							<li>
269 281
 								<a href="', isset($tab['url']) ? $tab['url'] : $menu_context['base_url'] . ';area=' . $menu_context['current_area'] . ';sa=' . $sa, $menu_context['extra_parameters'], isset($tab['add_params']) ? $tab['add_params'] : '', '">', $tab['label'], '</a>
270 282
 							</li>';
283
+			}
271 284
 		}
272 285
 
273 286
 		// the end of tabs
Please login to merge, or discard this patch.