Completed
Pull Request — release-2.1 (#4156)
by 01
09:11
created
Sources/Subs-Menu.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -286,7 +286,7 @@
 block discarded – undo
286 286
 /**
287 287
  * Delete a menu.
288 288
  * @param string $menu_id The ID of the menu to destroy or 'last' for the most recent one
289
- * @return bool|void False if the menu doesn't exist, nothing otherwise
289
+ * @return false|null False if the menu doesn't exist, nothing otherwise
290 290
  */
291 291
 function destroyMenu($menu_id = 'last')
292 292
 {
Please login to merge, or discard this patch.
Braces   +87 added lines, -63 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
  * Create a menu.
@@ -64,22 +65,26 @@  discard block
 block discarded – undo
64 65
 	$menu_context['current_action'] = isset($menuOptions['action']) ? $menuOptions['action'] : $context['current_action'];
65 66
 
66 67
 	// Allow extend *any* menu with a single hook
67
-	if (!empty($menu_context['current_action']))
68
-		call_integration_hook('integrate_' . $menu_context['current_action'] . '_areas', array(&$menuData));
68
+	if (!empty($menu_context['current_action'])) {
69
+			call_integration_hook('integrate_' . $menu_context['current_action'] . '_areas', array(&$menuData));
70
+	}
69 71
 
70 72
 	// What is the current area selected?
71
-	if (isset($menuOptions['current_area']) || isset($_GET['area']))
72
-		$menu_context['current_area'] = isset($menuOptions['current_area']) ? $menuOptions['current_area'] : $_GET['area'];
73
+	if (isset($menuOptions['current_area']) || isset($_GET['area'])) {
74
+			$menu_context['current_area'] = isset($menuOptions['current_area']) ? $menuOptions['current_area'] : $_GET['area'];
75
+	}
73 76
 
74 77
 	// Build a list of additional parameters that should go in the URL.
75 78
 	$menu_context['extra_parameters'] = '';
76
-	if (!empty($menuOptions['extra_url_parameters']))
77
-		foreach ($menuOptions['extra_url_parameters'] as $key => $value)
79
+	if (!empty($menuOptions['extra_url_parameters'])) {
80
+			foreach ($menuOptions['extra_url_parameters'] as $key => $value)
78 81
 			$menu_context['extra_parameters'] .= ';' . $key . '=' . $value;
82
+	}
79 83
 
80 84
 	// Only include the session ID in the URL if it's strictly necessary.
81
-	if (empty($menuOptions['disable_url_session_check']))
82
-		$menu_context['extra_parameters'] .= ';' . $context['session_var'] . '=' . $context['session_id'];
85
+	if (empty($menuOptions['disable_url_session_check'])) {
86
+			$menu_context['extra_parameters'] .= ';' . $context['session_var'] . '=' . $context['session_id'];
87
+	}
83 88
 
84 89
 	$include_data = array();
85 90
 
@@ -87,8 +92,9 @@  discard block
 block discarded – undo
87 92
 	foreach ($menuData as $section_id => $section)
88 93
 	{
89 94
 		// Is this enabled - or has as permission check - which fails?
90
-		if ((isset($section['enabled']) && $section['enabled'] == false) || (isset($section['permission']) && !allowedTo($section['permission'])))
91
-			continue;
95
+		if ((isset($section['enabled']) && $section['enabled'] == false) || (isset($section['permission']) && !allowedTo($section['permission']))) {
96
+					continue;
97
+		}
92 98
 
93 99
 		// Now we cycle through the sections to pick the right area.
94 100
 		foreach ($section['areas'] as $area_id => $area)
@@ -110,41 +116,45 @@  discard block
 block discarded – undo
110 116
 					if (empty($area['hidden']))
111 117
 					{
112 118
 						// First time this section?
113
-						if (!isset($menu_context['sections'][$section_id]))
114
-							$menu_context['sections'][$section_id]['title'] = $section['title'];
119
+						if (!isset($menu_context['sections'][$section_id])) {
120
+													$menu_context['sections'][$section_id]['title'] = $section['title'];
121
+						}
115 122
 
116 123
 						$menu_context['sections'][$section_id]['areas'][$area_id] = array('label' => isset($area['label']) ? $area['label'] : $txt[$area_id]);
117 124
 						// We'll need the ID as well...
118 125
 						$menu_context['sections'][$section_id]['id'] = $section_id;
119 126
 						// Does it have a custom URL?
120
-						if (isset($area['custom_url']))
121
-							$menu_context['sections'][$section_id]['areas'][$area_id]['url'] = $area['custom_url'];
127
+						if (isset($area['custom_url'])) {
128
+													$menu_context['sections'][$section_id]['areas'][$area_id]['url'] = $area['custom_url'];
129
+						}
122 130
 
123 131
 						// Does this area have its own icon?
124
-						if (!isset($area['force_menu_into_arms_of_another_menu']) && $user_info['name'] == 'iamanoompaloompa')
125
-							$menu_context['sections'][$section_id]['areas'][$area_id] = safe_unserialize(base64_decode('YTozOntzOjU6ImxhYmVsIjtzOjEyOiJPb21wYSBMb29tcGEiO3M6MzoidXJsIjtzOjQzOiJodHRwOi8vZW4ud2lraXBlZGlhLm9yZy93aWtpL09vbXBhX0xvb21wYXM/IjtzOjQ6Imljb24iO3M6ODY6IjxpbWcgc3JjPSJodHRwOi8vd3d3LnNpbXBsZW1hY2hpbmVzLm9yZy9pbWFnZXMvb29tcGEuZ2lmIiBhbHQ9IkknbSBhbiBPb21wYSBMb29tcGEiIC8+Ijt9'));
126
-						elseif (isset($area['icon']) && file_exists($settings['theme_dir'] . '/images/admin/' . $area['icon']))
127
-							$menu_context['sections'][$section_id]['areas'][$area_id]['icon'] = '<img src="' . $settings['images_url'] . '/admin/' . $area['icon'] . '" alt="">';
128
-						elseif (isset($area['icon']) && file_exists($settings['default_theme_dir'] . '/images/admin/' . $area['icon']))
129
-							$menu_context['sections'][$section_id]['areas'][$area_id]['icon'] = '<img src="' . $settings['default_images_url'] . '/admin/' . $area['icon'] . '" alt="">';
130
-						elseif (isset($area['icon']))
131
-							$menu_context['sections'][$section_id]['areas'][$area_id]['icon'] = '<span class="generic_icons ' . $area['icon'] . '"></span>';
132
-						else
133
-							$menu_context['sections'][$section_id]['areas'][$area_id]['icon'] = '<span class="generic_icons ' . $area_id . '"></span>';
134
-
135
-						if (isset($area['icon_class']) && empty($menu_context['sections'][$section_id]['areas'][$area_id]['icon']))
136
-							$menu_context['sections'][$section_id]['areas'][$area_id]['icon_class'] = $menu_context['current_action'] . '_menu_icon ' . $area['icon_class'];
137
-						elseif (isset($area['icon']))
132
+						if (!isset($area['force_menu_into_arms_of_another_menu']) && $user_info['name'] == 'iamanoompaloompa') {
133
+													$menu_context['sections'][$section_id]['areas'][$area_id] = safe_unserialize(base64_decode('YTozOntzOjU6ImxhYmVsIjtzOjEyOiJPb21wYSBMb29tcGEiO3M6MzoidXJsIjtzOjQzOiJodHRwOi8vZW4ud2lraXBlZGlhLm9yZy93aWtpL09vbXBhX0xvb21wYXM/IjtzOjQ6Imljb24iO3M6ODY6IjxpbWcgc3JjPSJodHRwOi8vd3d3LnNpbXBsZW1hY2hpbmVzLm9yZy9pbWFnZXMvb29tcGEuZ2lmIiBhbHQ9IkknbSBhbiBPb21wYSBMb29tcGEiIC8+Ijt9'));
134
+						} elseif (isset($area['icon']) && file_exists($settings['theme_dir'] . '/images/admin/' . $area['icon'])) {
135
+													$menu_context['sections'][$section_id]['areas'][$area_id]['icon'] = '<img src="' . $settings['images_url'] . '/admin/' . $area['icon'] . '" alt="">';
136
+						} elseif (isset($area['icon']) && file_exists($settings['default_theme_dir'] . '/images/admin/' . $area['icon'])) {
137
+													$menu_context['sections'][$section_id]['areas'][$area_id]['icon'] = '<img src="' . $settings['default_images_url'] . '/admin/' . $area['icon'] . '" alt="">';
138
+						} elseif (isset($area['icon'])) {
139
+													$menu_context['sections'][$section_id]['areas'][$area_id]['icon'] = '<span class="generic_icons ' . $area['icon'] . '"></span>';
140
+						} else {
141
+													$menu_context['sections'][$section_id]['areas'][$area_id]['icon'] = '<span class="generic_icons ' . $area_id . '"></span>';
142
+						}
143
+
144
+						if (isset($area['icon_class']) && empty($menu_context['sections'][$section_id]['areas'][$area_id]['icon'])) {
145
+													$menu_context['sections'][$section_id]['areas'][$area_id]['icon_class'] = $menu_context['current_action'] . '_menu_icon ' . $area['icon_class'];
146
+						} elseif (isset($area['icon']))
138 147
 						{
139
-							if ((substr($area['icon'], -4) === '.png' || substr($area['icon'], -4) === '.gif') && file_exists($settings['theme_dir'] . '/images/admin/big/' . $area['icon']))
140
-								$menu_context['sections'][$section_id]['areas'][$area_id]['icon_file'] = $settings['theme_url'] . '/images/admin/big/' . $area['icon'];
141
-							elseif ((substr($area['icon'], -4) === '.png' || substr($area['icon'], -4) === '.gif') && file_exists($settings['default_theme_dir'] . '/images/admin/big/' . $area['icon']))
142
-								$menu_context['sections'][$section_id]['areas'][$area_id]['icon_file'] = $settings['default_theme_url'] . '/images/admin/big/' . $area['icon'];
148
+							if ((substr($area['icon'], -4) === '.png' || substr($area['icon'], -4) === '.gif') && file_exists($settings['theme_dir'] . '/images/admin/big/' . $area['icon'])) {
149
+															$menu_context['sections'][$section_id]['areas'][$area_id]['icon_file'] = $settings['theme_url'] . '/images/admin/big/' . $area['icon'];
150
+							} elseif ((substr($area['icon'], -4) === '.png' || substr($area['icon'], -4) === '.gif') && file_exists($settings['default_theme_dir'] . '/images/admin/big/' . $area['icon'])) {
151
+															$menu_context['sections'][$section_id]['areas'][$area_id]['icon_file'] = $settings['default_theme_url'] . '/images/admin/big/' . $area['icon'];
152
+							}
143 153
 
144 154
 							$menu_context['sections'][$section_id]['areas'][$area_id]['icon_class'] = $menu_context['current_action'] . '_menu_icon ' . str_replace(array('.png', '.gif'), '', $area['icon']);
155
+						} else {
156
+													$menu_context['sections'][$section_id]['areas'][$area_id]['icon_class'] = $menu_context['current_action'] . '_menu_icon ' . str_replace(array('.png', '.gif'), '', $area_id);
145 157
 						}
146
-						else
147
-							$menu_context['sections'][$section_id]['areas'][$area_id]['icon_class'] = $menu_context['current_action'] . '_menu_icon ' . str_replace(array('.png', '.gif'), '', $area_id);
148 158
 
149 159
 						// Some areas may be listed but not active, which we show as greyed out.
150 160
 						$menu_context['sections'][$section_id]['areas'][$area_id]['inactive'] = !empty($area['inactive']);
@@ -158,35 +168,41 @@  discard block
 block discarded – undo
158 168
 							{
159 169
 								if ((empty($sub[1]) || allowedTo($sub[1])) && (!isset($sub['enabled']) || !empty($sub['enabled'])))
160 170
 								{
161
-									if ($first_sa == null)
162
-										$first_sa = $sa;
171
+									if ($first_sa == null) {
172
+																			$first_sa = $sa;
173
+									}
163 174
 
164 175
 									$menu_context['sections'][$section_id]['areas'][$area_id]['subsections'][$sa] = array('label' => $sub[0]);
165 176
 									// Custom URL?
166
-									if (isset($sub['url']))
167
-										$menu_context['sections'][$section_id]['areas'][$area_id]['subsections'][$sa]['url'] = $sub['url'];
177
+									if (isset($sub['url'])) {
178
+																			$menu_context['sections'][$section_id]['areas'][$area_id]['subsections'][$sa]['url'] = $sub['url'];
179
+									}
168 180
 
169 181
 									// A bit complicated - but is this set?
170 182
 									if ($menu_context['current_area'] == $area_id)
171 183
 									{
172 184
 										// Save which is the first...
173
-										if (empty($first_sa))
174
-											$first_sa = $sa;
185
+										if (empty($first_sa)) {
186
+																					$first_sa = $sa;
187
+										}
175 188
 
176 189
 										// Is this the current subsection?
177
-										if (isset($_REQUEST['sa']) && $_REQUEST['sa'] == $sa)
178
-											$menu_context['current_subsection'] = $sa;
190
+										if (isset($_REQUEST['sa']) && $_REQUEST['sa'] == $sa) {
191
+																					$menu_context['current_subsection'] = $sa;
192
+										}
179 193
 										// Otherwise is it the default?
180
-										elseif (!isset($menu_context['current_subsection']) && !empty($sub[2]))
181
-											$menu_context['current_subsection'] = $sa;
194
+										elseif (!isset($menu_context['current_subsection']) && !empty($sub[2])) {
195
+																					$menu_context['current_subsection'] = $sa;
196
+										}
182 197
 									}
183 198
 
184 199
 									// Let's assume this is the last, for now.
185 200
 									$last_sa = $sa;
186 201
 								}
187 202
 								// Mark it as disabled...
188
-								else
189
-									$menu_context['sections'][$section_id]['areas'][$area_id]['subsections'][$sa]['disabled'] = true;
203
+								else {
204
+																	$menu_context['sections'][$section_id]['areas'][$area_id]['subsections'][$sa]['disabled'] = true;
205
+								}
190 206
 							}
191 207
 
192 208
 							// Set which one is first, last and selected in the group.
@@ -195,8 +211,9 @@  discard block
 block discarded – undo
195 211
 								$menu_context['sections'][$section_id]['areas'][$area_id]['subsections'][$context['right_to_left'] ? $last_sa : $first_sa]['is_first'] = true;
196 212
 								$menu_context['sections'][$section_id]['areas'][$area_id]['subsections'][$context['right_to_left'] ? $first_sa : $last_sa]['is_last'] = true;
197 213
 
198
-								if ($menu_context['current_area'] == $area_id && !isset($menu_context['current_subsection']))
199
-									$menu_context['current_subsection'] = $first_sa;
214
+								if ($menu_context['current_area'] == $area_id && !isset($menu_context['current_subsection'])) {
215
+																	$menu_context['current_subsection'] = $first_sa;
216
+								}
200 217
 							}
201 218
 						}
202 219
 					}
@@ -230,23 +247,26 @@  discard block
 block discarded – undo
230 247
 	$menu_context['base_url'] = isset($menuOptions['base_url']) ? $menuOptions['base_url'] : $scripturl . '?action=' . $menu_context['current_action'];
231 248
 
232 249
 	// If we didn't find the area we were looking for go to a default one.
233
-	if (isset($backup_area) && empty($found_section))
234
-		$menu_context['current_area'] = $backup_area;
250
+	if (isset($backup_area) && empty($found_section)) {
251
+			$menu_context['current_area'] = $backup_area;
252
+	}
235 253
 
236 254
 	// If there are sections quickly goes through all the sections to check if the base menu has an url
237 255
 	if (!empty($menu_context['current_section']))
238 256
 	{
239 257
 		$menu_context['sections'][$menu_context['current_section']]['selected'] = true;
240 258
 		$menu_context['sections'][$menu_context['current_section']]['areas'][$menu_context['current_area']]['selected'] = true;
241
-		if (!empty($menu_context['sections'][$menu_context['current_section']]['areas'][$menu_context['current_area']]['subsections'][$context['current_subaction']]))
242
-			$menu_context['sections'][$menu_context['current_section']]['areas'][$menu_context['current_area']]['subsections'][$context['current_subaction']]['selected'] = true;
259
+		if (!empty($menu_context['sections'][$menu_context['current_section']]['areas'][$menu_context['current_area']]['subsections'][$context['current_subaction']])) {
260
+					$menu_context['sections'][$menu_context['current_section']]['areas'][$menu_context['current_area']]['subsections'][$context['current_subaction']]['selected'] = true;
261
+		}
243 262
 
244
-		foreach ($menu_context['sections'] as $section_id => $section)
245
-			foreach ($section['areas'] as $area_id => $area)
263
+		foreach ($menu_context['sections'] as $section_id => $section) {
264
+					foreach ($section['areas'] as $area_id => $area)
246 265
 			{
247 266
 				if (!isset($menu_context['sections'][$section_id]['url']))
248 267
 				{
249 268
 					$menu_context['sections'][$section_id]['url'] = isset($area['url']) ? $area['url'] : $menu_context['base_url'] . ';area=' . $area_id;
269
+		}
250 270
 					break;
251 271
 				}
252 272
 			}
@@ -257,8 +277,9 @@  discard block
 block discarded – undo
257 277
 	{
258 278
 		// Never happened!
259 279
 		$context['max_menu_id']--;
260
-		if ($context['max_menu_id'] == 0)
261
-			unset($context['max_menu_id']);
280
+		if ($context['max_menu_id'] == 0) {
281
+					unset($context['max_menu_id']);
282
+		}
262 283
 
263 284
 		return false;
264 285
 	}
@@ -269,8 +290,9 @@  discard block
 block discarded – undo
269 290
 	$context['template_layers'][] = $menu_context['layer_name'];
270 291
 
271 292
 	// Check we had something - for sanity sake.
272
-	if (empty($include_data))
273
-		return false;
293
+	if (empty($include_data)) {
294
+			return false;
295
+	}
274 296
 
275 297
 	// Finally - return information on the selected item.
276 298
 	$include_data += array(
@@ -293,12 +315,14 @@  discard block
 block discarded – undo
293 315
 	global $context;
294 316
 
295 317
 	$menu_name = $menu_id == 'last' && isset($context['max_menu_id']) && isset($context['menu_data_' . $context['max_menu_id']]) ? 'menu_data_' . $context['max_menu_id'] : 'menu_data_' . $menu_id;
296
-	if (!isset($context[$menu_name]))
297
-		return false;
318
+	if (!isset($context[$menu_name])) {
319
+			return false;
320
+	}
298 321
 
299 322
 	$layer_index = array_search($context[$menu_name]['layer_name'], $context['template_layers']);
300
-	if ($layer_index !== false)
301
-		unset($context['template_layers'][$layer_index]);
323
+	if ($layer_index !== false) {
324
+			unset($context['template_layers'][$layer_index]);
325
+	}
302 326
 
303 327
 	unset($context[$menu_name]);
304 328
 }
Please login to merge, or discard this patch.
Sources/Subs-Post.php 2 patches
Doc Comments   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1451,7 +1451,7 @@  discard block
 block discarded – undo
1451 1451
  * @param resource $socket Socket to send on
1452 1452
  * @param string $code The expected response code
1453 1453
  * @param string $response The response from the SMTP server
1454
- * @return bool Whether it responded as such.
1454
+ * @return string|boolean Whether it responded as such.
1455 1455
  */
1456 1456
 function server_parse($message, $socket, $code, &$response = null)
1457 1457
 {
@@ -2265,7 +2265,7 @@  discard block
 block discarded – undo
2265 2265
  * @param array $msgs Array of message ids
2266 2266
  * @param bool $approve Whether to approve the posts (if false, posts are unapproved)
2267 2267
  * @param bool $notify Whether to notify users
2268
- * @return bool Whether the operation was successful
2268
+ * @return null|boolean Whether the operation was successful
2269 2269
  */
2270 2270
 function approvePosts($msgs, $approve = true, $notify = true)
2271 2271
 {
@@ -2518,7 +2518,7 @@  discard block
 block discarded – undo
2518 2518
  *
2519 2519
  * @param array $topics Array of topic ids
2520 2520
  * @param bool $approve Whether to approve the topics. If false, unapproves them instead
2521
- * @return bool Whether the operation was successful
2521
+ * @return null|boolean Whether the operation was successful
2522 2522
  */
2523 2523
 function approveTopics($topics, $approve = true)
2524 2524
 {
@@ -2908,7 +2908,7 @@  discard block
 block discarded – undo
2908 2908
  *
2909 2909
  * @param resource $dict An enchant or pspell dictionary resource set up by {@link spell_init()}
2910 2910
  * @param string $word A word to check the spelling of
2911
- * @return bool Whether or not the specified word is spelled properly
2911
+ * @return boolean|null Whether or not the specified word is spelled properly
2912 2912
  */
2913 2913
 function spell_check($dict, $word)
2914 2914
 {
Please login to merge, or discard this patch.
Braces   +528 added lines, -393 removed lines patch added patch discarded remove patch
@@ -15,8 +15,9 @@  discard block
 block discarded – undo
15 15
  * @version 2.1 Beta 4
16 16
  */
17 17
 
18
-if (!defined('SMF'))
18
+if (!defined('SMF')) {
19 19
 	die('No direct access...');
20
+}
20 21
 
21 22
 /**
22 23
  * Takes a message and parses it, returning nothing.
@@ -46,17 +47,19 @@  discard block
 block discarded – undo
46 47
 	$message = preg_replace('~\.{100,}~', '...', $message);
47 48
 
48 49
 	// Trim off trailing quotes - these often happen by accident.
49
-	while (substr($message, -7) == '[quote]')
50
-		$message = substr($message, 0, -7);
51
-	while (substr($message, 0, 8) == '[/quote]')
52
-		$message = substr($message, 8);
50
+	while (substr($message, -7) == '[quote]') {
51
+			$message = substr($message, 0, -7);
52
+	}
53
+	while (substr($message, 0, 8) == '[/quote]') {
54
+			$message = substr($message, 8);
55
+	}
53 56
 
54 57
 	// Find all code blocks, work out whether we'd be parsing them, then ensure they are all closed.
55 58
 	$in_tag = false;
56 59
 	$had_tag = false;
57 60
 	$codeopen = 0;
58
-	if (preg_match_all('~(\[(/)*code(?:=[^\]]+)?\])~is', $message, $matches))
59
-		foreach ($matches[0] as $index => $dummy)
61
+	if (preg_match_all('~(\[(/)*code(?:=[^\]]+)?\])~is', $message, $matches)) {
62
+			foreach ($matches[0] as $index => $dummy)
60 63
 		{
61 64
 			// Closing?
62 65
 			if (!empty($matches[2][$index]))
@@ -64,6 +67,7 @@  discard block
 block discarded – undo
64 67
 				// If it's closing and we're not in a tag we need to open it...
65 68
 				if (!$in_tag)
66 69
 					$codeopen = true;
70
+	}
67 71
 				// Either way we ain't in one any more.
68 72
 				$in_tag = false;
69 73
 			}
@@ -72,17 +76,20 @@  discard block
 block discarded – undo
72 76
 			{
73 77
 				$had_tag = true;
74 78
 				// If we're in a tag don't do nought!
75
-				if (!$in_tag)
76
-					$in_tag = true;
79
+				if (!$in_tag) {
80
+									$in_tag = true;
81
+				}
77 82
 			}
78 83
 		}
79 84
 
80 85
 	// If we have an open tag, close it.
81
-	if ($in_tag)
82
-		$message .= '[/code]';
86
+	if ($in_tag) {
87
+			$message .= '[/code]';
88
+	}
83 89
 	// Open any ones that need to be open, only if we've never had a tag.
84
-	if ($codeopen && !$had_tag)
85
-		$message = '[code]' . $message;
90
+	if ($codeopen && !$had_tag) {
91
+			$message = '[code]' . $message;
92
+	}
86 93
 
87 94
 	// Now that we've fixed all the code tags, let's fix the img and url tags...
88 95
 	$parts = preg_split('~(\[/code\]|\[code(?:=[^\]]+)?\])~i', $message, -1, PREG_SPLIT_DELIM_CAPTURE);
@@ -108,23 +115,26 @@  discard block
 block discarded – undo
108 115
 	fixTags($message);
109 116
 
110 117
 	// Replace /me.+?\n with [me=name]dsf[/me]\n.
111
-	if (strpos($user_info['name'], '[') !== false || strpos($user_info['name'], ']') !== false || strpos($user_info['name'], '\'') !== false || strpos($user_info['name'], '"') !== false)
112
-		$message = preg_replace('~(\A|\n)/me(?: |&nbsp;)([^\n]*)(?:\z)?~i', '$1[me=&quot;' . $user_info['name'] . '&quot;]$2[/me]', $message);
113
-	else
114
-		$message = preg_replace('~(\A|\n)/me(?: |&nbsp;)([^\n]*)(?:\z)?~i', '$1[me=' . $user_info['name'] . ']$2[/me]', $message);
118
+	if (strpos($user_info['name'], '[') !== false || strpos($user_info['name'], ']') !== false || strpos($user_info['name'], '\'') !== false || strpos($user_info['name'], '"') !== false) {
119
+			$message = preg_replace('~(\A|\n)/me(?: |&nbsp;)([^\n]*)(?:\z)?~i', '$1[me=&quot;' . $user_info['name'] . '&quot;]$2[/me]', $message);
120
+	} else {
121
+			$message = preg_replace('~(\A|\n)/me(?: |&nbsp;)([^\n]*)(?:\z)?~i', '$1[me=' . $user_info['name'] . ']$2[/me]', $message);
122
+	}
115 123
 
116 124
 	if (!$previewing && strpos($message, '[html]') !== false)
117 125
 	{
118
-		if (allowedTo('admin_forum'))
119
-			$message = preg_replace_callback('~\[html\](.+?)\[/html\]~is', function($m) {
126
+		if (allowedTo('admin_forum')) {
127
+					$message = preg_replace_callback('~\[html\](.+?)\[/html\]~is', function($m) {
120 128
 				return '[html]' . strtr(un_htmlspecialchars($m[1]), array("\n" => '&#13;', '  ' => ' &#32;', '[' => '&#91;', ']' => '&#93;')) . '[/html]';
129
+		}
121 130
 			}, $message);
122 131
 
123 132
 		// We should edit them out, or else if an admin edits the message they will get shown...
124 133
 		else
125 134
 		{
126
-			while (strpos($message, '[html]') !== false)
127
-				$message = preg_replace('~\[[/]?html\]~i', '', $message);
135
+			while (strpos($message, '[html]') !== false) {
136
+							$message = preg_replace('~\[[/]?html\]~i', '', $message);
137
+			}
128 138
 		}
129 139
 	}
130 140
 
@@ -146,10 +156,12 @@  discard block
 block discarded – undo
146 156
 
147 157
 	$list_open = substr_count($message, '[list]') + substr_count($message, '[list ');
148 158
 	$list_close = substr_count($message, '[/list]');
149
-	if ($list_close - $list_open > 0)
150
-		$message = str_repeat('[list]', $list_close - $list_open) . $message;
151
-	if ($list_open - $list_close > 0)
152
-		$message = $message . str_repeat('[/list]', $list_open - $list_close);
159
+	if ($list_close - $list_open > 0) {
160
+			$message = str_repeat('[list]', $list_close - $list_open) . $message;
161
+	}
162
+	if ($list_open - $list_close > 0) {
163
+			$message = $message . str_repeat('[/list]', $list_open - $list_close);
164
+	}
153 165
 
154 166
 	$mistake_fixes = array(
155 167
 		// Find [table]s not followed by [tr].
@@ -198,8 +210,9 @@  discard block
 block discarded – undo
198 210
 	);
199 211
 
200 212
 	// Fix up some use of tables without [tr]s, etc. (it has to be done more than once to catch it all.)
201
-	for ($j = 0; $j < 3; $j++)
202
-		$message = preg_replace(array_keys($mistake_fixes), $mistake_fixes, $message);
213
+	for ($j = 0; $j < 3; $j++) {
214
+			$message = preg_replace(array_keys($mistake_fixes), $mistake_fixes, $message);
215
+	}
203 216
 
204 217
 	// Remove empty bbc from the sections outside the code tags
205 218
 	$allowedEmpty = array(
@@ -209,24 +222,28 @@  discard block
 block discarded – undo
209 222
 
210 223
 	require_once($sourcedir . '/Subs.php');
211 224
 
212
-	foreach (($codes = parse_bbc(false)) as $code)
213
-		if (!in_array($code['tag'], $allowedEmpty))
225
+	foreach (($codes = parse_bbc(false)) as $code) {
226
+			if (!in_array($code['tag'], $allowedEmpty))
214 227
 			$alltags[] = $code['tag'];
228
+	}
215 229
 
216 230
 	$alltags_regex = '\b' . implode("\b|\b", array_unique($alltags)) . '\b';
217 231
 
218
-	while (preg_match('~\[(' . $alltags_regex . ')[^\]]*\]\s*\[/\1\]\s?~i', $message))
219
-		$message = preg_replace('~\[(' . $alltags_regex . ')[^\]]*\]\s*\[/\1\]\s?~i', '', $message);
232
+	while (preg_match('~\[(' . $alltags_regex . ')[^\]]*\]\s*\[/\1\]\s?~i', $message)) {
233
+			$message = preg_replace('~\[(' . $alltags_regex . ')[^\]]*\]\s*\[/\1\]\s?~i', '', $message);
234
+	}
220 235
 
221 236
 	// Restore code blocks
222
-	if (!empty($code_tags))
223
-		$message = str_replace(array_keys($code_tags), array_values($code_tags), $message);
237
+	if (!empty($code_tags)) {
238
+			$message = str_replace(array_keys($code_tags), array_values($code_tags), $message);
239
+	}
224 240
 
225 241
 	// Restore white space entities
226
-	if (!$previewing)
227
-		$message = strtr($message, array('  ' => '&nbsp; ', "\n" => '<br>', $context['utf8'] ? "\xC2\xA0" : "\xA0" => '&nbsp;'));
228
-	else
229
-		$message = strtr($message, array('  ' => '&nbsp; ', $context['utf8'] ? "\xC2\xA0" : "\xA0" => '&nbsp;'));
242
+	if (!$previewing) {
243
+			$message = strtr($message, array('  ' => '&nbsp; ', "\n" => '<br>', $context['utf8'] ? "\xC2\xA0" : "\xA0" => '&nbsp;'));
244
+	} else {
245
+			$message = strtr($message, array('  ' => '&nbsp; ', $context['utf8'] ? "\xC2\xA0" : "\xA0" => '&nbsp;'));
246
+	}
230 247
 
231 248
 	// Now let's quickly clean up things that will slow our parser (which are common in posted code.)
232 249
 	$message = strtr($message, array('[]' => '&#91;]', '[&#039;' => '&#91;&#039;'));
@@ -269,8 +286,9 @@  discard block
 block discarded – undo
269 286
 		return "[time]" . timeformat("$m[1]", false) . "[/time]";
270 287
 	}, $message);
271 288
 
272
-	if (!empty($code_tags))
273
-		$message = str_replace(array_keys($code_tags), array_values($code_tags), $message);
289
+	if (!empty($code_tags)) {
290
+			$message = str_replace(array_keys($code_tags), array_values($code_tags), $message);
291
+	}
274 292
 
275 293
 	// Change breaks back to \n's and &nsbp; back to spaces.
276 294
 	return preg_replace('~<br( /)?' . '>~', "\n", str_replace('&nbsp;', ' ', $message));
@@ -351,8 +369,9 @@  discard block
 block discarded – undo
351 369
 	);
352 370
 
353 371
 	// Fix each type of tag.
354
-	foreach ($fixArray as $param)
355
-		fixTag($message, $param['tag'], $param['protocols'], $param['embeddedUrl'], $param['hasEqualSign'], !empty($param['hasExtra']));
372
+	foreach ($fixArray as $param) {
373
+			fixTag($message, $param['tag'], $param['protocols'], $param['embeddedUrl'], $param['hasEqualSign'], !empty($param['hasExtra']));
374
+	}
356 375
 
357 376
 	// Now fix possible security problems with images loading links automatically...
358 377
 	$message = preg_replace_callback('~(\[img.*?\])(.+?)\[/img\]~is', function($m)
@@ -388,16 +407,19 @@  discard block
 block discarded – undo
388 407
 					$desired_height = $height;
389 408
 				}
390 409
 				// Scale it to the width...
391
-				elseif (empty($desired_width) && !empty($height))
392
-					$desired_width = (int) (($desired_height * $width) / $height);
410
+				elseif (empty($desired_width) && !empty($height)) {
411
+									$desired_width = (int) (($desired_height * $width) / $height);
412
+				}
393 413
 				// Scale if to the height.
394
-				elseif (!empty($width))
395
-					$desired_height = (int) (($desired_width * $height) / $width);
414
+				elseif (!empty($width)) {
415
+									$desired_height = (int) (($desired_width * $height) / $width);
416
+				}
396 417
 			}
397 418
 
398 419
 			// If the width and height are fine, just continue along...
399
-			if ($desired_width <= $modSettings['max_image_width'] && $desired_height <= $modSettings['max_image_height'])
400
-				continue;
420
+			if ($desired_width <= $modSettings['max_image_width'] && $desired_height <= $modSettings['max_image_height']) {
421
+							continue;
422
+			}
401 423
 
402 424
 			// Too bad, it's too wide.  Make it as wide as the maximum.
403 425
 			if ($desired_width > $modSettings['max_image_width'] && !empty($modSettings['max_image_width']))
@@ -417,8 +439,9 @@  discard block
 block discarded – undo
417 439
 		}
418 440
 
419 441
 		// If any img tags were actually changed...
420
-		if (!empty($replaces))
421
-			$message = strtr($message, $replaces);
442
+		if (!empty($replaces)) {
443
+					$message = strtr($message, $replaces);
444
+		}
422 445
 	}
423 446
 }
424 447
 
@@ -437,10 +460,11 @@  discard block
 block discarded – undo
437 460
 {
438 461
 	global $boardurl, $scripturl;
439 462
 
440
-	if (preg_match('~^([^:]+://[^/]+)~', $boardurl, $match) != 0)
441
-		$domain_url = $match[1];
442
-	else
443
-		$domain_url = $boardurl . '/';
463
+	if (preg_match('~^([^:]+://[^/]+)~', $boardurl, $match) != 0) {
464
+			$domain_url = $match[1];
465
+	} else {
466
+			$domain_url = $boardurl . '/';
467
+	}
444 468
 
445 469
 	$replaces = array();
446 470
 
@@ -448,11 +472,11 @@  discard block
 block discarded – undo
448 472
 	{
449 473
 		$quoted = preg_match('~\[(' . $myTag . ')=&quot;~', $message);
450 474
 		preg_match_all('~\[(' . $myTag . ')=' . ($quoted ? '&quot;(.*?)&quot;' : '([^\]]*?)') . '\](?:(.+?)\[/(' . $myTag . ')\])?~is', $message, $matches);
475
+	} elseif ($hasEqualSign) {
476
+			preg_match_all('~\[(' . $myTag . ')=([^\]]*?)\](?:(.+?)\[/(' . $myTag . ')\])?~is', $message, $matches);
477
+	} else {
478
+			preg_match_all('~\[(' . $myTag . ($hasExtra ? '(?:[^\]]*?)' : '') . ')\](.+?)\[/(' . $myTag . ')\]~is', $message, $matches);
451 479
 	}
452
-	elseif ($hasEqualSign)
453
-		preg_match_all('~\[(' . $myTag . ')=([^\]]*?)\](?:(.+?)\[/(' . $myTag . ')\])?~is', $message, $matches);
454
-	else
455
-		preg_match_all('~\[(' . $myTag . ($hasExtra ? '(?:[^\]]*?)' : '') . ')\](.+?)\[/(' . $myTag . ')\]~is', $message, $matches);
456 480
 
457 481
 	foreach ($matches[0] as $k => $dummy)
458 482
 	{
@@ -465,49 +489,53 @@  discard block
 block discarded – undo
465 489
 		foreach ($protocols as $protocol)
466 490
 		{
467 491
 			$found = strncasecmp($replace, $protocol . '://', strlen($protocol) + 3) === 0;
468
-			if ($found)
469
-				break;
492
+			if ($found) {
493
+							break;
494
+			}
470 495
 		}
471 496
 
472 497
 		if (!$found && $protocols[0] == 'http')
473 498
 		{
474
-			if (substr($replace, 0, 1) == '/' && substr($replace, 0, 2) != '//')
475
-				$replace = $domain_url . $replace;
476
-			elseif (substr($replace, 0, 1) == '?')
477
-				$replace = $scripturl . $replace;
478
-			elseif (substr($replace, 0, 1) == '#' && $embeddedUrl)
499
+			if (substr($replace, 0, 1) == '/' && substr($replace, 0, 2) != '//') {
500
+							$replace = $domain_url . $replace;
501
+			} elseif (substr($replace, 0, 1) == '?') {
502
+							$replace = $scripturl . $replace;
503
+			} elseif (substr($replace, 0, 1) == '#' && $embeddedUrl)
479 504
 			{
480 505
 				$replace = '#' . preg_replace('~[^A-Za-z0-9_\-#]~', '', substr($replace, 1));
481 506
 				$this_tag = 'iurl';
482 507
 				$this_close = 'iurl';
508
+			} elseif (substr($replace, 0, 2) != '//') {
509
+							$replace = $protocols[0] . '://' . $replace;
483 510
 			}
484
-			elseif (substr($replace, 0, 2) != '//')
485
-				$replace = $protocols[0] . '://' . $replace;
486
-		}
487
-		elseif (!$found && $protocols[0] == 'ftp')
488
-			$replace = $protocols[0] . '://' . preg_replace('~^(?!ftps?)[^:]+://~', '', $replace);
489
-		elseif (!$found)
490
-			$replace = $protocols[0] . '://' . $replace;
491
-
492
-		if ($hasEqualSign && $embeddedUrl)
493
-			$replaces[$matches[0][$k]] = '[' . $this_tag . '=&quot;' . $replace . '&quot;]' . (empty($matches[4][$k]) ? '' : $matches[3][$k] . '[/' . $this_close . ']');
494
-		elseif ($hasEqualSign)
495
-			$replaces['[' . $matches[1][$k] . '=' . $matches[2][$k] . ']'] = '[' . $this_tag . '=' . $replace . ']';
496
-		elseif ($embeddedUrl)
497
-			$replaces['[' . $matches[1][$k] . ']' . $matches[2][$k] . '[/' . $matches[3][$k] . ']'] = '[' . $this_tag . '=' . $replace . ']' . $matches[2][$k] . '[/' . $this_close . ']';
498
-		else
499
-			$replaces['[' . $matches[1][$k] . ']' . $matches[2][$k] . '[/' . $matches[3][$k] . ']'] = '[' . $this_tag . ']' . $replace . '[/' . $this_close . ']';
511
+		} elseif (!$found && $protocols[0] == 'ftp') {
512
+					$replace = $protocols[0] . '://' . preg_replace('~^(?!ftps?)[^:]+://~', '', $replace);
513
+		} elseif (!$found) {
514
+					$replace = $protocols[0] . '://' . $replace;
515
+		}
516
+
517
+		if ($hasEqualSign && $embeddedUrl) {
518
+					$replaces[$matches[0][$k]] = '[' . $this_tag . '=&quot;' . $replace . '&quot;]' . (empty($matches[4][$k]) ? '' : $matches[3][$k] . '[/' . $this_close . ']');
519
+		} elseif ($hasEqualSign) {
520
+					$replaces['[' . $matches[1][$k] . '=' . $matches[2][$k] . ']'] = '[' . $this_tag . '=' . $replace . ']';
521
+		} elseif ($embeddedUrl) {
522
+					$replaces['[' . $matches[1][$k] . ']' . $matches[2][$k] . '[/' . $matches[3][$k] . ']'] = '[' . $this_tag . '=' . $replace . ']' . $matches[2][$k] . '[/' . $this_close . ']';
523
+		} else {
524
+					$replaces['[' . $matches[1][$k] . ']' . $matches[2][$k] . '[/' . $matches[3][$k] . ']'] = '[' . $this_tag . ']' . $replace . '[/' . $this_close . ']';
525
+		}
500 526
 	}
501 527
 
502 528
 	foreach ($replaces as $k => $v)
503 529
 	{
504
-		if ($k == $v)
505
-			unset($replaces[$k]);
530
+		if ($k == $v) {
531
+					unset($replaces[$k]);
532
+		}
506 533
 	}
507 534
 
508
-	if (!empty($replaces))
509
-		$message = strtr($message, $replaces);
510
-}
535
+	if (!empty($replaces)) {
536
+			$message = strtr($message, $replaces);
537
+	}
538
+	}
511 539
 
512 540
 /**
513 541
  * This function sends an email to the specified recipient(s).
@@ -551,8 +579,9 @@  discard block
 block discarded – undo
551 579
 	}
552 580
 
553 581
 	// Nothing left? Nothing else to do
554
-	if (empty($to_array))
555
-		return true;
582
+	if (empty($to_array)) {
583
+			return true;
584
+	}
556 585
 
557 586
 	// Once upon a time, Hotmail could not interpret non-ASCII mails.
558 587
 	// In honour of those days, it's still called the 'hotmail fix'.
@@ -569,15 +598,17 @@  discard block
 block discarded – undo
569 598
 		}
570 599
 
571 600
 		// Call this function recursively for the hotmail addresses.
572
-		if (!empty($hotmail_to))
573
-			$mail_result = sendmail($hotmail_to, $subject, $message, $from, $message_id, $send_html, $priority, true, $is_private);
601
+		if (!empty($hotmail_to)) {
602
+					$mail_result = sendmail($hotmail_to, $subject, $message, $from, $message_id, $send_html, $priority, true, $is_private);
603
+		}
574 604
 
575 605
 		// The remaining addresses no longer need the fix.
576 606
 		$hotmail_fix = false;
577 607
 
578 608
 		// No other addresses left? Return instantly.
579
-		if (empty($to_array))
580
-			return $mail_result;
609
+		if (empty($to_array)) {
610
+					return $mail_result;
611
+		}
581 612
 	}
582 613
 
583 614
 	// Get rid of entities.
@@ -602,13 +633,15 @@  discard block
 block discarded – undo
602 633
 	$headers .= 'Return-Path: ' . (empty($modSettings['mail_from']) ? $webmaster_email : $modSettings['mail_from']) . $line_break;
603 634
 	$headers .= 'Date: ' . gmdate('D, d M Y H:i:s') . ' -0000' . $line_break;
604 635
 
605
-	if ($message_id !== null && empty($modSettings['mail_no_message_id']))
606
-		$headers .= 'Message-ID: <' . md5($scripturl . microtime()) . '-' . $message_id . strstr(empty($modSettings['mail_from']) ? $webmaster_email : $modSettings['mail_from'], '@') . '>' . $line_break;
636
+	if ($message_id !== null && empty($modSettings['mail_no_message_id'])) {
637
+			$headers .= 'Message-ID: <' . md5($scripturl . microtime()) . '-' . $message_id . strstr(empty($modSettings['mail_from']) ? $webmaster_email : $modSettings['mail_from'], '@') . '>' . $line_break;
638
+	}
607 639
 	$headers .= 'X-Mailer: SMF' . $line_break;
608 640
 
609 641
 	// Pass this to the integration before we start modifying the output -- it'll make it easier later.
610
-	if (in_array(false, call_integration_hook('integrate_outgoing_email', array(&$subject, &$message, &$headers, &$to_array)), true))
611
-		return false;
642
+	if (in_array(false, call_integration_hook('integrate_outgoing_email', array(&$subject, &$message, &$headers, &$to_array)), true)) {
643
+			return false;
644
+	}
612 645
 
613 646
 	// Save the original message...
614 647
 	$orig_message = $message;
@@ -657,17 +690,19 @@  discard block
 block discarded – undo
657 690
 	}
658 691
 
659 692
 	// Are we using the mail queue, if so this is where we butt in...
660
-	if ($priority != 0)
661
-		return AddMailQueue(false, $to_array, $subject, $message, $headers, $send_html, $priority, $is_private);
693
+	if ($priority != 0) {
694
+			return AddMailQueue(false, $to_array, $subject, $message, $headers, $send_html, $priority, $is_private);
695
+	}
662 696
 
663 697
 	// If it's a priority mail, send it now - note though that this should NOT be used for sending many at once.
664 698
 	elseif (!empty($modSettings['mail_limit']))
665 699
 	{
666 700
 		list ($last_mail_time, $mails_this_minute) = @explode('|', $modSettings['mail_recent']);
667
-		if (empty($mails_this_minute) || time() > $last_mail_time + 60)
668
-			$new_queue_stat = time() . '|' . 1;
669
-		else
670
-			$new_queue_stat = $last_mail_time . '|' . ((int) $mails_this_minute + 1);
701
+		if (empty($mails_this_minute) || time() > $last_mail_time + 60) {
702
+					$new_queue_stat = time() . '|' . 1;
703
+		} else {
704
+					$new_queue_stat = $last_mail_time . '|' . ((int) $mails_this_minute + 1);
705
+		}
671 706
 
672 707
 		updateSettings(array('mail_recent' => $new_queue_stat));
673 708
 	}
@@ -692,12 +727,13 @@  discard block
 block discarded – undo
692 727
 
693 728
 			// Wait, wait, I'm still sending here!
694 729
 			@set_time_limit(300);
695
-			if (function_exists('apache_reset_timeout'))
696
-				@apache_reset_timeout();
730
+			if (function_exists('apache_reset_timeout')) {
731
+							@apache_reset_timeout();
732
+			}
697 733
 		}
734
+	} else {
735
+			$mail_result = $mail_result && smtp_mail($to_array, $subject, $message, $headers);
698 736
 	}
699
-	else
700
-		$mail_result = $mail_result && smtp_mail($to_array, $subject, $message, $headers);
701 737
 
702 738
 	// Everything go smoothly?
703 739
 	return $mail_result;
@@ -723,8 +759,9 @@  discard block
 block discarded – undo
723 759
 	static $cur_insert = array();
724 760
 	static $cur_insert_len = 0;
725 761
 
726
-	if ($cur_insert_len == 0)
727
-		$cur_insert = array();
762
+	if ($cur_insert_len == 0) {
763
+			$cur_insert = array();
764
+	}
728 765
 
729 766
 	// If we're flushing, make the final inserts - also if we're near the MySQL length limit!
730 767
 	if (($flush || $cur_insert_len > 800000) && !empty($cur_insert))
@@ -799,8 +836,9 @@  discard block
 block discarded – undo
799 836
 	}
800 837
 
801 838
 	// If they are using SSI there is a good chance obExit will never be called.  So lets be nice and flush it for them.
802
-	if (SMF === 'SSI' || SMF === 'BACKGROUND')
803
-		return AddMailQueue(true);
839
+	if (SMF === 'SSI' || SMF === 'BACKGROUND') {
840
+			return AddMailQueue(true);
841
+	}
804 842
 
805 843
 	return true;
806 844
 }
@@ -831,23 +869,26 @@  discard block
 block discarded – undo
831 869
 		'sent' => array()
832 870
 	);
833 871
 
834
-	if ($from === null)
835
-		$from = array(
872
+	if ($from === null) {
873
+			$from = array(
836 874
 			'id' => $user_info['id'],
837 875
 			'name' => $user_info['name'],
838 876
 			'username' => $user_info['username']
839 877
 		);
878
+	}
840 879
 
841 880
 	// This is the one that will go in their inbox.
842 881
 	$htmlmessage = $smcFunc['htmlspecialchars']($message, ENT_QUOTES);
843 882
 	preparsecode($htmlmessage);
844 883
 	$htmlsubject = strtr($smcFunc['htmlspecialchars']($subject), array("\r" => '', "\n" => '', "\t" => ''));
845
-	if ($smcFunc['strlen']($htmlsubject) > 100)
846
-		$htmlsubject = $smcFunc['substr']($htmlsubject, 0, 100);
884
+	if ($smcFunc['strlen']($htmlsubject) > 100) {
885
+			$htmlsubject = $smcFunc['substr']($htmlsubject, 0, 100);
886
+	}
847 887
 
848 888
 	// Make sure is an array
849
-	if (!is_array($recipients))
850
-		$recipients = array($recipients);
889
+	if (!is_array($recipients)) {
890
+			$recipients = array($recipients);
891
+	}
851 892
 
852 893
 	// Integrated PMs
853 894
 	call_integration_hook('integrate_personal_message', array(&$recipients, &$from, &$subject, &$message));
@@ -875,21 +916,23 @@  discard block
 block discarded – undo
875 916
 				'usernames' => array_keys($usernames),
876 917
 			)
877 918
 		);
878
-		while ($row = $smcFunc['db_fetch_assoc']($request))
879
-			if (isset($usernames[$smcFunc['strtolower']($row['member_name'])]))
919
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
920
+					if (isset($usernames[$smcFunc['strtolower']($row['member_name'])]))
880 921
 				$usernames[$smcFunc['strtolower']($row['member_name'])] = $row['id_member'];
922
+		}
881 923
 		$smcFunc['db_free_result']($request);
882 924
 
883 925
 		// Replace the usernames with IDs. Drop usernames that couldn't be found.
884
-		foreach ($recipients as $rec_type => $rec)
885
-			foreach ($rec as $id => $member)
926
+		foreach ($recipients as $rec_type => $rec) {
927
+					foreach ($rec as $id => $member)
886 928
 			{
887 929
 				if (is_numeric($recipients[$rec_type][$id]))
888 930
 					continue;
931
+		}
889 932
 
890
-				if (!empty($usernames[$member]))
891
-					$recipients[$rec_type][$id] = $usernames[$member];
892
-				else
933
+				if (!empty($usernames[$member])) {
934
+									$recipients[$rec_type][$id] = $usernames[$member];
935
+				} else
893 936
 				{
894 937
 					$log['failed'][$id] = sprintf($txt['pm_error_user_not_found'], $recipients[$rec_type][$id]);
895 938
 					unset($recipients[$rec_type][$id]);
@@ -927,8 +970,9 @@  discard block
 block discarded – undo
927 970
 		$delete = false;
928 971
 		foreach ($criteria as $criterium)
929 972
 		{
930
-			if (($criterium['t'] == 'mid' && $criterium['v'] == $from['id']) || ($criterium['t'] == 'gid' && in_array($criterium['v'], $user_info['groups'])) || ($criterium['t'] == 'sub' && strpos($subject, $criterium['v']) !== false) || ($criterium['t'] == 'msg' && strpos($message, $criterium['v']) !== false))
931
-				$delete = true;
973
+			if (($criterium['t'] == 'mid' && $criterium['v'] == $from['id']) || ($criterium['t'] == 'gid' && in_array($criterium['v'], $user_info['groups'])) || ($criterium['t'] == 'sub' && strpos($subject, $criterium['v']) !== false) || ($criterium['t'] == 'msg' && strpos($message, $criterium['v']) !== false)) {
974
+							$delete = true;
975
+			}
932 976
 			// If we're adding and one criteria don't match then we stop!
933 977
 			elseif (!$row['is_or'])
934 978
 			{
@@ -936,8 +980,9 @@  discard block
 block discarded – undo
936 980
 				break;
937 981
 			}
938 982
 		}
939
-		if ($delete)
940
-			$deletes[$row['id_member']] = 1;
983
+		if ($delete) {
984
+					$deletes[$row['id_member']] = 1;
985
+		}
941 986
 	}
942 987
 	$smcFunc['db_free_result']($request);
943 988
 
@@ -952,8 +997,9 @@  discard block
 block discarded – undo
952 997
 			array(
953 998
 			)
954 999
 		);
955
-		while ($row = $smcFunc['db_fetch_assoc']($request))
956
-			$message_limit_cache[$row['id_group']] = $row['max_messages'];
1000
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
1001
+					$message_limit_cache[$row['id_group']] = $row['max_messages'];
1002
+		}
957 1003
 		$smcFunc['db_free_result']($request);
958 1004
 	}
959 1005
 
@@ -961,8 +1007,9 @@  discard block
 block discarded – undo
961 1007
 	require_once($sourcedir . '/Subs-Members.php');
962 1008
 	$pmReadGroups = groupsAllowedTo('pm_read');
963 1009
 
964
-	if (empty($modSettings['permission_enable_deny']))
965
-		$pmReadGroups['denied'] = array();
1010
+	if (empty($modSettings['permission_enable_deny'])) {
1011
+			$pmReadGroups['denied'] = array();
1012
+	}
966 1013
 
967 1014
 	// Load their alert preferences
968 1015
 	require_once($sourcedir . '/Subs-Notify.php');
@@ -994,8 +1041,9 @@  discard block
 block discarded – undo
994 1041
 	while ($row = $smcFunc['db_fetch_assoc']($request))
995 1042
 	{
996 1043
 		// Don't do anything for members to be deleted!
997
-		if (isset($deletes[$row['id_member']]))
998
-			continue;
1044
+		if (isset($deletes[$row['id_member']])) {
1045
+					continue;
1046
+		}
999 1047
 
1000 1048
 		// Load the preferences for this member (if any)
1001 1049
 		$prefs = !empty($notifyPrefs[$row['id_member']]) ? $notifyPrefs[$row['id_member']] : array();
@@ -1016,8 +1064,9 @@  discard block
 block discarded – undo
1016 1064
 		{
1017 1065
 			foreach ($groups as $id)
1018 1066
 			{
1019
-				if (isset($message_limit_cache[$id]) && $message_limit != 0 && $message_limit < $message_limit_cache[$id])
1020
-					$message_limit = $message_limit_cache[$id];
1067
+				if (isset($message_limit_cache[$id]) && $message_limit != 0 && $message_limit < $message_limit_cache[$id]) {
1068
+									$message_limit = $message_limit_cache[$id];
1069
+				}
1021 1070
 			}
1022 1071
 
1023 1072
 			if ($message_limit > 0 && $message_limit <= $row['instant_messages'])
@@ -1065,8 +1114,9 @@  discard block
 block discarded – undo
1065 1114
 	$smcFunc['db_free_result']($request);
1066 1115
 
1067 1116
 	// Only 'send' the message if there are any recipients left.
1068
-	if (empty($all_to))
1069
-		return $log;
1117
+	if (empty($all_to)) {
1118
+			return $log;
1119
+	}
1070 1120
 
1071 1121
 	// Insert the message itself and then grab the last insert id.
1072 1122
 	$id_pm = $smcFunc['db_insert']('',
@@ -1087,8 +1137,8 @@  discard block
 block discarded – undo
1087 1137
 	if (!empty($id_pm))
1088 1138
 	{
1089 1139
 		// If this is new we need to set it part of it's own conversation.
1090
-		if (empty($pm_head))
1091
-			$smcFunc['db_query']('', '
1140
+		if (empty($pm_head)) {
1141
+					$smcFunc['db_query']('', '
1092 1142
 				UPDATE {db_prefix}personal_messages
1093 1143
 				SET id_pm_head = {int:id_pm_head}
1094 1144
 				WHERE id_pm = {int:id_pm_head}',
@@ -1096,6 +1146,7 @@  discard block
 block discarded – undo
1096 1146
 					'id_pm_head' => $id_pm,
1097 1147
 				)
1098 1148
 			);
1149
+		}
1099 1150
 
1100 1151
 		// Some people think manually deleting personal_messages is fun... it's not. We protect against it though :)
1101 1152
 		$smcFunc['db_query']('', '
@@ -1111,8 +1162,9 @@  discard block
 block discarded – undo
1111 1162
 		foreach ($all_to as $to)
1112 1163
 		{
1113 1164
 			$insertRows[] = array($id_pm, $to, in_array($to, $recipients['bcc']) ? 1 : 0, isset($deletes[$to]) ? 1 : 0, 1);
1114
-			if (!in_array($to, $recipients['bcc']))
1115
-				$to_list[] = $to;
1165
+			if (!in_array($to, $recipients['bcc'])) {
1166
+							$to_list[] = $to;
1167
+			}
1116 1168
 		}
1117 1169
 
1118 1170
 		$smcFunc['db_insert']('insert',
@@ -1130,9 +1182,9 @@  discard block
 block discarded – undo
1130 1182
 	{
1131 1183
 		censorText($message);
1132 1184
 		$message = trim(un_htmlspecialchars(strip_tags(strtr(parse_bbc($smcFunc['htmlspecialchars']($message), false), array('<br>' => "\n", '</div>' => "\n", '</li>' => "\n", '&#91;' => '[', '&#93;' => ']')))));
1185
+	} else {
1186
+			$message = '';
1133 1187
 	}
1134
-	else
1135
-		$message = '';
1136 1188
 
1137 1189
 	$to_names = array();
1138 1190
 	if (count($to_list) > 1)
@@ -1145,8 +1197,9 @@  discard block
 block discarded – undo
1145 1197
 				'to_members' => $to_list,
1146 1198
 			)
1147 1199
 		);
1148
-		while ($row = $smcFunc['db_fetch_assoc']($request))
1149
-			$to_names[] = un_htmlspecialchars($row['real_name']);
1200
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
1201
+					$to_names[] = un_htmlspecialchars($row['real_name']);
1202
+		}
1150 1203
 		$smcFunc['db_free_result']($request);
1151 1204
 	}
1152 1205
 	$replacements = array(
@@ -1174,11 +1227,13 @@  discard block
 block discarded – undo
1174 1227
 	loadLanguage('index+PersonalMessage');
1175 1228
 
1176 1229
 	// Add one to their unread and read message counts.
1177
-	foreach ($all_to as $k => $id)
1178
-		if (isset($deletes[$id]))
1230
+	foreach ($all_to as $k => $id) {
1231
+			if (isset($deletes[$id]))
1179 1232
 			unset($all_to[$k]);
1180
-	if (!empty($all_to))
1181
-		updateMemberData($all_to, array('instant_messages' => '+', 'unread_messages' => '+', 'new_pm' => 1));
1233
+	}
1234
+	if (!empty($all_to)) {
1235
+			updateMemberData($all_to, array('instant_messages' => '+', 'unread_messages' => '+', 'new_pm' => 1));
1236
+	}
1182 1237
 
1183 1238
 	return $log;
1184 1239
 }
@@ -1208,15 +1263,17 @@  discard block
 block discarded – undo
1208 1263
 		// Let's, for now, assume there are only &#021;'ish characters.
1209 1264
 		$simple = true;
1210 1265
 
1211
-		foreach ($matches[1] as $entity)
1212
-			if ($entity > 128)
1266
+		foreach ($matches[1] as $entity) {
1267
+					if ($entity > 128)
1213 1268
 				$simple = false;
1269
+		}
1214 1270
 		unset($matches);
1215 1271
 
1216
-		if ($simple)
1217
-			$string = preg_replace_callback('~&#(\d{3,8});~', function($m)
1272
+		if ($simple) {
1273
+					$string = preg_replace_callback('~&#(\d{3,8});~', function($m)
1218 1274
 			{
1219 1275
 				return chr("$m[1]");
1276
+		}
1220 1277
 			}, $string);
1221 1278
 		else
1222 1279
 		{
@@ -1224,8 +1281,9 @@  discard block
 block discarded – undo
1224 1281
 			if (!$context['utf8'] && function_exists('iconv'))
1225 1282
 			{
1226 1283
 				$newstring = @iconv($context['character_set'], 'UTF-8', $string);
1227
-				if ($newstring)
1228
-					$string = $newstring;
1284
+				if ($newstring) {
1285
+									$string = $newstring;
1286
+				}
1229 1287
 			}
1230 1288
 
1231 1289
 			$string = preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $string);
@@ -1241,23 +1299,25 @@  discard block
 block discarded – undo
1241 1299
 		if (!$context['utf8'] && function_exists('iconv'))
1242 1300
 		{
1243 1301
 			$newstring = @iconv($context['character_set'], 'UTF-8', $string);
1244
-			if ($newstring)
1245
-				$string = $newstring;
1302
+			if ($newstring) {
1303
+							$string = $newstring;
1304
+			}
1246 1305
 		}
1247 1306
 
1248 1307
 		$entityConvert = function($m)
1249 1308
 		{
1250 1309
 			$c = $m[1];
1251
-			if (strlen($c) === 1 && ord($c[0]) <= 0x7F)
1252
-				return $c;
1253
-			elseif (strlen($c) === 2 && ord($c[0]) >= 0xC0 && ord($c[0]) <= 0xDF)
1254
-				return "&#" . (((ord($c[0]) ^ 0xC0) << 6) + (ord($c[1]) ^ 0x80)) . ";";
1255
-			elseif (strlen($c) === 3 && ord($c[0]) >= 0xE0 && ord($c[0]) <= 0xEF)
1256
-				return "&#" . (((ord($c[0]) ^ 0xE0) << 12) + ((ord($c[1]) ^ 0x80) << 6) + (ord($c[2]) ^ 0x80)) . ";";
1257
-			elseif (strlen($c) === 4 && ord($c[0]) >= 0xF0 && ord($c[0]) <= 0xF7)
1258
-				return "&#" . (((ord($c[0]) ^ 0xF0) << 18) + ((ord($c[1]) ^ 0x80) << 12) + ((ord($c[2]) ^ 0x80) << 6) + (ord($c[3]) ^ 0x80)) . ";";
1259
-			else
1260
-				return "";
1310
+			if (strlen($c) === 1 && ord($c[0]) <= 0x7F) {
1311
+							return $c;
1312
+			} elseif (strlen($c) === 2 && ord($c[0]) >= 0xC0 && ord($c[0]) <= 0xDF) {
1313
+							return "&#" . (((ord($c[0]) ^ 0xC0) << 6) + (ord($c[1]) ^ 0x80)) . ";";
1314
+			} elseif (strlen($c) === 3 && ord($c[0]) >= 0xE0 && ord($c[0]) <= 0xEF) {
1315
+							return "&#" . (((ord($c[0]) ^ 0xE0) << 12) + ((ord($c[1]) ^ 0x80) << 6) + (ord($c[2]) ^ 0x80)) . ";";
1316
+			} elseif (strlen($c) === 4 && ord($c[0]) >= 0xF0 && ord($c[0]) <= 0xF7) {
1317
+							return "&#" . (((ord($c[0]) ^ 0xF0) << 18) + ((ord($c[1]) ^ 0x80) << 12) + ((ord($c[2]) ^ 0x80) << 6) + (ord($c[3]) ^ 0x80)) . ";";
1318
+			} else {
1319
+							return "";
1320
+			}
1261 1321
 		};
1262 1322
 
1263 1323
 		// Convert all 'special' characters to HTML entities.
@@ -1271,19 +1331,20 @@  discard block
 block discarded – undo
1271 1331
 		$string = base64_encode($string);
1272 1332
 
1273 1333
 		// Show the characterset and the transfer-encoding for header strings.
1274
-		if ($with_charset)
1275
-			$string = '=?' . $charset . '?B?' . $string . '?=';
1334
+		if ($with_charset) {
1335
+					$string = '=?' . $charset . '?B?' . $string . '?=';
1336
+		}
1276 1337
 
1277 1338
 		// Break it up in lines (mail body).
1278
-		else
1279
-			$string = chunk_split($string, 76, $line_break);
1339
+		else {
1340
+					$string = chunk_split($string, 76, $line_break);
1341
+		}
1280 1342
 
1281 1343
 		return array($charset, $string, 'base64');
1344
+	} else {
1345
+			return array($charset, $string, '7bit');
1346
+	}
1282 1347
 	}
1283
-
1284
-	else
1285
-		return array($charset, $string, '7bit');
1286
-}
1287 1348
 
1288 1349
 /**
1289 1350
  * Sends mail, like mail() but over SMTP.
@@ -1307,8 +1368,9 @@  discard block
 block discarded – undo
1307 1368
 	if ($modSettings['mail_type'] == 3 && $modSettings['smtp_username'] != '' && $modSettings['smtp_password'] != '')
1308 1369
 	{
1309 1370
 		$socket = fsockopen($modSettings['smtp_host'], 110, $errno, $errstr, 2);
1310
-		if (!$socket && (substr($modSettings['smtp_host'], 0, 5) == 'smtp.' || substr($modSettings['smtp_host'], 0, 11) == 'ssl://smtp.'))
1311
-			$socket = fsockopen(strtr($modSettings['smtp_host'], array('smtp.' => 'pop.')), 110, $errno, $errstr, 2);
1371
+		if (!$socket && (substr($modSettings['smtp_host'], 0, 5) == 'smtp.' || substr($modSettings['smtp_host'], 0, 11) == 'ssl://smtp.')) {
1372
+					$socket = fsockopen(strtr($modSettings['smtp_host'], array('smtp.' => 'pop.')), 110, $errno, $errstr, 2);
1373
+		}
1312 1374
 
1313 1375
 		if ($socket)
1314 1376
 		{
@@ -1329,8 +1391,9 @@  discard block
 block discarded – undo
1329 1391
 		// Maybe we can still save this?  The port might be wrong.
1330 1392
 		if (substr($modSettings['smtp_host'], 0, 4) == 'ssl:' && (empty($modSettings['smtp_port']) || $modSettings['smtp_port'] == 25))
1331 1393
 		{
1332
-			if ($socket = fsockopen($modSettings['smtp_host'], 465, $errno, $errstr, 3))
1333
-				log_error($txt['smtp_port_ssl']);
1394
+			if ($socket = fsockopen($modSettings['smtp_host'], 465, $errno, $errstr, 3)) {
1395
+							log_error($txt['smtp_port_ssl']);
1396
+			}
1334 1397
 		}
1335 1398
 
1336 1399
 		// Unable to connect!  Don't show any error message, but just log one and try to continue anyway.
@@ -1342,20 +1405,23 @@  discard block
 block discarded – undo
1342 1405
 	}
1343 1406
 
1344 1407
 	// Wait for a response of 220, without "-" continuer.
1345
-	if (!server_parse(null, $socket, '220'))
1346
-		return false;
1408
+	if (!server_parse(null, $socket, '220')) {
1409
+			return false;
1410
+	}
1347 1411
 
1348 1412
 	// Try and determine the servers name, fall back to the mail servers if not found
1349 1413
 	$helo = false;
1350
-	if (function_exists('gethostname') && gethostname() !== false)
1351
-		$helo = gethostname();
1352
-	elseif (function_exists('php_uname'))
1353
-		$helo = php_uname('n');
1354
-	elseif (array_key_exists('SERVER_NAME', $_SERVER) && !empty($_SERVER['SERVER_NAME']))
1355
-		$helo = $_SERVER['SERVER_NAME'];
1414
+	if (function_exists('gethostname') && gethostname() !== false) {
1415
+			$helo = gethostname();
1416
+	} elseif (function_exists('php_uname')) {
1417
+			$helo = php_uname('n');
1418
+	} elseif (array_key_exists('SERVER_NAME', $_SERVER) && !empty($_SERVER['SERVER_NAME'])) {
1419
+			$helo = $_SERVER['SERVER_NAME'];
1420
+	}
1356 1421
 
1357
-	if (empty($helo))
1358
-		$helo = $modSettings['smtp_host'];
1422
+	if (empty($helo)) {
1423
+			$helo = $modSettings['smtp_host'];
1424
+	}
1359 1425
 
1360 1426
 	// SMTP = 1, SMTP - STARTTLS = 2
1361 1427
 	if (in_array($modSettings['mail_type'], array(1, 2)) && $modSettings['smtp_username'] != '' && $modSettings['smtp_password'] != '')
@@ -1367,33 +1433,39 @@  discard block
 block discarded – undo
1367 1433
 			if ($modSettings['mail_type'] == 2 && preg_match("~250( |-)STARTTLS~mi", $response))
1368 1434
 			{
1369 1435
 				// Send STARTTLS to enable encryption
1370
-				if (!server_parse('STARTTLS', $socket, '220'))
1371
-					return false;
1436
+				if (!server_parse('STARTTLS', $socket, '220')) {
1437
+									return false;
1438
+				}
1372 1439
 				// Enable the encryption
1373
-				if (!@stream_socket_enable_crypto($socket, true, STREAM_CRYPTO_METHOD_TLS_CLIENT))
1374
-					return false;
1440
+				if (!@stream_socket_enable_crypto($socket, true, STREAM_CRYPTO_METHOD_TLS_CLIENT)) {
1441
+									return false;
1442
+				}
1375 1443
 				// Send the EHLO command again
1376
-				if (!server_parse('EHLO ' . $helo, $socket, null) == '250')
1377
-					return false;
1444
+				if (!server_parse('EHLO ' . $helo, $socket, null) == '250') {
1445
+									return false;
1446
+				}
1378 1447
 			}
1379 1448
 
1380
-			if (!server_parse('AUTH LOGIN', $socket, '334'))
1381
-				return false;
1449
+			if (!server_parse('AUTH LOGIN', $socket, '334')) {
1450
+							return false;
1451
+			}
1382 1452
 			// Send the username and password, encoded.
1383
-			if (!server_parse(base64_encode($modSettings['smtp_username']), $socket, '334'))
1384
-				return false;
1453
+			if (!server_parse(base64_encode($modSettings['smtp_username']), $socket, '334')) {
1454
+							return false;
1455
+			}
1385 1456
 			// The password is already encoded ;)
1386
-			if (!server_parse($modSettings['smtp_password'], $socket, '235'))
1387
-				return false;
1457
+			if (!server_parse($modSettings['smtp_password'], $socket, '235')) {
1458
+							return false;
1459
+			}
1460
+		} elseif (!server_parse('HELO ' . $helo, $socket, '250')) {
1461
+					return false;
1388 1462
 		}
1389
-		elseif (!server_parse('HELO ' . $helo, $socket, '250'))
1390
-			return false;
1391
-	}
1392
-	else
1463
+	} else
1393 1464
 	{
1394 1465
 		// Just say "helo".
1395
-		if (!server_parse('HELO ' . $helo, $socket, '250'))
1396
-			return false;
1466
+		if (!server_parse('HELO ' . $helo, $socket, '250')) {
1467
+					return false;
1468
+		}
1397 1469
 	}
1398 1470
 
1399 1471
 	// Fix the message for any lines beginning with a period! (the first is ignored, you see.)
@@ -1406,31 +1478,38 @@  discard block
 block discarded – undo
1406 1478
 		// Reset the connection to send another email.
1407 1479
 		if ($i != 0)
1408 1480
 		{
1409
-			if (!server_parse('RSET', $socket, '250'))
1410
-				return false;
1481
+			if (!server_parse('RSET', $socket, '250')) {
1482
+							return false;
1483
+			}
1411 1484
 		}
1412 1485
 
1413 1486
 		// From, to, and then start the data...
1414
-		if (!server_parse('MAIL FROM: <' . (empty($modSettings['mail_from']) ? $webmaster_email : $modSettings['mail_from']) . '>', $socket, '250'))
1415
-			return false;
1416
-		if (!server_parse('RCPT TO: <' . $mail_to . '>', $socket, '250'))
1417
-			return false;
1418
-		if (!server_parse('DATA', $socket, '354'))
1419
-			return false;
1487
+		if (!server_parse('MAIL FROM: <' . (empty($modSettings['mail_from']) ? $webmaster_email : $modSettings['mail_from']) . '>', $socket, '250')) {
1488
+					return false;
1489
+		}
1490
+		if (!server_parse('RCPT TO: <' . $mail_to . '>', $socket, '250')) {
1491
+					return false;
1492
+		}
1493
+		if (!server_parse('DATA', $socket, '354')) {
1494
+					return false;
1495
+		}
1420 1496
 		fputs($socket, 'Subject: ' . $subject . "\r\n");
1421
-		if (strlen($mail_to) > 0)
1422
-			fputs($socket, 'To: <' . $mail_to . '>' . "\r\n");
1497
+		if (strlen($mail_to) > 0) {
1498
+					fputs($socket, 'To: <' . $mail_to . '>' . "\r\n");
1499
+		}
1423 1500
 		fputs($socket, $headers . "\r\n\r\n");
1424 1501
 		fputs($socket, $message . "\r\n");
1425 1502
 
1426 1503
 		// Send a ., or in other words "end of data".
1427
-		if (!server_parse('.', $socket, '250'))
1428
-			return false;
1504
+		if (!server_parse('.', $socket, '250')) {
1505
+					return false;
1506
+		}
1429 1507
 
1430 1508
 		// Almost done, almost done... don't stop me just yet!
1431 1509
 		@set_time_limit(300);
1432
-		if (function_exists('apache_reset_timeout'))
1433
-			@apache_reset_timeout();
1510
+		if (function_exists('apache_reset_timeout')) {
1511
+					@apache_reset_timeout();
1512
+		}
1434 1513
 	}
1435 1514
 	fputs($socket, 'QUIT' . "\r\n");
1436 1515
 	fclose($socket);
@@ -1454,8 +1533,9 @@  discard block
 block discarded – undo
1454 1533
 {
1455 1534
 	global $txt;
1456 1535
 
1457
-	if ($message !== null)
1458
-		fputs($socket, $message . "\r\n");
1536
+	if ($message !== null) {
1537
+			fputs($socket, $message . "\r\n");
1538
+	}
1459 1539
 
1460 1540
 	// No response yet.
1461 1541
 	$server_response = '';
@@ -1471,8 +1551,9 @@  discard block
 block discarded – undo
1471 1551
 		$response .= $server_response;
1472 1552
 	}
1473 1553
 
1474
-	if ($code === null)
1475
-		return substr($server_response, 0, 3);
1554
+	if ($code === null) {
1555
+			return substr($server_response, 0, 3);
1556
+	}
1476 1557
 
1477 1558
 	if (substr($server_response, 0, 3) != $code)
1478 1559
 	{
@@ -1502,8 +1583,9 @@  discard block
 block discarded – undo
1502 1583
 	// Create a pspell or enchant dictionary resource
1503 1584
 	$dict = spell_init();
1504 1585
 
1505
-	if (!isset($_POST['spellstring']) || !$dict)
1506
-		die;
1586
+	if (!isset($_POST['spellstring']) || !$dict) {
1587
+			die;
1588
+	}
1507 1589
 
1508 1590
 	// Construct a bit of Javascript code.
1509 1591
 	$context['spell_js'] = '
@@ -1521,8 +1603,9 @@  discard block
 block discarded – undo
1521 1603
 		$check_word = explode('|', $alphas[$i]);
1522 1604
 
1523 1605
 		// If the word is a known word, or spelled right...
1524
-		if (in_array($smcFunc['strtolower']($check_word[0]), $known_words) || spell_check($dict, $check_word[0]) || !isset($check_word[2]))
1525
-			continue;
1606
+		if (in_array($smcFunc['strtolower']($check_word[0]), $known_words) || spell_check($dict, $check_word[0]) || !isset($check_word[2])) {
1607
+					continue;
1608
+		}
1526 1609
 
1527 1610
 		// Find the word, and move up the "last occurrence" to here.
1528 1611
 		$found_words = true;
@@ -1536,20 +1619,23 @@  discard block
 block discarded – undo
1536 1619
 		if (!empty($suggestions))
1537 1620
 		{
1538 1621
 			// But first check they aren't going to be censored - no naughty words!
1539
-			foreach ($suggestions as $k => $word)
1540
-				if ($suggestions[$k] != censorText($word))
1622
+			foreach ($suggestions as $k => $word) {
1623
+							if ($suggestions[$k] != censorText($word))
1541 1624
 					unset($suggestions[$k]);
1625
+			}
1542 1626
 
1543
-			if (!empty($suggestions))
1544
-				$context['spell_js'] .= '"' . implode('", "', $suggestions) . '"';
1627
+			if (!empty($suggestions)) {
1628
+							$context['spell_js'] .= '"' . implode('", "', $suggestions) . '"';
1629
+			}
1545 1630
 		}
1546 1631
 
1547 1632
 		$context['spell_js'] .= ']),';
1548 1633
 	}
1549 1634
 
1550 1635
 	// If words were found, take off the last comma.
1551
-	if ($found_words)
1552
-		$context['spell_js'] = substr($context['spell_js'], 0, -1);
1636
+	if ($found_words) {
1637
+			$context['spell_js'] = substr($context['spell_js'], 0, -1);
1638
+	}
1553 1639
 
1554 1640
 	$context['spell_js'] .= '
1555 1641
 		);';
@@ -1584,11 +1670,13 @@  discard block
 block discarded – undo
1584 1670
 	global $user_info, $smcFunc;
1585 1671
 
1586 1672
 	// Can't do it if there's no topics.
1587
-	if (empty($topics))
1588
-		return;
1673
+	if (empty($topics)) {
1674
+			return;
1675
+	}
1589 1676
 	// It must be an array - it must!
1590
-	if (!is_array($topics))
1591
-		$topics = array($topics);
1677
+	if (!is_array($topics)) {
1678
+			$topics = array($topics);
1679
+	}
1592 1680
 
1593 1681
 	// Get the subject and body...
1594 1682
 	$result = $smcFunc['db_query']('', '
@@ -1636,14 +1724,15 @@  discard block
 block discarded – undo
1636 1724
 	}
1637 1725
 	$smcFunc['db_free_result']($result);
1638 1726
 
1639
-	if (!empty($task_rows))
1640
-		$smcFunc['db_insert']('',
1727
+	if (!empty($task_rows)) {
1728
+			$smcFunc['db_insert']('',
1641 1729
 			'{db_prefix}background_tasks',
1642 1730
 			array('task_file' => 'string', 'task_class' => 'string', 'task_data' => 'string', 'claimed_time' => 'int'),
1643 1731
 			$task_rows,
1644 1732
 			array('id_task')
1645 1733
 		);
1646
-}
1734
+	}
1735
+	}
1647 1736
 
1648 1737
 /**
1649 1738
  * Create a post, either as new topic (id_topic = 0) or in an existing one.
@@ -1681,9 +1770,9 @@  discard block
 block discarded – undo
1681 1770
 	$msgOptions['send_notifications'] = isset($msgOptions['send_notifications']) ? (bool) $msgOptions['send_notifications'] : true;
1682 1771
 
1683 1772
 	// We need to know if the topic is approved. If we're told that's great - if not find out.
1684
-	if (!$modSettings['postmod_active'])
1685
-		$topicOptions['is_approved'] = true;
1686
-	elseif (!empty($topicOptions['id']) && !isset($topicOptions['is_approved']))
1773
+	if (!$modSettings['postmod_active']) {
1774
+			$topicOptions['is_approved'] = true;
1775
+	} elseif (!empty($topicOptions['id']) && !isset($topicOptions['is_approved']))
1687 1776
 	{
1688 1777
 		$request = $smcFunc['db_query']('', '
1689 1778
 			SELECT approved
@@ -1706,8 +1795,7 @@  discard block
 block discarded – undo
1706 1795
 			$posterOptions['id'] = 0;
1707 1796
 			$posterOptions['name'] = $txt['guest_title'];
1708 1797
 			$posterOptions['email'] = '';
1709
-		}
1710
-		elseif ($posterOptions['id'] != $user_info['id'])
1798
+		} elseif ($posterOptions['id'] != $user_info['id'])
1711 1799
 		{
1712 1800
 			$request = $smcFunc['db_query']('', '
1713 1801
 				SELECT member_name, email_address
@@ -1725,12 +1813,11 @@  discard block
 block discarded – undo
1725 1813
 				$posterOptions['id'] = 0;
1726 1814
 				$posterOptions['name'] = $txt['guest_title'];
1727 1815
 				$posterOptions['email'] = '';
1816
+			} else {
1817
+							list ($posterOptions['name'], $posterOptions['email']) = $smcFunc['db_fetch_row']($request);
1728 1818
 			}
1729
-			else
1730
-				list ($posterOptions['name'], $posterOptions['email']) = $smcFunc['db_fetch_row']($request);
1731 1819
 			$smcFunc['db_free_result']($request);
1732
-		}
1733
-		else
1820
+		} else
1734 1821
 		{
1735 1822
 			$posterOptions['name'] = $user_info['name'];
1736 1823
 			$posterOptions['email'] = $user_info['email'];
@@ -1740,8 +1827,9 @@  discard block
 block discarded – undo
1740 1827
 	if (!empty($modSettings['enable_mentions']))
1741 1828
 	{
1742 1829
 		$msgOptions['mentioned_members'] = Mentions::getMentionedMembers($msgOptions['body']);
1743
-		if (!empty($msgOptions['mentioned_members']))
1744
-			$msgOptions['body'] = Mentions::getBody($msgOptions['body'], $msgOptions['mentioned_members']);
1830
+		if (!empty($msgOptions['mentioned_members'])) {
1831
+					$msgOptions['body'] = Mentions::getBody($msgOptions['body'], $msgOptions['mentioned_members']);
1832
+		}
1745 1833
 	}
1746 1834
 
1747 1835
 	// It's do or die time: forget any user aborts!
@@ -1774,12 +1862,13 @@  discard block
 block discarded – undo
1774 1862
 	);
1775 1863
 
1776 1864
 	// Something went wrong creating the message...
1777
-	if (empty($msgOptions['id']))
1778
-		return false;
1865
+	if (empty($msgOptions['id'])) {
1866
+			return false;
1867
+	}
1779 1868
 
1780 1869
 	// Fix the attachments.
1781
-	if (!empty($msgOptions['attachments']))
1782
-		$smcFunc['db_query']('', '
1870
+	if (!empty($msgOptions['attachments'])) {
1871
+			$smcFunc['db_query']('', '
1783 1872
 			UPDATE {db_prefix}attachments
1784 1873
 			SET id_msg = {int:id_msg}
1785 1874
 			WHERE id_attach IN ({array_int:attachment_list})',
@@ -1788,6 +1877,7 @@  discard block
 block discarded – undo
1788 1877
 				'id_msg' => $msgOptions['id'],
1789 1878
 			)
1790 1879
 		);
1880
+	}
1791 1881
 
1792 1882
 	// What if we want to export new posts out to a CMS?
1793 1883
 	call_integration_hook('integrate_after_create_post', array($msgOptions, $topicOptions, $posterOptions, $message_columns, $message_parameters));
@@ -1864,20 +1954,23 @@  discard block
 block discarded – undo
1864 1954
 			'id_topic' => $topicOptions['id'],
1865 1955
 			'counter_increment' => 1,
1866 1956
 		);
1867
-		if ($msgOptions['approved'])
1868
-			$topics_columns = array(
1957
+		if ($msgOptions['approved']) {
1958
+					$topics_columns = array(
1869 1959
 				'id_member_updated = {int:poster_id}',
1870 1960
 				'id_last_msg = {int:id_msg}',
1871 1961
 				'num_replies = num_replies + {int:counter_increment}',
1872 1962
 			);
1873
-		else
1874
-			$topics_columns = array(
1963
+		} else {
1964
+					$topics_columns = array(
1875 1965
 				'unapproved_posts = unapproved_posts + {int:counter_increment}',
1876 1966
 			);
1877
-		if ($topicOptions['lock_mode'] !== null)
1878
-			$topics_columns[] = 'locked = {int:locked}';
1879
-		if ($topicOptions['sticky_mode'] !== null)
1880
-			$topics_columns[] = 'is_sticky = {int:is_sticky}';
1967
+		}
1968
+		if ($topicOptions['lock_mode'] !== null) {
1969
+					$topics_columns[] = 'locked = {int:locked}';
1970
+		}
1971
+		if ($topicOptions['sticky_mode'] !== null) {
1972
+					$topics_columns[] = 'is_sticky = {int:is_sticky}';
1973
+		}
1881 1974
 
1882 1975
 		call_integration_hook('integrate_modify_topic', array(&$topics_columns, &$update_parameters, &$msgOptions, &$topicOptions, &$posterOptions));
1883 1976
 
@@ -1906,8 +1999,8 @@  discard block
 block discarded – undo
1906 1999
 	);
1907 2000
 
1908 2001
 	// Increase the number of posts and topics on the board.
1909
-	if ($msgOptions['approved'])
1910
-		$smcFunc['db_query']('', '
2002
+	if ($msgOptions['approved']) {
2003
+			$smcFunc['db_query']('', '
1911 2004
 			UPDATE {db_prefix}boards
1912 2005
 			SET num_posts = num_posts + 1' . ($new_topic ? ', num_topics = num_topics + 1' : '') . '
1913 2006
 			WHERE id_board = {int:id_board}',
@@ -1915,7 +2008,7 @@  discard block
 block discarded – undo
1915 2008
 				'id_board' => $topicOptions['board'],
1916 2009
 			)
1917 2010
 		);
1918
-	else
2011
+	} else
1919 2012
 	{
1920 2013
 		$smcFunc['db_query']('', '
1921 2014
 			UPDATE {db_prefix}boards
@@ -1985,8 +2078,8 @@  discard block
 block discarded – undo
1985 2078
 		}
1986 2079
 	}
1987 2080
 
1988
-	if ($msgOptions['approved'] && empty($topicOptions['is_approved']))
1989
-		$smcFunc['db_insert']('',
2081
+	if ($msgOptions['approved'] && empty($topicOptions['is_approved'])) {
2082
+			$smcFunc['db_insert']('',
1990 2083
 			'{db_prefix}background_tasks',
1991 2084
 			array('task_file' => 'string', 'task_class' => 'string', 'task_data' => 'string', 'claimed_time' => 'int'),
1992 2085
 			array(
@@ -1998,19 +2091,22 @@  discard block
 block discarded – undo
1998 2091
 			),
1999 2092
 			array('id_task')
2000 2093
 		);
2094
+	}
2001 2095
 
2002 2096
 	// If there's a custom search index, it may need updating...
2003 2097
 	require_once($sourcedir . '/Search.php');
2004 2098
 	$searchAPI = findSearchAPI();
2005
-	if (is_callable(array($searchAPI, 'postCreated')))
2006
-		$searchAPI->postCreated($msgOptions, $topicOptions, $posterOptions);
2099
+	if (is_callable(array($searchAPI, 'postCreated'))) {
2100
+			$searchAPI->postCreated($msgOptions, $topicOptions, $posterOptions);
2101
+	}
2007 2102
 
2008 2103
 	// Increase the post counter for the user that created the post.
2009 2104
 	if (!empty($posterOptions['update_post_count']) && !empty($posterOptions['id']) && $msgOptions['approved'])
2010 2105
 	{
2011 2106
 		// Are you the one that happened to create this post?
2012
-		if ($user_info['id'] == $posterOptions['id'])
2013
-			$user_info['posts']++;
2107
+		if ($user_info['id'] == $posterOptions['id']) {
2108
+					$user_info['posts']++;
2109
+		}
2014 2110
 		updateMemberData($posterOptions['id'], array('posts' => '+'));
2015 2111
 	}
2016 2112
 
@@ -2018,19 +2114,21 @@  discard block
 block discarded – undo
2018 2114
 	$_SESSION['last_read_topic'] = 0;
2019 2115
 
2020 2116
 	// Better safe than sorry.
2021
-	if (isset($_SESSION['topicseen_cache'][$topicOptions['board']]))
2022
-		$_SESSION['topicseen_cache'][$topicOptions['board']]--;
2117
+	if (isset($_SESSION['topicseen_cache'][$topicOptions['board']])) {
2118
+			$_SESSION['topicseen_cache'][$topicOptions['board']]--;
2119
+	}
2023 2120
 
2024 2121
 	// Update all the stats so everyone knows about this new topic and message.
2025 2122
 	updateStats('message', true, $msgOptions['id']);
2026 2123
 
2027 2124
 	// Update the last message on the board assuming it's approved AND the topic is.
2028
-	if ($msgOptions['approved'])
2029
-		updateLastMessages($topicOptions['board'], $new_topic || !empty($topicOptions['is_approved']) ? $msgOptions['id'] : 0);
2125
+	if ($msgOptions['approved']) {
2126
+			updateLastMessages($topicOptions['board'], $new_topic || !empty($topicOptions['is_approved']) ? $msgOptions['id'] : 0);
2127
+	}
2030 2128
 
2031 2129
 	// Queue createPost background notification
2032
-	if ($msgOptions['send_notifications'] && $msgOptions['approved'])
2033
-		$smcFunc['db_insert']('',
2130
+	if ($msgOptions['send_notifications'] && $msgOptions['approved']) {
2131
+			$smcFunc['db_insert']('',
2034 2132
 			'{db_prefix}background_tasks',
2035 2133
 			array('task_file' => 'string', 'task_class' => 'string', 'task_data' => 'string', 'claimed_time' => 'int'),
2036 2134
 			array('$sourcedir/tasks/CreatePost-Notify.php', 'CreatePost_Notify_Background', json_encode(array(
@@ -2041,6 +2139,7 @@  discard block
 block discarded – undo
2041 2139
 			)), 0),
2042 2140
 			array('id_task')
2043 2141
 		);
2142
+	}
2044 2143
 
2045 2144
 	// Alright, done now... we can abort now, I guess... at least this much is done.
2046 2145
 	ignore_user_abort($previous_ignore_user_abort);
@@ -2067,14 +2166,18 @@  discard block
 block discarded – undo
2067 2166
 
2068 2167
 	// This is longer than it has to be, but makes it so we only set/change what we have to.
2069 2168
 	$messages_columns = array();
2070
-	if (isset($posterOptions['name']))
2071
-		$messages_columns['poster_name'] = $posterOptions['name'];
2072
-	if (isset($posterOptions['email']))
2073
-		$messages_columns['poster_email'] = $posterOptions['email'];
2074
-	if (isset($msgOptions['icon']))
2075
-		$messages_columns['icon'] = $msgOptions['icon'];
2076
-	if (isset($msgOptions['subject']))
2077
-		$messages_columns['subject'] = $msgOptions['subject'];
2169
+	if (isset($posterOptions['name'])) {
2170
+			$messages_columns['poster_name'] = $posterOptions['name'];
2171
+	}
2172
+	if (isset($posterOptions['email'])) {
2173
+			$messages_columns['poster_email'] = $posterOptions['email'];
2174
+	}
2175
+	if (isset($msgOptions['icon'])) {
2176
+			$messages_columns['icon'] = $msgOptions['icon'];
2177
+	}
2178
+	if (isset($msgOptions['subject'])) {
2179
+			$messages_columns['subject'] = $msgOptions['subject'];
2180
+	}
2078 2181
 	if (isset($msgOptions['body']))
2079 2182
 	{
2080 2183
 		$messages_columns['body'] = $msgOptions['body'];
@@ -2101,8 +2204,9 @@  discard block
 block discarded – undo
2101 2204
 		$messages_columns['modified_reason'] = $msgOptions['modify_reason'];
2102 2205
 		$messages_columns['id_msg_modified'] = $modSettings['maxMsgID'];
2103 2206
 	}
2104
-	if (isset($msgOptions['smileys_enabled']))
2105
-		$messages_columns['smileys_enabled'] = empty($msgOptions['smileys_enabled']) ? 0 : 1;
2207
+	if (isset($msgOptions['smileys_enabled'])) {
2208
+			$messages_columns['smileys_enabled'] = empty($msgOptions['smileys_enabled']) ? 0 : 1;
2209
+	}
2106 2210
 
2107 2211
 	// Which columns need to be ints?
2108 2212
 	$messageInts = array('modified_time', 'id_msg_modified', 'smileys_enabled');
@@ -2120,23 +2224,27 @@  discard block
 block discarded – undo
2120 2224
 		{
2121 2225
 			preg_match_all('/\[member\=([0-9]+)\]([^\[]*)\[\/member\]/U', $msgOptions['old_body'], $match);
2122 2226
 
2123
-			if (isset($match[1]) && isset($match[2]) && is_array($match[1]) && is_array($match[2]))
2124
-				foreach ($match[1] as $i => $oldID)
2227
+			if (isset($match[1]) && isset($match[2]) && is_array($match[1]) && is_array($match[2])) {
2228
+							foreach ($match[1] as $i => $oldID)
2125 2229
 					$oldmentions[$oldID] = array('id' => $oldID, 'real_name' => $match[2][$i]);
2230
+			}
2126 2231
 
2127
-			if (empty($modSettings['search_custom_index_config']))
2128
-				unset($msgOptions['old_body']);
2232
+			if (empty($modSettings['search_custom_index_config'])) {
2233
+							unset($msgOptions['old_body']);
2234
+			}
2129 2235
 		}
2130 2236
 
2131 2237
 		$mentions = Mentions::getMentionedMembers($msgOptions['body']);
2132 2238
 		$messages_columns['body'] = $msgOptions['body'] = Mentions::getBody($msgOptions['body'], $mentions);
2133 2239
 
2134 2240
 		// Remove the poster.
2135
-		if (isset($mentions[$user_info['id']]))
2136
-			unset($mentions[$user_info['id']]);
2241
+		if (isset($mentions[$user_info['id']])) {
2242
+					unset($mentions[$user_info['id']]);
2243
+		}
2137 2244
 
2138
-		if (isset($oldmentions[$user_info['id']]))
2139
-			unset($oldmentions[$user_info['id']]);
2245
+		if (isset($oldmentions[$user_info['id']])) {
2246
+					unset($oldmentions[$user_info['id']]);
2247
+		}
2140 2248
 
2141 2249
 		if (is_array($mentions) && is_array($oldmentions) && count(array_diff_key($mentions, $oldmentions)) > 0 && count($mentions) > count($oldmentions))
2142 2250
 		{
@@ -2166,8 +2274,9 @@  discard block
 block discarded – undo
2166 2274
 	}
2167 2275
 
2168 2276
 	// Nothing to do?
2169
-	if (empty($messages_columns))
2170
-		return true;
2277
+	if (empty($messages_columns)) {
2278
+			return true;
2279
+	}
2171 2280
 
2172 2281
 	// Change the post.
2173 2282
 	$smcFunc['db_query']('', '
@@ -2228,8 +2337,9 @@  discard block
 block discarded – undo
2228 2337
 	// If there's a custom search index, it needs to be modified...
2229 2338
 	require_once($sourcedir . '/Search.php');
2230 2339
 	$searchAPI = findSearchAPI();
2231
-	if (is_callable(array($searchAPI, 'postModified')))
2232
-		$searchAPI->postModified($msgOptions, $topicOptions, $posterOptions);
2340
+	if (is_callable(array($searchAPI, 'postModified'))) {
2341
+			$searchAPI->postModified($msgOptions, $topicOptions, $posterOptions);
2342
+	}
2233 2343
 
2234 2344
 	if (isset($msgOptions['subject']))
2235 2345
 	{
@@ -2243,14 +2353,16 @@  discard block
 block discarded – undo
2243 2353
 				'id_first_msg' => $msgOptions['id'],
2244 2354
 			)
2245 2355
 		);
2246
-		if ($smcFunc['db_num_rows']($request) == 1)
2247
-			updateStats('subject', $topicOptions['id'], $msgOptions['subject']);
2356
+		if ($smcFunc['db_num_rows']($request) == 1) {
2357
+					updateStats('subject', $topicOptions['id'], $msgOptions['subject']);
2358
+		}
2248 2359
 		$smcFunc['db_free_result']($request);
2249 2360
 	}
2250 2361
 
2251 2362
 	// Finally, if we are setting the approved state we need to do much more work :(
2252
-	if ($modSettings['postmod_active'] && isset($msgOptions['approved']))
2253
-		approvePosts($msgOptions['id'], $msgOptions['approved']);
2363
+	if ($modSettings['postmod_active'] && isset($msgOptions['approved'])) {
2364
+			approvePosts($msgOptions['id'], $msgOptions['approved']);
2365
+	}
2254 2366
 
2255 2367
 	return true;
2256 2368
 }
@@ -2267,11 +2379,13 @@  discard block
 block discarded – undo
2267 2379
 {
2268 2380
 	global $smcFunc;
2269 2381
 
2270
-	if (!is_array($msgs))
2271
-		$msgs = array($msgs);
2382
+	if (!is_array($msgs)) {
2383
+			$msgs = array($msgs);
2384
+	}
2272 2385
 
2273
-	if (empty($msgs))
2274
-		return false;
2386
+	if (empty($msgs)) {
2387
+			return false;
2388
+	}
2275 2389
 
2276 2390
 	// May as well start at the beginning, working out *what* we need to change.
2277 2391
 	$request = $smcFunc['db_query']('', '
@@ -2303,20 +2417,22 @@  discard block
 block discarded – undo
2303 2417
 		$topics[] = $row['id_topic'];
2304 2418
 
2305 2419
 		// Ensure our change array exists already.
2306
-		if (!isset($topic_changes[$row['id_topic']]))
2307
-			$topic_changes[$row['id_topic']] = array(
2420
+		if (!isset($topic_changes[$row['id_topic']])) {
2421
+					$topic_changes[$row['id_topic']] = array(
2308 2422
 				'id_last_msg' => $row['id_last_msg'],
2309 2423
 				'approved' => $row['topic_approved'],
2310 2424
 				'replies' => 0,
2311 2425
 				'unapproved_posts' => 0,
2312 2426
 			);
2313
-		if (!isset($board_changes[$row['id_board']]))
2314
-			$board_changes[$row['id_board']] = array(
2427
+		}
2428
+		if (!isset($board_changes[$row['id_board']])) {
2429
+					$board_changes[$row['id_board']] = array(
2315 2430
 				'posts' => 0,
2316 2431
 				'topics' => 0,
2317 2432
 				'unapproved_posts' => 0,
2318 2433
 				'unapproved_topics' => 0,
2319 2434
 			);
2435
+		}
2320 2436
 
2321 2437
 		// If it's the first message then the topic state changes!
2322 2438
 		if ($row['id_msg'] == $row['id_first_msg'])
@@ -2337,14 +2453,13 @@  discard block
 block discarded – undo
2337 2453
 				'poster' => $row['id_member'],
2338 2454
 				'new_topic' => true,
2339 2455
 			);
2340
-		}
2341
-		else
2456
+		} else
2342 2457
 		{
2343 2458
 			$topic_changes[$row['id_topic']]['replies'] += $approve ? 1 : -1;
2344 2459
 
2345 2460
 			// This will be a post... but don't notify unless it's not followed by approved ones.
2346
-			if ($row['id_msg'] > $row['id_last_msg'])
2347
-				$notification_posts[$row['id_topic']] = array(
2461
+			if ($row['id_msg'] > $row['id_last_msg']) {
2462
+							$notification_posts[$row['id_topic']] = array(
2348 2463
 					'id' => $row['id_msg'],
2349 2464
 					'body' => $row['body'],
2350 2465
 					'subject' => $row['subject'],
@@ -2355,28 +2470,33 @@  discard block
 block discarded – undo
2355 2470
 					'new_topic' => false,
2356 2471
 					'msg' => $row['id_msg'],
2357 2472
 				);
2473
+			}
2358 2474
 		}
2359 2475
 
2360 2476
 		// If this is being approved and id_msg is higher than the current id_last_msg then it changes.
2361
-		if ($approve && $row['id_msg'] > $topic_changes[$row['id_topic']]['id_last_msg'])
2362
-			$topic_changes[$row['id_topic']]['id_last_msg'] = $row['id_msg'];
2477
+		if ($approve && $row['id_msg'] > $topic_changes[$row['id_topic']]['id_last_msg']) {
2478
+					$topic_changes[$row['id_topic']]['id_last_msg'] = $row['id_msg'];
2479
+		}
2363 2480
 		// If this is being unapproved, and it's equal to the id_last_msg we need to find a new one!
2364
-		elseif (!$approve)
2365
-			// Default to the first message and then we'll override in a bit ;)
2481
+		elseif (!$approve) {
2482
+					// Default to the first message and then we'll override in a bit ;)
2366 2483
 			$topic_changes[$row['id_topic']]['id_last_msg'] = $row['id_first_msg'];
2484
+		}
2367 2485
 
2368 2486
 		$topic_changes[$row['id_topic']]['unapproved_posts'] += $approve ? -1 : 1;
2369 2487
 		$board_changes[$row['id_board']]['unapproved_posts'] += $approve ? -1 : 1;
2370 2488
 		$board_changes[$row['id_board']]['posts'] += $approve ? 1 : -1;
2371 2489
 
2372 2490
 		// Post count for the user?
2373
-		if ($row['id_member'] && empty($row['count_posts']))
2374
-			$member_post_changes[$row['id_member']] = isset($member_post_changes[$row['id_member']]) ? $member_post_changes[$row['id_member']] + 1 : 1;
2491
+		if ($row['id_member'] && empty($row['count_posts'])) {
2492
+					$member_post_changes[$row['id_member']] = isset($member_post_changes[$row['id_member']]) ? $member_post_changes[$row['id_member']] + 1 : 1;
2493
+		}
2375 2494
 	}
2376 2495
 	$smcFunc['db_free_result']($request);
2377 2496
 
2378
-	if (empty($msgs))
2379
-		return;
2497
+	if (empty($msgs)) {
2498
+			return;
2499
+	}
2380 2500
 
2381 2501
 	// Now we have the differences make the changes, first the easy one.
2382 2502
 	$smcFunc['db_query']('', '
@@ -2403,14 +2523,15 @@  discard block
 block discarded – undo
2403 2523
 				'approved' => 1,
2404 2524
 			)
2405 2525
 		);
2406
-		while ($row = $smcFunc['db_fetch_assoc']($request))
2407
-			$topic_changes[$row['id_topic']]['id_last_msg'] = $row['id_last_msg'];
2526
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
2527
+					$topic_changes[$row['id_topic']]['id_last_msg'] = $row['id_last_msg'];
2528
+		}
2408 2529
 		$smcFunc['db_free_result']($request);
2409 2530
 	}
2410 2531
 
2411 2532
 	// ... next the topics...
2412
-	foreach ($topic_changes as $id => $changes)
2413
-		$smcFunc['db_query']('', '
2533
+	foreach ($topic_changes as $id => $changes) {
2534
+			$smcFunc['db_query']('', '
2414 2535
 			UPDATE {db_prefix}topics
2415 2536
 			SET approved = {int:approved}, unapproved_posts = unapproved_posts + {int:unapproved_posts},
2416 2537
 				num_replies = num_replies + {int:num_replies}, id_last_msg = {int:id_last_msg}
@@ -2423,10 +2544,11 @@  discard block
 block discarded – undo
2423 2544
 				'id_topic' => $id,
2424 2545
 			)
2425 2546
 		);
2547
+	}
2426 2548
 
2427 2549
 	// ... finally the boards...
2428
-	foreach ($board_changes as $id => $changes)
2429
-		$smcFunc['db_query']('', '
2550
+	foreach ($board_changes as $id => $changes) {
2551
+			$smcFunc['db_query']('', '
2430 2552
 			UPDATE {db_prefix}boards
2431 2553
 			SET num_posts = num_posts + {int:num_posts}, unapproved_posts = unapproved_posts + {int:unapproved_posts},
2432 2554
 				num_topics = num_topics + {int:num_topics}, unapproved_topics = unapproved_topics + {int:unapproved_topics}
@@ -2439,13 +2561,14 @@  discard block
 block discarded – undo
2439 2561
 				'id_board' => $id,
2440 2562
 			)
2441 2563
 		);
2564
+	}
2442 2565
 
2443 2566
 	// Finally, least importantly, notifications!
2444 2567
 	if ($approve)
2445 2568
 	{
2446 2569
 		$task_rows = array();
2447
-		foreach (array_merge($notification_topics, $notification_posts) as $topic)
2448
-			$task_rows[] = array(
2570
+		foreach (array_merge($notification_topics, $notification_posts) as $topic) {
2571
+					$task_rows[] = array(
2449 2572
 				'$sourcedir/tasks/CreatePost-Notify.php', 'CreatePost_Notify_Background', json_encode(array(
2450 2573
 					'msgOptions' => array(
2451 2574
 						'id' => $topic['msg'],
@@ -2463,14 +2586,16 @@  discard block
 block discarded – undo
2463 2586
 					'type' => $topic['new_topic'] ? 'topic' : 'reply',
2464 2587
 				)), 0
2465 2588
 			);
2589
+		}
2466 2590
 
2467
-		if ($notify)
2468
-			$smcFunc['db_insert']('',
2591
+		if ($notify) {
2592
+					$smcFunc['db_insert']('',
2469 2593
 				'{db_prefix}background_tasks',
2470 2594
 				array('task_file' => 'string', 'task_class' => 'string', 'task_data' => 'string', 'claimed_time' => 'int'),
2471 2595
 				$task_rows,
2472 2596
 				array('id_task')
2473 2597
 			);
2598
+		}
2474 2599
 
2475 2600
 		$smcFunc['db_query']('', '
2476 2601
 			DELETE FROM {db_prefix}approval_queue
@@ -2486,8 +2611,9 @@  discard block
 block discarded – undo
2486 2611
 	else
2487 2612
 	{
2488 2613
 		$msgInserts = array();
2489
-		foreach ($msgs as $msg)
2490
-			$msgInserts[] = array($msg);
2614
+		foreach ($msgs as $msg) {
2615
+					$msgInserts[] = array($msg);
2616
+		}
2491 2617
 
2492 2618
 		$smcFunc['db_insert']('ignore',
2493 2619
 			'{db_prefix}approval_queue',
@@ -2501,9 +2627,10 @@  discard block
 block discarded – undo
2501 2627
 	updateLastMessages(array_keys($board_changes));
2502 2628
 
2503 2629
 	// Post count for the members?
2504
-	if (!empty($member_post_changes))
2505
-		foreach ($member_post_changes as $id_member => $count_change)
2630
+	if (!empty($member_post_changes)) {
2631
+			foreach ($member_post_changes as $id_member => $count_change)
2506 2632
 			updateMemberData($id_member, array('posts' => 'posts ' . ($approve ? '+' : '-') . ' ' . $count_change));
2633
+	}
2507 2634
 
2508 2635
 	return true;
2509 2636
 }
@@ -2520,11 +2647,13 @@  discard block
 block discarded – undo
2520 2647
 {
2521 2648
 	global $smcFunc;
2522 2649
 
2523
-	if (!is_array($topics))
2524
-		$topics = array($topics);
2650
+	if (!is_array($topics)) {
2651
+			$topics = array($topics);
2652
+	}
2525 2653
 
2526
-	if (empty($topics))
2527
-		return false;
2654
+	if (empty($topics)) {
2655
+			return false;
2656
+	}
2528 2657
 
2529 2658
 	$approve_type = $approve ? 0 : 1;
2530 2659
 
@@ -2540,8 +2669,9 @@  discard block
 block discarded – undo
2540 2669
 		)
2541 2670
 	);
2542 2671
 	$msgs = array();
2543
-	while ($row = $smcFunc['db_fetch_assoc']($request))
2544
-		$msgs[] = $row['id_msg'];
2672
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
2673
+			$msgs[] = $row['id_msg'];
2674
+	}
2545 2675
 	$smcFunc['db_free_result']($request);
2546 2676
 
2547 2677
 	return approvePosts($msgs, $approve);
@@ -2564,11 +2694,13 @@  discard block
 block discarded – undo
2564 2694
 	global $board_info, $board, $smcFunc;
2565 2695
 
2566 2696
 	// Please - let's be sane.
2567
-	if (empty($setboards))
2568
-		return false;
2697
+	if (empty($setboards)) {
2698
+			return false;
2699
+	}
2569 2700
 
2570
-	if (!is_array($setboards))
2571
-		$setboards = array($setboards);
2701
+	if (!is_array($setboards)) {
2702
+			$setboards = array($setboards);
2703
+	}
2572 2704
 
2573 2705
 	// If we don't know the id_msg we need to find it.
2574 2706
 	if (!$id_msg)
@@ -2586,15 +2718,16 @@  discard block
 block discarded – undo
2586 2718
 			)
2587 2719
 		);
2588 2720
 		$lastMsg = array();
2589
-		while ($row = $smcFunc['db_fetch_assoc']($request))
2590
-			$lastMsg[$row['id_board']] = $row['id_msg'];
2721
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
2722
+					$lastMsg[$row['id_board']] = $row['id_msg'];
2723
+		}
2591 2724
 		$smcFunc['db_free_result']($request);
2592
-	}
2593
-	else
2725
+	} else
2594 2726
 	{
2595 2727
 		// Just to note - there should only be one board passed if we are doing this.
2596
-		foreach ($setboards as $id_board)
2597
-			$lastMsg[$id_board] = $id_msg;
2728
+		foreach ($setboards as $id_board) {
2729
+					$lastMsg[$id_board] = $id_msg;
2730
+		}
2598 2731
 	}
2599 2732
 
2600 2733
 	$parent_boards = array();
@@ -2609,10 +2742,11 @@  discard block
 block discarded – undo
2609 2742
 			$lastModified[$id_board] = 0;
2610 2743
 		}
2611 2744
 
2612
-		if (!empty($board) && $id_board == $board)
2613
-			$parents = $board_info['parent_boards'];
2614
-		else
2615
-			$parents = getBoardParents($id_board);
2745
+		if (!empty($board) && $id_board == $board) {
2746
+					$parents = $board_info['parent_boards'];
2747
+		} else {
2748
+					$parents = getBoardParents($id_board);
2749
+		}
2616 2750
 
2617 2751
 		// Ignore any parents on the top child level.
2618 2752
 		// @todo Why?
@@ -2621,10 +2755,11 @@  discard block
 block discarded – undo
2621 2755
 			if ($parent['level'] != 0)
2622 2756
 			{
2623 2757
 				// If we're already doing this one as a board, is this a higher last modified?
2624
-				if (isset($lastModified[$id]) && $lastModified[$id_board] > $lastModified[$id])
2625
-					$lastModified[$id] = $lastModified[$id_board];
2626
-				elseif (!isset($lastModified[$id]) && (!isset($parent_boards[$id]) || $parent_boards[$id] < $lastModified[$id_board]))
2627
-					$parent_boards[$id] = $lastModified[$id_board];
2758
+				if (isset($lastModified[$id]) && $lastModified[$id_board] > $lastModified[$id]) {
2759
+									$lastModified[$id] = $lastModified[$id_board];
2760
+				} elseif (!isset($lastModified[$id]) && (!isset($parent_boards[$id]) || $parent_boards[$id] < $lastModified[$id_board])) {
2761
+									$parent_boards[$id] = $lastModified[$id_board];
2762
+				}
2628 2763
 			}
2629 2764
 		}
2630 2765
 	}
@@ -2637,23 +2772,24 @@  discard block
 block discarded – undo
2637 2772
 	// Finally, to save on queries make the changes...
2638 2773
 	foreach ($parent_boards as $id => $msg)
2639 2774
 	{
2640
-		if (!isset($parent_updates[$msg]))
2641
-			$parent_updates[$msg] = array($id);
2642
-		else
2643
-			$parent_updates[$msg][] = $id;
2775
+		if (!isset($parent_updates[$msg])) {
2776
+					$parent_updates[$msg] = array($id);
2777
+		} else {
2778
+					$parent_updates[$msg][] = $id;
2779
+		}
2644 2780
 	}
2645 2781
 
2646 2782
 	foreach ($lastMsg as $id => $msg)
2647 2783
 	{
2648
-		if (!isset($board_updates[$msg . '-' . $lastModified[$id]]))
2649
-			$board_updates[$msg . '-' . $lastModified[$id]] = array(
2784
+		if (!isset($board_updates[$msg . '-' . $lastModified[$id]])) {
2785
+					$board_updates[$msg . '-' . $lastModified[$id]] = array(
2650 2786
 				'id' => $msg,
2651 2787
 				'updated' => $lastModified[$id],
2652 2788
 				'boards' => array($id)
2653 2789
 			);
2654
-
2655
-		else
2656
-			$board_updates[$msg . '-' . $lastModified[$id]]['boards'][] = $id;
2790
+		} else {
2791
+					$board_updates[$msg . '-' . $lastModified[$id]]['boards'][] = $id;
2792
+		}
2657 2793
 	}
2658 2794
 
2659 2795
 	// Now commit the changes!
@@ -2745,11 +2881,13 @@  discard block
 block discarded – undo
2745 2881
 	global $txt, $mbname, $scripturl, $settings;
2746 2882
 
2747 2883
 	// First things first, load up the email templates language file, if we need to.
2748
-	if ($loadLang)
2749
-		loadLanguage('EmailTemplates', $lang);
2884
+	if ($loadLang) {
2885
+			loadLanguage('EmailTemplates', $lang);
2886
+	}
2750 2887
 
2751
-	if (!isset($txt[$template . '_subject']) || !isset($txt[$template . '_body']))
2752
-		fatal_lang_error('email_no_template', 'template', array($template));
2888
+	if (!isset($txt[$template . '_subject']) || !isset($txt[$template . '_body'])) {
2889
+			fatal_lang_error('email_no_template', 'template', array($template));
2890
+	}
2753 2891
 
2754 2892
 	$ret = array(
2755 2893
 		'subject' => $txt[$template . '_subject'],
@@ -2799,17 +2937,18 @@  discard block
 block discarded – undo
2799 2937
 function user_info_callback($matches)
2800 2938
 {
2801 2939
 	global $user_info;
2802
-	if (empty($matches[1]))
2803
-		return '';
2940
+	if (empty($matches[1])) {
2941
+			return '';
2942
+	}
2804 2943
 
2805 2944
 	$use_ref = true;
2806 2945
 	$ref = &$user_info;
2807 2946
 
2808 2947
 	foreach (explode('.', $matches[1]) as $index)
2809 2948
 	{
2810
-		if ($use_ref && isset($ref[$index]))
2811
-			$ref = &$ref[$index];
2812
-		else
2949
+		if ($use_ref && isset($ref[$index])) {
2950
+					$ref = &$ref[$index];
2951
+		} else
2813 2952
 		{
2814 2953
 			$use_ref = false;
2815 2954
 			break;
@@ -2846,8 +2985,7 @@  discard block
 block discarded – undo
2846 2985
 		if (!empty($lang_locale) && enchant_broker_dict_exists($context['enchant_broker'], $lang_locale))
2847 2986
 		{
2848 2987
 			$enchant_link = enchant_broker_request_dict($context['enchant_broker'], $lang_locale);
2849
-		}
2850
-		elseif (enchant_broker_dict_exists($context['enchant_broker'], $txt['lang_dictionary']))
2988
+		} elseif (enchant_broker_dict_exists($context['enchant_broker'], $txt['lang_dictionary']))
2851 2989
 		{
2852 2990
 			$enchant_link = enchant_broker_request_dict($context['enchant_broker'], $txt['lang_dictionary']);
2853 2991
 		}
@@ -2857,8 +2995,7 @@  discard block
 block discarded – undo
2857 2995
 		{
2858 2996
 			$context['provider'] = 'enchant';
2859 2997
 			return $enchant_link;
2860
-		}
2861
-		else
2998
+		} else
2862 2999
 		{
2863 3000
 			// Free up any resources used...
2864 3001
 			@enchant_broker_free($context['enchant_broker']);
@@ -2879,8 +3016,9 @@  discard block
 block discarded – undo
2879 3016
 		$pspell_link = pspell_new($txt['lang_dictionary'], $txt['lang_spelling'], '', strtr($context['character_set'], array('iso-' => 'iso', 'ISO-' => 'iso')), PSPELL_FAST | PSPELL_RUN_TOGETHER);
2880 3017
 
2881 3018
 		// Most people don't have anything but English installed... So we use English as a last resort.
2882
-		if (!$pspell_link)
2883
-			$pspell_link = pspell_new('en', '', '', '', PSPELL_FAST | PSPELL_RUN_TOGETHER);
3019
+		if (!$pspell_link) {
3020
+					$pspell_link = pspell_new('en', '', '', '', PSPELL_FAST | PSPELL_RUN_TOGETHER);
3021
+		}
2884 3022
 
2885 3023
 		error_reporting($old);
2886 3024
 		ob_end_clean();
@@ -2920,8 +3058,7 @@  discard block
 block discarded – undo
2920 3058
 			$word = iconv($txt['lang_character_set'], 'UTF-8', $word);
2921 3059
 		}
2922 3060
 		return enchant_dict_check($dict, $word);
2923
-	}
2924
-	elseif ($context['provider'] == 'pspell')
3061
+	} elseif ($context['provider'] == 'pspell')
2925 3062
 	{
2926 3063
 		return pspell_check($dict, $word);
2927 3064
 	}
@@ -2957,13 +3094,11 @@  discard block
 block discarded – undo
2957 3094
 			}
2958 3095
 
2959 3096
 			return $suggestions;
2960
-		}
2961
-		else
3097
+		} else
2962 3098
 		{
2963 3099
 			return enchant_dict_suggest($dict, $word);
2964 3100
 		}
2965
-	}
2966
-	elseif ($context['provider'] == 'pspell')
3101
+	} elseif ($context['provider'] == 'pspell')
2967 3102
 	{
2968 3103
 		return pspell_suggest($dict, $word);
2969 3104
 	}
Please login to merge, or discard this patch.
Sources/Subs-ReportedContent.php 4 patches
Doc Comments   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -566,7 +566,7 @@  discard block
 block discarded – undo
566 566
  *
567 567
  * @param int $report_id The report ID is used to fire a notification about the event.
568 568
  * @param array $data a formatted array of data to be inserted. Should be already properly sanitized.
569
- * @return bool  Boolean false if no data was provided.
569
+ * @return false|null  Boolean false if no data was provided.
570 570
  */
571 571
 function saveModComment($report_id, $data)
572 572
 {
@@ -632,8 +632,8 @@  discard block
 block discarded – undo
632 632
  * Saves the new information whenever a moderator comment is edited.
633 633
  *
634 634
  * @param int $comment_id The edited moderator comment ID.
635
- * @param array $data The new data to de inserted. Should be already properly sanitized.
636
- * @return bool  Boolean false if no data or no comment ID was provided.
635
+ * @param string $edited_comment
636
+ * @return false|null  Boolean false if no data or no comment ID was provided.
637 637
  */
638 638
 function editModComment($comment_id, $edited_comment)
639 639
 {
@@ -657,7 +657,7 @@  discard block
 block discarded – undo
657 657
  * Deletes a moderator comment from the DB.
658 658
  *
659 659
  * @param int $comment_id The moderator comment ID used to identify which report will be deleted.
660
- * @return bool  Boolean false if no data was provided.
660
+ * @return false|null  Boolean false if no data was provided.
661 661
  */
662 662
 function deleteModComment($comment_id)
663 663
 {
Please login to merge, or discard this patch.
Indentation   -1 removed lines patch added patch discarded remove patch
@@ -130,7 +130,6 @@
 block discarded – undo
130 130
  *
131 131
  * @param int $closed 1 for counting closed reports, 0 for open ones.
132 132
  * @return integer How many reports.
133
-
134 133
  */
135 134
 function countReports($closed = 0)
136 135
 {
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 	$smcFunc['db_query']('', '
50 50
 		UPDATE {db_prefix}log_reported
51 51
 		SET  {raw:action} = {string:value}
52
-		'. (is_array($report_id) ? 'WHERE id_report IN ({array_int:id_report})' : 'WHERE id_report = {int:id_report}') .'
52
+		'. (is_array($report_id) ? 'WHERE id_report IN ({array_int:id_report})' : 'WHERE id_report = {int:id_report}') . '
53 53
 			' . $board_query,
54 54
 		array(
55 55
 			'action' => $action,
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 			)
98 98
 		);
99 99
 
100
-		while($row = $smcFunc['db_fetch_assoc']($request))
100
+		while ($row = $smcFunc['db_fetch_assoc']($request))
101 101
 			$extra[$row['id_report']] = array(
102 102
 				'report' => $row['id_report'],
103 103
 				'member' => $row['id_member'],
Please login to merge, or discard this patch.
Braces   +70 added lines, -58 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
  * Updates a report with the given parameters. Logs each action via logAction()
@@ -28,19 +29,20 @@  discard block
 block discarded – undo
28 29
 	global $smcFunc, $user_info, $context;
29 30
 
30 31
 	// Don't bother.
31
-	if (empty($action) || empty($report_id))
32
-		return false;
32
+	if (empty($action) || empty($report_id)) {
33
+			return false;
34
+	}
33 35
 
34 36
 	// Add the "_all" thingy.
35
-	if ($action == 'ignore')
36
-		$action = 'ignore_all';
37
+	if ($action == 'ignore') {
38
+			$action = 'ignore_all';
39
+	}
37 40
 
38 41
 	// We don't need the board query for reported members
39 42
 	if ($context['report_type'] == 'members')
40 43
 	{
41 44
 		$board_query = '';
42
-	}
43
-	else
45
+	} else
44 46
 	{
45 47
 		$board_query = ' AND ' . $user_info['mod_cache']['bq'];
46 48
 	}
@@ -76,17 +78,17 @@  discard block
 block discarded – undo
76 78
 			)
77 79
 		);
78 80
 
79
-		while ($row = $smcFunc['db_fetch_assoc']($request))
80
-			$extra[$row['id_report']] = array(
81
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
82
+					$extra[$row['id_report']] = array(
81 83
 				'report' => $row['id_report'],
82 84
 				'board' => $row['id_board'],
83 85
 				'message' => $row['id_msg'],
84 86
 				'topic' => $row['id_topic'],
85 87
 			);
88
+		}
86 89
 
87 90
 		$smcFunc['db_free_result']($request);
88
-	}
89
-	else
91
+	} else
90 92
 	{
91 93
 		$request = $smcFunc['db_query']('', '
92 94
 			SELECT id_report, id_member, membername
@@ -97,28 +99,32 @@  discard block
 block discarded – undo
97 99
 			)
98 100
 		);
99 101
 
100
-		while($row = $smcFunc['db_fetch_assoc']($request))
101
-			$extra[$row['id_report']] = array(
102
+		while($row = $smcFunc['db_fetch_assoc']($request)) {
103
+					$extra[$row['id_report']] = array(
102 104
 				'report' => $row['id_report'],
103 105
 				'member' => $row['id_member'],
104 106
 			);
107
+		}
105 108
 
106 109
 		$smcFunc['db_free_result']($request);
107 110
 	}
108 111
 
109 112
 	// Back to "ignore".
110
-	if ($action == 'ignore_all')
111
-		$action = 'ignore';
113
+	if ($action == 'ignore_all') {
114
+			$action = 'ignore';
115
+	}
112 116
 
113 117
 	$log_report = $action == 'ignore' ? (!empty($value) ? 'ignore' : 'unignore') : (!empty($value) ? 'close' : 'open');
114 118
 
115
-	if ($context['report_type'] == 'members')
116
-		$log_report .= '_user';
119
+	if ($context['report_type'] == 'members') {
120
+			$log_report .= '_user';
121
+	}
117 122
 
118 123
 	// Log this action.
119
-	if (!empty($extra))
120
-		foreach ($extra as $report)
124
+	if (!empty($extra)) {
125
+			foreach ($extra as $report)
121 126
 			logAction($log_report . '_report', $report);
127
+	}
122 128
 
123 129
 	// Time to update.
124 130
 	updateSettings(array('last_mod_report_action' => time()));
@@ -140,14 +146,12 @@  discard block
 block discarded – undo
140 146
 	if ($context['report_type'] == 'members')
141 147
 	{
142 148
 		$and = 'lr.id_board = 0';
143
-	}
144
-	else
149
+	} else
145 150
 	{
146 151
 		if ($user_info['mod_cache']['bq'] == '1=1' || $user_info['mod_cache']['bq'] == '0=1')
147 152
 		{
148 153
 			$bq = $user_info['mod_cache']['bq'];
149
-		}
150
-		else
154
+		} else
151 155
 		{
152 156
 			$bq = 'lr.' . $user_info['mod_cache']['bq'];
153 157
 		}
@@ -203,8 +207,7 @@  discard block
 block discarded – undo
203 207
 				'max' => 10,
204 208
 			)
205 209
 		);
206
-	}
207
-	else
210
+	} else
208 211
 	{
209 212
 		$request = $smcFunc['db_query']('', '
210 213
 			SELECT lr.id_report, lr.id_msg, lr.id_topic, lr.id_board, lr.id_member, lr.subject, lr.body,
@@ -252,8 +255,7 @@  discard block
 block discarded – undo
252 255
 					'href' => $scripturl . '?action=profile;u=' . $row['id_user'],
253 256
 				),
254 257
 			);
255
-		}
256
-		else
258
+		} else
257 259
 		{
258 260
 			$report_boards_ids[] = $row['id_board'];
259 261
 			$extraDetails = array(
@@ -293,14 +295,16 @@  discard block
 block discarded – undo
293 295
 			)
294 296
 		);
