Completed
Pull Request — release-2.1 (#4452)
by Colin
07:48
created
avatars/Oxygen/index.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,9 +1,10 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 // Try to handle it with the upper level index.php. (it should know what to do.)
4
-if (file_exists(dirname(dirname(__FILE__)) . '/index.php'))
4
+if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) {
5 5
 	include (dirname(dirname(__FILE__)) . '/index.php');
6
-else
6
+} else {
7 7
 	exit;
8
+}
8 9
 
9 10
 ?>
10 11
\ No newline at end of file
Please login to merge, or discard this patch.
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.
Sources/tasks/CreatePost-Notify.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 class CreatePost_Notify_Background extends SMF_BackgroundTask
19 19
 {
20 20
 	/**
21
-     * This handles notifications when a new post is created - new topic, reply, quotes and mentions.
21
+	 * This handles notifications when a new post is created - new topic, reply, quotes and mentions.
22 22
 	 * @return bool Always returns true
23 23
 	 */
24 24
 	public function execute()
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 
107 107
 			// Don't send a notification if the watching member ignored the member who made the action.
108 108
 			if (!empty($data['pm_ignore_list']) && in_array($data['id_member_updated'], explode(',', $data['pm_ignore_list'])))
109
-			    continue;
109
+				continue;
110 110
 			if (!in_array($type, array('reply', 'topic')) && $notify_types == 2 && $member != $data['id_member_started'])
111 111
 				continue;
112 112
 			elseif (in_array($type, array('reply', 'topic')) && $member == $posterOptions['id'])
Please login to merge, or discard this patch.
Braces   +62 added lines, -46 removed lines patch added patch discarded remove patch
@@ -73,8 +73,9 @@  discard block
 block discarded – undo
73 73
 		while ($row = $smcFunc['db_fetch_assoc']($request))
74 74
 		{
75 75
 			$groups = array_merge(array($row['id_group'], $row['id_post_group']), (empty($row['additional_groups']) ? array() : explode(',', $row['additional_groups'])));
76
-			if (!in_array(1, $groups) && count(array_intersect($groups, explode(',', $row['member_groups']))) == 0)
77
-				continue;
76
+			if (!in_array(1, $groups) && count(array_intersect($groups, explode(',', $row['member_groups']))) == 0) {
77
+							continue;
78
+			}
78 79
 
79 80
 			$members[] = $row['id_member'];
80 81
 			$watched[$row['id_member']] = $row;
@@ -82,8 +83,9 @@  discard block
 block discarded – undo
82 83
 
83 84
 		$smcFunc['db_free_result']($request);
84 85
 
85
-		if (empty($members))
86
-			return true;
86
+		if (empty($members)) {
87
+					return true;
88
+		}
87 89
 
88 90
 		$members = array_unique($members);
89 91
 		$prefs = getNotifyPrefs($members, '', true);
@@ -105,20 +107,23 @@  discard block
 block discarded – undo
105 107
 			$notify_types = !empty($prefs[$member]['msg_notify_type']) ? $prefs[$member]['msg_notify_type'] : 1;
106 108
 
107 109
 			// Don't send a notification if the watching member ignored the member who made the action.
108
-			if (!empty($data['pm_ignore_list']) && in_array($data['id_member_updated'], explode(',', $data['pm_ignore_list'])))
109
-			    continue;
110
-			if (!in_array($type, array('reply', 'topic')) && $notify_types == 2 && $member != $data['id_member_started'])
111
-				continue;
112
-			elseif (in_array($type, array('reply', 'topic')) && $member == $posterOptions['id'])
113
-				continue;
114
-			elseif (!in_array($type, array('reply', 'topic')) && $notify_types == 3)
115
-				continue;
116
-			elseif ($notify_types == 4)
117
-				continue;
110
+			if (!empty($data['pm_ignore_list']) && in_array($data['id_member_updated'], explode(',', $data['pm_ignore_list']))) {
111
+						    continue;
112
+			}
113
+			if (!in_array($type, array('reply', 'topic')) && $notify_types == 2 && $member != $data['id_member_started']) {
114
+							continue;
115
+			} elseif (in_array($type, array('reply', 'topic')) && $member == $posterOptions['id']) {
116
+							continue;
117
+			} elseif (!in_array($type, array('reply', 'topic')) && $notify_types == 3) {
118
+							continue;
119
+			} elseif ($notify_types == 4) {
120
+							continue;
121
+			}
118 122
 
119 123
 			if ($frequency > 2 || (!empty($frequency) && $data['sent']) || in_array($member, $done_members)
120
-				|| (!empty($this->_details['members_only']) && !in_array($member, $this->_details['members_only'])))
121
-				continue;
124
+				|| (!empty($this->_details['members_only']) && !in_array($member, $this->_details['members_only']))) {
125
+							continue;
126
+			}
122 127
 
123 128
 			// Watched topic?
124 129
 			if (!empty($data['id_topic']) && $type != 'topic' && !empty($prefs[$member]))
@@ -128,10 +133,12 @@  discard block
 block discarded – undo
128 133
 
129 134
 				if ($type == 'reply')
130 135
 				{
131
-					if (!empty($prefs[$member]['msg_receive_body']))
132
-						$message_type .= '_body';
133
-					if (!empty($frequency))
134
-						$message_type .= '_once';
136
+					if (!empty($prefs[$member]['msg_receive_body'])) {
137
+											$message_type .= '_body';
138
+					}
139
+					if (!empty($frequency)) {
140
+											$message_type .= '_once';
141
+					}
135 142
 				}
136 143
 
137 144
 				$content_type = 'topic';
@@ -144,12 +151,14 @@  discard block
 block discarded – undo
144 151
 				$content_type = 'board';
145 152
 
146 153
 				$message_type = !empty($frequency) ? 'notify_boards_once' : 'notify_boards';
147
-				if (!empty($prefs[$member]['msg_receive_body']))
148
-					$message_type .= '_body';
154
+				if (!empty($prefs[$member]['msg_receive_body'])) {
155
+									$message_type .= '_body';
156
+				}
149 157
 			}
150 158
 			// If neither of the above, this might be a redundent row due to the OR clause in our SQL query, skip
151
-			else
152
-				continue;
159
+			else {
160
+							continue;
161
+			}
153 162
 
154 163
 			if ($pref & 0x02)
155 164
 			{
@@ -212,14 +221,15 @@  discard block
 block discarded – undo
212 221
 		);
213 222
 
214 223
 		// Insert the alerts if any
215
-		if (!empty($alert_rows))
216
-			$smcFunc['db_insert']('',
224
+		if (!empty($alert_rows)) {
225
+					$smcFunc['db_insert']('',
217 226
 				'{db_prefix}user_alerts',
218 227
 				array('alert_time' => 'int', 'id_member' => 'int', 'id_member_started' => 'int', 'member_name' => 'string',
219 228
 					'content_type' => 'string', 'content_id' => 'int', 'content_action' => 'string', 'is_read' => 'int', 'extra' => 'string'),
220 229
 				$alert_rows,
221 230
 				array()
222 231
 			);
232
+		}
223 233
 
224 234
 		return true;
225 235
 	}
@@ -230,8 +240,9 @@  discard block
 block discarded – undo
230 240
 
231 241
 		foreach ($quotedMembers as $id => $member)
232 242
 		{
233
-			if (!isset($prefs[$id]) || $id == $posterOptions['id'] || empty($prefs[$id]['msg_quote']))
234
-				continue;
243
+			if (!isset($prefs[$id]) || $id == $posterOptions['id'] || empty($prefs[$id]['msg_quote'])) {
244
+							continue;
245
+			}
235 246
 
236 247
 			$done_members[] = $id;
237 248
 
@@ -283,32 +294,35 @@  discard block
 block discarded – undo
283 294
 		{
284 295
 			if (preg_match('/\[quote(.*)?\]/i', $block, $matches))
285 296
 			{
286
-				if ($quote_level == 0)
287
-					$message .= '[quote' . $matches[1] . ']';
297
+				if ($quote_level == 0) {
298
+									$message .= '[quote' . $matches[1] . ']';
299
+				}
288 300
 				$quote_level++;
289
-			}
290
-			elseif (preg_match('/\[\/quote\]/i', $block))
301
+			} elseif (preg_match('/\[\/quote\]/i', $block))
291 302
 			{
292
-				if ($quote_level <= 1)
293
-					$message .= '[/quote]';
303
+				if ($quote_level <= 1) {
304
+									$message .= '[/quote]';
305
+				}
294 306
 				if ($quote_level >= 1)
295 307
 				{
296 308
 					$quote_level--;
297 309
 					$message .= "\n";
298 310
 				}
311
+			} elseif ($quote_level <= 1) {
312
+							$message .= $block;
299 313
 			}
300
-			elseif ($quote_level <= 1)
301
-				$message .= $block;
302 314
 		}
303 315
 
304 316
 		preg_match_all('/\[quote.*?link=msg=([0-9]+).*?\]/i', $message, $matches);
305 317
 
306 318
 		$id_msgs = $matches[1];
307
-		foreach ($id_msgs as $k => $id_msg)
308
-			$id_msgs[$k] = (int) $id_msg;
319
+		foreach ($id_msgs as $k => $id_msg) {
320
+					$id_msgs[$k] = (int) $id_msg;
321
+		}
309 322
 
310
-		if (empty($id_msgs))
311
-			return array();
323
+		if (empty($id_msgs)) {
324
+					return array();
325
+		}
312 326
 
313 327
 		// Get the messages
314 328
 		$request = $smcFunc['db_query']('', '
@@ -326,8 +340,9 @@  discard block
 block discarded – undo
326 340
 		$members = array();
327 341
 		while ($row = $smcFunc['db_fetch_assoc']($request))
328 342
 		{
329
-			if ($posterOptions['id'] == $row['id_member'])
330
-				continue;
343
+			if ($posterOptions['id'] == $row['id_member']) {
344
+							continue;
345
+			}
331 346
 
332 347
 			$members[$row['id_member']] = $row;
333 348
 		}
@@ -341,10 +356,11 @@  discard block
 block discarded – undo
341 356
 
342 357
 		foreach ($members as $id => $member)
343 358
 		{
344
-			if (!empty($prefs[$id]['msg_mention']))
345
-				$done_members[] = $id;
346
-			else
347
-				continue;
359
+			if (!empty($prefs[$id]['msg_mention'])) {
360
+							$done_members[] = $id;
361
+			} else {
362
+							continue;
363
+			}
348 364
 
349 365
 			// Alerts' emails are always instant
350 366
 			if ($prefs[$id]['msg_mention'] & 0x02)
Please login to merge, or discard this patch.
Sources/tasks/Likes-Notify.php 1 patch
Braces   +19 added lines, -14 removed lines patch added patch discarded remove patch
@@ -51,30 +51,33 @@  discard block
 block discarded – undo
51 51
 				$ignored_members = explode(',', $row['pm_ignore_list']);
52 52
 
53 53
 				// If the user is in group 1 anywhere, they can see everything anyway.
54
-				if (in_array(1, $groups) || count(array_intersect($allowed, $groups)) != 0)
55
-					$author = $row['id_member'];
54
+				if (in_array(1, $groups) || count(array_intersect($allowed, $groups)) != 0) {
55
+									$author = $row['id_member'];
56
+				}
56 57
 			}
57 58
 			$smcFunc['db_free_result']($request);
58
-		}
59
-		else
59
+		} else
60 60
 		{
61 61
 			// This isn't something we know natively how to support. Call the hooks, if they're dealing with it, return false, otherwise return the user id.
62 62
 			$hook_results = call_integration_hook('integrate_find_like_author', array($this->_details['content_type'], $this->_details['content_id']));
63
-			foreach ($hook_results as $result)
64
-				if (!empty($result))
63
+			foreach ($hook_results as $result) {
64
+							if (!empty($result))
65 65
 				{
66 66
 					$author = $result;
67
+			}
67 68
 					break;
68 69
 				}
69 70
 		}
70 71
 
71 72
 		// If we didn't have a member... leave.
72
-		if (empty($author))
73
-			return true;
73
+		if (empty($author)) {
74
+					return true;
75
+		}
74 76
 
75 77
 		// If the person who sent the notification is the person whose content it is, do nothing.
76
-		if ($author == $this->_details['sender_id'])
77
-			return true;
78
+		if ($author == $this->_details['sender_id']) {
79
+					return true;
80
+		}
78 81
 
79 82
 		// If the person who sent the notification is on this person's ignore list, do nothing.
80 83
 		if (!empty($ignored_members) && in_array($this->_details['sender_id'], $ignored_members)) {
@@ -88,8 +91,9 @@  discard block
 block discarded – undo
88 91
 		// As a result, the value should really just be non empty.
89 92
 
90 93
 		// Check the value. If no value or it's empty, they didn't want alerts, oh well.
91
-		if (empty($prefs[$author][$this->_details['content_type'] . '_like']))
92
-			return true;
94
+		if (empty($prefs[$author][$this->_details['content_type'] . '_like'])) {
95
+					return true;
96
+		}
93 97
 
94 98
 		// Don't spam the alerts: if there is an existing unread alert of the
95 99
 		// requested type for the target user from the sender, don't make a new one.
@@ -109,8 +113,9 @@  discard block
 block discarded – undo
109 113
 			)
110 114
 		);
111 115
 
112
-		if ($smcFunc['db_num_rows']($request) > 0)
113
-			return true;
116
+		if ($smcFunc['db_num_rows']($request) > 0) {
117
+					return true;
118
+		}
114 119
 		$smcFunc['db_free_result']($request);
115 120
 
116 121
 		// Issue, update, move on.
Please login to merge, or discard this patch.
Themes/default/Display.template.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -670,7 +670,7 @@
 block discarded – undo
670 670
 	// Show "<< Last Edit: Time by Person >>" if this post was edited. But we need the div even if it wasn't modified!
671 671
 	// Because we insert into it through AJAX and we don't want to stop themers moving it around if they so wish so they can put it where they want it.
672 672
 	echo '
673
-									<span class="smalltext modified floatright', !empty($modSettings['show_modify']) && !empty($message['modified']['name']) ? ' mvisible' : '','" id="modified_', $message['id'], '">';
673
+									<span class="smalltext modified floatright', !empty($modSettings['show_modify']) && !empty($message['modified']['name']) ? ' mvisible' : '', '" id="modified_', $message['id'], '">';
674 674
 
675 675
 	if (!empty($modSettings['show_modify']) && !empty($message['modified']['name']))
676 676
 		echo
Please login to merge, or discard this patch.
Braces   +236 added lines, -162 removed lines patch added patch discarded remove patch
@@ -18,18 +18,20 @@  discard block
 block discarded – undo
18 18
 	global $context, $settings, $options, $txt, $scripturl, $modSettings;
19 19
 
20 20
 	// Let them know, if their report was a success!
21
-	if ($context['report_sent'])
22
-		echo '
21
+	if ($context['report_sent']) {
22
+			echo '
23 23
 		<div class="infobox">
24 24
 			', $txt['report_sent'], '
25 25
 		</div>';
26
+	}
26 27
 
27 28
 	// Let them know why their message became unapproved.
28
-	if ($context['becomesUnapproved'])
29
-		echo '
29
+	if ($context['becomesUnapproved']) {
30
+			echo '
30 31
 		<div class="noticebox">
31 32
 			', $txt['post_becomesUnapproved'], '
32 33
 		</div>';
34
+	}
33 35
 
34 36
 	// Show new topic info here?
35 37
 	echo '
@@ -49,11 +51,13 @@  discard block
 block discarded – undo
49 51
 			<p>';
50 52
 
51 53
 		// Show just numbers...?
52
-		if ($settings['display_who_viewing'] == 1)
53
-			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
+		}
54 57
 		// Or show the actual people viewing the topic?
55
-		else
56
-			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
+		}
57 61
 
58 62
 		// Now show how many guests are here too.
59 63
 		echo $txt['who_and'], $context['view_num_guests'], ' ', $context['view_num_guests'] == 1 ? $txt['guest'] : $txt['guests'], $txt['who_viewing_topic'], '
@@ -91,10 +95,11 @@  discard block
 block discarded – undo
91 95
 						<dt class="', $option['voted_this'] ? ' voted' : '', '">', $option['option'], '</dt>
92 96
 						<dd class="statsbar', $option['voted_this'] ? ' voted' : '', '">';
93 97
 
94
-				if ($context['allow_results_view'])
95
-					echo '
98
+				if ($context['allow_results_view']) {
99
+									echo '
96 100
 							', $option['bar_ndt'], '
97 101
 							<span class="percentage">', $option['votes'], ' (', $option['percent'], '%)</span>';
102
+				}
98 103
 
99 104
 				echo '
100 105
 						</dd>';
@@ -103,9 +108,10 @@  discard block
 block discarded – undo
103 108
 			echo '
104 109
 					</dl>';
105 110
 
106
-			if ($context['allow_results_view'])
107
-				echo '
111
+			if ($context['allow_results_view']) {
112
+							echo '
108 113
 					<p><strong>', $txt['poll_total_voters'], ':</strong> ', $context['poll']['total_votes'], '</p>';
114
+			}
109 115
 		}
110 116
 		// They are allowed to vote! Go to it!
111 117
 		else
@@ -114,17 +120,19 @@  discard block
 block discarded – undo
114 120
 					<form action="', $scripturl, '?action=vote;topic=', $context['current_topic'], '.', $context['start'], ';poll=', $context['poll']['id'], '" method="post" accept-charset="', $context['character_set'], '">';
115 121
 
116 122
 			// Show a warning if they are allowed more than one option.
117
-			if ($context['poll']['allowed_warning'])
118
-				echo '
123
+			if ($context['poll']['allowed_warning']) {
124
+							echo '
119 125
 						<p class="smallpadding">', $context['poll']['allowed_warning'], '</p>';
126
+			}
120 127
 
121 128
 			echo '
122 129
 						<ul class="options">';
123 130
 
124 131
 			// Show each option with its button - a radio likely.
125
-			foreach ($context['poll']['options'] as $option)
126
-				echo '
132
+			foreach ($context['poll']['options'] as $option) {
133
+							echo '
127 134
 							<li>', $option['vote_button'], ' <label for="', $option['id'], '">', $option['option'], '</label></li>';
135
+			}
128 136
 
129 137
 			echo '
130 138
 						</ul>
@@ -136,9 +144,10 @@  discard block
 block discarded – undo
136 144
 		}
137 145
 
138 146
 		// Is the clock ticking?
139
-		if (!empty($context['poll']['expire_time']))
140
-			echo '
147
+		if (!empty($context['poll']['expire_time'])) {
148
+					echo '
141 149
 					<p><strong>', ($context['poll']['is_expired'] ? $txt['poll_expired_on'] : $txt['poll_expires_on']), ':</strong> ', $context['poll']['expire_time'], '</p>';
150
+		}
142 151
 
143 152
 		echo '
144 153
 				</div><!-- #poll_options -->
@@ -168,11 +177,13 @@  discard block
 block discarded – undo
168 177
 				<li>
169 178
 					<strong class="event_title"><a href="', $scripturl, '?action=calendar;event=', $event['id'], '">', $event['title'], '</a></strong>';
170 179
 
171
-			if ($event['can_edit'])
172
-				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
+			}
173 183
 
174
-			if ($event['can_export'])
175
-				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
+			}
176 187
 
177 188
 			echo '
178 189
 					<br>';
@@ -180,14 +191,14 @@  discard block
 block discarded – undo
180 191
 			if (!empty($event['allday']))
181 192
 			{
182 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>' : '';
183
-			}
184
-			else
194
+			} else
185 195
 			{
186 196
 				// Display event info relative to user's local timezone
187 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'] . '">';
188 198
 
189
-				if ($event['start_date_local'] != $event['end_date_local'])
190
-					echo trim($event['end_date_local']) . ', ';
199
+				if ($event['start_date_local'] != $event['end_date_local']) {
200
+									echo trim($event['end_date_local']) . ', ';
201
+				}
191 202
 
192 203
 				echo trim($event['end_time_local']);
193 204
 
@@ -196,24 +207,28 @@  discard block
 block discarded – undo
196 207
 				{
197 208
 					echo '</time> (<time datetime="' . $event['start_iso_gmdate'] . '">';
198 209
 
199
-					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'])
200
-						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
+					}
201 213
 
202 214
 					echo trim($event['start_time_orig']), '</time> &ndash; <time datetime="' . $event['end_iso_gmdate'] . '">';
203 215
 
204
-					if ($event['start_date_orig'] != $event['end_date_orig'])
205
-						echo trim($event['end_date_orig']) . ', ';
216
+					if ($event['start_date_orig'] != $event['end_date_orig']) {
217
+											echo trim($event['end_date_orig']) . ', ';
218
+					}
206 219
 
207 220
 					echo trim($event['end_time_orig']), ' ', $event['tz_abbrev'], '</time>)';
208 221
 				}
209 222
 				// Event is scheduled in the user's own timezone? Let 'em know, just to avoid confusion
210
-				else
211
-					echo ' ', $event['tz_abbrev'], '</time>';
223
+				else {
224
+									echo ' ', $event['tz_abbrev'], '</time>';
225
+				}
212 226
 			}
213 227
 
214
-			if (!empty($event['location']))
215
-				echo '
228
+			if (!empty($event['location'])) {
229
+							echo '
216 230
 					<br>', $event['location'];
231
+			}
217 232
 
218 233
 			echo '
219 234
 				</li>';
@@ -250,8 +265,9 @@  discard block
 block discarded – undo
250 265
 	$context['removableMessageIDs'] = array();
251 266
 
252 267
 	// Get all the messages...
253
-	while ($message = $context['get_message']())
254
-		template_single_post($message);
268
+	while ($message = $context['get_message']()) {
269
+			template_single_post($message);
270
+	}
255 271
 
256 272
 	echo '
257 273
 			</form>
@@ -289,8 +305,9 @@  discard block
 block discarded – undo
289 305
 		<div id="display_jump_to"></div>';
290 306
 
291 307
 	// Show quickreply
292
-	if ($context['can_reply'])
293
-		template_quickreply();
308
+	if ($context['can_reply']) {
309
+			template_quickreply();
310
+	}
294 311
 
295 312
 	// User action pop on mobile screen (or actually small screen), this uses responsive css does not check mobile device.
296 313
 	echo '
@@ -305,8 +322,8 @@  discard block
 block discarded – undo
305 322
 		</div>';
306 323
 
307 324
 	// Show the moderation button & pop only if user can moderate
308
-	if ($context['can_moderate_forum'] || $context['user']['is_mod'])
309
-		echo '
325
+	if ($context['can_moderate_forum'] || $context['user']['is_mod']) {
326
+			echo '
310 327
 		<div id="mobile_moderation" class="popup_container">
311 328
 			<div class="popup_window description">
312 329
 				<div class="popup_heading">
@@ -318,6 +335,7 @@  discard block
 block discarded – undo
318 335
 				</div>
319 336
 			</div>
320 337
 		</div>';
338
+	}
321 339
 
322 340
 	echo '
323 341
 		<script>';
@@ -441,9 +459,10 @@  discard block
 block discarded – undo
441 459
 				});
442 460
 			}';
443 461
 
444
-	if (!empty($context['ignoredMsgs']))
445
-		echo '
462
+	if (!empty($context['ignoredMsgs'])) {
463
+			echo '
446 464
 			ignore_toggles([', implode(', ', $context['ignoredMsgs']), '], ', JavaScriptEscape($txt['show_ignore_user_post']), ');';
465
+	}
447 466
 
448 467
 	echo '
449 468
 		</script>';
@@ -460,8 +479,9 @@  discard block
 block discarded – undo
460 479
 
461 480
 	$ignoring = false;
462 481
 
463
-	if ($message['can_remove'])
464
-		$context['removableMessageIDs'][] = $message['id'];
482
+	if ($message['can_remove']) {
483
+			$context['removableMessageIDs'][] = $message['id'];
484
+	}
465 485
 
466 486
 	// Are we ignoring this message?
467 487
 	if (!empty($message['is_ignored']))
@@ -488,9 +508,10 @@  discard block
 block discarded – undo
488 508
 							<div class="custom_fields_above_member">
489 509
 								<ul class="nolist">';
490 510
 
491
-		foreach ($message['custom_fields']['above_member'] as $custom)
492
-			echo '
511
+		foreach ($message['custom_fields']['above_member'] as $custom) {
512
+					echo '
493 513
 									<li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>';
514
+		}
494 515
 
495 516
 		echo '
496 517
 								</ul>
@@ -501,25 +522,28 @@  discard block
 block discarded – undo
501 522
 							<h4>';
502 523
 
503 524
 	// Show online and offline buttons?
504
-	if (!empty($modSettings['onlineEnable']) && !$message['member']['is_guest'])
505
-		echo '
525
+	if (!empty($modSettings['onlineEnable']) && !$message['member']['is_guest']) {
526
+			echo '
506 527
 								', $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>' : '';
528
+	}
507 529
 
508 530
 	// Custom fields BEFORE the username?
509
-	if (!empty($message['custom_fields']['before_member']))
510
-		foreach ($message['custom_fields']['before_member'] as $custom)
531
+	if (!empty($message['custom_fields']['before_member'])) {
532
+			foreach ($message['custom_fields']['before_member'] as $custom)
511 533
 			echo '
512 534
 								<span class="custom ', $custom['col_name'], '">', $custom['value'], '</span>';
535
+	}
513 536
 
514 537
 	// Show a link to the member's profile.
515 538
 	echo '
516 539
 								', $message['member']['link'];
517 540
 
518 541
 	// Custom fields AFTER the username?
519
-	if (!empty($message['custom_fields']['after_member']))
520
-		foreach ($message['custom_fields']['after_member'] as $custom)
542
+	if (!empty($message['custom_fields']['after_member'])) {
543
+			foreach ($message['custom_fields']['after_member'] as $custom)
521 544
 			echo '
522 545
 								<span class="custom ', $custom['col_name'], '">', $custom['value'], '</span>';
546
+	}
523 547
 
524 548
 	// Begin display of user info
525 549
 	echo '
@@ -527,51 +551,59 @@  discard block
 block discarded – undo
527 551
 							<ul class="user_info">';
528 552
 
529 553
 	// Show the user's avatar.
530
-	if (!empty($modSettings['show_user_images']) && empty($options['show_no_avatars']) && !empty($message['member']['avatar']['image']))
531
-		echo '
554
+	if (!empty($modSettings['show_user_images']) && empty($options['show_no_avatars']) && !empty($message['member']['avatar']['image'])) {
555
+			echo '
532 556
 								<li class="avatar">
533 557
 									<a href="', $message['member']['href'], '">', $message['member']['avatar']['image'], '</a>
534 558
 								</li>';
559
+	}
535 560
 
536 561
 	// Are there any custom fields below the avatar?
537
-	if (!empty($message['custom_fields']['below_avatar']))
538
-		foreach ($message['custom_fields']['below_avatar'] as $custom)
562
+	if (!empty($message['custom_fields']['below_avatar'])) {
563
+			foreach ($message['custom_fields']['below_avatar'] as $custom)
539 564
 			echo '
540 565
 								<li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>';
566
+	}
541 567
 
542 568
 	// Show the post group icons, but not for guests.
543
-	if (!$message['member']['is_guest'])
544
-		echo '
569
+	if (!$message['member']['is_guest']) {
570
+			echo '
545 571
 								<li class="icons">', $message['member']['group_icons'], '</li>';
572
+	}
546 573
 
547 574
 	// Show the member's primary group (like 'Administrator') if they have one.
548
-	if (!empty($message['member']['group']))
549
-		echo '
575
+	if (!empty($message['member']['group'])) {
576
+			echo '
550 577
 								<li class="membergroup">', $message['member']['group'], '</li>';
578
+	}
551 579
 
552 580
 	// Show the member's custom title, if they have one.
553
-	if (!empty($message['member']['title']))
554
-		echo '
581
+	if (!empty($message['member']['title'])) {
582
+			echo '
555 583
 								<li class="title">', $message['member']['title'], '</li>';
584
+	}
556 585
 
557 586
 	// Don't show these things for guests.
558 587
 	if (!$message['member']['is_guest'])
559 588
 	{
560 589
 
561 590
 		// 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.
562
-		if ((empty($modSettings['hide_post_group']) || empty($message['member']['group'])) && !empty($message['member']['post_group']))
563
-			echo '
591
+		if ((empty($modSettings['hide_post_group']) || empty($message['member']['group'])) && !empty($message['member']['post_group'])) {
592
+					echo '
564 593
 								<li class="postgroup">', $message['member']['post_group'], '</li>';
594
+		}
565 595
 
566 596
 		// Show how many posts they have made.
567
-		if (!isset($context['disabled_fields']['posts']))
568
-			echo '
597
+		if (!isset($context['disabled_fields']['posts'])) {
598
+					echo '
569 599
 								<li class="postcount">', $txt['member_postcount'], ': ', $message['member']['posts'], '</li>';
600
+		}
570 601
 
571 602
 		// Show their personal text?
572
-		if (!empty($modSettings['show_blurb']) && !empty($message['member']['blurb']))
573
-			echo '
603
+		if (!empty($modSettings['show_blurb']) && !empty($message['member']['blurb'])) {
604
+					echo '
574 605
 								<li class="blurb">', $message['member']['blurb'], '</li>';
606
+		}
575 607
 
576 608
 		// Any custom fields to show as icons?
577 609
 		if (!empty($message['custom_fields']['icons']))
@@ -580,9 +612,10 @@  discard block
 block discarded – undo
580 612
 								<li class="im_icons">
581 613
 									<ol>';
582 614
 
583
-			foreach ($message['custom_fields']['icons'] as $custom)
584
-				echo '
615
+			foreach ($message['custom_fields']['icons'] as $custom) {
616
+							echo '
585 617
 										<li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>';
618
+			}
586 619
 
587 620
 			echo '
588 621
 									</ol>
@@ -597,19 +630,22 @@  discard block
 block discarded – undo
597 630
 									<ol class="profile_icons">';
598 631
 
599 632
 			// Don't show an icon if they haven't specified a website.
600
-			if (!empty($message['member']['website']['url']) && !isset($context['disabled_fields']['website']))
601
-				echo '
633
+			if (!empty($message['member']['website']['url']) && !isset($context['disabled_fields']['website'])) {
634
+							echo '
602 635
 										<li><a href="', $message['member']['website']['url'], '" title="' . $message['member']['website']['title'] . '" target="_blank">', ($settings['use_image_buttons'] ? '<span class="generic_icons www centericon" title="' . $message['member']['website']['title'] . '"></span>' : $txt['www']), '</a></li>';
636
+			}
603 637
 
604 638
 			// Since we know this person isn't a guest, you *can* message them.
605
-			if ($context['can_send_pm'])
606
-				echo '
639
+			if ($context['can_send_pm']) {
640
+							echo '
607 641
 										<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>';
642
+			}
608 643
 
609 644
 			// Show the email if necessary
610
-			if (!empty($message['member']['email']) && $message['member']['show_email'])
611
-				echo '
645
+			if (!empty($message['member']['email']) && $message['member']['show_email']) {
646
+							echo '
612 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
+			}
613 649
 
614 650
 			echo '
615 651
 									</ol>
@@ -617,58 +653,66 @@  discard block
 block discarded – undo
617 653
 		}
