@@ -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 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 | { |
@@ -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']; |
@@ -19,7 +19,7 @@ |
||
19 | 19 | /** |
20 | 20 | * Truncate the GET array to a specified length |
21 | 21 | * @param array $arr The array to truncate |
22 | - * @param max_length $max_length The upperbound on the length |
|
22 | + * @param integer $max_length The upperbound on the length |
|
23 | 23 | * |
24 | 24 | * @return array The truncated array |
25 | 25 | */ |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * |
24 | 24 | * @return array The truncated array |
25 | 25 | */ |
26 | -function truncateArray($arr, $max_length=1900) |
|
26 | +function truncateArray($arr, $max_length = 1900) |
|
27 | 27 | { |
28 | 28 | $curr_length = array_sum(array_map("strlen", $arr)); |
29 | 29 | if ($curr_length <= $max_length) |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | else |
32 | 32 | { |
33 | 33 | // Truncate each element's value to a reasonable length |
34 | - $param_max = floor($max_length/count($arr)); |
|
34 | + $param_max = floor($max_length / count($arr)); |
|
35 | 35 | foreach ($arr as $key => &$value) |
36 | 36 | $value = substr($value, 0, $param_max - strlen($key) - 5); |
37 | 37 | return $arr; |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | if (filemtime($boarddir . '/db_last_error.php') === $last_db_error_change) |
198 | 198 | { |
199 | 199 | // Write the change |
200 | - $write_db_change = '<' . '?' . "php\n" . '$db_last_error = ' . time() . ';' . "\n" . '?' . '>'; |
|
200 | + $write_db_change = '<' . '?' . "php\n" . '$db_last_error = ' . time() . ';' . "\n" . '?' . '>'; |
|
201 | 201 | $written_bytes = file_put_contents($boarddir . '/db_last_error.php', $write_db_change, LOCK_EX); |
202 | 202 | |
203 | 203 | // survey says ... |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | ', $txt['debug_language_files'], count($context['debug']['language_files']), ': <em>', implode('</em>, <em>', $context['debug']['language_files']), '</em>.<br> |
271 | 271 | ', $txt['debug_stylesheets'], count($context['debug']['sheets']), ': <em>', implode('</em>, <em>', $context['debug']['sheets']), '</em>.<br> |
272 | 272 | ', $txt['debug_hooks'], empty($context['debug']['hooks']) ? 0 : count($context['debug']['hooks']) . ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_hooks\').style.display = \'inline\'; this.style.display = \'none\'; return false;">', $txt['debug_show'], '</a><span id="debug_hooks" style="display: none;"><em>' . implode('</em>, <em>', $context['debug']['hooks']), '</em></span>)', '<br> |
273 | - ',(isset($context['debug']['instances']) ? ($txt['debug_instances'] . (empty($context['debug']['instances']) ? 0 : count($context['debug']['instances'])) . ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_instances\').style.display = \'inline\'; this.style.display = \'none\'; return false;">'. $txt['debug_show'] .'</a><span id="debug_instances" style="display: none;"><em>'. implode('</em>, <em>', array_keys($context['debug']['instances'])) .'</em></span>)'. '<br>') : ''),' |
|
273 | + ',(isset($context['debug']['instances']) ? ($txt['debug_instances'] . (empty($context['debug']['instances']) ? 0 : count($context['debug']['instances'])) . ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_instances\').style.display = \'inline\'; this.style.display = \'none\'; return false;">' . $txt['debug_show'] . '</a><span id="debug_instances" style="display: none;"><em>' . implode('</em>, <em>', array_keys($context['debug']['instances'])) . '</em></span>)' . '<br>') : ''), ' |
|
274 | 274 | ', $txt['debug_files_included'], count($files), ' - ', round($total_size / 1024), $txt['debug_kb'], ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_include_info\').style.display = \'inline\'; this.style.display = \'none\'; return false;">', $txt['debug_show'], '</a><span id="debug_include_info" style="display: none;"><em>', implode('</em>, <em>', $files), '</em></span>)<br>'; |
275 | 275 | |
276 | 276 | if (function_exists('memory_get_peak_usage')) |
@@ -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 | * Truncate the GET array to a specified length |
@@ -26,14 +27,15 @@ discard block |
||
26 | 27 | function truncateArray($arr, $max_length=1900) |
27 | 28 | { |
28 | 29 | $curr_length = array_sum(array_map("strlen", $arr)); |
29 | - if ($curr_length <= $max_length) |
|
30 | - return $arr; |
|
31 | - else |
|
30 | + if ($curr_length <= $max_length) { |
|
31 | + return $arr; |
|
32 | + } else |
|
32 | 33 | { |
33 | 34 | // Truncate each element's value to a reasonable length |
34 | 35 | $param_max = floor($max_length/count($arr)); |
35 | - foreach ($arr as $key => &$value) |
|
36 | - $value = substr($value, 0, $param_max - strlen($key) - 5); |
|
36 | + foreach ($arr as $key => &$value) { |
|
37 | + $value = substr($value, 0, $param_max - strlen($key) - 5); |
|
38 | + } |
|
37 | 39 | return $arr; |
38 | 40 | } |
39 | 41 | } |
@@ -55,8 +57,9 @@ discard block |
||
55 | 57 | // Don't update for every page - this isn't wholly accurate but who cares. |
56 | 58 | if ($topic) |
57 | 59 | { |
58 | - if (isset($_SESSION['last_topic_id']) && $_SESSION['last_topic_id'] == $topic) |
|
59 | - $force = false; |
|
60 | + if (isset($_SESSION['last_topic_id']) && $_SESSION['last_topic_id'] == $topic) { |
|
61 | + $force = false; |
|
62 | + } |
|
60 | 63 | $_SESSION['last_topic_id'] = $topic; |
61 | 64 | } |
62 | 65 | } |
@@ -69,22 +72,24 @@ discard block |
||
69 | 72 | } |
70 | 73 | |
71 | 74 | // Don't mark them as online more than every so often. |
72 | - if (!empty($_SESSION['log_time']) && $_SESSION['log_time'] >= (time() - 8) && !$force) |
|
73 | - return; |
|
75 | + if (!empty($_SESSION['log_time']) && $_SESSION['log_time'] >= (time() - 8) && !$force) { |
|
76 | + return; |
|
77 | + } |
|
74 | 78 | |
75 | 79 | if (!empty($modSettings['who_enabled'])) |
76 | 80 | { |
77 | 81 | $encoded_get = truncateArray($_GET) + array('USER_AGENT' => $_SERVER['HTTP_USER_AGENT']); |
78 | 82 | |
79 | 83 | // In the case of a dlattach action, session_var may not be set. |
80 | - if (!isset($context['session_var'])) |
|
81 | - $context['session_var'] = $_SESSION['session_var']; |
|
84 | + if (!isset($context['session_var'])) { |
|
85 | + $context['session_var'] = $_SESSION['session_var']; |
|
86 | + } |
|
82 | 87 | |
83 | 88 | unset($encoded_get['sesc'], $encoded_get[$context['session_var']]); |
84 | 89 | $encoded_get = $smcFunc['json_encode']($encoded_get); |
90 | + } else { |
|
91 | + $encoded_get = ''; |
|
85 | 92 | } |
86 | - else |
|
87 | - $encoded_get = ''; |
|
88 | 93 | |
89 | 94 | // Guests use 0, members use their session ID. |
90 | 95 | $session_id = $user_info['is_guest'] ? 'ip' . $user_info['ip'] : session_id(); |
@@ -124,17 +129,18 @@ discard block |
||
124 | 129 | ); |
125 | 130 | |
126 | 131 | // Guess it got deleted. |
127 | - if ($smcFunc['db_affected_rows']() == 0) |
|
132 | + if ($smcFunc['db_affected_rows']() == 0) { |
|
133 | + $_SESSION['log_time'] = 0; |
|
134 | + } |
|
135 | + } else { |
|
128 | 136 | $_SESSION['log_time'] = 0; |
129 | 137 | } |
130 | - else |
|
131 | - $_SESSION['log_time'] = 0; |
|
132 | 138 | |
133 | 139 | // Otherwise, we have to delete and insert. |
134 | 140 | if (empty($_SESSION['log_time'])) |
135 | 141 | { |
136 | - if ($do_delete || !empty($user_info['id'])) |
|
137 | - $smcFunc['db_query']('', ' |
|
142 | + if ($do_delete || !empty($user_info['id'])) { |
|
143 | + $smcFunc['db_query']('', ' |
|
138 | 144 | DELETE FROM {db_prefix}log_online |
139 | 145 | WHERE ' . ($do_delete ? 'log_time < {int:log_time}' : '') . ($do_delete && !empty($user_info['id']) ? ' OR ' : '') . (empty($user_info['id']) ? '' : 'id_member = {int:current_member}'), |
140 | 146 | array( |
@@ -142,6 +148,7 @@ discard block |
||
142 | 148 | 'log_time' => time() - $modSettings['lastActive'] * 60, |
143 | 149 | ) |
144 | 150 | ); |
151 | + } |
|
145 | 152 | |
146 | 153 | $smcFunc['db_insert']($do_delete ? 'ignore' : 'replace', |
147 | 154 | '{db_prefix}log_online', |
@@ -155,21 +162,24 @@ discard block |
||
155 | 162 | $_SESSION['log_time'] = time(); |
156 | 163 | |
157 | 164 | // Well, they are online now. |
158 | - if (empty($_SESSION['timeOnlineUpdated'])) |
|
159 | - $_SESSION['timeOnlineUpdated'] = time(); |
|
165 | + if (empty($_SESSION['timeOnlineUpdated'])) { |
|
166 | + $_SESSION['timeOnlineUpdated'] = time(); |
|
167 | + } |
|
160 | 168 | |
161 | 169 | // Set their login time, if not already done within the last minute. |
162 | 170 | if (SMF != 'SSI' && !empty($user_info['last_login']) && $user_info['last_login'] < time() - 60 && (!isset($_REQUEST['action']) || !in_array($_REQUEST['action'], array('.xml', 'login2', 'logintfa')))) |
163 | 171 | { |
164 | 172 | // Don't count longer than 15 minutes. |
165 | - if (time() - $_SESSION['timeOnlineUpdated'] > 60 * 15) |
|
166 | - $_SESSION['timeOnlineUpdated'] = time(); |
|
173 | + if (time() - $_SESSION['timeOnlineUpdated'] > 60 * 15) { |
|
174 | + $_SESSION['timeOnlineUpdated'] = time(); |
|
175 | + } |
|
167 | 176 | |
168 | 177 | $user_settings['total_time_logged_in'] += time() - $_SESSION['timeOnlineUpdated']; |
169 | 178 | updateMemberData($user_info['id'], array('last_login' => time(), 'member_ip' => $user_info['ip'], 'member_ip2' => $_SERVER['BAN_CHECK_IP'], 'total_time_logged_in' => $user_settings['total_time_logged_in'])); |
170 | 179 | |
171 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
172 | - cache_put_data('user_settings-' . $user_info['id'], $user_settings, 60); |
|
180 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
181 | + cache_put_data('user_settings-' . $user_info['id'], $user_settings, 60); |
|
182 | + } |
|
173 | 183 | |
174 | 184 | $user_info['total_time_logged_in'] += time() - $_SESSION['timeOnlineUpdated']; |
175 | 185 | $_SESSION['timeOnlineUpdated'] = time(); |
@@ -206,8 +216,7 @@ discard block |
||
206 | 216 | // Oops. maybe we have no more disk space left, or some other troubles, troubles... |
207 | 217 | // Copy the file back and run for your life! |
208 | 218 | @copy($boarddir . '/db_last_error_bak.php', $boarddir . '/db_last_error.php'); |
209 | - } |
|
210 | - else |
|
219 | + } else |
|
211 | 220 | { |
212 | 221 | @touch($boarddir . '/' . 'Settings.php'); |
213 | 222 | return true; |
@@ -227,22 +236,27 @@ discard block |
||
227 | 236 | global $db_cache, $db_count, $cache_misses, $cache_count_misses, $db_show_debug, $cache_count, $cache_hits, $smcFunc, $txt; |
228 | 237 | |
229 | 238 | // Add to Settings.php if you want to show the debugging information. |
230 | - if (!isset($db_show_debug) || $db_show_debug !== true || (isset($_GET['action']) && $_GET['action'] == 'viewquery')) |
|
231 | - return; |
|
239 | + if (!isset($db_show_debug) || $db_show_debug !== true || (isset($_GET['action']) && $_GET['action'] == 'viewquery')) { |
|
240 | + return; |
|
241 | + } |
|
232 | 242 | |
233 | - if (empty($_SESSION['view_queries'])) |
|
234 | - $_SESSION['view_queries'] = 0; |
|
235 | - if (empty($context['debug']['language_files'])) |
|
236 | - $context['debug']['language_files'] = array(); |
|
237 | - if (empty($context['debug']['sheets'])) |
|
238 | - $context['debug']['sheets'] = array(); |
|
243 | + if (empty($_SESSION['view_queries'])) { |
|
244 | + $_SESSION['view_queries'] = 0; |
|
245 | + } |
|
246 | + if (empty($context['debug']['language_files'])) { |
|
247 | + $context['debug']['language_files'] = array(); |
|
248 | + } |
|
249 | + if (empty($context['debug']['sheets'])) { |
|
250 | + $context['debug']['sheets'] = array(); |
|
251 | + } |
|
239 | 252 | |
240 | 253 | $files = get_included_files(); |
241 | 254 | $total_size = 0; |
242 | 255 | for ($i = 0, $n = count($files); $i < $n; $i++) |
243 | 256 | { |
244 | - if (file_exists($files[$i])) |
|
245 | - $total_size += filesize($files[$i]); |
|
257 | + if (file_exists($files[$i])) { |
|
258 | + $total_size += filesize($files[$i]); |
|
259 | + } |
|
246 | 260 | $files[$i] = strtr($files[$i], array($boarddir => '.', $sourcedir => '(Sources)', $cachedir => '(Cache)', $settings['actual_theme_dir'] => '(Current Theme)')); |
247 | 261 | } |
248 | 262 | |
@@ -251,8 +265,9 @@ discard block |
||
251 | 265 | { |
252 | 266 | foreach ($db_cache as $q => $qq) |
253 | 267 | { |
254 | - if (!empty($qq['w'])) |
|
255 | - $warnings += count($qq['w']); |
|
268 | + if (!empty($qq['w'])) { |
|
269 | + $warnings += count($qq['w']); |
|
270 | + } |
|
256 | 271 | } |
257 | 272 | |
258 | 273 | $_SESSION['debug'] = &$db_cache; |
@@ -273,12 +288,14 @@ discard block |
||
273 | 288 | ',(isset($context['debug']['instances']) ? ($txt['debug_instances'] . (empty($context['debug']['instances']) ? 0 : count($context['debug']['instances'])) . ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_instances\').style.display = \'inline\'; this.style.display = \'none\'; return false;">'. $txt['debug_show'] .'</a><span id="debug_instances" style="display: none;"><em>'. implode('</em>, <em>', array_keys($context['debug']['instances'])) .'</em></span>)'. '<br>') : ''),' |
274 | 289 | ', $txt['debug_files_included'], count($files), ' - ', round($total_size / 1024), $txt['debug_kb'], ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_include_info\').style.display = \'inline\'; this.style.display = \'none\'; return false;">', $txt['debug_show'], '</a><span id="debug_include_info" style="display: none;"><em>', implode('</em>, <em>', $files), '</em></span>)<br>'; |
275 | 290 | |
276 | - if (function_exists('memory_get_peak_usage')) |
|
277 | - echo $txt['debug_memory_use'], ceil(memory_get_peak_usage() / 1024), $txt['debug_kb'], '<br>'; |
|
291 | + if (function_exists('memory_get_peak_usage')) { |
|
292 | + echo $txt['debug_memory_use'], ceil(memory_get_peak_usage() / 1024), $txt['debug_kb'], '<br>'; |
|
293 | + } |
|
278 | 294 | |
279 | 295 | // What tokens are active? |
280 | - if (isset($_SESSION['token'])) |
|
281 | - echo $txt['debug_tokens'] . '<em>' . implode(',</em> <em>', array_keys($_SESSION['token'])), '</em>.<br>'; |
|
296 | + if (isset($_SESSION['token'])) { |
|
297 | + echo $txt['debug_tokens'] . '<em>' . implode(',</em> <em>', array_keys($_SESSION['token'])), '</em>.<br>'; |
|
298 | + } |
|
282 | 299 | |
283 | 300 | if (!empty($modSettings['cache_enable']) && !empty($cache_hits)) |
284 | 301 | { |
@@ -292,10 +309,12 @@ discard block |
||
292 | 309 | $total_t += $cache_hit['t']; |
293 | 310 | $total_s += $cache_hit['s']; |
294 | 311 | } |
295 | - if (!isset($cache_misses)) |
|
296 | - $cache_misses = array(); |
|
297 | - foreach ($cache_misses as $missed) |
|
298 | - $missed_entries[] = $missed['d'] . ' ' . $missed['k']; |
|
312 | + if (!isset($cache_misses)) { |
|
313 | + $cache_misses = array(); |
|
314 | + } |
|
315 | + foreach ($cache_misses as $missed) { |
|
316 | + $missed_entries[] = $missed['d'] . ' ' . $missed['k']; |
|
317 | + } |
|
299 | 318 | |
300 | 319 | echo ' |
301 | 320 | ', $txt['debug_cache_hits'], $cache_count, ': ', sprintf($txt['debug_cache_seconds_bytes_total'], comma_format($total_t, 5), comma_format($total_s)), ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_cache_info\').style.display = \'inline\'; this.style.display = \'none\'; return false;">', $txt['debug_show'], '</a><span id="debug_cache_info" style="display: none;"><em>', implode('</em>, <em>', $entries), '</em></span>)<br> |
@@ -306,38 +325,44 @@ discard block |
||
306 | 325 | <a href="', $scripturl, '?action=viewquery" target="_blank" class="new_win">', $warnings == 0 ? sprintf($txt['debug_queries_used'], (int) $db_count) : sprintf($txt['debug_queries_used_and_warnings'], (int) $db_count, $warnings), '</a><br> |
307 | 326 | <br>'; |
308 | 327 | |
309 | - if ($_SESSION['view_queries'] == 1 && !empty($db_cache)) |
|
310 | - foreach ($db_cache as $q => $qq) |
|
328 | + if ($_SESSION['view_queries'] == 1 && !empty($db_cache)) { |
|
329 | + foreach ($db_cache as $q => $qq) |
|
311 | 330 | { |
312 | 331 | $is_select = strpos(trim($qq['q']), 'SELECT') === 0 || preg_match('~^INSERT(?: IGNORE)? INTO \w+(?:\s+\([^)]+\))?\s+SELECT .+$~s', trim($qq['q'])) != 0; |
332 | + } |
|
313 | 333 | // Temporary tables created in earlier queries are not explainable. |
314 | 334 | if ($is_select) |
315 | 335 | { |
316 | - foreach (array('log_topics_unread', 'topics_posted_in', 'tmp_log_search_topics', 'tmp_log_search_messages') as $tmp) |
|
317 | - if (strpos(trim($qq['q']), $tmp) !== false) |
|
336 | + foreach (array('log_topics_unread', 'topics_posted_in', 'tmp_log_search_topics', 'tmp_log_search_messages') as $tmp) { |
|
337 | + if (strpos(trim($qq['q']), $tmp) !== false) |
|
318 | 338 | { |
319 | 339 | $is_select = false; |
340 | + } |
|
320 | 341 | break; |
321 | 342 | } |
322 | 343 | } |
323 | 344 | // But actual creation of the temporary tables are. |
324 | - elseif (preg_match('~^CREATE TEMPORARY TABLE .+?SELECT .+$~s', trim($qq['q'])) != 0) |
|
325 | - $is_select = true; |
|
345 | + elseif (preg_match('~^CREATE TEMPORARY TABLE .+?SELECT .+$~s', trim($qq['q'])) != 0) { |
|
346 | + $is_select = true; |
|
347 | + } |
|
326 | 348 | |
327 | 349 | // Make the filenames look a bit better. |
328 | - if (isset($qq['f'])) |
|
329 | - $qq['f'] = preg_replace('~^' . preg_quote($boarddir, '~') . '~', '...', $qq['f']); |
|
350 | + if (isset($qq['f'])) { |
|
351 | + $qq['f'] = preg_replace('~^' . preg_quote($boarddir, '~') . '~', '...', $qq['f']); |
|
352 | + } |
|
330 | 353 | |
331 | 354 | echo ' |
332 | 355 | <strong>', $is_select ? '<a href="' . $scripturl . '?action=viewquery;qq=' . ($q + 1) . '#qq' . $q . '" target="_blank" class="new_win" style="text-decoration: none;">' : '', nl2br(str_replace("\t", ' ', $smcFunc['htmlspecialchars'](ltrim($qq['q'], "\n\r")))) . ($is_select ? '</a></strong>' : '</strong>') . '<br> |
333 | 356 | '; |
334 | - if (!empty($qq['f']) && !empty($qq['l'])) |
|
335 | - echo sprintf($txt['debug_query_in_line'], $qq['f'], $qq['l']); |
|
357 | + if (!empty($qq['f']) && !empty($qq['l'])) { |
|
358 | + echo sprintf($txt['debug_query_in_line'], $qq['f'], $qq['l']); |
|
359 | + } |
|
336 | 360 | |
337 | - if (isset($qq['s'], $qq['t']) && isset($txt['debug_query_which_took_at'])) |
|
338 | - echo sprintf($txt['debug_query_which_took_at'], round($qq['t'], 8), round($qq['s'], 8)) . '<br>'; |
|
339 | - elseif (isset($qq['t'])) |
|
340 | - echo sprintf($txt['debug_query_which_took'], round($qq['t'], 8)) . '<br>'; |
|
361 | + if (isset($qq['s'], $qq['t']) && isset($txt['debug_query_which_took_at'])) { |
|
362 | + echo sprintf($txt['debug_query_which_took_at'], round($qq['t'], 8), round($qq['s'], 8)) . '<br>'; |
|
363 | + } elseif (isset($qq['t'])) { |
|
364 | + echo sprintf($txt['debug_query_which_took'], round($qq['t'], 8)) . '<br>'; |
|
365 | + } |
|
341 | 366 | echo ' |
342 | 367 | <br>'; |
343 | 368 | } |
@@ -362,12 +387,14 @@ discard block |
||
362 | 387 | global $modSettings, $smcFunc; |
363 | 388 | static $cache_stats = array(); |
364 | 389 | |
365 | - if (empty($modSettings['trackStats'])) |
|
366 | - return false; |
|
367 | - if (!empty($stats)) |
|
368 | - return $cache_stats = array_merge($cache_stats, $stats); |
|
369 | - elseif (empty($cache_stats)) |
|
370 | - return false; |
|
390 | + if (empty($modSettings['trackStats'])) { |
|
391 | + return false; |
|
392 | + } |
|
393 | + if (!empty($stats)) { |
|
394 | + return $cache_stats = array_merge($cache_stats, $stats); |
|
395 | + } elseif (empty($cache_stats)) { |
|
396 | + return false; |
|
397 | + } |
|
371 | 398 | |
372 | 399 | $setStringUpdate = ''; |
373 | 400 | $insert_keys = array(); |
@@ -380,10 +407,11 @@ discard block |
||
380 | 407 | $setStringUpdate .= ' |
381 | 408 | ' . $field . ' = ' . ($change === '+' ? $field . ' + 1' : '{int:' . $field . '}') . ','; |
382 | 409 | |
383 | - if ($change === '+') |
|
384 | - $cache_stats[$field] = 1; |
|
385 | - else |
|
386 | - $update_parameters[$field] = $change; |
|
410 | + if ($change === '+') { |
|
411 | + $cache_stats[$field] = 1; |
|
412 | + } else { |
|
413 | + $update_parameters[$field] = $change; |
|
414 | + } |
|
387 | 415 | $insert_keys[$field] = 'int'; |
388 | 416 | } |
389 | 417 | |
@@ -447,43 +475,50 @@ discard block |
||
447 | 475 | ); |
448 | 476 | |
449 | 477 | // Make sure this particular log is enabled first... |
450 | - if (empty($modSettings['modlog_enabled'])) |
|
451 | - unset ($log_types['moderate']); |
|
452 | - if (empty($modSettings['userlog_enabled'])) |
|
453 | - unset ($log_types['user']); |
|
454 | - if (empty($modSettings['adminlog_enabled'])) |
|
455 | - unset ($log_types['admin']); |
|
478 | + if (empty($modSettings['modlog_enabled'])) { |
|
479 | + unset ($log_types['moderate']); |
|
480 | + } |
|
481 | + if (empty($modSettings['userlog_enabled'])) { |
|
482 | + unset ($log_types['user']); |
|
483 | + } |
|
484 | + if (empty($modSettings['adminlog_enabled'])) { |
|
485 | + unset ($log_types['admin']); |
|
486 | + } |
|
456 | 487 | |
457 | 488 | call_integration_hook('integrate_log_types', array(&$log_types)); |
458 | 489 | |
459 | 490 | foreach ($logs as $log) |
460 | 491 | { |
461 | - if (!isset($log_types[$log['log_type']])) |
|
462 | - return false; |
|
492 | + if (!isset($log_types[$log['log_type']])) { |
|
493 | + return false; |
|
494 | + } |
|
463 | 495 | |
464 | - if (!is_array($log['extra'])) |
|
465 | - trigger_error('logActions(): data is not an array with action \'' . $log['action'] . '\'', E_USER_NOTICE); |
|
496 | + if (!is_array($log['extra'])) { |
|
497 | + trigger_error('logActions(): data is not an array with action \'' . $log['action'] . '\'', E_USER_NOTICE); |
|
498 | + } |
|
466 | 499 | |
467 | 500 | // Pull out the parts we want to store separately, but also make sure that the data is proper |
468 | 501 | if (isset($log['extra']['topic'])) |
469 | 502 | { |
470 | - if (!is_numeric($log['extra']['topic'])) |
|
471 | - trigger_error('logActions(): data\'s topic is not a number', E_USER_NOTICE); |
|
503 | + if (!is_numeric($log['extra']['topic'])) { |
|
504 | + trigger_error('logActions(): data\'s topic is not a number', E_USER_NOTICE); |
|
505 | + } |
|
472 | 506 | $topic_id = empty($log['extra']['topic']) ? 0 : (int) $log['extra']['topic']; |
473 | 507 | unset($log['extra']['topic']); |
508 | + } else { |
|
509 | + $topic_id = 0; |
|
474 | 510 | } |
475 | - else |
|
476 | - $topic_id = 0; |
|
477 | 511 | |
478 | 512 | if (isset($log['extra']['message'])) |
479 | 513 | { |
480 | - if (!is_numeric($log['extra']['message'])) |
|
481 | - trigger_error('logActions(): data\'s message is not a number', E_USER_NOTICE); |
|
514 | + if (!is_numeric($log['extra']['message'])) { |
|
515 | + trigger_error('logActions(): data\'s message is not a number', E_USER_NOTICE); |
|
516 | + } |
|
482 | 517 | $msg_id = empty($log['extra']['message']) ? 0 : (int) $log['extra']['message']; |
483 | 518 | unset($log['extra']['message']); |
519 | + } else { |
|
520 | + $msg_id = 0; |
|
484 | 521 | } |
485 | - else |
|
486 | - $msg_id = 0; |
|
487 | 522 | |
488 | 523 | // @todo cache this? |
489 | 524 | // Is there an associated report on this? |
@@ -510,23 +545,26 @@ discard block |
||
510 | 545 | $smcFunc['db_free_result']($request); |
511 | 546 | } |
512 | 547 | |
513 | - if (isset($log['extra']['member']) && !is_numeric($log['extra']['member'])) |
|
514 | - trigger_error('logActions(): data\'s member is not a number', E_USER_NOTICE); |
|
548 | + if (isset($log['extra']['member']) && !is_numeric($log['extra']['member'])) { |
|
549 | + trigger_error('logActions(): data\'s member is not a number', E_USER_NOTICE); |
|
550 | + } |
|
515 | 551 | |
516 | 552 | if (isset($log['extra']['board'])) |
517 | 553 | { |
518 | - if (!is_numeric($log['extra']['board'])) |
|
519 | - trigger_error('logActions(): data\'s board is not a number', E_USER_NOTICE); |
|
554 | + if (!is_numeric($log['extra']['board'])) { |
|
555 | + trigger_error('logActions(): data\'s board is not a number', E_USER_NOTICE); |
|
556 | + } |
|
520 | 557 | $board_id = empty($log['extra']['board']) ? 0 : (int) $log['extra']['board']; |
521 | 558 | unset($log['extra']['board']); |
559 | + } else { |
|
560 | + $board_id = 0; |
|
522 | 561 | } |
523 | - else |
|
524 | - $board_id = 0; |
|
525 | 562 | |
526 | 563 | if (isset($log['extra']['board_to'])) |
527 | 564 | { |
528 | - if (!is_numeric($log['extra']['board_to'])) |
|
529 | - trigger_error('logActions(): data\'s board_to is not a number', E_USER_NOTICE); |
|
565 | + if (!is_numeric($log['extra']['board_to'])) { |
|
566 | + trigger_error('logActions(): data\'s board_to is not a number', E_USER_NOTICE); |
|
567 | + } |
|
530 | 568 | if (empty($board_id)) |
531 | 569 | { |
532 | 570 | $board_id = empty($log['extra']['board_to']) ? 0 : (int) $log['extra']['board_to']; |
@@ -534,10 +572,11 @@ discard block |
||
534 | 572 | } |
535 | 573 | } |
536 | 574 | |
537 | - if (isset($log['extra']['member_affected'])) |
|
538 | - $memID = $log['extra']['member_affected']; |
|
539 | - else |
|
540 | - $memID = $user_info['id']; |
|
575 | + if (isset($log['extra']['member_affected'])) { |
|
576 | + $memID = $log['extra']['member_affected']; |
|
577 | + } else { |
|
578 | + $memID = $user_info['id']; |
|
579 | + } |
|
541 | 580 | |
542 | 581 | $inserts[] = array( |
543 | 582 | time(), $log_types[$log['log_type']], $memID, $user_info['ip'], $log['action'], |
@@ -64,9 +64,10 @@ discard block |
||
64 | 64 | <strong>', $txt['administrators'], ':</strong> |
65 | 65 | ', implode(', ', $context['administrators']); |
66 | 66 | // If we have lots of admins... don't show them all. |
67 | - if (!empty($context['more_admins_link'])) |
|
68 | - echo ' |
|
67 | + if (!empty($context['more_admins_link'])) { |
|
68 | + echo ' |
|
69 | 69 | (', $context['more_admins_link'], ')'; |
70 | + } |
|
70 | 71 | |
71 | 72 | echo ' |
72 | 73 | </div> |
@@ -83,16 +84,18 @@ discard block |
||
83 | 84 | foreach ($area['areas'] as $item_id => $item) |
84 | 85 | { |
85 | 86 | // No point showing the 'home' page here, we're already on it! |
86 | - if ($area_id == 'forum' && $item_id == 'index') |
|
87 | - continue; |
|
87 | + if ($area_id == 'forum' && $item_id == 'index') { |
|
88 | + continue; |
|
89 | + } |
|
88 | 90 | |
89 | 91 | $url = isset($item['url']) ? $item['url'] : $scripturl . '?action=admin;area=' . $item_id . (!empty($context[$context['admin_menu_name']]['extra_parameters']) ? $context[$context['admin_menu_name']]['extra_parameters'] : ''); |
90 | - if (!empty($item['icon_file'])) |
|
91 | - echo ' |
|
92 | + if (!empty($item['icon_file'])) { |
|
93 | + echo ' |
|
92 | 94 | <a href="', $url, '" class="admin_group', !empty($item['inactive']) ? ' inactive' : '', '"><img class="large_admin_menu_icon_file" src="', $item['icon_file'], '" alt="">', $item['label'], '</a>'; |
93 | - else |
|
94 | - echo ' |
|
95 | + } else { |
|
96 | + echo ' |
|
95 | 97 | <a href="', $url, '"><span class="large_', $item['icon_class'], !empty($item['inactive']) ? ' inactive' : '', '"></span>', $item['label'], '</a>'; |
98 | + } |
|
96 | 99 | } |
97 | 100 | |
98 | 101 | echo ' |
@@ -103,10 +106,11 @@ discard block |
||
103 | 106 | </div>'; |
104 | 107 | |
105 | 108 | // The below functions include all the scripts needed from the simplemachines.org site. The language and format are passed for internationalization. |
106 | - if (empty($modSettings['disable_smf_js'])) |
|
107 | - echo ' |
|
109 | + if (empty($modSettings['disable_smf_js'])) { |
|
110 | + echo ' |
|
108 | 111 | <script src="', $scripturl, '?action=viewsmfile;filename=current-version.js"></script> |
109 | 112 | <script src="', $scripturl, '?action=viewsmfile;filename=latest-news.js"></script>'; |
113 | + } |
|
110 | 114 | |
111 | 115 | // This sets the announcements and current versions themselves ;). |
112 | 116 | echo ' |
@@ -185,9 +189,10 @@ discard block |
||
185 | 189 | <em>', $version['version'], '</em>'; |
186 | 190 | |
187 | 191 | // more details for this item, show them a link |
188 | - if ($context['can_admin'] && isset($version['more'])) |
|
189 | - echo |
|
192 | + if ($context['can_admin'] && isset($version['more'])) { |
|
193 | + echo |
|
190 | 194 | ' <a href="', $scripturl, $version['more'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['version_check_more'], '</a>'; |
195 | + } |
|
191 | 196 | echo ' |
192 | 197 | <br>'; |
193 | 198 | } |
@@ -218,20 +223,22 @@ discard block |
||
218 | 223 | |
219 | 224 | foreach ($context['credits'] as $section) |
220 | 225 | { |
221 | - if (isset($section['pretext'])) |
|
222 | - echo ' |
|
226 | + if (isset($section['pretext'])) { |
|
227 | + echo ' |
|
223 | 228 | <p>', $section['pretext'], '</p><hr>'; |
229 | + } |
|
224 | 230 | |
225 | 231 | echo ' |
226 | 232 | <dl>'; |
227 | 233 | |
228 | 234 | foreach ($section['groups'] as $group) |
229 | 235 | { |
230 | - if (isset($group['title'])) |
|
231 | - echo ' |
|
236 | + if (isset($group['title'])) { |
|
237 | + echo ' |
|
232 | 238 | <dt> |
233 | 239 | <strong>', $group['title'], ':</strong> |
234 | 240 | </dt>'; |
241 | + } |
|
235 | 242 | |
236 | 243 | echo ' |
237 | 244 | <dd>', implode(', ', $group['members']), '</dd>'; |
@@ -240,10 +247,11 @@ discard block |
||
240 | 247 | echo ' |
241 | 248 | </dl>'; |
242 | 249 | |
243 | - if (isset($section['posttext'])) |
|
244 | - echo ' |
|
250 | + if (isset($section['posttext'])) { |
|
251 | + echo ' |
|
245 | 252 | <hr> |
246 | 253 | <p>', $section['posttext'], '</p>'; |
254 | + } |
|
247 | 255 | } |
248 | 256 | |
249 | 257 | echo ' |
@@ -259,9 +267,10 @@ discard block |
||
259 | 267 | smfSupportVersions.forum = "', $context['forum_version'], '";'; |
260 | 268 | |
261 | 269 | // Don't worry, none of this is logged, it's just used to give information that might be of use. |
262 | - foreach ($context['current_versions'] as $variable => $version) |
|
263 | - echo ' |
|
270 | + foreach ($context['current_versions'] as $variable => $version) { |
|
271 | + echo ' |
|
264 | 272 | smfSupportVersions.', $variable, ' = "', $version['version'], '";'; |
273 | + } |
|
265 | 274 | |
266 | 275 | // Now we just have to include the script and wait ;). |
267 | 276 | echo ' |
@@ -358,8 +367,8 @@ discard block |
||
358 | 367 | <tbody>'; |
359 | 368 | |
360 | 369 | // Loop through every source file displaying its version - using javascript. |
361 | - foreach ($context['file_versions'] as $filename => $version) |
|
362 | - echo ' |
|
370 | + foreach ($context['file_versions'] as $filename => $version) { |
|
371 | + echo ' |
|
363 | 372 | <tr class="windowbg"> |
364 | 373 | <td class="half_table"> |
365 | 374 | ', $filename, ' |
@@ -371,6 +380,7 @@ discard block |
||
371 | 380 | <em id="currentSources', $filename, '">??</em> |
372 | 381 | </td> |
373 | 382 | </tr>'; |
383 | + } |
|
374 | 384 | |
375 | 385 | // Default template files. |
376 | 386 | echo ' |
@@ -396,8 +406,8 @@ discard block |
||
396 | 406 | <table id="Default" class="table_grid"> |
397 | 407 | <tbody>'; |
398 | 408 | |
399 | - foreach ($context['default_template_versions'] as $filename => $version) |
|
400 | - echo ' |
|
409 | + foreach ($context['default_template_versions'] as $filename => $version) { |
|
410 | + echo ' |
|
401 | 411 | <tr class="windowbg"> |
402 | 412 | <td class="half_table"> |
403 | 413 | ', $filename, ' |
@@ -409,6 +419,7 @@ discard block |
||
409 | 419 | <em id="currentDefault', $filename, '">??</em> |
410 | 420 | </td> |
411 | 421 | </tr>'; |
422 | + } |
|
412 | 423 | |
413 | 424 | // Now the language files... |
414 | 425 | echo ' |
@@ -436,8 +447,8 @@ discard block |
||
436 | 447 | |
437 | 448 | foreach ($context['default_language_versions'] as $language => $files) |
438 | 449 | { |
439 | - foreach ($files as $filename => $version) |
|
440 | - echo ' |
|
450 | + foreach ($files as $filename => $version) { |
|
451 | + echo ' |
|
441 | 452 | <tr class="windowbg"> |
442 | 453 | <td class="half_table"> |
443 | 454 | ', $filename, '.<em>', $language, '</em>.php |
@@ -449,6 +460,7 @@ discard block |
||
449 | 460 | <em id="current', $filename, '.', $language, '">??</em> |
450 | 461 | </td> |
451 | 462 | </tr>'; |
463 | + } |
|
452 | 464 | } |
453 | 465 | |
454 | 466 | echo ' |
@@ -478,8 +490,8 @@ discard block |
||
478 | 490 | <table id="Templates" class="table_grid"> |
479 | 491 | <tbody>'; |
480 | 492 | |
481 | - foreach ($context['template_versions'] as $filename => $version) |
|
482 | - echo ' |
|
493 | + foreach ($context['template_versions'] as $filename => $version) { |
|
494 | + echo ' |
|
483 | 495 | <tr class="windowbg"> |
484 | 496 | <td class="half_table"> |
485 | 497 | ', $filename, ' |
@@ -491,6 +503,7 @@ discard block |
||
491 | 503 | <em id="currentTemplates', $filename, '">??</em> |
492 | 504 | </td> |
493 | 505 | </tr>'; |
506 | + } |
|
494 | 507 | |
495 | 508 | echo ' |
496 | 509 | </tbody> |
@@ -520,8 +533,8 @@ discard block |
||
520 | 533 | <table id="Tasks" class="table_grid"> |
521 | 534 | <tbody>'; |
522 | 535 | |
523 | - foreach ($context['tasks_versions'] as $filename => $version) |
|
524 | - echo ' |
|
536 | + foreach ($context['tasks_versions'] as $filename => $version) { |
|
537 | + echo ' |
|
525 | 538 | <tr class="windowbg"> |
526 | 539 | <td class="half_table"> |
527 | 540 | ', $filename, ' |
@@ -533,6 +546,7 @@ discard block |
||
533 | 546 | <em id="currentTasks', $filename, '">??</em> |
534 | 547 | </td> |
535 | 548 | </tr>'; |
549 | + } |
|
536 | 550 | |
537 | 551 | echo ' |
538 | 552 | </tbody> |
@@ -574,9 +588,10 @@ discard block |
||
574 | 588 | { |
575 | 589 | global $context, $scripturl, $txt, $modSettings; |
576 | 590 | |
577 | - if (!empty($context['saved_successful'])) |
|
578 | - echo ' |
|
591 | + if (!empty($context['saved_successful'])) { |
|
592 | + echo ' |
|
579 | 593 | <div class="infobox">', $txt['settings_saved'], '</div>'; |
594 | + } |
|
580 | 595 | |
581 | 596 | // First section is for adding/removing words from the censored list. |
582 | 597 | echo ' |
@@ -591,11 +606,12 @@ discard block |
||
591 | 606 | <p>', $txt['admin_censored_where'], '</p>'; |
592 | 607 | |
593 | 608 | // Show text boxes for censoring [bad ] => [good ]. |
594 | - foreach ($context['censored_words'] as $vulgar => $proper) |
|
595 | - echo ' |
|
609 | + foreach ($context['censored_words'] as $vulgar => $proper) { |
|
610 | + echo ' |
|
596 | 611 | <div class="block"> |
597 | 612 | <input type="text" name="censor_vulgar[]" value="', $vulgar, '" size="30"> => <input type="text" name="censor_proper[]" value="', $proper, '" size="30"> |
598 | 613 | </div>'; |
614 | + } |
|
599 | 615 | |
600 | 616 | // Now provide a way to censor more words. |
601 | 617 | echo ' |
@@ -669,19 +685,21 @@ discard block |
||
669 | 685 | <div class="windowbg2 noup"> |
670 | 686 | ', $txt['not_done_reason']; |
671 | 687 | |
672 | - if (!empty($context['continue_percent'])) |
|
673 | - echo ' |
|
688 | + if (!empty($context['continue_percent'])) { |
|
689 | + echo ' |
|
674 | 690 | <div class="progress_bar"> |
675 | 691 | <div class="full_bar">', $context['continue_percent'], '%</div> |
676 | 692 | <div class="green_percent" style="width: ', $context['continue_percent'], '%;"> </div> |
677 | 693 | </div>'; |
694 | + } |
|
678 | 695 | |
679 | - if (!empty($context['substep_enabled'])) |
|
680 | - echo ' |
|
696 | + if (!empty($context['substep_enabled'])) { |
|
697 | + echo ' |
|
681 | 698 | <div class="progress_bar"> |
682 | 699 | <div class="full_bar">', $context['substep_title'], ' (', $context['substep_continue_percent'], '%)</div> |
683 | 700 | <div class="blue_percent" style="width: ', $context['substep_continue_percent'], '%;"> </div> |
684 | 701 | </div>'; |
702 | + } |
|
685 | 703 | |
686 | 704 | echo ' |
687 | 705 | <form action="', $scripturl, $context['continue_get_data'], '" method="post" accept-charset="', $context['character_set'], '" name="autoSubmit" id="autoSubmit"> |
@@ -716,35 +734,40 @@ discard block |
||
716 | 734 | { |
717 | 735 | global $context, $txt, $scripturl; |
718 | 736 | |
719 | - if (!empty($context['saved_successful'])) |
|
720 | - echo ' |
|
737 | + if (!empty($context['saved_successful'])) { |
|
738 | + echo ' |
|
721 | 739 | <div class="infobox">', $txt['settings_saved'], '</div>'; |
722 | - elseif (!empty($context['saved_failed'])) |
|
723 | - echo ' |
|
740 | + } elseif (!empty($context['saved_failed'])) { |
|
741 | + echo ' |
|
724 | 742 | <div class="errorbox">', sprintf($txt['settings_not_saved'], $context['saved_failed']), '</div>'; |
743 | + } |
|
725 | 744 | |
726 | - if (!empty($context['settings_pre_javascript'])) |
|
727 | - echo ' |
|
745 | + if (!empty($context['settings_pre_javascript'])) { |
|
746 | + echo ' |
|
728 | 747 | <script>', $context['settings_pre_javascript'], '</script>'; |
748 | + } |
|
729 | 749 | |
730 | - if (!empty($context['settings_insert_above'])) |
|
731 | - echo $context['settings_insert_above']; |
|
750 | + if (!empty($context['settings_insert_above'])) { |
|
751 | + echo $context['settings_insert_above']; |
|
752 | + } |
|
732 | 753 | |
733 | 754 | echo ' |
734 | 755 | <div id="admincenter"> |
735 | 756 | <form id="admin_form_wrapper" action="', $context['post_url'], '" method="post" accept-charset="', $context['character_set'], '"', !empty($context['force_form_onsubmit']) ? ' onsubmit="' . $context['force_form_onsubmit'] . '"' : '', '>'; |
736 | 757 | |
737 | 758 | // Is there a custom title? |
738 | - if (isset($context['settings_title'])) |
|
739 | - echo ' |
|
759 | + if (isset($context['settings_title'])) { |
|
760 | + echo ' |
|
740 | 761 | <div class="cat_bar"> |
741 | 762 | <h3 class="catbg">', $context['settings_title'], '</h3> |
742 | 763 | </div>'; |
764 | + } |
|
743 | 765 | |
744 | 766 | // Have we got a message to display? |
745 | - if (!empty($context['settings_message'])) |
|
746 | - echo ' |
|
767 | + if (!empty($context['settings_message'])) { |
|
768 | + echo ' |
|
747 | 769 | <div class="information">', $context['settings_message'], '</div>'; |
770 | + } |
|
748 | 771 | |
749 | 772 | // Now actually loop through all the variables. |
750 | 773 | $is_open = false; |
@@ -797,8 +820,9 @@ discard block |
||
797 | 820 | // Hang about? Are you pulling my leg - a callback?! |
798 | 821 | if (is_array($config_var) && $config_var['type'] == 'callback') |
799 | 822 | { |
800 | - if (function_exists('template_callback_' . $config_var['name'])) |
|
801 | - call_user_func('template_callback_' . $config_var['name']); |
|
823 | + if (function_exists('template_callback_' . $config_var['name'])) { |
|
824 | + call_user_func('template_callback_' . $config_var['name']); |
|
825 | + } |
|
802 | 826 | |
803 | 827 | continue; |
804 | 828 | } |
@@ -828,9 +852,10 @@ discard block |
||
828 | 852 | $text_types = array('color', 'date', 'datetime', 'datetime-local', 'email', 'month', 'time'); |
829 | 853 | |
830 | 854 | // Show the [?] button. |
831 | - if ($config_var['help']) |
|
832 | - echo ' |
|
855 | + if ($config_var['help']) { |
|
856 | + echo ' |
|
833 | 857 | <a id="setting_', $config_var['name'], '_help" href="', $scripturl, '?action=helpadmin;help=', $config_var['help'], '" onclick="return reqOverlayDiv(this.href);"><span class="generic_icons help" title="', $txt['help'], '"></span></a> '; |
858 | + } |
|
834 | 859 | |
835 | 860 | echo ' |
836 | 861 | <a id="setting_', $config_var['name'], '"></a> <span', ($config_var['disabled'] ? ' style="color: #777777;"' : ($config_var['invalid'] ? ' class="error"' : '')), '><label for="', $config_var['name'], '">', $config_var['label'], '</label>', $subtext, ($config_var['type'] == 'password' ? '<br><em>' . $txt['admin_confirm_password'] . '</em>' : ''), '</span> |
@@ -839,22 +864,25 @@ discard block |
||
839 | 864 | $config_var['preinput']; |
840 | 865 | |
841 | 866 | // Show a check box. |
842 | - if ($config_var['type'] == 'check') |
|
843 | - echo ' |
|
867 | + if ($config_var['type'] == 'check') { |
|
868 | + echo ' |
|
844 | 869 | <input type="checkbox"', $javascript, $disabled, ' name="', $config_var['name'], '" id="', $config_var['name'], '"', ($config_var['value'] ? ' checked' : ''), ' value="1" class="input_check">'; |
870 | + } |
|
845 | 871 | // Escape (via htmlspecialchars.) the text box. |
846 | - elseif ($config_var['type'] == 'password') |
|
847 | - echo ' |
|
872 | + elseif ($config_var['type'] == 'password') { |
|
873 | + echo ' |
|
848 | 874 | <input type="password"', $disabled, $javascript, ' name="', $config_var['name'], '[0]"', ($config_var['size'] ? ' size="' . $config_var['size'] . '"' : ''), ' value="*#fakepass#*" onfocus="this.value = \'\'; this.form.', $config_var['name'], '.disabled = false;" class="input_password"><br> |
849 | 875 | <input type="password" disabled id="', $config_var['name'], '" name="', $config_var['name'], '[1]"', ($config_var['size'] ? ' size="' . $config_var['size'] . '"' : ''), ' class="input_password">'; |
876 | + } |
|
850 | 877 | // Show a selection box. |
851 | 878 | elseif ($config_var['type'] == 'select') |
852 | 879 | { |
853 | 880 | echo ' |
854 | 881 | <select name="', $config_var['name'], '" id="', $config_var['name'], '" ', $javascript, $disabled, (!empty($config_var['multiple']) ? ' multiple="multiple"' : ''), (!empty($config_var['multiple']) && !empty($config_var['size']) ? ' size="' . $config_var['size'] . '"' : ''), '>'; |
855 | - foreach ($config_var['data'] as $option) |
|
856 | - echo ' |
|
882 | + foreach ($config_var['data'] as $option) { |
|
883 | + echo ' |
|
857 | 884 | <option value="', $option[0], '"', (!empty($config_var['value']) && ($option[0] == $config_var['value'] || (!empty($config_var['multiple']) && in_array($option[0], $config_var['value']))) ? ' selected' : ''), '>', $option[1], '</option>'; |
885 | + } |
|
858 | 886 | echo ' |
859 | 887 | </select>'; |
860 | 888 | } |
@@ -868,15 +896,17 @@ discard block |
||
868 | 896 | <legend class="board_selector"><a href="#">', $txt['select_boards_from_list'], '</a></legend>'; |
869 | 897 | foreach ($context['board_list'] as $id_cat => $cat) |
870 | 898 | { |
871 | - if (!$first) |
|
872 | - echo ' |
|
899 | + if (!$first) { |
|
900 | + echo ' |
|
873 | 901 | <hr>'; |
902 | + } |
|
874 | 903 | echo ' |
875 | 904 | <strong>', $cat['name'], '</strong> |
876 | 905 | <ul>'; |
877 | - foreach ($cat['boards'] as $id_board => $brd) |
|
878 | - echo ' |
|
906 | + foreach ($cat['boards'] as $id_board => $brd) { |
|
907 | + echo ' |
|
879 | 908 | <li><label><input type="checkbox" name="', $config_var['name'], '[', $brd['id'], ']" value="1" class="input_check"', in_array($brd['id'], $config_var['value']) ? ' checked' : '', '> ', $brd['child_level'] > 0 ? str_repeat(' ', $brd['child_level']) : '', $brd['name'], '</label></li>'; |
909 | + } |
|
880 | 910 | |
881 | 911 | echo ' |
882 | 912 | </ul>'; |
@@ -886,12 +916,14 @@ discard block |
||
886 | 916 | </fieldset>'; |
887 | 917 | } |
888 | 918 | // Text area? |
889 | - elseif ($config_var['type'] == 'large_text') |
|
890 | - echo ' |
|
919 | + elseif ($config_var['type'] == 'large_text') { |
|
920 | + echo ' |
|
891 | 921 | <textarea rows="', (!empty($config_var['size']) ? $config_var['size'] : (!empty($config_var['rows']) ? $config_var['rows'] : 4)), '" cols="', (!empty($config_var['cols']) ? $config_var['cols'] : 30), '" ', $javascript, $disabled, ' name="', $config_var['name'], '" id="', $config_var['name'], '">', $config_var['value'], '</textarea>'; |
922 | + } |
|
892 | 923 | // Permission group? |
893 | - elseif ($config_var['type'] == 'permissions') |
|
894 | - theme_inline_permissions($config_var['name']); |
|
924 | + elseif ($config_var['type'] == 'permissions') { |
|
925 | + theme_inline_permissions($config_var['name']); |
|
926 | + } |
|
895 | 927 | // BBC selection? |
896 | 928 | elseif ($config_var['type'] == 'bbc') |
897 | 929 | { |
@@ -902,20 +934,22 @@ discard block |
||
902 | 934 | |
903 | 935 | foreach ($context['bbc_columns'] as $bbcColumn) |
904 | 936 | { |
905 | - foreach ($bbcColumn as $bbcTag) |
|
906 | - echo ' |
|
937 | + foreach ($bbcColumn as $bbcTag) { |
|
938 | + echo ' |
|
907 | 939 | <li class="list_bbc floatleft"> |
908 | 940 | <input type="checkbox" name="', $config_var['name'], '_enabledTags[]" id="tag_', $config_var['name'], '_', $bbcTag['tag'], '" value="', $bbcTag['tag'], '"', !in_array($bbcTag['tag'], $context['bbc_sections'][$config_var['name']]['disabled']) ? ' checked' : '', ' class="input_check"> <label for="tag_', $config_var['name'], '_', $bbcTag['tag'], '">', $bbcTag['tag'], '</label>', $bbcTag['show_help'] ? ' (<a href="' . $scripturl . '?action=helpadmin;help=tag_' . $bbcTag['tag'] . '" onclick="return reqOverlayDiv(this.href);">?</a>)' : '', ' |
909 | 941 | </li>'; |
942 | + } |
|
910 | 943 | } |
911 | 944 | echo ' </ul> |
912 | 945 | <input type="checkbox" id="bbc_', $config_var['name'], '_select_all" onclick="invertAll(this, this.form, \'', $config_var['name'], '_enabledTags\');"', $context['bbc_sections'][$config_var['name']]['all_selected'] ? ' checked' : '', ' class="input_check"> <label for="bbc_', $config_var['name'], '_select_all"><em>', $txt['bbcTagsToUse_select_all'], '</em></label> |
913 | 946 | </fieldset>'; |
914 | 947 | } |
915 | 948 | // A simple message? |
916 | - elseif ($config_var['type'] == 'var_message') |
|
917 | - echo ' |
|
949 | + elseif ($config_var['type'] == 'var_message') { |
|
950 | + echo ' |
|
918 | 951 | <div', !empty($config_var['name']) ? ' id="' . $config_var['name'] . '"' : '', '>', $config_var['var_message'], '</div>'; |
952 | + } |
|
919 | 953 | // Assume it must be a text box |
920 | 954 | else |
921 | 955 | { |
@@ -940,63 +974,70 @@ discard block |
||
940 | 974 | ' . $config_var['postinput'] : '', |
941 | 975 | '</dd>'; |
942 | 976 | } |
943 | - } |
|
944 | - |
|
945 | - else |
|
977 | + } else |
|
946 | 978 | { |
947 | 979 | // Just show a separator. |
948 | - if ($config_var == '') |
|
949 | - echo ' |
|
980 | + if ($config_var == '') { |
|
981 | + echo ' |
|
950 | 982 | </dl> |
951 | 983 | <hr> |
952 | 984 | <dl class="settings">'; |
953 | - else |
|
954 | - echo ' |
|
985 | + } else { |
|
986 | + echo ' |
|
955 | 987 | <dd> |
956 | 988 | <strong>' . $config_var . '</strong> |
957 | 989 | </dd>'; |
990 | + } |
|
958 | 991 | } |
959 | 992 | } |
960 | 993 | |
961 | - if ($is_open) |
|
962 | - echo ' |
|
994 | + if ($is_open) { |
|
995 | + echo ' |
|
963 | 996 | </dl>'; |
997 | + } |
|
964 | 998 | |
965 | - if (empty($context['settings_save_dont_show'])) |
|
966 | - echo ' |
|
999 | + if (empty($context['settings_save_dont_show'])) { |
|
1000 | + echo ' |
|
967 | 1001 | <input type="submit" value="', $txt['save'], '"', (!empty($context['save_disabled']) ? ' disabled' : ''), (!empty($context['settings_save_onclick']) ? ' onclick="' . $context['settings_save_onclick'] . '"' : ''), ' class="button_submit">'; |
1002 | + } |
|
968 | 1003 | |
969 | - if ($is_open) |
|
970 | - echo ' |
|
1004 | + if ($is_open) { |
|
1005 | + echo ' |
|
971 | 1006 | </div>'; |
1007 | + } |
|
972 | 1008 | |
973 | 1009 | |
974 | 1010 | // At least one token has to be used! |
975 | - if (isset($context['admin-ssc_token'])) |
|
976 | - echo ' |
|
1011 | + if (isset($context['admin-ssc_token'])) { |
|
1012 | + echo ' |
|
977 | 1013 | <input type="hidden" name="', $context['admin-ssc_token_var'], '" value="', $context['admin-ssc_token'], '">'; |
1014 | + } |
|
978 | 1015 | |
979 | - if (isset($context['admin-dbsc_token'])) |
|
980 | - echo ' |
|
1016 | + if (isset($context['admin-dbsc_token'])) { |
|
1017 | + echo ' |
|
981 | 1018 | <input type="hidden" name="', $context['admin-dbsc_token_var'], '" value="', $context['admin-dbsc_token'], '">'; |
1019 | + } |
|
982 | 1020 | |
983 | - if (isset($context['admin-mp_token'])) |
|
984 | - echo ' |
|
1021 | + if (isset($context['admin-mp_token'])) { |
|
1022 | + echo ' |
|
985 | 1023 | <input type="hidden" name="', $context['admin-mp_token_var'], '" value="', $context['admin-mp_token'], '">'; |
1024 | + } |
|
986 | 1025 | |
987 | 1026 | echo ' |
988 | 1027 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
989 | 1028 | </form> |
990 | 1029 | </div>'; |
991 | 1030 | |
992 | - if (!empty($context['settings_post_javascript'])) |
|
993 | - echo ' |
|
1031 | + if (!empty($context['settings_post_javascript'])) { |
|
1032 | + echo ' |
|
994 | 1033 | <script> |
995 | 1034 | ', $context['settings_post_javascript'], ' |
996 | 1035 | </script>'; |
1036 | + } |
|
997 | 1037 | |
998 | - if (!empty($context['settings_insert_below'])) |
|
999 | - echo $context['settings_insert_below']; |
|
1038 | + if (!empty($context['settings_insert_below'])) { |
|
1039 | + echo $context['settings_insert_below']; |
|
1040 | + } |
|
1000 | 1041 | |
1001 | 1042 | // We may have added a board listing. If we did, we need to make it work. |
1002 | 1043 | addInlineJavascript(' |
@@ -1019,9 +1060,10 @@ discard block |
||
1019 | 1060 | { |
1020 | 1061 | global $context, $txt; |
1021 | 1062 | |
1022 | - if (!empty($context['saved_successful'])) |
|
1023 | - echo ' |
|
1063 | + if (!empty($context['saved_successful'])) { |
|
1064 | + echo ' |
|
1024 | 1065 | <div class="infobox">', $txt['settings_saved'], '</div>'; |
1066 | + } |
|
1025 | 1067 | |
1026 | 1068 | // Standard fields. |
1027 | 1069 | template_show_list('standard_profile_fields'); |
@@ -1053,11 +1095,12 @@ discard block |
||
1053 | 1095 | if (isset($_GET['msg'])) |
1054 | 1096 | { |
1055 | 1097 | loadLanguage('Errors'); |
1056 | - if (isset($txt['custom_option_' . $_GET['msg']])) |
|
1057 | - echo ' |
|
1098 | + if (isset($txt['custom_option_' . $_GET['msg']])) { |
|
1099 | + echo ' |
|
1058 | 1100 | <div class="errorbox">', |
1059 | 1101 | $txt['custom_option_' . $_GET['msg']], ' |
1060 | 1102 | </div>'; |
1103 | + } |
|
1061 | 1104 | } |
1062 | 1105 | |
1063 | 1106 | echo ' |
@@ -1123,9 +1166,10 @@ discard block |
||
1123 | 1166 | <dd> |
1124 | 1167 | <select name="placement" id="placement">'; |
1125 | 1168 | |
1126 | - foreach ($context['cust_profile_fields_placement'] as $order => $name) |
|
1127 | - echo ' |
|
1169 | + foreach ($context['cust_profile_fields_placement'] as $order => $name) { |
|
1170 | + echo ' |
|
1128 | 1171 | <option value="', $order, '"', $context['field']['placement'] == $order ? ' selected' : '', '>', $txt['custom_profile_placement_' . $name], '</option>'; |
1172 | + } |
|
1129 | 1173 | |
1130 | 1174 | echo ' |
1131 | 1175 | </select> |
@@ -1148,9 +1192,10 @@ discard block |
||
1148 | 1192 | </dt> |
1149 | 1193 | <dd> |
1150 | 1194 | <select name="field_type" id="field_type" onchange="updateInputBoxes();">'; |
1151 | - foreach (array('text', 'textarea', 'select', 'radio', 'check') as $field_type) |
|
1152 | - echo ' |
|
1195 | + foreach (array('text', 'textarea', 'select', 'radio', 'check') as $field_type) { |
|
1196 | + echo ' |
|
1153 | 1197 | <option value="', $field_type, '"', $context['field']['type'] == $field_type ? ' selected' : '', '>', $txt['custom_profile_type_' . $field_type], '</option>'; |
1198 | + } |
|
1154 | 1199 | |
1155 | 1200 | echo ' |
1156 | 1201 | </select> |
@@ -1251,9 +1296,10 @@ discard block |
||
1251 | 1296 | </fieldset> |
1252 | 1297 | <input type="submit" name="save" value="', $txt['save'], '" class="button_submit">'; |
1253 | 1298 | |
1254 | - if ($context['fid']) |
|
1255 | - echo ' |
|
1299 | + if ($context['fid']) { |
|
1300 | + echo ' |
|
1256 | 1301 | <input type="submit" name="delete" value="', $txt['delete'], '" data-confirm="', $txt['custom_edit_delete_sure'], '" class="button_submit you_sure">'; |
1302 | + } |
|
1257 | 1303 | |
1258 | 1304 | echo ' |
1259 | 1305 | </div> |
@@ -1296,8 +1342,7 @@ discard block |
||
1296 | 1342 | { |
1297 | 1343 | echo ' |
1298 | 1344 | <p class="centertext"><strong>', $txt['admin_search_results_none'], '</strong></p>'; |
1299 | - } |
|
1300 | - else |
|
1345 | + } else |
|
1301 | 1346 | { |
1302 | 1347 | echo ' |
1303 | 1348 | <ol class="search_results">'; |
@@ -1323,9 +1368,10 @@ discard block |
||
1323 | 1368 | <li> |
1324 | 1369 | <a href="', $result['url'], '"><strong>', $result['name'], '</strong></a> [', isset($txt['admin_search_section_' . $result['type']]) ? $txt['admin_search_section_' . $result['type']] : $result['type'], ']'; |
1325 | 1370 | |
1326 | - if ($result['help']) |
|
1327 | - echo ' |
|
1371 | + if ($result['help']) { |
|
1372 | + echo ' |
|
1328 | 1373 | <p class="double_height">', $result['help'], '</p>'; |
1374 | + } |
|
1329 | 1375 | |
1330 | 1376 | echo ' |
1331 | 1377 | </li>'; |
@@ -1365,18 +1411,20 @@ discard block |
||
1365 | 1411 | <strong>', $txt['setup_verification_answer'], '</strong> |
1366 | 1412 | </dd>'; |
1367 | 1413 | |
1368 | - if (!empty($context['qa_by_lang'][$lang_id])) |
|
1369 | - foreach ($context['qa_by_lang'][$lang_id] as $q_id) |
|
1414 | + if (!empty($context['qa_by_lang'][$lang_id])) { |
|
1415 | + foreach ($context['qa_by_lang'][$lang_id] as $q_id) |
|
1370 | 1416 | { |
1371 | 1417 | $question = $context['question_answers'][$q_id]; |
1418 | + } |
|
1372 | 1419 | echo ' |
1373 | 1420 | <dt> |
1374 | 1421 | <input type="text" name="question[', $lang_id, '][', $q_id, ']" value="', $question['question'], '" size="50" class="input_text verification_question"> |
1375 | 1422 | </dt> |
1376 | 1423 | <dd>'; |
1377 | - foreach ($question['answers'] as $answer) |
|
1378 | - echo ' |
|
1424 | + foreach ($question['answers'] as $answer) { |
|
1425 | + echo ' |
|
1379 | 1426 | <input type="text" name="answer[', $lang_id, '][', $q_id, '][]" value="', $answer, '" size="50" class="input_text verification_answer">'; |
1427 | + } |
|
1380 | 1428 | |
1381 | 1429 | echo ' |
1382 | 1430 | <div class="qa_add_answer"><a href="javascript:void(0);" onclick="return addAnswer(this);">[ ', $txt['setup_verification_add_answer'], ' ]</a></div> |
@@ -1415,11 +1463,12 @@ discard block |
||
1415 | 1463 | ', $txt['errors_found'], ': |
1416 | 1464 | <ul>'; |
1417 | 1465 | |
1418 | - foreach ($context['repair_errors'] as $error) |
|
1419 | - echo ' |
|
1466 | + foreach ($context['repair_errors'] as $error) { |
|
1467 | + echo ' |
|
1420 | 1468 | <li> |
1421 | 1469 | ', $error, ' |
1422 | 1470 | </li>'; |
1471 | + } |
|
1423 | 1472 | |
1424 | 1473 | echo ' |
1425 | 1474 | </ul> |
@@ -1429,16 +1478,15 @@ discard block |
||
1429 | 1478 | <p class="padding"> |
1430 | 1479 | <strong><a href="', $scripturl, '?action=admin;area=repairboards;fixErrors;', $context['session_var'], '=', $context['session_id'], '">', $txt['yes'], '</a> - <a href="', $scripturl, '?action=admin;area=maintain">', $txt['no'], '</a></strong> |
1431 | 1480 | </p>'; |
1432 | - } |
|
1433 | - else |
|
1434 | - echo ' |
|
1481 | + } else { |
|
1482 | + echo ' |
|
1435 | 1483 | <p>', $txt['maintain_no_errors'], '</p> |
1436 | 1484 | <p class="padding"> |
1437 | 1485 | <a href="', $scripturl, '?action=admin;area=maintain;sa=routine">', $txt['maintain_return'], '</a> |
1438 | 1486 | </p>'; |
1487 | + } |
|
1439 | 1488 | |
1440 | - } |
|
1441 | - else |
|
1489 | + } else |
|
1442 | 1490 | { |
1443 | 1491 | if (!empty($context['redirect_to_recount'])) |
1444 | 1492 | { |
@@ -1450,8 +1498,7 @@ discard block |
||
1450 | 1498 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
1451 | 1499 | <input type="submit" name="recount" id="recount_now" value="', $txt['errors_recount_now'], '"> |
1452 | 1500 | </form>'; |
1453 | - } |
|
1454 | - else |
|
1501 | + } else |
|
1455 | 1502 | { |
1456 | 1503 | echo ' |
1457 | 1504 | <p>', $txt['errors_fixed'], '</p> |
@@ -1603,8 +1650,8 @@ discard block |
||
1603 | 1650 | function template_admin_quick_search() |
1604 | 1651 | { |
1605 | 1652 | global $context, $txt; |
1606 | - if ($context['user']['is_admin']) |
|
1607 | - echo ' |
|
1653 | + if ($context['user']['is_admin']) { |
|
1654 | + echo ' |
|
1608 | 1655 | <span class="floatright admin_search"> |
1609 | 1656 | <span class="generic_icons filter centericon"></span> |
1610 | 1657 | <input type="search" name="search_term" value="', $txt['admin_search'], '" onclick="if (this.value == \'', $txt['admin_search'], '\') this.value = \'\';" class="input_text"> |
@@ -1615,6 +1662,7 @@ discard block |
||
1615 | 1662 | </select> |
1616 | 1663 | <input type="submit" name="search_go" id="search_go" value="', $txt['admin_search_go'], '" class="button_submit"> |
1617 | 1664 | </span>'; |
1618 | -} |
|
1665 | + } |
|
1666 | + } |
|
1619 | 1667 | |
1620 | 1668 | ?> |
1621 | 1669 | \ No newline at end of file |
@@ -31,67 +31,67 @@ |
||
31 | 31 | */ |
32 | 32 | class ReCaptcha |
33 | 33 | { |
34 | - /** |
|
35 | - * Version of this client library. |
|
36 | - * @const string |
|
37 | - */ |
|
38 | - const VERSION = 'php_1.1.2'; |
|
34 | + /** |
|
35 | + * Version of this client library. |
|
36 | + * @const string |
|
37 | + */ |
|
38 | + const VERSION = 'php_1.1.2'; |
|
39 | 39 | |
40 | - /** |
|
41 | - * Shared secret for the site. |
|
42 | - * @var string |
|
43 | - */ |
|
44 | - private $secret; |
|
40 | + /** |
|
41 | + * Shared secret for the site. |
|
42 | + * @var string |
|
43 | + */ |
|
44 | + private $secret; |
|
45 | 45 | |
46 | - /** |
|
47 | - * Method used to communicate with service. Defaults to POST request. |
|
48 | - * @var RequestMethod |
|
49 | - */ |
|
50 | - private $requestMethod; |
|
46 | + /** |
|
47 | + * Method used to communicate with service. Defaults to POST request. |
|
48 | + * @var RequestMethod |
|
49 | + */ |
|
50 | + private $requestMethod; |
|
51 | 51 | |
52 | - /** |
|
53 | - * Create a configured instance to use the reCAPTCHA service. |
|
54 | - * |
|
55 | - * @param string $secret shared secret between site and reCAPTCHA server. |
|
56 | - * @param RequestMethod $requestMethod method used to send the request. Defaults to POST. |
|
57 | - */ |
|
58 | - public function __construct($secret, RequestMethod $requestMethod = null) |
|
59 | - { |
|
60 | - if (empty($secret)) { |
|
61 | - throw new \RuntimeException('No secret provided'); |
|
62 | - } |
|
52 | + /** |
|
53 | + * Create a configured instance to use the reCAPTCHA service. |
|
54 | + * |
|
55 | + * @param string $secret shared secret between site and reCAPTCHA server. |
|
56 | + * @param RequestMethod $requestMethod method used to send the request. Defaults to POST. |
|
57 | + */ |
|
58 | + public function __construct($secret, RequestMethod $requestMethod = null) |
|
59 | + { |
|
60 | + if (empty($secret)) { |
|
61 | + throw new \RuntimeException('No secret provided'); |
|
62 | + } |
|
63 | 63 | |
64 | - if (!is_string($secret)) { |
|
65 | - throw new \RuntimeException('The provided secret must be a string'); |
|
66 | - } |
|
64 | + if (!is_string($secret)) { |
|
65 | + throw new \RuntimeException('The provided secret must be a string'); |
|
66 | + } |
|
67 | 67 | |
68 | - $this->secret = $secret; |
|
68 | + $this->secret = $secret; |
|
69 | 69 | |
70 | - if (!is_null($requestMethod)) { |
|
71 | - $this->requestMethod = $requestMethod; |
|
72 | - } else { |
|
73 | - $this->requestMethod = new RequestMethod\Post(); |
|
74 | - } |
|
75 | - } |
|
70 | + if (!is_null($requestMethod)) { |
|
71 | + $this->requestMethod = $requestMethod; |
|
72 | + } else { |
|
73 | + $this->requestMethod = new RequestMethod\Post(); |
|
74 | + } |
|
75 | + } |
|
76 | 76 | |
77 | - /** |
|
78 | - * Calls the reCAPTCHA siteverify API to verify whether the user passes |
|
79 | - * CAPTCHA test. |
|
80 | - * |
|
81 | - * @param string $response The value of 'g-recaptcha-response' in the submitted form. |
|
82 | - * @param string $remoteIp The end user's IP address. |
|
83 | - * @return Response Response from the service. |
|
84 | - */ |
|
85 | - public function verify($response, $remoteIp = null) |
|
86 | - { |
|
87 | - // Discard empty solution submissions |
|
88 | - if (empty($response)) { |
|
89 | - $recaptchaResponse = new Response(false, array('missing-input-response')); |
|
90 | - return $recaptchaResponse; |
|
91 | - } |
|
77 | + /** |
|
78 | + * Calls the reCAPTCHA siteverify API to verify whether the user passes |
|
79 | + * CAPTCHA test. |
|
80 | + * |
|
81 | + * @param string $response The value of 'g-recaptcha-response' in the submitted form. |
|
82 | + * @param string $remoteIp The end user's IP address. |
|
83 | + * @return Response Response from the service. |
|
84 | + */ |
|
85 | + public function verify($response, $remoteIp = null) |
|
86 | + { |
|
87 | + // Discard empty solution submissions |
|
88 | + if (empty($response)) { |
|
89 | + $recaptchaResponse = new Response(false, array('missing-input-response')); |
|
90 | + return $recaptchaResponse; |
|
91 | + } |
|
92 | 92 | |
93 | - $params = new RequestParameters($this->secret, $response, $remoteIp, self::VERSION); |
|
94 | - $rawResponse = $this->requestMethod->submit($params); |
|
95 | - return Response::fromJson($rawResponse); |
|
96 | - } |
|
93 | + $params = new RequestParameters($this->secret, $response, $remoteIp, self::VERSION); |
|
94 | + $rawResponse = $this->requestMethod->submit($params); |
|
95 | + return Response::fromJson($rawResponse); |
|
96 | + } |
|
97 | 97 | } |
@@ -251,7 +251,7 @@ |
||
251 | 251 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
252 | 252 | $fts_language[$row['cfgname']] = $row['cfgname']; |
253 | 253 | |
254 | - $config_vars = array_merge ($config_vars, array( |
|
254 | + $config_vars = array_merge($config_vars, array( |
|
255 | 255 | '', |
256 | 256 | array('search_language', $txt['search_language'], 'db', 'select', $fts_language, 'pgFulltextSearch') |
257 | 257 | ) |
@@ -59,8 +59,9 @@ discard block |
||
59 | 59 | * @version 2.1 Beta 4 |
60 | 60 | */ |
61 | 61 | |
62 | -if (!defined('SMF')) |
|
62 | +if (!defined('SMF')) { |
|
63 | 63 | die('No direct access...'); |
64 | +} |
|
64 | 65 | |
65 | 66 | /** |
66 | 67 | * This is the main dispatcher. Sets up all the available sub-actions, all the tabs and selects |
@@ -111,10 +112,11 @@ discard block |
||
111 | 112 | $settings_not_writable = !is_writable($boarddir . '/Settings.php'); |
112 | 113 | $settings_backup_fail = !@is_writable($boarddir . '/Settings_bak.php') || !@copy($boarddir . '/Settings.php', $boarddir . '/Settings_bak.php'); |
113 | 114 | |
114 | - if ($settings_not_writable) |
|
115 | - $context['settings_message'] = '<div class="centertext"><strong>' . $txt['settings_not_writable'] . '</strong></div><br>'; |
|
116 | - elseif ($settings_backup_fail) |
|
117 | - $context['settings_message'] = '<div class="centertext"><strong>' . $txt['admin_backup_fail'] . '</strong></div><br>'; |
|
115 | + if ($settings_not_writable) { |
|
116 | + $context['settings_message'] = '<div class="centertext"><strong>' . $txt['settings_not_writable'] . '</strong></div><br>'; |
|
117 | + } elseif ($settings_backup_fail) { |
|
118 | + $context['settings_message'] = '<div class="centertext"><strong>' . $txt['admin_backup_fail'] . '</strong></div><br>'; |
|
119 | + } |
|
118 | 120 | |
119 | 121 | $context['settings_not_writable'] = $settings_not_writable; |
120 | 122 | |
@@ -168,8 +170,9 @@ discard block |
||
168 | 170 | |
169 | 171 | call_integration_hook('integrate_general_settings', array(&$config_vars)); |
170 | 172 | |
171 | - if ($return_config) |
|
172 | - return $config_vars; |
|
173 | + if ($return_config) { |
|
174 | + return $config_vars; |
|
175 | + } |
|
173 | 176 | |
174 | 177 | // Setup the template stuff. |
175 | 178 | $context['post_url'] = $scripturl . '?action=admin;area=serversettings;sa=general;save'; |
@@ -186,8 +189,9 @@ discard block |
||
186 | 189 | $registerSMStats = registerSMStats(); |
187 | 190 | |
188 | 191 | // Failed to register, disable it again. |
189 | - if (empty($registerSMStats)) |
|
190 | - $_POST['enable_sm_stats'] = 0; |
|
192 | + if (empty($registerSMStats)) { |
|
193 | + $_POST['enable_sm_stats'] = 0; |
|
194 | + } |
|
191 | 195 | } |
192 | 196 | |
193 | 197 | saveSettings($config_vars); |
@@ -248,8 +252,9 @@ discard block |
||
248 | 252 | $request = $smcFunc['db_query']('', 'SELECT cfgname FROM pg_ts_config', array()); |
249 | 253 | $fts_language = array(); |
250 | 254 | |
251 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
252 | - $fts_language[$row['cfgname']] = $row['cfgname']; |
|
255 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
256 | + $fts_language[$row['cfgname']] = $row['cfgname']; |
|
257 | + } |
|
253 | 258 | |
254 | 259 | $config_vars = array_merge ($config_vars, array( |
255 | 260 | '', |
@@ -261,8 +266,9 @@ discard block |
||
261 | 266 | |
262 | 267 | call_integration_hook('integrate_database_settings', array(&$config_vars)); |
263 | 268 | |
264 | - if ($return_config) |
|
265 | - return $config_vars; |
|
269 | + if ($return_config) { |
|
270 | + return $config_vars; |
|
271 | + } |
|
266 | 272 | |
267 | 273 | // Setup the template stuff. |
268 | 274 | $context['post_url'] = $scripturl . '?action=admin;area=serversettings;sa=database;save'; |
@@ -337,13 +343,15 @@ discard block |
||
337 | 343 | hideGlobalCookies(); |
338 | 344 | });', true); |
339 | 345 | |
340 | - if (empty($user_settings['tfa_secret'])) |
|
341 | - addInlineJavaScript(''); |
|
346 | + if (empty($user_settings['tfa_secret'])) { |
|
347 | + addInlineJavaScript(''); |
|
348 | + } |
|
342 | 349 | |
343 | 350 | call_integration_hook('integrate_cookie_settings', array(&$config_vars)); |
344 | 351 | |
345 | - if ($return_config) |
|
346 | - return $config_vars; |
|
352 | + if ($return_config) { |
|
353 | + return $config_vars; |
|
354 | + } |
|
347 | 355 | |
348 | 356 | $context['post_url'] = $scripturl . '?action=admin;area=serversettings;sa=cookie;save'; |
349 | 357 | $context['settings_title'] = $txt['cookies_sessions_settings']; |
@@ -354,11 +362,13 @@ discard block |
||
354 | 362 | call_integration_hook('integrate_save_cookie_settings'); |
355 | 363 | |
356 | 364 | // Local and global do not play nicely together. |
357 | - if (!empty($_POST['localCookies']) && empty($_POST['globalCookies'])) |
|
358 | - unset ($_POST['globalCookies']); |
|
365 | + if (!empty($_POST['localCookies']) && empty($_POST['globalCookies'])) { |
|
366 | + unset ($_POST['globalCookies']); |
|
367 | + } |
|
359 | 368 | |
360 | - if (!empty($_POST['globalCookiesDomain']) && strpos($boardurl, $_POST['globalCookiesDomain']) === false) |
|
361 | - fatal_lang_error('invalid_cookie_domain', false); |
|
369 | + if (!empty($_POST['globalCookiesDomain']) && strpos($boardurl, $_POST['globalCookiesDomain']) === false) { |
|
370 | + fatal_lang_error('invalid_cookie_domain', false); |
|
371 | + } |
|
362 | 372 | |
363 | 373 | saveSettings($config_vars); |
364 | 374 | |
@@ -441,8 +451,9 @@ discard block |
||
441 | 451 | |
442 | 452 | call_integration_hook('integrate_general_security_settings', array(&$config_vars)); |
443 | 453 | |
444 | - if ($return_config) |
|
445 | - return $config_vars; |
|
454 | + if ($return_config) { |
|
455 | + return $config_vars; |
|
456 | + } |
|
446 | 457 | |
447 | 458 | // Saving? |
448 | 459 | if (isset($_GET['save'])) |
@@ -481,8 +492,7 @@ discard block |
||
481 | 492 | $txt['cache_settings_message'] = $txt['detected_no_caching']; |
482 | 493 | $cache_level = array($txt['cache_off']); |
483 | 494 | $detected['none'] = $txt['cache_off']; |
484 | - } |
|
485 | - else |
|
495 | + } else |
|
486 | 496 | { |
487 | 497 | $txt['cache_settings_message'] = sprintf($txt['detected_accelerators'], implode(', ', $detected)); |
488 | 498 | $cache_level = array($txt['cache_off'], $txt['cache_level1'], $txt['cache_level2'], $txt['cache_level3']); |
@@ -519,8 +529,9 @@ discard block |
||
519 | 529 | } |
520 | 530 | } |
521 | 531 | } |
522 | - if ($return_config) |
|
523 | - return $config_vars; |
|
532 | + if ($return_config) { |
|
533 | + return $config_vars; |
|
534 | + } |
|
524 | 535 | |
525 | 536 | // Saving again? |
526 | 537 | if (isset($_GET['save'])) |
@@ -548,8 +559,9 @@ discard block |
||
548 | 559 | $context['save_disabled'] = $context['settings_not_writable']; |
549 | 560 | |
550 | 561 | // Decide what message to show. |
551 | - if (!$context['save_disabled']) |
|
552 | - $context['settings_message'] = $txt['caching_information']; |
|
562 | + if (!$context['save_disabled']) { |
|
563 | + $context['settings_message'] = $txt['caching_information']; |
|
564 | + } |
|
553 | 565 | |
554 | 566 | // Prepare the template. |
555 | 567 | prepareServerSettingsContext($config_vars); |
@@ -572,24 +584,25 @@ discard block |
||
572 | 584 | if (stripos(PHP_OS, 'win') === 0) |
573 | 585 | { |
574 | 586 | $context['settings_message'] = $txt['loadavg_disabled_windows']; |
575 | - if (isset($_GET['save'])) |
|
576 | - $_SESSION['adm-save'] = $txt['loadavg_disabled_windows']; |
|
577 | - } |
|
578 | - elseif (stripos(PHP_OS, 'darwin') === 0) |
|
587 | + if (isset($_GET['save'])) { |
|
588 | + $_SESSION['adm-save'] = $txt['loadavg_disabled_windows']; |
|
589 | + } |
|
590 | + } elseif (stripos(PHP_OS, 'darwin') === 0) |
|
579 | 591 | { |
580 | 592 | $context['settings_message'] = $txt['loadavg_disabled_osx']; |
581 | - if (isset($_GET['save'])) |
|
582 | - $_SESSION['adm-save'] = $txt['loadavg_disabled_osx']; |
|
583 | - } |
|
584 | - else |
|
593 | + if (isset($_GET['save'])) { |
|
594 | + $_SESSION['adm-save'] = $txt['loadavg_disabled_osx']; |
|
595 | + } |
|
596 | + } else |
|
585 | 597 | { |
586 | 598 | $modSettings['load_average'] = @file_get_contents('/proc/loadavg'); |
587 | - if (!empty($modSettings['load_average']) && preg_match('~^([^ ]+?) ([^ ]+?) ([^ ]+)~', $modSettings['load_average'], $matches) !== 0) |
|
588 | - $modSettings['load_average'] = (float) $matches[1]; |
|
589 | - elseif (($modSettings['load_average'] = @`uptime`) !== null && preg_match('~load averages?: (\d+\.\d+), (\d+\.\d+), (\d+\.\d+)~i', $modSettings['load_average'], $matches) !== 0) |
|
590 | - $modSettings['load_average'] = (float) $matches[1]; |
|
591 | - else |
|
592 | - unset($modSettings['load_average']); |
|
599 | + if (!empty($modSettings['load_average']) && preg_match('~^([^ ]+?) ([^ ]+?) ([^ ]+)~', $modSettings['load_average'], $matches) !== 0) { |
|
600 | + $modSettings['load_average'] = (float) $matches[1]; |
|
601 | + } elseif (($modSettings['load_average'] = @`uptime`) !== null && preg_match('~load averages?: (\d+\.\d+), (\d+\.\d+), (\d+\.\d+)~i', $modSettings['load_average'], $matches) !== 0) { |
|
602 | + $modSettings['load_average'] = (float) $matches[1]; |
|
603 | + } else { |
|
604 | + unset($modSettings['load_average']); |
|
605 | + } |
|
593 | 606 | |
594 | 607 | if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) |
595 | 608 | { |
@@ -625,8 +638,9 @@ discard block |
||
625 | 638 | |
626 | 639 | call_integration_hook('integrate_loadavg_settings', array(&$config_vars)); |
627 | 640 | |
628 | - if ($return_config) |
|
629 | - return $config_vars; |
|
641 | + if ($return_config) { |
|
642 | + return $config_vars; |
|
643 | + } |
|
630 | 644 | |
631 | 645 | $context['post_url'] = $scripturl . '?action=admin;area=serversettings;sa=loads;save'; |
632 | 646 | $context['settings_title'] = $txt['load_balancing_settings']; |
@@ -637,24 +651,27 @@ discard block |
||
637 | 651 | // Stupidity is not allowed. |
638 | 652 | foreach ($_POST as $key => $value) |
639 | 653 | { |
640 | - if (strpos($key, 'loadavg') === 0 || $key === 'loadavg_enable' || !in_array($key, array_keys($default_values))) |
|
641 | - continue; |
|
642 | - else |
|
643 | - $_POST[$key] = (float) $value; |
|
644 | - |
|
645 | - if ($key == 'loadavg_auto_opt' && $value <= 1) |
|
646 | - $_POST['loadavg_auto_opt'] = 1.0; |
|
647 | - elseif ($key == 'loadavg_forum' && $value < 10) |
|
648 | - $_POST['loadavg_forum'] = 10.0; |
|
649 | - elseif ($value < 2) |
|
650 | - $_POST[$key] = 2.0; |
|
654 | + if (strpos($key, 'loadavg') === 0 || $key === 'loadavg_enable' || !in_array($key, array_keys($default_values))) { |
|
655 | + continue; |
|
656 | + } else { |
|
657 | + $_POST[$key] = (float) $value; |
|
658 | + } |
|
659 | + |
|
660 | + if ($key == 'loadavg_auto_opt' && $value <= 1) { |
|
661 | + $_POST['loadavg_auto_opt'] = 1.0; |
|
662 | + } elseif ($key == 'loadavg_forum' && $value < 10) { |
|
663 | + $_POST['loadavg_forum'] = 10.0; |
|
664 | + } elseif ($value < 2) { |
|
665 | + $_POST[$key] = 2.0; |
|
666 | + } |
|
651 | 667 | } |
652 | 668 | |
653 | 669 | call_integration_hook('integrate_save_loadavg_settings'); |
654 | 670 | |
655 | 671 | saveDBSettings($config_vars); |
656 | - if (!isset($_SESSION['adm-save'])) |
|
657 | - $_SESSION['adm-save'] = true; |
|
672 | + if (!isset($_SESSION['adm-save'])) { |
|
673 | + $_SESSION['adm-save'] = true; |
|
674 | + } |
|
658 | 675 | redirectexit('action=admin;area=serversettings;sa=loads;' . $context['session_var'] . '=' . $context['session_id']); |
659 | 676 | } |
660 | 677 | |
@@ -690,10 +707,11 @@ discard block |
||
690 | 707 | |
691 | 708 | if (isset($_SESSION['adm-save'])) |
692 | 709 | { |
693 | - if ($_SESSION['adm-save'] === true) |
|
694 | - $context['saved_successful'] = true; |
|
695 | - else |
|
696 | - $context['saved_failed'] = $_SESSION['adm-save']; |
|
710 | + if ($_SESSION['adm-save'] === true) { |
|
711 | + $context['saved_successful'] = true; |
|
712 | + } else { |
|
713 | + $context['saved_failed'] = $_SESSION['adm-save']; |
|
714 | + } |
|
697 | 715 | |
698 | 716 | unset($_SESSION['adm-save']); |
699 | 717 | } |
@@ -701,9 +719,9 @@ discard block |
||
701 | 719 | $context['config_vars'] = array(); |
702 | 720 | foreach ($config_vars as $identifier => $config_var) |
703 | 721 | { |
704 | - if (!is_array($config_var) || !isset($config_var[1])) |
|
705 | - $context['config_vars'][] = $config_var; |
|
706 | - else |
|
722 | + if (!is_array($config_var) || !isset($config_var[1])) { |
|
723 | + $context['config_vars'][] = $config_var; |
|
724 | + } else |
|
707 | 725 | { |
708 | 726 | $varname = $config_var[0]; |
709 | 727 | global $$varname; |
@@ -738,16 +756,19 @@ discard block |
||
738 | 756 | if ($config_var[3] == 'int' || $config_var[3] == 'float') |
739 | 757 | { |
740 | 758 | // Default to a min of 0 if one isn't set |
741 | - if (isset($config_var['min'])) |
|
742 | - $context['config_vars'][$config_var[0]]['min'] = $config_var['min']; |
|
743 | - else |
|
744 | - $context['config_vars'][$config_var[0]]['min'] = 0; |
|
759 | + if (isset($config_var['min'])) { |
|
760 | + $context['config_vars'][$config_var[0]]['min'] = $config_var['min']; |
|
761 | + } else { |
|
762 | + $context['config_vars'][$config_var[0]]['min'] = 0; |
|
763 | + } |
|
745 | 764 | |
746 | - if (isset($config_var['max'])) |
|
747 | - $context['config_vars'][$config_var[0]]['max'] = $config_var['max']; |
|
765 | + if (isset($config_var['max'])) { |
|
766 | + $context['config_vars'][$config_var[0]]['max'] = $config_var['max']; |
|
767 | + } |
|
748 | 768 | |
749 | - if (isset($config_var['step'])) |
|
750 | - $context['config_vars'][$config_var[0]]['step'] = $config_var['step']; |
|
769 | + if (isset($config_var['step'])) { |
|
770 | + $context['config_vars'][$config_var[0]]['step'] = $config_var['step']; |
|
771 | + } |
|
751 | 772 | } |
752 | 773 | |
753 | 774 | // If this is a select box handle any data. |
@@ -755,12 +776,13 @@ discard block |
||
755 | 776 | { |
756 | 777 | // If it's associative |
757 | 778 | $config_values = array_values($config_var[4]); |
758 | - if (isset($config_values[0]) && is_array($config_values[0])) |
|
759 | - $context['config_vars'][$config_var[0]]['data'] = $config_var[4]; |
|
760 | - else |
|
779 | + if (isset($config_values[0]) && is_array($config_values[0])) { |
|
780 | + $context['config_vars'][$config_var[0]]['data'] = $config_var[4]; |
|
781 | + } else |
|
761 | 782 | { |
762 | - foreach ($config_var[4] as $key => $item) |
|
763 | - $context['config_vars'][$config_var[0]]['data'][] = array($key, $item); |
|
783 | + foreach ($config_var[4] as $key => $item) { |
|
784 | + $context['config_vars'][$config_var[0]]['data'][] = array($key, $item); |
|
785 | + } |
|
764 | 786 | } |
765 | 787 | } |
766 | 788 | } |
@@ -785,10 +807,11 @@ discard block |
||
785 | 807 | |
786 | 808 | if (isset($_SESSION['adm-save'])) |
787 | 809 | { |
788 | - if ($_SESSION['adm-save'] === true) |
|
789 | - $context['saved_successful'] = true; |
|
790 | - else |
|
791 | - $context['saved_failed'] = $_SESSION['adm-save']; |
|
810 | + if ($_SESSION['adm-save'] === true) { |
|
811 | + $context['saved_successful'] = true; |
|
812 | + } else { |
|
813 | + $context['saved_failed'] = $_SESSION['adm-save']; |
|
814 | + } |
|
792 | 815 | |
793 | 816 | unset($_SESSION['adm-save']); |
794 | 817 | } |
@@ -800,26 +823,30 @@ discard block |
||
800 | 823 | foreach ($config_vars as $config_var) |
801 | 824 | { |
802 | 825 | // HR? |
803 | - if (!is_array($config_var)) |
|
804 | - $context['config_vars'][] = $config_var; |
|
805 | - else |
|
826 | + if (!is_array($config_var)) { |
|
827 | + $context['config_vars'][] = $config_var; |
|
828 | + } else |
|
806 | 829 | { |
807 | 830 | // If it has no name it doesn't have any purpose! |
808 | - if (empty($config_var[1])) |
|
809 | - continue; |
|
831 | + if (empty($config_var[1])) { |
|
832 | + continue; |
|
833 | + } |
|
810 | 834 | |
811 | 835 | // Special case for inline permissions |
812 | - if ($config_var[0] == 'permissions' && allowedTo('manage_permissions')) |
|
813 | - $inlinePermissions[] = $config_var[1]; |
|
814 | - elseif ($config_var[0] == 'permissions') |
|
815 | - continue; |
|
836 | + if ($config_var[0] == 'permissions' && allowedTo('manage_permissions')) { |
|
837 | + $inlinePermissions[] = $config_var[1]; |
|
838 | + } elseif ($config_var[0] == 'permissions') { |
|
839 | + continue; |
|
840 | + } |
|
816 | 841 | |
817 | - if ($config_var[0] == 'boards') |
|
818 | - $board_list = true; |
|
842 | + if ($config_var[0] == 'boards') { |
|
843 | + $board_list = true; |
|
844 | + } |
|
819 | 845 | |
820 | 846 | // Are we showing the BBC selection box? |
821 | - if ($config_var[0] == 'bbc') |
|
822 | - $bbcChoice[] = $config_var[1]; |
|
847 | + if ($config_var[0] == 'bbc') { |
|
848 | + $bbcChoice[] = $config_var[1]; |
|
849 | + } |
|
823 | 850 | |
824 | 851 | // We need to do some parsing of the value before we pass it in. |
825 | 852 | if (isset($modSettings[$config_var[1]])) |
@@ -838,8 +865,7 @@ discard block |
||
838 | 865 | default: |
839 | 866 | $value = $smcFunc['htmlspecialchars']($modSettings[$config_var[1]]); |
840 | 867 | } |
841 | - } |
|
842 | - else |
|
868 | + } else |
|
843 | 869 | { |
844 | 870 | // Darn, it's empty. What type is expected? |
845 | 871 | switch ($config_var[0]) |
@@ -879,16 +905,19 @@ discard block |
||
879 | 905 | if ($config_var[0] == 'int' || $config_var[0] == 'float') |
880 | 906 | { |
881 | 907 | // Default to a min of 0 if one isn't set |
882 | - if (isset($config_var['min'])) |
|
883 | - $context['config_vars'][$config_var[1]]['min'] = $config_var['min']; |
|
884 | - else |
|
885 | - $context['config_vars'][$config_var[1]]['min'] = 0; |
|
908 | + if (isset($config_var['min'])) { |
|
909 | + $context['config_vars'][$config_var[1]]['min'] = $config_var['min']; |
|
910 | + } else { |
|
911 | + $context['config_vars'][$config_var[1]]['min'] = 0; |
|
912 | + } |
|
886 | 913 | |
887 | - if (isset($config_var['max'])) |
|
888 | - $context['config_vars'][$config_var[1]]['max'] = $config_var['max']; |
|
914 | + if (isset($config_var['max'])) { |
|
915 | + $context['config_vars'][$config_var[1]]['max'] = $config_var['max']; |
|
916 | + } |
|
889 | 917 | |
890 | - if (isset($config_var['step'])) |
|
891 | - $context['config_vars'][$config_var[1]]['step'] = $config_var['step']; |
|
918 | + if (isset($config_var['step'])) { |
|
919 | + $context['config_vars'][$config_var[1]]['step'] = $config_var['step']; |
|
920 | + } |
|
892 | 921 | } |
893 | 922 | |
894 | 923 | // If this is a select box handle any data. |
@@ -902,12 +931,13 @@ discard block |
||
902 | 931 | } |
903 | 932 | |
904 | 933 | // If it's associative |
905 | - if (isset($config_var[2][0]) && is_array($config_var[2][0])) |
|
906 | - $context['config_vars'][$config_var[1]]['data'] = $config_var[2]; |
|
907 | - else |
|
934 | + if (isset($config_var[2][0]) && is_array($config_var[2][0])) { |
|
935 | + $context['config_vars'][$config_var[1]]['data'] = $config_var[2]; |
|
936 | + } else |
|
908 | 937 | { |
909 | - foreach ($config_var[2] as $key => $item) |
|
910 | - $context['config_vars'][$config_var[1]]['data'][] = array($key, $item); |
|
938 | + foreach ($config_var[2] as $key => $item) { |
|
939 | + $context['config_vars'][$config_var[1]]['data'][] = array($key, $item); |
|
940 | + } |
|
911 | 941 | } |
912 | 942 | } |
913 | 943 | |
@@ -916,17 +946,19 @@ discard block |
||
916 | 946 | { |
917 | 947 | if (!is_numeric($k)) |
918 | 948 | { |
919 | - if (substr($k, 0, 2) == 'on') |
|
920 | - $context['config_vars'][$config_var[1]]['javascript'] .= ' ' . $k . '="' . $v . '"'; |
|
921 | - else |
|
922 | - $context['config_vars'][$config_var[1]][$k] = $v; |
|
949 | + if (substr($k, 0, 2) == 'on') { |
|
950 | + $context['config_vars'][$config_var[1]]['javascript'] .= ' ' . $k . '="' . $v . '"'; |
|
951 | + } else { |
|
952 | + $context['config_vars'][$config_var[1]][$k] = $v; |
|
953 | + } |
|
923 | 954 | } |
924 | 955 | |
925 | 956 | // See if there are any other labels that might fit? |
926 | - if (isset($txt['setting_' . $config_var[1]])) |
|
927 | - $context['config_vars'][$config_var[1]]['label'] = $txt['setting_' . $config_var[1]]; |
|
928 | - elseif (isset($txt['groups_' . $config_var[1]])) |
|
929 | - $context['config_vars'][$config_var[1]]['label'] = $txt['groups_' . $config_var[1]]; |
|
957 | + if (isset($txt['setting_' . $config_var[1]])) { |
|
958 | + $context['config_vars'][$config_var[1]]['label'] = $txt['setting_' . $config_var[1]]; |
|
959 | + } elseif (isset($txt['groups_' . $config_var[1]])) { |
|
960 | + $context['config_vars'][$config_var[1]]['label'] = $txt['groups_' . $config_var[1]]; |
|
961 | + } |
|
930 | 962 | } |
931 | 963 | |
932 | 964 | // Set the subtext in case it's part of the label. |
@@ -959,8 +991,9 @@ discard block |
||
959 | 991 | // What are the options, eh? |
960 | 992 | $temp = parse_bbc(false); |
961 | 993 | $bbcTags = array(); |
962 | - foreach ($temp as $tag) |
|
963 | - $bbcTags[] = $tag['tag']; |
|
994 | + foreach ($temp as $tag) { |
|
995 | + $bbcTags[] = $tag['tag']; |
|
996 | + } |
|
964 | 997 | |
965 | 998 | $bbcTags = array_unique($bbcTags); |
966 | 999 | $totalTags = count($bbcTags); |
@@ -975,8 +1008,9 @@ discard block |
||
975 | 1008 | $col = 0; $i = 0; |
976 | 1009 | foreach ($bbcTags as $tag) |
977 | 1010 | { |
978 | - if ($i % $tagsPerColumn == 0 && $i != 0) |
|
979 | - $col++; |
|
1011 | + if ($i % $tagsPerColumn == 0 && $i != 0) { |
|
1012 | + $col++; |
|
1013 | + } |
|
980 | 1014 | |
981 | 1015 | $context['bbc_columns'][$col][] = array( |
982 | 1016 | 'tag' => $tag, |
@@ -1019,18 +1053,21 @@ discard block |
||
1019 | 1053 | validateToken('admin-ssc'); |
1020 | 1054 | |
1021 | 1055 | // Fix the darn stupid cookiename! (more may not be allowed, but these for sure!) |
1022 | - if (isset($_POST['cookiename'])) |
|
1023 | - $_POST['cookiename'] = preg_replace('~[,;\s\.$]+~' . ($context['utf8'] ? 'u' : ''), '', $_POST['cookiename']); |
|
1056 | + if (isset($_POST['cookiename'])) { |
|
1057 | + $_POST['cookiename'] = preg_replace('~[,;\s\.$]+~' . ($context['utf8'] ? 'u' : ''), '', $_POST['cookiename']); |
|
1058 | + } |
|
1024 | 1059 | |
1025 | 1060 | // Fix the forum's URL if necessary. |
1026 | 1061 | if (isset($_POST['boardurl'])) |
1027 | 1062 | { |
1028 | - if (substr($_POST['boardurl'], -10) == '/index.php') |
|
1029 | - $_POST['boardurl'] = substr($_POST['boardurl'], 0, -10); |
|
1030 | - elseif (substr($_POST['boardurl'], -1) == '/') |
|
1031 | - $_POST['boardurl'] = substr($_POST['boardurl'], 0, -1); |
|
1032 | - if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://') |
|
1033 | - $_POST['boardurl'] = 'http://' . $_POST['boardurl']; |
|
1063 | + if (substr($_POST['boardurl'], -10) == '/index.php') { |
|
1064 | + $_POST['boardurl'] = substr($_POST['boardurl'], 0, -10); |
|
1065 | + } elseif (substr($_POST['boardurl'], -1) == '/') { |
|
1066 | + $_POST['boardurl'] = substr($_POST['boardurl'], 0, -1); |
|
1067 | + } |
|
1068 | + if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://') { |
|
1069 | + $_POST['boardurl'] = 'http://' . $_POST['boardurl']; |
|
1070 | + } |
|
1034 | 1071 | } |
1035 | 1072 | |
1036 | 1073 | // Any passwords? |
@@ -1065,21 +1102,21 @@ discard block |
||
1065 | 1102 | // Figure out which config vars we're saving here... |
1066 | 1103 | foreach ($config_vars as $var) |
1067 | 1104 | { |
1068 | - if (!is_array($var) || $var[2] != 'file' || (!in_array($var[0], $config_bools) && !isset($_POST[$var[0]]))) |
|
1069 | - continue; |
|
1105 | + if (!is_array($var) || $var[2] != 'file' || (!in_array($var[0], $config_bools) && !isset($_POST[$var[0]]))) { |
|
1106 | + continue; |
|
1107 | + } |
|
1070 | 1108 | |
1071 | 1109 | $config_var = $var[0]; |
1072 | 1110 | |
1073 | 1111 | if (in_array($config_var, $config_passwords)) |
1074 | 1112 | { |
1075 | - if (isset($_POST[$config_var][1]) && $_POST[$config_var][0] == $_POST[$config_var][1]) |
|
1076 | - $new_settings[$config_var] = '\'' . addcslashes($_POST[$config_var][0], '\'\\') . '\''; |
|
1077 | - } |
|
1078 | - elseif (in_array($config_var, $config_strs)) |
|
1113 | + if (isset($_POST[$config_var][1]) && $_POST[$config_var][0] == $_POST[$config_var][1]) { |
|
1114 | + $new_settings[$config_var] = '\'' . addcslashes($_POST[$config_var][0], '\'\\') . '\''; |
|
1115 | + } |
|
1116 | + } elseif (in_array($config_var, $config_strs)) |
|
1079 | 1117 | { |
1080 | 1118 | $new_settings[$config_var] = '\'' . addcslashes($_POST[$config_var], '\'\\') . '\''; |
1081 | - } |
|
1082 | - elseif (in_array($config_var, $config_ints)) |
|
1119 | + } elseif (in_array($config_var, $config_ints)) |
|
1083 | 1120 | { |
1084 | 1121 | $new_settings[$config_var] = (int) $_POST[$config_var]; |
1085 | 1122 | |
@@ -1088,17 +1125,17 @@ discard block |
||
1088 | 1125 | $new_settings[$config_var] = max($min, $new_settings[$config_var]); |
1089 | 1126 | |
1090 | 1127 | // Is there a max value for this as well? |
1091 | - if (isset($var['max'])) |
|
1092 | - $new_settings[$config_var] = min($var['max'], $new_settings[$config_var]); |
|
1093 | - } |
|
1094 | - elseif (in_array($config_var, $config_bools)) |
|
1128 | + if (isset($var['max'])) { |
|
1129 | + $new_settings[$config_var] = min($var['max'], $new_settings[$config_var]); |
|
1130 | + } |
|
1131 | + } elseif (in_array($config_var, $config_bools)) |
|
1095 | 1132 | { |
1096 | - if (!empty($_POST[$config_var])) |
|
1097 | - $new_settings[$config_var] = '1'; |
|
1098 | - else |
|
1099 | - $new_settings[$config_var] = '0'; |
|
1100 | - } |
|
1101 | - else |
|
1133 | + if (!empty($_POST[$config_var])) { |
|
1134 | + $new_settings[$config_var] = '1'; |
|
1135 | + } else { |
|
1136 | + $new_settings[$config_var] = '0'; |
|
1137 | + } |
|
1138 | + } else |
|
1102 | 1139 | { |
1103 | 1140 | // This shouldn't happen, but it might... |
1104 | 1141 | fatal_error('Unknown config_var \'' . $config_var . '\''); |
@@ -1114,30 +1151,35 @@ discard block |
||
1114 | 1151 | foreach ($config_vars as $config_var) |
1115 | 1152 | { |
1116 | 1153 | // We just saved the file-based settings, so skip their definitions. |
1117 | - if (!is_array($config_var) || $config_var[2] == 'file') |
|
1118 | - continue; |
|
1154 | + if (!is_array($config_var) || $config_var[2] == 'file') { |
|
1155 | + continue; |
|
1156 | + } |
|
1119 | 1157 | |
1120 | 1158 | $new_setting = array($config_var[3], $config_var[0]); |
1121 | 1159 | |
1122 | 1160 | // Select options need carried over, too. |
1123 | - if (isset($config_var[4])) |
|
1124 | - $new_setting[] = $config_var[4]; |
|
1161 | + if (isset($config_var[4])) { |
|
1162 | + $new_setting[] = $config_var[4]; |
|
1163 | + } |
|
1125 | 1164 | |
1126 | 1165 | // Include min and max if necessary |
1127 | - if (isset($config_var['min'])) |
|
1128 | - $new_setting['min'] = $config_var['min']; |
|
1166 | + if (isset($config_var['min'])) { |
|
1167 | + $new_setting['min'] = $config_var['min']; |
|
1168 | + } |
|
1129 | 1169 | |
1130 | - if (isset($config_var['max'])) |
|
1131 | - $new_setting['max'] = $config_var['max']; |
|
1170 | + if (isset($config_var['max'])) { |
|
1171 | + $new_setting['max'] = $config_var['max']; |
|
1172 | + } |
|
1132 | 1173 | |
1133 | 1174 | // Rewrite the definition a bit. |
1134 | 1175 | $new_settings[] = $new_setting; |
1135 | 1176 | } |
1136 | 1177 | |
1137 | 1178 | // Save the new database-based settings, if any. |
1138 | - if (!empty($new_settings)) |
|
1139 | - saveDBSettings($new_settings); |
|
1140 | -} |
|
1179 | + if (!empty($new_settings)) { |
|
1180 | + saveDBSettings($new_settings); |
|
1181 | + } |
|
1182 | + } |
|
1141 | 1183 | |
1142 | 1184 | /** |
1143 | 1185 | * Helper function for saving database settings. |
@@ -1155,22 +1197,25 @@ discard block |
||
1155 | 1197 | $inlinePermissions = array(); |
1156 | 1198 | foreach ($config_vars as $var) |
1157 | 1199 | { |
1158 | - if (!isset($var[1]) || (!isset($_POST[$var[1]]) && $var[0] != 'check' && $var[0] != 'permissions' && $var[0] != 'boards' && ($var[0] != 'bbc' || !isset($_POST[$var[1] . '_enabledTags'])))) |
|
1159 | - continue; |
|
1200 | + if (!isset($var[1]) || (!isset($_POST[$var[1]]) && $var[0] != 'check' && $var[0] != 'permissions' && $var[0] != 'boards' && ($var[0] != 'bbc' || !isset($_POST[$var[1] . '_enabledTags'])))) { |
|
1201 | + continue; |
|
1202 | + } |
|
1160 | 1203 | |
1161 | 1204 | // Checkboxes! |
1162 | - elseif ($var[0] == 'check') |
|
1163 | - $setArray[$var[1]] = !empty($_POST[$var[1]]) ? '1' : '0'; |
|
1205 | + elseif ($var[0] == 'check') { |
|
1206 | + $setArray[$var[1]] = !empty($_POST[$var[1]]) ? '1' : '0'; |
|
1207 | + } |
|
1164 | 1208 | // Select boxes! |
1165 | - elseif ($var[0] == 'select' && in_array($_POST[$var[1]], array_keys($var[2]))) |
|
1166 | - $setArray[$var[1]] = $_POST[$var[1]]; |
|
1167 | - elseif ($var[0] == 'select' && !empty($var['multiple']) && array_intersect($_POST[$var[1]], array_keys($var[2])) != array()) |
|
1209 | + elseif ($var[0] == 'select' && in_array($_POST[$var[1]], array_keys($var[2]))) { |
|
1210 | + $setArray[$var[1]] = $_POST[$var[1]]; |
|
1211 | + } elseif ($var[0] == 'select' && !empty($var['multiple']) && array_intersect($_POST[$var[1]], array_keys($var[2])) != array()) |
|
1168 | 1212 | { |
1169 | 1213 | // For security purposes we validate this line by line. |
1170 | 1214 | $lOptions = array(); |
1171 | - foreach ($_POST[$var[1]] as $invar) |
|
1172 | - if (in_array($invar, array_keys($var[2]))) |
|
1215 | + foreach ($_POST[$var[1]] as $invar) { |
|
1216 | + if (in_array($invar, array_keys($var[2]))) |
|
1173 | 1217 | $lOptions[] = $invar; |
1218 | + } |
|
1174 | 1219 | |
1175 | 1220 | $setArray[$var[1]] = $smcFunc['json_encode']($lOptions); |
1176 | 1221 | } |
@@ -1184,18 +1229,20 @@ discard block |
||
1184 | 1229 | $request = $smcFunc['db_query']('', ' |
1185 | 1230 | SELECT id_board |
1186 | 1231 | FROM {db_prefix}boards'); |
1187 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
1188 | - $board_list[$row[0]] = true; |
|
1232 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
1233 | + $board_list[$row[0]] = true; |
|
1234 | + } |
|
1189 | 1235 | |
1190 | 1236 | $smcFunc['db_free_result']($request); |
1191 | 1237 | } |
1192 | 1238 | |
1193 | 1239 | $lOptions = array(); |
1194 | 1240 | |
1195 | - if (!empty($_POST[$var[1]])) |
|
1196 | - foreach ($_POST[$var[1]] as $invar => $dummy) |
|
1241 | + if (!empty($_POST[$var[1]])) { |
|
1242 | + foreach ($_POST[$var[1]] as $invar => $dummy) |
|
1197 | 1243 | if (isset($board_list[$invar])) |
1198 | 1244 | $lOptions[] = $invar; |
1245 | + } |
|
1199 | 1246 | |
1200 | 1247 | $setArray[$var[1]] = !empty($lOptions) ? implode(',', $lOptions) : ''; |
1201 | 1248 | } |
@@ -1209,8 +1256,9 @@ discard block |
||
1209 | 1256 | $setArray[$var[1]] = max($min, $setArray[$var[1]]); |
1210 | 1257 | |
1211 | 1258 | // Do we have a max value for this as well? |
1212 | - if (isset($var['max'])) |
|
1213 | - $setArray[$var[1]] = min($var['max'], $setArray[$var[1]]); |
|
1259 | + if (isset($var['max'])) { |
|
1260 | + $setArray[$var[1]] = min($var['max'], $setArray[$var[1]]); |
|
1261 | + } |
|
1214 | 1262 | } |
1215 | 1263 | // Floating point! |
1216 | 1264 | elseif ($var[0] == 'float') |
@@ -1222,40 +1270,47 @@ discard block |
||
1222 | 1270 | $setArray[$var[1]] = max($min, $setArray[$var[1]]); |
1223 | 1271 | |
1224 | 1272 | // Do we have a max value for this as well? |
1225 | - if (isset($var['max'])) |
|
1226 | - $setArray[$var[1]] = min($var['max'], $setArray[$var[1]]); |
|
1273 | + if (isset($var['max'])) { |
|
1274 | + $setArray[$var[1]] = min($var['max'], $setArray[$var[1]]); |
|
1275 | + } |
|
1227 | 1276 | } |
1228 | 1277 | // Text! |
1229 | - elseif (in_array($var[0], array('text', 'large_text', 'color', 'date', 'datetime', 'datetime-local', 'email', 'month', 'time'))) |
|
1230 | - $setArray[$var[1]] = $_POST[$var[1]]; |
|
1278 | + elseif (in_array($var[0], array('text', 'large_text', 'color', 'date', 'datetime', 'datetime-local', 'email', 'month', 'time'))) { |
|
1279 | + $setArray[$var[1]] = $_POST[$var[1]]; |
|
1280 | + } |
|
1231 | 1281 | // Passwords! |
1232 | 1282 | elseif ($var[0] == 'password') |
1233 | 1283 | { |
1234 | - if (isset($_POST[$var[1]][1]) && $_POST[$var[1]][0] == $_POST[$var[1]][1]) |
|
1235 | - $setArray[$var[1]] = $_POST[$var[1]][0]; |
|
1284 | + if (isset($_POST[$var[1]][1]) && $_POST[$var[1]][0] == $_POST[$var[1]][1]) { |
|
1285 | + $setArray[$var[1]] = $_POST[$var[1]][0]; |
|
1286 | + } |
|
1236 | 1287 | } |
1237 | 1288 | // BBC. |
1238 | 1289 | elseif ($var[0] == 'bbc') |
1239 | 1290 | { |
1240 | 1291 | |
1241 | 1292 | $bbcTags = array(); |
1242 | - foreach (parse_bbc(false) as $tag) |
|
1243 | - $bbcTags[] = $tag['tag']; |
|
1293 | + foreach (parse_bbc(false) as $tag) { |
|
1294 | + $bbcTags[] = $tag['tag']; |
|
1295 | + } |
|
1244 | 1296 | |
1245 | - if (!isset($_POST[$var[1] . '_enabledTags'])) |
|
1246 | - $_POST[$var[1] . '_enabledTags'] = array(); |
|
1247 | - elseif (!is_array($_POST[$var[1] . '_enabledTags'])) |
|
1248 | - $_POST[$var[1] . '_enabledTags'] = array($_POST[$var[1] . '_enabledTags']); |
|
1297 | + if (!isset($_POST[$var[1] . '_enabledTags'])) { |
|
1298 | + $_POST[$var[1] . '_enabledTags'] = array(); |
|
1299 | + } elseif (!is_array($_POST[$var[1] . '_enabledTags'])) { |
|
1300 | + $_POST[$var[1] . '_enabledTags'] = array($_POST[$var[1] . '_enabledTags']); |
|
1301 | + } |
|
1249 | 1302 | |
1250 | 1303 | $setArray[$var[1]] = implode(',', array_diff($bbcTags, $_POST[$var[1] . '_enabledTags'])); |
1251 | 1304 | } |
1252 | 1305 | // Permissions? |
1253 | - elseif ($var[0] == 'permissions') |
|
1254 | - $inlinePermissions[] = $var[1]; |
|
1306 | + elseif ($var[0] == 'permissions') { |
|
1307 | + $inlinePermissions[] = $var[1]; |
|
1308 | + } |
|
1255 | 1309 | } |
1256 | 1310 | |
1257 | - if (!empty($setArray)) |
|
1258 | - updateSettings($setArray); |
|
1311 | + if (!empty($setArray)) { |
|
1312 | + updateSettings($setArray); |
|
1313 | + } |
|
1259 | 1314 | |
1260 | 1315 | // If we have inline permissions we need to save them. |
1261 | 1316 | if (!empty($inlinePermissions) && allowedTo('manage_permissions')) |
@@ -1292,18 +1347,21 @@ discard block |
||
1292 | 1347 | // put all of it into an array |
1293 | 1348 | foreach ($info_lines as $line) |
1294 | 1349 | { |
1295 | - if (preg_match('~(' . $remove . ')~', $line)) |
|
1296 | - continue; |
|
1350 | + if (preg_match('~(' . $remove . ')~', $line)) { |
|
1351 | + continue; |
|
1352 | + } |
|
1297 | 1353 | |
1298 | 1354 | // new category? |
1299 | - if (strpos($line, '<h2>') !== false) |
|
1300 | - $category = preg_match('~<h2>(.*)</h2>~', $line, $title) ? $category = $title[1] : $category; |
|
1355 | + if (strpos($line, '<h2>') !== false) { |
|
1356 | + $category = preg_match('~<h2>(.*)</h2>~', $line, $title) ? $category = $title[1] : $category; |
|
1357 | + } |
|
1301 | 1358 | |
1302 | 1359 | // load it as setting => value or the old setting local master |
1303 | - if (preg_match('~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~', $line, $val)) |
|
1304 | - $pinfo[$category][$val[1]] = $val[2]; |
|
1305 | - elseif (preg_match('~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~', $line, $val)) |
|
1306 | - $pinfo[$category][$val[1]] = array($txt['phpinfo_localsettings'] => $val[2], $txt['phpinfo_defaultsettings'] => $val[3]); |
|
1360 | + if (preg_match('~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~', $line, $val)) { |
|
1361 | + $pinfo[$category][$val[1]] = $val[2]; |
|
1362 | + } elseif (preg_match('~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~', $line, $val)) { |
|
1363 | + $pinfo[$category][$val[1]] = array($txt['phpinfo_localsettings'] => $val[2], $txt['phpinfo_defaultsettings'] => $val[3]); |
|
1364 | + } |
|
1307 | 1365 | } |
1308 | 1366 | |
1309 | 1367 | // load it in to context and display it |
@@ -1338,8 +1396,9 @@ discard block |
||
1338 | 1396 | $testAPI = new $cache_class_name(); |
1339 | 1397 | |
1340 | 1398 | // No Support? NEXT! |
1341 | - if (!$testAPI->isSupported(true)) |
|
1342 | - continue; |
|
1399 | + if (!$testAPI->isSupported(true)) { |
|
1400 | + continue; |
|
1401 | + } |
|
1343 | 1402 | |
1344 | 1403 | $apis[$tryCache] = isset($txt[$tryCache . '_cache']) ? $txt[$tryCache . '_cache'] : $tryCache; |
1345 | 1404 | } |
@@ -1364,8 +1423,9 @@ discard block |
||
1364 | 1423 | global $modSettings, $boardurl, $smcFunc; |
1365 | 1424 | |
1366 | 1425 | // Already have a key? Can't register again. |
1367 | - if (!empty($modSettings['sm_stats_key'])) |
|
1368 | - return true; |
|
1426 | + if (!empty($modSettings['sm_stats_key'])) { |
|
1427 | + return true; |
|
1428 | + } |
|
1369 | 1429 | |
1370 | 1430 | $fp = @fsockopen('www.simplemachines.org', 80, $errno, $errstr); |
1371 | 1431 | if ($fp) |
@@ -1376,8 +1436,9 @@ discard block |
||
1376 | 1436 | fwrite($fp, $out); |
1377 | 1437 | |
1378 | 1438 | $return_data = ''; |
1379 | - while (!feof($fp)) |
|
1380 | - $return_data .= fgets($fp, 128); |
|
1439 | + while (!feof($fp)) { |
|
1440 | + $return_data .= fgets($fp, 128); |
|
1441 | + } |
|
1381 | 1442 | |
1382 | 1443 | fclose($fp); |
1383 | 1444 |
@@ -38,12 +38,12 @@ discard block |
||
38 | 38 | $version = $smcFunc['db_get_version'](); |
39 | 39 | // if we got a Beta Version |
40 | 40 | if (stripos($version, 'beta') !== false) |
41 | - $version = substr($version, 0, stripos($version, 'beta')).'.0'; |
|
41 | + $version = substr($version, 0, stripos($version, 'beta')) . '.0'; |
|
42 | 42 | // or RC |
43 | 43 | if (stripos($version, 'rc') !== false) |
44 | - $version = substr($version, 0, stripos($version, 'rc')).'.0'; |
|
44 | + $version = substr($version, 0, stripos($version, 'rc')) . '.0'; |
|
45 | 45 | |
46 | - if (version_compare($version,'9.5.0','>=')) |
|
46 | + if (version_compare($version, '9.5.0', '>=')) |
|
47 | 47 | $smcFunc['db_support_ignore'] = true; |
48 | 48 | } |
49 | 49 | |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | */ |
56 | 56 | function smf_db_search_support($search_type) |
57 | 57 | { |
58 | - $supported_types = array('custom','fulltext'); |
|
58 | + $supported_types = array('custom', 'fulltext'); |
|
59 | 59 | |
60 | 60 | return in_array($search_type, $supported_types); |
61 | 61 | } |
@@ -109,9 +109,9 @@ discard block |
||
109 | 109 | if (preg_match('~^\s*INSERT\sIGNORE~i', $db_string) != 0) |
110 | 110 | { |
111 | 111 | $db_string = preg_replace('~^\s*INSERT\sIGNORE~i', 'INSERT', $db_string); |
112 | - if ($smcFunc['db_support_ignore']){ |
|
112 | + if ($smcFunc['db_support_ignore']) { |
|
113 | 113 | //pg style "INSERT INTO.... ON CONFLICT DO NOTHING" |
114 | - $db_string = $db_string.' ON CONFLICT DO NOTHING'; |
|
114 | + $db_string = $db_string . ' ON CONFLICT DO NOTHING'; |
|
115 | 115 | } |
116 | 116 | else |
117 | 117 | { |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | $language_ftx = $modSettings['search_language']; |
169 | 169 | else |
170 | 170 | { |
171 | - $request = $smcFunc['db_query']('',' |
|
171 | + $request = $smcFunc['db_query']('', ' |
|
172 | 172 | SELECT cfgname FROM pg_ts_config WHERE oid = current_setting({string:default_language})::regconfig', |
173 | 173 | array( |
174 | 174 | 'default_language' => 'default_text_search_config' |
@@ -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 | * Add the file functions to the $smcFunc array. |
@@ -23,29 +24,33 @@ discard block |
||
23 | 24 | { |
24 | 25 | global $smcFunc; |
25 | 26 | |
26 | - if (!isset($smcFunc['db_search_query']) || $smcFunc['db_search_query'] != 'smf_db_search_query') |
|
27 | - $smcFunc += array( |
|
27 | + if (!isset($smcFunc['db_search_query']) || $smcFunc['db_search_query'] != 'smf_db_search_query') { |
|
28 | + $smcFunc += array( |
|
28 | 29 | 'db_search_query' => 'smf_db_search_query', |
29 | 30 | 'db_search_support' => 'smf_db_search_support', |
30 | 31 | 'db_create_word_search' => 'smf_db_create_word_search', |
31 | 32 | 'db_support_ignore' => false, |
32 | 33 | 'db_search_language' => 'smf_db_search_language', |
33 | 34 | ); |
35 | + } |
|
34 | 36 | |
35 | 37 | db_extend(); |
36 | 38 | |
37 | 39 | //pg 9.5 got ignore support |
38 | 40 | $version = $smcFunc['db_get_version'](); |
39 | 41 | // if we got a Beta Version |
40 | - if (stripos($version, 'beta') !== false) |
|
41 | - $version = substr($version, 0, stripos($version, 'beta')).'.0'; |
|
42 | + if (stripos($version, 'beta') !== false) { |
|
43 | + $version = substr($version, 0, stripos($version, 'beta')).'.0'; |
|
44 | + } |
|
42 | 45 | // or RC |
43 | - if (stripos($version, 'rc') !== false) |
|
44 | - $version = substr($version, 0, stripos($version, 'rc')).'.0'; |
|
46 | + if (stripos($version, 'rc') !== false) { |
|
47 | + $version = substr($version, 0, stripos($version, 'rc')).'.0'; |
|
48 | + } |
|
45 | 49 | |
46 | - if (version_compare($version,'9.5.0','>=')) |
|
47 | - $smcFunc['db_support_ignore'] = true; |
|
48 | -} |
|
50 | + if (version_compare($version,'9.5.0','>=')) { |
|
51 | + $smcFunc['db_support_ignore'] = true; |
|
52 | + } |
|
53 | + } |
|
49 | 54 | |
50 | 55 | /** |
51 | 56 | * This function will tell you whether this database type supports this search type. |
@@ -104,16 +109,16 @@ discard block |
||
104 | 109 | ), |
105 | 110 | ); |
106 | 111 | |
107 | - if (isset($replacements[$identifier])) |
|
108 | - $db_string = preg_replace(array_keys($replacements[$identifier]), array_values($replacements[$identifier]), $db_string); |
|
112 | + if (isset($replacements[$identifier])) { |
|
113 | + $db_string = preg_replace(array_keys($replacements[$identifier]), array_values($replacements[$identifier]), $db_string); |
|
114 | + } |
|
109 | 115 | if (preg_match('~^\s*INSERT\sIGNORE~i', $db_string) != 0) |
110 | 116 | { |
111 | 117 | $db_string = preg_replace('~^\s*INSERT\sIGNORE~i', 'INSERT', $db_string); |
112 | 118 | if ($smcFunc['db_support_ignore']){ |
113 | 119 | //pg style "INSERT INTO.... ON CONFLICT DO NOTHING" |
114 | 120 | $db_string = $db_string.' ON CONFLICT DO NOTHING'; |
115 | - } |
|
116 | - else |
|
121 | + } else |
|
117 | 122 | { |
118 | 123 | // Don't error on multi-insert. |
119 | 124 | $db_values['db_error_skip'] = true; |
@@ -121,8 +126,9 @@ discard block |
||
121 | 126 | } |
122 | 127 | |
123 | 128 | //fix double quotes |
124 | - if ($identifier == 'insert_into_log_messages_fulltext') |
|
125 | - $db_values = str_replace('"', "'", $db_values); |
|
129 | + if ($identifier == 'insert_into_log_messages_fulltext') { |
|
130 | + $db_values = str_replace('"', "'", $db_values); |
|
131 | + } |
|
126 | 132 | |
127 | 133 | $return = $smcFunc['db_query']('', $db_string, |
128 | 134 | $db_values, $connection |
@@ -164,9 +170,9 @@ discard block |
||
164 | 170 | |
165 | 171 | $language_ftx = 'english'; |
166 | 172 | |
167 | - if (!empty($modSettings['search_language'])) |
|
168 | - $language_ftx = $modSettings['search_language']; |
|
169 | - else |
|
173 | + if (!empty($modSettings['search_language'])) { |
|
174 | + $language_ftx = $modSettings['search_language']; |
|
175 | + } else |
|
170 | 176 | { |
171 | 177 | $request = $smcFunc['db_query']('',' |
172 | 178 | SELECT cfgname FROM pg_ts_config WHERE oid = current_setting({string:default_language})::regconfig', |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | /** |
82 | 82 | * Make files writable. First try to use regular chmod, but if that fails, try to use FTP. |
83 | 83 | * |
84 | - * @param $files |
|
84 | + * @param string[] $files |
|
85 | 85 | * @return bool |
86 | 86 | */ |
87 | 87 | function makeFilesWritable(&$files) |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | /** |
323 | 323 | * Prints an error to stderr. |
324 | 324 | * |
325 | - * @param $message |
|
325 | + * @param string $message |
|
326 | 326 | * @param bool $fatal |
327 | 327 | */ |
328 | 328 | function print_error($message, $fatal = false) |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * This file contains helper functions for upgrade.php |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF_VERSION')) |
|
16 | +if (!defined('SMF_VERSION')) { |
|
17 | 17 | die('No direct access!'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Clean the cache using the SMF 2.1 CacheAPI. |
@@ -45,8 +46,9 @@ discard block |
||
45 | 46 | global $smcFunc; |
46 | 47 | static $member_groups = array(); |
47 | 48 | |
48 | - if (!empty($member_groups)) |
|
49 | - return $member_groups; |
|
49 | + if (!empty($member_groups)) { |
|
50 | + return $member_groups; |
|
51 | + } |
|
50 | 52 | |
51 | 53 | $request = $smcFunc['db_query']('', ' |
52 | 54 | SELECT group_name, id_group |
@@ -71,8 +73,9 @@ discard block |
||
71 | 73 | ) |
72 | 74 | ); |
73 | 75 | } |
74 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
75 | - $member_groups[trim($row[0])] = $row[1]; |
|
76 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
77 | + $member_groups[trim($row[0])] = $row[1]; |
|
78 | + } |
|
76 | 79 | $smcFunc['db_free_result']($request); |
77 | 80 | |
78 | 81 | return $member_groups; |
@@ -88,8 +91,9 @@ discard block |
||
88 | 91 | { |
89 | 92 | global $upcontext, $boarddir, $sourcedir; |
90 | 93 | |
91 | - if (empty($files)) |
|
92 | - return true; |
|
94 | + if (empty($files)) { |
|
95 | + return true; |
|
96 | + } |
|
93 | 97 | |
94 | 98 | $failure = false; |
95 | 99 | // On linux, it's easy - just use is_writable! |
@@ -100,22 +104,25 @@ discard block |
||
100 | 104 | foreach ($files as $k => $file) |
101 | 105 | { |
102 | 106 | // Some files won't exist, try to address up front |
103 | - if (!file_exists($file)) |
|
104 | - @touch($file); |
|
107 | + if (!file_exists($file)) { |
|
108 | + @touch($file); |
|
109 | + } |
|
105 | 110 | // NOW do the writable check... |
106 | 111 | if (!is_writable($file)) |
107 | 112 | { |
108 | 113 | @chmod($file, 0755); |
109 | 114 | |
110 | 115 | // Well, 755 hopefully worked... if not, try 777. |
111 | - if (!is_writable($file) && !@chmod($file, 0777)) |
|
112 | - $failure = true; |
|
116 | + if (!is_writable($file) && !@chmod($file, 0777)) { |
|
117 | + $failure = true; |
|
118 | + } |
|
113 | 119 | // Otherwise remove it as it's good! |
114 | - else |
|
115 | - unset($files[$k]); |
|
120 | + else { |
|
121 | + unset($files[$k]); |
|
122 | + } |
|
123 | + } else { |
|
124 | + unset($files[$k]); |
|
116 | 125 | } |
117 | - else |
|
118 | - unset($files[$k]); |
|
119 | 126 | } |
120 | 127 | } |
121 | 128 | // Windows is trickier. Let's try opening for r+... |
@@ -126,30 +133,35 @@ discard block |
||
126 | 133 | foreach ($files as $k => $file) |
127 | 134 | { |
128 | 135 | // Folders can't be opened for write... but the index.php in them can ;). |
129 | - if (is_dir($file)) |
|
130 | - $file .= '/index.php'; |
|
136 | + if (is_dir($file)) { |
|
137 | + $file .= '/index.php'; |
|
138 | + } |
|
131 | 139 | |
132 | 140 | // Funny enough, chmod actually does do something on windows - it removes the read only attribute. |
133 | 141 | @chmod($file, 0777); |
134 | 142 | $fp = @fopen($file, 'r+'); |
135 | 143 | |
136 | 144 | // Hmm, okay, try just for write in that case... |
137 | - if (!$fp) |
|
138 | - $fp = @fopen($file, 'w'); |
|
145 | + if (!$fp) { |
|
146 | + $fp = @fopen($file, 'w'); |
|
147 | + } |
|
139 | 148 | |
140 | - if (!$fp) |
|
141 | - $failure = true; |
|
142 | - else |
|
143 | - unset($files[$k]); |
|
149 | + if (!$fp) { |
|
150 | + $failure = true; |
|
151 | + } else { |
|
152 | + unset($files[$k]); |
|
153 | + } |
|
144 | 154 | @fclose($fp); |
145 | 155 | } |
146 | 156 | } |
147 | 157 | |
148 | - if (empty($files)) |
|
149 | - return true; |
|
158 | + if (empty($files)) { |
|
159 | + return true; |
|
160 | + } |
|
150 | 161 | |
151 | - if (!isset($_SERVER)) |
|
152 | - return !$failure; |
|
162 | + if (!isset($_SERVER)) { |
|
163 | + return !$failure; |
|
164 | + } |
|
153 | 165 | |
154 | 166 | // What still needs to be done? |
155 | 167 | $upcontext['chmod']['files'] = $files; |
@@ -201,36 +213,40 @@ discard block |
||
201 | 213 | |
202 | 214 | if (!isset($ftp) || $ftp->error !== false) |
203 | 215 | { |
204 | - if (!isset($ftp)) |
|
205 | - $ftp = new ftp_connection(null); |
|
216 | + if (!isset($ftp)) { |
|
217 | + $ftp = new ftp_connection(null); |
|
218 | + } |
|
206 | 219 | // Save the error so we can mess with listing... |
207 | - elseif ($ftp->error !== false && !isset($upcontext['chmod']['ftp_error'])) |
|
208 | - $upcontext['chmod']['ftp_error'] = $ftp->last_message === null ? '' : $ftp->last_message; |
|
220 | + elseif ($ftp->error !== false && !isset($upcontext['chmod']['ftp_error'])) { |
|
221 | + $upcontext['chmod']['ftp_error'] = $ftp->last_message === null ? '' : $ftp->last_message; |
|
222 | + } |
|
209 | 223 | |
210 | 224 | list ($username, $detect_path, $found_path) = $ftp->detect_path(dirname(__FILE__)); |
211 | 225 | |
212 | - if ($found_path || !isset($upcontext['chmod']['path'])) |
|
213 | - $upcontext['chmod']['path'] = $detect_path; |
|
226 | + if ($found_path || !isset($upcontext['chmod']['path'])) { |
|
227 | + $upcontext['chmod']['path'] = $detect_path; |
|
228 | + } |
|
214 | 229 | |
215 | - if (!isset($upcontext['chmod']['username'])) |
|
216 | - $upcontext['chmod']['username'] = $username; |
|
230 | + if (!isset($upcontext['chmod']['username'])) { |
|
231 | + $upcontext['chmod']['username'] = $username; |
|
232 | + } |
|
217 | 233 | |
218 | 234 | // Don't forget the login token. |
219 | 235 | $upcontext += createToken('login'); |
220 | 236 | |
221 | 237 | return false; |
222 | - } |
|
223 | - else |
|
238 | + } else |
|
224 | 239 | { |
225 | 240 | // We want to do a relative path for FTP. |
226 | 241 | if (!in_array($upcontext['chmod']['path'], array('', '/'))) |
227 | 242 | { |
228 | 243 | $ftp_root = strtr($boarddir, array($upcontext['chmod']['path'] => '')); |
229 | - if (substr($ftp_root, -1) == '/' && ($upcontext['chmod']['path'] == '' || $upcontext['chmod']['path'][0] === '/')) |
|
230 | - $ftp_root = substr($ftp_root, 0, -1); |
|
244 | + if (substr($ftp_root, -1) == '/' && ($upcontext['chmod']['path'] == '' || $upcontext['chmod']['path'][0] === '/')) { |
|
245 | + $ftp_root = substr($ftp_root, 0, -1); |
|
246 | + } |
|
247 | + } else { |
|
248 | + $ftp_root = $boarddir; |
|
231 | 249 | } |
232 | - else |
|
233 | - $ftp_root = $boarddir; |
|
234 | 250 | |
235 | 251 | // Save the info for next time! |
236 | 252 | $_SESSION['installer_temp_ftp'] = array( |
@@ -244,10 +260,12 @@ discard block |
||
244 | 260 | |
245 | 261 | foreach ($files as $k => $file) |
246 | 262 | { |
247 | - if (!is_writable($file)) |
|
248 | - $ftp->chmod($file, 0755); |
|
249 | - if (!is_writable($file)) |
|
250 | - $ftp->chmod($file, 0777); |
|
263 | + if (!is_writable($file)) { |
|
264 | + $ftp->chmod($file, 0755); |
|
265 | + } |
|
266 | + if (!is_writable($file)) { |
|
267 | + $ftp->chmod($file, 0777); |
|
268 | + } |
|
251 | 269 | |
252 | 270 | // Assuming that didn't work calculate the path without the boarddir. |
253 | 271 | if (!is_writable($file)) |
@@ -256,19 +274,23 @@ discard block |
||
256 | 274 | { |
257 | 275 | $ftp_file = strtr($file, array($_SESSION['installer_temp_ftp']['root'] => '')); |
258 | 276 | $ftp->chmod($ftp_file, 0755); |
259 | - if (!is_writable($file)) |
|
260 | - $ftp->chmod($ftp_file, 0777); |
|
277 | + if (!is_writable($file)) { |
|
278 | + $ftp->chmod($ftp_file, 0777); |
|
279 | + } |
|
261 | 280 | // Sometimes an extra slash can help... |
262 | 281 | $ftp_file = '/' . $ftp_file; |
263 | - if (!is_writable($file)) |
|
264 | - $ftp->chmod($ftp_file, 0755); |
|
265 | - if (!is_writable($file)) |
|
266 | - $ftp->chmod($ftp_file, 0777); |
|
282 | + if (!is_writable($file)) { |
|
283 | + $ftp->chmod($ftp_file, 0755); |
|
284 | + } |
|
285 | + if (!is_writable($file)) { |
|
286 | + $ftp->chmod($ftp_file, 0777); |
|
287 | + } |
|
267 | 288 | } |
268 | 289 | } |
269 | 290 | |
270 | - if (is_writable($file)) |
|
271 | - unset($files[$k]); |
|
291 | + if (is_writable($file)) { |
|
292 | + unset($files[$k]); |
|
293 | + } |
|
272 | 294 | } |
273 | 295 | |
274 | 296 | $ftp->close(); |
@@ -278,8 +300,9 @@ discard block |
||
278 | 300 | // What remains? |
279 | 301 | $upcontext['chmod']['files'] = $files; |
280 | 302 | |
281 | - if (empty($files)) |
|
282 | - return true; |
|
303 | + if (empty($files)) { |
|
304 | + return true; |
|
305 | + } |
|
283 | 306 | |
284 | 307 | return false; |
285 | 308 | } |
@@ -294,12 +317,14 @@ discard block |
||
294 | 317 | { |
295 | 318 | |
296 | 319 | // Some files won't exist, try to address up front |
297 | - if (!file_exists($file)) |
|
298 | - @touch($file); |
|
320 | + if (!file_exists($file)) { |
|
321 | + @touch($file); |
|
322 | + } |
|
299 | 323 | |
300 | 324 | // NOW do the writable check... |
301 | - if (is_writable($file)) |
|
302 | - return true; |
|
325 | + if (is_writable($file)) { |
|
326 | + return true; |
|
327 | + } |
|
303 | 328 | |
304 | 329 | @chmod($file, 0755); |
305 | 330 | |
@@ -309,10 +334,11 @@ discard block |
||
309 | 334 | foreach ($chmod_values as $val) |
310 | 335 | { |
311 | 336 | // If it's writable, break out of the loop |
312 | - if (is_writable($file)) |
|
313 | - break; |
|
314 | - else |
|
315 | - @chmod($file, $val); |
|
337 | + if (is_writable($file)) { |
|
338 | + break; |
|
339 | + } else { |
|
340 | + @chmod($file, $val); |
|
341 | + } |
|
316 | 342 | } |
317 | 343 | |
318 | 344 | return is_writable($file); |
@@ -339,14 +365,16 @@ discard block |
||
339 | 365 | { |
340 | 366 | static $fp = null; |
341 | 367 | |
342 | - if ($fp === null) |
|
343 | - $fp = fopen('php://stderr', 'wb'); |
|
368 | + if ($fp === null) { |
|
369 | + $fp = fopen('php://stderr', 'wb'); |
|
370 | + } |
|
344 | 371 | |
345 | 372 | fwrite($fp, $message . "\n"); |
346 | 373 | |
347 | - if ($fatal) |
|
348 | - exit; |
|
349 | -} |
|
374 | + if ($fatal) { |
|
375 | + exit; |
|
376 | + } |
|
377 | + } |
|
350 | 378 | |
351 | 379 | /** |
352 | 380 | * Throws a graphical error message. |
@@ -16,8 +16,9 @@ discard block |
||
16 | 16 | * @version 2.1 Beta 4 |
17 | 17 | */ |
18 | 18 | |
19 | -if (!defined('SMF')) |
|
19 | +if (!defined('SMF')) { |
|
20 | 20 | die('No direct access...'); |
21 | +} |
|
21 | 22 | |
22 | 23 | |
23 | 24 | /** |
@@ -28,14 +29,16 @@ discard block |
||
28 | 29 | function sha1_smf($str) |
29 | 30 | { |
30 | 31 | // If we have mhash loaded in, use it instead! |
31 | - if (function_exists('mhash') && defined('MHASH_SHA1')) |
|
32 | - return bin2hex(mhash(MHASH_SHA1, $str)); |
|
32 | + if (function_exists('mhash') && defined('MHASH_SHA1')) { |
|
33 | + return bin2hex(mhash(MHASH_SHA1, $str)); |
|
34 | + } |
|
33 | 35 | |
34 | 36 | $nblk = (strlen($str) + 8 >> 6) + 1; |
35 | 37 | $blks = array_pad(array(), $nblk * 16, 0); |
36 | 38 | |
37 | - for ($i = 0; $i < strlen($str); $i++) |
|
38 | - $blks[$i >> 2] |= ord($str{$i}) << (24 - ($i % 4) * 8); |
|
39 | + for ($i = 0; $i < strlen($str); $i++) { |
|
40 | + $blks[$i >> 2] |= ord($str{$i}) << (24 - ($i % 4) * 8); |
|
41 | + } |
|
39 | 42 | |
40 | 43 | $blks[$i >> 2] |= 0x80 << (24 - ($i % 4) * 8); |
41 | 44 | |
@@ -70,10 +73,11 @@ discard block |
||
70 | 73 | |
71 | 74 | for ($j = 0; $j < 80; $j++) |
72 | 75 | { |
73 | - if ($j < 16) |
|
74 | - $w[$j] = isset($x[$i + $j]) ? $x[$i + $j] : 0; |
|
75 | - else |
|
76 | - $w[$j] = sha1_rol($w[$j - 3] ^ $w[$j - 8] ^ $w[$j - 14] ^ $w[$j - 16], 1); |
|
76 | + if ($j < 16) { |
|
77 | + $w[$j] = isset($x[$i + $j]) ? $x[$i + $j] : 0; |
|
78 | + } else { |
|
79 | + $w[$j] = sha1_rol($w[$j - 3] ^ $w[$j - 8] ^ $w[$j - 14] ^ $w[$j - 16], 1); |
|
80 | + } |
|
77 | 81 | |
78 | 82 | $t = sha1_rol($a, 5) + sha1_ft($j, $b, $c, $d) + $e + $w[$j] + sha1_kt($j); |
79 | 83 | $e = $d; |
@@ -103,12 +107,15 @@ discard block |
||
103 | 107 | */ |
104 | 108 | function sha1_ft($t, $b, $c, $d) |
105 | 109 | { |
106 | - if ($t < 20) |
|
107 | - return ($b & $c) | ((~$b) & $d); |
|
108 | - if ($t < 40) |
|
109 | - return $b ^ $c ^ $d; |
|
110 | - if ($t < 60) |
|
111 | - return ($b & $c) | ($b & $d) | ($c & $d); |
|
110 | + if ($t < 20) { |
|
111 | + return ($b & $c) | ((~$b) & $d); |
|
112 | + } |
|
113 | + if ($t < 40) { |
|
114 | + return $b ^ $c ^ $d; |
|
115 | + } |
|
116 | + if ($t < 60) { |
|
117 | + return ($b & $c) | ($b & $d) | ($c & $d); |
|
118 | + } |
|
112 | 119 | |
113 | 120 | return $b ^ $c ^ $d; |
114 | 121 | } |
@@ -132,10 +139,11 @@ discard block |
||
132 | 139 | function sha1_rol($num, $cnt) |
133 | 140 | { |
134 | 141 | // Unfortunately, PHP uses unsigned 32-bit longs only. So we have to kludge it a bit. |
135 | - if ($num & 0x80000000) |
|
136 | - $a = ($num >> 1 & 0x7fffffff) >> (31 - $cnt); |
|
137 | - else |
|
138 | - $a = $num >> (32 - $cnt); |
|
142 | + if ($num & 0x80000000) { |
|
143 | + $a = ($num >> 1 & 0x7fffffff) >> (31 - $cnt); |
|
144 | + } else { |
|
145 | + $a = $num >> (32 - $cnt); |
|
146 | + } |
|
139 | 147 | |
140 | 148 | return ($num << $cnt) | $a; |
141 | 149 | } |
@@ -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 allows to move a topic, making sure to ask the moderator |
@@ -32,8 +33,9 @@ discard block |
||
32 | 33 | { |
33 | 34 | global $txt, $board, $topic, $user_info, $context, $language, $scripturl, $smcFunc, $modSettings, $sourcedir; |
34 | 35 | |
35 | - if (empty($topic)) |
|
36 | - fatal_lang_error('no_access', false); |
|
36 | + if (empty($topic)) { |
|
37 | + fatal_lang_error('no_access', false); |
|
38 | + } |
|
37 | 39 | |
38 | 40 | $request = $smcFunc['db_query']('', ' |
39 | 41 | SELECT t.id_member_started, ms.subject, t.approved |
@@ -49,8 +51,9 @@ discard block |
||
49 | 51 | $smcFunc['db_free_result']($request); |
50 | 52 | |
51 | 53 | // Can they see it - if not approved? |
52 | - if ($modSettings['postmod_active'] && !$context['is_approved']) |
|
53 | - isAllowedTo('approve_posts'); |
|
54 | + if ($modSettings['postmod_active'] && !$context['is_approved']) { |
|
55 | + isAllowedTo('approve_posts'); |
|
56 | + } |
|
54 | 57 | |
55 | 58 | // Permission check! |
56 | 59 | // @todo |
@@ -59,9 +62,9 @@ discard block |
||
59 | 62 | if ($id_member_started == $user_info['id']) |
60 | 63 | { |
61 | 64 | isAllowedTo('move_own'); |
65 | + } else { |
|
66 | + isAllowedTo('move_any'); |
|
62 | 67 | } |
63 | - else |
|
64 | - isAllowedTo('move_any'); |
|
65 | 68 | } |
66 | 69 | |
67 | 70 | $context['move_any'] = $user_info['is_admin'] || $modSettings['topic_move_any']; |
@@ -83,11 +86,13 @@ discard block |
||
83 | 86 | 'not_redirection' => true, |
84 | 87 | ); |
85 | 88 | |
86 | - if (!empty($_SESSION['move_to_topic']) && $_SESSION['move_to_topic'] != $board) |
|
87 | - $options['selected_board'] = $_SESSION['move_to_topic']; |
|
89 | + if (!empty($_SESSION['move_to_topic']) && $_SESSION['move_to_topic'] != $board) { |
|
90 | + $options['selected_board'] = $_SESSION['move_to_topic']; |
|
91 | + } |
|
88 | 92 | |
89 | - if (!$context['move_any']) |
|
90 | - $options['included_boards'] = $boards; |
|
93 | + if (!$context['move_any']) { |
|
94 | + $options['included_boards'] = $boards; |
|
95 | + } |
|
91 | 96 | |
92 | 97 | require_once($sourcedir . '/Subs-MessageIndex.php'); |
93 | 98 | $context['categories'] = getBoardList($options); |
@@ -138,12 +143,14 @@ discard block |
||
138 | 143 | global $txt, $topic, $scripturl, $sourcedir, $context; |
139 | 144 | global $board, $language, $user_info, $smcFunc; |
140 | 145 | |
141 | - if (empty($topic)) |
|
142 | - fatal_lang_error('no_access', false); |
|
146 | + if (empty($topic)) { |
|
147 | + fatal_lang_error('no_access', false); |
|
148 | + } |
|
143 | 149 | |
144 | 150 | // You can't choose to have a redirection topic and use an empty reason. |
145 | - if (isset($_POST['postRedirect']) && (!isset($_POST['reason']) || trim($_POST['reason']) == '')) |
|
146 | - fatal_lang_error('movetopic_no_reason', false); |
|
151 | + if (isset($_POST['postRedirect']) && (!isset($_POST['reason']) || trim($_POST['reason']) == '')) { |
|
152 | + fatal_lang_error('movetopic_no_reason', false); |
|
153 | + } |
|
147 | 154 | |
148 | 155 | moveTopicConcurrence(); |
149 | 156 | |
@@ -163,16 +170,18 @@ discard block |
||
163 | 170 | $smcFunc['db_free_result']($request); |
164 | 171 | |
165 | 172 | // Can they see it? |
166 | - if (!$context['is_approved']) |
|
167 | - isAllowedTo('approve_posts'); |
|
173 | + if (!$context['is_approved']) { |
|
174 | + isAllowedTo('approve_posts'); |
|
175 | + } |
|
168 | 176 | |
169 | 177 | // Can they move topics on this board? |
170 | 178 | if (!allowedTo('move_any')) |
171 | 179 | { |
172 | - if ($id_member_started == $user_info['id']) |
|
173 | - isAllowedTo('move_own'); |
|
174 | - else |
|
175 | - isAllowedTo('move_any'); |
|
180 | + if ($id_member_started == $user_info['id']) { |
|
181 | + isAllowedTo('move_own'); |
|
182 | + } else { |
|
183 | + isAllowedTo('move_any'); |
|
184 | + } |
|
176 | 185 | } |
177 | 186 | |
178 | 187 | checkSession(); |
@@ -197,8 +206,9 @@ discard block |
||
197 | 206 | 'blank_redirect' => '', |
198 | 207 | ) |
199 | 208 | ); |
200 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
201 | - fatal_lang_error('no_board'); |
|
209 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
210 | + fatal_lang_error('no_board'); |
|
211 | + } |
|
202 | 212 | list ($pcounter, $board_name, $subject) = $smcFunc['db_fetch_row']($request); |
203 | 213 | $smcFunc['db_free_result']($request); |
204 | 214 | |
@@ -210,8 +220,9 @@ discard block |
||
210 | 220 | { |
211 | 221 | $_POST['custom_subject'] = strtr($smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['custom_subject'])), array("\r" => '', "\n" => '', "\t" => '')); |
212 | 222 | // Keep checking the length. |
213 | - if ($smcFunc['strlen']($_POST['custom_subject']) > 100) |
|
214 | - $_POST['custom_subject'] = $smcFunc['substr']($_POST['custom_subject'], 0, 100); |
|
223 | + if ($smcFunc['strlen']($_POST['custom_subject']) > 100) { |
|
224 | + $_POST['custom_subject'] = $smcFunc['substr']($_POST['custom_subject'], 0, 100); |
|
225 | + } |
|
215 | 226 | |
216 | 227 | // If it's still valid move onwards and upwards. |
217 | 228 | if ($_POST['custom_subject'] != '') |
@@ -221,9 +232,9 @@ discard block |
||
221 | 232 | // Get a response prefix, but in the forum's default language. |
222 | 233 | if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix'))) |
223 | 234 | { |
224 | - if ($language === $user_info['language']) |
|
225 | - $context['response_prefix'] = $txt['response_prefix']; |
|
226 | - else |
|
235 | + if ($language === $user_info['language']) { |
|
236 | + $context['response_prefix'] = $txt['response_prefix']; |
|
237 | + } else |
|
227 | 238 | { |
228 | 239 | loadLanguage('index', $language, false); |
229 | 240 | $context['response_prefix'] = $txt['response_prefix']; |
@@ -263,8 +274,9 @@ discard block |
||
263 | 274 | if (isset($_POST['postRedirect'])) |
264 | 275 | { |
265 | 276 | // Should be in the boardwide language. |
266 | - if ($user_info['language'] != $language) |
|
267 | - loadLanguage('index', $language); |
|
277 | + if ($user_info['language'] != $language) { |
|
278 | + loadLanguage('index', $language); |
|
279 | + } |
|
268 | 280 | |
269 | 281 | $_POST['reason'] = $smcFunc['htmlspecialchars']($_POST['reason'], ENT_QUOTES); |
270 | 282 | preparsecode($_POST['reason']); |
@@ -328,8 +340,9 @@ discard block |
||
328 | 340 | $posters = array(); |
329 | 341 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
330 | 342 | { |
331 | - if (!isset($posters[$row['id_member']])) |
|
332 | - $posters[$row['id_member']] = 0; |
|
343 | + if (!isset($posters[$row['id_member']])) { |
|
344 | + $posters[$row['id_member']] = 0; |
|
345 | + } |
|
333 | 346 | |
334 | 347 | $posters[$row['id_member']]++; |
335 | 348 | } |
@@ -338,11 +351,13 @@ discard block |
||
338 | 351 | foreach ($posters as $id_member => $posts) |
339 | 352 | { |
340 | 353 | // The board we're moving from counted posts, but not to. |
341 | - if (empty($pcounter_from)) |
|
342 | - updateMemberData($id_member, array('posts' => 'posts - ' . $posts)); |
|
354 | + if (empty($pcounter_from)) { |
|
355 | + updateMemberData($id_member, array('posts' => 'posts - ' . $posts)); |
|
356 | + } |
|
343 | 357 | // The reverse: from didn't, to did. |
344 | - else |
|
345 | - updateMemberData($id_member, array('posts' => 'posts + ' . $posts)); |
|
358 | + else { |
|
359 | + updateMemberData($id_member, array('posts' => 'posts + ' . $posts)); |
|
360 | + } |
|
346 | 361 | } |
347 | 362 | } |
348 | 363 | |
@@ -350,17 +365,19 @@ discard block |
||
350 | 365 | moveTopics($topic, $_POST['toboard']); |
351 | 366 | |
352 | 367 | // Log that they moved this topic. |
353 | - if (!allowedTo('move_own') || $id_member_started != $user_info['id']) |
|
354 | - logAction('move', array('topic' => $topic, 'board_from' => $board, 'board_to' => $_POST['toboard'])); |
|
368 | + if (!allowedTo('move_own') || $id_member_started != $user_info['id']) { |
|
369 | + logAction('move', array('topic' => $topic, 'board_from' => $board, 'board_to' => $_POST['toboard'])); |
|
370 | + } |
|
355 | 371 | // Notify people that this topic has been moved? |
356 | 372 | sendNotifications($topic, 'move'); |
357 | 373 | |
358 | 374 | // Why not go back to the original board in case they want to keep moving? |
359 | - if (!isset($_REQUEST['goback'])) |
|
360 | - redirectexit('board=' . $board . '.0'); |
|
361 | - else |
|
362 | - redirectexit('topic=' . $topic . '.0'); |
|
363 | -} |
|
375 | + if (!isset($_REQUEST['goback'])) { |
|
376 | + redirectexit('board=' . $board . '.0'); |
|
377 | + } else { |
|
378 | + redirectexit('topic=' . $topic . '.0'); |
|
379 | + } |
|
380 | + } |
|
364 | 381 | |
365 | 382 | /** |
366 | 383 | * Moves one or more topics to a specific board. (doesn't check permissions.) |
@@ -376,18 +393,21 @@ discard block |
||
376 | 393 | global $sourcedir, $user_info, $modSettings, $smcFunc; |
377 | 394 | |
378 | 395 | // Empty array? |
379 | - if (empty($topics)) |
|
380 | - return; |
|
396 | + if (empty($topics)) { |
|
397 | + return; |
|
398 | + } |
|
381 | 399 | |
382 | 400 | // Only a single topic. |
383 | - if (is_numeric($topics)) |
|
384 | - $topics = array($topics); |
|
401 | + if (is_numeric($topics)) { |
|
402 | + $topics = array($topics); |
|
403 | + } |
|
385 | 404 | |
386 | 405 | $fromBoards = array(); |
387 | 406 | |
388 | 407 | // Destination board empty or equal to 0? |
389 | - if (empty($toBoard)) |
|
390 | - return; |
|
408 | + if (empty($toBoard)) { |
|
409 | + return; |
|
410 | + } |
|
391 | 411 | |
392 | 412 | // Are we moving to the recycle board? |
393 | 413 | $isRecycleDest = !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] == $toBoard; |
@@ -395,8 +415,9 @@ discard block |
||
395 | 415 | // Callback for search APIs to do their thing |
396 | 416 | require_once($sourcedir . '/Search.php'); |
397 | 417 | $searchAPI = findSearchAPI(); |
398 | - if ($searchAPI->supportsMethod('topicsMoved')) |
|
399 | - $searchAPI->topicsMoved($topics, $toBoard); |
|
418 | + if ($searchAPI->supportsMethod('topicsMoved')) { |
|
419 | + $searchAPI->topicsMoved($topics, $toBoard); |
|
420 | + } |
|
400 | 421 | |
401 | 422 | // Determine the source boards... |
402 | 423 | $request = $smcFunc['db_query']('', ' |
@@ -410,8 +431,9 @@ discard block |
||
410 | 431 | ) |
411 | 432 | ); |
412 | 433 | // Num of rows = 0 -> no topics found. Num of rows > 1 -> topics are on multiple boards. |
413 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
414 | - return; |
|
434 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
435 | + return; |
|
436 | + } |
|
415 | 437 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
416 | 438 | { |
417 | 439 | if (!isset($fromBoards[$row['id_board']]['num_posts'])) |
@@ -429,10 +451,11 @@ discard block |
||
429 | 451 | $fromBoards[$row['id_board']]['unapproved_posts'] += $row['unapproved_posts']; |
430 | 452 | |
431 | 453 | // Add the topics to the right type. |
432 | - if ($row['approved']) |
|
433 | - $fromBoards[$row['id_board']]['num_topics'] += $row['num_topics']; |
|
434 | - else |
|
435 | - $fromBoards[$row['id_board']]['unapproved_topics'] += $row['num_topics']; |
|
454 | + if ($row['approved']) { |
|
455 | + $fromBoards[$row['id_board']]['num_topics'] += $row['num_topics']; |
|
456 | + } else { |
|
457 | + $fromBoards[$row['id_board']]['unapproved_topics'] += $row['num_topics']; |
|
458 | + } |
|
436 | 459 | } |
437 | 460 | $smcFunc['db_free_result']($request); |
438 | 461 | |
@@ -558,13 +581,14 @@ discard block |
||
558 | 581 | ) |
559 | 582 | ); |
560 | 583 | $approval_msgs = array(); |
561 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
562 | - $approval_msgs[] = $row['id_msg']; |
|
584 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
585 | + $approval_msgs[] = $row['id_msg']; |
|
586 | + } |
|
563 | 587 | $smcFunc['db_free_result']($request); |
564 | 588 | |
565 | 589 | // Empty the approval queue for these, as we're going to approve them next. |
566 | - if (!empty($approval_msgs)) |
|
567 | - $smcFunc['db_query']('', ' |
|
590 | + if (!empty($approval_msgs)) { |
|
591 | + $smcFunc['db_query']('', ' |
|
568 | 592 | DELETE FROM {db_prefix}approval_queue |
569 | 593 | WHERE id_msg IN ({array_int:message_list}) |
570 | 594 | AND id_attach = {int:id_attach}', |
@@ -573,6 +597,7 @@ discard block |
||
573 | 597 | 'id_attach' => 0, |
574 | 598 | ) |
575 | 599 | ); |
600 | + } |
|
576 | 601 | |
577 | 602 | // Get all the current max and mins. |
578 | 603 | $request = $smcFunc['db_query']('', ' |
@@ -606,8 +631,8 @@ discard block |
||
606 | 631 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
607 | 632 | { |
608 | 633 | // If not, update. |
609 | - if ($row['first_msg'] != $topicMaxMin[$row['id_topic']]['min'] || $row['last_msg'] != $topicMaxMin[$row['id_topic']]['max']) |
|
610 | - $smcFunc['db_query']('', ' |
|
634 | + if ($row['first_msg'] != $topicMaxMin[$row['id_topic']]['min'] || $row['last_msg'] != $topicMaxMin[$row['id_topic']]['max']) { |
|
635 | + $smcFunc['db_query']('', ' |
|
611 | 636 | UPDATE {db_prefix}topics |
612 | 637 | SET id_first_msg = {int:first_msg}, id_last_msg = {int:last_msg} |
613 | 638 | WHERE id_topic = {int:selected_topic}', |
@@ -617,6 +642,7 @@ discard block |
||
617 | 642 | 'selected_topic' => $row['id_topic'], |
618 | 643 | ) |
619 | 644 | ); |
645 | + } |
|
620 | 646 | } |
621 | 647 | $smcFunc['db_free_result']($request); |
622 | 648 | } |
@@ -675,9 +701,10 @@ discard block |
||
675 | 701 | } |
676 | 702 | |
677 | 703 | // Update the cache? |
678 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 3) |
|
679 | - foreach ($topics as $topic_id) |
|
704 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 3) { |
|
705 | + foreach ($topics as $topic_id) |
|
680 | 706 | cache_put_data('topic_board-' . $topic_id, null, 120); |
707 | + } |
|
681 | 708 | |
682 | 709 | require_once($sourcedir . '/Subs-Post.php'); |
683 | 710 | |
@@ -701,15 +728,17 @@ discard block |
||
701 | 728 | { |
702 | 729 | global $board, $topic, $smcFunc, $scripturl; |
703 | 730 | |
704 | - if (isset($_GET['current_board'])) |
|
705 | - $move_from = (int) $_GET['current_board']; |
|
731 | + if (isset($_GET['current_board'])) { |
|
732 | + $move_from = (int) $_GET['current_board']; |
|
733 | + } |
|
706 | 734 | |
707 | - if (empty($move_from) || empty($board) || empty($topic)) |
|
708 | - return true; |
|
735 | + if (empty($move_from) || empty($board) || empty($topic)) { |
|
736 | + return true; |
|
737 | + } |
|
709 | 738 | |
710 | - if ($move_from == $board) |
|
711 | - return true; |
|
712 | - else |
|
739 | + if ($move_from == $board) { |
|
740 | + return true; |
|
741 | + } else |
|
713 | 742 | { |
714 | 743 | $request = $smcFunc['db_query']('', ' |
715 | 744 | SELECT m.subject, b.name |