Completed
Pull Request — release-2.1 (#4029)
by Mert
09:24 queued 21s
created
Sources/DbSearch-mysql.php 1 patch
Braces   +13 added lines, -10 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 3
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 /**
20 21
  *  Add the file functions to the $smcFunc array.
@@ -23,14 +24,15 @@  discard block
 block discarded – undo
23 24
 {
24 25
 	global $smcFunc;
25 26
 
26
-	if (!isset($smcFunc['db_search_query']) || $smcFunc['db_search_query'] != 'smf_db_query')
27
-		$smcFunc += array(
27
+	if (!isset($smcFunc['db_search_query']) || $smcFunc['db_search_query'] != 'smf_db_query') {
28
+			$smcFunc += array(
28 29
 			'db_search_query' => 'smf_db_query',
29 30
 			'db_search_support' => 'smf_db_search_support',
30 31
 			'db_create_word_search' => 'smf_db_create_word_search',
31 32
 			'db_support_ignore' => true,
32 33
 		);
33
-}
34
+	}
35
+	}
34 36
 
35 37
 /**
36 38
  * This function will tell you whether this database type supports this search type.
@@ -54,12 +56,13 @@  discard block
 block discarded – undo
54 56
 {
55 57
 	global $smcFunc;
56 58
 
57
-	if ($size == 'small')
58
-		$size = 'smallint(5)';
59
-	elseif ($size == 'medium')
60
-		$size = 'mediumint(8)';
61
-	else
62
-		$size = 'int(10)';
59
+	if ($size == 'small') {
60
+			$size = 'smallint(5)';
61
+	} elseif ($size == 'medium') {
62
+			$size = 'mediumint(8)';
63
+	} else {
64
+			$size = 'int(10)';
65
+	}
63 66
 
64 67
 	$smcFunc['db_query']('', '
65 68
 		CREATE TABLE {db_prefix}log_search_words (
Please login to merge, or discard this patch.
Sources/Notify.php 1 patch
Braces   +23 added lines, -20 removed lines patch added patch discarded remove patch
@@ -14,8 +14,9 @@  discard block
 block discarded – undo
14 14
  * @version 2.1 Beta 3
15 15
  */
16 16
 
17
-if (!defined('SMF'))
17
+if (!defined('SMF')) {
18 18
 	die('No direct access...');
19
+}
19 20
 
20 21
 /**
21 22
  * Turn off/on notification for a particular board.
@@ -34,8 +35,9 @@  discard block
 block discarded – undo
34 35
 	is_not_guest();
35 36
 
36 37
 	// You have to specify a board to turn notifications on!
37
-	if (empty($board))
38
-		fatal_lang_error('no_board', false);
38
+	if (empty($board)) {
39
+			fatal_lang_error('no_board', false);
40
+	}
39 41
 
40 42
 	// No subaction: find out what to do.
41 43
 	if (isset($_GET['mode']))
@@ -48,16 +50,16 @@  discard block
 block discarded – undo
48 50
 		require_once($sourcedir . '/Subs-Notify.php');
49 51
 		setNotifyPrefs($user_info['id'], array('board_notify_' . $board => $alertPref));
50 52
 
51
-		if ($mode > 1)
52
-			// Turn notification on.  (note this just blows smoke if it's already on.)
53
+		if ($mode > 1) {
54
+					// Turn notification on.  (note this just blows smoke if it's already on.)
53 55
 			$smcFunc['db_insert']('ignore',
54 56
 				'{db_prefix}log_notify',
55 57
 				array('id_member' => 'int', 'id_board' => 'int'),
56 58
 				array($user_info['id'], $board),
57 59
 				array('id_member', 'id_board')
58 60
 			);
59
-		else
60
-			$smcFunc['db_query']('', '
61
+		} else {
62
+					$smcFunc['db_query']('', '
61 63
 				DELETE FROM {db_prefix}log_notify
62 64
 				WHERE id_member = {int:current_member}
63 65
 				AND id_board = {int:current_board}',
@@ -66,6 +68,7 @@  discard block
 block discarded – undo
66 68
 					'current_member' => $user_info['id'],
67 69
 				)
68 70
 			);
71
+		}
69 72
 
70 73
 	}
71 74
 
@@ -81,10 +84,10 @@  discard block
 block discarded – undo
81 84
 			),
82 85
 		);
83 86
 		$context['sub_template'] = 'generic_xml';
87
+	} else {
88
+			redirectexit('board=' . $board . '.' . $_REQUEST['start']);
89
+	}
84 90
 	}
85
-	else
86
-		redirectexit('board=' . $board . '.' . $_REQUEST['start']);
87
-}
88 91
 
89 92
 /**
90 93
  * Turn off/on unread replies subscription for a topic as well as sets individual topic's alert preferences
@@ -108,8 +111,9 @@  discard block
 block discarded – undo
108 111
 			$mode = (int) $_GET['mode'];
109 112
 			$alertPref = $mode <= 1 ? 0 : ($mode == 2 ? 1 : 3);
110 113
 
111
-			if (empty($mode))
112
-				$mode = 1;
114
+			if (empty($mode)) {
115
+							$mode = 1;
116
+			}
113 117
 
114 118
 			$request = $smcFunc['db_query']('', '
115 119
 				SELECT id_member, id_topic, id_msg, unwatched
@@ -132,8 +136,7 @@  discard block
 block discarded – undo
132 136
 					'id_msg' => 0,
133 137
 					'unwatched' => empty($mode) ? 1 : 0,
134 138
 				);
135
-			}
136
-			else
139
+			} else
137 140
 			{
138 141
 				$insert = false;
139 142
 				$log['unwatched'] = empty($mode) ? 1 : 0;
@@ -160,9 +163,8 @@  discard block
 block discarded – undo
160 163
 					array($user_info['id'], $log['id_topic']),
161 164
 					array('id_member', 'id_board')
162 165
 				);
163
-			}
164
-			else
165
-				$smcFunc['db_query']('', '
166
+			} else {
167
+							$smcFunc['db_query']('', '
166 168
 					DELETE FROM {db_prefix}log_notify
167 169
 					WHERE id_topic = {int:topic}
168 170
 						AND id_member = {int:member}',
@@ -170,6 +172,7 @@  discard block
 block discarded – undo
170 172
 						'topic' => $log['id_topic'],
171 173
 						'member' => $user_info['id'],
172 174
 					));
175
+			}
173 176
 
174 177
 		}
175 178
 	}
@@ -186,9 +189,9 @@  discard block
 block discarded – undo
186 189
 			),
187 190
 		);
188 191
 		$context['sub_template'] = 'generic_xml';
192
+	} else {
193
+			redirectexit('topic=' . $topic . '.' . $_REQUEST['start']);
194
+	}
189 195
 	}
190
-	else
191
-		redirectexit('topic=' . $topic . '.' . $_REQUEST['start']);
192
-}
193 196
 
194 197
 ?>
195 198
\ No newline at end of file
Please login to merge, or discard this patch.
Sources/Attachments.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 		// Just send a generic message.
77 77
 		else
78 78
 			$this->setResponse(array(
79
-				'text' => $this->_sa == 'add' ? 'attach_error_title' :   'attached_file_deleted_error',
79
+				'text' => $this->_sa == 'add' ? 'attach_error_title' : 'attached_file_deleted_error',
80 80
 				'type' => 'error',
81 81
 				'data' => false,
82 82
 			));
@@ -404,7 +404,7 @@  discard block
 block discarded – undo
404 404
 			// Gotta urlencode the filename.
405 405
 			if ($this->_attachResults)
406 406
 				foreach ($this->_attachResults as $k => $v)
407
-					$this->_attachResults[$k]['name'] =  urlencode($this->_attachResults[$k]['name']);
407
+					$this->_attachResults[$k]['name'] = urlencode($this->_attachResults[$k]['name']);
408 408
 
409 409
 			$this->_response = array(
410 410
 				'files' => $this->_attachResults ? $this->_attachResults : false,
@@ -431,7 +431,7 @@  discard block
 block discarded – undo
431 431
 			ob_start();
432 432
 
433 433
 		// Set the header.
434
-		header('Content-Type: application/json; charset='. $context['character_set'] .'');
434
+		header('Content-Type: application/json; charset=' . $context['character_set'] . '');
435 435
 
436 436
 		echo json_encode($this->_response ? $this->_response : array());
437 437
 
Please login to merge, or discard this patch.
Braces   +102 added lines, -75 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 3
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 class Attachments
20 21
 {
@@ -70,16 +71,18 @@  discard block
 block discarded – undo
70 71
 
71 72
 		$this->_sa = !empty($_REQUEST['sa']) ? $smcFunc['htmlspecialchars']($smcFunc['htmltrim']($_REQUEST['sa'])) : false;
72 73
 
73
-		if ($this->_canPostAttachment && $this->_sa && in_array($this->_sa, $this->_subActions))
74
-			$this->{$this->_sa}();
74
+		if ($this->_canPostAttachment && $this->_sa && in_array($this->_sa, $this->_subActions)) {
75
+					$this->{$this->_sa}();
76
+		}
75 77
 
76 78
 		// Just send a generic message.
77
-		else
78
-			$this->setResponse(array(
79
+		else {
80
+					$this->setResponse(array(
79 81
 				'text' => $this->_sa == 'add' ? 'attach_error_title' :   'attached_file_deleted_error',
80 82
 				'type' => 'error',
81 83
 				'data' => false,
82 84
 			));
85
+		}
83 86
 
84 87
 		// Back to the future, oh, to the browser!
85 88
 		$this->sendResponse();
@@ -95,12 +98,13 @@  discard block
 block discarded – undo
95 98
 		$attachID = !empty($_REQUEST['attach']) && is_numeric($_REQUEST['attach']) ? (int) $_REQUEST['attach'] : 0;
96 99
 
97 100
 		// Need something to work with.
98
-		if (!$attachID || (!empty($_SESSION['already_attached']) && !isset($_SESSION['already_attached'][$attachID])))
99
-			return $this->setResponse(array(
101
+		if (!$attachID || (!empty($_SESSION['already_attached']) && !isset($_SESSION['already_attached'][$attachID]))) {
102
+					return $this->setResponse(array(
100 103
 				'text' => 'attached_file_deleted_error',
101 104
 				'type' => 'error',
102 105
 				'data' => false,
103 106
 			));
107
+		}
104 108
 
105 109
 		// Lets pass some params and see what happens :P
106 110
 		$affectedMessage = removeAttachments(array('id_attach' => $attachID), '', true, true);
@@ -119,19 +123,21 @@  discard block
 block discarded – undo
119 123
 	public function add()
120 124
 	{
121 125
 		// You gotta be able to post attachments.
122
-		if (!$this->_canPostAttachment)
123
-			return $this->setResponse(array(
126
+		if (!$this->_canPostAttachment) {
127
+					return $this->setResponse(array(
124 128
 				'text' => 'attached_file_cannot',
125 129
 				'type' => 'error',
126 130
 				'data' => false,
127 131
 			));
132
+		}
128 133
 
129 134
 		// Process them at once!
130 135
 		$this->processAttachments();
131 136
 
132 137
 		// The attachments was created and moved the the right folder, time to update the DB.
133
-		if (!empty($_SESSION['temp_attachments']))
134
-			$this->createAtttach();
138
+		if (!empty($_SESSION['temp_attachments'])) {
139
+					$this->createAtttach();
140
+		}
135 141
 
136 142
 		// Set the response.
137 143
 		$this->setResponse();
@@ -144,8 +150,9 @@  discard block
 block discarded – undo
144 150
 	{
145 151
 		global $context, $modSettings, $smcFunc, $user_info, $txt;
146 152
 
147
-		if (!isset($_FILES['attachment']['name']))
148
-			$_FILES['attachment']['tmp_name'] = array();
153
+		if (!isset($_FILES['attachment']['name'])) {
154
+					$_FILES['attachment']['tmp_name'] = array();
155
+		}
149 156
 
150 157
 		// If there are attachments, calculate the total size and how many.
151 158
 		$context['attachments']['total_size'] = 0;
@@ -155,25 +162,30 @@  discard block
 block discarded – undo
155 162
 		if (isset($_REQUEST['msg']))
156 163
 		{
157 164
 			$context['attachments']['quantity'] = count($context['current_attachments']);
158
-			foreach ($context['current_attachments'] as $attachment)
159
-				$context['attachments']['total_size'] += $attachment['size'];
165
+			foreach ($context['current_attachments'] as $attachment) {
166
+							$context['attachments']['total_size'] += $attachment['size'];
167
+			}
160 168
 		}
161 169
 
162 170
 		// A bit of house keeping first.
163
-		if (!empty($_SESSION['temp_attachments']) && count($_SESSION['temp_attachments']) == 1)
164
-			unset($_SESSION['temp_attachments']);
171
+		if (!empty($_SESSION['temp_attachments']) && count($_SESSION['temp_attachments']) == 1) {
172
+					unset($_SESSION['temp_attachments']);
173
+		}
165 174
 
166 175
 		// Our infamous SESSION var, we are gonna have soo much fun with it!
167
-		if (!isset($_SESSION['temp_attachments']))
168
-			$_SESSION['temp_attachments'] = array();
176
+		if (!isset($_SESSION['temp_attachments'])) {
177
+					$_SESSION['temp_attachments'] = array();
178
+		}
169 179
 
170 180
 		// Make sure we're uploading to the right place.
171
-		if (!empty($modSettings['automanage_attachments']))
172
-			automanage_attachments_check_directory();
181
+		if (!empty($modSettings['automanage_attachments'])) {
182
+					automanage_attachments_check_directory();
183
+		}
173 184
 
174 185
 		// Is the attachments folder actually there?
175
-		if (!empty($context['dir_creation_error']))
176
-			$this->_generalErrors[] = $context['dir_creation_error'];
186
+		if (!empty($context['dir_creation_error'])) {
187
+					$this->_generalErrors[] = $context['dir_creation_error'];
188
+		}
177 189
 
178 190
 		// The current attach folder ha some issues...
179 191
 		elseif (!is_dir($this->_attchDir))
@@ -198,13 +210,12 @@  discard block
 block discarded – undo
198 210
 			);
199 211
 			list ($context['attachments']['quantity'], $context['attachments']['total_size']) = $smcFunc['db_fetch_row']($request);
200 212
 			$smcFunc['db_free_result']($request);
201
-		}
202
-
203
-		else
204
-			$context['attachments'] = array(
213
+		} else {
214
+					$context['attachments'] = array(
205 215
 				'quantity' => 0,
206 216
 				'total_size' => 0,
207 217
 			);
218
+		}
208 219
 
209 220
 		// Check for other general errors here.
210 221
 
@@ -212,9 +223,10 @@  discard block
 block discarded – undo
212 223
 		if (!empty($this->_generalErrors))
213 224
 		{
214 225
 			// And delete the files 'cos they ain't going nowhere.
215
-			foreach ($_FILES['attachment']['tmp_name'] as $n => $dummy)
216
-				if (file_exists($_FILES['attachment']['tmp_name'][$n]))
226
+			foreach ($_FILES['attachment']['tmp_name'] as $n => $dummy) {
227
+							if (file_exists($_FILES['attachment']['tmp_name'][$n]))
217 228
 					unlink($_FILES['attachment']['tmp_name'][$n]);
229
+			}
218 230
 
219 231
 			$_FILES['attachment']['tmp_name'] = array();
220 232
 
@@ -225,26 +237,29 @@  discard block
 block discarded – undo
225 237
 		// Loop through $_FILES['attachment'] array and move each file to the current attachments folder.
226 238
 		foreach ($_FILES['attachment']['tmp_name'] as $n => $dummy)
227 239
 		{
228
-			if ($_FILES['attachment']['name'][$n] == '')
229
-				continue;
240
+			if ($_FILES['attachment']['name'][$n] == '') {
241
+							continue;
242
+			}
230 243
 
231 244
 			// First, let's first check for PHP upload errors.
232 245
 			$errors = array();
233 246
 			if (!empty($_FILES['attachment']['error'][$n]))
234 247
 			{
235
-				if ($_FILES['attachment']['error'][$n] == 2)
236
-					$errors[] = array('file_too_big', array($modSettings['attachmentSizeLimit']));
237
-
238
-				else
239
-					log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_' . $_FILES['attachment']['error'][$n]]);
248
+				if ($_FILES['attachment']['error'][$n] == 2) {
249
+									$errors[] = array('file_too_big', array($modSettings['attachmentSizeLimit']));
250
+				} else {
251
+									log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_' . $_FILES['attachment']['error'][$n]]);
252
+				}
240 253
 
241 254
 				// Log this one, because...
242
-				if ($_FILES['attachment']['error'][$n] == 6)
243
-					log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_6'], 'critical');
255
+				if ($_FILES['attachment']['error'][$n] == 6) {
256
+									log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_6'], 'critical');
257
+				}
244 258
 
245 259
 				// Weird, no errors were cached, still fill out a generic one.
246
-				if (empty($errors))
247
-					$errors[] = 'attach_php_error';
260
+				if (empty($errors)) {
261
+									$errors[] = 'attach_php_error';
262
+				}
248 263
 			}
249 264
 
250 265
 			// Try to move and rename the file before doing any more checks on it.
@@ -256,8 +271,9 @@  discard block
 block discarded – undo
256 271
 			{
257 272
 				// The reported MIME type of the attachment might not be reliable.
258 273
 				// Fortunately, PHP 5.3+ lets us easily verify the real MIME type.
259
-				if (function_exists('mime_content_type'))
260
-					$_FILES['attachment']['type'][$n] = mime_content_type($_FILES['attachment']['tmp_name'][$n]);
274
+				if (function_exists('mime_content_type')) {
275
+									$_FILES['attachment']['type'][$n] = mime_content_type($_FILES['attachment']['tmp_name'][$n]);
276
+				}
261 277
 
262 278
 				$_SESSION['temp_attachments'][$attachID] = array(
263 279
 					'name' => $smcFunc['htmlspecialchars'](basename($_FILES['attachment']['name'][$n])),
@@ -269,16 +285,18 @@  discard block
 block discarded – undo
269 285
 				);
270 286
 
271 287
 				// Move the file to the attachments folder with a temp name for now.
272
-				if (@move_uploaded_file($_FILES['attachment']['tmp_name'][$n], $destName))
273
-					smf_chmod($destName, 0644);
288
+				if (@move_uploaded_file($_FILES['attachment']['tmp_name'][$n], $destName)) {
289
+									smf_chmod($destName, 0644);
290
+				}
274 291
 
275 292
 				// This is madness!!
276 293
 				else
277 294
 				{
278 295
 					// File couldn't be moved.
279 296
 					$_SESSION['temp_attachments'][$attachID]['errors'][] = 'attach_timeout';
280
-					if (file_exists($_FILES['attachment']['tmp_name'][$n]))
281
-						unlink($_FILES['attachment']['tmp_name'][$n]);
297
+					if (file_exists($_FILES['attachment']['tmp_name'][$n])) {
298
+											unlink($_FILES['attachment']['tmp_name'][$n]);
299
+					}
282 300
 				}
283 301
 			}
284 302
 
@@ -291,13 +309,15 @@  discard block
 block discarded – undo
291 309
 					'errors' => $errors,
292 310
 				);
293 311
 
294
-				if (file_exists($_FILES['attachment']['tmp_name'][$n]))
295
-					unlink($_FILES['attachment']['tmp_name'][$n]);
312
+				if (file_exists($_FILES['attachment']['tmp_name'][$n])) {
313
+									unlink($_FILES['attachment']['tmp_name'][$n]);
314
+				}
296 315
 			}
297 316
 
298 317
 			// If there's no errors to this point. We still do need to apply some additional checks before we are finished.
299
-			if (empty($_SESSION['temp_attachments'][$attachID]['errors']))
300
-				attachmentChecks($attachID);
318
+			if (empty($_SESSION['temp_attachments'][$attachID]['errors'])) {
319
+							attachmentChecks($attachID);
320
+			}
301 321
 		}
302 322
 
303 323
 		// Mod authors, finally a hook to hang an alternate attachment upload system upon
@@ -344,14 +364,15 @@  discard block
 block discarded – undo
344 364
 
345 365
 					$_SESSION['already_attached'][$attachmentOptions['attachID']] = $attachmentOptions['attachID'];
346 366
 
347
-					if (!empty($attachmentOptions['thumb']))
348
-						$_SESSION['already_attached'][$attachmentOptions['thumb']] = $attachmentOptions['thumb'];
367
+					if (!empty($attachmentOptions['thumb'])) {
368
+											$_SESSION['already_attached'][$attachmentOptions['thumb']] = $attachmentOptions['thumb'];
369
+					}
349 370
 
350
-					if ($this->_msg)
351
-						assignAttachments($_SESSION['already_attached'], $this->_msg);
371
+					if ($this->_msg) {
372
+											assignAttachments($_SESSION['already_attached'], $this->_msg);
373
+					}
352 374
 				}
353
-			}
354
-			else
375
+			} else
355 376
 			{
356 377
 				// Sort out the errors for display and delete any associated files.
357 378
 				$log_these = array('attachments_no_create', 'attachments_no_write', 'attach_timeout', 'ran_out_of_space', 'cant_access_upload_path', 'attach_0_byte_file');
@@ -363,14 +384,16 @@  discard block
 block discarded – undo
363 384
 					if (!is_array($error))
364 385
 					{
365 386
 						$attachmentOptions['errors'][] = $txt[$error];
366
-						if (in_array($error, $log_these))
367
-							log_error($attachment['name'] . ': ' . $txt[$error], 'critical');
387
+						if (in_array($error, $log_these)) {
388
+													log_error($attachment['name'] . ': ' . $txt[$error], 'critical');
389
+						}
390
+					} else {
391
+											$attachmentOptions['errors'][] = vsprintf($txt[$error[0]], $error[1]);
368 392
 					}
369
-					else
370
-						$attachmentOptions['errors'][] = vsprintf($txt[$error[0]], $error[1]);
371 393
 				}
372
-				if (file_exists($attachment['tmp_name']))
373
-					unlink($attachment['tmp_name']);
394
+				if (file_exists($attachment['tmp_name'])) {
395
+									unlink($attachment['tmp_name']);
396
+				}
374 397
 			}
375 398
 
376 399
 			// Regardless of errors, pass the results.
@@ -378,8 +401,9 @@  discard block
 block discarded – undo
378 401
 		}
379 402
 
380 403
 		// Temp save this on the db.
381
-		if (!empty($_SESSION['already_attached']))
382
-			$this->_attachSuccess = $_SESSION['already_attached'];
404
+		if (!empty($_SESSION['already_attached'])) {
405
+					$this->_attachSuccess = $_SESSION['already_attached'];
406
+		}
383 407
 
384 408
 		unset($_SESSION['temp_attachments']);
385 409
 	}
@@ -399,14 +423,16 @@  discard block
 block discarded – undo
399 423
 		if ($this->_sa == 'add')
400 424
 		{
401 425
 			// Is there any generic errors? made some sense out of them!
402
-			if ($this->_generalErrors)
403
-				foreach ($this->_generalErrors as $k => $v)
426
+			if ($this->_generalErrors) {
427
+							foreach ($this->_generalErrors as $k => $v)
404 428
 					$this->_generalErrors[$k] = (is_array($v) ? vsprintf($txt[$v[0]], $v[1]) : $txt[$v]);
429
+			}
405 430
 
406 431
 			// Gotta urlencode the filename.
407
-			if ($this->_attachResults)
408
-				foreach ($this->_attachResults as $k => $v)
432
+			if ($this->_attachResults) {
433
+							foreach ($this->_attachResults as $k => $v)
409 434
 					$this->_attachResults[$k]['name'] =  urlencode($this->_attachResults[$k]['name']);
435
+			}
410 436
 
411 437
 			$this->_response = array(
412 438
 				'files' => $this->_attachResults ? $this->_attachResults : false,
@@ -415,9 +441,10 @@  discard block
 block discarded – undo
415 441
 		}
416 442
 
417 443
 		// Rest of us mere mortals gets no special treatment...
418
-		elseif (!empty($data))
419
-			if (!empty($data['text']) && !empty($txt[$data['text']]))
444
+		elseif (!empty($data)) {
445
+					if (!empty($data['text']) && !empty($txt[$data['text']]))
420 446
 				$this->_response['text'] = $txt[$data['text']];
447
+		}
421 448
 	}
422 449
 
423 450
 	protected function sendResponse()
@@ -426,11 +453,11 @@  discard block
 block discarded – undo
426 453
 
427 454
 		ob_end_clean();
428 455
 
429
-		if (!empty($modSettings['CompressedOutput']))
430
-			@ob_start('ob_gzhandler');
431
-
432
-		else
433
-			ob_start();
456
+		if (!empty($modSettings['CompressedOutput'])) {
457
+					@ob_start('ob_gzhandler');
458
+		} else {
459
+					ob_start();
460
+		}
434 461
 
435 462
 		// Set the header.
436 463
 		header('Content-Type: application/json; charset='. $context['character_set'] .'');
Please login to merge, or discard this patch.
Sources/CacheAPI-zend.php 1 patch
Braces   +15 added lines, -11 removed lines patch added patch discarded remove patch
@@ -11,8 +11,9 @@  discard block
 block discarded – undo
11 11
  * @version 2.1 Beta 3
12 12
  */
13 13
 
14
-if (!defined('SMF'))
14
+if (!defined('SMF')) {
15 15
 	die('Hacking attempt...');
16
+}
16 17
 
17 18
 /**
18 19
  * Our Cache API class
@@ -29,8 +30,9 @@  discard block
 block discarded – undo
29 30
 
30 31
 		$supported = function_exists('zend_shm_cache_fetch') || function_exists('output_cache_get');
31 32
 
32
-		if ($test)
33
-			return $supported;
33
+		if ($test) {
34
+					return $supported;
35
+		}
34 36
 		return parent::isSupported() && $supported;
35 37
 	}
36 38
 
@@ -42,10 +44,11 @@  discard block
 block discarded – undo
42 44
 		$key = $this->prefix . strtr($key, ':/', '-_');
43 45
 
44 46
 		// Zend's pricey stuff.
45
-		if (function_exists('zend_shm_cache_fetch'))
46
-			return zend_shm_cache_fetch('SMF::' . $key);
47
-		elseif (function_exists('output_cache_get'))
48
-			return output_cache_get($key, $ttl);
47
+		if (function_exists('zend_shm_cache_fetch')) {
48
+					return zend_shm_cache_fetch('SMF::' . $key);
49
+		} elseif (function_exists('output_cache_get')) {
50
+					return output_cache_get($key, $ttl);
51
+		}
49 52
 	}
50 53
 
51 54
 	/**
@@ -55,10 +58,11 @@  discard block
 block discarded – undo
55 58
 	{
56 59
 		$key = $this->prefix . strtr($key, ':/', '-_');
57 60
 
58
-		if (function_exists('zend_shm_cache_store'))
59
-			return zend_shm_cache_store('SMF::' . $key, $value, $ttl);
60
-		elseif (function_exists('output_cache_put'))
61
-			return output_cache_put($key, $value);
61
+		if (function_exists('zend_shm_cache_store')) {
62
+					return zend_shm_cache_store('SMF::' . $key, $value, $ttl);
63
+		} elseif (function_exists('output_cache_put')) {
64
+					return output_cache_put($key, $value);
65
+		}
62 66
 	}
63 67
 
64 68
 	/**
Please login to merge, or discard this patch.
Sources/SearchAPI-Custom.php 1 patch
Braces   +48 added lines, -34 removed lines patch added patch discarded remove patch
@@ -11,8 +11,9 @@  discard block
 block discarded – undo
11 11
  * @version 2.1 Beta 3
12 12
  */
13 13
 
14
-if (!defined('SMF'))
14
+if (!defined('SMF')) {
15 15
 	die('No direct access...');
16
+}
16 17
 
17 18
 /**
18 19
  * Used for the "custom search index" option
@@ -54,8 +55,9 @@  discard block
 block discarded – undo
54 55
 			return;
55 56
 		}
56 57
 
57
-		if (empty($modSettings['search_custom_index_config']))
58
-			return;
58
+		if (empty($modSettings['search_custom_index_config'])) {
59
+					return;
60
+		}
59 61
 
60 62
 		$this->indexSettings = smf_json_decode($modSettings['search_custom_index_config'], true);
61 63
 
@@ -118,21 +120,23 @@  discard block
 block discarded – undo
118 120
 
119 121
 		$subwords = text2words($word, $this->min_word_length, true);
120 122
 
121
-		if (empty($modSettings['search_force_index']))
122
-			$wordsSearch['words'][] = $word;
123
+		if (empty($modSettings['search_force_index'])) {
124
+					$wordsSearch['words'][] = $word;
125
+		}
123 126
 
124 127
 		// Excluded phrases don't benefit from being split into subwords.
125
-		if (count($subwords) > 1 && $isExcluded)
126
-			return;
127
-		else
128
+		if (count($subwords) > 1 && $isExcluded) {
129
+					return;
130
+		} else
128 131
 		{
129 132
 			foreach ($subwords as $subword)
130 133
 			{
131 134
 				if ($smcFunc['strlen']($subword) >= $this->min_word_length && !in_array($subword, $this->bannedWords))
132 135
 				{
133 136
 					$wordsSearch['indexed_words'][] = $subword;
134
-					if ($isExcluded)
135
-						$wordsExclude[] = $subword;
137
+					if ($isExcluded) {
138
+											$wordsExclude[] = $subword;
139
+					}
136 140
 				}
137 141
 			}
138 142
 		}
@@ -153,8 +157,9 @@  discard block
 block discarded – undo
153 157
 		$query_where = array();
154 158
 		$query_params = $search_data['params'];
155 159
 
156
-		if ($query_params['id_search'])
157
-			$query_select['id_search'] = '{int:id_search}';
160
+		if ($query_params['id_search']) {
161
+					$query_select['id_search'] = '{int:id_search}';
162
+		}
158 163
 
159 164
 		$count = 0;
160 165
 		foreach ($words['words'] as $regularWord)
@@ -163,30 +168,37 @@  discard block
 block discarded – undo
163 168
 			$query_params['complex_body_' . $count++] = empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? '%' . strtr($regularWord, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $regularWord), '\\\'') . '[[:>:]]';
164 169
 		}
165 170
 
166
-		if ($query_params['user_query'])
167
-			$query_where[] = '{raw:user_query}';
168
-		if ($query_params['board_query'])
169
-			$query_where[] = 'm.id_board {raw:board_query}';
171
+		if ($query_params['user_query']) {
172
+					$query_where[] = '{raw:user_query}';
173
+		}
174
+		if ($query_params['board_query']) {
175
+					$query_where[] = 'm.id_board {raw:board_query}';
176
+		}
170 177
 
171
-		if ($query_params['topic'])
172
-			$query_where[] = 'm.id_topic = {int:topic}';
173
-		if ($query_params['min_msg_id'])
174
-			$query_where[] = 'm.id_msg >= {int:min_msg_id}';
175
-		if ($query_params['max_msg_id'])
176
-			$query_where[] = 'm.id_msg <= {int:max_msg_id}';
178
+		if ($query_params['topic']) {
179
+					$query_where[] = 'm.id_topic = {int:topic}';
180
+		}
181
+		if ($query_params['min_msg_id']) {
182
+					$query_where[] = 'm.id_msg >= {int:min_msg_id}';
183
+		}
184
+		if ($query_params['max_msg_id']) {
185
+					$query_where[] = 'm.id_msg <= {int:max_msg_id}';
186
+		}
177 187
 
178 188
 		$count = 0;
179
-		if (!empty($query_params['excluded_phrases']) && empty($modSettings['search_force_index']))
180
-			foreach ($query_params['excluded_phrases'] as $phrase)
189
+		if (!empty($query_params['excluded_phrases']) && empty($modSettings['search_force_index'])) {
190
+					foreach ($query_params['excluded_phrases'] as $phrase)
181 191
 			{
182 192
 				$query_where[] = 'subject NOT ' . (empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? ' LIKE ' : ' RLIKE ') . '{string:exclude_subject_phrase_' . $count . '}';
193
+		}
183 194
 				$query_params['exclude_subject_phrase_' . $count++] = empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? '%' . strtr($phrase, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $phrase), '\\\'') . '[[:>:]]';
184 195
 			}
185 196
 		$count = 0;
186
-		if (!empty($query_params['excluded_subject_words']) && empty($modSettings['search_force_index']))
187
-			foreach ($query_params['excluded_subject_words'] as $excludedWord)
197
+		if (!empty($query_params['excluded_subject_words']) && empty($modSettings['search_force_index'])) {
198
+					foreach ($query_params['excluded_subject_words'] as $excludedWord)
188 199
 			{
189 200
 				$query_where[] = 'subject NOT ' . (empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? ' LIKE ' : ' RLIKE ') . '{string:exclude_subject_words_' . $count . '}';
201
+		}
190 202
 				$query_params['exclude_subject_words_' . $count++] = empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? '%' . strtr($excludedWord, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $excludedWord), '\\\'') . '[[:>:]]';
191 203
 			}
192 204
 
@@ -199,8 +211,7 @@  discard block
 block discarded – undo
199 211
 			{
200 212
 				$query_left_join[] = '{db_prefix}log_search_words AS lsw' . $numTables . ' ON (lsw' . $numTables . '.id_word = ' . $indexedWord . ' AND lsw' . $numTables . '.id_msg = m.id_msg)';
201 213
 				$query_where[] = '(lsw' . $numTables . '.id_word IS NULL)';
202
-			}
203
-			else
214
+			} else
204 215
 			{
205 216
 				$query_inner_join[] = '{db_prefix}log_search_words AS lsw' . $numTables . ' ON (lsw' . $numTables . '.id_msg = ' . ($prev_join === 0 ? 'm' : 'lsw' . $prev_join) . '.id_msg)';
206 217
 				$query_where[] = 'lsw' . $numTables . '.id_word = ' . $indexedWord;
@@ -236,16 +247,18 @@  discard block
 block discarded – undo
236 247
 		$customIndexSettings = smf_json_decode($modSettings['search_custom_index_config'], true);
237 248
 
238 249
 		$inserts = array();
239
-		foreach (text2words($msgOptions['body'], $customIndexSettings['bytes_per_word'], true) as $word)
240
-			$inserts[] = array($word, $msgOptions['id']);
250
+		foreach (text2words($msgOptions['body'], $customIndexSettings['bytes_per_word'], true) as $word) {
251
+					$inserts[] = array($word, $msgOptions['id']);
252
+		}
241 253
 
242
-		if (!empty($inserts))
243
-			$smcFunc['db_insert']('ignore',
254
+		if (!empty($inserts)) {
255
+					$smcFunc['db_insert']('ignore',
244 256
 				'{db_prefix}log_search_words',
245 257
 				array('id_word' => 'int', 'id_msg' => 'int'),
246 258
 				$inserts,
247 259
 				array('id_word', 'id_msg')
248 260
 			);
261
+		}
249 262
 	}
250 263
 
251 264
 	/**
@@ -288,8 +301,9 @@  discard block
 block discarded – undo
288 301
 			if (!empty($inserted_words))
289 302
 			{
290 303
 				$inserts = array();
291
-				foreach ($inserted_words as $word)
292
-					$inserts[] = array($word, $msgOptions['id']);
304
+				foreach ($inserted_words as $word) {
305
+									$inserts[] = array($word, $msgOptions['id']);
306
+				}
293 307
 				$smcFunc['db_insert']('insert',
294 308
 					'{db_prefix}log_search_words',
295 309
 					array('id_word' => 'string', 'id_msg' => 'int'),
Please login to merge, or discard this patch.
Sources/ViewQuery.php 1 patch
Braces   +34 added lines, -26 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 3
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 /**
20 21
  * Show the database queries for debugging
@@ -30,8 +31,9 @@  discard block
 block discarded – undo
30 31
 	global $scripturl, $settings, $context, $db_connection, $boarddir, $smcFunc, $txt, $db_show_debug;
31 32
 
32 33
 	// We should have debug mode enabled, as well as something to display!
33
-	if (!isset($db_show_debug) || $db_show_debug !== true || !isset($_SESSION['debug']))
34
-		fatal_lang_error('no_access', false);
34
+	if (!isset($db_show_debug) || $db_show_debug !== true || !isset($_SESSION['debug'])) {
35
+			fatal_lang_error('no_access', false);
36
+	}
35 37
 
36 38
 	// Don't allow except for administrators.
37 39
 	isAllowedTo('admin_forum');
@@ -41,10 +43,11 @@  discard block
 block discarded – undo
41 43
 	{
42 44
 		$_SESSION['view_queries'] = $_SESSION['view_queries'] == 1 ? 0 : 1;
43 45
 
44
-		if (strpos($_SESSION['old_url'], 'action=viewquery') !== false)
45
-			redirectexit();
46
-		else
47
-			redirectexit($_SESSION['old_url']);
46
+		if (strpos($_SESSION['old_url'], 'action=viewquery') !== false) {
47
+					redirectexit();
48
+		} else {
49
+					redirectexit($_SESSION['old_url']);
50
+		}
48 51
 	}
49 52
 
50 53
 	call_integration_hook('integrate_egg_nog');
@@ -83,26 +86,28 @@  discard block
 block discarded – undo
83 86
 		foreach ($query as $line)
84 87
 		{
85 88
 			preg_match('/^(\t*)/', $line, $temp);
86
-			if (strlen($temp[0]) < $min_indent || $min_indent == 0)
87
-				$min_indent = strlen($temp[0]);
89
+			if (strlen($temp[0]) < $min_indent || $min_indent == 0) {
90
+							$min_indent = strlen($temp[0]);
91
+			}
92
+		}
93
+		foreach ($query as $l => $dummy) {
94
+					$query[$l] = substr($dummy, $min_indent);
88 95
 		}
89
-		foreach ($query as $l => $dummy)
90
-			$query[$l] = substr($dummy, $min_indent);
91 96
 		$query_data['q'] = implode("\n", $query);
92 97
 
93 98
 		// Make the filenames look a bit better.
94
-		if (isset($query_data['f']))
95
-			$query_data['f'] = preg_replace('~^' . preg_quote($boarddir, '~') . '~', '...', $query_data['f']);
99
+		if (isset($query_data['f'])) {
100
+					$query_data['f'] = preg_replace('~^' . preg_quote($boarddir, '~') . '~', '...', $query_data['f']);
101
+		}
96 102
 
97 103
 		$is_select_query = substr(trim($query_data['q']), 0, 6) == 'SELECT';
98
-		if ($is_select_query)
99
-			$select = $query_data['q'];
100
-		elseif (preg_match('~^INSERT(?: IGNORE)? INTO \w+(?:\s+\([^)]+\))?\s+(SELECT .+)$~s', trim($query_data['q']), $matches) != 0)
104
+		if ($is_select_query) {
105
+					$select = $query_data['q'];
106
+		} elseif (preg_match('~^INSERT(?: IGNORE)? INTO \w+(?:\s+\([^)]+\))?\s+(SELECT .+)$~s', trim($query_data['q']), $matches) != 0)
101 107
 		{
102 108
 			$is_select_query = true;
103 109
 			$select = $matches[1];
104
-		}
105
-		elseif (preg_match('~^CREATE TEMPORARY TABLE .+?(SELECT .+)$~s', trim($query_data['q']), $matches) != 0)
110
+		} elseif (preg_match('~^CREATE TEMPORARY TABLE .+?(SELECT .+)$~s', trim($query_data['q']), $matches) != 0)
106 111
 		{
107 112
 			$is_select_query = true;
108 113
 			$select = $matches[1];
@@ -110,10 +115,11 @@  discard block
 block discarded – undo
110 115
 		// Temporary tables created in earlier queries are not explainable.
111 116
 		if ($is_select_query)
112 117
 		{
113
-			foreach (array('log_topics_unread', 'topics_posted_in', 'tmp_log_search_topics', 'tmp_log_search_messages') as $tmp)
114
-				if (strpos($select, $tmp) !== false)
118
+			foreach (array('log_topics_unread', 'topics_posted_in', 'tmp_log_search_topics', 'tmp_log_search_messages') as $tmp) {
119
+							if (strpos($select, $tmp) !== false)
115 120
 				{
116 121
 					$is_select_query = false;
122
+			}
117 123
 					break;
118 124
 				}
119 125
 		}
@@ -124,13 +130,15 @@  discard block
 block discarded – undo
124 130
 				', nl2br(str_replace("\t", '&nbsp;&nbsp;&nbsp;', $smcFunc['htmlspecialchars']($query_data['q']))), '
125 131
 			</a><br>';
126 132
 
127
-		if (!empty($query_data['f']) && !empty($query_data['l']))
128
-			echo sprintf($txt['debug_query_in_line'], $query_data['f'], $query_data['l']);
133
+		if (!empty($query_data['f']) && !empty($query_data['l'])) {
134
+					echo sprintf($txt['debug_query_in_line'], $query_data['f'], $query_data['l']);
135
+		}
129 136
 
130
-		if (isset($query_data['s'], $query_data['t']) && isset($txt['debug_query_which_took_at']))
131
-			echo sprintf($txt['debug_query_which_took_at'], round($query_data['t'], 8), round($query_data['s'], 8));
132
-		else
133
-			echo sprintf($txt['debug_query_which_took'], round($query_data['t'], 8));
137
+		if (isset($query_data['s'], $query_data['t']) && isset($txt['debug_query_which_took_at'])) {
138
+					echo sprintf($txt['debug_query_which_took_at'], round($query_data['t'], 8), round($query_data['s'], 8));
139
+		} else {
140
+					echo sprintf($txt['debug_query_which_took'], round($query_data['t'], 8));
141
+		}
134 142
 
135 143
 		echo '
136 144
 		</div>';
Please login to merge, or discard this patch.
Sources/Printpage.php 1 patch
Braces   +30 added lines, -23 removed lines patch added patch discarded remove patch
@@ -14,8 +14,9 @@  discard block
 block discarded – undo
14 14
  * @version 2.1 Beta 3
15 15
  */
16 16
 
17
-if (!defined('SMF'))
17
+if (!defined('SMF')) {
18 18
 	die('No direct access...');
19
+}
19 20
 
20 21
 /**
21 22
  * Format a topic to be printer friendly.
@@ -32,8 +33,9 @@  discard block
 block discarded – undo
32 33
 	global $board_info, $smcFunc, $modSettings;
33 34
 
34 35
 	// Redirect to the boardindex if no valid topic id is provided.
35
-	if (empty($topic))
36
-		redirectexit();
36
+	if (empty($topic)) {
37
+			redirectexit();
38
+	}
37 39
 
38 40
 	if (!empty($modSettings['disable_print_topic']))
39 41
 	{
@@ -59,8 +61,9 @@  discard block
 block discarded – undo
59 61
 		)
60 62
 	);
61 63
 	// Redirect to the boardindex if no valid topic id is provided.
62
-	if ($smcFunc['db_num_rows']($request) == 0)
63
-		redirectexit();
64
+	if ($smcFunc['db_num_rows']($request) == 0) {
65
+			redirectexit();
66
+	}
64 67
 	$row = $smcFunc['db_fetch_assoc']($request);
65 68
 	$smcFunc['db_free_result']($request);
66 69
 
@@ -134,20 +137,21 @@  discard block
 block discarded – undo
134 137
 				foreach ($guestinfo as $i => $guestvoted)
135 138
 				{
136 139
 					$guestvoted = explode(',', $guestvoted);
137
-					if ($guestvoted[0] == $row['id_poll'])
138
-						break;
140
+					if ($guestvoted[0] == $row['id_poll']) {
141
+											break;
142
+					}
139 143
 				}
140 144
 				// Has the poll been reset since guest voted?
141 145
 				if ($pollinfo['reset_poll'] > $guestvoted[1])
142 146
 				{
143 147
 					// Remove the poll info from the cookie to allow guest to vote again
144 148
 					unset($guestinfo[$i]);
145
-					if (!empty($guestinfo))
146
-						$_COOKIE['guest_poll_vote'] = ';' . implode(';', $guestinfo);
147
-					else
148
-						unset($_COOKIE['guest_poll_vote']);
149
-				}
150
-				else
149
+					if (!empty($guestinfo)) {
150
+											$_COOKIE['guest_poll_vote'] = ';' . implode(';', $guestinfo);
151
+					} else {
152
+											unset($_COOKIE['guest_poll_vote']);
153
+					}
154
+				} else
151 155
 				{
152 156
 					// What did they vote for?
153 157
 					unset($guestvoted[0], $guestvoted[1]);
@@ -233,8 +237,9 @@  discard block
 block discarded – undo
233 237
 	$context['poster_name'] = $row['poster_name'];
234 238
 	$context['post_time'] = timeformat($row['poster_time'], false);
235 239
 	$context['parent_boards'] = array();
236
-	foreach ($board_info['parent_boards'] as $parent)
237
-		$context['parent_boards'][] = $parent['name'];
240
+	foreach ($board_info['parent_boards'] as $parent) {
241
+			$context['parent_boards'][] = $parent['name'];
242
+	}
238 243
 
239 244
 	// Split the topics up so we can print them.
240 245
 	$request = $smcFunc['db_query']('', '
@@ -266,8 +271,9 @@  discard block
 block discarded – undo
266 271
 			'id_msg' => $row['id_msg'],
267 272
 		);
268 273
 
269
-		if (!isset($context['topic_subject']))
270
-			$context['topic_subject'] = $row['subject'];
274
+		if (!isset($context['topic_subject'])) {
275
+					$context['topic_subject'] = $row['subject'];
276
+		}
271 277
 	}
272 278
 	$smcFunc['db_free_result']($request);
273 279
 
@@ -275,8 +281,9 @@  discard block
 block discarded – undo
275 281
 	if (isset($_REQUEST['images']) && !empty($modSettings['attachmentEnable']) && allowedTo('view_attachments'))
276 282
 	{
277 283
 		$messages = array();
278
-		foreach ($context['posts'] as $temp)
279
-			$messages[] = $temp['id_msg'];
284
+		foreach ($context['posts'] as $temp) {
285
+					$messages[] = $temp['id_msg'];
286
+		}
280 287
 
281 288
 		// build the request
282 289
 		$request = $smcFunc['db_query']('', '
@@ -295,8 +302,9 @@  discard block
 block discarded – undo
295 302
 		while ($row = $smcFunc['db_fetch_assoc']($request))
296 303
 		{
297 304
 			$temp[$row['id_attach']] = $row;
298
-			if (!isset($context['printattach'][$row['id_msg']]))
299
-				$context['printattach'][$row['id_msg']] = array();
305
+			if (!isset($context['printattach'][$row['id_msg']])) {
306
+							$context['printattach'][$row['id_msg']] = array();
307
+			}
300 308
 		}
301 309
 		$smcFunc['db_free_result']($request);
302 310
 		ksort($temp);
@@ -313,8 +321,7 @@  discard block
 block discarded – undo
313 321
 						$row['height'] = floor($row['height'] * ($modSettings['max_image_width'] / $row['width']));
314 322
 						$row['width'] = $modSettings['max_image_width'];
315 323
 					}
316
-				}
317
-				elseif (!empty($modSettings['max_image_width']))
324
+				} elseif (!empty($modSettings['max_image_width']))
318 325
 				{
319 326
 					if ($row['height'] > $modSettings['max_image_height'])
320 327
 					{
Please login to merge, or discard this patch.
Sources/CacheAPI-memcache.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -61,7 +61,7 @@
 block discarded – undo
61 61
 			$server = trim($servers[array_rand($servers)]);
62 62
 
63 63
 			// Normal host names do not contain slashes, while e.g. unix sockets do. Assume alternative transport pipe with port 0.
64
-			if (strpos($server,'/') !== false)
64
+			if (strpos($server, '/') !== false)
65 65
 				$host = $server;
66 66
 			else
67 67
 			{
Please login to merge, or discard this patch.
Braces   +19 added lines, -14 removed lines patch added patch discarded remove patch
@@ -11,8 +11,9 @@  discard block
 block discarded – undo
11 11
  * @version 2.1 Beta 3
12 12
  */
13 13
 
14
-if (!defined('SMF'))
14
+if (!defined('SMF')) {
15 15
 	die('Hacking attempt...');
16
+}
16 17
 
17 18
 /**
18 19
  * Our Cache API class
@@ -34,8 +35,9 @@  discard block
 block discarded – undo
34 35
 
35 36
 		$supported = class_exists('memcache');
36 37
 
37
-		if ($test)
38
-			return $supported;
38
+		if ($test) {
39
+					return $supported;
40
+		}
39 41
 		return parent::isSupported() && $supported && !empty($cache_memcached);
40 42
 	}
41 43
 
@@ -61,9 +63,9 @@  discard block
 block discarded – undo
61 63
 			$server = trim($servers[array_rand($servers)]);
62 64
 
63 65
 			// Normal host names do not contain slashes, while e.g. unix sockets do. Assume alternative transport pipe with port 0.
64
-			if (strpos($server,'/') !== false)
65
-				$host = $server;
66
-			else
66
+			if (strpos($server,'/') !== false) {
67
+							$host = $server;
68
+			} else
67 69
 			{
68 70
 				$server = explode(':', $server);
69 71
 				$host = $server[0];
@@ -71,10 +73,11 @@  discard block
 block discarded – undo
71 73
 			}
72 74
 
73 75
 			// Don't wait too long: yes, we want the server, but we might be able to run the query faster!
74
-			if (empty($db_persist))
75
-				$connected = $this->memcache->connect($host, $port);
76
-			else
77
-				$connected = $this->memcache->pconnect($host, $port);
76
+			if (empty($db_persist)) {
77
+							$connected = $this->memcache->connect($host, $port);
78
+			} else {
79
+							$connected = $this->memcache->pconnect($host, $port);
80
+			}
78 81
 		}
79 82
 
80 83
 		return $connected;
@@ -90,8 +93,9 @@  discard block
 block discarded – undo
90 93
 		$value = $this->memcache->get($key);
91 94
 
92 95
 		// $value should return either data or false (from failure, key not found or empty array).
93
-		if ($value === false)
94
-			return null;
96
+		if ($value === false) {
97
+					return null;
98
+		}
95 99
 		return $value;
96 100
 	}
97 101
 
@@ -132,8 +136,9 @@  discard block
 block discarded – undo
132 136
 		$config_vars[] = $txt['cache_memcache_settings'];
133 137
 		$config_vars[] = array('cache_memcached', $txt['cache_memcache_servers'], 'file', 'text', 0, 'cache_memcached', 'postinput' => '<br /><div class="smalltext"><em>' . $txt['cache_memcache_servers_subtext'] . '</em></div>');
134 138
 
135
-		if (!isset($context['settings_post_javascript']))
136
-			$context['settings_post_javascript'] = '';
139
+		if (!isset($context['settings_post_javascript'])) {
140
+					$context['settings_post_javascript'] = '';
141
+		}
137 142
 
138 143
 		$context['settings_post_javascript'] .= '
139 144
 			$("#cache_accelerator").change(function (e) {
Please login to merge, or discard this patch.
Sources/Topic.php 1 patch
Braces   +31 added lines, -21 removed lines patch added patch discarded remove patch
@@ -14,8 +14,9 @@  discard block
 block discarded – undo
14 14
  * @version 2.1 Beta 3
15 15
  */
16 16
 
17
-if (!defined('SMF'))
17
+if (!defined('SMF')) {
18 18
 	die('No direct access...');
19
+}
19 20
 
20 21
 /**
21 22
  * Locks a topic... either by way of a moderator or the topic starter.
@@ -32,8 +33,9 @@  discard block
 block discarded – undo
32 33
 	global $topic, $user_info, $sourcedir, $board, $smcFunc;
33 34
 
34 35
 	// Just quit if there's no topic to lock.
35
-	if (empty($topic))
36
-		fatal_lang_error('not_a_topic', false);
36
+	if (empty($topic)) {
37
+			fatal_lang_error('not_a_topic', false);
38
+	}
37 39
 
38 40
 	checkSession('get');
39 41
 
@@ -55,23 +57,28 @@  discard block
 block discarded – undo
55 57
 
56 58
 	// Can you lock topics here, mister?
57 59
 	$user_lock = !allowedTo('lock_any');
58
-	if ($user_lock && $starter == $user_info['id'])
59
-		isAllowedTo('lock_own');
60
-	else
61
-		isAllowedTo('lock_any');
60
+	if ($user_lock && $starter == $user_info['id']) {
61
+			isAllowedTo('lock_own');
62
+	} else {
63
+			isAllowedTo('lock_any');
64
+	}
62 65
 
63 66
 	// Locking with high privileges.
64
-	if ($locked == '0' && !$user_lock)
65
-		$locked = '1';
67
+	if ($locked == '0' && !$user_lock) {
68
+			$locked = '1';
69
+	}
66 70
 	// Locking with low privileges.
67
-	elseif ($locked == '0')
68
-		$locked = '2';
71
+	elseif ($locked == '0') {
72
+			$locked = '2';
73
+	}
69 74
 	// Unlocking - make sure you don't unlock what you can't.
70
-	elseif ($locked == '2' || ($locked == '1' && !$user_lock))
71
-		$locked = '0';
75
+	elseif ($locked == '2' || ($locked == '1' && !$user_lock)) {
76
+			$locked = '0';
77
+	}
72 78
 	// You cannot unlock this!
73
-	else
74
-		fatal_lang_error('locked_by_admin', 'user');
79
+	else {
80
+			fatal_lang_error('locked_by_admin', 'user');
81
+	}
75 82
 
76 83
 	// Actually lock the topic in the database with the new value.
77 84
 	$smcFunc['db_query']('', '
@@ -85,8 +92,9 @@  discard block
 block discarded – undo
85 92
 	);
86 93
 
87 94
 	// If they are allowed a "moderator" permission, log it in the moderator log.
88
-	if (!$user_lock)
89
-		logAction($locked ? 'lock' : 'unlock', array('topic' => $topic, 'board' => $board));
95
+	if (!$user_lock) {
96
+			logAction($locked ? 'lock' : 'unlock', array('topic' => $topic, 'board' => $board));
97
+	}
90 98
 	// Notify people that this topic has been locked?
91 99
 	sendNotifications($topic, empty($locked) ? 'unlock' : 'lock');
92 100
 
@@ -112,8 +120,9 @@  discard block
 block discarded – undo
112 120
 	isAllowedTo('make_sticky');
113 121
 
114 122
 	// You can't sticky a board or something!
115
-	if (empty($topic))
116
-		fatal_lang_error('not_a_topic', false);
123
+	if (empty($topic)) {
124
+			fatal_lang_error('not_a_topic', false);
125
+	}
117 126
 
118 127
 	checkSession('get');
119 128
 
@@ -147,8 +156,9 @@  discard block
 block discarded – undo
147 156
 	// Log this sticky action - always a moderator thing.
148 157
 	logAction(empty($is_sticky) ? 'sticky' : 'unsticky', array('topic' => $topic, 'board' => $board));
149 158
 	// Notify people that this topic has been stickied?
150
-	if (empty($is_sticky))
151
-		sendNotifications($topic, 'sticky');
159
+	if (empty($is_sticky)) {
160
+			sendNotifications($topic, 'sticky');
161
+	}
152 162
 
153 163
 	// Take them back to the now stickied topic.
154 164
 	redirectexit('topic=' . $topic . '.' . $_REQUEST['start'] . ';moderate');
Please login to merge, or discard this patch.