618 654
 
619 655
 		// Any custom fields for standard placement?
620
-		if (!empty($message['custom_fields']['standard']))
621
-			foreach ($message['custom_fields']['standard'] as $custom)
656
+		if (!empty($message['custom_fields']['standard'])) {
657
+					foreach ($message['custom_fields']['standard'] as $custom)
622 658
 				echo '
623 659
 								<li class="custom ', $custom['col_name'], '">', $custom['title'], ': ', $custom['value'], '</li>';
660
+		}
624 661
 
625 662
 	}
626 663
 	// Otherwise, show the guest's email.
627
-	elseif (!empty($message['member']['email']) && $message['member']['show_email'])
628
-		echo '
664
+	elseif (!empty($message['member']['email']) && $message['member']['show_email']) {
665
+			echo '
629 666
 								<li class="email">
630 667
 									<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>
631 668
 								</li>';
669
+	}
632 670
 
633 671
 	// Show the IP to this user for this post - because you can moderate?
634
-	if (!empty($context['can_moderate_forum']) && !empty($message['member']['ip']))
635
-		echo '
672
+	if (!empty($context['can_moderate_forum']) && !empty($message['member']['ip'])) {
673
+			echo '
636 674
 								<li class="poster_ip">
637 675
 									<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>
638 676
 								</li>';
677
+	}
639 678
 
640 679
 	// Or, should we show it because this is you?
641
-	elseif ($message['can_see_ip'])
642
-		echo '
680
+	elseif ($message['can_see_ip']) {
681
+			echo '
643 682
 								<li class="poster_ip">
644 683
 									<a href="', $scripturl, '?action=helpadmin;help=see_member_ip" onclick="return reqOverlayDiv(this.href);" class="help">', $message['member']['ip'], '</a>
645 684
 								</li>';
685
+	}
646 686
 
647 687
 	// Okay, are you at least logged in? Then we can show something about why IPs are logged...
648
-	elseif (!$context['user']['is_guest'])
649
-		echo '
688
+	elseif (!$context['user']['is_guest']) {
689
+			echo '
650 690
 								<li class="poster_ip">
651 691
 									<a href="', $scripturl, '?action=helpadmin;help=see_member_ip" onclick="return reqOverlayDiv(this.href);" class="help">', $txt['logged'], '</a>
652 692
 								</li>';
693
+	}
653 694
 
654 695
 	// Otherwise, you see NOTHING!
655
-	else
656
-		echo '
696
+	else {
697
+			echo '
657 698
 								<li class="poster_ip">', $txt['logged'], '</li>';
699
+	}
658 700
 
659 701
 	// Are we showing the warning status?
660 702
 	// Don't show these things for guests.
661
-	if (!$message['member']['is_guest'] && $message['member']['can_see_warning'])
662
-		echo '
703
+	if (!$message['member']['is_guest'] && $message['member']['can_see_warning']) {
704
+			echo '
663 705
 								<li class="warning">
664 706
 									', $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>
665 707
 								</li>';
708
+	}
666 709
 
667 710
 	// Are there any custom fields to show at the bottom of the poster info?
668
-	if (!empty($message['custom_fields']['bottom_poster']))
669
-		foreach ($message['custom_fields']['bottom_poster'] as $custom)
711
+	if (!empty($message['custom_fields']['bottom_poster'])) {
712
+			foreach ($message['custom_fields']['bottom_poster'] as $custom)
670 713
 			echo '
671 714
 								<li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>';
715
+	}
672 716
 
673 717
 	// Poster info ends.
674 718
 	echo '
@@ -698,9 +742,10 @@  discard block
 block discarded – undo
698 742
 	echo '
699 743
 									<span class="smalltext modified floatright', !empty($modSettings['show_modify']) && !empty($message['modified']['name']) ? ' mvisible' : '','" id="modified_', $message['id'], '">';
700 744
 
701
-	if (!empty($modSettings['show_modify']) && !empty($message['modified']['name']))
702
-		echo
745
+	if (!empty($modSettings['show_modify']) && !empty($message['modified']['name'])) {
746
+			echo
703 747
 										$message['modified']['last_edit_text'];
748
+	}
704 749
 
705 750
 	echo '
706 751
 									</span>
@@ -709,22 +754,24 @@  discard block
 block discarded – undo
709 754
 							</div><!-- .keyinfo -->';
710 755
 
711 756
 	// Ignoring this user? Hide the post.
712
-	if ($ignoring)
713
-		echo '
757
+	if ($ignoring) {
758
+			echo '
714 759
 							<div id="msg_', $message['id'], '_ignored_prompt">
715 760
 								', $txt['ignoring_user'], '
716 761
 								<a href="#" id="msg_', $message['id'], '_ignored_link" style="display: none;">', $txt['show_ignore_user_post'], '</a>
717 762
 							</div>';
763
+	}
718 764
 
719 765
 	// Show the post itself, finally!
720 766
 	echo '
721 767
 							<div class="post">';
722 768
 
723
-	if (!$message['approved'] && $message['member']['id'] != 0 && $message['member']['id'] == $context['user']['id'])
724
-		echo '
769
+	if (!$message['approved'] && $message['member']['id'] != 0 && $message['member']['id'] == $context['user']['id']) {
770
+			echo '
725 771
 								<div class="approve_post">
726 772
 									', $txt['post_awaiting_approval'], '
727 773
 								</div>';
774
+	}
728 775
 	echo '
729 776
 								<div class="inner" data-msgid="', $message['id'], '" id="msg_', $message['id'], '"', $ignoring ? ' style="display:none;"' : '', '>
730 777
 									', $message['body'], '
@@ -743,9 +790,9 @@  discard block
 block discarded – undo
743 790
 		foreach ($message['attachment'] as $attachment)
744 791
 		{
745 792
 			// Do we want this attachment to not be showed here?
746
-			if (!empty($modSettings['dont_show_attach_under_post']) && !empty($context['show_attach_under_post'][$attachment['id']]))
747
-				continue;
748
-			elseif (!$div_output)
793
+			if (!empty($modSettings['dont_show_attach_under_post']) && !empty($context['show_attach_under_post'][$attachment['id']])) {
794
+							continue;
795
+			} elseif (!$div_output)
749 796
 			{
750 797
 				$div_output = true;
751 798
 
@@ -762,9 +809,10 @@  discard block
 block discarded – undo
762 809
 									<legend>
763 810
 										', $txt['attach_awaiting_approve'];
764 811
 
765
-				if ($context['can_approve'])
766
-					echo '
812
+				if ($context['can_approve']) {
813
+									echo '
767 814
 										&nbsp;[<a href="', $scripturl, '?action=attachapprove;sa=all;mid=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['approve_all'], '</a>]';
815
+				}
768 816
 
769 817
 				echo '
770 818
 									</legend>';
@@ -778,12 +826,13 @@  discard block
 block discarded – undo
778 826
 				echo '
779 827
 										<div class="attachments_top">';
780 828
 
781
-				if ($attachment['thumbnail']['has_thumb'])
782
-					echo '
829
+				if ($attachment['thumbnail']['has_thumb']) {
830
+									echo '
783 831
 											<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>';
784
-				else
785
-					echo '
832
+				} else {
833
+									echo '
786 834
 											<img src="' . $attachment['href'] . ';image" alt="" width="' . $attachment['width'] . '" height="' . $attachment['height'] . '" class="atc_img">';
835
+				}
787 836
 
788 837
 				echo '
789 838
 										</div><!-- .attachments_top -->';
@@ -793,9 +842,10 @@  discard block
 block discarded – undo
793 842
 										<div class="attachments_bot">
794 843
 											<a href="' . $attachment['href'] . '"><img src="' . $settings['images_url'] . '/icons/clip.png" class="centericon" alt="*">&nbsp;' . $attachment['name'] . '</a> ';
795 844
 
796
-			if (!$attachment['is_approved'] && $context['can_approve'])
797
-				echo '
845
+			if (!$attachment['is_approved'] && $context['can_approve']) {
846
+							echo '
798 847
 											[<a href="', $scripturl, '?action=attachapprove;sa=approve;aid=', $attachment['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['approve'], '</a>] [<a href="', $scripturl, '?action=attachapprove;sa=reject;aid=', $attachment['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['delete'], '</a>] ';
848
+			}
799 849
 			echo '
800 850
 											<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'])), '
801 851
 										</div><!-- .attachments_bot -->';
@@ -804,35 +854,40 @@  discard block
 block discarded – undo
804 854
 									</div><!-- .attached -->';
805 855
 
806 856
 			// Next attachment line ?
807
-			if (++$i % $attachments_per_line === 0)
808
-				echo '
857
+			if (++$i % $attachments_per_line === 0) {
858
+							echo '
809 859
 									<br>';
860
+			}
810 861
 		}
811 862
 
812 863
 		// If we had unapproved attachments clean up.
813
-		if ($last_approved_state == 0)
814
-			echo '
864
+		if ($last_approved_state == 0) {
865
+					echo '
815 866
 								</fieldset>';
867
+		}
816 868
 
817 869
 		// Only do this if we output a div above - otherwise it'll break things
818
-		if ($div_output)
819
-			echo '
870
+		if ($div_output) {
871
+					echo '
820 872
 							</div><!-- #msg_[id]_footer -->';
873
+		}
821 874
 	}
822 875
 
823 876
 	// And stuff below the attachments.
824
-	if ($context['can_report_moderator'] || !empty($modSettings['enable_likes']) || $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'])
825
-		echo '
877
+	if ($context['can_report_moderator'] || !empty($modSettings['enable_likes']) || $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']) {
878
+			echo '
826 879
 							<div class="under_message">';
880
+	}
827 881
 
828 882
 	// Maybe they want to report this post to the moderator(s)?
829
-	if ($context['can_report_moderator'])
830
-		echo '
883
+	if ($context['can_report_moderator']) {
884
+			echo '
831 885
 								<ul class="floatright smalltext">
832 886
 									<li class="report_link">
833 887
 										<a href="', $scripturl, '?action=reporttm;topic=', $context['current_topic'], '.', $message['counter'], ';msg=', $message['id'], '">', $txt['report_to_mod'], '</a>
834 888
 									</li>
835 889
 								</ul>';
890
+	}
836 891
 
837 892
 	// What about likes?
838 893
 	if (!empty($modSettings['enable_likes']))
@@ -879,83 +934,95 @@  discard block
 block discarded – undo
879 934
 								<ul class="quickbuttons">';
880 935
 
881 936
 		// Can they quote? if so they can select and quote as well!
882
-		if ($context['can_quote'])
883
-			echo '
937
+		if ($context['can_quote']) {
938
+					echo '
884 939
 									<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>
885 940
 									<li style="display:none;" id="quoteSelected_', $message['id'], '">
886 941
 										<a href="javascript:void(0)"><span class="generic_icons quote_selected"></span>', $txt['quote_selected_action'], '</a>
887 942
 									</li>';
943
+		}
888 944
 
889 945
 		// Can the user modify the contents of this post? Show the modify inline image.
890
-		if ($message['can_modify'])
891
-			echo '
946
+		if ($message['can_modify']) {
947
+					echo '
892 948
 									<li class="quick_edit">
893 949
 										<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>
894 950
 									</li>';
951
+		}
895 952
 
896
-		if ($message['can_approve'] || $message['can_unapprove'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'])
897
-			echo '
953
+		if ($message['can_approve'] || $message['can_unapprove'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg']) {
954
+					echo '
898 955
 									<li class="post_options">', $txt['post_options'];
956
+		}
899 957
 
900 958
 		echo '
901 959
 										<ul>';
902 960
 
903 961
 		// Can the user modify the contents of this post?
904
-		if ($message['can_modify'])
905
-			echo '
962
+		if ($message['can_modify']) {
963
+					echo '
906 964
 											<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>';
965
+		}
907 966
 
908 967
 		// How about... even... remove it entirely?!
909
-		if ($context['can_delete'] && ($context['topic_first_message'] == $message['id']))
910
-			echo '
968
+		if ($context['can_delete'] && ($context['topic_first_message'] == $message['id'])) {
969
+					echo '
911 970
 											<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>';
912
-
913
-		elseif ($message['can_remove'] && ($context['topic_first_message'] != $message['id']))
914
-			echo '
971
+		} elseif ($message['can_remove'] && ($context['topic_first_message'] != $message['id'])) {
972
+					echo '
915 973
 											<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>';
974
+		}
916 975
 
917 976
 		// What about splitting it off the rest of the topic?
918
-		if ($context['can_split'] && !empty($context['real_num_replies']))
919
-			echo '
977
+		if ($context['can_split'] && !empty($context['real_num_replies'])) {
978
+					echo '
920 979
 											<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>';
980
+		}
921 981
 
922 982
 		// Can we issue a warning because of this post? Remember, we can't give guests warnings.
923
-		if ($context['can_issue_warning'] && !$message['is_message_author'] && !$message['member']['is_guest'])
924
-			echo '
983
+		if ($context['can_issue_warning'] && !$message['is_message_author'] && !$message['member']['is_guest']) {
984
+					echo '
925 985
 											<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>';
986
+		}
926 987
 
927 988
 		// Can we restore topics?
928
-		if ($context['can_restore_msg'])
929
-			echo '
989
+		if ($context['can_restore_msg']) {
990
+					echo '
930 991
 											<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>';
992
+		}
931 993
 
932 994
 		// Maybe we can approve it, maybe we should?
933
-		if ($message['can_approve'])
934
-			echo '
995
+		if ($message['can_approve']) {
996
+					echo '
935 997
 											<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>';
998
+		}
936 999
 
937 1000
 		// Maybe we can unapprove it?
938
-		if ($message['can_unapprove'])
939
-			echo '
1001
+		if ($message['can_unapprove']) {
1002
+					echo '
940 1003
 											<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>';
1004
+		}
941 1005
 
942 1006
 		echo '
943 1007
 										</ul>
944 1008
 									</li>';
945 1009
 
946 1010
 		// Show a checkbox for quick moderation?
947
-		if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && $message['can_remove'])
948
-			echo '
1011
+		if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && $message['can_remove']) {
1012
+					echo '
949 1013
 									<li style="display: none;" id="in_topic_mod_check_', $message['id'], '"></li>';
1014
+		}
950 1015
 
951
-		if ($message['can_approve'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'])
952
-			echo '
1016
+		if ($message['can_approve'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg']) {
1017
+					echo '
953 1018
 								</ul><!-- .quickbuttons -->';
1019
+		}
954 1020
 	}
955 1021
 
956
-	if ($context['can_report_moderator'] || !empty($modSettings['enable_likes']) || $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'])
957
-		echo '
1022
+	if ($context['can_report_moderator'] || !empty($modSettings['enable_likes']) || $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']) {
1023
+			echo '
958 1024
 							</div><!-- .under_message -->';
1025
+	}
959 1026
 
960 1027
 	echo '
961 1028
 						</div><!-- .postarea -->
@@ -968,9 +1035,10 @@  discard block
 block discarded – undo
968 1035
 							<div class="custom_fields_above_signature">
969 1036
 								<ul class="nolist">';
970 1037
 
971
-		foreach ($message['custom_fields']['above_signature'] as $custom)
972
-			echo '
1038
+		foreach ($message['custom_fields']['above_signature'] as $custom) {
1039
+					echo '
973 1040
 									<li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>';
1041
+		}
974 1042
 
975 1043
 		echo '
976 1044
 								</ul>
@@ -978,11 +1046,12 @@  discard block
 block discarded – undo
978 1046
 	}
979 1047
 
980 1048
 	// Show the member's signature?
981
-	if (!empty($message['member']['signature']) && empty($options['show_no_signatures']) && $context['signature_enabled'])
982
-		echo '
1049
+	if (!empty($message['member']['signature']) && empty($options['show_no_signatures']) && $context['signature_enabled']) {
1050
+			echo '
983 1051
 							<div class="signature" id="msg_', $message['id'], '_signature"', $ignoring ? ' style="display:none;"' : '', '>
984 1052
 								', $message['member']['signature'], '
985 1053
 							</div>';
1054
+	}
986 1055
 
987 1056
 
988 1057
 	// Are there any custom profile fields for below the signature?
@@ -992,9 +1061,10 @@  discard block
 block discarded – undo
992 1061
 							<div class="custom_fields_below_signature">
993 1062
 								<ul class="nolist">';
994 1063
 
995
-		foreach ($message['custom_fields']['below_signature'] as $custom)
996
-			echo '
1064
+		foreach ($message['custom_fields']['below_signature'] as $custom) {
1065
+					echo '
997 1066
 									<li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>';
1067
+		}
998 1068
 
999 1069
 		echo '
1000 1070
 								</ul>
@@ -1044,8 +1114,8 @@  discard block
 block discarded – undo
1044 1114
 						<input type="hidden" name="seqnum" value="', $context['form_sequence_number'], '">';
1045 1115
 
1046 1116
 	// Guests just need more.
1047
-	if ($context['user']['is_guest'])
1048
-		echo '
1117
+	if ($context['user']['is_guest']) {
1118
+			echo '
1049 1119
 						<dl id="post_header">
1050 1120
 							<dt>
1051 1121
 								', $txt['name'], ':
@@ -1060,6 +1130,7 @@  discard block
 block discarded – undo
1060 1130
 								<input type="email" name="email" size="25" value="', $context['email'], '" tabindex="', $context['tabindex']++, '" required>
1061 1131
 							</dd>
1062 1132
 						</dl>';
1133
+	}
1063 1134
 
1064 1135
 	echo '
1065 1136
 						', template_control_richedit($context['post_box_name'], 'smileyBox_message', 'bbcBox_message'), '
@@ -1084,12 +1155,13 @@  discard block
 block discarded – undo
1084 1155
 						</script>';
1085 1156
 
1086 1157
 	// Is visual verification enabled?
1087
-	if ($context['require_verification'])
1088
-		echo '
1158
+	if ($context['require_verification']) {
1159
+			echo '
1089 1160
 						<div class="post_verification">
1090 1161
 							<strong>', $txt['verification'], ':</strong>
1091 1162
 							', template_control_verification($context['visual_verification_id'], 'all'), '
1092 1163
 						</div>';
1164
+	}
1093 1165
 
1094 1166
 	// Finally, the submit buttons.
1095 1167
 	echo '
@@ -1105,8 +1177,8 @@  discard block
 block discarded – undo
1105 1177
 		<br class="clear">';
1106 1178
 
1107 1179
 	// Draft autosave available and the user has it enabled?
1108
-	if (!empty($context['drafts_autosave']))
1109
-		echo '
1180
+	if (!empty($context['drafts_autosave'])) {
1181
+			echo '
1110 1182
 		<script>
1111 1183
 			var oDraftAutoSave = new smf_DraftAutoSave({
1112 1184
 				sSelf: \'oDraftAutoSave\',
@@ -1118,12 +1190,14 @@  discard block
 block discarded – undo
1118 1190
 				iFreq: ', (empty($modSettings['masterAutoSaveDraftsDelay']) ? 60000 : $modSettings['masterAutoSaveDraftsDelay'] * 1000), '
1119 1191
 			});
1120 1192
 		</script>';
1193
+	}
1121 1194
 
1122
-	if ($context['show_spellchecking'])
1123
-		echo '
1195
+	if ($context['show_spellchecking']) {
1196
+			echo '
1124 1197
 		<form action="', $scripturl, '?action=spellcheck" method="post" accept-charset="', $context['character_set'], '" name="spell_form" id="spell_form" target="spellWindow">
1125 1198
 			<input type="hidden" name="spellstring" value="">
1126 1199
 		</form>';
1200
+	}
1127 1201
 
1128 1202
 	echo '
1129 1203
 		<script>
Please login to merge, or discard this patch.
proxy.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -118,7 +118,7 @@
 block discarded – undo
118 118
 
119 119
 		// Right, image not cached? Simply redirect, then.
120 120
 		if (!$response)
121
-		    redirectexit($request);
121
+			redirectexit($request);
122 122
 
123 123
 		// Make sure we're serving an image
124 124
 		$contentParts = explode('/', !empty($cached['content_type']) ? $cached['content_type'] : '');
Please login to merge, or discard this patch.
Braces   +33 added lines, -22 removed lines patch added patch discarded remove patch
@@ -63,26 +63,31 @@  discard block
 block discarded – undo
63 63
 	 */
64 64
 	public function checkRequest()
65 65
 	{
66
-		if (!$this->enabled)
67
-			return false;
66
+		if (!$this->enabled) {
67
+					return false;
68
+		}
68 69
 
69 70
 		// Try to create the image cache directory if it doesn't exist
70
-		if (!file_exists($this->cache))
71
-			if (!mkdir($this->cache) || !copy(dirname($this->cache) . '/index.php', $this->cache . '/index.php'))
71
+		if (!file_exists($this->cache)) {
72
+					if (!mkdir($this->cache) || !copy(dirname($this->cache) . '/index.php', $this->cache . '/index.php'))
72 73
 				return false;
74
+		}
73 75
 
74
-		if (empty($_GET['hash']) || empty($_GET['request']))
75
-			return false;
76
+		if (empty($_GET['hash']) || empty($_GET['request'])) {
77
+					return false;
78
+		}
76 79
 
77 80
 		$hash = $_GET['hash'];
78 81
 		$request = $_GET['request'];
79 82
 
80
-		if (md5($request . $this->secret) != $hash)
81
-			return false;
83
+		if (md5($request . $this->secret) != $hash) {
84
+					return false;
85
+		}
82 86
 
83 87
 		// Attempt to cache the request if it doesn't exist
84
-		if (!$this->isCached($request))
85
-			return $this->cacheImage($request);
88
+		if (!$this->isCached($request)) {
89
+					return $this->cacheImage($request);
90
+		}
86 91
 
87 92
 		return true;
88 93
 	}
@@ -111,19 +116,22 @@  discard block
 block discarded – undo
111 116
 		if (!$cached || time() - $cached['time'] > (5 * 86400))
112 117
 		{
113 118
 			@unlink($cached_file);
114
-			if ($this->checkRequest())
115
-				$this->serve();
119
+			if ($this->checkRequest()) {
120
+							$this->serve();
121
+			}
116 122
 			redirectexit($request);
117 123
 		}
118 124
 
119 125
 		// Right, image not cached? Simply redirect, then.
120
-		if (!$response)
121
-		    redirectexit($request);
126
+		if (!$response) {
127
+				    redirectexit($request);
128
+		}
122 129
 
123 130
 		// Make sure we're serving an image
124 131
 		$contentParts = explode('/', !empty($cached['content_type']) ? $cached['content_type'] : '');
125
-		if ($contentParts[0] != 'image')
126
-			exit;
132
+		if ($contentParts[0] != 'image') {
133
+					exit;
134
+		}
127 135
 
128 136
 		header('Content-type: ' . $cached['content_type']);
129 137
 		header('Content-length: ' . $cached['size']);
@@ -170,8 +178,9 @@  discard block
 block discarded – undo
170 178
 		$responseCode = $request->result('code');
171 179
 		$response = $request->result();
172 180
 
173
-		if (empty($response))
174
-			return false;
181
+		if (empty($response)) {
182
+					return false;
183
+		}
175 184
 
176 185
 		if ($responseCode != 200) {
177 186
 			return false;
@@ -181,12 +190,14 @@  discard block
 block discarded – undo
181 190
 
182 191
 		// Make sure the url is returning an image
183 192
 		$contentParts = explode('/', !empty($headers['content-type']) ? $headers['content-type'] : '');
184
-		if ($contentParts[0] != 'image')
185
-			return false;
193
+		if ($contentParts[0] != 'image') {
194
+					return false;
195
+		}
186 196
 
187 197
 		// Validate the filesize
188
-		if ($response['size'] > ($this->maxSize * 1024))
189
-			return false;
198
+		if ($response['size'] > ($this->maxSize * 1024)) {
199
+					return false;
200
+		}
190 201
 
191 202
 		return file_put_contents($dest, json_encode(array(
192 203
 			'content_type' => $headers['content-type'],
Please login to merge, or discard this patch.
Sources/Subs-Package.php 2 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
  * @param bool $single_file If true returns the contents of the file specified by destination if it exists
29 29
  * @param bool $overwrite Whether to overwrite existing files
30 30
  * @param null|array $files_to_extract Specific files to extract
31
- * @return array|false An array of information about extracted files or false on failure
31
+ * @return string An array of information about extracted files or false on failure
32 32
  */
33 33
 function read_tgz_file($gzfilename, $destination, $single_file = false, $overwrite = false, $files_to_extract = null)
34 34
 {
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
  * @param bool $single_file Whether to only extract a single file
60 60
  * @param bool $overwrite Whether to overwrite existing data
61 61
  * @param null|array $files_to_extract If set, only extracts the specified files
62
- * @return array|false An array of information about the extracted files or false on failure
62
+ * @return string An array of information about the extracted files or false on failure
63 63
  */
64 64
 function read_tgz_data($gzfilename, $destination, $single_file = false, $overwrite = false, $files_to_extract = null)
65 65
 {
@@ -3255,7 +3255,7 @@  discard block
 block discarded – undo
3255 3255
 	 * https://php.net/crc32#79567
3256 3256
 	 *
3257 3257
 	 * @param string $number
3258
-	 * @return string The crc32
3258
+	 * @return integer The crc32
3259 3259
 	 */
3260 3260
 	function smf_crc32($number)
3261 3261
 	{
Please login to merge, or discard this patch.
Braces   +853 added lines, -669 removed lines patch added patch discarded remove patch
@@ -16,8 +16,9 @@  discard block
 block discarded – undo
16 16
  * @version 2.1 Beta 4
17 17
  */
18 18
 
19
-if (!defined('SMF'))
19
+if (!defined('SMF')) {
20 20
 	die('No direct access...');
21
+}
21 22
 
22 23
 /**
23 24
  * Reads a .tar.gz file, filename, in and extracts file(s) from it.
@@ -67,47 +68,53 @@  discard block
 block discarded – undo
67 68
 	loadLanguage('Packages');
68 69
 
69 70
 	// This function sorta needs gzinflate!
70
-	if (!function_exists('gzinflate'))
71
-		fatal_lang_error('package_no_zlib', 'critical');
71
+	if (!function_exists('gzinflate')) {
72
+			fatal_lang_error('package_no_zlib', 'critical');
73
+	}
72 74
 
73 75
 	if (substr($gzfilename, 0, 7) == 'http://' || substr($gzfilename, 0, 8) == 'https://')
74 76
 	{
75 77
 		$data = fetch_web_data($gzfilename);
76 78
 
77
-		if ($data === false)
78
-			return false;
79
-	}
80
-	else
79
+		if ($data === false) {
80
+					return false;
81
+		}
82
+	} else
81 83
 	{
82 84
 		$data = @file_get_contents($gzfilename);
83 85
 
84
-		if ($data === false)
85
-			return false;
86
+		if ($data === false) {
87
+					return false;
88
+		}
86 89
 	}
87 90
 
88 91
 	umask(0);
89
-	if (!$single_file && $destination !== null && !file_exists($destination))
90
-		mktree($destination, 0777);
92
+	if (!$single_file && $destination !== null && !file_exists($destination)) {
93
+			mktree($destination, 0777);
94
+	}
91 95
 
92 96
 	// No signature?
93
-	if (strlen($data) < 2)
94
-		return false;
97
+	if (strlen($data) < 2) {
98
+			return false;
99
+	}
95 100
 
96 101
 	$id = unpack('H2a/H2b', substr($data, 0, 2));
97 102
 	if (strtolower($id['a'] . $id['b']) != '1f8b')
98 103
 	{
99 104
 		// Okay, this ain't no tar.gz, but maybe it's a zip file.
100
-		if (substr($data, 0, 2) == 'PK')
101
-			return read_zip_file($gzfilename, $destination, $single_file, $overwrite, $files_to_extract);
102
-		else
103
-			return false;
105
+		if (substr($data, 0, 2) == 'PK') {
106
+					return read_zip_file($gzfilename, $destination, $single_file, $overwrite, $files_to_extract);
107
+		} else {
108
+					return false;
109
+		}
104 110
 	}
105 111
 
106 112
 	$flags = unpack('Ct/Cf', substr($data, 2, 2));
107 113
 
108 114
 	// Not deflate!
109
-	if ($flags['t'] != 8)
110
-		return false;
115
+	if ($flags['t'] != 8) {
116
+			return false;
117
+	}
111 118
 	$flags = $flags['f'];
112 119
 
113 120
 	$offset = 10;
@@ -117,18 +124,21 @@  discard block
 block discarded – undo
117 124
 	// @todo Might be mussed.
118 125
 	if ($flags & 12)
119 126
 	{
120
-		while ($flags & 8 && $data{$offset++} != "\0")
121
-			continue;
122
-		while ($flags & 4 && $data{$offset++} != "\0")
123
-			continue;
127
+		while ($flags & 8 && $data{$offset++} != "\0") {
128
+					continue;
129
+		}
130
+		while ($flags & 4 && $data{$offset++} != "\0") {
131
+					continue;
132
+		}
124 133
 	}
125 134
 
126 135
 	$crc = unpack('Vcrc32/Visize', substr($data, strlen($data) - 8, 8));
127 136
 	$data = @gzinflate(substr($data, $offset, strlen($data) - 8 - $offset));
128 137
 
129 138
 	// smf_crc32 and crc32 may not return the same results, so we accept either.
130
-	if ($crc['crc32'] != smf_crc32($data) && $crc['crc32'] != crc32($data))
131
-		return false;
139
+	if ($crc['crc32'] != smf_crc32($data) && $crc['crc32'] != crc32($data)) {
140
+			return false;
141
+	}
132 142
 
133 143
 	$blocks = strlen($data) / 512 - 1;
134 144
 	$offset = 0;
@@ -149,83 +159,98 @@  discard block
 block discarded – undo
149 159
 
150 160
 		foreach ($current as $k => $v)
151 161
 		{
152
-			if (in_array($k, $octdec))
153
-				$current[$k] = octdec(trim($v));
154
-			else
155
-				$current[$k] = trim($v);
162
+			if (in_array($k, $octdec)) {
163
+							$current[$k] = octdec(trim($v));
164
+			} else {
165
+							$current[$k] = trim($v);
166
+			}
156 167
 		}
157 168
 
158
-		if ($current['type'] == 5 && substr($current['filename'], -1) != '/')
159
-			$current['filename'] .= '/';
169
+		if ($current['type'] == 5 && substr($current['filename'], -1) != '/') {
170
+					$current['filename'] .= '/';
171
+		}
160 172
 
161 173
 		$checksum = 256;
162
-		for ($i = 0; $i < 148; $i++)
163
-			$checksum += ord($header{$i});
164
-		for ($i = 156; $i < 512; $i++)
165
-			$checksum += ord($header{$i});
174
+		for ($i = 0; $i < 148; $i++) {
175
+					$checksum += ord($header{$i});
176
+		}
177
+		for ($i = 156; $i < 512; $i++) {
178
+					$checksum += ord($header{$i});
179
+		}
166 180
 
167
-		if ($current['checksum'] != $checksum)
168
-			break;
181
+		if ($current['checksum'] != $checksum) {
182
+					break;
183
+		}
169 184
 
170 185
 		$size = ceil($current['size'] / 512);
171 186
 		$current['data'] = substr($data, ++$offset << 9, $current['size']);
172 187
 		$offset += $size;
173 188
 
174 189
 		// Not a directory and doesn't exist already...
175
-		if (substr($current['filename'], -1, 1) != '/' && !file_exists($destination . '/' . $current['filename']))
176
-			$write_this = true;
190
+		if (substr($current['filename'], -1, 1) != '/' && !file_exists($destination . '/' . $current['filename'])) {
191
+					$write_this = true;
192
+		}
177 193
 		// File exists... check if it is newer.
178
-		elseif (substr($current['filename'], -1, 1) != '/')
179
-			$write_this = $overwrite || filemtime($destination . '/' . $current['filename']) < $current['mtime'];
194
+		elseif (substr($current['filename'], -1, 1) != '/') {
195
+					$write_this = $overwrite || filemtime($destination . '/' . $current['filename']) < $current['mtime'];
196
+		}
180 197
 		// Folder... create.
181 198
 		elseif ($destination !== null && !$single_file)
182 199
 		{
183 200
 			// Protect from accidental parent directory writing...
184 201
 			$current['filename'] = strtr($current['filename'], array('../' => '', '/..' => ''));
185 202
 
186
-			if (!file_exists($destination . '/' . $current['filename']))
187
-				mktree($destination . '/' . $current['filename'], 0777);
203
+			if (!file_exists($destination . '/' . $current['filename'])) {
204
+							mktree($destination . '/' . $current['filename'], 0777);
205
+			}
188 206
 			$write_this = false;
207
+		} else {
208
+					$write_this = false;
189 209
 		}
190
-		else
191
-			$write_this = false;
192 210
 
193 211
 		if ($write_this && $destination !== null)
194 212
 		{
195
-			if (strpos($current['filename'], '/') !== false && !$single_file)
196
-				mktree($destination . '/' . dirname($current['filename']), 0777);
213
+			if (strpos($current['filename'], '/') !== false && !$single_file) {
214
+							mktree($destination . '/' . dirname($current['filename']), 0777);
215
+			}
197 216
 
198 217
 			// Is this the file we're looking for?
199
-			if ($single_file && ($destination == $current['filename'] || $destination == '*/' . basename($current['filename'])))
200
-				return $current['data'];
218
+			if ($single_file && ($destination == $current['filename'] || $destination == '*/' . basename($current['filename']))) {
219
+							return $current['data'];
220
+			}
201 221
 			// If we're looking for another file, keep going.
202
-			elseif ($single_file)
203
-				continue;
222
+			elseif ($single_file) {
223
+							continue;
224
+			}
204 225
 			// Looking for restricted files?
205
-			elseif ($files_to_extract !== null && !in_array($current['filename'], $files_to_extract))
206
-				continue;
226
+			elseif ($files_to_extract !== null && !in_array($current['filename'], $files_to_extract)) {
227
+							continue;
228
+			}
207 229
 
208 230
 			package_put_contents($destination . '/' . $current['filename'], $current['data']);
209 231
 		}
210 232
 
211
-		if (substr($current['filename'], -1, 1) != '/')
212
-			$return[] = array(
233
+		if (substr($current['filename'], -1, 1) != '/') {
234
+					$return[] = array(
213 235
 				'filename' => $current['filename'],
214 236
 				'md5' => md5($current['data']),
215 237
 				'preview' => substr($current['data'], 0, 100),
216 238
 				'size' => $current['size'],
217 239
 				'skipped' => false
218 240
 			);
241
+		}
219 242
 	}
220 243
 
221
-	if ($destination !== null && !$single_file)
222
-		package_flush_cache();
244
+	if ($destination !== null && !$single_file) {
245
+			package_flush_cache();
246
+	}
223 247
 
224
-	if ($single_file)
225
-		return false;
226
-	else
227
-		return $return;
228
-}
248
+	if ($single_file) {
249
+			return false;
250
+	} else {
251
+			return $return;
252
+	}
253
+	}
229 254
 
230 255
 /**
231 256
  * Extract zip data. A functional copy of {@list read_zip_data()}.
@@ -254,65 +279,74 @@  discard block
 block discarded – undo
254 279
 			{
255 280
 				$i = $iterator->getSubPathname();
256 281
 				// If this is a file, and it doesn't exist.... happy days!
257
-				if (substr($i, -1) != '/' && !file_exists($destination . '/' . $i))
258
-					$write_this = true;
282
+				if (substr($i, -1) != '/' && !file_exists($destination . '/' . $i)) {
283
+									$write_this = true;
284
+				}
259 285
 				// If the file exists, we may not want to overwrite it.
260
-				elseif (substr($i, -1) != '/')
261
-					$write_this = $overwrite;
262
-				else
263
-					$write_this = false;
286
+				elseif (substr($i, -1) != '/') {
287
+									$write_this = $overwrite;
288
+				} else {
289
+									$write_this = false;
290
+				}
264 291
 
265 292
 				// Get the actual compressed data.
266
-				if (!$file_info->isDir())
267
-					$file_data = file_get_contents($file_info);
268
-				elseif ($destination !== null && !$single_file)
293
+				if (!$file_info->isDir()) {
294
+									$file_data = file_get_contents($file_info);
295
+				} elseif ($destination !== null && !$single_file)
269 296
 				{
270 297
 					// Folder... create.
271
-					if (!file_exists($destination . '/' . $i))
272
-						mktree($destination . '/' . $i, 0777);
298
+					if (!file_exists($destination . '/' . $i)) {
299
+											mktree($destination . '/' . $i, 0777);
300
+					}
273 301
 					$file_data = null;
302
+				} else {
303
+									$file_data = null;
274 304
 				}
275
-				else
276
-					$file_data = null;
277 305
 
278 306
 				// Okay!  We can write this file, looks good from here...
279 307
 				if ($write_this && $destination !== null)
280 308
 				{
281
-					if (!$single_file && !is_dir($destination . '/' . dirname($i)))
282
-						mktree($destination . '/' . dirname($i), 0777);
309
+					if (!$single_file && !is_dir($destination . '/' . dirname($i))) {
310
+											mktree($destination . '/' . dirname($i), 0777);
311
+					}
283 312
 
284 313
 					// If we're looking for a specific file, and this is it... ka-bam, baby.
285
-					if ($single_file && ($destination == $i || $destination == '*/' . basename($i)))
286
-						return $file_data;
314
+					if ($single_file && ($destination == $i || $destination == '*/' . basename($i))) {
315
+											return $file_data;
316
+					}
287 317
 					// Oh?  Another file.  Fine.  You don't like this file, do you?  I know how it is.  Yeah... just go away.  No, don't apologize.  I know this file's just not *good enough* for you.
288
-					elseif ($single_file)
289
-						continue;
318
+					elseif ($single_file) {
319
+											continue;
320
+					}
290 321
 					// Don't really want this?
291
-					elseif ($files_to_extract !== null && !in_array($i, $files_to_extract))
292
-						continue;
322
+					elseif ($files_to_extract !== null && !in_array($i, $files_to_extract)) {
323
+											continue;
324
+					}
293 325
 
294 326
 					package_put_contents($destination . '/' . $i, $file_data);
295 327
 				}
296 328
 
297
-				if (substr($i, -1, 1) != '/')
298
-					$return[] = array(
329
+				if (substr($i, -1, 1) != '/') {
330
+									$return[] = array(
299 331
 						'filename' => $i,
300 332
 						'md5' => md5($file_data),
301 333
 						'preview' => substr($file_data, 0, 100),
302 334
 						'size' => strlen($file_data),
303 335
 						'skipped' => false
304 336
 					);
337
+				}
305 338
 			}
306 339
 
307
-		if ($destination !== null && !$single_file)
308
-			package_flush_cache();
340
+		if ($destination !== null && !$single_file) {
341
+					package_flush_cache();
342
+		}
309 343
 
310
-		if ($single_file)
311
-			return false;
312
-		else
313
-			return $return;
314
-	}
315
-	catch (Exception $e)
344
+		if ($single_file) {
345
+					return false;
346
+		} else {
347
+					return $return;
348
+		}
349
+	} catch (Exception $e)
316 350
 	{
317 351
 		return false;
318 352
 	}
@@ -334,13 +368,15 @@  discard block
 block discarded – undo
334 368
 function read_zip_data($data, $destination, $single_file = false, $overwrite = false, $files_to_extract = null)
335 369
 {
336 370
 	umask(0);
337
-	if ($destination !== null && !file_exists($destination) && !$single_file)
338
-		mktree($destination, 0777);
371
+	if ($destination !== null && !file_exists($destination) && !$single_file) {
372
+			mktree($destination, 0777);
373
+	}
339 374
 
340 375
 	// Look for the end of directory signature 0x06054b50
341 376
 	$data_ecr = explode("\x50\x4b\x05\x06", $data);
342
-	if (!isset($data_ecr[1]))
343
-		return false;
377
+	if (!isset($data_ecr[1])) {
378
+			return false;
379
+	}
344 380
 
345 381
 	$return = array();
346 382
 
@@ -355,8 +391,9 @@  discard block
 block discarded – undo
355 391
 	array_shift($file_sections);
356 392
 
357 393
 	// sections and count from the signature must match or the zip file is bad
358
-	if (count($file_sections) != $zip_info['files'])
359
-		return false;
394
+	if (count($file_sections) != $zip_info['files']) {
395
+			return false;
396
+	}
360 397
 
361 398
 	// go though each file in the archive
362 399
 	foreach ($file_sections as $data)
@@ -378,68 +415,79 @@  discard block
 block discarded – undo
378 415
 		}
379 416
 
380 417
 		// If this is a file, and it doesn't exist.... happy days!
381
-		if (substr($file_info['filename'], -1) != '/' && !file_exists($destination . '/' . $file_info['filename']))
382
-			$write_this = true;
418
+		if (substr($file_info['filename'], -1) != '/' && !file_exists($destination . '/' . $file_info['filename'])) {
419
+					$write_this = true;
420
+		}
383 421
 		// If the file exists, we may not want to overwrite it.
384
-		elseif (substr($file_info['filename'], -1) != '/')
385
-			$write_this = $overwrite;
422
+		elseif (substr($file_info['filename'], -1) != '/') {
423
+					$write_this = $overwrite;
424
+		}
386 425
 		// This is a directory, so we're gonna want to create it. (probably...)
387 426
 		elseif ($destination !== null && !$single_file)
388 427
 		{
389 428
 			// Just a little accident prevention, don't mind me.
390 429
 			$file_info['filename'] = strtr($file_info['filename'], array('../' => '', '/..' => ''));
391 430
 
392
-			if (!file_exists($destination . '/' . $file_info['filename']))
393
-				mktree($destination . '/' . $file_info['filename'], 0777);
431
+			if (!file_exists($destination . '/' . $file_info['filename'])) {
432
+							mktree($destination . '/' . $file_info['filename'], 0777);
433
+			}
394 434
 			$write_this = false;
435
+		} else {
436
+					$write_this = false;
395 437
 		}
396
-		else
397
-			$write_this = false;
398 438
 
399 439
 		// Get the actual compressed data.
400 440
 		$file_info['data'] = substr($data, 26 + $file_info['filename_length'] + $file_info['extrafield_length']);
401 441
 
402 442
 		// Only inflate it if we need to ;)
403
-		if (!empty($file_info['compress_method']) || ($file_info['compressed_size'] != $file_info['size']))
404
-			$file_info['data'] = gzinflate($file_info['data']);
443
+		if (!empty($file_info['compress_method']) || ($file_info['compressed_size'] != $file_info['size'])) {
444
+					$file_info['data'] = gzinflate($file_info['data']);
445
+		}
405 446
 
406 447
 		// Okay!  We can write this file, looks good from here...
407 448
 		if ($write_this && $destination !== null)
408 449
 		{
409
-			if ((strpos($file_info['filename'], '/') !== false && !$single_file) || (!$single_file && !is_dir($file_info['dir'])))
410
-				mktree($file_info['dir'], 0777);
450
+			if ((strpos($file_info['filename'], '/') !== false && !$single_file) || (!$single_file && !is_dir($file_info['dir']))) {
451
+							mktree($file_info['dir'], 0777);
452
+			}
411 453
 
412 454
 			// If we're looking for a specific file, and this is it... ka-bam, baby.
413
-			if ($single_file && ($destination == $file_info['filename'] || $destination == '*/' . basename($file_info['filename'])))
414
-				return $file_info['data'];
455
+			if ($single_file && ($destination == $file_info['filename'] || $destination == '*/' . basename($file_info['filename']))) {
456
+							return $file_info['data'];
457
+			}
415 458
 			// Oh?  Another file.  Fine.  You don't like this file, do you?  I know how it is.  Yeah... just go away.  No, don't apologize.  I know this file's just not *good enough* for you.
416
-			elseif ($single_file)
417
-				continue;
459
+			elseif ($single_file) {
460
+							continue;
461
+			}
418 462
 			// Don't really want this?
419
-			elseif ($files_to_extract !== null && !in_array($file_info['filename'], $files_to_extract))
420
-				continue;
463
+			elseif ($files_to_extract !== null && !in_array($file_info['filename'], $files_to_extract)) {
464
+							continue;
465
+			}
421 466
 
422 467
 			package_put_contents($destination . '/' . $file_info['filename'], $file_info['data']);
423 468
 		}
424 469
 
425
-		if (substr($file_info['filename'], -1, 1) != '/')
426
-			$return[] = array(
470
+		if (substr($file_info['filename'], -1, 1) != '/') {
471
+					$return[] = array(
427 472
 				'filename' => $file_info['filename'],
428 473
 				'md5' => md5($file_info['data']),
429 474
 				'preview' => substr($file_info['data'], 0, 100),
430 475
 				'size' => $file_info['size'],
431 476
 				'skipped' => false
432 477
 			);
478
+		}
433 479
 	}
434 480
 
435
-	if ($destination !== null && !$single_file)
436
-		package_flush_cache();
481
+	if ($destination !== null && !$single_file) {
482
+			package_flush_cache();
483
+	}
437 484
 
438
-	if ($single_file)
439
-		return false;
440
-	else
441
-		return $return;
442
-}
485
+	if ($single_file) {
486
+			return false;
487
+	} else {
488
+			return $return;
489
+	}
490
+	}
443 491
 
444 492
 /**
445 493
  * Checks the existence of a remote file since file_exists() does not do remote.
@@ -451,14 +499,16 @@  discard block
 block discarded – undo
451 499
 {
452 500
 	$a_url = parse_url($url);
453 501
 
454
-	if (!isset($a_url['scheme']))
455
-		return false;
502
+	if (!isset($a_url['scheme'])) {
503
+			return false;
504
+	}
456 505
 
457 506
 	// Attempt to connect...
458 507
 	$temp = '';
459 508
 	$fid = fsockopen($a_url['host'], !isset($a_url['port']) ? 80 : $a_url['port'], $temp, $temp, 8);
460
-	if (!$fid)
461
-		return false;
509
+	if (!$fid) {
510
+			return false;
511
+	}
462 512
 
463 513
 	fputs($fid, 'HEAD ' . $a_url['path'] . ' HTTP/1.0' . "\r\n" . 'Host: ' . $a_url['host'] . "\r\n\r\n");
464 514
 	$head = fread($fid, 1024);
@@ -493,8 +543,9 @@  discard block
 block discarded – undo
493 543
 	while ($row = $smcFunc['db_fetch_assoc']($request))
494 544
 	{
495 545
 		// Already found this? If so don't add it twice!
496
-		if (in_array($row['package_id'], $found))
497
-			continue;
546
+		if (in_array($row['package_id'], $found)) {
547
+					continue;
548
+		}
498 549
 
499 550
 		$found[] = $row['package_id'];
500 551
 
@@ -529,19 +580,21 @@  discard block
 block discarded – undo
529 580
 	global $sourcedir, $packagesdir;
530 581
 
531 582
 	// Extract package-info.xml from downloaded file. (*/ is used because it could be in any directory.)
532
-	if (strpos($gzfilename, 'http://') !== false || strpos($gzfilename, 'https://') !== false)
533
-		$packageInfo = read_tgz_data($gzfilename, 'package-info.xml', true);
534
-	else
583
+	if (strpos($gzfilename, 'http://') !== false || strpos($gzfilename, 'https://') !== false) {
584
+			$packageInfo = read_tgz_data($gzfilename, 'package-info.xml', true);
585
+	} else
535 586
 	{
536
-		if (!file_exists($packagesdir . '/' . $gzfilename))
537
-			return 'package_get_error_not_found';
587
+		if (!file_exists($packagesdir . '/' . $gzfilename)) {
588
+					return 'package_get_error_not_found';
589
+		}
538 590
 
539
-		if (is_file($packagesdir . '/' . $gzfilename))
540
-			$packageInfo = read_tgz_file($packagesdir . '/' . $gzfilename, '*/package-info.xml', true);
541
-		elseif (file_exists($packagesdir . '/' . $gzfilename . '/package-info.xml'))
542
-			$packageInfo = file_get_contents($packagesdir . '/' . $gzfilename . '/package-info.xml');
543
-		else
544
-			return 'package_get_error_missing_xml';
591
+		if (is_file($packagesdir . '/' . $gzfilename)) {
592
+					$packageInfo = read_tgz_file($packagesdir . '/' . $gzfilename, '*/package-info.xml', true);
593
+		} elseif (file_exists($packagesdir . '/' . $gzfilename . '/package-info.xml')) {
594
+					$packageInfo = file_get_contents($packagesdir . '/' . $gzfilename . '/package-info.xml');
595
+		} else {
596
+					return 'package_get_error_missing_xml';
597
+		}
545 598
 	}
546 599
 
547 600
 	// Nothing?
@@ -549,10 +602,11 @@  discard block
 block discarded – undo
549 602
 	{
550 603
 		// Perhaps they are trying to install a theme, lets tell them nicely this is the wrong function
551 604
 		$packageInfo = read_tgz_file($packagesdir . '/' . $gzfilename, '*/theme_info.xml', true);
552
-		if (!empty($packageInfo))
553
-			return 'package_get_error_is_theme';
554
-		else
555
-			return 'package_get_error_is_zero';
605
+		if (!empty($packageInfo)) {
606
+					return 'package_get_error_is_theme';
607
+		} else {
608
+					return 'package_get_error_is_zero';
609
+		}
556 610
 	}
557 611
 
558 612
 	// Parse package-info.xml into an xmlArray.
@@ -560,8 +614,9 @@  discard block
 block discarded – undo
560 614
 	$packageInfo = new xmlArray($packageInfo);
561 615
 
562 616
 	// @todo Error message of some sort?
563
-	if (!$packageInfo->exists('package-info[0]'))
564
-		return 'package_get_error_packageinfo_corrupt';
617
+	if (!$packageInfo->exists('package-info[0]')) {
618
+			return 'package_get_error_packageinfo_corrupt';
619
+	}
565 620
 
566 621
 	$packageInfo = $packageInfo->path('package-info[0]');
567 622
 
@@ -580,8 +635,9 @@  discard block
 block discarded – undo
580 635
 		}
581 636
 	}
582 637
 
583
-	if (!isset($package['type']))
584
-		$package['type'] = 'modification';
638
+	if (!isset($package['type'])) {
639
+			$package['type'] = 'modification';
640
+	}
585 641
 
586 642
 	return $package;
587 643
 }
@@ -634,15 +690,14 @@  discard block
 block discarded – undo
634 690
 					{
635 691
 						$ftp_file = strtr($file, array($_SESSION['pack_ftp']['root'] => ''));
636 692
 						$package_ftp->chmod($ftp_file, $perms);
693
+					} else {
694
+											smf_chmod($file, $perms);
637 695
 					}
638
-					else
639
-						smf_chmod($file, $perms);
640 696
 
641 697
 					$new_permissions = @fileperms($file);
642 698
 					$result = $new_permissions == $perms ? 'success' : 'failure';
643 699
 					unset($_SESSION['pack_ftp']['original_perms'][$file]);
644
-				}
645
-				elseif ($do_change)
700
+				} elseif ($do_change)
646 701
 				{
647 702
 					$new_permissions = '';
648 703
 					$result = 'skipped';
@@ -758,8 +813,7 @@  discard block
 block discarded – undo
758 813
 
759 814
 			$context['sub_template'] = 'show_list';
760 815
 			$context['default_list'] = 'restore_file_permissions';
761
-		}
762
-		else
816
+		} else
763 817
 		{
764 818
 			unset($listOptions['columns']['result']);
765 819
 		}
