@@ -76,7 +76,7 @@ discard block |
||
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 | )); |
@@ -406,7 +406,7 @@ discard block |
||
406 | 406 | // Gotta urlencode the filename. |
407 | 407 | if ($this->_attachResults) |
408 | 408 | foreach ($this->_attachResults as $k => $v) |
409 | - $this->_attachResults[$k]['name'] = urlencode($this->_attachResults[$k]['name']); |
|
409 | + $this->_attachResults[$k]['name'] = urlencode($this->_attachResults[$k]['name']); |
|
410 | 410 | |
411 | 411 | $this->_response = array( |
412 | 412 | 'files' => $this->_attachResults ? $this->_attachResults : false, |
@@ -433,7 +433,7 @@ discard block |
||
433 | 433 | ob_start(); |
434 | 434 | |
435 | 435 | // Set the header. |
436 | - header('Content-Type: application/json; charset='. $context['character_set'] .''); |
|
436 | + header('Content-Type: application/json; charset=' . $context['character_set'] . ''); |
|
437 | 437 | |
438 | 438 | echo $smcFunc['json_encode']($this->_response ? $this->_response : array()); |
439 | 439 |
@@ -13,8 +13,9 @@ discard block |
||
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 | class Attachments |
20 | 21 | { |
@@ -70,16 +71,18 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | // You don't need to know. |
@@ -382,8 +405,9 @@ discard block |
||
382 | 405 | } |
383 | 406 | |
384 | 407 | // Temp save this on the db. |
385 | - if (!empty($_SESSION['already_attached'])) |
|
386 | - $this->_attachSuccess = $_SESSION['already_attached']; |
|
408 | + if (!empty($_SESSION['already_attached'])) { |
|
409 | + $this->_attachSuccess = $_SESSION['already_attached']; |
|
410 | + } |
|
387 | 411 | |
388 | 412 | unset($_SESSION['temp_attachments']); |
389 | 413 | } |
@@ -403,14 +427,16 @@ discard block |
||
403 | 427 | if ($this->_sa == 'add') |
404 | 428 | { |
405 | 429 | // Is there any generic errors? made some sense out of them! |
406 | - if ($this->_generalErrors) |
|
407 | - foreach ($this->_generalErrors as $k => $v) |
|
430 | + if ($this->_generalErrors) { |
|
431 | + foreach ($this->_generalErrors as $k => $v) |
|
408 | 432 | $this->_generalErrors[$k] = (is_array($v) ? vsprintf($txt[$v[0]], $v[1]) : $txt[$v]); |
433 | + } |
|
409 | 434 | |
410 | 435 | // Gotta urlencode the filename. |
411 | - if ($this->_attachResults) |
|
412 | - foreach ($this->_attachResults as $k => $v) |
|
436 | + if ($this->_attachResults) { |
|
437 | + foreach ($this->_attachResults as $k => $v) |
|
413 | 438 | $this->_attachResults[$k]['name'] = urlencode($this->_attachResults[$k]['name']); |
439 | + } |
|
414 | 440 | |
415 | 441 | $this->_response = array( |
416 | 442 | 'files' => $this->_attachResults ? $this->_attachResults : false, |
@@ -419,9 +445,10 @@ discard block |
||
419 | 445 | } |
420 | 446 | |
421 | 447 | // Rest of us mere mortals gets no special treatment... |
422 | - elseif (!empty($data)) |
|
423 | - if (!empty($data['text']) && !empty($txt[$data['text']])) |
|
448 | + elseif (!empty($data)) { |
|
449 | + if (!empty($data['text']) && !empty($txt[$data['text']])) |
|
424 | 450 | $this->_response['text'] = $txt[$data['text']]; |
451 | + } |
|
425 | 452 | } |
426 | 453 | |
427 | 454 | protected function sendResponse() |
@@ -430,11 +457,11 @@ discard block |
||
430 | 457 | |
431 | 458 | ob_end_clean(); |
432 | 459 | |
433 | - if (!empty($modSettings['CompressedOutput'])) |
|
434 | - @ob_start('ob_gzhandler'); |
|
435 | - |
|
436 | - else |
|
437 | - ob_start(); |
|
460 | + if (!empty($modSettings['CompressedOutput'])) { |
|
461 | + @ob_start('ob_gzhandler'); |
|
462 | + } else { |
|
463 | + ob_start(); |
|
464 | + } |
|
438 | 465 | |
439 | 466 | // Set the header. |
440 | 467 | header('Content-Type: application/json; charset='. $context['character_set'] .''); |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | * @version 2.1 Beta 4 |
15 | 15 | */ |
16 | 16 | |
17 | -if (!defined('SMF')) |
|
17 | +if (!defined('SMF')) { |
|
18 | 18 | die('No direct access...'); |
19 | +} |
|
19 | 20 | |
20 | 21 | loadLanguage('Drafts'); |
21 | 22 | |
@@ -33,8 +34,9 @@ discard block |
||
33 | 34 | global $context, $user_info, $smcFunc, $modSettings, $board; |
34 | 35 | |
35 | 36 | // can you be, should you be ... here? |
36 | - if (empty($modSettings['drafts_post_enabled']) || !allowedTo('post_draft') || !isset($_POST['save_draft']) || !isset($_POST['id_draft'])) |
|
37 | - return false; |
|
37 | + if (empty($modSettings['drafts_post_enabled']) || !allowedTo('post_draft') || !isset($_POST['save_draft']) || !isset($_POST['id_draft'])) { |
|
38 | + return false; |
|
39 | + } |
|
38 | 40 | |
39 | 41 | // read in what they sent us, if anything |
40 | 42 | $id_draft = (int) $_POST['id_draft']; |
@@ -46,14 +48,16 @@ discard block |
||
46 | 48 | $context['draft_saved_on'] = $draft_info['poster_time']; |
47 | 49 | |
48 | 50 | // since we were called from the autosave function, send something back |
49 | - if (!empty($id_draft)) |
|
50 | - XmlDraft($id_draft); |
|
51 | + if (!empty($id_draft)) { |
|
52 | + XmlDraft($id_draft); |
|
53 | + } |
|
51 | 54 | |
52 | 55 | return true; |
53 | 56 | } |
54 | 57 | |
55 | - if (!isset($_POST['message'])) |
|
56 | - $_POST['message'] = isset($_POST['quickReply']) ? $_POST['quickReply'] : ''; |
|
58 | + if (!isset($_POST['message'])) { |
|
59 | + $_POST['message'] = isset($_POST['quickReply']) ? $_POST['quickReply'] : ''; |
|
60 | + } |
|
57 | 61 | |
58 | 62 | // prepare any data from the form |
59 | 63 | $topic_id = empty($_REQUEST['topic']) ? 0 : (int) $_REQUEST['topic']; |
@@ -66,8 +70,9 @@ discard block |
||
66 | 70 | |
67 | 71 | // message and subject still need a bit more work |
68 | 72 | preparsecode($draft['body']); |
69 | - if ($smcFunc['strlen']($draft['subject']) > 100) |
|
70 | - $draft['subject'] = $smcFunc['substr']($draft['subject'], 0, 100); |
|
73 | + if ($smcFunc['strlen']($draft['subject']) > 100) { |
|
74 | + $draft['subject'] = $smcFunc['substr']($draft['subject'], 0, 100); |
|
75 | + } |
|
71 | 76 | |
72 | 77 | // Modifying an existing draft, like hitting the save draft button or autosave enabled? |
73 | 78 | if (!empty($id_draft) && !empty($draft_info)) |
@@ -148,9 +153,9 @@ discard block |
||
148 | 153 | { |
149 | 154 | $context['draft_saved'] = true; |
150 | 155 | $context['id_draft'] = $id_draft; |
156 | + } else { |
|
157 | + $post_errors[] = 'draft_not_saved'; |
|
151 | 158 | } |
152 | - else |
|
153 | - $post_errors[] = 'draft_not_saved'; |
|
154 | 159 | |
155 | 160 | // cleanup |
156 | 161 | unset($_POST['save_draft']); |
@@ -180,8 +185,9 @@ discard block |
||
180 | 185 | global $context, $user_info, $smcFunc, $modSettings; |
181 | 186 | |
182 | 187 | // PM survey says ... can you stay or must you go |
183 | - if (empty($modSettings['drafts_pm_enabled']) || !allowedTo('pm_draft') || !isset($_POST['save_draft'])) |
|
184 | - return false; |
|
188 | + if (empty($modSettings['drafts_pm_enabled']) || !allowedTo('pm_draft') || !isset($_POST['save_draft'])) { |
|
189 | + return false; |
|
190 | + } |
|
185 | 191 | |
186 | 192 | // read in what you sent us |
187 | 193 | $id_pm_draft = (int) $_POST['id_pm_draft']; |
@@ -193,8 +199,9 @@ discard block |
||
193 | 199 | $context['draft_saved_on'] = $draft_info['poster_time']; |
194 | 200 | |
195 | 201 | // Send something back to the javascript caller |
196 | - if (!empty($id_draft)) |
|
197 | - XmlDraft($id_draft); |
|
202 | + if (!empty($id_draft)) { |
|
203 | + XmlDraft($id_draft); |
|
204 | + } |
|
198 | 205 | |
199 | 206 | return true; |
200 | 207 | } |
@@ -204,9 +211,9 @@ discard block |
||
204 | 211 | { |
205 | 212 | $recipientList['to'] = isset($_POST['recipient_to']) ? explode(',', $_POST['recipient_to']) : array(); |
206 | 213 | $recipientList['bcc'] = isset($_POST['recipient_bcc']) ? explode(',', $_POST['recipient_bcc']) : array(); |
214 | + } elseif (!empty($draft_info['to_list']) && empty($recipientList)) { |
|
215 | + $recipientList = $smcFunc['json_decode']($draft_info['to_list'], true); |
|
207 | 216 | } |
208 | - elseif (!empty($draft_info['to_list']) && empty($recipientList)) |
|
209 | - $recipientList = $smcFunc['json_decode']($draft_info['to_list'], true); |
|
210 | 217 | |
211 | 218 | // prepare the data we got from the form |
212 | 219 | $reply_id = empty($_POST['replied_to']) ? 0 : (int) $_POST['replied_to']; |
@@ -215,8 +222,9 @@ discard block |
||
215 | 222 | |
216 | 223 | // message and subject always need a bit more work |
217 | 224 | preparsecode($draft['body']); |
218 | - if ($smcFunc['strlen']($draft['subject']) > 100) |
|
219 | - $draft['subject'] = $smcFunc['substr']($draft['subject'], 0, 100); |
|
225 | + if ($smcFunc['strlen']($draft['subject']) > 100) { |
|
226 | + $draft['subject'] = $smcFunc['substr']($draft['subject'], 0, 100); |
|
227 | + } |
|
220 | 228 | |
221 | 229 | // Modifying an existing PM draft? |
222 | 230 | if (!empty($id_pm_draft) && !empty($draft_info)) |
@@ -280,9 +288,9 @@ discard block |
||
280 | 288 | { |
281 | 289 | $context['draft_saved'] = true; |
282 | 290 | $context['id_pm_draft'] = $id_pm_draft; |
291 | + } else { |
|
292 | + $post_errors[] = 'draft_not_saved'; |
|
283 | 293 | } |
284 | - else |
|
285 | - $post_errors[] = 'draft_not_saved'; |
|
286 | 294 | } |
287 | 295 | |
288 | 296 | // if we were called from the autosave function, send something back |
@@ -315,8 +323,9 @@ discard block |
||
315 | 323 | $type = (int) $type; |
316 | 324 | |
317 | 325 | // nothing to read, nothing to do |
318 | - if (empty($id_draft)) |
|
319 | - return false; |
|
326 | + if (empty($id_draft)) { |
|
327 | + return false; |
|
328 | + } |
|
320 | 329 | |
321 | 330 | // load in this draft from the DB |
322 | 331 | $request = $smcFunc['db_query']('', ' |
@@ -337,8 +346,9 @@ discard block |
||
337 | 346 | ); |
338 | 347 | |
339 | 348 | // no results? |
340 | - if (!$smcFunc['db_num_rows']($request)) |
|
341 | - return false; |
|
349 | + if (!$smcFunc['db_num_rows']($request)) { |
|
350 | + return false; |
|
351 | + } |
|
342 | 352 | |
343 | 353 | // load up the data |
344 | 354 | $draft_info = $smcFunc['db_fetch_assoc']($request); |
@@ -358,8 +368,7 @@ discard block |
||
358 | 368 | $context['subject'] = !empty($draft_info['subject']) ? stripslashes($draft_info['subject']) : ''; |
359 | 369 | $context['board'] = !empty($draft_info['id_board']) ? $draft_info['id_board'] : ''; |
360 | 370 | $context['id_draft'] = !empty($draft_info['id_draft']) ? $draft_info['id_draft'] : 0; |
361 | - } |
|
362 | - elseif ($type === 1) |
|
371 | + } elseif ($type === 1) |
|
363 | 372 | { |
364 | 373 | // one of those pm drafts? then set it up like we have an error |
365 | 374 | $_REQUEST['subject'] = !empty($draft_info['subject']) ? stripslashes($draft_info['subject']) : ''; |
@@ -395,12 +404,14 @@ discard block |
||
395 | 404 | global $user_info, $smcFunc; |
396 | 405 | |
397 | 406 | // Only a single draft. |
398 | - if (is_numeric($id_draft)) |
|
399 | - $id_draft = array($id_draft); |
|
407 | + if (is_numeric($id_draft)) { |
|
408 | + $id_draft = array($id_draft); |
|
409 | + } |
|
400 | 410 | |
401 | 411 | // can't delete nothing |
402 | - if (empty($id_draft) || ($check && empty($user_info['id']))) |
|
403 | - return false; |
|
412 | + if (empty($id_draft) || ($check && empty($user_info['id']))) { |
|
413 | + return false; |
|
414 | + } |
|
404 | 415 | |
405 | 416 | $smcFunc['db_query']('', ' |
406 | 417 | DELETE FROM {db_prefix}user_drafts |
@@ -429,14 +440,16 @@ discard block |
||
429 | 440 | global $smcFunc, $scripturl, $context, $txt, $modSettings; |
430 | 441 | |
431 | 442 | // Permissions |
432 | - if (($draft_type === 0 && empty($context['drafts_save'])) || ($draft_type === 1 && empty($context['drafts_pm_save'])) || empty($member_id)) |
|
433 | - return false; |
|
443 | + if (($draft_type === 0 && empty($context['drafts_save'])) || ($draft_type === 1 && empty($context['drafts_pm_save'])) || empty($member_id)) { |
|
444 | + return false; |
|
445 | + } |
|
434 | 446 | |
435 | 447 | $context['drafts'] = array(); |
436 | 448 | |
437 | 449 | // has a specific draft has been selected? Load it up if there is not a message already in the editor |
438 | - if (isset($_REQUEST['id_draft']) && empty($_POST['subject']) && empty($_POST['message'])) |
|
439 | - ReadDraft((int) $_REQUEST['id_draft'], $draft_type, true, true); |
|
450 | + if (isset($_REQUEST['id_draft']) && empty($_POST['subject']) && empty($_POST['message'])) { |
|
451 | + ReadDraft((int) $_REQUEST['id_draft'], $draft_type, true, true); |
|
452 | + } |
|
440 | 453 | |
441 | 454 | // load the drafts this user has available |
442 | 455 | $request = $smcFunc['db_query']('', ' |
@@ -459,8 +472,9 @@ discard block |
||
459 | 472 | // add them to the draft array for display |
460 | 473 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
461 | 474 | { |
462 | - if (empty($row['subject'])) |
|
463 | - $row['subject'] = $txt['no_subject']; |
|
475 | + if (empty($row['subject'])) { |
|
476 | + $row['subject'] = $txt['no_subject']; |
|
477 | + } |
|
464 | 478 | |
465 | 479 | // Post drafts |
466 | 480 | if ($draft_type === 0) |
@@ -545,8 +559,9 @@ discard block |
||
545 | 559 | } |
546 | 560 | |
547 | 561 | // Default to 10. |
548 | - if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount'])) |
|
549 | - $_REQUEST['viewscount'] = 10; |
|
562 | + if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount'])) { |
|
563 | + $_REQUEST['viewscount'] = 10; |
|
564 | + } |
|
550 | 565 | |
551 | 566 | // Get the count of applicable drafts on the boards they can (still) see ... |
552 | 567 | // @todo .. should we just let them see their drafts even if they have lost board access ? |
@@ -611,12 +626,14 @@ discard block |
||
611 | 626 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
612 | 627 | { |
613 | 628 | // Censor.... |
614 | - if (empty($row['body'])) |
|
615 | - $row['body'] = ''; |
|
629 | + if (empty($row['body'])) { |
|
630 | + $row['body'] = ''; |
|
631 | + } |
|
616 | 632 | |
617 | 633 | $row['subject'] = $smcFunc['htmltrim']($row['subject']); |
618 | - if (empty($row['subject'])) |
|
619 | - $row['subject'] = $txt['no_subject']; |
|
634 | + if (empty($row['subject'])) { |
|
635 | + $row['subject'] = $txt['no_subject']; |
|
636 | + } |
|
620 | 637 | |
621 | 638 | censorText($row['body']); |
622 | 639 | censorText($row['subject']); |
@@ -648,8 +665,9 @@ discard block |
||
648 | 665 | $smcFunc['db_free_result']($request); |
649 | 666 | |
650 | 667 | // If the drafts were retrieved in reverse order, get them right again. |
651 | - if ($reverse) |
|
652 | - $context['drafts'] = array_reverse($context['drafts'], true); |
|
668 | + if ($reverse) { |
|
669 | + $context['drafts'] = array_reverse($context['drafts'], true); |
|
670 | + } |
|
653 | 671 | |
654 | 672 | // Menu tab |
655 | 673 | $context[$context['profile_menu_name']]['tab_data'] = array( |
@@ -707,8 +725,9 @@ discard block |
||
707 | 725 | } |
708 | 726 | |
709 | 727 | // Default to 10. |
710 | - if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount'])) |
|
711 | - $_REQUEST['viewscount'] = 10; |
|
728 | + if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount'])) { |
|
729 | + $_REQUEST['viewscount'] = 10; |
|
730 | + } |
|
712 | 731 | |
713 | 732 | // Get the count of applicable drafts |
714 | 733 | $request = $smcFunc['db_query']('', ' |
@@ -767,12 +786,14 @@ discard block |
||
767 | 786 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
768 | 787 | { |
769 | 788 | // Censor.... |
770 | - if (empty($row['body'])) |
|
771 | - $row['body'] = ''; |
|
789 | + if (empty($row['body'])) { |
|
790 | + $row['body'] = ''; |
|
791 | + } |
|
772 | 792 | |
773 | 793 | $row['subject'] = $smcFunc['htmltrim']($row['subject']); |
774 | - if (empty($row['subject'])) |
|
775 | - $row['subject'] = $txt['no_subject']; |
|
794 | + if (empty($row['subject'])) { |
|
795 | + $row['subject'] = $txt['no_subject']; |
|
796 | + } |
|
776 | 797 | |
777 | 798 | censorText($row['body']); |
778 | 799 | censorText($row['subject']); |
@@ -827,8 +848,9 @@ discard block |
||
827 | 848 | $smcFunc['db_free_result']($request); |
828 | 849 | |
829 | 850 | // if the drafts were retrieved in reverse order, then put them in the right order again. |
830 | - if ($reverse) |
|
831 | - $context['drafts'] = array_reverse($context['drafts'], true); |
|
851 | + if ($reverse) { |
|
852 | + $context['drafts'] = array_reverse($context['drafts'], true); |
|
853 | + } |
|
832 | 854 | |
833 | 855 | // off to the template we go |
834 | 856 | $context['page_title'] = $txt['drafts']; |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | * |
174 | 174 | * @param string $post_errors A string of info about errors encountered trying to save this draft |
175 | 175 | * @param array $recipientList An array of data about who this PM is being sent to |
176 | - * @return boolean false if you can't save the draft, true if we're doing this via XML more than 5 seconds after the last save, nothing otherwise |
|
176 | + * @return boolean|null false if you can't save the draft, true if we're doing this via XML more than 5 seconds after the last save, nothing otherwise |
|
177 | 177 | */ |
178 | 178 | function SavePMDraft(&$post_errors, $recipientList) |
179 | 179 | { |
@@ -388,7 +388,7 @@ discard block |
||
388 | 388 | * |
389 | 389 | * @param int $id_draft The ID of the draft to delete |
390 | 390 | * @param boolean $check Whether or not to check that the draft belongs to the current user |
391 | - * @return boolean False if it couldn't be deleted (doesn't return anything otherwise) |
|
391 | + * @return false|null False if it couldn't be deleted (doesn't return anything otherwise) |
|
392 | 392 | */ |
393 | 393 | function DeleteDraft($id_draft, $check = true) |
394 | 394 | { |
@@ -422,7 +422,7 @@ discard block |
||
422 | 422 | * @param int $member_id ID of the member to show drafts for |
423 | 423 | * @param boolean|integer $topic If $type is 1, this can be set to only load drafts for posts in the specific topic |
424 | 424 | * @param int $draft_type The type of drafts to show - 0 for post drafts, 1 for PM drafts |
425 | - * @return boolean False if the drafts couldn't be loaded, nothing otherwise |
|
425 | + * @return false|null False if the drafts couldn't be loaded, nothing otherwise |
|
426 | 426 | */ |
427 | 427 | function ShowDrafts($member_id, $topic = false, $draft_type = 0) |
428 | 428 | { |
@@ -16,8 +16,9 @@ discard block |
||
16 | 16 | |
17 | 17 | // Start things rolling by getting SMF alive... |
18 | 18 | $ssi_guest_access = true; |
19 | -if (!file_exists(dirname(__FILE__) . '/SSI.php')) |
|
19 | +if (!file_exists(dirname(__FILE__) . '/SSI.php')) { |
|
20 | 20 | die('Cannot find SSI.php'); |
21 | +} |
|
21 | 22 | |
22 | 23 | require_once(dirname(__FILE__) . '/SSI.php'); |
23 | 24 | require_once($sourcedir . '/ManagePaid.php'); |
@@ -35,20 +36,22 @@ discard block |
||
35 | 36 | } |
36 | 37 | |
37 | 38 | // I assume we're even active? |
38 | -if (empty($modSettings['paid_enabled'])) |
|
39 | +if (empty($modSettings['paid_enabled'])) { |
|
39 | 40 | exit; |
41 | +} |
|
40 | 42 | |
41 | 43 | // If we have some custom people who find out about problems load them here. |
42 | 44 | $notify_users = array(); |
43 | 45 | if (!empty($modSettings['paid_email_to'])) |
44 | 46 | { |
45 | - foreach (explode(',', $modSettings['paid_email_to']) as $email) |
|
46 | - $notify_users[] = array( |
|
47 | + foreach (explode(',', $modSettings['paid_email_to']) as $email) { |
|
48 | + $notify_users[] = array( |
|
47 | 49 | 'email' => $email, |
48 | 50 | 'name' => $txt['who_member'], |
49 | 51 | 'id' => 0, |
50 | 52 | ); |
51 | -} |
|
53 | + } |
|
54 | + } |
|
52 | 55 | |
53 | 56 | // We need to see whether we can find the correct payment gateway, |
54 | 57 | // we'll going to go through all our gateway scripts and find out |
@@ -65,8 +68,9 @@ discard block |
||
65 | 68 | } |
66 | 69 | } |
67 | 70 | |
68 | -if (empty($txnType)) |
|
71 | +if (empty($txnType)) { |
|
69 | 72 | generateSubscriptionError($txt['paid_unknown_transaction_type']); |
73 | +} |
|
70 | 74 | |
71 | 75 | // Get the subscription and member ID amoungst others... |
72 | 76 | @list($subscription_id, $member_id) = $gatewayClass->precheck(); |
@@ -76,8 +80,9 @@ discard block |
||
76 | 80 | $member_id = (int) $member_id; |
77 | 81 | |
78 | 82 | // This would be bad... |
79 | -if (empty($member_id)) |
|
83 | +if (empty($member_id)) { |
|
80 | 84 | generateSubscriptionError($txt['paid_empty_member']); |
85 | +} |
|
81 | 86 | |
82 | 87 | // Verify the member. |
83 | 88 | $request = $smcFunc['db_query']('', ' |
@@ -89,8 +94,9 @@ discard block |
||
89 | 94 | ) |
90 | 95 | ); |
91 | 96 | // Didn't find them? |
92 | -if ($smcFunc['db_num_rows']($request) === 0) |
|
97 | +if ($smcFunc['db_num_rows']($request) === 0) { |
|
93 | 98 | generateSubscriptionError(sprintf($txt['paid_could_not_find_member'], $member_id)); |
99 | +} |
|
94 | 100 | $member_info = $smcFunc['db_fetch_assoc']($request); |
95 | 101 | $smcFunc['db_free_result']($request); |
96 | 102 | |
@@ -105,8 +111,9 @@ discard block |
||
105 | 111 | ); |
106 | 112 | |
107 | 113 | // Didn't find it? |
108 | -if ($smcFunc['db_num_rows']($request) === 0) |
|
114 | +if ($smcFunc['db_num_rows']($request) === 0) { |
|
109 | 115 | generateSubscriptionError(sprintf($txt['paid_count_not_find_subscription'], $member_id, $subscription_id)); |
116 | +} |
|
110 | 117 | |
111 | 118 | $subscription_info = $smcFunc['db_fetch_assoc']($request); |
112 | 119 | $smcFunc['db_free_result']($request); |
@@ -123,8 +130,9 @@ discard block |
||
123 | 130 | 'current_member' => $member_id, |
124 | 131 | ) |
125 | 132 | ); |
126 | -if ($smcFunc['db_num_rows']($request) === 0) |
|
133 | +if ($smcFunc['db_num_rows']($request) === 0) { |
|
127 | 134 | generateSubscriptionError(sprintf($txt['paid_count_not_find_subscription_log'], $member_id, $subscription_id)); |
135 | +} |
|
128 | 136 | $subscription_info += $smcFunc['db_fetch_assoc']($request); |
129 | 137 | $smcFunc['db_free_result']($request); |
130 | 138 | |
@@ -139,8 +147,7 @@ discard block |
||
139 | 147 | removeSubscription($subscription_id, $member_id); |
140 | 148 | $subscription_act = time(); |
141 | 149 | $status = 0; |
142 | - } |
|
143 | - else |
|
150 | + } else |
|
144 | 151 | { |
145 | 152 | loadSubscriptions(); |
146 | 153 | $subscription_act = $subscription_info['end_time'] - $context['subscriptions'][$subscription_id]['num_length']; |
@@ -188,16 +195,18 @@ discard block |
||
188 | 195 | if (!$gatewayClass->isSubscription()) |
189 | 196 | { |
190 | 197 | $real_details = $smcFunc['json_decode']($subscription_info['pending_details'], true); |
191 | - if (empty($real_details)) |
|
192 | - generateSubscriptionError(sprintf($txt['paid_count_not_find_outstanding_payment'], $member_id, $subscription_id)); |
|
198 | + if (empty($real_details)) { |
|
199 | + generateSubscriptionError(sprintf($txt['paid_count_not_find_outstanding_payment'], $member_id, $subscription_id)); |
|
200 | + } |
|
193 | 201 | |
194 | 202 | // Now we just try to find anything pending. |
195 | 203 | // We don't really care which it is as security happens later. |
196 | 204 | foreach ($real_details as $id => $detail) |
197 | 205 | { |
198 | 206 | unset($real_details[$id]); |
199 | - if ($detail[3] == 'payback' && $subscription_info['payments_pending']) |
|
200 | - $subscription_info['payments_pending']--; |
|
207 | + if ($detail[3] == 'payback' && $subscription_info['payments_pending']) { |
|
208 | + $subscription_info['payments_pending']--; |
|
209 | + } |
|
201 | 210 | break; |
202 | 211 | } |
203 | 212 | |
@@ -223,10 +232,11 @@ discard block |
||
223 | 232 | // This is a little harder, can we find the right duration? |
224 | 233 | foreach ($cost as $duration => $value) |
225 | 234 | { |
226 | - if ($duration == 'fixed') |
|
227 | - continue; |
|
228 | - elseif ((float) $value == (float) $total_cost) |
|
229 | - $found_duration = strtoupper(substr($duration, 0, 1)); |
|
235 | + if ($duration == 'fixed') { |
|
236 | + continue; |
|
237 | + } elseif ((float) $value == (float) $total_cost) { |
|
238 | + $found_duration = strtoupper(substr($duration, 0, 1)); |
|
239 | + } |
|
230 | 240 | } |
231 | 241 | |
232 | 242 | // If we have the duration then we're done. |
@@ -235,8 +245,7 @@ discard block |
||
235 | 245 | $notify = true; |
236 | 246 | addSubscription($subscription_id, $member_id, $found_duration); |
237 | 247 | } |
238 | - } |
|
239 | - else |
|
248 | + } else |
|
240 | 249 | { |
241 | 250 | $actual_cost = $cost['fixed']; |
242 | 251 | |
@@ -268,10 +277,10 @@ discard block |
||
268 | 277 | // Maybe they're cancelling. Some subscriptions may require actively doing something, but PayPal doesn't, for example. |
269 | 278 | elseif ($gatewayClass->isCancellation()) |
270 | 279 | { |
271 | - if (method_exists($gatewayClass, 'performCancel')) |
|
272 | - $gatewayClass->performCancel($subscription_id, $member_id, $subscription_info); |
|
273 | -} |
|
274 | -else |
|
280 | + if (method_exists($gatewayClass, 'performCancel')) { |
|
281 | + $gatewayClass->performCancel($subscription_id, $member_id, $subscription_info); |
|
282 | + } |
|
283 | + } else |
|
275 | 284 | { |
276 | 285 | // Some other "valid" transaction such as: |
277 | 286 | // |
@@ -308,8 +317,9 @@ discard block |
||
308 | 317 | // Maybe we can try to give them the post data? |
309 | 318 | if (!empty($_POST)) |
310 | 319 | { |
311 | - foreach ($_POST as $key => $val) |
|
312 | - $text .= '<br>' . $smcFunc['htmlspecialchars']($key) . ': ' . $smcFunc['htmlspecialchars']($val); |
|
320 | + foreach ($_POST as $key => $val) { |
|
321 | + $text .= '<br>' . $smcFunc['htmlspecialchars']($key) . ': ' . $smcFunc['htmlspecialchars']($val); |
|
322 | + } |
|
313 | 323 | } |
314 | 324 | |
315 | 325 | // Then just log and die. |
@@ -86,7 +86,7 @@ |
||
86 | 86 | foreach ($board['children'] as $child) |
87 | 87 | { |
88 | 88 | if (!$child['is_redirect']) |
89 | - $child['link'] = ''. ($child['new'] ? '<a href="' . $scripturl . '?action=unread;board=' . $child['id'] . '" title="' . $txt['new_posts'] . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')"><span class="new_posts">' . $txt['new'] . '</span></a>' : '') . '<a href="' . $child['href'] . '" ' . ($child['new'] ? 'class="board_new_posts" ' : '') . 'title="' . ($child['new'] ? $txt['new_posts'] : $txt['old_posts']) . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')">' . $child['name'] . '</a>'; |
|
89 | + $child['link'] = '' . ($child['new'] ? '<a href="' . $scripturl . '?action=unread;board=' . $child['id'] . '" title="' . $txt['new_posts'] . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')"><span class="new_posts">' . $txt['new'] . '</span></a>' : '') . '<a href="' . $child['href'] . '" ' . ($child['new'] ? 'class="board_new_posts" ' : '') . 'title="' . ($child['new'] ? $txt['new_posts'] : $txt['old_posts']) . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')">' . $child['name'] . '</a>'; |
|
90 | 90 | else |
91 | 91 | $child['link'] = '<a href="' . $child['href'] . '" title="' . comma_format($child['posts']) . ' ' . $txt['redirects'] . '">' . $child['name'] . '</a>'; |
92 | 92 |
@@ -18,11 +18,12 @@ discard block |
||
18 | 18 | global $context, $settings, $options, $scripturl, $modSettings, $txt; |
19 | 19 | |
20 | 20 | // Let them know why their message became unapproved. |
21 | - if ($context['becomesUnapproved']) |
|
22 | - echo ' |
|
21 | + if ($context['becomesUnapproved']) { |
|
22 | + echo ' |
|
23 | 23 | <div class="noticebox"> |
24 | 24 | ', $txt['post_becomesUnapproved'], ' |
25 | 25 | </div>'; |
26 | + } |
|
26 | 27 | |
27 | 28 | if (!empty($context['boards']) && (!empty($options['show_children']) || $context['start'] == 0)) |
28 | 29 | { |
@@ -46,17 +47,19 @@ discard block |
||
46 | 47 | </a>'; |
47 | 48 | |
48 | 49 | // Has it outstanding posts for approval? |
49 | - if ($board['can_approve_posts'] && ($board['unapproved_posts'] || $board['unapproved_topics'])) |
|
50 | - echo ' |
|
50 | + if ($board['can_approve_posts'] && ($board['unapproved_posts'] || $board['unapproved_topics'])) { |
|
51 | + echo ' |
|
51 | 52 | <a href="', $scripturl, '?action=moderate;area=postmod;sa=', ($board['unapproved_topics'] > 0 ? 'topics' : 'posts'), ';brd=', $board['id'], ';', $context['session_var'], '=', $context['session_id'], '" title="', sprintf($txt['unapproved_posts'], $board['unapproved_topics'], $board['unapproved_posts']), '" class="moderation_link">(!)</a>'; |
53 | + } |
|
52 | 54 | |
53 | 55 | echo ' |
54 | 56 | <p class="board_description">', $board['description'], '</p>'; |
55 | 57 | |
56 | 58 | // Show the "Moderators: ". Each has name, href, link, and id. (but we're gonna use link_moderators.) |
57 | - if (!empty($board['moderators']) || !empty($board['moderator_groups'])) |
|
58 | - echo ' |
|
59 | + if (!empty($board['moderators']) || !empty($board['moderator_groups'])) { |
|
60 | + echo ' |
|
59 | 61 | <p class="moderators">', count($board['link_moderators']) === 1 ? $txt['moderator'] : $txt['moderators'], ': ', implode(', ', $board['link_moderators']), '</p>'; |
62 | + } |
|
60 | 63 | |
61 | 64 | // Show some basic information about the number of posts, etc. |
62 | 65 | echo ' |
@@ -68,9 +71,10 @@ discard block |
||
68 | 71 | </div> |
69 | 72 | <div class="lastpost lpr_border">'; |
70 | 73 | |
71 | - if (!empty($board['last_post']['id'])) |
|
72 | - echo ' |
|
74 | + if (!empty($board['last_post']['id'])) { |
|
75 | + echo ' |
|
73 | 76 | <p>', $board['last_post']['last_post_message'], '</p>'; |
77 | + } |
|
74 | 78 | |
75 | 79 | echo ' |
76 | 80 | </div>'; |
@@ -84,14 +88,16 @@ discard block |
||
84 | 88 | id, name, description, new (is it new?), topics (#), posts (#), href, link, and last_post. */ |
85 | 89 | foreach ($board['children'] as $child) |
86 | 90 | { |
87 | - if (!$child['is_redirect']) |
|
88 | - $child['link'] = ''. ($child['new'] ? '<a href="' . $scripturl . '?action=unread;board=' . $child['id'] . '" title="' . $txt['new_posts'] . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')"><span class="new_posts">' . $txt['new'] . '</span></a>' : '') . '<a href="' . $child['href'] . '" ' . ($child['new'] ? 'class="board_new_posts" ' : '') . 'title="' . ($child['new'] ? $txt['new_posts'] : $txt['old_posts']) . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')">' . $child['name'] . '</a>'; |
|
89 | - else |
|
90 | - $child['link'] = '<a href="' . $child['href'] . '" title="' . comma_format($child['posts']) . ' ' . $txt['redirects'] . '">' . $child['name'] . '</a>'; |
|
91 | + if (!$child['is_redirect']) { |
|
92 | + $child['link'] = ''. ($child['new'] ? '<a href="' . $scripturl . '?action=unread;board=' . $child['id'] . '" title="' . $txt['new_posts'] . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')"><span class="new_posts">' . $txt['new'] . '</span></a>' : '') . '<a href="' . $child['href'] . '" ' . ($child['new'] ? 'class="board_new_posts" ' : '') . 'title="' . ($child['new'] ? $txt['new_posts'] : $txt['old_posts']) . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')">' . $child['name'] . '</a>'; |
|
93 | + } else { |
|
94 | + $child['link'] = '<a href="' . $child['href'] . '" title="' . comma_format($child['posts']) . ' ' . $txt['redirects'] . '">' . $child['name'] . '</a>'; |
|
95 | + } |
|
91 | 96 | |
92 | 97 | // Has it posts awaiting approval? |
93 | - if ($child['can_approve_posts'] && ($child['unapproved_posts'] | $child['unapproved_topics'])) |
|
94 | - $child['link'] .= ' <a href="' . $scripturl . '?action=moderate;area=postmod;sa=' . ($child['unapproved_topics'] > 0 ? 'topics' : 'posts') . ';brd=' . $child['id'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '" title="' . sprintf($txt['unapproved_posts'], $child['unapproved_topics'], $child['unapproved_posts']) . '" class="moderation_link">(!)</a>'; |
|
98 | + if ($child['can_approve_posts'] && ($child['unapproved_posts'] | $child['unapproved_topics'])) { |
|
99 | + $child['link'] .= ' <a href="' . $scripturl . '?action=moderate;area=postmod;sa=' . ($child['unapproved_topics'] > 0 ? 'topics' : 'posts') . ';brd=' . $child['id'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '" title="' . sprintf($txt['unapproved_posts'], $child['unapproved_topics'], $child['unapproved_posts']) . '" class="moderation_link">(!)</a>'; |
|
100 | + } |
|
95 | 101 | |
96 | 102 | $children[] = $child['new'] ? '<span class="strong">' . $child['link'] . '</span>' : '<span>' . $child['link'] . '</span>'; |
97 | 103 | } |
@@ -111,8 +117,9 @@ discard block |
||
111 | 117 | } |
112 | 118 | |
113 | 119 | // They can only mark read if they are logged in and it's enabled! |
114 | - if (!$context['user']['is_logged']) |
|
115 | - unset($context['normal_buttons']['markread']); |
|
120 | + if (!$context['user']['is_logged']) { |
|
121 | + unset($context['normal_buttons']['markread']); |
|
122 | + } |
|
116 | 123 | |
117 | 124 | if (!$context['no_topic_listing']) |
118 | 125 | { |
@@ -139,13 +146,15 @@ discard block |
||
139 | 146 | <h3>', $context['name'], '</h3> |
140 | 147 | <p>'; |
141 | 148 | |
142 | - if ($context['description'] != '') |
|
143 | - echo ' |
|
149 | + if ($context['description'] != '') { |
|
150 | + echo ' |
|
144 | 151 | ', $context['description']; |
152 | + } |
|
145 | 153 | |
146 | - if (!empty($context['moderators'])) |
|
147 | - echo ' |
|
154 | + if (!empty($context['moderators'])) { |
|
155 | + echo ' |
|
148 | 156 | ', count($context['moderators']) === 1 ? $txt['moderator'] : $txt['moderators'], ': ', implode(', ', $context['link_moderators']), '.'; |
157 | + } |
|
149 | 158 | |
150 | 159 | echo ' |
151 | 160 | </p> |
@@ -153,9 +162,10 @@ discard block |
||
153 | 162 | } |
154 | 163 | |
155 | 164 | // If Quick Moderation is enabled start the form. |
156 | - if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] > 0 && !empty($context['topics'])) |
|
157 | - echo ' |
|
165 | + if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] > 0 && !empty($context['topics'])) { |
|
166 | + echo ' |
|
158 | 167 | <form action="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], '" method="post" accept-charset="', $context['character_set'], '" class="clear" name="quickModForm" id="quickModForm">'; |
168 | + } |
|
159 | 169 | |
160 | 170 | echo ' |
161 | 171 | <div id="messageindex">'; |
@@ -165,11 +175,11 @@ discard block |
||
165 | 175 | echo ' |
166 | 176 | <div class="information">'; |
167 | 177 | |
168 | - if ($settings['display_who_viewing'] == 1) |
|
169 | - echo count($context['view_members']), ' ', count($context['view_members']) === 1 ? $txt['who_member'] : $txt['members']; |
|
170 | - |
|
171 | - else |
|
172 | - echo empty($context['view_members_list']) ? '0 ' . $txt['members'] : implode(', ', $context['view_members_list']) . (empty($context['view_num_hidden']) || $context['can_moderate_forum'] ? '' : ' (+ ' . $context['view_num_hidden'] . ' ' . $txt['hidden'] . ')'); |
|
178 | + if ($settings['display_who_viewing'] == 1) { |
|
179 | + echo count($context['view_members']), ' ', count($context['view_members']) === 1 ? $txt['who_member'] : $txt['members']; |
|
180 | + } else { |
|
181 | + echo empty($context['view_members_list']) ? '0 ' . $txt['members'] : implode(', ', $context['view_members_list']) . (empty($context['view_num_hidden']) || $context['can_moderate_forum'] ? '' : ' (+ ' . $context['view_num_hidden'] . ' ' . $txt['hidden'] . ')'); |
|
182 | + } |
|
173 | 183 | echo $txt['who_and'], $context['view_num_guests'], ' ', $context['view_num_guests'] == 1 ? $txt['guest'] : $txt['guests'], $txt['who_viewing_board']; |
174 | 184 | |
175 | 185 | echo ' |
@@ -189,32 +199,36 @@ discard block |
||
189 | 199 | <div class="lastpost">', $context['topics_headers']['last_post'], '</div>'; |
190 | 200 | |
191 | 201 | // Show a "select all" box for quick moderation? |
192 | - if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] == 1) |
|
193 | - echo ' |
|
202 | + if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] == 1) { |
|
203 | + echo ' |
|
194 | 204 | <div class="moderation"> |
195 | 205 | <input type="checkbox" onclick="invertAll(this, this.form, \'topics[]\');"> |
196 | 206 | </div>'; |
207 | + } |
|
197 | 208 | |
198 | 209 | // If it's on in "image" mode, don't show anything but the column. |
199 | - elseif (!empty($context['can_quick_mod'])) |
|
200 | - echo ' |
|
210 | + elseif (!empty($context['can_quick_mod'])) { |
|
211 | + echo ' |
|
201 | 212 | <div class="moderation"></div>'; |
213 | + } |
|
202 | 214 | } |
203 | 215 | |
204 | 216 | // No topics... just say, "sorry bub". |
205 | - else |
|
206 | - echo ' |
|
217 | + else { |
|
218 | + echo ' |
|
207 | 219 | <h3 class="titlebg">', $txt['topic_alert_none'], '</h3>'; |
220 | + } |
|
208 | 221 | |
209 | 222 | echo ' |
210 | 223 | </div><!-- #topic_header -->'; |
211 | 224 | |
212 | 225 | // If this person can approve items and we have some awaiting approval tell them. |
213 | - if (!empty($context['unapproved_posts_message'])) |
|
214 | - echo ' |
|
226 | + if (!empty($context['unapproved_posts_message'])) { |
|
227 | + echo ' |
|
215 | 228 | <div class="information"> |
216 | 229 | <span class="alert">!</span> ', $context['unapproved_posts_message'], ' |
217 | 230 | </div>'; |
231 | + } |
|
218 | 232 | |
219 | 233 | // Contain the topic list |
220 | 234 | echo ' |
@@ -235,25 +249,30 @@ discard block |
||
235 | 249 | echo ' |
236 | 250 | <div class="icons floatright">'; |
237 | 251 | |
238 | - if ($topic['is_watched']) |
|
239 | - echo ' |
|
252 | + if ($topic['is_watched']) { |
|
253 | + echo ' |
|
240 | 254 | <span class="generic_icons watch" title="', $txt['watching_this_topic'], '"></span>'; |
255 | + } |
|
241 | 256 | |
242 | - if ($topic['is_locked']) |
|
243 | - echo ' |
|
257 | + if ($topic['is_locked']) { |
|
258 | + echo ' |
|
244 | 259 | <span class="generic_icons lock"></span>'; |
260 | + } |
|
245 | 261 | |
246 | - if ($topic['is_sticky']) |
|
247 | - echo ' |
|
262 | + if ($topic['is_sticky']) { |
|
263 | + echo ' |
|
248 | 264 | <span class="generic_icons sticky"></span>'; |
265 | + } |
|
249 | 266 | |
250 | - if ($topic['is_redirect']) |
|
251 | - echo ' |
|
267 | + if ($topic['is_redirect']) { |
|
268 | + echo ' |
|
252 | 269 | <span class="generic_icons move"></span>'; |
270 | + } |
|
253 | 271 | |
254 | - if ($topic['is_poll']) |
|
255 | - echo ' |
|
272 | + if ($topic['is_poll']) { |
|
273 | + echo ' |
|
256 | 274 | <span class="generic_icons poll"></span>'; |
275 | + } |
|
257 | 276 | |
258 | 277 | echo ' |
259 | 278 | </div>'; |
@@ -285,26 +304,31 @@ discard block |
||
285 | 304 | echo ' |
286 | 305 | <div class="moderation">'; |
287 | 306 | |
288 | - if ($options['display_quick_mod'] == 1) |
|
289 | - echo ' |
|
307 | + if ($options['display_quick_mod'] == 1) { |
|
308 | + echo ' |
|
290 | 309 | <input type="checkbox" name="topics[]" value="', $topic['id'], '">'; |
291 | - else |
|
310 | + } else |
|
292 | 311 | { |
293 | 312 | // Check permissions on each and show only the ones they are allowed to use. |
294 | - if ($topic['quick_mod']['remove']) |
|
295 | - echo '<a href="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], ';actions%5B', $topic['id'], '%5D=remove;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons delete" title="', $txt['remove_topic'], '"></span></a>'; |
|
313 | + if ($topic['quick_mod']['remove']) { |
|
314 | + echo '<a href="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], ';actions%5B', $topic['id'], '%5D=remove;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons delete" title="', $txt['remove_topic'], '"></span></a>'; |
|
315 | + } |
|
296 | 316 | |
297 | - if ($topic['quick_mod']['lock']) |
|
298 | - echo '<a href="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], ';actions%5B', $topic['id'], '%5D=lock;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons lock" title="', $topic['is_locked'] ? $txt['set_unlock'] : $txt['set_lock'], '"></span></a>'; |
|
317 | + if ($topic['quick_mod']['lock']) { |
|
318 | + echo '<a href="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], ';actions%5B', $topic['id'], '%5D=lock;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons lock" title="', $topic['is_locked'] ? $txt['set_unlock'] : $txt['set_lock'], '"></span></a>'; |
|
319 | + } |
|
299 | 320 | |
300 | - if ($topic['quick_mod']['lock'] || $topic['quick_mod']['remove']) |
|
301 | - echo '<br>'; |
|
321 | + if ($topic['quick_mod']['lock'] || $topic['quick_mod']['remove']) { |
|
322 | + echo '<br>'; |
|
323 | + } |
|
302 | 324 | |
303 | - if ($topic['quick_mod']['sticky']) |
|
304 | - echo '<a href="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], ';actions%5B', $topic['id'], '%5D=sticky;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons sticky" title="', $topic['is_sticky'] ? $txt['set_nonsticky'] : $txt['set_sticky'], '"></span></a>'; |
|
325 | + if ($topic['quick_mod']['sticky']) { |
|
326 | + echo '<a href="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], ';actions%5B', $topic['id'], '%5D=sticky;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons sticky" title="', $topic['is_sticky'] ? $txt['set_nonsticky'] : $txt['set_sticky'], '"></span></a>'; |
|
327 | + } |
|
305 | 328 | |
306 | - if ($topic['quick_mod']['move']) |
|
307 | - echo '<a href="', $scripturl, '?action=movetopic;current_board=', $context['current_board'], ';board=', $context['current_board'], '.', $context['start'], ';topic=', $topic['id'], '.0"><span class="generic_icons move" title="', $txt['move_topic'], '"></span></a>'; |
|
329 | + if ($topic['quick_mod']['move']) { |
|
330 | + echo '<a href="', $scripturl, '?action=movetopic;current_board=', $context['current_board'], ';board=', $context['current_board'], '.', $context['start'], ';topic=', $topic['id'], '.0"><span class="generic_icons move" title="', $txt['move_topic'], '"></span></a>'; |
|
331 | + } |
|
308 | 332 | } |
309 | 333 | echo ' |
310 | 334 | </div><!-- .moderation -->'; |
@@ -322,18 +346,20 @@ discard block |
||
322 | 346 | <select class="qaction" name="qaction"', $context['can_move'] ? ' onchange="this.form.move_to.disabled = (this.options[this.selectedIndex].value != \'move\');"' : '', '> |
323 | 347 | <option value="">--------</option>'; |
324 | 348 | |
325 | - foreach ($context['qmod_actions'] as $qmod_action) |
|
326 | - if ($context['can_' . $qmod_action]) |
|
349 | + foreach ($context['qmod_actions'] as $qmod_action) { |
|
350 | + if ($context['can_' . $qmod_action]) |
|
327 | 351 | echo ' |
328 | 352 | <option value="' . $qmod_action . '">' . $txt['quick_mod_' . $qmod_action] . '</option>'; |
353 | + } |
|
329 | 354 | |
330 | 355 | echo ' |
331 | 356 | </select>'; |
332 | 357 | |
333 | 358 | // Show a list of boards they can move the topic to. |
334 | - if ($context['can_move']) |
|
335 | - echo ' |
|
359 | + if ($context['can_move']) { |
|
360 | + echo ' |
|
336 | 361 | <span id="quick_mod_jump_to"></span>'; |
362 | + } |
|
337 | 363 | |
338 | 364 | echo ' |
339 | 365 | <input type="submit" value="', $txt['quick_mod_go'], '" onclick="return document.forms.quickModForm.qaction.value != \'\' && confirm(\'', $txt['quickmod_confirm'], '\');" class="button qaction"> |
@@ -344,10 +370,11 @@ discard block |
||
344 | 370 | </div><!-- #messageindex -->'; |
345 | 371 | |
346 | 372 | // Finish off the form - again. |
347 | - if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] > 0 && !empty($context['topics'])) |
|
348 | - echo ' |
|
373 | + if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] > 0 && !empty($context['topics'])) { |
|
374 | + echo ' |
|
349 | 375 | <input type="hidden" name="' . $context['session_var'] . '" value="' . $context['session_id'] . '"> |
350 | 376 | </form>'; |
377 | + } |
|
351 | 378 | |
352 | 379 | // Mobile action buttons (bottom) |
353 | 380 | echo ' |
@@ -369,8 +396,8 @@ discard block |
||
369 | 396 | // Show breadcrumbs at the bottom too. |
370 | 397 | theme_linktree(); |
371 | 398 | |
372 | - if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics']) && $context['can_move']) |
|
373 | - echo ' |
|
399 | + if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics']) && $context['can_move']) { |
|
400 | + echo ' |
|
374 | 401 | <script> |
375 | 402 | if (typeof(window.XMLHttpRequest) != "undefined") |
376 | 403 | aJumpTo[aJumpTo.length] = new JumpTo({ |
@@ -389,6 +416,7 @@ discard block |
||
389 | 416 | sCustomName: "move_to" |
390 | 417 | }); |
391 | 418 | </script>'; |
419 | + } |
|
392 | 420 | |
393 | 421 | // Javascript for inline editing. |
394 | 422 | echo ' |
@@ -425,8 +453,8 @@ discard block |
||
425 | 453 | <div class="information"> |
426 | 454 | <p class="floatright" id="message_index_jump_to"></p>'; |
427 | 455 | |
428 | - if (empty($context['no_topic_listing'])) |
|
429 | - echo ' |
|
456 | + if (empty($context['no_topic_listing'])) { |
|
457 | + echo ' |
|
430 | 458 | <p class="floatleft">', !empty($modSettings['enableParticipation']) && $context['user']['is_logged'] ? ' |
431 | 459 | <img src="' . $settings['images_url'] . '/icons/profile_sm.png" alt="" class="centericon"> ' . $txt['participation_caption'] . '<br>' : '', ' |
432 | 460 | '. ($modSettings['pollMode'] == '1' ? '<span class="generic_icons poll centericon"></span> ' . $txt['poll'] : '') . '<br> |
@@ -436,9 +464,10 @@ discard block |
||
436 | 464 | <span class="generic_icons lock centericon"></span> ' . $txt['locked_topic'] . '<br> |
437 | 465 | <span class="generic_icons sticky centericon"></span> ' . $txt['sticky_topic'] . '<br> |
438 | 466 | </p>'; |
467 | + } |
|
439 | 468 | |
440 | - if (!empty($context['jump_to'])) |
|
441 | - echo ' |
|
469 | + if (!empty($context['jump_to'])) { |
|
470 | + echo ' |
|
442 | 471 | <script> |
443 | 472 | if (typeof(window.XMLHttpRequest) != "undefined") |
444 | 473 | aJumpTo[aJumpTo.length] = new JumpTo({ |
@@ -454,6 +483,7 @@ discard block |
||
454 | 483 | sGoButtonLabel: "', $txt['quick_mod_go'], '" |
455 | 484 | }); |
456 | 485 | </script>'; |
486 | + } |
|
457 | 487 | |
458 | 488 | echo ' |
459 | 489 | <br class="clear"> |
@@ -13,8 +13,9 @@ discard block |
||
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 dispatcher; doesn't do anything, just delegates. |
@@ -92,18 +93,19 @@ discard block |
||
92 | 93 | checkSession('get'); |
93 | 94 | validateToken('admin-bm-' . (int) $_REQUEST['src_board'], 'request'); |
94 | 95 | |
95 | - if ($_REQUEST['move_to'] === 'top') |
|
96 | - $boardOptions = array( |
|
96 | + if ($_REQUEST['move_to'] === 'top') { |
|
97 | + $boardOptions = array( |
|
97 | 98 | 'move_to' => $_REQUEST['move_to'], |
98 | 99 | 'target_category' => (int) $_REQUEST['target_cat'], |
99 | 100 | 'move_first_child' => true, |
100 | 101 | ); |
101 | - else |
|
102 | - $boardOptions = array( |
|
102 | + } else { |
|
103 | + $boardOptions = array( |
|
103 | 104 | 'move_to' => $_REQUEST['move_to'], |
104 | 105 | 'target_board' => (int) $_REQUEST['target_board'], |
105 | 106 | 'move_first_child' => true, |
106 | 107 | ); |
108 | + } |
|
107 | 109 | modifyBoard((int) $_REQUEST['src_board'], $boardOptions); |
108 | 110 | } |
109 | 111 | |
@@ -148,15 +150,16 @@ discard block |
||
148 | 150 | $security = $context['session_var'] . '=' . $context['session_id'] . ';' . $context['admin-bm-' . $context['move_board'] . '_token_var'] . '=' . $context['admin-bm-' . $context['move_board'] . '_token']; |
149 | 151 | foreach ($boardList[$catid] as $boardid) |
150 | 152 | { |
151 | - if (!isset($context['categories'][$catid]['move_link'])) |
|
152 | - $context['categories'][$catid]['move_link'] = array( |
|
153 | + if (!isset($context['categories'][$catid]['move_link'])) { |
|
154 | + $context['categories'][$catid]['move_link'] = array( |
|
153 | 155 | 'child_level' => 0, |
154 | 156 | 'label' => $txt['mboards_order_before'] . ' \'' . $smcFunc['htmlspecialchars']($boards[$boardid]['name']) . '\'', |
155 | 157 | 'href' => $scripturl . '?action=admin;area=manageboards;sa=move;src_board=' . $context['move_board'] . ';target_board=' . $boardid . ';move_to=before;' . $security, |
156 | 158 | ); |
159 | + } |
|
157 | 160 | |
158 | - if (!$context['categories'][$catid]['boards'][$boardid]['move']) |
|
159 | - $context['categories'][$catid]['boards'][$boardid]['move_links'] = array( |
|
161 | + if (!$context['categories'][$catid]['boards'][$boardid]['move']) { |
|
162 | + $context['categories'][$catid]['boards'][$boardid]['move_links'] = array( |
|
160 | 163 | array( |
161 | 164 | 'child_level' => $boards[$boardid]['level'], |
162 | 165 | 'label' => $txt['mboards_order_after'] . '\'' . $smcFunc['htmlspecialchars']($boards[$boardid]['name']) . '\'', |
@@ -170,34 +173,39 @@ discard block |
||
170 | 173 | 'class' => 'here', |
171 | 174 | ), |
172 | 175 | ); |
176 | + } |
|
173 | 177 | |
174 | 178 | $difference = $boards[$boardid]['level'] - $prev_child_level; |
175 | - if ($difference == 1) |
|
176 | - array_push($stack, !empty($context['categories'][$catid]['boards'][$prev_board]['move_links']) ? array_shift($context['categories'][$catid]['boards'][$prev_board]['move_links']) : null); |
|
177 | - elseif ($difference < 0) |
|
179 | + if ($difference == 1) { |
|
180 | + array_push($stack, !empty($context['categories'][$catid]['boards'][$prev_board]['move_links']) ? array_shift($context['categories'][$catid]['boards'][$prev_board]['move_links']) : null); |
|
181 | + } elseif ($difference < 0) |
|
178 | 182 | { |
179 | - if (empty($context['categories'][$catid]['boards'][$prev_board]['move_links'])) |
|
180 | - $context['categories'][$catid]['boards'][$prev_board]['move_links'] = array(); |
|
181 | - for ($i = 0; $i < -$difference; $i++) |
|
182 | - if (($temp = array_pop($stack)) != null) |
|
183 | + if (empty($context['categories'][$catid]['boards'][$prev_board]['move_links'])) { |
|
184 | + $context['categories'][$catid]['boards'][$prev_board]['move_links'] = array(); |
|
185 | + } |
|
186 | + for ($i = 0; $i < -$difference; $i++) { |
|
187 | + if (($temp = array_pop($stack)) != null) |
|
183 | 188 | array_unshift($context['categories'][$catid]['boards'][$prev_board]['move_links'], $temp); |
189 | + } |
|
184 | 190 | } |
185 | 191 | |
186 | 192 | $prev_board = $boardid; |
187 | 193 | $prev_child_level = $boards[$boardid]['level']; |
188 | 194 | |
189 | 195 | } |
190 | - if (!empty($stack) && !empty($context['categories'][$catid]['boards'][$prev_board]['move_links'])) |
|
191 | - $context['categories'][$catid]['boards'][$prev_board]['move_links'] = array_merge($stack, $context['categories'][$catid]['boards'][$prev_board]['move_links']); |
|
192 | - elseif (!empty($stack)) |
|
193 | - $context['categories'][$catid]['boards'][$prev_board]['move_links'] = $stack; |
|
196 | + if (!empty($stack) && !empty($context['categories'][$catid]['boards'][$prev_board]['move_links'])) { |
|
197 | + $context['categories'][$catid]['boards'][$prev_board]['move_links'] = array_merge($stack, $context['categories'][$catid]['boards'][$prev_board]['move_links']); |
|
198 | + } elseif (!empty($stack)) { |
|
199 | + $context['categories'][$catid]['boards'][$prev_board]['move_links'] = $stack; |
|
200 | + } |
|
194 | 201 | |
195 | - if (empty($boardList[$catid])) |
|
196 | - $context['categories'][$catid]['move_link'] = array( |
|
202 | + if (empty($boardList[$catid])) { |
|
203 | + $context['categories'][$catid]['move_link'] = array( |
|
197 | 204 | 'child_level' => 0, |
198 | 205 | 'label' => $txt['mboards_order_before'] . ' \'' . $smcFunc['htmlspecialchars']($tree['node']['name']) . '\'', |
199 | 206 | 'href' => $scripturl . '?action=admin;area=manageboards;sa=move;src_board=' . $context['move_board'] . ';target_cat=' . $catid . ';move_to=top;' . $security, |
200 | 207 | ); |
208 | + } |
|
201 | 209 | } |
202 | 210 | } |
203 | 211 | |
@@ -253,9 +261,9 @@ discard block |
||
253 | 261 | ); |
254 | 262 | } |
255 | 263 | // Category doesn't exist, man... sorry. |
256 | - elseif (!isset($cat_tree[$_REQUEST['cat']])) |
|
257 | - redirectexit('action=admin;area=manageboards'); |
|
258 | - else |
|
264 | + elseif (!isset($cat_tree[$_REQUEST['cat']])) { |
|
265 | + redirectexit('action=admin;area=manageboards'); |
|
266 | + } else |
|
259 | 267 | { |
260 | 268 | $context['category'] = array( |
261 | 269 | 'id' => $_REQUEST['cat'], |
@@ -267,30 +275,31 @@ discard block |
||
267 | 275 | 'is_empty' => empty($cat_tree[$_REQUEST['cat']]['children']) |
268 | 276 | ); |
269 | 277 | |
270 | - foreach ($boardList[$_REQUEST['cat']] as $child_board) |
|
271 | - $context['category']['children'][] = str_repeat('-', $boards[$child_board]['level']) . ' ' . $boards[$child_board]['name']; |
|
278 | + foreach ($boardList[$_REQUEST['cat']] as $child_board) { |
|
279 | + $context['category']['children'][] = str_repeat('-', $boards[$child_board]['level']) . ' ' . $boards[$child_board]['name']; |
|
280 | + } |
|
272 | 281 | } |
273 | 282 | |
274 | 283 | $prevCat = 0; |
275 | 284 | foreach ($cat_tree as $catid => $tree) |
276 | 285 | { |
277 | - if ($catid == $_REQUEST['cat'] && $prevCat > 0) |
|
278 | - $context['category_order'][$prevCat]['selected'] = true; |
|
279 | - elseif ($catid != $_REQUEST['cat']) |
|
280 | - $context['category_order'][$catid] = array( |
|
286 | + if ($catid == $_REQUEST['cat'] && $prevCat > 0) { |
|
287 | + $context['category_order'][$prevCat]['selected'] = true; |
|
288 | + } elseif ($catid != $_REQUEST['cat']) { |
|
289 | + $context['category_order'][$catid] = array( |
|
281 | 290 | 'id' => $catid, |
282 | 291 | 'name' => $txt['mboards_order_after'] . $tree['node']['name'], |
283 | 292 | 'selected' => false, |
284 | 293 | 'true_name' => $tree['node']['name'] |
285 | 294 | ); |
295 | + } |
|
286 | 296 | $prevCat = $catid; |
287 | 297 | } |
288 | 298 | if (!isset($_REQUEST['delete'])) |
289 | 299 | { |
290 | 300 | $context['sub_template'] = 'modify_category'; |
291 | 301 | $context['page_title'] = $_REQUEST['sa'] == 'newcat' ? $txt['mboards_new_cat_name'] : $txt['catEdit']; |
292 | - } |
|
293 | - else |
|
302 | + } else |
|
294 | 303 | { |
295 | 304 | $context['sub_template'] = 'confirm_category_delete'; |
296 | 305 | $context['page_title'] = $txt['mboards_delete_cat']; |
@@ -327,8 +336,9 @@ discard block |
||
327 | 336 | { |
328 | 337 | $catOptions = array(); |
329 | 338 | |
330 | - if (isset($_POST['cat_order'])) |
|
331 | - $catOptions['move_after'] = (int) $_POST['cat_order']; |
|
339 | + if (isset($_POST['cat_order'])) { |
|
340 | + $catOptions['move_after'] = (int) $_POST['cat_order']; |
|
341 | + } |
|
332 | 342 | |
333 | 343 | // Change "This & That" to "This & That" but don't change "¢" to "&cent;"... |
334 | 344 | $catOptions['cat_name'] = parse_bbc($smcFunc['htmlspecialchars']($_POST['cat_name']), false, '', $context['description_allowed_tags']); |
@@ -336,10 +346,11 @@ discard block |
||
336 | 346 | |
337 | 347 | $catOptions['is_collapsible'] = isset($_POST['collapse']); |
338 | 348 | |
339 | - if (isset($_POST['add'])) |
|
340 | - createCategory($catOptions); |
|
341 | - else |
|
342 | - modifyCategory($_POST['cat'], $catOptions); |
|
349 | + if (isset($_POST['add'])) { |
|
350 | + createCategory($catOptions); |
|
351 | + } else { |
|
352 | + modifyCategory($_POST['cat'], $catOptions); |
|
353 | + } |
|
343 | 354 | } |
344 | 355 | // If they want to delete - first give them confirmation. |
345 | 356 | elseif (isset($_POST['delete']) && !isset($_POST['confirmation']) && !isset($_POST['empty'])) |
@@ -353,13 +364,14 @@ discard block |
||
353 | 364 | // First off - check if we are moving all the current boards first - before we start deleting! |
354 | 365 | if (isset($_POST['delete_action']) && $_POST['delete_action'] == 1) |
355 | 366 | { |
356 | - if (empty($_POST['cat_to'])) |
|
357 | - fatal_lang_error('mboards_delete_error'); |
|
367 | + if (empty($_POST['cat_to'])) { |
|
368 | + fatal_lang_error('mboards_delete_error'); |
|
369 | + } |
|
358 | 370 | |
359 | 371 | deleteCategories(array($_POST['cat']), (int) $_POST['cat_to']); |
372 | + } else { |
|
373 | + deleteCategories(array($_POST['cat'])); |
|
360 | 374 | } |
361 | - else |
|
362 | - deleteCategories(array($_POST['cat'])); |
|
363 | 375 | } |
364 | 376 | |
365 | 377 | redirectexit('action=admin;area=manageboards'); |
@@ -404,8 +416,9 @@ discard block |
||
404 | 416 | if ($_REQUEST['sa'] == 'newboard') |
405 | 417 | { |
406 | 418 | // Category doesn't exist, man... sorry. |
407 | - if (empty($_REQUEST['cat'])) |
|
408 | - redirectexit('action=admin;area=manageboards'); |
|
419 | + if (empty($_REQUEST['cat'])) { |
|
420 | + redirectexit('action=admin;area=manageboards'); |
|
421 | + } |
|
409 | 422 | |
410 | 423 | // Some things that need to be setup for a new board. |
411 | 424 | $curBoard = array( |
@@ -429,8 +442,7 @@ discard block |
||
429 | 442 | 'category' => (int) $_REQUEST['cat'], |
430 | 443 | 'no_children' => true, |
431 | 444 | ); |
432 | - } |
|
433 | - else |
|
445 | + } else |
|
434 | 446 | { |
435 | 447 | // Just some easy shortcuts. |
436 | 448 | $curBoard = &$boards[$_REQUEST['boardid']]; |
@@ -478,8 +490,9 @@ discard block |
||
478 | 490 | ); |
479 | 491 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
480 | 492 | { |
481 | - if ($_REQUEST['sa'] == 'newboard' && $row['min_posts'] == -1) |
|
482 | - $curBoard['member_groups'][] = $row['id_group']; |
|
493 | + if ($_REQUEST['sa'] == 'newboard' && $row['min_posts'] == -1) { |
|
494 | + $curBoard['member_groups'][] = $row['id_group']; |
|
495 | + } |
|
483 | 496 | |
484 | 497 | $context['groups'][(int) $row['id_group']] = array( |
485 | 498 | 'id' => $row['id_group'], |
@@ -492,8 +505,9 @@ discard block |
||
492 | 505 | $smcFunc['db_free_result']($request); |
493 | 506 | |
494 | 507 | // Category doesn't exist, man... sorry. |
495 | - if (!isset($boardList[$curBoard['category']])) |
|
496 | - redirectexit('action=admin;area=manageboards'); |
|
508 | + if (!isset($boardList[$curBoard['category']])) { |
|
509 | + redirectexit('action=admin;area=manageboards'); |
|
510 | + } |
|
497 | 511 | |
498 | 512 | foreach ($boardList[$curBoard['category']] as $boardid) |
499 | 513 | { |
@@ -507,8 +521,7 @@ discard block |
||
507 | 521 | 'is_child' => false, |
508 | 522 | 'selected' => true |
509 | 523 | ); |
510 | - } |
|
511 | - else |
|
524 | + } else |
|
512 | 525 | { |
513 | 526 | $context['board_order'][] = array( |
514 | 527 | 'id' => $boardid, |
@@ -525,19 +538,21 @@ discard block |
||
525 | 538 | $context['can_move_children'] = false; |
526 | 539 | $context['children'] = $boards[$_REQUEST['boardid']]['tree']['children']; |
527 | 540 | |
528 | - foreach ($context['board_order'] as $lBoard) |
|
529 | - if ($lBoard['is_child'] == false && $lBoard['selected'] == false) |
|
541 | + foreach ($context['board_order'] as $lBoard) { |
|
542 | + if ($lBoard['is_child'] == false && $lBoard['selected'] == false) |
|
530 | 543 | $context['can_move_children'] = true; |
544 | + } |
|
531 | 545 | } |
532 | 546 | |
533 | 547 | // Get other available categories. |
534 | 548 | $context['categories'] = array(); |
535 | - foreach ($cat_tree as $catID => $tree) |
|
536 | - $context['categories'][] = array( |
|
549 | + foreach ($cat_tree as $catID => $tree) { |
|
550 | + $context['categories'][] = array( |
|
537 | 551 | 'id' => $catID == $curBoard['category'] ? 0 : $catID, |
538 | 552 | 'name' => $tree['node']['name'], |
539 | 553 | 'selected' => $catID == $curBoard['category'] |
540 | 554 | ); |
555 | + } |
|
541 | 556 | |
542 | 557 | $request = $smcFunc['db_query']('', ' |
543 | 558 | SELECT mem.id_member, mem.real_name |
@@ -549,14 +564,16 @@ discard block |
||
549 | 564 | ) |
550 | 565 | ); |
551 | 566 | $context['board']['moderators'] = array(); |
552 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
553 | - $context['board']['moderators'][$row['id_member']] = $row['real_name']; |
|
567 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
568 | + $context['board']['moderators'][$row['id_member']] = $row['real_name']; |
|
569 | + } |
|
554 | 570 | $smcFunc['db_free_result']($request); |
555 | 571 | |
556 | 572 | $context['board']['moderator_list'] = empty($context['board']['moderators']) ? '' : '"' . implode('", "', $context['board']['moderators']) . '"'; |
557 | 573 | |
558 | - if (!empty($context['board']['moderators'])) |
|
559 | - list ($context['board']['last_moderator_id']) = array_slice(array_keys($context['board']['moderators']), -1); |
|
574 | + if (!empty($context['board']['moderators'])) { |
|
575 | + list ($context['board']['last_moderator_id']) = array_slice(array_keys($context['board']['moderators']), -1); |
|
576 | + } |
|
560 | 577 | |
561 | 578 | // Get all the groups assigned as moderators |
562 | 579 | $request = $smcFunc['db_query']('', ' |
@@ -568,14 +585,16 @@ discard block |
||
568 | 585 | ) |
569 | 586 | ); |
570 | 587 | $context['board']['moderator_groups'] = array(); |
571 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
572 | - $context['board']['moderator_groups'][$row['id_group']] = $context['groups'][$row['id_group']]['name']; |
|
588 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
589 | + $context['board']['moderator_groups'][$row['id_group']] = $context['groups'][$row['id_group']]['name']; |
|
590 | + } |
|
573 | 591 | $smcFunc['db_free_result']($request); |
574 | 592 | |
575 | 593 | $context['board']['moderator_groups_list'] = empty($context['board']['moderator_groups']) ? '' : '"' . implode('", &qout;', $context['board']['moderator_groups']) . '"'; |
576 | 594 | |
577 | - if (!empty($context['board']['moderator_groups'])) |
|
578 | - list ($context['board']['last_moderator_group_id']) = array_slice(array_keys($context['board']['moderator_groups']), -1); |
|
595 | + if (!empty($context['board']['moderator_groups'])) { |
|
596 | + list ($context['board']['last_moderator_group_id']) = array_slice(array_keys($context['board']['moderator_groups']), -1); |
|
597 | + } |
|
579 | 598 | |
580 | 599 | // Get all the themes... |
581 | 600 | $request = $smcFunc['db_query']('', ' |
@@ -587,8 +606,9 @@ discard block |
||
587 | 606 | ) |
588 | 607 | ); |
589 | 608 | $context['themes'] = array(); |
590 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
591 | - $context['themes'][] = $row; |
|
609 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
610 | + $context['themes'][] = $row; |
|
611 | + } |
|
592 | 612 | $smcFunc['db_free_result']($request); |
593 | 613 | |
594 | 614 | if (!isset($_REQUEST['delete'])) |
@@ -596,8 +616,7 @@ discard block |
||
596 | 616 | $context['sub_template'] = 'modify_board'; |
597 | 617 | $context['page_title'] = $txt['boardsEdit']; |
598 | 618 | loadJavaScriptFile('suggest.js', array('defer' => false), 'smf_suggest'); |
599 | - } |
|
600 | - else |
|
619 | + } else |
|
601 | 620 | { |
602 | 621 | $context['sub_template'] = 'confirm_board_delete'; |
603 | 622 | $context['page_title'] = $txt['mboards_delete_board']; |
@@ -641,8 +660,9 @@ discard block |
||
641 | 660 | // Change the boardorder of this board? |
642 | 661 | elseif (!empty($_POST['placement']) && !empty($_POST['board_order'])) |
643 | 662 | { |
644 | - if (!in_array($_POST['placement'], array('before', 'after', 'child'))) |
|
645 | - fatal_lang_error('mangled_post', false); |
|
663 | + if (!in_array($_POST['placement'], array('before', 'after', 'child'))) { |
|
664 | + fatal_lang_error('mangled_post', false); |
|
665 | + } |
|
646 | 666 | |
647 | 667 | $boardOptions['move_to'] = $_POST['placement']; |
648 | 668 | $boardOptions['target_board'] = (int) $_POST['board_order']; |
@@ -655,13 +675,14 @@ discard block |
||
655 | 675 | $boardOptions['access_groups'] = array(); |
656 | 676 | $boardOptions['deny_groups'] = array(); |
657 | 677 | |
658 | - if (!empty($_POST['groups'])) |
|
659 | - foreach ($_POST['groups'] as $group => $action) |
|
678 | + if (!empty($_POST['groups'])) { |
|
679 | + foreach ($_POST['groups'] as $group => $action) |
|
660 | 680 | { |
661 | 681 | if ($action == 'allow') |
662 | 682 | $boardOptions['access_groups'][] = (int) $group; |
663 | - elseif ($action == 'deny') |
|
664 | - $boardOptions['deny_groups'][] = (int) $group; |
|
683 | + } elseif ($action == 'deny') { |
|
684 | + $boardOptions['deny_groups'][] = (int) $group; |
|
685 | + } |
|
665 | 686 | } |
666 | 687 | |
667 | 688 | // People with manage-boards are special. |
@@ -673,8 +694,9 @@ discard block |
||
673 | 694 | // Secondly, make sure those with super cow powers (like apt-get, or in this case manage boards) are upgraded. |
674 | 695 | $boardOptions['access_groups'] = array_unique(array_merge($boardOptions['access_groups'], $board_managers)); |
675 | 696 | |
676 | - if (strlen(implode(',', $boardOptions['access_groups'])) > 255 || strlen(implode(',', $boardOptions['deny_groups'])) > 255) |
|
677 | - fatal_lang_error('too_many_groups', false); |
|
697 | + if (strlen(implode(',', $boardOptions['access_groups'])) > 255 || strlen(implode(',', $boardOptions['deny_groups'])) > 255) { |
|
698 | + fatal_lang_error('too_many_groups', false); |
|
699 | + } |
|
678 | 700 | |
679 | 701 | // Do not allow HTML tags. Parse the string. |
680 | 702 | $boardOptions['board_name'] = parse_bbc($smcFunc['htmlspecialchars']($_POST['board_name']), false, '', $context['description_allowed_tags']); |
@@ -685,8 +707,9 @@ discard block |
||
685 | 707 | if (isset($_POST['moderator_list']) && is_array($_POST['moderator_list'])) |
686 | 708 | { |
687 | 709 | $moderators = array(); |
688 | - foreach ($_POST['moderator_list'] as $moderator) |
|
689 | - $moderators[(int) $moderator] = (int) $moderator; |
|
710 | + foreach ($_POST['moderator_list'] as $moderator) { |
|
711 | + $moderators[(int) $moderator] = (int) $moderator; |
|
712 | + } |
|
690 | 713 | $boardOptions['moderators'] = $moderators; |
691 | 714 | } |
692 | 715 | |
@@ -695,8 +718,9 @@ discard block |
||
695 | 718 | if (isset($_POST['moderator_group_list']) && is_array($_POST['moderator_group_list'])) |
696 | 719 | { |
697 | 720 | $moderator_groups = array(); |
698 | - foreach ($_POST['moderator_group_list'] as $moderator_group) |
|
699 | - $moderator_groups[(int) $moderator_group] = (int) $moderator_group; |
|
721 | + foreach ($_POST['moderator_group_list'] as $moderator_group) { |
|
722 | + $moderator_groups[(int) $moderator_group] = (int) $moderator_group; |
|
723 | + } |
|
700 | 724 | $boardOptions['moderator_groups'] = $moderator_groups; |
701 | 725 | } |
702 | 726 | |
@@ -722,56 +746,62 @@ discard block |
||
722 | 746 | $smcFunc['db_free_result']($request); |
723 | 747 | |
724 | 748 | // If we're turning redirection on check the board doesn't have posts in it - if it does don't make it a redirection board. |
725 | - if ($boardOptions['redirect'] && empty($oldRedirect) && $numPosts) |
|
726 | - unset($boardOptions['redirect']); |
|
749 | + if ($boardOptions['redirect'] && empty($oldRedirect) && $numPosts) { |
|
750 | + unset($boardOptions['redirect']); |
|
751 | + } |
|
727 | 752 | // Reset the redirection count when switching on/off. |
728 | - elseif (empty($boardOptions['redirect']) != empty($oldRedirect)) |
|
729 | - $boardOptions['num_posts'] = 0; |
|
753 | + elseif (empty($boardOptions['redirect']) != empty($oldRedirect)) { |
|
754 | + $boardOptions['num_posts'] = 0; |
|
755 | + } |
|
730 | 756 | // Resetting the count? |
731 | - elseif ($boardOptions['redirect'] && !empty($_POST['reset_redirect'])) |
|
732 | - $boardOptions['num_posts'] = 0; |
|
757 | + elseif ($boardOptions['redirect'] && !empty($_POST['reset_redirect'])) { |
|
758 | + $boardOptions['num_posts'] = 0; |
|
759 | + } |
|
733 | 760 | } |
734 | 761 | |
735 | 762 | // Create a new board... |
736 | 763 | if (isset($_POST['add'])) |
737 | 764 | { |
738 | 765 | // New boards by default go to the bottom of the category. |
739 | - if (empty($_POST['new_cat'])) |
|
740 | - $boardOptions['target_category'] = (int) $_POST['cur_cat']; |
|
741 | - if (!isset($boardOptions['move_to'])) |
|
742 | - $boardOptions['move_to'] = 'bottom'; |
|
766 | + if (empty($_POST['new_cat'])) { |
|
767 | + $boardOptions['target_category'] = (int) $_POST['cur_cat']; |
|
768 | + } |
|
769 | + if (!isset($boardOptions['move_to'])) { |
|
770 | + $boardOptions['move_to'] = 'bottom'; |
|
771 | + } |
|
743 | 772 | |
744 | 773 | createBoard($boardOptions); |
745 | 774 | } |
746 | 775 | |
747 | 776 | // ...or update an existing board. |
748 | - else |
|
749 | - modifyBoard($_POST['boardid'], $boardOptions); |
|
750 | - } |
|
751 | - elseif (isset($_POST['delete']) && !isset($_POST['confirmation']) && !isset($_POST['no_children'])) |
|
777 | + else { |
|
778 | + modifyBoard($_POST['boardid'], $boardOptions); |
|
779 | + } |
|
780 | + } elseif (isset($_POST['delete']) && !isset($_POST['confirmation']) && !isset($_POST['no_children'])) |
|
752 | 781 | { |
753 | 782 | EditBoard(); |
754 | 783 | return; |
755 | - } |
|
756 | - elseif (isset($_POST['delete'])) |
|
784 | + } elseif (isset($_POST['delete'])) |
|
757 | 785 | { |
758 | 786 | // First off - check if we are moving all the current child boards first - before we start deleting! |
759 | 787 | if (isset($_POST['delete_action']) && $_POST['delete_action'] == 1) |
760 | 788 | { |
761 | - if (empty($_POST['board_to'])) |
|
762 | - fatal_lang_error('mboards_delete_board_error'); |
|
789 | + if (empty($_POST['board_to'])) { |
|
790 | + fatal_lang_error('mboards_delete_board_error'); |
|
791 | + } |
|
763 | 792 | |
764 | 793 | deleteBoards(array($_POST['boardid']), (int) $_POST['board_to']); |
794 | + } else { |
|
795 | + deleteBoards(array($_POST['boardid']), 0); |
|
765 | 796 | } |
766 | - else |
|
767 | - deleteBoards(array($_POST['boardid']), 0); |
|
768 | 797 | } |
769 | 798 | |
770 | - if (isset($_REQUEST['rid']) && $_REQUEST['rid'] == 'permissions') |
|
771 | - redirectexit('action=admin;area=permissions;sa=board;' . $context['session_var'] . '=' . $context['session_id']); |
|
772 | - else |
|
773 | - redirectexit('action=admin;area=manageboards'); |
|
774 | -} |
|
799 | + if (isset($_REQUEST['rid']) && $_REQUEST['rid'] == 'permissions') { |
|
800 | + redirectexit('action=admin;area=permissions;sa=board;' . $context['session_var'] . '=' . $context['session_id']); |
|
801 | + } else { |
|
802 | + redirectexit('action=admin;area=manageboards'); |
|
803 | + } |
|
804 | + } |
|
775 | 805 | |
776 | 806 | /** |
777 | 807 | * Used to retrieve data for modifying a board category |
@@ -808,8 +838,9 @@ discard block |
||
808 | 838 | $smcFunc['db_free_result']($request); |
809 | 839 | |
810 | 840 | // This would probably never happen, but just to be sure. |
811 | - if ($cat .= $allowed_sa[1]) |
|
812 | - die(str_replace(',', ' to', $cat)); |
|
841 | + if ($cat .= $allowed_sa[1]) { |
|
842 | + die(str_replace(',', ' to', $cat)); |
|
843 | + } |
|
813 | 844 | |
814 | 845 | redirectexit(); |
815 | 846 | } |
@@ -835,8 +866,9 @@ discard block |
||
835 | 866 | 'empty_string' => '', |
836 | 867 | ) |
837 | 868 | ); |
838 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
839 | - $recycle_boards[$row['id_board']] = $row['cat_name'] . ' - ' . $row['board_name']; |
|
869 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
870 | + $recycle_boards[$row['id_board']] = $row['cat_name'] . ' - ' . $row['board_name']; |
|
871 | + } |
|
840 | 872 | $smcFunc['db_free_result']($request); |
841 | 873 | |
842 | 874 | if (!empty($recycle_boards)) |
@@ -844,9 +876,9 @@ discard block |
||
844 | 876 | require_once($sourcedir . '/Subs-Boards.php'); |
845 | 877 | sortBoards($recycle_boards); |
846 | 878 | $recycle_boards = array('') + $recycle_boards; |
879 | + } else { |
|
880 | + $recycle_boards = array(''); |
|
847 | 881 | } |
848 | - else |
|
849 | - $recycle_boards = array(''); |
|
850 | 882 | |
851 | 883 | // Here and the board settings... |
852 | 884 | $config_vars = array( |
@@ -864,8 +896,9 @@ discard block |
||
864 | 896 | |
865 | 897 | call_integration_hook('integrate_modify_board_settings', array(&$config_vars)); |
866 | 898 | |
867 | - if ($return_config) |
|
868 | - return $config_vars; |
|
899 | + if ($return_config) { |
|
900 | + return $config_vars; |
|
901 | + } |
|
869 | 902 | |
870 | 903 | // Needed for the settings template. |
871 | 904 | require_once($sourcedir . '/ManageServer.php'); |
@@ -2259,9 +2259,9 @@ discard block |
||
2259 | 2259 | * |
2260 | 2260 | * @uses the template_include() function to include the file. |
2261 | 2261 | * @param string $template_name The name of the template to load |
2262 | - * @param array|string $style_sheets The name of a single stylesheet or an array of names of stylesheets to load |
|
2262 | + * @param string $style_sheets The name of a single stylesheet or an array of names of stylesheets to load |
|
2263 | 2263 | * @param bool $fatal If true, dies with an error message if the template cannot be found |
2264 | - * @return boolean Whether or not the template was loaded |
|
2264 | + * @return boolean|null Whether or not the template was loaded |
|
2265 | 2265 | */ |
2266 | 2266 | function loadTemplate($template_name, $style_sheets = array(), $fatal = true) |
2267 | 2267 | { |
@@ -2444,7 +2444,7 @@ discard block |
||
2444 | 2444 | * - all code added with this function is added to the same <style> tag so do make sure your css is valid! |
2445 | 2445 | * |
2446 | 2446 | * @param string $css Some css code |
2447 | - * @return void|bool Adds the CSS to the $context['css_header'] array or returns if no CSS is specified |
|
2447 | + * @return false|null Adds the CSS to the $context['css_header'] array or returns if no CSS is specified |
|
2448 | 2448 | */ |
2449 | 2449 | function addInlineCss($css) |
2450 | 2450 | { |
@@ -2558,7 +2558,7 @@ discard block |
||
2558 | 2558 | * |
2559 | 2559 | * @param string $javascript Some JS code |
2560 | 2560 | * @param bool $defer Whether the script should load in <head> or before the closing <html> tag |
2561 | - * @return void|bool Adds the code to one of the $context['javascript_inline'] arrays or returns if no JS was specified |
|
2561 | + * @return false|null Adds the code to one of the $context['javascript_inline'] arrays or returns if no JS was specified |
|
2562 | 2562 | */ |
2563 | 2563 | function addInlineJavaScript($javascript, $defer = false) |
2564 | 2564 | { |
@@ -2791,7 +2791,7 @@ discard block |
||
2791 | 2791 | * It will try to choose only utf8 or non-utf8 languages. |
2792 | 2792 | * |
2793 | 2793 | * @param bool $use_cache Whether or not to use the cache |
2794 | - * @return array An array of information about available languages |
|
2794 | + * @return string An array of information about available languages |
|
2795 | 2795 | */ |
2796 | 2796 | function getLanguages($use_cache = true) |
2797 | 2797 | { |
@@ -1719,7 +1719,7 @@ |
||
1719 | 1719 | $id_theme = $modSettings['theme_guests']; |
1720 | 1720 | |
1721 | 1721 | // We already load the basic stuff? |
1722 | - if (empty($settings['theme_id']) || $settings['theme_id'] != $id_theme ) |
|
1722 | + if (empty($settings['theme_id']) || $settings['theme_id'] != $id_theme) |
|
1723 | 1723 | { |
1724 | 1724 | // Verify the id_theme... no foul play. |
1725 | 1725 | // Always allow the board specific theme, if they are overriding. |
@@ -13,8 +13,9 @@ discard block |
||
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 | * Load the $modSettings array. |
@@ -25,13 +26,14 @@ discard block |
||
25 | 26 | global $cache_enable, $sourcedir, $context; |
26 | 27 | |
27 | 28 | // Most database systems have not set UTF-8 as their default input charset. |
28 | - if (!empty($db_character_set)) |
|
29 | - $smcFunc['db_query']('', ' |
|
29 | + if (!empty($db_character_set)) { |
|
30 | + $smcFunc['db_query']('', ' |
|
30 | 31 | SET NAMES {string:db_character_set}', |
31 | 32 | array( |
32 | 33 | 'db_character_set' => $db_character_set, |
33 | 34 | ) |
34 | 35 | ); |
36 | + } |
|
35 | 37 | |
36 | 38 | // We need some caching support, maybe. |
37 | 39 | loadCacheAccelerator(); |
@@ -46,28 +48,36 @@ discard block |
||
46 | 48 | ) |
47 | 49 | ); |
48 | 50 | $modSettings = array(); |
49 | - if (!$request) |
|
50 | - display_db_error(); |
|
51 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
52 | - $modSettings[$row[0]] = $row[1]; |
|
51 | + if (!$request) { |
|
52 | + display_db_error(); |
|
53 | + } |
|
54 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
55 | + $modSettings[$row[0]] = $row[1]; |
|
56 | + } |
|
53 | 57 | $smcFunc['db_free_result']($request); |
54 | 58 | |
55 | 59 | // Do a few things to protect against missing settings or settings with invalid values... |
56 | - if (empty($modSettings['defaultMaxTopics']) || $modSettings['defaultMaxTopics'] <= 0 || $modSettings['defaultMaxTopics'] > 999) |
|
57 | - $modSettings['defaultMaxTopics'] = 20; |
|
58 | - if (empty($modSettings['defaultMaxMessages']) || $modSettings['defaultMaxMessages'] <= 0 || $modSettings['defaultMaxMessages'] > 999) |
|
59 | - $modSettings['defaultMaxMessages'] = 15; |
|
60 | - if (empty($modSettings['defaultMaxMembers']) || $modSettings['defaultMaxMembers'] <= 0 || $modSettings['defaultMaxMembers'] > 999) |
|
61 | - $modSettings['defaultMaxMembers'] = 30; |
|
62 | - if (empty($modSettings['defaultMaxListItems']) || $modSettings['defaultMaxListItems'] <= 0 || $modSettings['defaultMaxListItems'] > 999) |
|
63 | - $modSettings['defaultMaxListItems'] = 15; |
|
60 | + if (empty($modSettings['defaultMaxTopics']) || $modSettings['defaultMaxTopics'] <= 0 || $modSettings['defaultMaxTopics'] > 999) { |
|
61 | + $modSettings['defaultMaxTopics'] = 20; |
|
62 | + } |
|
63 | + if (empty($modSettings['defaultMaxMessages']) || $modSettings['defaultMaxMessages'] <= 0 || $modSettings['defaultMaxMessages'] > 999) { |
|
64 | + $modSettings['defaultMaxMessages'] = 15; |
|
65 | + } |
|
66 | + if (empty($modSettings['defaultMaxMembers']) || $modSettings['defaultMaxMembers'] <= 0 || $modSettings['defaultMaxMembers'] > 999) { |
|
67 | + $modSettings['defaultMaxMembers'] = 30; |
|
68 | + } |
|
69 | + if (empty($modSettings['defaultMaxListItems']) || $modSettings['defaultMaxListItems'] <= 0 || $modSettings['defaultMaxListItems'] > 999) { |
|
70 | + $modSettings['defaultMaxListItems'] = 15; |
|
71 | + } |
|
64 | 72 | |
65 | 73 | // We excpiclity do not use $smcFunc['json_decode'] here yet, as $smcFunc is not fully loaded. |
66 | - if (!is_array($modSettings['attachmentUploadDir'])) |
|
67 | - $modSettings['attachmentUploadDir'] = smf_json_decode($modSettings['attachmentUploadDir'], true); |
|
74 | + if (!is_array($modSettings['attachmentUploadDir'])) { |
|
75 | + $modSettings['attachmentUploadDir'] = smf_json_decode($modSettings['attachmentUploadDir'], true); |
|
76 | + } |
|
68 | 77 | |
69 | - if (!empty($cache_enable)) |
|
70 | - cache_put_data('modSettings', $modSettings, 90); |
|
78 | + if (!empty($cache_enable)) { |
|
79 | + cache_put_data('modSettings', $modSettings, 90); |
|
80 | + } |
|
71 | 81 | } |
72 | 82 | |
73 | 83 | $modSettings['cache_enable'] = $cache_enable; |
@@ -87,8 +97,9 @@ discard block |
||
87 | 97 | }; |
88 | 98 | $fix_utf8mb4 = function($string) use ($utf8, $smcFunc) |
89 | 99 | { |
90 | - if (!$utf8 || $smcFunc['db_mb4']) |
|
91 | - return $string; |
|
100 | + if (!$utf8 || $smcFunc['db_mb4']) { |
|
101 | + return $string; |
|
102 | + } |
|
92 | 103 | |
93 | 104 | $i = 0; |
94 | 105 | $len = strlen($string); |
@@ -100,18 +111,15 @@ discard block |
||
100 | 111 | { |
101 | 112 | $new_string .= $string[$i]; |
102 | 113 | $i++; |
103 | - } |
|
104 | - elseif ($ord < 224) |
|
114 | + } elseif ($ord < 224) |
|
105 | 115 | { |
106 | 116 | $new_string .= $string[$i] . $string[$i + 1]; |
107 | 117 | $i += 2; |
108 | - } |
|
109 | - elseif ($ord < 240) |
|
118 | + } elseif ($ord < 240) |
|
110 | 119 | { |
111 | 120 | $new_string .= $string[$i] . $string[$i + 1] . $string[$i + 2]; |
112 | 121 | $i += 3; |
113 | - } |
|
114 | - elseif ($ord < 248) |
|
122 | + } elseif ($ord < 248) |
|
115 | 123 | { |
116 | 124 | // Magic happens. |
117 | 125 | $val = (ord($string[$i]) & 0x07) << 18; |
@@ -155,8 +163,7 @@ discard block |
||
155 | 163 | { |
156 | 164 | $result = array_search($needle, array_slice($haystack_arr, $offset)); |
157 | 165 | return is_int($result) ? $result + $offset : false; |
158 | - } |
|
159 | - else |
|
166 | + } else |
|
160 | 167 | { |
161 | 168 | $needle_arr = preg_split('~(&#' . (empty($modSettings['disableEntityCheck']) ? '\d{1,7}' : '021') . ';|"|&|<|>| |.)~' . ($utf8 ? 'u' : '') . '', $ent_check($needle), -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); |
162 | 169 | $needle_size = count($needle_arr); |
@@ -165,8 +172,9 @@ discard block |
||
165 | 172 | while ((int) $result === $result) |
166 | 173 | { |
167 | 174 | $offset += $result; |
168 | - if (array_slice($haystack_arr, $offset, $needle_size) === $needle_arr) |
|
169 | - return $offset; |
|
175 | + if (array_slice($haystack_arr, $offset, $needle_size) === $needle_arr) { |
|
176 | + return $offset; |
|
177 | + } |
|
170 | 178 | $result = array_search($needle_arr[0], array_slice($haystack_arr, ++$offset)); |
171 | 179 | } |
172 | 180 | return false; |
@@ -204,8 +212,9 @@ discard block |
||
204 | 212 | $string = $ent_check($string); |
205 | 213 | preg_match('~^(' . $ent_list . '|.){' . $smcFunc['strlen'](substr($string, 0, $length)) . '}~' . ($utf8 ? 'u' : ''), $string, $matches); |
206 | 214 | $string = $matches[0]; |
207 | - while (strlen($string) > $length) |
|
208 | - $string = preg_replace('~(?:' . $ent_list . '|.)$~' . ($utf8 ? 'u' : ''), '', $string); |
|
215 | + while (strlen($string) > $length) { |
|
216 | + $string = preg_replace('~(?:' . $ent_list . '|.)$~' . ($utf8 ? 'u' : ''), '', $string); |
|
217 | + } |
|
209 | 218 | return $string; |
210 | 219 | }, |
211 | 220 | 'ucfirst' => $utf8 ? function($string) use (&$smcFunc) |
@@ -215,8 +224,9 @@ discard block |
||
215 | 224 | 'ucwords' => $utf8 ? function($string) use (&$smcFunc) |
216 | 225 | { |
217 | 226 | $words = preg_split('~([\s\r\n\t]+)~', $string, -1, PREG_SPLIT_DELIM_CAPTURE); |
218 | - for ($i = 0, $n = count($words); $i < $n; $i += 2) |
|
219 | - $words[$i] = $smcFunc['ucfirst']($words[$i]); |
|
227 | + for ($i = 0, $n = count($words); $i < $n; $i += 2) { |
|
228 | + $words[$i] = $smcFunc['ucfirst']($words[$i]); |
|
229 | + } |
|
220 | 230 | return implode('', $words); |
221 | 231 | } : 'ucwords', |
222 | 232 | 'json_decode' => 'smf_json_decode', |
@@ -224,16 +234,17 @@ discard block |
||
224 | 234 | ); |
225 | 235 | |
226 | 236 | // Setting the timezone is a requirement for some functions. |
227 | - if (isset($modSettings['default_timezone']) && in_array($modSettings['default_timezone'], timezone_identifiers_list())) |
|
228 | - date_default_timezone_set($modSettings['default_timezone']); |
|
229 | - else |
|
237 | + if (isset($modSettings['default_timezone']) && in_array($modSettings['default_timezone'], timezone_identifiers_list())) { |
|
238 | + date_default_timezone_set($modSettings['default_timezone']); |
|
239 | + } else |
|
230 | 240 | { |
231 | 241 | // Get PHP's default timezone, if set |
232 | 242 | $ini_tz = ini_get('date.timezone'); |
233 | - if (!empty($ini_tz)) |
|
234 | - $modSettings['default_timezone'] = $ini_tz; |
|
235 | - else |
|
236 | - $modSettings['default_timezone'] = ''; |
|
243 | + if (!empty($ini_tz)) { |
|
244 | + $modSettings['default_timezone'] = $ini_tz; |
|
245 | + } else { |
|
246 | + $modSettings['default_timezone'] = ''; |
|
247 | + } |
|
237 | 248 | |
238 | 249 | // If date.timezone is unset, invalid, or just plain weird, make a best guess |
239 | 250 | if (!in_array($modSettings['default_timezone'], timezone_identifiers_list())) |
@@ -251,22 +262,26 @@ discard block |
||
251 | 262 | if (($modSettings['load_average'] = cache_get_data('loadavg', 90)) == null) |
252 | 263 | { |
253 | 264 | $modSettings['load_average'] = @file_get_contents('/proc/loadavg'); |
254 | - if (!empty($modSettings['load_average']) && preg_match('~^([^ ]+?) ([^ ]+?) ([^ ]+)~', $modSettings['load_average'], $matches) != 0) |
|
255 | - $modSettings['load_average'] = (float) $matches[1]; |
|
256 | - elseif (($modSettings['load_average'] = @`uptime`) != null && preg_match('~load average[s]?: (\d+\.\d+), (\d+\.\d+), (\d+\.\d+)~i', $modSettings['load_average'], $matches) != 0) |
|
257 | - $modSettings['load_average'] = (float) $matches[1]; |
|
258 | - else |
|
259 | - unset($modSettings['load_average']); |
|
265 | + if (!empty($modSettings['load_average']) && preg_match('~^([^ ]+?) ([^ ]+?) ([^ ]+)~', $modSettings['load_average'], $matches) != 0) { |
|
266 | + $modSettings['load_average'] = (float) $matches[1]; |
|
267 | + } elseif (($modSettings['load_average'] = @`uptime`) != null && preg_match('~load average[s]?: (\d+\.\d+), (\d+\.\d+), (\d+\.\d+)~i', $modSettings['load_average'], $matches) != 0) { |
|
268 | + $modSettings['load_average'] = (float) $matches[1]; |
|
269 | + } else { |
|
270 | + unset($modSettings['load_average']); |
|
271 | + } |
|
260 | 272 | |
261 | - if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) |
|
262 | - cache_put_data('loadavg', $modSettings['load_average'], 90); |
|
273 | + if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) { |
|
274 | + cache_put_data('loadavg', $modSettings['load_average'], 90); |
|
275 | + } |
|
263 | 276 | } |
264 | 277 | |
265 | - if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) |
|
266 | - call_integration_hook('integrate_load_average', array($modSettings['load_average'])); |
|
278 | + if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) { |
|
279 | + call_integration_hook('integrate_load_average', array($modSettings['load_average'])); |
|
280 | + } |
|
267 | 281 | |
268 | - if (!empty($modSettings['loadavg_forum']) && !empty($modSettings['load_average']) && $modSettings['load_average'] >= $modSettings['loadavg_forum']) |
|
269 | - display_loadavg_error(); |
|
282 | + if (!empty($modSettings['loadavg_forum']) && !empty($modSettings['load_average']) && $modSettings['load_average'] >= $modSettings['loadavg_forum']) { |
|
283 | + display_loadavg_error(); |
|
284 | + } |
|
270 | 285 | } |
271 | 286 | |
272 | 287 | // Is post moderation alive and well? Everywhere else assumes this has been defined, so let's make sure it is. |
@@ -287,8 +302,9 @@ discard block |
||
287 | 302 | if (defined('SMF_INTEGRATION_SETTINGS')) |
288 | 303 | { |
289 | 304 | $integration_settings = $smcFunc['json_decode'](SMF_INTEGRATION_SETTINGS, true); |
290 | - foreach ($integration_settings as $hook => $function) |
|
291 | - add_integration_function($hook, $function, '', false); |
|
305 | + foreach ($integration_settings as $hook => $function) { |
|
306 | + add_integration_function($hook, $function, '', false); |
|
307 | + } |
|
292 | 308 | } |
293 | 309 | |
294 | 310 | // Any files to pre include? |
@@ -298,8 +314,9 @@ discard block |
||
298 | 314 | foreach ($pre_includes as $include) |
299 | 315 | { |
300 | 316 | $include = strtr(trim($include), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir)); |
301 | - if (file_exists($include)) |
|
302 | - require_once($include); |
|
317 | + if (file_exists($include)) { |
|
318 | + require_once($include); |
|
319 | + } |
|
303 | 320 | } |
304 | 321 | } |
305 | 322 | |
@@ -405,9 +422,9 @@ discard block |
||
405 | 422 | break; |
406 | 423 | } |
407 | 424 | } |
425 | + } else { |
|
426 | + $id_member = 0; |
|
408 | 427 | } |
409 | - else |
|
410 | - $id_member = 0; |
|
411 | 428 | |
412 | 429 | if (empty($id_member) && isset($_COOKIE[$cookiename])) |
413 | 430 | { |
@@ -415,12 +432,14 @@ discard block |
||
415 | 432 | $cookie_data = $smcFunc['json_decode']($_COOKIE[$cookiename], true, false); |
416 | 433 | |
417 | 434 | // Legacy format (for recent 2.0 --> 2.1 upgrades) |
418 | - if (empty($cookie_data)) |
|
419 | - $cookie_data = safe_unserialize($_COOKIE[$cookiename]); |
|
435 | + if (empty($cookie_data)) { |
|
436 | + $cookie_data = safe_unserialize($_COOKIE[$cookiename]); |
|
437 | + } |
|
420 | 438 | |
421 | 439 | // Malformed or was reset |
422 | - if (empty($cookie_data)) |
|
423 | - $cookie_data = array(0, '', 0, '', ''); |
|
440 | + if (empty($cookie_data)) { |
|
441 | + $cookie_data = array(0, '', 0, '', ''); |
|
442 | + } |
|
424 | 443 | |
425 | 444 | list ($id_member, $password, $login_span, $cookie_domain, $cookie_path) = $cookie_data; |
426 | 445 | |
@@ -428,19 +447,21 @@ discard block |
||
428 | 447 | |
429 | 448 | // Make sure the cookie is set to the correct domain and path |
430 | 449 | require_once($sourcedir . '/Subs-Auth.php'); |
431 | - if (array($cookie_domain, $cookie_path) != url_parts(!empty($modSettings['localCookies']), !empty($modSettings['globalCookies']))) |
|
432 | - setLoginCookie($login_span - time(), $id_member); |
|
433 | - } |
|
434 | - elseif (empty($id_member) && isset($_SESSION['login_' . $cookiename]) && ($_SESSION['USER_AGENT'] == $_SERVER['HTTP_USER_AGENT'] || !empty($modSettings['disableCheckUA']))) |
|
450 | + if (array($cookie_domain, $cookie_path) != url_parts(!empty($modSettings['localCookies']), !empty($modSettings['globalCookies']))) { |
|
451 | + setLoginCookie($login_span - time(), $id_member); |
|
452 | + } |
|
453 | + } elseif (empty($id_member) && isset($_SESSION['login_' . $cookiename]) && ($_SESSION['USER_AGENT'] == $_SERVER['HTTP_USER_AGENT'] || !empty($modSettings['disableCheckUA']))) |
|
435 | 454 | { |
436 | 455 | // @todo Perhaps we can do some more checking on this, such as on the first octet of the IP? |
437 | 456 | $cookie_data = $smcFunc['json_decode']($_SESSION['login_' . $cookiename], true); |
438 | 457 | |
439 | - if (empty($cookie_data)) |
|
440 | - $cookie_data = safe_unserialize($_SESSION['login_' . $cookiename]); |
|
458 | + if (empty($cookie_data)) { |
|
459 | + $cookie_data = safe_unserialize($_SESSION['login_' . $cookiename]); |
|
460 | + } |
|
441 | 461 | |
442 | - if (empty($cookie_data)) |
|
443 | - $cookie_data = array(0, '', 0); |
|
462 | + if (empty($cookie_data)) { |
|
463 | + $cookie_data = array(0, '', 0); |
|
464 | + } |
|
444 | 465 | |
445 | 466 | list ($id_member, $password, $login_span) = $cookie_data; |
446 | 467 | $id_member = !empty($id_member) && strlen($password) == 128 && $login_span > time() ? (int) $id_member : 0; |
@@ -465,30 +486,34 @@ discard block |
||
465 | 486 | $user_settings = $smcFunc['db_fetch_assoc']($request); |
466 | 487 | $smcFunc['db_free_result']($request); |
467 | 488 | |
468 | - if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($user_settings['avatar'], 'http://') !== false && empty($user_info['possibly_robot'])) |
|
469 | - $user_settings['avatar'] = strtr($boardurl, array('http://' => 'https://')) . '/proxy.php?request=' . urlencode($user_settings['avatar']) . '&hash=' . md5($user_settings['avatar'] . $image_proxy_secret); |
|
489 | + if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($user_settings['avatar'], 'http://') !== false && empty($user_info['possibly_robot'])) { |
|
490 | + $user_settings['avatar'] = strtr($boardurl, array('http://' => 'https://')) . '/proxy.php?request=' . urlencode($user_settings['avatar']) . '&hash=' . md5($user_settings['avatar'] . $image_proxy_secret); |
|
491 | + } |
|
470 | 492 | |
471 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
472 | - cache_put_data('user_settings-' . $id_member, $user_settings, 60); |
|
493 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
494 | + cache_put_data('user_settings-' . $id_member, $user_settings, 60); |
|
495 | + } |
|
473 | 496 | } |
474 | 497 | |
475 | 498 | // Did we find 'im? If not, junk it. |
476 | 499 | if (!empty($user_settings)) |
477 | 500 | { |
478 | 501 | // As much as the password should be right, we can assume the integration set things up. |
479 | - if (!empty($already_verified) && $already_verified === true) |
|
480 | - $check = true; |
|
502 | + if (!empty($already_verified) && $already_verified === true) { |
|
503 | + $check = true; |
|
504 | + } |
|
481 | 505 | // SHA-512 hash should be 128 characters long. |
482 | - elseif (strlen($password) == 128) |
|
483 | - $check = hash_salt($user_settings['passwd'], $user_settings['password_salt']) == $password; |
|
484 | - else |
|
485 | - $check = false; |
|
506 | + elseif (strlen($password) == 128) { |
|
507 | + $check = hash_salt($user_settings['passwd'], $user_settings['password_salt']) == $password; |
|
508 | + } else { |
|
509 | + $check = false; |
|
510 | + } |
|
486 | 511 | |
487 | 512 | // Wrong password or not activated - either way, you're going nowhere. |
488 | 513 | $id_member = $check && ($user_settings['is_activated'] == 1 || $user_settings['is_activated'] == 11) ? (int) $user_settings['id_member'] : 0; |
514 | + } else { |
|
515 | + $id_member = 0; |
|
489 | 516 | } |
490 | - else |
|
491 | - $id_member = 0; |
|
492 | 517 | |
493 | 518 | // If we no longer have the member maybe they're being all hackey, stop brute force! |
494 | 519 | if (!$id_member) |
@@ -517,8 +542,9 @@ discard block |
||
517 | 542 | |
518 | 543 | list ($tfamember, $tfasecret) = $tfa_data; |
519 | 544 | |
520 | - if (!isset($tfamember, $tfasecret) || (int) $tfamember != $id_member) |
|
521 | - $tfasecret = null; |
|
545 | + if (!isset($tfamember, $tfasecret) || (int) $tfamember != $id_member) { |
|
546 | + $tfasecret = null; |
|
547 | + } |
|
522 | 548 | } |
523 | 549 | |
524 | 550 | if (empty($tfasecret) || hash_salt($user_settings['tfa_backup'], $user_settings['password_salt']) != $tfasecret) |
@@ -538,10 +564,12 @@ discard block |
||
538 | 564 | // Are we forcing 2FA? Need to check if the user groups actually require 2FA |
539 | 565 | elseif (!empty($modSettings['tfa_mode']) && $modSettings['tfa_mode'] >= 2 && $id_member && empty($user_settings['tfa_secret'])) |
540 | 566 | { |
541 | - if ($modSettings['tfa_mode'] == 2) //only do this if we are just forcing SOME membergroups |
|
567 | + if ($modSettings['tfa_mode'] == 2) { |
|
568 | + //only do this if we are just forcing SOME membergroups |
|
542 | 569 | { |
543 | 570 | //Build an array of ALL user membergroups. |
544 | 571 | $full_groups = array($user_settings['id_group']); |
572 | + } |
|
545 | 573 | if (!empty($user_settings['additional_groups'])) |
546 | 574 | { |
547 | 575 | $full_groups = array_merge($full_groups, explode(',', $user_settings['additional_groups'])); |
@@ -561,15 +589,17 @@ discard block |
||
561 | 589 | ); |
562 | 590 | $row = $smcFunc['db_fetch_assoc']($request); |
563 | 591 | $smcFunc['db_free_result']($request); |
592 | + } else { |
|
593 | + $row['total'] = 1; |
|
564 | 594 | } |
565 | - else |
|
566 | - $row['total'] = 1; //simplifies logics in the next "if" |
|
595 | + //simplifies logics in the next "if" |
|
567 | 596 | |
568 | 597 | $area = !empty($_REQUEST['area']) ? $_REQUEST['area'] : ''; |
569 | 598 | $action = !empty($_REQUEST['action']) ? $_REQUEST['action'] : ''; |
570 | 599 | |
571 | - if ($row['total'] > 0 && !in_array($action, array('profile', 'logout')) || ($action == 'profile' && $area != 'tfasetup')) |
|
572 | - redirectexit('action=profile;area=tfasetup;forced'); |
|
600 | + if ($row['total'] > 0 && !in_array($action, array('profile', 'logout')) || ($action == 'profile' && $area != 'tfasetup')) { |
|
601 | + redirectexit('action=profile;area=tfasetup;forced'); |
|
602 | + } |
|
573 | 603 | } |
574 | 604 | } |
575 | 605 | |
@@ -606,33 +636,37 @@ discard block |
||
606 | 636 | updateMemberData($id_member, array('id_msg_last_visit' => (int) $modSettings['maxMsgID'], 'last_login' => time(), 'member_ip' => $_SERVER['REMOTE_ADDR'], 'member_ip2' => $_SERVER['BAN_CHECK_IP'])); |
607 | 637 | $user_settings['last_login'] = time(); |
608 | 638 | |
609 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
610 | - cache_put_data('user_settings-' . $id_member, $user_settings, 60); |
|
639 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
640 | + cache_put_data('user_settings-' . $id_member, $user_settings, 60); |
|
641 | + } |
|
611 | 642 | |
612 | - if (!empty($modSettings['cache_enable'])) |
|
613 | - cache_put_data('user_last_visit-' . $id_member, $_SESSION['id_msg_last_visit'], 5 * 3600); |
|
643 | + if (!empty($modSettings['cache_enable'])) { |
|
644 | + cache_put_data('user_last_visit-' . $id_member, $_SESSION['id_msg_last_visit'], 5 * 3600); |
|
645 | + } |
|
614 | 646 | } |
647 | + } elseif (empty($_SESSION['id_msg_last_visit'])) { |
|
648 | + $_SESSION['id_msg_last_visit'] = $user_settings['id_msg_last_visit']; |
|
615 | 649 | } |
616 | - elseif (empty($_SESSION['id_msg_last_visit'])) |
|
617 | - $_SESSION['id_msg_last_visit'] = $user_settings['id_msg_last_visit']; |
|
618 | 650 | |
619 | 651 | $username = $user_settings['member_name']; |
620 | 652 | |
621 | - if (empty($user_settings['additional_groups'])) |
|
622 | - $user_info = array( |
|
653 | + if (empty($user_settings['additional_groups'])) { |
|
654 | + $user_info = array( |
|
623 | 655 | 'groups' => array($user_settings['id_group'], $user_settings['id_post_group']) |
624 | 656 | ); |
625 | - else |
|
626 | - $user_info = array( |
|
657 | + } else { |
|
658 | + $user_info = array( |
|
627 | 659 | 'groups' => array_merge( |
628 | 660 | array($user_settings['id_group'], $user_settings['id_post_group']), |
629 | 661 | explode(',', $user_settings['additional_groups']) |
630 | 662 | ) |
631 | 663 | ); |
664 | + } |
|
632 | 665 | |
633 | 666 | // Because history has proven that it is possible for groups to go bad - clean up in case. |
634 | - foreach ($user_info['groups'] as $k => $v) |
|
635 | - $user_info['groups'][$k] = (int) $v; |
|
667 | + foreach ($user_info['groups'] as $k => $v) { |
|
668 | + $user_info['groups'][$k] = (int) $v; |
|
669 | + } |
|
636 | 670 | |
637 | 671 | // This is a logged in user, so definitely not a spider. |
638 | 672 | $user_info['possibly_robot'] = false; |
@@ -646,8 +680,7 @@ discard block |
||
646 | 680 | $time_system = new DateTime('now', $tz_system); |
647 | 681 | $time_user = new DateTime('now', $tz_user); |
648 | 682 | $user_info['time_offset'] = ($tz_user->getOffset($time_user) - $tz_system->getOffset($time_system)) / 3600; |
649 | - } |
|
650 | - else |
|
683 | + } else |
|
651 | 684 | { |
652 | 685 | // !!! Compatibility. |
653 | 686 | $user_info['time_offset'] = empty($user_settings['time_offset']) ? 0 : $user_settings['time_offset']; |
@@ -661,8 +694,9 @@ discard block |
||
661 | 694 | $user_info = array('groups' => array(-1)); |
662 | 695 | $user_settings = array(); |
663 | 696 | |
664 | - if (isset($_COOKIE[$cookiename]) && empty($context['tfa_member'])) |
|
665 | - $_COOKIE[$cookiename] = ''; |
|
697 | + if (isset($_COOKIE[$cookiename]) && empty($context['tfa_member'])) { |
|
698 | + $_COOKIE[$cookiename] = ''; |
|
699 | + } |
|
666 | 700 | |
667 | 701 | // Expire the 2FA cookie |
668 | 702 | if (isset($_COOKIE[$cookiename . '_tfa']) && empty($context['tfa_member'])) |
@@ -679,19 +713,20 @@ discard block |
||
679 | 713 | } |
680 | 714 | |
681 | 715 | // Create a login token if it doesn't exist yet. |
682 | - if (!isset($_SESSION['token']['post-login'])) |
|
683 | - createToken('login'); |
|
684 | - else |
|
685 | - list ($context['login_token_var'],,, $context['login_token']) = $_SESSION['token']['post-login']; |
|
716 | + if (!isset($_SESSION['token']['post-login'])) { |
|
717 | + createToken('login'); |
|
718 | + } else { |
|
719 | + list ($context['login_token_var'],,, $context['login_token']) = $_SESSION['token']['post-login']; |
|
720 | + } |
|
686 | 721 | |
687 | 722 | // Do we perhaps think this is a search robot? Check every five minutes just in case... |
688 | 723 | if ((!empty($modSettings['spider_mode']) || !empty($modSettings['spider_group'])) && (!isset($_SESSION['robot_check']) || $_SESSION['robot_check'] < time() - 300)) |
689 | 724 | { |
690 | 725 | require_once($sourcedir . '/ManageSearchEngines.php'); |
691 | 726 | $user_info['possibly_robot'] = SpiderCheck(); |
727 | + } elseif (!empty($modSettings['spider_mode'])) { |
|
728 | + $user_info['possibly_robot'] = isset($_SESSION['id_robot']) ? $_SESSION['id_robot'] : 0; |
|
692 | 729 | } |
693 | - elseif (!empty($modSettings['spider_mode'])) |
|
694 | - $user_info['possibly_robot'] = isset($_SESSION['id_robot']) ? $_SESSION['id_robot'] : 0; |
|
695 | 730 | // If we haven't turned on proper spider hunts then have a guess! |
696 | 731 | else |
697 | 732 | { |
@@ -739,8 +774,9 @@ discard block |
||
739 | 774 | $user_info['groups'] = array_unique($user_info['groups']); |
740 | 775 | |
741 | 776 | // Make sure that the last item in the ignore boards array is valid. If the list was too long it could have an ending comma that could cause problems. |
742 | - if (!empty($user_info['ignoreboards']) && empty($user_info['ignoreboards'][$tmp = count($user_info['ignoreboards']) - 1])) |
|
743 | - unset($user_info['ignoreboards'][$tmp]); |
|
777 | + if (!empty($user_info['ignoreboards']) && empty($user_info['ignoreboards'][$tmp = count($user_info['ignoreboards']) - 1])) { |
|
778 | + unset($user_info['ignoreboards'][$tmp]); |
|
779 | + } |
|
744 | 780 | |
745 | 781 | // Allow the user to change their language. |
746 | 782 | if (!empty($modSettings['userLanguage'])) |
@@ -753,13 +789,14 @@ discard block |
||
753 | 789 | $user_info['language'] = strtr($_GET['language'], './\\:', '____'); |
754 | 790 | |
755 | 791 | // Make it permanent for members. |
756 | - if (!empty($user_info['id'])) |
|
757 | - updateMemberData($user_info['id'], array('lngfile' => $user_info['language'])); |
|
758 | - else |
|
759 | - $_SESSION['language'] = $user_info['language']; |
|
792 | + if (!empty($user_info['id'])) { |
|
793 | + updateMemberData($user_info['id'], array('lngfile' => $user_info['language'])); |
|
794 | + } else { |
|
795 | + $_SESSION['language'] = $user_info['language']; |
|
796 | + } |
|
797 | + } elseif (!empty($_SESSION['language']) && isset($languages[strtr($_SESSION['language'], './\\:', '____')])) { |
|
798 | + $user_info['language'] = strtr($_SESSION['language'], './\\:', '____'); |
|
760 | 799 | } |
761 | - elseif (!empty($_SESSION['language']) && isset($languages[strtr($_SESSION['language'], './\\:', '____')])) |
|
762 | - $user_info['language'] = strtr($_SESSION['language'], './\\:', '____'); |
|
763 | 800 | } |
764 | 801 | |
765 | 802 | $temp = build_query_board($user_info['id']); |
@@ -822,9 +859,9 @@ discard block |
||
822 | 859 | } |
823 | 860 | |
824 | 861 | // Remember redirection is the key to avoiding fallout from your bosses. |
825 | - if (!empty($topic)) |
|
826 | - redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg']); |
|
827 | - else |
|
862 | + if (!empty($topic)) { |
|
863 | + redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg']); |
|
864 | + } else |
|
828 | 865 | { |
829 | 866 | loadPermissions(); |
830 | 867 | loadTheme(); |
@@ -842,10 +879,11 @@ discard block |
||
842 | 879 | if (!empty($modSettings['cache_enable']) && (empty($topic) || $modSettings['cache_enable'] >= 3)) |
843 | 880 | { |
844 | 881 | // @todo SLOW? |
845 | - if (!empty($topic)) |
|
846 | - $temp = cache_get_data('topic_board-' . $topic, 120); |
|
847 | - else |
|
848 | - $temp = cache_get_data('board-' . $board, 120); |
|
882 | + if (!empty($topic)) { |
|
883 | + $temp = cache_get_data('topic_board-' . $topic, 120); |
|
884 | + } else { |
|
885 | + $temp = cache_get_data('board-' . $board, 120); |
|
886 | + } |
|
849 | 887 | |
850 | 888 | if (!empty($temp)) |
851 | 889 | { |
@@ -883,8 +921,9 @@ discard block |
||
883 | 921 | $row = $smcFunc['db_fetch_assoc']($request); |
884 | 922 | |
885 | 923 | // Set the current board. |
886 | - if (!empty($row['id_board'])) |
|
887 | - $board = $row['id_board']; |
|
924 | + if (!empty($row['id_board'])) { |
|
925 | + $board = $row['id_board']; |
|
926 | + } |
|
888 | 927 | |
889 | 928 | // Basic operating information. (globals... :/) |
890 | 929 | $board_info = array( |
@@ -920,21 +959,23 @@ discard block |
||
920 | 959 | |
921 | 960 | do |
922 | 961 | { |
923 | - if (!empty($row['id_moderator'])) |
|
924 | - $board_info['moderators'][$row['id_moderator']] = array( |
|
962 | + if (!empty($row['id_moderator'])) { |
|
963 | + $board_info['moderators'][$row['id_moderator']] = array( |
|
925 | 964 | 'id' => $row['id_moderator'], |
926 | 965 | 'name' => $row['real_name'], |
927 | 966 | 'href' => $scripturl . '?action=profile;u=' . $row['id_moderator'], |
928 | 967 | 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_moderator'] . '">' . $row['real_name'] . '</a>' |
929 | 968 | ); |
969 | + } |
|
930 | 970 | |
931 | - if (!empty($row['id_moderator_group'])) |
|
932 | - $board_info['moderator_groups'][$row['id_moderator_group']] = array( |
|
971 | + if (!empty($row['id_moderator_group'])) { |
|
972 | + $board_info['moderator_groups'][$row['id_moderator_group']] = array( |
|
933 | 973 | 'id' => $row['id_moderator_group'], |
934 | 974 | 'name' => $row['group_name'], |
935 | 975 | 'href' => $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'], |
936 | 976 | 'link' => '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'] . '">' . $row['group_name'] . '</a>' |
937 | 977 | ); |
978 | + } |
|
938 | 979 | } |
939 | 980 | while ($row = $smcFunc['db_fetch_assoc']($request)); |
940 | 981 | |
@@ -966,12 +1007,12 @@ discard block |
||
966 | 1007 | if (!empty($modSettings['cache_enable']) && (empty($topic) || $modSettings['cache_enable'] >= 3)) |
967 | 1008 | { |
968 | 1009 | // @todo SLOW? |
969 | - if (!empty($topic)) |
|
970 | - cache_put_data('topic_board-' . $topic, $board_info, 120); |
|
1010 | + if (!empty($topic)) { |
|
1011 | + cache_put_data('topic_board-' . $topic, $board_info, 120); |
|
1012 | + } |
|
971 | 1013 | cache_put_data('board-' . $board, $board_info, 120); |
972 | 1014 | } |
973 | - } |
|
974 | - else |
|
1015 | + } else |
|
975 | 1016 | { |
976 | 1017 | // Otherwise the topic is invalid, there are no moderators, etc. |
977 | 1018 | $board_info = array( |
@@ -985,8 +1026,9 @@ discard block |
||
985 | 1026 | $smcFunc['db_free_result']($request); |
986 | 1027 | } |
987 | 1028 | |
988 | - if (!empty($topic)) |
|
989 | - $_GET['board'] = (int) $board; |
|
1029 | + if (!empty($topic)) { |
|
1030 | + $_GET['board'] = (int) $board; |
|
1031 | + } |
|
990 | 1032 | |
991 | 1033 | if (!empty($board)) |
992 | 1034 | { |
@@ -996,10 +1038,12 @@ discard block |
||
996 | 1038 | // Now check if the user is a moderator. |
997 | 1039 | $user_info['is_mod'] = isset($board_info['moderators'][$user_info['id']]) || count(array_intersect($user_info['groups'], $moderator_groups)) != 0; |
998 | 1040 | |
999 | - if (count(array_intersect($user_info['groups'], $board_info['groups'])) == 0 && !$user_info['is_admin']) |
|
1000 | - $board_info['error'] = 'access'; |
|
1001 | - if (!empty($modSettings['deny_boards_access']) && count(array_intersect($user_info['groups'], $board_info['deny_groups'])) != 0 && !$user_info['is_admin']) |
|
1002 | - $board_info['error'] = 'access'; |
|
1041 | + if (count(array_intersect($user_info['groups'], $board_info['groups'])) == 0 && !$user_info['is_admin']) { |
|
1042 | + $board_info['error'] = 'access'; |
|
1043 | + } |
|
1044 | + if (!empty($modSettings['deny_boards_access']) && count(array_intersect($user_info['groups'], $board_info['deny_groups'])) != 0 && !$user_info['is_admin']) { |
|
1045 | + $board_info['error'] = 'access'; |
|
1046 | + } |
|
1003 | 1047 | |
1004 | 1048 | // Build up the linktree. |
1005 | 1049 | $context['linktree'] = array_merge( |
@@ -1022,8 +1066,9 @@ discard block |
||
1022 | 1066 | $context['current_board'] = $board; |
1023 | 1067 | |
1024 | 1068 | // No posting in redirection boards! |
1025 | - if (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'post' && !empty($board_info['redirect'])) |
|
1026 | - $board_info['error'] == 'post_in_redirect'; |
|
1069 | + if (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'post' && !empty($board_info['redirect'])) { |
|
1070 | + $board_info['error'] == 'post_in_redirect'; |
|
1071 | + } |
|
1027 | 1072 | |
1028 | 1073 | // Hacker... you can't see this topic, I'll tell you that. (but moderators can!) |
1029 | 1074 | if (!empty($board_info['error']) && (!empty($modSettings['deny_boards_access']) || $board_info['error'] != 'access' || !$user_info['is_mod'])) |
@@ -1049,24 +1094,23 @@ discard block |
||
1049 | 1094 | ob_end_clean(); |
1050 | 1095 | header('HTTP/1.1 403 Forbidden'); |
1051 | 1096 | die; |
1052 | - } |
|
1053 | - elseif ($board_info['error'] == 'post_in_redirect') |
|
1097 | + } elseif ($board_info['error'] == 'post_in_redirect') |
|
1054 | 1098 | { |
1055 | 1099 | // Slightly different error message here... |
1056 | 1100 | fatal_lang_error('cannot_post_redirect', false); |
1057 | - } |
|
1058 | - elseif ($user_info['is_guest']) |
|
1101 | + } elseif ($user_info['is_guest']) |
|
1059 | 1102 | { |
1060 | 1103 | loadLanguage('Errors'); |
1061 | 1104 | is_not_guest($txt['topic_gone']); |
1105 | + } else { |
|
1106 | + fatal_lang_error('topic_gone', false); |
|
1062 | 1107 | } |
1063 | - else |
|
1064 | - fatal_lang_error('topic_gone', false); |
|
1065 | 1108 | } |
1066 | 1109 | |
1067 | - if ($user_info['is_mod']) |
|
1068 | - $user_info['groups'][] = 3; |
|
1069 | -} |
|
1110 | + if ($user_info['is_mod']) { |
|
1111 | + $user_info['groups'][] = 3; |
|
1112 | + } |
|
1113 | + } |
|
1070 | 1114 | |
1071 | 1115 | /** |
1072 | 1116 | * Load this user's permissions. |
@@ -1087,8 +1131,9 @@ discard block |
||
1087 | 1131 | asort($cache_groups); |
1088 | 1132 | $cache_groups = implode(',', $cache_groups); |
1089 | 1133 | // If it's a spider then cache it different. |
1090 | - if ($user_info['possibly_robot']) |
|
1091 | - $cache_groups .= '-spider'; |
|
1134 | + if ($user_info['possibly_robot']) { |
|
1135 | + $cache_groups .= '-spider'; |
|
1136 | + } |
|
1092 | 1137 | |
1093 | 1138 | if ($modSettings['cache_enable'] >= 2 && !empty($board) && ($temp = cache_get_data('permissions:' . $cache_groups . ':' . $board, 240)) != null && time() - 240 > $modSettings['settings_updated']) |
1094 | 1139 | { |
@@ -1096,9 +1141,9 @@ discard block |
||
1096 | 1141 | banPermissions(); |
1097 | 1142 | |
1098 | 1143 | return; |
1144 | + } elseif (($temp = cache_get_data('permissions:' . $cache_groups, 240)) != null && time() - 240 > $modSettings['settings_updated']) { |
|
1145 | + list ($user_info['permissions'], $removals) = $temp; |
|
1099 | 1146 | } |
1100 | - elseif (($temp = cache_get_data('permissions:' . $cache_groups, 240)) != null && time() - 240 > $modSettings['settings_updated']) |
|
1101 | - list ($user_info['permissions'], $removals) = $temp; |
|
1102 | 1147 | } |
1103 | 1148 | |
1104 | 1149 | // If it is detected as a robot, and we are restricting permissions as a special group - then implement this. |
@@ -1120,23 +1165,26 @@ discard block |
||
1120 | 1165 | $removals = array(); |
1121 | 1166 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1122 | 1167 | { |
1123 | - if (empty($row['add_deny'])) |
|
1124 | - $removals[] = $row['permission']; |
|
1125 | - else |
|
1126 | - $user_info['permissions'][] = $row['permission']; |
|
1168 | + if (empty($row['add_deny'])) { |
|
1169 | + $removals[] = $row['permission']; |
|
1170 | + } else { |
|
1171 | + $user_info['permissions'][] = $row['permission']; |
|
1172 | + } |
|
1127 | 1173 | } |
1128 | 1174 | $smcFunc['db_free_result']($request); |
1129 | 1175 | |
1130 | - if (isset($cache_groups)) |
|
1131 | - cache_put_data('permissions:' . $cache_groups, array($user_info['permissions'], $removals), 240); |
|
1176 | + if (isset($cache_groups)) { |
|
1177 | + cache_put_data('permissions:' . $cache_groups, array($user_info['permissions'], $removals), 240); |
|
1178 | + } |
|
1132 | 1179 | } |
1133 | 1180 | |
1134 | 1181 | // Get the board permissions. |
1135 | 1182 | if (!empty($board)) |
1136 | 1183 | { |
1137 | 1184 | // Make sure the board (if any) has been loaded by loadBoard(). |
1138 | - if (!isset($board_info['profile'])) |
|
1139 | - fatal_lang_error('no_board'); |
|
1185 | + if (!isset($board_info['profile'])) { |
|
1186 | + fatal_lang_error('no_board'); |
|
1187 | + } |
|
1140 | 1188 | |
1141 | 1189 | $request = $smcFunc['db_query']('', ' |
1142 | 1190 | SELECT permission, add_deny |
@@ -1152,20 +1200,23 @@ discard block |
||
1152 | 1200 | ); |
1153 | 1201 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1154 | 1202 | { |
1155 | - if (empty($row['add_deny'])) |
|
1156 | - $removals[] = $row['permission']; |
|
1157 | - else |
|
1158 | - $user_info['permissions'][] = $row['permission']; |
|
1203 | + if (empty($row['add_deny'])) { |
|
1204 | + $removals[] = $row['permission']; |
|
1205 | + } else { |
|
1206 | + $user_info['permissions'][] = $row['permission']; |
|
1207 | + } |
|
1159 | 1208 | } |
1160 | 1209 | $smcFunc['db_free_result']($request); |
1161 | 1210 | } |
1162 | 1211 | |
1163 | 1212 | // Remove all the permissions they shouldn't have ;). |
1164 | - if (!empty($modSettings['permission_enable_deny'])) |
|
1165 | - $user_info['permissions'] = array_diff($user_info['permissions'], $removals); |
|
1213 | + if (!empty($modSettings['permission_enable_deny'])) { |
|
1214 | + $user_info['permissions'] = array_diff($user_info['permissions'], $removals); |
|
1215 | + } |
|
1166 | 1216 | |
1167 | - if (isset($cache_groups) && !empty($board) && $modSettings['cache_enable'] >= 2) |
|
1168 | - cache_put_data('permissions:' . $cache_groups . ':' . $board, array($user_info['permissions'], null), 240); |
|
1217 | + if (isset($cache_groups) && !empty($board) && $modSettings['cache_enable'] >= 2) { |
|
1218 | + cache_put_data('permissions:' . $cache_groups . ':' . $board, array($user_info['permissions'], null), 240); |
|
1219 | + } |
|
1169 | 1220 | |
1170 | 1221 | // Banned? Watch, don't touch.. |
1171 | 1222 | banPermissions(); |
@@ -1177,17 +1228,18 @@ discard block |
||
1177 | 1228 | { |
1178 | 1229 | require_once($sourcedir . '/Subs-Auth.php'); |
1179 | 1230 | rebuildModCache(); |
1231 | + } else { |
|
1232 | + $user_info['mod_cache'] = $_SESSION['mc']; |
|
1180 | 1233 | } |
1181 | - else |
|
1182 | - $user_info['mod_cache'] = $_SESSION['mc']; |
|
1183 | 1234 | |
1184 | 1235 | // This is a useful phantom permission added to the current user, and only the current user while they are logged in. |
1185 | 1236 | // For example this drastically simplifies certain changes to the profile area. |
1186 | 1237 | $user_info['permissions'][] = 'is_not_guest'; |
1187 | 1238 | // And now some backwards compatibility stuff for mods and whatnot that aren't expecting the new permissions. |
1188 | 1239 | $user_info['permissions'][] = 'profile_view_own'; |
1189 | - if (in_array('profile_view', $user_info['permissions'])) |
|
1190 | - $user_info['permissions'][] = 'profile_view_any'; |
|
1240 | + if (in_array('profile_view', $user_info['permissions'])) { |
|
1241 | + $user_info['permissions'][] = 'profile_view_any'; |
|
1242 | + } |
|
1191 | 1243 | } |
1192 | 1244 | } |
1193 | 1245 | |
@@ -1205,8 +1257,9 @@ discard block |
||
1205 | 1257 | global $image_proxy_enabled, $image_proxy_secret, $boardurl, $user_info; |
1206 | 1258 | |
1207 | 1259 | // Can't just look for no users :P. |
1208 | - if (empty($users)) |
|
1209 | - return array(); |
|
1260 | + if (empty($users)) { |
|
1261 | + return array(); |
|
1262 | + } |
|
1210 | 1263 | |
1211 | 1264 | // Pass the set value |
1212 | 1265 | $context['loadMemberContext_set'] = $set; |
@@ -1221,8 +1274,9 @@ discard block |
||
1221 | 1274 | for ($i = 0, $n = count($users); $i < $n; $i++) |
1222 | 1275 | { |
1223 | 1276 | $data = cache_get_data('member_data-' . $set . '-' . $users[$i], 240); |
1224 | - if ($data == null) |
|
1225 | - continue; |
|
1277 | + if ($data == null) { |
|
1278 | + continue; |
|
1279 | + } |
|
1226 | 1280 | |
1227 | 1281 | $loaded_ids[] = $data['id_member']; |
1228 | 1282 | $user_profile[$data['id_member']] = $data; |
@@ -1289,16 +1343,19 @@ discard block |
||
1289 | 1343 | $row['avatar_original'] = !empty($row['avatar']) ? $row['avatar'] : ''; |
1290 | 1344 | |
1291 | 1345 | // Take care of proxying avatar if required, do this here for maximum reach |
1292 | - if ($image_proxy_enabled && !empty($row['avatar']) && stripos($row['avatar'], 'http://') !== false && empty($user_info['possibly_robot'])) |
|
1293 | - $row['avatar'] = $boardurl . '/proxy.php?request=' . urlencode($row['avatar']) . '&hash=' . md5($row['avatar'] . $image_proxy_secret); |
|
1346 | + if ($image_proxy_enabled && !empty($row['avatar']) && stripos($row['avatar'], 'http://') !== false && empty($user_info['possibly_robot'])) { |
|
1347 | + $row['avatar'] = $boardurl . '/proxy.php?request=' . urlencode($row['avatar']) . '&hash=' . md5($row['avatar'] . $image_proxy_secret); |
|
1348 | + } |
|
1294 | 1349 | |
1295 | 1350 | // Keep track of the member's normal member group |
1296 | 1351 | $row['primary_group'] = $row['member_group']; |
1297 | 1352 | |
1298 | - if (isset($row['member_ip'])) |
|
1299 | - $row['member_ip'] = inet_dtop($row['member_ip']); |
|
1300 | - if (isset($row['member_ip2'])) |
|
1301 | - $row['member_ip2'] = inet_dtop($row['member_ip2']); |
|
1353 | + if (isset($row['member_ip'])) { |
|
1354 | + $row['member_ip'] = inet_dtop($row['member_ip']); |
|
1355 | + } |
|
1356 | + if (isset($row['member_ip2'])) { |
|
1357 | + $row['member_ip2'] = inet_dtop($row['member_ip2']); |
|
1358 | + } |
|
1302 | 1359 | $new_loaded_ids[] = $row['id_member']; |
1303 | 1360 | $loaded_ids[] = $row['id_member']; |
1304 | 1361 | $row['options'] = array(); |
@@ -1317,8 +1374,9 @@ discard block |
||
1317 | 1374 | 'loaded_ids' => $new_loaded_ids, |
1318 | 1375 | ) |
1319 | 1376 | ); |
1320 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1321 | - $user_profile[$row['id_member']]['options'][$row['variable']] = $row['value']; |
|
1377 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1378 | + $user_profile[$row['id_member']]['options'][$row['variable']] = $row['value']; |
|
1379 | + } |
|
1322 | 1380 | $smcFunc['db_free_result']($request); |
1323 | 1381 | } |
1324 | 1382 | |
@@ -1329,10 +1387,11 @@ discard block |
||
1329 | 1387 | { |
1330 | 1388 | foreach ($loaded_ids as $a_member) |
1331 | 1389 | { |
1332 | - if (!empty($user_profile[$a_member]['additional_groups'])) |
|
1333 | - $groups = array_merge(array($user_profile[$a_member]['id_group']), explode(',', $user_profile[$a_member]['additional_groups'])); |
|
1334 | - else |
|
1335 | - $groups = array($user_profile[$a_member]['id_group']); |
|
1390 | + if (!empty($user_profile[$a_member]['additional_groups'])) { |
|
1391 | + $groups = array_merge(array($user_profile[$a_member]['id_group']), explode(',', $user_profile[$a_member]['additional_groups'])); |
|
1392 | + } else { |
|
1393 | + $groups = array($user_profile[$a_member]['id_group']); |
|
1394 | + } |
|
1336 | 1395 | |
1337 | 1396 | $temp = array_intersect($groups, array_keys($board_info['moderator_groups'])); |
1338 | 1397 | |
@@ -1345,8 +1404,9 @@ discard block |
||
1345 | 1404 | |
1346 | 1405 | if (!empty($new_loaded_ids) && !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 3) |
1347 | 1406 | { |
1348 | - for ($i = 0, $n = count($new_loaded_ids); $i < $n; $i++) |
|
1349 | - cache_put_data('member_data-' . $set . '-' . $new_loaded_ids[$i], $user_profile[$new_loaded_ids[$i]], 240); |
|
1407 | + for ($i = 0, $n = count($new_loaded_ids); $i < $n; $i++) { |
|
1408 | + cache_put_data('member_data-' . $set . '-' . $new_loaded_ids[$i], $user_profile[$new_loaded_ids[$i]], 240); |
|
1409 | + } |
|
1350 | 1410 | } |
1351 | 1411 | |
1352 | 1412 | // Are we loading any moderators? If so, fix their group data... |
@@ -1372,14 +1432,17 @@ discard block |
||
1372 | 1432 | foreach ($temp_mods as $id) |
1373 | 1433 | { |
1374 | 1434 | // By popular demand, don't show admins or global moderators as moderators. |
1375 | - if ($user_profile[$id]['id_group'] != 1 && $user_profile[$id]['id_group'] != 2) |
|
1376 | - $user_profile[$id]['member_group'] = $row['member_group']; |
|
1435 | + if ($user_profile[$id]['id_group'] != 1 && $user_profile[$id]['id_group'] != 2) { |
|
1436 | + $user_profile[$id]['member_group'] = $row['member_group']; |
|
1437 | + } |
|
1377 | 1438 | |
1378 | 1439 | // If the Moderator group has no color or icons, but their group does... don't overwrite. |
1379 | - if (!empty($row['icons'])) |
|
1380 | - $user_profile[$id]['icons'] = $row['icons']; |
|
1381 | - if (!empty($row['member_group_color'])) |
|
1382 | - $user_profile[$id]['member_group_color'] = $row['member_group_color']; |
|
1440 | + if (!empty($row['icons'])) { |
|
1441 | + $user_profile[$id]['icons'] = $row['icons']; |
|
1442 | + } |
|
1443 | + if (!empty($row['member_group_color'])) { |
|
1444 | + $user_profile[$id]['member_group_color'] = $row['member_group_color']; |
|
1445 | + } |
|
1383 | 1446 | } |
1384 | 1447 | } |
1385 | 1448 | |
@@ -1401,12 +1464,14 @@ discard block |
||
1401 | 1464 | static $loadedLanguages = array(); |
1402 | 1465 | |
1403 | 1466 | // If this person's data is already loaded, skip it. |
1404 | - if (isset($dataLoaded[$user])) |
|
1405 | - return true; |
|
1467 | + if (isset($dataLoaded[$user])) { |
|
1468 | + return true; |
|
1469 | + } |
|
1406 | 1470 | |
1407 | 1471 | // We can't load guests or members not loaded by loadMemberData()! |
1408 | - if ($user == 0) |
|
1409 | - return false; |
|
1472 | + if ($user == 0) { |
|
1473 | + return false; |
|
1474 | + } |
|
1410 | 1475 | if (!isset($user_profile[$user])) |
1411 | 1476 | { |
1412 | 1477 | trigger_error('loadMemberContext(): member id ' . $user . ' not previously loaded by loadMemberData()', E_USER_WARNING); |
@@ -1432,12 +1497,16 @@ discard block |
||
1432 | 1497 | $buddy_list = !empty($profile['buddy_list']) ? explode(',', $profile['buddy_list']) : array(); |
1433 | 1498 | |
1434 | 1499 | //We need a little fallback for the membergroup icons. If it doesn't exist in the current theme, fallback to default theme |
1435 | - if (isset($profile['icons'][1]) && file_exists($settings['actual_theme_dir'] . '/images/membericons/' . $profile['icons'][1])) //icon is set and exists |
|
1500 | + if (isset($profile['icons'][1]) && file_exists($settings['actual_theme_dir'] . '/images/membericons/' . $profile['icons'][1])) { |
|
1501 | + //icon is set and exists |
|
1436 | 1502 | $group_icon_url = $settings['images_url'] . '/membericons/' . $profile['icons'][1]; |
1437 | - elseif (isset($profile['icons'][1])) //icon is set and doesn't exist, fallback to default |
|
1503 | + } elseif (isset($profile['icons'][1])) { |
|
1504 | + //icon is set and doesn't exist, fallback to default |
|
1438 | 1505 | $group_icon_url = $settings['default_images_url'] . '/membericons/' . $profile['icons'][1]; |
1439 | - else //not set, bye bye |
|
1506 | + } else { |
|
1507 | + //not set, bye bye |
|
1440 | 1508 | $group_icon_url = ''; |
1509 | + } |
|
1441 | 1510 | |
1442 | 1511 | // These minimal values are always loaded |
1443 | 1512 | $memberContext[$user] = array( |
@@ -1456,8 +1525,9 @@ discard block |
||
1456 | 1525 | if ($context['loadMemberContext_set'] != 'minimal') |
1457 | 1526 | { |
1458 | 1527 | // Go the extra mile and load the user's native language name. |
1459 | - if (empty($loadedLanguages)) |
|
1460 | - $loadedLanguages = getLanguages(); |
|
1528 | + if (empty($loadedLanguages)) { |
|
1529 | + $loadedLanguages = getLanguages(); |
|
1530 | + } |
|
1461 | 1531 | |
1462 | 1532 | $memberContext[$user] += array( |
1463 | 1533 | 'username_color' => '<span ' . (!empty($profile['member_group_color']) ? 'style="color:' . $profile['member_group_color'] . ';"' : '') . '>' . $profile['member_name'] . '</span>', |
@@ -1512,31 +1582,33 @@ discard block |
||
1512 | 1582 | { |
1513 | 1583 | if (!empty($modSettings['gravatarOverride']) || (!empty($modSettings['gravatarEnabled']) && stristr($profile['avatar'], 'gravatar://'))) |
1514 | 1584 | { |
1515 | - if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($profile['avatar'], 'gravatar://') && strlen($profile['avatar']) > 11) |
|
1516 | - $image = get_gravatar_url($smcFunc['substr']($profile['avatar'], 11)); |
|
1517 | - else |
|
1518 | - $image = get_gravatar_url($profile['email_address']); |
|
1519 | - } |
|
1520 | - else |
|
1585 | + if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($profile['avatar'], 'gravatar://') && strlen($profile['avatar']) > 11) { |
|
1586 | + $image = get_gravatar_url($smcFunc['substr']($profile['avatar'], 11)); |
|
1587 | + } else { |
|
1588 | + $image = get_gravatar_url($profile['email_address']); |
|
1589 | + } |
|
1590 | + } else |
|
1521 | 1591 | { |
1522 | 1592 | // So it's stored in the member table? |
1523 | 1593 | if (!empty($profile['avatar'])) |
1524 | 1594 | { |
1525 | 1595 | $image = (stristr($profile['avatar'], 'http://') || stristr($profile['avatar'], 'https://')) ? $profile['avatar'] : $modSettings['avatar_url'] . '/' . $profile['avatar']; |
1596 | + } elseif (!empty($profile['filename'])) { |
|
1597 | + $image = $modSettings['custom_avatar_url'] . '/' . $profile['filename']; |
|
1526 | 1598 | } |
1527 | - elseif (!empty($profile['filename'])) |
|
1528 | - $image = $modSettings['custom_avatar_url'] . '/' . $profile['filename']; |
|
1529 | 1599 | // Right... no avatar...use the default one |
1530 | - else |
|
1531 | - $image = $modSettings['avatar_url'] . '/default.png'; |
|
1600 | + else { |
|
1601 | + $image = $modSettings['avatar_url'] . '/default.png'; |
|
1602 | + } |
|
1532 | 1603 | } |
1533 | - if (!empty($image)) |
|
1534 | - $memberContext[$user]['avatar'] = array( |
|
1604 | + if (!empty($image)) { |
|
1605 | + $memberContext[$user]['avatar'] = array( |
|
1535 | 1606 | 'name' => $profile['avatar'], |
1536 | 1607 | 'image' => '<img class="avatar" src="' . $image . '" alt="avatar_' . $profile['member_name'] . '">', |
1537 | 1608 | 'href' => $image, |
1538 | 1609 | 'url' => $image, |
1539 | 1610 | ); |
1611 | + } |
|
1540 | 1612 | } |
1541 | 1613 | |
1542 | 1614 | // Are we also loading the members custom fields into context? |
@@ -1544,13 +1616,15 @@ discard block |
||
1544 | 1616 | { |
1545 | 1617 | $memberContext[$user]['custom_fields'] = array(); |
1546 | 1618 | |
1547 | - if (!isset($context['display_fields'])) |
|
1548 | - $context['display_fields'] = $smcFunc['json_decode']($modSettings['displayFields'], true); |
|
1619 | + if (!isset($context['display_fields'])) { |
|
1620 | + $context['display_fields'] = $smcFunc['json_decode']($modSettings['displayFields'], true); |
|
1621 | + } |
|
1549 | 1622 | |
1550 | 1623 | foreach ($context['display_fields'] as $custom) |
1551 | 1624 | { |
1552 | - if (!isset($custom['col_name']) || trim($custom['col_name']) == '' || empty($profile['options'][$custom['col_name']])) |
|
1553 | - continue; |
|
1625 | + if (!isset($custom['col_name']) || trim($custom['col_name']) == '' || empty($profile['options'][$custom['col_name']])) { |
|
1626 | + continue; |
|
1627 | + } |
|
1554 | 1628 | |
1555 | 1629 | $value = $profile['options'][$custom['col_name']]; |
1556 | 1630 | |
@@ -1558,31 +1632,36 @@ discard block |
||
1558 | 1632 | $currentKey = 0; |
1559 | 1633 | |
1560 | 1634 | // Create a key => value array for multiple options fields |
1561 | - if (!empty($custom['options'])) |
|
1562 | - foreach ($custom['options'] as $k => $v) |
|
1635 | + if (!empty($custom['options'])) { |
|
1636 | + foreach ($custom['options'] as $k => $v) |
|
1563 | 1637 | { |
1564 | 1638 | $fieldOptions[] = $v; |
1565 | - if (empty($currentKey)) |
|
1566 | - $currentKey = $v == $value ? $k : 0; |
|
1639 | + } |
|
1640 | + if (empty($currentKey)) { |
|
1641 | + $currentKey = $v == $value ? $k : 0; |
|
1642 | + } |
|
1567 | 1643 | } |
1568 | 1644 | |
1569 | 1645 | // BBC? |
1570 | - if ($custom['bbc']) |
|
1571 | - $value = parse_bbc($value); |
|
1646 | + if ($custom['bbc']) { |
|
1647 | + $value = parse_bbc($value); |
|
1648 | + } |
|
1572 | 1649 | |
1573 | 1650 | // ... or checkbox? |
1574 | - elseif (isset($custom['type']) && $custom['type'] == 'check') |
|
1575 | - $value = $value ? $txt['yes'] : $txt['no']; |
|
1651 | + elseif (isset($custom['type']) && $custom['type'] == 'check') { |
|
1652 | + $value = $value ? $txt['yes'] : $txt['no']; |
|
1653 | + } |
|
1576 | 1654 | |
1577 | 1655 | // Enclosing the user input within some other text? |
1578 | - if (!empty($custom['enclose'])) |
|
1579 | - $value = strtr($custom['enclose'], array( |
|
1656 | + if (!empty($custom['enclose'])) { |
|
1657 | + $value = strtr($custom['enclose'], array( |
|
1580 | 1658 | '{SCRIPTURL}' => $scripturl, |
1581 | 1659 | '{IMAGES_URL}' => $settings['images_url'], |
1582 | 1660 | '{DEFAULT_IMAGES_URL}' => $settings['default_images_url'], |
1583 | 1661 | '{INPUT}' => $value, |
1584 | 1662 | '{KEY}' => $currentKey, |
1585 | 1663 | )); |
1664 | + } |
|
1586 | 1665 | |
1587 | 1666 | $memberContext[$user]['custom_fields'][] = array( |
1588 | 1667 | 'title' => !empty($custom['title']) ? $custom['title'] : $custom['col_name'], |
@@ -1609,8 +1688,9 @@ discard block |
||
1609 | 1688 | global $smcFunc, $txt, $scripturl, $settings; |
1610 | 1689 | |
1611 | 1690 | // Do not waste my time... |
1612 | - if (empty($users) || empty($params)) |
|
1613 | - return false; |
|
1691 | + if (empty($users) || empty($params)) { |
|
1692 | + return false; |
|
1693 | + } |
|
1614 | 1694 | |
1615 | 1695 | // Make sure it's an array. |
1616 | 1696 | $users = !is_array($users) ? array($users) : array_unique($users); |
@@ -1637,41 +1717,48 @@ discard block |
||
1637 | 1717 | $currentKey = 0; |
1638 | 1718 | |
1639 | 1719 | // Create a key => value array for multiple options fields |
1640 | - if (!empty($row['field_options'])) |
|
1641 | - foreach (explode(',', $row['field_options']) as $k => $v) |
|
1720 | + if (!empty($row['field_options'])) { |
|
1721 | + foreach (explode(',', $row['field_options']) as $k => $v) |
|
1642 | 1722 | { |
1643 | 1723 | $fieldOptions[] = $v; |
1644 | - if (empty($currentKey)) |
|
1645 | - $currentKey = $v == $row['value'] ? $k : 0; |
|
1724 | + } |
|
1725 | + if (empty($currentKey)) { |
|
1726 | + $currentKey = $v == $row['value'] ? $k : 0; |
|
1727 | + } |
|
1646 | 1728 | } |
1647 | 1729 | |
1648 | 1730 | // BBC? |
1649 | - if (!empty($row['bbc'])) |
|
1650 | - $row['value'] = parse_bbc($row['value']); |
|
1731 | + if (!empty($row['bbc'])) { |
|
1732 | + $row['value'] = parse_bbc($row['value']); |
|
1733 | + } |
|
1651 | 1734 | |
1652 | 1735 | // ... or checkbox? |
1653 | - elseif (isset($row['type']) && $row['type'] == 'check') |
|
1654 | - $row['value'] = !empty($row['value']) ? $txt['yes'] : $txt['no']; |
|
1736 | + elseif (isset($row['type']) && $row['type'] == 'check') { |
|
1737 | + $row['value'] = !empty($row['value']) ? $txt['yes'] : $txt['no']; |
|
1738 | + } |
|
1655 | 1739 | |
1656 | 1740 | // Enclosing the user input within some other text? |
1657 | - if (!empty($row['enclose'])) |
|
1658 | - $row['value'] = strtr($row['enclose'], array( |
|
1741 | + if (!empty($row['enclose'])) { |
|
1742 | + $row['value'] = strtr($row['enclose'], array( |
|
1659 | 1743 | '{SCRIPTURL}' => $scripturl, |
1660 | 1744 | '{IMAGES_URL}' => $settings['images_url'], |
1661 | 1745 | '{DEFAULT_IMAGES_URL}' => $settings['default_images_url'], |
1662 | 1746 | '{INPUT}' => un_htmlspecialchars($row['value']), |
1663 | 1747 | '{KEY}' => $currentKey, |
1664 | 1748 | )); |
1749 | + } |
|
1665 | 1750 | |
1666 | 1751 | // Send a simple array if there is just 1 param |
1667 | - if (count($params) == 1) |
|
1668 | - $return[$row['id_member']] = $row; |
|
1752 | + if (count($params) == 1) { |
|
1753 | + $return[$row['id_member']] = $row; |
|
1754 | + } |
|
1669 | 1755 | |
1670 | 1756 | // More than 1? knock yourself out... |
1671 | 1757 | else |
1672 | 1758 | { |
1673 | - if (!isset($return[$row['id_member']])) |
|
1674 | - $return[$row['id_member']] = array(); |
|
1759 | + if (!isset($return[$row['id_member']])) { |
|
1760 | + $return[$row['id_member']] = array(); |
|
1761 | + } |
|
1675 | 1762 | |
1676 | 1763 | $return[$row['id_member']][$row['variable']] = $row; |
1677 | 1764 | } |
@@ -1705,8 +1792,9 @@ discard block |
||
1705 | 1792 | global $context; |
1706 | 1793 | |
1707 | 1794 | // Don't know any browser! |
1708 | - if (empty($context['browser'])) |
|
1709 | - detectBrowser(); |
|
1795 | + if (empty($context['browser'])) { |
|
1796 | + detectBrowser(); |
|
1797 | + } |
|
1710 | 1798 | |
1711 | 1799 | return !empty($context['browser'][$browser]) || !empty($context['browser']['is_' . $browser]) ? true : false; |
1712 | 1800 | } |
@@ -1724,8 +1812,9 @@ discard block |
||
1724 | 1812 | global $context, $settings, $options, $sourcedir, $ssi_theme, $smcFunc, $language, $board, $image_proxy_enabled; |
1725 | 1813 | |
1726 | 1814 | // The theme was specified by parameter. |
1727 | - if (!empty($id_theme)) |
|
1728 | - $id_theme = (int) $id_theme; |
|
1815 | + if (!empty($id_theme)) { |
|
1816 | + $id_theme = (int) $id_theme; |
|
1817 | + } |
|
1729 | 1818 | // The theme was specified by REQUEST. |
1730 | 1819 | elseif (!empty($_REQUEST['theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum'))) |
1731 | 1820 | { |
@@ -1733,54 +1822,61 @@ discard block |
||
1733 | 1822 | $_SESSION['id_theme'] = $id_theme; |
1734 | 1823 | } |
1735 | 1824 | // The theme was specified by REQUEST... previously. |
1736 | - elseif (!empty($_SESSION['id_theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum'))) |
|
1737 | - $id_theme = (int) $_SESSION['id_theme']; |
|
1825 | + elseif (!empty($_SESSION['id_theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum'))) { |
|
1826 | + $id_theme = (int) $_SESSION['id_theme']; |
|
1827 | + } |
|
1738 | 1828 | // The theme is just the user's choice. (might use ?board=1;theme=0 to force board theme.) |
1739 | - elseif (!empty($user_info['theme']) && !isset($_REQUEST['theme'])) |
|
1740 | - $id_theme = $user_info['theme']; |
|
1829 | + elseif (!empty($user_info['theme']) && !isset($_REQUEST['theme'])) { |
|
1830 | + $id_theme = $user_info['theme']; |
|
1831 | + } |
|
1741 | 1832 | // The theme was specified by the board. |
1742 | - elseif (!empty($board_info['theme'])) |
|
1743 | - $id_theme = $board_info['theme']; |
|
1833 | + elseif (!empty($board_info['theme'])) { |
|
1834 | + $id_theme = $board_info['theme']; |
|
1835 | + } |
|
1744 | 1836 | // The theme is the forum's default. |
1745 | - else |
|
1746 | - $id_theme = $modSettings['theme_guests']; |
|
1837 | + else { |
|
1838 | + $id_theme = $modSettings['theme_guests']; |
|
1839 | + } |
|
1747 | 1840 | |
1748 | 1841 | // We already load the basic stuff? |
1749 | 1842 | if (empty($settings['theme_id']) || $settings['theme_id'] != $id_theme ) |
1750 | 1843 | { |
1751 | 1844 | // Verify the id_theme... no foul play. |
1752 | 1845 | // Always allow the board specific theme, if they are overriding. |
1753 | - if (!empty($board_info['theme']) && $board_info['override_theme']) |
|
1754 | - $id_theme = $board_info['theme']; |
|
1846 | + if (!empty($board_info['theme']) && $board_info['override_theme']) { |
|
1847 | + $id_theme = $board_info['theme']; |
|
1848 | + } |
|
1755 | 1849 | // If they have specified a particular theme to use with SSI allow it to be used. |
1756 | - elseif (!empty($ssi_theme) && $id_theme == $ssi_theme) |
|
1757 | - $id_theme = (int) $id_theme; |
|
1758 | - elseif (!empty($modSettings['enableThemes']) && !allowedTo('admin_forum')) |
|
1850 | + elseif (!empty($ssi_theme) && $id_theme == $ssi_theme) { |
|
1851 | + $id_theme = (int) $id_theme; |
|
1852 | + } elseif (!empty($modSettings['enableThemes']) && !allowedTo('admin_forum')) |
|
1759 | 1853 | { |
1760 | 1854 | $themes = explode(',', $modSettings['enableThemes']); |
1761 | - if (!in_array($id_theme, $themes)) |
|
1762 | - $id_theme = $modSettings['theme_guests']; |
|
1763 | - else |
|
1764 | - $id_theme = (int) $id_theme; |
|
1855 | + if (!in_array($id_theme, $themes)) { |
|
1856 | + $id_theme = $modSettings['theme_guests']; |
|
1857 | + } else { |
|
1858 | + $id_theme = (int) $id_theme; |
|
1859 | + } |
|
1860 | + } else { |
|
1861 | + $id_theme = (int) $id_theme; |
|
1765 | 1862 | } |
1766 | - else |
|
1767 | - $id_theme = (int) $id_theme; |
|
1768 | 1863 | |
1769 | 1864 | $member = empty($user_info['id']) ? -1 : $user_info['id']; |
1770 | 1865 | |
1771 | 1866 | // Disable image proxy if we don't have SSL enabled |
1772 | - if (empty($modSettings['force_ssl']) || $modSettings['force_ssl'] < 2) |
|
1773 | - $image_proxy_enabled = false; |
|
1867 | + if (empty($modSettings['force_ssl']) || $modSettings['force_ssl'] < 2) { |
|
1868 | + $image_proxy_enabled = false; |
|
1869 | + } |
|
1774 | 1870 | |
1775 | 1871 | if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2 && ($temp = cache_get_data('theme_settings-' . $id_theme . ':' . $member, 60)) != null && time() - 60 > $modSettings['settings_updated']) |
1776 | 1872 | { |
1777 | 1873 | $themeData = $temp; |
1778 | 1874 | $flag = true; |
1875 | + } elseif (($temp = cache_get_data('theme_settings-' . $id_theme, 90)) != null && time() - 60 > $modSettings['settings_updated']) { |
|
1876 | + $themeData = $temp + array($member => array()); |
|
1877 | + } else { |
|
1878 | + $themeData = array(-1 => array(), 0 => array(), $member => array()); |
|
1779 | 1879 | } |
1780 | - elseif (($temp = cache_get_data('theme_settings-' . $id_theme, 90)) != null && time() - 60 > $modSettings['settings_updated']) |
|
1781 | - $themeData = $temp + array($member => array()); |
|
1782 | - else |
|
1783 | - $themeData = array(-1 => array(), 0 => array(), $member => array()); |
|
1784 | 1880 | |
1785 | 1881 | if (empty($flag)) |
1786 | 1882 | { |
@@ -1799,31 +1895,37 @@ discard block |
||
1799 | 1895 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
1800 | 1896 | { |
1801 | 1897 | // There are just things we shouldn't be able to change as members. |
1802 | - if ($row['id_member'] != 0 && in_array($row['variable'], array('actual_theme_url', 'actual_images_url', 'base_theme_dir', 'base_theme_url', 'default_images_url', 'default_theme_dir', 'default_theme_url', 'default_template', 'images_url', 'number_recent_posts', 'smiley_sets_default', 'theme_dir', 'theme_id', 'theme_layers', 'theme_templates', 'theme_url'))) |
|
1803 | - continue; |
|
1898 | + if ($row['id_member'] != 0 && in_array($row['variable'], array('actual_theme_url', 'actual_images_url', 'base_theme_dir', 'base_theme_url', 'default_images_url', 'default_theme_dir', 'default_theme_url', 'default_template', 'images_url', 'number_recent_posts', 'smiley_sets_default', 'theme_dir', 'theme_id', 'theme_layers', 'theme_templates', 'theme_url'))) { |
|
1899 | + continue; |
|
1900 | + } |
|
1804 | 1901 | |
1805 | 1902 | // If this is the theme_dir of the default theme, store it. |
1806 | - if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['id_theme'] == '1' && empty($row['id_member'])) |
|
1807 | - $themeData[0]['default_' . $row['variable']] = $row['value']; |
|
1903 | + if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['id_theme'] == '1' && empty($row['id_member'])) { |
|
1904 | + $themeData[0]['default_' . $row['variable']] = $row['value']; |
|
1905 | + } |
|
1808 | 1906 | |
1809 | 1907 | // If this isn't set yet, is a theme option, or is not the default theme.. |
1810 | - if (!isset($themeData[$row['id_member']][$row['variable']]) || $row['id_theme'] != '1') |
|
1811 | - $themeData[$row['id_member']][$row['variable']] = substr($row['variable'], 0, 5) == 'show_' ? $row['value'] == '1' : $row['value']; |
|
1908 | + if (!isset($themeData[$row['id_member']][$row['variable']]) || $row['id_theme'] != '1') { |
|
1909 | + $themeData[$row['id_member']][$row['variable']] = substr($row['variable'], 0, 5) == 'show_' ? $row['value'] == '1' : $row['value']; |
|
1910 | + } |
|
1812 | 1911 | } |
1813 | 1912 | $smcFunc['db_free_result']($result); |
1814 | 1913 | |
1815 | - if (!empty($themeData[-1])) |
|
1816 | - foreach ($themeData[-1] as $k => $v) |
|
1914 | + if (!empty($themeData[-1])) { |
|
1915 | + foreach ($themeData[-1] as $k => $v) |
|
1817 | 1916 | { |
1818 | 1917 | if (!isset($themeData[$member][$k])) |
1819 | 1918 | $themeData[$member][$k] = $v; |
1919 | + } |
|
1820 | 1920 | } |
1821 | 1921 | |
1822 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
1823 | - cache_put_data('theme_settings-' . $id_theme . ':' . $member, $themeData, 60); |
|
1922 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
1923 | + cache_put_data('theme_settings-' . $id_theme . ':' . $member, $themeData, 60); |
|
1924 | + } |
|
1824 | 1925 | // Only if we didn't already load that part of the cache... |
1825 | - elseif (!isset($temp)) |
|
1826 | - cache_put_data('theme_settings-' . $id_theme, array(-1 => $themeData[-1], 0 => $themeData[0]), 90); |
|
1926 | + elseif (!isset($temp)) { |
|
1927 | + cache_put_data('theme_settings-' . $id_theme, array(-1 => $themeData[-1], 0 => $themeData[0]), 90); |
|
1928 | + } |
|
1827 | 1929 | } |
1828 | 1930 | |
1829 | 1931 | $settings = $themeData[0]; |
@@ -1840,17 +1942,20 @@ discard block |
||
1840 | 1942 | $settings['template_dirs'][] = $settings['theme_dir']; |
1841 | 1943 | |
1842 | 1944 | // Based on theme (if there is one). |
1843 | - if (!empty($settings['base_theme_dir'])) |
|
1844 | - $settings['template_dirs'][] = $settings['base_theme_dir']; |
|
1945 | + if (!empty($settings['base_theme_dir'])) { |
|
1946 | + $settings['template_dirs'][] = $settings['base_theme_dir']; |
|
1947 | + } |
|
1845 | 1948 | |
1846 | 1949 | // Lastly the default theme. |
1847 | - if ($settings['theme_dir'] != $settings['default_theme_dir']) |
|
1848 | - $settings['template_dirs'][] = $settings['default_theme_dir']; |
|
1950 | + if ($settings['theme_dir'] != $settings['default_theme_dir']) { |
|
1951 | + $settings['template_dirs'][] = $settings['default_theme_dir']; |
|
1952 | + } |
|
1849 | 1953 | } |
1850 | 1954 | |
1851 | 1955 | |
1852 | - if (!$initialize) |
|
1853 | - return; |
|
1956 | + if (!$initialize) { |
|
1957 | + return; |
|
1958 | + } |
|
1854 | 1959 | |
1855 | 1960 | // Check to see if we're forcing SSL |
1856 | 1961 | if (!empty($modSettings['force_ssl']) && $modSettings['force_ssl'] == 2 && empty($maintenance) && |
@@ -1871,8 +1976,9 @@ discard block |
||
1871 | 1976 | $detected_url = httpsOn() ? 'https://' : 'http://'; |
1872 | 1977 | $detected_url .= empty($_SERVER['HTTP_HOST']) ? $_SERVER['SERVER_NAME'] . (empty($_SERVER['SERVER_PORT']) || $_SERVER['SERVER_PORT'] == '80' ? '' : ':' . $_SERVER['SERVER_PORT']) : $_SERVER['HTTP_HOST']; |
1873 | 1978 | $temp = preg_replace('~/' . basename($scripturl) . '(/.+)?$~', '', strtr(dirname($_SERVER['PHP_SELF']), '\\', '/')); |
1874 | - if ($temp != '/') |
|
1875 | - $detected_url .= $temp; |
|
1979 | + if ($temp != '/') { |
|
1980 | + $detected_url .= $temp; |
|
1981 | + } |
|
1876 | 1982 | } |
1877 | 1983 | if (isset($detected_url) && $detected_url != $boardurl) |
1878 | 1984 | { |
@@ -1884,8 +1990,9 @@ discard block |
||
1884 | 1990 | foreach ($aliases as $alias) |
1885 | 1991 | { |
1886 | 1992 | // Rip off all the boring parts, spaces, etc. |
1887 | - if ($detected_url == trim($alias) || strtr($detected_url, array('http://' => '', 'https://' => '')) == trim($alias)) |
|
1888 | - $do_fix = true; |
|
1993 | + if ($detected_url == trim($alias) || strtr($detected_url, array('http://' => '', 'https://' => '')) == trim($alias)) { |
|
1994 | + $do_fix = true; |
|
1995 | + } |
|
1889 | 1996 | } |
1890 | 1997 | } |
1891 | 1998 | |
@@ -1893,21 +2000,23 @@ discard block |
||
1893 | 2000 | if (empty($do_fix) && strtr($detected_url, array('://' => '://www.')) == $boardurl && (empty($_GET) || count($_GET) == 1) && SMF != 'SSI') |
1894 | 2001 | { |
1895 | 2002 | // Okay, this seems weird, but we don't want an endless loop - this will make $_GET not empty ;). |
1896 | - if (empty($_GET)) |
|
1897 | - redirectexit('wwwRedirect'); |
|
1898 | - else |
|
2003 | + if (empty($_GET)) { |
|
2004 | + redirectexit('wwwRedirect'); |
|
2005 | + } else |
|
1899 | 2006 | { |
1900 | 2007 | $k = key($_GET); |
1901 | 2008 | $v = current($_GET); |
1902 | 2009 | |
1903 | - if ($k != 'wwwRedirect') |
|
1904 | - redirectexit('wwwRedirect;' . $k . '=' . $v); |
|
2010 | + if ($k != 'wwwRedirect') { |
|
2011 | + redirectexit('wwwRedirect;' . $k . '=' . $v); |
|
2012 | + } |
|
1905 | 2013 | } |
1906 | 2014 | } |
1907 | 2015 | |
1908 | 2016 | // #3 is just a check for SSL... |
1909 | - if (strtr($detected_url, array('https://' => 'http://')) == $boardurl) |
|
1910 | - $do_fix = true; |
|
2017 | + if (strtr($detected_url, array('https://' => 'http://')) == $boardurl) { |
|
2018 | + $do_fix = true; |
|
2019 | + } |
|
1911 | 2020 | |
1912 | 2021 | // Okay, #4 - perhaps it's an IP address? We're gonna want to use that one, then. (assuming it's the IP or something...) |
1913 | 2022 | if (!empty($do_fix) || preg_match('~^http[s]?://(?:[\d\.:]+|\[[\d:]+\](?::\d+)?)(?:$|/)~', $detected_url) == 1) |
@@ -1942,8 +2051,9 @@ discard block |
||
1942 | 2051 | $board_info['moderators'][$k]['link'] = strtr($dummy['link'], array('"' . $oldurl => '"' . $boardurl)); |
1943 | 2052 | } |
1944 | 2053 | } |
1945 | - foreach ($context['linktree'] as $k => $dummy) |
|
1946 | - $context['linktree'][$k]['url'] = strtr($dummy['url'], array($oldurl => $boardurl)); |
|
2054 | + foreach ($context['linktree'] as $k => $dummy) { |
|
2055 | + $context['linktree'][$k]['url'] = strtr($dummy['url'], array($oldurl => $boardurl)); |
|
2056 | + } |
|
1947 | 2057 | } |
1948 | 2058 | } |
1949 | 2059 | // Set up the contextual user array. |
@@ -1962,16 +2072,16 @@ discard block |
||
1962 | 2072 | 'email' => $user_info['email'], |
1963 | 2073 | 'ignoreusers' => $user_info['ignoreusers'], |
1964 | 2074 | ); |
1965 | - if (!$context['user']['is_guest']) |
|
1966 | - $context['user']['name'] = $user_info['name']; |
|
1967 | - elseif ($context['user']['is_guest'] && !empty($txt['guest_title'])) |
|
1968 | - $context['user']['name'] = $txt['guest_title']; |
|
2075 | + if (!$context['user']['is_guest']) { |
|
2076 | + $context['user']['name'] = $user_info['name']; |
|
2077 | + } elseif ($context['user']['is_guest'] && !empty($txt['guest_title'])) { |
|
2078 | + $context['user']['name'] = $txt['guest_title']; |
|
2079 | + } |
|
1969 | 2080 | |
1970 | 2081 | // Determine the current smiley set. |
1971 | 2082 | $user_info['smiley_set'] = (!in_array($user_info['smiley_set'], explode(',', $modSettings['smiley_sets_known'])) && $user_info['smiley_set'] != 'none') || empty($modSettings['smiley_sets_enable']) ? (!empty($settings['smiley_sets_default']) ? $settings['smiley_sets_default'] : $modSettings['smiley_sets_default']) : $user_info['smiley_set']; |
1972 | 2083 | $context['user']['smiley_set'] = $user_info['smiley_set']; |
1973 | - } |
|
1974 | - else |
|
2084 | + } else |
|
1975 | 2085 | { |
1976 | 2086 | // What to do when there is no $user_info (e.g., an error very early in the login process) |
1977 | 2087 | $context['user'] = array( |
@@ -2005,18 +2115,24 @@ discard block |
||
2005 | 2115 | } |
2006 | 2116 | |
2007 | 2117 | // Some basic information... |
2008 | - if (!isset($context['html_headers'])) |
|
2009 | - $context['html_headers'] = ''; |
|
2010 | - if (!isset($context['javascript_files'])) |
|
2011 | - $context['javascript_files'] = array(); |
|
2012 | - if (!isset($context['css_files'])) |
|
2013 | - $context['css_files'] = array(); |
|
2014 | - if (!isset($context['css_header'])) |
|
2015 | - $context['css_header'] = array(); |
|
2016 | - if (!isset($context['javascript_inline'])) |
|
2017 | - $context['javascript_inline'] = array('standard' => array(), 'defer' => array()); |
|
2018 | - if (!isset($context['javascript_vars'])) |
|
2019 | - $context['javascript_vars'] = array(); |
|
2118 | + if (!isset($context['html_headers'])) { |
|
2119 | + $context['html_headers'] = ''; |
|
2120 | + } |
|
2121 | + if (!isset($context['javascript_files'])) { |
|
2122 | + $context['javascript_files'] = array(); |
|
2123 | + } |
|
2124 | + if (!isset($context['css_files'])) { |
|
2125 | + $context['css_files'] = array(); |
|
2126 | + } |
|
2127 | + if (!isset($context['css_header'])) { |
|
2128 | + $context['css_header'] = array(); |
|
2129 | + } |
|
2130 | + if (!isset($context['javascript_inline'])) { |
|
2131 | + $context['javascript_inline'] = array('standard' => array(), 'defer' => array()); |
|
2132 | + } |
|
2133 | + if (!isset($context['javascript_vars'])) { |
|
2134 | + $context['javascript_vars'] = array(); |
|
2135 | + } |
|
2020 | 2136 | |
2021 | 2137 | $context['login_url'] = (!empty($modSettings['force_ssl']) && $modSettings['force_ssl'] < 2 ? strtr($scripturl, array('http://' => 'https://')) : $scripturl) . '?action=login2'; |
2022 | 2138 | $context['menu_separator'] = !empty($settings['use_image_buttons']) ? ' ' : ' | '; |
@@ -2028,16 +2144,18 @@ discard block |
||
2028 | 2144 | $context['current_action'] = isset($_REQUEST['action']) ? $smcFunc['htmlspecialchars']($_REQUEST['action']) : null; |
2029 | 2145 | $context['current_subaction'] = isset($_REQUEST['sa']) ? $_REQUEST['sa'] : null; |
2030 | 2146 | $context['can_register'] = empty($modSettings['registration_method']) || $modSettings['registration_method'] != 3; |
2031 | - if (isset($modSettings['load_average'])) |
|
2032 | - $context['load_average'] = $modSettings['load_average']; |
|
2147 | + if (isset($modSettings['load_average'])) { |
|
2148 | + $context['load_average'] = $modSettings['load_average']; |
|
2149 | + } |
|
2033 | 2150 | |
2034 | 2151 | // Detect the browser. This is separated out because it's also used in attachment downloads |
2035 | 2152 | detectBrowser(); |
2036 | 2153 | |
2037 | 2154 | // Set the top level linktree up. |
2038 | 2155 | // Note that if we're dealing with certain very early errors (e.g., login) the linktree might not be set yet... |
2039 | - if (empty($context['linktree'])) |
|
2040 | - $context['linktree'] = array(); |
|
2156 | + if (empty($context['linktree'])) { |
|
2157 | + $context['linktree'] = array(); |
|
2158 | + } |
|
2041 | 2159 | array_unshift($context['linktree'], array( |
2042 | 2160 | 'url' => $scripturl, |
2043 | 2161 | 'name' => $context['forum_name_html_safe'] |
@@ -2046,8 +2164,9 @@ discard block |
||
2046 | 2164 | // This allows sticking some HTML on the page output - useful for controls. |
2047 | 2165 | $context['insert_after_template'] = ''; |
2048 | 2166 | |
2049 | - if (!isset($txt)) |
|
2050 | - $txt = array(); |
|
2167 | + if (!isset($txt)) { |
|
2168 | + $txt = array(); |
|
2169 | + } |
|
2051 | 2170 | |
2052 | 2171 | $simpleActions = array( |
2053 | 2172 | 'findmember', |
@@ -2093,9 +2212,10 @@ discard block |
||
2093 | 2212 | |
2094 | 2213 | // See if theres any extra param to check. |
2095 | 2214 | $requiresXML = false; |
2096 | - foreach ($extraParams as $key => $extra) |
|
2097 | - if (isset($_REQUEST[$extra])) |
|
2215 | + foreach ($extraParams as $key => $extra) { |
|
2216 | + if (isset($_REQUEST[$extra])) |
|
2098 | 2217 | $requiresXML = true; |
2218 | + } |
|
2099 | 2219 | |
2100 | 2220 | // Output is fully XML, so no need for the index template. |
2101 | 2221 | if (isset($_REQUEST['xml']) && (in_array($context['current_action'], $xmlActions) || $requiresXML)) |
@@ -2110,37 +2230,39 @@ discard block |
||
2110 | 2230 | { |
2111 | 2231 | loadLanguage('index+Modifications'); |
2112 | 2232 | $context['template_layers'] = array(); |
2113 | - } |
|
2114 | - |
|
2115 | - else |
|
2233 | + } else |
|
2116 | 2234 | { |
2117 | 2235 | // Custom templates to load, or just default? |
2118 | - if (isset($settings['theme_templates'])) |
|
2119 | - $templates = explode(',', $settings['theme_templates']); |
|
2120 | - else |
|
2121 | - $templates = array('index'); |
|
2236 | + if (isset($settings['theme_templates'])) { |
|
2237 | + $templates = explode(',', $settings['theme_templates']); |
|
2238 | + } else { |
|
2239 | + $templates = array('index'); |
|
2240 | + } |
|
2122 | 2241 | |
2123 | 2242 | // Load each template... |
2124 | - foreach ($templates as $template) |
|
2125 | - loadTemplate($template); |
|
2243 | + foreach ($templates as $template) { |
|
2244 | + loadTemplate($template); |
|
2245 | + } |
|
2126 | 2246 | |
2127 | 2247 | // ...and attempt to load their associated language files. |
2128 | 2248 | $required_files = implode('+', array_merge($templates, array('Modifications'))); |
2129 | 2249 | loadLanguage($required_files, '', false); |
2130 | 2250 | |
2131 | 2251 | // Custom template layers? |
2132 | - if (isset($settings['theme_layers'])) |
|
2133 | - $context['template_layers'] = explode(',', $settings['theme_layers']); |
|
2134 | - else |
|
2135 | - $context['template_layers'] = array('html', 'body'); |
|
2252 | + if (isset($settings['theme_layers'])) { |
|
2253 | + $context['template_layers'] = explode(',', $settings['theme_layers']); |
|
2254 | + } else { |
|
2255 | + $context['template_layers'] = array('html', 'body'); |
|
2256 | + } |
|
2136 | 2257 | } |
2137 | 2258 | |
2138 | 2259 | // Initialize the theme. |
2139 | 2260 | loadSubTemplate('init', 'ignore'); |
2140 | 2261 | |
2141 | 2262 | // Allow overriding the board wide time/number formats. |
2142 | - if (empty($user_settings['time_format']) && !empty($txt['time_format'])) |
|
2143 | - $user_info['time_format'] = $txt['time_format']; |
|
2263 | + if (empty($user_settings['time_format']) && !empty($txt['time_format'])) { |
|
2264 | + $user_info['time_format'] = $txt['time_format']; |
|
2265 | + } |
|
2144 | 2266 | |
2145 | 2267 | // Set the character set from the template. |
2146 | 2268 | $context['character_set'] = empty($modSettings['global_character_set']) ? $txt['lang_character_set'] : $modSettings['global_character_set']; |
@@ -2148,12 +2270,14 @@ discard block |
||
2148 | 2270 | $context['right_to_left'] = !empty($txt['lang_rtl']); |
2149 | 2271 | |
2150 | 2272 | // Guests may still need a name. |
2151 | - if ($context['user']['is_guest'] && empty($context['user']['name'])) |
|
2152 | - $context['user']['name'] = $txt['guest_title']; |
|
2273 | + if ($context['user']['is_guest'] && empty($context['user']['name'])) { |
|
2274 | + $context['user']['name'] = $txt['guest_title']; |
|
2275 | + } |
|
2153 | 2276 | |
2154 | 2277 | // Any theme-related strings that need to be loaded? |
2155 | - if (!empty($settings['require_theme_strings'])) |
|
2156 | - loadLanguage('ThemeStrings', '', false); |
|
2278 | + if (!empty($settings['require_theme_strings'])) { |
|
2279 | + loadLanguage('ThemeStrings', '', false); |
|
2280 | + } |
|
2157 | 2281 | |
2158 | 2282 | // Make a special URL for the language. |
2159 | 2283 | $settings['lang_images_url'] = $settings['images_url'] . '/' . (!empty($txt['image_lang']) ? $txt['image_lang'] : $user_info['language']); |
@@ -2164,8 +2288,9 @@ discard block |
||
2164 | 2288 | // Here is my luvly Responsive CSS |
2165 | 2289 | loadCSSFile('responsive.css', array('force_current' => false, 'validate' => true, 'minimize' => true), 'smf_responsive'); |
2166 | 2290 | |
2167 | - if ($context['right_to_left']) |
|
2168 | - loadCSSFile('rtl.css', array(), 'smf_rtl'); |
|
2291 | + if ($context['right_to_left']) { |
|
2292 | + loadCSSFile('rtl.css', array(), 'smf_rtl'); |
|
2293 | + } |
|
2169 | 2294 | |
2170 | 2295 | // We allow theme variants, because we're cool. |
2171 | 2296 | $context['theme_variant'] = ''; |
@@ -2173,14 +2298,17 @@ discard block |
||
2173 | 2298 | if (!empty($settings['theme_variants'])) |
2174 | 2299 | { |
2175 | 2300 | // Overriding - for previews and that ilk. |
2176 | - if (!empty($_REQUEST['variant'])) |
|
2177 | - $_SESSION['id_variant'] = $_REQUEST['variant']; |
|
2301 | + if (!empty($_REQUEST['variant'])) { |
|
2302 | + $_SESSION['id_variant'] = $_REQUEST['variant']; |
|
2303 | + } |
|
2178 | 2304 | // User selection? |
2179 | - if (empty($settings['disable_user_variant']) || allowedTo('admin_forum')) |
|
2180 | - $context['theme_variant'] = !empty($_SESSION['id_variant']) ? $_SESSION['id_variant'] : (!empty($options['theme_variant']) ? $options['theme_variant'] : ''); |
|
2305 | + if (empty($settings['disable_user_variant']) || allowedTo('admin_forum')) { |
|
2306 | + $context['theme_variant'] = !empty($_SESSION['id_variant']) ? $_SESSION['id_variant'] : (!empty($options['theme_variant']) ? $options['theme_variant'] : ''); |
|
2307 | + } |
|
2181 | 2308 | // If not a user variant, select the default. |
2182 | - if ($context['theme_variant'] == '' || !in_array($context['theme_variant'], $settings['theme_variants'])) |
|
2183 | - $context['theme_variant'] = !empty($settings['default_variant']) && in_array($settings['default_variant'], $settings['theme_variants']) ? $settings['default_variant'] : $settings['theme_variants'][0]; |
|
2309 | + if ($context['theme_variant'] == '' || !in_array($context['theme_variant'], $settings['theme_variants'])) { |
|
2310 | + $context['theme_variant'] = !empty($settings['default_variant']) && in_array($settings['default_variant'], $settings['theme_variants']) ? $settings['default_variant'] : $settings['theme_variants'][0]; |
|
2311 | + } |
|
2184 | 2312 | |
2185 | 2313 | // Do this to keep things easier in the templates. |
2186 | 2314 | $context['theme_variant'] = '_' . $context['theme_variant']; |
@@ -2189,20 +2317,23 @@ discard block |
||
2189 | 2317 | if (!empty($context['theme_variant'])) |
2190 | 2318 | { |
2191 | 2319 | loadCSSFile('index' . $context['theme_variant'] . '.css', array(), 'smf_index' . $context['theme_variant']); |
2192 | - if ($context['right_to_left']) |
|
2193 | - loadCSSFile('rtl' . $context['theme_variant'] . '.css', array(), 'smf_rtl' . $context['theme_variant']); |
|
2320 | + if ($context['right_to_left']) { |
|
2321 | + loadCSSFile('rtl' . $context['theme_variant'] . '.css', array(), 'smf_rtl' . $context['theme_variant']); |
|
2322 | + } |
|
2194 | 2323 | } |
2195 | 2324 | } |
2196 | 2325 | |
2197 | 2326 | // Let's be compatible with old themes! |
2198 | - if (!function_exists('template_html_above') && in_array('html', $context['template_layers'])) |
|
2199 | - $context['template_layers'] = array('main'); |
|
2327 | + if (!function_exists('template_html_above') && in_array('html', $context['template_layers'])) { |
|
2328 | + $context['template_layers'] = array('main'); |
|
2329 | + } |
|
2200 | 2330 | |
2201 | 2331 | $context['tabindex'] = 1; |
2202 | 2332 | |
2203 | 2333 | // Compatibility. |
2204 | - if (!isset($settings['theme_version'])) |
|
2205 | - $modSettings['memberCount'] = $modSettings['totalMembers']; |
|
2334 | + if (!isset($settings['theme_version'])) { |
|
2335 | + $modSettings['memberCount'] = $modSettings['totalMembers']; |
|
2336 | + } |
|
2206 | 2337 | |
2207 | 2338 | // Default JS variables for use in every theme |
2208 | 2339 | $context['javascript_vars'] = array( |
@@ -2221,18 +2352,18 @@ discard block |
||
2221 | 2352 | ); |
2222 | 2353 | |
2223 | 2354 | // Add the JQuery library to the list of files to load. |
2224 | - if (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'cdn') |
|
2225 | - loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js', array('external' => true), 'smf_jquery'); |
|
2226 | - |
|
2227 | - elseif (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'local') |
|
2228 | - loadJavaScriptFile('jquery-3.2.1.min.js', array('seed' => false), 'smf_jquery'); |
|
2229 | - |
|
2230 | - elseif (isset($modSettings['jquery_source'], $modSettings['jquery_custom']) && $modSettings['jquery_source'] == 'custom') |
|
2231 | - loadJavaScriptFile($modSettings['jquery_custom'], array('external' => true), 'smf_jquery'); |
|
2355 | + if (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'cdn') { |
|
2356 | + loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js', array('external' => true), 'smf_jquery'); |
|
2357 | + } elseif (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'local') { |
|
2358 | + loadJavaScriptFile('jquery-3.2.1.min.js', array('seed' => false), 'smf_jquery'); |
|
2359 | + } elseif (isset($modSettings['jquery_source'], $modSettings['jquery_custom']) && $modSettings['jquery_source'] == 'custom') { |
|
2360 | + loadJavaScriptFile($modSettings['jquery_custom'], array('external' => true), 'smf_jquery'); |
|
2361 | + } |
|
2232 | 2362 | |
2233 | 2363 | // Auto loading? template_javascript() will take care of the local half of this. |
2234 | - else |
|
2235 | - loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js', array('external' => true), 'smf_jquery'); |
|
2364 | + else { |
|
2365 | + loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js', array('external' => true), 'smf_jquery'); |
|
2366 | + } |
|
2236 | 2367 | |
2237 | 2368 | // Queue our JQuery plugins! |
2238 | 2369 | loadJavaScriptFile('smf_jquery_plugins.js', array('minimize' => true), 'smf_jquery_plugins'); |
@@ -2255,12 +2386,12 @@ discard block |
||
2255 | 2386 | require_once($sourcedir . '/ScheduledTasks.php'); |
2256 | 2387 | |
2257 | 2388 | // What to do, what to do?! |
2258 | - if (empty($modSettings['next_task_time']) || $modSettings['next_task_time'] < time()) |
|
2259 | - AutoTask(); |
|
2260 | - else |
|
2261 | - ReduceMailQueue(); |
|
2262 | - } |
|
2263 | - else |
|
2389 | + if (empty($modSettings['next_task_time']) || $modSettings['next_task_time'] < time()) { |
|
2390 | + AutoTask(); |
|
2391 | + } else { |
|
2392 | + ReduceMailQueue(); |
|
2393 | + } |
|
2394 | + } else |
|
2264 | 2395 | { |
2265 | 2396 | $type = empty($modSettings['next_task_time']) || $modSettings['next_task_time'] < time() ? 'task' : 'mailq'; |
2266 | 2397 | $ts = $type == 'mailq' ? $modSettings['mail_next_send'] : $modSettings['next_task_time']; |
@@ -2311,8 +2442,9 @@ discard block |
||
2311 | 2442 | foreach ($theme_includes as $include) |
2312 | 2443 | { |
2313 | 2444 | $include = strtr(trim($include), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir'])); |
2314 | - if (file_exists($include)) |
|
2315 | - require_once($include); |
|
2445 | + if (file_exists($include)) { |
|
2446 | + require_once($include); |
|
2447 | + } |
|
2316 | 2448 | } |
2317 | 2449 | } |
2318 | 2450 | |
@@ -2342,16 +2474,19 @@ discard block |
||
2342 | 2474 | // Do any style sheets first, cause we're easy with those. |
2343 | 2475 | if (!empty($style_sheets)) |
2344 | 2476 | { |
2345 | - if (!is_array($style_sheets)) |
|
2346 | - $style_sheets = array($style_sheets); |
|
2477 | + if (!is_array($style_sheets)) { |
|
2478 | + $style_sheets = array($style_sheets); |
|
2479 | + } |
|
2347 | 2480 | |
2348 | - foreach ($style_sheets as $sheet) |
|
2349 | - loadCSSFile($sheet . '.css', array(), $sheet); |
|
2481 | + foreach ($style_sheets as $sheet) { |
|
2482 | + loadCSSFile($sheet . '.css', array(), $sheet); |
|
2483 | + } |
|
2350 | 2484 | } |
2351 | 2485 | |
2352 | 2486 | // No template to load? |
2353 | - if ($template_name === false) |
|
2354 | - return true; |
|
2487 | + if ($template_name === false) { |
|
2488 | + return true; |
|
2489 | + } |
|
2355 | 2490 | |
2356 | 2491 | $loaded = false; |
2357 | 2492 | foreach ($settings['template_dirs'] as $template_dir) |
@@ -2366,12 +2501,14 @@ discard block |
||
2366 | 2501 | |
2367 | 2502 | if ($loaded) |
2368 | 2503 | { |
2369 | - if ($db_show_debug === true) |
|
2370 | - $context['debug']['templates'][] = $template_name . ' (' . basename($template_dir) . ')'; |
|
2504 | + if ($db_show_debug === true) { |
|
2505 | + $context['debug']['templates'][] = $template_name . ' (' . basename($template_dir) . ')'; |
|
2506 | + } |
|
2371 | 2507 | |
2372 | 2508 | // If they have specified an initialization function for this template, go ahead and call it now. |
2373 | - if (function_exists('template_' . $template_name . '_init')) |
|
2374 | - call_user_func('template_' . $template_name . '_init'); |
|
2509 | + if (function_exists('template_' . $template_name . '_init')) { |
|
2510 | + call_user_func('template_' . $template_name . '_init'); |
|
2511 | + } |
|
2375 | 2512 | } |
2376 | 2513 | // Hmmm... doesn't exist?! I don't suppose the directory is wrong, is it? |
2377 | 2514 | elseif (!file_exists($settings['default_theme_dir']) && file_exists($boarddir . '/Themes/default')) |
@@ -2391,13 +2528,14 @@ discard block |
||
2391 | 2528 | loadTemplate($template_name); |
2392 | 2529 | } |
2393 | 2530 | // Cause an error otherwise. |
2394 | - elseif ($template_name != 'Errors' && $template_name != 'index' && $fatal) |
|
2395 | - fatal_lang_error('theme_template_error', 'template', array((string) $template_name)); |
|
2396 | - elseif ($fatal) |
|
2397 | - die(log_error(sprintf(isset($txt['theme_template_error']) ? $txt['theme_template_error'] : 'Unable to load Themes/default/%s.template.php!', (string) $template_name), 'template')); |
|
2398 | - else |
|
2399 | - return false; |
|
2400 | -} |
|
2531 | + elseif ($template_name != 'Errors' && $template_name != 'index' && $fatal) { |
|
2532 | + fatal_lang_error('theme_template_error', 'template', array((string) $template_name)); |
|
2533 | + } elseif ($fatal) { |
|
2534 | + die(log_error(sprintf(isset($txt['theme_template_error']) ? $txt['theme_template_error'] : 'Unable to load Themes/default/%s.template.php!', (string) $template_name), 'template')); |
|
2535 | + } else { |
|
2536 | + return false; |
|
2537 | + } |
|
2538 | + } |
|
2401 | 2539 | |
2402 | 2540 | /** |
2403 | 2541 | * Load a sub-template. |
@@ -2415,17 +2553,19 @@ discard block |
||
2415 | 2553 | { |
2416 | 2554 | global $context, $txt, $db_show_debug; |
2417 | 2555 | |
2418 | - if ($db_show_debug === true) |
|
2419 | - $context['debug']['sub_templates'][] = $sub_template_name; |
|
2556 | + if ($db_show_debug === true) { |
|
2557 | + $context['debug']['sub_templates'][] = $sub_template_name; |
|
2558 | + } |
|
2420 | 2559 | |
2421 | 2560 | // Figure out what the template function is named. |
2422 | 2561 | $theme_function = 'template_' . $sub_template_name; |
2423 | - if (function_exists($theme_function)) |
|
2424 | - $theme_function(); |
|
2425 | - elseif ($fatal === false) |
|
2426 | - fatal_lang_error('theme_template_error', 'template', array((string) $sub_template_name)); |
|
2427 | - elseif ($fatal !== 'ignore') |
|
2428 | - die(log_error(sprintf(isset($txt['theme_template_error']) ? $txt['theme_template_error'] : 'Unable to load the %s sub template!', (string) $sub_template_name), 'template')); |
|
2562 | + if (function_exists($theme_function)) { |
|
2563 | + $theme_function(); |
|
2564 | + } elseif ($fatal === false) { |
|
2565 | + fatal_lang_error('theme_template_error', 'template', array((string) $sub_template_name)); |
|
2566 | + } elseif ($fatal !== 'ignore') { |
|
2567 | + die(log_error(sprintf(isset($txt['theme_template_error']) ? $txt['theme_template_error'] : 'Unable to load the %s sub template!', (string) $sub_template_name), 'template')); |
|
2568 | + } |
|
2429 | 2569 | |
2430 | 2570 | // Are we showing debugging for templates? Just make sure not to do it before the doctype... |
2431 | 2571 | if (allowedTo('admin_forum') && isset($_REQUEST['debug']) && !in_array($sub_template_name, array('init', 'main_below')) && ob_get_length() > 0 && !isset($_REQUEST['xml'])) |
@@ -2462,8 +2602,9 @@ discard block |
||
2462 | 2602 | $params['validate'] = isset($params['validate']) ? $params['validate'] : true; |
2463 | 2603 | |
2464 | 2604 | // If this is an external file, automatically set this to false. |
2465 | - if (!empty($params['external'])) |
|
2466 | - $params['minimize'] = false; |
|
2605 | + if (!empty($params['external'])) { |
|
2606 | + $params['minimize'] = false; |
|
2607 | + } |
|
2467 | 2608 | |
2468 | 2609 | // Account for shorthand like admin.css?alp21 filenames |
2469 | 2610 | $has_seed = strpos($fileName, '.css?'); |
@@ -2480,13 +2621,10 @@ discard block |
||
2480 | 2621 | { |
2481 | 2622 | $fileUrl = $settings['default_theme_url'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']); |
2482 | 2623 | $filePath = $settings['default_theme_dir'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']); |
2624 | + } else { |
|
2625 | + $fileUrl = false; |
|
2483 | 2626 | } |
2484 | - |
|
2485 | - else |
|
2486 | - $fileUrl = false; |
|
2487 | - } |
|
2488 | - |
|
2489 | - else |
|
2627 | + } else |
|
2490 | 2628 | { |
2491 | 2629 | $fileUrl = $settings[$themeRef . '_url'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']); |
2492 | 2630 | $filePath = $settings[$themeRef . '_dir'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']); |
@@ -2501,12 +2639,14 @@ discard block |
||
2501 | 2639 | } |
2502 | 2640 | |
2503 | 2641 | // Add it to the array for use in the template |
2504 | - if (!empty($fileName)) |
|
2505 | - $context['css_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params); |
|
2642 | + if (!empty($fileName)) { |
|
2643 | + $context['css_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params); |
|
2644 | + } |
|
2506 | 2645 | |
2507 | - if (!empty($context['right_to_left']) && !empty($params['rtl'])) |
|
2508 | - loadCSSFile($params['rtl'], array_diff_key($params, array('rtl' => 0))); |
|
2509 | -} |
|
2646 | + if (!empty($context['right_to_left']) && !empty($params['rtl'])) { |
|
2647 | + loadCSSFile($params['rtl'], array_diff_key($params, array('rtl' => 0))); |
|
2648 | + } |
|
2649 | + } |
|
2510 | 2650 | |
2511 | 2651 | /** |
2512 | 2652 | * Add a block of inline css code to be executed later |
@@ -2523,8 +2663,9 @@ discard block |
||
2523 | 2663 | global $context; |
2524 | 2664 | |
2525 | 2665 | // Gotta add something... |
2526 | - if (empty($css)) |
|
2527 | - return false; |
|
2666 | + if (empty($css)) { |
|
2667 | + return false; |
|
2668 | + } |
|
2528 | 2669 | |
2529 | 2670 | $context['css_header'][] = $css; |
2530 | 2671 | } |
@@ -2559,8 +2700,9 @@ discard block |
||
2559 | 2700 | $params['validate'] = isset($params['validate']) ? $params['validate'] : true; |
2560 | 2701 | |
2561 | 2702 | // If this is an external file, automatically set this to false. |
2562 | - if (!empty($params['external'])) |
|
2563 | - $params['minimize'] = false; |
|
2703 | + if (!empty($params['external'])) { |
|
2704 | + $params['minimize'] = false; |
|
2705 | + } |
|
2564 | 2706 | |
2565 | 2707 | // Account for shorthand like admin.js?alp21 filenames |
2566 | 2708 | $has_seed = strpos($fileName, '.js?'); |
@@ -2577,16 +2719,12 @@ discard block |
||
2577 | 2719 | { |
2578 | 2720 | $fileUrl = $settings['default_theme_url'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']); |
2579 | 2721 | $filePath = $settings['default_theme_dir'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']); |
2580 | - } |
|
2581 | - |
|
2582 | - else |
|
2722 | + } else |
|
2583 | 2723 | { |
2584 | 2724 | $fileUrl = false; |
2585 | 2725 | $filePath = false; |
2586 | 2726 | } |
2587 | - } |
|
2588 | - |
|
2589 | - else |
|
2727 | + } else |
|
2590 | 2728 | { |
2591 | 2729 | $fileUrl = $settings[$themeRef . '_url'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']); |
2592 | 2730 | $filePath = $settings[$themeRef . '_dir'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']); |
@@ -2601,9 +2739,10 @@ discard block |
||
2601 | 2739 | } |
2602 | 2740 | |
2603 | 2741 | // Add it to the array for use in the template |
2604 | - if (!empty($fileName)) |
|
2605 | - $context['javascript_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params); |
|
2606 | -} |
|
2742 | + if (!empty($fileName)) { |
|
2743 | + $context['javascript_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params); |
|
2744 | + } |
|
2745 | + } |
|
2607 | 2746 | |
2608 | 2747 | /** |
2609 | 2748 | * Add a Javascript variable for output later (for feeding text strings and similar to JS) |
@@ -2617,9 +2756,10 @@ discard block |
||
2617 | 2756 | { |
2618 | 2757 | global $context; |
2619 | 2758 | |
2620 | - if (!empty($key) && (!empty($value) || $value === '0')) |
|
2621 | - $context['javascript_vars'][$key] = !empty($escape) ? JavaScriptEscape($value) : $value; |
|
2622 | -} |
|
2759 | + if (!empty($key) && (!empty($value) || $value === '0')) { |
|
2760 | + $context['javascript_vars'][$key] = !empty($escape) ? JavaScriptEscape($value) : $value; |
|
2761 | + } |
|
2762 | + } |
|
2623 | 2763 | |
2624 | 2764 | /** |
2625 | 2765 | * Add a block of inline Javascript code to be executed later |
@@ -2636,8 +2776,9 @@ discard block |
||
2636 | 2776 | { |
2637 | 2777 | global $context; |
2638 | 2778 | |
2639 | - if (empty($javascript)) |
|
2640 | - return false; |
|
2779 | + if (empty($javascript)) { |
|
2780 | + return false; |
|
2781 | + } |
|
2641 | 2782 | |
2642 | 2783 | $context['javascript_inline'][($defer === true ? 'defer' : 'standard')][] = $javascript; |
2643 | 2784 | } |
@@ -2658,15 +2799,18 @@ discard block |
||
2658 | 2799 | static $already_loaded = array(); |
2659 | 2800 | |
2660 | 2801 | // Default to the user's language. |
2661 | - if ($lang == '') |
|
2662 | - $lang = isset($user_info['language']) ? $user_info['language'] : $language; |
|
2802 | + if ($lang == '') { |
|
2803 | + $lang = isset($user_info['language']) ? $user_info['language'] : $language; |
|
2804 | + } |
|
2663 | 2805 | |
2664 | 2806 | // Do we want the English version of language file as fallback? |
2665 | - if (empty($modSettings['disable_language_fallback']) && $lang != 'english') |
|
2666 | - loadLanguage($template_name, 'english', false); |
|
2807 | + if (empty($modSettings['disable_language_fallback']) && $lang != 'english') { |
|
2808 | + loadLanguage($template_name, 'english', false); |
|
2809 | + } |
|
2667 | 2810 | |
2668 | - if (!$force_reload && isset($already_loaded[$template_name]) && $already_loaded[$template_name] == $lang) |
|
2669 | - return $lang; |
|
2811 | + if (!$force_reload && isset($already_loaded[$template_name]) && $already_loaded[$template_name] == $lang) { |
|
2812 | + return $lang; |
|
2813 | + } |
|
2670 | 2814 | |
2671 | 2815 | // Make sure we have $settings - if not we're in trouble and need to find it! |
2672 | 2816 | if (empty($settings['default_theme_dir'])) |
@@ -2677,8 +2821,9 @@ discard block |
||
2677 | 2821 | |
2678 | 2822 | // What theme are we in? |
2679 | 2823 | $theme_name = basename($settings['theme_url']); |
2680 | - if (empty($theme_name)) |
|
2681 | - $theme_name = 'unknown'; |
|
2824 | + if (empty($theme_name)) { |
|
2825 | + $theme_name = 'unknown'; |
|
2826 | + } |
|
2682 | 2827 | |
2683 | 2828 | // For each file open it up and write it out! |
2684 | 2829 | foreach (explode('+', $template_name) as $template) |
@@ -2720,8 +2865,9 @@ discard block |
||
2720 | 2865 | $found = true; |
2721 | 2866 | |
2722 | 2867 | // setlocale is required for basename() & pathinfo() to work properly on the selected language |
2723 | - if (!empty($txt['lang_locale']) && !empty($modSettings['global_character_set'])) |
|
2724 | - setlocale(LC_CTYPE, $txt['lang_locale'] . '.' . $modSettings['global_character_set']); |
|
2868 | + if (!empty($txt['lang_locale']) && !empty($modSettings['global_character_set'])) { |
|
2869 | + setlocale(LC_CTYPE, $txt['lang_locale'] . '.' . $modSettings['global_character_set']); |
|
2870 | + } |
|
2725 | 2871 | |
2726 | 2872 | break; |
2727 | 2873 | } |
@@ -2761,8 +2907,9 @@ discard block |
||
2761 | 2907 | } |
2762 | 2908 | |
2763 | 2909 | // Keep track of what we're up to soldier. |
2764 | - if ($db_show_debug === true) |
|
2765 | - $context['debug']['language_files'][] = $template_name . '.' . $lang . ' (' . $theme_name . ')'; |
|
2910 | + if ($db_show_debug === true) { |
|
2911 | + $context['debug']['language_files'][] = $template_name . '.' . $lang . ' (' . $theme_name . ')'; |
|
2912 | + } |
|
2766 | 2913 | |
2767 | 2914 | // Remember what we have loaded, and in which language. |
2768 | 2915 | $already_loaded[$template_name] = $lang; |
@@ -2808,8 +2955,9 @@ discard block |
||
2808 | 2955 | ) |
2809 | 2956 | ); |
2810 | 2957 | // In the EXTREMELY unlikely event this happens, give an error message. |
2811 | - if ($smcFunc['db_num_rows']($result) == 0) |
|
2812 | - fatal_lang_error('parent_not_found', 'critical'); |
|
2958 | + if ($smcFunc['db_num_rows']($result) == 0) { |
|
2959 | + fatal_lang_error('parent_not_found', 'critical'); |
|
2960 | + } |
|
2813 | 2961 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
2814 | 2962 | { |
2815 | 2963 | if (!isset($boards[$row['id_board']])) |
@@ -2826,8 +2974,8 @@ discard block |
||
2826 | 2974 | ); |
2827 | 2975 | } |
2828 | 2976 | // If a moderator exists for this board, add that moderator for all children too. |
2829 | - if (!empty($row['id_moderator'])) |
|
2830 | - foreach ($boards as $id => $dummy) |
|
2977 | + if (!empty($row['id_moderator'])) { |
|
2978 | + foreach ($boards as $id => $dummy) |
|
2831 | 2979 | { |
2832 | 2980 | $boards[$id]['moderators'][$row['id_moderator']] = array( |
2833 | 2981 | 'id' => $row['id_moderator'], |
@@ -2835,11 +2983,12 @@ discard block |
||
2835 | 2983 | 'href' => $scripturl . '?action=profile;u=' . $row['id_moderator'], |
2836 | 2984 | 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_moderator'] . '">' . $row['real_name'] . '</a>' |
2837 | 2985 | ); |
2986 | + } |
|
2838 | 2987 | } |
2839 | 2988 | |
2840 | 2989 | // If a moderator group exists for this board, add that moderator group for all children too |
2841 | - if (!empty($row['id_moderator_group'])) |
|
2842 | - foreach ($boards as $id => $dummy) |
|
2990 | + if (!empty($row['id_moderator_group'])) { |
|
2991 | + foreach ($boards as $id => $dummy) |
|
2843 | 2992 | { |
2844 | 2993 | $boards[$id]['moderator_groups'][$row['id_moderator_group']] = array( |
2845 | 2994 | 'id' => $row['id_moderator_group'], |
@@ -2847,6 +2996,7 @@ discard block |
||
2847 | 2996 | 'href' => $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'], |
2848 | 2997 | 'link' => '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'] . '">' . $row['group_name'] . '</a>' |
2849 | 2998 | ); |
2999 | + } |
|
2850 | 3000 | } |
2851 | 3001 | } |
2852 | 3002 | $smcFunc['db_free_result']($result); |
@@ -2873,23 +3023,27 @@ discard block |
||
2873 | 3023 | if (!$use_cache || ($context['languages'] = cache_get_data('known_languages', !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600)) == null) |
2874 | 3024 | { |
2875 | 3025 | // If we don't have our ucwords function defined yet, let's load the settings data. |
2876 | - if (empty($smcFunc['ucwords'])) |
|
2877 | - reloadSettings(); |
|
3026 | + if (empty($smcFunc['ucwords'])) { |
|
3027 | + reloadSettings(); |
|
3028 | + } |
|
2878 | 3029 | |
2879 | 3030 | // If we don't have our theme information yet, let's get it. |
2880 | - if (empty($settings['default_theme_dir'])) |
|
2881 | - loadTheme(0, false); |
|
3031 | + if (empty($settings['default_theme_dir'])) { |
|
3032 | + loadTheme(0, false); |
|
3033 | + } |
|
2882 | 3034 | |
2883 | 3035 | // Default language directories to try. |
2884 | 3036 | $language_directories = array( |
2885 | 3037 | $settings['default_theme_dir'] . '/languages', |
2886 | 3038 | ); |
2887 | - if (!empty($settings['actual_theme_dir']) && $settings['actual_theme_dir'] != $settings['default_theme_dir']) |
|
2888 | - $language_directories[] = $settings['actual_theme_dir'] . '/languages'; |
|
3039 | + if (!empty($settings['actual_theme_dir']) && $settings['actual_theme_dir'] != $settings['default_theme_dir']) { |
|
3040 | + $language_directories[] = $settings['actual_theme_dir'] . '/languages'; |
|
3041 | + } |
|
2889 | 3042 | |
2890 | 3043 | // We possibly have a base theme directory. |
2891 | - if (!empty($settings['base_theme_dir'])) |
|
2892 | - $language_directories[] = $settings['base_theme_dir'] . '/languages'; |
|
3044 | + if (!empty($settings['base_theme_dir'])) { |
|
3045 | + $language_directories[] = $settings['base_theme_dir'] . '/languages'; |
|
3046 | + } |
|
2893 | 3047 | |
2894 | 3048 | // Remove any duplicates. |
2895 | 3049 | $language_directories = array_unique($language_directories); |
@@ -2903,20 +3057,21 @@ discard block |
||
2903 | 3057 | foreach ($language_directories as $language_dir) |
2904 | 3058 | { |
2905 | 3059 | // Can't look in here... doesn't exist! |
2906 | - if (!file_exists($language_dir)) |
|
2907 | - continue; |
|
3060 | + if (!file_exists($language_dir)) { |
|
3061 | + continue; |
|
3062 | + } |
|
2908 | 3063 | |
2909 | 3064 | $dir = dir($language_dir); |
2910 | 3065 | while ($entry = $dir->read()) |
2911 | 3066 | { |
2912 | 3067 | // Look for the index language file... For good measure skip any "index.language-utf8.php" files |
2913 | - if (!preg_match('~^index\.(.+[^-utf8])\.php$~', $entry, $matches)) |
|
2914 | - continue; |
|
2915 | - |
|
2916 | - if (!empty($langList) && !empty($langList[$matches[1]])) |
|
2917 | - $langName = $langList[$matches[1]]; |
|
3068 | + if (!preg_match('~^index\.(.+[^-utf8])\.php$~', $entry, $matches)) { |
|
3069 | + continue; |
|
3070 | + } |
|
2918 | 3071 | |
2919 | - else |
|
3072 | + if (!empty($langList) && !empty($langList[$matches[1]])) { |
|
3073 | + $langName = $langList[$matches[1]]; |
|
3074 | + } else |
|
2920 | 3075 | { |
2921 | 3076 | $langName = $smcFunc['ucwords'](strtr($matches[1], array('_' => ' '))); |
2922 | 3077 | |
@@ -2957,12 +3112,14 @@ discard block |
||
2957 | 3112 | } |
2958 | 3113 | |
2959 | 3114 | // Do we need to store the lang list? |
2960 | - if (empty($langList)) |
|
2961 | - updateSettings(array('langList' => $smcFunc['json_encode']($catchLang))); |
|
3115 | + if (empty($langList)) { |
|
3116 | + updateSettings(array('langList' => $smcFunc['json_encode']($catchLang))); |
|
3117 | + } |
|
2962 | 3118 | |
2963 | 3119 | // Let's cash in on this deal. |
2964 | - if (!empty($modSettings['cache_enable'])) |
|
2965 | - cache_put_data('known_languages', $context['languages'], !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600); |
|
3120 | + if (!empty($modSettings['cache_enable'])) { |
|
3121 | + cache_put_data('known_languages', $context['languages'], !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600); |
|
3122 | + } |
|
2966 | 3123 | } |
2967 | 3124 | |
2968 | 3125 | return $context['languages']; |
@@ -2985,8 +3142,9 @@ discard block |
||
2985 | 3142 | global $modSettings, $options, $txt; |
2986 | 3143 | static $censor_vulgar = null, $censor_proper; |
2987 | 3144 | |
2988 | - if ((!empty($options['show_no_censored']) && !empty($modSettings['allow_no_censored']) && !$force) || empty($modSettings['censor_vulgar']) || trim($text) === '') |
|
2989 | - return $text; |
|
3145 | + if ((!empty($options['show_no_censored']) && !empty($modSettings['allow_no_censored']) && !$force) || empty($modSettings['censor_vulgar']) || trim($text) === '') { |
|
3146 | + return $text; |
|
3147 | + } |
|
2990 | 3148 | |
2991 | 3149 | // If they haven't yet been loaded, load them. |
2992 | 3150 | if ($censor_vulgar == null) |
@@ -3014,9 +3172,9 @@ discard block |
||
3014 | 3172 | { |
3015 | 3173 | $func = !empty($modSettings['censorIgnoreCase']) ? 'str_ireplace' : 'str_replace'; |
3016 | 3174 | $text = $func($censor_vulgar, $censor_proper, $text); |
3175 | + } else { |
|
3176 | + $text = preg_replace($censor_vulgar, $censor_proper, $text); |
|
3017 | 3177 | } |
3018 | - else |
|
3019 | - $text = preg_replace($censor_vulgar, $censor_proper, $text); |
|
3020 | 3178 | |
3021 | 3179 | return $text; |
3022 | 3180 | } |
@@ -3042,38 +3200,42 @@ discard block |
||
3042 | 3200 | @ini_set('track_errors', '1'); |
3043 | 3201 | |
3044 | 3202 | // Don't include the file more than once, if $once is true. |
3045 | - if ($once && in_array($filename, $templates)) |
|
3046 | - return; |
|
3203 | + if ($once && in_array($filename, $templates)) { |
|
3204 | + return; |
|
3205 | + } |
|
3047 | 3206 | // Add this file to the include list, whether $once is true or not. |
3048 | - else |
|
3049 | - $templates[] = $filename; |
|
3207 | + else { |
|
3208 | + $templates[] = $filename; |
|
3209 | + } |
|
3050 | 3210 | |
3051 | 3211 | // Are we going to use eval? |
3052 | 3212 | if (empty($modSettings['disableTemplateEval'])) |
3053 | 3213 | { |
3054 | 3214 | $file_found = file_exists($filename) && eval('?' . '>' . rtrim(file_get_contents($filename))) !== false; |
3055 | 3215 | $settings['current_include_filename'] = $filename; |
3056 | - } |
|
3057 | - else |
|
3216 | + } else |
|
3058 | 3217 | { |
3059 | 3218 | $file_found = file_exists($filename); |
3060 | 3219 | |
3061 | - if ($once && $file_found) |
|
3062 | - require_once($filename); |
|
3063 | - elseif ($file_found) |
|
3064 | - require($filename); |
|
3220 | + if ($once && $file_found) { |
|
3221 | + require_once($filename); |
|
3222 | + } elseif ($file_found) { |
|
3223 | + require($filename); |
|
3224 | + } |
|
3065 | 3225 | } |
3066 | 3226 | |
3067 | 3227 | if ($file_found !== true) |
3068 | 3228 | { |
3069 | 3229 | ob_end_clean(); |
3070 | - if (!empty($modSettings['enableCompressedOutput'])) |
|
3071 | - @ob_start('ob_gzhandler'); |
|
3072 | - else |
|
3073 | - ob_start(); |
|
3230 | + if (!empty($modSettings['enableCompressedOutput'])) { |
|
3231 | + @ob_start('ob_gzhandler'); |
|
3232 | + } else { |
|
3233 | + ob_start(); |
|
3234 | + } |
|
3074 | 3235 | |
3075 | - if (isset($_GET['debug'])) |
|
3076 | - header('Content-Type: application/xhtml+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
3236 | + if (isset($_GET['debug'])) { |
|
3237 | + header('Content-Type: application/xhtml+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
3238 | + } |
|
3077 | 3239 | |
3078 | 3240 | // Don't cache error pages!! |
3079 | 3241 | header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); |
@@ -3092,12 +3254,13 @@ discard block |
||
3092 | 3254 | echo '<!DOCTYPE html> |
3093 | 3255 | <html', !empty($context['right_to_left']) ? ' dir="rtl"' : '', '> |
3094 | 3256 | <head>'; |
3095 | - if (isset($context['character_set'])) |
|
3096 | - echo ' |
|
3257 | + if (isset($context['character_set'])) { |
|
3258 | + echo ' |
|
3097 | 3259 | <meta charset="', $context['character_set'], '">'; |
3260 | + } |
|
3098 | 3261 | |
3099 | - if (!empty($maintenance) && !allowedTo('admin_forum')) |
|
3100 | - echo ' |
|
3262 | + if (!empty($maintenance) && !allowedTo('admin_forum')) { |
|
3263 | + echo ' |
|
3101 | 3264 | <title>', $mtitle, '</title> |
3102 | 3265 | </head> |
3103 | 3266 | <body> |
@@ -3105,8 +3268,8 @@ discard block |
||
3105 | 3268 | ', $mmessage, ' |
3106 | 3269 | </body> |
3107 | 3270 | </html>'; |
3108 | - elseif (!allowedTo('admin_forum')) |
|
3109 | - echo ' |
|
3271 | + } elseif (!allowedTo('admin_forum')) { |
|
3272 | + echo ' |
|
3110 | 3273 | <title>', $txt['template_parse_error'], '</title> |
3111 | 3274 | </head> |
3112 | 3275 | <body> |
@@ -3114,16 +3277,18 @@ discard block |
||
3114 | 3277 | ', $txt['template_parse_error_message'], ' |
3115 | 3278 | </body> |
3116 | 3279 | </html>'; |
3117 | - else |
|
3280 | + } else |
|
3118 | 3281 | { |
3119 | 3282 | require_once($sourcedir . '/Subs-Package.php'); |
3120 | 3283 | |
3121 | 3284 | $error = fetch_web_data($boardurl . strtr($filename, array($boarddir => '', strtr($boarddir, '\\', '/') => ''))); |
3122 | 3285 | $error_array = error_get_last(); |
3123 | - if (empty($error) && ini_get('track_errors') && !empty($error_array)) |
|
3124 | - $error = $error_array['message']; |
|
3125 | - if (empty($error)) |
|
3126 | - $error = $txt['template_parse_errmsg']; |
|
3286 | + if (empty($error) && ini_get('track_errors') && !empty($error_array)) { |
|
3287 | + $error = $error_array['message']; |
|
3288 | + } |
|
3289 | + if (empty($error)) { |
|
3290 | + $error = $txt['template_parse_errmsg']; |
|
3291 | + } |
|
3127 | 3292 | |
3128 | 3293 | $error = strtr($error, array('<b>' => '<strong>', '</b>' => '</strong>')); |
3129 | 3294 | |
@@ -3134,11 +3299,12 @@ discard block |
||
3134 | 3299 | <h3>', $txt['template_parse_error'], '</h3> |
3135 | 3300 | ', sprintf($txt['template_parse_error_details'], strtr($filename, array($boarddir => '', strtr($boarddir, '\\', '/') => ''))); |
3136 | 3301 | |
3137 | - if (!empty($error)) |
|
3138 | - echo ' |
|
3302 | + if (!empty($error)) { |
|
3303 | + echo ' |
|
3139 | 3304 | <hr> |
3140 | 3305 | |
3141 | 3306 | <div style="margin: 0 20px;"><pre>', strtr(strtr($error, array('<strong>' . $boarddir => '<strong>...', '<strong>' . strtr($boarddir, '\\', '/') => '<strong>...')), '\\', '/'), '</pre></div>'; |
3307 | + } |
|
3142 | 3308 | |
3143 | 3309 | // I know, I know... this is VERY COMPLICATED. Still, it's good. |
3144 | 3310 | if (preg_match('~ <strong>(\d+)</strong><br( /)?' . '>$~i', $error, $match) != 0) |
@@ -3148,10 +3314,11 @@ discard block |
||
3148 | 3314 | $data2 = preg_split('~\<br( /)?\>~', $data2); |
3149 | 3315 | |
3150 | 3316 | // Fix the PHP code stuff... |
3151 | - if (!isBrowser('gecko')) |
|
3152 | - $data2 = str_replace("\t", '<span style="white-space: pre;">' . "\t" . '</span>', $data2); |
|
3153 | - else |
|
3154 | - $data2 = str_replace('<pre style="display: inline;">' . "\t" . '</pre>', "\t", $data2); |
|
3317 | + if (!isBrowser('gecko')) { |
|
3318 | + $data2 = str_replace("\t", '<span style="white-space: pre;">' . "\t" . '</span>', $data2); |
|
3319 | + } else { |
|
3320 | + $data2 = str_replace('<pre style="display: inline;">' . "\t" . '</pre>', "\t", $data2); |
|
3321 | + } |
|
3155 | 3322 | |
3156 | 3323 | // Now we get to work around a bug in PHP where it doesn't escape <br>s! |
3157 | 3324 | $j = -1; |
@@ -3159,8 +3326,9 @@ discard block |
||
3159 | 3326 | { |
3160 | 3327 | $j++; |
3161 | 3328 | |
3162 | - if (substr_count($line, '<br>') == 0) |
|
3163 | - continue; |
|
3329 | + if (substr_count($line, '<br>') == 0) { |
|
3330 | + continue; |
|
3331 | + } |
|
3164 | 3332 | |
3165 | 3333 | $n = substr_count($line, '<br>'); |
3166 | 3334 | for ($i = 0; $i < $n; $i++) |
@@ -3179,38 +3347,42 @@ discard block |
||
3179 | 3347 | // Figure out what the color coding was before... |
3180 | 3348 | $line = max($match[1] - 9, 1); |
3181 | 3349 | $last_line = ''; |
3182 | - for ($line2 = $line - 1; $line2 > 1; $line2--) |
|
3183 | - if (strpos($data2[$line2], '<') !== false) |
|
3350 | + for ($line2 = $line - 1; $line2 > 1; $line2--) { |
|
3351 | + if (strpos($data2[$line2], '<') !== false) |
|
3184 | 3352 | { |
3185 | 3353 | if (preg_match('~(<[^/>]+>)[^<]*$~', $data2[$line2], $color_match) != 0) |
3186 | 3354 | $last_line = $color_match[1]; |
3355 | + } |
|
3187 | 3356 | break; |
3188 | 3357 | } |
3189 | 3358 | |
3190 | 3359 | // Show the relevant lines... |
3191 | 3360 | for ($n = min($match[1] + 4, count($data2) + 1); $line <= $n; $line++) |
3192 | 3361 | { |
3193 | - if ($line == $match[1]) |
|
3194 | - echo '</pre><div style="background-color: #ffb0b5;"><pre style="margin: 0;">'; |
|
3362 | + if ($line == $match[1]) { |
|
3363 | + echo '</pre><div style="background-color: #ffb0b5;"><pre style="margin: 0;">'; |
|
3364 | + } |
|
3195 | 3365 | |
3196 | 3366 | echo '<span style="color: black;">', sprintf('%' . strlen($n) . 's', $line), ':</span> '; |
3197 | - if (isset($data2[$line]) && $data2[$line] != '') |
|
3198 | - echo substr($data2[$line], 0, 2) == '</' ? preg_replace('~^</[^>]+>~', '', $data2[$line]) : $last_line . $data2[$line]; |
|
3367 | + if (isset($data2[$line]) && $data2[$line] != '') { |
|
3368 | + echo substr($data2[$line], 0, 2) == '</' ? preg_replace('~^</[^>]+>~', '', $data2[$line]) : $last_line . $data2[$line]; |
|
3369 | + } |
|
3199 | 3370 | |
3200 | 3371 | if (isset($data2[$line]) && preg_match('~(<[^/>]+>)[^<]*$~', $data2[$line], $color_match) != 0) |
3201 | 3372 | { |
3202 | 3373 | $last_line = $color_match[1]; |
3203 | 3374 | echo '</', substr($last_line, 1, 4), '>'; |
3375 | + } elseif ($last_line != '' && strpos($data2[$line], '<') !== false) { |
|
3376 | + $last_line = ''; |
|
3377 | + } elseif ($last_line != '' && $data2[$line] != '') { |
|
3378 | + echo '</', substr($last_line, 1, 4), '>'; |
|
3204 | 3379 | } |
3205 | - elseif ($last_line != '' && strpos($data2[$line], '<') !== false) |
|
3206 | - $last_line = ''; |
|
3207 | - elseif ($last_line != '' && $data2[$line] != '') |
|
3208 | - echo '</', substr($last_line, 1, 4), '>'; |
|
3209 | 3380 | |
3210 | - if ($line == $match[1]) |
|
3211 | - echo '</pre></div><pre style="margin: 0;">'; |
|
3212 | - else |
|
3213 | - echo "\n"; |
|
3381 | + if ($line == $match[1]) { |
|
3382 | + echo '</pre></div><pre style="margin: 0;">'; |
|
3383 | + } else { |
|
3384 | + echo "\n"; |
|
3385 | + } |
|
3214 | 3386 | } |
3215 | 3387 | |
3216 | 3388 | echo '</pre></div>'; |
@@ -3234,8 +3406,9 @@ discard block |
||
3234 | 3406 | global $db_type, $db_name, $ssi_db_user, $ssi_db_passwd, $sourcedir, $db_prefix, $db_port; |
3235 | 3407 | |
3236 | 3408 | // Figure out what type of database we are using. |
3237 | - if (empty($db_type) || !file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php')) |
|
3238 | - $db_type = 'mysql'; |
|
3409 | + if (empty($db_type) || !file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php')) { |
|
3410 | + $db_type = 'mysql'; |
|
3411 | + } |
|
3239 | 3412 | |
3240 | 3413 | // Load the file for the database. |
3241 | 3414 | require_once($sourcedir . '/Subs-Db-' . $db_type . '.php'); |
@@ -3243,8 +3416,9 @@ discard block |
||
3243 | 3416 | $db_options = array(); |
3244 | 3417 | |
3245 | 3418 | // Add in the port if needed |
3246 | - if (!empty($db_port)) |
|
3247 | - $db_options['port'] = $db_port; |
|
3419 | + if (!empty($db_port)) { |
|
3420 | + $db_options['port'] = $db_port; |
|
3421 | + } |
|
3248 | 3422 | |
3249 | 3423 | // If we are in SSI try them first, but don't worry if it doesn't work, we have the normal username and password we can use. |
3250 | 3424 | if (SMF == 'SSI' && !empty($ssi_db_user) && !empty($ssi_db_passwd)) |
@@ -3263,13 +3437,15 @@ discard block |
||
3263 | 3437 | } |
3264 | 3438 | |
3265 | 3439 | // Safe guard here, if there isn't a valid connection lets put a stop to it. |
3266 | - if (!$db_connection) |
|
3267 | - display_db_error(); |
|
3440 | + if (!$db_connection) { |
|
3441 | + display_db_error(); |
|
3442 | + } |
|
3268 | 3443 | |
3269 | 3444 | // If in SSI mode fix up the prefix. |
3270 | - if (SMF == 'SSI') |
|
3271 | - db_fix_prefix($db_prefix, $db_name); |
|
3272 | -} |
|
3445 | + if (SMF == 'SSI') { |
|
3446 | + db_fix_prefix($db_prefix, $db_name); |
|
3447 | + } |
|
3448 | + } |
|
3273 | 3449 | |
3274 | 3450 | /** |
3275 | 3451 | * Try to load up a supported caching method. This is saved in $cacheAPI if we are not overriding it. |
@@ -3283,10 +3459,11 @@ discard block |
||
3283 | 3459 | global $sourcedir, $cacheAPI, $cache_accelerator; |
3284 | 3460 | |
3285 | 3461 | // Not overriding this and we have a cacheAPI, send it back. |
3286 | - if (empty($overrideCache) && is_object($cacheAPI)) |
|
3287 | - return $cacheAPI; |
|
3288 | - elseif (is_null($cacheAPI)) |
|
3289 | - $cacheAPI = false; |
|
3462 | + if (empty($overrideCache) && is_object($cacheAPI)) { |
|
3463 | + return $cacheAPI; |
|
3464 | + } elseif (is_null($cacheAPI)) { |
|
3465 | + $cacheAPI = false; |
|
3466 | + } |
|
3290 | 3467 | |
3291 | 3468 | // Make sure our class is in session. |
3292 | 3469 | require_once($sourcedir . '/Class-CacheAPI.php'); |
@@ -3307,8 +3484,9 @@ discard block |
||
3307 | 3484 | if (!$testAPI->isSupported()) |
3308 | 3485 | { |
3309 | 3486 | // Can we save ourselves? |
3310 | - if (!empty($fallbackSMF) && is_null($overrideCache) && $tryAccelerator != 'smf') |
|
3311 | - return loadCacheAccelerator(null, false); |
|
3487 | + if (!empty($fallbackSMF) && is_null($overrideCache) && $tryAccelerator != 'smf') { |
|
3488 | + return loadCacheAccelerator(null, false); |
|
3489 | + } |
|
3312 | 3490 | return false; |
3313 | 3491 | } |
3314 | 3492 | |
@@ -3320,9 +3498,9 @@ discard block |
||
3320 | 3498 | { |
3321 | 3499 | $cacheAPI = $testAPI; |
3322 | 3500 | return $cacheAPI; |
3501 | + } else { |
|
3502 | + return $testAPI; |
|
3323 | 3503 | } |
3324 | - else |
|
3325 | - return $testAPI; |
|
3326 | 3504 | } |
3327 | 3505 | } |
3328 | 3506 | |
@@ -3342,8 +3520,9 @@ discard block |
||
3342 | 3520 | |
3343 | 3521 | // @todo Why are we doing this if caching is disabled? |
3344 | 3522 | |
3345 | - if (function_exists('call_integration_hook')) |
|
3346 | - call_integration_hook('pre_cache_quick_get', array(&$key, &$file, &$function, &$params, &$level)); |
|
3523 | + if (function_exists('call_integration_hook')) { |
|
3524 | + call_integration_hook('pre_cache_quick_get', array(&$key, &$file, &$function, &$params, &$level)); |
|
3525 | + } |
|
3347 | 3526 | |
3348 | 3527 | /* Refresh the cache if either: |
3349 | 3528 | 1. Caching is disabled. |
@@ -3357,16 +3536,19 @@ discard block |
||
3357 | 3536 | require_once($sourcedir . '/' . $file); |
3358 | 3537 | $cache_block = call_user_func_array($function, $params); |
3359 | 3538 | |
3360 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= $level) |
|
3361 | - cache_put_data($key, $cache_block, $cache_block['expires'] - time()); |
|
3539 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= $level) { |
|
3540 | + cache_put_data($key, $cache_block, $cache_block['expires'] - time()); |
|
3541 | + } |
|
3362 | 3542 | } |
3363 | 3543 | |
3364 | 3544 | // Some cached data may need a freshening up after retrieval. |
3365 | - if (!empty($cache_block['post_retri_eval'])) |
|
3366 | - eval($cache_block['post_retri_eval']); |
|
3545 | + if (!empty($cache_block['post_retri_eval'])) { |
|
3546 | + eval($cache_block['post_retri_eval']); |
|
3547 | + } |
|
3367 | 3548 | |
3368 | - if (function_exists('call_integration_hook')) |
|
3369 | - call_integration_hook('post_cache_quick_get', array(&$cache_block)); |
|
3549 | + if (function_exists('call_integration_hook')) { |
|
3550 | + call_integration_hook('post_cache_quick_get', array(&$cache_block)); |
|
3551 | + } |
|
3370 | 3552 | |
3371 | 3553 | return $cache_block['data']; |
3372 | 3554 | } |
@@ -3393,8 +3575,9 @@ discard block |
||
3393 | 3575 | global $smcFunc, $cache_enable, $cacheAPI; |
3394 | 3576 | global $cache_hits, $cache_count, $db_show_debug; |
3395 | 3577 | |
3396 | - if (empty($cache_enable) || empty($cacheAPI)) |
|
3397 | - return; |
|
3578 | + if (empty($cache_enable) || empty($cacheAPI)) { |
|
3579 | + return; |
|
3580 | + } |
|
3398 | 3581 | |
3399 | 3582 | $cache_count = isset($cache_count) ? $cache_count + 1 : 1; |
3400 | 3583 | if (isset($db_show_debug) && $db_show_debug === true) |
@@ -3407,12 +3590,14 @@ discard block |
||
3407 | 3590 | $value = $value === null ? null : (isset($smcFunc['json_encode']) ? $smcFunc['json_encode']($value) : json_encode($value)); |
3408 | 3591 | $cacheAPI->putData($key, $value, $ttl); |
3409 | 3592 | |
3410 | - if (function_exists('call_integration_hook')) |
|
3411 | - call_integration_hook('cache_put_data', array(&$key, &$value, &$ttl)); |
|
3593 | + if (function_exists('call_integration_hook')) { |
|
3594 | + call_integration_hook('cache_put_data', array(&$key, &$value, &$ttl)); |
|
3595 | + } |
|
3412 | 3596 | |
3413 | - if (isset($db_show_debug) && $db_show_debug === true) |
|
3414 | - $cache_hits[$cache_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st)); |
|
3415 | -} |
|
3597 | + if (isset($db_show_debug) && $db_show_debug === true) { |
|
3598 | + $cache_hits[$cache_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st)); |
|
3599 | + } |
|
3600 | + } |
|
3416 | 3601 | |
3417 | 3602 | /** |
3418 | 3603 | * Gets the value from the cache specified by key, so long as it is not older than ttl seconds. |
@@ -3428,8 +3613,9 @@ discard block |
||
3428 | 3613 | global $smcFunc, $cache_enable, $cacheAPI; |
3429 | 3614 | global $cache_hits, $cache_count, $cache_misses, $cache_count_misses, $db_show_debug; |
3430 | 3615 | |
3431 | - if (empty($cache_enable) || empty($cacheAPI)) |
|
3432 | - return; |
|
3616 | + if (empty($cache_enable) || empty($cacheAPI)) { |
|
3617 | + return; |
|
3618 | + } |
|
3433 | 3619 | |
3434 | 3620 | $cache_count = isset($cache_count) ? $cache_count + 1 : 1; |
3435 | 3621 | if (isset($db_show_debug) && $db_show_debug === true) |
@@ -3449,16 +3635,18 @@ discard block |
||
3449 | 3635 | |
3450 | 3636 | if (empty($value)) |
3451 | 3637 | { |
3452 | - if (!is_array($cache_misses)) |
|
3453 | - $cache_misses = array(); |
|
3638 | + if (!is_array($cache_misses)) { |
|
3639 | + $cache_misses = array(); |
|
3640 | + } |
|
3454 | 3641 | |
3455 | 3642 | $cache_count_misses = isset($cache_count_misses) ? $cache_count_misses + 1 : 1; |
3456 | 3643 | $cache_misses[$cache_count_misses] = array('k' => $original_key, 'd' => 'get'); |
3457 | 3644 | } |
3458 | 3645 | } |
3459 | 3646 | |
3460 | - if (function_exists('call_integration_hook') && isset($value)) |
|
3461 | - call_integration_hook('cache_get_data', array(&$key, &$ttl, &$value)); |
|
3647 | + if (function_exists('call_integration_hook') && isset($value)) { |
|
3648 | + call_integration_hook('cache_get_data', array(&$key, &$ttl, &$value)); |
|
3649 | + } |
|
3462 | 3650 | |
3463 | 3651 | return empty($value) ? null : (isset($smcFunc['json_encode']) ? $smcFunc['json_decode']($value, true) : smf_json_decode($value, true)); |
3464 | 3652 | } |
@@ -3480,8 +3668,9 @@ discard block |
||
3480 | 3668 | global $cacheAPI; |
3481 | 3669 | |
3482 | 3670 | // If we can't get to the API, can't do this. |
3483 | - if (empty($cacheAPI)) |
|
3484 | - return; |
|
3671 | + if (empty($cacheAPI)) { |
|
3672 | + return; |
|
3673 | + } |
|
3485 | 3674 | |
3486 | 3675 | // Ask the API to do the heavy lifting. cleanCache also calls invalidateCache to be sure. |
3487 | 3676 | $cacheAPI->cleanCache($type); |
@@ -3506,8 +3695,9 @@ discard block |
||
3506 | 3695 | global $modSettings, $boardurl, $smcFunc, $image_proxy_enabled, $image_proxy_secret, $user_info; |
3507 | 3696 | |
3508 | 3697 | // Come on! |
3509 | - if (empty($data)) |
|
3510 | - return array(); |
|
3698 | + if (empty($data)) { |
|
3699 | + return array(); |
|
3700 | + } |
|
3511 | 3701 | |
3512 | 3702 | // Set a nice default var. |
3513 | 3703 | $image = ''; |
@@ -3515,11 +3705,11 @@ discard block |
||
3515 | 3705 | // Gravatar has been set as mandatory! |
3516 | 3706 | if (!empty($modSettings['gravatarOverride'])) |
3517 | 3707 | { |
3518 | - if (!empty($modSettings['gravatarAllowExtraEmail']) && !empty($data['avatar']) && stristr($data['avatar'], 'gravatar://')) |
|
3519 | - $image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11)); |
|
3520 | - |
|
3521 | - else if (!empty($data['email'])) |
|
3522 | - $image = get_gravatar_url($data['email']); |
|
3708 | + if (!empty($modSettings['gravatarAllowExtraEmail']) && !empty($data['avatar']) && stristr($data['avatar'], 'gravatar://')) { |
|
3709 | + $image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11)); |
|
3710 | + } else if (!empty($data['email'])) { |
|
3711 | + $image = get_gravatar_url($data['email']); |
|
3712 | + } |
|
3523 | 3713 | } |
3524 | 3714 | |
3525 | 3715 | // Look if the user has a gravatar field or has set an external url as avatar. |
@@ -3531,54 +3721,60 @@ discard block |
||
3531 | 3721 | // Gravatar. |
3532 | 3722 | if (stristr($data['avatar'], 'gravatar://')) |
3533 | 3723 | { |
3534 | - if ($data['avatar'] == 'gravatar://') |
|
3535 | - $image = get_gravatar_url($data['email']); |
|
3536 | - |
|
3537 | - elseif (!empty($modSettings['gravatarAllowExtraEmail'])) |
|
3538 | - $image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11)); |
|
3724 | + if ($data['avatar'] == 'gravatar://') { |
|
3725 | + $image = get_gravatar_url($data['email']); |
|
3726 | + } elseif (!empty($modSettings['gravatarAllowExtraEmail'])) { |
|
3727 | + $image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11)); |
|
3728 | + } |
|
3539 | 3729 | } |
3540 | 3730 | |
3541 | 3731 | // External url. |
3542 | 3732 | else |
3543 | 3733 | { |
3544 | 3734 | // Using ssl? |
3545 | - if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($data['avatar'], 'http://') !== false && empty($user_info['possibly_robot'])) |
|
3546 | - $image = strtr($boardurl, array('http://' => 'https://')) . '/proxy.php?request=' . urlencode($data['avatar']) . '&hash=' . md5($data['avatar'] . $image_proxy_secret); |
|
3735 | + if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($data['avatar'], 'http://') !== false && empty($user_info['possibly_robot'])) { |
|
3736 | + $image = strtr($boardurl, array('http://' => 'https://')) . '/proxy.php?request=' . urlencode($data['avatar']) . '&hash=' . md5($data['avatar'] . $image_proxy_secret); |
|
3737 | + } |
|
3547 | 3738 | |
3548 | 3739 | // Just a plain external url. |
3549 | - else |
|
3550 | - $image = (stristr($data['avatar'], 'http://') || stristr($data['avatar'], 'https://')) ? $data['avatar'] : $modSettings['avatar_url'] . '/' . $data['avatar']; |
|
3740 | + else { |
|
3741 | + $image = (stristr($data['avatar'], 'http://') || stristr($data['avatar'], 'https://')) ? $data['avatar'] : $modSettings['avatar_url'] . '/' . $data['avatar']; |
|
3742 | + } |
|
3551 | 3743 | } |
3552 | 3744 | } |
3553 | 3745 | |
3554 | 3746 | // Perhaps this user has an attachment as avatar... |
3555 | - else if (!empty($data['filename'])) |
|
3556 | - $image = $modSettings['custom_avatar_url'] . '/' . $data['filename']; |
|
3747 | + else if (!empty($data['filename'])) { |
|
3748 | + $image = $modSettings['custom_avatar_url'] . '/' . $data['filename']; |
|
3749 | + } |
|
3557 | 3750 | |
3558 | 3751 | // Right... no avatar... use our default image. |
3559 | - else |
|
3560 | - $image = $modSettings['avatar_url'] . '/default.png'; |
|
3752 | + else { |
|
3753 | + $image = $modSettings['avatar_url'] . '/default.png'; |
|
3754 | + } |
|
3561 | 3755 | } |
3562 | 3756 | |
3563 | 3757 | call_integration_hook('integrate_set_avatar_data', array(&$image, &$data)); |
3564 | 3758 | |
3565 | 3759 | // At this point in time $image has to be filled unless you chose to force gravatar and the user doesn't have the needed data to retrieve it... thus a check for !empty() is still needed. |
3566 | - if (!empty($image)) |
|
3567 | - return array( |
|
3760 | + if (!empty($image)) { |
|
3761 | + return array( |
|
3568 | 3762 | 'name' => !empty($data['avatar']) ? $data['avatar'] : '', |
3569 | 3763 | 'image' => '<img class="avatar" src="' . $image . '" />', |
3570 | 3764 | 'href' => $image, |
3571 | 3765 | 'url' => $image, |
3572 | 3766 | ); |
3767 | + } |
|
3573 | 3768 | |
3574 | 3769 | // Fallback to make life easier for everyone... |
3575 | - else |
|
3576 | - return array( |
|
3770 | + else { |
|
3771 | + return array( |
|
3577 | 3772 | 'name' => '', |
3578 | 3773 | 'image' => '', |
3579 | 3774 | 'href' => '', |
3580 | 3775 | 'url' => '', |
3581 | 3776 | ); |
3582 | -} |
|
3777 | + } |
|
3778 | + } |
|
3583 | 3779 | |
3584 | 3780 | ?> |
3585 | 3781 | \ No newline at end of file |
@@ -500,7 +500,7 @@ discard block |
||
500 | 500 | /** |
501 | 501 | * Returns the amount of affected rows for a query. |
502 | 502 | * |
503 | - * @param mixed $result |
|
503 | + * @param resource|null $result |
|
504 | 504 | * |
505 | 505 | * @return int |
506 | 506 | * |
@@ -869,7 +869,7 @@ discard block |
||
869 | 869 | * |
870 | 870 | * @param string $db_name The database name |
871 | 871 | * @param resource $db_connection The database connection |
872 | - * @return true Always returns true |
|
872 | + * @return boolean Always returns true |
|
873 | 873 | */ |
874 | 874 | function smf_db_select_db($db_name, $db_connection) |
875 | 875 | { |
@@ -199,22 +199,22 @@ discard block |
||
199 | 199 | |
200 | 200 | case 'date': |
201 | 201 | if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d)$~', $replacement, $date_matches) === 1) |
202 | - return sprintf('\'%04d-%02d-%02d\'', $date_matches[1], $date_matches[2], $date_matches[3]).'::date'; |
|
202 | + return sprintf('\'%04d-%02d-%02d\'', $date_matches[1], $date_matches[2], $date_matches[3]) . '::date'; |
|
203 | 203 | else |
204 | 204 | smf_db_error_backtrace('Wrong value type sent to the database. Date expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
205 | 205 | break; |
206 | 206 | |
207 | 207 | case 'time': |
208 | 208 | if (preg_match('~^([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $time_matches) === 1) |
209 | - return sprintf('\'%02d:%02d:%02d\'', $time_matches[1], $time_matches[2], $time_matches[3]).'::time'; |
|
209 | + return sprintf('\'%02d:%02d:%02d\'', $time_matches[1], $time_matches[2], $time_matches[3]) . '::time'; |
|
210 | 210 | else |
211 | 211 | smf_db_error_backtrace('Wrong value type sent to the database. Time expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
212 | 212 | break; |
213 | 213 | |
214 | 214 | case 'datetime': |
215 | 215 | if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d) ([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $datetime_matches) === 1) |
216 | - return 'to_timestamp('. |
|
217 | - sprintf('\'%04d-%02d-%02d %02d:%02d:%02d\'', $datetime_matches[1], $datetime_matches[2], $datetime_matches[3], $datetime_matches[4], $datetime_matches[5] ,$datetime_matches[6]). |
|
216 | + return 'to_timestamp(' . |
|
217 | + sprintf('\'%04d-%02d-%02d %02d:%02d:%02d\'', $datetime_matches[1], $datetime_matches[2], $datetime_matches[3], $datetime_matches[4], $datetime_matches[5], $datetime_matches[6]) . |
|
218 | 218 | ',\'YYYY-MM-DD HH24:MI:SS\')'; |
219 | 219 | else |
220 | 220 | smf_db_error_backtrace('Wrong value type sent to the database. Datetime expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
@@ -424,7 +424,7 @@ discard block |
||
424 | 424 | $old_pos = 0; |
425 | 425 | $pos = -1; |
426 | 426 | // Remove the string escape for better runtime |
427 | - $db_string_1 = str_replace('\'\'','',$db_string); |
|
427 | + $db_string_1 = str_replace('\'\'', '', $db_string); |
|
428 | 428 | while (true) |
429 | 429 | { |
430 | 430 | $pos = strpos($db_string_1, '\'', $pos + 1); |
@@ -802,7 +802,7 @@ discard block |
||
802 | 802 | if (!empty($keys) && (count($keys) > 0) && $returnmode > 0) |
803 | 803 | { |
804 | 804 | // we only take the first key |
805 | - $returning = ' RETURNING '.$keys[0]; |
|
805 | + $returning = ' RETURNING ' . $keys[0]; |
|
806 | 806 | $with_returning = true; |
807 | 807 | } |
808 | 808 | |
@@ -833,7 +833,7 @@ discard block |
||
833 | 833 | INSERT INTO ' . $table . '("' . implode('", "', $indexed_columns) . '") |
834 | 834 | VALUES |
835 | 835 | ' . implode(', |
836 | - ', $insertRows).$replace.$returning, |
|
836 | + ', $insertRows) . $replace . $returning, |
|
837 | 837 | array( |
838 | 838 | 'security_override' => true, |
839 | 839 | 'db_error_skip' => $method == 'ignore' || $table === $db_prefix . 'log_errors', |
@@ -846,7 +846,7 @@ discard block |
||
846 | 846 | if ($returnmode === 2) |
847 | 847 | $return_var = array(); |
848 | 848 | |
849 | - while(($row = $smcFunc['db_fetch_row']($request)) && $with_returning) |
|
849 | + while (($row = $smcFunc['db_fetch_row']($request)) && $with_returning) |
|
850 | 850 | { |
851 | 851 | if (is_numeric($row[0])) // try to emulate mysql limitation |
852 | 852 | { |
@@ -1009,7 +1009,7 @@ discard block |
||
1009 | 1009 | */ |
1010 | 1010 | function smf_db_custom_order($field, $array_values, $desc = false) |
1011 | 1011 | { |
1012 | - $return = 'CASE '. $field . ' '; |
|
1012 | + $return = 'CASE ' . $field . ' '; |
|
1013 | 1013 | $count = count($array_values); |
1014 | 1014 | $then = ($desc ? ' THEN -' : ' THEN '); |
1015 | 1015 |
@@ -13,8 +13,9 @@ discard block |
||
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 | * Maps the implementations in this file (smf_db_function_name) |
@@ -34,8 +35,8 @@ discard block |
||
34 | 35 | global $smcFunc; |
35 | 36 | |
36 | 37 | // Map some database specific functions, only do this once. |
37 | - if (!isset($smcFunc['db_fetch_assoc'])) |
|
38 | - $smcFunc += array( |
|
38 | + if (!isset($smcFunc['db_fetch_assoc'])) { |
|
39 | + $smcFunc += array( |
|
39 | 40 | 'db_query' => 'smf_db_query', |
40 | 41 | 'db_quote' => 'smf_db_quote', |
41 | 42 | 'db_insert' => 'smf_db_insert', |
@@ -64,11 +65,13 @@ discard block |
||
64 | 65 | 'db_error_insert' => 'smf_db_error_insert', |
65 | 66 | 'db_custom_order' => 'smf_db_custom_order', |
66 | 67 | ); |
68 | + } |
|
67 | 69 | |
68 | - if (!empty($db_options['persist'])) |
|
69 | - $connection = @pg_pconnect('host=' . $db_server . ' dbname=' . $db_name . ' user=\'' . $db_user . '\' password=\'' . $db_passwd . '\'' . (empty($db_options['port']) ? '' : ' port=\'' . $db_options['port'] . '\'')); |
|
70 | - else |
|
71 | - $connection = @pg_connect('host=' . $db_server . ' dbname=' . $db_name . ' user=\'' . $db_user . '\' password=\'' . $db_passwd . '\'' . (empty($db_options['port']) ? '' : ' port=\'' . $db_options['port'] . '\'')); |
|
70 | + if (!empty($db_options['persist'])) { |
|
71 | + $connection = @pg_pconnect('host=' . $db_server . ' dbname=' . $db_name . ' user=\'' . $db_user . '\' password=\'' . $db_passwd . '\'' . (empty($db_options['port']) ? '' : ' port=\'' . $db_options['port'] . '\'')); |
|
72 | + } else { |
|
73 | + $connection = @pg_connect('host=' . $db_server . ' dbname=' . $db_name . ' user=\'' . $db_user . '\' password=\'' . $db_passwd . '\'' . (empty($db_options['port']) ? '' : ' port=\'' . $db_options['port'] . '\'')); |
|
74 | + } |
|
72 | 75 | |
73 | 76 | // Something's wrong, show an error if its fatal (which we assume it is) |
74 | 77 | if (!$connection) |
@@ -76,8 +79,7 @@ discard block |
||
76 | 79 | if (!empty($db_options['non_fatal'])) |
77 | 80 | { |
78 | 81 | return null; |
79 | - } |
|
80 | - else |
|
82 | + } else |
|
81 | 83 | { |
82 | 84 | display_db_error(); |
83 | 85 | } |
@@ -128,31 +130,38 @@ discard block |
||
128 | 130 | |
129 | 131 | list ($values, $connection) = $db_callback; |
130 | 132 | |
131 | - if ($matches[1] === 'db_prefix') |
|
132 | - return $db_prefix; |
|
133 | + if ($matches[1] === 'db_prefix') { |
|
134 | + return $db_prefix; |
|
135 | + } |
|
133 | 136 | |
134 | - if (isset($user_info[$matches[1]]) && strpos($matches[1], 'query_') !== false) |
|
135 | - return $user_info[$matches[1]]; |
|
137 | + if (isset($user_info[$matches[1]]) && strpos($matches[1], 'query_') !== false) { |
|
138 | + return $user_info[$matches[1]]; |
|
139 | + } |
|
136 | 140 | |
137 | - if ($matches[1] === 'empty') |
|
138 | - return '\'\''; |
|
141 | + if ($matches[1] === 'empty') { |
|
142 | + return '\'\''; |
|
143 | + } |
|
139 | 144 | |
140 | - if (!isset($matches[2])) |
|
141 | - smf_db_error_backtrace('Invalid value inserted or no type specified.', '', E_USER_ERROR, __FILE__, __LINE__); |
|
145 | + if (!isset($matches[2])) { |
|
146 | + smf_db_error_backtrace('Invalid value inserted or no type specified.', '', E_USER_ERROR, __FILE__, __LINE__); |
|
147 | + } |
|
142 | 148 | |
143 | - if ($matches[1] === 'literal') |
|
144 | - return '\'' . pg_escape_string($matches[2]) . '\''; |
|
149 | + if ($matches[1] === 'literal') { |
|
150 | + return '\'' . pg_escape_string($matches[2]) . '\''; |
|
151 | + } |
|
145 | 152 | |
146 | - if (!isset($values[$matches[2]])) |
|
147 | - smf_db_error_backtrace('The database value you\'re trying to insert does not exist: ' . (isset($smcFunc['htmlspecialchars']) ? $smcFunc['htmlspecialchars']($matches[2]) : htmlspecialchars($matches[2])), '', E_USER_ERROR, __FILE__, __LINE__); |
|
153 | + if (!isset($values[$matches[2]])) { |
|
154 | + smf_db_error_backtrace('The database value you\'re trying to insert does not exist: ' . (isset($smcFunc['htmlspecialchars']) ? $smcFunc['htmlspecialchars']($matches[2]) : htmlspecialchars($matches[2])), '', E_USER_ERROR, __FILE__, __LINE__); |
|
155 | + } |
|
148 | 156 | |
149 | 157 | $replacement = $values[$matches[2]]; |
150 | 158 | |
151 | 159 | switch ($matches[1]) |
152 | 160 | { |
153 | 161 | case 'int': |
154 | - if (!is_numeric($replacement) || (string) $replacement !== (string) (int) $replacement) |
|
155 | - smf_db_error_backtrace('Wrong value type sent to the database. Integer expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
162 | + if (!is_numeric($replacement) || (string) $replacement !== (string) (int) $replacement) { |
|
163 | + smf_db_error_backtrace('Wrong value type sent to the database. Integer expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
164 | + } |
|
156 | 165 | return (string) (int) $replacement; |
157 | 166 | break; |
158 | 167 | |
@@ -164,65 +173,73 @@ discard block |
||
164 | 173 | case 'array_int': |
165 | 174 | if (is_array($replacement)) |
166 | 175 | { |
167 | - if (empty($replacement)) |
|
168 | - smf_db_error_backtrace('Database error, given array of integer values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
176 | + if (empty($replacement)) { |
|
177 | + smf_db_error_backtrace('Database error, given array of integer values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
178 | + } |
|
169 | 179 | |
170 | 180 | foreach ($replacement as $key => $value) |
171 | 181 | { |
172 | - if (!is_numeric($value) || (string) $value !== (string) (int) $value) |
|
173 | - smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
182 | + if (!is_numeric($value) || (string) $value !== (string) (int) $value) { |
|
183 | + smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
184 | + } |
|
174 | 185 | |
175 | 186 | $replacement[$key] = (string) (int) $value; |
176 | 187 | } |
177 | 188 | |
178 | 189 | return implode(', ', $replacement); |
190 | + } else { |
|
191 | + smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
179 | 192 | } |
180 | - else |
|
181 | - smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
182 | 193 | |
183 | 194 | break; |
184 | 195 | |
185 | 196 | case 'array_string': |
186 | 197 | if (is_array($replacement)) |
187 | 198 | { |
188 | - if (empty($replacement)) |
|
189 | - smf_db_error_backtrace('Database error, given array of string values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
199 | + if (empty($replacement)) { |
|
200 | + smf_db_error_backtrace('Database error, given array of string values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
201 | + } |
|
190 | 202 | |
191 | - foreach ($replacement as $key => $value) |
|
192 | - $replacement[$key] = sprintf('\'%1$s\'', pg_escape_string($value)); |
|
203 | + foreach ($replacement as $key => $value) { |
|
204 | + $replacement[$key] = sprintf('\'%1$s\'', pg_escape_string($value)); |
|
205 | + } |
|
193 | 206 | |
194 | 207 | return implode(', ', $replacement); |
208 | + } else { |
|
209 | + smf_db_error_backtrace('Wrong value type sent to the database. Array of strings expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
195 | 210 | } |
196 | - else |
|
197 | - smf_db_error_backtrace('Wrong value type sent to the database. Array of strings expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
198 | 211 | break; |
199 | 212 | |
200 | 213 | case 'date': |
201 | - if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d)$~', $replacement, $date_matches) === 1) |
|
202 | - return sprintf('\'%04d-%02d-%02d\'', $date_matches[1], $date_matches[2], $date_matches[3]).'::date'; |
|
203 | - else |
|
204 | - smf_db_error_backtrace('Wrong value type sent to the database. Date expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
214 | + if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d)$~', $replacement, $date_matches) === 1) { |
|
215 | + return sprintf('\'%04d-%02d-%02d\'', $date_matches[1], $date_matches[2], $date_matches[3]).'::date'; |
|
216 | + } else { |
|
217 | + smf_db_error_backtrace('Wrong value type sent to the database. Date expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
218 | + } |
|
205 | 219 | break; |
206 | 220 | |
207 | 221 | case 'time': |
208 | - if (preg_match('~^([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $time_matches) === 1) |
|
209 | - return sprintf('\'%02d:%02d:%02d\'', $time_matches[1], $time_matches[2], $time_matches[3]).'::time'; |
|
210 | - else |
|
211 | - smf_db_error_backtrace('Wrong value type sent to the database. Time expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
222 | + if (preg_match('~^([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $time_matches) === 1) { |
|
223 | + return sprintf('\'%02d:%02d:%02d\'', $time_matches[1], $time_matches[2], $time_matches[3]).'::time'; |
|
224 | + } else { |
|
225 | + smf_db_error_backtrace('Wrong value type sent to the database. Time expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
226 | + } |
|
212 | 227 | break; |
213 | 228 | |
214 | 229 | case 'datetime': |
215 | - if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d) ([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $datetime_matches) === 1) |
|
216 | - return 'to_timestamp('. |
|
230 | + if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d) ([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $datetime_matches) === 1) { |
|
231 | + return 'to_timestamp('. |
|
217 | 232 | sprintf('\'%04d-%02d-%02d %02d:%02d:%02d\'', $datetime_matches[1], $datetime_matches[2], $datetime_matches[3], $datetime_matches[4], $datetime_matches[5] ,$datetime_matches[6]). |
218 | 233 | ',\'YYYY-MM-DD HH24:MI:SS\')'; |
219 | - else |
|
220 | - smf_db_error_backtrace('Wrong value type sent to the database. Datetime expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
234 | + } else { |
|
235 | + smf_db_error_backtrace('Wrong value type sent to the database. Datetime expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
236 | + } |
|
221 | 237 | break; |
222 | 238 | |
223 | 239 | case 'float': |
224 | - if (!is_numeric($replacement)) |
|
225 | - smf_db_error_backtrace('Wrong value type sent to the database. Floating point number expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
240 | + if (!is_numeric($replacement)) { |
|
241 | + smf_db_error_backtrace('Wrong value type sent to the database. Floating point number expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
242 | + } |
|
226 | 243 | return (string) (float) $replacement; |
227 | 244 | break; |
228 | 245 | |
@@ -235,31 +252,36 @@ discard block |
||
235 | 252 | break; |
236 | 253 | |
237 | 254 | case 'inet': |
238 | - if ($replacement == 'null' || $replacement == '') |
|
239 | - return 'null'; |
|
240 | - if (inet_pton($replacement) === false) |
|
241 | - smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
255 | + if ($replacement == 'null' || $replacement == '') { |
|
256 | + return 'null'; |
|
257 | + } |
|
258 | + if (inet_pton($replacement) === false) { |
|
259 | + smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
260 | + } |
|
242 | 261 | return sprintf('\'%1$s\'::inet', pg_escape_string($replacement)); |
243 | 262 | |
244 | 263 | case 'array_inet': |
245 | 264 | if (is_array($replacement)) |
246 | 265 | { |
247 | - if (empty($replacement)) |
|
248 | - smf_db_error_backtrace('Database error, given array of IPv4 or IPv6 values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
266 | + if (empty($replacement)) { |
|
267 | + smf_db_error_backtrace('Database error, given array of IPv4 or IPv6 values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
268 | + } |
|
249 | 269 | |
250 | 270 | foreach ($replacement as $key => $value) |
251 | 271 | { |
252 | - if ($replacement == 'null' || $replacement == '') |
|
253 | - $replacement[$key] = 'null'; |
|
254 | - if (!isValidIP($value)) |
|
255 | - smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
272 | + if ($replacement == 'null' || $replacement == '') { |
|
273 | + $replacement[$key] = 'null'; |
|
274 | + } |
|
275 | + if (!isValidIP($value)) { |
|
276 | + smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
277 | + } |
|
256 | 278 | $replacement[$key] = sprintf('\'%1$s\'::inet', pg_escape_string($value)); |
257 | 279 | } |
258 | 280 | |
259 | 281 | return implode(', ', $replacement); |
282 | + } else { |
|
283 | + smf_db_error_backtrace('Wrong value type sent to the database. Array of IPv4 or IPv6 expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
260 | 284 | } |
261 | - else |
|
262 | - smf_db_error_backtrace('Wrong value type sent to the database. Array of IPv4 or IPv6 expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
263 | 285 | break; |
264 | 286 | |
265 | 287 | default: |
@@ -350,14 +372,16 @@ discard block |
||
350 | 372 | ), |
351 | 373 | ); |
352 | 374 | |
353 | - if (isset($replacements[$identifier])) |
|
354 | - $db_string = preg_replace(array_keys($replacements[$identifier]), array_values($replacements[$identifier]), $db_string); |
|
375 | + if (isset($replacements[$identifier])) { |
|
376 | + $db_string = preg_replace(array_keys($replacements[$identifier]), array_values($replacements[$identifier]), $db_string); |
|
377 | + } |
|
355 | 378 | |
356 | 379 | // Limits need to be a little different. |
357 | 380 | $db_string = preg_replace('~\sLIMIT\s(\d+|{int:.+}),\s*(\d+|{int:.+})\s*$~i', 'LIMIT $2 OFFSET $1', $db_string); |
358 | 381 | |
359 | - if (trim($db_string) == '') |
|
360 | - return false; |
|
382 | + if (trim($db_string) == '') { |
|
383 | + return false; |
|
384 | + } |
|
361 | 385 | |
362 | 386 | // Comments that are allowed in a query are preg_removed. |
363 | 387 | static $allowed_comments_from = array( |
@@ -377,8 +401,9 @@ discard block |
||
377 | 401 | $db_count = !isset($db_count) ? 1 : $db_count + 1; |
378 | 402 | $db_replace_result = 0; |
379 | 403 | |
380 | - if (empty($modSettings['disableQueryCheck']) && strpos($db_string, '\'') !== false && empty($db_values['security_override'])) |
|
381 | - smf_db_error_backtrace('Hacking attempt...', 'Illegal character (\') used in query...', true, __FILE__, __LINE__); |
|
404 | + if (empty($modSettings['disableQueryCheck']) && strpos($db_string, '\'') !== false && empty($db_values['security_override'])) { |
|
405 | + smf_db_error_backtrace('Hacking attempt...', 'Illegal character (\') used in query...', true, __FILE__, __LINE__); |
|
406 | + } |
|
382 | 407 | |
383 | 408 | if (empty($db_values['security_override']) && (!empty($db_values) || strpos($db_string, '{db_prefix}') !== false)) |
384 | 409 | { |
@@ -403,17 +428,18 @@ discard block |
||
403 | 428 | while (true) |
404 | 429 | { |
405 | 430 | $pos = strpos($db_string_1, '\'', $pos + 1); |
406 | - if ($pos === false) |
|
407 | - break; |
|
431 | + if ($pos === false) { |
|
432 | + break; |
|
433 | + } |
|
408 | 434 | $clean .= substr($db_string_1, $old_pos, $pos - $old_pos); |
409 | 435 | |
410 | 436 | while (true) |
411 | 437 | { |
412 | 438 | $pos1 = strpos($db_string_1, '\'', $pos + 1); |
413 | 439 | $pos2 = strpos($db_string_1, '\\', $pos + 1); |
414 | - if ($pos1 === false) |
|
415 | - break; |
|
416 | - elseif ($pos2 === false || $pos2 > $pos1) |
|
440 | + if ($pos1 === false) { |
|
441 | + break; |
|
442 | + } elseif ($pos2 === false || $pos2 > $pos1) |
|
417 | 443 | { |
418 | 444 | $pos = $pos1; |
419 | 445 | break; |
@@ -429,16 +455,19 @@ discard block |
||
429 | 455 | $clean = trim(strtolower(preg_replace($allowed_comments_from, $allowed_comments_to, $clean))); |
430 | 456 | |
431 | 457 | // Comments? We don't use comments in our queries, we leave 'em outside! |
432 | - if (strpos($clean, '/*') > 2 || strpos($clean, '--') !== false || strpos($clean, ';') !== false) |
|
433 | - $fail = true; |
|
458 | + if (strpos($clean, '/*') > 2 || strpos($clean, '--') !== false || strpos($clean, ';') !== false) { |
|
459 | + $fail = true; |
|
460 | + } |
|
434 | 461 | // Trying to change passwords, slow us down, or something? |
435 | - elseif (strpos($clean, 'sleep') !== false && preg_match('~(^|[^a-z])sleep($|[^[_a-z])~s', $clean) != 0) |
|
436 | - $fail = true; |
|
437 | - elseif (strpos($clean, 'benchmark') !== false && preg_match('~(^|[^a-z])benchmark($|[^[a-z])~s', $clean) != 0) |
|
438 | - $fail = true; |
|
462 | + elseif (strpos($clean, 'sleep') !== false && preg_match('~(^|[^a-z])sleep($|[^[_a-z])~s', $clean) != 0) { |
|
463 | + $fail = true; |
|
464 | + } elseif (strpos($clean, 'benchmark') !== false && preg_match('~(^|[^a-z])benchmark($|[^[a-z])~s', $clean) != 0) { |
|
465 | + $fail = true; |
|
466 | + } |
|
439 | 467 | |
440 | - if (!empty($fail) && function_exists('log_error')) |
|
441 | - smf_db_error_backtrace('Hacking attempt...', 'Hacking attempt...' . "\n" . $db_string, E_USER_ERROR, __FILE__, __LINE__); |
|
468 | + if (!empty($fail) && function_exists('log_error')) { |
|
469 | + smf_db_error_backtrace('Hacking attempt...', 'Hacking attempt...' . "\n" . $db_string, E_USER_ERROR, __FILE__, __LINE__); |
|
470 | + } |
|
442 | 471 | } |
443 | 472 | |
444 | 473 | // Set optimize stuff |
@@ -465,8 +494,9 @@ discard block |
||
465 | 494 | list ($file, $line) = smf_db_error_backtrace('', '', 'return', __FILE__, __LINE__); |
466 | 495 | |
467 | 496 | // Initialize $db_cache if not already initialized. |
468 | - if (!isset($db_cache)) |
|
469 | - $db_cache = array(); |
|
497 | + if (!isset($db_cache)) { |
|
498 | + $db_cache = array(); |
|
499 | + } |
|
470 | 500 | |
471 | 501 | if (!empty($_SESSION['debug_redirect'])) |
472 | 502 | { |
@@ -484,12 +514,14 @@ discard block |
||
484 | 514 | |
485 | 515 | $db_last_result = @pg_query($connection, $db_string); |
486 | 516 | |
487 | - if ($db_last_result === false && empty($db_values['db_error_skip'])) |
|
488 | - $db_last_result = smf_db_error($db_string, $connection); |
|
517 | + if ($db_last_result === false && empty($db_values['db_error_skip'])) { |
|
518 | + $db_last_result = smf_db_error($db_string, $connection); |
|
519 | + } |
|
489 | 520 | |
490 | 521 | // Debugging. |
491 | - if (isset($db_show_debug) && $db_show_debug === true) |
|
492 | - $db_cache[$db_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st)); |
|
522 | + if (isset($db_show_debug) && $db_show_debug === true) { |
|
523 | + $db_cache[$db_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st)); |
|
524 | + } |
|
493 | 525 | |
494 | 526 | return $db_last_result; |
495 | 527 | } |
@@ -506,10 +538,11 @@ discard block |
||
506 | 538 | { |
507 | 539 | global $db_last_result, $db_replace_result; |
508 | 540 | |
509 | - if ($db_replace_result) |
|
510 | - return $db_replace_result; |
|
511 | - elseif ($result === null && !$db_last_result) |
|
512 | - return 0; |
|
541 | + if ($db_replace_result) { |
|
542 | + return $db_replace_result; |
|
543 | + } elseif ($result === null && !$db_last_result) { |
|
544 | + return 0; |
|
545 | + } |
|
513 | 546 | |
514 | 547 | return pg_affected_rows($result === null ? $db_last_result : $result); |
515 | 548 | } |
@@ -533,8 +566,9 @@ discard block |
||
533 | 566 | array( |
534 | 567 | ) |
535 | 568 | ); |
536 | - if (!$request) |
|
537 | - return false; |
|
569 | + if (!$request) { |
|
570 | + return false; |
|
571 | + } |
|
538 | 572 | list ($lastID) = $smcFunc['db_fetch_row']($request); |
539 | 573 | $smcFunc['db_free_result']($request); |
540 | 574 | |
@@ -555,12 +589,13 @@ discard block |
||
555 | 589 | // Decide which connection to use |
556 | 590 | $connection = $connection === null ? $db_connection : $connection; |
557 | 591 | |
558 | - if ($type == 'begin') |
|
559 | - return @pg_query($connection, 'BEGIN'); |
|
560 | - elseif ($type == 'rollback') |
|
561 | - return @pg_query($connection, 'ROLLBACK'); |
|
562 | - elseif ($type == 'commit') |
|
563 | - return @pg_query($connection, 'COMMIT'); |
|
592 | + if ($type == 'begin') { |
|
593 | + return @pg_query($connection, 'BEGIN'); |
|
594 | + } elseif ($type == 'rollback') { |
|
595 | + return @pg_query($connection, 'ROLLBACK'); |
|
596 | + } elseif ($type == 'commit') { |
|
597 | + return @pg_query($connection, 'COMMIT'); |
|
598 | + } |
|
564 | 599 | |
565 | 600 | return false; |
566 | 601 | } |
@@ -588,19 +623,22 @@ discard block |
||
588 | 623 | $query_error = @pg_last_error($connection); |
589 | 624 | |
590 | 625 | // Log the error. |
591 | - if (function_exists('log_error')) |
|
592 | - log_error($txt['database_error'] . ': ' . $query_error . (!empty($modSettings['enableErrorQueryLogging']) ? "\n\n" . $db_string : ''), 'database', $file, $line); |
|
626 | + if (function_exists('log_error')) { |
|
627 | + log_error($txt['database_error'] . ': ' . $query_error . (!empty($modSettings['enableErrorQueryLogging']) ? "\n\n" . $db_string : ''), 'database', $file, $line); |
|
628 | + } |
|
593 | 629 | |
594 | 630 | // Nothing's defined yet... just die with it. |
595 | - if (empty($context) || empty($txt)) |
|
596 | - die($query_error); |
|
631 | + if (empty($context) || empty($txt)) { |
|
632 | + die($query_error); |
|
633 | + } |
|
597 | 634 | |
598 | 635 | // Show an error message, if possible. |
599 | 636 | $context['error_title'] = $txt['database_error']; |
600 | - if (allowedTo('admin_forum')) |
|
601 | - $context['error_message'] = nl2br($query_error) . '<br>' . $txt['file'] . ': ' . $file . '<br>' . $txt['line'] . ': ' . $line; |
|
602 | - else |
|
603 | - $context['error_message'] = $txt['try_again']; |
|
637 | + if (allowedTo('admin_forum')) { |
|
638 | + $context['error_message'] = nl2br($query_error) . '<br>' . $txt['file'] . ': ' . $file . '<br>' . $txt['line'] . ': ' . $line; |
|
639 | + } else { |
|
640 | + $context['error_message'] = $txt['try_again']; |
|
641 | + } |
|
604 | 642 | |
605 | 643 | if (allowedTo('admin_forum') && isset($db_show_debug) && $db_show_debug === true) |
606 | 644 | { |
@@ -622,12 +660,14 @@ discard block |
||
622 | 660 | { |
623 | 661 | global $db_row_count; |
624 | 662 | |
625 | - if ($counter !== false) |
|
626 | - return pg_fetch_row($request, $counter); |
|
663 | + if ($counter !== false) { |
|
664 | + return pg_fetch_row($request, $counter); |
|
665 | + } |
|
627 | 666 | |
628 | 667 | // Reset the row counter... |
629 | - if (!isset($db_row_count[(int) $request])) |
|
630 | - $db_row_count[(int) $request] = 0; |
|
668 | + if (!isset($db_row_count[(int) $request])) { |
|
669 | + $db_row_count[(int) $request] = 0; |
|
670 | + } |
|
631 | 671 | |
632 | 672 | // Return the right row. |
633 | 673 | return @pg_fetch_row($request, $db_row_count[(int) $request]++); |
@@ -644,12 +684,14 @@ discard block |
||
644 | 684 | { |
645 | 685 | global $db_row_count; |
646 | 686 | |
647 | - if ($counter !== false) |
|
648 | - return pg_fetch_assoc($request, $counter); |
|
687 | + if ($counter !== false) { |
|
688 | + return pg_fetch_assoc($request, $counter); |
|
689 | + } |
|
649 | 690 | |
650 | 691 | // Reset the row counter... |
651 | - if (!isset($db_row_count[(int) $request])) |
|
652 | - $db_row_count[(int) $request] = 0; |
|
692 | + if (!isset($db_row_count[(int) $request])) { |
|
693 | + $db_row_count[(int) $request] = 0; |
|
694 | + } |
|
653 | 695 | |
654 | 696 | // Return the right row. |
655 | 697 | return @pg_fetch_assoc($request, $db_row_count[(int) $request]++); |
@@ -702,11 +744,13 @@ discard block |
||
702 | 744 | |
703 | 745 | $replace = ''; |
704 | 746 | |
705 | - if (empty($data)) |
|
706 | - return; |
|
747 | + if (empty($data)) { |
|
748 | + return; |
|
749 | + } |
|
707 | 750 | |
708 | - if (!is_array($data[array_rand($data)])) |
|
709 | - $data = array($data); |
|
751 | + if (!is_array($data[array_rand($data)])) { |
|
752 | + $data = array($data); |
|
753 | + } |
|
710 | 754 | |
711 | 755 | // Replace the prefix holder with the actual prefix. |
712 | 756 | $table = str_replace('{db_prefix}', $db_prefix, $table); |
@@ -725,11 +769,13 @@ discard block |
||
725 | 769 | //pg 9.5 got replace support |
726 | 770 | $pg_version = $smcFunc['db_get_version'](); |
727 | 771 | // if we got a Beta Version |
728 | - if (stripos($pg_version, 'beta') !== false) |
|
729 | - $pg_version = substr($pg_version, 0, stripos($pg_version, 'beta')) . '.0'; |
|
772 | + if (stripos($pg_version, 'beta') !== false) { |
|
773 | + $pg_version = substr($pg_version, 0, stripos($pg_version, 'beta')) . '.0'; |
|
774 | + } |
|
730 | 775 | // or RC |
731 | - if (stripos($pg_version, 'rc') !== false) |
|
732 | - $pg_version = substr($pg_version, 0, stripos($pg_version, 'rc')) . '.0'; |
|
776 | + if (stripos($pg_version, 'rc') !== false) { |
|
777 | + $pg_version = substr($pg_version, 0, stripos($pg_version, 'rc')) . '.0'; |
|
778 | + } |
|
733 | 779 | |
734 | 780 | $replace_support = (version_compare($pg_version, '9.5.0', '>=') ? true : false); |
735 | 781 | } |
@@ -748,32 +794,35 @@ discard block |
||
748 | 794 | $key_str .= ($count_pk > 0 ? ',' : ''); |
749 | 795 | $key_str .= $columnName; |
750 | 796 | $count_pk++; |
751 | - } |
|
752 | - else if ($method == 'replace') //normal field |
|
797 | + } else if ($method == 'replace') { |
|
798 | + //normal field |
|
753 | 799 | { |
754 | 800 | $col_str .= ($count > 0 ? ',' : ''); |
801 | + } |
|
755 | 802 | $col_str .= $columnName . ' = EXCLUDED.' . $columnName; |
756 | 803 | $count++; |
757 | 804 | } |
758 | 805 | } |
759 | - if ($method == 'replace') |
|
760 | - $replace = ' ON CONFLICT (' . $key_str . ') DO UPDATE SET ' . $col_str; |
|
761 | - else |
|
762 | - $replace = ' ON CONFLICT (' . $key_str . ') DO NOTHING'; |
|
763 | - } |
|
764 | - else if ($method == 'replace') |
|
806 | + if ($method == 'replace') { |
|
807 | + $replace = ' ON CONFLICT (' . $key_str . ') DO UPDATE SET ' . $col_str; |
|
808 | + } else { |
|
809 | + $replace = ' ON CONFLICT (' . $key_str . ') DO NOTHING'; |
|
810 | + } |
|
811 | + } else if ($method == 'replace') |
|
765 | 812 | { |
766 | 813 | foreach ($columns as $columnName => $type) |
767 | 814 | { |
768 | 815 | // Are we restricting the length? |
769 | - if (strpos($type, 'string-') !== false) |
|
770 | - $actualType = sprintf($columnName . ' = SUBSTRING({string:%1$s}, 1, ' . substr($type, 7) . '), ', $count); |
|
771 | - else |
|
772 | - $actualType = sprintf($columnName . ' = {%1$s:%2$s}, ', $type, $count); |
|
816 | + if (strpos($type, 'string-') !== false) { |
|
817 | + $actualType = sprintf($columnName . ' = SUBSTRING({string:%1$s}, 1, ' . substr($type, 7) . '), ', $count); |
|
818 | + } else { |
|
819 | + $actualType = sprintf($columnName . ' = {%1$s:%2$s}, ', $type, $count); |
|
820 | + } |
|
773 | 821 | |
774 | 822 | // A key? That's what we were looking for. |
775 | - if (in_array($columnName, $keys)) |
|
776 | - $where .= (empty($where) ? '' : ' AND ') . substr($actualType, 0, -2); |
|
823 | + if (in_array($columnName, $keys)) { |
|
824 | + $where .= (empty($where) ? '' : ' AND ') . substr($actualType, 0, -2); |
|
825 | + } |
|
777 | 826 | $count++; |
778 | 827 | } |
779 | 828 | |
@@ -809,10 +858,11 @@ discard block |
||
809 | 858 | foreach ($columns as $columnName => $type) |
810 | 859 | { |
811 | 860 | // Are we restricting the length? |
812 | - if (strpos($type, 'string-') !== false) |
|
813 | - $insertData .= sprintf('SUBSTRING({string:%1$s}, 1, ' . substr($type, 7) . '), ', $columnName); |
|
814 | - else |
|
815 | - $insertData .= sprintf('{%1$s:%2$s}, ', $type, $columnName); |
|
861 | + if (strpos($type, 'string-') !== false) { |
|
862 | + $insertData .= sprintf('SUBSTRING({string:%1$s}, 1, ' . substr($type, 7) . '), ', $columnName); |
|
863 | + } else { |
|
864 | + $insertData .= sprintf('{%1$s:%2$s}, ', $type, $columnName); |
|
865 | + } |
|
816 | 866 | } |
817 | 867 | $insertData = substr($insertData, 0, -2) . ')'; |
818 | 868 | |
@@ -821,8 +871,9 @@ discard block |
||
821 | 871 | |
822 | 872 | // Here's where the variables are injected to the query. |
823 | 873 | $insertRows = array(); |
824 | - foreach ($data as $dataRow) |
|
825 | - $insertRows[] = smf_db_quote($insertData, array_combine($indexed_columns, $dataRow), $connection); |
|
874 | + foreach ($data as $dataRow) { |
|
875 | + $insertRows[] = smf_db_quote($insertData, array_combine($indexed_columns, $dataRow), $connection); |
|
876 | + } |
|
826 | 877 | |
827 | 878 | // Do the insert. |
828 | 879 | $request = $smcFunc['db_query']('', ' |
@@ -839,19 +890,21 @@ discard block |
||
839 | 890 | |
840 | 891 | if ($with_returning && $request !== false) |
841 | 892 | { |
842 | - if ($returnmode === 2) |
|
843 | - $return_var = array(); |
|
893 | + if ($returnmode === 2) { |
|
894 | + $return_var = array(); |
|
895 | + } |
|
844 | 896 | |
845 | 897 | while(($row = $smcFunc['db_fetch_row']($request)) && $with_returning) |
846 | 898 | { |
847 | - if (is_numeric($row[0])) // try to emulate mysql limitation |
|
899 | + if (is_numeric($row[0])) { |
|
900 | + // try to emulate mysql limitation |
|
848 | 901 | { |
849 | 902 | if ($returnmode === 1) |
850 | 903 | $return_var = $row[0]; |
851 | - elseif ($returnmode === 2) |
|
852 | - $return_var[] = $row[0]; |
|
853 | - } |
|
854 | - else |
|
904 | + } elseif ($returnmode === 2) { |
|
905 | + $return_var[] = $row[0]; |
|
906 | + } |
|
907 | + } else |
|
855 | 908 | { |
856 | 909 | $with_returning = false; |
857 | 910 | trigger_error('trying to returning ID Field which is not a Int field', E_USER_ERROR); |
@@ -860,9 +913,10 @@ discard block |
||
860 | 913 | } |
861 | 914 | } |
862 | 915 | |
863 | - if ($with_returning && !empty($return_var)) |
|
864 | - return $return_var; |
|
865 | -} |
|
916 | + if ($with_returning && !empty($return_var)) { |
|
917 | + return $return_var; |
|
918 | + } |
|
919 | + } |
|
866 | 920 | |
867 | 921 | /** |
868 | 922 | * Dummy function really. Doesn't do anything on PostgreSQL. |
@@ -899,8 +953,9 @@ discard block |
||
899 | 953 | */ |
900 | 954 | function smf_db_error_backtrace($error_message, $log_message = '', $error_type = false, $file = null, $line = null) |
901 | 955 | { |
902 | - if (empty($log_message)) |
|
903 | - $log_message = $error_message; |
|
956 | + if (empty($log_message)) { |
|
957 | + $log_message = $error_message; |
|
958 | + } |
|
904 | 959 | |
905 | 960 | foreach (debug_backtrace() as $step) |
906 | 961 | { |
@@ -919,12 +974,14 @@ discard block |
||
919 | 974 | } |
920 | 975 | |
921 | 976 | // A special case - we want the file and line numbers for debugging. |
922 | - if ($error_type == 'return') |
|
923 | - return array($file, $line); |
|
977 | + if ($error_type == 'return') { |
|
978 | + return array($file, $line); |
|
979 | + } |
|
924 | 980 | |
925 | 981 | // Is always a critical error. |
926 | - if (function_exists('log_error')) |
|
927 | - log_error($log_message, 'critical', $file, $line); |
|
982 | + if (function_exists('log_error')) { |
|
983 | + log_error($log_message, 'critical', $file, $line); |
|
984 | + } |
|
928 | 985 | |
929 | 986 | if (function_exists('fatal_error')) |
930 | 987 | { |
@@ -932,12 +989,12 @@ discard block |
||
932 | 989 | |
933 | 990 | // Cannot continue... |
934 | 991 | exit; |
992 | + } elseif ($error_type) { |
|
993 | + trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : ''), $error_type); |
|
994 | + } else { |
|
995 | + trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : '')); |
|
996 | + } |
|
935 | 997 | } |
936 | - elseif ($error_type) |
|
937 | - trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : ''), $error_type); |
|
938 | - else |
|
939 | - trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : '')); |
|
940 | -} |
|
941 | 998 | |
942 | 999 | /** |
943 | 1000 | * Escape the LIKE wildcards so that they match the character and not the wildcard. |
@@ -954,10 +1011,11 @@ discard block |
||
954 | 1011 | '\\' => '\\\\', |
955 | 1012 | ); |
956 | 1013 | |
957 | - if ($translate_human_wildcards) |
|
958 | - $replacements += array( |
|
1014 | + if ($translate_human_wildcards) { |
|
1015 | + $replacements += array( |
|
959 | 1016 | '*' => '%', |
960 | 1017 | ); |
1018 | + } |
|
961 | 1019 | |
962 | 1020 | return strtr($string, $replacements); |
963 | 1021 | } |
@@ -985,11 +1043,12 @@ discard block |
||
985 | 1043 | global $db_prefix, $db_connection; |
986 | 1044 | static $pg_error_data_prep; |
987 | 1045 | |
988 | - if (empty($pg_error_data_prep)) |
|
989 | - $pg_error_data_prep = pg_prepare($db_connection, 'smf_log_errors', |
|
1046 | + if (empty($pg_error_data_prep)) { |
|
1047 | + $pg_error_data_prep = pg_prepare($db_connection, 'smf_log_errors', |
|
990 | 1048 | 'INSERT INTO ' . $db_prefix . 'log_errors(id_member, log_time, ip, url, message, session, error_type, file, line) |
991 | 1049 | VALUES( $1, $2, $3, $4, $5, $6, $7, $8, $9)' |
992 | 1050 | ); |
1051 | + } |
|
993 | 1052 | |
994 | 1053 | pg_execute($db_connection, 'smf_log_errors', $error_array); |
995 | 1054 | } |
@@ -1009,8 +1068,9 @@ discard block |
||
1009 | 1068 | $count = count($array_values); |
1010 | 1069 | $then = ($desc ? ' THEN -' : ' THEN '); |
1011 | 1070 | |
1012 | - for ($i = 0; $i < $count; $i++) |
|
1013 | - $return .= 'WHEN ' . (int) $array_values[$i] . $then . $i . ' '; |
|
1071 | + for ($i = 0; $i < $count; $i++) { |
|
1072 | + $return .= 'WHEN ' . (int) $array_values[$i] . $then . $i . ' '; |
|
1073 | + } |
|
1014 | 1074 | |
1015 | 1075 | $return .= 'END'; |
1016 | 1076 | return $return; |
@@ -1334,7 +1334,7 @@ discard block |
||
1334 | 1334 | 'class' => 'centercol', |
1335 | 1335 | ), |
1336 | 1336 | 'data' => array( |
1337 | - 'function' => function ($rowData) |
|
1337 | + 'function' => function($rowData) |
|
1338 | 1338 | { |
1339 | 1339 | $isChecked = $rowData['disabled'] ? '' : ' checked'; |
1340 | 1340 | $onClickHandler = $rowData['can_show_register'] ? sprintf(' onclick="document.getElementById(\'reg_%1$s\').disabled = !this.checked;"', $rowData['id']) : ''; |
@@ -1350,7 +1350,7 @@ discard block |
||
1350 | 1350 | 'class' => 'centercol', |
1351 | 1351 | ), |
1352 | 1352 | 'data' => array( |
1353 | - 'function' => function ($rowData) |
|
1353 | + 'function' => function($rowData) |
|
1354 | 1354 | { |
1355 | 1355 | $isChecked = $rowData['on_register'] && !$rowData['disabled'] ? ' checked' : ''; |
1356 | 1356 | $isDisabled = $rowData['can_show_register'] ? '' : ' disabled'; |
@@ -1397,15 +1397,15 @@ discard block |
||
1397 | 1397 | 'value' => $txt['custom_profile_fieldorder'], |
1398 | 1398 | ), |
1399 | 1399 | 'data' => array( |
1400 | - 'function' => function ($rowData) use ($context, $txt, $scripturl) |
|
1400 | + 'function' => function($rowData) use ($context, $txt, $scripturl) |
|
1401 | 1401 | { |
1402 | - $return = '<p class="centertext bold_text">'. $rowData['field_order'] .'<br>'; |
|
1402 | + $return = '<p class="centertext bold_text">' . $rowData['field_order'] . '<br>'; |
|
1403 | 1403 | |
1404 | 1404 | if ($rowData['field_order'] > 1) |
1405 | - $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=up"><span class="toggle_up" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_up'] .'"></span></a>'; |
|
1405 | + $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=up"><span class="toggle_up" title="' . $txt['custom_edit_order_move'] . ' ' . $txt['custom_edit_order_up'] . '"></span></a>'; |
|
1406 | 1406 | |
1407 | 1407 | if ($rowData['field_order'] < $context['custFieldsMaxOrder']) |
1408 | - $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=down"><span class="toggle_down" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_down'] .'"></span></a>'; |
|
1408 | + $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=down"><span class="toggle_down" title="' . $txt['custom_edit_order_move'] . ' ' . $txt['custom_edit_order_down'] . '"></span></a>'; |
|
1409 | 1409 | |
1410 | 1410 | $return .= '</p>'; |
1411 | 1411 | |
@@ -1423,7 +1423,7 @@ discard block |
||
1423 | 1423 | 'value' => $txt['custom_profile_fieldname'], |
1424 | 1424 | ), |
1425 | 1425 | 'data' => array( |
1426 | - 'function' => function ($rowData) use ($scripturl) |
|
1426 | + 'function' => function($rowData) use ($scripturl) |
|
1427 | 1427 | { |
1428 | 1428 | return sprintf('<a href="%1$s?action=admin;area=featuresettings;sa=profileedit;fid=%2$d">%3$s</a><div class="smalltext">%4$s</div>', $scripturl, $rowData['id_field'], $rowData['field_name'], $rowData['field_desc']); |
1429 | 1429 | }, |
@@ -1439,7 +1439,7 @@ discard block |
||
1439 | 1439 | 'value' => $txt['custom_profile_fieldtype'], |
1440 | 1440 | ), |
1441 | 1441 | 'data' => array( |
1442 | - 'function' => function ($rowData) use ($txt) |
|
1442 | + 'function' => function($rowData) use ($txt) |
|
1443 | 1443 | { |
1444 | 1444 | $textKey = sprintf('custom_profile_type_%1$s', $rowData['field_type']); |
1445 | 1445 | return isset($txt[$textKey]) ? $txt[$textKey] : $textKey; |
@@ -1457,7 +1457,7 @@ discard block |
||
1457 | 1457 | 'value' => $txt['custom_profile_active'], |
1458 | 1458 | ), |
1459 | 1459 | 'data' => array( |
1460 | - 'function' => function ($rowData) use ($txt) |
|
1460 | + 'function' => function($rowData) use ($txt) |
|
1461 | 1461 | { |
1462 | 1462 | return $rowData['active'] ? $txt['yes'] : $txt['no']; |
1463 | 1463 | }, |
@@ -1474,7 +1474,7 @@ discard block |
||
1474 | 1474 | 'value' => $txt['custom_profile_placement'], |
1475 | 1475 | ), |
1476 | 1476 | 'data' => array( |
1477 | - 'function' => function ($rowData) |
|
1477 | + 'function' => function($rowData) |
|
1478 | 1478 | { |
1479 | 1479 | global $txt, $context; |
1480 | 1480 | |
@@ -1709,7 +1709,7 @@ discard block |
||
1709 | 1709 | redirectexit('action=admin;area=featuresettings;sa=profile'); // @todo implement an error handler |
1710 | 1710 | |
1711 | 1711 | // All good, proceed. |
1712 | - $smcFunc['db_query']('',' |
|
1712 | + $smcFunc['db_query']('', ' |
|
1713 | 1713 | UPDATE {db_prefix}custom_fields |
1714 | 1714 | SET field_order = {int:old_order} |
1715 | 1715 | WHERE field_order = {int:new_order}', |
@@ -1718,7 +1718,7 @@ discard block |
||
1718 | 1718 | 'old_order' => $context['field']['order'], |
1719 | 1719 | ) |
1720 | 1720 | ); |
1721 | - $smcFunc['db_query']('',' |
|
1721 | + $smcFunc['db_query']('', ' |
|
1722 | 1722 | UPDATE {db_prefix}custom_fields |
1723 | 1723 | SET field_order = {int:new_order} |
1724 | 1724 | WHERE id_field = {int:id_field}', |
@@ -1820,7 +1820,7 @@ discard block |
||
1820 | 1820 | $smcFunc['db_free_result']($request); |
1821 | 1821 | |
1822 | 1822 | $unique = false; |
1823 | - for ($i = 0; !$unique && $i < 9; $i ++) |
|
1823 | + for ($i = 0; !$unique && $i < 9; $i++) |
|
1824 | 1824 | { |
1825 | 1825 | if (!in_array($col_name, $current_fields)) |
1826 | 1826 | $unique = true; |
@@ -1993,7 +1993,7 @@ discard block |
||
1993 | 1993 | ); |
1994 | 1994 | |
1995 | 1995 | // Re-arrange the order. |
1996 | - $smcFunc['db_query']('',' |
|
1996 | + $smcFunc['db_query']('', ' |
|
1997 | 1997 | UPDATE {db_prefix}custom_fields |
1998 | 1998 | SET field_order = field_order - 1 |
1999 | 1999 | WHERE field_order > {int:current_order}', |
@@ -2257,7 +2257,7 @@ discard block |
||
2257 | 2257 | $context['token_check'] = 'noti-admin'; |
2258 | 2258 | |
2259 | 2259 | // Specify our action since we'll want to post back here instead of the profile |
2260 | - $context['action'] = 'action=admin;area=featuresettings;sa=alerts;'. $context['session_var'] .'='. $context['session_id']; |
|
2260 | + $context['action'] = 'action=admin;area=featuresettings;sa=alerts;' . $context['session_var'] . '=' . $context['session_id']; |
|
2261 | 2261 | |
2262 | 2262 | loadTemplate('Profile'); |
2263 | 2263 | loadLanguage('Profile'); |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | * @version 2.1 Beta 4 |
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 | * This function makes sure the requested subaction does exists, if it doesn't, it sets a default action or. |
@@ -206,16 +207,18 @@ discard block |
||
206 | 207 | { |
207 | 208 | $all_zones = timezone_identifiers_list(); |
208 | 209 | // Make sure we set the value to the same as the printed value. |
209 | - foreach ($all_zones as $zone) |
|
210 | - $config_vars['default_timezone'][2][$zone] = $zone; |
|
210 | + foreach ($all_zones as $zone) { |
|
211 | + $config_vars['default_timezone'][2][$zone] = $zone; |
|
212 | + } |
|
213 | + } else { |
|
214 | + unset($config_vars['default_timezone']); |
|
211 | 215 | } |
212 | - else |
|
213 | - unset($config_vars['default_timezone']); |
|
214 | 216 | |
215 | 217 | call_integration_hook('integrate_modify_basic_settings', array(&$config_vars)); |
216 | 218 | |
217 | - if ($return_config) |
|
218 | - return $config_vars; |
|
219 | + if ($return_config) { |
|
220 | + return $config_vars; |
|
221 | + } |
|
219 | 222 | |
220 | 223 | // Saving? |
221 | 224 | if (isset($_GET['save'])) |
@@ -223,8 +226,9 @@ discard block |
||
223 | 226 | checkSession(); |
224 | 227 | |
225 | 228 | // Prevent absurd boundaries here - make it a day tops. |
226 | - if (isset($_POST['lastActive'])) |
|
227 | - $_POST['lastActive'] = min((int) $_POST['lastActive'], 1440); |
|
229 | + if (isset($_POST['lastActive'])) { |
|
230 | + $_POST['lastActive'] = min((int) $_POST['lastActive'], 1440); |
|
231 | + } |
|
228 | 232 | |
229 | 233 | call_integration_hook('integrate_save_basic_settings'); |
230 | 234 | |
@@ -269,8 +273,9 @@ discard block |
||
269 | 273 | |
270 | 274 | call_integration_hook('integrate_modify_bbc_settings', array(&$config_vars)); |
271 | 275 | |
272 | - if ($return_config) |
|
273 | - return $config_vars; |
|
276 | + if ($return_config) { |
|
277 | + return $config_vars; |
|
278 | + } |
|
274 | 279 | |
275 | 280 | // Setup the template. |
276 | 281 | require_once($sourcedir . '/ManageServer.php'); |
@@ -287,13 +292,15 @@ discard block |
||
287 | 292 | |
288 | 293 | // Clean up the tags. |
289 | 294 | $bbcTags = array(); |
290 | - foreach (parse_bbc(false) as $tag) |
|
291 | - $bbcTags[] = $tag['tag']; |
|
295 | + foreach (parse_bbc(false) as $tag) { |
|
296 | + $bbcTags[] = $tag['tag']; |
|
297 | + } |
|
292 | 298 | |
293 | - if (!isset($_POST['disabledBBC_enabledTags'])) |
|
294 | - $_POST['disabledBBC_enabledTags'] = array(); |
|
295 | - elseif (!is_array($_POST['disabledBBC_enabledTags'])) |
|
296 | - $_POST['disabledBBC_enabledTags'] = array($_POST['disabledBBC_enabledTags']); |
|
299 | + if (!isset($_POST['disabledBBC_enabledTags'])) { |
|
300 | + $_POST['disabledBBC_enabledTags'] = array(); |
|
301 | + } elseif (!is_array($_POST['disabledBBC_enabledTags'])) { |
|
302 | + $_POST['disabledBBC_enabledTags'] = array($_POST['disabledBBC_enabledTags']); |
|
303 | + } |
|
297 | 304 | // Work out what is actually disabled! |
298 | 305 | $_POST['disabledBBC'] = implode(',', array_diff($bbcTags, $_POST['disabledBBC_enabledTags'])); |
299 | 306 | |
@@ -337,8 +344,9 @@ discard block |
||
337 | 344 | |
338 | 345 | call_integration_hook('integrate_layout_settings', array(&$config_vars)); |
339 | 346 | |
340 | - if ($return_config) |
|
341 | - return $config_vars; |
|
347 | + if ($return_config) { |
|
348 | + return $config_vars; |
|
349 | + } |
|
342 | 350 | |
343 | 351 | // Saving? |
344 | 352 | if (isset($_GET['save'])) |
@@ -379,8 +387,9 @@ discard block |
||
379 | 387 | |
380 | 388 | call_integration_hook('integrate_likes_settings', array(&$config_vars)); |
381 | 389 | |
382 | - if ($return_config) |
|
383 | - return $config_vars; |
|
390 | + if ($return_config) { |
|
391 | + return $config_vars; |
|
392 | + } |
|
384 | 393 | |
385 | 394 | // Saving? |
386 | 395 | if (isset($_GET['save'])) |
@@ -418,8 +427,9 @@ discard block |
||
418 | 427 | |
419 | 428 | call_integration_hook('integrate_mentions_settings', array(&$config_vars)); |
420 | 429 | |
421 | - if ($return_config) |
|
422 | - return $config_vars; |
|
430 | + if ($return_config) { |
|
431 | + return $config_vars; |
|
432 | + } |
|
423 | 433 | |
424 | 434 | // Saving? |
425 | 435 | if (isset($_GET['save'])) |
@@ -463,8 +473,8 @@ discard block |
||
463 | 473 | 'enable' => array('check', 'warning_enable'), |
464 | 474 | ); |
465 | 475 | |
466 | - if (!empty($modSettings['warning_settings']) && $currently_enabled) |
|
467 | - $config_vars += array( |
|
476 | + if (!empty($modSettings['warning_settings']) && $currently_enabled) { |
|
477 | + $config_vars += array( |
|
468 | 478 | '', |
469 | 479 | array('int', 'warning_watch', 'subtext' => $txt['setting_warning_watch_note'] . ' ' . $txt['zero_to_disable']), |
470 | 480 | 'moderate' => array('int', 'warning_moderate', 'subtext' => $txt['setting_warning_moderate_note'] . ' ' . $txt['zero_to_disable']), |
@@ -473,15 +483,18 @@ discard block |
||
473 | 483 | 'rem2' => array('int', 'warning_decrement', 'subtext' => $txt['setting_warning_decrement_note'] . ' ' . $txt['zero_to_disable']), |
474 | 484 | array('permissions', 'view_warning'), |
475 | 485 | ); |
486 | + } |
|
476 | 487 | |
477 | 488 | call_integration_hook('integrate_warning_settings', array(&$config_vars)); |
478 | 489 | |
479 | - if ($return_config) |
|
480 | - return $config_vars; |
|
490 | + if ($return_config) { |
|
491 | + return $config_vars; |
|
492 | + } |
|
481 | 493 | |
482 | 494 | // Cannot use moderation if post moderation is not enabled. |
483 | - if (!$modSettings['postmod_active']) |
|
484 | - unset($config_vars['moderate']); |
|
495 | + if (!$modSettings['postmod_active']) { |
|
496 | + unset($config_vars['moderate']); |
|
497 | + } |
|
485 | 498 | |
486 | 499 | // Will need the utility functions from here. |
487 | 500 | require_once($sourcedir . '/ManageServer.php'); |
@@ -506,16 +519,16 @@ discard block |
||
506 | 519 | 'warning_watch' => 10, |
507 | 520 | 'warning_mute' => 60, |
508 | 521 | ); |
509 | - if ($modSettings['postmod_active']) |
|
510 | - $vars['warning_moderate'] = 35; |
|
522 | + if ($modSettings['postmod_active']) { |
|
523 | + $vars['warning_moderate'] = 35; |
|
524 | + } |
|
511 | 525 | |
512 | 526 | foreach ($vars as $var => $value) |
513 | 527 | { |
514 | 528 | $config_vars[] = array('int', $var); |
515 | 529 | $_POST[$var] = $value; |
516 | 530 | } |
517 | - } |
|
518 | - else |
|
531 | + } else |
|
519 | 532 | { |
520 | 533 | $_POST['warning_watch'] = min($_POST['warning_watch'], 100); |
521 | 534 | $_POST['warning_moderate'] = $modSettings['postmod_active'] ? min($_POST['warning_moderate'], 100) : 0; |
@@ -603,8 +616,9 @@ discard block |
||
603 | 616 | |
604 | 617 | call_integration_hook('integrate_spam_settings', array(&$config_vars)); |
605 | 618 | |
606 | - if ($return_config) |
|
607 | - return $config_vars; |
|
619 | + if ($return_config) { |
|
620 | + return $config_vars; |
|
621 | + } |
|
608 | 622 | |
609 | 623 | // You need to be an admin to edit settings! |
610 | 624 | isAllowedTo('admin_forum'); |
@@ -638,8 +652,9 @@ discard block |
||
638 | 652 | |
639 | 653 | if (empty($context['qa_by_lang'][strtr($language, array('-utf8' => ''))]) && !empty($context['question_answers'])) |
640 | 654 | { |
641 | - if (empty($context['settings_insert_above'])) |
|
642 | - $context['settings_insert_above'] = ''; |
|
655 | + if (empty($context['settings_insert_above'])) { |
|
656 | + $context['settings_insert_above'] = ''; |
|
657 | + } |
|
643 | 658 | |
644 | 659 | $context['settings_insert_above'] .= '<div class="noticebox">' . sprintf($txt['question_not_defined'], $context['languages'][$language]['name']) . '</div>'; |
645 | 660 | } |
@@ -682,8 +697,9 @@ discard block |
||
682 | 697 | $_POST['pm_spam_settings'] = (int) $_POST['max_pm_recipients'] . ',' . (int) $_POST['pm_posts_verification'] . ',' . (int) $_POST['pm_posts_per_hour']; |
683 | 698 | |
684 | 699 | // Hack in guest requiring verification! |
685 | - if (empty($_POST['posts_require_captcha']) && !empty($_POST['guests_require_captcha'])) |
|
686 | - $_POST['posts_require_captcha'] = -1; |
|
700 | + if (empty($_POST['posts_require_captcha']) && !empty($_POST['guests_require_captcha'])) { |
|
701 | + $_POST['posts_require_captcha'] = -1; |
|
702 | + } |
|
687 | 703 | |
688 | 704 | $save_vars = $config_vars; |
689 | 705 | unset($save_vars['pm1'], $save_vars['pm2'], $save_vars['pm3'], $save_vars['guest_verify']); |
@@ -700,14 +716,16 @@ discard block |
||
700 | 716 | foreach ($context['qa_languages'] as $lang_id => $dummy) |
701 | 717 | { |
702 | 718 | // If we had some questions for this language before, but don't now, delete everything from that language. |
703 | - if ((!isset($_POST['question'][$lang_id]) || !is_array($_POST['question'][$lang_id])) && !empty($context['qa_by_lang'][$lang_id])) |
|
704 | - $changes['delete'] = array_merge($questions['delete'], $context['qa_by_lang'][$lang_id]); |
|
719 | + if ((!isset($_POST['question'][$lang_id]) || !is_array($_POST['question'][$lang_id])) && !empty($context['qa_by_lang'][$lang_id])) { |
|
720 | + $changes['delete'] = array_merge($questions['delete'], $context['qa_by_lang'][$lang_id]); |
|
721 | + } |
|
705 | 722 | |
706 | 723 | // Now step through and see if any existing questions no longer exist. |
707 | - if (!empty($context['qa_by_lang'][$lang_id])) |
|
708 | - foreach ($context['qa_by_lang'][$lang_id] as $q_id) |
|
724 | + if (!empty($context['qa_by_lang'][$lang_id])) { |
|
725 | + foreach ($context['qa_by_lang'][$lang_id] as $q_id) |
|
709 | 726 | if (empty($_POST['question'][$lang_id][$q_id])) |
710 | 727 | $changes['delete'][] = $q_id; |
728 | + } |
|
711 | 729 | |
712 | 730 | // Now let's see if there are new questions or ones that need updating. |
713 | 731 | if (isset($_POST['question'][$lang_id])) |
@@ -716,14 +734,16 @@ discard block |
||
716 | 734 | { |
717 | 735 | // Ignore junky ids. |
718 | 736 | $q_id = (int) $q_id; |
719 | - if ($q_id <= 0) |
|
720 | - continue; |
|
737 | + if ($q_id <= 0) { |
|
738 | + continue; |
|
739 | + } |
|
721 | 740 | |
722 | 741 | // Check the question isn't empty (because they want to delete it?) |
723 | 742 | if (empty($question) || trim($question) == '') |
724 | 743 | { |
725 | - if (isset($context['question_answers'][$q_id])) |
|
726 | - $changes['delete'][] = $q_id; |
|
744 | + if (isset($context['question_answers'][$q_id])) { |
|
745 | + $changes['delete'][] = $q_id; |
|
746 | + } |
|
727 | 747 | continue; |
728 | 748 | } |
729 | 749 | $question = $smcFunc['htmlspecialchars'](trim($question)); |
@@ -731,19 +751,22 @@ discard block |
||
731 | 751 | // Get the answers. Firstly check there actually might be some. |
732 | 752 | if (!isset($_POST['answer'][$lang_id][$q_id]) || !is_array($_POST['answer'][$lang_id][$q_id])) |
733 | 753 | { |
734 | - if (isset($context['question_answers'][$q_id])) |
|
735 | - $changes['delete'][] = $q_id; |
|
754 | + if (isset($context['question_answers'][$q_id])) { |
|
755 | + $changes['delete'][] = $q_id; |
|
756 | + } |
|
736 | 757 | continue; |
737 | 758 | } |
738 | 759 | // Now get them and check that they might be viable. |
739 | 760 | $answers = array(); |
740 | - foreach ($_POST['answer'][$lang_id][$q_id] as $answer) |
|
741 | - if (!empty($answer) && trim($answer) !== '') |
|
761 | + foreach ($_POST['answer'][$lang_id][$q_id] as $answer) { |
|
762 | + if (!empty($answer) && trim($answer) !== '') |
|
742 | 763 | $answers[] = $smcFunc['htmlspecialchars'](trim($answer)); |
764 | + } |
|
743 | 765 | if (empty($answers)) |
744 | 766 | { |
745 | - if (isset($context['question_answers'][$q_id])) |
|
746 | - $changes['delete'][] = $q_id; |
|
767 | + if (isset($context['question_answers'][$q_id])) { |
|
768 | + $changes['delete'][] = $q_id; |
|
769 | + } |
|
747 | 770 | continue; |
748 | 771 | } |
749 | 772 | $answers = $smcFunc['json_encode']($answers); |
@@ -753,16 +776,17 @@ discard block |
||
753 | 776 | { |
754 | 777 | // New question. Now, we don't want to randomly consume ids, so we'll set those, rather than trusting the browser's supplied ids. |
755 | 778 | $changes['insert'][] = array($lang_id, $question, $answers); |
756 | - } |
|
757 | - else |
|
779 | + } else |
|
758 | 780 | { |
759 | 781 | // It's an existing question. Let's see what's changed, if anything. |
760 | - if ($lang_id != $context['question_answers'][$q_id]['lngfile'] || $question != $context['question_answers'][$q_id]['question'] || $answers != $context['question_answers'][$q_id]['answers']) |
|
761 | - $changes['replace'][$q_id] = array('lngfile' => $lang_id, 'question' => $question, 'answers' => $answers); |
|
782 | + if ($lang_id != $context['question_answers'][$q_id]['lngfile'] || $question != $context['question_answers'][$q_id]['question'] || $answers != $context['question_answers'][$q_id]['answers']) { |
|
783 | + $changes['replace'][$q_id] = array('lngfile' => $lang_id, 'question' => $question, 'answers' => $answers); |
|
784 | + } |
|
762 | 785 | } |
763 | 786 | |
764 | - if (!isset($qs_per_lang[$lang_id])) |
|
765 | - $qs_per_lang[$lang_id] = 0; |
|
787 | + if (!isset($qs_per_lang[$lang_id])) { |
|
788 | + $qs_per_lang[$lang_id] = 0; |
|
789 | + } |
|
766 | 790 | $qs_per_lang[$lang_id]++; |
767 | 791 | } |
768 | 792 | } |
@@ -812,8 +836,9 @@ discard block |
||
812 | 836 | |
813 | 837 | // Lastly, the count of messages needs to be no more than the lowest number of questions for any one language. |
814 | 838 | $count_questions = empty($qs_per_lang) ? 0 : min($qs_per_lang); |
815 | - if (empty($count_questions) || $_POST['qa_verification_number'] > $count_questions) |
|
816 | - $_POST['qa_verification_number'] = $count_questions; |
|
839 | + if (empty($count_questions) || $_POST['qa_verification_number'] > $count_questions) { |
|
840 | + $_POST['qa_verification_number'] = $count_questions; |
|
841 | + } |
|
817 | 842 | |
818 | 843 | call_integration_hook('integrate_save_spam_settings', array(&$save_vars)); |
819 | 844 | |
@@ -828,24 +853,27 @@ discard block |
||
828 | 853 | |
829 | 854 | $character_range = array_merge(range('A', 'H'), array('K', 'M', 'N', 'P', 'R'), range('T', 'Y')); |
830 | 855 | $_SESSION['visual_verification_code'] = ''; |
831 | - for ($i = 0; $i < 6; $i++) |
|
832 | - $_SESSION['visual_verification_code'] .= $character_range[array_rand($character_range)]; |
|
856 | + for ($i = 0; $i < 6; $i++) { |
|
857 | + $_SESSION['visual_verification_code'] .= $character_range[array_rand($character_range)]; |
|
858 | + } |
|
833 | 859 | |
834 | 860 | // Some javascript for CAPTCHA. |
835 | 861 | $context['settings_post_javascript'] = ''; |
836 | - if ($context['use_graphic_library']) |
|
837 | - $context['settings_post_javascript'] .= ' |
|
862 | + if ($context['use_graphic_library']) { |
|
863 | + $context['settings_post_javascript'] .= ' |
|
838 | 864 | function refreshImages() |
839 | 865 | { |
840 | 866 | var imageType = document.getElementById(\'visual_verification_type\').value; |
841 | 867 | document.getElementById(\'verification_image\').src = \'' . $context['verification_image_href'] . ';type=\' + imageType; |
842 | 868 | }'; |
869 | + } |
|
843 | 870 | |
844 | 871 | // Show the image itself, or text saying we can't. |
845 | - if ($context['use_graphic_library']) |
|
846 | - $config_vars['vv']['postinput'] = '<br><img src="' . $context['verification_image_href'] . ';type=' . (empty($modSettings['visual_verification_type']) ? 0 : $modSettings['visual_verification_type']) . '" alt="' . $txt['setting_image_verification_sample'] . '" id="verification_image"><br>'; |
|
847 | - else |
|
848 | - $config_vars['vv']['postinput'] = '<br><span class="smalltext">' . $txt['setting_image_verification_nogd'] . '</span>'; |
|
872 | + if ($context['use_graphic_library']) { |
|
873 | + $config_vars['vv']['postinput'] = '<br><img src="' . $context['verification_image_href'] . ';type=' . (empty($modSettings['visual_verification_type']) ? 0 : $modSettings['visual_verification_type']) . '" alt="' . $txt['setting_image_verification_sample'] . '" id="verification_image"><br>'; |
|
874 | + } else { |
|
875 | + $config_vars['vv']['postinput'] = '<br><span class="smalltext">' . $txt['setting_image_verification_nogd'] . '</span>'; |
|
876 | + } |
|
849 | 877 | |
850 | 878 | // Hack for PM spam settings. |
851 | 879 | list ($modSettings['max_pm_recipients'], $modSettings['pm_posts_verification'], $modSettings['pm_posts_per_hour']) = explode(',', $modSettings['pm_spam_settings']); |
@@ -855,9 +883,10 @@ discard block |
||
855 | 883 | $modSettings['posts_require_captcha'] = !isset($modSettings['posts_require_captcha']) || $modSettings['posts_require_captcha'] == -1 ? 0 : $modSettings['posts_require_captcha']; |
856 | 884 | |
857 | 885 | // Some minor javascript for the guest post setting. |
858 | - if ($modSettings['posts_require_captcha']) |
|
859 | - $context['settings_post_javascript'] .= ' |
|
886 | + if ($modSettings['posts_require_captcha']) { |
|
887 | + $context['settings_post_javascript'] .= ' |
|
860 | 888 | document.getElementById(\'guests_require_captcha\').disabled = true;'; |
889 | + } |
|
861 | 890 | |
862 | 891 | // And everything else. |
863 | 892 | $context['post_url'] = $scripturl . '?action=admin;area=antispam;save'; |
@@ -904,8 +933,9 @@ discard block |
||
904 | 933 | |
905 | 934 | call_integration_hook('integrate_signature_settings', array(&$config_vars)); |
906 | 935 | |
907 | - if ($return_config) |
|
908 | - return $config_vars; |
|
936 | + if ($return_config) { |
|
937 | + return $config_vars; |
|
938 | + } |
|
909 | 939 | |
910 | 940 | // Setup the template. |
911 | 941 | $context['page_title'] = $txt['signature_settings']; |
@@ -960,8 +990,9 @@ discard block |
||
960 | 990 | $sig = strtr($row['signature'], array('<br>' => "\n")); |
961 | 991 | |
962 | 992 | // Max characters... |
963 | - if (!empty($sig_limits[1])) |
|
964 | - $sig = $smcFunc['substr']($sig, 0, $sig_limits[1]); |
|
993 | + if (!empty($sig_limits[1])) { |
|
994 | + $sig = $smcFunc['substr']($sig, 0, $sig_limits[1]); |
|
995 | + } |
|
965 | 996 | // Max lines... |
966 | 997 | if (!empty($sig_limits[2])) |
967 | 998 | { |
@@ -971,8 +1002,9 @@ discard block |
||
971 | 1002 | if ($sig[$i] == "\n") |
972 | 1003 | { |
973 | 1004 | $count++; |
974 | - if ($count >= $sig_limits[2]) |
|
975 | - $sig = substr($sig, 0, $i) . strtr(substr($sig, $i), array("\n" => ' ')); |
|
1005 | + if ($count >= $sig_limits[2]) { |
|
1006 | + $sig = substr($sig, 0, $i) . strtr(substr($sig, $i), array("\n" => ' ')); |
|
1007 | + } |
|
976 | 1008 | } |
977 | 1009 | } |
978 | 1010 | } |
@@ -983,17 +1015,19 @@ discard block |
||
983 | 1015 | { |
984 | 1016 | $limit_broke = 0; |
985 | 1017 | // Attempt to allow all sizes of abuse, so to speak. |
986 | - if ($matches[2][$ind] == 'px' && $size > $sig_limits[7]) |
|
987 | - $limit_broke = $sig_limits[7] . 'px'; |
|
988 | - elseif ($matches[2][$ind] == 'pt' && $size > ($sig_limits[7] * 0.75)) |
|
989 | - $limit_broke = ((int) $sig_limits[7] * 0.75) . 'pt'; |
|
990 | - elseif ($matches[2][$ind] == 'em' && $size > ((float) $sig_limits[7] / 16)) |
|
991 | - $limit_broke = ((float) $sig_limits[7] / 16) . 'em'; |
|
992 | - elseif ($matches[2][$ind] != 'px' && $matches[2][$ind] != 'pt' && $matches[2][$ind] != 'em' && $sig_limits[7] < 18) |
|
993 | - $limit_broke = 'large'; |
|
994 | - |
|
995 | - if ($limit_broke) |
|
996 | - $sig = str_replace($matches[0][$ind], '[size=' . $sig_limits[7] . 'px', $sig); |
|
1018 | + if ($matches[2][$ind] == 'px' && $size > $sig_limits[7]) { |
|
1019 | + $limit_broke = $sig_limits[7] . 'px'; |
|
1020 | + } elseif ($matches[2][$ind] == 'pt' && $size > ($sig_limits[7] * 0.75)) { |
|
1021 | + $limit_broke = ((int) $sig_limits[7] * 0.75) . 'pt'; |
|
1022 | + } elseif ($matches[2][$ind] == 'em' && $size > ((float) $sig_limits[7] / 16)) { |
|
1023 | + $limit_broke = ((float) $sig_limits[7] / 16) . 'em'; |
|
1024 | + } elseif ($matches[2][$ind] != 'px' && $matches[2][$ind] != 'pt' && $matches[2][$ind] != 'em' && $sig_limits[7] < 18) { |
|
1025 | + $limit_broke = 'large'; |
|
1026 | + } |
|
1027 | + |
|
1028 | + if ($limit_broke) { |
|
1029 | + $sig = str_replace($matches[0][$ind], '[size=' . $sig_limits[7] . 'px', $sig); |
|
1030 | + } |
|
997 | 1031 | } |
998 | 1032 | } |
999 | 1033 | |
@@ -1049,32 +1083,34 @@ discard block |
||
1049 | 1083 | $img_offset = false; |
1050 | 1084 | } |
1051 | 1085 | } |
1086 | + } else { |
|
1087 | + $replaces[$image] = ''; |
|
1052 | 1088 | } |
1053 | - else |
|
1054 | - $replaces[$image] = ''; |
|
1055 | 1089 | |
1056 | 1090 | continue; |
1057 | 1091 | } |
1058 | 1092 | |
1059 | 1093 | // Does it have predefined restraints? Width first. |
1060 | - if ($matches[6][$key]) |
|
1061 | - $matches[2][$key] = $matches[6][$key]; |
|
1094 | + if ($matches[6][$key]) { |
|
1095 | + $matches[2][$key] = $matches[6][$key]; |
|
1096 | + } |
|
1062 | 1097 | if ($matches[2][$key] && $sig_limits[5] && $matches[2][$key] > $sig_limits[5]) |
1063 | 1098 | { |
1064 | 1099 | $width = $sig_limits[5]; |
1065 | 1100 | $matches[4][$key] = $matches[4][$key] * ($width / $matches[2][$key]); |
1101 | + } elseif ($matches[2][$key]) { |
|
1102 | + $width = $matches[2][$key]; |
|
1066 | 1103 | } |
1067 | - elseif ($matches[2][$key]) |
|
1068 | - $width = $matches[2][$key]; |
|
1069 | 1104 | // ... and height. |
1070 | 1105 | if ($matches[4][$key] && $sig_limits[6] && $matches[4][$key] > $sig_limits[6]) |
1071 | 1106 | { |
1072 | 1107 | $height = $sig_limits[6]; |
1073 | - if ($width != -1) |
|
1074 | - $width = $width * ($height / $matches[4][$key]); |
|
1108 | + if ($width != -1) { |
|
1109 | + $width = $width * ($height / $matches[4][$key]); |
|
1110 | + } |
|
1111 | + } elseif ($matches[4][$key]) { |
|
1112 | + $height = $matches[4][$key]; |
|
1075 | 1113 | } |
1076 | - elseif ($matches[4][$key]) |
|
1077 | - $height = $matches[4][$key]; |
|
1078 | 1114 | |
1079 | 1115 | // If the dimensions are still not fixed - we need to check the actual image. |
1080 | 1116 | if (($width == -1 && $sig_limits[5]) || ($height == -1 && $sig_limits[6])) |
@@ -1092,12 +1128,13 @@ discard block |
||
1092 | 1128 | if ($sizes[1] > $sig_limits[6] && $sig_limits[6]) |
1093 | 1129 | { |
1094 | 1130 | $height = $sig_limits[6]; |
1095 | - if ($width == -1) |
|
1096 | - $width = $sizes[0]; |
|
1131 | + if ($width == -1) { |
|
1132 | + $width = $sizes[0]; |
|
1133 | + } |
|
1097 | 1134 | $width = $width * ($height / $sizes[1]); |
1135 | + } elseif ($width != -1) { |
|
1136 | + $height = $sizes[1]; |
|
1098 | 1137 | } |
1099 | - elseif ($width != -1) |
|
1100 | - $height = $sizes[1]; |
|
1101 | 1138 | } |
1102 | 1139 | } |
1103 | 1140 | |
@@ -1110,8 +1147,9 @@ discard block |
||
1110 | 1147 | // Record that we got one. |
1111 | 1148 | $image_count_holder[$image] = isset($image_count_holder[$image]) ? $image_count_holder[$image] + 1 : 1; |
1112 | 1149 | } |
1113 | - if (!empty($replaces)) |
|
1114 | - $sig = str_replace(array_keys($replaces), array_values($replaces), $sig); |
|
1150 | + if (!empty($replaces)) { |
|
1151 | + $sig = str_replace(array_keys($replaces), array_values($replaces), $sig); |
|
1152 | + } |
|
1115 | 1153 | } |
1116 | 1154 | } |
1117 | 1155 | // Try to fix disabled tags. |
@@ -1123,18 +1161,20 @@ discard block |
||
1123 | 1161 | |
1124 | 1162 | $sig = strtr($sig, array("\n" => '<br>')); |
1125 | 1163 | call_integration_hook('integrate_apply_signature_settings', array(&$sig, $sig_limits, $disabledTags)); |
1126 | - if ($sig != $row['signature']) |
|
1127 | - $changes[$row['id_member']] = $sig; |
|
1164 | + if ($sig != $row['signature']) { |
|
1165 | + $changes[$row['id_member']] = $sig; |
|
1166 | + } |
|
1167 | + } |
|
1168 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
1169 | + $done = true; |
|
1128 | 1170 | } |
1129 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
1130 | - $done = true; |
|
1131 | 1171 | $smcFunc['db_free_result']($request); |
1132 | 1172 | |
1133 | 1173 | // Do we need to delete what we have? |
1134 | 1174 | if (!empty($changes)) |
1135 | 1175 | { |
1136 | - foreach ($changes as $id => $sig) |
|
1137 | - $smcFunc['db_query']('', ' |
|
1176 | + foreach ($changes as $id => $sig) { |
|
1177 | + $smcFunc['db_query']('', ' |
|
1138 | 1178 | UPDATE {db_prefix}members |
1139 | 1179 | SET signature = {string:signature} |
1140 | 1180 | WHERE id_member = {int:id_member}', |
@@ -1143,11 +1183,13 @@ discard block |
||
1143 | 1183 | 'signature' => $sig, |
1144 | 1184 | ) |
1145 | 1185 | ); |
1186 | + } |
|
1146 | 1187 | } |
1147 | 1188 | |
1148 | 1189 | $_GET['step'] += 50; |
1149 | - if (!$done) |
|
1150 | - pauseSignatureApplySettings(); |
|
1190 | + if (!$done) { |
|
1191 | + pauseSignatureApplySettings(); |
|
1192 | + } |
|
1151 | 1193 | } |
1152 | 1194 | $settings_applied = true; |
1153 | 1195 | } |
@@ -1165,8 +1207,9 @@ discard block |
||
1165 | 1207 | ); |
1166 | 1208 | |
1167 | 1209 | // Temporarily make each setting a modSetting! |
1168 | - foreach ($context['signature_settings'] as $key => $value) |
|
1169 | - $modSettings['signature_' . $key] = $value; |
|
1210 | + foreach ($context['signature_settings'] as $key => $value) { |
|
1211 | + $modSettings['signature_' . $key] = $value; |
|
1212 | + } |
|
1170 | 1213 | |
1171 | 1214 | // Make sure we check the right tags! |
1172 | 1215 | $modSettings['bbc_disabled_signature_bbc'] = $disabledTags; |
@@ -1178,23 +1221,26 @@ discard block |
||
1178 | 1221 | |
1179 | 1222 | // Clean up the tag stuff! |
1180 | 1223 | $bbcTags = array(); |
1181 | - foreach (parse_bbc(false) as $tag) |
|
1182 | - $bbcTags[] = $tag['tag']; |
|
1224 | + foreach (parse_bbc(false) as $tag) { |
|
1225 | + $bbcTags[] = $tag['tag']; |
|
1226 | + } |
|
1183 | 1227 | |
1184 | - if (!isset($_POST['signature_bbc_enabledTags'])) |
|
1185 | - $_POST['signature_bbc_enabledTags'] = array(); |
|
1186 | - elseif (!is_array($_POST['signature_bbc_enabledTags'])) |
|
1187 | - $_POST['signature_bbc_enabledTags'] = array($_POST['signature_bbc_enabledTags']); |
|
1228 | + if (!isset($_POST['signature_bbc_enabledTags'])) { |
|
1229 | + $_POST['signature_bbc_enabledTags'] = array(); |
|
1230 | + } elseif (!is_array($_POST['signature_bbc_enabledTags'])) { |
|
1231 | + $_POST['signature_bbc_enabledTags'] = array($_POST['signature_bbc_enabledTags']); |
|
1232 | + } |
|
1188 | 1233 | |
1189 | 1234 | $sig_limits = array(); |
1190 | 1235 | foreach ($context['signature_settings'] as $key => $value) |
1191 | 1236 | { |
1192 | - if ($key == 'allow_smileys') |
|
1193 | - continue; |
|
1194 | - elseif ($key == 'max_smileys' && empty($_POST['signature_allow_smileys'])) |
|
1195 | - $sig_limits[] = -1; |
|
1196 | - else |
|
1197 | - $sig_limits[] = !empty($_POST['signature_' . $key]) ? max(1, (int) $_POST['signature_' . $key]) : 0; |
|
1237 | + if ($key == 'allow_smileys') { |
|
1238 | + continue; |
|
1239 | + } elseif ($key == 'max_smileys' && empty($_POST['signature_allow_smileys'])) { |
|
1240 | + $sig_limits[] = -1; |
|
1241 | + } else { |
|
1242 | + $sig_limits[] = !empty($_POST['signature_' . $key]) ? max(1, (int) $_POST['signature_' . $key]) : 0; |
|
1243 | + } |
|
1198 | 1244 | } |
1199 | 1245 | |
1200 | 1246 | call_integration_hook('integrate_save_signature_settings', array(&$sig_limits, &$bbcTags)); |
@@ -1227,12 +1273,14 @@ discard block |
||
1227 | 1273 | |
1228 | 1274 | // Try get more time... |
1229 | 1275 | @set_time_limit(600); |
1230 | - if (function_exists('apache_reset_timeout')) |
|
1231 | - @apache_reset_timeout(); |
|
1276 | + if (function_exists('apache_reset_timeout')) { |
|
1277 | + @apache_reset_timeout(); |
|
1278 | + } |
|
1232 | 1279 | |
1233 | 1280 | // Have we exhausted all the time we allowed? |
1234 | - if (time() - array_sum(explode(' ', $sig_start)) < 3) |
|
1235 | - return; |
|
1281 | + if (time() - array_sum(explode(' ', $sig_start)) < 3) { |
|
1282 | + return; |
|
1283 | + } |
|
1236 | 1284 | |
1237 | 1285 | $context['continue_get_data'] = '?action=admin;area=featuresettings;sa=sig;apply;step=' . $_GET['step'] . ';' . $context['session_var'] . '=' . $context['session_id']; |
1238 | 1286 | $context['page_title'] = $txt['not_done_title']; |
@@ -1278,9 +1326,10 @@ discard block |
||
1278 | 1326 | $disable_fields = array_flip($standard_fields); |
1279 | 1327 | if (!empty($_POST['active'])) |
1280 | 1328 | { |
1281 | - foreach ($_POST['active'] as $value) |
|
1282 | - if (isset($disable_fields[$value])) |
|
1329 | + foreach ($_POST['active'] as $value) { |
|
1330 | + if (isset($disable_fields[$value])) |
|
1283 | 1331 | unset($disable_fields[$value]); |
1332 | + } |
|
1284 | 1333 | } |
1285 | 1334 | // What we have left! |
1286 | 1335 | $changes['disabled_profile_fields'] = empty($disable_fields) ? '' : implode(',', array_keys($disable_fields)); |
@@ -1289,16 +1338,18 @@ discard block |
||
1289 | 1338 | $reg_fields = array(); |
1290 | 1339 | if (!empty($_POST['reg'])) |
1291 | 1340 | { |
1292 | - foreach ($_POST['reg'] as $value) |
|
1293 | - if (in_array($value, $standard_fields) && !isset($disable_fields[$value])) |
|
1341 | + foreach ($_POST['reg'] as $value) { |
|
1342 | + if (in_array($value, $standard_fields) && !isset($disable_fields[$value])) |
|
1294 | 1343 | $reg_fields[] = $value; |
1344 | + } |
|
1295 | 1345 | } |
1296 | 1346 | // What we have left! |
1297 | 1347 | $changes['registration_fields'] = empty($reg_fields) ? '' : implode(',', $reg_fields); |
1298 | 1348 | |
1299 | 1349 | $_SESSION['adm-save'] = true; |
1300 | - if (!empty($changes)) |
|
1301 | - updateSettings($changes); |
|
1350 | + if (!empty($changes)) { |
|
1351 | + updateSettings($changes); |
|
1352 | + } |
|
1302 | 1353 | } |
1303 | 1354 | |
1304 | 1355 | createToken('admin-scp'); |
@@ -1401,11 +1452,13 @@ discard block |
||
1401 | 1452 | { |
1402 | 1453 | $return = '<p class="centertext bold_text">'. $rowData['field_order'] .'<br>'; |
1403 | 1454 | |
1404 | - if ($rowData['field_order'] > 1) |
|
1405 | - $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=up"><span class="toggle_up" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_up'] .'"></span></a>'; |
|
1455 | + if ($rowData['field_order'] > 1) { |
|
1456 | + $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=up"><span class="toggle_up" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_up'] .'"></span></a>'; |
|
1457 | + } |
|
1406 | 1458 | |
1407 | - if ($rowData['field_order'] < $context['custFieldsMaxOrder']) |
|
1408 | - $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=down"><span class="toggle_down" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_down'] .'"></span></a>'; |
|
1459 | + if ($rowData['field_order'] < $context['custFieldsMaxOrder']) { |
|
1460 | + $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=down"><span class="toggle_down" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_down'] .'"></span></a>'; |
|
1461 | + } |
|
1409 | 1462 | |
1410 | 1463 | $return .= '</p>'; |
1411 | 1464 | |
@@ -1543,16 +1596,16 @@ discard block |
||
1543 | 1596 | $disabled_fields = isset($modSettings['disabled_profile_fields']) ? explode(',', $modSettings['disabled_profile_fields']) : array(); |
1544 | 1597 | $registration_fields = isset($modSettings['registration_fields']) ? explode(',', $modSettings['registration_fields']) : array(); |
1545 | 1598 | |
1546 | - foreach ($standard_fields as $field) |
|
1547 | - $list[] = array( |
|
1599 | + foreach ($standard_fields as $field) { |
|
1600 | + $list[] = array( |
|
1548 | 1601 | 'id' => $field, |
1549 | 1602 | 'label' => isset($txt['standard_profile_field_' . $field]) ? $txt['standard_profile_field_' . $field] : (isset($txt[$field]) ? $txt[$field] : $field), |
1550 | 1603 | 'disabled' => in_array($field, $disabled_fields), |
1551 | 1604 | 'on_register' => in_array($field, $registration_fields) && !in_array($field, $fields_no_registration), |
1552 | 1605 | 'can_show_register' => !in_array($field, $fields_no_registration), |
1553 | 1606 | ); |
1554 | - } |
|
1555 | - else |
|
1607 | + } |
|
1608 | + } else |
|
1556 | 1609 | { |
1557 | 1610 | // Load all the fields. |
1558 | 1611 | $request = $smcFunc['db_query']('', ' |
@@ -1566,8 +1619,9 @@ discard block |
||
1566 | 1619 | 'items_per_page' => $items_per_page, |
1567 | 1620 | ) |
1568 | 1621 | ); |
1569 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1570 | - $list[] = $row; |
|
1622 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1623 | + $list[] = $row; |
|
1624 | + } |
|
1571 | 1625 | $smcFunc['db_free_result']($request); |
1572 | 1626 | } |
1573 | 1627 | |
@@ -1633,9 +1687,9 @@ discard block |
||
1633 | 1687 | $context['field'] = array(); |
1634 | 1688 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1635 | 1689 | { |
1636 | - if ($row['field_type'] == 'textarea') |
|
1637 | - @list ($rows, $cols) = @explode(',', $row['default_value']); |
|
1638 | - else |
|
1690 | + if ($row['field_type'] == 'textarea') { |
|
1691 | + @list ($rows, $cols) = @explode(',', $row['default_value']); |
|
1692 | + } else |
|
1639 | 1693 | { |
1640 | 1694 | $rows = 3; |
1641 | 1695 | $cols = 30; |
@@ -1671,8 +1725,8 @@ discard block |
||
1671 | 1725 | } |
1672 | 1726 | |
1673 | 1727 | // Setup the default values as needed. |
1674 | - if (empty($context['field'])) |
|
1675 | - $context['field'] = array( |
|
1728 | + if (empty($context['field'])) { |
|
1729 | + $context['field'] = array( |
|
1676 | 1730 | 'name' => '', |
1677 | 1731 | 'col_name' => '???', |
1678 | 1732 | 'desc' => '', |
@@ -1697,6 +1751,7 @@ discard block |
||
1697 | 1751 | 'enclose' => '', |
1698 | 1752 | 'placement' => 0, |
1699 | 1753 | ); |
1754 | + } |
|
1700 | 1755 | |
1701 | 1756 | // Are we moving it? |
1702 | 1757 | if (isset($_GET['move']) && in_array($smcFunc['htmlspecialchars']($_GET['move']), $move_to)) |
@@ -1705,8 +1760,10 @@ discard block |
||
1705 | 1760 | $new_order = ($_GET['move'] == 'up' ? ($context['field']['order'] - 1) : ($context['field']['order'] + 1)); |
1706 | 1761 | |
1707 | 1762 | // Is this a valid position? |
1708 | - if ($new_order <= 0 || $new_order > $order_count) |
|
1709 | - redirectexit('action=admin;area=featuresettings;sa=profile'); // @todo implement an error handler |
|
1763 | + if ($new_order <= 0 || $new_order > $order_count) { |
|
1764 | + redirectexit('action=admin;area=featuresettings;sa=profile'); |
|
1765 | + } |
|
1766 | + // @todo implement an error handler |
|
1710 | 1767 | |
1711 | 1768 | // All good, proceed. |
1712 | 1769 | $smcFunc['db_query']('',' |
@@ -1737,12 +1794,14 @@ discard block |
||
1737 | 1794 | validateToken('admin-ecp'); |
1738 | 1795 | |
1739 | 1796 | // Everyone needs a name - even the (bracket) unknown... |
1740 | - if (trim($_POST['field_name']) == '') |
|
1741 | - redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $_GET['fid'] . ';msg=need_name'); |
|
1797 | + if (trim($_POST['field_name']) == '') { |
|
1798 | + redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $_GET['fid'] . ';msg=need_name'); |
|
1799 | + } |
|
1742 | 1800 | |
1743 | 1801 | // Regex you say? Do a very basic test to see if the pattern is valid |
1744 | - if (!empty($_POST['regex']) && @preg_match($_POST['regex'], 'dummy') === false) |
|
1745 | - redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $_GET['fid'] . ';msg=regex_error'); |
|
1802 | + if (!empty($_POST['regex']) && @preg_match($_POST['regex'], 'dummy') === false) { |
|
1803 | + redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $_GET['fid'] . ';msg=regex_error'); |
|
1804 | + } |
|
1746 | 1805 | |
1747 | 1806 | $_POST['field_name'] = $smcFunc['htmlspecialchars']($_POST['field_name']); |
1748 | 1807 | $_POST['field_desc'] = $smcFunc['htmlspecialchars']($_POST['field_desc']); |
@@ -1759,8 +1818,9 @@ discard block |
||
1759 | 1818 | |
1760 | 1819 | // Some masking stuff... |
1761 | 1820 | $mask = isset($_POST['mask']) ? $_POST['mask'] : ''; |
1762 | - if ($mask == 'regex' && isset($_POST['regex'])) |
|
1763 | - $mask .= $_POST['regex']; |
|
1821 | + if ($mask == 'regex' && isset($_POST['regex'])) { |
|
1822 | + $mask .= $_POST['regex']; |
|
1823 | + } |
|
1764 | 1824 | |
1765 | 1825 | $field_length = isset($_POST['max_length']) ? (int) $_POST['max_length'] : 255; |
1766 | 1826 | $enclose = isset($_POST['enclose']) ? $_POST['enclose'] : ''; |
@@ -1779,8 +1839,9 @@ discard block |
||
1779 | 1839 | $v = strtr($v, array(',' => '')); |
1780 | 1840 | |
1781 | 1841 | // Nada, zip, etc... |
1782 | - if (trim($v) == '') |
|
1783 | - continue; |
|
1842 | + if (trim($v) == '') { |
|
1843 | + continue; |
|
1844 | + } |
|
1784 | 1845 | |
1785 | 1846 | // Otherwise, save it boy. |
1786 | 1847 | $field_options .= $v . ','; |
@@ -1788,15 +1849,17 @@ discard block |
||
1788 | 1849 | $newOptions[$k] = $v; |
1789 | 1850 | |
1790 | 1851 | // Is it default? |
1791 | - if (isset($_POST['default_select']) && $_POST['default_select'] == $k) |
|
1792 | - $default = $v; |
|
1852 | + if (isset($_POST['default_select']) && $_POST['default_select'] == $k) { |
|
1853 | + $default = $v; |
|
1854 | + } |
|
1793 | 1855 | } |
1794 | 1856 | $field_options = substr($field_options, 0, -1); |
1795 | 1857 | } |
1796 | 1858 | |
1797 | 1859 | // Text area has default has dimensions |
1798 | - if ($_POST['field_type'] == 'textarea') |
|
1799 | - $default = (int) $_POST['rows'] . ',' . (int) $_POST['cols']; |
|
1860 | + if ($_POST['field_type'] == 'textarea') { |
|
1861 | + $default = (int) $_POST['rows'] . ',' . (int) $_POST['cols']; |
|
1862 | + } |
|
1800 | 1863 | |
1801 | 1864 | // Come up with the unique name? |
1802 | 1865 | if (empty($context['fid'])) |
@@ -1805,32 +1868,36 @@ discard block |
||
1805 | 1868 | preg_match('~([\w\d_-]+)~', $col_name, $matches); |
1806 | 1869 | |
1807 | 1870 | // If there is nothing to the name, then let's start out own - for foreign languages etc. |
1808 | - if (isset($matches[1])) |
|
1809 | - $col_name = $initial_col_name = 'cust_' . strtolower($matches[1]); |
|
1810 | - else |
|
1811 | - $col_name = $initial_col_name = 'cust_' . mt_rand(1, 9999); |
|
1871 | + if (isset($matches[1])) { |
|
1872 | + $col_name = $initial_col_name = 'cust_' . strtolower($matches[1]); |
|
1873 | + } else { |
|
1874 | + $col_name = $initial_col_name = 'cust_' . mt_rand(1, 9999); |
|
1875 | + } |
|
1812 | 1876 | |
1813 | 1877 | // Make sure this is unique. |
1814 | 1878 | $current_fields = array(); |
1815 | 1879 | $request = $smcFunc['db_query']('', ' |
1816 | 1880 | SELECT id_field, col_name |
1817 | 1881 | FROM {db_prefix}custom_fields'); |
1818 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1819 | - $current_fields[$row['id_field']] = $row['col_name']; |
|
1882 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1883 | + $current_fields[$row['id_field']] = $row['col_name']; |
|
1884 | + } |
|
1820 | 1885 | $smcFunc['db_free_result']($request); |
1821 | 1886 | |
1822 | 1887 | $unique = false; |
1823 | 1888 | for ($i = 0; !$unique && $i < 9; $i ++) |
1824 | 1889 | { |
1825 | - if (!in_array($col_name, $current_fields)) |
|
1826 | - $unique = true; |
|
1827 | - else |
|
1828 | - $col_name = $initial_col_name . $i; |
|
1890 | + if (!in_array($col_name, $current_fields)) { |
|
1891 | + $unique = true; |
|
1892 | + } else { |
|
1893 | + $col_name = $initial_col_name . $i; |
|
1894 | + } |
|
1829 | 1895 | } |
1830 | 1896 | |
1831 | 1897 | // Still not a unique column name? Leave it up to the user, then. |
1832 | - if (!$unique) |
|
1833 | - fatal_lang_error('custom_option_not_unique'); |
|
1898 | + if (!$unique) { |
|
1899 | + fatal_lang_error('custom_option_not_unique'); |
|
1900 | + } |
|
1834 | 1901 | } |
1835 | 1902 | // Work out what to do with the user data otherwise... |
1836 | 1903 | else |
@@ -1858,8 +1925,9 @@ discard block |
||
1858 | 1925 | // Work out what's changed! |
1859 | 1926 | foreach ($context['field']['options'] as $k => $option) |
1860 | 1927 | { |
1861 | - if (trim($option) == '') |
|
1862 | - continue; |
|
1928 | + if (trim($option) == '') { |
|
1929 | + continue; |
|
1930 | + } |
|
1863 | 1931 | |
1864 | 1932 | // Still exists? |
1865 | 1933 | if (in_array($option, $newOptions)) |
@@ -1873,8 +1941,8 @@ discard block |
||
1873 | 1941 | foreach ($optionChanges as $k => $option) |
1874 | 1942 | { |
1875 | 1943 | // Just been renamed? |
1876 | - if (!in_array($k, $takenKeys) && !empty($newOptions[$k])) |
|
1877 | - $smcFunc['db_query']('', ' |
|
1944 | + if (!in_array($k, $takenKeys) && !empty($newOptions[$k])) { |
|
1945 | + $smcFunc['db_query']('', ' |
|
1878 | 1946 | UPDATE {db_prefix}themes |
1879 | 1947 | SET value = {string:new_value} |
1880 | 1948 | WHERE variable = {string:current_column} |
@@ -1887,6 +1955,7 @@ discard block |
||
1887 | 1955 | 'old_value' => $option, |
1888 | 1956 | ) |
1889 | 1957 | ); |
1958 | + } |
|
1890 | 1959 | } |
1891 | 1960 | } |
1892 | 1961 | // @todo Maybe we should adjust based on new text length limits? |
@@ -1929,8 +1998,8 @@ discard block |
||
1929 | 1998 | ); |
1930 | 1999 | |
1931 | 2000 | // Just clean up any old selects - these are a pain! |
1932 | - if (($_POST['field_type'] == 'select' || $_POST['field_type'] == 'radio') && !empty($newOptions)) |
|
1933 | - $smcFunc['db_query']('', ' |
|
2001 | + if (($_POST['field_type'] == 'select' || $_POST['field_type'] == 'radio') && !empty($newOptions)) { |
|
2002 | + $smcFunc['db_query']('', ' |
|
1934 | 2003 | DELETE FROM {db_prefix}themes |
1935 | 2004 | WHERE variable = {string:current_column} |
1936 | 2005 | AND value NOT IN ({array_string:new_option_values}) |
@@ -1941,8 +2010,8 @@ discard block |
||
1941 | 2010 | 'current_column' => $context['field']['col_name'], |
1942 | 2011 | ) |
1943 | 2012 | ); |
1944 | - } |
|
1945 | - else |
|
2013 | + } |
|
2014 | + } else |
|
1946 | 2015 | { |
1947 | 2016 | // Gotta figure it out the order. |
1948 | 2017 | $new_order = $order_count > 1 ? ($order_count + 1) : 1; |
@@ -2116,11 +2185,13 @@ discard block |
||
2116 | 2185 | call_integration_hook('integrate_prune_settings', array(&$config_vars, &$prune_toggle, false)); |
2117 | 2186 | |
2118 | 2187 | $prune_toggle_dt = array(); |
2119 | - foreach ($prune_toggle as $item) |
|
2120 | - $prune_toggle_dt[] = 'setting_' . $item; |
|
2188 | + foreach ($prune_toggle as $item) { |
|
2189 | + $prune_toggle_dt[] = 'setting_' . $item; |
|
2190 | + } |
|
2121 | 2191 | |
2122 | - if ($return_config) |
|
2123 | - return $config_vars; |
|
2192 | + if ($return_config) { |
|
2193 | + return $config_vars; |
|
2194 | + } |
|
2124 | 2195 | |
2125 | 2196 | addInlineJavaScript(' |
2126 | 2197 | function togglePruned() |
@@ -2158,15 +2229,16 @@ discard block |
||
2158 | 2229 | $vals = array(); |
2159 | 2230 | foreach ($config_vars as $index => $dummy) |
2160 | 2231 | { |
2161 | - if (!is_array($dummy) || $index == 'pruningOptions' || !in_array($dummy[1], $prune_toggle)) |
|
2162 | - continue; |
|
2232 | + if (!is_array($dummy) || $index == 'pruningOptions' || !in_array($dummy[1], $prune_toggle)) { |
|
2233 | + continue; |
|
2234 | + } |
|
2163 | 2235 | |
2164 | 2236 | $vals[] = empty($_POST[$dummy[1]]) || $_POST[$dummy[1]] < 0 ? 0 : (int) $_POST[$dummy[1]]; |
2165 | 2237 | } |
2166 | 2238 | $_POST['pruningOptions'] = implode(',', $vals); |
2239 | + } else { |
|
2240 | + $_POST['pruningOptions'] = ''; |
|
2167 | 2241 | } |
2168 | - else |
|
2169 | - $_POST['pruningOptions'] = ''; |
|
2170 | 2242 | |
2171 | 2243 | saveDBSettings($savevar); |
2172 | 2244 | $_SESSION['adm-save'] = true; |
@@ -2178,10 +2250,11 @@ discard block |
||
2178 | 2250 | $context['sub_template'] = 'show_settings'; |
2179 | 2251 | |
2180 | 2252 | // Get the actual values |
2181 | - if (!empty($modSettings['pruningOptions'])) |
|
2182 | - @list ($modSettings['pruneErrorLog'], $modSettings['pruneModLog'], $modSettings['pruneBanLog'], $modSettings['pruneReportLog'], $modSettings['pruneScheduledTaskLog'], $modSettings['pruneSpiderHitLog']) = explode(',', $modSettings['pruningOptions']); |
|
2183 | - else |
|
2184 | - $modSettings['pruneErrorLog'] = $modSettings['pruneModLog'] = $modSettings['pruneBanLog'] = $modSettings['pruneReportLog'] = $modSettings['pruneScheduledTaskLog'] = $modSettings['pruneSpiderHitLog'] = 0; |
|
2253 | + if (!empty($modSettings['pruningOptions'])) { |
|
2254 | + @list ($modSettings['pruneErrorLog'], $modSettings['pruneModLog'], $modSettings['pruneBanLog'], $modSettings['pruneReportLog'], $modSettings['pruneScheduledTaskLog'], $modSettings['pruneSpiderHitLog']) = explode(',', $modSettings['pruningOptions']); |
|
2255 | + } else { |
|
2256 | + $modSettings['pruneErrorLog'] = $modSettings['pruneModLog'] = $modSettings['pruneBanLog'] = $modSettings['pruneReportLog'] = $modSettings['pruneScheduledTaskLog'] = $modSettings['pruneSpiderHitLog'] = 0; |
|
2257 | + } |
|
2185 | 2258 | |
2186 | 2259 | prepareDBSettingContext($config_vars); |
2187 | 2260 | } |
@@ -2203,8 +2276,9 @@ discard block |
||
2203 | 2276 | // Make it even easier to add new settings. |
2204 | 2277 | call_integration_hook('integrate_general_mod_settings', array(&$config_vars)); |
2205 | 2278 | |
2206 | - if ($return_config) |
|
2207 | - return $config_vars; |
|
2279 | + if ($return_config) { |
|
2280 | + return $config_vars; |
|
2281 | + } |
|
2208 | 2282 | |
2209 | 2283 | $context['post_url'] = $scripturl . '?action=admin;area=modsettings;save;sa=general'; |
2210 | 2284 | $context['settings_title'] = $txt['mods_cat_modifications_misc']; |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | $query_where = array(); |
167 | 167 | $query_params = $search_data['params']; |
168 | 168 | |
169 | - if( $smcFunc['db_title'] == "PostgreSQL") |
|
169 | + if ($smcFunc['db_title'] == "PostgreSQL") |
|
170 | 170 | $modSettings['search_simple_fulltext'] = true; |
171 | 171 | |
172 | 172 | if ($query_params['id_search']) |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | |
210 | 210 | if (!empty($modSettings['search_simple_fulltext'])) |
211 | 211 | { |
212 | - if($smcFunc['db_title'] == "PostgreSQL") |
|
212 | + if ($smcFunc['db_title'] == "PostgreSQL") |
|
213 | 213 | { |
214 | 214 | $language_ftx = $smcFunc['db_search_language'](); |
215 | 215 | |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | // remove any indexed words that are used in the complex body search terms |
228 | 228 | $words['indexed_words'] = array_diff($words['indexed_words'], $words['complex_words']); |
229 | 229 | |
230 | - if($smcFunc['db_title'] == "PostgreSQL"){ |
|
230 | + if ($smcFunc['db_title'] == "PostgreSQL") { |
|
231 | 231 | $row = 0; |
232 | 232 | foreach ($words['indexed_words'] as $fulltextWord) { |
233 | 233 | $query_params['boolean_match'] .= ($row <> 0 ? '&' : ''); |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | |
244 | 244 | // if we have bool terms to search, add them in |
245 | 245 | if ($query_params['boolean_match']) { |
246 | - if($smcFunc['db_title'] == "PostgreSQL") |
|
246 | + if ($smcFunc['db_title'] == "PostgreSQL") |
|
247 | 247 | { |
248 | 248 | $language_ftx = $smcFunc['db_search_language'](); |
249 | 249 | |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | |
257 | 257 | } |
258 | 258 | |
259 | - $ignoreRequest = $smcFunc['db_search_query']('insert_into_log_messages_fulltext', ($smcFunc['db_support_ignore'] ? ( ' |
|
259 | + $ignoreRequest = $smcFunc['db_search_query']('insert_into_log_messages_fulltext', ($smcFunc['db_support_ignore'] ? (' |
|
260 | 260 | INSERT IGNORE INTO {db_prefix}' . $search_data['insert_into'] . ' |
261 | 261 | (' . implode(', ', array_keys($query_select)) . ')') : '') . ' |
262 | 262 | SELECT ' . implode(', ', $query_select) . ' |
@@ -11,8 +11,9 @@ discard block |
||
11 | 11 | * @version 2.1 Beta 4 |
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 | * Class fulltext_search |
@@ -98,8 +99,9 @@ discard block |
||
98 | 99 | $smcFunc['db_free_result']($request); |
99 | 100 | } |
100 | 101 | // 4 is the MySQL default... |
101 | - else |
|
102 | - $min_word_length = 4; |
|
102 | + else { |
|
103 | + $min_word_length = 4; |
|
104 | + } |
|
103 | 105 | |
104 | 106 | return $min_word_length; |
105 | 107 | } |
@@ -138,8 +140,7 @@ discard block |
||
138 | 140 | $wordsSearch['words'][] = trim($word, "/*- "); |
139 | 141 | $wordsSearch['complex_words'][] = count($subwords) === 1 ? $word : '"' . $word . '"'; |
140 | 142 | } |
141 | - } |
|
142 | - elseif ($smcFunc['strlen'](trim($word, "/*- ")) < $this->min_word_length) |
|
143 | + } elseif ($smcFunc['strlen'](trim($word, "/*- ")) < $this->min_word_length) |
|
143 | 144 | { |
144 | 145 | // short words have feelings too |
145 | 146 | $wordsSearch['words'][] = trim($word, "/*- "); |
@@ -149,8 +150,9 @@ discard block |
||
149 | 150 | |
150 | 151 | $fulltextWord = count($subwords) === 1 ? $word : '"' . $word . '"'; |
151 | 152 | $wordsSearch['indexed_words'][] = $fulltextWord; |
152 | - if ($isExcluded) |
|
153 | - $wordsExclude[] = $fulltextWord; |
|
153 | + if ($isExcluded) { |
|
154 | + $wordsExclude[] = $fulltextWord; |
|
155 | + } |
|
154 | 156 | } |
155 | 157 | |
156 | 158 | /** |
@@ -166,44 +168,54 @@ discard block |
||
166 | 168 | $query_where = array(); |
167 | 169 | $query_params = $search_data['params']; |
168 | 170 | |
169 | - if( $smcFunc['db_title'] == "PostgreSQL") |
|
170 | - $modSettings['search_simple_fulltext'] = true; |
|
171 | + if( $smcFunc['db_title'] == "PostgreSQL") { |
|
172 | + $modSettings['search_simple_fulltext'] = true; |
|
173 | + } |
|
171 | 174 | |
172 | - if ($query_params['id_search']) |
|
173 | - $query_select['id_search'] = '{int:id_search}'; |
|
175 | + if ($query_params['id_search']) { |
|
176 | + $query_select['id_search'] = '{int:id_search}'; |
|
177 | + } |
|
174 | 178 | |
175 | 179 | $count = 0; |
176 | - if (empty($modSettings['search_simple_fulltext'])) |
|
177 | - foreach ($words['words'] as $regularWord) |
|
180 | + if (empty($modSettings['search_simple_fulltext'])) { |
|
181 | + foreach ($words['words'] as $regularWord) |
|
178 | 182 | { |
179 | 183 | $query_where[] = 'm.body' . (in_array($regularWord, $query_params['excluded_words']) ? ' NOT' : '') . (empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? ' LIKE ' : 'RLIKE') . '{string:complex_body_' . $count . '}'; |
184 | + } |
|
180 | 185 | $query_params['complex_body_' . $count++] = empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? '%' . strtr($regularWord, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $regularWord), '\\\'') . '[[:>:]]'; |
181 | 186 | } |
182 | 187 | |
183 | - if ($query_params['user_query']) |
|
184 | - $query_where[] = '{raw:user_query}'; |
|
185 | - if ($query_params['board_query']) |
|
186 | - $query_where[] = 'm.id_board {raw:board_query}'; |
|
188 | + if ($query_params['user_query']) { |
|
189 | + $query_where[] = '{raw:user_query}'; |
|
190 | + } |
|
191 | + if ($query_params['board_query']) { |
|
192 | + $query_where[] = 'm.id_board {raw:board_query}'; |
|
193 | + } |
|
187 | 194 | |
188 | - if ($query_params['topic']) |
|
189 | - $query_where[] = 'm.id_topic = {int:topic}'; |
|
190 | - if ($query_params['min_msg_id']) |
|
191 | - $query_where[] = 'm.id_msg >= {int:min_msg_id}'; |
|
192 | - if ($query_params['max_msg_id']) |
|
193 | - $query_where[] = 'm.id_msg <= {int:max_msg_id}'; |
|
195 | + if ($query_params['topic']) { |
|
196 | + $query_where[] = 'm.id_topic = {int:topic}'; |
|
197 | + } |
|
198 | + if ($query_params['min_msg_id']) { |
|
199 | + $query_where[] = 'm.id_msg >= {int:min_msg_id}'; |
|
200 | + } |
|
201 | + if ($query_params['max_msg_id']) { |
|
202 | + $query_where[] = 'm.id_msg <= {int:max_msg_id}'; |
|
203 | + } |
|
194 | 204 | |
195 | 205 | $count = 0; |
196 | - if (!empty($query_params['excluded_phrases']) && empty($modSettings['search_force_index'])) |
|
197 | - foreach ($query_params['excluded_phrases'] as $phrase) |
|
206 | + if (!empty($query_params['excluded_phrases']) && empty($modSettings['search_force_index'])) { |
|
207 | + foreach ($query_params['excluded_phrases'] as $phrase) |
|
198 | 208 | { |
199 | 209 | $query_where[] = 'subject NOT ' . (empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? ' LIKE ' : 'RLIKE') . '{string:exclude_subject_phrase_' . $count . '}'; |
210 | + } |
|
200 | 211 | $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), '\\\'') . '[[:>:]]'; |
201 | 212 | } |
202 | 213 | $count = 0; |
203 | - if (!empty($query_params['excluded_subject_words']) && empty($modSettings['search_force_index'])) |
|
204 | - foreach ($query_params['excluded_subject_words'] as $excludedWord) |
|
214 | + if (!empty($query_params['excluded_subject_words']) && empty($modSettings['search_force_index'])) { |
|
215 | + foreach ($query_params['excluded_subject_words'] as $excludedWord) |
|
205 | 216 | { |
206 | 217 | $query_where[] = 'subject NOT ' . (empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? ' LIKE ' : 'RLIKE') . '{string:exclude_subject_words_' . $count . '}'; |
218 | + } |
|
207 | 219 | $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), '\\\'') . '[[:>:]]'; |
208 | 220 | } |
209 | 221 | |
@@ -215,12 +227,11 @@ discard block |
||
215 | 227 | |
216 | 228 | $query_where[] = 'to_tsvector({string:language_ftx},body) @@ plainto_tsquery({string:language_ftx},{string:body_match})'; |
217 | 229 | $query_params['language_ftx'] = $language_ftx; |
230 | + } else { |
|
231 | + $query_where[] = 'MATCH (body) AGAINST ({string:body_match})'; |
|
218 | 232 | } |
219 | - else |
|
220 | - $query_where[] = 'MATCH (body) AGAINST ({string:body_match})'; |
|
221 | 233 | $query_params['body_match'] = implode(' ', array_diff($words['indexed_words'], $query_params['excluded_index_words'])); |
222 | - } |
|
223 | - else |
|
234 | + } else |
|
224 | 235 | { |
225 | 236 | $query_params['boolean_match'] = ''; |
226 | 237 | |
@@ -234,10 +245,10 @@ discard block |
||
234 | 245 | $query_params['boolean_match'] .= (in_array($fulltextWord, $query_params['excluded_index_words']) ? '!' : '') . $fulltextWord . ' '; |
235 | 246 | $row++; |
236 | 247 | } |
237 | - } |
|
238 | - else |
|
239 | - foreach ($words['indexed_words'] as $fulltextWord) |
|
248 | + } else { |
|
249 | + foreach ($words['indexed_words'] as $fulltextWord) |
|
240 | 250 | $query_params['boolean_match'] .= (in_array($fulltextWord, $query_params['excluded_index_words']) ? '-' : '+') . $fulltextWord . ' '; |
251 | + } |
|
241 | 252 | |
242 | 253 | $query_params['boolean_match'] = substr($query_params['boolean_match'], 0, -1); |
243 | 254 | |
@@ -249,9 +260,9 @@ discard block |
||
249 | 260 | |
250 | 261 | $query_where[] = 'to_tsvector({string:language_ftx},body) @@ plainto_tsquery({string:language_ftx},{string:boolean_match})'; |
251 | 262 | $query_params['language_ftx'] = $language_ftx; |
263 | + } else { |
|
264 | + $query_where[] = 'MATCH (body) AGAINST ({string:boolean_match} IN BOOLEAN MODE)'; |
|
252 | 265 | } |
253 | - else |
|
254 | - $query_where[] = 'MATCH (body) AGAINST ({string:boolean_match} IN BOOLEAN MODE)'; |
|
255 | 266 | } |
256 | 267 | |
257 | 268 | } |