295 297
 
296
-		while ($row = $smcFunc['db_fetch_assoc']($request))
297
-			$board_names[$row['id_board']] = $row['name'];
298
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
299
+					$board_names[$row['id_board']] = $row['name'];
300
+		}
298 301
 
299 302
 		$smcFunc['db_free_result']($request);
300 303
 
301
-		foreach ($reports as $id_report => $report)
302
-			if (!empty($board_names[$report['topic']['id_board']]))
304
+		foreach ($reports as $id_report => $report) {
305
+					if (!empty($board_names[$report['topic']['id_board']]))
303 306
 				$reports[$id_report]['topic']['board_name'] = $board_names[$report['topic']['id_board']];
307
+		}
304 308
 	}
305 309
 
306 310
 	// Now get all the people who reported it.
@@ -350,10 +354,11 @@  discard block
 block discarded – undo
350 354
 {
351 355
 	global $user_info, $smcFunc;
352 356
 
353
-	if ($type == 'members')
354
-		$bq = '';
355
-	else
356
-		$bq = '	AND ' . $user_info['mod_cache']['bq'];
357
+	if ($type == 'members') {
358
+			$bq = '';
359
+	} else {
360
+			$bq = '	AND ' . $user_info['mod_cache']['bq'];
361
+	}
357 362
 
358 363
 	$request = $smcFunc['db_query']('', '
359 364
 		SELECT COUNT(*)
@@ -392,8 +397,9 @@  discard block
 block discarded – undo
392 397
 {
393 398
 	global $smcFunc, $user_info, $context;
394 399
 
395
-	if (empty($report_id))
396
-		return false;
400
+	if (empty($report_id)) {
401
+			return false;
402
+	}
397 403
 
398 404
 	// We don't need all this info if we're only getting user info
399 405
 	if ($context['report_type'] == 'members')
@@ -411,8 +417,7 @@  discard block
 block discarded – undo
411 417
 				'id_report' => $report_id,
412 418
 			)
413 419
 		);
414
-	}
415
-	else
420
+	} else
416 421
 	{
417 422
 		// Get the report details, need this so we can limit access to a particular board.
418 423
 		$request = $smcFunc['db_query']('', '
@@ -431,8 +436,9 @@  discard block
 block discarded – undo
431 436
 	}
432 437
 
433 438
 	// So did we find anything?
434
-	if (!$smcFunc['db_num_rows']($request))
435
-		return false;
439
+	if (!$smcFunc['db_num_rows']($request)) {
440
+			return false;
441
+	}
436 442
 
437 443
 	// Woohoo we found a report and they can see it!
438 444
 	$row = $smcFunc['db_fetch_assoc']($request);
@@ -451,8 +457,9 @@  discard block
 block discarded – undo
451 457
 {
452 458
 	global $smcFunc, $scripturl, $user_info, $txt;
453 459
 
454
-	if (empty($report_id))
455
-		return false;
460
+	if (empty($report_id)) {
461
+			return false;
462
+	}
456 463
 
457 464
 	$report = array(
458 465
 		'comments' => array(),
@@ -533,8 +540,9 @@  discard block
 block discarded – undo
533 540
 {
534 541
 	global $smcFunc, $user_info;
535 542
 
536
-	if (empty($comment_id))
537
-		return false;
543
+	if (empty($comment_id)) {
544
+			return false;
545
+	}
538 546
 
539 547
 	$request = $smcFunc['db_query']('', '
540 548
 		SELECT id_comment, id_notice, log_time, body, id_member
@@ -551,8 +559,9 @@  discard block
 block discarded – undo
551 559
 	$smcFunc['db_free_result']($request);
552 560
 
553 561
 	// Add the permission
554
-	if (!empty($comment))
555
-		$comment['can_edit'] = allowedTo('admin_forum') || (($user_info['id'] == $comment['id_member']));
562
+	if (!empty($comment)) {
563
+			$comment['can_edit'] = allowedTo('admin_forum') || (($user_info['id'] == $comment['id_member']));
564
+	}
556 565
 
557 566
 	return $comment;
558 567
 }
@@ -568,8 +577,9 @@  discard block
 block discarded – undo
568 577
 {
569 578
 	global $smcFunc, $user_info, $context;
570 579
 
571
-	if (empty($data))
572
-		return false;
580
+	if (empty($data)) {
581
+			return false;
582
+	}
573 583
 
574 584
 	$data = array_merge(array($user_info['id'], $user_info['name'], 'reportc', ''), $data);
575 585
 
@@ -598,8 +608,7 @@  discard block
 block discarded – undo
598 608
 			'comment_id' => $last_comment,
599 609
 			'time' => time(),
600 610
 		);
601
-	}
602
-	else
611
+	} else
603 612
 	{
604 613
 		$prefix = 'Msg';
605 614
 		$data = array(
@@ -615,14 +624,15 @@  discard block
 block discarded – undo
615 624
 	}
616 625
 
617 626
 	// And get ready to notify people.
618
-	if (!empty($report))
619
-		$smcFunc['db_insert']('insert',
627
+	if (!empty($report)) {
628
+			$smcFunc['db_insert']('insert',
620 629
 			'{db_prefix}background_tasks',
621 630
 			array('task_file' => 'string', 'task_class' => 'string', 'task_data' => 'string', 'claimed_time' => 'int'),
622 631
 			array('$sourcedir/tasks/' . $prefix . 'ReportReply-Notify.php', $prefix . 'ReportReply_Notify_Background', json_encode($data), 0),
623 632
 			array('id_task')
624 633
 		);
625
-}
634
+	}
635
+	}
626 636
 
627 637
 /**
628 638
  * Saves the new information whenever a moderator comment is edited.
@@ -635,8 +645,9 @@  discard block
 block discarded – undo
635 645
 {
636 646
 	global $smcFunc;
637 647
 
638
-	if (empty($comment_id) || empty($edited_comment))
639
-		return false;
648
+	if (empty($comment_id) || empty($edited_comment)) {
649
+			return false;
650
+	}
640 651
 
641 652
 	$smcFunc['db_query']('', '
642 653
 		UPDATE {db_prefix}log_comments
@@ -659,8 +670,9 @@  discard block
 block discarded – undo
659 670
 {
660 671
 	global $smcFunc;
661 672
 
662
-	if (empty($comment_id))
663
-		return false;
673
+	if (empty($comment_id)) {
674
+			return false;
675
+	}
664 676
 
665 677
 	$smcFunc['db_query']('', '
666 678
 		DELETE FROM {db_prefix}log_comments
Please login to merge, or discard this patch.
Sources/Subs-Sound.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@
 block discarded – undo
24 24
  * Used by VerificationCode() (Register.php).
25 25
  *
26 26
  * @param string $word
27
- * @return boolean false on failure
27
+ * @return null|false false on failure
28 28
  */
29 29
 
30 30
 function createWaveFile($word)
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@
 block discarded – undo
38 38
 	cache_put_data('wave_file/' . $user_info['ip2'], $ip2 ? $ip2 + 1 : 1, 20);
39 39
 
40 40
 	// Fixate randomization for this word.
41
-    $tmp = unpack('n', md5($word . session_id()));
41
+	$tmp = unpack('n', md5($word . session_id()));
42 42
 	mt_srand(end($tmp));
43 43
 
44 44
 	// Try to see if there's a sound font in the user's language.
Please login to merge, or discard this patch.
Braces   +32 added lines, -20 removed lines patch added patch discarded remove patch
@@ -15,8 +15,9 @@  discard block
 block discarded – undo
15 15
  * @version 2.1 Beta 4
16 16
  */
17 17
 
18
-if (!defined('SMF'))
18
+if (!defined('SMF')) {
19 19
 	die('No direct access...');
20
+}
20 21
 
21 22
 /**
22 23
  * Creates a wave file that spells the letters of $word.
@@ -32,8 +33,9 @@  discard block
 block discarded – undo
32 33
 	global $settings, $user_info;
33 34
 
34 35
 	// Allow max 2 requests per 20 seconds.
35
-	if (($ip = cache_get_data('wave_file/' . $user_info['ip'], 20)) > 2 || ($ip2 = cache_get_data('wave_file/' . $user_info['ip2'], 20)) > 2)
36
-		die(header('HTTP/1.1 400 Bad Request'));
36
+	if (($ip = cache_get_data('wave_file/' . $user_info['ip'], 20)) > 2 || ($ip2 = cache_get_data('wave_file/' . $user_info['ip2'], 20)) > 2) {
37
+			die(header('HTTP/1.1 400 Bad Request'));
38
+	}
37 39
 	cache_put_data('wave_file/' . $user_info['ip'], $ip ? $ip + 1 : 1, 20);
38 40
 	cache_put_data('wave_file/' . $user_info['ip2'], $ip2 ? $ip2 + 1 : 1, 20);
39 41
 
@@ -42,16 +44,19 @@  discard block
 block discarded – undo
42 44
 	mt_srand(end($tmp));
43 45
 
44 46
 	// Try to see if there's a sound font in the user's language.
45
-	if (file_exists($settings['default_theme_dir'] . '/fonts/sound/a.' . $user_info['language'] . '.wav'))
46
-		$sound_language = $user_info['language'];
47
+	if (file_exists($settings['default_theme_dir'] . '/fonts/sound/a.' . $user_info['language'] . '.wav')) {
48
+			$sound_language = $user_info['language'];
49
+	}
47 50
 
48 51
 	// English should be there.
49
-	elseif (file_exists($settings['default_theme_dir'] . '/fonts/sound/a.english.wav'))
50
-		$sound_language = 'english';
52
+	elseif (file_exists($settings['default_theme_dir'] . '/fonts/sound/a.english.wav')) {
53
+			$sound_language = 'english';
54
+	}
51 55
 
52 56
 	// Guess not...
53
-	else
54
-		return false;
57
+	else {
58
+			return false;
59
+	}
55 60
 
56 61
 	// File names are in lower case so lets make sure that we are only using a lower case string
57 62
 	$word = strtolower($word);
@@ -61,20 +66,25 @@  discard block
 block discarded – undo
61 66
 	for ($i = 0; $i < strlen($word); $i++)
62 67
 	{
63 68
 		$sound_letter = implode('', file($settings['default_theme_dir'] . '/fonts/sound/' . $word{$i} . '.' . $sound_language . '.wav'));
64
-		if (strpos($sound_letter, 'data') === false)
65
-			return false;
69
+		if (strpos($sound_letter, 'data') === false) {
70
+					return false;
71
+		}
66 72
 
67 73
 		$sound_letter = substr($sound_letter, strpos($sound_letter, 'data') + 8);
68 74
 		switch ($word{$i} === 's' ? 0 : mt_rand(0, 2))
69 75
 		{
70
-			case 0 : for ($j = 0, $n = strlen($sound_letter); $j < $n; $j++)
71
-					for ($k = 0, $m = round(mt_rand(15, 25) / 10); $k < $m; $k++)
72
-						$sound_word .= $word{$i} === 's' ? $sound_letter{$j} : chr(mt_rand(max(ord($sound_letter{$j}) - 1, 0x00), min(ord($sound_letter{$j}) + 1, 0xFF)));
76
+			case 0 : for ($j = 0, $n = strlen($sound_letter); $j < $n; $j++) {
77
+								for ($k = 0, $m = round(mt_rand(15, 25) / 10);
78
+			}
79
+			$k < $m; $k++) {
80
+											$sound_word .= $word{$i} === 's' ? $sound_letter{$j} : chr(mt_rand(max(ord($sound_letter{$j}) - 1, 0x00), min(ord($sound_letter{$j}) + 1, 0xFF)));
81
+					}
73 82
 			break;
74 83
 
75 84
 			case 1:
76
-				for ($j = 0, $n = strlen($sound_letter) - 1; $j < $n; $j += 2)
77
-					$sound_word .= (mt_rand(0, 3) == 0 ? '' : $sound_letter{$j}) . (mt_rand(0, 3) === 0 ? $sound_letter{$j + 1} : $sound_letter{$j}) . (mt_rand(0, 3) === 0 ? $sound_letter{$j} : $sound_letter{$j + 1}) . $sound_letter{$j + 1} . (mt_rand(0, 3) == 0 ? $sound_letter{$j + 1} : '');
85
+				for ($j = 0, $n = strlen($sound_letter) - 1; $j < $n; $j += 2) {
86
+									$sound_word .= (mt_rand(0, 3) == 0 ? '' : $sound_letter{$j}) . (mt_rand(0, 3) === 0 ? $sound_letter{$j + 1} : $sound_letter{$j}) . (mt_rand(0, 3) === 0 ? $sound_letter{$j} : $sound_letter{$j + 1}) . $sound_letter{$j + 1} . (mt_rand(0, 3) == 0 ? $sound_letter{$j + 1} : '');
87
+				}
78 88
 				$sound_word .= str_repeat($sound_letter{$n}, 2);
79 89
 			break;
80 90
 
@@ -82,10 +92,12 @@  discard block
 block discarded – undo
82 92
 				$shift = 0;
83 93
 				for ($j = 0, $n = strlen($sound_letter); $j < $n; $j++)
84 94
 				{
85
-					if (mt_rand(0, 10) === 0)
86
-						$shift += mt_rand(-3, 3);
87
-					for ($k = 0, $m = round(mt_rand(15, 25) / 10); $k < $m; $k++)
88
-						$sound_word .= chr(min(max(ord($sound_letter{$j}) + $shift, 0x00), 0xFF));
95
+					if (mt_rand(0, 10) === 0) {
96
+											$shift += mt_rand(-3, 3);
97
+					}
98
+					for ($k = 0, $m = round(mt_rand(15, 25) / 10); $k < $m; $k++) {
99
+											$sound_word .= chr(min(max(ord($sound_letter{$j}) + $shift, 0x00), 0xFF));
100
+					}
89 101
 				}
90 102
 			break;
91 103
 
Please login to merge, or discard this patch.
Sources/Subs-Themes.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -425,7 +425,7 @@
 block discarded – undo
425 425
  *
426 426
  * This is a recursive function, it will call itself if there are subdirs inside the main directory.
427 427
  * @param string $path The absolute path to the directory to be removed
428
- * @return bool true when success, false on error.
428
+ * @return false|null true when success, false on error.
429 429
  */
430 430
 function remove_dir($path)
431 431
 {
Please login to merge, or discard this patch.
Braces   +67 added lines, -46 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 4
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 /**
20 21
  * Gets a single theme's info.
@@ -27,8 +28,9 @@  discard block
 block discarded – undo
27 28
 	global $smcFunc, $modSettings;
28 29
 
29 30
 	// No data, no fun!
30
-	if (empty($id))
31
-		return false;
31
+	if (empty($id)) {
32
+			return false;
33
+	}
32 34
 
33 35
 	// Make sure $id is an int.
34 36
 	$id = (int) $id;
@@ -171,8 +173,9 @@  discard block
 block discarded – undo
171 173
 	global $sourcedir, $forum_version, $txt, $scripturl, $context;
172 174
 	global $explicit_images;
173 175
 
174
-	if (empty($path))
175
-		return false;
176
+	if (empty($path)) {
177
+			return false;
178
+	}
176 179
 
177 180
 	$xml_data = array();
178 181
 	$explicit_images = false;
@@ -229,9 +232,10 @@  discard block
 block discarded – undo
229 232
 	);
230 233
 
231 234
 	// Assign the values to be stored.
232
-	foreach ($xml_elements as $var => $name)
233
-		if (!empty($theme_info_xml[$name]))
235
+	foreach ($xml_elements as $var => $name) {
236
+			if (!empty($theme_info_xml[$name]))
234 237
 			$xml_data[$var] = $theme_info_xml[$name];
238
+	}
235 239
 
236 240
 	// Add the supported versions.
237 241
 	$xml_data['install_for'] = $install_versions;
@@ -243,8 +247,9 @@  discard block
 block discarded – undo
243 247
 		$explicit_images = true;
244 248
 	}
245 249
 
246
-	if (!empty($theme_info_xml['extra']))
247
-		$xml_data += smf_json_decode($theme_info_xml['extra'], true);
250
+	if (!empty($theme_info_xml['extra'])) {
251
+			$xml_data += smf_json_decode($theme_info_xml['extra'], true);
252
+	}
248 253
 
249 254
 	return $xml_data;
250 255
 }
@@ -262,12 +267,14 @@  discard block
 block discarded – undo
262 267
 	global $settings, $explicit_images;
263 268
 
264 269
 	// External use? no problem!
265
-	if ($to_install)
266
-		$context['to_install'] = $to_install;
270
+	if ($to_install) {
271
+			$context['to_install'] = $to_install;
272
+	}
267 273
 
268 274
 	// One last check.
269
-	if (empty($context['to_install']['theme_dir']) || basename($context['to_install']['theme_dir']) == 'Themes')
270
-		fatal_lang_error('theme_install_invalid_dir', false);
275
+	if (empty($context['to_install']['theme_dir']) || basename($context['to_install']['theme_dir']) == 'Themes') {
276
+			fatal_lang_error('theme_install_invalid_dir', false);
277
+	}
271 278
 
272 279
 	// OK, is this a newer version of an already installed theme?
273 280
 	if (!empty($context['to_install']['version']))
@@ -291,8 +298,8 @@  discard block
 block discarded – undo
291 298
 		$smcFunc['db_free_result']($request);
292 299
 
293 300
 		// Got something, lets figure it out what to do next.
294
-		if (!empty($to_update) && !empty($to_update['version']))
295
-			switch (compareVersions($context['to_install']['version'], $to_update['version']))
301
+		if (!empty($to_update) && !empty($to_update['version'])) {
302
+					switch (compareVersions($context['to_install']['version'], $to_update['version']))
296 303
 			{
297 304
 				case 1: // Got a newer version, update the old entry.
298 305
 					$smcFunc['db_query']('', '
@@ -306,6 +313,7 @@  discard block
 block discarded – undo
306 313
 							'id_theme' => $to_update['id_theme'],
307 314
 						)
308 315
 					);
316
+		}
309 317
 
310 318
 					// Done with the update, tell the user about it.
311 319
 					$context['to_install']['updated'] = true;
@@ -371,13 +379,15 @@  discard block
 block discarded – undo
371 379
 				$context['to_install']['base_theme_url'] = $temp['theme_url'];
372 380
 				$context['to_install']['base_theme_dir'] = $temp['theme_dir'];
373 381
 
374
-				if (empty($explicit_images) && !empty($context['to_install']['base_theme_url']))
375
-					$context['to_install']['theme_url'] = $context['to_install']['base_theme_url'];
382
+				if (empty($explicit_images) && !empty($context['to_install']['base_theme_url'])) {
383
+									$context['to_install']['theme_url'] = $context['to_install']['base_theme_url'];
384
+				}
376 385
 			}
377 386
 
378 387
 			// Nope, sorry, couldn't find any theme already installed.
379
-			else
380
-				fatal_lang_error('package_get_error_theme_no_based_on_found', false, $context['to_install']['based_on']);
388
+			else {
389
+							fatal_lang_error('package_get_error_theme_no_based_on_found', false, $context['to_install']['based_on']);
390
+			}
381 391
 		}
382 392
 
383 393
 		unset($context['to_install']['based_on']);
@@ -400,16 +410,18 @@  discard block
 block discarded – undo
400 410
 	call_integration_hook('integrate_theme_install', array(&$context['to_install'], $id_theme));
401 411
 
402 412
 	$inserts = array();
403
-	foreach ($context['to_install'] as $var => $val)
404
-		$inserts[] = array($id_theme, $var, $val);
413
+	foreach ($context['to_install'] as $var => $val) {
414
+			$inserts[] = array($id_theme, $var, $val);
415
+	}
405 416
 
406
-	if (!empty($inserts))
407
-		$smcFunc['db_insert']('insert',
417
+	if (!empty($inserts)) {
418
+			$smcFunc['db_insert']('insert',
408 419
 			'{db_prefix}themes',
409 420
 			array('id_theme' => 'int', 'variable' => 'string-255', 'value' => 'string-65534'),
410 421
 			$inserts,
411 422
 			array('id_theme', 'variable')
412 423
 		);
424
+	}
413 425
 
414 426
 	// Update the known and enable Theme's settings.
415 427
 	$known = strtr($modSettings['knownThemes'] . ',' . $id_theme, array(',,' => ','));
@@ -428,21 +440,24 @@  discard block
 block discarded – undo
428 440
  */
429 441
 function remove_dir($path)
430 442
 {
431
-	if (empty($path))
432
-		return false;
443
+	if (empty($path)) {
444
+			return false;
445
+	}
433 446
 
434 447
 	if (is_dir($path))
435 448
 	{
436 449
 		$objects = scandir($path);
437 450
 
438
-		foreach ($objects as $object)
439
-			if ($object != '.' && $object != '..')
451
+		foreach ($objects as $object) {
452
+					if ($object != '.' && $object != '..')
440 453
 			{
441 454
 				if (filetype($path . '/' . $object) == 'dir')
442 455
 					remove_dir($path . '/' . $object);
456
+		}
443 457
 
444
-				else
445
-					unlink($path . '/' . $object);
458
+				else {
459
+									unlink($path . '/' . $object);
460
+				}
446 461
 			}
447 462
 	}
448 463
 
@@ -461,8 +476,9 @@  discard block
 block discarded – undo
461 476
 	global $smcFunc, $modSettings;
462 477
 
463 478
 	// Can't delete the default theme, sorry!
464
-	if (empty($themeID) || $themeID == 1)
465
-		return false;
479
+	if (empty($themeID) || $themeID == 1) {
480
+			return false;
481
+	}
466 482
 
467 483
 	$known = explode(',', $modSettings['knownThemes']);
468 484
 	$enable = explode(',', $modSettings['enableThemes']);
@@ -512,8 +528,9 @@  discard block
 block discarded – undo
512 528
 	updateSettings(array('enableThemes' => $enable, 'knownThemes' => $known));
513 529
 
514 530
 	// Fix it if the theme was the overall default theme.
515
-	if ($modSettings['theme_guests'] == $themeID)
516
-		updateSettings(array('theme_guests' => '1'));
531
+	if ($modSettings['theme_guests'] == $themeID) {
532
+			updateSettings(array('theme_guests' => '1'));
533
+	}
517 534
 
518 535
 	return true;
519 536
 }
@@ -530,13 +547,15 @@  discard block
 block discarded – undo
530 547
 	global $scripturl, $txt, $context;
531 548
 
532 549
 	// Is it even a directory?
533
-	if (!is_dir($path))
534
-		fatal_lang_error('error_invalid_dir', 'critical');
550
+	if (!is_dir($path)) {
551
+			fatal_lang_error('error_invalid_dir', 'critical');
552
+	}
535 553
 
536 554
 	$dir = dir($path);
537 555
 	$entries = array();
538
-	while ($entry = $dir->read())
539
-		$entries[] = $entry;
556
+	while ($entry = $dir->read()) {
557
+			$entries[] = $entry;
558
+	}
540 559
 	$dir->close();
541 560
 
542 561
 	natcasesort($entries);
@@ -547,11 +566,12 @@  discard block
 block discarded – undo
547 566
 	foreach ($entries as $entry)
548 567
 	{
549 568
 		// Skip all dot files, including .htaccess.
550
-		if (substr($entry, 0, 1) == '.' || $entry == 'CVS')
551
-			continue;
569
+		if (substr($entry, 0, 1) == '.' || $entry == 'CVS') {
570
+					continue;
571
+		}
552 572
 
553
-		if (is_dir($path . '/' . $entry))
554
-			$listing1[] = array(
573
+		if (is_dir($path . '/' . $entry)) {
574
+					$listing1[] = array(
555 575
 				'filename' => $entry,
556 576
 				'is_writable' => is_writable($path . '/' . $entry),
557 577
 				'is_directory' => true,
@@ -561,13 +581,14 @@  discard block
 block discarded – undo
561 581
 				'href' => $scripturl . '?action=admin;area=theme;th=' . $_GET['th'] . ';' . $context['session_var'] . '=' . $context['session_id'] . ';sa=edit;directory=' . $relative . $entry,
562 582
 				'size' => '',
563 583
 			);
564
-		else
584
+		} else
565 585
 		{
566 586
 			$size = filesize($path . '/' . $entry);
567
-			if ($size > 2048 || $size == 1024)
568
-				$size = comma_format($size / 1024) . ' ' . $txt['themeadmin_edit_kilobytes'];
569
-			else
570
-				$size = comma_format($size) . ' ' . $txt['themeadmin_edit_bytes'];
587
+			if ($size > 2048 || $size == 1024) {
588
+							$size = comma_format($size / 1024) . ' ' . $txt['themeadmin_edit_kilobytes'];
589
+			} else {
590
+							$size = comma_format($size) . ' ' . $txt['themeadmin_edit_bytes'];
591
+			}
571 592
 
572 593
 			$listing2[] = array(
573 594
 				'filename' => $entry,
Please login to merge, or discard this patch.
Sources/Subscriptions-PayPal.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -402,7 +402,7 @@
 block discarded – undo
402 402
 	 * A private function to find out the subscription details.
403 403
 	 *
404 404
 	 * @access private
405
-	 * @return boolean|void False on failure, otherwise just sets $_POST['item_number']
405
+	 * @return false|null False on failure, otherwise just sets $_POST['item_number']
406 406
 	 */
407 407
 	private function _findSubscription()
408 408
 	{
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -236,7 +236,7 @@
 block discarded – undo
236 236
 			$header = 'POST /cgi-bin/webscr HTTP/1.1' . "\r\n";
237 237
 			$header .= 'Content-Type: application/x-www-form-urlencoded' . "\r\n";
238 238
 			$header .= 'Host: www.' . (!empty($modSettings['paidsubs_test']) ? 'sandbox.' : '') . 'paypal.com' . "\r\n";
239
-			$header .= 'Content-Length: ' . strlen ($requestString) . "\r\n";
239
+			$header .= 'Content-Length: ' . strlen($requestString) . "\r\n";
240 240
 			$header .= 'Connection: close' . "\r\n\r\n";
241 241
 
242 242
 			// Open the connection.
Please login to merge, or discard this patch.
Braces   +83 added lines, -61 removed lines patch added patch discarded remove patch
@@ -14,8 +14,9 @@  discard block
 block discarded – undo
14 14
 // This won't be dedicated without this - this must exist in each gateway!
15 15
 // SMF Payment Gateway: paypal
16 16
 
17
-if (!defined('SMF'))
17
+if (!defined('SMF')) {
18 18
 	die('No direct access...');
19
+}
19 20
 
20 21
 /**
21 22
  * Class for returning available form data for this gateway
@@ -118,8 +119,7 @@  discard block
 block discarded – undo
118 119
 		{
119 120
 			$return_data['hidden']['p3'] = 1;
120 121
 			$return_data['hidden']['t3'] = strtoupper(substr($period, 0, 1));
121
-		}
122
-		else
122
+		} else
123 123
 		{
124 124
 			preg_match('~(\d*)(\w)~', $sub_data['real_length'], $match);
125 125
 			$unit = $match[1];
@@ -130,14 +130,15 @@  discard block
 block discarded – undo
130 130
 		}
131 131
 
132 132
 		// If it's repeatable do some javascript to respect this idea.
133
-		if (!empty($sub_data['repeatable']))
134
-			$return_data['javascript'] = '
133
+		if (!empty($sub_data['repeatable'])) {
134
+					$return_data['javascript'] = '
135 135
 				document.write(\'<label for="do_paypal_recur"><input type="checkbox" name="do_paypal_recur" id="do_paypal_recur" checked onclick="switchPaypalRecur();" class="input_check">' . $txt['paid_make_recurring'] . '</label><br>\');
136 136
 
137 137
 				function switchPaypalRecur()
138 138
 				{
139 139
 					document.getElementById("paypal_cmd").value = document.getElementById("do_paypal_recur").checked ? "_xclick-subscriptions" : "_xclick";
140 140
 				}';
141
+		}
141 142
 
142 143
 		return $return_data;
143 144
 	}
@@ -160,20 +161,24 @@  discard block
 block discarded – undo
160 161
 		global $modSettings;
161 162
 
162 163
 		// Has the user set up an email address?
163
-		if ((empty($modSettings['paidsubs_test']) && empty($modSettings['paypal_email'])) || (!empty($modSettings['paidsubs_test']) && empty($modSettings['paypal_sandbox_email'])))
164
-			return false;
164
+		if ((empty($modSettings['paidsubs_test']) && empty($modSettings['paypal_email'])) || (!empty($modSettings['paidsubs_test']) && empty($modSettings['paypal_sandbox_email']))) {
165
+					return false;
166
+		}
165 167
 		// Check the correct transaction types are even here.
166
-		if ((!isset($_POST['txn_type']) && !isset($_POST['payment_status'])) || (!isset($_POST['business']) && !isset($_POST['receiver_email'])))
167
-			return false;
168
+		if ((!isset($_POST['txn_type']) && !isset($_POST['payment_status'])) || (!isset($_POST['business']) && !isset($_POST['receiver_email']))) {
169
+					return false;
170
+		}
168 171
 		// Correct email address?
169
-		if (!isset($_POST['business']))
170
-			$_POST['business'] = $_POST['receiver_email'];
172
+		if (!isset($_POST['business'])) {
173
+					$_POST['business'] = $_POST['receiver_email'];
174
+		}
171 175
 
172 176
 		// Are we testing?
173
-		if (empty($modSettings['paidsubs_test']) && strtolower($modSettings['paypal_sandbox_email']) != strtolower($_POST['business']) && (empty($modSettings['paypal_additional_emails']) || !in_array(strtolower($_POST['business']), explode(',', strtolower($modSettings['paypal_additional_emails'])))))
174
-			return false;
175
-		elseif (strtolower($modSettings['paypal_email']) != strtolower($_POST['business']) && (empty($modSettings['paypal_additional_emails']) || !in_array(strtolower($_POST['business']), explode(',', $modSettings['paypal_additional_emails']))))
176
-			return false;
177
+		if (empty($modSettings['paidsubs_test']) && strtolower($modSettings['paypal_sandbox_email']) != strtolower($_POST['business']) && (empty($modSettings['paypal_additional_emails']) || !in_array(strtolower($_POST['business']), explode(',', strtolower($modSettings['paypal_additional_emails']))))) {
178
+					return false;
179
+		} elseif (strtolower($modSettings['paypal_email']) != strtolower($_POST['business']) && (empty($modSettings['paypal_additional_emails']) || !in_array(strtolower($_POST['business']), explode(',', $modSettings['paypal_additional_emails'])))) {
180
+					return false;
181
+		}
177 182
 		return true;
178 183
 	}
179 184
 
@@ -192,15 +197,17 @@  discard block
 block discarded – undo
192 197
 		global $modSettings, $txt;
193 198
 
194 199
 		// Put this to some default value.
195
-		if (!isset($_POST['txn_type']))
196
-			$_POST['txn_type'] = '';
200
+		if (!isset($_POST['txn_type'])) {
201
+					$_POST['txn_type'] = '';
202
+		}
197 203
 
198 204
 		// Build the request string - starting with the minimum requirement.
199 205
 		$requestString = 'cmd=_notify-validate';
200 206
 
201 207
 		// Now my dear, add all the posted bits in the order we got them
202
-		foreach ($_POST as $k => $v)
203
-			$requestString .= '&' . $k . '=' . urlencode($v);
208
+		foreach ($_POST as $k => $v) {
209
+					$requestString .= '&' . $k . '=' . urlencode($v);
210
+		}
204 211
 
205 212
 		// Can we use curl?
206 213
 		if (function_exists('curl_init') && $curl = curl_init((!empty($modSettings['paidsubs_test']) ? 'https://www.sandbox.' : 'https://www.') . 'paypal.com/cgi-bin/webscr'))
@@ -240,14 +247,16 @@  discard block
 block discarded – undo
240 247
 			$header .= 'Connection: close' . "\r\n\r\n";
241 248
 
242 249
 			// Open the connection.
243
-			if (!empty($modSettings['paidsubs_test']))
244
-				$fp = fsockopen('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30);
245
-			else
246
-				$fp = fsockopen('www.paypal.com', 80, $errno, $errstr, 30);
250
+			if (!empty($modSettings['paidsubs_test'])) {
251
+							$fp = fsockopen('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30);
252
+			} else {
253
+							$fp = fsockopen('www.paypal.com', 80, $errno, $errstr, 30);
254
+			}
247 255
 
248 256
 			// Did it work?
249
-			if (!$fp)
250
-				generateSubscriptionError($txt['paypal_could_not_connect']);
257
+			if (!$fp) {
258
+							generateSubscriptionError($txt['paypal_could_not_connect']);
259
+			}
251 260
 
252 261
 			// Put the data to the port.
253 262
 			fputs($fp, $header . $requestString);
@@ -256,8 +265,9 @@  discard block
 block discarded – undo
256 265
 			while (!feof($fp))
257 266
 			{
258 267
 				$this->return_data = fgets($fp, 1024);
259
-				if (strcmp(trim($this->return_data), 'VERIFIED') === 0)
260
-					break;
268
+				if (strcmp(trim($this->return_data), 'VERIFIED') === 0) {
269
+									break;
270
+				}
261 271
 			}
262 272
 
263 273
 			// Clean up.
@@ -265,28 +275,34 @@  discard block
 block discarded – undo
265 275
 		}
266 276
 
267 277
 		// If this isn't verified then give up...
268
-		if (strcmp(trim($this->return_data), 'VERIFIED') !== 0)
269
-			exit;
278
+		if (strcmp(trim($this->return_data), 'VERIFIED') !== 0) {
279
+					exit;
280
+		}
270 281
 
271 282
 		// Check that this is intended for us.
272
-		if (strtolower($modSettings['paypal_email']) != strtolower($_POST['business']) && (empty($modSettings['paypal_additional_emails']) || !in_array(strtolower($_POST['business']), explode(',', strtolower($modSettings['paypal_additional_emails'])))))
273
-			exit;
283
+		if (strtolower($modSettings['paypal_email']) != strtolower($_POST['business']) && (empty($modSettings['paypal_additional_emails']) || !in_array(strtolower($_POST['business']), explode(',', strtolower($modSettings['paypal_additional_emails']))))) {
284
+					exit;
285
+		}
274 286
 
275 287
 		// Is this a subscription - and if so is it a secondary payment that we need to process?
276 288
 		// If so, make sure we get it in the expected format. Seems PayPal sometimes sends it without urlencoding.
277
-		if (!empty($_POST['item_number']) && strpos($_POST['item_number'], ' ') !== false)
278
-			$_POST['item_number'] = str_replace(' ', '+', $_POST['item_number']);
279
-		if ($this->isSubscription() && (empty($_POST['item_number']) || strpos($_POST['item_number'], '+') === false))
280
-			// Calculate the subscription it relates to!
289
+		if (!empty($_POST['item_number']) && strpos($_POST['item_number'], ' ') !== false) {
290
+					$_POST['item_number'] = str_replace(' ', '+', $_POST['item_number']);
291
+		}
292
+		if ($this->isSubscription() && (empty($_POST['item_number']) || strpos($_POST['item_number'], '+') === false)) {
293
+					// Calculate the subscription it relates to!
281 294
 			$this->_findSubscription();
295
+		}
282 296
 
283 297
 		// Verify the currency!
284
-		if (strtolower($_POST['mc_currency']) !== strtolower($modSettings['paid_currency_code']))
285
-			exit;
298
+		if (strtolower($_POST['mc_currency']) !== strtolower($modSettings['paid_currency_code'])) {
299
+					exit;
300
+		}
286 301
 
287 302
 		// Can't exist if it doesn't contain anything.
288
-		if (empty($_POST['item_number']))
289
-			exit;
303
+		if (empty($_POST['item_number'])) {
304
+					exit;
305
+		}
290 306
 
291 307
 		// Return the id_sub and id_member
292 308
 		return explode('+', $_POST['item_number']);
@@ -299,10 +315,11 @@  discard block
 block discarded – undo
299 315
 	 */
300 316
 	public function isRefund()
301 317
 	{
302
-		if ($_POST['payment_status'] === 'Refunded' || $_POST['payment_status'] === 'Reversed' || $_POST['txn_type'] === 'Refunded' || ($_POST['txn_type'] === 'reversal' && $_POST['payment_status'] === 'Completed'))
303
-			return true;
304
-		else
305
-			return false;
318
+		if ($_POST['payment_status'] === 'Refunded' || $_POST['payment_status'] === 'Reversed' || $_POST['txn_type'] === 'Refunded' || ($_POST['txn_type'] === 'reversal' && $_POST['payment_status'] === 'Completed')) {
319
+					return true;
320
+		} else {
321
+					return false;
322
+		}
306 323
 	}
307 324
 
308 325
 	/**
@@ -312,10 +329,11 @@  discard block
 block discarded – undo
312 329
 	 */
313 330
 	public function isSubscription()
314 331
 	{
315
-		if (substr($_POST['txn_type'], 0, 14) === 'subscr_payment' && $_POST['payment_status'] === 'Completed')
316
-			return true;
317
-		else
318
-			return false;
332
+		if (substr($_POST['txn_type'], 0, 14) === 'subscr_payment' && $_POST['payment_status'] === 'Completed') {
333
+					return true;
334
+		} else {
335
+					return false;
336
+		}
319 337
 	}
320 338
 
321 339
 	/**
@@ -325,10 +343,11 @@  discard block
 block discarded – undo
325 343
 	 */
326 344
 	public function isPayment()
327 345
 	{
328
-		if ($_POST['payment_status'] === 'Completed' && $_POST['txn_type'] === 'web_accept')
329
-			return true;
330
-		else
331
-			return false;
346
+		if ($_POST['payment_status'] === 'Completed' && $_POST['txn_type'] === 'web_accept') {
347
+					return true;
348
+		} else {
349
+					return false;
350
+		}
332 351
 	}
333 352
 
334 353
 	/**
@@ -341,10 +360,11 @@  discard block
 block discarded – undo
341 360
 		// subscr_cancel is sent when the user cancels, subscr_eot is sent when the subscription reaches final payment
342 361
 		// Neither require us to *do* anything as per performCancel().
343 362
 		// subscr_eot, if sent, indicates an end of payments term.
344
-		if (substr($_POST['txn_type'], 0, 13) === 'subscr_cancel' || substr($_POST['txn_type'], 0, 10) === 'subscr_eot')
345
-			return true;
346
-		else
347
-			return false;
363
+		if (substr($_POST['txn_type'], 0, 13) === 'subscr_cancel' || substr($_POST['txn_type'], 0, 10) === 'subscr_eot') {
364
+					return true;
365
+		} else {
366
+					return false;
367
+		}
348 368
 	}
349 369
 
350 370
 	/**
@@ -409,8 +429,9 @@  discard block
 block discarded – undo
409 429
 		global $smcFunc;
410 430
 
411 431
 		// Assume we have this?
412
-		if (empty($_POST['subscr_id']))
413
-			return false;
432
+		if (empty($_POST['subscr_id'])) {
433
+					return false;
434
+		}
414 435
 
415 436
 		// Do we have this in the database?
416 437
 		$request = $smcFunc['db_query']('', '
@@ -439,11 +460,12 @@  discard block
 block discarded – undo
439 460
 						'payer_email' => $_POST['payer_email'],
440 461
 					)
441 462
 				);
442
-				if ($smcFunc['db_num_rows']($request) === 0)
443
-					return false;
463
+				if ($smcFunc['db_num_rows']($request) === 0) {
464
+									return false;
465
+				}
466
+			} else {
467
+							return false;
444 468
 			}
445
-			else
446
-				return false;
447 469
 		}
448 470
 		list ($member_id, $subscription_id) = $smcFunc['db_fetch_row']($request);
449 471
 		$_POST['item_number'] = $member_id . '+' . $subscription_id;
Please login to merge, or discard this patch.
Sources/tasks/EventNew-Notify.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@
 block discarded – undo
21 21
 {
22 22
 	/**
23 23
      * This executes the task - loads up the information, puts the email in the queue and inserts alerts as needed.
24
-	 * @return bool Always returns true
24
+	 * @return boolean|null Always returns true
25 25
 	 */
26 26
 	public function execute()
27 27
  	{
Please login to merge, or discard this patch.
Braces   +11 added lines, -8 removed lines patch added patch discarded remove patch
@@ -32,8 +32,9 @@  discard block
 block discarded – undo
32 32
 		$members = membersAllowedTo('calendar_view');
33 33
 
34 34
 		// Don't alert the event creator
35
-		if (!empty($this->_details['sender_id']))
36
-			$members = array_diff($members, array($this->_details['sender_id']));
35
+		if (!empty($this->_details['sender_id'])) {
36
+					$members = array_diff($members, array($this->_details['sender_id']));
37
+		}
37 38
 
38 39
 		// Having successfully figured this out, now let's get the preferences of everyone.
39 40
 		require_once($sourcedir . '/Subs-Notify.php');
@@ -44,10 +45,11 @@  discard block
 block discarded – undo
44 45
 		if (!empty($this->_details['sender_id']) && empty($this->_details['sender_name']))
45 46
 		{
46 47
 			loadMemberData($this->_details['sender_id'], 'minimal');
47
-			if (!empty($user_profile[$this->_details['sender_id']]))
48
-				$this->_details['sender_name'] = $user_profile[$this->_details['sender_id']]['real_name'];
49
-			else
50
-				$this->_details['sender_id'] = 0;
48
+			if (!empty($user_profile[$this->_details['sender_id']])) {
49
+							$this->_details['sender_name'] = $user_profile[$this->_details['sender_id']]['real_name'];
50
+			} else {
51
+							$this->_details['sender_id'] = 0;
52
+			}
51 53
 		}
52 54
 
53 55
 		// So now we find out who wants what.
@@ -59,9 +61,10 @@  discard block
 block discarded – undo
59 61
 
60 62
 		foreach ($prefs as $member => $pref_option)
61 63
 		{
62
-			foreach ($alert_bits as $type => $bitvalue)
63
-				if ($pref_option['event_new'] & $bitvalue)
64
+			foreach ($alert_bits as $type => $bitvalue) {
65
+							if ($pref_option['event_new'] & $bitvalue)
64 66
 					$notifies[$type][] = $member;
67
+			}
65 68
 		}
66 69
 
67 70
 		// Firstly, anyone who wants alerts.
Please login to merge, or discard this patch.
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 class EventNew_Notify_Background extends SMF_BackgroundTask
21 21
 {
22 22
 	/**
23
-     * This executes the task - loads up the information, puts the email in the queue and inserts alerts as needed.
23
+	 * This executes the task - loads up the information, puts the email in the queue and inserts alerts as needed.
24 24
 	 * @return bool Always returns true
25 25
 	 */
26 26
 	public function execute()
@@ -81,8 +81,8 @@  discard block
 block discarded – undo
81 81
 					'content_action' => empty($this->_details['sender_id']) ? 'new_guest' : 'new',
82 82
 					'is_read' => 0,
83 83
 					'extra' => json_encode(
84
-					    array(
85
-					        "event_id" => $this->_details['event_id'],
84
+						array(
85
+							"event_id" => $this->_details['event_id'],
86 86
 							"event_title" => $this->_details['event_title']
87 87
 						)
88 88
 					),
Please login to merge, or discard this patch.
Sources/Xml.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -80,7 +80,7 @@
 block discarded – undo
80 80
 /**
81 81
  * Handles retrieving previews of news items, newsletters, signatures and warnings.
82 82
  * Calls the appropriate function based on $_POST['item']
83
- * @return void|bool Returns false if $_POST['item'] isn't set or isn't valid
83
+ * @return false|null Returns false if $_POST['item'] isn't set or isn't valid
84 84
  */
85 85
 function RetrievePreview()
86 86
 {
Please login to merge, or discard this patch.
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -272,13 +272,13 @@
 block discarded – undo
272 272
 				$context['post_error']['messages'][] = $txt['mc_warning_template_error_no_body'];
273 273
 			// Add in few replacements.
274 274
 			/**
275
-			* These are the defaults:
276
-			* - {MEMBER} - Member Name. => current user for review
277
-			* - {MESSAGE} - Link to Offending Post. (If Applicable) => not applicable here, so not replaced
278
-			* - {FORUMNAME} - Forum Name.
279
-			* - {SCRIPTURL} - Web address of forum.
280
-			* - {REGARDS} - Standard email sign-off.
281
-			*/
275
+			 * These are the defaults:
276
+			 * - {MEMBER} - Member Name. => current user for review
277
+			 * - {MESSAGE} - Link to Offending Post. (If Applicable) => not applicable here, so not replaced
278
+			 * - {FORUMNAME} - Forum Name.
279
+			 * - {SCRIPTURL} - Web address of forum.
280
+			 * - {REGARDS} - Standard email sign-off.
281
+			 */
282 282
 			$find = array(
283 283
 				'{MEMBER}',
284 284
 				'{FORUMNAME}',
Please login to merge, or discard this patch.
Braces   +55 added lines, -42 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 4
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 /**
20 21
  * The main handler and designator for AJAX stuff - jumpto, message icons and previews
@@ -32,8 +33,9 @@  discard block
 block discarded – undo
32 33
 	// Easy adding of sub actions.
33 34
 	call_integration_hook('integrate_XMLhttpMain_subActions', array(&$subActions));
34 35
 
35
-	if (!isset($_REQUEST['sa'], $subActions[$_REQUEST['sa']]))
36
-		fatal_lang_error('no_access', false);
36
+	if (!isset($_REQUEST['sa'], $subActions[$_REQUEST['sa']])) {
37
+			fatal_lang_error('no_access', false);
38
+	}
37 39
 
38 40
 	call_helper($subActions[$_REQUEST['sa']]);
39 41
 }
@@ -57,8 +59,9 @@  discard block
 block discarded – undo
57 59
 	foreach ($context['jump_to'] as $id_cat => $cat)
58 60
 	{
59 61
 		$context['jump_to'][$id_cat]['name'] = un_htmlspecialchars(strip_tags($cat['name']));
60
-		foreach ($cat['boards'] as $id_board => $board)
61
-			$context['jump_to'][$id_cat]['boards'][$id_board]['name'] = un_htmlspecialchars(strip_tags($board['name']));
62
+		foreach ($cat['boards'] as $id_board => $board) {
63
+					$context['jump_to'][$id_cat]['boards'][$id_board]['name'] = un_htmlspecialchars(strip_tags($board['name']));
64
+		}
62 65
 	}
63 66
 
64 67
 	$context['sub_template'] = 'jump_to';
@@ -95,8 +98,9 @@  discard block
 block discarded – undo
95 98
 
96 99
 	$context['sub_template'] = 'generic_xml';
97 100
 
98
-	if (!isset($_POST['item']) || !in_array($_POST['item'], $items))
99
-		return false;
101
+	if (!isset($_POST['item']) || !in_array($_POST['item'], $items)) {
102
+			return false;
103
+	}
100 104
 
101 105
 	$_POST['item']();
102 106
 }
@@ -112,10 +116,11 @@  discard block
 block discarded – undo
112 116
 
113 117
 	$errors = array();
114 118
 	$news = !isset($_POST['news']) ? '' : $smcFunc['htmlspecialchars']($_POST['news'], ENT_QUOTES);
115
-	if (empty($news))
116
-		$errors[] = array('value' => 'no_news');
117
-	else
118
-		preparsecode($news);
119
+	if (empty($news)) {
120
+			$errors[] = array('value' => 'no_news');
121
+	} else {
122
+			preparsecode($news);
123
+	}
119 124
 
120 125
 	$context['xml_data'] = array(
121 126
 		'news' => array(
@@ -148,10 +153,12 @@  discard block
 block discarded – undo
148 153
 	$context['send_pm'] = !empty($_POST['send_pm']) ? 1 : 0;
149 154
 	$context['send_html'] = !empty($_POST['send_html']) ? 1 : 0;
150 155
 
151
-	if (empty($_POST['subject']))
152
-		$context['post_error']['messages'][] = $txt['error_no_subject'];
153
-	if (empty($_POST['message']))
154
-		$context['post_error']['messages'][] = $txt['error_no_message'];
156
+	if (empty($_POST['subject'])) {
157
+			$context['post_error']['messages'][] = $txt['error_no_subject'];
158
+	}
159
+	if (empty($_POST['message'])) {
160
+			$context['post_error']['messages'][] = $txt['error_no_message'];
161
+	}
155 162
 
156 163
 	prepareMailingForPreview();
157 164
 
@@ -196,38 +203,41 @@  discard block
 block discarded – undo
196 203
 		$preview_signature = !empty($_POST['signature']) ? $_POST['signature'] : $txt['no_signature_preview'];
197 204
 		$validation = profileValidateSignature($preview_signature);
198 205
 
199
-		if ($validation !== true && $validation !== false)
200
-			$errors[] = array('value' => $txt['profile_error_' . $validation], 'attributes' => array('type' => 'error'));
206
+		if ($validation !== true && $validation !== false) {
207
+					$errors[] = array('value' => $txt['profile_error_' . $validation], 'attributes' => array('type' => 'error'));
208
+		}
201 209
 
202 210
 		censorText($preview_signature);
203 211
 		$preview_signature = parse_bbc($preview_signature, true, 'sig' . $user);
204
-	}
205
-	elseif (!$can_change)
212
+	} elseif (!$can_change)
206 213
 	{
207
-		if ($is_owner)
208
-			$errors[] = array('value' => $txt['cannot_profile_extra_own'], 'attributes' => array('type' => 'error'));
209
-		else
210
-			$errors[] = array('value' => $txt['cannot_profile_extra_any'], 'attributes' => array('type' => 'error'));
214
+		if ($is_owner) {
215
+					$errors[] = array('value' => $txt['cannot_profile_extra_own'], 'attributes' => array('type' => 'error'));
216
+		} else {
217
+					$errors[] = array('value' => $txt['cannot_profile_extra_any'], 'attributes' => array('type' => 'error'));
218
+		}
219
+	} else {
220
+			$errors[] = array('value' => $txt['no_user_selected'], 'attributes' => array('type' => 'error'));
211 221
 	}
212
-	else
213
-		$errors[] = array('value' => $txt['no_user_selected'], 'attributes' => array('type' => 'error'));
214 222
 
215 223
 	$context['xml_data']['signatures'] = array(
216 224
 			'identifier' => 'signature',
217 225
 			'children' => array()
218 226
 		);
219
-	if (isset($current_signature))
220
-		$context['xml_data']['signatures']['children'][] = array(
227
+	if (isset($current_signature)) {
228
+			$context['xml_data']['signatures']['children'][] = array(
221 229
 					'value' => $current_signature,
222 230
 					'attributes' => array('type' => 'current'),
223 231
 				);
224
-	if (isset($preview_signature))
225
-		$context['xml_data']['signatures']['children'][] = array(
232
+	}
233
+	if (isset($preview_signature)) {
234
+			$context['xml_data']['signatures']['children'][] = array(
226 235
 					'value' => $preview_signature,
227 236
 					'attributes' => array('type' => 'preview'),
228 237
 				);
229
-	if (!empty($errors))
230
-		$context['xml_data']['errors'] = array(
238
+	}
239
+	if (!empty($errors)) {
240
+			$context['xml_data']['errors'] = array(
231 241
 			'identifier' => 'error',
232 242
 			'children' => array_merge(
233 243
 				array(
@@ -239,7 +249,8 @@  discard block
 block discarded – undo
239 249
 				$errors
240 250
 			),
241 251
 		);
242
-}
252
+	}
253
+	}
243 254
 
244 255
 /**
245 256
  * Handles previewing user warnings
@@ -259,15 +270,17 @@  discard block
 block discarded – undo
259 270
 		$context['preview_subject'] = !empty($_POST['title']) ? trim($smcFunc['htmlspecialchars']($_POST['title'])) : '';
260 271
 		if (isset($_POST['issuing']))
261 272
 		{
262
-			if (empty($_POST['title']) || empty($_POST['body']))
263
-				$context['post_error']['messages'][] = $txt['warning_notify_blank'];
264
-		}
265
-		else
273
+			if (empty($_POST['title']) || empty($_POST['body'])) {
274
+							$context['post_error']['messages'][] = $txt['warning_notify_blank'];
275
+			}
276
+		} else
266 277
 		{
267
-			if (empty($_POST['title']))
268
-				$context['post_error']['messages'][] = $txt['mc_warning_template_error_no_title'];
269
-			if (empty($_POST['body']))
270
-				$context['post_error']['messages'][] = $txt['mc_warning_template_error_no_body'];
278
+			if (empty($_POST['title'])) {
279
+							$context['post_error']['messages'][] = $txt['mc_warning_template_error_no_title'];
280
+			}
281
+			if (empty($_POST['body'])) {
282
+							$context['post_error']['messages'][] = $txt['mc_warning_template_error_no_body'];
283
+			}
271 284
 			// Add in few replacements.
272 285
 			/**
273 286
 			* These are the defaults:
@@ -298,9 +311,9 @@  discard block
 block discarded – undo
298 311
 			$warning_body = parse_bbc($warning_body, true);
299 312
 		}
300 313
 		$context['preview_message'] = $warning_body;
314
+	} else {
315
+			$context['post_error']['messages'][] = array('value' => $txt['cannot_issue_warning'], 'attributes' => array('type' => 'error'));
301 316
 	}
302
-	else
303
-		$context['post_error']['messages'][] = array('value' => $txt['cannot_issue_warning'], 'attributes' => array('type' => 'error'));
304 317
 
305 318
 	$context['sub_template'] = 'warning';
306 319
 }
Please login to merge, or discard this patch.
SSI.php 2 patches
Doc Comments   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1717,7 +1717,7 @@  discard block
 block discarded – undo
1717 1717
 /**
1718 1718
  * Show today's birthdays.
1719 1719
  * @param string $output_method The output method. If 'echo', displays a list of users, otherwise returns an array of info about them.
1720
- * @return void|array Displays a list of users or returns an array of info about them depending on output_method.
1720
+ * @return null|string Displays a list of users or returns an array of info about them depending on output_method.
1721 1721
  */
1722 1722
 function ssi_todaysBirthdays($output_method = 'echo')
1723 1723
 {
@@ -1746,7 +1746,7 @@  discard block
 block discarded – undo
1746 1746
 /**
1747 1747
  * Shows today's holidays.
1748 1748
  * @param string $output_method The output method. If 'echo', displays a list of holidays, otherwise returns an array of info about them.
1749
- * @return void|array Displays a list of holidays or returns an array of info about them depending on output_method
1749
+ * @return null|string Displays a list of holidays or returns an array of info about them depending on output_method
1750 1750
  */
1751 1751
 function ssi_todaysHolidays($output_method = 'echo')
1752 1752
 {
@@ -1773,7 +1773,7 @@  discard block
 block discarded – undo
1773 1773
 
1774 1774
 /**
1775 1775
  * @param string $output_method The output method. If 'echo', displays a list of events, otherwise returns an array of info about them.
1776
- * @return void|array Displays a list of events or returns an array of info about them depending on output_method
1776
+ * @return null|string Displays a list of events or returns an array of info about them depending on output_method
1777 1777
  */
1778 1778
 function ssi_todaysEvents($output_method = 'echo')
1779 1779
 {
@@ -1807,7 +1807,7 @@  discard block
 block discarded – undo
1807 1807
 /**
1808 1808
  * Shows today's calendar items (events, birthdays and holidays)
1809 1809
  * @param string $output_method The output method. If 'echo', displays a list of calendar items, otherwise returns an array of info about them.
1810
- * @return void|array Displays a list of calendar items or returns an array of info about them depending on output_method
1810
+ * @return null|string Displays a list of calendar items or returns an array of info about them depending on output_method
1811 1811
  */
1812 1812
 function ssi_todaysCalendar($output_method = 'echo')
1813 1813
 {
@@ -2198,7 +2198,7 @@  discard block
 block discarded – undo
2198 2198
  * @param int|string $id The ID or username of a user
2199 2199
  * @param string $password The password to check
2200 2200
  * @param bool $is_username If true, treats $id as a username rather than a user ID
2201
- * @return bool Whether or not the password is correct.
2201
+ * @return null|boolean Whether or not the password is correct.
2202 2202
  */
2203 2203
 function ssi_checkPassword($id = null, $password = null, $is_username = false)
2204 2204
 {
Please login to merge, or discard this patch.
Braces   +426 added lines, -304 removed lines patch added patch discarded remove patch
@@ -12,8 +12,9 @@  discard block
 block discarded – undo
12 12
  */
13 13
 
14 14
 // Don't do anything if SMF is already loaded.
15
-if (defined('SMF'))
15
+if (defined('SMF')) {
16 16
 	return true;
17
+}
17 18
 
18 19
 define('SMF', 'SSI');
19 20
 
@@ -28,16 +29,18 @@  discard block
 block discarded – undo
28 29
 $time_start = microtime();
29 30
 
30 31
 // Just being safe...
31
-foreach (array('db_character_set', 'cachedir') as $variable)
32
+foreach (array('db_character_set', 'cachedir') as $variable) {
32 33
 	if (isset($GLOBALS[$variable]))
33 34
 		unset($GLOBALS[$variable]);
35
+}
34 36
 
35 37
 // Get the forum's settings for database and file paths.
36 38
 require_once(dirname(__FILE__) . '/Settings.php');
37 39
 
38 40
 // Make absolutely sure the cache directory is defined.
39
-if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache'))
41
+if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) {
40 42
 	$cachedir = $boarddir . '/cache';
43
+}
41 44
 
42 45
 $ssi_error_reporting = error_reporting(defined('E_STRICT') ? E_ALL | E_STRICT : E_ALL);
43 46
 /* Set this to one of three values depending on what you want to happen in the case of a fatal error.
@@ -48,12 +51,14 @@  discard block
 block discarded – undo
48 51
 $ssi_on_error_method = false;
49 52
 
50 53
 // Don't do john didley if the forum's been shut down completely.
51
-if ($maintenance == 2 && (!isset($ssi_maintenance_off) || $ssi_maintenance_off !== true))
54
+if ($maintenance == 2 && (!isset($ssi_maintenance_off) || $ssi_maintenance_off !== true)) {
52 55
 	die($mmessage);
56
+}
53 57
 
54 58
 // Fix for using the current directory as a path.
55
-if (substr($sourcedir, 0, 1) == '.' && substr($sourcedir, 1, 1) != '.')
59
+if (substr($sourcedir, 0, 1) == '.' && substr($sourcedir, 1, 1) != '.') {
56 60
 	$sourcedir = dirname(__FILE__) . substr($sourcedir, 1);
61
+}
57 62
 
58 63
 // Load the important includes.
59 64
 require_once($sourcedir . '/QueryString.php');
@@ -78,34 +83,38 @@  discard block
 block discarded – undo
78 83
 cleanRequest();
79 84
 
80 85
 // Seed the random generator?
81
-if (empty($modSettings['rand_seed']) || mt_rand(1, 250) == 69)
86
+if (empty($modSettings['rand_seed']) || mt_rand(1, 250) == 69) {
82 87
 	smf_seed_generator();
88
+}
83 89
 
84 90
 // Check on any hacking attempts.
85
-if (isset($_REQUEST['GLOBALS']) || isset($_COOKIE['GLOBALS']))
91
+if (isset($_REQUEST['GLOBALS']) || isset($_COOKIE['GLOBALS'])) {
86 92
 	die('No direct access...');
87
-elseif (isset($_REQUEST['ssi_theme']) && (int) $_REQUEST['ssi_theme'] == (int) $ssi_theme)
93
+} elseif (isset($_REQUEST['ssi_theme']) && (int) $_REQUEST['ssi_theme'] == (int) $ssi_theme) {
88 94
 	die('No direct access...');
89
-elseif (isset($_COOKIE['ssi_theme']) && (int) $_COOKIE['ssi_theme'] == (int) $ssi_theme)
95
+} elseif (isset($_COOKIE['ssi_theme']) && (int) $_COOKIE['ssi_theme'] == (int) $ssi_theme) {
90 96
 	die('No direct access...');
91
-elseif (isset($_REQUEST['ssi_layers'], $ssi_layers) && (@get_magic_quotes_gpc() ? stripslashes($_REQUEST['ssi_layers']) : $_REQUEST['ssi_layers']) == $ssi_layers)
97
+} elseif (isset($_REQUEST['ssi_layers'], $ssi_layers) && (@get_magic_quotes_gpc() ? stripslashes($_REQUEST['ssi_layers']) : $_REQUEST['ssi_layers']) == $ssi_layers) {
92 98
 	die('No direct access...');
93
-if (isset($_REQUEST['context']))
99
+}
100
+if (isset($_REQUEST['context'])) {
94 101
 	die('No direct access...');
102
+}
95 103
 
96 104
 // Gzip output? (because it must be boolean and true, this can't be hacked.)
97
-if (isset($ssi_gzip) && $ssi_gzip === true && ini_get('zlib.output_compression') != '1' && ini_get('output_handler') != 'ob_gzhandler' && version_compare(PHP_VERSION, '4.2.0', '>='))
105
+if (isset($ssi_gzip) && $ssi_gzip === true && ini_get('zlib.output_compression') != '1' && ini_get('output_handler') != 'ob_gzhandler' && version_compare(PHP_VERSION, '4.2.0', '>=')) {
98 106
 	ob_start('ob_gzhandler');
99
-else
107
+} else {
100 108
 	$modSettings['enableCompressedOutput'] = '0';
109
+}
101 110
 
102 111
 // Primarily, this is to fix the URLs...
103 112
 ob_start('ob_sessrewrite');
104 113
 
105 114
 // Start the session... known to scramble SSI includes in cases...
106
-if (!headers_sent())
115
+if (!headers_sent()) {
107 116
 	loadSession();
108
-else
117
+} else
109 118
 {
110 119
 	if (isset($_COOKIE[session_name()]) || isset($_REQUEST[session_name()]))
111 120
 	{
@@ -139,12 +148,14 @@  discard block
 block discarded – undo
139 148
 loadTheme(isset($ssi_theme) ? (int) $ssi_theme : 0);
140 149
 
141 150
 // @todo: probably not the best place, but somewhere it should be set...
142
-if (!headers_sent())
151
+if (!headers_sent()) {
143 152
 	header('Content-Type: text/html; charset=' . (empty($modSettings['global_character_set']) ? (empty($txt['lang_character_set']) ? 'ISO-8859-1' : $txt['lang_character_set']) : $modSettings['global_character_set']));
153
+}
144 154
 
145 155
 // Take care of any banning that needs to be done.
146
-if (isset($_REQUEST['ssi_ban']) || (isset($ssi_ban) && $ssi_ban === true))
156
+if (isset($_REQUEST['ssi_ban']) || (isset($ssi_ban) && $ssi_ban === true)) {
147 157
 	is_not_banned();
158
+}
148 159
 
149 160
 // Do we allow guests in here?
150 161
 if (empty($ssi_guest_access) && empty($modSettings['allow_guestAccess']) && $user_info['is_guest'] && basename($_SERVER['PHP_SELF']) != 'SSI.php')
@@ -159,17 +170,19 @@  discard block
 block discarded – undo
159 170
 {
160 171
 	$context['template_layers'] = $ssi_layers;
161 172
 	template_header();
162
-}
163
-else
173
+} else {
164 174
 	setupThemeContext();
175
+}
165 176
 
166 177
 // Make sure they didn't muss around with the settings... but only if it's not cli.
167
-if (isset($_SERVER['REMOTE_ADDR']) && !isset($_SERVER['is_cli']) && session_id() == '')
178
+if (isset($_SERVER['REMOTE_ADDR']) && !isset($_SERVER['is_cli']) && session_id() == '') {
168 179
 	trigger_error($txt['ssi_session_broken'], E_USER_NOTICE);
180
+}
169 181
 
170 182
 // Without visiting the forum this session variable might not be set on submit.
171
-if (!isset($_SESSION['USER_AGENT']) && (!isset($_GET['ssi_function']) || $_GET['ssi_function'] !== 'pollVote'))
183
+if (!isset($_SESSION['USER_AGENT']) && (!isset($_GET['ssi_function']) || $_GET['ssi_function'] !== 'pollVote')) {
172 184
 	$_SESSION['USER_AGENT'] = $_SERVER['HTTP_USER_AGENT'];
185
+}
173 186
 
174 187
 // Have the ability to easily add functions to SSI.
175 188
 call_integration_hook('integrate_SSI');
@@ -178,11 +191,13 @@  discard block
 block discarded – undo
178 191
 if (basename($_SERVER['PHP_SELF']) == 'SSI.php')
179 192
 {
180 193
 	// You shouldn't just access SSI.php directly by URL!!
181
-	if (!isset($_GET['ssi_function']))
182
-		die(sprintf($txt['ssi_not_direct'], $user_info['is_admin'] ? '\'' . addslashes(__FILE__) . '\'' : '\'SSI.php\''));
194
+	if (!isset($_GET['ssi_function'])) {
195
+			die(sprintf($txt['ssi_not_direct'], $user_info['is_admin'] ? '\'' . addslashes(__FILE__) . '\'' : '\'SSI.php\''));
196
+	}
183 197
 	// Call a function passed by GET.
184
-	if (function_exists('ssi_' . $_GET['ssi_function']) && (!empty($modSettings['allow_guestAccess']) || !$user_info['is_guest']))
185
-		call_user_func('ssi_' . $_GET['ssi_function']);
198
+	if (function_exists('ssi_' . $_GET['ssi_function']) && (!empty($modSettings['allow_guestAccess']) || !$user_info['is_guest'])) {
199
+			call_user_func('ssi_' . $_GET['ssi_function']);
200
+	}
186 201
 	exit;
187 202
 }
188 203
 
@@ -199,9 +214,10 @@  discard block
 block discarded – undo
199 214
  */
200 215
 function ssi_shutdown()
201 216
 {
202
-	if (!isset($_GET['ssi_function']) || $_GET['ssi_function'] != 'shutdown')
203
-		template_footer();
204
-}
217
+	if (!isset($_GET['ssi_function']) || $_GET['ssi_function'] != 'shutdown') {
218
+			template_footer();
219
+	}
220
+	}
205 221
 
206 222
 /**
207 223
  * Display a welcome message, like: Hey, User, you have 0 messages, 0 are new.
@@ -214,15 +230,17 @@  discard block
 block discarded – undo
214 230
 
215 231
 	if ($output_method == 'echo')
216 232
 	{
217
-		if ($context['user']['is_guest'])
218
-			echo sprintf($txt[$context['can_register'] ? 'welcome_guest_register' : 'welcome_guest'], $txt['guest_title'], $context['forum_name_html_safe'], $scripturl . '?action=login', 'return reqOverlayDiv(this.href, ' . JavaScriptEscape($txt['login']) . ');', $scripturl . '?action=signup');
219
-		else
220
-			echo $txt['hello_member'], ' <strong>', $context['user']['name'], '</strong>', allowedTo('pm_read') ? ', ' . (empty($context['user']['messages']) ? $txt['msg_alert_no_messages'] : (($context['user']['messages'] == 1 ? sprintf($txt['msg_alert_one_message'], $scripturl . '?action=pm') : sprintf($txt['msg_alert_many_message'], $scripturl . '?action=pm', $context['user']['messages'])) . ', ' . ($context['user']['unread_messages'] == 1 ? $txt['msg_alert_one_new'] : sprintf($txt['msg_alert_many_new'], $context['user']['unread_messages'])))) : '';
233
+		if ($context['user']['is_guest']) {
234
+					echo sprintf($txt[$context['can_register'] ? 'welcome_guest_register' : 'welcome_guest'], $txt['guest_title'], $context['forum_name_html_safe'], $scripturl . '?action=login', 'return reqOverlayDiv(this.href, ' . JavaScriptEscape($txt['login']) . ');', $scripturl . '?action=signup');
235
+		} else {
236
+					echo $txt['hello_member'], ' <strong>', $context['user']['name'], '</strong>', allowedTo('pm_read') ? ', ' . (empty($context['user']['messages']) ? $txt['msg_alert_no_messages'] : (($context['user']['messages'] == 1 ? sprintf($txt['msg_alert_one_message'], $scripturl . '?action=pm') : sprintf($txt['msg_alert_many_message'], $scripturl . '?action=pm', $context['user']['messages'])) . ', ' . ($context['user']['unread_messages'] == 1 ? $txt['msg_alert_one_new'] : sprintf($txt['msg_alert_many_new'], $context['user']['unread_messages'])))) : '';
237
+		}
221 238
 	}
222 239
 	// Don't echo... then do what?!
223
-	else
224
-		return $context['user'];
225
-}
240
+	else {
241
+			return $context['user'];
242
+	}
243
+	}
226 244
 
227 245
 /**
228 246
  * Display a menu bar, like is displayed at the top of the forum.
@@ -233,12 +251,14 @@  discard block
 block discarded – undo
233 251
 {
234 252
 	global $context;
235 253
 
236
-	if ($output_method == 'echo')
237
-		template_menu();
254
+	if ($output_method == 'echo') {
255
+			template_menu();
256
+	}
238 257
 	// What else could this do?
239
-	else
240
-		return $context['menu_buttons'];
241
-}
258
+	else {
259
+			return $context['menu_buttons'];
260
+	}
261
+	}
242 262
 
243 263
 /**
244 264
  * Show a logout link.
@@ -250,20 +270,23 @@  discard block
 block discarded – undo
250 270
 {
251 271
 	global $context, $txt, $scripturl;
252 272
 
253
-	if ($redirect_to != '')
254
-		$_SESSION['logout_url'] = $redirect_to;
273
+	if ($redirect_to != '') {
274
+			$_SESSION['logout_url'] = $redirect_to;
275
+	}
255 276
 
256 277
 	// Guests can't log out.
257
-	if ($context['user']['is_guest'])
258
-		return false;
278
+	if ($context['user']['is_guest']) {
279
+			return false;
280
+	}
259 281
 
260 282
 	$link = '<a href="' . $scripturl . '?action=logout;' . $context['session_var'] . '=' . $context['session_id'] . '">' . $txt['logout'] . '</a>';
261 283
 
262
-	if ($output_method == 'echo')
263
-		echo $link;
264
-	else
265
-		return $link;
266
-}
284
+	if ($output_method == 'echo') {
285
+			echo $link;
286
+	} else {
287
+			return $link;
288
+	}
289
+	}
267 290
 
268 291
 /**
269 292
  * Recent post list:   [board] Subject by Poster    Date
@@ -279,17 +302,17 @@  discard block
 block discarded – undo
279 302
 	global $modSettings, $context;
280 303
 
281 304
 	// Excluding certain boards...
282
-	if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0)
283
-		$exclude_boards = array($modSettings['recycle_board']);
284
-	else
285
-		$exclude_boards = empty($exclude_boards) ? array() : (is_array($exclude_boards) ? $exclude_boards : array($exclude_boards));
305
+	if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0) {
306
+			$exclude_boards = array($modSettings['recycle_board']);
307
+	} else {
308
+			$exclude_boards = empty($exclude_boards) ? array() : (is_array($exclude_boards) ? $exclude_boards : array($exclude_boards));
309
+	}
286 310
 
287 311
 	// What about including certain boards - note we do some protection here as pre-2.0 didn't have this parameter.
288 312
 	if (is_array($include_boards) || (int) $include_boards === $include_boards)
289 313
 	{
290 314
 		$include_boards = is_array($include_boards) ? $include_boards : array($include_boards);
291
-	}
292
-	elseif ($include_boards != null)
315
+	} elseif ($include_boards != null)
293 316
 	{
294 317
 		$include_boards = array();
295 318
 	}
@@ -326,8 +349,9 @@  discard block
 block discarded – undo
326 349
 {
327 350
 	global $modSettings;
328 351
 
329
-	if (empty($post_ids))
330
-		return;
352
+	if (empty($post_ids)) {
353
+			return;
354
+	}
331 355
 
332 356
 	// Allow the user to request more than one - why not?
333 357
 	$post_ids = is_array($post_ids) ? $post_ids : array($post_ids);
@@ -362,8 +386,9 @@  discard block
 block discarded – undo
362 386
 	global $scripturl, $txt, $user_info;
363 387
 	global $modSettings, $smcFunc, $context;
364 388
 
365
-	if (!empty($modSettings['enable_likes']))
366
-		$context['can_like'] = allowedTo('likes_like');
389
+	if (!empty($modSettings['enable_likes'])) {
390
+			$context['can_like'] = allowedTo('likes_like');
391
+	}
367 392
 
368 393
 	// Find all the posts. Newer ones will have higher IDs.
369 394
 	$request = $smcFunc['db_query']('substring', '
@@ -429,12 +454,13 @@  discard block
 block discarded – undo
429 454
 		);
430 455
 
431 456
 		// Get the likes for each message.
432
-		if (!empty($modSettings['enable_likes']))
433
-			$posts[$row['id_msg']]['likes'] = array(
457
+		if (!empty($modSettings['enable_likes'])) {
458
+					$posts[$row['id_msg']]['likes'] = array(
434 459
 				'count' => $row['likes'],
435 460
 				'you' => in_array($row['id_msg'], prepareLikesContext($row['id_topic'])),
436 461
 				'can_like' => !$context['user']['is_guest'] && $row['id_member'] != $context['user']['id'] && !empty($context['can_like']),
437 462
 			);
463
+		}
438 464
 	}
439 465
 	$smcFunc['db_free_result']($request);
440 466
 
@@ -442,13 +468,14 @@  discard block
 block discarded – undo
442 468
 	call_integration_hook('integrate_ssi_queryPosts', array(&$posts));
443 469
 
444 470
 	// Just return it.
445
-	if ($output_method != 'echo' || empty($posts))
446
-		return $posts;
471
+	if ($output_method != 'echo' || empty($posts)) {
472
+			return $posts;
473
+	}
447 474
 
448 475
 	echo '
449 476
 		<table style="border: none" class="ssi_table">';
450
-	foreach ($posts as $post)
451
-		echo '
477
+	foreach ($posts as $post) {
478
+			echo '
452 479
 			<tr>
453 480
 				<td style="text-align: right; vertical-align: top; white-space: nowrap">
454 481
 					[', $post['board']['link'], ']
@@ -462,6 +489,7 @@  discard block
 block discarded – undo
462 489
 					', $post['time'], '
463 490
 				</td>
464 491
 			</tr>';
492
+	}
465 493
 	echo '
466 494
 		</table>';
467 495
 }
@@ -479,25 +507,26 @@  discard block
 block discarded – undo
479 507
 	global $settings, $scripturl, $txt, $user_info;
480 508
 	global $modSettings, $smcFunc, $context;
481 509
 
482
-	if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0)
483
-		$exclude_boards = array($modSettings['recycle_board']);
484
-	else
485
-		$exclude_boards = empty($exclude_boards) ? array() : (is_array($exclude_boards) ? $exclude_boards : array($exclude_boards));
510
+	if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0) {
511
+			$exclude_boards = array($modSettings['recycle_board']);
512
+	} else {
513
+			$exclude_boards = empty($exclude_boards) ? array() : (is_array($exclude_boards) ? $exclude_boards : array($exclude_boards));
514
+	}
486 515
 
487 516
 	// Only some boards?.
488 517
 	if (is_array($include_boards) || (int) $include_boards === $include_boards)
489 518
 	{
490 519
 		$include_boards = is_array($include_boards) ? $include_boards : array($include_boards);
491
-	}
492
-	elseif ($include_boards != null)
520
+	} elseif ($include_boards != null)
493 521
 	{
494 522
 		$output_method = $include_boards;
495 523
 		$include_boards = array();
496 524
 	}
497 525
 
498 526
 	$icon_sources = array();
499
-	foreach ($context['stable_icons'] as $icon)
500
-		$icon_sources[$icon] = 'images_url';
527
+	foreach ($context['stable_icons'] as $icon) {
528
+			$icon_sources[$icon] = 'images_url';
529
+	}
501 530
 
502 531
 	// Find all the posts in distinct topics.  Newer ones will have higher IDs.
503 532
 	$request = $smcFunc['db_query']('substring', '
@@ -522,13 +551,15 @@  discard block
 block discarded – undo
522 551
 		)
523 552
 	);
524 553
 	$topics = array();
525
-	while ($row = $smcFunc['db_fetch_assoc']($request))
526
-		$topics[$row['id_topic']] = $row;
554
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
555
+			$topics[$row['id_topic']] = $row;
556
+	}
527 557
 	$smcFunc['db_free_result']($request);
528 558
 
529 559
 	// Did we find anything? If not, bail.
530
-	if (empty($topics))
531
-		return array();
560
+	if (empty($topics)) {
561
+			return array();
562
+	}
532 563
 
533 564
 	$recycle_board = !empty($modSettings['recycle_enable']) && !empty($modSettings['recycle_board']) ? (int) $modSettings['recycle_board'] : 0;
534 565
 
@@ -556,19 +587,22 @@  discard block
 block discarded – undo
556 587
 	while ($row = $smcFunc['db_fetch_assoc']($request))
557 588
 	{
558 589
 		$row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']), array('<br>' => '&#10;')));
559
-		if ($smcFunc['strlen']($row['body']) > 128)
560
-			$row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...';
590
+		if ($smcFunc['strlen']($row['body']) > 128) {
591
+					$row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...';
592
+		}
561 593
 
562 594
 		// Censor the subject.
563 595
 		censorText($row['subject']);
564 596
 		censorText($row['body']);
565 597
 
566 598
 		// Recycled icon
567
-		if (!empty($recycle_board) && $topics[$row['id_topic']]['id_board'])
568
-			$row['icon'] = 'recycled';
599
+		if (!empty($recycle_board) && $topics[$row['id_topic']]['id_board']) {
600
+					$row['icon'] = 'recycled';
601
+		}
569 602
 
570
-		if (!empty($modSettings['messageIconChecks_enable']) && !isset($icon_sources[$row['icon']]))
571
-			$icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.png') ? 'images_url' : 'default_images_url';
603
+		if (!empty($modSettings['messageIconChecks_enable']) && !isset($icon_sources[$row['icon']])) {
604
+					$icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.png') ? 'images_url' : 'default_images_url';
605
+		}
572 606
 
573 607
 		// Build the array.
574 608
 		$posts[] = array(
@@ -607,13 +641,14 @@  discard block
 block discarded – undo
607 641
 	call_integration_hook('integrate_ssi_recentTopics', array(&$posts));
608 642
 
609 643
 	// Just return it.
610
-	if ($output_method != 'echo' || empty($posts))
611
-		return $posts;
644
+	if ($output_method != 'echo' || empty($posts)) {
645
+			return $posts;
646
+	}
612 647
 
613 648
 	echo '
614 649
 		<table style="border: none" class="ssi_table">';
615
-	foreach ($posts as $post)
616
-		echo '
650
+	foreach ($posts as $post) {
651
+			echo '
617 652
 			<tr>
618 653
 				<td style="text-align: right; vertical-align: top; white-space: nowrap">
619 654
 					[', $post['board']['link'], ']
@@ -627,6 +662,7 @@  discard block
 block discarded – undo
627 662
 					', $post['time'], '
628 663
 				</td>
629 664
 			</tr>';
665
+	}
630 666
 	echo '
631 667
 		</table>';
632 668
 }
@@ -651,27 +687,30 @@  discard block
 block discarded – undo
651 687
 		)
652 688
 	);
653 689
 	$return = array();
654
-	while ($row = $smcFunc['db_fetch_assoc']($request))
655
-		$return[] = array(
690
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
691
+			$return[] = array(
656 692
 			'id' => $row['id_member'],
657 693
 			'name' => $row['real_name'],
658 694
 			'href' => $scripturl . '?action=profile;u=' . $row['id_member'],
659 695
 			'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>',
660 696
 			'posts' => $row['posts']
661 697
 		);
698
+	}
662 699
 	$smcFunc['db_free_result']($request);
663 700
 
664 701
 	// If mods want to do somthing with this list of members, let them do that now.
665 702
 	call_integration_hook('integrate_ssi_topPoster', array(&$return));
666 703
 
667 704
 	// Just return all the top posters.
668
-	if ($output_method != 'echo')
669
-		return $return;
705
+	if ($output_method != 'echo') {
706
+			return $return;
707
+	}
670 708
 
671 709
 	// Make a quick array to list the links in.
672 710
 	$temp_array = array();
673
-	foreach ($return as $member)
674
-		$temp_array[] = $member['link'];
711
+	foreach ($return as $member) {
712
+			$temp_array[] = $member['link'];
713
+	}
675 714
 
676 715
 	echo implode(', ', $temp_array);
677 716
 }
@@ -703,8 +742,8 @@  discard block
 block discarded – undo
703 742
 		)
704 743
 	);
705 744
 	$boards = array();
706
-	while ($row = $smcFunc['db_fetch_assoc']($request))
707
-		$boards[] = array(
745
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
746
+			$boards[] = array(
708 747
 			'id' => $row['id_board'],
709 748
 			'num_posts' => $row['num_posts'],
710 749
 			'num_topics' => $row['num_topics'],
@@ -713,14 +752,16 @@  discard block
 block discarded – undo
713 752
 			'href' => $scripturl . '?board=' . $row['id_board'] . '.0',
714 753
 			'link' => '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'
715 754
 		);
755
+	}
716 756
 	$smcFunc['db_free_result']($request);
717 757
 
718 758
 	// If mods want to do somthing with this list of boards, let them do that now.
719 759
 	call_integration_hook('integrate_ssi_topBoards', array(&$boards));
720 760
 
721 761
 	// If we shouldn't output or have nothing to output, just jump out.
722
-	if ($output_method != 'echo' || empty($boards))
723
-		return $boards;
762
+	if ($output_method != 'echo' || empty($boards)) {
763
+			return $boards;
764
+	}
724 765
 
725 766
 	echo '
726 767
 		<table class="ssi_table">
@@ -729,13 +770,14 @@  discard block
 block discarded – undo
729 770
 				<th style="text-align: left">', $txt['board_topics'], '</th>
730 771
 				<th style="text-align: left">', $txt['posts'], '</th>
731 772
 			</tr>';
732
-	foreach ($boards as $sBoard)
733
-		echo '
773
+	foreach ($boards as $sBoard) {
774
+			echo '
734 775
 			<tr>
735 776
 				<td>', $sBoard['link'], $sBoard['new'] ? ' <a href="' . $sBoard['href'] . '"><span class="new_posts">' . $txt['new'] . '</span></a>' : '', '</td>
736 777
 				<td style="text-align: right">', comma_format($sBoard['num_topics']), '</td>
737 778
 				<td style="text-align: right">', comma_format($sBoard['num_posts']), '</td>
738 779
 			</tr>';
780
+	}
739 781
 	echo '
740 782
 		</table>';
741 783
 }
@@ -768,12 +810,13 @@  discard block
 block discarded – undo
768 810
 			)
769 811
 		);
770 812
 		$topic_ids = array();
771
-		while ($row = $smcFunc['db_fetch_assoc']($request))
772
-			$topic_ids[] = $row['id_topic'];
813
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
814
+					$topic_ids[] = $row['id_topic'];
815
+		}
773 816
 		$smcFunc['db_free_result']($request);
817
+	} else {
818
+			$topic_ids = array();
774 819
 	}
775
-	else
776
-		$topic_ids = array();
777 820
 
778 821
 	$request = $smcFunc['db_query']('', '
779 822
 		SELECT m.subject, m.id_topic, t.num_views, t.num_replies
@@ -812,8 +855,9 @@  discard block
 block discarded – undo
812 855
 	// If mods want to do somthing with this list of topics, let them do that now.
813 856
 	call_integration_hook('integrate_ssi_topTopics', array(&$topics, $type));
814 857
 
815
-	if ($output_method != 'echo' || empty($topics))
816
-		return $topics;
858
+	if ($output_method != 'echo' || empty($topics)) {
859
+			return $topics;
860
+	}
817 861
 
818 862
 	echo '
819 863
 		<table class="ssi_table">
@@ -822,8 +866,8 @@  discard block
 block discarded – undo
822 866
 				<th style="text-align: left">', $txt['views'], '</th>
823 867
 				<th style="text-align: left">', $txt['replies'], '</th>
824 868
 			</tr>';
825
-	foreach ($topics as $sTopic)
826
-		echo '
869
+	foreach ($topics as $sTopic) {
870
+			echo '
827 871
 			<tr>
828 872
 				<td style="text-align: left">
829 873
 					', $sTopic['link'], '
@@ -831,6 +875,7 @@  discard block
 block discarded – undo
831 875
 				<td style="text-align: right">', comma_format($sTopic['num_views']), '</td>
832 876
 				<td style="text-align: right">', comma_format($sTopic['num_replies']), '</td>
833 877
 			</tr>';
878
+	}
834 879
 	echo '
835 880
 		</table>';
836 881
 }
@@ -866,12 +911,13 @@  discard block
 block discarded – undo
866 911
 {
867 912
 	global $txt, $context;
868 913
 
869
-	if ($output_method == 'echo')
870
-		echo '
914
+	if ($output_method == 'echo') {
915
+			echo '
871 916
 	', sprintf($txt['welcome_newest_member'], $context['common_stats']['latest_member']['link']), '<br>';
872
-	else
873
-		return $context['common_stats']['latest_member'];
874
-}
917
+	} else {
918
+			return $context['common_stats']['latest_member'];
919
+	}
920
+	}
875 921
 
876 922
 /**
877 923
  * Fetches a random member.
@@ -920,8 +966,9 @@  discard block
 block discarded – undo
920 966
 	}
921 967
 
922 968
 	// Just to be sure put the random generator back to something... random.
923
-	if ($random_type != '')
924
-		mt_srand(time());
969
+	if ($random_type != '') {
970
+			mt_srand(time());
971
+	}
925 972
 
926 973
 	return $result;
927 974
 }
@@ -934,8 +981,9 @@  discard block
 block discarded – undo
934 981
  */
935 982
 function ssi_fetchMember($member_ids = array(), $output_method = 'echo')
936 983
 {
937
-	if (empty($member_ids))
938
-		return;
984
+	if (empty($member_ids)) {
985
+			return;
986
+	}
939 987
 
940 988
 	// Can have more than one member if you really want...
941 989
 	$member_ids = is_array($member_ids) ? $member_ids : array($member_ids);
@@ -960,8 +1008,9 @@  discard block
 block discarded – undo
960 1008
  */
961 1009
 function ssi_fetchGroupMembers($group_id = null, $output_method = 'echo')
962 1010
 {
963
-	if ($group_id === null)
964
-		return;
1011
+	if ($group_id === null) {
1012
+			return;
1013
+	}
965 1014
 
966 1015
 	$query_where = '
967 1016
 		id_group = {int:id_group}
@@ -988,8 +1037,9 @@  discard block
 block discarded – undo
988 1037
 {
989 1038
 	global $smcFunc, $memberContext;
990 1039
 
991
-	if ($query_where === null)
992
-		return;
1040
+	if ($query_where === null) {
1041
+			return;
1042
+	}
993 1043
 
994 1044
 	// Fetch the members in question.
995 1045
 	$request = $smcFunc['db_query']('', '
@@ -1002,12 +1052,14 @@  discard block
 block discarded – undo
1002 1052
 		))
1003 1053
 	);
1004 1054
 	$members = array();
1005
-	while ($row = $smcFunc['db_fetch_assoc']($request))
1006
-		$members[] = $row['id_member'];
1055
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
1056
+			$members[] = $row['id_member'];
1057
+	}
1007 1058
 	$smcFunc['db_free_result']($request);
1008 1059
 
1009
-	if (empty($members))
1010
-		return array();
1060
+	if (empty($members)) {
1061
+			return array();
1062
+	}
1011 1063
 
1012 1064
 	// If mods want to do somthing with this list of members, let them do that now.
1013 1065
 	call_integration_hook('integrate_ssi_queryMembers', array(&$members));
@@ -1016,23 +1068,25 @@  discard block
 block discarded – undo
1016 1068
 	loadMemberData($members);
1017 1069
 
1018 1070
 	// Draw the table!
1019
-	if ($output_method == 'echo')
1020
-		echo '
1071
+	if ($output_method == 'echo') {
1072
+			echo '
1021 1073
 		<table style="border: none" class="ssi_table">';
1074
+	}
1022 1075
 
1023 1076
 	$query_members = array();
1024 1077
 	foreach ($members as $member)
1025 1078
 	{
1026 1079
 		// Load their context data.
1027
-		if (!loadMemberContext($member))
1028
-			continue;
1080
+		if (!loadMemberContext($member)) {
1081
+					continue;
1082
+		}
1029 1083
 
1030 1084
 		// Store this member's information.
1031 1085
 		$query_members[$member] = $memberContext[$member];
1032 1086
 
1033 1087
 		// Only do something if we're echo'ing.
1034
-		if ($output_method == 'echo')
1035
-			echo '
1088
+		if ($output_method == 'echo') {
1089
+					echo '
1036 1090
 			<tr>
1037 1091
 				<td style="text-align: right; vertical-align: top; white-space: nowrap">
1038 1092
 					', $query_members[$member]['link'], '
@@ -1040,12 +1094,14 @@  discard block
 block discarded – undo
1040 1094
 					<br>', $query_members[$member]['avatar']['image'], '
1041 1095
 				</td>
1042 1096
 			</tr>';
1097
+		}
1043 1098
 	}
1044 1099
 
1045 1100
 	// End the table if appropriate.
1046
-	if ($output_method == 'echo')
1047
-		echo '
1101
+	if ($output_method == 'echo') {
1102
+			echo '
1048 1103
 		</table>';
1104
+	}
1049 1105
 
1050 1106
 	// Send back the data.
1051 1107
 	return $query_members;
@@ -1060,8 +1116,9 @@  discard block
 block discarded – undo
1060 1116
 {
1061 1117
 	global $txt, $scripturl, $modSettings, $smcFunc;
1062 1118
 
1063
-	if (!allowedTo('view_stats'))
1064
-		return;
1119
+	if (!allowedTo('view_stats')) {
1120
+			return;
1121
+	}
1065 1122
 
1066 1123
 	$totals = array(
1067 1124
 		'members' => $modSettings['totalMembers'],
@@ -1090,8 +1147,9 @@  discard block
 block discarded – undo
1090 1147
 	// If mods want to do somthing with the board stats, let them do that now.
1091 1148
 	call_integration_hook('integrate_ssi_boardStats', array(&$totals));
1092 1149
 
1093
-	if ($output_method != 'echo')
1094
-		return $totals;
1150
+	if ($output_method != 'echo') {
1151
+			return $totals;
1152
+	}
1095 1153
 
1096 1154
 	echo '
1097 1155
 		', $txt['total_members'], ': <a href="', $scripturl . '?action=mlist">', comma_format($totals['members']), '</a><br>
@@ -1120,8 +1178,8 @@  discard block
 block discarded – undo
1120 1178
 	call_integration_hook('integrate_ssi_whosOnline', array(&$return));
1121 1179
 
1122 1180
 	// Add some redundancy for backwards compatibility reasons.
1123
-	if ($output_method != 'echo')
1124
-		return $return + array(
1181
+	if ($output_method != 'echo') {
1182
+			return $return + array(
1125 1183
 			'users' => $return['users_online'],
1126 1184
 			'guests' => $return['num_guests'],
1127 1185
 			'hidden' => $return['num_users_hidden'],
@@ -1129,29 +1187,35 @@  discard block
 block discarded – undo
1129 1187
 			'num_users' => $return['num_users_online'],
1130 1188
 			'total_users' => $return['num_users_online'] + $return['num_guests'],
1131 1189
 		);
1190
+	}
1132 1191
 
1133 1192
 	echo '
1134 1193
 		', comma_format($return['num_guests']), ' ', $return['num_guests'] == 1 ? $txt['guest'] : $txt['guests'], ', ', comma_format($return['num_users_online']), ' ', $return['num_users_online'] == 1 ? $txt['user'] : $txt['users'];
1135 1194
 
1136 1195
 	$bracketList = array();
1137
-	if (!empty($user_info['buddies']))
1138
-		$bracketList[] = comma_format($return['num_buddies']) . ' ' . ($return['num_buddies'] == 1 ? $txt['buddy'] : $txt['buddies']);
1139
-	if (!empty($return['num_spiders']))
1140
-		$bracketList[] = comma_format($return['num_spiders']) . ' ' . ($return['num_spiders'] == 1 ? $txt['spider'] : $txt['spiders']);
1141
-	if (!empty($return['num_users_hidden']))
1142
-		$bracketList[] = comma_format($return['num_users_hidden']) . ' ' . $txt['hidden'];
1196
+	if (!empty($user_info['buddies'])) {
1197
+			$bracketList[] = comma_format($return['num_buddies']) . ' ' . ($return['num_buddies'] == 1 ? $txt['buddy'] : $txt['buddies']);
1198
+	}
1199
+	if (!empty($return['num_spiders'])) {
1200
+			$bracketList[] = comma_format($return['num_spiders']) . ' ' . ($return['num_spiders'] == 1 ? $txt['spider'] : $txt['spiders']);
1201
+	}
1202
+	if (!empty($return['num_users_hidden'])) {
1203
+			$bracketList[] = comma_format($return['num_users_hidden']) . ' ' . $txt['hidden'];
1204
+	}
1143 1205
 
1144
-	if (!empty($bracketList))
1145
-		echo ' (' . implode(', ', $bracketList) . ')';
1206
+	if (!empty($bracketList)) {
1207
+			echo ' (' . implode(', ', $bracketList) . ')';
1208
+	}
1146 1209
 
1147 1210
 	echo '<br>
1148 1211
 			', implode(', ', $return['list_users_online']);
1149 1212
 
1150 1213
 	// Showing membergroups?
1151
-	if (!empty($settings['show_group_key']) && !empty($return['membergroups']))
1152
-		echo '<br>
1214
+	if (!empty($settings['show_group_key']) && !empty($return['membergroups'])) {
1215
+			echo '<br>
1153 1216
 			[' . implode(']&nbsp;&nbsp;[', $return['membergroups']) . ']';
1154
-}
1217
+	}
1218
+	}
1155 1219
 
1156 1220
 /**
1157 1221
  * Just like whosOnline except it also logs the online presence.
@@ -1162,11 +1226,12 @@  discard block
 block discarded – undo
1162 1226
 {
1163 1227
 	writeLog();
1164 1228
 
1165
-	if ($output_method != 'echo')
1166
-		return ssi_whosOnline($output_method);
1167
-	else
1168
-		ssi_whosOnline($output_method);
1169
-}
1229
+	if ($output_method != 'echo') {
1230
+			return ssi_whosOnline($output_method);
1231
+	} else {
1232
+			ssi_whosOnline($output_method);
1233
+	}
1234
+	}
1170 1235
 
1171 1236
 // Shows a login box.
1172 1237
 /**
@@ -1179,11 +1244,13 @@  discard block
 block discarded – undo
1179 1244
 {
1180 1245
 	global $scripturl, $txt, $user_info, $context;
1181 1246
 
1182
-	if ($redirect_to != '')
1183
-		$_SESSION['login_url'] = $redirect_to;
1247
+	if ($redirect_to != '') {
1248
+			$_SESSION['login_url'] = $redirect_to;
1249
+	}
1184 1250
 
1185
-	if ($output_method != 'echo' || !$user_info['is_guest'])
1186
-		return $user_info['is_guest'];
1251
+	if ($output_method != 'echo' || !$user_info['is_guest']) {
1252
+			return $user_info['is_guest'];
1253
+	}
1187 1254
 
1188 1255
 	// Create a login token
1189 1256
 	createToken('login');
@@ -1235,8 +1302,9 @@  discard block
 block discarded – undo
1235 1302
 
1236 1303
 	$boardsAllowed = array_intersect(boardsAllowedTo('poll_view'), boardsAllowedTo('poll_vote'));
1237 1304
 
1238
-	if (empty($boardsAllowed))
1239
-		return array();
1305
+	if (empty($boardsAllowed)) {
1306
+			return array();
1307
+	}
1240 1308
 
1241 1309
 	$request = $smcFunc['db_query']('', '
1242 1310
 		SELECT p.id_poll, p.question, t.id_topic, p.max_votes, p.guest_vote, p.hide_results, p.expire_time
@@ -1269,12 +1337,14 @@  discard block
 block discarded – undo
1269 1337
 	$smcFunc['db_free_result']($request);
1270 1338
 
1271 1339
 	// This user has voted on all the polls.
1272
-	if (empty($row) || !is_array($row))
1273
-		return array();
1340
+	if (empty($row) || !is_array($row)) {
1341
+			return array();
1342
+	}
1274 1343
 
1275 1344
 	// If this is a guest who's voted we'll through ourselves to show poll to show the results.
1276
-	if ($user_info['is_guest'] && (!$row['guest_vote'] || (isset($_COOKIE['guest_poll_vote']) && in_array($row['id_poll'], explode(',', $_COOKIE['guest_poll_vote'])))))
1277
-		return ssi_showPoll($row['id_topic'], $output_method);
1345
+	if ($user_info['is_guest'] && (!$row['guest_vote'] || (isset($_COOKIE['guest_poll_vote']) && in_array($row['id_poll'], explode(',', $_COOKIE['guest_poll_vote']))))) {
1346
+			return ssi_showPoll($row['id_topic'], $output_method);
1347
+	}
1278 1348
 
1279 1349
 	$request = $smcFunc['db_query']('', '
1280 1350
 		SELECT COUNT(DISTINCT id_member)
@@ -1338,8 +1408,9 @@  discard block
 block discarded – undo
1338 1408
 	// If mods want to do somthing with this list of polls, let them do that now.
1339 1409
 	call_integration_hook('integrate_ssi_recentPoll', array(&$return, $topPollInstead));
1340 1410
 
1341
-	if ($output_method != 'echo')
1342
-		return $return;
1411
+	if ($output_method != 'echo') {
1412
+			return $return;
1413
+	}
1343 1414
 
1344 1415
 	if ($allow_view_results)
1345 1416
 	{
@@ -1348,19 +1419,20 @@  discard block
 block discarded – undo
1348 1419
 			<strong>', $return['question'], '</strong><br>
1349 1420
 			', !empty($return['allowed_warning']) ? $return['allowed_warning'] . '<br>' : '';
1350 1421
 
1351
-		foreach ($return['options'] as $option)
1352
-			echo '
1422
+		foreach ($return['options'] as $option) {
1423
+					echo '
1353 1424
 			<label for="', $option['id'], '">', $option['vote_button'], ' ', $option['option'], '</label><br>';
1425
+		}
1354 1426
 
1355 1427
 		echo '
1356 1428
 			<input type="submit" value="', $txt['poll_vote'], '" class="button_submit">
1357 1429
 			<input type="hidden" name="poll" value="', $return['id'], '">
1358 1430
 			<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
1359 1431
 		</form>';
1432
+	} else {
1433
+			echo $txt['poll_cannot_see'];
1434
+	}
1360 1435
 	}
1361
-	else
1362
-		echo $txt['poll_cannot_see'];
1363
-}
1364 1436
 
1365 1437
 /**
1366 1438
  * Shows the poll from the specified topic
@@ -1374,13 +1446,15 @@  discard block
 block discarded – undo
1374 1446
 
1375 1447
 	$boardsAllowed = boardsAllowedTo('poll_view');
1376 1448
 
1377
-	if (empty($boardsAllowed))
1378
-		return array();
1449
+	if (empty($boardsAllowed)) {
1450
+			return array();
1451
+	}
1379 1452
 
1380
-	if ($topic === null && isset($_REQUEST['ssi_topic']))
1381
-		$topic = (int) $_REQUEST['ssi_topic'];
1382
-	else
1383
-		$topic = (int) $topic;
1453
+	if ($topic === null && isset($_REQUEST['ssi_topic'])) {
1454
+			$topic = (int) $_REQUEST['ssi_topic'];
1455
+	} else {
1456
+			$topic = (int) $topic;
1457
+	}
1384 1458
 
1385 1459
 	$request = $smcFunc['db_query']('', '
1386 1460
 		SELECT
@@ -1401,17 +1475,18 @@  discard block
 block discarded – undo
1401 1475
 	);
1402 1476
 
1403 1477
 	// Either this topic has no poll, or the user cannot view it.
1404
-	if ($smcFunc['db_num_rows']($request) == 0)
1405
-		return array();
1478
+	if ($smcFunc['db_num_rows']($request) == 0) {
1479
+			return array();
1480
+	}
1406 1481
 
1407 1482
 	$row = $smcFunc['db_fetch_assoc']($request);
1408 1483
 	$smcFunc['db_free_result']($request);
1409 1484
 
1410 1485
 	// Check if they can vote.
1411 1486
 	$already_voted = false;
1412
-	if (!empty($row['expire_time']) && $row['expire_time'] < time())
1413
-		$allow_vote = false;
1414
-	elseif ($user_info['is_guest'])
1487
+	if (!empty($row['expire_time']) && $row['expire_time'] < time()) {
1488
+			$allow_vote = false;
1489
+	} elseif ($user_info['is_guest'])
1415 1490
 	{
1416 1491
 		// There's a difference between "allowed to vote" and "already voted"...
1417 1492
 		$allow_vote = $row['guest_vote'];
@@ -1421,10 +1496,9 @@  discard block
 block discarded – undo
1421 1496
 		{
1422 1497
 			$already_voted = true;
1423 1498
 		}
1424
-	}
1425
-	elseif (!empty($row['voting_locked']) || !allowedTo('poll_vote', $row['id_board']))
1426
-		$allow_vote = false;
1427
-	else
1499
+	} elseif (!empty($row['voting_locked']) || !allowedTo('poll_vote', $row['id_board'])) {
1500
+			$allow_vote = false;
1501
+	} else
1428 1502
 	{
1429 1503
 		$request = $smcFunc['db_query']('', '
1430 1504
 			SELECT id_member
@@ -1506,8 +1580,9 @@  discard block
 block discarded – undo
1506 1580
 	// If mods want to do somthing with this poll, let them do that now.
1507 1581
 	call_integration_hook('integrate_ssi_showPoll', array(&$return));
1508 1582
 
1509
-	if ($output_method != 'echo')
1510
-		return $return;
1583
+	if ($output_method != 'echo') {
1584
+			return $return;
1585
+	}
1511 1586
 
1512 1587
 	if ($return['allow_vote'])
1513 1588
 	{
@@ -1516,17 +1591,17 @@  discard block
 block discarded – undo
1516 1591
 				<strong>', $return['question'], '</strong><br>
1517 1592
 				', !empty($return['allowed_warning']) ? $return['allowed_warning'] . '<br>' : '';
1518 1593
 
1519
-		foreach ($return['options'] as $option)
1520
-			echo '
1594
+		foreach ($return['options'] as $option) {
1595
+					echo '
1521 1596
 				<label for="', $option['id'], '">', $option['vote_button'], ' ', $option['option'], '</label><br>';
1597
+		}
1522 1598
 
1523 1599
 		echo '
1524 1600
 				<input type="submit" value="', $txt['poll_vote'], '" class="button_submit">
1525 1601
 				<input type="hidden" name="poll" value="', $return['id'], '">
1526 1602
 				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
1527 1603
 			</form>';
1528
-	}
1529
-	else
1604
+	} else
1530 1605
 	{
1531 1606
 		echo '
1532 1607
 			<div class="ssi_poll">
@@ -1606,27 +1681,32 @@  discard block
 block discarded – undo
1606 1681
 			'is_approved' => 1,
1607 1682
 		)
1608 1683
 	);
1609
-	if ($smcFunc['db_num_rows']($request) == 0)
1610
-		die;
1684
+	if ($smcFunc['db_num_rows']($request) == 0) {
1685
+			die;
1686
+	}
1611 1687
 	$row = $smcFunc['db_fetch_assoc']($request);
1612 1688
 	$smcFunc['db_free_result']($request);
1613 1689
 
1614
-	if (!empty($row['voting_locked']) || ($row['selected'] != -1 && !$user_info['is_guest']) || (!empty($row['expire_time']) && time() > $row['expire_time']))
1615
-		redirectexit('topic=' . $row['id_topic'] . '.0');
1690
+	if (!empty($row['voting_locked']) || ($row['selected'] != -1 && !$user_info['is_guest']) || (!empty($row['expire_time']) && time() > $row['expire_time'])) {
1691
+			redirectexit('topic=' . $row['id_topic'] . '.0');
1692
+	}
1616 1693
 
1617 1694
 	// Too many options checked?
1618
-	if (count($_REQUEST['options']) > $row['max_votes'])
1619
-		redirectexit('topic=' . $row['id_topic'] . '.0');
1695
+	if (count($_REQUEST['options']) > $row['max_votes']) {
1696
+			redirectexit('topic=' . $row['id_topic'] . '.0');
1697
+	}
1620 1698
 
1621 1699
 	// It's a guest who has already voted?
1622 1700
 	if ($user_info['is_guest'])
1623 1701
 	{
1624 1702
 		// Guest voting disabled?
1625
-		if (!$row['guest_vote'])
1626
-			redirectexit('topic=' . $row['id_topic'] . '.0');
1703
+		if (!$row['guest_vote']) {
1704
+					redirectexit('topic=' . $row['id_topic'] . '.0');
1705
+		}
1627 1706
 		// Already voted?
1628
-		elseif (isset($_COOKIE['guest_poll_vote']) && in_array($row['id_poll'], explode(',', $_COOKIE['guest_poll_vote'])))
1629
-			redirectexit('topic=' . $row['id_topic'] . '.0');
1707
+		elseif (isset($_COOKIE['guest_poll_vote']) && in_array($row['id_poll'], explode(',', $_COOKIE['guest_poll_vote']))) {
1708
+					redirectexit('topic=' . $row['id_topic'] . '.0');
1709
+		}
1630 1710
 	}
1631 1711
 
1632 1712
 	$sOptions = array();
@@ -1680,11 +1760,13 @@  discard block
 block discarded – undo
1680 1760
 {
1681 1761
 	global $scripturl, $txt, $context;
1682 1762
 
1683
-	if (!allowedTo('search_posts'))
1684
-		return;
1763
+	if (!allowedTo('search_posts')) {
1764
+			return;
1765
+	}
1685 1766
 
1686
-	if ($output_method != 'echo')
1687
-		return $scripturl . '?action=search';
1767
+	if ($output_method != 'echo') {
1768
+			return $scripturl . '?action=search';
1769
+	}
1688 1770
 
1689 1771
 	echo '
1690 1772
 		<form action="', $scripturl, '?action=search2" method="post" accept-charset="', $context['character_set'], '">
@@ -1706,8 +1788,9 @@  discard block
 block discarded – undo
1706 1788
 	// If mods want to do somthing with the news, let them do that now. Don't need to pass the news line itself, since it is already in $context.
1707 1789
 	call_integration_hook('integrate_ssi_news');
1708 1790
 
1709
-	if ($output_method != 'echo')
1710
-		return $context['random_news_line'];
1791
+	if ($output_method != 'echo') {
1792
+			return $context['random_news_line'];
1793
+	}
1711 1794
 
1712 1795
 	echo $context['random_news_line'];
1713 1796
 }
@@ -1721,8 +1804,9 @@  discard block
 block discarded – undo
1721 1804
 {
1722 1805
 	global $scripturl, $modSettings, $user_info;
1723 1806
 
1724
-	if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view') || !allowedTo('profile_view'))
1725
-		return;
1807
+	if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view') || !allowedTo('profile_view')) {
1808
+			return;
1809
+	}
1726 1810
 
1727 1811
 	$eventOptions = array(
1728 1812
 		'include_birthdays' => true,
@@ -1733,13 +1817,15 @@  discard block
 block discarded – undo
1733 1817
 	// The ssi_todaysCalendar variants all use the same hook and just pass on $eventOptions so the hooked code can distinguish different cases if necessary
1734 1818
 	call_integration_hook('integrate_ssi_calendar', array(&$return, $eventOptions));
1735 1819
 
1736
-	if ($output_method != 'echo')
1737
-		return $return['calendar_birthdays'];
1820
+	if ($output_method != 'echo') {
1821
+			return $return['calendar_birthdays'];
1822
+	}
1738 1823
 
1739
-	foreach ($return['calendar_birthdays'] as $member)
1740
-		echo '
1824
+	foreach ($return['calendar_birthdays'] as $member) {
1825
+			echo '
1741 1826
 			<a href="', $scripturl, '?action=profile;u=', $member['id'], '"><span class="fix_rtl_names">' . $member['name'] . '</span>' . (isset($member['age']) ? ' (' . $member['age'] . ')' : '') . '</a>' . (!$member['is_last'] ? ', ' : '');
1742
-}
1827
+	}
1828
+	}
1743 1829
 
1744 1830
 /**
1745 1831
  * Shows today's holidays.
@@ -1750,8 +1836,9 @@  discard block
 block discarded – undo
1750 1836
 {
1751 1837
 	global $modSettings, $user_info;
1752 1838
 
1753
-	if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view'))
1754
-		return;
1839
+	if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) {
1840
+			return;
1841
+	}
1755 1842
 
1756 1843
 	$eventOptions = array(
1757 1844
 		'include_holidays' => true,
@@ -1762,8 +1849,9 @@  discard block
 block discarded – undo
1762 1849
 	// The ssi_todaysCalendar variants all use the same hook and just pass on $eventOptions so the hooked code can distinguish different cases if necessary
1763 1850
 	call_integration_hook('integrate_ssi_calendar', array(&$return, $eventOptions));
1764 1851
 
1765
-	if ($output_method != 'echo')
1766
-		return $return['calendar_holidays'];
1852
+	if ($output_method != 'echo') {
1853
+			return $return['calendar_holidays'];
1854
+	}
1767 1855
 
1768 1856
 	echo '
1769 1857
 		', implode(', ', $return['calendar_holidays']);
@@ -1777,8 +1865,9 @@  discard block
 block discarded – undo
1777 1865
 {
1778 1866
 	global $modSettings, $user_info;
1779 1867
 
1780
-	if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view'))
1781
-		return;
1868
+	if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) {
1869
+			return;
1870
+	}
1782 1871
 
1783 1872
 	$eventOptions = array(
1784 1873
 		'include_events' => true,
@@ -1789,14 +1878,16 @@  discard block
 block discarded – undo
1789 1878
 	// The ssi_todaysCalendar variants all use the same hook and just pass on $eventOptions so the hooked code can distinguish different cases if necessary
1790 1879
 	call_integration_hook('integrate_ssi_calendar', array(&$return, $eventOptions));
1791 1880
 
1792
-	if ($output_method != 'echo')
1793
-		return $return['calendar_events'];
1881
+	if ($output_method != 'echo') {
1882
+			return $return['calendar_events'];
1883
+	}
1794 1884
 
1795 1885
 	foreach ($return['calendar_events'] as $event)
1796 1886
 	{
1797
-		if ($event['can_edit'])
1798
-			echo '
1887
+		if ($event['can_edit']) {
1888
+					echo '
1799 1889
 	<a href="' . $event['modify_href'] . '" style="color: #ff0000;">*</a> ';
1890
+		}
1800 1891
 		echo '
1801 1892
 	' . $event['link'] . (!$event['is_last'] ? ', ' : '');
1802 1893
 	}
@@ -1811,8 +1902,9 @@  discard block
 block discarded – undo
1811 1902
 {
1812 1903
 	global $modSettings, $txt, $scripturl, $user_info;
1813 1904
 
1814
-	if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view'))
1815
-		return;
1905
+	if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) {
1906
+			return;
1907
+	}
1816 1908
 
1817 1909
 	$eventOptions = array(
1818 1910
 		'include_birthdays' => allowedTo('profile_view'),
@@ -1825,19 +1917,22 @@  discard block
 block discarded – undo
1825 1917
 	// The ssi_todaysCalendar variants all use the same hook and just pass on $eventOptions so the hooked code can distinguish different cases if necessary
1826 1918
 	call_integration_hook('integrate_ssi_calendar', array(&$return, $eventOptions));
1827 1919
 
1828
-	if ($output_method != 'echo')
1829
-		return $return;
1920
+	if ($output_method != 'echo') {
1921
+			return $return;
1922
+	}
1830 1923
 
1831
-	if (!empty($return['calendar_holidays']))
1832
-		echo '
1924
+	if (!empty($return['calendar_holidays'])) {
1925
+			echo '
1833 1926
 			<span class="holiday">' . $txt['calendar_prompt'] . ' ' . implode(', ', $return['calendar_holidays']) . '<br></span>';
1927
+	}
1834 1928
 	if (!empty($return['calendar_birthdays']))
1835 1929
 	{
1836 1930
 		echo '
1837 1931
 			<span class="birthday">' . $txt['birthdays_upcoming'] . '</span> ';
1838
-		foreach ($return['calendar_birthdays'] as $member)
1839
-			echo '
1932
+		foreach ($return['calendar_birthdays'] as $member) {
1933
+					echo '
1840 1934
 			<a href="', $scripturl, '?action=profile;u=', $member['id'], '"><span class="fix_rtl_names">', $member['name'], '</span>', isset($member['age']) ? ' (' . $member['age'] . ')' : '', '</a>', !$member['is_last'] ? ', ' : '';
1935
+		}
1841 1936
 		echo '
1842 1937
 			<br>';
1843 1938
 	}
@@ -1847,9 +1942,10 @@  discard block
 block discarded – undo
1847 1942
 			<span class="event">' . $txt['events_upcoming'] . '</span> ';
1848 1943
 		foreach ($return['calendar_events'] as $event)
1849 1944
 		{
1850
-			if ($event['can_edit'])
1851
-				echo '
1945
+			if ($event['can_edit']) {
1946
+							echo '
1852 1947
 			<a href="' . $event['modify_href'] . '" style="color: #ff0000;">*</a> ';
1948
+			}
1853 1949
 			echo '
1854 1950
 			' . $event['link'] . (!$event['is_last'] ? ', ' : '');
1855 1951
 		}
@@ -1873,25 +1969,29 @@  discard block
 block discarded – undo
1873 1969
 	loadLanguage('Stats');
1874 1970
 
1875 1971
 	// Must be integers....
1876
-	if ($limit === null)
1877
-		$limit = isset($_GET['limit']) ? (int) $_GET['limit'] : 5;
1878
-	else
1879
-		$limit = (int) $limit;
1880
-
1881
-	if ($start === null)
1882
-		$start = isset($_GET['start']) ? (int) $_GET['start'] : 0;
1883
-	else
1884
-		$start = (int) $start;
1885
-
1886
-	if ($board !== null)
1887
-		$board = (int) $board;
1888
-	elseif (isset($_GET['board']))
1889
-		$board = (int) $_GET['board'];
1890
-
1891
-	if ($length === null)
1892
-		$length = isset($_GET['length']) ? (int) $_GET['length'] : 0;
1893
-	else
1894
-		$length = (int) $length;
1972
+	if ($limit === null) {
1973
+			$limit = isset($_GET['limit']) ? (int) $_GET['limit'] : 5;
1974
+	} else {
1975
+			$limit = (int) $limit;
1976
+	}
1977
+
1978
+	if ($start === null) {
1979
+			$start = isset($_GET['start']) ? (int) $_GET['start'] : 0;
1980
+	} else {
1981
+			$start = (int) $start;
1982
+	}
1983
+
1984
+	if ($board !== null) {
1985
+			$board = (int) $board;
1986
+	} elseif (isset($_GET['board'])) {
1987
+			$board = (int) $_GET['board'];
1988
+	}
1989
+
1990
+	if ($length === null) {
1991
+			$length = isset($_GET['length']) ? (int) $_GET['length'] : 0;
1992
+	} else {
1993
+			$length = (int) $length;
1994
+	}
1895 1995
 
1896 1996
 	$limit = max(0, $limit);
1897 1997
 	$start = max(0, $start);
@@ -1909,17 +2009,19 @@  discard block
 block discarded – undo
1909 2009
 	);
1910 2010
 	if ($smcFunc['db_num_rows']($request) == 0)
1911 2011
 	{
1912
-		if ($output_method == 'echo')
1913
-			die($txt['ssi_no_guests']);
1914
-		else
1915
-			return array();
2012
+		if ($output_method == 'echo') {
2013
+					die($txt['ssi_no_guests']);
2014
+		} else {
2015
+					return array();
2016
+		}
1916 2017
 	}
1917 2018
 	list ($board) = $smcFunc['db_fetch_row']($request);
1918 2019
 	$smcFunc['db_free_result']($request);
1919 2020
 
1920 2021
 	$icon_sources = array();
1921
-	foreach ($context['stable_icons'] as $icon)
1922
-		$icon_sources[$icon] = 'images_url';
2022
+	foreach ($context['stable_icons'] as $icon) {
2023
+			$icon_sources[$icon] = 'images_url';
2024
+	}
1923 2025
 
1924 2026
 	if (!empty($modSettings['enable_likes']))
1925 2027
 	{
@@ -1943,12 +2045,14 @@  discard block
 block discarded – undo
1943 2045
 		)
1944 2046
 	);
1945 2047
 	$posts = array();
1946
-	while ($row = $smcFunc['db_fetch_assoc']($request))
1947
-		$posts[] = $row['id_first_msg'];
2048
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
2049
+			$posts[] = $row['id_first_msg'];
2050
+	}
1948 2051
 	$smcFunc['db_free_result']($request);
1949 2052
 
1950
-	if (empty($posts))
1951
-		return array();
2053
+	if (empty($posts)) {
2054
+			return array();
2055
+	}
1952 2056
 
1953 2057
 	// Find the posts.
1954 2058
 	$request = $smcFunc['db_query']('', '
@@ -1978,24 +2082,28 @@  discard block
 block discarded – undo
1978 2082
 			$last_space = strrpos($row['body'], ' ');
1979 2083
 			$last_open = strrpos($row['body'], '<');
1980 2084
 			$last_close = strrpos($row['body'], '>');
1981
-			if (empty($last_space) || ($last_space == $last_open + 3 && (empty($last_close) || (!empty($last_close) && $last_close < $last_open))) || $last_space < $last_open || $last_open == $length - 6)
1982
-				$cutoff = $last_open;
1983
-			elseif (empty($last_close) || $last_close < $last_open)
1984
-				$cutoff = $last_space;
2085
+			if (empty($last_space) || ($last_space == $last_open + 3 && (empty($last_close) || (!empty($last_close) && $last_close < $last_open))) || $last_space < $last_open || $last_open == $length - 6) {
2086
+							$cutoff = $last_open;
2087
+			} elseif (empty($last_close) || $last_close < $last_open) {
2088
+							$cutoff = $last_space;
2089
+			}
1985 2090
 
1986
-			if ($cutoff !== false)
1987
-				$row['body'] = $smcFunc['substr']($row['body'], 0, $cutoff);
2091
+			if ($cutoff !== false) {
2092
+							$row['body'] = $smcFunc['substr']($row['body'], 0, $cutoff);
2093
+			}
1988 2094
 			$row['body'] .= '...';
1989 2095
 		}
1990 2096
 
1991 2097
 		$row['body'] = parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']);
1992 2098
 
1993
-		if (!empty($recycle_board) && $row['id_board'] == $recycle_board)
1994
-			$row['icon'] = 'recycled';
2099
+		if (!empty($recycle_board) && $row['id_board'] == $recycle_board) {
2100
+					$row['icon'] = 'recycled';
2101
+		}
1995 2102
 
1996 2103
 		// Check that this message icon is there...
1997
-		if (!empty($modSettings['messageIconChecks_enable']) && !isset($icon_sources[$row['icon']]))
1998
-			$icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.png') ? 'images_url' : 'default_images_url';
2104
+		if (!empty($modSettings['messageIconChecks_enable']) && !isset($icon_sources[$row['icon']])) {
2105
+					$icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.png') ? 'images_url' : 'default_images_url';
2106
+		}
1999 2107
 
2000 2108
 		censorText($row['subject']);
2001 2109
 		censorText($row['body']);
@@ -2032,16 +2140,18 @@  discard block
 block discarded – undo
2032 2140
 	}
2033 2141
 	$smcFunc['db_free_result']($request);
2034 2142
 
2035
-	if (empty($return))
2036
-		return $return;
2143
+	if (empty($return)) {
2144
+			return $return;
2145
+	}
2037 2146
 
2038 2147
 	$return[count($return) - 1]['is_last'] = true;
2039 2148
 
2040 2149
 	// If mods want to do somthing with this list of posts, let them do that now.
2041 2150
 	call_integration_hook('integrate_ssi_boardNews', array(&$return));
2042 2151
 
2043
-	if ($output_method != 'echo')
2044
-		return $return;
2152
+	if ($output_method != 'echo') {
2153
+			return $return;
2154
+	}
2045 2155
 
2046 2156
 	foreach ($return as $news)
2047 2157
 	{
@@ -2093,9 +2203,10 @@  discard block
 block discarded – undo
2093 2203
 		echo '
2094 2204
 			</div>';
2095 2205
 
2096
-		if (!$news['is_last'])
2097
-			echo '
2206
+		if (!$news['is_last']) {
2207
+					echo '
2098 2208
 			<hr>';
2209
+		}
2099 2210
 	}
2100 2211
 }
2101 2212
 
@@ -2109,8 +2220,9 @@  discard block
 block discarded – undo
2109 2220
 {
2110 2221
 	global $user_info, $scripturl, $modSettings, $txt, $context, $smcFunc;
2111 2222
 
2112
-	if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view'))
2113
-		return;
2223
+	if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) {
2224
+			return;
2225
+	}
2114 2226
 
2115 2227
 	// Find all events which are happening in the near future that the member can see.
2116 2228
 	$request = $smcFunc['db_query']('', '
@@ -2136,20 +2248,23 @@  discard block
 block discarded – undo
2136 2248
 	while ($row = $smcFunc['db_fetch_assoc']($request))
2137 2249
 	{
2138 2250
 		// Check if we've already come by an event linked to this same topic with the same title... and don't display it if we have.
2139
-		if (!empty($duplicates[$row['title'] . $row['id_topic']]))
2140
-			continue;
2251
+		if (!empty($duplicates[$row['title'] . $row['id_topic']])) {
2252
+					continue;
2253
+		}
2141 2254
 
2142 2255
 		// Censor the title.
2143 2256
 		censorText($row['title']);
2144 2257
 
2145
-		if ($row['start_date'] < strftime('%Y-%m-%d', forum_time(false)))
2146
-			$date = strftime('%Y-%m-%d', forum_time(false));
2147
-		else
2148
-			$date = $row['start_date'];
2258
+		if ($row['start_date'] < strftime('%Y-%m-%d', forum_time(false))) {
2259
+					$date = strftime('%Y-%m-%d', forum_time(false));
2260
+		} else {
2261
+					$date = $row['start_date'];
2262
+		}
2149 2263
 
2150 2264
 		// If the topic it is attached to is not approved then don't link it.
2151
-		if (!empty($row['id_first_msg']) && !$row['approved'])
2152
-			$row['id_board'] = $row['id_topic'] = $row['id_first_msg'] = 0;
2265
+		if (!empty($row['id_first_msg']) && !$row['approved']) {
2266
+					$row['id_board'] = $row['id_topic'] = $row['id_first_msg'] = 0;
2267
+		}
2153 2268
 
2154 2269
 		$allday = (empty($row['start_time']) || empty($row['end_time']) || empty($row['timezone']) || !in_array($row['timezone'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) ? true : false;
2155 2270
 
@@ -2175,24 +2290,27 @@  discard block
 block discarded – undo
2175 2290
 	}
2176 2291
 	$smcFunc['db_free_result']($request);
2177 2292
 
2178
-	foreach ($return as $mday => $array)
2179
-		$return[$mday][count($array) - 1]['is_last'] = true;
2293
+	foreach ($return as $mday => $array) {
2294
+			$return[$mday][count($array) - 1]['is_last'] = true;
2295
+	}
2180 2296
 
2181 2297
 	// If mods want to do somthing with this list of events, let them do that now.
2182 2298
 	call_integration_hook('integrate_ssi_recentEvents', array(&$return));
2183 2299
 
2184
-	if ($output_method != 'echo' || empty($return))
2185
-		return $return;
2300
+	if ($output_method != 'echo' || empty($return)) {
2301
+			return $return;
2302
+	}
2186 2303
 
2187 2304
 	// Well the output method is echo.
2188 2305
 	echo '
2189 2306
 			<span class="event">' . $txt['events'] . '</span> ';
2190
-	foreach ($return as $mday => $array)
2191
-		foreach ($array as $event)
2307
+	foreach ($return as $mday => $array) {
2308
+			foreach ($array as $event)
2192 2309
 		{
2193 2310
 			if ($event['can_edit'])
2194 2311
 				echo '
2195 2312
 				<a href="' . $event['modify_href'] . '" style="color: #ff0000;">*</a> ';
2313
+	}
2196 2314
 
2197 2315
 			echo '
2198 2316
 				' . $event['link'] . (!$event['is_last'] ? ', ' : '');
@@ -2211,8 +2329,9 @@  discard block
 block discarded – undo
2211 2329
 	global $smcFunc;
2212 2330
 
2213 2331
 	// If $id is null, this was most likely called from a query string and should do nothing.
2214
-	if ($id === null)
2215
-		return;
2332
+	if ($id === null) {
2333
+			return;
2334
+	}
2216 2335
 
2217 2336
 	$request = $smcFunc['db_query']('', '
2218 2337
 		SELECT passwd, member_name, is_activated
@@ -2244,8 +2363,9 @@  discard block
 block discarded – undo
2244 2363
 	$attachments_boards = boardsAllowedTo('view_attachments');
2245 2364
 
2246 2365
 	// No boards?  Adios amigo.
2247
-	if (empty($attachments_boards))
2248
-		return array();
2366
+	if (empty($attachments_boards)) {
2367
+			return array();
2368
+	}
2249 2369
 
2250 2370
 	// Is it an array?
2251 2371
 	$attachment_ext = (array) $attachment_ext;
@@ -2329,8 +2449,9 @@  discard block
 block discarded – undo
2329 2449
 	call_integration_hook('integrate_ssi_recentAttachments', array(&$attachments));
2330 2450
 
2331 2451
 	// So you just want an array?  Here you can have it.
2332
-	if ($output_method == 'array' || empty($attachments))
2333
-		return $attachments;
2452
+	if ($output_method == 'array' || empty($attachments)) {
2453
+			return $attachments;
2454
+	}
2334 2455
 
2335 2456
 	// Give them the default.
2336 2457
 	echo '
@@ -2341,14 +2462,15 @@  discard block
 block discarded – undo
2341 2462
 				<th style="text-align: left; padding: 2">', $txt['downloads'], '</th>
2342 2463
 				<th style="text-align: left; padding: 2">', $txt['filesize'], '</th>
2343 2464
 			</tr>';
2344
-	foreach ($attachments as $attach)
2345
-		echo '
2465
+	foreach ($attachments as $attach) {
2466
+			echo '
2346 2467
 			<tr>
2347 2468
 				<td>', $attach['file']['link'], '</td>
2348 2469
 				<td>', $attach['member']['link'], '</td>
2349 2470
 				<td style="text-align: center">', $attach['file']['downloads'], '</td>
2350 2471
 				<td>', $attach['file']['filesize'], '</td>
2351 2472
 			</tr>';
2473
+	}
2352 2474
 	echo '
2353 2475
 		</table>';
2354 2476
 }
Please login to merge, or discard this patch.