@@ -769,12 +823,14 @@  discard block
 block discarded – undo
769 823
 		createList($listOptions);
770 824
 
771 825
 		// If we just restored permissions then whereever we are, we are now done and dusted.
772
-		if (!empty($_POST['restore_perms']))
773
-			obExit();
826
+		if (!empty($_POST['restore_perms'])) {
827
+					obExit();
828
+		}
774 829
 	}
775 830
 	// Otherwise, it's entirely irrelevant?
776
-	elseif ($restore_write_status)
777
-		return true;
831
+	elseif ($restore_write_status) {
832
+			return true;
833
+	}
778 834
 
779 835
 	// This is where we report what we got up to.
780 836
 	$return_data = array(
@@ -812,11 +868,12 @@  discard block
 block discarded – undo
812 868
 			if (!in_array($_POST['ftp_path'], array('', '/')))
813 869
 			{
814 870
 				$ftp_root = strtr($boarddir, array($_POST['ftp_path'] => ''));
815
-				if (substr($ftp_root, -1) == '/' && ($_POST['ftp_path'] == '' || substr($_POST['ftp_path'], 0, 1) == '/'))
816
-					$ftp_root = substr($ftp_root, 0, -1);
871
+				if (substr($ftp_root, -1) == '/' && ($_POST['ftp_path'] == '' || substr($_POST['ftp_path'], 0, 1) == '/')) {
872
+									$ftp_root = substr($ftp_root, 0, -1);
873
+				}
874
+			} else {
875
+							$ftp_root = $boarddir;
817 876
 			}
818
-			else
819
-				$ftp_root = $boarddir;
820 877
 
821 878
 			$_SESSION['pack_ftp'] = array(
822 879
 				'server' => $_POST['ftp_server'],
@@ -828,8 +885,9 @@  discard block
 block discarded – undo
828 885
 				'connected' => true,
829 886
 			);
830 887
 
831
-			if (!isset($modSettings['package_path']) || $modSettings['package_path'] != $_POST['ftp_path'])
832
-				updateSettings(array('package_path' => $_POST['ftp_path']));
888
+			if (!isset($modSettings['package_path']) || $modSettings['package_path'] != $_POST['ftp_path']) {
889
+							updateSettings(array('package_path' => $_POST['ftp_path']));
890
+			}
833 891
 
834 892
 			// This is now the primary connection.
835 893
 			$package_ftp = $ftp;
@@ -842,12 +900,13 @@  discard block
 block discarded – undo
842 900
 		foreach ($chmodFiles as $k => $file)
843 901
 		{
844 902
 			// Sometimes this can somehow happen maybe?
845
-			if (empty($file))
846
-				unset($chmodFiles[$k]);
903
+			if (empty($file)) {
904
+							unset($chmodFiles[$k]);
905
+			}
847 906
 			// Already writable?
848
-			elseif (@is_writable($file))
849
-				$return_data['files']['writable'][] = $file;
850
-			else
907
+			elseif (@is_writable($file)) {
908
+							$return_data['files']['writable'][] = $file;
909
+			} else
851 910
 			{
852 911
 				// Now try to change that.
853 912
 				$return_data['files'][package_chmod($file, 'writable', true) ? 'writable' : 'notwritable'][] = $file;
@@ -864,19 +923,21 @@  discard block
 block discarded – undo
864 923
 			{
865 924
 				require_once($sourcedir . '/Class-Package.php');
866 925
 				$ftp = new ftp_connection(null);
926
+			} elseif ($ftp->error !== false && !isset($ftp_error)) {
927
+							$ftp_error = $ftp->last_message === null ? '' : $ftp->last_message;
867 928
 			}
868
-			elseif ($ftp->error !== false && !isset($ftp_error))
869
-				$ftp_error = $ftp->last_message === null ? '' : $ftp->last_message;
870 929
 
871 930
 			list ($username, $detect_path, $found_path) = $ftp->detect_path($boarddir);
872 931
 
873
-			if ($found_path)
874
-				$_POST['ftp_path'] = $detect_path;
875
-			elseif (!isset($_POST['ftp_path']))
876
-				$_POST['ftp_path'] = isset($modSettings['package_path']) ? $modSettings['package_path'] : $detect_path;
932
+			if ($found_path) {
933
+							$_POST['ftp_path'] = $detect_path;
934
+			} elseif (!isset($_POST['ftp_path'])) {
935
+							$_POST['ftp_path'] = isset($modSettings['package_path']) ? $modSettings['package_path'] : $detect_path;
936
+			}
877 937
 
878
-			if (!isset($_POST['ftp_username']))
879
-				$_POST['ftp_username'] = $username;
938
+			if (!isset($_POST['ftp_username'])) {
939
+							$_POST['ftp_username'] = $username;
940
+			}
880 941
 		}
881 942
 
882 943
 		$context['package_ftp'] = array(
@@ -889,8 +950,9 @@  discard block
 block discarded – undo
889 950
 		);
890 951
 
891 952
 		// Which files failed?
892
-		if (!isset($context['notwritable_files']))
893
-			$context['notwritable_files'] = array();
953
+		if (!isset($context['notwritable_files'])) {
954
+					$context['notwritable_files'] = array();
955
+		}
894 956
 		$context['notwritable_files'] = array_merge($context['notwritable_files'], $return_data['files']['notwritable']);
895 957
 
896 958
 		// Sent here to die?
@@ -923,40 +985,48 @@  discard block
 block discarded – undo
923 985
 		foreach ($files as $k => $file)
924 986
 		{
925 987
 			// If this file doesn't exist, then we actually want to look at the directory, no?
926
-			if (!file_exists($file))
927
-				$file = dirname($file);
988
+			if (!file_exists($file)) {
989
+							$file = dirname($file);
990
+			}
928 991
 
929 992
 			// This looks odd, but it's an attempt to work around PHP suExec.
930
-			if (!@is_writable($file))
931
-				smf_chmod($file, 0755);
932
-			if (!@is_writable($file))
933
-				smf_chmod($file, 0777);
934
-			if (!@is_writable(dirname($file)))
935
-				smf_chmod($file, 0755);
936
-			if (!@is_writable(dirname($file)))
937
-				smf_chmod($file, 0777);
993
+			if (!@is_writable($file)) {
994
+							smf_chmod($file, 0755);
995
+			}
996
+			if (!@is_writable($file)) {
997
+							smf_chmod($file, 0777);
998
+			}
999
+			if (!@is_writable(dirname($file))) {
1000
+							smf_chmod($file, 0755);
1001
+			}
1002
+			if (!@is_writable(dirname($file))) {
1003
+							smf_chmod($file, 0777);
1004
+			}
938 1005
 
939 1006
 			$fp = is_dir($file) ? @opendir($file) : @fopen($file, 'rb');
940 1007
 			if (@is_writable($file) && $fp)
941 1008
 			{
942 1009
 				unset($files[$k]);
943
-				if (!is_dir($file))
944
-					fclose($fp);
945
-				else
946
-					closedir($fp);
1010
+				if (!is_dir($file)) {
1011
+									fclose($fp);
1012
+				} else {
1013
+									closedir($fp);
1014
+				}
947 1015
 			}
948 1016
 		}
949 1017
 
950 1018
 		// No FTP required!
951
-		if (empty($files))
952
-			return array();
1019
+		if (empty($files)) {
1020
+					return array();
1021
+		}
953 1022
 	}
954 1023
 
955 1024
 	// They've opted to not use FTP, and try anyway.
956 1025
 	if (isset($_SESSION['pack_ftp']) && $_SESSION['pack_ftp'] == false)
957 1026
 	{
958
-		if ($files === null)
959
-			return array();
1027
+		if ($files === null) {
1028
+					return array();
1029
+		}
960 1030
 
961 1031
 		foreach ($files as $k => $file)
962 1032
 		{
@@ -968,26 +1038,29 @@  discard block
 block discarded – undo
968 1038
 				smf_chmod($file, 0755);
969 1039
 			}
970 1040
 
971
-			if (!@is_writable($file))
972
-				smf_chmod($file, 0777);
973
-			if (!@is_writable(dirname($file)))
974
-				smf_chmod(dirname($file), 0777);
1041
+			if (!@is_writable($file)) {
1042
+							smf_chmod($file, 0777);
1043
+			}
1044
+			if (!@is_writable(dirname($file))) {
1045
+							smf_chmod(dirname($file), 0777);
1046
+			}
975 1047
 
976
-			if (@is_writable($file))
977
-				unset($files[$k]);
1048
+			if (@is_writable($file)) {
1049
+							unset($files[$k]);
1050
+			}
978 1051
 		}
979 1052
 
980 1053
 		return $files;
981
-	}
982
-	elseif (isset($_SESSION['pack_ftp']))
1054
+	} elseif (isset($_SESSION['pack_ftp']))
983 1055
 	{
984 1056
 		// Load the file containing the ftp_connection class.
985 1057
 		require_once($sourcedir . '/Class-Package.php');
986 1058
 
987 1059
 		$package_ftp = new ftp_connection($_SESSION['pack_ftp']['server'], $_SESSION['pack_ftp']['port'], $_SESSION['pack_ftp']['username'], package_crypt($_SESSION['pack_ftp']['password']));
988 1060
 
989
-		if ($files === null)
990
-			return array();
1061
+		if ($files === null) {
1062
+					return array();
1063
+		}
991 1064
 
992 1065
 		foreach ($files as $k => $file)
993 1066
 		{
@@ -1001,13 +1074,16 @@  discard block
 block discarded – undo
1001 1074
 				$package_ftp->chmod($ftp_file, 0755);
1002 1075
 			}
1003 1076
 
1004
-			if (!@is_writable($file))
1005
-				$package_ftp->chmod($ftp_file, 0777);
1006
-			if (!@is_writable(dirname($file)))
1007
-				$package_ftp->chmod(dirname($ftp_file), 0777);
1077
+			if (!@is_writable($file)) {
1078
+							$package_ftp->chmod($ftp_file, 0777);
1079
+			}
1080
+			if (!@is_writable(dirname($file))) {
1081
+							$package_ftp->chmod(dirname($ftp_file), 0777);
1082
+			}
1008 1083
 
1009
-			if (@is_writable($file))
1010
-				unset($files[$k]);
1084
+			if (@is_writable($file)) {
1085
+							unset($files[$k]);
1086
+			}
1011 1087
 		}
1012 1088
 
1013 1089
 		return $files;
@@ -1019,8 +1095,7 @@  discard block
 block discarded – undo
1019 1095
 
1020 1096
 		$files = packageRequireFTP($destination_url, $files, $return);
1021 1097
 		return $files;
1022
-	}
1023
-	elseif (isset($_POST['ftp_username']))
1098
+	} elseif (isset($_POST['ftp_username']))
1024 1099
 	{
1025 1100
 		require_once($sourcedir . '/Class-Package.php');
1026 1101
 		$ftp = new ftp_connection($_POST['ftp_server'], $_POST['ftp_port'], $_POST['ftp_username'], $_POST['ftp_password']);
@@ -1042,19 +1117,21 @@  discard block
 block discarded – undo
1042 1117
 		{
1043 1118
 			require_once($sourcedir . '/Class-Package.php');
1044 1119
 			$ftp = new ftp_connection(null);
1120
+		} elseif ($ftp->error !== false && !isset($ftp_error)) {
1121
+					$ftp_error = $ftp->last_message === null ? '' : $ftp->last_message;
1045 1122
 		}
1046
-		elseif ($ftp->error !== false && !isset($ftp_error))
1047
-			$ftp_error = $ftp->last_message === null ? '' : $ftp->last_message;
1048 1123
 
1049 1124
 		list ($username, $detect_path, $found_path) = $ftp->detect_path($boarddir);
1050 1125
 
1051
-		if ($found_path)
1052
-			$_POST['ftp_path'] = $detect_path;
1053
-		elseif (!isset($_POST['ftp_path']))
1054
-			$_POST['ftp_path'] = isset($modSettings['package_path']) ? $modSettings['package_path'] : $detect_path;
1126
+		if ($found_path) {
1127
+					$_POST['ftp_path'] = $detect_path;
1128
+		} elseif (!isset($_POST['ftp_path'])) {
1129
+					$_POST['ftp_path'] = isset($modSettings['package_path']) ? $modSettings['package_path'] : $detect_path;
1130
+		}
1055 1131
 
1056
-		if (!isset($_POST['ftp_username']))
1057
-			$_POST['ftp_username'] = $username;
1132
+		if (!isset($_POST['ftp_username'])) {
1133
+					$_POST['ftp_username'] = $username;
1134
+		}
1058 1135
 
1059 1136
 		$context['package_ftp'] = array(
1060 1137
 			'server' => isset($_POST['ftp_server']) ? $_POST['ftp_server'] : (isset($modSettings['package_server']) ? $modSettings['package_server'] : 'localhost'),
@@ -1066,23 +1143,24 @@  discard block
 block discarded – undo
1066 1143
 		);
1067 1144
 
1068 1145
 		// If we're returning dump out here.
1069
-		if ($return)
1070
-			return $files;
1146
+		if ($return) {
1147
+					return $files;
1148
+		}
1071 1149
 
1072 1150
 		$context['page_title'] = $txt['package_ftp_necessary'];
1073 1151
 		$context['sub_template'] = 'ftp_required';
1074 1152
 		obExit();
1075
-	}
1076
-	else
1153
+	} else
1077 1154
 	{
1078 1155
 		if (!in_array($_POST['ftp_path'], array('', '/')))
1079 1156
 		{
1080 1157
 			$ftp_root = strtr($boarddir, array($_POST['ftp_path'] => ''));
1081
-			if (substr($ftp_root, -1) == '/' && ($_POST['ftp_path'] == '' || $_POST['ftp_path'][0] == '/'))
1082
-				$ftp_root = substr($ftp_root, 0, -1);
1158
+			if (substr($ftp_root, -1) == '/' && ($_POST['ftp_path'] == '' || $_POST['ftp_path'][0] == '/')) {
1159
+							$ftp_root = substr($ftp_root, 0, -1);
1160
+			}
1161
+		} else {
1162
+					$ftp_root = $boarddir;
1083 1163
 		}
1084
-		else
1085
-			$ftp_root = $boarddir;
1086 1164
 
1087 1165
 		$_SESSION['pack_ftp'] = array(
1088 1166
 			'server' => $_POST['ftp_server'],
@@ -1093,8 +1171,9 @@  discard block
 block discarded – undo
1093 1171
 			'root' => $ftp_root,
1094 1172
 		);
1095 1173
 
1096
-		if (!isset($modSettings['package_path']) || $modSettings['package_path'] != $_POST['ftp_path'])
1097
-			updateSettings(array('package_path' => $_POST['ftp_path']));
1174
+		if (!isset($modSettings['package_path']) || $modSettings['package_path'] != $_POST['ftp_path']) {
1175
+					updateSettings(array('package_path' => $_POST['ftp_path']));
1176
+		}
1098 1177
 
1099 1178
 		$files = packageRequireFTP($destination_url, $files, $return);
1100 1179
 	}
@@ -1122,16 +1201,18 @@  discard block
 block discarded – undo
1122 1201
 	global $packagesdir, $forum_version, $context, $temp_path, $language, $smcFunc;
1123 1202
 
1124 1203
 	// Mayday!  That action doesn't exist!!
1125
-	if (empty($packageXML) || !$packageXML->exists($method))
1126
-		return array();
1204
+	if (empty($packageXML) || !$packageXML->exists($method)) {
1205
+			return array();
1206
+	}
1127 1207
 
1128 1208
 	// We haven't found the package script yet...
1129 1209
 	$script = false;
1130 1210
 	$the_version = strtr($forum_version, array('SMF ' => ''));
1131 1211
 
1132 1212
 	// Emulation support...
1133
-	if (!empty($_SESSION['version_emulate']))
1134
-		$the_version = $_SESSION['version_emulate'];
1213
+	if (!empty($_SESSION['version_emulate'])) {
1214
+			$the_version = $_SESSION['version_emulate'];
1215
+	}
1135 1216
 
1136 1217
 	// Single package emulation
1137 1218
 	if (!empty($_REQUEST['ve']) && !empty($_REQUEST['package']))
@@ -1139,8 +1220,9 @@  discard block
 block discarded – undo
1139 1220
 		$the_version = $_REQUEST['ve'];
1140 1221
 		$_SESSION['single_version_emulate'][$_REQUEST['package']] = $the_version;
1141 1222
 	}
1142
-	if (!empty($_REQUEST['package']) && (!empty($_SESSION['single_version_emulate'][$_REQUEST['package']])))
1143
-		$the_version = $_SESSION['single_version_emulate'][$_REQUEST['package']];
1223
+	if (!empty($_REQUEST['package']) && (!empty($_SESSION['single_version_emulate'][$_REQUEST['package']]))) {
1224
+			$the_version = $_SESSION['single_version_emulate'][$_REQUEST['package']];
1225
+	}
1144 1226
 
1145 1227
 	// Get all the versions of this method and find the right one.
1146 1228
 	$these_methods = $packageXML->set($method);
@@ -1150,16 +1232,18 @@  discard block
 block discarded – undo
1150 1232
 		if ($this_method->exists('@for'))
1151 1233
 		{
1152 1234
 			// Don't keep going if this won't work for this version of SMF.
1153
-			if (!matchPackageVersion($the_version, $this_method->fetch('@for')))
1154
-				continue;
1235
+			if (!matchPackageVersion($the_version, $this_method->fetch('@for'))) {
1236
+							continue;
1237
+			}
1155 1238
 		}
1156 1239
 
1157 1240
 		// Upgrades may go from a certain old version of the mod.
1158 1241
 		if ($method == 'upgrade' && $this_method->exists('@from'))
1159 1242
 		{
1160 1243
 			// Well, this is for the wrong old version...
1161
-			if (!matchPackageVersion($previous_version, $this_method->fetch('@from')))
1162
-				continue;
1244
+			if (!matchPackageVersion($previous_version, $this_method->fetch('@from'))) {
1245
+							continue;
1246
+			}
1163 1247
 		}
1164 1248
 
1165 1249
 		// We've found it!
@@ -1168,8 +1252,9 @@  discard block
 block discarded – undo
1168 1252
 	}
1169 1253
 
1170 1254
 	// Bad news, a matching script wasn't found!
1171
-	if (!($script instanceof xmlArray))
1172
-		return array();
1255
+	if (!($script instanceof xmlArray)) {
1256
+			return array();
1257
+	}
1173 1258
 
1174 1259
 	// Find all the actions in this method - in theory, these should only be allowed actions. (* means all.)
1175 1260
 	$actions = $script->set('*');
@@ -1198,12 +1283,12 @@  discard block
 block discarded – undo
1198 1283
 					if ((isset($_REQUEST['readme']) && $action->fetch('@lang') == $_REQUEST['readme']) || (isset($_REQUEST['license']) && $action->fetch('@lang') == $_REQUEST['license']) || (!isset($_REQUEST['readme']) && $action->fetch('@lang') == $language) || (!isset($_REQUEST['license']) && $action->fetch('@lang') == $language))
1199 1284
 					{
1200 1285
 						// In case the user put the blocks in the wrong order.
1201
-						if (isset($context[$type]['selected']) && $context[$type]['selected'] == 'default')
1202
-							$context[$type][] = 'default';
1286
+						if (isset($context[$type]['selected']) && $context[$type]['selected'] == 'default') {
1287
+													$context[$type][] = 'default';
1288
+						}
1203 1289
 
1204 1290
 						$context[$type]['selected'] = $smcFunc['htmlspecialchars']($action->fetch('@lang'));
1205
-					}
1206
-					else
1291
+					} else
1207 1292
 					{
1208 1293
 						// We don't want this now, but we'll allow the user to select to read it.
1209 1294
 						$context[$type][] = $smcFunc['htmlspecialchars']($action->fetch('@lang'));
@@ -1218,9 +1303,9 @@  discard block
 block discarded – undo
1218 1303
 					{
1219 1304
 						$context[$type][] = 'default';
1220 1305
 						continue;
1306
+					} else {
1307
+											$context[$type]['selected'] = 'default';
1221 1308
 					}
1222
-					else
1223
-						$context[$type]['selected'] = 'default';
1224 1309
 				}
1225 1310
 			}
1226 1311
 
@@ -1230,9 +1315,9 @@  discard block
 block discarded – undo
1230 1315
 				$filename = $temp_path . '$auto_' . $temp_auto++ . (in_array($actionType, array('readme', 'redirect', 'license')) ? '.txt' : ($actionType == 'code' || $actionType == 'database' ? '.php' : '.mod'));
1231 1316
 				package_put_contents($filename, $action->fetch('.'));
1232 1317
 				$filename = strtr($filename, array($temp_path => ''));
1318
+			} else {
1319
+							$filename = $action->fetch('.');
1233 1320
 			}
1234
-			else
1235
-				$filename = $action->fetch('.');
1236 1321
 
1237 1322
 			$return[] = array(
1238 1323
 				'type' => $actionType,
@@ -1247,8 +1332,7 @@  discard block
 block discarded – undo
1247 1332
 			);
1248 1333
 
1249 1334
 			continue;
1250
-		}
1251
-		elseif ($actionType == 'hook')
1335
+		} elseif ($actionType == 'hook')
1252 1336
 		{
1253 1337
 			$return[] = array(
1254 1338
 				'type' => $actionType,
@@ -1260,16 +1344,16 @@  discard block
 block discarded – undo
1260 1344
 				'description' => '',
1261 1345
 			);
1262 1346
 			continue;
1263
-		}
1264
-		elseif ($actionType == 'credits')
1347
+		} elseif ($actionType == 'credits')
1265 1348
 		{
1266 1349
 			// quick check of any supplied url
1267 1350
 			$url = $action->exists('@url') ? $action->fetch('@url') : '';
1268 1351
 			if (strlen(trim($url)) > 0 && substr($url, 0, 7) !== 'http://' && substr($url, 0, 8) !== 'https://')
1269 1352
 			{
1270 1353
 				$url = 'http://' . $url;
1271
-				if (strlen($url) < 8 || (substr($url, 0, 7) !== 'http://' && substr($url, 0, 8) !== 'https://'))
1272
-					$url = '';
1354
+				if (strlen($url) < 8 || (substr($url, 0, 7) !== 'http://' && substr($url, 0, 8) !== 'https://')) {
1355
+									$url = '';
1356
+				}
1273 1357
 			}
1274 1358
 
1275 1359
 			$return[] = array(
@@ -1281,8 +1365,7 @@  discard block
 block discarded – undo
1281 1365
 				'title' => $action->fetch('.'),
1282 1366
 			);
1283 1367
 			continue;
1284
-		}
1285
-		elseif ($actionType == 'requires')
1368
+		} elseif ($actionType == 'requires')
1286 1369
 		{
1287 1370
 			$return[] = array(
1288 1371
 				'type' => $actionType,
@@ -1291,14 +1374,12 @@  discard block
 block discarded – undo
1291 1374
 				'description' => '',
1292 1375
 			);
1293 1376
 			continue;
1294
-		}
1295
-		elseif ($actionType == 'error')
1377
+		} elseif ($actionType == 'error')
1296 1378
 		{
1297 1379
 			$return[] = array(
1298 1380
 				'type' => 'error',
1299 1381
 			);
1300
-		}
1301
-		elseif (in_array($actionType, array('require-file', 'remove-file', 'require-dir', 'remove-dir', 'move-file', 'move-dir', 'create-file', 'create-dir')))
1382
+		} elseif (in_array($actionType, array('require-file', 'remove-file', 'require-dir', 'remove-dir', 'move-file', 'move-dir', 'create-file', 'create-dir')))
1302 1383
 		{
1303 1384
 			$this_action = &$return[];
1304 1385
 			$this_action = array(
@@ -1312,8 +1393,7 @@  discard block
 block discarded – undo
1312 1393
 			{
1313 1394
 				$this_action['unparsed_destination'] = $action->fetch('@destination');
1314 1395
 				$this_action['destination'] = parse_path($action->fetch('@destination')) . '/' . basename($this_action['filename']);
1315
-			}
1316
-			else
1396
+			} else
1317 1397
 			{
1318 1398
 				$this_action['unparsed_filename'] = $this_action['filename'];
1319 1399
 				$this_action['filename'] = parse_path($this_action['filename']);
@@ -1322,10 +1402,11 @@  discard block
 block discarded – undo
1322 1402
 			// If we're moving or requiring (copying) a file.
1323 1403
 			if (substr($actionType, 0, 4) == 'move' || substr($actionType, 0, 7) == 'require')
1324 1404
 			{
1325
-				if ($action->exists('@from'))
1326
-					$this_action['source'] = parse_path($action->fetch('@from'));
1327
-				else
1328
-					$this_action['source'] = $temp_path . $this_action['filename'];
1405
+				if ($action->exists('@from')) {
1406
+									$this_action['source'] = parse_path($action->fetch('@from'));
1407
+				} else {
1408
+									$this_action['source'] = $temp_path . $this_action['filename'];
1409
+				}
1329 1410
 			}
1330 1411
 
1331 1412
 			// Check if these things can be done. (chmod's etc.)
@@ -1334,22 +1415,23 @@  discard block
 block discarded – undo
1334 1415
 				if (!mktree($this_action['destination'], false))
1335 1416
 				{
1336 1417
 					$temp = $this_action['destination'];
1337
-					while (!file_exists($temp) && strlen($temp) > 1)
1338
-						$temp = dirname($temp);
1418
+					while (!file_exists($temp) && strlen($temp) > 1) {
1419
+											$temp = dirname($temp);
1420
+					}
1339 1421
 
1340 1422
 					$return[] = array(
1341 1423
 						'type' => 'chmod',
1342 1424
 						'filename' => $temp
1343 1425
 					);
1344 1426
 				}
1345
-			}
1346
-			elseif ($actionType == 'create-file')
1427
+			} elseif ($actionType == 'create-file')
1347 1428
 			{
1348 1429
 				if (!mktree(dirname($this_action['destination']), false))
1349 1430
 				{
1350 1431
 					$temp = dirname($this_action['destination']);
1351
-					while (!file_exists($temp) && strlen($temp) > 1)
1352
-						$temp = dirname($temp);
1432
+					while (!file_exists($temp) && strlen($temp) > 1) {
1433
+											$temp = dirname($temp);
1434
+					}
1353 1435
 
1354 1436
 					$return[] = array(
1355 1437
 						'type' => 'chmod',
@@ -1357,36 +1439,38 @@  discard block
 block discarded – undo
1357 1439
 					);
1358 1440
 				}
1359 1441
 
1360
-				if (!is_writable($this_action['destination']) && (file_exists($this_action['destination']) || !is_writable(dirname($this_action['destination']))))
1361
-					$return[] = array(
1442
+				if (!is_writable($this_action['destination']) && (file_exists($this_action['destination']) || !is_writable(dirname($this_action['destination'])))) {
1443
+									$return[] = array(
1362 1444
 						'type' => 'chmod',
1363 1445
 						'filename' => $this_action['destination']
1364 1446
 					);
1365
-			}
1366
-			elseif ($actionType == 'require-dir')
1447
+				}
1448
+			} elseif ($actionType == 'require-dir')
1367 1449
 			{
1368 1450
 				if (!mktree($this_action['destination'], false))
1369 1451
 				{
1370 1452
 					$temp = $this_action['destination'];
1371
-					while (!file_exists($temp) && strlen($temp) > 1)
1372
-						$temp = dirname($temp);
1453
+					while (!file_exists($temp) && strlen($temp) > 1) {
1454
+											$temp = dirname($temp);
1455
+					}
1373 1456
 
1374 1457
 					$return[] = array(
1375 1458
 						'type' => 'chmod',
1376 1459
 						'filename' => $temp
1377 1460
 					);
1378 1461
 				}
1379
-			}
1380
-			elseif ($actionType == 'require-file')
1462
+			} elseif ($actionType == 'require-file')
1381 1463
 			{
1382
-				if ($action->exists('@theme'))
1383
-					$this_action['theme_action'] = $action->fetch('@theme');
1464
+				if ($action->exists('@theme')) {
1465
+									$this_action['theme_action'] = $action->fetch('@theme');
1466
+				}
1384 1467
 
1385 1468
 				if (!mktree(dirname($this_action['destination']), false))
1386 1469
 				{
1387 1470
 					$temp = dirname($this_action['destination']);
1388
-					while (!file_exists($temp) && strlen($temp) > 1)
1389
-						$temp = dirname($temp);
1471
+					while (!file_exists($temp) && strlen($temp) > 1) {
1472
+											$temp = dirname($temp);
1473
+					}
1390 1474
 
1391 1475
 					$return[] = array(
1392 1476
 						'type' => 'chmod',
@@ -1394,19 +1478,20 @@  discard block
 block discarded – undo
1394 1478
 					);
1395 1479
 				}
1396 1480
 
1397
-				if (!is_writable($this_action['destination']) && (file_exists($this_action['destination']) || !is_writable(dirname($this_action['destination']))))
1398
-					$return[] = array(
1481
+				if (!is_writable($this_action['destination']) && (file_exists($this_action['destination']) || !is_writable(dirname($this_action['destination'])))) {
1482
+									$return[] = array(
1399 1483
 						'type' => 'chmod',
1400 1484
 						'filename' => $this_action['destination']
1401 1485
 					);
1402
-			}
1403
-			elseif ($actionType == 'move-dir' || $actionType == 'move-file')
1486
+				}
1487
+			} elseif ($actionType == 'move-dir' || $actionType == 'move-file')
1404 1488
 			{
1405 1489
 				if (!mktree(dirname($this_action['destination']), false))
1406 1490
 				{
1407 1491
 					$temp = dirname($this_action['destination']);
1408
-					while (!file_exists($temp) && strlen($temp) > 1)
1409
-						$temp = dirname($temp);
1492
+					while (!file_exists($temp) && strlen($temp) > 1) {
1493
+											$temp = dirname($temp);
1494
+					}
1410 1495
 
1411 1496
 					$return[] = array(
1412 1497
 						'type' => 'chmod',
@@ -1414,30 +1499,30 @@  discard block
 block discarded – undo
1414 1499
 					);
1415 1500
 				}
1416 1501
 
1417
-				if (!is_writable($this_action['destination']) && (file_exists($this_action['destination']) || !is_writable(dirname($this_action['destination']))))
1418
-					$return[] = array(
1502
+				if (!is_writable($this_action['destination']) && (file_exists($this_action['destination']) || !is_writable(dirname($this_action['destination'])))) {
1503
+									$return[] = array(
1419 1504
 						'type' => 'chmod',
1420 1505
 						'filename' => $this_action['destination']
1421 1506
 					);
1422
-			}
1423
-			elseif ($actionType == 'remove-dir')
1507
+				}
1508
+			} elseif ($actionType == 'remove-dir')
1424 1509
 			{
1425
-				if (!is_writable($this_action['filename']) && file_exists($this_action['filename']))
1426
-					$return[] = array(
1510
+				if (!is_writable($this_action['filename']) && file_exists($this_action['filename'])) {
1511
+									$return[] = array(
1427 1512
 						'type' => 'chmod',
1428 1513
 						'filename' => $this_action['filename']
1429 1514
 					);
1430
-			}
1431
-			elseif ($actionType == 'remove-file')
1515
+				}
1516
+			} elseif ($actionType == 'remove-file')
1432 1517
 			{
1433
-				if (!is_writable($this_action['filename']) && file_exists($this_action['filename']))
1434
-					$return[] = array(
1518
+				if (!is_writable($this_action['filename']) && file_exists($this_action['filename'])) {
1519
+									$return[] = array(
1435 1520
 						'type' => 'chmod',
1436 1521
 						'filename' => $this_action['filename']
1437 1522
 					);
1523
+				}
1438 1524
 			}
1439
-		}
1440
-		else
1525
+		} else
1441 1526
 		{
1442 1527
 			$return[] = array(
1443 1528
 				'type' => 'error',
@@ -1448,8 +1533,9 @@  discard block
 block discarded – undo
1448 1533
 	}
1449 1534
 
1450 1535
 	// Only testing - just return a list of things to be done.
1451
-	if ($testing_only)
1452
-		return $return;
1536
+	if ($testing_only) {
1537
+			return $return;
1538
+	}
1453 1539
 
1454 1540
 	umask(0);
1455 1541
 
@@ -1457,78 +1543,81 @@  discard block
 block discarded – undo
1457 1543
 	$not_done = array(array('type' => '!'));
1458 1544
 	foreach ($return as $action)
1459 1545
 	{
1460
-		if (in_array($action['type'], array('modification', 'code', 'database', 'redirect', 'hook', 'credits')))
1461
-			$not_done[] = $action;
1546
+		if (in_array($action['type'], array('modification', 'code', 'database', 'redirect', 'hook', 'credits'))) {
1547
+					$not_done[] = $action;
1548
+		}
1462 1549
 
1463 1550
 		if ($action['type'] == 'create-dir')
1464 1551
 		{
1465
-			if (!mktree($action['destination'], 0755) || !is_writable($action['destination']))
1466
-				$failure |= !mktree($action['destination'], 0777);
1467
-		}
1468
-		elseif ($action['type'] == 'create-file')
1552
+			if (!mktree($action['destination'], 0755) || !is_writable($action['destination'])) {
1553
+							$failure |= !mktree($action['destination'], 0777);
1554
+			}
1555
+		} elseif ($action['type'] == 'create-file')
1469 1556
 		{
1470
-			if (!mktree(dirname($action['destination']), 0755) || !is_writable(dirname($action['destination'])))
1471
-				$failure |= !mktree(dirname($action['destination']), 0777);
1557
+			if (!mktree(dirname($action['destination']), 0755) || !is_writable(dirname($action['destination']))) {
1558
+							$failure |= !mktree(dirname($action['destination']), 0777);
1559
+			}
1472 1560
 
1473 1561
 			// Create an empty file.
1474 1562
 			package_put_contents($action['destination'], package_get_contents($action['source']), $testing_only);
1475 1563
 
1476
-			if (!file_exists($action['destination']))
1477
-				$failure = true;
1478
-		}
1479
-		elseif ($action['type'] == 'require-dir')
1564
+			if (!file_exists($action['destination'])) {
1565
+							$failure = true;
1566
+			}
1567
+		} elseif ($action['type'] == 'require-dir')
1480 1568
 		{
1481 1569
 			copytree($action['source'], $action['destination']);
1482 1570
 			// Any other theme folders?
1483
-			if (!empty($context['theme_copies']) && !empty($context['theme_copies'][$action['type']][$action['destination']]))
1484
-				foreach ($context['theme_copies'][$action['type']][$action['destination']] as $theme_destination)
1571
+			if (!empty($context['theme_copies']) && !empty($context['theme_copies'][$action['type']][$action['destination']])) {
1572
+							foreach ($context['theme_copies'][$action['type']][$action['destination']] as $theme_destination)
1485 1573
 					copytree($action['source'], $theme_destination);
1486
-		}
1487
-		elseif ($action['type'] == 'require-file')
1574
+			}
1575
+		} elseif ($action['type'] == 'require-file')
1488 1576
 		{
1489
-			if (!mktree(dirname($action['destination']), 0755) || !is_writable(dirname($action['destination'])))
1490
-				$failure |= !mktree(dirname($action['destination']), 0777);
1577
+			if (!mktree(dirname($action['destination']), 0755) || !is_writable(dirname($action['destination']))) {
1578
+							$failure |= !mktree(dirname($action['destination']), 0777);
1579
+			}
1491 1580
 
1492 1581
 			package_put_contents($action['destination'], package_get_contents($action['source']), $testing_only);
1493 1582
 
1494 1583
 			$failure |= !copy($action['source'], $action['destination']);
1495 1584
 
1496 1585
 			// Any other theme files?
1497
-			if (!empty($context['theme_copies']) && !empty($context['theme_copies'][$action['type']][$action['destination']]))
1498
-				foreach ($context['theme_copies'][$action['type']][$action['destination']] as $theme_destination)
1586
+			if (!empty($context['theme_copies']) && !empty($context['theme_copies'][$action['type']][$action['destination']])) {
1587
+							foreach ($context['theme_copies'][$action['type']][$action['destination']] as $theme_destination)
1499 1588
 				{
1500 1589
 					if (!mktree(dirname($theme_destination), 0755) || !is_writable(dirname($theme_destination)))
1501 1590
 						$failure |= !mktree(dirname($theme_destination), 0777);
1591
+			}
1502 1592
 
1503 1593
 					package_put_contents($theme_destination, package_get_contents($action['source']), $testing_only);
1504 1594
 
1505 1595
 					$failure |= !copy($action['source'], $theme_destination);
1506 1596
 				}
1507
-		}
1508
-		elseif ($action['type'] == 'move-file')
1597
+		} elseif ($action['type'] == 'move-file')
1509 1598
 		{
1510
-			if (!mktree(dirname($action['destination']), 0755) || !is_writable(dirname($action['destination'])))
1511
-				$failure |= !mktree(dirname($action['destination']), 0777);
1599
+			if (!mktree(dirname($action['destination']), 0755) || !is_writable(dirname($action['destination']))) {
1600
+							$failure |= !mktree(dirname($action['destination']), 0777);
1601
+			}
1512 1602
 
1513 1603
 			$failure |= !rename($action['source'], $action['destination']);
1514
-		}
1515
-		elseif ($action['type'] == 'move-dir')
1604
+		} elseif ($action['type'] == 'move-dir')
1516 1605
 		{
1517
-			if (!mktree($action['destination'], 0755) || !is_writable($action['destination']))
1518
-				$failure |= !mktree($action['destination'], 0777);
1606
+			if (!mktree($action['destination'], 0755) || !is_writable($action['destination'])) {
1607
+							$failure |= !mktree($action['destination'], 0777);
1608
+			}
1519 1609
 
1520 1610
 			$failure |= !rename($action['source'], $action['destination']);
1521
-		}
1522
-		elseif ($action['type'] == 'remove-dir')
1611
+		} elseif ($action['type'] == 'remove-dir')
1523 1612
 		{
1524 1613
 			deltree($action['filename']);
1525 1614
 
1526 1615
 			// Any other theme folders?
1527
-			if (!empty($context['theme_copies']) && !empty($context['theme_copies'][$action['type']][$action['filename']]))
1528
-				foreach ($context['theme_copies'][$action['type']][$action['filename']] as $theme_destination)
1616
+			if (!empty($context['theme_copies']) && !empty($context['theme_copies'][$action['type']][$action['filename']])) {
1617
+							foreach ($context['theme_copies'][$action['type']][$action['filename']] as $theme_destination)
1529 1618
 					deltree($theme_destination);
1530
-		}
1531
-		elseif ($action['type'] == 'remove-file')
1619
+			}
1620
+		} elseif ($action['type'] == 'remove-file')
1532 1621
 		{
1533 1622
 			// Make sure the file exists before deleting it.
1534 1623
 			if (file_exists($action['filename']))
@@ -1537,16 +1626,18 @@  discard block
 block discarded – undo
1537 1626
 				$failure |= !unlink($action['filename']);
1538 1627
 			}
1539 1628
 			// The file that was supposed to be deleted couldn't be found.
1540
-			else
1541
-				$failure = true;
1629
+			else {
1630
+							$failure = true;
1631
+			}
1542 1632
 
1543 1633
 			// Any other theme folders?
1544
-			if (!empty($context['theme_copies']) && !empty($context['theme_copies'][$action['type']][$action['filename']]))
1545
-				foreach ($context['theme_copies'][$action['type']][$action['filename']] as $theme_destination)
1634
+			if (!empty($context['theme_copies']) && !empty($context['theme_copies'][$action['type']][$action['filename']])) {
1635
+							foreach ($context['theme_copies'][$action['type']][$action['filename']] as $theme_destination)
1546 1636
 					if (file_exists($theme_destination))
1547 1637
 						$failure |= !unlink($theme_destination);
1548
-					else
1549
-						$failure = true;
1638
+			} else {
1639
+											$failure = true;
1640
+					}
1550 1641
 		}
1551 1642
 	}
1552 1643
 
@@ -1568,8 +1659,9 @@  discard block
 block discarded – undo
1568 1659
 {
1569 1660
 	static $near_version = 0;
1570 1661
 
1571
-	if ($reset)
1572
-		$near_version = 0;
1662
+	if ($reset) {
1663
+			$near_version = 0;
1664
+	}
1573 1665
 
1574 1666
 	// Normalize the $versions while we remove our previous Doh!
1575 1667
 	$versions = explode(',', str_replace(array(' ', '2.0rc1-1'), array('', '2.0rc1.1'), strtolower($versions)));
@@ -1578,16 +1670,19 @@  discard block
 block discarded – undo
1578 1670
 	foreach ($versions as $for)
1579 1671
 	{
1580 1672
 		// Adjust for those wild cards
1581
-		if (strpos($for, '*') !== false)
1582
-			$for = str_replace('*', '0dev0', $for) . '-' . str_replace('*', '999', $for);
1673
+		if (strpos($for, '*') !== false) {
1674
+					$for = str_replace('*', '0dev0', $for) . '-' . str_replace('*', '999', $for);
1675
+		}
1583 1676
 
1584 1677
 		// If we have a range, grab the lower value, done this way so it looks normal-er to the user e.g. 2.0 vs 2.0.99
1585
-		if (strpos($for, '-') !== false)
1586
-			list ($for, $higher) = explode('-', $for);
1678
+		if (strpos($for, '-') !== false) {
1679
+					list ($for, $higher) = explode('-', $for);
1680
+		}
1587 1681
 
1588 1682
 		// Do the compare, if the for is greater, than what we have but not greater than what we are running .....
1589
-		if (compareVersions($near_version, $for) === -1 && compareVersions($for, $the_version) !== 1)
1590
-			$near_version = $for;
1683
+		if (compareVersions($near_version, $for) === -1 && compareVersions($for, $the_version) !== 1) {
1684
+					$near_version = $for;
1685
+		}
1591 1686
 	}
1592 1687
 
1593 1688
 	return !empty($near_version) ? $near_version : false;
@@ -1610,15 +1705,17 @@  discard block
 block discarded – undo
1610 1705
 	$versions = explode(',', str_replace(array(' ', '2.0rc1-1'), array('', '2.0rc1.1'), strtolower($versions)));
1611 1706
 
1612 1707
 	// Perhaps we do accept anything?
1613
-	if (in_array('all', $versions))
1614
-		return true;
1708
+	if (in_array('all', $versions)) {
1709
+			return true;
1710
+	}
1615 1711
 
1616 1712
 	// Loop through each version.
1617 1713
 	foreach ($versions as $for)
1618 1714
 	{
1619 1715
 		// Wild card spotted?
1620
-		if (strpos($for, '*') !== false)
1621
-			$for = str_replace('*', '0dev0', $for) . '-' . str_replace('*', '999', $for);
1716
+		if (strpos($for, '*') !== false) {
1717
+					$for = str_replace('*', '0dev0', $for) . '-' . str_replace('*', '999', $for);
1718
+		}
1622 1719
 
1623 1720
 		// Do we have a range?
1624 1721
 		if (strpos($for, '-') !== false)
@@ -1626,12 +1723,14 @@  discard block
 block discarded – undo
1626 1723
 			list ($lower, $upper) = explode('-', $for);
1627 1724
 
1628 1725
 			// Compare the version against lower and upper bounds.
1629
-			if (compareVersions($version, $lower) > -1 && compareVersions($version, $upper) < 1)
1630
-				return true;
1726
+			if (compareVersions($version, $lower) > -1 && compareVersions($version, $upper) < 1) {
1727
+							return true;
1728
+			}
1631 1729
 		}
1632 1730
 		// Otherwise check if they are equal...
1633
-		elseif (compareVersions($version, $for) === 0)
1634
-			return true;
1731
+		elseif (compareVersions($version, $for) === 0) {
1732
+					return true;
1733
+		}
1635 1734
 	}
1636 1735
 
1637 1736
 	return false;
@@ -1671,12 +1770,14 @@  discard block
 block discarded – undo
1671 1770
 	}
1672 1771
 
1673 1772
 	// Are they the same, perhaps?
1674
-	if ($versions[1] === $versions[2])
1675
-		return 0;
1773
+	if ($versions[1] === $versions[2]) {
1774
+			return 0;
1775
+	}
1676 1776
 
1677 1777
 	// Get version numbering categories...
1678
-	if (!isset($categories))
1679
-		$categories = array_keys($versions[1]);
1778
+	if (!isset($categories)) {
1779
+			$categories = array_keys($versions[1]);
1780
+	}
1680 1781
 
1681 1782
 	// Loop through each category.
1682 1783
 	foreach ($categories as $category)
@@ -1686,13 +1787,15 @@  discard block
 block discarded – undo
1686 1787
 		{
1687 1788
 			// Dev builds are a problematic exception.
1688 1789
 			// (stable) dev < (stable) but (unstable) dev = (unstable)
1689
-			if ($category == 'type')
1690
-				return $versions[1][$category] > $versions[2][$category] ? ($versions[1]['dev'] ? -1 : 1) : ($versions[2]['dev'] ? 1 : -1);
1691
-			elseif ($category == 'dev')
1692
-				return $versions[1]['dev'] ? ($versions[2]['type'] == 'stable' ? -1 : 0) : ($versions[1]['type'] == 'stable' ? 1 : 0);
1790
+			if ($category == 'type') {
1791
+							return $versions[1][$category] > $versions[2][$category] ? ($versions[1]['dev'] ? -1 : 1) : ($versions[2]['dev'] ? 1 : -1);
1792
+			} elseif ($category == 'dev') {
1793
+							return $versions[1]['dev'] ? ($versions[2]['type'] == 'stable' ? -1 : 0) : ($versions[1]['type'] == 'stable' ? 1 : 0);
1794
+			}
1693 1795
 			// Otherwise a simple comparison.
1694
-			else
1695
-				return $versions[1][$category] > $versions[2][$category] ? 1 : -1;
1796
+			else {
1797
+							return $versions[1][$category] > $versions[2][$category] ? 1 : -1;
1798
+			}
1696 1799
 		}
1697 1800
 	}
1698 1801
 
@@ -1726,11 +1829,13 @@  discard block
 block discarded – undo
1726 1829
 	);
1727 1830
 
1728 1831
 	// do we parse in a package directory?
1729
-	if (!empty($temp_path))
1730
-		$dirs['$package'] = $temp_path;
1832
+	if (!empty($temp_path)) {
1833
+			$dirs['$package'] = $temp_path;
1834
+	}
1731 1835
 
1732
-	if (strlen($path) == 0)
1733
-		trigger_error('parse_path(): There should never be an empty filename', E_USER_ERROR);
1836
+	if (strlen($path) == 0) {
1837
+			trigger_error('parse_path(): There should never be an empty filename', E_USER_ERROR);
1838
+	}
1734 1839
 
1735 1840
 	return strtr($path, $dirs);
1736 1841
 }
@@ -1747,8 +1852,9 @@  discard block
 block discarded – undo
1747 1852
 	/** @var ftp_connection $package_ftp */
1748 1853
 	global $package_ftp;
1749 1854
 
1750
-	if (!file_exists($dir))
1751
-		return;
1855
+	if (!file_exists($dir)) {
1856
+			return;
1857
+	}
1752 1858
 
1753 1859
 	$current_dir = @opendir($dir);
1754 1860
 	if ($current_dir == false)
@@ -1756,8 +1862,9 @@  discard block
 block discarded – undo
1756 1862
 		if ($delete_dir && isset($package_ftp))
1757 1863
 		{
1758 1864
 			$ftp_file = strtr($dir, array($_SESSION['pack_ftp']['root'] => ''));
1759
-			if (!is_dir($dir))
1760
-				$package_ftp->chmod($ftp_file, 0777);
1865
+			if (!is_dir($dir)) {
1866
+							$package_ftp->chmod($ftp_file, 0777);
1867
+			}
1761 1868
 			$package_ftp->unlink($ftp_file);
1762 1869
 		}
1763 1870
 
@@ -1766,26 +1873,28 @@  discard block
 block discarded – undo
1766 1873
 
1767 1874
 	while ($entryname = readdir($current_dir))
1768 1875
 	{
1769
-		if (in_array($entryname, array('.', '..')))
1770
-			continue;
1876
+		if (in_array($entryname, array('.', '..'))) {
1877
+					continue;
1878
+		}
1771 1879
 
1772
-		if (is_dir($dir . '/' . $entryname))
1773
-			deltree($dir . '/' . $entryname);
1774
-		else
1880
+		if (is_dir($dir . '/' . $entryname)) {
1881
+					deltree($dir . '/' . $entryname);
1882
+		} else
1775 1883
 		{
1776 1884
 			// Here, 755 doesn't really matter since we're deleting it anyway.
1777 1885
 			if (isset($package_ftp))
1778 1886
 			{
1779 1887
 				$ftp_file = strtr($dir . '/' . $entryname, array($_SESSION['pack_ftp']['root'] => ''));
1780 1888
 
1781
-				if (!is_writable($dir . '/' . $entryname))
1782
-					$package_ftp->chmod($ftp_file, 0777);
1889
+				if (!is_writable($dir . '/' . $entryname)) {
1890
+									$package_ftp->chmod($ftp_file, 0777);
1891
+				}
1783 1892
 				$package_ftp->unlink($ftp_file);
1784
-			}
1785
-			else
1893
+			} else
1786 1894
 			{
1787
-				if (!is_writable($dir . '/' . $entryname))
1788
-					smf_chmod($dir . '/' . $entryname, 0777);
1895
+				if (!is_writable($dir . '/' . $entryname)) {
1896
+									smf_chmod($dir . '/' . $entryname, 0777);
1897
+				}
1789 1898
 				unlink($dir . '/' . $entryname);
1790 1899
 			}
1791 1900
 		}
@@ -1798,14 +1907,15 @@  discard block
 block discarded – undo
1798 1907
 		if (isset($package_ftp))
1799 1908
 		{
1800 1909
 			$ftp_file = strtr($dir, array($_SESSION['pack_ftp']['root'] => ''));
1801
-			if (!is_writable($dir . '/' . $entryname))
1802
-				$package_ftp->chmod($ftp_file, 0777);
1910
+			if (!is_writable($dir . '/' . $entryname)) {
1911
+							$package_ftp->chmod($ftp_file, 0777);
1912
+			}
1803 1913
 			$package_ftp->unlink($ftp_file);
1804
-		}
1805
-		else
1914
+		} else
1806 1915
 		{
1807
-			if (!is_writable($dir))
1808
-				smf_chmod($dir, 0777);
1916
+			if (!is_writable($dir)) {
1917
+							smf_chmod($dir, 0777);
1918
+			}
1809 1919
 			@rmdir($dir);
1810 1920
 		}
1811 1921
 	}
@@ -1828,10 +1938,11 @@  discard block
 block discarded – undo
1828 1938
 	{
1829 1939
 		if (!is_writable($strPath) && $mode !== false)
1830 1940
 		{
1831
-			if (isset($package_ftp))
1832
-				$package_ftp->chmod(strtr($strPath, array($_SESSION['pack_ftp']['root'] => '')), $mode);
1833
-			else
1834
-				smf_chmod($strPath, $mode);
1941
+			if (isset($package_ftp)) {
1942
+							$package_ftp->chmod(strtr($strPath, array($_SESSION['pack_ftp']['root'] => '')), $mode);
1943
+			} else {
1944
+							smf_chmod($strPath, $mode);
1945
+			}
1835 1946
 		}
1836 1947
 
1837 1948
 		$test = @opendir($strPath);
@@ -1839,36 +1950,37 @@  discard block
 block discarded – undo
1839 1950
 		{
1840 1951
 			closedir($test);
1841 1952
 			return is_writable($strPath);
1953
+		} else {
1954
+					return false;
1842 1955
 		}
1843
-		else
1844
-			return false;
1845 1956
 	}
1846 1957
 	// Is this an invalid path and/or we can't make the directory?
1847
-	if ($strPath == dirname($strPath) || !mktree(dirname($strPath), $mode))
1848
-		return false;
1958
+	if ($strPath == dirname($strPath) || !mktree(dirname($strPath), $mode)) {
1959
+			return false;
1960
+	}
1849 1961
 
1850 1962
 	if (!is_writable(dirname($strPath)) && $mode !== false)
1851 1963
 	{
1852
-		if (isset($package_ftp))
1853
-			$package_ftp->chmod(dirname(strtr($strPath, array($_SESSION['pack_ftp']['root'] => ''))), $mode);
1854
-		else
1855
-			smf_chmod(dirname($strPath), $mode);
1964
+		if (isset($package_ftp)) {
1965
+					$package_ftp->chmod(dirname(strtr($strPath, array($_SESSION['pack_ftp']['root'] => ''))), $mode);
1966
+		} else {
1967
+					smf_chmod(dirname($strPath), $mode);
1968
+		}
1856 1969
 	}
1857 1970
 
1858
-	if ($mode !== false && isset($package_ftp))
1859
-		return $package_ftp->create_dir(strtr($strPath, array($_SESSION['pack_ftp']['root'] => '')));
1860
-	elseif ($mode === false)
1971
+	if ($mode !== false && isset($package_ftp)) {
1972
+			return $package_ftp->create_dir(strtr($strPath, array($_SESSION['pack_ftp']['root'] => '')));
1973
+	} elseif ($mode === false)
1861 1974
 	{
1862 1975
 		$test = @opendir(dirname($strPath));
1863 1976
 		if ($test)
1864 1977
 		{
1865 1978
 			closedir($test);
1866 1979
 			return true;
1980
+		} else {
1981
+					return false;
1867 1982
 		}
1868
-		else
1869
-			return false;
1870
-	}
1871
-	else
1983
+	} else
1872 1984
 	{
1873 1985
 		@mkdir($strPath, $mode);
1874 1986
 		$test = @opendir($strPath);
@@ -1876,9 +1988,9 @@  discard block
 block discarded – undo
1876 1988
 		{
1877 1989
 			closedir($test);
1878 1990
 			return true;
1991
+		} else {
1992
+					return false;
1879 1993
 		}
1880
-		else
1881
-			return false;
1882 1994
 	}
1883 1995
 }
1884 1996
 
@@ -1894,39 +2006,46 @@  discard block
 block discarded – undo
1894 2006
 	/** @var ftp_connection $package_ftp */
1895 2007
 	global $package_ftp;
1896 2008
 
1897
-	if (!file_exists($destination) || !is_writable($destination))
1898
-		mktree($destination, 0755);
1899
-	if (!is_writable($destination))
1900
-		mktree($destination, 0777);
2009
+	if (!file_exists($destination) || !is_writable($destination)) {
2010
+			mktree($destination, 0755);
2011
+	}
2012
+	if (!is_writable($destination)) {
2013
+			mktree($destination, 0777);
2014
+	}
1901 2015
 
1902 2016
 	$current_dir = opendir($source);
1903
-	if ($current_dir == false)
1904
-		return;
2017
+	if ($current_dir == false) {
2018
+			return;
2019
+	}
1905 2020
 
1906 2021
 	while ($entryname = readdir($current_dir))
1907 2022
 	{
1908
-		if (in_array($entryname, array('.', '..')))
1909
-			continue;
2023
+		if (in_array($entryname, array('.', '..'))) {
2024
+					continue;
2025
+		}
1910 2026
 
1911
-		if (isset($package_ftp))
1912
-			$ftp_file = strtr($destination . '/' . $entryname, array($_SESSION['pack_ftp']['root'] => ''));
2027
+		if (isset($package_ftp)) {
2028
+					$ftp_file = strtr($destination . '/' . $entryname, array($_SESSION['pack_ftp']['root'] => ''));
2029
+		}
1913 2030
 
1914 2031
 		if (is_file($source . '/' . $entryname))
1915 2032
 		{
1916
-			if (isset($package_ftp) && !file_exists($destination . '/' . $entryname))
1917
-				$package_ftp->create_file($ftp_file);
1918
-			elseif (!file_exists($destination . '/' . $entryname))
1919
-				@touch($destination . '/' . $entryname);
2033
+			if (isset($package_ftp) && !file_exists($destination . '/' . $entryname)) {
2034
+							$package_ftp->create_file($ftp_file);
2035
+			} elseif (!file_exists($destination . '/' . $entryname)) {
2036
+							@touch($destination . '/' . $entryname);
2037
+			}
1920 2038
 		}
1921 2039
 
1922 2040
 		package_chmod($destination . '/' . $entryname);
1923 2041
 
1924
-		if (is_dir($source . '/' . $entryname))
1925
-			copytree($source . '/' . $entryname, $destination . '/' . $entryname);
1926
-		elseif (file_exists($destination . '/' . $entryname))
1927
-			package_put_contents($destination . '/' . $entryname, package_get_contents($source . '/' . $entryname));
1928
-		else
1929
-			copy($source . '/' . $entryname, $destination . '/' . $entryname);
2042
+		if (is_dir($source . '/' . $entryname)) {
2043
+					copytree($source . '/' . $entryname, $destination . '/' . $entryname);
2044
+		} elseif (file_exists($destination . '/' . $entryname)) {
2045
+					package_put_contents($destination . '/' . $entryname, package_get_contents($source . '/' . $entryname));
2046
+		} else {
2047
+					copy($source . '/' . $entryname, $destination . '/' . $entryname);
2048
+		}
1930 2049
 	}
1931 2050
 
1932 2051
 	closedir($current_dir);
@@ -1944,21 +2063,24 @@  discard block
 block discarded – undo
1944 2063
 	$data = array();
1945 2064
 
1946 2065
 	$dir = @dir($path . $sub_path);
1947
-	if (!$dir)
1948
-		return array();
2066
+	if (!$dir) {
2067
+			return array();
2068
+	}
1949 2069
 	while ($entry = $dir->read())
1950 2070
 	{
1951
-		if ($entry == '.' || $entry == '..')
1952
-			continue;
2071
+		if ($entry == '.' || $entry == '..') {
2072
+					continue;
2073
+		}
1953 2074
 
1954
-		if (is_dir($path . $sub_path . '/' . $entry))
1955
-			$data = array_merge($data, listtree($path, $sub_path . '/' . $entry));
1956
-		else
1957
-			$data[] = array(
2075
+		if (is_dir($path . $sub_path . '/' . $entry)) {
2076
+					$data = array_merge($data, listtree($path, $sub_path . '/' . $entry));
2077
+		} else {
2078
+					$data[] = array(
1958 2079
 				'filename' => $sub_path == '' ? $entry : $sub_path . '/' . $entry,
1959 2080
 				'size' => filesize($path . $sub_path . '/' . $entry),
1960 2081
 				'skipped' => false,
1961 2082
 			);
2083
+		}
1962 2084
 	}
1963 2085
 	$dir->close();
1964 2086
 
@@ -2013,8 +2135,9 @@  discard block
 block discarded – undo
2013 2135
 		{
2014 2136
 			// If this filename is relative, if so take a guess at what it should be.
2015 2137
 			$real_filename = $filename;
2016
-			if (strpos($filename, 'Themes') === 0)
2017
-				$real_filename = $boarddir . '/' . $filename;
2138
+			if (strpos($filename, 'Themes') === 0) {
2139
+							$real_filename = $boarddir . '/' . $filename;
2140
+			}
2018 2141
 
2019 2142
 			if (strpos($real_filename, $theme['theme_dir']) === 0)
2020 2143
 			{
@@ -2033,8 +2156,9 @@  discard block
 block discarded – undo
2033 2156
 		foreach ($theme_paths as $id => $theme)
2034 2157
 		{
2035 2158
 			// Default is getting done anyway, so no need for involvement here.
2036
-			if ($id == 1)
2037
-				continue;
2159
+			if ($id == 1) {
2160
+							continue;
2161
+			}
2038 2162
 
2039 2163
 			// For every template, do we want it? Yea, no, maybe?
2040 2164
 			foreach ($template_changes[1] as $index => $template_file)
@@ -2057,8 +2181,9 @@  discard block
 block discarded – undo
2057 2181
 		);
2058 2182
 
2059 2183
 		// Sometimes though, we have some additional files for other themes, if we have add them to the mix.
2060
-		if (isset($custom_themes_add[$files_to_change[1]]))
2061
-			$files_to_change += $custom_themes_add[$files_to_change[1]];
2184
+		if (isset($custom_themes_add[$files_to_change[1]])) {
2185
+					$files_to_change += $custom_themes_add[$files_to_change[1]];
2186
+		}
2062 2187
 
2063 2188
 		// Now, loop through all the files we're changing, and, well, change them ;)
2064 2189
 		foreach ($files_to_change as $theme => $working_file)
@@ -2092,11 +2217,13 @@  discard block
 block discarded – undo
2092 2217
 				continue;
2093 2218
 			}
2094 2219
 			// Okay, we're creating this file then...?
2095
-			elseif (!file_exists($working_file))
2096
-				$working_data = '';
2220
+			elseif (!file_exists($working_file)) {
2221
+							$working_data = '';
2222
+			}
2097 2223
 			// Phew, it exists!  Load 'er up!
2098
-			else
2099
-				$working_data = str_replace("\r", '', package_get_contents($working_file));
2224
+			else {
2225
+							$working_data = str_replace("\r", '', package_get_contents($working_file));
2226
+			}
2100 2227
 
2101 2228
 			$actions[] = array(
2102 2229
 				'type' => 'opened',
@@ -2117,8 +2244,8 @@  discard block
 block discarded – undo
2117 2244
 
2118 2245
 				// Grab all search items of this operation (in most cases just 1).
2119 2246
 				$searches = $operation->set('search');
2120
-				foreach ($searches as $i => $search)
2121
-					$actual_operation['searches'][] = array(
2247
+				foreach ($searches as $i => $search) {
2248
+									$actual_operation['searches'][] = array(
2122 2249
 						'position' => $search->exists('@position') && in_array(trim($search->fetch('@position')), array('before', 'after', 'replace', 'end')) ? trim($search->fetch('@position')) : 'replace',
2123 2250
 						'is_reg_exp' => $search->exists('@regexp') && trim($search->fetch('@regexp')) === 'true',
2124 2251
 						'loose_whitespace' => $search->exists('@whitespace') && trim($search->fetch('@whitespace')) === 'loose',
@@ -2127,6 +2254,7 @@  discard block
 block discarded – undo
2127 2254
 						'preg_search' => '',
2128 2255
 						'preg_replace' => '',
2129 2256
 					);
2257
+				}
2130 2258
 
2131 2259
 				// At least one search should be defined.
2132 2260
 				if (empty($actual_operation['searches']))
@@ -2151,30 +2279,32 @@  discard block
 block discarded – undo
2151 2279
 						// Reverse modification of regular expressions are not allowed.
2152 2280
 						if ($search['is_reg_exp'])
2153 2281
 						{
2154
-							if ($actual_operation['error'] === 'fatal')
2155
-								$actions[] = array(
2282
+							if ($actual_operation['error'] === 'fatal') {
2283
+															$actions[] = array(
2156 2284
 									'type' => 'failure',
2157 2285
 									'filename' => $working_file,
2158 2286
 									'search' => $search['search'],
2159 2287
 									'is_custom' => $theme > 1 ? $theme : 0,
2160 2288
 								);
2289
+							}
2161 2290
 
2162 2291
 							// Continue to the next operation.
2163 2292
 							continue 2;
2164 2293
 						}
2165 2294
 
2166 2295
 						// The replacement is now the search subject...
2167
-						if ($search['position'] === 'replace' || $search['position'] === 'end')
2168
-							$actual_operation['searches'][$i]['search'] = $search['add'];
2169
-						else
2296
+						if ($search['position'] === 'replace' || $search['position'] === 'end') {
2297
+													$actual_operation['searches'][$i]['search'] = $search['add'];
2298
+						} else
2170 2299
 						{
2171 2300
 							// Reversing a before/after modification becomes a replacement.
2172 2301
 							$actual_operation['searches'][$i]['position'] = 'replace';
2173 2302
 
2174
-							if ($search['position'] === 'before')
2175
-								$actual_operation['searches'][$i]['search'] .= $search['add'];
2176
-							elseif ($search['position'] === 'after')
2177
-								$actual_operation['searches'][$i]['search'] = $search['add'] . $search['search'];
2303
+							if ($search['position'] === 'before') {
2304
+															$actual_operation['searches'][$i]['search'] .= $search['add'];
2305
+							} elseif ($search['position'] === 'after') {
2306
+															$actual_operation['searches'][$i]['search'] = $search['add'] . $search['search'];
2307
+							}
2178 2308
 						}
2179 2309
 
2180 2310
 						// ...and the search subject is now the replacement.
@@ -2202,16 +2332,17 @@  discard block
 block discarded – undo
2202 2332
 				foreach ($actual_operation['searches'] as $i => $search)
2203 2333
 				{
2204 2334
 					// Not much needed if the search subject is already a regexp.
2205
-					if ($search['is_reg_exp'])
2206
-						$actual_operation['searches'][$i]['preg_search'] = $search['search'];
2207
-					else
2335
+					if ($search['is_reg_exp']) {
2336
+											$actual_operation['searches'][$i]['preg_search'] = $search['search'];
2337
+					} else
2208 2338
 					{
2209 2339
 						// Make the search subject fit into a regular expression.
2210 2340
 						$actual_operation['searches'][$i]['preg_search'] = preg_quote($search['search'], '~');
2211 2341
 
2212 2342
 						// Using 'loose', a random amount of tabs and spaces may be used.
2213
-						if ($search['loose_whitespace'])
2214
-							$actual_operation['searches'][$i]['preg_search'] = preg_replace('~[ \t]+~', '[ \t]+', $actual_operation['searches'][$i]['preg_search']);
2343
+						if ($search['loose_whitespace']) {
2344
+													$actual_operation['searches'][$i]['preg_search'] = preg_replace('~[ \t]+~', '[ \t]+', $actual_operation['searches'][$i]['preg_search']);
2345
+						}
2215 2346
 					}
2216 2347
 
2217 2348
 					// Shuzzup.  This is done so we can safely use a regular expression. ($0 is bad!!)
@@ -2237,8 +2368,7 @@  discard block
 block discarded – undo
2237 2368
 						if ($undo)
2238 2369
 						{
2239 2370
 							$actual_operation['searches'][$i]['preg_replace'] = '';
2240
-						}
2241
-						else
2371
+						} else
2242 2372
 						{
2243 2373
 							$actual_operation['searches'][$i]['preg_search'] = '(\\n\\?\\>)?$';
2244 2374
 							$actual_operation['searches'][$i]['preg_replace'] .= '$1';
@@ -2285,8 +2415,9 @@  discard block
 block discarded – undo
2285 2415
 					}
2286 2416
 
2287 2417
 					// Replace it into nothing? That's not an option...unless it's an undoing end.
2288
-					if ($search['add'] === '' && ($search['position'] !== 'end' || !$undo))
2289
-						continue;
2418
+					if ($search['add'] === '' && ($search['position'] !== 'end' || !$undo)) {
2419
+											continue;
2420
+					}
2290 2421
 
2291 2422
 					// Finally, we're doing some replacements.
2292 2423
 					$working_data = preg_replace('~' . $actual_operation['searches'][$i]['preg_search'] . '~s', $actual_operation['searches'][$i]['preg_replace'], $working_data, 1);
@@ -2311,22 +2442,25 @@  discard block
 block discarded – undo
2311 2442
 
2312 2443
 			package_chmod($working_file);
2313 2444
 
2314
-			if ((file_exists($working_file) && !is_writable($working_file)) || (!file_exists($working_file) && !is_writable(dirname($working_file))))
2315
-				$actions[] = array(
2445
+			if ((file_exists($working_file) && !is_writable($working_file)) || (!file_exists($working_file) && !is_writable(dirname($working_file)))) {
2446
+							$actions[] = array(
2316 2447
 					'type' => 'chmod',
2317 2448
 					'filename' => $working_file
2318 2449
 				);
2450
+			}
2319 2451
 
2320
-			if (basename($working_file) == 'Settings_bak.php')
2321
-				continue;
2452
+			if (basename($working_file) == 'Settings_bak.php') {
2453
+							continue;
2454
+			}
2322 2455
 
2323 2456
 			if (!$testing && !empty($modSettings['package_make_backups']) && file_exists($working_file))
2324 2457
 			{
2325 2458
 				// No, no, not Settings.php!
2326
-				if (basename($working_file) == 'Settings.php')
2327
-					@copy($working_file, dirname($working_file) . '/Settings_bak.php');
2328
-				else
2329
-					@copy($working_file, $working_file . '~');
2459
+				if (basename($working_file) == 'Settings.php') {
2460
+									@copy($working_file, dirname($working_file) . '/Settings_bak.php');
2461
+				} else {
2462
+									@copy($working_file, $working_file . '~');
2463
+				}
2330 2464
 			}
2331 2465
 
2332 2466
 			// Always call this, even if in testing, because it won't really be written in testing mode.
@@ -2393,8 +2527,9 @@  discard block
 block discarded – undo
2393 2527
 		if ($code_match[1] != 'edit file' && $code_match[1] != 'file')
2394 2528
 		{
2395 2529
 			// It's a step, let's add that to the current steps.
2396
-			if (isset($temp_changes[$step_counter]))
2397
-				$temp_changes[$step_counter]['changes'][] = $code_match[0];
2530
+			if (isset($temp_changes[$step_counter])) {
2531
+							$temp_changes[$step_counter]['changes'][] = $code_match[0];
2532
+			}
2398 2533
 			continue;
2399 2534
 		}
2400 2535
 
@@ -2411,11 +2546,13 @@  discard block
 block discarded – undo
2411 2546
 		foreach ($theme_paths as $id => $theme)
2412 2547
 		{
2413 2548
 			// If this filename is relative, if so take a guess at what it should be.
2414
-			if (strpos($filename, 'Themes') === 0)
2415
-				$filename = $boarddir . '/' . $filename;
2549
+			if (strpos($filename, 'Themes') === 0) {
2550
+							$filename = $boarddir . '/' . $filename;
2551
+			}
2416 2552
 
2417
-			if (strpos($filename, $theme['theme_dir']) === 0)
2418
-				$template_changes[$id][$counter] = substr($filename, strlen($theme['theme_dir']) + 1);
2553
+			if (strpos($filename, $theme['theme_dir']) === 0) {
2554
+							$template_changes[$id][$counter] = substr($filename, strlen($theme['theme_dir']) + 1);
2555
+			}
2419 2556
 		}
2420 2557
 	}
2421 2558
 
@@ -2428,8 +2565,9 @@  discard block
 block discarded – undo
2428 2565
 		foreach ($theme_paths as $id => $theme)
2429 2566
 		{
2430 2567
 			// Don't do default, it means nothing to me.
2431
-			if ($id == 1)
2432
-				continue;
2568
+			if ($id == 1) {
2569
+							continue;
2570
+			}
2433 2571
 
2434 2572
 			// Now, for each file do we need to edit it?
2435 2573
 			foreach ($template_changes[1] as $pos => $template_file)
@@ -2465,32 +2603,36 @@  discard block
 block discarded – undo
2465 2603
 				package_chmod($working_file);
2466 2604
 
2467 2605
 				// Don't even dare.
2468
-				if (basename($working_file) == 'Settings_bak.php')
2469
-					continue;
2606
+				if (basename($working_file) == 'Settings_bak.php') {
2607
+									continue;
2608
+				}
2470 2609
 
2471
-				if (!is_writable($working_file))
2472
-					$actions[] = array(
2610
+				if (!is_writable($working_file)) {
2611
+									$actions[] = array(
2473 2612
 						'type' => 'chmod',
2474 2613
 						'filename' => $working_file
2475 2614
 					);
2615
+				}
2476 2616
 
2477 2617
 				if (!$testing && !empty($modSettings['package_make_backups']) && file_exists($working_file))
2478 2618
 				{
2479
-					if (basename($working_file) == 'Settings.php')
2480
-						@copy($working_file, dirname($working_file) . '/Settings_bak.php');
2481
-					else
2482
-						@copy($working_file, $working_file . '~');
2619
+					if (basename($working_file) == 'Settings.php') {
2620
+											@copy($working_file, dirname($working_file) . '/Settings_bak.php');
2621
+					} else {
2622
+											@copy($working_file, $working_file . '~');
2623
+					}
2483 2624
 				}
2484 2625
 
2485 2626
 				package_put_contents($working_file, $working_data, $testing);
2486 2627
 			}
2487 2628
 
2488
-			if ($working_file !== null)
2489
-				$actions[] = array(
2629
+			if ($working_file !== null) {
2630
+							$actions[] = array(
2490 2631
 					'type' => 'saved',
2491 2632
 					'filename' => $working_file,
2492 2633
 					'is_custom' => $is_custom,
2493 2634
 				);
2635
+			}
2494 2636
 
2495 2637
 			// Is this "now working on" file a theme specific one?
2496 2638
 			$is_custom = isset($theme_id_ref[$counter - 1]) ? $theme_id_ref[$counter - 1] : 0;
@@ -2509,10 +2651,11 @@  discard block
 block discarded – undo
2509 2651
 			{
2510 2652
 				$places_to_check = array($boarddir, $sourcedir, $settings['default_theme_dir'], $settings['default_theme_dir'] . '/languages');
2511 2653
 
2512
-				foreach ($places_to_check as $place)
2513
-					if (file_exists($place . '/' . $working_file))
2654
+				foreach ($places_to_check as $place) {
2655
+									if (file_exists($place . '/' . $working_file))
2514 2656
 					{
2515 2657
 						$working_file = $place . '/' . $working_file;
2658
+				}
2516 2659
 						break;
2517 2660
 					}
2518 2661
 			}
@@ -2526,8 +2669,7 @@  discard block
 block discarded – undo
2526 2669
 					'type' => 'opened',
2527 2670
 					'filename' => $working_file
2528 2671
 				);
2529
-			}
2530
-			else
2672
+			} else
2531 2673
 			{
2532 2674
 				$actions[] = array(
2533 2675
 					'type' => 'missing',
@@ -2563,11 +2705,13 @@  discard block
 block discarded – undo
2563 2705
 			$replace_with = $code_match[2];
2564 2706
 
2565 2707
 			// Add this afterward...
2566
-			if ($code_match[1] == 'add' || $code_match[1] == 'add after')
2567
-				$replace_with = $working_search . "\n" . $replace_with;
2708
+			if ($code_match[1] == 'add' || $code_match[1] == 'add after') {
2709
+							$replace_with = $working_search . "\n" . $replace_with;
2710
+			}
2568 2711
 			// Add this beforehand.
2569
-			elseif ($code_match[1] == 'before' || $code_match[1] == 'add before' || $code_match[1] == 'above' || $code_match[1] == 'add above')
2570
-				$replace_with .= "\n" . $working_search;
2712
+			elseif ($code_match[1] == 'before' || $code_match[1] == 'add before' || $code_match[1] == 'above' || $code_match[1] == 'add above') {
2713
+							$replace_with .= "\n" . $working_search;
2714
+			}
2571 2715
 			// Otherwise.. replace with $replace_with ;).
2572 2716
 		}
2573 2717
 
@@ -2630,29 +2774,32 @@  discard block
 block discarded – undo
2630 2774
 	{
2631 2775
 		package_chmod($working_file);
2632 2776
 
2633
-		if (!is_writable($working_file))
2634
-			$actions[] = array(
2777
+		if (!is_writable($working_file)) {
2778
+					$actions[] = array(
2635 2779
 				'type' => 'chmod',
2636 2780
 				'filename' => $working_file
2637 2781
 			);
2782
+		}
2638 2783
 
2639 2784
 		if (!$testing && !empty($modSettings['package_make_backups']) && file_exists($working_file))
2640 2785
 		{
2641
-			if (basename($working_file) == 'Settings.php')
2642
-				@copy($working_file, dirname($working_file) . '/Settings_bak.php');
2643
-			else
2644
-				@copy($working_file, $working_file . '~');
2786
+			if (basename($working_file) == 'Settings.php') {
2787
+							@copy($working_file, dirname($working_file) . '/Settings_bak.php');
2788
+			} else {
2789
+							@copy($working_file, $working_file . '~');
2790
+			}
2645 2791
 		}
2646 2792
 
2647 2793
 		package_put_contents($working_file, $working_data, $testing);
2648 2794
 	}
2649 2795
 
2650
-	if ($working_file !== null)
2651
-		$actions[] = array(
2796
+	if ($working_file !== null) {
2797
+			$actions[] = array(
2652 2798
 			'type' => 'saved',
2653 2799
 			'filename' => $working_file,
2654 2800
 			'is_custom' => $is_custom,
2655 2801
 		);
2802
+	}
2656 2803
 
2657 2804
 	$actions[] = array(
2658 2805
 		'type' => 'result',
@@ -2678,17 +2825,19 @@  discard block
 block discarded – undo
2678 2825
 		$mem_check = setMemoryLimit('128M');
2679 2826
 
2680 2827
 		// Windows doesn't seem to care about the memory_limit.
2681
-		if (!empty($modSettings['package_disable_cache']) || $mem_check || stripos(PHP_OS, 'win') !== false)
2682
-			$package_cache = array();
2683
-		else
2684
-			$package_cache = false;
2828
+		if (!empty($modSettings['package_disable_cache']) || $mem_check || stripos(PHP_OS, 'win') !== false) {
2829
+					$package_cache = array();
2830
+		} else {
2831
+					$package_cache = false;
2832
+		}
2685 2833
 	}
2686 2834
 
2687
-	if (strpos($filename, 'Packages/') !== false || $package_cache === false || !isset($package_cache[$filename]))
2688
-		return file_get_contents($filename);
2689
-	else
2690
-		return $package_cache[$filename];
2691
-}
2835
+	if (strpos($filename, 'Packages/') !== false || $package_cache === false || !isset($package_cache[$filename])) {
2836
+			return file_get_contents($filename);
2837
+	} else {
2838
+			return $package_cache[$filename];
2839
+	}
2840
+	}
2692 2841
 
2693 2842
 /**
2694 2843
  * Writes data to a file, almost exactly like the file_put_contents() function.
@@ -2712,19 +2861,22 @@  discard block
 block discarded – undo
2712 2861
 		// Try to increase the memory limit - we don't want to run out of ram!
2713 2862
 		$mem_check = setMemoryLimit('128M');
2714 2863
 
2715
-		if (!empty($modSettings['package_disable_cache']) || $mem_check || stripos(PHP_OS, 'win') !== false)
2716
-			$package_cache = array();
2717
-		else
2718
-			$package_cache = false;
2864
+		if (!empty($modSettings['package_disable_cache']) || $mem_check || stripos(PHP_OS, 'win') !== false) {
2865
+					$package_cache = array();
2866
+		} else {
2867
+					$package_cache = false;
2868
+		}
2719 2869
 	}
2720 2870
 
2721
-	if (isset($package_ftp))
2722
-		$ftp_file = strtr($filename, array($_SESSION['pack_ftp']['root'] => ''));
2871
+	if (isset($package_ftp)) {
2872
+			$ftp_file = strtr($filename, array($_SESSION['pack_ftp']['root'] => ''));
2873
+	}
2723 2874
 
2724
-	if (!file_exists($filename) && isset($package_ftp))
2725
-		$package_ftp->create_file($ftp_file);
2726
-	elseif (!file_exists($filename))
2727
-		@touch($filename);
2875
+	if (!file_exists($filename) && isset($package_ftp)) {
2876
+			$package_ftp->create_file($ftp_file);
2877
+	} elseif (!file_exists($filename)) {
2878
+			@touch($filename);
2879
+	}
2728 2880
 
2729 2881
 	package_chmod($filename);
2730 2882
 
@@ -2733,22 +2885,23 @@  discard block
 block discarded – undo
2733 2885
 		$fp = @fopen($filename, in_array(substr($filename, -3), $text_filetypes) ? 'w' : 'wb');
2734 2886
 
2735 2887
 		// We should show an error message or attempt a rollback, no?
2736
-		if (!$fp)
2737
-			return false;
2888
+		if (!$fp) {
2889
+					return false;
2890
+		}
2738 2891
 
2739 2892
 		fwrite($fp, $data);
2740 2893
 		fclose($fp);
2741
-	}
2742
-	elseif (strpos($filename, 'Packages/') !== false || $package_cache === false)
2743
-		return strlen($data);
2744
-	else
2894
+	} elseif (strpos($filename, 'Packages/') !== false || $package_cache === false) {
2895
+			return strlen($data);
2896
+	} else
2745 2897
 	{
2746 2898
 		$package_cache[$filename] = $data;
2747 2899
 
2748 2900
 		// Permission denied, eh?
2749 2901
 		$fp = @fopen($filename, 'r+');
2750
-		if (!$fp)
2751
-			return false;
2902
+		if (!$fp) {
2903
+					return false;
2904
+		}
2752 2905
 		fclose($fp);
2753 2906
 	}
2754 2907
 
@@ -2766,19 +2919,22 @@  discard block
 block discarded – undo
2766 2919
 	global $package_ftp, $package_cache;
2767 2920
 	static $text_filetypes = array('php', 'txt', '.js', 'css', 'vbs', 'tml', 'htm');
2768 2921
 
2769
-	if (empty($package_cache))
2770
-		return;
2922
+	if (empty($package_cache)) {
2923
+			return;
2924
+	}
2771 2925
 
2772 2926
 	// First, let's check permissions!
2773 2927
 	foreach ($package_cache as $filename => $data)
2774 2928
 	{
2775
-		if (isset($package_ftp))
2776
-			$ftp_file = strtr($filename, array($_SESSION['pack_ftp']['root'] => ''));
2929
+		if (isset($package_ftp)) {
2930
+					$ftp_file = strtr($filename, array($_SESSION['pack_ftp']['root'] => ''));
2931
+		}
2777 2932
 
2778
-		if (!file_exists($filename) && isset($package_ftp))
2779
-			$package_ftp->create_file($ftp_file);
2780
-		elseif (!file_exists($filename))
2781
-			@touch($filename);
2933
+		if (!file_exists($filename) && isset($package_ftp)) {
2934
+					$package_ftp->create_file($ftp_file);
2935
+		} elseif (!file_exists($filename)) {
2936
+					@touch($filename);
2937
+		}
2782 2938
 
2783 2939
 		$result = package_chmod($filename);
2784 2940
 
@@ -2832,8 +2988,9 @@  discard block
 block discarded – undo
2832 2988
 	/** @var ftp_connection $package_ftp */
2833 2989
 	global $package_ftp;
2834 2990
 
2835
-	if (file_exists($filename) && is_writable($filename) && $perm_state == 'writable')
2836
-		return true;
2991
+	if (file_exists($filename) && is_writable($filename) && $perm_state == 'writable') {
2992
+			return true;
2993
+	}
2837 2994
 
2838 2995
 	// Start off checking without FTP.
2839 2996
 	if (!isset($package_ftp) || $package_ftp === false)
@@ -2855,8 +3012,7 @@  discard block
 block discarded – undo
2855 3012
 
2856 3013
 				// Keep track of the writable status here.
2857 3014
 				$file_permissions = @fileperms($chmod_file);
2858
-			}
2859
-			else
3015
+			} else
2860 3016
 			{
2861 3017
 				// This looks odd, but it's an attempt to work around PHP suExec.
2862 3018
 				if (!file_exists($chmod_file) && $perm_state == 'writable')
@@ -2866,24 +3022,28 @@  discard block
 block discarded – undo
2866 3022
 					mktree(dirname($chmod_file), 0755);
2867 3023
 					@touch($chmod_file);
2868 3024
 					smf_chmod($chmod_file, 0755);
3025
+				} else {
3026
+									$file_permissions = @fileperms($chmod_file);
2869 3027
 				}
2870
-				else
2871
-					$file_permissions = @fileperms($chmod_file);
2872 3028
 			}
2873 3029
 
2874 3030
 			// This looks odd, but it's another attempt to work around PHP suExec.
2875
-			if ($perm_state != 'writable')
2876
-				smf_chmod($chmod_file, $perm_state == 'execute' ? 0755 : 0644);
2877
-			else
3031
+			if ($perm_state != 'writable') {
3032
+							smf_chmod($chmod_file, $perm_state == 'execute' ? 0755 : 0644);
3033
+			} else
2878 3034
 			{
2879
-				if (!@is_writable($chmod_file))
2880
-					smf_chmod($chmod_file, 0755);
2881
-				if (!@is_writable($chmod_file))
2882
-					smf_chmod($chmod_file, 0777);
2883
-				if (!@is_writable(dirname($chmod_file)))
2884
-					smf_chmod($chmod_file, 0755);
2885
-				if (!@is_writable(dirname($chmod_file)))
2886
-					smf_chmod($chmod_file, 0777);
3035
+				if (!@is_writable($chmod_file)) {
3036
+									smf_chmod($chmod_file, 0755);
3037
+				}
3038
+				if (!@is_writable($chmod_file)) {
3039
+									smf_chmod($chmod_file, 0777);
3040
+				}
3041
+				if (!@is_writable(dirname($chmod_file))) {
3042
+									smf_chmod($chmod_file, 0755);
3043
+				}
3044
+				if (!@is_writable(dirname($chmod_file))) {
3045
+									smf_chmod($chmod_file, 0777);
3046
+				}
2887 3047
 			}
2888 3048
 
2889 3049
 			// The ultimate writable test.
@@ -2892,20 +3052,22 @@  discard block
 block discarded – undo
2892 3052
 				$fp = is_dir($chmod_file) ? @opendir($chmod_file) : @fopen($chmod_file, 'rb');
2893 3053
 				if (@is_writable($chmod_file) && $fp)
2894 3054
 				{
2895
-					if (!is_dir($chmod_file))
2896
-						fclose($fp);
2897
-					else
2898
-						closedir($fp);
3055
+					if (!is_dir($chmod_file)) {
3056
+											fclose($fp);
3057
+					} else {
3058
+											closedir($fp);
3059
+					}
2899 3060
 
2900 3061
 					// It worked!
2901
-					if ($track_change)
2902
-						$_SESSION['pack_ftp']['original_perms'][$chmod_file] = $file_permissions;
3062
+					if ($track_change) {
3063
+											$_SESSION['pack_ftp']['original_perms'][$chmod_file] = $file_permissions;
3064
+					}
2903 3065
 
2904 3066
 					return true;
2905 3067
 				}
3068
+			} elseif ($perm_state != 'writable' && isset($_SESSION['pack_ftp']['original_perms'][$chmod_file])) {
3069
+							unset($_SESSION['pack_ftp']['original_perms'][$chmod_file]);
2906 3070
 			}
2907
-			elseif ($perm_state != 'writable' && isset($_SESSION['pack_ftp']['original_perms'][$chmod_file]))
2908
-				unset($_SESSION['pack_ftp']['original_perms'][$chmod_file]);
2909 3071
 		}
2910 3072
 
2911 3073
 		// If we're here we're a failure.
@@ -2924,31 +3086,33 @@  discard block
 block discarded – undo
2924 3086
 			mktree(dirname($filename), 0755);
2925 3087
 			$package_ftp->create_file($ftp_file);
2926 3088
 			$package_ftp->chmod($ftp_file, 0755);
3089
+		} else {
3090
+					$file_permissions = @fileperms($filename);
2927 3091
 		}
2928
-		else
2929
-			$file_permissions = @fileperms($filename);
2930 3092
 
2931 3093
 		if ($perm_state != 'writable')
2932 3094
 		{
2933 3095
 			$package_ftp->chmod($ftp_file, $perm_state == 'execute' ? 0755 : 0644);
2934
-		}
2935
-		else
3096
+		} else
2936 3097
 		{
2937
-			if (!@is_writable($filename))
2938
-				$package_ftp->chmod($ftp_file, 0777);
2939
-			if (!@is_writable(dirname($filename)))
2940
-				$package_ftp->chmod(dirname($ftp_file), 0777);
3098
+			if (!@is_writable($filename)) {
3099
+							$package_ftp->chmod($ftp_file, 0777);
3100
+			}
3101
+			if (!@is_writable(dirname($filename))) {
3102
+							$package_ftp->chmod(dirname($ftp_file), 0777);
3103
+			}
2941 3104
 		}
2942 3105
 
2943 3106
 		if (@is_writable($filename))
2944 3107
 		{
2945
-			if ($track_change)
2946
-				$_SESSION['pack_ftp']['original_perms'][$filename] = $file_permissions;
3108
+			if ($track_change) {
3109
+							$_SESSION['pack_ftp']['original_perms'][$filename] = $file_permissions;
3110
+			}
2947 3111
 
2948 3112
 			return true;
3113
+		} elseif ($perm_state != 'writable' && isset($_SESSION['pack_ftp']['original_perms'][$filename])) {
3114
+					unset($_SESSION['pack_ftp']['original_perms'][$filename]);
2949 3115
 		}
2950
-		elseif ($perm_state != 'writable' && isset($_SESSION['pack_ftp']['original_perms'][$filename]))
2951
-			unset($_SESSION['pack_ftp']['original_perms'][$filename]);
2952 3116
 	}
2953 3117
 
2954 3118
 	// Oh dear, we failed if we get here.
@@ -2966,11 +3130,13 @@  discard block
 block discarded – undo
2966 3130
 	$n = strlen($pass);
2967 3131
 
2968 3132
 	$salt = session_id();
2969
-	while (strlen($salt) < $n)
2970
-		$salt .= session_id();
3133
+	while (strlen($salt) < $n) {
3134
+			$salt .= session_id();
3135
+	}
2971 3136
 
2972
-	for ($i = 0; $i < $n; $i++)
2973
-		$pass{$i} = chr(ord($pass{$i}) ^ (ord($salt{$i}) - 32));
3137
+	for ($i = 0; $i < $n; $i++) {
3138
+			$pass{$i} = chr(ord($pass{$i}) ^ (ord($salt{$i}) - 32));
3139
+	}
2974 3140
 
2975 3141
 	return $pass;
2976 3142
 }
@@ -2989,8 +3155,9 @@  discard block
 block discarded – undo
2989 3155
 	$base_files = array('index.php', 'SSI.php', 'agreement.txt', 'cron.php', 'ssi_examples.php', 'ssi_examples.shtml', 'subscriptions.php');
2990 3156
 	foreach ($base_files as $file)
2991 3157
 	{
2992
-		if (file_exists($boarddir . '/' . $file))
2993
-			$files[empty($_REQUEST['use_full_paths']) ? $file : $boarddir . '/' . $file] = $boarddir . '/' . $file;
3158
+		if (file_exists($boarddir . '/' . $file)) {
3159
+					$files[empty($_REQUEST['use_full_paths']) ? $file : $boarddir . '/' . $file] = $boarddir . '/' . $file;
3160
+		}
2994 3161
 	}
2995 3162
 
2996 3163
 	$dirs = array(
@@ -3007,8 +3174,9 @@  discard block
 block discarded – undo
3007 3174
 			'theme_dir' => 'theme_dir',
3008 3175
 		)
3009 3176
 	);
3010
-	while ($row = $smcFunc['db_fetch_assoc']($request))
3011
-		$dirs[$row['value']] = empty($_REQUEST['use_full_paths']) ? 'Themes/' . basename($row['value']) . '/' : strtr($row['value'] . '/', '\\', '/');
3177
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
3178
+			$dirs[$row['value']] = empty($_REQUEST['use_full_paths']) ? 'Themes/' . basename($row['value']) . '/' : strtr($row['value'] . '/', '\\', '/');
3179
+	}
3012 3180
 	$smcFunc['db_free_result']($request);
3013 3181
 
3014 3182
 	try
@@ -3023,11 +3191,13 @@  discard block
 block discarded – undo
3023 3191
 
3024 3192
 			foreach ($iter as $entry => $dir)
3025 3193
 			{
3026
-				if ($dir->isDir())
3027
-					continue;
3194
+				if ($dir->isDir()) {
3195
+									continue;
3196
+				}
3028 3197
 
3029
-				if (preg_match('~^(\.{1,2}|CVS|backup.*|help|images|.*\~)$~', $entry) != 0)
3030
-					continue;
3198
+				if (preg_match('~^(\.{1,2}|CVS|backup.*|help|images|.*\~)$~', $entry) != 0) {
3199
+									continue;
3200
+				}
3031 3201
 
3032 3202
 				$files[empty($_REQUEST['use_full_paths']) ? str_replace(realpath($boarddir), '', $entry) : $entry] = $entry;
3033 3203
 			}
@@ -3035,10 +3205,12 @@  discard block
 block discarded – undo
3035 3205
 		$obj = new ArrayObject($files);
3036 3206
 		$iterator = $obj->getIterator();
3037 3207
 
3038
-		if (!file_exists($packagesdir . '/backups'))
3039
-			mktree($packagesdir . '/backups', 0777);
3040
-		if (!is_writable($packagesdir . '/backups'))
3041
-			package_chmod($packagesdir . '/backups');
3208
+		if (!file_exists($packagesdir . '/backups')) {
3209
+					mktree($packagesdir . '/backups', 0777);
3210
+		}
3211
+		if (!is_writable($packagesdir . '/backups')) {
3212
+					package_chmod($packagesdir . '/backups');
3213
+		}
3042 3214
 		$output_file = $packagesdir . '/backups/' . strftime('%Y-%m-%d_') . preg_replace('~[$\\\\/:<>|?*"\']~', '', $id);
3043 3215
 		$output_ext = '.tar';
3044 3216
 		$output_ext_target = '.tar.gz';
@@ -3046,16 +3218,18 @@  discard block
 block discarded – undo
3046 3218
 		if (file_exists($output_file . $output_ext_target))
3047 3219
 		{
3048 3220
 			$i = 2;
3049
-			while (file_exists($output_file . '_' . $i . $output_ext_target))
3050
-				$i++;
3221
+			while (file_exists($output_file . '_' . $i . $output_ext_target)) {
3222
+							$i++;
3223
+			}
3051 3224
 			$output_file = $output_file . '_' . $i . $output_ext;
3225
+		} else {
3226
+					$output_file .= $output_ext;
3052 3227
 		}
3053
-		else
3054
-			$output_file .= $output_ext;
3055 3228
 
3056 3229
 		@set_time_limit(300);
3057
-		if (function_exists('apache_reset_timeout'))
3058
-			@apache_reset_timeout();
3230
+		if (function_exists('apache_reset_timeout')) {
3231
+					@apache_reset_timeout();
3232
+		}
3059 3233
 
3060 3234
 		$a = new PharData($output_file);
3061 3235
 		$a->buildFromIterator($iterator);
@@ -3067,8 +3241,7 @@  discard block
 block discarded – undo
3067 3241
 		 */
3068 3242
 		unset($a);
3069 3243
 		unlink($output_file);
3070
-	}
3071
-	catch (Exception $e)
3244
+	} catch (Exception $e)
3072 3245
 	{
3073 3246
 		log_error($e->getMessage(), 'backup');
3074 3247
 
@@ -3100,32 +3273,35 @@  discard block
 block discarded – undo
3100 3273
 	preg_match('~^(http|ftp)(s)?://([^/:]+)(:(\d+))?(.+)$~', $url, $match);
3101 3274
 
3102 3275
 	// An FTP url. We should try connecting and RETRieving it...
3103
-	if (empty($match[1]))
3104
-		return false;
3105
-	elseif ($match[1] == 'ftp')
3276
+	if (empty($match[1])) {
3277
+			return false;
3278
+	} elseif ($match[1] == 'ftp')
3106 3279
 	{
3107 3280
 		// Include the file containing the ftp_connection class.
3108 3281
 		require_once($sourcedir . '/Class-Package.php');
3109 3282
 
3110 3283
 		// Establish a connection and attempt to enable passive mode.
3111 3284
 		$ftp = new ftp_connection(($match[2] ? 'ssl://' : '') . $match[3], empty($match[5]) ? 21 : $match[5], 'anonymous', $webmaster_email);
3112
-		if ($ftp->error !== false || !$ftp->passive())
3113
-			return false;
3285
+		if ($ftp->error !== false || !$ftp->passive()) {
3286
+					return false;
3287
+		}
3114 3288
 
3115 3289
 		// I want that one *points*!
3116 3290
 		fwrite($ftp->connection, 'RETR ' . $match[6] . "\r\n");
3117 3291
 
3118 3292
 		// Since passive mode worked (or we would have returned already!) open the connection.
3119 3293
 		$fp = @fsockopen($ftp->pasv['ip'], $ftp->pasv['port'], $err, $err, 5);
3120
-		if (!$fp)
3121
-			return false;
3294
+		if (!$fp) {
3295
+					return false;
3296
+		}
3122 3297
 
3123 3298
 		// The server should now say something in acknowledgement.
3124 3299
 		$ftp->check_response(150);
3125 3300
 
3126 3301
 		$data = '';
3127
-		while (!feof($fp))
3128
-			$data .= fread($fp, 4096);
3302
+		while (!feof($fp)) {
3303
+					$data .= fread($fp, 4096);
3304
+		}
3129 3305
 		fclose($fp);
3130 3306
 
3131 3307
 		// All done, right?  Good.
@@ -3142,22 +3318,25 @@  discard block
 block discarded – undo
3142 3318
 		$fetch_data->get_url_data($url, $post_data);
3143 3319
 
3144 3320
 		// no errors and a 200 result, then we have a good dataset, well we at least have data ;)
3145
-		if ($fetch_data->result('code') == 200 && !$fetch_data->result('error'))
3146
-			$data = $fetch_data->result('body');
3147
-		else
3148
-			return false;
3321
+		if ($fetch_data->result('code') == 200 && !$fetch_data->result('error')) {
3322
+					$data = $fetch_data->result('body');
3323
+		} else {
3324
+					return false;
3325
+		}
3149 3326
 	}
3150 3327
 	// This is more likely; a standard HTTP URL.
3151 3328
 	elseif (isset($match[1]) && $match[1] == 'http')
3152 3329
 	{
3153
-		if ($keep_alive && $match[3] == $keep_alive_dom)
3154
-			$fp = $keep_alive_fp;
3330
+		if ($keep_alive && $match[3] == $keep_alive_dom) {
3331
+					$fp = $keep_alive_fp;
3332
+		}
3155 3333
 		if (empty($fp))
3156 3334
 		{
3157 3335
 			// Open the socket on the port we want...
3158 3336
 			$fp = @fsockopen(($match[2] ? 'ssl://' : '') . $match[3], empty($match[5]) ? ($match[2] ? 443 : 80) : $match[5], $err, $err, 5);
3159
-			if (!$fp)
3160
-				return false;
3337
+			if (!$fp) {
3338
+							return false;
3339
+			}
3161 3340
 		}
3162 3341
 
3163 3342
 		if ($keep_alive)
@@ -3172,20 +3351,21 @@  discard block
 block discarded – undo
3172 3351
 			fwrite($fp, 'GET ' . ($match[6] !== '/' ? str_replace(' ', '%20', $match[6]) : '') . ' HTTP/1.0' . "\r\n");
3173 3352
 			fwrite($fp, 'Host: ' . $match[3] . (empty($match[5]) ? ($match[2] ? ':443' : '') : ':' . $match[5]) . "\r\n");
3174 3353
 			fwrite($fp, 'User-Agent: PHP/SMF' . "\r\n");
3175
-			if ($keep_alive)
3176
-				fwrite($fp, 'Connection: Keep-Alive' . "\r\n\r\n");
3177
-			else
3178
-				fwrite($fp, 'Connection: close' . "\r\n\r\n");
3179
-		}
3180
-		else
3354
+			if ($keep_alive) {
3355
+							fwrite($fp, 'Connection: Keep-Alive' . "\r\n\r\n");
3356
+			} else {
3357
+							fwrite($fp, 'Connection: close' . "\r\n\r\n");
3358
+			}
3359
+		} else
3181 3360
 		{
3182 3361
 			fwrite($fp, 'POST ' . ($match[6] !== '/' ? $match[6] : '') . ' HTTP/1.0' . "\r\n");
3183 3362
 			fwrite($fp, 'Host: ' . $match[3] . (empty($match[5]) ? ($match[2] ? ':443' : '') : ':' . $match[5]) . "\r\n");
3184 3363
 			fwrite($fp, 'User-Agent: PHP/SMF' . "\r\n");
3185
-			if ($keep_alive)
3186
-				fwrite($fp, 'Connection: Keep-Alive' . "\r\n");
3187
-			else
3188
-				fwrite($fp, 'Connection: close' . "\r\n");
3364
+			if ($keep_alive) {
3365
+							fwrite($fp, 'Connection: Keep-Alive' . "\r\n");
3366
+			} else {
3367
+							fwrite($fp, 'Connection: close' . "\r\n");
3368
+			}
3189 3369
 			fwrite($fp, 'Content-Type: application/x-www-form-urlencoded' . "\r\n");
3190 3370
 			fwrite($fp, 'Content-Length: ' . strlen($post_data) . "\r\n\r\n");
3191 3371
 			fwrite($fp, $post_data);
@@ -3198,30 +3378,33 @@  discard block
 block discarded – undo
3198 3378
 		{
3199 3379
 			$header = '';
3200 3380
 			$location = '';
3201
-			while (!feof($fp) && trim($header = fgets($fp, 4096)) != '')
3202
-				if (strpos($header, 'Location:') !== false)
3381
+			while (!feof($fp) && trim($header = fgets($fp, 4096)) != '') {
3382
+							if (strpos($header, 'Location:') !== false)
3203 3383
 					$location = trim(substr($header, strpos($header, ':') + 1));
3384
+			}
3204 3385
 
3205
-			if (empty($location))
3206
-				return false;
3207
-			else
3386
+			if (empty($location)) {
3387
+							return false;
3388
+			} else
3208 3389
 			{
3209
-				if (!$keep_alive)
3210
-					fclose($fp);
3390
+				if (!$keep_alive) {
3391
+									fclose($fp);
3392
+				}
3211 3393
 				return fetch_web_data($location, $post_data, $keep_alive, $redirection_level + 1);
3212 3394
 			}
3213 3395
 		}
3214 3396
 
3215 3397
 		// Make sure we get a 200 OK.
3216
-		elseif (preg_match('~^HTTP/\S+\s+20[01]~i', $response) === 0)
3217
-			return false;
3398
+		elseif (preg_match('~^HTTP/\S+\s+20[01]~i', $response) === 0) {
3399
+					return false;
3400
+		}
3218 3401
 
3219 3402
 		// Skip the headers...
3220 3403
 		while (!feof($fp) && trim($header = fgets($fp, 4096)) != '')
3221 3404
 		{
3222
-			if (preg_match('~content-length:\s*(\d+)~i', $header, $match) != 0)
3223
-				$content_length = $match[1];
3224
-			elseif (preg_match('~connection:\s*close~i', $header) != 0)
3405
+			if (preg_match('~content-length:\s*(\d+)~i', $header, $match) != 0) {
3406
+							$content_length = $match[1];
3407
+			} elseif (preg_match('~connection:\s*close~i', $header) != 0)
3225 3408
 			{
3226 3409
 				$keep_alive_dom = null;
3227 3410
 				$keep_alive = false;
@@ -3233,19 +3416,20 @@  discard block
 block discarded – undo
3233 3416
 		$data = '';
3234 3417
 		if (isset($content_length))
3235 3418
 		{
3236
-			while (!feof($fp) && strlen($data) < $content_length)
3237
-				$data .= fread($fp, $content_length - strlen($data));
3238
-		}
3239
-		else
3419
+			while (!feof($fp) && strlen($data) < $content_length) {
3420
+							$data .= fread($fp, $content_length - strlen($data));
3421
+			}
3422
+		} else
3240 3423
 		{
3241
-			while (!feof($fp))
3242
-				$data .= fread($fp, 4096);
3424
+			while (!feof($fp)) {
3425
+							$data .= fread($fp, 4096);
3426
+			}
3243 3427
 		}
3244 3428
 
3245
-		if (!$keep_alive)
3246
-			fclose($fp);
3247
-	}
3248
-	else
3429
+		if (!$keep_alive) {
3430
+					fclose($fp);
3431
+		}
3432
+	} else
3249 3433
 	{
3250 3434
 		// Umm, this shouldn't happen?
3251 3435
 		trigger_error('fetch_web_data(): Bad URL', E_USER_NOTICE);
Please login to merge, or discard this patch.
Sources/ManageServer.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -239,7 +239,7 @@
 block discarded – undo
239 239
 		while ($row = $smcFunc['db_fetch_assoc']($request))
240 240
 			$fts_language[$row['cfgname']] = $row['cfgname'];
241 241
 		
242
-		$config_vars = array_merge ($config_vars, array(
242
+		$config_vars = array_merge($config_vars, array(
243 243
 				'',
244 244
 				array('search_language', $txt['search_language'], 'db', 'select', $fts_language, 'pgFulltextSearch')
245 245
 			)
Please login to merge, or discard this patch.
Braces   +309 added lines, -239 removed lines patch added patch discarded remove patch
@@ -59,8 +59,9 @@  discard block
 block discarded – undo
59 59
  * @version 2.1 Beta 4
60 60
  */
61 61
 
62
-if (!defined('SMF'))
62
+if (!defined('SMF')) {
63 63
 	die('No direct access...');
64
+}
64 65
 
65 66
 /**
66 67
  * This is the main dispatcher. Sets up all the available sub-actions, all the tabs and selects
@@ -111,10 +112,11 @@  discard block
 block discarded – undo
111 112
 	$settings_not_writable = !is_writable($boarddir . '/Settings.php');
112 113
 	$settings_backup_fail = !@is_writable($boarddir . '/Settings_bak.php') || !@copy($boarddir . '/Settings.php', $boarddir . '/Settings_bak.php');
113 114
 
114
-	if ($settings_not_writable)
115
-		$context['settings_message'] = '<div class="centertext"><strong>' . $txt['settings_not_writable'] . '</strong></div><br>';
116
-	elseif ($settings_backup_fail)
117
-		$context['settings_message'] = '<div class="centertext"><strong>' . $txt['admin_backup_fail'] . '</strong></div><br>';
115
+	if ($settings_not_writable) {
116
+			$context['settings_message'] = '<div class="centertext"><strong>' . $txt['settings_not_writable'] . '</strong></div><br>';
117
+	} elseif ($settings_backup_fail) {
118
+			$context['settings_message'] = '<div class="centertext"><strong>' . $txt['admin_backup_fail'] . '</strong></div><br>';
119
+	}
118 120
 
119 121
 	$context['settings_not_writable'] = $settings_not_writable;
120 122
 
@@ -142,10 +144,11 @@  discard block
 block discarded – undo
142 144
 
143 145
 	// If no cert, force_ssl must remain 0
144 146
 	require_once($sourcedir . '/Subs.php');
145
-	if (!ssl_cert_found($boardurl) && empty($modSettings['force_ssl']))
146
-		$disable_force_ssl = true;
147
-	else
148
-		$disable_force_ssl = false;
147
+	if (!ssl_cert_found($boardurl) && empty($modSettings['force_ssl'])) {
148
+			$disable_force_ssl = true;
149
+	} else {
150
+			$disable_force_ssl = false;
151
+	}
149 152
 
150 153
 	/* If you're writing a mod, it's a bad idea to add things here....
151 154
 	For each option:
@@ -175,8 +178,9 @@  discard block
 block discarded – undo
175 178
 
176 179
 	call_integration_hook('integrate_general_settings', array(&$config_vars));
177 180
 
178
-	if ($return_config)
179
-		return $config_vars;
181
+	if ($return_config) {
182
+			return $config_vars;
183
+	}
180 184
 
181 185
 	// Setup the template stuff.
182 186
 	$context['post_url'] = $scripturl . '?action=admin;area=serversettings;sa=general;save';
@@ -193,16 +197,18 @@  discard block
 block discarded – undo
193 197
 			$registerSMStats = registerSMStats();
194 198
 
195 199
 			// Failed to register, disable it again.
196
-			if (empty($registerSMStats))
197
-				$_POST['enable_sm_stats'] = 0;
200
+			if (empty($registerSMStats)) {
201
+							$_POST['enable_sm_stats'] = 0;
202
+			}
198 203
 		}
199 204
 
200 205
 		// Ensure all URLs are aligned with the new force_ssl setting
201 206
 		// Treat unset like 0
202
-		if (isset($_POST['force_ssl']))
203
-			AlignURLsWithSSLSetting($_POST['force_ssl']);
204
-		else
205
-			AlignURLsWithSSLSetting(0);
207
+		if (isset($_POST['force_ssl'])) {
208
+					AlignURLsWithSSLSetting($_POST['force_ssl']);
209
+		} else {
210
+					AlignURLsWithSSLSetting(0);
211
+		}
206 212
 			
207 213
 		saveSettings($config_vars);
208 214
 		$_SESSION['adm-save'] = true;
@@ -255,10 +261,11 @@  discard block
 block discarded – undo
255 261
 	require_once($sourcedir . '/Subs-Admin.php');
256 262
 
257 263
 	// Check $boardurl
258
-	if ($new_force_ssl == 2)
259
-		$newval = strtr($boardurl, array('http://' => 'https://'));
260
-	else
261
-		$newval = strtr($boardurl, array('https://' => 'http://'));
264
+	if ($new_force_ssl == 2) {
265
+			$newval = strtr($boardurl, array('http://' => 'https://'));
266
+	} else {
267
+			$newval = strtr($boardurl, array('https://' => 'http://'));
268
+	}
262 269
 	updateSettingsFile(array('boardurl' => '\'' . addslashes($newval) . '\''));
263 270
 
264 271
 	$new_settings = array();
@@ -266,20 +273,22 @@  discard block
 block discarded – undo
266 273
 	// Check $smileys_url, but only if it points to a subfolder of $boardurl
267 274
 	if (BoardurlMatch($modSettings['smileys_url']))
268 275
 	{
269
-		if ($new_force_ssl == 2)
270
-			$newval = strtr($modSettings['smileys_url'], array('http://' => 'https://'));
271
-		else
272
-			$newval = strtr($modSettings['smileys_url'], array('https://' => 'http://'));
276
+		if ($new_force_ssl == 2) {
277
+					$newval = strtr($modSettings['smileys_url'], array('http://' => 'https://'));
278
+		} else {
279
+					$newval = strtr($modSettings['smileys_url'], array('https://' => 'http://'));
280
+		}
273 281
 		$new_settings['smileys_url'] = $newval;
274 282
 	}
275 283
 
276 284
 	// Check $avatar_url, but only if it points to a subfolder of $boardurl
277 285
 	if (BoardurlMatch($modSettings['avatar_url']))
278 286
 	{
279
-		if ($new_force_ssl == 2)
280
-			$newval = strtr($modSettings['avatar_url'], array('http://' => 'https://'));
281
-		else
282
-			$newval = strtr($modSettings['avatar_url'], array('https://' => 'http://'));
287
+		if ($new_force_ssl == 2) {
288
+					$newval = strtr($modSettings['avatar_url'], array('http://' => 'https://'));
289
+		} else {
290
+					$newval = strtr($modSettings['avatar_url'], array('https://' => 'http://'));
291
+		}
283 292
 		$new_settings['avatar_url'] = $newval;
284 293
 	}
285 294
 
@@ -287,16 +296,18 @@  discard block
 block discarded – undo
287 296
 	// This one had been optional in the past, make sure it is set first
288 297
 	if (isset($modSettings['custom_avatar_url']) && BoardurlMatch($modSettings['custom_avatar_url']))
289 298
 	{
290
-		if ($new_force_ssl == 2)
291
-			$newval = strtr($modSettings['custom_avatar_url'], array('http://' => 'https://'));
292
-		else
293
-			$newval = strtr($modSettings['custom_avatar_url'], array('https://' => 'http://'));
299
+		if ($new_force_ssl == 2) {
300
+					$newval = strtr($modSettings['custom_avatar_url'], array('http://' => 'https://'));
301
+		} else {
302
+					$newval = strtr($modSettings['custom_avatar_url'], array('https://' => 'http://'));
303
+		}
294 304
 		$new_settings['custom_avatar_url'] = $newval;
295 305
 	}
296 306
 
297 307
 	// Save updates to the settings table
298
-	if (!empty($new_settings))
299
-		updateSettings($new_settings, true);
308
+	if (!empty($new_settings)) {
309
+			updateSettings($new_settings, true);
310
+	}
300 311
 
301 312
 	// Now we move onto the themes.
302 313
 	// First, get a list of theme URLs...
@@ -317,10 +328,11 @@  discard block
 block discarded – undo
317 328
 		// First check to see if it points to a subfolder of $boardurl
318 329
 		if (BoardurlMatch($row['value']))
319 330
 		{
320
-			if ($new_force_ssl == 2)
321
-				$newval = strtr($row['value'], array('http://' => 'https://'));
322
-			else
323
-				$newval = strtr($row['value'], array('https://' => 'http://'));
331
+			if ($new_force_ssl == 2) {
332
+							$newval = strtr($row['value'], array('http://' => 'https://'));
333
+			} else {
334
+							$newval = strtr($row['value'], array('https://' => 'http://'));
335
+			}
324 336
 			$smcFunc['db_query']('', '
325 337
 				UPDATE {db_prefix}themes
326 338
 				   SET value = {string:theme_val}
@@ -360,11 +372,12 @@  discard block
 block discarded – undo
360 372
 
361 373
 	// If leftmost portion of path matches boardurl, return true
362 374
 	$result = strpos($urlpath, $boardurlpath);
363
-	if ($result === false || $result != 0)
364
-		return false;
365
-	else
366
-		return true;
367
-}
375
+	if ($result === false || $result != 0) {
376
+			return false;
377
+	} else {
378
+			return true;
379
+	}
380
+	}
368 381
 
369 382
 /**
370 383
  * Basic database and paths settings - database name, host, etc.
@@ -402,8 +415,9 @@  discard block
 block discarded – undo
402 415
 		$request = $smcFunc['db_query']('', 'SELECT cfgname FROM pg_ts_config', array());
403 416
 		$fts_language = array();
404 417
 
405
-		while ($row = $smcFunc['db_fetch_assoc']($request))
406
-			$fts_language[$row['cfgname']] = $row['cfgname'];
418
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
419
+					$fts_language[$row['cfgname']] = $row['cfgname'];
420
+		}
407 421
 
408 422
 		$config_vars = array_merge ($config_vars, array(
409 423
 				'',
@@ -415,8 +429,9 @@  discard block
 block discarded – undo
415 429
 
416 430
 	call_integration_hook('integrate_database_settings', array(&$config_vars));
417 431
 
418
-	if ($return_config)
419
-		return $config_vars;
432
+	if ($return_config) {
433
+			return $config_vars;
434
+	}
420 435
 
421 436
 	// Setup the template stuff.
422 437
 	$context['post_url'] = $scripturl . '?action=admin;area=serversettings;sa=database;save';
@@ -491,13 +506,15 @@  discard block
 block discarded – undo
491 506
 		hideGlobalCookies();
492 507
 	});', true);
493 508
 
494
-	if (empty($user_settings['tfa_secret']))
495
-		addInlineJavaScript('');
509
+	if (empty($user_settings['tfa_secret'])) {
510
+			addInlineJavaScript('');
511
+	}
496 512
 
497 513
 	call_integration_hook('integrate_cookie_settings', array(&$config_vars));
498 514
 
499
-	if ($return_config)
500
-		return $config_vars;
515
+	if ($return_config) {
516
+			return $config_vars;
517
+	}
501 518
 
502 519
 	$context['post_url'] = $scripturl . '?action=admin;area=serversettings;sa=cookie;save';
503 520
 	$context['settings_title'] = $txt['cookies_sessions_settings'];
@@ -508,11 +525,13 @@  discard block
 block discarded – undo
508 525
 		call_integration_hook('integrate_save_cookie_settings');
509 526
 
510 527
 		// Local and global do not play nicely together.
511
-		if (!empty($_POST['localCookies']) && empty($_POST['globalCookies']))
512
-			unset ($_POST['globalCookies']);
528
+		if (!empty($_POST['localCookies']) && empty($_POST['globalCookies'])) {
529
+					unset ($_POST['globalCookies']);
530
+		}
513 531
 
514
-		if (!empty($_POST['globalCookiesDomain']) && strpos($boardurl, $_POST['globalCookiesDomain']) === false)
515
-			fatal_lang_error('invalid_cookie_domain', false);
532
+		if (!empty($_POST['globalCookiesDomain']) && strpos($boardurl, $_POST['globalCookiesDomain']) === false) {
533
+					fatal_lang_error('invalid_cookie_domain', false);
534
+		}
516 535
 
517 536
 		saveSettings($config_vars);
518 537
 
@@ -595,8 +614,9 @@  discard block
 block discarded – undo
595 614
 
596 615
 	call_integration_hook('integrate_general_security_settings', array(&$config_vars));
597 616
 
598
-	if ($return_config)
599
-		return $config_vars;
617
+	if ($return_config) {
618
+			return $config_vars;
619
+	}
600 620
 
601 621
 	// Saving?
602 622
 	if (isset($_GET['save']))
@@ -635,8 +655,7 @@  discard block
 block discarded – undo
635 655
 		$txt['cache_settings_message'] = $txt['detected_no_caching'];
636 656
 		$cache_level = array($txt['cache_off']);
637 657
 		$detected['none'] = $txt['cache_off'];
638
-	}
639
-	else
658
+	} else
640 659
 	{
641 660
 		$txt['cache_settings_message'] = sprintf($txt['detected_accelerators'], implode(', ', $detected));
642 661
 		$cache_level = array($txt['cache_off'], $txt['cache_level1'], $txt['cache_level2'], $txt['cache_level3']);
@@ -673,8 +692,9 @@  discard block
 block discarded – undo
673 692
 			}
674 693
 		}
675 694
 	}
676
-	if ($return_config)
677
-		return $config_vars;
695
+	if ($return_config) {
696
+			return $config_vars;
697
+	}
678 698
 
679 699
 	// Saving again?
680 700
 	if (isset($_GET['save']))
@@ -702,8 +722,9 @@  discard block
 block discarded – undo
702 722
 	$context['save_disabled'] = $context['settings_not_writable'];
703 723
 
704 724
 	// Decide what message to show.
705
-	if (!$context['save_disabled'])
706
-		$context['settings_message'] = $txt['caching_information'];
725
+	if (!$context['save_disabled']) {
726
+			$context['settings_message'] = $txt['caching_information'];
727
+	}
707 728
 
708 729
 	// Prepare the template.
709 730
 	prepareServerSettingsContext($config_vars);
@@ -726,24 +747,25 @@  discard block
 block discarded – undo
726 747
 	if (stripos(PHP_OS, 'win') === 0)
727 748
 	{
728 749
 		$context['settings_message'] = $txt['loadavg_disabled_windows'];
729
-		if (isset($_GET['save']))
730
-			$_SESSION['adm-save'] = $txt['loadavg_disabled_windows'];
731
-	}
732
-	elseif (stripos(PHP_OS, 'darwin') === 0)
750
+		if (isset($_GET['save'])) {
751
+					$_SESSION['adm-save'] = $txt['loadavg_disabled_windows'];
752
+		}
753
+	} elseif (stripos(PHP_OS, 'darwin') === 0)
733 754
 	{
734 755
 		$context['settings_message'] = $txt['loadavg_disabled_osx'];
735
-		if (isset($_GET['save']))
736
-			$_SESSION['adm-save'] = $txt['loadavg_disabled_osx'];
737
-	}
738
-	else
756
+		if (isset($_GET['save'])) {
757
+					$_SESSION['adm-save'] = $txt['loadavg_disabled_osx'];
758
+		}
759
+	} else
739 760
 	{
740 761
 		$modSettings['load_average'] = @file_get_contents('/proc/loadavg');
741
-		if (!empty($modSettings['load_average']) && preg_match('~^([^ ]+?) ([^ ]+?) ([^ ]+)~', $modSettings['load_average'], $matches) !== 0)
742
-			$modSettings['load_average'] = (float) $matches[1];
743
-		elseif (($modSettings['load_average'] = @`uptime`) !== null && preg_match('~load averages?: (\d+\.\d+), (\d+\.\d+), (\d+\.\d+)~i', $modSettings['load_average'], $matches) !== 0)
744
-			$modSettings['load_average'] = (float) $matches[1];
745
-		else
746
-			unset($modSettings['load_average']);
762
+		if (!empty($modSettings['load_average']) && preg_match('~^([^ ]+?) ([^ ]+?) ([^ ]+)~', $modSettings['load_average'], $matches) !== 0) {
763
+					$modSettings['load_average'] = (float) $matches[1];
764
+		} elseif (($modSettings['load_average'] = @`uptime`) !== null && preg_match('~load averages?: (\d+\.\d+), (\d+\.\d+), (\d+\.\d+)~i', $modSettings['load_average'], $matches) !== 0) {
765
+					$modSettings['load_average'] = (float) $matches[1];
766
+		} else {
767
+					unset($modSettings['load_average']);
768
+		}
747 769
 
748 770
 		if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0)
749 771
 		{
@@ -779,8 +801,9 @@  discard block
 block discarded – undo
779 801
 
780 802
 	call_integration_hook('integrate_loadavg_settings', array(&$config_vars));
781 803
 
782
-	if ($return_config)
783
-		return $config_vars;
804
+	if ($return_config) {
805
+			return $config_vars;
806
+	}
784 807
 
785 808
 	$context['post_url'] = $scripturl . '?action=admin;area=serversettings;sa=loads;save';
786 809
 	$context['settings_title'] = $txt['load_balancing_settings'];
@@ -791,24 +814,27 @@  discard block
 block discarded – undo
791 814
 		// Stupidity is not allowed.
792 815
 		foreach ($_POST as $key => $value)
793 816
 		{
794
-			if (strpos($key, 'loadavg') === 0 || $key === 'loadavg_enable' || !in_array($key, array_keys($default_values)))
795
-				continue;
796
-			else
797
-				$_POST[$key] = (float) $value;
798
-
799
-			if ($key == 'loadavg_auto_opt' && $value <= 1)
800
-				$_POST['loadavg_auto_opt'] = 1.0;
801
-			elseif ($key == 'loadavg_forum' && $value < 10)
802
-				$_POST['loadavg_forum'] = 10.0;
803
-			elseif ($value < 2)
804
-				$_POST[$key] = 2.0;
817
+			if (strpos($key, 'loadavg') === 0 || $key === 'loadavg_enable' || !in_array($key, array_keys($default_values))) {
818
+							continue;
819
+			} else {
820
+							$_POST[$key] = (float) $value;
821
+			}
822
+
823
+			if ($key == 'loadavg_auto_opt' && $value <= 1) {
824
+							$_POST['loadavg_auto_opt'] = 1.0;
825
+			} elseif ($key == 'loadavg_forum' && $value < 10) {
826
+							$_POST['loadavg_forum'] = 10.0;
827
+			} elseif ($value < 2) {
828
+							$_POST[$key] = 2.0;
829
+			}
805 830
 		}
806 831
 
807 832
 		call_integration_hook('integrate_save_loadavg_settings');
808 833
 
809 834
 		saveDBSettings($config_vars);
810
-		if (!isset($_SESSION['adm-save']))
811
-			$_SESSION['adm-save'] = true;
835
+		if (!isset($_SESSION['adm-save'])) {
836
+					$_SESSION['adm-save'] = true;
837
+		}
812 838
 		redirectexit('action=admin;area=serversettings;sa=loads;' . $context['session_var'] . '=' . $context['session_id']);
813 839
 	}
814 840
 
@@ -844,10 +870,11 @@  discard block
 block discarded – undo
844 870
 
845 871
 	if (isset($_SESSION['adm-save']))
846 872
 	{
847
-		if ($_SESSION['adm-save'] === true)
848
-			$context['saved_successful'] = true;
849
-		else
850
-			$context['saved_failed'] = $_SESSION['adm-save'];
873
+		if ($_SESSION['adm-save'] === true) {
874
+					$context['saved_successful'] = true;
875
+		} else {
876
+					$context['saved_failed'] = $_SESSION['adm-save'];
877
+		}
851 878
 
852 879
 		unset($_SESSION['adm-save']);
853 880
 	}
@@ -855,9 +882,9 @@  discard block
 block discarded – undo
855 882
 	$context['config_vars'] = array();
856 883
 	foreach ($config_vars as $identifier => $config_var)
857 884
 	{
858
-		if (!is_array($config_var) || !isset($config_var[1]))
859
-			$context['config_vars'][] = $config_var;
860
-		else
885
+		if (!is_array($config_var) || !isset($config_var[1])) {
886
+					$context['config_vars'][] = $config_var;
887
+		} else
861 888
 		{
862 889
 			$varname = $config_var[0];
863 890
 			global $$varname;
@@ -892,16 +919,19 @@  discard block
 block discarded – undo
892 919
 			if ($config_var[3] == 'int' || $config_var[3] == 'float')
893 920
 			{
894 921
 				// Default to a min of 0 if one isn't set
895
-				if (isset($config_var['min']))
896
-					$context['config_vars'][$config_var[0]]['min'] = $config_var['min'];
897
-				else
898
-					$context['config_vars'][$config_var[0]]['min'] = 0;
922
+				if (isset($config_var['min'])) {
923
+									$context['config_vars'][$config_var[0]]['min'] = $config_var['min'];
924
+				} else {
925
+									$context['config_vars'][$config_var[0]]['min'] = 0;
926
+				}
899 927
 
900
-				if (isset($config_var['max']))
901
-					$context['config_vars'][$config_var[0]]['max'] = $config_var['max'];
928
+				if (isset($config_var['max'])) {
929
+									$context['config_vars'][$config_var[0]]['max'] = $config_var['max'];
930
+				}
902 931
 
903
-				if (isset($config_var['step']))
904
-					$context['config_vars'][$config_var[0]]['step'] = $config_var['step'];
932
+				if (isset($config_var['step'])) {
933
+									$context['config_vars'][$config_var[0]]['step'] = $config_var['step'];
934
+				}
905 935
 			}
906 936
 
907 937
 			// If this is a select box handle any data.
@@ -909,12 +939,13 @@  discard block
 block discarded – undo
909 939
 			{
910 940
 				// If it's associative
911 941
 				$config_values = array_values($config_var[4]);
912
-				if (isset($config_values[0]) && is_array($config_values[0]))
913
-					$context['config_vars'][$config_var[0]]['data'] = $config_var[4];
914
-				else
942
+				if (isset($config_values[0]) && is_array($config_values[0])) {
943
+									$context['config_vars'][$config_var[0]]['data'] = $config_var[4];
944
+				} else
915 945
 				{
916
-					foreach ($config_var[4] as $key => $item)
917
-						$context['config_vars'][$config_var[0]]['data'][] = array($key, $item);
946
+					foreach ($config_var[4] as $key => $item) {
947
+											$context['config_vars'][$config_var[0]]['data'][] = array($key, $item);
948
+					}
918 949
 				}
919 950
 			}
920 951
 		}
@@ -939,10 +970,11 @@  discard block
 block discarded – undo
939 970
 
940 971
 	if (isset($_SESSION['adm-save']))
941 972
 	{
942
-		if ($_SESSION['adm-save'] === true)
943
-			$context['saved_successful'] = true;
944
-		else
945
-			$context['saved_failed'] = $_SESSION['adm-save'];
973
+		if ($_SESSION['adm-save'] === true) {
974
+					$context['saved_successful'] = true;
975
+		} else {
976
+					$context['saved_failed'] = $_SESSION['adm-save'];
977
+		}
946 978
 
947 979
 		unset($_SESSION['adm-save']);
948 980
 	}
@@ -954,26 +986,30 @@  discard block
 block discarded – undo
954 986
 	foreach ($config_vars as $config_var)
955 987
 	{
956 988
 		// HR?
957
-		if (!is_array($config_var))
958
-			$context['config_vars'][] = $config_var;
959
-		else
989
+		if (!is_array($config_var)) {
990
+					$context['config_vars'][] = $config_var;
991
+		} else
960 992
 		{
961 993
 			// If it has no name it doesn't have any purpose!
962
-			if (empty($config_var[1]))
963
-				continue;
994
+			if (empty($config_var[1])) {
995
+							continue;
996
+			}
964 997
 
965 998
 			// Special case for inline permissions
966
-			if ($config_var[0] == 'permissions' && allowedTo('manage_permissions'))
967
-				$inlinePermissions[] = $config_var[1];
968
-			elseif ($config_var[0] == 'permissions')
969
-				continue;
999
+			if ($config_var[0] == 'permissions' && allowedTo('manage_permissions')) {
1000
+							$inlinePermissions[] = $config_var[1];
1001
+			} elseif ($config_var[0] == 'permissions') {
1002
+							continue;
1003
+			}
970 1004
 
971
-			if ($config_var[0] == 'boards')
972
-				$board_list = true;
1005
+			if ($config_var[0] == 'boards') {
1006
+							$board_list = true;
1007
+			}
973 1008
 
974 1009
 			// Are we showing the BBC selection box?
975
-			if ($config_var[0] == 'bbc')
976
-				$bbcChoice[] = $config_var[1];
1010
+			if ($config_var[0] == 'bbc') {
1011
+							$bbcChoice[] = $config_var[1];
1012
+			}
977 1013
 
978 1014
 			// We need to do some parsing of the value before we pass it in.
979 1015
 			if (isset($modSettings[$config_var[1]]))
@@ -992,8 +1028,7 @@  discard block
 block discarded – undo
992 1028
 					default:
993 1029
 						$value = $smcFunc['htmlspecialchars']($modSettings[$config_var[1]]);
994 1030
 				}
995
-			}
996
-			else
1031
+			} else
997 1032
 			{
998 1033
 				// Darn, it's empty. What type is expected?
999 1034
 				switch ($config_var[0])
@@ -1033,16 +1068,19 @@  discard block
 block discarded – undo
1033 1068
 			if ($config_var[0] == 'int' || $config_var[0] == 'float')
1034 1069
 			{
1035 1070
 				// Default to a min of 0 if one isn't set
1036
-				if (isset($config_var['min']))
1037
-					$context['config_vars'][$config_var[1]]['min'] = $config_var['min'];
1038
-				else
1039
-					$context['config_vars'][$config_var[1]]['min'] = 0;
1071
+				if (isset($config_var['min'])) {
1072
+									$context['config_vars'][$config_var[1]]['min'] = $config_var['min'];
1073
+				} else {
1074
+									$context['config_vars'][$config_var[1]]['min'] = 0;
1075
+				}
1040 1076
 
1041
-				if (isset($config_var['max']))
1042
-					$context['config_vars'][$config_var[1]]['max'] = $config_var['max'];
1077
+				if (isset($config_var['max'])) {
1078
+									$context['config_vars'][$config_var[1]]['max'] = $config_var['max'];
1079
+				}
1043 1080
 
1044
-				if (isset($config_var['step']))
1045
-					$context['config_vars'][$config_var[1]]['step'] = $config_var['step'];
1081
+				if (isset($config_var['step'])) {
1082
+									$context['config_vars'][$config_var[1]]['step'] = $config_var['step'];
1083
+				}
1046 1084
 			}
1047 1085
 
1048 1086
 			// If this is a select box handle any data.
@@ -1056,12 +1094,13 @@  discard block
 block discarded – undo
1056 1094
 				}
1057 1095
 
1058 1096
 				// If it's associative
1059
-				if (isset($config_var[2][0]) && is_array($config_var[2][0]))
1060
-					$context['config_vars'][$config_var[1]]['data'] = $config_var[2];
1061
-				else
1097
+				if (isset($config_var[2][0]) && is_array($config_var[2][0])) {
1098
+									$context['config_vars'][$config_var[1]]['data'] = $config_var[2];
1099
+				} else
1062 1100
 				{
1063
-					foreach ($config_var[2] as $key => $item)
1064
-						$context['config_vars'][$config_var[1]]['data'][] = array($key, $item);
1101
+					foreach ($config_var[2] as $key => $item) {
1102
+											$context['config_vars'][$config_var[1]]['data'][] = array($key, $item);
1103
+					}
1065 1104
 				}
1066 1105
 			}
1067 1106
 
@@ -1070,17 +1109,19 @@  discard block
 block discarded – undo
1070 1109
 			{
1071 1110
 				if (!is_numeric($k))
1072 1111
 				{
1073
-					if (substr($k, 0, 2) == 'on')
1074
-						$context['config_vars'][$config_var[1]]['javascript'] .= ' ' . $k . '="' . $v . '"';
1075
-					else
1076
-						$context['config_vars'][$config_var[1]][$k] = $v;
1112
+					if (substr($k, 0, 2) == 'on') {
1113
+											$context['config_vars'][$config_var[1]]['javascript'] .= ' ' . $k . '="' . $v . '"';
1114
+					} else {
1115
+											$context['config_vars'][$config_var[1]][$k] = $v;
1116
+					}
1077 1117
 				}
1078 1118
 
1079 1119
 				// See if there are any other labels that might fit?
1080
-				if (isset($txt['setting_' . $config_var[1]]))
1081
-					$context['config_vars'][$config_var[1]]['label'] = $txt['setting_' . $config_var[1]];
1082
-				elseif (isset($txt['groups_' . $config_var[1]]))
1083
-					$context['config_vars'][$config_var[1]]['label'] = $txt['groups_' . $config_var[1]];
1120
+				if (isset($txt['setting_' . $config_var[1]])) {
1121
+									$context['config_vars'][$config_var[1]]['label'] = $txt['setting_' . $config_var[1]];
1122
+				} elseif (isset($txt['groups_' . $config_var[1]])) {
1123
+									$context['config_vars'][$config_var[1]]['label'] = $txt['groups_' . $config_var[1]];
1124
+				}
1084 1125
 			}
1085 1126
 
1086 1127
 			// Set the subtext in case it's part of the label.
@@ -1113,8 +1154,9 @@  discard block
 block discarded – undo
1113 1154
 		// What are the options, eh?
1114 1155
 		$temp = parse_bbc(false);
1115 1156
 		$bbcTags = array();
1116
-		foreach ($temp as $tag)
1117
-			$bbcTags[] = $tag['tag'];
1157
+		foreach ($temp as $tag) {
1158
+					$bbcTags[] = $tag['tag'];
1159
+		}
1118 1160
 
1119 1161
 		$bbcTags = array_unique($bbcTags);
1120 1162
 		$totalTags = count($bbcTags);
@@ -1129,8 +1171,9 @@  discard block
 block discarded – undo
1129 1171
 		$col = 0; $i = 0;
1130 1172
 		foreach ($bbcTags as $tag)
1131 1173
 		{
1132
-			if ($i % $tagsPerColumn == 0 && $i != 0)
1133
-				$col++;
1174
+			if ($i % $tagsPerColumn == 0 && $i != 0) {
1175
+							$col++;
1176
+			}
1134 1177
 
1135 1178
 			$context['bbc_columns'][$col][] = array(
1136 1179
 				'tag' => $tag,
@@ -1173,18 +1216,21 @@  discard block
 block discarded – undo
1173 1216
 	validateToken('admin-ssc');
1174 1217
 
1175 1218
 	// Fix the darn stupid cookiename! (more may not be allowed, but these for sure!)
1176
-	if (isset($_POST['cookiename']))
1177
-		$_POST['cookiename'] = preg_replace('~[,;\s\.$]+~' . ($context['utf8'] ? 'u' : ''), '', $_POST['cookiename']);
1219
+	if (isset($_POST['cookiename'])) {
1220
+			$_POST['cookiename'] = preg_replace('~[,;\s\.$]+~' . ($context['utf8'] ? 'u' : ''), '', $_POST['cookiename']);
1221
+	}
1178 1222
 
1179 1223
 	// Fix the forum's URL if necessary.
1180 1224
 	if (isset($_POST['boardurl']))
1181 1225
 	{
1182
-		if (substr($_POST['boardurl'], -10) == '/index.php')
1183
-			$_POST['boardurl'] = substr($_POST['boardurl'], 0, -10);
1184
-		elseif (substr($_POST['boardurl'], -1) == '/')
1185
-			$_POST['boardurl'] = substr($_POST['boardurl'], 0, -1);
1186
-		if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://')
1187
-			$_POST['boardurl'] = 'http://' . $_POST['boardurl'];
1226
+		if (substr($_POST['boardurl'], -10) == '/index.php') {
1227
+					$_POST['boardurl'] = substr($_POST['boardurl'], 0, -10);
1228
+		} elseif (substr($_POST['boardurl'], -1) == '/') {
1229
+					$_POST['boardurl'] = substr($_POST['boardurl'], 0, -1);
1230
+		}
1231
+		if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://') {
1232
+					$_POST['boardurl'] = 'http://' . $_POST['boardurl'];
1233
+		}
1188 1234
 	}
1189 1235
 
1190 1236
 	// Any passwords?
@@ -1219,21 +1265,21 @@  discard block
 block discarded – undo
1219 1265
 	// Figure out which config vars we're saving here...
1220 1266
 	foreach ($config_vars as $var)
1221 1267
 	{
1222
-		if (!is_array($var) || $var[2] != 'file' || (!in_array($var[0], $config_bools) && !isset($_POST[$var[0]])))
1223
-			continue;
1268
+		if (!is_array($var) || $var[2] != 'file' || (!in_array($var[0], $config_bools) && !isset($_POST[$var[0]]))) {
1269
+					continue;
1270
+		}
1224 1271
 
1225 1272
 		$config_var = $var[0];
1226 1273
 
1227 1274
 		if (in_array($config_var, $config_passwords))
1228 1275
 		{
1229
-			if (isset($_POST[$config_var][1]) && $_POST[$config_var][0] == $_POST[$config_var][1])
1230
-				$new_settings[$config_var] = '\'' . addcslashes($_POST[$config_var][0], '\'\\') . '\'';
1231
-		}
1232
-		elseif (in_array($config_var, $config_strs))
1276
+			if (isset($_POST[$config_var][1]) && $_POST[$config_var][0] == $_POST[$config_var][1]) {
1277
+							$new_settings[$config_var] = '\'' . addcslashes($_POST[$config_var][0], '\'\\') . '\'';
1278
+			}
1279
+		} elseif (in_array($config_var, $config_strs))
1233 1280
 		{
1234 1281
 			$new_settings[$config_var] = '\'' . addcslashes($_POST[$config_var], '\'\\') . '\'';
1235
-		}
1236
-		elseif (in_array($config_var, $config_ints))
1282
+		} elseif (in_array($config_var, $config_ints))
1237 1283
 		{
1238 1284
 			$new_settings[$config_var] = (int) $_POST[$config_var];
1239 1285
 
@@ -1242,17 +1288,17 @@  discard block
 block discarded – undo
1242 1288
 			$new_settings[$config_var] = max($min, $new_settings[$config_var]);
1243 1289
 
1244 1290
 			// Is there a max value for this as well?
1245
-			if (isset($var['max']))
1246
-				$new_settings[$config_var] = min($var['max'], $new_settings[$config_var]);
1247
-		}
1248
-		elseif (in_array($config_var, $config_bools))
1291
+			if (isset($var['max'])) {
1292
+							$new_settings[$config_var] = min($var['max'], $new_settings[$config_var]);
1293
+			}
1294
+		} elseif (in_array($config_var, $config_bools))
1249 1295
 		{
1250
-			if (!empty($_POST[$config_var]))
1251
-				$new_settings[$config_var] = '1';
1252
-			else
1253
-				$new_settings[$config_var] = '0';
1254
-		}
1255
-		else
1296
+			if (!empty($_POST[$config_var])) {
1297
+							$new_settings[$config_var] = '1';
1298
+			} else {
1299
+							$new_settings[$config_var] = '0';
1300
+			}
1301
+		} else
1256 1302
 		{
1257 1303
 			// This shouldn't happen, but it might...
1258 1304
 			fatal_error('Unknown config_var \'' . $config_var . '\'');
@@ -1268,30 +1314,35 @@  discard block
 block discarded – undo
1268 1314
 	foreach ($config_vars as $config_var)
1269 1315
 	{
1270 1316
 		// We just saved the file-based settings, so skip their definitions.
1271
-		if (!is_array($config_var) || $config_var[2] == 'file')
1272
-			continue;
1317
+		if (!is_array($config_var) || $config_var[2] == 'file') {
1318
+					continue;
1319
+		}
1273 1320
 
1274 1321
 		$new_setting = array($config_var[3], $config_var[0]);
1275 1322
 
1276 1323
 		// Select options need carried over, too.
1277
-		if (isset($config_var[4]))
1278
-			$new_setting[] = $config_var[4];
1324
+		if (isset($config_var[4])) {
1325
+					$new_setting[] = $config_var[4];
1326
+		}
1279 1327
 
1280 1328
 		// Include min and max if necessary
1281
-		if (isset($config_var['min']))
1282
-			$new_setting['min'] = $config_var['min'];
1329
+		if (isset($config_var['min'])) {
1330
+					$new_setting['min'] = $config_var['min'];
1331
+		}
1283 1332
 
1284
-		if (isset($config_var['max']))
1285
-			$new_setting['max'] = $config_var['max'];
1333
+		if (isset($config_var['max'])) {
1334
+					$new_setting['max'] = $config_var['max'];
1335
+		}
1286 1336
 
1287 1337
 		// Rewrite the definition a bit.
1288 1338
 		$new_settings[] = $new_setting;
1289 1339
 	}
1290 1340
 
1291 1341
 	// Save the new database-based settings, if any.
1292
-	if (!empty($new_settings))
1293
-		saveDBSettings($new_settings);
1294
-}
1342
+	if (!empty($new_settings)) {
1343
+			saveDBSettings($new_settings);
1344
+	}
1345
+	}
1295 1346
 
1296 1347
 /**
1297 1348
  * Helper function for saving database settings.
@@ -1309,22 +1360,25 @@  discard block
 block discarded – undo
1309 1360
 	$inlinePermissions = array();
1310 1361
 	foreach ($config_vars as $var)
1311 1362
 	{
1312
-		if (!isset($var[1]) || (!isset($_POST[$var[1]]) && $var[0] != 'check' && $var[0] != 'permissions' && $var[0] != 'boards' && ($var[0] != 'bbc' || !isset($_POST[$var[1] . '_enabledTags']))))
1313
-			continue;
1363
+		if (!isset($var[1]) || (!isset($_POST[$var[1]]) && $var[0] != 'check' && $var[0] != 'permissions' && $var[0] != 'boards' && ($var[0] != 'bbc' || !isset($_POST[$var[1] . '_enabledTags'])))) {
1364
+					continue;
1365
+		}
1314 1366
 
1315 1367
 		// Checkboxes!
1316
-		elseif ($var[0] == 'check')
1317
-			$setArray[$var[1]] = !empty($_POST[$var[1]]) ? '1' : '0';
1368
+		elseif ($var[0] == 'check') {
1369
+					$setArray[$var[1]] = !empty($_POST[$var[1]]) ? '1' : '0';
1370
+		}
1318 1371
 		// Select boxes!
1319
-		elseif ($var[0] == 'select' && in_array($_POST[$var[1]], array_keys($var[2])))
1320
-			$setArray[$var[1]] = $_POST[$var[1]];
1321
-		elseif ($var[0] == 'select' && !empty($var['multiple']) && array_intersect($_POST[$var[1]], array_keys($var[2])) != array())
1372
+		elseif ($var[0] == 'select' && in_array($_POST[$var[1]], array_keys($var[2]))) {
1373
+					$setArray[$var[1]] = $_POST[$var[1]];
1374
+		} elseif ($var[0] == 'select' && !empty($var['multiple']) && array_intersect($_POST[$var[1]], array_keys($var[2])) != array())
1322 1375
 		{
1323 1376
 			// For security purposes we validate this line by line.
1324 1377
 			$lOptions = array();
1325
-			foreach ($_POST[$var[1]] as $invar)
1326
-				if (in_array($invar, array_keys($var[2])))
1378
+			foreach ($_POST[$var[1]] as $invar) {
1379
+							if (in_array($invar, array_keys($var[2])))
1327 1380
 					$lOptions[] = $invar;
1381
+			}
1328 1382
 
1329 1383
 			$setArray[$var[1]] = $smcFunc['json_encode']($lOptions);
1330 1384
 		}
@@ -1338,18 +1392,20 @@  discard block
 block discarded – undo
1338 1392
 				$request = $smcFunc['db_query']('', '
1339 1393
 					SELECT id_board
1340 1394
 					FROM {db_prefix}boards');
1341
-				while ($row = $smcFunc['db_fetch_row']($request))
1342
-					$board_list[$row[0]] = true;
1395
+				while ($row = $smcFunc['db_fetch_row']($request)) {
1396
+									$board_list[$row[0]] = true;
1397
+				}
1343 1398
 
1344 1399
 				$smcFunc['db_free_result']($request);
1345 1400
 			}
1346 1401
 
1347 1402
 			$lOptions = array();
1348 1403
 
1349
-			if (!empty($_POST[$var[1]]))
1350
-				foreach ($_POST[$var[1]] as $invar => $dummy)
1404
+			if (!empty($_POST[$var[1]])) {
1405
+							foreach ($_POST[$var[1]] as $invar => $dummy)
1351 1406
 					if (isset($board_list[$invar]))
1352 1407
 						$lOptions[] = $invar;
1408
+			}
1353 1409
 
1354 1410
 			$setArray[$var[1]] = !empty($lOptions) ? implode(',', $lOptions) : '';
1355 1411
 		}
@@ -1363,8 +1419,9 @@  discard block
 block discarded – undo
1363 1419
 			$setArray[$var[1]] = max($min, $setArray[$var[1]]);
1364 1420
 
1365 1421
 			// Do we have a max value for this as well?
1366
-			if (isset($var['max']))
1367
-				$setArray[$var[1]] = min($var['max'], $setArray[$var[1]]);
1422
+			if (isset($var['max'])) {
1423
+							$setArray[$var[1]] = min($var['max'], $setArray[$var[1]]);
1424
+			}
1368 1425
 		}
1369 1426
 		// Floating point!
1370 1427
 		elseif ($var[0] == 'float')
@@ -1376,40 +1433,47 @@  discard block
 block discarded – undo
1376 1433
 			$setArray[$var[1]] = max($min, $setArray[$var[1]]);
1377 1434
 
1378 1435
 			// Do we have a max value for this as well?
1379
-			if (isset($var['max']))
1380
-				$setArray[$var[1]] = min($var['max'], $setArray[$var[1]]);
1436
+			if (isset($var['max'])) {
1437
+							$setArray[$var[1]] = min($var['max'], $setArray[$var[1]]);
1438
+			}
1381 1439
 		}
1382 1440
 		// Text!
1383
-		elseif (in_array($var[0], array('text', 'large_text', 'color', 'date', 'datetime', 'datetime-local', 'email', 'month', 'time')))
1384
-			$setArray[$var[1]] = $_POST[$var[1]];
1441
+		elseif (in_array($var[0], array('text', 'large_text', 'color', 'date', 'datetime', 'datetime-local', 'email', 'month', 'time'))) {
1442
+					$setArray[$var[1]] = $_POST[$var[1]];
1443
+		}
1385 1444
 		// Passwords!
1386 1445
 		elseif ($var[0] == 'password')
1387 1446
 		{
1388
-			if (isset($_POST[$var[1]][1]) && $_POST[$var[1]][0] == $_POST[$var[1]][1])
1389
-				$setArray[$var[1]] = $_POST[$var[1]][0];
1447
+			if (isset($_POST[$var[1]][1]) && $_POST[$var[1]][0] == $_POST[$var[1]][1]) {
1448
+							$setArray[$var[1]] = $_POST[$var[1]][0];
1449
+			}
1390 1450
 		}
1391 1451
 		// BBC.
1392 1452
 		elseif ($var[0] == 'bbc')
1393 1453
 		{
1394 1454
 
1395 1455
 			$bbcTags = array();
1396
-			foreach (parse_bbc(false) as $tag)
1397
-				$bbcTags[] = $tag['tag'];
1456
+			foreach (parse_bbc(false) as $tag) {
1457
+							$bbcTags[] = $tag['tag'];
1458
+			}
1398 1459
 
1399
-			if (!isset($_POST[$var[1] . '_enabledTags']))
1400
-				$_POST[$var[1] . '_enabledTags'] = array();
1401
-			elseif (!is_array($_POST[$var[1] . '_enabledTags']))
1402
-				$_POST[$var[1] . '_enabledTags'] = array($_POST[$var[1] . '_enabledTags']);
1460
+			if (!isset($_POST[$var[1] . '_enabledTags'])) {
1461
+							$_POST[$var[1] . '_enabledTags'] = array();
1462
+			} elseif (!is_array($_POST[$var[1] . '_enabledTags'])) {
1463
+							$_POST[$var[1] . '_enabledTags'] = array($_POST[$var[1] . '_enabledTags']);
1464
+			}
1403 1465
 
1404 1466
 			$setArray[$var[1]] = implode(',', array_diff($bbcTags, $_POST[$var[1] . '_enabledTags']));
1405 1467
 		}
1406 1468
 		// Permissions?
1407
-		elseif ($var[0] == 'permissions')
1408
-			$inlinePermissions[] = $var[1];
1469
+		elseif ($var[0] == 'permissions') {
1470
+					$inlinePermissions[] = $var[1];
1471
+		}
1409 1472
 	}
1410 1473
 
1411
-	if (!empty($setArray))
1412
-		updateSettings($setArray);
1474
+	if (!empty($setArray)) {
1475
+			updateSettings($setArray);
1476
+	}
1413 1477
 
1414 1478
 	// If we have inline permissions we need to save them.
1415 1479
 	if (!empty($inlinePermissions) && allowedTo('manage_permissions'))
@@ -1446,18 +1510,21 @@  discard block
 block discarded – undo
1446 1510
 	// put all of it into an array
1447 1511
 	foreach ($info_lines as $line)
1448 1512
 	{
1449
-		if (preg_match('~(' . $remove . ')~', $line))
1450
-			continue;
1513
+		if (preg_match('~(' . $remove . ')~', $line)) {
1514
+					continue;
1515
+		}
1451 1516
 
1452 1517
 		// new category?
1453
-		if (strpos($line, '<h2>') !== false)
1454
-			$category = preg_match('~<h2>(.*)</h2>~', $line, $title) ? $category = $title[1] : $category;
1518
+		if (strpos($line, '<h2>') !== false) {
1519
+					$category = preg_match('~<h2>(.*)</h2>~', $line, $title) ? $category = $title[1] : $category;
1520
+		}
1455 1521
 
1456 1522
 		// load it as setting => value or the old setting local master
1457
-		if (preg_match('~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~', $line, $val))
1458
-			$pinfo[$category][$val[1]] = $val[2];
1459
-		elseif (preg_match('~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~', $line, $val))
1460
-			$pinfo[$category][$val[1]] = array($txt['phpinfo_localsettings'] => $val[2], $txt['phpinfo_defaultsettings'] => $val[3]);
1523
+		if (preg_match('~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~', $line, $val)) {
1524
+					$pinfo[$category][$val[1]] = $val[2];
1525
+		} elseif (preg_match('~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~', $line, $val)) {
1526
+					$pinfo[$category][$val[1]] = array($txt['phpinfo_localsettings'] => $val[2], $txt['phpinfo_defaultsettings'] => $val[3]);
1527
+		}
1461 1528
 	}
1462 1529
 
1463 1530
 	// load it in to context and display it
@@ -1492,8 +1559,9 @@  discard block
 block discarded – undo
1492 1559
 				$testAPI = new $cache_class_name();
1493 1560
 
1494 1561
 				// No Support?  NEXT!
1495
-				if (!$testAPI->isSupported(true))
1496
-					continue;
1562
+				if (!$testAPI->isSupported(true)) {
1563
+									continue;
1564
+				}
1497 1565
 
1498 1566
 				$apis[$tryCache] = isset($txt[$tryCache . '_cache']) ? $txt[$tryCache . '_cache'] : $tryCache;
1499 1567
 			}
@@ -1518,8 +1586,9 @@  discard block
 block discarded – undo
1518 1586
 	global $modSettings, $boardurl, $smcFunc;
1519 1587
 
1520 1588
 	// Already have a key?  Can't register again.
1521
-	if (!empty($modSettings['sm_stats_key']))
1522
-		return true;
1589
+	if (!empty($modSettings['sm_stats_key'])) {
1590
+			return true;
1591
+	}
1523 1592
 
1524 1593
 	$fp = @fsockopen('www.simplemachines.org', 80, $errno, $errstr);
1525 1594
 	if ($fp)
@@ -1530,8 +1599,9 @@  discard block
 block discarded – undo
1530 1599
 		fwrite($fp, $out);
1531 1600
 
1532 1601
 		$return_data = '';
1533
-		while (!feof($fp))
1534
-			$return_data .= fgets($fp, 128);
1602
+		while (!feof($fp)) {
1603
+					$return_data .= fgets($fp, 128);
1604
+		}
1535 1605
 
1536 1606
 		fclose($fp);
1537 1607
 
Please login to merge, or discard this patch.
Sources/DbSearch-postgresql.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -38,12 +38,12 @@  discard block
 block discarded – undo
38 38
 	$version = $smcFunc['db_get_version']();
39 39
 	// if we got a Beta Version
40 40
 	if (stripos($version, 'beta') !== false)
41
-		$version = substr($version, 0, stripos($version, 'beta')).'.0';
41
+		$version = substr($version, 0, stripos($version, 'beta')) . '.0';
42 42
 	// or RC
43 43
 	if (stripos($version, 'rc') !== false)
44
-		$version = substr($version, 0, stripos($version, 'rc')).'.0';
44
+		$version = substr($version, 0, stripos($version, 'rc')) . '.0';
45 45
 
46
-	if (version_compare($version,'9.5.0','>='))
46
+	if (version_compare($version, '9.5.0', '>='))
47 47
 		$smcFunc['db_support_ignore'] = true;
48 48
 }
49 49
 
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
  */
56 56
 function smf_db_search_support($search_type)
57 57
 {
58
-	$supported_types = array('custom','fulltext');
58
+	$supported_types = array('custom', 'fulltext');
59 59
 
60 60
 	return in_array($search_type, $supported_types);
61 61
 }
@@ -109,9 +109,9 @@  discard block
 block discarded – undo
109 109
 	if (preg_match('~^\s*INSERT\sIGNORE~i', $db_string) != 0)
110 110
 	{
111 111
 		$db_string = preg_replace('~^\s*INSERT\sIGNORE~i', 'INSERT', $db_string);
112
-		if ($smcFunc['db_support_ignore']){
112
+		if ($smcFunc['db_support_ignore']) {
113 113
 			//pg style "INSERT INTO.... ON CONFLICT DO NOTHING"
114
-			$db_string = $db_string.' ON CONFLICT DO NOTHING';
114
+			$db_string = $db_string . ' ON CONFLICT DO NOTHING';
115 115
 		}
116 116
 		else
117 117
 		{
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
 		$language_ftx = $modSettings['search_language'];
169 169
 	else
170 170
 	{
171
-		$request = $smcFunc['db_query']('','
171
+		$request = $smcFunc['db_query']('', '
172 172
 			SELECT cfgname FROM pg_ts_config WHERE oid = current_setting({string:default_language})::regconfig',
173 173
 			array(
174 174
 			'default_language' => 'default_text_search_config'
Please login to merge, or discard this patch.
Braces   +25 added lines, -19 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 4
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 /**
20 21
  *  Add the file functions to the $smcFunc array.
@@ -23,29 +24,33 @@  discard block
 block discarded – undo
23 24
 {
24 25
 	global $smcFunc;
25 26
 
26
-	if (!isset($smcFunc['db_search_query']) || $smcFunc['db_search_query'] != 'smf_db_search_query')
27
-		$smcFunc += array(
27
+	if (!isset($smcFunc['db_search_query']) || $smcFunc['db_search_query'] != 'smf_db_search_query') {
28
+			$smcFunc += array(
28 29
 			'db_search_query' => 'smf_db_search_query',
29 30
 			'db_search_support' => 'smf_db_search_support',
30 31
 			'db_create_word_search' => 'smf_db_create_word_search',
31 32
 			'db_support_ignore' => false,
32 33
 			'db_search_language' => 'smf_db_search_language',
33 34
 		);
35
+	}
34 36
 
35 37
 	db_extend();
36 38
 
37 39
 	//pg 9.5 got ignore support
38 40
 	$version = $smcFunc['db_get_version']();
39 41
 	// if we got a Beta Version
40
-	if (stripos($version, 'beta') !== false)
41
-		$version = substr($version, 0, stripos($version, 'beta')).'.0';
42
+	if (stripos($version, 'beta') !== false) {
43
+			$version = substr($version, 0, stripos($version, 'beta')).'.0';
44
+	}
42 45
 	// or RC
43
-	if (stripos($version, 'rc') !== false)
44
-		$version = substr($version, 0, stripos($version, 'rc')).'.0';
46
+	if (stripos($version, 'rc') !== false) {
47
+			$version = substr($version, 0, stripos($version, 'rc')).'.0';
48
+	}
45 49
 
46
-	if (version_compare($version,'9.5.0','>='))
47
-		$smcFunc['db_support_ignore'] = true;
48
-}
50
+	if (version_compare($version,'9.5.0','>=')) {
51
+			$smcFunc['db_support_ignore'] = true;
52
+	}
53
+	}
49 54
 
50 55
 /**
51 56
  * This function will tell you whether this database type supports this search type.
@@ -104,16 +109,16 @@  discard block
 block discarded – undo
104 109
 		),
105 110
 	);
106 111
 
107
-	if (isset($replacements[$identifier]))
108
-		$db_string = preg_replace(array_keys($replacements[$identifier]), array_values($replacements[$identifier]), $db_string);
112
+	if (isset($replacements[$identifier])) {
113
+			$db_string = preg_replace(array_keys($replacements[$identifier]), array_values($replacements[$identifier]), $db_string);
114
+	}
109 115
 	if (preg_match('~^\s*INSERT\sIGNORE~i', $db_string) != 0)
110 116
 	{
111 117
 		$db_string = preg_replace('~^\s*INSERT\sIGNORE~i', 'INSERT', $db_string);
112 118
 		if ($smcFunc['db_support_ignore']){
113 119
 			//pg style "INSERT INTO.... ON CONFLICT DO NOTHING"
114 120
 			$db_string = $db_string.' ON CONFLICT DO NOTHING';
115
-		}
116
-		else
121
+		} else
117 122
 		{
118 123
 			// Don't error on multi-insert.
119 124
 			$db_values['db_error_skip'] = true;
@@ -121,8 +126,9 @@  discard block
 block discarded – undo
121 126
 	}
122 127
 
123 128
 	//fix double quotes
124
-	if ($identifier == 'insert_into_log_messages_fulltext')
125
-		$db_values = str_replace('"', "'", $db_values);
129
+	if ($identifier == 'insert_into_log_messages_fulltext') {
130
+			$db_values = str_replace('"', "'", $db_values);
131
+	}
126 132
 
127 133
 	$return = $smcFunc['db_query']('', $db_string,
128 134
 		$db_values, $connection
@@ -164,9 +170,9 @@  discard block
 block discarded – undo
164 170
 
165 171
 	$language_ftx = 'english';
166 172
 
167
-	if (!empty($modSettings['search_language']))
168
-		$language_ftx = $modSettings['search_language'];
169
-	else
173
+	if (!empty($modSettings['search_language'])) {
174
+			$language_ftx = $modSettings['search_language'];
175
+	} else
170 176
 	{
171 177
 		$request = $smcFunc['db_query']('','
172 178
 			SELECT cfgname FROM pg_ts_config WHERE oid = current_setting({string:default_language})::regconfig',
Please login to merge, or discard this patch.