@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | * @version 2.1 Beta 4 |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | -if (!defined('SMF')) |
|
| 17 | +if (!defined('SMF')) { |
|
| 18 | 18 | die('No direct access...'); |
| 19 | +} |
|
| 19 | 20 | |
| 20 | 21 | loadLanguage('Drafts'); |
| 21 | 22 | |
@@ -33,8 +34,9 @@ discard block |
||
| 33 | 34 | global $context, $user_info, $smcFunc, $modSettings, $board; |
| 34 | 35 | |
| 35 | 36 | // can you be, should you be ... here? |
| 36 | - if (empty($modSettings['drafts_post_enabled']) || !allowedTo('post_draft') || !isset($_POST['save_draft']) || !isset($_POST['id_draft'])) |
|
| 37 | - return false; |
|
| 37 | + if (empty($modSettings['drafts_post_enabled']) || !allowedTo('post_draft') || !isset($_POST['save_draft']) || !isset($_POST['id_draft'])) { |
|
| 38 | + return false; |
|
| 39 | + } |
|
| 38 | 40 | |
| 39 | 41 | // read in what they sent us, if anything |
| 40 | 42 | $id_draft = (int) $_POST['id_draft']; |
@@ -46,14 +48,16 @@ discard block |
||
| 46 | 48 | $context['draft_saved_on'] = $draft_info['poster_time']; |
| 47 | 49 | |
| 48 | 50 | // since we were called from the autosave function, send something back |
| 49 | - if (!empty($id_draft)) |
|
| 50 | - XmlDraft($id_draft); |
|
| 51 | + if (!empty($id_draft)) { |
|
| 52 | + XmlDraft($id_draft); |
|
| 53 | + } |
|
| 51 | 54 | |
| 52 | 55 | return true; |
| 53 | 56 | } |
| 54 | 57 | |
| 55 | - if (!isset($_POST['message'])) |
|
| 56 | - $_POST['message'] = isset($_POST['quickReply']) ? $_POST['quickReply'] : ''; |
|
| 58 | + if (!isset($_POST['message'])) { |
|
| 59 | + $_POST['message'] = isset($_POST['quickReply']) ? $_POST['quickReply'] : ''; |
|
| 60 | + } |
|
| 57 | 61 | |
| 58 | 62 | // prepare any data from the form |
| 59 | 63 | $topic_id = empty($_REQUEST['topic']) ? 0 : (int) $_REQUEST['topic']; |
@@ -66,8 +70,9 @@ discard block |
||
| 66 | 70 | |
| 67 | 71 | // message and subject still need a bit more work |
| 68 | 72 | preparsecode($draft['body']); |
| 69 | - if ($smcFunc['strlen']($draft['subject']) > 100) |
|
| 70 | - $draft['subject'] = $smcFunc['substr']($draft['subject'], 0, 100); |
|
| 73 | + if ($smcFunc['strlen']($draft['subject']) > 100) { |
|
| 74 | + $draft['subject'] = $smcFunc['substr']($draft['subject'], 0, 100); |
|
| 75 | + } |
|
| 71 | 76 | |
| 72 | 77 | // Modifying an existing draft, like hitting the save draft button or autosave enabled? |
| 73 | 78 | if (!empty($id_draft) && !empty($draft_info)) |
@@ -148,9 +153,9 @@ discard block |
||
| 148 | 153 | { |
| 149 | 154 | $context['draft_saved'] = true; |
| 150 | 155 | $context['id_draft'] = $id_draft; |
| 156 | + } else { |
|
| 157 | + $post_errors[] = 'draft_not_saved'; |
|
| 151 | 158 | } |
| 152 | - else |
|
| 153 | - $post_errors[] = 'draft_not_saved'; |
|
| 154 | 159 | |
| 155 | 160 | // cleanup |
| 156 | 161 | unset($_POST['save_draft']); |
@@ -180,8 +185,9 @@ discard block |
||
| 180 | 185 | global $context, $user_info, $smcFunc, $modSettings; |
| 181 | 186 | |
| 182 | 187 | // PM survey says ... can you stay or must you go |
| 183 | - if (empty($modSettings['drafts_pm_enabled']) || !allowedTo('pm_draft') || !isset($_POST['save_draft'])) |
|
| 184 | - return false; |
|
| 188 | + if (empty($modSettings['drafts_pm_enabled']) || !allowedTo('pm_draft') || !isset($_POST['save_draft'])) { |
|
| 189 | + return false; |
|
| 190 | + } |
|
| 185 | 191 | |
| 186 | 192 | // read in what you sent us |
| 187 | 193 | $id_pm_draft = (int) $_POST['id_pm_draft']; |
@@ -193,8 +199,9 @@ discard block |
||
| 193 | 199 | $context['draft_saved_on'] = $draft_info['poster_time']; |
| 194 | 200 | |
| 195 | 201 | // Send something back to the javascript caller |
| 196 | - if (!empty($id_draft)) |
|
| 197 | - XmlDraft($id_draft); |
|
| 202 | + if (!empty($id_draft)) { |
|
| 203 | + XmlDraft($id_draft); |
|
| 204 | + } |
|
| 198 | 205 | |
| 199 | 206 | return true; |
| 200 | 207 | } |
@@ -204,9 +211,9 @@ discard block |
||
| 204 | 211 | { |
| 205 | 212 | $recipientList['to'] = isset($_POST['recipient_to']) ? explode(',', $_POST['recipient_to']) : array(); |
| 206 | 213 | $recipientList['bcc'] = isset($_POST['recipient_bcc']) ? explode(',', $_POST['recipient_bcc']) : array(); |
| 214 | + } elseif (!empty($draft_info['to_list']) && empty($recipientList)) { |
|
| 215 | + $recipientList = $smcFunc['json_decode']($draft_info['to_list'], true); |
|
| 207 | 216 | } |
| 208 | - elseif (!empty($draft_info['to_list']) && empty($recipientList)) |
|
| 209 | - $recipientList = $smcFunc['json_decode']($draft_info['to_list'], true); |
|
| 210 | 217 | |
| 211 | 218 | // prepare the data we got from the form |
| 212 | 219 | $reply_id = empty($_POST['replied_to']) ? 0 : (int) $_POST['replied_to']; |
@@ -215,8 +222,9 @@ discard block |
||
| 215 | 222 | |
| 216 | 223 | // message and subject always need a bit more work |
| 217 | 224 | preparsecode($draft['body']); |
| 218 | - if ($smcFunc['strlen']($draft['subject']) > 100) |
|
| 219 | - $draft['subject'] = $smcFunc['substr']($draft['subject'], 0, 100); |
|
| 225 | + if ($smcFunc['strlen']($draft['subject']) > 100) { |
|
| 226 | + $draft['subject'] = $smcFunc['substr']($draft['subject'], 0, 100); |
|
| 227 | + } |
|
| 220 | 228 | |
| 221 | 229 | // Modifying an existing PM draft? |
| 222 | 230 | if (!empty($id_pm_draft) && !empty($draft_info)) |
@@ -280,9 +288,9 @@ discard block |
||
| 280 | 288 | { |
| 281 | 289 | $context['draft_saved'] = true; |
| 282 | 290 | $context['id_pm_draft'] = $id_pm_draft; |
| 291 | + } else { |
|
| 292 | + $post_errors[] = 'draft_not_saved'; |
|
| 283 | 293 | } |
| 284 | - else |
|
| 285 | - $post_errors[] = 'draft_not_saved'; |
|
| 286 | 294 | } |
| 287 | 295 | |
| 288 | 296 | // if we were called from the autosave function, send something back |
@@ -315,8 +323,9 @@ discard block |
||
| 315 | 323 | $type = (int) $type; |
| 316 | 324 | |
| 317 | 325 | // nothing to read, nothing to do |
| 318 | - if (empty($id_draft)) |
|
| 319 | - return false; |
|
| 326 | + if (empty($id_draft)) { |
|
| 327 | + return false; |
|
| 328 | + } |
|
| 320 | 329 | |
| 321 | 330 | // load in this draft from the DB |
| 322 | 331 | $request = $smcFunc['db_query']('', ' |
@@ -337,8 +346,9 @@ discard block |
||
| 337 | 346 | ); |
| 338 | 347 | |
| 339 | 348 | // no results? |
| 340 | - if (!$smcFunc['db_num_rows']($request)) |
|
| 341 | - return false; |
|
| 349 | + if (!$smcFunc['db_num_rows']($request)) { |
|
| 350 | + return false; |
|
| 351 | + } |
|
| 342 | 352 | |
| 343 | 353 | // load up the data |
| 344 | 354 | $draft_info = $smcFunc['db_fetch_assoc']($request); |
@@ -358,8 +368,7 @@ discard block |
||
| 358 | 368 | $context['subject'] = !empty($draft_info['subject']) ? stripslashes($draft_info['subject']) : ''; |
| 359 | 369 | $context['board'] = !empty($draft_info['id_board']) ? $draft_info['id_board'] : ''; |
| 360 | 370 | $context['id_draft'] = !empty($draft_info['id_draft']) ? $draft_info['id_draft'] : 0; |
| 361 | - } |
|
| 362 | - elseif ($type === 1) |
|
| 371 | + } elseif ($type === 1) |
|
| 363 | 372 | { |
| 364 | 373 | // one of those pm drafts? then set it up like we have an error |
| 365 | 374 | $_REQUEST['subject'] = !empty($draft_info['subject']) ? stripslashes($draft_info['subject']) : ''; |
@@ -395,12 +404,14 @@ discard block |
||
| 395 | 404 | global $user_info, $smcFunc; |
| 396 | 405 | |
| 397 | 406 | // Only a single draft. |
| 398 | - if (is_numeric($id_draft)) |
|
| 399 | - $id_draft = array($id_draft); |
|
| 407 | + if (is_numeric($id_draft)) { |
|
| 408 | + $id_draft = array($id_draft); |
|
| 409 | + } |
|
| 400 | 410 | |
| 401 | 411 | // can't delete nothing |
| 402 | - if (empty($id_draft) || ($check && empty($user_info['id']))) |
|
| 403 | - return false; |
|
| 412 | + if (empty($id_draft) || ($check && empty($user_info['id']))) { |
|
| 413 | + return false; |
|
| 414 | + } |
|
| 404 | 415 | |
| 405 | 416 | $smcFunc['db_query']('', ' |
| 406 | 417 | DELETE FROM {db_prefix}user_drafts |
@@ -429,14 +440,16 @@ discard block |
||
| 429 | 440 | global $smcFunc, $scripturl, $context, $txt, $modSettings; |
| 430 | 441 | |
| 431 | 442 | // Permissions |
| 432 | - if (($draft_type === 0 && empty($context['drafts_save'])) || ($draft_type === 1 && empty($context['drafts_pm_save'])) || empty($member_id)) |
|
| 433 | - return false; |
|
| 443 | + if (($draft_type === 0 && empty($context['drafts_save'])) || ($draft_type === 1 && empty($context['drafts_pm_save'])) || empty($member_id)) { |
|
| 444 | + return false; |
|
| 445 | + } |
|
| 434 | 446 | |
| 435 | 447 | $context['drafts'] = array(); |
| 436 | 448 | |
| 437 | 449 | // has a specific draft has been selected? Load it up if there is not a message already in the editor |
| 438 | - if (isset($_REQUEST['id_draft']) && empty($_POST['subject']) && empty($_POST['message'])) |
|
| 439 | - ReadDraft((int) $_REQUEST['id_draft'], $draft_type, true, true); |
|
| 450 | + if (isset($_REQUEST['id_draft']) && empty($_POST['subject']) && empty($_POST['message'])) { |
|
| 451 | + ReadDraft((int) $_REQUEST['id_draft'], $draft_type, true, true); |
|
| 452 | + } |
|
| 440 | 453 | |
| 441 | 454 | // load the drafts this user has available |
| 442 | 455 | $request = $smcFunc['db_query']('', ' |
@@ -459,8 +472,9 @@ discard block |
||
| 459 | 472 | // add them to the draft array for display |
| 460 | 473 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 461 | 474 | { |
| 462 | - if (empty($row['subject'])) |
|
| 463 | - $row['subject'] = $txt['no_subject']; |
|
| 475 | + if (empty($row['subject'])) { |
|
| 476 | + $row['subject'] = $txt['no_subject']; |
|
| 477 | + } |
|
| 464 | 478 | |
| 465 | 479 | // Post drafts |
| 466 | 480 | if ($draft_type === 0) |
@@ -545,8 +559,9 @@ discard block |
||
| 545 | 559 | } |
| 546 | 560 | |
| 547 | 561 | // Default to 10. |
| 548 | - if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount'])) |
|
| 549 | - $_REQUEST['viewscount'] = 10; |
|
| 562 | + if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount'])) { |
|
| 563 | + $_REQUEST['viewscount'] = 10; |
|
| 564 | + } |
|
| 550 | 565 | |
| 551 | 566 | // Get the count of applicable drafts on the boards they can (still) see ... |
| 552 | 567 | // @todo .. should we just let them see their drafts even if they have lost board access ? |
@@ -611,12 +626,14 @@ discard block |
||
| 611 | 626 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 612 | 627 | { |
| 613 | 628 | // Censor.... |
| 614 | - if (empty($row['body'])) |
|
| 615 | - $row['body'] = ''; |
|
| 629 | + if (empty($row['body'])) { |
|
| 630 | + $row['body'] = ''; |
|
| 631 | + } |
|
| 616 | 632 | |
| 617 | 633 | $row['subject'] = $smcFunc['htmltrim']($row['subject']); |
| 618 | - if (empty($row['subject'])) |
|
| 619 | - $row['subject'] = $txt['no_subject']; |
|
| 634 | + if (empty($row['subject'])) { |
|
| 635 | + $row['subject'] = $txt['no_subject']; |
|
| 636 | + } |
|
| 620 | 637 | |
| 621 | 638 | censorText($row['body']); |
| 622 | 639 | censorText($row['subject']); |
@@ -648,8 +665,9 @@ discard block |
||
| 648 | 665 | $smcFunc['db_free_result']($request); |
| 649 | 666 | |
| 650 | 667 | // If the drafts were retrieved in reverse order, get them right again. |
| 651 | - if ($reverse) |
|
| 652 | - $context['drafts'] = array_reverse($context['drafts'], true); |
|
| 668 | + if ($reverse) { |
|
| 669 | + $context['drafts'] = array_reverse($context['drafts'], true); |
|
| 670 | + } |
|
| 653 | 671 | |
| 654 | 672 | // Menu tab |
| 655 | 673 | $context[$context['profile_menu_name']]['tab_data'] = array( |
@@ -707,8 +725,9 @@ discard block |
||
| 707 | 725 | } |
| 708 | 726 | |
| 709 | 727 | // Default to 10. |
| 710 | - if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount'])) |
|
| 711 | - $_REQUEST['viewscount'] = 10; |
|
| 728 | + if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount'])) { |
|
| 729 | + $_REQUEST['viewscount'] = 10; |
|
| 730 | + } |
|
| 712 | 731 | |
| 713 | 732 | // Get the count of applicable drafts |
| 714 | 733 | $request = $smcFunc['db_query']('', ' |
@@ -767,12 +786,14 @@ discard block |
||
| 767 | 786 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 768 | 787 | { |
| 769 | 788 | // Censor.... |
| 770 | - if (empty($row['body'])) |
|
| 771 | - $row['body'] = ''; |
|
| 789 | + if (empty($row['body'])) { |
|
| 790 | + $row['body'] = ''; |
|
| 791 | + } |
|
| 772 | 792 | |
| 773 | 793 | $row['subject'] = $smcFunc['htmltrim']($row['subject']); |
| 774 | - if (empty($row['subject'])) |
|
| 775 | - $row['subject'] = $txt['no_subject']; |
|
| 794 | + if (empty($row['subject'])) { |
|
| 795 | + $row['subject'] = $txt['no_subject']; |
|
| 796 | + } |
|
| 776 | 797 | |
| 777 | 798 | censorText($row['body']); |
| 778 | 799 | censorText($row['subject']); |
@@ -827,8 +848,9 @@ discard block |
||
| 827 | 848 | $smcFunc['db_free_result']($request); |
| 828 | 849 | |
| 829 | 850 | // if the drafts were retrieved in reverse order, then put them in the right order again. |
| 830 | - if ($reverse) |
|
| 831 | - $context['drafts'] = array_reverse($context['drafts'], true); |
|
| 851 | + if ($reverse) { |
|
| 852 | + $context['drafts'] = array_reverse($context['drafts'], true); |
|
| 853 | + } |
|
| 832 | 854 | |
| 833 | 855 | // off to the template we go |
| 834 | 856 | $context['page_title'] = $txt['drafts']; |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | * |
| 174 | 174 | * @param string $post_errors A string of info about errors encountered trying to save this draft |
| 175 | 175 | * @param array $recipientList An array of data about who this PM is being sent to |
| 176 | - * @return boolean false if you can't save the draft, true if we're doing this via XML more than 5 seconds after the last save, nothing otherwise |
|
| 176 | + * @return boolean|null false if you can't save the draft, true if we're doing this via XML more than 5 seconds after the last save, nothing otherwise |
|
| 177 | 177 | */ |
| 178 | 178 | function SavePMDraft(&$post_errors, $recipientList) |
| 179 | 179 | { |
@@ -388,7 +388,7 @@ discard block |
||
| 388 | 388 | * |
| 389 | 389 | * @param int $id_draft The ID of the draft to delete |
| 390 | 390 | * @param boolean $check Whether or not to check that the draft belongs to the current user |
| 391 | - * @return boolean False if it couldn't be deleted (doesn't return anything otherwise) |
|
| 391 | + * @return false|null False if it couldn't be deleted (doesn't return anything otherwise) |
|
| 392 | 392 | */ |
| 393 | 393 | function DeleteDraft($id_draft, $check = true) |
| 394 | 394 | { |
@@ -422,7 +422,7 @@ discard block |
||
| 422 | 422 | * @param int $member_id ID of the member to show drafts for |
| 423 | 423 | * @param boolean|integer $topic If $type is 1, this can be set to only load drafts for posts in the specific topic |
| 424 | 424 | * @param int $draft_type The type of drafts to show - 0 for post drafts, 1 for PM drafts |
| 425 | - * @return boolean False if the drafts couldn't be loaded, nothing otherwise |
|
| 425 | + * @return false|null False if the drafts couldn't be loaded, nothing otherwise |
|
| 426 | 426 | */ |
| 427 | 427 | function ShowDrafts($member_id, $topic = false, $draft_type = 0) |
| 428 | 428 | { |
@@ -16,8 +16,9 @@ discard block |
||
| 16 | 16 | |
| 17 | 17 | // Start things rolling by getting SMF alive... |
| 18 | 18 | $ssi_guest_access = true; |
| 19 | -if (!file_exists(dirname(__FILE__) . '/SSI.php')) |
|
| 19 | +if (!file_exists(dirname(__FILE__) . '/SSI.php')) { |
|
| 20 | 20 | die('Cannot find SSI.php'); |
| 21 | +} |
|
| 21 | 22 | |
| 22 | 23 | require_once(dirname(__FILE__) . '/SSI.php'); |
| 23 | 24 | require_once($sourcedir . '/ManagePaid.php'); |
@@ -35,20 +36,22 @@ discard block |
||
| 35 | 36 | } |
| 36 | 37 | |
| 37 | 38 | // I assume we're even active? |
| 38 | -if (empty($modSettings['paid_enabled'])) |
|
| 39 | +if (empty($modSettings['paid_enabled'])) { |
|
| 39 | 40 | exit; |
| 41 | +} |
|
| 40 | 42 | |
| 41 | 43 | // If we have some custom people who find out about problems load them here. |
| 42 | 44 | $notify_users = array(); |
| 43 | 45 | if (!empty($modSettings['paid_email_to'])) |
| 44 | 46 | { |
| 45 | - foreach (explode(',', $modSettings['paid_email_to']) as $email) |
|
| 46 | - $notify_users[] = array( |
|
| 47 | + foreach (explode(',', $modSettings['paid_email_to']) as $email) { |
|
| 48 | + $notify_users[] = array( |
|
| 47 | 49 | 'email' => $email, |
| 48 | 50 | 'name' => $txt['who_member'], |
| 49 | 51 | 'id' => 0, |
| 50 | 52 | ); |
| 51 | -} |
|
| 53 | + } |
|
| 54 | + } |
|
| 52 | 55 | |
| 53 | 56 | // We need to see whether we can find the correct payment gateway, |
| 54 | 57 | // we'll going to go through all our gateway scripts and find out |
@@ -65,8 +68,9 @@ discard block |
||
| 65 | 68 | } |
| 66 | 69 | } |
| 67 | 70 | |
| 68 | -if (empty($txnType)) |
|
| 71 | +if (empty($txnType)) { |
|
| 69 | 72 | generateSubscriptionError($txt['paid_unknown_transaction_type']); |
| 73 | +} |
|
| 70 | 74 | |
| 71 | 75 | // Get the subscription and member ID amoungst others... |
| 72 | 76 | @list($subscription_id, $member_id) = $gatewayClass->precheck(); |
@@ -76,8 +80,9 @@ discard block |
||
| 76 | 80 | $member_id = (int) $member_id; |
| 77 | 81 | |
| 78 | 82 | // This would be bad... |
| 79 | -if (empty($member_id)) |
|
| 83 | +if (empty($member_id)) { |
|
| 80 | 84 | generateSubscriptionError($txt['paid_empty_member']); |
| 85 | +} |
|
| 81 | 86 | |
| 82 | 87 | // Verify the member. |
| 83 | 88 | $request = $smcFunc['db_query']('', ' |
@@ -89,8 +94,9 @@ discard block |
||
| 89 | 94 | ) |
| 90 | 95 | ); |
| 91 | 96 | // Didn't find them? |
| 92 | -if ($smcFunc['db_num_rows']($request) === 0) |
|
| 97 | +if ($smcFunc['db_num_rows']($request) === 0) { |
|
| 93 | 98 | generateSubscriptionError(sprintf($txt['paid_could_not_find_member'], $member_id)); |
| 99 | +} |
|
| 94 | 100 | $member_info = $smcFunc['db_fetch_assoc']($request); |
| 95 | 101 | $smcFunc['db_free_result']($request); |
| 96 | 102 | |
@@ -105,8 +111,9 @@ discard block |
||
| 105 | 111 | ); |
| 106 | 112 | |
| 107 | 113 | // Didn't find it? |
| 108 | -if ($smcFunc['db_num_rows']($request) === 0) |
|
| 114 | +if ($smcFunc['db_num_rows']($request) === 0) { |
|
| 109 | 115 | generateSubscriptionError(sprintf($txt['paid_count_not_find_subscription'], $member_id, $subscription_id)); |
| 116 | +} |
|
| 110 | 117 | |
| 111 | 118 | $subscription_info = $smcFunc['db_fetch_assoc']($request); |
| 112 | 119 | $smcFunc['db_free_result']($request); |
@@ -123,8 +130,9 @@ discard block |
||
| 123 | 130 | 'current_member' => $member_id, |
| 124 | 131 | ) |
| 125 | 132 | ); |
| 126 | -if ($smcFunc['db_num_rows']($request) === 0) |
|
| 133 | +if ($smcFunc['db_num_rows']($request) === 0) { |
|
| 127 | 134 | generateSubscriptionError(sprintf($txt['paid_count_not_find_subscription_log'], $member_id, $subscription_id)); |
| 135 | +} |
|
| 128 | 136 | $subscription_info += $smcFunc['db_fetch_assoc']($request); |
| 129 | 137 | $smcFunc['db_free_result']($request); |
| 130 | 138 | |
@@ -139,8 +147,7 @@ discard block |
||
| 139 | 147 | removeSubscription($subscription_id, $member_id); |
| 140 | 148 | $subscription_act = time(); |
| 141 | 149 | $status = 0; |
| 142 | - } |
|
| 143 | - else |
|
| 150 | + } else |
|
| 144 | 151 | { |
| 145 | 152 | loadSubscriptions(); |
| 146 | 153 | $subscription_act = $subscription_info['end_time'] - $context['subscriptions'][$subscription_id]['num_length']; |
@@ -188,16 +195,18 @@ discard block |
||
| 188 | 195 | if (!$gatewayClass->isSubscription()) |
| 189 | 196 | { |
| 190 | 197 | $real_details = $smcFunc['json_decode']($subscription_info['pending_details'], true); |
| 191 | - if (empty($real_details)) |
|
| 192 | - generateSubscriptionError(sprintf($txt['paid_count_not_find_outstanding_payment'], $member_id, $subscription_id)); |
|
| 198 | + if (empty($real_details)) { |
|
| 199 | + generateSubscriptionError(sprintf($txt['paid_count_not_find_outstanding_payment'], $member_id, $subscription_id)); |
|
| 200 | + } |
|
| 193 | 201 | |
| 194 | 202 | // Now we just try to find anything pending. |
| 195 | 203 | // We don't really care which it is as security happens later. |
| 196 | 204 | foreach ($real_details as $id => $detail) |
| 197 | 205 | { |
| 198 | 206 | unset($real_details[$id]); |
| 199 | - if ($detail[3] == 'payback' && $subscription_info['payments_pending']) |
|
| 200 | - $subscription_info['payments_pending']--; |
|
| 207 | + if ($detail[3] == 'payback' && $subscription_info['payments_pending']) { |
|
| 208 | + $subscription_info['payments_pending']--; |
|
| 209 | + } |
|
| 201 | 210 | break; |
| 202 | 211 | } |
| 203 | 212 | |
@@ -223,10 +232,11 @@ discard block |
||
| 223 | 232 | // This is a little harder, can we find the right duration? |
| 224 | 233 | foreach ($cost as $duration => $value) |
| 225 | 234 | { |
| 226 | - if ($duration == 'fixed') |
|
| 227 | - continue; |
|
| 228 | - elseif ((float) $value == (float) $total_cost) |
|
| 229 | - $found_duration = strtoupper(substr($duration, 0, 1)); |
|
| 235 | + if ($duration == 'fixed') { |
|
| 236 | + continue; |
|
| 237 | + } elseif ((float) $value == (float) $total_cost) { |
|
| 238 | + $found_duration = strtoupper(substr($duration, 0, 1)); |
|
| 239 | + } |
|
| 230 | 240 | } |
| 231 | 241 | |
| 232 | 242 | // If we have the duration then we're done. |
@@ -235,8 +245,7 @@ discard block |
||
| 235 | 245 | $notify = true; |
| 236 | 246 | addSubscription($subscription_id, $member_id, $found_duration); |
| 237 | 247 | } |
| 238 | - } |
|
| 239 | - else |
|
| 248 | + } else |
|
| 240 | 249 | { |
| 241 | 250 | $actual_cost = $cost['fixed']; |
| 242 | 251 | |
@@ -268,10 +277,10 @@ discard block |
||
| 268 | 277 | // Maybe they're cancelling. Some subscriptions may require actively doing something, but PayPal doesn't, for example. |
| 269 | 278 | elseif ($gatewayClass->isCancellation()) |
| 270 | 279 | { |
| 271 | - if (method_exists($gatewayClass, 'performCancel')) |
|
| 272 | - $gatewayClass->performCancel($subscription_id, $member_id, $subscription_info); |
|
| 273 | -} |
|
| 274 | -else |
|
| 280 | + if (method_exists($gatewayClass, 'performCancel')) { |
|
| 281 | + $gatewayClass->performCancel($subscription_id, $member_id, $subscription_info); |
|
| 282 | + } |
|
| 283 | + } else |
|
| 275 | 284 | { |
| 276 | 285 | // Some other "valid" transaction such as: |
| 277 | 286 | // |
@@ -308,8 +317,9 @@ discard block |
||
| 308 | 317 | // Maybe we can try to give them the post data? |
| 309 | 318 | if (!empty($_POST)) |
| 310 | 319 | { |
| 311 | - foreach ($_POST as $key => $val) |
|
| 312 | - $text .= '<br>' . $smcFunc['htmlspecialchars']($key) . ': ' . $smcFunc['htmlspecialchars']($val); |
|
| 320 | + foreach ($_POST as $key => $val) { |
|
| 321 | + $text .= '<br>' . $smcFunc['htmlspecialchars']($key) . ': ' . $smcFunc['htmlspecialchars']($val); |
|
| 322 | + } |
|
| 313 | 323 | } |
| 314 | 324 | |
| 315 | 325 | // Then just log and die. |
@@ -86,7 +86,7 @@ |
||
| 86 | 86 | foreach ($board['children'] as $child) |
| 87 | 87 | { |
| 88 | 88 | if (!$child['is_redirect']) |
| 89 | - $child['link'] = ''. ($child['new'] ? '<a href="' . $scripturl . '?action=unread;board=' . $child['id'] . '" title="' . $txt['new_posts'] . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')"><span class="new_posts">' . $txt['new'] . '</span></a>' : '') . '<a href="' . $child['href'] . '" ' . ($child['new'] ? 'class="board_new_posts" ' : '') . 'title="' . ($child['new'] ? $txt['new_posts'] : $txt['old_posts']) . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')">' . $child['name'] . '</a>'; |
|
| 89 | + $child['link'] = '' . ($child['new'] ? '<a href="' . $scripturl . '?action=unread;board=' . $child['id'] . '" title="' . $txt['new_posts'] . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')"><span class="new_posts">' . $txt['new'] . '</span></a>' : '') . '<a href="' . $child['href'] . '" ' . ($child['new'] ? 'class="board_new_posts" ' : '') . 'title="' . ($child['new'] ? $txt['new_posts'] : $txt['old_posts']) . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')">' . $child['name'] . '</a>'; |
|
| 90 | 90 | else |
| 91 | 91 | $child['link'] = '<a href="' . $child['href'] . '" title="' . comma_format($child['posts']) . ' ' . $txt['redirects'] . '">' . $child['name'] . '</a>'; |
| 92 | 92 | |
@@ -18,11 +18,12 @@ discard block |
||
| 18 | 18 | global $context, $settings, $options, $scripturl, $modSettings, $txt; |
| 19 | 19 | |
| 20 | 20 | // Let them know why their message became unapproved. |
| 21 | - if ($context['becomesUnapproved']) |
|
| 22 | - echo ' |
|
| 21 | + if ($context['becomesUnapproved']) { |
|
| 22 | + echo ' |
|
| 23 | 23 | <div class="noticebox"> |
| 24 | 24 | ', $txt['post_becomesUnapproved'], ' |
| 25 | 25 | </div>'; |
| 26 | + } |
|
| 26 | 27 | |
| 27 | 28 | if (!empty($context['boards']) && (!empty($options['show_children']) || $context['start'] == 0)) |
| 28 | 29 | { |
@@ -46,17 +47,19 @@ discard block |
||
| 46 | 47 | </a>'; |
| 47 | 48 | |
| 48 | 49 | // Has it outstanding posts for approval? |
| 49 | - if ($board['can_approve_posts'] && ($board['unapproved_posts'] || $board['unapproved_topics'])) |
|
| 50 | - echo ' |
|
| 50 | + if ($board['can_approve_posts'] && ($board['unapproved_posts'] || $board['unapproved_topics'])) { |
|
| 51 | + echo ' |
|
| 51 | 52 | <a href="', $scripturl, '?action=moderate;area=postmod;sa=', ($board['unapproved_topics'] > 0 ? 'topics' : 'posts'), ';brd=', $board['id'], ';', $context['session_var'], '=', $context['session_id'], '" title="', sprintf($txt['unapproved_posts'], $board['unapproved_topics'], $board['unapproved_posts']), '" class="moderation_link">(!)</a>'; |
| 53 | + } |
|
| 52 | 54 | |
| 53 | 55 | echo ' |
| 54 | 56 | <p class="board_description">', $board['description'], '</p>'; |
| 55 | 57 | |
| 56 | 58 | // Show the "Moderators: ". Each has name, href, link, and id. (but we're gonna use link_moderators.) |
| 57 | - if (!empty($board['moderators']) || !empty($board['moderator_groups'])) |
|
| 58 | - echo ' |
|
| 59 | + if (!empty($board['moderators']) || !empty($board['moderator_groups'])) { |
|
| 60 | + echo ' |
|
| 59 | 61 | <p class="moderators">', count($board['link_moderators']) === 1 ? $txt['moderator'] : $txt['moderators'], ': ', implode(', ', $board['link_moderators']), '</p>'; |
| 62 | + } |
|
| 60 | 63 | |
| 61 | 64 | // Show some basic information about the number of posts, etc. |
| 62 | 65 | echo ' |
@@ -68,9 +71,10 @@ discard block |
||
| 68 | 71 | </div> |
| 69 | 72 | <div class="lastpost lpr_border">'; |
| 70 | 73 | |
| 71 | - if (!empty($board['last_post']['id'])) |
|
| 72 | - echo ' |
|
| 74 | + if (!empty($board['last_post']['id'])) { |
|
| 75 | + echo ' |
|
| 73 | 76 | <p>', $board['last_post']['last_post_message'], '</p>'; |
| 77 | + } |
|
| 74 | 78 | |
| 75 | 79 | echo ' |
| 76 | 80 | </div>'; |
@@ -84,14 +88,16 @@ discard block |
||
| 84 | 88 | id, name, description, new (is it new?), topics (#), posts (#), href, link, and last_post. */ |
| 85 | 89 | foreach ($board['children'] as $child) |
| 86 | 90 | { |
| 87 | - if (!$child['is_redirect']) |
|
| 88 | - $child['link'] = ''. ($child['new'] ? '<a href="' . $scripturl . '?action=unread;board=' . $child['id'] . '" title="' . $txt['new_posts'] . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')"><span class="new_posts">' . $txt['new'] . '</span></a>' : '') . '<a href="' . $child['href'] . '" ' . ($child['new'] ? 'class="board_new_posts" ' : '') . 'title="' . ($child['new'] ? $txt['new_posts'] : $txt['old_posts']) . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')">' . $child['name'] . '</a>'; |
|
| 89 | - else |
|
| 90 | - $child['link'] = '<a href="' . $child['href'] . '" title="' . comma_format($child['posts']) . ' ' . $txt['redirects'] . '">' . $child['name'] . '</a>'; |
|
| 91 | + if (!$child['is_redirect']) { |
|
| 92 | + $child['link'] = ''. ($child['new'] ? '<a href="' . $scripturl . '?action=unread;board=' . $child['id'] . '" title="' . $txt['new_posts'] . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')"><span class="new_posts">' . $txt['new'] . '</span></a>' : '') . '<a href="' . $child['href'] . '" ' . ($child['new'] ? 'class="board_new_posts" ' : '') . 'title="' . ($child['new'] ? $txt['new_posts'] : $txt['old_posts']) . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')">' . $child['name'] . '</a>'; |
|
| 93 | + } else { |
|
| 94 | + $child['link'] = '<a href="' . $child['href'] . '" title="' . comma_format($child['posts']) . ' ' . $txt['redirects'] . '">' . $child['name'] . '</a>'; |
|
| 95 | + } |
|
| 91 | 96 | |
| 92 | 97 | // Has it posts awaiting approval? |
| 93 | - if ($child['can_approve_posts'] && ($child['unapproved_posts'] | $child['unapproved_topics'])) |
|
| 94 | - $child['link'] .= ' <a href="' . $scripturl . '?action=moderate;area=postmod;sa=' . ($child['unapproved_topics'] > 0 ? 'topics' : 'posts') . ';brd=' . $child['id'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '" title="' . sprintf($txt['unapproved_posts'], $child['unapproved_topics'], $child['unapproved_posts']) . '" class="moderation_link">(!)</a>'; |
|
| 98 | + if ($child['can_approve_posts'] && ($child['unapproved_posts'] | $child['unapproved_topics'])) { |
|
| 99 | + $child['link'] .= ' <a href="' . $scripturl . '?action=moderate;area=postmod;sa=' . ($child['unapproved_topics'] > 0 ? 'topics' : 'posts') . ';brd=' . $child['id'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '" title="' . sprintf($txt['unapproved_posts'], $child['unapproved_topics'], $child['unapproved_posts']) . '" class="moderation_link">(!)</a>'; |
|
| 100 | + } |
|
| 95 | 101 | |
| 96 | 102 | $children[] = $child['new'] ? '<span class="strong">' . $child['link'] . '</span>' : '<span>' . $child['link'] . '</span>'; |
| 97 | 103 | } |
@@ -135,13 +141,15 @@ discard block |
||
| 135 | 141 | <h3>', $context['name'], '</h3> |
| 136 | 142 | <p>'; |
| 137 | 143 | |
| 138 | - if ($context['description'] != '') |
|
| 139 | - echo ' |
|
| 144 | + if ($context['description'] != '') { |
|
| 145 | + echo ' |
|
| 140 | 146 | ', $context['description']; |
| 147 | + } |
|
| 141 | 148 | |
| 142 | - if (!empty($context['moderators'])) |
|
| 143 | - echo ' |
|
| 149 | + if (!empty($context['moderators'])) { |
|
| 150 | + echo ' |
|
| 144 | 151 | ', count($context['moderators']) === 1 ? $txt['moderator'] : $txt['moderators'], ': ', implode(', ', $context['link_moderators']), '.'; |
| 152 | + } |
|
| 145 | 153 | |
| 146 | 154 | echo ' |
| 147 | 155 | </p> |
@@ -149,9 +157,10 @@ discard block |
||
| 149 | 157 | } |
| 150 | 158 | |
| 151 | 159 | // If Quick Moderation is enabled start the form. |
| 152 | - if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] > 0 && !empty($context['topics'])) |
|
| 153 | - echo ' |
|
| 160 | + if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] > 0 && !empty($context['topics'])) { |
|
| 161 | + echo ' |
|
| 154 | 162 | <form action="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], '" method="post" accept-charset="', $context['character_set'], '" class="clear" name="quickModForm" id="quickModForm">'; |
| 163 | + } |
|
| 155 | 164 | |
| 156 | 165 | echo ' |
| 157 | 166 | <div id="messageindex">'; |
@@ -161,11 +170,11 @@ discard block |
||
| 161 | 170 | echo ' |
| 162 | 171 | <div class="information">'; |
| 163 | 172 | |
| 164 | - if ($settings['display_who_viewing'] == 1) |
|
| 165 | - echo count($context['view_members']), ' ', count($context['view_members']) === 1 ? $txt['who_member'] : $txt['members']; |
|
| 166 | - |
|
| 167 | - else |
|
| 168 | - echo empty($context['view_members_list']) ? '0 ' . $txt['members'] : implode(', ', $context['view_members_list']) . (empty($context['view_num_hidden']) || $context['can_moderate_forum'] ? '' : ' (+ ' . $context['view_num_hidden'] . ' ' . $txt['hidden'] . ')'); |
|
| 173 | + if ($settings['display_who_viewing'] == 1) { |
|
| 174 | + echo count($context['view_members']), ' ', count($context['view_members']) === 1 ? $txt['who_member'] : $txt['members']; |
|
| 175 | + } else { |
|
| 176 | + echo empty($context['view_members_list']) ? '0 ' . $txt['members'] : implode(', ', $context['view_members_list']) . (empty($context['view_num_hidden']) || $context['can_moderate_forum'] ? '' : ' (+ ' . $context['view_num_hidden'] . ' ' . $txt['hidden'] . ')'); |
|
| 177 | + } |
|
| 169 | 178 | echo $txt['who_and'], $context['view_num_guests'], ' ', $context['view_num_guests'] == 1 ? $txt['guest'] : $txt['guests'], $txt['who_viewing_board']; |
| 170 | 179 | |
| 171 | 180 | echo ' |
@@ -185,32 +194,36 @@ discard block |
||
| 185 | 194 | <div class="lastpost">', $context['topics_headers']['last_post'], '</div>'; |
| 186 | 195 | |
| 187 | 196 | // Show a "select all" box for quick moderation? |
| 188 | - if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] == 1) |
|
| 189 | - echo ' |
|
| 197 | + if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] == 1) { |
|
| 198 | + echo ' |
|
| 190 | 199 | <div class="moderation"> |
| 191 | 200 | <input type="checkbox" onclick="invertAll(this, this.form, \'topics[]\');"> |
| 192 | 201 | </div>'; |
| 202 | + } |
|
| 193 | 203 | |
| 194 | 204 | // If it's on in "image" mode, don't show anything but the column. |
| 195 | - elseif (!empty($context['can_quick_mod'])) |
|
| 196 | - echo ' |
|
| 205 | + elseif (!empty($context['can_quick_mod'])) { |
|
| 206 | + echo ' |
|
| 197 | 207 | <div class="moderation"></div>'; |
| 208 | + } |
|
| 198 | 209 | } |
| 199 | 210 | |
| 200 | 211 | // No topics... just say, "sorry bub". |
| 201 | - else |
|
| 202 | - echo ' |
|
| 212 | + else { |
|
| 213 | + echo ' |
|
| 203 | 214 | <h3 class="titlebg">', $txt['topic_alert_none'], '</h3>'; |
| 215 | + } |
|
| 204 | 216 | |
| 205 | 217 | echo ' |
| 206 | 218 | </div><!-- #topic_header -->'; |
| 207 | 219 | |
| 208 | 220 | // If this person can approve items and we have some awaiting approval tell them. |
| 209 | - if (!empty($context['unapproved_posts_message'])) |
|
| 210 | - echo ' |
|
| 221 | + if (!empty($context['unapproved_posts_message'])) { |
|
| 222 | + echo ' |
|
| 211 | 223 | <div class="information"> |
| 212 | 224 | <span class="alert">!</span> ', $context['unapproved_posts_message'], ' |
| 213 | 225 | </div>'; |
| 226 | + } |
|
| 214 | 227 | |
| 215 | 228 | // Contain the topic list |
| 216 | 229 | echo ' |
@@ -231,25 +244,30 @@ discard block |
||
| 231 | 244 | echo ' |
| 232 | 245 | <div class="icons floatright">'; |
| 233 | 246 | |
| 234 | - if ($topic['is_watched']) |
|
| 235 | - echo ' |
|
| 247 | + if ($topic['is_watched']) { |
|
| 248 | + echo ' |
|
| 236 | 249 | <span class="generic_icons watch" title="', $txt['watching_this_topic'], '"></span>'; |
| 250 | + } |
|
| 237 | 251 | |
| 238 | - if ($topic['is_locked']) |
|
| 239 | - echo ' |
|
| 252 | + if ($topic['is_locked']) { |
|
| 253 | + echo ' |
|
| 240 | 254 | <span class="generic_icons lock"></span>'; |
| 255 | + } |
|
| 241 | 256 | |
| 242 | - if ($topic['is_sticky']) |
|
| 243 | - echo ' |
|
| 257 | + if ($topic['is_sticky']) { |
|
| 258 | + echo ' |
|
| 244 | 259 | <span class="generic_icons sticky"></span>'; |
| 260 | + } |
|
| 245 | 261 | |
| 246 | - if ($topic['is_redirect']) |
|
| 247 | - echo ' |
|
| 262 | + if ($topic['is_redirect']) { |
|
| 263 | + echo ' |
|
| 248 | 264 | <span class="generic_icons move"></span>'; |
| 265 | + } |
|
| 249 | 266 | |
| 250 | - if ($topic['is_poll']) |
|
| 251 | - echo ' |
|
| 267 | + if ($topic['is_poll']) { |
|
| 268 | + echo ' |
|
| 252 | 269 | <span class="generic_icons poll"></span>'; |
| 270 | + } |
|
| 253 | 271 | |
| 254 | 272 | echo ' |
| 255 | 273 | </div>'; |
@@ -281,26 +299,31 @@ discard block |
||
| 281 | 299 | echo ' |
| 282 | 300 | <div class="moderation">'; |
| 283 | 301 | |
| 284 | - if ($options['display_quick_mod'] == 1) |
|
| 285 | - echo ' |
|
| 302 | + if ($options['display_quick_mod'] == 1) { |
|
| 303 | + echo ' |
|
| 286 | 304 | <input type="checkbox" name="topics[]" value="', $topic['id'], '">'; |
| 287 | - else |
|
| 305 | + } else |
|
| 288 | 306 | { |
| 289 | 307 | // Check permissions on each and show only the ones they are allowed to use. |
| 290 | - if ($topic['quick_mod']['remove']) |
|
| 291 | - echo '<a href="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], ';actions%5B', $topic['id'], '%5D=remove;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons delete" title="', $txt['remove_topic'], '"></span></a>'; |
|
| 308 | + if ($topic['quick_mod']['remove']) { |
|
| 309 | + echo '<a href="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], ';actions%5B', $topic['id'], '%5D=remove;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons delete" title="', $txt['remove_topic'], '"></span></a>'; |
|
| 310 | + } |
|
| 292 | 311 | |
| 293 | - if ($topic['quick_mod']['lock']) |
|
| 294 | - echo '<a href="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], ';actions%5B', $topic['id'], '%5D=lock;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons lock" title="', $topic['is_locked'] ? $txt['set_unlock'] : $txt['set_lock'], '"></span></a>'; |
|
| 312 | + if ($topic['quick_mod']['lock']) { |
|
| 313 | + echo '<a href="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], ';actions%5B', $topic['id'], '%5D=lock;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons lock" title="', $topic['is_locked'] ? $txt['set_unlock'] : $txt['set_lock'], '"></span></a>'; |
|
| 314 | + } |
|
| 295 | 315 | |
| 296 | - if ($topic['quick_mod']['lock'] || $topic['quick_mod']['remove']) |
|
| 297 | - echo '<br>'; |
|
| 316 | + if ($topic['quick_mod']['lock'] || $topic['quick_mod']['remove']) { |
|
| 317 | + echo '<br>'; |
|
| 318 | + } |
|
| 298 | 319 | |
| 299 | - if ($topic['quick_mod']['sticky']) |
|
| 300 | - echo '<a href="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], ';actions%5B', $topic['id'], '%5D=sticky;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons sticky" title="', $topic['is_sticky'] ? $txt['set_nonsticky'] : $txt['set_sticky'], '"></span></a>'; |
|
| 320 | + if ($topic['quick_mod']['sticky']) { |
|
| 321 | + echo '<a href="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], ';actions%5B', $topic['id'], '%5D=sticky;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons sticky" title="', $topic['is_sticky'] ? $txt['set_nonsticky'] : $txt['set_sticky'], '"></span></a>'; |
|
| 322 | + } |
|
| 301 | 323 | |
| 302 | - if ($topic['quick_mod']['move']) |
|
| 303 | - echo '<a href="', $scripturl, '?action=movetopic;current_board=', $context['current_board'], ';board=', $context['current_board'], '.', $context['start'], ';topic=', $topic['id'], '.0"><span class="generic_icons move" title="', $txt['move_topic'], '"></span></a>'; |
|
| 324 | + if ($topic['quick_mod']['move']) { |
|
| 325 | + echo '<a href="', $scripturl, '?action=movetopic;current_board=', $context['current_board'], ';board=', $context['current_board'], '.', $context['start'], ';topic=', $topic['id'], '.0"><span class="generic_icons move" title="', $txt['move_topic'], '"></span></a>'; |
|
| 326 | + } |
|
| 304 | 327 | } |
| 305 | 328 | echo ' |
| 306 | 329 | </div><!-- .moderation -->'; |
@@ -318,18 +341,20 @@ discard block |
||
| 318 | 341 | <select class="qaction" name="qaction"', $context['can_move'] ? ' onchange="this.form.move_to.disabled = (this.options[this.selectedIndex].value != \'move\');"' : '', '> |
| 319 | 342 | <option value="">--------</option>'; |
| 320 | 343 | |
| 321 | - foreach ($context['qmod_actions'] as $qmod_action) |
|
| 322 | - if ($context['can_' . $qmod_action]) |
|
| 344 | + foreach ($context['qmod_actions'] as $qmod_action) { |
|
| 345 | + if ($context['can_' . $qmod_action]) |
|
| 323 | 346 | echo ' |
| 324 | 347 | <option value="' . $qmod_action . '">' . $txt['quick_mod_' . $qmod_action] . '</option>'; |
| 348 | + } |
|
| 325 | 349 | |
| 326 | 350 | echo ' |
| 327 | 351 | </select>'; |
| 328 | 352 | |
| 329 | 353 | // Show a list of boards they can move the topic to. |
| 330 | - if ($context['can_move']) |
|
| 331 | - echo ' |
|
| 354 | + if ($context['can_move']) { |
|
| 355 | + echo ' |
|
| 332 | 356 | <span id="quick_mod_jump_to"></span>'; |
| 357 | + } |
|
| 333 | 358 | |
| 334 | 359 | echo ' |
| 335 | 360 | <input type="submit" value="', $txt['quick_mod_go'], '" onclick="return document.forms.quickModForm.qaction.value != \'\' && confirm(\'', $txt['quickmod_confirm'], '\');" class="button qaction"> |
@@ -340,10 +365,11 @@ discard block |
||
| 340 | 365 | </div><!-- #messageindex -->'; |
| 341 | 366 | |
| 342 | 367 | // Finish off the form - again. |
| 343 | - if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] > 0 && !empty($context['topics'])) |
|
| 344 | - echo ' |
|
| 368 | + if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] > 0 && !empty($context['topics'])) { |
|
| 369 | + echo ' |
|
| 345 | 370 | <input type="hidden" name="' . $context['session_var'] . '" value="' . $context['session_id'] . '"> |
| 346 | 371 | </form>'; |
| 372 | + } |
|
| 347 | 373 | |
| 348 | 374 | // Mobile action buttons (bottom) |
| 349 | 375 | echo ' |
@@ -365,8 +391,8 @@ discard block |
||
| 365 | 391 | // Show breadcrumbs at the bottom too. |
| 366 | 392 | theme_linktree(); |
| 367 | 393 | |
| 368 | - if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics']) && $context['can_move']) |
|
| 369 | - echo ' |
|
| 394 | + if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics']) && $context['can_move']) { |
|
| 395 | + echo ' |
|
| 370 | 396 | <script> |
| 371 | 397 | if (typeof(window.XMLHttpRequest) != "undefined") |
| 372 | 398 | aJumpTo[aJumpTo.length] = new JumpTo({ |
@@ -385,6 +411,7 @@ discard block |
||
| 385 | 411 | sCustomName: "move_to" |
| 386 | 412 | }); |
| 387 | 413 | </script>'; |
| 414 | + } |
|
| 388 | 415 | |
| 389 | 416 | // Javascript for inline editing. |
| 390 | 417 | echo ' |
@@ -421,8 +448,8 @@ discard block |
||
| 421 | 448 | <div class="information"> |
| 422 | 449 | <p class="floatright" id="message_index_jump_to"></p>'; |
| 423 | 450 | |
| 424 | - if (empty($context['no_topic_listing'])) |
|
| 425 | - echo ' |
|
| 451 | + if (empty($context['no_topic_listing'])) { |
|
| 452 | + echo ' |
|
| 426 | 453 | <p class="floatleft">', !empty($modSettings['enableParticipation']) && $context['user']['is_logged'] ? ' |
| 427 | 454 | <img src="' . $settings['images_url'] . '/icons/profile_sm.png" alt="" class="centericon"> ' . $txt['participation_caption'] . '<br>' : '', ' |
| 428 | 455 | '. ($modSettings['pollMode'] == '1' ? '<span class="generic_icons poll centericon"></span> ' . $txt['poll'] : '') . '<br> |
@@ -432,9 +459,10 @@ discard block |
||
| 432 | 459 | <span class="generic_icons lock centericon"></span> ' . $txt['locked_topic'] . '<br> |
| 433 | 460 | <span class="generic_icons sticky centericon"></span> ' . $txt['sticky_topic'] . '<br> |
| 434 | 461 | </p>'; |
| 462 | + } |
|
| 435 | 463 | |
| 436 | - if (!empty($context['jump_to'])) |
|
| 437 | - echo ' |
|
| 464 | + if (!empty($context['jump_to'])) { |
|
| 465 | + echo ' |
|
| 438 | 466 | <script> |
| 439 | 467 | if (typeof(window.XMLHttpRequest) != "undefined") |
| 440 | 468 | aJumpTo[aJumpTo.length] = new JumpTo({ |
@@ -450,6 +478,7 @@ discard block |
||
| 450 | 478 | sGoButtonLabel: "', $txt['quick_mod_go'], '" |
| 451 | 479 | }); |
| 452 | 480 | </script>'; |
| 481 | + } |
|
| 453 | 482 | |
| 454 | 483 | echo ' |
| 455 | 484 | <br class="clear"> |
@@ -2259,9 +2259,9 @@ discard block |
||
| 2259 | 2259 | * |
| 2260 | 2260 | * @uses the template_include() function to include the file. |
| 2261 | 2261 | * @param string $template_name The name of the template to load |
| 2262 | - * @param array|string $style_sheets The name of a single stylesheet or an array of names of stylesheets to load |
|
| 2262 | + * @param string $style_sheets The name of a single stylesheet or an array of names of stylesheets to load |
|
| 2263 | 2263 | * @param bool $fatal If true, dies with an error message if the template cannot be found |
| 2264 | - * @return boolean Whether or not the template was loaded |
|
| 2264 | + * @return boolean|null Whether or not the template was loaded |
|
| 2265 | 2265 | */ |
| 2266 | 2266 | function loadTemplate($template_name, $style_sheets = array(), $fatal = true) |
| 2267 | 2267 | { |
@@ -2444,7 +2444,7 @@ discard block |
||
| 2444 | 2444 | * - all code added with this function is added to the same <style> tag so do make sure your css is valid! |
| 2445 | 2445 | * |
| 2446 | 2446 | * @param string $css Some css code |
| 2447 | - * @return void|bool Adds the CSS to the $context['css_header'] array or returns if no CSS is specified |
|
| 2447 | + * @return false|null Adds the CSS to the $context['css_header'] array or returns if no CSS is specified |
|
| 2448 | 2448 | */ |
| 2449 | 2449 | function addInlineCss($css) |
| 2450 | 2450 | { |
@@ -2558,7 +2558,7 @@ discard block |
||
| 2558 | 2558 | * |
| 2559 | 2559 | * @param string $javascript Some JS code |
| 2560 | 2560 | * @param bool $defer Whether the script should load in <head> or before the closing <html> tag |
| 2561 | - * @return void|bool Adds the code to one of the $context['javascript_inline'] arrays or returns if no JS was specified |
|
| 2561 | + * @return false|null Adds the code to one of the $context['javascript_inline'] arrays or returns if no JS was specified |
|
| 2562 | 2562 | */ |
| 2563 | 2563 | function addInlineJavaScript($javascript, $defer = false) |
| 2564 | 2564 | { |
@@ -2791,7 +2791,7 @@ discard block |
||
| 2791 | 2791 | * It will try to choose only utf8 or non-utf8 languages. |
| 2792 | 2792 | * |
| 2793 | 2793 | * @param bool $use_cache Whether or not to use the cache |
| 2794 | - * @return array An array of information about available languages |
|
| 2794 | + * @return string An array of information about available languages |
|
| 2795 | 2795 | */ |
| 2796 | 2796 | function getLanguages($use_cache = true) |
| 2797 | 2797 | { |
@@ -1742,7 +1742,7 @@ discard block |
||
| 1742 | 1742 | } |
| 1743 | 1743 | |
| 1744 | 1744 | // We already load the basic stuff? |
| 1745 | - if (empty($settings['theme_id']) || $settings['theme_id'] != $id_theme ) |
|
| 1745 | + if (empty($settings['theme_id']) || $settings['theme_id'] != $id_theme) |
|
| 1746 | 1746 | { |
| 1747 | 1747 | $member = empty($user_info['id']) ? -1 : $user_info['id']; |
| 1748 | 1748 | |
@@ -1767,7 +1767,7 @@ discard block |
||
| 1767 | 1767 | SELECT variable, value, id_member, id_theme |
| 1768 | 1768 | FROM {db_prefix}themes |
| 1769 | 1769 | WHERE id_member' . (empty($themeData[0]) ? ' IN (-1, 0, {int:id_member})' : ' = {int:id_member}') . ' |
| 1770 | - AND id_theme' . ($id_theme == 1 ? ' = {int:id_theme}' : ' IN ({int:id_theme}, 1)') .' |
|
| 1770 | + AND id_theme' . ($id_theme == 1 ? ' = {int:id_theme}' : ' IN ({int:id_theme}, 1)') . ' |
|
| 1771 | 1771 | ORDER BY id_theme asc', |
| 1772 | 1772 | array( |
| 1773 | 1773 | 'id_theme' => $id_theme, |
@@ -1997,7 +1997,7 @@ discard block |
||
| 1997 | 1997 | if (!isset($context['javascript_vars'])) |
| 1998 | 1998 | $context['javascript_vars'] = array(); |
| 1999 | 1999 | |
| 2000 | - $context['login_url'] = $scripturl . '?action=login2'; |
|
| 2000 | + $context['login_url'] = $scripturl . '?action=login2'; |
|
| 2001 | 2001 | $context['menu_separator'] = !empty($settings['use_image_buttons']) ? ' ' : ' | '; |
| 2002 | 2002 | $context['session_var'] = $_SESSION['session_var']; |
| 2003 | 2003 | $context['session_id'] = $_SESSION['session_value']; |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 4 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * Load the $modSettings array. |
@@ -25,13 +26,14 @@ discard block |
||
| 25 | 26 | global $cache_enable, $sourcedir, $context; |
| 26 | 27 | |
| 27 | 28 | // Most database systems have not set UTF-8 as their default input charset. |
| 28 | - if (!empty($db_character_set)) |
|
| 29 | - $smcFunc['db_query']('', ' |
|
| 29 | + if (!empty($db_character_set)) { |
|
| 30 | + $smcFunc['db_query']('', ' |
|
| 30 | 31 | SET NAMES {string:db_character_set}', |
| 31 | 32 | array( |
| 32 | 33 | 'db_character_set' => $db_character_set, |
| 33 | 34 | ) |
| 34 | 35 | ); |
| 36 | + } |
|
| 35 | 37 | |
| 36 | 38 | // We need some caching support, maybe. |
| 37 | 39 | loadCacheAccelerator(); |
@@ -46,28 +48,36 @@ discard block |
||
| 46 | 48 | ) |
| 47 | 49 | ); |
| 48 | 50 | $modSettings = array(); |
| 49 | - if (!$request) |
|
| 50 | - display_db_error(); |
|
| 51 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
| 52 | - $modSettings[$row[0]] = $row[1]; |
|
| 51 | + if (!$request) { |
|
| 52 | + display_db_error(); |
|
| 53 | + } |
|
| 54 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
| 55 | + $modSettings[$row[0]] = $row[1]; |
|
| 56 | + } |
|
| 53 | 57 | $smcFunc['db_free_result']($request); |
| 54 | 58 | |
| 55 | 59 | // Do a few things to protect against missing settings or settings with invalid values... |
| 56 | - if (empty($modSettings['defaultMaxTopics']) || $modSettings['defaultMaxTopics'] <= 0 || $modSettings['defaultMaxTopics'] > 999) |
|
| 57 | - $modSettings['defaultMaxTopics'] = 20; |
|
| 58 | - if (empty($modSettings['defaultMaxMessages']) || $modSettings['defaultMaxMessages'] <= 0 || $modSettings['defaultMaxMessages'] > 999) |
|
| 59 | - $modSettings['defaultMaxMessages'] = 15; |
|
| 60 | - if (empty($modSettings['defaultMaxMembers']) || $modSettings['defaultMaxMembers'] <= 0 || $modSettings['defaultMaxMembers'] > 999) |
|
| 61 | - $modSettings['defaultMaxMembers'] = 30; |
|
| 62 | - if (empty($modSettings['defaultMaxListItems']) || $modSettings['defaultMaxListItems'] <= 0 || $modSettings['defaultMaxListItems'] > 999) |
|
| 63 | - $modSettings['defaultMaxListItems'] = 15; |
|
| 60 | + if (empty($modSettings['defaultMaxTopics']) || $modSettings['defaultMaxTopics'] <= 0 || $modSettings['defaultMaxTopics'] > 999) { |
|
| 61 | + $modSettings['defaultMaxTopics'] = 20; |
|
| 62 | + } |
|
| 63 | + if (empty($modSettings['defaultMaxMessages']) || $modSettings['defaultMaxMessages'] <= 0 || $modSettings['defaultMaxMessages'] > 999) { |
|
| 64 | + $modSettings['defaultMaxMessages'] = 15; |
|
| 65 | + } |
|
| 66 | + if (empty($modSettings['defaultMaxMembers']) || $modSettings['defaultMaxMembers'] <= 0 || $modSettings['defaultMaxMembers'] > 999) { |
|
| 67 | + $modSettings['defaultMaxMembers'] = 30; |
|
| 68 | + } |
|
| 69 | + if (empty($modSettings['defaultMaxListItems']) || $modSettings['defaultMaxListItems'] <= 0 || $modSettings['defaultMaxListItems'] > 999) { |
|
| 70 | + $modSettings['defaultMaxListItems'] = 15; |
|
| 71 | + } |
|
| 64 | 72 | |
| 65 | 73 | // We excpiclity do not use $smcFunc['json_decode'] here yet, as $smcFunc is not fully loaded. |
| 66 | - if (!is_array($modSettings['attachmentUploadDir'])) |
|
| 67 | - $modSettings['attachmentUploadDir'] = smf_json_decode($modSettings['attachmentUploadDir'], true); |
|
| 74 | + if (!is_array($modSettings['attachmentUploadDir'])) { |
|
| 75 | + $modSettings['attachmentUploadDir'] = smf_json_decode($modSettings['attachmentUploadDir'], true); |
|
| 76 | + } |
|
| 68 | 77 | |
| 69 | - if (!empty($cache_enable)) |
|
| 70 | - cache_put_data('modSettings', $modSettings, 90); |
|
| 78 | + if (!empty($cache_enable)) { |
|
| 79 | + cache_put_data('modSettings', $modSettings, 90); |
|
| 80 | + } |
|
| 71 | 81 | } |
| 72 | 82 | |
| 73 | 83 | $modSettings['cache_enable'] = $cache_enable; |
@@ -87,8 +97,9 @@ discard block |
||
| 87 | 97 | }; |
| 88 | 98 | $fix_utf8mb4 = function($string) use ($utf8, $smcFunc) |
| 89 | 99 | { |
| 90 | - if (!$utf8 || $smcFunc['db_mb4']) |
|
| 91 | - return $string; |
|
| 100 | + if (!$utf8 || $smcFunc['db_mb4']) { |
|
| 101 | + return $string; |
|
| 102 | + } |
|
| 92 | 103 | |
| 93 | 104 | $i = 0; |
| 94 | 105 | $len = strlen($string); |
@@ -100,18 +111,15 @@ discard block |
||
| 100 | 111 | { |
| 101 | 112 | $new_string .= $string[$i]; |
| 102 | 113 | $i++; |
| 103 | - } |
|
| 104 | - elseif ($ord < 224) |
|
| 114 | + } elseif ($ord < 224) |
|
| 105 | 115 | { |
| 106 | 116 | $new_string .= $string[$i] . $string[$i + 1]; |
| 107 | 117 | $i += 2; |
| 108 | - } |
|
| 109 | - elseif ($ord < 240) |
|
| 118 | + } elseif ($ord < 240) |
|
| 110 | 119 | { |
| 111 | 120 | $new_string .= $string[$i] . $string[$i + 1] . $string[$i + 2]; |
| 112 | 121 | $i += 3; |
| 113 | - } |
|
| 114 | - elseif ($ord < 248) |
|
| 122 | + } elseif ($ord < 248) |
|
| 115 | 123 | { |
| 116 | 124 | // Magic happens. |
| 117 | 125 | $val = (ord($string[$i]) & 0x07) << 18; |
@@ -155,8 +163,7 @@ discard block |
||
| 155 | 163 | { |
| 156 | 164 | $result = array_search($needle, array_slice($haystack_arr, $offset)); |
| 157 | 165 | return is_int($result) ? $result + $offset : false; |
| 158 | - } |
|
| 159 | - else |
|
| 166 | + } else |
|
| 160 | 167 | { |
| 161 | 168 | $needle_arr = preg_split('~(' . $ent_list . '|.)~' . ($utf8 ? 'u' : '') . '', $ent_check($needle), -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); |
| 162 | 169 | $needle_size = count($needle_arr); |
@@ -165,8 +172,9 @@ discard block |
||
| 165 | 172 | while ((int) $result === $result) |
| 166 | 173 | { |
| 167 | 174 | $offset += $result; |
| 168 | - if (array_slice($haystack_arr, $offset, $needle_size) === $needle_arr) |
|
| 169 | - return $offset; |
|
| 175 | + if (array_slice($haystack_arr, $offset, $needle_size) === $needle_arr) { |
|
| 176 | + return $offset; |
|
| 177 | + } |
|
| 170 | 178 | $result = array_search($needle_arr[0], array_slice($haystack_arr, ++$offset)); |
| 171 | 179 | } |
| 172 | 180 | return false; |
@@ -204,8 +212,9 @@ discard block |
||
| 204 | 212 | $string = $ent_check($string); |
| 205 | 213 | preg_match('~^(' . $ent_list . '|.){' . $smcFunc['strlen'](substr($string, 0, $length)) . '}~' . ($utf8 ? 'u' : ''), $string, $matches); |
| 206 | 214 | $string = $matches[0]; |
| 207 | - while (strlen($string) > $length) |
|
| 208 | - $string = preg_replace('~(?:' . $ent_list . '|.)$~' . ($utf8 ? 'u' : ''), '', $string); |
|
| 215 | + while (strlen($string) > $length) { |
|
| 216 | + $string = preg_replace('~(?:' . $ent_list . '|.)$~' . ($utf8 ? 'u' : ''), '', $string); |
|
| 217 | + } |
|
| 209 | 218 | return $string; |
| 210 | 219 | }, |
| 211 | 220 | 'ucfirst' => $utf8 ? function($string) use (&$smcFunc) |
@@ -215,8 +224,9 @@ discard block |
||
| 215 | 224 | 'ucwords' => $utf8 ? function($string) use (&$smcFunc) |
| 216 | 225 | { |
| 217 | 226 | $words = preg_split('~([\s\r\n\t]+)~', $string, -1, PREG_SPLIT_DELIM_CAPTURE); |
| 218 | - for ($i = 0, $n = count($words); $i < $n; $i += 2) |
|
| 219 | - $words[$i] = $smcFunc['ucfirst']($words[$i]); |
|
| 227 | + for ($i = 0, $n = count($words); $i < $n; $i += 2) { |
|
| 228 | + $words[$i] = $smcFunc['ucfirst']($words[$i]); |
|
| 229 | + } |
|
| 220 | 230 | return implode('', $words); |
| 221 | 231 | } : 'ucwords', |
| 222 | 232 | 'json_decode' => 'smf_json_decode', |
@@ -224,16 +234,17 @@ discard block |
||
| 224 | 234 | ); |
| 225 | 235 | |
| 226 | 236 | // Setting the timezone is a requirement for some functions. |
| 227 | - if (isset($modSettings['default_timezone']) && in_array($modSettings['default_timezone'], timezone_identifiers_list())) |
|
| 228 | - date_default_timezone_set($modSettings['default_timezone']); |
|
| 229 | - else |
|
| 237 | + if (isset($modSettings['default_timezone']) && in_array($modSettings['default_timezone'], timezone_identifiers_list())) { |
|
| 238 | + date_default_timezone_set($modSettings['default_timezone']); |
|
| 239 | + } else |
|
| 230 | 240 | { |
| 231 | 241 | // Get PHP's default timezone, if set |
| 232 | 242 | $ini_tz = ini_get('date.timezone'); |
| 233 | - if (!empty($ini_tz)) |
|
| 234 | - $modSettings['default_timezone'] = $ini_tz; |
|
| 235 | - else |
|
| 236 | - $modSettings['default_timezone'] = ''; |
|
| 243 | + if (!empty($ini_tz)) { |
|
| 244 | + $modSettings['default_timezone'] = $ini_tz; |
|
| 245 | + } else { |
|
| 246 | + $modSettings['default_timezone'] = ''; |
|
| 247 | + } |
|
| 237 | 248 | |
| 238 | 249 | // If date.timezone is unset, invalid, or just plain weird, make a best guess |
| 239 | 250 | if (!in_array($modSettings['default_timezone'], timezone_identifiers_list())) |
@@ -251,22 +262,26 @@ discard block |
||
| 251 | 262 | if (($modSettings['load_average'] = cache_get_data('loadavg', 90)) == null) |
| 252 | 263 | { |
| 253 | 264 | $modSettings['load_average'] = @file_get_contents('/proc/loadavg'); |
| 254 | - if (!empty($modSettings['load_average']) && preg_match('~^([^ ]+?) ([^ ]+?) ([^ ]+)~', $modSettings['load_average'], $matches) != 0) |
|
| 255 | - $modSettings['load_average'] = (float) $matches[1]; |
|
| 256 | - elseif (($modSettings['load_average'] = @`uptime`) != null && preg_match('~load average[s]?: (\d+\.\d+), (\d+\.\d+), (\d+\.\d+)~i', $modSettings['load_average'], $matches) != 0) |
|
| 257 | - $modSettings['load_average'] = (float) $matches[1]; |
|
| 258 | - else |
|
| 259 | - unset($modSettings['load_average']); |
|
| 265 | + if (!empty($modSettings['load_average']) && preg_match('~^([^ ]+?) ([^ ]+?) ([^ ]+)~', $modSettings['load_average'], $matches) != 0) { |
|
| 266 | + $modSettings['load_average'] = (float) $matches[1]; |
|
| 267 | + } elseif (($modSettings['load_average'] = @`uptime`) != null && preg_match('~load average[s]?: (\d+\.\d+), (\d+\.\d+), (\d+\.\d+)~i', $modSettings['load_average'], $matches) != 0) { |
|
| 268 | + $modSettings['load_average'] = (float) $matches[1]; |
|
| 269 | + } else { |
|
| 270 | + unset($modSettings['load_average']); |
|
| 271 | + } |
|
| 260 | 272 | |
| 261 | - if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) |
|
| 262 | - cache_put_data('loadavg', $modSettings['load_average'], 90); |
|
| 273 | + if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) { |
|
| 274 | + cache_put_data('loadavg', $modSettings['load_average'], 90); |
|
| 275 | + } |
|
| 263 | 276 | } |
| 264 | 277 | |
| 265 | - if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) |
|
| 266 | - call_integration_hook('integrate_load_average', array($modSettings['load_average'])); |
|
| 278 | + if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) { |
|
| 279 | + call_integration_hook('integrate_load_average', array($modSettings['load_average'])); |
|
| 280 | + } |
|
| 267 | 281 | |
| 268 | - if (!empty($modSettings['loadavg_forum']) && !empty($modSettings['load_average']) && $modSettings['load_average'] >= $modSettings['loadavg_forum']) |
|
| 269 | - display_loadavg_error(); |
|
| 282 | + if (!empty($modSettings['loadavg_forum']) && !empty($modSettings['load_average']) && $modSettings['load_average'] >= $modSettings['loadavg_forum']) { |
|
| 283 | + display_loadavg_error(); |
|
| 284 | + } |
|
| 270 | 285 | } |
| 271 | 286 | |
| 272 | 287 | // Is post moderation alive and well? Everywhere else assumes this has been defined, so let's make sure it is. |
@@ -287,8 +302,9 @@ discard block |
||
| 287 | 302 | if (defined('SMF_INTEGRATION_SETTINGS')) |
| 288 | 303 | { |
| 289 | 304 | $integration_settings = $smcFunc['json_decode'](SMF_INTEGRATION_SETTINGS, true); |
| 290 | - foreach ($integration_settings as $hook => $function) |
|
| 291 | - add_integration_function($hook, $function, '', false); |
|
| 305 | + foreach ($integration_settings as $hook => $function) { |
|
| 306 | + add_integration_function($hook, $function, '', false); |
|
| 307 | + } |
|
| 292 | 308 | } |
| 293 | 309 | |
| 294 | 310 | // Any files to pre include? |
@@ -298,8 +314,9 @@ discard block |
||
| 298 | 314 | foreach ($pre_includes as $include) |
| 299 | 315 | { |
| 300 | 316 | $include = strtr(trim($include), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir)); |
| 301 | - if (file_exists($include)) |
|
| 302 | - require_once($include); |
|
| 317 | + if (file_exists($include)) { |
|
| 318 | + require_once($include); |
|
| 319 | + } |
|
| 303 | 320 | } |
| 304 | 321 | } |
| 305 | 322 | |
@@ -392,9 +409,9 @@ discard block |
||
| 392 | 409 | break; |
| 393 | 410 | } |
| 394 | 411 | } |
| 412 | + } else { |
|
| 413 | + $id_member = 0; |
|
| 395 | 414 | } |
| 396 | - else |
|
| 397 | - $id_member = 0; |
|
| 398 | 415 | |
| 399 | 416 | if (empty($id_member) && isset($_COOKIE[$cookiename])) |
| 400 | 417 | { |
@@ -402,8 +419,9 @@ discard block |
||
| 402 | 419 | $cookie_data = $smcFunc['json_decode']($_COOKIE[$cookiename], true, false); |
| 403 | 420 | |
| 404 | 421 | // Legacy format (for recent 2.0 --> 2.1 upgrades) |
| 405 | - if (empty($cookie_data)) |
|
| 406 | - $cookie_data = safe_unserialize($_COOKIE[$cookiename]); |
|
| 422 | + if (empty($cookie_data)) { |
|
| 423 | + $cookie_data = safe_unserialize($_COOKIE[$cookiename]); |
|
| 424 | + } |
|
| 407 | 425 | |
| 408 | 426 | list($id_member, $password, $login_span, $cookie_domain, $cookie_path) = array_pad((array) $cookie_data, 5, ''); |
| 409 | 427 | |
@@ -411,16 +429,17 @@ discard block |
||
| 411 | 429 | |
| 412 | 430 | // Make sure the cookie is set to the correct domain and path |
| 413 | 431 | require_once($sourcedir . '/Subs-Auth.php'); |
| 414 | - if (array($cookie_domain, $cookie_path) !== url_parts(!empty($modSettings['localCookies']), !empty($modSettings['globalCookies']))) |
|
| 415 | - setLoginCookie((int) $login_span - time(), $id_member); |
|
| 416 | - } |
|
| 417 | - elseif (empty($id_member) && isset($_SESSION['login_' . $cookiename]) && ($_SESSION['USER_AGENT'] == $_SERVER['HTTP_USER_AGENT'] || !empty($modSettings['disableCheckUA']))) |
|
| 432 | + if (array($cookie_domain, $cookie_path) !== url_parts(!empty($modSettings['localCookies']), !empty($modSettings['globalCookies']))) { |
|
| 433 | + setLoginCookie((int) $login_span - time(), $id_member); |
|
| 434 | + } |
|
| 435 | + } elseif (empty($id_member) && isset($_SESSION['login_' . $cookiename]) && ($_SESSION['USER_AGENT'] == $_SERVER['HTTP_USER_AGENT'] || !empty($modSettings['disableCheckUA']))) |
|
| 418 | 436 | { |
| 419 | 437 | // @todo Perhaps we can do some more checking on this, such as on the first octet of the IP? |
| 420 | 438 | $cookie_data = $smcFunc['json_decode']($_SESSION['login_' . $cookiename], true); |
| 421 | 439 | |
| 422 | - if (empty($cookie_data)) |
|
| 423 | - $cookie_data = safe_unserialize($_SESSION['login_' . $cookiename]); |
|
| 440 | + if (empty($cookie_data)) { |
|
| 441 | + $cookie_data = safe_unserialize($_SESSION['login_' . $cookiename]); |
|
| 442 | + } |
|
| 424 | 443 | |
| 425 | 444 | list($id_member, $password, $login_span) = array_pad((array) $cookie_data, 3, ''); |
| 426 | 445 | $id_member = !empty($id_member) && strlen($password) == 128 && (int) $login_span > time() ? (int) $id_member : 0; |
@@ -445,30 +464,34 @@ discard block |
||
| 445 | 464 | $user_settings = $smcFunc['db_fetch_assoc']($request); |
| 446 | 465 | $smcFunc['db_free_result']($request); |
| 447 | 466 | |
| 448 | - if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($user_settings['avatar'], 'http://') !== false && empty($user_info['possibly_robot'])) |
|
| 449 | - $user_settings['avatar'] = get_proxied_url($user_settings['avatar']); |
|
| 467 | + if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($user_settings['avatar'], 'http://') !== false && empty($user_info['possibly_robot'])) { |
|
| 468 | + $user_settings['avatar'] = get_proxied_url($user_settings['avatar']); |
|
| 469 | + } |
|
| 450 | 470 | |
| 451 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
| 452 | - cache_put_data('user_settings-' . $id_member, $user_settings, 60); |
|
| 471 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
| 472 | + cache_put_data('user_settings-' . $id_member, $user_settings, 60); |
|
| 473 | + } |
|
| 453 | 474 | } |
| 454 | 475 | |
| 455 | 476 | // Did we find 'im? If not, junk it. |
| 456 | 477 | if (!empty($user_settings)) |
| 457 | 478 | { |
| 458 | 479 | // As much as the password should be right, we can assume the integration set things up. |
| 459 | - if (!empty($already_verified) && $already_verified === true) |
|
| 460 | - $check = true; |
|
| 480 | + if (!empty($already_verified) && $already_verified === true) { |
|
| 481 | + $check = true; |
|
| 482 | + } |
|
| 461 | 483 | // SHA-512 hash should be 128 characters long. |
| 462 | - elseif (strlen($password) == 128) |
|
| 463 | - $check = hash_salt($user_settings['passwd'], $user_settings['password_salt']) == $password; |
|
| 464 | - else |
|
| 465 | - $check = false; |
|
| 484 | + elseif (strlen($password) == 128) { |
|
| 485 | + $check = hash_salt($user_settings['passwd'], $user_settings['password_salt']) == $password; |
|
| 486 | + } else { |
|
| 487 | + $check = false; |
|
| 488 | + } |
|
| 466 | 489 | |
| 467 | 490 | // Wrong password or not activated - either way, you're going nowhere. |
| 468 | 491 | $id_member = $check && ($user_settings['is_activated'] == 1 || $user_settings['is_activated'] == 11) ? (int) $user_settings['id_member'] : 0; |
| 492 | + } else { |
|
| 493 | + $id_member = 0; |
|
| 469 | 494 | } |
| 470 | - else |
|
| 471 | - $id_member = 0; |
|
| 472 | 495 | |
| 473 | 496 | // If we no longer have the member maybe they're being all hackey, stop brute force! |
| 474 | 497 | if (!$id_member) |
@@ -497,8 +520,9 @@ discard block |
||
| 497 | 520 | |
| 498 | 521 | list ($tfamember, $tfasecret) = array_pad((array) $tfa_data, 2, ''); |
| 499 | 522 | |
| 500 | - if (!isset($tfamember, $tfasecret) || (int) $tfamember != $id_member) |
|
| 501 | - $tfasecret = null; |
|
| 523 | + if (!isset($tfamember, $tfasecret) || (int) $tfamember != $id_member) { |
|
| 524 | + $tfasecret = null; |
|
| 525 | + } |
|
| 502 | 526 | } |
| 503 | 527 | |
| 504 | 528 | // They didn't finish logging in before coming here? Then they're no one to us. |
@@ -520,10 +544,12 @@ discard block |
||
| 520 | 544 | // Are we forcing 2FA? Need to check if the user groups actually require 2FA |
| 521 | 545 | elseif (!empty($modSettings['tfa_mode']) && $modSettings['tfa_mode'] >= 2 && $id_member && empty($user_settings['tfa_secret'])) |
| 522 | 546 | { |
| 523 | - if ($modSettings['tfa_mode'] == 2) //only do this if we are just forcing SOME membergroups |
|
| 547 | + if ($modSettings['tfa_mode'] == 2) { |
|
| 548 | + //only do this if we are just forcing SOME membergroups |
|
| 524 | 549 | { |
| 525 | 550 | //Build an array of ALL user membergroups. |
| 526 | 551 | $full_groups = array($user_settings['id_group']); |
| 552 | + } |
|
| 527 | 553 | if (!empty($user_settings['additional_groups'])) |
| 528 | 554 | { |
| 529 | 555 | $full_groups = array_merge($full_groups, explode(',', $user_settings['additional_groups'])); |
@@ -543,15 +569,17 @@ discard block |
||
| 543 | 569 | ); |
| 544 | 570 | $row = $smcFunc['db_fetch_assoc']($request); |
| 545 | 571 | $smcFunc['db_free_result']($request); |
| 572 | + } else { |
|
| 573 | + $row['total'] = 1; |
|
| 546 | 574 | } |
| 547 | - else |
|
| 548 | - $row['total'] = 1; //simplifies logics in the next "if" |
|
| 575 | + //simplifies logics in the next "if" |
|
| 549 | 576 | |
| 550 | 577 | $area = !empty($_REQUEST['area']) ? $_REQUEST['area'] : ''; |
| 551 | 578 | $action = !empty($_REQUEST['action']) ? $_REQUEST['action'] : ''; |
| 552 | 579 | |
| 553 | - if ($row['total'] > 0 && !in_array($action, array('profile', 'logout')) || ($action == 'profile' && $area != 'tfasetup')) |
|
| 554 | - redirectexit('action=profile;area=tfasetup;forced'); |
|
| 580 | + if ($row['total'] > 0 && !in_array($action, array('profile', 'logout')) || ($action == 'profile' && $area != 'tfasetup')) { |
|
| 581 | + redirectexit('action=profile;area=tfasetup;forced'); |
|
| 582 | + } |
|
| 555 | 583 | } |
| 556 | 584 | } |
| 557 | 585 | |
@@ -588,33 +616,37 @@ discard block |
||
| 588 | 616 | updateMemberData($id_member, array('id_msg_last_visit' => (int) $modSettings['maxMsgID'], 'last_login' => time(), 'member_ip' => $_SERVER['REMOTE_ADDR'], 'member_ip2' => $_SERVER['BAN_CHECK_IP'])); |
| 589 | 617 | $user_settings['last_login'] = time(); |
| 590 | 618 | |
| 591 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
| 592 | - cache_put_data('user_settings-' . $id_member, $user_settings, 60); |
|
| 619 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
| 620 | + cache_put_data('user_settings-' . $id_member, $user_settings, 60); |
|
| 621 | + } |
|
| 593 | 622 | |
| 594 | - if (!empty($modSettings['cache_enable'])) |
|
| 595 | - cache_put_data('user_last_visit-' . $id_member, $_SESSION['id_msg_last_visit'], 5 * 3600); |
|
| 623 | + if (!empty($modSettings['cache_enable'])) { |
|
| 624 | + cache_put_data('user_last_visit-' . $id_member, $_SESSION['id_msg_last_visit'], 5 * 3600); |
|
| 625 | + } |
|
| 596 | 626 | } |
| 627 | + } elseif (empty($_SESSION['id_msg_last_visit'])) { |
|
| 628 | + $_SESSION['id_msg_last_visit'] = $user_settings['id_msg_last_visit']; |
|
| 597 | 629 | } |
| 598 | - elseif (empty($_SESSION['id_msg_last_visit'])) |
|
| 599 | - $_SESSION['id_msg_last_visit'] = $user_settings['id_msg_last_visit']; |
|
| 600 | 630 | |
| 601 | 631 | $username = $user_settings['member_name']; |
| 602 | 632 | |
| 603 | - if (empty($user_settings['additional_groups'])) |
|
| 604 | - $user_info = array( |
|
| 633 | + if (empty($user_settings['additional_groups'])) { |
|
| 634 | + $user_info = array( |
|
| 605 | 635 | 'groups' => array($user_settings['id_group'], $user_settings['id_post_group']) |
| 606 | 636 | ); |
| 607 | - else |
|
| 608 | - $user_info = array( |
|
| 637 | + } else { |
|
| 638 | + $user_info = array( |
|
| 609 | 639 | 'groups' => array_merge( |
| 610 | 640 | array($user_settings['id_group'], $user_settings['id_post_group']), |
| 611 | 641 | explode(',', $user_settings['additional_groups']) |
| 612 | 642 | ) |
| 613 | 643 | ); |
| 644 | + } |
|
| 614 | 645 | |
| 615 | 646 | // Because history has proven that it is possible for groups to go bad - clean up in case. |
| 616 | - foreach ($user_info['groups'] as $k => $v) |
|
| 617 | - $user_info['groups'][$k] = (int) $v; |
|
| 647 | + foreach ($user_info['groups'] as $k => $v) { |
|
| 648 | + $user_info['groups'][$k] = (int) $v; |
|
| 649 | + } |
|
| 618 | 650 | |
| 619 | 651 | // This is a logged in user, so definitely not a spider. |
| 620 | 652 | $user_info['possibly_robot'] = false; |
@@ -628,8 +660,7 @@ discard block |
||
| 628 | 660 | $time_system = new DateTime('now', $tz_system); |
| 629 | 661 | $time_user = new DateTime('now', $tz_user); |
| 630 | 662 | $user_info['time_offset'] = ($tz_user->getOffset($time_user) - $tz_system->getOffset($time_system)) / 3600; |
| 631 | - } |
|
| 632 | - else |
|
| 663 | + } else |
|
| 633 | 664 | { |
| 634 | 665 | // !!! Compatibility. |
| 635 | 666 | $user_info['time_offset'] = empty($user_settings['time_offset']) ? 0 : $user_settings['time_offset']; |
@@ -643,8 +674,9 @@ discard block |
||
| 643 | 674 | $user_info = array('groups' => array(-1)); |
| 644 | 675 | $user_settings = array(); |
| 645 | 676 | |
| 646 | - if (isset($_COOKIE[$cookiename]) && empty($context['tfa_member'])) |
|
| 647 | - $_COOKIE[$cookiename] = ''; |
|
| 677 | + if (isset($_COOKIE[$cookiename]) && empty($context['tfa_member'])) { |
|
| 678 | + $_COOKIE[$cookiename] = ''; |
|
| 679 | + } |
|
| 648 | 680 | |
| 649 | 681 | // Expire the 2FA cookie |
| 650 | 682 | if (isset($_COOKIE[$cookiename . '_tfa']) && empty($context['tfa_member'])) |
@@ -661,19 +693,20 @@ discard block |
||
| 661 | 693 | } |
| 662 | 694 | |
| 663 | 695 | // Create a login token if it doesn't exist yet. |
| 664 | - if (!isset($_SESSION['token']['post-login'])) |
|
| 665 | - createToken('login'); |
|
| 666 | - else |
|
| 667 | - list ($context['login_token_var'],,, $context['login_token']) = $_SESSION['token']['post-login']; |
|
| 696 | + if (!isset($_SESSION['token']['post-login'])) { |
|
| 697 | + createToken('login'); |
|
| 698 | + } else { |
|
| 699 | + list ($context['login_token_var'],,, $context['login_token']) = $_SESSION['token']['post-login']; |
|
| 700 | + } |
|
| 668 | 701 | |
| 669 | 702 | // Do we perhaps think this is a search robot? Check every five minutes just in case... |
| 670 | 703 | if ((!empty($modSettings['spider_mode']) || !empty($modSettings['spider_group'])) && (!isset($_SESSION['robot_check']) || $_SESSION['robot_check'] < time() - 300)) |
| 671 | 704 | { |
| 672 | 705 | require_once($sourcedir . '/ManageSearchEngines.php'); |
| 673 | 706 | $user_info['possibly_robot'] = SpiderCheck(); |
| 707 | + } elseif (!empty($modSettings['spider_mode'])) { |
|
| 708 | + $user_info['possibly_robot'] = isset($_SESSION['id_robot']) ? $_SESSION['id_robot'] : 0; |
|
| 674 | 709 | } |
| 675 | - elseif (!empty($modSettings['spider_mode'])) |
|
| 676 | - $user_info['possibly_robot'] = isset($_SESSION['id_robot']) ? $_SESSION['id_robot'] : 0; |
|
| 677 | 710 | // If we haven't turned on proper spider hunts then have a guess! |
| 678 | 711 | else |
| 679 | 712 | { |
@@ -721,8 +754,9 @@ discard block |
||
| 721 | 754 | $user_info['groups'] = array_unique($user_info['groups']); |
| 722 | 755 | |
| 723 | 756 | // Make sure that the last item in the ignore boards array is valid. If the list was too long it could have an ending comma that could cause problems. |
| 724 | - if (!empty($user_info['ignoreboards']) && empty($user_info['ignoreboards'][$tmp = count($user_info['ignoreboards']) - 1])) |
|
| 725 | - unset($user_info['ignoreboards'][$tmp]); |
|
| 757 | + if (!empty($user_info['ignoreboards']) && empty($user_info['ignoreboards'][$tmp = count($user_info['ignoreboards']) - 1])) { |
|
| 758 | + unset($user_info['ignoreboards'][$tmp]); |
|
| 759 | + } |
|
| 726 | 760 | |
| 727 | 761 | // Allow the user to change their language. |
| 728 | 762 | if (!empty($modSettings['userLanguage'])) |
@@ -735,13 +769,14 @@ discard block |
||
| 735 | 769 | $user_info['language'] = strtr($_GET['language'], './\\:', '____'); |
| 736 | 770 | |
| 737 | 771 | // Make it permanent for members. |
| 738 | - if (!empty($user_info['id'])) |
|
| 739 | - updateMemberData($user_info['id'], array('lngfile' => $user_info['language'])); |
|
| 740 | - else |
|
| 741 | - $_SESSION['language'] = $user_info['language']; |
|
| 772 | + if (!empty($user_info['id'])) { |
|
| 773 | + updateMemberData($user_info['id'], array('lngfile' => $user_info['language'])); |
|
| 774 | + } else { |
|
| 775 | + $_SESSION['language'] = $user_info['language']; |
|
| 776 | + } |
|
| 777 | + } elseif (!empty($_SESSION['language']) && isset($languages[strtr($_SESSION['language'], './\\:', '____')])) { |
|
| 778 | + $user_info['language'] = strtr($_SESSION['language'], './\\:', '____'); |
|
| 742 | 779 | } |
| 743 | - elseif (!empty($_SESSION['language']) && isset($languages[strtr($_SESSION['language'], './\\:', '____')])) |
|
| 744 | - $user_info['language'] = strtr($_SESSION['language'], './\\:', '____'); |
|
| 745 | 780 | } |
| 746 | 781 | |
| 747 | 782 | $temp = build_query_board($user_info['id']); |
@@ -804,9 +839,9 @@ discard block |
||
| 804 | 839 | } |
| 805 | 840 | |
| 806 | 841 | // Remember redirection is the key to avoiding fallout from your bosses. |
| 807 | - if (!empty($topic)) |
|
| 808 | - redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg']); |
|
| 809 | - else |
|
| 842 | + if (!empty($topic)) { |
|
| 843 | + redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg']); |
|
| 844 | + } else |
|
| 810 | 845 | { |
| 811 | 846 | loadPermissions(); |
| 812 | 847 | loadTheme(); |
@@ -824,10 +859,11 @@ discard block |
||
| 824 | 859 | if (!empty($modSettings['cache_enable']) && (empty($topic) || $modSettings['cache_enable'] >= 3)) |
| 825 | 860 | { |
| 826 | 861 | // @todo SLOW? |
| 827 | - if (!empty($topic)) |
|
| 828 | - $temp = cache_get_data('topic_board-' . $topic, 120); |
|
| 829 | - else |
|
| 830 | - $temp = cache_get_data('board-' . $board, 120); |
|
| 862 | + if (!empty($topic)) { |
|
| 863 | + $temp = cache_get_data('topic_board-' . $topic, 120); |
|
| 864 | + } else { |
|
| 865 | + $temp = cache_get_data('board-' . $board, 120); |
|
| 866 | + } |
|
| 831 | 867 | |
| 832 | 868 | if (!empty($temp)) |
| 833 | 869 | { |
@@ -865,8 +901,9 @@ discard block |
||
| 865 | 901 | $row = $smcFunc['db_fetch_assoc']($request); |
| 866 | 902 | |
| 867 | 903 | // Set the current board. |
| 868 | - if (!empty($row['id_board'])) |
|
| 869 | - $board = $row['id_board']; |
|
| 904 | + if (!empty($row['id_board'])) { |
|
| 905 | + $board = $row['id_board']; |
|
| 906 | + } |
|
| 870 | 907 | |
| 871 | 908 | // Basic operating information. (globals... :/) |
| 872 | 909 | $board_info = array( |
@@ -902,21 +939,23 @@ discard block |
||
| 902 | 939 | |
| 903 | 940 | do |
| 904 | 941 | { |
| 905 | - if (!empty($row['id_moderator'])) |
|
| 906 | - $board_info['moderators'][$row['id_moderator']] = array( |
|
| 942 | + if (!empty($row['id_moderator'])) { |
|
| 943 | + $board_info['moderators'][$row['id_moderator']] = array( |
|
| 907 | 944 | 'id' => $row['id_moderator'], |
| 908 | 945 | 'name' => $row['real_name'], |
| 909 | 946 | 'href' => $scripturl . '?action=profile;u=' . $row['id_moderator'], |
| 910 | 947 | 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_moderator'] . '">' . $row['real_name'] . '</a>' |
| 911 | 948 | ); |
| 949 | + } |
|
| 912 | 950 | |
| 913 | - if (!empty($row['id_moderator_group'])) |
|
| 914 | - $board_info['moderator_groups'][$row['id_moderator_group']] = array( |
|
| 951 | + if (!empty($row['id_moderator_group'])) { |
|
| 952 | + $board_info['moderator_groups'][$row['id_moderator_group']] = array( |
|
| 915 | 953 | 'id' => $row['id_moderator_group'], |
| 916 | 954 | 'name' => $row['group_name'], |
| 917 | 955 | 'href' => $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'], |
| 918 | 956 | 'link' => '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'] . '">' . $row['group_name'] . '</a>' |
| 919 | 957 | ); |
| 958 | + } |
|
| 920 | 959 | } |
| 921 | 960 | while ($row = $smcFunc['db_fetch_assoc']($request)); |
| 922 | 961 | |
@@ -948,12 +987,12 @@ discard block |
||
| 948 | 987 | if (!empty($modSettings['cache_enable']) && (empty($topic) || $modSettings['cache_enable'] >= 3)) |
| 949 | 988 | { |
| 950 | 989 | // @todo SLOW? |
| 951 | - if (!empty($topic)) |
|
| 952 | - cache_put_data('topic_board-' . $topic, $board_info, 120); |
|
| 990 | + if (!empty($topic)) { |
|
| 991 | + cache_put_data('topic_board-' . $topic, $board_info, 120); |
|
| 992 | + } |
|
| 953 | 993 | cache_put_data('board-' . $board, $board_info, 120); |
| 954 | 994 | } |
| 955 | - } |
|
| 956 | - else |
|
| 995 | + } else |
|
| 957 | 996 | { |
| 958 | 997 | // Otherwise the topic is invalid, there are no moderators, etc. |
| 959 | 998 | $board_info = array( |
@@ -967,8 +1006,9 @@ discard block |
||
| 967 | 1006 | $smcFunc['db_free_result']($request); |
| 968 | 1007 | } |
| 969 | 1008 | |
| 970 | - if (!empty($topic)) |
|
| 971 | - $_GET['board'] = (int) $board; |
|
| 1009 | + if (!empty($topic)) { |
|
| 1010 | + $_GET['board'] = (int) $board; |
|
| 1011 | + } |
|
| 972 | 1012 | |
| 973 | 1013 | if (!empty($board)) |
| 974 | 1014 | { |
@@ -978,10 +1018,12 @@ discard block |
||
| 978 | 1018 | // Now check if the user is a moderator. |
| 979 | 1019 | $user_info['is_mod'] = isset($board_info['moderators'][$user_info['id']]) || count(array_intersect($user_info['groups'], $moderator_groups)) != 0; |
| 980 | 1020 | |
| 981 | - if (count(array_intersect($user_info['groups'], $board_info['groups'])) == 0 && !$user_info['is_admin']) |
|
| 982 | - $board_info['error'] = 'access'; |
|
| 983 | - if (!empty($modSettings['deny_boards_access']) && count(array_intersect($user_info['groups'], $board_info['deny_groups'])) != 0 && !$user_info['is_admin']) |
|
| 984 | - $board_info['error'] = 'access'; |
|
| 1021 | + if (count(array_intersect($user_info['groups'], $board_info['groups'])) == 0 && !$user_info['is_admin']) { |
|
| 1022 | + $board_info['error'] = 'access'; |
|
| 1023 | + } |
|
| 1024 | + if (!empty($modSettings['deny_boards_access']) && count(array_intersect($user_info['groups'], $board_info['deny_groups'])) != 0 && !$user_info['is_admin']) { |
|
| 1025 | + $board_info['error'] = 'access'; |
|
| 1026 | + } |
|
| 985 | 1027 | |
| 986 | 1028 | // Build up the linktree. |
| 987 | 1029 | $context['linktree'] = array_merge( |
@@ -1004,8 +1046,9 @@ discard block |
||
| 1004 | 1046 | $context['current_board'] = $board; |
| 1005 | 1047 | |
| 1006 | 1048 | // No posting in redirection boards! |
| 1007 | - if (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'post' && !empty($board_info['redirect'])) |
|
| 1008 | - $board_info['error'] == 'post_in_redirect'; |
|
| 1049 | + if (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'post' && !empty($board_info['redirect'])) { |
|
| 1050 | + $board_info['error'] == 'post_in_redirect'; |
|
| 1051 | + } |
|
| 1009 | 1052 | |
| 1010 | 1053 | // Hacker... you can't see this topic, I'll tell you that. (but moderators can!) |
| 1011 | 1054 | if (!empty($board_info['error']) && (!empty($modSettings['deny_boards_access']) || $board_info['error'] != 'access' || !$user_info['is_mod'])) |
@@ -1031,24 +1074,23 @@ discard block |
||
| 1031 | 1074 | ob_end_clean(); |
| 1032 | 1075 | header('HTTP/1.1 403 Forbidden'); |
| 1033 | 1076 | die; |
| 1034 | - } |
|
| 1035 | - elseif ($board_info['error'] == 'post_in_redirect') |
|
| 1077 | + } elseif ($board_info['error'] == 'post_in_redirect') |
|
| 1036 | 1078 | { |
| 1037 | 1079 | // Slightly different error message here... |
| 1038 | 1080 | fatal_lang_error('cannot_post_redirect', false); |
| 1039 | - } |
|
| 1040 | - elseif ($user_info['is_guest']) |
|
| 1081 | + } elseif ($user_info['is_guest']) |
|
| 1041 | 1082 | { |
| 1042 | 1083 | loadLanguage('Errors'); |
| 1043 | 1084 | is_not_guest($txt['topic_gone']); |
| 1085 | + } else { |
|
| 1086 | + fatal_lang_error('topic_gone', false); |
|
| 1044 | 1087 | } |
| 1045 | - else |
|
| 1046 | - fatal_lang_error('topic_gone', false); |
|
| 1047 | 1088 | } |
| 1048 | 1089 | |
| 1049 | - if ($user_info['is_mod']) |
|
| 1050 | - $user_info['groups'][] = 3; |
|
| 1051 | -} |
|
| 1090 | + if ($user_info['is_mod']) { |
|
| 1091 | + $user_info['groups'][] = 3; |
|
| 1092 | + } |
|
| 1093 | + } |
|
| 1052 | 1094 | |
| 1053 | 1095 | /** |
| 1054 | 1096 | * Load this user's permissions. |
@@ -1069,8 +1111,9 @@ discard block |
||
| 1069 | 1111 | asort($cache_groups); |
| 1070 | 1112 | $cache_groups = implode(',', $cache_groups); |
| 1071 | 1113 | // If it's a spider then cache it different. |
| 1072 | - if ($user_info['possibly_robot']) |
|
| 1073 | - $cache_groups .= '-spider'; |
|
| 1114 | + if ($user_info['possibly_robot']) { |
|
| 1115 | + $cache_groups .= '-spider'; |
|
| 1116 | + } |
|
| 1074 | 1117 | |
| 1075 | 1118 | if ($modSettings['cache_enable'] >= 2 && !empty($board) && ($temp = cache_get_data('permissions:' . $cache_groups . ':' . $board, 240)) != null && time() - 240 > $modSettings['settings_updated']) |
| 1076 | 1119 | { |
@@ -1078,9 +1121,9 @@ discard block |
||
| 1078 | 1121 | banPermissions(); |
| 1079 | 1122 | |
| 1080 | 1123 | return; |
| 1124 | + } elseif (($temp = cache_get_data('permissions:' . $cache_groups, 240)) != null && time() - 240 > $modSettings['settings_updated']) { |
|
| 1125 | + list ($user_info['permissions'], $removals) = $temp; |
|
| 1081 | 1126 | } |
| 1082 | - elseif (($temp = cache_get_data('permissions:' . $cache_groups, 240)) != null && time() - 240 > $modSettings['settings_updated']) |
|
| 1083 | - list ($user_info['permissions'], $removals) = $temp; |
|
| 1084 | 1127 | } |
| 1085 | 1128 | |
| 1086 | 1129 | // If it is detected as a robot, and we are restricting permissions as a special group - then implement this. |
@@ -1102,23 +1145,26 @@ discard block |
||
| 1102 | 1145 | $removals = array(); |
| 1103 | 1146 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1104 | 1147 | { |
| 1105 | - if (empty($row['add_deny'])) |
|
| 1106 | - $removals[] = $row['permission']; |
|
| 1107 | - else |
|
| 1108 | - $user_info['permissions'][] = $row['permission']; |
|
| 1148 | + if (empty($row['add_deny'])) { |
|
| 1149 | + $removals[] = $row['permission']; |
|
| 1150 | + } else { |
|
| 1151 | + $user_info['permissions'][] = $row['permission']; |
|
| 1152 | + } |
|
| 1109 | 1153 | } |
| 1110 | 1154 | $smcFunc['db_free_result']($request); |
| 1111 | 1155 | |
| 1112 | - if (isset($cache_groups)) |
|
| 1113 | - cache_put_data('permissions:' . $cache_groups, array($user_info['permissions'], $removals), 240); |
|
| 1156 | + if (isset($cache_groups)) { |
|
| 1157 | + cache_put_data('permissions:' . $cache_groups, array($user_info['permissions'], $removals), 240); |
|
| 1158 | + } |
|
| 1114 | 1159 | } |
| 1115 | 1160 | |
| 1116 | 1161 | // Get the board permissions. |
| 1117 | 1162 | if (!empty($board)) |
| 1118 | 1163 | { |
| 1119 | 1164 | // Make sure the board (if any) has been loaded by loadBoard(). |
| 1120 | - if (!isset($board_info['profile'])) |
|
| 1121 | - fatal_lang_error('no_board'); |
|
| 1165 | + if (!isset($board_info['profile'])) { |
|
| 1166 | + fatal_lang_error('no_board'); |
|
| 1167 | + } |
|
| 1122 | 1168 | |
| 1123 | 1169 | $request = $smcFunc['db_query']('', ' |
| 1124 | 1170 | SELECT permission, add_deny |
@@ -1134,20 +1180,23 @@ discard block |
||
| 1134 | 1180 | ); |
| 1135 | 1181 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1136 | 1182 | { |
| 1137 | - if (empty($row['add_deny'])) |
|
| 1138 | - $removals[] = $row['permission']; |
|
| 1139 | - else |
|
| 1140 | - $user_info['permissions'][] = $row['permission']; |
|
| 1183 | + if (empty($row['add_deny'])) { |
|
| 1184 | + $removals[] = $row['permission']; |
|
| 1185 | + } else { |
|
| 1186 | + $user_info['permissions'][] = $row['permission']; |
|
| 1187 | + } |
|
| 1141 | 1188 | } |
| 1142 | 1189 | $smcFunc['db_free_result']($request); |
| 1143 | 1190 | } |
| 1144 | 1191 | |
| 1145 | 1192 | // Remove all the permissions they shouldn't have ;). |
| 1146 | - if (!empty($modSettings['permission_enable_deny'])) |
|
| 1147 | - $user_info['permissions'] = array_diff($user_info['permissions'], $removals); |
|
| 1193 | + if (!empty($modSettings['permission_enable_deny'])) { |
|
| 1194 | + $user_info['permissions'] = array_diff($user_info['permissions'], $removals); |
|
| 1195 | + } |
|
| 1148 | 1196 | |
| 1149 | - if (isset($cache_groups) && !empty($board) && $modSettings['cache_enable'] >= 2) |
|
| 1150 | - cache_put_data('permissions:' . $cache_groups . ':' . $board, array($user_info['permissions'], null), 240); |
|
| 1197 | + if (isset($cache_groups) && !empty($board) && $modSettings['cache_enable'] >= 2) { |
|
| 1198 | + cache_put_data('permissions:' . $cache_groups . ':' . $board, array($user_info['permissions'], null), 240); |
|
| 1199 | + } |
|
| 1151 | 1200 | |
| 1152 | 1201 | // Banned? Watch, don't touch.. |
| 1153 | 1202 | banPermissions(); |
@@ -1159,17 +1208,18 @@ discard block |
||
| 1159 | 1208 | { |
| 1160 | 1209 | require_once($sourcedir . '/Subs-Auth.php'); |
| 1161 | 1210 | rebuildModCache(); |
| 1211 | + } else { |
|
| 1212 | + $user_info['mod_cache'] = $_SESSION['mc']; |
|
| 1162 | 1213 | } |
| 1163 | - else |
|
| 1164 | - $user_info['mod_cache'] = $_SESSION['mc']; |
|
| 1165 | 1214 | |
| 1166 | 1215 | // This is a useful phantom permission added to the current user, and only the current user while they are logged in. |
| 1167 | 1216 | // For example this drastically simplifies certain changes to the profile area. |
| 1168 | 1217 | $user_info['permissions'][] = 'is_not_guest'; |
| 1169 | 1218 | // And now some backwards compatibility stuff for mods and whatnot that aren't expecting the new permissions. |
| 1170 | 1219 | $user_info['permissions'][] = 'profile_view_own'; |
| 1171 | - if (in_array('profile_view', $user_info['permissions'])) |
|
| 1172 | - $user_info['permissions'][] = 'profile_view_any'; |
|
| 1220 | + if (in_array('profile_view', $user_info['permissions'])) { |
|
| 1221 | + $user_info['permissions'][] = 'profile_view_any'; |
|
| 1222 | + } |
|
| 1173 | 1223 | } |
| 1174 | 1224 | } |
| 1175 | 1225 | |
@@ -1187,8 +1237,9 @@ discard block |
||
| 1187 | 1237 | global $image_proxy_enabled, $boardurl, $user_info; |
| 1188 | 1238 | |
| 1189 | 1239 | // Can't just look for no users :P. |
| 1190 | - if (empty($users)) |
|
| 1191 | - return array(); |
|
| 1240 | + if (empty($users)) { |
|
| 1241 | + return array(); |
|
| 1242 | + } |
|
| 1192 | 1243 | |
| 1193 | 1244 | // Pass the set value |
| 1194 | 1245 | $context['loadMemberContext_set'] = $set; |
@@ -1203,8 +1254,9 @@ discard block |
||
| 1203 | 1254 | for ($i = 0, $n = count($users); $i < $n; $i++) |
| 1204 | 1255 | { |
| 1205 | 1256 | $data = cache_get_data('member_data-' . $set . '-' . $users[$i], 240); |
| 1206 | - if ($data == null) |
|
| 1207 | - continue; |
|
| 1257 | + if ($data == null) { |
|
| 1258 | + continue; |
|
| 1259 | + } |
|
| 1208 | 1260 | |
| 1209 | 1261 | $loaded_ids[] = $data['id_member']; |
| 1210 | 1262 | $user_profile[$data['id_member']] = $data; |
@@ -1271,16 +1323,19 @@ discard block |
||
| 1271 | 1323 | $row['avatar_original'] = !empty($row['avatar']) ? $row['avatar'] : ''; |
| 1272 | 1324 | |
| 1273 | 1325 | // Take care of proxying avatar if required, do this here for maximum reach |
| 1274 | - if ($image_proxy_enabled && !empty($row['avatar']) && stripos($row['avatar'], 'http://') !== false && empty($user_info['possibly_robot'])) |
|
| 1275 | - $row['avatar'] = get_proxied_url($row['avatar']); |
|
| 1326 | + if ($image_proxy_enabled && !empty($row['avatar']) && stripos($row['avatar'], 'http://') !== false && empty($user_info['possibly_robot'])) { |
|
| 1327 | + $row['avatar'] = get_proxied_url($row['avatar']); |
|
| 1328 | + } |
|
| 1276 | 1329 | |
| 1277 | 1330 | // Keep track of the member's normal member group |
| 1278 | 1331 | $row['primary_group'] = $row['member_group']; |
| 1279 | 1332 | |
| 1280 | - if (isset($row['member_ip'])) |
|
| 1281 | - $row['member_ip'] = inet_dtop($row['member_ip']); |
|
| 1282 | - if (isset($row['member_ip2'])) |
|
| 1283 | - $row['member_ip2'] = inet_dtop($row['member_ip2']); |
|
| 1333 | + if (isset($row['member_ip'])) { |
|
| 1334 | + $row['member_ip'] = inet_dtop($row['member_ip']); |
|
| 1335 | + } |
|
| 1336 | + if (isset($row['member_ip2'])) { |
|
| 1337 | + $row['member_ip2'] = inet_dtop($row['member_ip2']); |
|
| 1338 | + } |
|
| 1284 | 1339 | $new_loaded_ids[] = $row['id_member']; |
| 1285 | 1340 | $loaded_ids[] = $row['id_member']; |
| 1286 | 1341 | $row['options'] = array(); |
@@ -1299,8 +1354,9 @@ discard block |
||
| 1299 | 1354 | 'loaded_ids' => $new_loaded_ids, |
| 1300 | 1355 | ) |
| 1301 | 1356 | ); |
| 1302 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1303 | - $user_profile[$row['id_member']]['options'][$row['variable']] = $row['value']; |
|
| 1357 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1358 | + $user_profile[$row['id_member']]['options'][$row['variable']] = $row['value']; |
|
| 1359 | + } |
|
| 1304 | 1360 | $smcFunc['db_free_result']($request); |
| 1305 | 1361 | } |
| 1306 | 1362 | |
@@ -1311,10 +1367,11 @@ discard block |
||
| 1311 | 1367 | { |
| 1312 | 1368 | foreach ($loaded_ids as $a_member) |
| 1313 | 1369 | { |
| 1314 | - if (!empty($user_profile[$a_member]['additional_groups'])) |
|
| 1315 | - $groups = array_merge(array($user_profile[$a_member]['id_group']), explode(',', $user_profile[$a_member]['additional_groups'])); |
|
| 1316 | - else |
|
| 1317 | - $groups = array($user_profile[$a_member]['id_group']); |
|
| 1370 | + if (!empty($user_profile[$a_member]['additional_groups'])) { |
|
| 1371 | + $groups = array_merge(array($user_profile[$a_member]['id_group']), explode(',', $user_profile[$a_member]['additional_groups'])); |
|
| 1372 | + } else { |
|
| 1373 | + $groups = array($user_profile[$a_member]['id_group']); |
|
| 1374 | + } |
|
| 1318 | 1375 | |
| 1319 | 1376 | $temp = array_intersect($groups, array_keys($board_info['moderator_groups'])); |
| 1320 | 1377 | |
@@ -1327,8 +1384,9 @@ discard block |
||
| 1327 | 1384 | |
| 1328 | 1385 | if (!empty($new_loaded_ids) && !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 3) |
| 1329 | 1386 | { |
| 1330 | - for ($i = 0, $n = count($new_loaded_ids); $i < $n; $i++) |
|
| 1331 | - cache_put_data('member_data-' . $set . '-' . $new_loaded_ids[$i], $user_profile[$new_loaded_ids[$i]], 240); |
|
| 1387 | + for ($i = 0, $n = count($new_loaded_ids); $i < $n; $i++) { |
|
| 1388 | + cache_put_data('member_data-' . $set . '-' . $new_loaded_ids[$i], $user_profile[$new_loaded_ids[$i]], 240); |
|
| 1389 | + } |
|
| 1332 | 1390 | } |
| 1333 | 1391 | |
| 1334 | 1392 | // Are we loading any moderators? If so, fix their group data... |
@@ -1354,14 +1412,17 @@ discard block |
||
| 1354 | 1412 | foreach ($temp_mods as $id) |
| 1355 | 1413 | { |
| 1356 | 1414 | // By popular demand, don't show admins or global moderators as moderators. |
| 1357 | - if ($user_profile[$id]['id_group'] != 1 && $user_profile[$id]['id_group'] != 2) |
|
| 1358 | - $user_profile[$id]['member_group'] = $row['member_group']; |
|
| 1415 | + if ($user_profile[$id]['id_group'] != 1 && $user_profile[$id]['id_group'] != 2) { |
|
| 1416 | + $user_profile[$id]['member_group'] = $row['member_group']; |
|
| 1417 | + } |
|
| 1359 | 1418 | |
| 1360 | 1419 | // If the Moderator group has no color or icons, but their group does... don't overwrite. |
| 1361 | - if (!empty($row['icons'])) |
|
| 1362 | - $user_profile[$id]['icons'] = $row['icons']; |
|
| 1363 | - if (!empty($row['member_group_color'])) |
|
| 1364 | - $user_profile[$id]['member_group_color'] = $row['member_group_color']; |
|
| 1420 | + if (!empty($row['icons'])) { |
|
| 1421 | + $user_profile[$id]['icons'] = $row['icons']; |
|
| 1422 | + } |
|
| 1423 | + if (!empty($row['member_group_color'])) { |
|
| 1424 | + $user_profile[$id]['member_group_color'] = $row['member_group_color']; |
|
| 1425 | + } |
|
| 1365 | 1426 | } |
| 1366 | 1427 | } |
| 1367 | 1428 | |
@@ -1383,12 +1444,14 @@ discard block |
||
| 1383 | 1444 | static $loadedLanguages = array(); |
| 1384 | 1445 | |
| 1385 | 1446 | // If this person's data is already loaded, skip it. |
| 1386 | - if (isset($dataLoaded[$user])) |
|
| 1387 | - return true; |
|
| 1447 | + if (isset($dataLoaded[$user])) { |
|
| 1448 | + return true; |
|
| 1449 | + } |
|
| 1388 | 1450 | |
| 1389 | 1451 | // We can't load guests or members not loaded by loadMemberData()! |
| 1390 | - if ($user == 0) |
|
| 1391 | - return false; |
|
| 1452 | + if ($user == 0) { |
|
| 1453 | + return false; |
|
| 1454 | + } |
|
| 1392 | 1455 | if (!isset($user_profile[$user])) |
| 1393 | 1456 | { |
| 1394 | 1457 | trigger_error('loadMemberContext(): member id ' . $user . ' not previously loaded by loadMemberData()', E_USER_WARNING); |
@@ -1414,12 +1477,16 @@ discard block |
||
| 1414 | 1477 | $buddy_list = !empty($profile['buddy_list']) ? explode(',', $profile['buddy_list']) : array(); |
| 1415 | 1478 | |
| 1416 | 1479 | //We need a little fallback for the membergroup icons. If it doesn't exist in the current theme, fallback to default theme |
| 1417 | - if (isset($profile['icons'][1]) && file_exists($settings['actual_theme_dir'] . '/images/membericons/' . $profile['icons'][1])) //icon is set and exists |
|
| 1480 | + if (isset($profile['icons'][1]) && file_exists($settings['actual_theme_dir'] . '/images/membericons/' . $profile['icons'][1])) { |
|
| 1481 | + //icon is set and exists |
|
| 1418 | 1482 | $group_icon_url = $settings['images_url'] . '/membericons/' . $profile['icons'][1]; |
| 1419 | - elseif (isset($profile['icons'][1])) //icon is set and doesn't exist, fallback to default |
|
| 1483 | + } elseif (isset($profile['icons'][1])) { |
|
| 1484 | + //icon is set and doesn't exist, fallback to default |
|
| 1420 | 1485 | $group_icon_url = $settings['default_images_url'] . '/membericons/' . $profile['icons'][1]; |
| 1421 | - else //not set, bye bye |
|
| 1486 | + } else { |
|
| 1487 | + //not set, bye bye |
|
| 1422 | 1488 | $group_icon_url = ''; |
| 1489 | + } |
|
| 1423 | 1490 | |
| 1424 | 1491 | // These minimal values are always loaded |
| 1425 | 1492 | $memberContext[$user] = array( |
@@ -1438,8 +1505,9 @@ discard block |
||
| 1438 | 1505 | if ($context['loadMemberContext_set'] != 'minimal') |
| 1439 | 1506 | { |
| 1440 | 1507 | // Go the extra mile and load the user's native language name. |
| 1441 | - if (empty($loadedLanguages)) |
|
| 1442 | - $loadedLanguages = getLanguages(); |
|
| 1508 | + if (empty($loadedLanguages)) { |
|
| 1509 | + $loadedLanguages = getLanguages(); |
|
| 1510 | + } |
|
| 1443 | 1511 | |
| 1444 | 1512 | $memberContext[$user] += array( |
| 1445 | 1513 | 'username_color' => '<span ' . (!empty($profile['member_group_color']) ? 'style="color:' . $profile['member_group_color'] . ';"' : '') . '>' . $profile['member_name'] . '</span>', |
@@ -1494,31 +1562,33 @@ discard block |
||
| 1494 | 1562 | { |
| 1495 | 1563 | if (!empty($modSettings['gravatarOverride']) || (!empty($modSettings['gravatarEnabled']) && stristr($profile['avatar'], 'gravatar://'))) |
| 1496 | 1564 | { |
| 1497 | - if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($profile['avatar'], 'gravatar://') && strlen($profile['avatar']) > 11) |
|
| 1498 | - $image = get_gravatar_url($smcFunc['substr']($profile['avatar'], 11)); |
|
| 1499 | - else |
|
| 1500 | - $image = get_gravatar_url($profile['email_address']); |
|
| 1501 | - } |
|
| 1502 | - else |
|
| 1565 | + if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($profile['avatar'], 'gravatar://') && strlen($profile['avatar']) > 11) { |
|
| 1566 | + $image = get_gravatar_url($smcFunc['substr']($profile['avatar'], 11)); |
|
| 1567 | + } else { |
|
| 1568 | + $image = get_gravatar_url($profile['email_address']); |
|
| 1569 | + } |
|
| 1570 | + } else |
|
| 1503 | 1571 | { |
| 1504 | 1572 | // So it's stored in the member table? |
| 1505 | 1573 | if (!empty($profile['avatar'])) |
| 1506 | 1574 | { |
| 1507 | 1575 | $image = (stristr($profile['avatar'], 'http://') || stristr($profile['avatar'], 'https://')) ? $profile['avatar'] : $modSettings['avatar_url'] . '/' . $profile['avatar']; |
| 1576 | + } elseif (!empty($profile['filename'])) { |
|
| 1577 | + $image = $modSettings['custom_avatar_url'] . '/' . $profile['filename']; |
|
| 1508 | 1578 | } |
| 1509 | - elseif (!empty($profile['filename'])) |
|
| 1510 | - $image = $modSettings['custom_avatar_url'] . '/' . $profile['filename']; |
|
| 1511 | 1579 | // Right... no avatar...use the default one |
| 1512 | - else |
|
| 1513 | - $image = $modSettings['avatar_url'] . '/default.png'; |
|
| 1580 | + else { |
|
| 1581 | + $image = $modSettings['avatar_url'] . '/default.png'; |
|
| 1582 | + } |
|
| 1514 | 1583 | } |
| 1515 | - if (!empty($image)) |
|
| 1516 | - $memberContext[$user]['avatar'] = array( |
|
| 1584 | + if (!empty($image)) { |
|
| 1585 | + $memberContext[$user]['avatar'] = array( |
|
| 1517 | 1586 | 'name' => $profile['avatar'], |
| 1518 | 1587 | 'image' => '<img class="avatar" src="' . $image . '" alt="avatar_' . $profile['member_name'] . '">', |
| 1519 | 1588 | 'href' => $image, |
| 1520 | 1589 | 'url' => $image, |
| 1521 | 1590 | ); |
| 1591 | + } |
|
| 1522 | 1592 | } |
| 1523 | 1593 | |
| 1524 | 1594 | // Are we also loading the members custom fields into context? |
@@ -1526,13 +1596,15 @@ discard block |
||
| 1526 | 1596 | { |
| 1527 | 1597 | $memberContext[$user]['custom_fields'] = array(); |
| 1528 | 1598 | |
| 1529 | - if (!isset($context['display_fields'])) |
|
| 1530 | - $context['display_fields'] = $smcFunc['json_decode']($modSettings['displayFields'], true); |
|
| 1599 | + if (!isset($context['display_fields'])) { |
|
| 1600 | + $context['display_fields'] = $smcFunc['json_decode']($modSettings['displayFields'], true); |
|
| 1601 | + } |
|
| 1531 | 1602 | |
| 1532 | 1603 | foreach ($context['display_fields'] as $custom) |
| 1533 | 1604 | { |
| 1534 | - if (!isset($custom['col_name']) || trim($custom['col_name']) == '' || empty($profile['options'][$custom['col_name']])) |
|
| 1535 | - continue; |
|
| 1605 | + if (!isset($custom['col_name']) || trim($custom['col_name']) == '' || empty($profile['options'][$custom['col_name']])) { |
|
| 1606 | + continue; |
|
| 1607 | + } |
|
| 1536 | 1608 | |
| 1537 | 1609 | $value = $profile['options'][$custom['col_name']]; |
| 1538 | 1610 | |
@@ -1540,31 +1612,36 @@ discard block |
||
| 1540 | 1612 | $currentKey = 0; |
| 1541 | 1613 | |
| 1542 | 1614 | // Create a key => value array for multiple options fields |
| 1543 | - if (!empty($custom['options'])) |
|
| 1544 | - foreach ($custom['options'] as $k => $v) |
|
| 1615 | + if (!empty($custom['options'])) { |
|
| 1616 | + foreach ($custom['options'] as $k => $v) |
|
| 1545 | 1617 | { |
| 1546 | 1618 | $fieldOptions[] = $v; |
| 1547 | - if (empty($currentKey)) |
|
| 1548 | - $currentKey = $v == $value ? $k : 0; |
|
| 1619 | + } |
|
| 1620 | + if (empty($currentKey)) { |
|
| 1621 | + $currentKey = $v == $value ? $k : 0; |
|
| 1622 | + } |
|
| 1549 | 1623 | } |
| 1550 | 1624 | |
| 1551 | 1625 | // BBC? |
| 1552 | - if ($custom['bbc']) |
|
| 1553 | - $value = parse_bbc($value); |
|
| 1626 | + if ($custom['bbc']) { |
|
| 1627 | + $value = parse_bbc($value); |
|
| 1628 | + } |
|
| 1554 | 1629 | |
| 1555 | 1630 | // ... or checkbox? |
| 1556 | - elseif (isset($custom['type']) && $custom['type'] == 'check') |
|
| 1557 | - $value = $value ? $txt['yes'] : $txt['no']; |
|
| 1631 | + elseif (isset($custom['type']) && $custom['type'] == 'check') { |
|
| 1632 | + $value = $value ? $txt['yes'] : $txt['no']; |
|
| 1633 | + } |
|
| 1558 | 1634 | |
| 1559 | 1635 | // Enclosing the user input within some other text? |
| 1560 | - if (!empty($custom['enclose'])) |
|
| 1561 | - $value = strtr($custom['enclose'], array( |
|
| 1636 | + if (!empty($custom['enclose'])) { |
|
| 1637 | + $value = strtr($custom['enclose'], array( |
|
| 1562 | 1638 | '{SCRIPTURL}' => $scripturl, |
| 1563 | 1639 | '{IMAGES_URL}' => $settings['images_url'], |
| 1564 | 1640 | '{DEFAULT_IMAGES_URL}' => $settings['default_images_url'], |
| 1565 | 1641 | '{INPUT}' => $value, |
| 1566 | 1642 | '{KEY}' => $currentKey, |
| 1567 | 1643 | )); |
| 1644 | + } |
|
| 1568 | 1645 | |
| 1569 | 1646 | $memberContext[$user]['custom_fields'][] = array( |
| 1570 | 1647 | 'title' => !empty($custom['title']) ? $custom['title'] : $custom['col_name'], |
@@ -1591,8 +1668,9 @@ discard block |
||
| 1591 | 1668 | global $smcFunc, $txt, $scripturl, $settings; |
| 1592 | 1669 | |
| 1593 | 1670 | // Do not waste my time... |
| 1594 | - if (empty($users) || empty($params)) |
|
| 1595 | - return false; |
|
| 1671 | + if (empty($users) || empty($params)) { |
|
| 1672 | + return false; |
|
| 1673 | + } |
|
| 1596 | 1674 | |
| 1597 | 1675 | // Make sure it's an array. |
| 1598 | 1676 | $users = !is_array($users) ? array($users) : array_unique($users); |
@@ -1619,41 +1697,48 @@ discard block |
||
| 1619 | 1697 | $currentKey = 0; |
| 1620 | 1698 | |
| 1621 | 1699 | // Create a key => value array for multiple options fields |
| 1622 | - if (!empty($row['field_options'])) |
|
| 1623 | - foreach (explode(',', $row['field_options']) as $k => $v) |
|
| 1700 | + if (!empty($row['field_options'])) { |
|
| 1701 | + foreach (explode(',', $row['field_options']) as $k => $v) |
|
| 1624 | 1702 | { |
| 1625 | 1703 | $fieldOptions[] = $v; |
| 1626 | - if (empty($currentKey)) |
|
| 1627 | - $currentKey = $v == $row['value'] ? $k : 0; |
|
| 1704 | + } |
|
| 1705 | + if (empty($currentKey)) { |
|
| 1706 | + $currentKey = $v == $row['value'] ? $k : 0; |
|
| 1707 | + } |
|
| 1628 | 1708 | } |
| 1629 | 1709 | |
| 1630 | 1710 | // BBC? |
| 1631 | - if (!empty($row['bbc'])) |
|
| 1632 | - $row['value'] = parse_bbc($row['value']); |
|
| 1711 | + if (!empty($row['bbc'])) { |
|
| 1712 | + $row['value'] = parse_bbc($row['value']); |
|
| 1713 | + } |
|
| 1633 | 1714 | |
| 1634 | 1715 | // ... or checkbox? |
| 1635 | - elseif (isset($row['type']) && $row['type'] == 'check') |
|
| 1636 | - $row['value'] = !empty($row['value']) ? $txt['yes'] : $txt['no']; |
|
| 1716 | + elseif (isset($row['type']) && $row['type'] == 'check') { |
|
| 1717 | + $row['value'] = !empty($row['value']) ? $txt['yes'] : $txt['no']; |
|
| 1718 | + } |
|
| 1637 | 1719 | |
| 1638 | 1720 | // Enclosing the user input within some other text? |
| 1639 | - if (!empty($row['enclose'])) |
|
| 1640 | - $row['value'] = strtr($row['enclose'], array( |
|
| 1721 | + if (!empty($row['enclose'])) { |
|
| 1722 | + $row['value'] = strtr($row['enclose'], array( |
|
| 1641 | 1723 | '{SCRIPTURL}' => $scripturl, |
| 1642 | 1724 | '{IMAGES_URL}' => $settings['images_url'], |
| 1643 | 1725 | '{DEFAULT_IMAGES_URL}' => $settings['default_images_url'], |
| 1644 | 1726 | '{INPUT}' => un_htmlspecialchars($row['value']), |
| 1645 | 1727 | '{KEY}' => $currentKey, |
| 1646 | 1728 | )); |
| 1729 | + } |
|
| 1647 | 1730 | |
| 1648 | 1731 | // Send a simple array if there is just 1 param |
| 1649 | - if (count($params) == 1) |
|
| 1650 | - $return[$row['id_member']] = $row; |
|
| 1732 | + if (count($params) == 1) { |
|
| 1733 | + $return[$row['id_member']] = $row; |
|
| 1734 | + } |
|
| 1651 | 1735 | |
| 1652 | 1736 | // More than 1? knock yourself out... |
| 1653 | 1737 | else |
| 1654 | 1738 | { |
| 1655 | - if (!isset($return[$row['id_member']])) |
|
| 1656 | - $return[$row['id_member']] = array(); |
|
| 1739 | + if (!isset($return[$row['id_member']])) { |
|
| 1740 | + $return[$row['id_member']] = array(); |
|
| 1741 | + } |
|
| 1657 | 1742 | |
| 1658 | 1743 | $return[$row['id_member']][$row['variable']] = $row; |
| 1659 | 1744 | } |
@@ -1687,8 +1772,9 @@ discard block |
||
| 1687 | 1772 | global $context; |
| 1688 | 1773 | |
| 1689 | 1774 | // Don't know any browser! |
| 1690 | - if (empty($context['browser'])) |
|
| 1691 | - detectBrowser(); |
|
| 1775 | + if (empty($context['browser'])) { |
|
| 1776 | + detectBrowser(); |
|
| 1777 | + } |
|
| 1692 | 1778 | |
| 1693 | 1779 | return !empty($context['browser'][$browser]) || !empty($context['browser']['is_' . $browser]) ? true : false; |
| 1694 | 1780 | } |
@@ -1706,8 +1792,9 @@ discard block |
||
| 1706 | 1792 | global $context, $settings, $options, $sourcedir, $ssi_theme, $smcFunc, $language, $board, $image_proxy_enabled; |
| 1707 | 1793 | |
| 1708 | 1794 | // The theme was specified by parameter. |
| 1709 | - if (!empty($id_theme)) |
|
| 1710 | - $id_theme = (int) $id_theme; |
|
| 1795 | + if (!empty($id_theme)) { |
|
| 1796 | + $id_theme = (int) $id_theme; |
|
| 1797 | + } |
|
| 1711 | 1798 | // The theme was specified by REQUEST. |
| 1712 | 1799 | elseif (!empty($_REQUEST['theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum'))) |
| 1713 | 1800 | { |
@@ -1715,32 +1802,38 @@ discard block |
||
| 1715 | 1802 | $_SESSION['id_theme'] = $id_theme; |
| 1716 | 1803 | } |
| 1717 | 1804 | // The theme was specified by REQUEST... previously. |
| 1718 | - elseif (!empty($_SESSION['id_theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum'))) |
|
| 1719 | - $id_theme = (int) $_SESSION['id_theme']; |
|
| 1805 | + elseif (!empty($_SESSION['id_theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum'))) { |
|
| 1806 | + $id_theme = (int) $_SESSION['id_theme']; |
|
| 1807 | + } |
|
| 1720 | 1808 | // The theme is just the user's choice. (might use ?board=1;theme=0 to force board theme.) |
| 1721 | - elseif (!empty($user_info['theme']) && !isset($_REQUEST['theme'])) |
|
| 1722 | - $id_theme = $user_info['theme']; |
|
| 1809 | + elseif (!empty($user_info['theme']) && !isset($_REQUEST['theme'])) { |
|
| 1810 | + $id_theme = $user_info['theme']; |
|
| 1811 | + } |
|
| 1723 | 1812 | // The theme was specified by the board. |
| 1724 | - elseif (!empty($board_info['theme'])) |
|
| 1725 | - $id_theme = $board_info['theme']; |
|
| 1813 | + elseif (!empty($board_info['theme'])) { |
|
| 1814 | + $id_theme = $board_info['theme']; |
|
| 1815 | + } |
|
| 1726 | 1816 | // The theme is the forum's default. |
| 1727 | - else |
|
| 1728 | - $id_theme = $modSettings['theme_guests']; |
|
| 1817 | + else { |
|
| 1818 | + $id_theme = $modSettings['theme_guests']; |
|
| 1819 | + } |
|
| 1729 | 1820 | |
| 1730 | 1821 | // Verify the id_theme... no foul play. |
| 1731 | 1822 | // Always allow the board specific theme, if they are overriding. |
| 1732 | - if (!empty($board_info['theme']) && $board_info['override_theme']) |
|
| 1733 | - $id_theme = $board_info['theme']; |
|
| 1823 | + if (!empty($board_info['theme']) && $board_info['override_theme']) { |
|
| 1824 | + $id_theme = $board_info['theme']; |
|
| 1825 | + } |
|
| 1734 | 1826 | // If they have specified a particular theme to use with SSI allow it to be used. |
| 1735 | - elseif (!empty($ssi_theme) && $id_theme == $ssi_theme) |
|
| 1736 | - $id_theme = (int) $id_theme; |
|
| 1737 | - elseif (!empty($modSettings['enableThemes']) && !allowedTo('admin_forum')) |
|
| 1827 | + elseif (!empty($ssi_theme) && $id_theme == $ssi_theme) { |
|
| 1828 | + $id_theme = (int) $id_theme; |
|
| 1829 | + } elseif (!empty($modSettings['enableThemes']) && !allowedTo('admin_forum')) |
|
| 1738 | 1830 | { |
| 1739 | 1831 | $themes = explode(',', $modSettings['enableThemes']); |
| 1740 | - if (!in_array($id_theme, $themes)) |
|
| 1741 | - $id_theme = $modSettings['theme_guests']; |
|
| 1742 | - else |
|
| 1743 | - $id_theme = (int) $id_theme; |
|
| 1832 | + if (!in_array($id_theme, $themes)) { |
|
| 1833 | + $id_theme = $modSettings['theme_guests']; |
|
| 1834 | + } else { |
|
| 1835 | + $id_theme = (int) $id_theme; |
|
| 1836 | + } |
|
| 1744 | 1837 | } |
| 1745 | 1838 | |
| 1746 | 1839 | // We already load the basic stuff? |
@@ -1749,18 +1842,19 @@ discard block |
||
| 1749 | 1842 | $member = empty($user_info['id']) ? -1 : $user_info['id']; |
| 1750 | 1843 | |
| 1751 | 1844 | // Disable image proxy if we don't have SSL enabled |
| 1752 | - if (empty($modSettings['force_ssl'])) |
|
| 1753 | - $image_proxy_enabled = false; |
|
| 1845 | + if (empty($modSettings['force_ssl'])) { |
|
| 1846 | + $image_proxy_enabled = false; |
|
| 1847 | + } |
|
| 1754 | 1848 | |
| 1755 | 1849 | if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2 && ($temp = cache_get_data('theme_settings-' . $id_theme . ':' . $member, 60)) != null && time() - 60 > $modSettings['settings_updated']) |
| 1756 | 1850 | { |
| 1757 | 1851 | $themeData = $temp; |
| 1758 | 1852 | $flag = true; |
| 1853 | + } elseif (($temp = cache_get_data('theme_settings-' . $id_theme, 90)) != null && time() - 60 > $modSettings['settings_updated']) { |
|
| 1854 | + $themeData = $temp + array($member => array()); |
|
| 1855 | + } else { |
|
| 1856 | + $themeData = array(-1 => array(), 0 => array(), $member => array()); |
|
| 1759 | 1857 | } |
| 1760 | - elseif (($temp = cache_get_data('theme_settings-' . $id_theme, 90)) != null && time() - 60 > $modSettings['settings_updated']) |
|
| 1761 | - $themeData = $temp + array($member => array()); |
|
| 1762 | - else |
|
| 1763 | - $themeData = array(-1 => array(), 0 => array(), $member => array()); |
|
| 1764 | 1858 | |
| 1765 | 1859 | if (empty($flag)) |
| 1766 | 1860 | { |
@@ -1780,31 +1874,37 @@ discard block |
||
| 1780 | 1874 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 1781 | 1875 | { |
| 1782 | 1876 | // There are just things we shouldn't be able to change as members. |
| 1783 | - if ($row['id_member'] != 0 && in_array($row['variable'], array('actual_theme_url', 'actual_images_url', 'base_theme_dir', 'base_theme_url', 'default_images_url', 'default_theme_dir', 'default_theme_url', 'default_template', 'images_url', 'number_recent_posts', 'smiley_sets_default', 'theme_dir', 'theme_id', 'theme_layers', 'theme_templates', 'theme_url'))) |
|
| 1784 | - continue; |
|
| 1877 | + if ($row['id_member'] != 0 && in_array($row['variable'], array('actual_theme_url', 'actual_images_url', 'base_theme_dir', 'base_theme_url', 'default_images_url', 'default_theme_dir', 'default_theme_url', 'default_template', 'images_url', 'number_recent_posts', 'smiley_sets_default', 'theme_dir', 'theme_id', 'theme_layers', 'theme_templates', 'theme_url'))) { |
|
| 1878 | + continue; |
|
| 1879 | + } |
|
| 1785 | 1880 | |
| 1786 | 1881 | // If this is the theme_dir of the default theme, store it. |
| 1787 | - if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['id_theme'] == '1' && empty($row['id_member'])) |
|
| 1788 | - $themeData[0]['default_' . $row['variable']] = $row['value']; |
|
| 1882 | + if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['id_theme'] == '1' && empty($row['id_member'])) { |
|
| 1883 | + $themeData[0]['default_' . $row['variable']] = $row['value']; |
|
| 1884 | + } |
|
| 1789 | 1885 | |
| 1790 | 1886 | // If this isn't set yet, is a theme option, or is not the default theme.. |
| 1791 | - if (!isset($themeData[$row['id_member']][$row['variable']]) || $row['id_theme'] != '1') |
|
| 1792 | - $themeData[$row['id_member']][$row['variable']] = substr($row['variable'], 0, 5) == 'show_' ? $row['value'] == '1' : $row['value']; |
|
| 1887 | + if (!isset($themeData[$row['id_member']][$row['variable']]) || $row['id_theme'] != '1') { |
|
| 1888 | + $themeData[$row['id_member']][$row['variable']] = substr($row['variable'], 0, 5) == 'show_' ? $row['value'] == '1' : $row['value']; |
|
| 1889 | + } |
|
| 1793 | 1890 | } |
| 1794 | 1891 | $smcFunc['db_free_result']($result); |
| 1795 | 1892 | |
| 1796 | - if (!empty($themeData[-1])) |
|
| 1797 | - foreach ($themeData[-1] as $k => $v) |
|
| 1893 | + if (!empty($themeData[-1])) { |
|
| 1894 | + foreach ($themeData[-1] as $k => $v) |
|
| 1798 | 1895 | { |
| 1799 | 1896 | if (!isset($themeData[$member][$k])) |
| 1800 | 1897 | $themeData[$member][$k] = $v; |
| 1898 | + } |
|
| 1801 | 1899 | } |
| 1802 | 1900 | |
| 1803 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
| 1804 | - cache_put_data('theme_settings-' . $id_theme . ':' . $member, $themeData, 60); |
|
| 1901 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
| 1902 | + cache_put_data('theme_settings-' . $id_theme . ':' . $member, $themeData, 60); |
|
| 1903 | + } |
|
| 1805 | 1904 | // Only if we didn't already load that part of the cache... |
| 1806 | - elseif (!isset($temp)) |
|
| 1807 | - cache_put_data('theme_settings-' . $id_theme, array(-1 => $themeData[-1], 0 => $themeData[0]), 90); |
|
| 1905 | + elseif (!isset($temp)) { |
|
| 1906 | + cache_put_data('theme_settings-' . $id_theme, array(-1 => $themeData[-1], 0 => $themeData[0]), 90); |
|
| 1907 | + } |
|
| 1808 | 1908 | } |
| 1809 | 1909 | |
| 1810 | 1910 | $settings = $themeData[0]; |
@@ -1821,17 +1921,20 @@ discard block |
||
| 1821 | 1921 | $settings['template_dirs'][] = $settings['theme_dir']; |
| 1822 | 1922 | |
| 1823 | 1923 | // Based on theme (if there is one). |
| 1824 | - if (!empty($settings['base_theme_dir'])) |
|
| 1825 | - $settings['template_dirs'][] = $settings['base_theme_dir']; |
|
| 1924 | + if (!empty($settings['base_theme_dir'])) { |
|
| 1925 | + $settings['template_dirs'][] = $settings['base_theme_dir']; |
|
| 1926 | + } |
|
| 1826 | 1927 | |
| 1827 | 1928 | // Lastly the default theme. |
| 1828 | - if ($settings['theme_dir'] != $settings['default_theme_dir']) |
|
| 1829 | - $settings['template_dirs'][] = $settings['default_theme_dir']; |
|
| 1929 | + if ($settings['theme_dir'] != $settings['default_theme_dir']) { |
|
| 1930 | + $settings['template_dirs'][] = $settings['default_theme_dir']; |
|
| 1931 | + } |
|
| 1830 | 1932 | } |
| 1831 | 1933 | |
| 1832 | 1934 | |
| 1833 | - if (!$initialize) |
|
| 1834 | - return; |
|
| 1935 | + if (!$initialize) { |
|
| 1936 | + return; |
|
| 1937 | + } |
|
| 1835 | 1938 | |
| 1836 | 1939 | // Check to see if we're forcing SSL |
| 1837 | 1940 | if (!empty($modSettings['force_ssl']) && empty($maintenance) && |
@@ -1852,8 +1955,9 @@ discard block |
||
| 1852 | 1955 | $detected_url = httpsOn() ? 'https://' : 'http://'; |
| 1853 | 1956 | $detected_url .= empty($_SERVER['HTTP_HOST']) ? $_SERVER['SERVER_NAME'] . (empty($_SERVER['SERVER_PORT']) || $_SERVER['SERVER_PORT'] == '80' ? '' : ':' . $_SERVER['SERVER_PORT']) : $_SERVER['HTTP_HOST']; |
| 1854 | 1957 | $temp = preg_replace('~/' . basename($scripturl) . '(/.+)?$~', '', strtr(dirname($_SERVER['PHP_SELF']), '\\', '/')); |
| 1855 | - if ($temp != '/') |
|
| 1856 | - $detected_url .= $temp; |
|
| 1958 | + if ($temp != '/') { |
|
| 1959 | + $detected_url .= $temp; |
|
| 1960 | + } |
|
| 1857 | 1961 | } |
| 1858 | 1962 | if (isset($detected_url) && $detected_url != $boardurl) |
| 1859 | 1963 | { |
@@ -1865,8 +1969,9 @@ discard block |
||
| 1865 | 1969 | foreach ($aliases as $alias) |
| 1866 | 1970 | { |
| 1867 | 1971 | // Rip off all the boring parts, spaces, etc. |
| 1868 | - if ($detected_url == trim($alias) || strtr($detected_url, array('http://' => '', 'https://' => '')) == trim($alias)) |
|
| 1869 | - $do_fix = true; |
|
| 1972 | + if ($detected_url == trim($alias) || strtr($detected_url, array('http://' => '', 'https://' => '')) == trim($alias)) { |
|
| 1973 | + $do_fix = true; |
|
| 1974 | + } |
|
| 1870 | 1975 | } |
| 1871 | 1976 | } |
| 1872 | 1977 | |
@@ -1874,21 +1979,23 @@ discard block |
||
| 1874 | 1979 | if (empty($do_fix) && strtr($detected_url, array('://' => '://www.')) == $boardurl && (empty($_GET) || count($_GET) == 1) && SMF != 'SSI') |
| 1875 | 1980 | { |
| 1876 | 1981 | // Okay, this seems weird, but we don't want an endless loop - this will make $_GET not empty ;). |
| 1877 | - if (empty($_GET)) |
|
| 1878 | - redirectexit('wwwRedirect'); |
|
| 1879 | - else |
|
| 1982 | + if (empty($_GET)) { |
|
| 1983 | + redirectexit('wwwRedirect'); |
|
| 1984 | + } else |
|
| 1880 | 1985 | { |
| 1881 | 1986 | $k = key($_GET); |
| 1882 | 1987 | $v = current($_GET); |
| 1883 | 1988 | |
| 1884 | - if ($k != 'wwwRedirect') |
|
| 1885 | - redirectexit('wwwRedirect;' . $k . '=' . $v); |
|
| 1989 | + if ($k != 'wwwRedirect') { |
|
| 1990 | + redirectexit('wwwRedirect;' . $k . '=' . $v); |
|
| 1991 | + } |
|
| 1886 | 1992 | } |
| 1887 | 1993 | } |
| 1888 | 1994 | |
| 1889 | 1995 | // #3 is just a check for SSL... |
| 1890 | - if (strtr($detected_url, array('https://' => 'http://')) == $boardurl) |
|
| 1891 | - $do_fix = true; |
|
| 1996 | + if (strtr($detected_url, array('https://' => 'http://')) == $boardurl) { |
|
| 1997 | + $do_fix = true; |
|
| 1998 | + } |
|
| 1892 | 1999 | |
| 1893 | 2000 | // Okay, #4 - perhaps it's an IP address? We're gonna want to use that one, then. (assuming it's the IP or something...) |
| 1894 | 2001 | if (!empty($do_fix) || preg_match('~^http[s]?://(?:[\d\.:]+|\[[\d:]+\](?::\d+)?)(?:$|/)~', $detected_url) == 1) |
@@ -1923,8 +2030,9 @@ discard block |
||
| 1923 | 2030 | $board_info['moderators'][$k]['link'] = strtr($dummy['link'], array('"' . $oldurl => '"' . $boardurl)); |
| 1924 | 2031 | } |
| 1925 | 2032 | } |
| 1926 | - foreach ($context['linktree'] as $k => $dummy) |
|
| 1927 | - $context['linktree'][$k]['url'] = strtr($dummy['url'], array($oldurl => $boardurl)); |
|
| 2033 | + foreach ($context['linktree'] as $k => $dummy) { |
|
| 2034 | + $context['linktree'][$k]['url'] = strtr($dummy['url'], array($oldurl => $boardurl)); |
|
| 2035 | + } |
|
| 1928 | 2036 | } |
| 1929 | 2037 | } |
| 1930 | 2038 | // Set up the contextual user array. |
@@ -1943,16 +2051,16 @@ discard block |
||
| 1943 | 2051 | 'email' => $user_info['email'], |
| 1944 | 2052 | 'ignoreusers' => $user_info['ignoreusers'], |
| 1945 | 2053 | ); |
| 1946 | - if (!$context['user']['is_guest']) |
|
| 1947 | - $context['user']['name'] = $user_info['name']; |
|
| 1948 | - elseif ($context['user']['is_guest'] && !empty($txt['guest_title'])) |
|
| 1949 | - $context['user']['name'] = $txt['guest_title']; |
|
| 2054 | + if (!$context['user']['is_guest']) { |
|
| 2055 | + $context['user']['name'] = $user_info['name']; |
|
| 2056 | + } elseif ($context['user']['is_guest'] && !empty($txt['guest_title'])) { |
|
| 2057 | + $context['user']['name'] = $txt['guest_title']; |
|
| 2058 | + } |
|
| 1950 | 2059 | |
| 1951 | 2060 | // Determine the current smiley set. |
| 1952 | 2061 | $user_info['smiley_set'] = (!in_array($user_info['smiley_set'], explode(',', $modSettings['smiley_sets_known'])) && $user_info['smiley_set'] != 'none') || empty($modSettings['smiley_sets_enable']) ? (!empty($settings['smiley_sets_default']) ? $settings['smiley_sets_default'] : $modSettings['smiley_sets_default']) : $user_info['smiley_set']; |
| 1953 | 2062 | $context['user']['smiley_set'] = $user_info['smiley_set']; |
| 1954 | - } |
|
| 1955 | - else |
|
| 2063 | + } else |
|
| 1956 | 2064 | { |
| 1957 | 2065 | // What to do when there is no $user_info (e.g., an error very early in the login process) |
| 1958 | 2066 | $context['user'] = array( |
@@ -1986,18 +2094,24 @@ discard block |
||
| 1986 | 2094 | } |
| 1987 | 2095 | |
| 1988 | 2096 | // Some basic information... |
| 1989 | - if (!isset($context['html_headers'])) |
|
| 1990 | - $context['html_headers'] = ''; |
|
| 1991 | - if (!isset($context['javascript_files'])) |
|
| 1992 | - $context['javascript_files'] = array(); |
|
| 1993 | - if (!isset($context['css_files'])) |
|
| 1994 | - $context['css_files'] = array(); |
|
| 1995 | - if (!isset($context['css_header'])) |
|
| 1996 | - $context['css_header'] = array(); |
|
| 1997 | - if (!isset($context['javascript_inline'])) |
|
| 1998 | - $context['javascript_inline'] = array('standard' => array(), 'defer' => array()); |
|
| 1999 | - if (!isset($context['javascript_vars'])) |
|
| 2000 | - $context['javascript_vars'] = array(); |
|
| 2097 | + if (!isset($context['html_headers'])) { |
|
| 2098 | + $context['html_headers'] = ''; |
|
| 2099 | + } |
|
| 2100 | + if (!isset($context['javascript_files'])) { |
|
| 2101 | + $context['javascript_files'] = array(); |
|
| 2102 | + } |
|
| 2103 | + if (!isset($context['css_files'])) { |
|
| 2104 | + $context['css_files'] = array(); |
|
| 2105 | + } |
|
| 2106 | + if (!isset($context['css_header'])) { |
|
| 2107 | + $context['css_header'] = array(); |
|
| 2108 | + } |
|
| 2109 | + if (!isset($context['javascript_inline'])) { |
|
| 2110 | + $context['javascript_inline'] = array('standard' => array(), 'defer' => array()); |
|
| 2111 | + } |
|
| 2112 | + if (!isset($context['javascript_vars'])) { |
|
| 2113 | + $context['javascript_vars'] = array(); |
|
| 2114 | + } |
|
| 2001 | 2115 | |
| 2002 | 2116 | $context['login_url'] = $scripturl . '?action=login2'; |
| 2003 | 2117 | $context['menu_separator'] = !empty($settings['use_image_buttons']) ? ' ' : ' | '; |
@@ -2009,16 +2123,18 @@ discard block |
||
| 2009 | 2123 | $context['current_action'] = isset($_REQUEST['action']) ? $smcFunc['htmlspecialchars']($_REQUEST['action']) : null; |
| 2010 | 2124 | $context['current_subaction'] = isset($_REQUEST['sa']) ? $_REQUEST['sa'] : null; |
| 2011 | 2125 | $context['can_register'] = empty($modSettings['registration_method']) || $modSettings['registration_method'] != 3; |
| 2012 | - if (isset($modSettings['load_average'])) |
|
| 2013 | - $context['load_average'] = $modSettings['load_average']; |
|
| 2126 | + if (isset($modSettings['load_average'])) { |
|
| 2127 | + $context['load_average'] = $modSettings['load_average']; |
|
| 2128 | + } |
|
| 2014 | 2129 | |
| 2015 | 2130 | // Detect the browser. This is separated out because it's also used in attachment downloads |
| 2016 | 2131 | detectBrowser(); |
| 2017 | 2132 | |
| 2018 | 2133 | // Set the top level linktree up. |
| 2019 | 2134 | // Note that if we're dealing with certain very early errors (e.g., login) the linktree might not be set yet... |
| 2020 | - if (empty($context['linktree'])) |
|
| 2021 | - $context['linktree'] = array(); |
|
| 2135 | + if (empty($context['linktree'])) { |
|
| 2136 | + $context['linktree'] = array(); |
|
| 2137 | + } |
|
| 2022 | 2138 | array_unshift($context['linktree'], array( |
| 2023 | 2139 | 'url' => $scripturl, |
| 2024 | 2140 | 'name' => $context['forum_name_html_safe'] |
@@ -2027,8 +2143,9 @@ discard block |
||
| 2027 | 2143 | // This allows sticking some HTML on the page output - useful for controls. |
| 2028 | 2144 | $context['insert_after_template'] = ''; |
| 2029 | 2145 | |
| 2030 | - if (!isset($txt)) |
|
| 2031 | - $txt = array(); |
|
| 2146 | + if (!isset($txt)) { |
|
| 2147 | + $txt = array(); |
|
| 2148 | + } |
|
| 2032 | 2149 | |
| 2033 | 2150 | $simpleActions = array( |
| 2034 | 2151 | 'findmember', |
@@ -2074,9 +2191,10 @@ discard block |
||
| 2074 | 2191 | |
| 2075 | 2192 | // See if theres any extra param to check. |
| 2076 | 2193 | $requiresXML = false; |
| 2077 | - foreach ($extraParams as $key => $extra) |
|
| 2078 | - if (isset($_REQUEST[$extra])) |
|
| 2194 | + foreach ($extraParams as $key => $extra) { |
|
| 2195 | + if (isset($_REQUEST[$extra])) |
|
| 2079 | 2196 | $requiresXML = true; |
| 2197 | + } |
|
| 2080 | 2198 | |
| 2081 | 2199 | // Output is fully XML, so no need for the index template. |
| 2082 | 2200 | if (isset($_REQUEST['xml']) && (in_array($context['current_action'], $xmlActions) || $requiresXML)) |
@@ -2091,37 +2209,39 @@ discard block |
||
| 2091 | 2209 | { |
| 2092 | 2210 | loadLanguage('index+Modifications'); |
| 2093 | 2211 | $context['template_layers'] = array(); |
| 2094 | - } |
|
| 2095 | - |
|
| 2096 | - else |
|
| 2212 | + } else |
|
| 2097 | 2213 | { |
| 2098 | 2214 | // Custom templates to load, or just default? |
| 2099 | - if (isset($settings['theme_templates'])) |
|
| 2100 | - $templates = explode(',', $settings['theme_templates']); |
|
| 2101 | - else |
|
| 2102 | - $templates = array('index'); |
|
| 2215 | + if (isset($settings['theme_templates'])) { |
|
| 2216 | + $templates = explode(',', $settings['theme_templates']); |
|
| 2217 | + } else { |
|
| 2218 | + $templates = array('index'); |
|
| 2219 | + } |
|
| 2103 | 2220 | |
| 2104 | 2221 | // Load each template... |
| 2105 | - foreach ($templates as $template) |
|
| 2106 | - loadTemplate($template); |
|
| 2222 | + foreach ($templates as $template) { |
|
| 2223 | + loadTemplate($template); |
|
| 2224 | + } |
|
| 2107 | 2225 | |
| 2108 | 2226 | // ...and attempt to load their associated language files. |
| 2109 | 2227 | $required_files = implode('+', array_merge($templates, array('Modifications'))); |
| 2110 | 2228 | loadLanguage($required_files, '', false); |
| 2111 | 2229 | |
| 2112 | 2230 | // Custom template layers? |
| 2113 | - if (isset($settings['theme_layers'])) |
|
| 2114 | - $context['template_layers'] = explode(',', $settings['theme_layers']); |
|
| 2115 | - else |
|
| 2116 | - $context['template_layers'] = array('html', 'body'); |
|
| 2231 | + if (isset($settings['theme_layers'])) { |
|
| 2232 | + $context['template_layers'] = explode(',', $settings['theme_layers']); |
|
| 2233 | + } else { |
|
| 2234 | + $context['template_layers'] = array('html', 'body'); |
|
| 2235 | + } |
|
| 2117 | 2236 | } |
| 2118 | 2237 | |
| 2119 | 2238 | // Initialize the theme. |
| 2120 | 2239 | loadSubTemplate('init', 'ignore'); |
| 2121 | 2240 | |
| 2122 | 2241 | // Allow overriding the board wide time/number formats. |
| 2123 | - if (empty($user_settings['time_format']) && !empty($txt['time_format'])) |
|
| 2124 | - $user_info['time_format'] = $txt['time_format']; |
|
| 2242 | + if (empty($user_settings['time_format']) && !empty($txt['time_format'])) { |
|
| 2243 | + $user_info['time_format'] = $txt['time_format']; |
|
| 2244 | + } |
|
| 2125 | 2245 | |
| 2126 | 2246 | // Set the character set from the template. |
| 2127 | 2247 | $context['character_set'] = empty($modSettings['global_character_set']) ? $txt['lang_character_set'] : $modSettings['global_character_set']; |
@@ -2129,12 +2249,14 @@ discard block |
||
| 2129 | 2249 | $context['right_to_left'] = !empty($txt['lang_rtl']); |
| 2130 | 2250 | |
| 2131 | 2251 | // Guests may still need a name. |
| 2132 | - if ($context['user']['is_guest'] && empty($context['user']['name'])) |
|
| 2133 | - $context['user']['name'] = $txt['guest_title']; |
|
| 2252 | + if ($context['user']['is_guest'] && empty($context['user']['name'])) { |
|
| 2253 | + $context['user']['name'] = $txt['guest_title']; |
|
| 2254 | + } |
|
| 2134 | 2255 | |
| 2135 | 2256 | // Any theme-related strings that need to be loaded? |
| 2136 | - if (!empty($settings['require_theme_strings'])) |
|
| 2137 | - loadLanguage('ThemeStrings', '', false); |
|
| 2257 | + if (!empty($settings['require_theme_strings'])) { |
|
| 2258 | + loadLanguage('ThemeStrings', '', false); |
|
| 2259 | + } |
|
| 2138 | 2260 | |
| 2139 | 2261 | // Make a special URL for the language. |
| 2140 | 2262 | $settings['lang_images_url'] = $settings['images_url'] . '/' . (!empty($txt['image_lang']) ? $txt['image_lang'] : $user_info['language']); |
@@ -2145,8 +2267,9 @@ discard block |
||
| 2145 | 2267 | // Here is my luvly Responsive CSS |
| 2146 | 2268 | loadCSSFile('responsive.css', array('force_current' => false, 'validate' => true, 'minimize' => true, 'order_pos' => 9000), 'smf_responsive'); |
| 2147 | 2269 | |
| 2148 | - if ($context['right_to_left']) |
|
| 2149 | - loadCSSFile('rtl.css', array('order_pos' => 200), 'smf_rtl'); |
|
| 2270 | + if ($context['right_to_left']) { |
|
| 2271 | + loadCSSFile('rtl.css', array('order_pos' => 200), 'smf_rtl'); |
|
| 2272 | + } |
|
| 2150 | 2273 | |
| 2151 | 2274 | // We allow theme variants, because we're cool. |
| 2152 | 2275 | $context['theme_variant'] = ''; |
@@ -2154,14 +2277,17 @@ discard block |
||
| 2154 | 2277 | if (!empty($settings['theme_variants'])) |
| 2155 | 2278 | { |
| 2156 | 2279 | // Overriding - for previews and that ilk. |
| 2157 | - if (!empty($_REQUEST['variant'])) |
|
| 2158 | - $_SESSION['id_variant'] = $_REQUEST['variant']; |
|
| 2280 | + if (!empty($_REQUEST['variant'])) { |
|
| 2281 | + $_SESSION['id_variant'] = $_REQUEST['variant']; |
|
| 2282 | + } |
|
| 2159 | 2283 | // User selection? |
| 2160 | - if (empty($settings['disable_user_variant']) || allowedTo('admin_forum')) |
|
| 2161 | - $context['theme_variant'] = !empty($_SESSION['id_variant']) ? $_SESSION['id_variant'] : (!empty($options['theme_variant']) ? $options['theme_variant'] : ''); |
|
| 2284 | + if (empty($settings['disable_user_variant']) || allowedTo('admin_forum')) { |
|
| 2285 | + $context['theme_variant'] = !empty($_SESSION['id_variant']) ? $_SESSION['id_variant'] : (!empty($options['theme_variant']) ? $options['theme_variant'] : ''); |
|
| 2286 | + } |
|
| 2162 | 2287 | // If not a user variant, select the default. |
| 2163 | - if ($context['theme_variant'] == '' || !in_array($context['theme_variant'], $settings['theme_variants'])) |
|
| 2164 | - $context['theme_variant'] = !empty($settings['default_variant']) && in_array($settings['default_variant'], $settings['theme_variants']) ? $settings['default_variant'] : $settings['theme_variants'][0]; |
|
| 2288 | + if ($context['theme_variant'] == '' || !in_array($context['theme_variant'], $settings['theme_variants'])) { |
|
| 2289 | + $context['theme_variant'] = !empty($settings['default_variant']) && in_array($settings['default_variant'], $settings['theme_variants']) ? $settings['default_variant'] : $settings['theme_variants'][0]; |
|
| 2290 | + } |
|
| 2165 | 2291 | |
| 2166 | 2292 | // Do this to keep things easier in the templates. |
| 2167 | 2293 | $context['theme_variant'] = '_' . $context['theme_variant']; |
@@ -2170,20 +2296,23 @@ discard block |
||
| 2170 | 2296 | if (!empty($context['theme_variant'])) |
| 2171 | 2297 | { |
| 2172 | 2298 | loadCSSFile('index' . $context['theme_variant'] . '.css', array('order_pos' => 300), 'smf_index' . $context['theme_variant']); |
| 2173 | - if ($context['right_to_left']) |
|
| 2174 | - loadCSSFile('rtl' . $context['theme_variant'] . '.css', array('order_pos' => 400), 'smf_rtl' . $context['theme_variant']); |
|
| 2299 | + if ($context['right_to_left']) { |
|
| 2300 | + loadCSSFile('rtl' . $context['theme_variant'] . '.css', array('order_pos' => 400), 'smf_rtl' . $context['theme_variant']); |
|
| 2301 | + } |
|
| 2175 | 2302 | } |
| 2176 | 2303 | } |
| 2177 | 2304 | |
| 2178 | 2305 | // Let's be compatible with old themes! |
| 2179 | - if (!function_exists('template_html_above') && in_array('html', $context['template_layers'])) |
|
| 2180 | - $context['template_layers'] = array('main'); |
|
| 2306 | + if (!function_exists('template_html_above') && in_array('html', $context['template_layers'])) { |
|
| 2307 | + $context['template_layers'] = array('main'); |
|
| 2308 | + } |
|
| 2181 | 2309 | |
| 2182 | 2310 | $context['tabindex'] = 1; |
| 2183 | 2311 | |
| 2184 | 2312 | // Compatibility. |
| 2185 | - if (!isset($settings['theme_version'])) |
|
| 2186 | - $modSettings['memberCount'] = $modSettings['totalMembers']; |
|
| 2313 | + if (!isset($settings['theme_version'])) { |
|
| 2314 | + $modSettings['memberCount'] = $modSettings['totalMembers']; |
|
| 2315 | + } |
|
| 2187 | 2316 | |
| 2188 | 2317 | // Default JS variables for use in every theme |
| 2189 | 2318 | $context['javascript_vars'] = array( |
@@ -2202,18 +2331,18 @@ discard block |
||
| 2202 | 2331 | ); |
| 2203 | 2332 | |
| 2204 | 2333 | // Add the JQuery library to the list of files to load. |
| 2205 | - if (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'cdn') |
|
| 2206 | - loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js', array('external' => true), 'smf_jquery'); |
|
| 2207 | - |
|
| 2208 | - elseif (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'local') |
|
| 2209 | - loadJavaScriptFile('jquery-3.2.1.min.js', array('seed' => false), 'smf_jquery'); |
|
| 2210 | - |
|
| 2211 | - elseif (isset($modSettings['jquery_source'], $modSettings['jquery_custom']) && $modSettings['jquery_source'] == 'custom') |
|
| 2212 | - loadJavaScriptFile($modSettings['jquery_custom'], array('external' => true), 'smf_jquery'); |
|
| 2334 | + if (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'cdn') { |
|
| 2335 | + loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js', array('external' => true), 'smf_jquery'); |
|
| 2336 | + } elseif (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'local') { |
|
| 2337 | + loadJavaScriptFile('jquery-3.2.1.min.js', array('seed' => false), 'smf_jquery'); |
|
| 2338 | + } elseif (isset($modSettings['jquery_source'], $modSettings['jquery_custom']) && $modSettings['jquery_source'] == 'custom') { |
|
| 2339 | + loadJavaScriptFile($modSettings['jquery_custom'], array('external' => true), 'smf_jquery'); |
|
| 2340 | + } |
|
| 2213 | 2341 | |
| 2214 | 2342 | // Auto loading? template_javascript() will take care of the local half of this. |
| 2215 | - else |
|
| 2216 | - loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js', array('external' => true), 'smf_jquery'); |
|
| 2343 | + else { |
|
| 2344 | + loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js', array('external' => true), 'smf_jquery'); |
|
| 2345 | + } |
|
| 2217 | 2346 | |
| 2218 | 2347 | // Queue our JQuery plugins! |
| 2219 | 2348 | loadJavaScriptFile('smf_jquery_plugins.js', array('minimize' => true), 'smf_jquery_plugins'); |
@@ -2236,12 +2365,12 @@ discard block |
||
| 2236 | 2365 | require_once($sourcedir . '/ScheduledTasks.php'); |
| 2237 | 2366 | |
| 2238 | 2367 | // What to do, what to do?! |
| 2239 | - if (empty($modSettings['next_task_time']) || $modSettings['next_task_time'] < time()) |
|
| 2240 | - AutoTask(); |
|
| 2241 | - else |
|
| 2242 | - ReduceMailQueue(); |
|
| 2243 | - } |
|
| 2244 | - else |
|
| 2368 | + if (empty($modSettings['next_task_time']) || $modSettings['next_task_time'] < time()) { |
|
| 2369 | + AutoTask(); |
|
| 2370 | + } else { |
|
| 2371 | + ReduceMailQueue(); |
|
| 2372 | + } |
|
| 2373 | + } else |
|
| 2245 | 2374 | { |
| 2246 | 2375 | $type = empty($modSettings['next_task_time']) || $modSettings['next_task_time'] < time() ? 'task' : 'mailq'; |
| 2247 | 2376 | $ts = $type == 'mailq' ? $modSettings['mail_next_send'] : $modSettings['next_task_time']; |
@@ -2292,8 +2421,9 @@ discard block |
||
| 2292 | 2421 | foreach ($theme_includes as $include) |
| 2293 | 2422 | { |
| 2294 | 2423 | $include = strtr(trim($include), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir'])); |
| 2295 | - if (file_exists($include)) |
|
| 2296 | - require_once($include); |
|
| 2424 | + if (file_exists($include)) { |
|
| 2425 | + require_once($include); |
|
| 2426 | + } |
|
| 2297 | 2427 | } |
| 2298 | 2428 | } |
| 2299 | 2429 | |
@@ -2323,16 +2453,19 @@ discard block |
||
| 2323 | 2453 | // Do any style sheets first, cause we're easy with those. |
| 2324 | 2454 | if (!empty($style_sheets)) |
| 2325 | 2455 | { |
| 2326 | - if (!is_array($style_sheets)) |
|
| 2327 | - $style_sheets = array($style_sheets); |
|
| 2456 | + if (!is_array($style_sheets)) { |
|
| 2457 | + $style_sheets = array($style_sheets); |
|
| 2458 | + } |
|
| 2328 | 2459 | |
| 2329 | - foreach ($style_sheets as $sheet) |
|
| 2330 | - loadCSSFile($sheet . '.css', array(), $sheet); |
|
| 2460 | + foreach ($style_sheets as $sheet) { |
|
| 2461 | + loadCSSFile($sheet . '.css', array(), $sheet); |
|
| 2462 | + } |
|
| 2331 | 2463 | } |
| 2332 | 2464 | |
| 2333 | 2465 | // No template to load? |
| 2334 | - if ($template_name === false) |
|
| 2335 | - return true; |
|
| 2466 | + if ($template_name === false) { |
|
| 2467 | + return true; |
|
| 2468 | + } |
|
| 2336 | 2469 | |
| 2337 | 2470 | $loaded = false; |
| 2338 | 2471 | foreach ($settings['template_dirs'] as $template_dir) |
@@ -2347,12 +2480,14 @@ discard block |
||
| 2347 | 2480 | |
| 2348 | 2481 | if ($loaded) |
| 2349 | 2482 | { |
| 2350 | - if ($db_show_debug === true) |
|
| 2351 | - $context['debug']['templates'][] = $template_name . ' (' . basename($template_dir) . ')'; |
|
| 2483 | + if ($db_show_debug === true) { |
|
| 2484 | + $context['debug']['templates'][] = $template_name . ' (' . basename($template_dir) . ')'; |
|
| 2485 | + } |
|
| 2352 | 2486 | |
| 2353 | 2487 | // If they have specified an initialization function for this template, go ahead and call it now. |
| 2354 | - if (function_exists('template_' . $template_name . '_init')) |
|
| 2355 | - call_user_func('template_' . $template_name . '_init'); |
|
| 2488 | + if (function_exists('template_' . $template_name . '_init')) { |
|
| 2489 | + call_user_func('template_' . $template_name . '_init'); |
|
| 2490 | + } |
|
| 2356 | 2491 | } |
| 2357 | 2492 | // Hmmm... doesn't exist?! I don't suppose the directory is wrong, is it? |
| 2358 | 2493 | elseif (!file_exists($settings['default_theme_dir']) && file_exists($boarddir . '/Themes/default')) |
@@ -2372,13 +2507,14 @@ discard block |
||
| 2372 | 2507 | loadTemplate($template_name); |
| 2373 | 2508 | } |
| 2374 | 2509 | // Cause an error otherwise. |
| 2375 | - elseif ($template_name != 'Errors' && $template_name != 'index' && $fatal) |
|
| 2376 | - fatal_lang_error('theme_template_error', 'template', array((string) $template_name)); |
|
| 2377 | - elseif ($fatal) |
|
| 2378 | - die(log_error(sprintf(isset($txt['theme_template_error']) ? $txt['theme_template_error'] : 'Unable to load Themes/default/%s.template.php!', (string) $template_name), 'template')); |
|
| 2379 | - else |
|
| 2380 | - return false; |
|
| 2381 | -} |
|
| 2510 | + elseif ($template_name != 'Errors' && $template_name != 'index' && $fatal) { |
|
| 2511 | + fatal_lang_error('theme_template_error', 'template', array((string) $template_name)); |
|
| 2512 | + } elseif ($fatal) { |
|
| 2513 | + die(log_error(sprintf(isset($txt['theme_template_error']) ? $txt['theme_template_error'] : 'Unable to load Themes/default/%s.template.php!', (string) $template_name), 'template')); |
|
| 2514 | + } else { |
|
| 2515 | + return false; |
|
| 2516 | + } |
|
| 2517 | + } |
|
| 2382 | 2518 | |
| 2383 | 2519 | /** |
| 2384 | 2520 | * Load a sub-template. |
@@ -2396,17 +2532,19 @@ discard block |
||
| 2396 | 2532 | { |
| 2397 | 2533 | global $context, $txt, $db_show_debug; |
| 2398 | 2534 | |
| 2399 | - if ($db_show_debug === true) |
|
| 2400 | - $context['debug']['sub_templates'][] = $sub_template_name; |
|
| 2535 | + if ($db_show_debug === true) { |
|
| 2536 | + $context['debug']['sub_templates'][] = $sub_template_name; |
|
| 2537 | + } |
|
| 2401 | 2538 | |
| 2402 | 2539 | // Figure out what the template function is named. |
| 2403 | 2540 | $theme_function = 'template_' . $sub_template_name; |
| 2404 | - if (function_exists($theme_function)) |
|
| 2405 | - $theme_function(); |
|
| 2406 | - elseif ($fatal === false) |
|
| 2407 | - fatal_lang_error('theme_template_error', 'template', array((string) $sub_template_name)); |
|
| 2408 | - elseif ($fatal !== 'ignore') |
|
| 2409 | - die(log_error(sprintf(isset($txt['theme_template_error']) ? $txt['theme_template_error'] : 'Unable to load the %s sub template!', (string) $sub_template_name), 'template')); |
|
| 2541 | + if (function_exists($theme_function)) { |
|
| 2542 | + $theme_function(); |
|
| 2543 | + } elseif ($fatal === false) { |
|
| 2544 | + fatal_lang_error('theme_template_error', 'template', array((string) $sub_template_name)); |
|
| 2545 | + } elseif ($fatal !== 'ignore') { |
|
| 2546 | + die(log_error(sprintf(isset($txt['theme_template_error']) ? $txt['theme_template_error'] : 'Unable to load the %s sub template!', (string) $sub_template_name), 'template')); |
|
| 2547 | + } |
|
| 2410 | 2548 | |
| 2411 | 2549 | // Are we showing debugging for templates? Just make sure not to do it before the doctype... |
| 2412 | 2550 | if (allowedTo('admin_forum') && isset($_REQUEST['debug']) && !in_array($sub_template_name, array('init', 'main_below')) && ob_get_length() > 0 && !isset($_REQUEST['xml'])) |
@@ -2436,8 +2574,9 @@ discard block |
||
| 2436 | 2574 | { |
| 2437 | 2575 | global $settings, $context, $modSettings; |
| 2438 | 2576 | |
| 2439 | - if (empty($context['css_files_order'])) |
|
| 2440 | - $context['css_files_order'] = array(); |
|
| 2577 | + if (empty($context['css_files_order'])) { |
|
| 2578 | + $context['css_files_order'] = array(); |
|
| 2579 | + } |
|
| 2441 | 2580 | |
| 2442 | 2581 | $params['seed'] = (!array_key_exists('seed', $params) || (array_key_exists('seed', $params) && $params['seed'] === true)) ? (array_key_exists('browser_cache', $modSettings) ? $modSettings['browser_cache'] : '') : (is_string($params['seed']) ? ($params['seed'] = $params['seed'][0] === '?' ? $params['seed'] : '?' . $params['seed']) : ''); |
| 2443 | 2582 | $params['force_current'] = isset($params['force_current']) ? $params['force_current'] : false; |
@@ -2448,8 +2587,9 @@ discard block |
||
| 2448 | 2587 | $params['order_pos'] = isset($params['order_pos']) ? (int) $params['order_pos'] : 3000; |
| 2449 | 2588 | |
| 2450 | 2589 | // If this is an external file, automatically set this to false. |
| 2451 | - if (!empty($params['external'])) |
|
| 2452 | - $params['minimize'] = false; |
|
| 2590 | + if (!empty($params['external'])) { |
|
| 2591 | + $params['minimize'] = false; |
|
| 2592 | + } |
|
| 2453 | 2593 | |
| 2454 | 2594 | // Account for shorthand like admin.css?alp21 filenames |
| 2455 | 2595 | $has_seed = strpos($fileName, '.css?'); |
@@ -2466,16 +2606,12 @@ discard block |
||
| 2466 | 2606 | { |
| 2467 | 2607 | $fileUrl = $settings['default_theme_url'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']); |
| 2468 | 2608 | $filePath = $settings['default_theme_dir'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']); |
| 2469 | - } |
|
| 2470 | - |
|
| 2471 | - else |
|
| 2609 | + } else |
|
| 2472 | 2610 | { |
| 2473 | 2611 | $fileUrl = false; |
| 2474 | 2612 | $filePath = false; |
| 2475 | 2613 | } |
| 2476 | - } |
|
| 2477 | - |
|
| 2478 | - else |
|
| 2614 | + } else |
|
| 2479 | 2615 | { |
| 2480 | 2616 | $fileUrl = $settings[$themeRef . '_url'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']); |
| 2481 | 2617 | $filePath = $settings[$themeRef . '_dir'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']); |
@@ -2493,16 +2629,18 @@ discard block |
||
| 2493 | 2629 | if (!empty($fileName)) |
| 2494 | 2630 | { |
| 2495 | 2631 | // find a free number/position |
| 2496 | - while (isset($context['css_files_order'][$params['order_pos']])) |
|
| 2497 | - $params['order_pos']++; |
|
| 2632 | + while (isset($context['css_files_order'][$params['order_pos']])) { |
|
| 2633 | + $params['order_pos']++; |
|
| 2634 | + } |
|
| 2498 | 2635 | $context['css_files_order'][$params['order_pos']] = $id; |
| 2499 | 2636 | |
| 2500 | 2637 | $context['css_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params); |
| 2501 | 2638 | } |
| 2502 | 2639 | |
| 2503 | - if (!empty($context['right_to_left']) && !empty($params['rtl'])) |
|
| 2504 | - loadCSSFile($params['rtl'], array_diff_key($params, array('rtl' => 0))); |
|
| 2505 | -} |
|
| 2640 | + if (!empty($context['right_to_left']) && !empty($params['rtl'])) { |
|
| 2641 | + loadCSSFile($params['rtl'], array_diff_key($params, array('rtl' => 0))); |
|
| 2642 | + } |
|
| 2643 | + } |
|
| 2506 | 2644 | |
| 2507 | 2645 | /** |
| 2508 | 2646 | * Add a block of inline css code to be executed later |
@@ -2519,8 +2657,9 @@ discard block |
||
| 2519 | 2657 | global $context; |
| 2520 | 2658 | |
| 2521 | 2659 | // Gotta add something... |
| 2522 | - if (empty($css)) |
|
| 2523 | - return false; |
|
| 2660 | + if (empty($css)) { |
|
| 2661 | + return false; |
|
| 2662 | + } |
|
| 2524 | 2663 | |
| 2525 | 2664 | $context['css_header'][] = $css; |
| 2526 | 2665 | } |
@@ -2556,8 +2695,9 @@ discard block |
||
| 2556 | 2695 | $params['validate'] = isset($params['validate']) ? $params['validate'] : true; |
| 2557 | 2696 | |
| 2558 | 2697 | // If this is an external file, automatically set this to false. |
| 2559 | - if (!empty($params['external'])) |
|
| 2560 | - $params['minimize'] = false; |
|
| 2698 | + if (!empty($params['external'])) { |
|
| 2699 | + $params['minimize'] = false; |
|
| 2700 | + } |
|
| 2561 | 2701 | |
| 2562 | 2702 | // Account for shorthand like admin.js?alp21 filenames |
| 2563 | 2703 | $has_seed = strpos($fileName, '.js?'); |
@@ -2574,16 +2714,12 @@ discard block |
||
| 2574 | 2714 | { |
| 2575 | 2715 | $fileUrl = $settings['default_theme_url'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']); |
| 2576 | 2716 | $filePath = $settings['default_theme_dir'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']); |
| 2577 | - } |
|
| 2578 | - |
|
| 2579 | - else |
|
| 2717 | + } else |
|
| 2580 | 2718 | { |
| 2581 | 2719 | $fileUrl = false; |
| 2582 | 2720 | $filePath = false; |
| 2583 | 2721 | } |
| 2584 | - } |
|
| 2585 | - |
|
| 2586 | - else |
|
| 2722 | + } else |
|
| 2587 | 2723 | { |
| 2588 | 2724 | $fileUrl = $settings[$themeRef . '_url'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']); |
| 2589 | 2725 | $filePath = $settings[$themeRef . '_dir'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']); |
@@ -2598,9 +2734,10 @@ discard block |
||
| 2598 | 2734 | } |
| 2599 | 2735 | |
| 2600 | 2736 | // Add it to the array for use in the template |
| 2601 | - if (!empty($fileName)) |
|
| 2602 | - $context['javascript_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params); |
|
| 2603 | -} |
|
| 2737 | + if (!empty($fileName)) { |
|
| 2738 | + $context['javascript_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params); |
|
| 2739 | + } |
|
| 2740 | + } |
|
| 2604 | 2741 | |
| 2605 | 2742 | /** |
| 2606 | 2743 | * Add a Javascript variable for output later (for feeding text strings and similar to JS) |
@@ -2614,9 +2751,10 @@ discard block |
||
| 2614 | 2751 | { |
| 2615 | 2752 | global $context; |
| 2616 | 2753 | |
| 2617 | - if (!empty($key) && (!empty($value) || $value === '0')) |
|
| 2618 | - $context['javascript_vars'][$key] = !empty($escape) ? JavaScriptEscape($value) : $value; |
|
| 2619 | -} |
|
| 2754 | + if (!empty($key) && (!empty($value) || $value === '0')) { |
|
| 2755 | + $context['javascript_vars'][$key] = !empty($escape) ? JavaScriptEscape($value) : $value; |
|
| 2756 | + } |
|
| 2757 | + } |
|
| 2620 | 2758 | |
| 2621 | 2759 | /** |
| 2622 | 2760 | * Add a block of inline Javascript code to be executed later |
@@ -2633,8 +2771,9 @@ discard block |
||
| 2633 | 2771 | { |
| 2634 | 2772 | global $context; |
| 2635 | 2773 | |
| 2636 | - if (empty($javascript)) |
|
| 2637 | - return false; |
|
| 2774 | + if (empty($javascript)) { |
|
| 2775 | + return false; |
|
| 2776 | + } |
|
| 2638 | 2777 | |
| 2639 | 2778 | $context['javascript_inline'][($defer === true ? 'defer' : 'standard')][] = $javascript; |
| 2640 | 2779 | } |
@@ -2655,15 +2794,18 @@ discard block |
||
| 2655 | 2794 | static $already_loaded = array(); |
| 2656 | 2795 | |
| 2657 | 2796 | // Default to the user's language. |
| 2658 | - if ($lang == '') |
|
| 2659 | - $lang = isset($user_info['language']) ? $user_info['language'] : $language; |
|
| 2797 | + if ($lang == '') { |
|
| 2798 | + $lang = isset($user_info['language']) ? $user_info['language'] : $language; |
|
| 2799 | + } |
|
| 2660 | 2800 | |
| 2661 | 2801 | // Do we want the English version of language file as fallback? |
| 2662 | - if (empty($modSettings['disable_language_fallback']) && $lang != 'english') |
|
| 2663 | - loadLanguage($template_name, 'english', false); |
|
| 2802 | + if (empty($modSettings['disable_language_fallback']) && $lang != 'english') { |
|
| 2803 | + loadLanguage($template_name, 'english', false); |
|
| 2804 | + } |
|
| 2664 | 2805 | |
| 2665 | - if (!$force_reload && isset($already_loaded[$template_name]) && $already_loaded[$template_name] == $lang) |
|
| 2666 | - return $lang; |
|
| 2806 | + if (!$force_reload && isset($already_loaded[$template_name]) && $already_loaded[$template_name] == $lang) { |
|
| 2807 | + return $lang; |
|
| 2808 | + } |
|
| 2667 | 2809 | |
| 2668 | 2810 | // Make sure we have $settings - if not we're in trouble and need to find it! |
| 2669 | 2811 | if (empty($settings['default_theme_dir'])) |
@@ -2674,8 +2816,9 @@ discard block |
||
| 2674 | 2816 | |
| 2675 | 2817 | // What theme are we in? |
| 2676 | 2818 | $theme_name = basename($settings['theme_url']); |
| 2677 | - if (empty($theme_name)) |
|
| 2678 | - $theme_name = 'unknown'; |
|
| 2819 | + if (empty($theme_name)) { |
|
| 2820 | + $theme_name = 'unknown'; |
|
| 2821 | + } |
|
| 2679 | 2822 | |
| 2680 | 2823 | // For each file open it up and write it out! |
| 2681 | 2824 | foreach (explode('+', $template_name) as $template) |
@@ -2717,8 +2860,9 @@ discard block |
||
| 2717 | 2860 | $found = true; |
| 2718 | 2861 | |
| 2719 | 2862 | // setlocale is required for basename() & pathinfo() to work properly on the selected language |
| 2720 | - if (!empty($txt['lang_locale']) && !empty($modSettings['global_character_set'])) |
|
| 2721 | - setlocale(LC_CTYPE, $txt['lang_locale'] . '.' . $modSettings['global_character_set']); |
|
| 2863 | + if (!empty($txt['lang_locale']) && !empty($modSettings['global_character_set'])) { |
|
| 2864 | + setlocale(LC_CTYPE, $txt['lang_locale'] . '.' . $modSettings['global_character_set']); |
|
| 2865 | + } |
|
| 2722 | 2866 | |
| 2723 | 2867 | break; |
| 2724 | 2868 | } |
@@ -2758,8 +2902,9 @@ discard block |
||
| 2758 | 2902 | } |
| 2759 | 2903 | |
| 2760 | 2904 | // Keep track of what we're up to soldier. |
| 2761 | - if ($db_show_debug === true) |
|
| 2762 | - $context['debug']['language_files'][] = $template_name . '.' . $lang . ' (' . $theme_name . ')'; |
|
| 2905 | + if ($db_show_debug === true) { |
|
| 2906 | + $context['debug']['language_files'][] = $template_name . '.' . $lang . ' (' . $theme_name . ')'; |
|
| 2907 | + } |
|
| 2763 | 2908 | |
| 2764 | 2909 | // Remember what we have loaded, and in which language. |
| 2765 | 2910 | $already_loaded[$template_name] = $lang; |
@@ -2805,8 +2950,9 @@ discard block |
||
| 2805 | 2950 | ) |
| 2806 | 2951 | ); |
| 2807 | 2952 | // In the EXTREMELY unlikely event this happens, give an error message. |
| 2808 | - if ($smcFunc['db_num_rows']($result) == 0) |
|
| 2809 | - fatal_lang_error('parent_not_found', 'critical'); |
|
| 2953 | + if ($smcFunc['db_num_rows']($result) == 0) { |
|
| 2954 | + fatal_lang_error('parent_not_found', 'critical'); |
|
| 2955 | + } |
|
| 2810 | 2956 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 2811 | 2957 | { |
| 2812 | 2958 | if (!isset($boards[$row['id_board']])) |
@@ -2823,8 +2969,8 @@ discard block |
||
| 2823 | 2969 | ); |
| 2824 | 2970 | } |
| 2825 | 2971 | // If a moderator exists for this board, add that moderator for all children too. |
| 2826 | - if (!empty($row['id_moderator'])) |
|
| 2827 | - foreach ($boards as $id => $dummy) |
|
| 2972 | + if (!empty($row['id_moderator'])) { |
|
| 2973 | + foreach ($boards as $id => $dummy) |
|
| 2828 | 2974 | { |
| 2829 | 2975 | $boards[$id]['moderators'][$row['id_moderator']] = array( |
| 2830 | 2976 | 'id' => $row['id_moderator'], |
@@ -2832,11 +2978,12 @@ discard block |
||
| 2832 | 2978 | 'href' => $scripturl . '?action=profile;u=' . $row['id_moderator'], |
| 2833 | 2979 | 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_moderator'] . '">' . $row['real_name'] . '</a>' |
| 2834 | 2980 | ); |
| 2981 | + } |
|
| 2835 | 2982 | } |
| 2836 | 2983 | |
| 2837 | 2984 | // If a moderator group exists for this board, add that moderator group for all children too |
| 2838 | - if (!empty($row['id_moderator_group'])) |
|
| 2839 | - foreach ($boards as $id => $dummy) |
|
| 2985 | + if (!empty($row['id_moderator_group'])) { |
|
| 2986 | + foreach ($boards as $id => $dummy) |
|
| 2840 | 2987 | { |
| 2841 | 2988 | $boards[$id]['moderator_groups'][$row['id_moderator_group']] = array( |
| 2842 | 2989 | 'id' => $row['id_moderator_group'], |
@@ -2844,6 +2991,7 @@ discard block |
||
| 2844 | 2991 | 'href' => $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'], |
| 2845 | 2992 | 'link' => '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'] . '">' . $row['group_name'] . '</a>' |
| 2846 | 2993 | ); |
| 2994 | + } |
|
| 2847 | 2995 | } |
| 2848 | 2996 | } |
| 2849 | 2997 | $smcFunc['db_free_result']($result); |
@@ -2870,23 +3018,27 @@ discard block |
||
| 2870 | 3018 | if (!$use_cache || ($context['languages'] = cache_get_data('known_languages', !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600)) == null) |
| 2871 | 3019 | { |
| 2872 | 3020 | // If we don't have our ucwords function defined yet, let's load the settings data. |
| 2873 | - if (empty($smcFunc['ucwords'])) |
|
| 2874 | - reloadSettings(); |
|
| 3021 | + if (empty($smcFunc['ucwords'])) { |
|
| 3022 | + reloadSettings(); |
|
| 3023 | + } |
|
| 2875 | 3024 | |
| 2876 | 3025 | // If we don't have our theme information yet, let's get it. |
| 2877 | - if (empty($settings['default_theme_dir'])) |
|
| 2878 | - loadTheme(0, false); |
|
| 3026 | + if (empty($settings['default_theme_dir'])) { |
|
| 3027 | + loadTheme(0, false); |
|
| 3028 | + } |
|
| 2879 | 3029 | |
| 2880 | 3030 | // Default language directories to try. |
| 2881 | 3031 | $language_directories = array( |
| 2882 | 3032 | $settings['default_theme_dir'] . '/languages', |
| 2883 | 3033 | ); |
| 2884 | - if (!empty($settings['actual_theme_dir']) && $settings['actual_theme_dir'] != $settings['default_theme_dir']) |
|
| 2885 | - $language_directories[] = $settings['actual_theme_dir'] . '/languages'; |
|
| 3034 | + if (!empty($settings['actual_theme_dir']) && $settings['actual_theme_dir'] != $settings['default_theme_dir']) { |
|
| 3035 | + $language_directories[] = $settings['actual_theme_dir'] . '/languages'; |
|
| 3036 | + } |
|
| 2886 | 3037 | |
| 2887 | 3038 | // We possibly have a base theme directory. |
| 2888 | - if (!empty($settings['base_theme_dir'])) |
|
| 2889 | - $language_directories[] = $settings['base_theme_dir'] . '/languages'; |
|
| 3039 | + if (!empty($settings['base_theme_dir'])) { |
|
| 3040 | + $language_directories[] = $settings['base_theme_dir'] . '/languages'; |
|
| 3041 | + } |
|
| 2890 | 3042 | |
| 2891 | 3043 | // Remove any duplicates. |
| 2892 | 3044 | $language_directories = array_unique($language_directories); |
@@ -2900,20 +3052,21 @@ discard block |
||
| 2900 | 3052 | foreach ($language_directories as $language_dir) |
| 2901 | 3053 | { |
| 2902 | 3054 | // Can't look in here... doesn't exist! |
| 2903 | - if (!file_exists($language_dir)) |
|
| 2904 | - continue; |
|
| 3055 | + if (!file_exists($language_dir)) { |
|
| 3056 | + continue; |
|
| 3057 | + } |
|
| 2905 | 3058 | |
| 2906 | 3059 | $dir = dir($language_dir); |
| 2907 | 3060 | while ($entry = $dir->read()) |
| 2908 | 3061 | { |
| 2909 | 3062 | // Look for the index language file... For good measure skip any "index.language-utf8.php" files |
| 2910 | - if (!preg_match('~^index\.(.+[^-utf8])\.php$~', $entry, $matches)) |
|
| 2911 | - continue; |
|
| 2912 | - |
|
| 2913 | - if (!empty($langList) && !empty($langList[$matches[1]])) |
|
| 2914 | - $langName = $langList[$matches[1]]; |
|
| 3063 | + if (!preg_match('~^index\.(.+[^-utf8])\.php$~', $entry, $matches)) { |
|
| 3064 | + continue; |
|
| 3065 | + } |
|
| 2915 | 3066 | |
| 2916 | - else |
|
| 3067 | + if (!empty($langList) && !empty($langList[$matches[1]])) { |
|
| 3068 | + $langName = $langList[$matches[1]]; |
|
| 3069 | + } else |
|
| 2917 | 3070 | { |
| 2918 | 3071 | $langName = $smcFunc['ucwords'](strtr($matches[1], array('_' => ' '))); |
| 2919 | 3072 | |
@@ -2954,12 +3107,14 @@ discard block |
||
| 2954 | 3107 | } |
| 2955 | 3108 | |
| 2956 | 3109 | // Do we need to store the lang list? |
| 2957 | - if (empty($langList)) |
|
| 2958 | - updateSettings(array('langList' => $smcFunc['json_encode']($catchLang))); |
|
| 3110 | + if (empty($langList)) { |
|
| 3111 | + updateSettings(array('langList' => $smcFunc['json_encode']($catchLang))); |
|
| 3112 | + } |
|
| 2959 | 3113 | |
| 2960 | 3114 | // Let's cash in on this deal. |
| 2961 | - if (!empty($modSettings['cache_enable'])) |
|
| 2962 | - cache_put_data('known_languages', $context['languages'], !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600); |
|
| 3115 | + if (!empty($modSettings['cache_enable'])) { |
|
| 3116 | + cache_put_data('known_languages', $context['languages'], !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600); |
|
| 3117 | + } |
|
| 2963 | 3118 | } |
| 2964 | 3119 | |
| 2965 | 3120 | return $context['languages']; |
@@ -2982,8 +3137,9 @@ discard block |
||
| 2982 | 3137 | global $modSettings, $options, $txt; |
| 2983 | 3138 | static $censor_vulgar = null, $censor_proper; |
| 2984 | 3139 | |
| 2985 | - if ((!empty($options['show_no_censored']) && !empty($modSettings['allow_no_censored']) && !$force) || empty($modSettings['censor_vulgar']) || trim($text) === '') |
|
| 2986 | - return $text; |
|
| 3140 | + if ((!empty($options['show_no_censored']) && !empty($modSettings['allow_no_censored']) && !$force) || empty($modSettings['censor_vulgar']) || trim($text) === '') { |
|
| 3141 | + return $text; |
|
| 3142 | + } |
|
| 2987 | 3143 | |
| 2988 | 3144 | // If they haven't yet been loaded, load them. |
| 2989 | 3145 | if ($censor_vulgar == null) |
@@ -3014,9 +3170,9 @@ discard block |
||
| 3014 | 3170 | { |
| 3015 | 3171 | $func = !empty($modSettings['censorIgnoreCase']) ? 'str_ireplace' : 'str_replace'; |
| 3016 | 3172 | $text = $func($censor_vulgar, $censor_proper, $text); |
| 3173 | + } else { |
|
| 3174 | + $text = preg_replace($censor_vulgar, $censor_proper, $text); |
|
| 3017 | 3175 | } |
| 3018 | - else |
|
| 3019 | - $text = preg_replace($censor_vulgar, $censor_proper, $text); |
|
| 3020 | 3176 | |
| 3021 | 3177 | return $text; |
| 3022 | 3178 | } |
@@ -3042,30 +3198,35 @@ discard block |
||
| 3042 | 3198 | @ini_set('track_errors', '1'); |
| 3043 | 3199 | |
| 3044 | 3200 | // Don't include the file more than once, if $once is true. |
| 3045 | - if ($once && in_array($filename, $templates)) |
|
| 3046 | - return; |
|
| 3201 | + if ($once && in_array($filename, $templates)) { |
|
| 3202 | + return; |
|
| 3203 | + } |
|
| 3047 | 3204 | // Add this file to the include list, whether $once is true or not. |
| 3048 | - else |
|
| 3049 | - $templates[] = $filename; |
|
| 3205 | + else { |
|
| 3206 | + $templates[] = $filename; |
|
| 3207 | + } |
|
| 3050 | 3208 | |
| 3051 | 3209 | |
| 3052 | 3210 | $file_found = file_exists($filename); |
| 3053 | 3211 | |
| 3054 | - if ($once && $file_found) |
|
| 3055 | - require_once($filename); |
|
| 3056 | - elseif ($file_found) |
|
| 3057 | - require($filename); |
|
| 3212 | + if ($once && $file_found) { |
|
| 3213 | + require_once($filename); |
|
| 3214 | + } elseif ($file_found) { |
|
| 3215 | + require($filename); |
|
| 3216 | + } |
|
| 3058 | 3217 | |
| 3059 | 3218 | if ($file_found !== true) |
| 3060 | 3219 | { |
| 3061 | 3220 | ob_end_clean(); |
| 3062 | - if (!empty($modSettings['enableCompressedOutput'])) |
|
| 3063 | - @ob_start('ob_gzhandler'); |
|
| 3064 | - else |
|
| 3065 | - ob_start(); |
|
| 3221 | + if (!empty($modSettings['enableCompressedOutput'])) { |
|
| 3222 | + @ob_start('ob_gzhandler'); |
|
| 3223 | + } else { |
|
| 3224 | + ob_start(); |
|
| 3225 | + } |
|
| 3066 | 3226 | |
| 3067 | - if (isset($_GET['debug'])) |
|
| 3068 | - header('content-type: application/xhtml+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
| 3227 | + if (isset($_GET['debug'])) { |
|
| 3228 | + header('content-type: application/xhtml+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
| 3229 | + } |
|
| 3069 | 3230 | |
| 3070 | 3231 | // Don't cache error pages!! |
| 3071 | 3232 | header('expires: Mon, 26 Jul 1997 05:00:00 GMT'); |
@@ -3084,12 +3245,13 @@ discard block |
||
| 3084 | 3245 | echo '<!DOCTYPE html> |
| 3085 | 3246 | <html', !empty($context['right_to_left']) ? ' dir="rtl"' : '', '> |
| 3086 | 3247 | <head>'; |
| 3087 | - if (isset($context['character_set'])) |
|
| 3088 | - echo ' |
|
| 3248 | + if (isset($context['character_set'])) { |
|
| 3249 | + echo ' |
|
| 3089 | 3250 | <meta charset="', $context['character_set'], '">'; |
| 3251 | + } |
|
| 3090 | 3252 | |
| 3091 | - if (!empty($maintenance) && !allowedTo('admin_forum')) |
|
| 3092 | - echo ' |
|
| 3253 | + if (!empty($maintenance) && !allowedTo('admin_forum')) { |
|
| 3254 | + echo ' |
|
| 3093 | 3255 | <title>', $mtitle, '</title> |
| 3094 | 3256 | </head> |
| 3095 | 3257 | <body> |
@@ -3097,8 +3259,8 @@ discard block |
||
| 3097 | 3259 | ', $mmessage, ' |
| 3098 | 3260 | </body> |
| 3099 | 3261 | </html>'; |
| 3100 | - elseif (!allowedTo('admin_forum')) |
|
| 3101 | - echo ' |
|
| 3262 | + } elseif (!allowedTo('admin_forum')) { |
|
| 3263 | + echo ' |
|
| 3102 | 3264 | <title>', $txt['template_parse_error'], '</title> |
| 3103 | 3265 | </head> |
| 3104 | 3266 | <body> |
@@ -3106,14 +3268,16 @@ discard block |
||
| 3106 | 3268 | ', $txt['template_parse_error_message'], ' |
| 3107 | 3269 | </body> |
| 3108 | 3270 | </html>'; |
| 3109 | - else |
|
| 3271 | + } else |
|
| 3110 | 3272 | { |
| 3111 | 3273 | $error = fetch_web_data($boardurl . strtr($filename, array($boarddir => '', strtr($boarddir, '\\', '/') => ''))); |
| 3112 | 3274 | $error_array = error_get_last(); |
| 3113 | - if (empty($error) && ini_get('track_errors') && !empty($error_array)) |
|
| 3114 | - $error = $error_array['message']; |
|
| 3115 | - if (empty($error)) |
|
| 3116 | - $error = $txt['template_parse_errmsg']; |
|
| 3275 | + if (empty($error) && ini_get('track_errors') && !empty($error_array)) { |
|
| 3276 | + $error = $error_array['message']; |
|
| 3277 | + } |
|
| 3278 | + if (empty($error)) { |
|
| 3279 | + $error = $txt['template_parse_errmsg']; |
|
| 3280 | + } |
|
| 3117 | 3281 | |
| 3118 | 3282 | $error = strtr($error, array('<b>' => '<strong>', '</b>' => '</strong>')); |
| 3119 | 3283 | |
@@ -3124,11 +3288,12 @@ discard block |
||
| 3124 | 3288 | <h3>', $txt['template_parse_error'], '</h3> |
| 3125 | 3289 | ', sprintf($txt['template_parse_error_details'], strtr($filename, array($boarddir => '', strtr($boarddir, '\\', '/') => ''))); |
| 3126 | 3290 | |
| 3127 | - if (!empty($error)) |
|
| 3128 | - echo ' |
|
| 3291 | + if (!empty($error)) { |
|
| 3292 | + echo ' |
|
| 3129 | 3293 | <hr> |
| 3130 | 3294 | |
| 3131 | 3295 | <div style="margin: 0 20px;"><pre>', strtr(strtr($error, array('<strong>' . $boarddir => '<strong>...', '<strong>' . strtr($boarddir, '\\', '/') => '<strong>...')), '\\', '/'), '</pre></div>'; |
| 3296 | + } |
|
| 3132 | 3297 | |
| 3133 | 3298 | // I know, I know... this is VERY COMPLICATED. Still, it's good. |
| 3134 | 3299 | if (preg_match('~ <strong>(\d+)</strong><br( /)?' . '>$~i', $error, $match) != 0) |
@@ -3138,10 +3303,11 @@ discard block |
||
| 3138 | 3303 | $data2 = preg_split('~\<br( /)?\>~', $data2); |
| 3139 | 3304 | |
| 3140 | 3305 | // Fix the PHP code stuff... |
| 3141 | - if (!isBrowser('gecko')) |
|
| 3142 | - $data2 = str_replace("\t", '<span style="white-space: pre;">' . "\t" . '</span>', $data2); |
|
| 3143 | - else |
|
| 3144 | - $data2 = str_replace('<pre style="display: inline;">' . "\t" . '</pre>', "\t", $data2); |
|
| 3306 | + if (!isBrowser('gecko')) { |
|
| 3307 | + $data2 = str_replace("\t", '<span style="white-space: pre;">' . "\t" . '</span>', $data2); |
|
| 3308 | + } else { |
|
| 3309 | + $data2 = str_replace('<pre style="display: inline;">' . "\t" . '</pre>', "\t", $data2); |
|
| 3310 | + } |
|
| 3145 | 3311 | |
| 3146 | 3312 | // Now we get to work around a bug in PHP where it doesn't escape <br>s! |
| 3147 | 3313 | $j = -1; |
@@ -3149,8 +3315,9 @@ discard block |
||
| 3149 | 3315 | { |
| 3150 | 3316 | $j++; |
| 3151 | 3317 | |
| 3152 | - if (substr_count($line, '<br>') == 0) |
|
| 3153 | - continue; |
|
| 3318 | + if (substr_count($line, '<br>') == 0) { |
|
| 3319 | + continue; |
|
| 3320 | + } |
|
| 3154 | 3321 | |
| 3155 | 3322 | $n = substr_count($line, '<br>'); |
| 3156 | 3323 | for ($i = 0; $i < $n; $i++) |
@@ -3169,38 +3336,42 @@ discard block |
||
| 3169 | 3336 | // Figure out what the color coding was before... |
| 3170 | 3337 | $line = max($match[1] - 9, 1); |
| 3171 | 3338 | $last_line = ''; |
| 3172 | - for ($line2 = $line - 1; $line2 > 1; $line2--) |
|
| 3173 | - if (strpos($data2[$line2], '<') !== false) |
|
| 3339 | + for ($line2 = $line - 1; $line2 > 1; $line2--) { |
|
| 3340 | + if (strpos($data2[$line2], '<') !== false) |
|
| 3174 | 3341 | { |
| 3175 | 3342 | if (preg_match('~(<[^/>]+>)[^<]*$~', $data2[$line2], $color_match) != 0) |
| 3176 | 3343 | $last_line = $color_match[1]; |
| 3344 | + } |
|
| 3177 | 3345 | break; |
| 3178 | 3346 | } |
| 3179 | 3347 | |
| 3180 | 3348 | // Show the relevant lines... |
| 3181 | 3349 | for ($n = min($match[1] + 4, count($data2) + 1); $line <= $n; $line++) |
| 3182 | 3350 | { |
| 3183 | - if ($line == $match[1]) |
|
| 3184 | - echo '</pre><div style="background-color: #ffb0b5;"><pre style="margin: 0;">'; |
|
| 3351 | + if ($line == $match[1]) { |
|
| 3352 | + echo '</pre><div style="background-color: #ffb0b5;"><pre style="margin: 0;">'; |
|
| 3353 | + } |
|
| 3185 | 3354 | |
| 3186 | 3355 | echo '<span style="color: black;">', sprintf('%' . strlen($n) . 's', $line), ':</span> '; |
| 3187 | - if (isset($data2[$line]) && $data2[$line] != '') |
|
| 3188 | - echo substr($data2[$line], 0, 2) == '</' ? preg_replace('~^</[^>]+>~', '', $data2[$line]) : $last_line . $data2[$line]; |
|
| 3356 | + if (isset($data2[$line]) && $data2[$line] != '') { |
|
| 3357 | + echo substr($data2[$line], 0, 2) == '</' ? preg_replace('~^</[^>]+>~', '', $data2[$line]) : $last_line . $data2[$line]; |
|
| 3358 | + } |
|
| 3189 | 3359 | |
| 3190 | 3360 | if (isset($data2[$line]) && preg_match('~(<[^/>]+>)[^<]*$~', $data2[$line], $color_match) != 0) |
| 3191 | 3361 | { |
| 3192 | 3362 | $last_line = $color_match[1]; |
| 3193 | 3363 | echo '</', substr($last_line, 1, 4), '>'; |
| 3364 | + } elseif ($last_line != '' && strpos($data2[$line], '<') !== false) { |
|
| 3365 | + $last_line = ''; |
|
| 3366 | + } elseif ($last_line != '' && $data2[$line] != '') { |
|
| 3367 | + echo '</', substr($last_line, 1, 4), '>'; |
|
| 3194 | 3368 | } |
| 3195 | - elseif ($last_line != '' && strpos($data2[$line], '<') !== false) |
|
| 3196 | - $last_line = ''; |
|
| 3197 | - elseif ($last_line != '' && $data2[$line] != '') |
|
| 3198 | - echo '</', substr($last_line, 1, 4), '>'; |
|
| 3199 | 3369 | |
| 3200 | - if ($line == $match[1]) |
|
| 3201 | - echo '</pre></div><pre style="margin: 0;">'; |
|
| 3202 | - else |
|
| 3203 | - echo "\n"; |
|
| 3370 | + if ($line == $match[1]) { |
|
| 3371 | + echo '</pre></div><pre style="margin: 0;">'; |
|
| 3372 | + } else { |
|
| 3373 | + echo "\n"; |
|
| 3374 | + } |
|
| 3204 | 3375 | } |
| 3205 | 3376 | |
| 3206 | 3377 | echo '</pre></div>'; |
@@ -3224,8 +3395,9 @@ discard block |
||
| 3224 | 3395 | global $db_type, $db_name, $ssi_db_user, $ssi_db_passwd, $sourcedir, $db_prefix, $db_port; |
| 3225 | 3396 | |
| 3226 | 3397 | // Figure out what type of database we are using. |
| 3227 | - if (empty($db_type) || !file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php')) |
|
| 3228 | - $db_type = 'mysql'; |
|
| 3398 | + if (empty($db_type) || !file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php')) { |
|
| 3399 | + $db_type = 'mysql'; |
|
| 3400 | + } |
|
| 3229 | 3401 | |
| 3230 | 3402 | // Load the file for the database. |
| 3231 | 3403 | require_once($sourcedir . '/Subs-Db-' . $db_type . '.php'); |
@@ -3233,8 +3405,9 @@ discard block |
||
| 3233 | 3405 | $db_options = array(); |
| 3234 | 3406 | |
| 3235 | 3407 | // Add in the port if needed |
| 3236 | - if (!empty($db_port)) |
|
| 3237 | - $db_options['port'] = $db_port; |
|
| 3408 | + if (!empty($db_port)) { |
|
| 3409 | + $db_options['port'] = $db_port; |
|
| 3410 | + } |
|
| 3238 | 3411 | |
| 3239 | 3412 | // If we are in SSI try them first, but don't worry if it doesn't work, we have the normal username and password we can use. |
| 3240 | 3413 | if (SMF == 'SSI' && !empty($ssi_db_user) && !empty($ssi_db_passwd)) |
@@ -3253,13 +3426,15 @@ discard block |
||
| 3253 | 3426 | } |
| 3254 | 3427 | |
| 3255 | 3428 | // Safe guard here, if there isn't a valid connection lets put a stop to it. |
| 3256 | - if (!$db_connection) |
|
| 3257 | - display_db_error(); |
|
| 3429 | + if (!$db_connection) { |
|
| 3430 | + display_db_error(); |
|
| 3431 | + } |
|
| 3258 | 3432 | |
| 3259 | 3433 | // If in SSI mode fix up the prefix. |
| 3260 | - if (SMF == 'SSI') |
|
| 3261 | - db_fix_prefix($db_prefix, $db_name); |
|
| 3262 | -} |
|
| 3434 | + if (SMF == 'SSI') { |
|
| 3435 | + db_fix_prefix($db_prefix, $db_name); |
|
| 3436 | + } |
|
| 3437 | + } |
|
| 3263 | 3438 | |
| 3264 | 3439 | /** |
| 3265 | 3440 | * Try to load up a supported caching method. This is saved in $cacheAPI if we are not overriding it. |
@@ -3273,10 +3448,11 @@ discard block |
||
| 3273 | 3448 | global $sourcedir, $cacheAPI, $cache_accelerator; |
| 3274 | 3449 | |
| 3275 | 3450 | // Not overriding this and we have a cacheAPI, send it back. |
| 3276 | - if (empty($overrideCache) && is_object($cacheAPI)) |
|
| 3277 | - return $cacheAPI; |
|
| 3278 | - elseif (is_null($cacheAPI)) |
|
| 3279 | - $cacheAPI = false; |
|
| 3451 | + if (empty($overrideCache) && is_object($cacheAPI)) { |
|
| 3452 | + return $cacheAPI; |
|
| 3453 | + } elseif (is_null($cacheAPI)) { |
|
| 3454 | + $cacheAPI = false; |
|
| 3455 | + } |
|
| 3280 | 3456 | |
| 3281 | 3457 | // Make sure our class is in session. |
| 3282 | 3458 | require_once($sourcedir . '/Class-CacheAPI.php'); |
@@ -3297,8 +3473,9 @@ discard block |
||
| 3297 | 3473 | if (!$testAPI->isSupported()) |
| 3298 | 3474 | { |
| 3299 | 3475 | // Can we save ourselves? |
| 3300 | - if (!empty($fallbackSMF) && is_null($overrideCache) && $tryAccelerator != 'smf') |
|
| 3301 | - return loadCacheAccelerator(null, false); |
|
| 3476 | + if (!empty($fallbackSMF) && is_null($overrideCache) && $tryAccelerator != 'smf') { |
|
| 3477 | + return loadCacheAccelerator(null, false); |
|
| 3478 | + } |
|
| 3302 | 3479 | return false; |
| 3303 | 3480 | } |
| 3304 | 3481 | |
@@ -3310,9 +3487,9 @@ discard block |
||
| 3310 | 3487 | { |
| 3311 | 3488 | $cacheAPI = $testAPI; |
| 3312 | 3489 | return $cacheAPI; |
| 3490 | + } else { |
|
| 3491 | + return $testAPI; |
|
| 3313 | 3492 | } |
| 3314 | - else |
|
| 3315 | - return $testAPI; |
|
| 3316 | 3493 | } |
| 3317 | 3494 | } |
| 3318 | 3495 | |
@@ -3332,8 +3509,9 @@ discard block |
||
| 3332 | 3509 | |
| 3333 | 3510 | // @todo Why are we doing this if caching is disabled? |
| 3334 | 3511 | |
| 3335 | - if (function_exists('call_integration_hook')) |
|
| 3336 | - call_integration_hook('pre_cache_quick_get', array(&$key, &$file, &$function, &$params, &$level)); |
|
| 3512 | + if (function_exists('call_integration_hook')) { |
|
| 3513 | + call_integration_hook('pre_cache_quick_get', array(&$key, &$file, &$function, &$params, &$level)); |
|
| 3514 | + } |
|
| 3337 | 3515 | |
| 3338 | 3516 | /* Refresh the cache if either: |
| 3339 | 3517 | 1. Caching is disabled. |
@@ -3347,16 +3525,19 @@ discard block |
||
| 3347 | 3525 | require_once($sourcedir . '/' . $file); |
| 3348 | 3526 | $cache_block = call_user_func_array($function, $params); |
| 3349 | 3527 | |
| 3350 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= $level) |
|
| 3351 | - cache_put_data($key, $cache_block, $cache_block['expires'] - time()); |
|
| 3528 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= $level) { |
|
| 3529 | + cache_put_data($key, $cache_block, $cache_block['expires'] - time()); |
|
| 3530 | + } |
|
| 3352 | 3531 | } |
| 3353 | 3532 | |
| 3354 | 3533 | // Some cached data may need a freshening up after retrieval. |
| 3355 | - if (!empty($cache_block['post_retri_eval'])) |
|
| 3356 | - eval($cache_block['post_retri_eval']); |
|
| 3534 | + if (!empty($cache_block['post_retri_eval'])) { |
|
| 3535 | + eval($cache_block['post_retri_eval']); |
|
| 3536 | + } |
|
| 3357 | 3537 | |
| 3358 | - if (function_exists('call_integration_hook')) |
|
| 3359 | - call_integration_hook('post_cache_quick_get', array(&$cache_block)); |
|
| 3538 | + if (function_exists('call_integration_hook')) { |
|
| 3539 | + call_integration_hook('post_cache_quick_get', array(&$cache_block)); |
|
| 3540 | + } |
|
| 3360 | 3541 | |
| 3361 | 3542 | return $cache_block['data']; |
| 3362 | 3543 | } |
@@ -3383,8 +3564,9 @@ discard block |
||
| 3383 | 3564 | global $smcFunc, $cache_enable, $cacheAPI; |
| 3384 | 3565 | global $cache_hits, $cache_count, $db_show_debug; |
| 3385 | 3566 | |
| 3386 | - if (empty($cache_enable) || empty($cacheAPI)) |
|
| 3387 | - return; |
|
| 3567 | + if (empty($cache_enable) || empty($cacheAPI)) { |
|
| 3568 | + return; |
|
| 3569 | + } |
|
| 3388 | 3570 | |
| 3389 | 3571 | $cache_count = isset($cache_count) ? $cache_count + 1 : 1; |
| 3390 | 3572 | if (isset($db_show_debug) && $db_show_debug === true) |
@@ -3397,12 +3579,14 @@ discard block |
||
| 3397 | 3579 | $value = $value === null ? null : (isset($smcFunc['json_encode']) ? $smcFunc['json_encode']($value) : json_encode($value)); |
| 3398 | 3580 | $cacheAPI->putData($key, $value, $ttl); |
| 3399 | 3581 | |
| 3400 | - if (function_exists('call_integration_hook')) |
|
| 3401 | - call_integration_hook('cache_put_data', array(&$key, &$value, &$ttl)); |
|
| 3582 | + if (function_exists('call_integration_hook')) { |
|
| 3583 | + call_integration_hook('cache_put_data', array(&$key, &$value, &$ttl)); |
|
| 3584 | + } |
|
| 3402 | 3585 | |
| 3403 | - if (isset($db_show_debug) && $db_show_debug === true) |
|
| 3404 | - $cache_hits[$cache_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st)); |
|
| 3405 | -} |
|
| 3586 | + if (isset($db_show_debug) && $db_show_debug === true) { |
|
| 3587 | + $cache_hits[$cache_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st)); |
|
| 3588 | + } |
|
| 3589 | + } |
|
| 3406 | 3590 | |
| 3407 | 3591 | /** |
| 3408 | 3592 | * Gets the value from the cache specified by key, so long as it is not older than ttl seconds. |
@@ -3418,8 +3602,9 @@ discard block |
||
| 3418 | 3602 | global $smcFunc, $cache_enable, $cacheAPI; |
| 3419 | 3603 | global $cache_hits, $cache_count, $cache_misses, $cache_count_misses, $db_show_debug; |
| 3420 | 3604 | |
| 3421 | - if (empty($cache_enable) || empty($cacheAPI)) |
|
| 3422 | - return; |
|
| 3605 | + if (empty($cache_enable) || empty($cacheAPI)) { |
|
| 3606 | + return; |
|
| 3607 | + } |
|
| 3423 | 3608 | |
| 3424 | 3609 | $cache_count = isset($cache_count) ? $cache_count + 1 : 1; |
| 3425 | 3610 | if (isset($db_show_debug) && $db_show_debug === true) |
@@ -3439,16 +3624,18 @@ discard block |
||
| 3439 | 3624 | |
| 3440 | 3625 | if (empty($value)) |
| 3441 | 3626 | { |
| 3442 | - if (!is_array($cache_misses)) |
|
| 3443 | - $cache_misses = array(); |
|
| 3627 | + if (!is_array($cache_misses)) { |
|
| 3628 | + $cache_misses = array(); |
|
| 3629 | + } |
|
| 3444 | 3630 | |
| 3445 | 3631 | $cache_count_misses = isset($cache_count_misses) ? $cache_count_misses + 1 : 1; |
| 3446 | 3632 | $cache_misses[$cache_count_misses] = array('k' => $original_key, 'd' => 'get'); |
| 3447 | 3633 | } |
| 3448 | 3634 | } |
| 3449 | 3635 | |
| 3450 | - if (function_exists('call_integration_hook') && isset($value)) |
|
| 3451 | - call_integration_hook('cache_get_data', array(&$key, &$ttl, &$value)); |
|
| 3636 | + if (function_exists('call_integration_hook') && isset($value)) { |
|
| 3637 | + call_integration_hook('cache_get_data', array(&$key, &$ttl, &$value)); |
|
| 3638 | + } |
|
| 3452 | 3639 | |
| 3453 | 3640 | return empty($value) ? null : (isset($smcFunc['json_decode']) ? $smcFunc['json_decode']($value, true) : smf_json_decode($value, true)); |
| 3454 | 3641 | } |
@@ -3470,8 +3657,9 @@ discard block |
||
| 3470 | 3657 | global $cacheAPI; |
| 3471 | 3658 | |
| 3472 | 3659 | // If we can't get to the API, can't do this. |
| 3473 | - if (empty($cacheAPI)) |
|
| 3474 | - return; |
|
| 3660 | + if (empty($cacheAPI)) { |
|
| 3661 | + return; |
|
| 3662 | + } |
|
| 3475 | 3663 | |
| 3476 | 3664 | // Ask the API to do the heavy lifting. cleanCache also calls invalidateCache to be sure. |
| 3477 | 3665 | $cacheAPI->cleanCache($type); |
@@ -3496,8 +3684,9 @@ discard block |
||
| 3496 | 3684 | global $modSettings, $boardurl, $smcFunc, $image_proxy_enabled, $user_info; |
| 3497 | 3685 | |
| 3498 | 3686 | // Come on! |
| 3499 | - if (empty($data)) |
|
| 3500 | - return array(); |
|
| 3687 | + if (empty($data)) { |
|
| 3688 | + return array(); |
|
| 3689 | + } |
|
| 3501 | 3690 | |
| 3502 | 3691 | // Set a nice default var. |
| 3503 | 3692 | $image = ''; |
@@ -3505,11 +3694,11 @@ discard block |
||
| 3505 | 3694 | // Gravatar has been set as mandatory! |
| 3506 | 3695 | if (!empty($modSettings['gravatarOverride'])) |
| 3507 | 3696 | { |
| 3508 | - if (!empty($modSettings['gravatarAllowExtraEmail']) && !empty($data['avatar']) && stristr($data['avatar'], 'gravatar://')) |
|
| 3509 | - $image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11)); |
|
| 3510 | - |
|
| 3511 | - else if (!empty($data['email'])) |
|
| 3512 | - $image = get_gravatar_url($data['email']); |
|
| 3697 | + if (!empty($modSettings['gravatarAllowExtraEmail']) && !empty($data['avatar']) && stristr($data['avatar'], 'gravatar://')) { |
|
| 3698 | + $image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11)); |
|
| 3699 | + } else if (!empty($data['email'])) { |
|
| 3700 | + $image = get_gravatar_url($data['email']); |
|
| 3701 | + } |
|
| 3513 | 3702 | } |
| 3514 | 3703 | |
| 3515 | 3704 | // Look if the user has a gravatar field or has set an external url as avatar. |
@@ -3521,54 +3710,60 @@ discard block |
||
| 3521 | 3710 | // Gravatar. |
| 3522 | 3711 | if (stristr($data['avatar'], 'gravatar://')) |
| 3523 | 3712 | { |
| 3524 | - if ($data['avatar'] == 'gravatar://') |
|
| 3525 | - $image = get_gravatar_url($data['email']); |
|
| 3526 | - |
|
| 3527 | - elseif (!empty($modSettings['gravatarAllowExtraEmail'])) |
|
| 3528 | - $image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11)); |
|
| 3713 | + if ($data['avatar'] == 'gravatar://') { |
|
| 3714 | + $image = get_gravatar_url($data['email']); |
|
| 3715 | + } elseif (!empty($modSettings['gravatarAllowExtraEmail'])) { |
|
| 3716 | + $image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11)); |
|
| 3717 | + } |
|
| 3529 | 3718 | } |
| 3530 | 3719 | |
| 3531 | 3720 | // External url. |
| 3532 | 3721 | else |
| 3533 | 3722 | { |
| 3534 | 3723 | // Using ssl? |
| 3535 | - if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($data['avatar'], 'http://') !== false && empty($user_info['possibly_robot'])) |
|
| 3536 | - $image = get_proxied_url($data['avatar']); |
|
| 3724 | + if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($data['avatar'], 'http://') !== false && empty($user_info['possibly_robot'])) { |
|
| 3725 | + $image = get_proxied_url($data['avatar']); |
|
| 3726 | + } |
|
| 3537 | 3727 | |
| 3538 | 3728 | // Just a plain external url. |
| 3539 | - else |
|
| 3540 | - $image = (stristr($data['avatar'], 'http://') || stristr($data['avatar'], 'https://')) ? $data['avatar'] : $modSettings['avatar_url'] . '/' . $data['avatar']; |
|
| 3729 | + else { |
|
| 3730 | + $image = (stristr($data['avatar'], 'http://') || stristr($data['avatar'], 'https://')) ? $data['avatar'] : $modSettings['avatar_url'] . '/' . $data['avatar']; |
|
| 3731 | + } |
|
| 3541 | 3732 | } |
| 3542 | 3733 | } |
| 3543 | 3734 | |
| 3544 | 3735 | // Perhaps this user has an attachment as avatar... |
| 3545 | - else if (!empty($data['filename'])) |
|
| 3546 | - $image = $modSettings['custom_avatar_url'] . '/' . $data['filename']; |
|
| 3736 | + else if (!empty($data['filename'])) { |
|
| 3737 | + $image = $modSettings['custom_avatar_url'] . '/' . $data['filename']; |
|
| 3738 | + } |
|
| 3547 | 3739 | |
| 3548 | 3740 | // Right... no avatar... use our default image. |
| 3549 | - else |
|
| 3550 | - $image = $modSettings['avatar_url'] . '/default.png'; |
|
| 3741 | + else { |
|
| 3742 | + $image = $modSettings['avatar_url'] . '/default.png'; |
|
| 3743 | + } |
|
| 3551 | 3744 | } |
| 3552 | 3745 | |
| 3553 | 3746 | call_integration_hook('integrate_set_avatar_data', array(&$image, &$data)); |
| 3554 | 3747 | |
| 3555 | 3748 | // At this point in time $image has to be filled unless you chose to force gravatar and the user doesn't have the needed data to retrieve it... thus a check for !empty() is still needed. |
| 3556 | - if (!empty($image)) |
|
| 3557 | - return array( |
|
| 3749 | + if (!empty($image)) { |
|
| 3750 | + return array( |
|
| 3558 | 3751 | 'name' => !empty($data['avatar']) ? $data['avatar'] : '', |
| 3559 | 3752 | 'image' => '<img class="avatar" src="' . $image . '" />', |
| 3560 | 3753 | 'href' => $image, |
| 3561 | 3754 | 'url' => $image, |
| 3562 | 3755 | ); |
| 3756 | + } |
|
| 3563 | 3757 | |
| 3564 | 3758 | // Fallback to make life easier for everyone... |
| 3565 | - else |
|
| 3566 | - return array( |
|
| 3759 | + else { |
|
| 3760 | + return array( |
|
| 3567 | 3761 | 'name' => '', |
| 3568 | 3762 | 'image' => '', |
| 3569 | 3763 | 'href' => '', |
| 3570 | 3764 | 'url' => '', |
| 3571 | 3765 | ); |
| 3572 | -} |
|
| 3766 | + } |
|
| 3767 | + } |
|
| 3573 | 3768 | |
| 3574 | 3769 | ?> |
| 3575 | 3770 | \ No newline at end of file |
@@ -500,7 +500,7 @@ discard block |
||
| 500 | 500 | /** |
| 501 | 501 | * Returns the amount of affected rows for a query. |
| 502 | 502 | * |
| 503 | - * @param mixed $result |
|
| 503 | + * @param resource|null $result |
|
| 504 | 504 | * |
| 505 | 505 | * @return int |
| 506 | 506 | * |
@@ -869,7 +869,7 @@ discard block |
||
| 869 | 869 | * |
| 870 | 870 | * @param string $db_name The database name |
| 871 | 871 | * @param resource $db_connection The database connection |
| 872 | - * @return true Always returns true |
|
| 872 | + * @return boolean Always returns true |
|
| 873 | 873 | */ |
| 874 | 874 | function smf_db_select_db($db_name, $db_connection) |
| 875 | 875 | { |
@@ -199,22 +199,22 @@ discard block |
||
| 199 | 199 | |
| 200 | 200 | case 'date': |
| 201 | 201 | if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d)$~', $replacement, $date_matches) === 1) |
| 202 | - return sprintf('\'%04d-%02d-%02d\'', $date_matches[1], $date_matches[2], $date_matches[3]).'::date'; |
|
| 202 | + return sprintf('\'%04d-%02d-%02d\'', $date_matches[1], $date_matches[2], $date_matches[3]) . '::date'; |
|
| 203 | 203 | else |
| 204 | 204 | smf_db_error_backtrace('Wrong value type sent to the database. Date expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
| 205 | 205 | break; |
| 206 | 206 | |
| 207 | 207 | case 'time': |
| 208 | 208 | if (preg_match('~^([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $time_matches) === 1) |
| 209 | - return sprintf('\'%02d:%02d:%02d\'', $time_matches[1], $time_matches[2], $time_matches[3]).'::time'; |
|
| 209 | + return sprintf('\'%02d:%02d:%02d\'', $time_matches[1], $time_matches[2], $time_matches[3]) . '::time'; |
|
| 210 | 210 | else |
| 211 | 211 | smf_db_error_backtrace('Wrong value type sent to the database. Time expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
| 212 | 212 | break; |
| 213 | 213 | |
| 214 | 214 | case 'datetime': |
| 215 | 215 | if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d) ([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $datetime_matches) === 1) |
| 216 | - return 'to_timestamp('. |
|
| 217 | - sprintf('\'%04d-%02d-%02d %02d:%02d:%02d\'', $datetime_matches[1], $datetime_matches[2], $datetime_matches[3], $datetime_matches[4], $datetime_matches[5] ,$datetime_matches[6]). |
|
| 216 | + return 'to_timestamp(' . |
|
| 217 | + sprintf('\'%04d-%02d-%02d %02d:%02d:%02d\'', $datetime_matches[1], $datetime_matches[2], $datetime_matches[3], $datetime_matches[4], $datetime_matches[5], $datetime_matches[6]) . |
|
| 218 | 218 | ',\'YYYY-MM-DD HH24:MI:SS\')'; |
| 219 | 219 | else |
| 220 | 220 | smf_db_error_backtrace('Wrong value type sent to the database. Datetime expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
@@ -424,7 +424,7 @@ discard block |
||
| 424 | 424 | $old_pos = 0; |
| 425 | 425 | $pos = -1; |
| 426 | 426 | // Remove the string escape for better runtime |
| 427 | - $db_string_1 = str_replace('\'\'','',$db_string); |
|
| 427 | + $db_string_1 = str_replace('\'\'', '', $db_string); |
|
| 428 | 428 | while (true) |
| 429 | 429 | { |
| 430 | 430 | $pos = strpos($db_string_1, '\'', $pos + 1); |
@@ -802,7 +802,7 @@ discard block |
||
| 802 | 802 | if (!empty($keys) && (count($keys) > 0) && $returnmode > 0) |
| 803 | 803 | { |
| 804 | 804 | // we only take the first key |
| 805 | - $returning = ' RETURNING '.$keys[0]; |
|
| 805 | + $returning = ' RETURNING ' . $keys[0]; |
|
| 806 | 806 | $with_returning = true; |
| 807 | 807 | } |
| 808 | 808 | |
@@ -833,7 +833,7 @@ discard block |
||
| 833 | 833 | INSERT INTO ' . $table . '("' . implode('", "', $indexed_columns) . '") |
| 834 | 834 | VALUES |
| 835 | 835 | ' . implode(', |
| 836 | - ', $insertRows).$replace.$returning, |
|
| 836 | + ', $insertRows) . $replace . $returning, |
|
| 837 | 837 | array( |
| 838 | 838 | 'security_override' => true, |
| 839 | 839 | 'db_error_skip' => $method == 'ignore' || $table === $db_prefix . 'log_errors', |
@@ -846,7 +846,7 @@ discard block |
||
| 846 | 846 | if ($returnmode === 2) |
| 847 | 847 | $return_var = array(); |
| 848 | 848 | |
| 849 | - while(($row = $smcFunc['db_fetch_row']($request)) && $with_returning) |
|
| 849 | + while (($row = $smcFunc['db_fetch_row']($request)) && $with_returning) |
|
| 850 | 850 | { |
| 851 | 851 | if (is_numeric($row[0])) // try to emulate mysql limitation |
| 852 | 852 | { |
@@ -1009,7 +1009,7 @@ discard block |
||
| 1009 | 1009 | */ |
| 1010 | 1010 | function smf_db_custom_order($field, $array_values, $desc = false) |
| 1011 | 1011 | { |
| 1012 | - $return = 'CASE '. $field . ' '; |
|
| 1012 | + $return = 'CASE ' . $field . ' '; |
|
| 1013 | 1013 | $count = count($array_values); |
| 1014 | 1014 | $then = ($desc ? ' THEN -' : ' THEN '); |
| 1015 | 1015 | |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 4 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * Maps the implementations in this file (smf_db_function_name) |
@@ -34,8 +35,8 @@ discard block |
||
| 34 | 35 | global $smcFunc; |
| 35 | 36 | |
| 36 | 37 | // Map some database specific functions, only do this once. |
| 37 | - if (!isset($smcFunc['db_fetch_assoc'])) |
|
| 38 | - $smcFunc += array( |
|
| 38 | + if (!isset($smcFunc['db_fetch_assoc'])) { |
|
| 39 | + $smcFunc += array( |
|
| 39 | 40 | 'db_query' => 'smf_db_query', |
| 40 | 41 | 'db_quote' => 'smf_db_quote', |
| 41 | 42 | 'db_insert' => 'smf_db_insert', |
@@ -65,15 +66,18 @@ discard block |
||
| 65 | 66 | 'db_custom_order' => 'smf_db_custom_order', |
| 66 | 67 | 'db_native_replace' => 'smf_db_native_replace', |
| 67 | 68 | ); |
| 69 | + } |
|
| 68 | 70 | |
| 69 | 71 | // We are not going to make it very far without these. |
| 70 | - if (!function_exists('pg_pconnect')) |
|
| 71 | - display_db_error(); |
|
| 72 | + if (!function_exists('pg_pconnect')) { |
|
| 73 | + display_db_error(); |
|
| 74 | + } |
|
| 72 | 75 | |
| 73 | - if (!empty($db_options['persist'])) |
|
| 74 | - $connection = @pg_pconnect((empty($db_server) ? '' : 'host=' . $db_server . ' ') . 'dbname=' . $db_name . ' user=\'' . $db_user . '\' password=\'' . $db_passwd . '\'' . (empty($db_options['port']) ? '' : ' port=\'' . $db_options['port'] . '\'')); |
|
| 75 | - else |
|
| 76 | - $connection = @pg_connect((empty($db_server) ? '' : 'host=' . $db_server . ' ') . 'dbname=' . $db_name . ' user=\'' . $db_user . '\' password=\'' . $db_passwd . '\'' . (empty($db_options['port']) ? '' : ' port=\'' . $db_options['port'] . '\'')); |
|
| 76 | + if (!empty($db_options['persist'])) { |
|
| 77 | + $connection = @pg_pconnect((empty($db_server) ? '' : 'host=' . $db_server . ' ') . 'dbname=' . $db_name . ' user=\'' . $db_user . '\' password=\'' . $db_passwd . '\'' . (empty($db_options['port']) ? '' : ' port=\'' . $db_options['port'] . '\'')); |
|
| 78 | + } else { |
|
| 79 | + $connection = @pg_connect((empty($db_server) ? '' : 'host=' . $db_server . ' ') . 'dbname=' . $db_name . ' user=\'' . $db_user . '\' password=\'' . $db_passwd . '\'' . (empty($db_options['port']) ? '' : ' port=\'' . $db_options['port'] . '\'')); |
|
| 80 | + } |
|
| 77 | 81 | |
| 78 | 82 | // Something's wrong, show an error if its fatal (which we assume it is) |
| 79 | 83 | if (!$connection) |
@@ -81,8 +85,7 @@ discard block |
||
| 81 | 85 | if (!empty($db_options['non_fatal'])) |
| 82 | 86 | { |
| 83 | 87 | return null; |
| 84 | - } |
|
| 85 | - else |
|
| 88 | + } else |
|
| 86 | 89 | { |
| 87 | 90 | display_db_error(); |
| 88 | 91 | } |
@@ -133,31 +136,38 @@ discard block |
||
| 133 | 136 | |
| 134 | 137 | list ($values, $connection) = $db_callback; |
| 135 | 138 | |
| 136 | - if ($matches[1] === 'db_prefix') |
|
| 137 | - return $db_prefix; |
|
| 139 | + if ($matches[1] === 'db_prefix') { |
|
| 140 | + return $db_prefix; |
|
| 141 | + } |
|
| 138 | 142 | |
| 139 | - if (isset($user_info[$matches[1]]) && strpos($matches[1], 'query_') !== false) |
|
| 140 | - return $user_info[$matches[1]]; |
|
| 143 | + if (isset($user_info[$matches[1]]) && strpos($matches[1], 'query_') !== false) { |
|
| 144 | + return $user_info[$matches[1]]; |
|
| 145 | + } |
|
| 141 | 146 | |
| 142 | - if ($matches[1] === 'empty') |
|
| 143 | - return '\'\''; |
|
| 147 | + if ($matches[1] === 'empty') { |
|
| 148 | + return '\'\''; |
|
| 149 | + } |
|
| 144 | 150 | |
| 145 | - if (!isset($matches[2])) |
|
| 146 | - smf_db_error_backtrace('Invalid value inserted or no type specified.', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 151 | + if (!isset($matches[2])) { |
|
| 152 | + smf_db_error_backtrace('Invalid value inserted or no type specified.', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 153 | + } |
|
| 147 | 154 | |
| 148 | - if ($matches[1] === 'literal') |
|
| 149 | - return '\'' . pg_escape_string($matches[2]) . '\''; |
|
| 155 | + if ($matches[1] === 'literal') { |
|
| 156 | + return '\'' . pg_escape_string($matches[2]) . '\''; |
|
| 157 | + } |
|
| 150 | 158 | |
| 151 | - if (!isset($values[$matches[2]])) |
|
| 152 | - smf_db_error_backtrace('The database value you\'re trying to insert does not exist: ' . (isset($smcFunc['htmlspecialchars']) ? $smcFunc['htmlspecialchars']($matches[2]) : htmlspecialchars($matches[2])), '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 159 | + if (!isset($values[$matches[2]])) { |
|
| 160 | + smf_db_error_backtrace('The database value you\'re trying to insert does not exist: ' . (isset($smcFunc['htmlspecialchars']) ? $smcFunc['htmlspecialchars']($matches[2]) : htmlspecialchars($matches[2])), '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 161 | + } |
|
| 153 | 162 | |
| 154 | 163 | $replacement = $values[$matches[2]]; |
| 155 | 164 | |
| 156 | 165 | switch ($matches[1]) |
| 157 | 166 | { |
| 158 | 167 | case 'int': |
| 159 | - if (!is_numeric($replacement) || (string) $replacement !== (string) (int) $replacement) |
|
| 160 | - smf_db_error_backtrace('Wrong value type sent to the database. Integer expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 168 | + if (!is_numeric($replacement) || (string) $replacement !== (string) (int) $replacement) { |
|
| 169 | + smf_db_error_backtrace('Wrong value type sent to the database. Integer expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 170 | + } |
|
| 161 | 171 | return (string) (int) $replacement; |
| 162 | 172 | break; |
| 163 | 173 | |
@@ -169,65 +179,73 @@ discard block |
||
| 169 | 179 | case 'array_int': |
| 170 | 180 | if (is_array($replacement)) |
| 171 | 181 | { |
| 172 | - if (empty($replacement)) |
|
| 173 | - smf_db_error_backtrace('Database error, given array of integer values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 182 | + if (empty($replacement)) { |
|
| 183 | + smf_db_error_backtrace('Database error, given array of integer values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 184 | + } |
|
| 174 | 185 | |
| 175 | 186 | foreach ($replacement as $key => $value) |
| 176 | 187 | { |
| 177 | - if (!is_numeric($value) || (string) $value !== (string) (int) $value) |
|
| 178 | - smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 188 | + if (!is_numeric($value) || (string) $value !== (string) (int) $value) { |
|
| 189 | + smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 190 | + } |
|
| 179 | 191 | |
| 180 | 192 | $replacement[$key] = (string) (int) $value; |
| 181 | 193 | } |
| 182 | 194 | |
| 183 | 195 | return implode(', ', $replacement); |
| 196 | + } else { |
|
| 197 | + smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 184 | 198 | } |
| 185 | - else |
|
| 186 | - smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 187 | 199 | |
| 188 | 200 | break; |
| 189 | 201 | |
| 190 | 202 | case 'array_string': |
| 191 | 203 | if (is_array($replacement)) |
| 192 | 204 | { |
| 193 | - if (empty($replacement)) |
|
| 194 | - smf_db_error_backtrace('Database error, given array of string values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 205 | + if (empty($replacement)) { |
|
| 206 | + smf_db_error_backtrace('Database error, given array of string values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 207 | + } |
|
| 195 | 208 | |
| 196 | - foreach ($replacement as $key => $value) |
|
| 197 | - $replacement[$key] = sprintf('\'%1$s\'', pg_escape_string($value)); |
|
| 209 | + foreach ($replacement as $key => $value) { |
|
| 210 | + $replacement[$key] = sprintf('\'%1$s\'', pg_escape_string($value)); |
|
| 211 | + } |
|
| 198 | 212 | |
| 199 | 213 | return implode(', ', $replacement); |
| 214 | + } else { |
|
| 215 | + smf_db_error_backtrace('Wrong value type sent to the database. Array of strings expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 200 | 216 | } |
| 201 | - else |
|
| 202 | - smf_db_error_backtrace('Wrong value type sent to the database. Array of strings expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 203 | 217 | break; |
| 204 | 218 | |
| 205 | 219 | case 'date': |
| 206 | - if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d)$~', $replacement, $date_matches) === 1) |
|
| 207 | - return sprintf('\'%04d-%02d-%02d\'', $date_matches[1], $date_matches[2], $date_matches[3]).'::date'; |
|
| 208 | - else |
|
| 209 | - smf_db_error_backtrace('Wrong value type sent to the database. Date expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 220 | + if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d)$~', $replacement, $date_matches) === 1) { |
|
| 221 | + return sprintf('\'%04d-%02d-%02d\'', $date_matches[1], $date_matches[2], $date_matches[3]).'::date'; |
|
| 222 | + } else { |
|
| 223 | + smf_db_error_backtrace('Wrong value type sent to the database. Date expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 224 | + } |
|
| 210 | 225 | break; |
| 211 | 226 | |
| 212 | 227 | case 'time': |
| 213 | - if (preg_match('~^([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $time_matches) === 1) |
|
| 214 | - return sprintf('\'%02d:%02d:%02d\'', $time_matches[1], $time_matches[2], $time_matches[3]).'::time'; |
|
| 215 | - else |
|
| 216 | - smf_db_error_backtrace('Wrong value type sent to the database. Time expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 228 | + if (preg_match('~^([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $time_matches) === 1) { |
|
| 229 | + return sprintf('\'%02d:%02d:%02d\'', $time_matches[1], $time_matches[2], $time_matches[3]).'::time'; |
|
| 230 | + } else { |
|
| 231 | + smf_db_error_backtrace('Wrong value type sent to the database. Time expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 232 | + } |
|
| 217 | 233 | break; |
| 218 | 234 | |
| 219 | 235 | case 'datetime': |
| 220 | - if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d) ([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $datetime_matches) === 1) |
|
| 221 | - return 'to_timestamp('. |
|
| 236 | + if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d) ([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $datetime_matches) === 1) { |
|
| 237 | + return 'to_timestamp('. |
|
| 222 | 238 | sprintf('\'%04d-%02d-%02d %02d:%02d:%02d\'', $datetime_matches[1], $datetime_matches[2], $datetime_matches[3], $datetime_matches[4], $datetime_matches[5] ,$datetime_matches[6]). |
| 223 | 239 | ',\'YYYY-MM-DD HH24:MI:SS\')'; |
| 224 | - else |
|
| 225 | - smf_db_error_backtrace('Wrong value type sent to the database. Datetime expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 240 | + } else { |
|
| 241 | + smf_db_error_backtrace('Wrong value type sent to the database. Datetime expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 242 | + } |
|
| 226 | 243 | break; |
| 227 | 244 | |
| 228 | 245 | case 'float': |
| 229 | - if (!is_numeric($replacement)) |
|
| 230 | - smf_db_error_backtrace('Wrong value type sent to the database. Floating point number expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 246 | + if (!is_numeric($replacement)) { |
|
| 247 | + smf_db_error_backtrace('Wrong value type sent to the database. Floating point number expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 248 | + } |
|
| 231 | 249 | return (string) (float) $replacement; |
| 232 | 250 | break; |
| 233 | 251 | |
@@ -240,31 +258,36 @@ discard block |
||
| 240 | 258 | break; |
| 241 | 259 | |
| 242 | 260 | case 'inet': |
| 243 | - if ($replacement == 'null' || $replacement == '') |
|
| 244 | - return 'null'; |
|
| 245 | - if (inet_pton($replacement) === false) |
|
| 246 | - smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 261 | + if ($replacement == 'null' || $replacement == '') { |
|
| 262 | + return 'null'; |
|
| 263 | + } |
|
| 264 | + if (inet_pton($replacement) === false) { |
|
| 265 | + smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 266 | + } |
|
| 247 | 267 | return sprintf('\'%1$s\'::inet', pg_escape_string($replacement)); |
| 248 | 268 | |
| 249 | 269 | case 'array_inet': |
| 250 | 270 | if (is_array($replacement)) |
| 251 | 271 | { |
| 252 | - if (empty($replacement)) |
|
| 253 | - smf_db_error_backtrace('Database error, given array of IPv4 or IPv6 values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 272 | + if (empty($replacement)) { |
|
| 273 | + smf_db_error_backtrace('Database error, given array of IPv4 or IPv6 values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 274 | + } |
|
| 254 | 275 | |
| 255 | 276 | foreach ($replacement as $key => $value) |
| 256 | 277 | { |
| 257 | - if ($replacement == 'null' || $replacement == '') |
|
| 258 | - $replacement[$key] = 'null'; |
|
| 259 | - if (!isValidIP($value)) |
|
| 260 | - smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 278 | + if ($replacement == 'null' || $replacement == '') { |
|
| 279 | + $replacement[$key] = 'null'; |
|
| 280 | + } |
|
| 281 | + if (!isValidIP($value)) { |
|
| 282 | + smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 283 | + } |
|
| 261 | 284 | $replacement[$key] = sprintf('\'%1$s\'::inet', pg_escape_string($value)); |
| 262 | 285 | } |
| 263 | 286 | |
| 264 | 287 | return implode(', ', $replacement); |
| 288 | + } else { |
|
| 289 | + smf_db_error_backtrace('Wrong value type sent to the database. Array of IPv4 or IPv6 expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 265 | 290 | } |
| 266 | - else |
|
| 267 | - smf_db_error_backtrace('Wrong value type sent to the database. Array of IPv4 or IPv6 expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 268 | 291 | break; |
| 269 | 292 | |
| 270 | 293 | default: |
@@ -352,14 +375,16 @@ discard block |
||
| 352 | 375 | ), |
| 353 | 376 | ); |
| 354 | 377 | |
| 355 | - if (isset($replacements[$identifier])) |
|
| 356 | - $db_string = preg_replace(array_keys($replacements[$identifier]), array_values($replacements[$identifier]), $db_string); |
|
| 378 | + if (isset($replacements[$identifier])) { |
|
| 379 | + $db_string = preg_replace(array_keys($replacements[$identifier]), array_values($replacements[$identifier]), $db_string); |
|
| 380 | + } |
|
| 357 | 381 | |
| 358 | 382 | // Limits need to be a little different. |
| 359 | 383 | $db_string = preg_replace('~\sLIMIT\s(\d+|{int:.+}),\s*(\d+|{int:.+})\s*$~i', 'LIMIT $2 OFFSET $1', $db_string); |
| 360 | 384 | |
| 361 | - if (trim($db_string) == '') |
|
| 362 | - return false; |
|
| 385 | + if (trim($db_string) == '') { |
|
| 386 | + return false; |
|
| 387 | + } |
|
| 363 | 388 | |
| 364 | 389 | // Comments that are allowed in a query are preg_removed. |
| 365 | 390 | static $allowed_comments_from = array( |
@@ -379,8 +404,9 @@ discard block |
||
| 379 | 404 | $db_count = !isset($db_count) ? 1 : $db_count + 1; |
| 380 | 405 | $db_replace_result = 0; |
| 381 | 406 | |
| 382 | - if (empty($modSettings['disableQueryCheck']) && strpos($db_string, '\'') !== false && empty($db_values['security_override'])) |
|
| 383 | - smf_db_error_backtrace('Hacking attempt...', 'Illegal character (\') used in query...', true, __FILE__, __LINE__); |
|
| 407 | + if (empty($modSettings['disableQueryCheck']) && strpos($db_string, '\'') !== false && empty($db_values['security_override'])) { |
|
| 408 | + smf_db_error_backtrace('Hacking attempt...', 'Illegal character (\') used in query...', true, __FILE__, __LINE__); |
|
| 409 | + } |
|
| 384 | 410 | |
| 385 | 411 | if (empty($db_values['security_override']) && (!empty($db_values) || strpos($db_string, '{db_prefix}') !== false)) |
| 386 | 412 | { |
@@ -405,17 +431,18 @@ discard block |
||
| 405 | 431 | while (true) |
| 406 | 432 | { |
| 407 | 433 | $pos = strpos($db_string_1, '\'', $pos + 1); |
| 408 | - if ($pos === false) |
|
| 409 | - break; |
|
| 434 | + if ($pos === false) { |
|
| 435 | + break; |
|
| 436 | + } |
|
| 410 | 437 | $clean .= substr($db_string_1, $old_pos, $pos - $old_pos); |
| 411 | 438 | |
| 412 | 439 | while (true) |
| 413 | 440 | { |
| 414 | 441 | $pos1 = strpos($db_string_1, '\'', $pos + 1); |
| 415 | 442 | $pos2 = strpos($db_string_1, '\\', $pos + 1); |
| 416 | - if ($pos1 === false) |
|
| 417 | - break; |
|
| 418 | - elseif ($pos2 === false || $pos2 > $pos1) |
|
| 443 | + if ($pos1 === false) { |
|
| 444 | + break; |
|
| 445 | + } elseif ($pos2 === false || $pos2 > $pos1) |
|
| 419 | 446 | { |
| 420 | 447 | $pos = $pos1; |
| 421 | 448 | break; |
@@ -431,16 +458,19 @@ discard block |
||
| 431 | 458 | $clean = trim(strtolower(preg_replace($allowed_comments_from, $allowed_comments_to, $clean))); |
| 432 | 459 | |
| 433 | 460 | // Comments? We don't use comments in our queries, we leave 'em outside! |
| 434 | - if (strpos($clean, '/*') > 2 || strpos($clean, '--') !== false || strpos($clean, ';') !== false) |
|
| 435 | - $fail = true; |
|
| 461 | + if (strpos($clean, '/*') > 2 || strpos($clean, '--') !== false || strpos($clean, ';') !== false) { |
|
| 462 | + $fail = true; |
|
| 463 | + } |
|
| 436 | 464 | // Trying to change passwords, slow us down, or something? |
| 437 | - elseif (strpos($clean, 'sleep') !== false && preg_match('~(^|[^a-z])sleep($|[^[_a-z])~s', $clean) != 0) |
|
| 438 | - $fail = true; |
|
| 439 | - elseif (strpos($clean, 'benchmark') !== false && preg_match('~(^|[^a-z])benchmark($|[^[a-z])~s', $clean) != 0) |
|
| 440 | - $fail = true; |
|
| 465 | + elseif (strpos($clean, 'sleep') !== false && preg_match('~(^|[^a-z])sleep($|[^[_a-z])~s', $clean) != 0) { |
|
| 466 | + $fail = true; |
|
| 467 | + } elseif (strpos($clean, 'benchmark') !== false && preg_match('~(^|[^a-z])benchmark($|[^[a-z])~s', $clean) != 0) { |
|
| 468 | + $fail = true; |
|
| 469 | + } |
|
| 441 | 470 | |
| 442 | - if (!empty($fail) && function_exists('log_error')) |
|
| 443 | - smf_db_error_backtrace('Hacking attempt...', 'Hacking attempt...' . "\n" . $db_string, E_USER_ERROR, __FILE__, __LINE__); |
|
| 471 | + if (!empty($fail) && function_exists('log_error')) { |
|
| 472 | + smf_db_error_backtrace('Hacking attempt...', 'Hacking attempt...' . "\n" . $db_string, E_USER_ERROR, __FILE__, __LINE__); |
|
| 473 | + } |
|
| 444 | 474 | } |
| 445 | 475 | |
| 446 | 476 | // Set optimize stuff |
@@ -467,8 +497,9 @@ discard block |
||
| 467 | 497 | list ($file, $line) = smf_db_error_backtrace('', '', 'return', __FILE__, __LINE__); |
| 468 | 498 | |
| 469 | 499 | // Initialize $db_cache if not already initialized. |
| 470 | - if (!isset($db_cache)) |
|
| 471 | - $db_cache = array(); |
|
| 500 | + if (!isset($db_cache)) { |
|
| 501 | + $db_cache = array(); |
|
| 502 | + } |
|
| 472 | 503 | |
| 473 | 504 | if (!empty($_SESSION['debug_redirect'])) |
| 474 | 505 | { |
@@ -486,12 +517,14 @@ discard block |
||
| 486 | 517 | |
| 487 | 518 | $db_last_result = @pg_query($connection, $db_string); |
| 488 | 519 | |
| 489 | - if ($db_last_result === false && empty($db_values['db_error_skip'])) |
|
| 490 | - $db_last_result = smf_db_error($db_string, $connection); |
|
| 520 | + if ($db_last_result === false && empty($db_values['db_error_skip'])) { |
|
| 521 | + $db_last_result = smf_db_error($db_string, $connection); |
|
| 522 | + } |
|
| 491 | 523 | |
| 492 | 524 | // Debugging. |
| 493 | - if (isset($db_show_debug) && $db_show_debug === true) |
|
| 494 | - $db_cache[$db_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st)); |
|
| 525 | + if (isset($db_show_debug) && $db_show_debug === true) { |
|
| 526 | + $db_cache[$db_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st)); |
|
| 527 | + } |
|
| 495 | 528 | |
| 496 | 529 | return $db_last_result; |
| 497 | 530 | } |
@@ -508,10 +541,11 @@ discard block |
||
| 508 | 541 | { |
| 509 | 542 | global $db_last_result, $db_replace_result; |
| 510 | 543 | |
| 511 | - if ($db_replace_result) |
|
| 512 | - return $db_replace_result; |
|
| 513 | - elseif ($result === null && !$db_last_result) |
|
| 514 | - return 0; |
|
| 544 | + if ($db_replace_result) { |
|
| 545 | + return $db_replace_result; |
|
| 546 | + } elseif ($result === null && !$db_last_result) { |
|
| 547 | + return 0; |
|
| 548 | + } |
|
| 515 | 549 | |
| 516 | 550 | return pg_affected_rows($result === null ? $db_last_result : $result); |
| 517 | 551 | } |
@@ -535,8 +569,9 @@ discard block |
||
| 535 | 569 | array( |
| 536 | 570 | ) |
| 537 | 571 | ); |
| 538 | - if (!$request) |
|
| 539 | - return false; |
|
| 572 | + if (!$request) { |
|
| 573 | + return false; |
|
| 574 | + } |
|
| 540 | 575 | list ($lastID) = $smcFunc['db_fetch_row']($request); |
| 541 | 576 | $smcFunc['db_free_result']($request); |
| 542 | 577 | |
@@ -557,12 +592,13 @@ discard block |
||
| 557 | 592 | // Decide which connection to use |
| 558 | 593 | $connection = $connection === null ? $db_connection : $connection; |
| 559 | 594 | |
| 560 | - if ($type == 'begin') |
|
| 561 | - return @pg_query($connection, 'BEGIN'); |
|
| 562 | - elseif ($type == 'rollback') |
|
| 563 | - return @pg_query($connection, 'ROLLBACK'); |
|
| 564 | - elseif ($type == 'commit') |
|
| 565 | - return @pg_query($connection, 'COMMIT'); |
|
| 595 | + if ($type == 'begin') { |
|
| 596 | + return @pg_query($connection, 'BEGIN'); |
|
| 597 | + } elseif ($type == 'rollback') { |
|
| 598 | + return @pg_query($connection, 'ROLLBACK'); |
|
| 599 | + } elseif ($type == 'commit') { |
|
| 600 | + return @pg_query($connection, 'COMMIT'); |
|
| 601 | + } |
|
| 566 | 602 | |
| 567 | 603 | return false; |
| 568 | 604 | } |
@@ -590,19 +626,22 @@ discard block |
||
| 590 | 626 | $query_error = @pg_last_error($connection); |
| 591 | 627 | |
| 592 | 628 | // Log the error. |
| 593 | - if (function_exists('log_error')) |
|
| 594 | - log_error($txt['database_error'] . ': ' . $query_error . (!empty($modSettings['enableErrorQueryLogging']) ? "\n\n" . $db_string : ''), 'database', $file, $line); |
|
| 629 | + if (function_exists('log_error')) { |
|
| 630 | + log_error($txt['database_error'] . ': ' . $query_error . (!empty($modSettings['enableErrorQueryLogging']) ? "\n\n" . $db_string : ''), 'database', $file, $line); |
|
| 631 | + } |
|
| 595 | 632 | |
| 596 | 633 | // Nothing's defined yet... just die with it. |
| 597 | - if (empty($context) || empty($txt)) |
|
| 598 | - die($query_error); |
|
| 634 | + if (empty($context) || empty($txt)) { |
|
| 635 | + die($query_error); |
|
| 636 | + } |
|
| 599 | 637 | |
| 600 | 638 | // Show an error message, if possible. |
| 601 | 639 | $context['error_title'] = $txt['database_error']; |
| 602 | - if (allowedTo('admin_forum')) |
|
| 603 | - $context['error_message'] = nl2br($query_error) . '<br>' . $txt['file'] . ': ' . $file . '<br>' . $txt['line'] . ': ' . $line; |
|
| 604 | - else |
|
| 605 | - $context['error_message'] = $txt['try_again']; |
|
| 640 | + if (allowedTo('admin_forum')) { |
|
| 641 | + $context['error_message'] = nl2br($query_error) . '<br>' . $txt['file'] . ': ' . $file . '<br>' . $txt['line'] . ': ' . $line; |
|
| 642 | + } else { |
|
| 643 | + $context['error_message'] = $txt['try_again']; |
|
| 644 | + } |
|
| 606 | 645 | |
| 607 | 646 | if (allowedTo('admin_forum') && isset($db_show_debug) && $db_show_debug === true) |
| 608 | 647 | { |
@@ -624,12 +663,14 @@ discard block |
||
| 624 | 663 | { |
| 625 | 664 | global $db_row_count; |
| 626 | 665 | |
| 627 | - if ($counter !== false) |
|
| 628 | - return pg_fetch_row($request, $counter); |
|
| 666 | + if ($counter !== false) { |
|
| 667 | + return pg_fetch_row($request, $counter); |
|
| 668 | + } |
|
| 629 | 669 | |
| 630 | 670 | // Reset the row counter... |
| 631 | - if (!isset($db_row_count[(int) $request])) |
|
| 632 | - $db_row_count[(int) $request] = 0; |
|
| 671 | + if (!isset($db_row_count[(int) $request])) { |
|
| 672 | + $db_row_count[(int) $request] = 0; |
|
| 673 | + } |
|
| 633 | 674 | |
| 634 | 675 | // Return the right row. |
| 635 | 676 | return @pg_fetch_row($request, $db_row_count[(int) $request]++); |
@@ -646,12 +687,14 @@ discard block |
||
| 646 | 687 | { |
| 647 | 688 | global $db_row_count; |
| 648 | 689 | |
| 649 | - if ($counter !== false) |
|
| 650 | - return pg_fetch_assoc($request, $counter); |
|
| 690 | + if ($counter !== false) { |
|
| 691 | + return pg_fetch_assoc($request, $counter); |
|
| 692 | + } |
|
| 651 | 693 | |
| 652 | 694 | // Reset the row counter... |
| 653 | - if (!isset($db_row_count[(int) $request])) |
|
| 654 | - $db_row_count[(int) $request] = 0; |
|
| 695 | + if (!isset($db_row_count[(int) $request])) { |
|
| 696 | + $db_row_count[(int) $request] = 0; |
|
| 697 | + } |
|
| 655 | 698 | |
| 656 | 699 | // Return the right row. |
| 657 | 700 | return @pg_fetch_assoc($request, $db_row_count[(int) $request]++); |
@@ -704,11 +747,13 @@ discard block |
||
| 704 | 747 | |
| 705 | 748 | $replace = ''; |
| 706 | 749 | |
| 707 | - if (empty($data)) |
|
| 708 | - return; |
|
| 750 | + if (empty($data)) { |
|
| 751 | + return; |
|
| 752 | + } |
|
| 709 | 753 | |
| 710 | - if (!is_array($data[array_rand($data)])) |
|
| 711 | - $data = array($data); |
|
| 754 | + if (!is_array($data[array_rand($data)])) { |
|
| 755 | + $data = array($data); |
|
| 756 | + } |
|
| 712 | 757 | |
| 713 | 758 | // Replace the prefix holder with the actual prefix. |
| 714 | 759 | $table = str_replace('{db_prefix}', $db_prefix, $table); |
@@ -734,32 +779,35 @@ discard block |
||
| 734 | 779 | $key_str .= ($count_pk > 0 ? ',' : ''); |
| 735 | 780 | $key_str .= $columnName; |
| 736 | 781 | $count_pk++; |
| 737 | - } |
|
| 738 | - else if ($method == 'replace') //normal field |
|
| 782 | + } else if ($method == 'replace') { |
|
| 783 | + //normal field |
|
| 739 | 784 | { |
| 740 | 785 | $col_str .= ($count > 0 ? ',' : ''); |
| 786 | + } |
|
| 741 | 787 | $col_str .= $columnName . ' = EXCLUDED.' . $columnName; |
| 742 | 788 | $count++; |
| 743 | 789 | } |
| 744 | 790 | } |
| 745 | - if ($method == 'replace') |
|
| 746 | - $replace = ' ON CONFLICT (' . $key_str . ') DO UPDATE SET ' . $col_str; |
|
| 747 | - else |
|
| 748 | - $replace = ' ON CONFLICT (' . $key_str . ') DO NOTHING'; |
|
| 749 | - } |
|
| 750 | - else if ($method == 'replace') |
|
| 791 | + if ($method == 'replace') { |
|
| 792 | + $replace = ' ON CONFLICT (' . $key_str . ') DO UPDATE SET ' . $col_str; |
|
| 793 | + } else { |
|
| 794 | + $replace = ' ON CONFLICT (' . $key_str . ') DO NOTHING'; |
|
| 795 | + } |
|
| 796 | + } else if ($method == 'replace') |
|
| 751 | 797 | { |
| 752 | 798 | foreach ($columns as $columnName => $type) |
| 753 | 799 | { |
| 754 | 800 | // Are we restricting the length? |
| 755 | - if (strpos($type, 'string-') !== false) |
|
| 756 | - $actualType = sprintf($columnName . ' = SUBSTRING({string:%1$s}, 1, ' . substr($type, 7) . '), ', $count); |
|
| 757 | - else |
|
| 758 | - $actualType = sprintf($columnName . ' = {%1$s:%2$s}, ', $type, $count); |
|
| 801 | + if (strpos($type, 'string-') !== false) { |
|
| 802 | + $actualType = sprintf($columnName . ' = SUBSTRING({string:%1$s}, 1, ' . substr($type, 7) . '), ', $count); |
|
| 803 | + } else { |
|
| 804 | + $actualType = sprintf($columnName . ' = {%1$s:%2$s}, ', $type, $count); |
|
| 805 | + } |
|
| 759 | 806 | |
| 760 | 807 | // A key? That's what we were looking for. |
| 761 | - if (in_array($columnName, $keys)) |
|
| 762 | - $where .= (empty($where) ? '' : ' AND ') . substr($actualType, 0, -2); |
|
| 808 | + if (in_array($columnName, $keys)) { |
|
| 809 | + $where .= (empty($where) ? '' : ' AND ') . substr($actualType, 0, -2); |
|
| 810 | + } |
|
| 763 | 811 | $count++; |
| 764 | 812 | } |
| 765 | 813 | |
@@ -795,10 +843,11 @@ discard block |
||
| 795 | 843 | foreach ($columns as $columnName => $type) |
| 796 | 844 | { |
| 797 | 845 | // Are we restricting the length? |
| 798 | - if (strpos($type, 'string-') !== false) |
|
| 799 | - $insertData .= sprintf('SUBSTRING({string:%1$s}, 1, ' . substr($type, 7) . '), ', $columnName); |
|
| 800 | - else |
|
| 801 | - $insertData .= sprintf('{%1$s:%2$s}, ', $type, $columnName); |
|
| 846 | + if (strpos($type, 'string-') !== false) { |
|
| 847 | + $insertData .= sprintf('SUBSTRING({string:%1$s}, 1, ' . substr($type, 7) . '), ', $columnName); |
|
| 848 | + } else { |
|
| 849 | + $insertData .= sprintf('{%1$s:%2$s}, ', $type, $columnName); |
|
| 850 | + } |
|
| 802 | 851 | } |
| 803 | 852 | $insertData = substr($insertData, 0, -2) . ')'; |
| 804 | 853 | |
@@ -807,8 +856,9 @@ discard block |
||
| 807 | 856 | |
| 808 | 857 | // Here's where the variables are injected to the query. |
| 809 | 858 | $insertRows = array(); |
| 810 | - foreach ($data as $dataRow) |
|
| 811 | - $insertRows[] = smf_db_quote($insertData, array_combine($indexed_columns, $dataRow), $connection); |
|
| 859 | + foreach ($data as $dataRow) { |
|
| 860 | + $insertRows[] = smf_db_quote($insertData, array_combine($indexed_columns, $dataRow), $connection); |
|
| 861 | + } |
|
| 812 | 862 | |
| 813 | 863 | // Do the insert. |
| 814 | 864 | $request = $smcFunc['db_query']('', ' |
@@ -825,19 +875,21 @@ discard block |
||
| 825 | 875 | |
| 826 | 876 | if ($with_returning && $request !== false) |
| 827 | 877 | { |
| 828 | - if ($returnmode === 2) |
|
| 829 | - $return_var = array(); |
|
| 878 | + if ($returnmode === 2) { |
|
| 879 | + $return_var = array(); |
|
| 880 | + } |
|
| 830 | 881 | |
| 831 | 882 | while(($row = $smcFunc['db_fetch_row']($request)) && $with_returning) |
| 832 | 883 | { |
| 833 | - if (is_numeric($row[0])) // try to emulate mysql limitation |
|
| 884 | + if (is_numeric($row[0])) { |
|
| 885 | + // try to emulate mysql limitation |
|
| 834 | 886 | { |
| 835 | 887 | if ($returnmode === 1) |
| 836 | 888 | $return_var = $row[0]; |
| 837 | - elseif ($returnmode === 2) |
|
| 838 | - $return_var[] = $row[0]; |
|
| 839 | - } |
|
| 840 | - else |
|
| 889 | + } elseif ($returnmode === 2) { |
|
| 890 | + $return_var[] = $row[0]; |
|
| 891 | + } |
|
| 892 | + } else |
|
| 841 | 893 | { |
| 842 | 894 | $with_returning = false; |
| 843 | 895 | trigger_error('trying to returning ID Field which is not a Int field', E_USER_ERROR); |
@@ -846,9 +898,10 @@ discard block |
||
| 846 | 898 | } |
| 847 | 899 | } |
| 848 | 900 | |
| 849 | - if ($with_returning && !empty($return_var)) |
|
| 850 | - return $return_var; |
|
| 851 | -} |
|
| 901 | + if ($with_returning && !empty($return_var)) { |
|
| 902 | + return $return_var; |
|
| 903 | + } |
|
| 904 | + } |
|
| 852 | 905 | |
| 853 | 906 | /** |
| 854 | 907 | * Dummy function really. Doesn't do anything on PostgreSQL. |
@@ -885,8 +938,9 @@ discard block |
||
| 885 | 938 | */ |
| 886 | 939 | function smf_db_error_backtrace($error_message, $log_message = '', $error_type = false, $file = null, $line = null) |
| 887 | 940 | { |
| 888 | - if (empty($log_message)) |
|
| 889 | - $log_message = $error_message; |
|
| 941 | + if (empty($log_message)) { |
|
| 942 | + $log_message = $error_message; |
|
| 943 | + } |
|
| 890 | 944 | |
| 891 | 945 | foreach (debug_backtrace() as $step) |
| 892 | 946 | { |
@@ -905,12 +959,14 @@ discard block |
||
| 905 | 959 | } |
| 906 | 960 | |
| 907 | 961 | // A special case - we want the file and line numbers for debugging. |
| 908 | - if ($error_type == 'return') |
|
| 909 | - return array($file, $line); |
|
| 962 | + if ($error_type == 'return') { |
|
| 963 | + return array($file, $line); |
|
| 964 | + } |
|
| 910 | 965 | |
| 911 | 966 | // Is always a critical error. |
| 912 | - if (function_exists('log_error')) |
|
| 913 | - log_error($log_message, 'critical', $file, $line); |
|
| 967 | + if (function_exists('log_error')) { |
|
| 968 | + log_error($log_message, 'critical', $file, $line); |
|
| 969 | + } |
|
| 914 | 970 | |
| 915 | 971 | if (function_exists('fatal_error')) |
| 916 | 972 | { |
@@ -918,12 +974,12 @@ discard block |
||
| 918 | 974 | |
| 919 | 975 | // Cannot continue... |
| 920 | 976 | exit; |
| 977 | + } elseif ($error_type) { |
|
| 978 | + trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : ''), $error_type); |
|
| 979 | + } else { |
|
| 980 | + trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : '')); |
|
| 981 | + } |
|
| 921 | 982 | } |
| 922 | - elseif ($error_type) |
|
| 923 | - trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : ''), $error_type); |
|
| 924 | - else |
|
| 925 | - trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : '')); |
|
| 926 | -} |
|
| 927 | 983 | |
| 928 | 984 | /** |
| 929 | 985 | * Escape the LIKE wildcards so that they match the character and not the wildcard. |
@@ -940,10 +996,11 @@ discard block |
||
| 940 | 996 | '\\' => '\\\\', |
| 941 | 997 | ); |
| 942 | 998 | |
| 943 | - if ($translate_human_wildcards) |
|
| 944 | - $replacements += array( |
|
| 999 | + if ($translate_human_wildcards) { |
|
| 1000 | + $replacements += array( |
|
| 945 | 1001 | '*' => '%', |
| 946 | 1002 | ); |
| 1003 | + } |
|
| 947 | 1004 | |
| 948 | 1005 | return strtr($string, $replacements); |
| 949 | 1006 | } |
@@ -972,14 +1029,16 @@ discard block |
||
| 972 | 1029 | static $pg_error_data_prep; |
| 973 | 1030 | |
| 974 | 1031 | // without database we can't do anything |
| 975 | - if (empty($db_connection)) |
|
| 976 | - return; |
|
| 1032 | + if (empty($db_connection)) { |
|
| 1033 | + return; |
|
| 1034 | + } |
|
| 977 | 1035 | |
| 978 | - if (empty($pg_error_data_prep)) |
|
| 979 | - $pg_error_data_prep = pg_prepare($db_connection, 'smf_log_errors', |
|
| 1036 | + if (empty($pg_error_data_prep)) { |
|
| 1037 | + $pg_error_data_prep = pg_prepare($db_connection, 'smf_log_errors', |
|
| 980 | 1038 | 'INSERT INTO ' . $db_prefix . 'log_errors(id_member, log_time, ip, url, message, session, error_type, file, line, backtrace) |
| 981 | 1039 | VALUES( $1, $2, $3, $4, $5, $6, $7, $8, $9, $10)' |
| 982 | 1040 | ); |
| 1041 | + } |
|
| 983 | 1042 | |
| 984 | 1043 | pg_execute($db_connection, 'smf_log_errors', $error_array); |
| 985 | 1044 | } |
@@ -999,8 +1058,9 @@ discard block |
||
| 999 | 1058 | $count = count($array_values); |
| 1000 | 1059 | $then = ($desc ? ' THEN -' : ' THEN '); |
| 1001 | 1060 | |
| 1002 | - for ($i = 0; $i < $count; $i++) |
|
| 1003 | - $return .= 'WHEN ' . (int) $array_values[$i] . $then . $i . ' '; |
|
| 1061 | + for ($i = 0; $i < $count; $i++) { |
|
| 1062 | + $return .= 'WHEN ' . (int) $array_values[$i] . $then . $i . ' '; |
|
| 1063 | + } |
|
| 1004 | 1064 | |
| 1005 | 1065 | $return .= 'END'; |
| 1006 | 1066 | return $return; |
@@ -1023,11 +1083,13 @@ discard block |
||
| 1023 | 1083 | //pg 9.5 got replace support |
| 1024 | 1084 | $pg_version = $smcFunc['db_get_version'](); |
| 1025 | 1085 | // if we got a Beta Version |
| 1026 | - if (stripos($pg_version, 'beta') !== false) |
|
| 1027 | - $pg_version = substr($pg_version, 0, stripos($pg_version, 'beta')) . '.0'; |
|
| 1086 | + if (stripos($pg_version, 'beta') !== false) { |
|
| 1087 | + $pg_version = substr($pg_version, 0, stripos($pg_version, 'beta')) . '.0'; |
|
| 1088 | + } |
|
| 1028 | 1089 | // or RC |
| 1029 | - if (stripos($pg_version, 'rc') !== false) |
|
| 1030 | - $pg_version = substr($pg_version, 0, stripos($pg_version, 'rc')) . '.0'; |
|
| 1090 | + if (stripos($pg_version, 'rc') !== false) { |
|
| 1091 | + $pg_version = substr($pg_version, 0, stripos($pg_version, 'rc')) . '.0'; |
|
| 1092 | + } |
|
| 1031 | 1093 | |
| 1032 | 1094 | $replace_support = (version_compare($pg_version, '9.5.0', '>=') ? true : false); |
| 1033 | 1095 | } |
@@ -1334,7 +1334,7 @@ discard block |
||
| 1334 | 1334 | 'class' => 'centercol', |
| 1335 | 1335 | ), |
| 1336 | 1336 | 'data' => array( |
| 1337 | - 'function' => function ($rowData) |
|
| 1337 | + 'function' => function($rowData) |
|
| 1338 | 1338 | { |
| 1339 | 1339 | $isChecked = $rowData['disabled'] ? '' : ' checked'; |
| 1340 | 1340 | $onClickHandler = $rowData['can_show_register'] ? sprintf(' onclick="document.getElementById(\'reg_%1$s\').disabled = !this.checked;"', $rowData['id']) : ''; |
@@ -1350,7 +1350,7 @@ discard block |
||
| 1350 | 1350 | 'class' => 'centercol', |
| 1351 | 1351 | ), |
| 1352 | 1352 | 'data' => array( |
| 1353 | - 'function' => function ($rowData) |
|
| 1353 | + 'function' => function($rowData) |
|
| 1354 | 1354 | { |
| 1355 | 1355 | $isChecked = $rowData['on_register'] && !$rowData['disabled'] ? ' checked' : ''; |
| 1356 | 1356 | $isDisabled = $rowData['can_show_register'] ? '' : ' disabled'; |
@@ -1397,15 +1397,15 @@ discard block |
||
| 1397 | 1397 | 'value' => $txt['custom_profile_fieldorder'], |
| 1398 | 1398 | ), |
| 1399 | 1399 | 'data' => array( |
| 1400 | - 'function' => function ($rowData) use ($context, $txt, $scripturl) |
|
| 1400 | + 'function' => function($rowData) use ($context, $txt, $scripturl) |
|
| 1401 | 1401 | { |
| 1402 | - $return = '<p class="centertext bold_text">'. $rowData['field_order'] .'<br>'; |
|
| 1402 | + $return = '<p class="centertext bold_text">' . $rowData['field_order'] . '<br>'; |
|
| 1403 | 1403 | |
| 1404 | 1404 | if ($rowData['field_order'] > 1) |
| 1405 | - $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=up"><span class="toggle_up" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_up'] .'"></span></a>'; |
|
| 1405 | + $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=up"><span class="toggle_up" title="' . $txt['custom_edit_order_move'] . ' ' . $txt['custom_edit_order_up'] . '"></span></a>'; |
|
| 1406 | 1406 | |
| 1407 | 1407 | if ($rowData['field_order'] < $context['custFieldsMaxOrder']) |
| 1408 | - $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=down"><span class="toggle_down" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_down'] .'"></span></a>'; |
|
| 1408 | + $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=down"><span class="toggle_down" title="' . $txt['custom_edit_order_move'] . ' ' . $txt['custom_edit_order_down'] . '"></span></a>'; |
|
| 1409 | 1409 | |
| 1410 | 1410 | $return .= '</p>'; |
| 1411 | 1411 | |
@@ -1423,7 +1423,7 @@ discard block |
||
| 1423 | 1423 | 'value' => $txt['custom_profile_fieldname'], |
| 1424 | 1424 | ), |
| 1425 | 1425 | 'data' => array( |
| 1426 | - 'function' => function ($rowData) use ($scripturl) |
|
| 1426 | + 'function' => function($rowData) use ($scripturl) |
|
| 1427 | 1427 | { |
| 1428 | 1428 | return sprintf('<a href="%1$s?action=admin;area=featuresettings;sa=profileedit;fid=%2$d">%3$s</a><div class="smalltext">%4$s</div>', $scripturl, $rowData['id_field'], $rowData['field_name'], $rowData['field_desc']); |
| 1429 | 1429 | }, |
@@ -1439,7 +1439,7 @@ discard block |
||
| 1439 | 1439 | 'value' => $txt['custom_profile_fieldtype'], |
| 1440 | 1440 | ), |
| 1441 | 1441 | 'data' => array( |
| 1442 | - 'function' => function ($rowData) use ($txt) |
|
| 1442 | + 'function' => function($rowData) use ($txt) |
|
| 1443 | 1443 | { |
| 1444 | 1444 | $textKey = sprintf('custom_profile_type_%1$s', $rowData['field_type']); |
| 1445 | 1445 | return isset($txt[$textKey]) ? $txt[$textKey] : $textKey; |
@@ -1457,7 +1457,7 @@ discard block |
||
| 1457 | 1457 | 'value' => $txt['custom_profile_active'], |
| 1458 | 1458 | ), |
| 1459 | 1459 | 'data' => array( |
| 1460 | - 'function' => function ($rowData) use ($txt) |
|
| 1460 | + 'function' => function($rowData) use ($txt) |
|
| 1461 | 1461 | { |
| 1462 | 1462 | return $rowData['active'] ? $txt['yes'] : $txt['no']; |
| 1463 | 1463 | }, |
@@ -1474,7 +1474,7 @@ discard block |
||
| 1474 | 1474 | 'value' => $txt['custom_profile_placement'], |
| 1475 | 1475 | ), |
| 1476 | 1476 | 'data' => array( |
| 1477 | - 'function' => function ($rowData) |
|
| 1477 | + 'function' => function($rowData) |
|
| 1478 | 1478 | { |
| 1479 | 1479 | global $txt, $context; |
| 1480 | 1480 | |
@@ -1709,7 +1709,7 @@ discard block |
||
| 1709 | 1709 | redirectexit('action=admin;area=featuresettings;sa=profile'); // @todo implement an error handler |
| 1710 | 1710 | |
| 1711 | 1711 | // All good, proceed. |
| 1712 | - $smcFunc['db_query']('',' |
|
| 1712 | + $smcFunc['db_query']('', ' |
|
| 1713 | 1713 | UPDATE {db_prefix}custom_fields |
| 1714 | 1714 | SET field_order = {int:old_order} |
| 1715 | 1715 | WHERE field_order = {int:new_order}', |
@@ -1718,7 +1718,7 @@ discard block |
||
| 1718 | 1718 | 'old_order' => $context['field']['order'], |
| 1719 | 1719 | ) |
| 1720 | 1720 | ); |
| 1721 | - $smcFunc['db_query']('',' |
|
| 1721 | + $smcFunc['db_query']('', ' |
|
| 1722 | 1722 | UPDATE {db_prefix}custom_fields |
| 1723 | 1723 | SET field_order = {int:new_order} |
| 1724 | 1724 | WHERE id_field = {int:id_field}', |
@@ -1820,7 +1820,7 @@ discard block |
||
| 1820 | 1820 | $smcFunc['db_free_result']($request); |
| 1821 | 1821 | |
| 1822 | 1822 | $unique = false; |
| 1823 | - for ($i = 0; !$unique && $i < 9; $i ++) |
|
| 1823 | + for ($i = 0; !$unique && $i < 9; $i++) |
|
| 1824 | 1824 | { |
| 1825 | 1825 | if (!in_array($col_name, $current_fields)) |
| 1826 | 1826 | $unique = true; |
@@ -1993,7 +1993,7 @@ discard block |
||
| 1993 | 1993 | ); |
| 1994 | 1994 | |
| 1995 | 1995 | // Re-arrange the order. |
| 1996 | - $smcFunc['db_query']('',' |
|
| 1996 | + $smcFunc['db_query']('', ' |
|
| 1997 | 1997 | UPDATE {db_prefix}custom_fields |
| 1998 | 1998 | SET field_order = field_order - 1 |
| 1999 | 1999 | WHERE field_order > {int:current_order}', |
@@ -2257,7 +2257,7 @@ discard block |
||
| 2257 | 2257 | $context['token_check'] = 'noti-admin'; |
| 2258 | 2258 | |
| 2259 | 2259 | // Specify our action since we'll want to post back here instead of the profile |
| 2260 | - $context['action'] = 'action=admin;area=featuresettings;sa=alerts;'. $context['session_var'] .'='. $context['session_id']; |
|
| 2260 | + $context['action'] = 'action=admin;area=featuresettings;sa=alerts;' . $context['session_var'] . '=' . $context['session_id']; |
|
| 2261 | 2261 | |
| 2262 | 2262 | loadTemplate('Profile'); |
| 2263 | 2263 | loadLanguage('Profile'); |
@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | * @version 2.1 Beta 4 |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | -if (!defined('SMF')) |
|
| 17 | +if (!defined('SMF')) { |
|
| 18 | 18 | die('No direct access...'); |
| 19 | +} |
|
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * This function makes sure the requested subaction does exists, if it doesn't, it sets a default action or. |
@@ -206,16 +207,18 @@ discard block |
||
| 206 | 207 | { |
| 207 | 208 | $all_zones = timezone_identifiers_list(); |
| 208 | 209 | // Make sure we set the value to the same as the printed value. |
| 209 | - foreach ($all_zones as $zone) |
|
| 210 | - $config_vars['default_timezone'][2][$zone] = $zone; |
|
| 210 | + foreach ($all_zones as $zone) { |
|
| 211 | + $config_vars['default_timezone'][2][$zone] = $zone; |
|
| 212 | + } |
|
| 213 | + } else { |
|
| 214 | + unset($config_vars['default_timezone']); |
|
| 211 | 215 | } |
| 212 | - else |
|
| 213 | - unset($config_vars['default_timezone']); |
|
| 214 | 216 | |
| 215 | 217 | call_integration_hook('integrate_modify_basic_settings', array(&$config_vars)); |
| 216 | 218 | |
| 217 | - if ($return_config) |
|
| 218 | - return $config_vars; |
|
| 219 | + if ($return_config) { |
|
| 220 | + return $config_vars; |
|
| 221 | + } |
|
| 219 | 222 | |
| 220 | 223 | // Saving? |
| 221 | 224 | if (isset($_GET['save'])) |
@@ -223,8 +226,9 @@ discard block |
||
| 223 | 226 | checkSession(); |
| 224 | 227 | |
| 225 | 228 | // Prevent absurd boundaries here - make it a day tops. |
| 226 | - if (isset($_POST['lastActive'])) |
|
| 227 | - $_POST['lastActive'] = min((int) $_POST['lastActive'], 1440); |
|
| 229 | + if (isset($_POST['lastActive'])) { |
|
| 230 | + $_POST['lastActive'] = min((int) $_POST['lastActive'], 1440); |
|
| 231 | + } |
|
| 228 | 232 | |
| 229 | 233 | call_integration_hook('integrate_save_basic_settings'); |
| 230 | 234 | |
@@ -232,8 +236,9 @@ discard block |
||
| 232 | 236 | $_SESSION['adm-save'] = true; |
| 233 | 237 | |
| 234 | 238 | // Do a bit of housekeeping |
| 235 | - if (empty($_POST['minimize_files'])) |
|
| 236 | - deleteAllMinified(); |
|
| 239 | + if (empty($_POST['minimize_files'])) { |
|
| 240 | + deleteAllMinified(); |
|
| 241 | + } |
|
| 237 | 242 | |
| 238 | 243 | writeLog(); |
| 239 | 244 | redirectexit('action=admin;area=featuresettings;sa=basic'); |
@@ -273,8 +278,9 @@ discard block |
||
| 273 | 278 | |
| 274 | 279 | call_integration_hook('integrate_modify_bbc_settings', array(&$config_vars)); |
| 275 | 280 | |
| 276 | - if ($return_config) |
|
| 277 | - return $config_vars; |
|
| 281 | + if ($return_config) { |
|
| 282 | + return $config_vars; |
|
| 283 | + } |
|
| 278 | 284 | |
| 279 | 285 | // Setup the template. |
| 280 | 286 | require_once($sourcedir . '/ManageServer.php'); |
@@ -291,13 +297,15 @@ discard block |
||
| 291 | 297 | |
| 292 | 298 | // Clean up the tags. |
| 293 | 299 | $bbcTags = array(); |
| 294 | - foreach (parse_bbc(false) as $tag) |
|
| 295 | - $bbcTags[] = $tag['tag']; |
|
| 300 | + foreach (parse_bbc(false) as $tag) { |
|
| 301 | + $bbcTags[] = $tag['tag']; |
|
| 302 | + } |
|
| 296 | 303 | |
| 297 | - if (!isset($_POST['disabledBBC_enabledTags'])) |
|
| 298 | - $_POST['disabledBBC_enabledTags'] = array(); |
|
| 299 | - elseif (!is_array($_POST['disabledBBC_enabledTags'])) |
|
| 300 | - $_POST['disabledBBC_enabledTags'] = array($_POST['disabledBBC_enabledTags']); |
|
| 304 | + if (!isset($_POST['disabledBBC_enabledTags'])) { |
|
| 305 | + $_POST['disabledBBC_enabledTags'] = array(); |
|
| 306 | + } elseif (!is_array($_POST['disabledBBC_enabledTags'])) { |
|
| 307 | + $_POST['disabledBBC_enabledTags'] = array($_POST['disabledBBC_enabledTags']); |
|
| 308 | + } |
|
| 301 | 309 | // Work out what is actually disabled! |
| 302 | 310 | $_POST['disabledBBC'] = implode(',', array_diff($bbcTags, $_POST['disabledBBC_enabledTags'])); |
| 303 | 311 | |
@@ -341,8 +349,9 @@ discard block |
||
| 341 | 349 | |
| 342 | 350 | call_integration_hook('integrate_layout_settings', array(&$config_vars)); |
| 343 | 351 | |
| 344 | - if ($return_config) |
|
| 345 | - return $config_vars; |
|
| 352 | + if ($return_config) { |
|
| 353 | + return $config_vars; |
|
| 354 | + } |
|
| 346 | 355 | |
| 347 | 356 | // Saving? |
| 348 | 357 | if (isset($_GET['save'])) |
@@ -382,8 +391,9 @@ discard block |
||
| 382 | 391 | |
| 383 | 392 | call_integration_hook('integrate_likes_settings', array(&$config_vars)); |
| 384 | 393 | |
| 385 | - if ($return_config) |
|
| 386 | - return $config_vars; |
|
| 394 | + if ($return_config) { |
|
| 395 | + return $config_vars; |
|
| 396 | + } |
|
| 387 | 397 | |
| 388 | 398 | // Saving? |
| 389 | 399 | if (isset($_GET['save'])) |
@@ -421,8 +431,9 @@ discard block |
||
| 421 | 431 | |
| 422 | 432 | call_integration_hook('integrate_mentions_settings', array(&$config_vars)); |
| 423 | 433 | |
| 424 | - if ($return_config) |
|
| 425 | - return $config_vars; |
|
| 434 | + if ($return_config) { |
|
| 435 | + return $config_vars; |
|
| 436 | + } |
|
| 426 | 437 | |
| 427 | 438 | // Saving? |
| 428 | 439 | if (isset($_GET['save'])) |
@@ -466,8 +477,8 @@ discard block |
||
| 466 | 477 | 'enable' => array('check', 'warning_enable'), |
| 467 | 478 | ); |
| 468 | 479 | |
| 469 | - if (!empty($modSettings['warning_settings']) && $currently_enabled) |
|
| 470 | - $config_vars += array( |
|
| 480 | + if (!empty($modSettings['warning_settings']) && $currently_enabled) { |
|
| 481 | + $config_vars += array( |
|
| 471 | 482 | '', |
| 472 | 483 | array('int', 'warning_watch', 'subtext' => $txt['setting_warning_watch_note'] . ' ' . $txt['zero_to_disable']), |
| 473 | 484 | 'moderate' => array('int', 'warning_moderate', 'subtext' => $txt['setting_warning_moderate_note'] . ' ' . $txt['zero_to_disable']), |
@@ -476,15 +487,18 @@ discard block |
||
| 476 | 487 | 'rem2' => array('int', 'warning_decrement', 'subtext' => $txt['setting_warning_decrement_note'] . ' ' . $txt['zero_to_disable']), |
| 477 | 488 | array('permissions', 'view_warning'), |
| 478 | 489 | ); |
| 490 | + } |
|
| 479 | 491 | |
| 480 | 492 | call_integration_hook('integrate_warning_settings', array(&$config_vars)); |
| 481 | 493 | |
| 482 | - if ($return_config) |
|
| 483 | - return $config_vars; |
|
| 494 | + if ($return_config) { |
|
| 495 | + return $config_vars; |
|
| 496 | + } |
|
| 484 | 497 | |
| 485 | 498 | // Cannot use moderation if post moderation is not enabled. |
| 486 | - if (!$modSettings['postmod_active']) |
|
| 487 | - unset($config_vars['moderate']); |
|
| 499 | + if (!$modSettings['postmod_active']) { |
|
| 500 | + unset($config_vars['moderate']); |
|
| 501 | + } |
|
| 488 | 502 | |
| 489 | 503 | // Will need the utility functions from here. |
| 490 | 504 | require_once($sourcedir . '/ManageServer.php'); |
@@ -509,16 +523,16 @@ discard block |
||
| 509 | 523 | 'warning_watch' => 10, |
| 510 | 524 | 'warning_mute' => 60, |
| 511 | 525 | ); |
| 512 | - if ($modSettings['postmod_active']) |
|
| 513 | - $vars['warning_moderate'] = 35; |
|
| 526 | + if ($modSettings['postmod_active']) { |
|
| 527 | + $vars['warning_moderate'] = 35; |
|
| 528 | + } |
|
| 514 | 529 | |
| 515 | 530 | foreach ($vars as $var => $value) |
| 516 | 531 | { |
| 517 | 532 | $config_vars[] = array('int', $var); |
| 518 | 533 | $_POST[$var] = $value; |
| 519 | 534 | } |
| 520 | - } |
|
| 521 | - else |
|
| 535 | + } else |
|
| 522 | 536 | { |
| 523 | 537 | $_POST['warning_watch'] = min($_POST['warning_watch'], 100); |
| 524 | 538 | $_POST['warning_moderate'] = $modSettings['postmod_active'] ? min($_POST['warning_moderate'], 100) : 0; |
@@ -606,8 +620,9 @@ discard block |
||
| 606 | 620 | |
| 607 | 621 | call_integration_hook('integrate_spam_settings', array(&$config_vars)); |
| 608 | 622 | |
| 609 | - if ($return_config) |
|
| 610 | - return $config_vars; |
|
| 623 | + if ($return_config) { |
|
| 624 | + return $config_vars; |
|
| 625 | + } |
|
| 611 | 626 | |
| 612 | 627 | // You need to be an admin to edit settings! |
| 613 | 628 | isAllowedTo('admin_forum'); |
@@ -641,8 +656,9 @@ discard block |
||
| 641 | 656 | |
| 642 | 657 | if (empty($context['qa_by_lang'][strtr($language, array('-utf8' => ''))]) && !empty($context['question_answers'])) |
| 643 | 658 | { |
| 644 | - if (empty($context['settings_insert_above'])) |
|
| 645 | - $context['settings_insert_above'] = ''; |
|
| 659 | + if (empty($context['settings_insert_above'])) { |
|
| 660 | + $context['settings_insert_above'] = ''; |
|
| 661 | + } |
|
| 646 | 662 | |
| 647 | 663 | $context['settings_insert_above'] .= '<div class="noticebox">' . sprintf($txt['question_not_defined'], $context['languages'][$language]['name']) . '</div>'; |
| 648 | 664 | } |
@@ -685,8 +701,9 @@ discard block |
||
| 685 | 701 | $_POST['pm_spam_settings'] = (int) $_POST['max_pm_recipients'] . ',' . (int) $_POST['pm_posts_verification'] . ',' . (int) $_POST['pm_posts_per_hour']; |
| 686 | 702 | |
| 687 | 703 | // Hack in guest requiring verification! |
| 688 | - if (empty($_POST['posts_require_captcha']) && !empty($_POST['guests_require_captcha'])) |
|
| 689 | - $_POST['posts_require_captcha'] = -1; |
|
| 704 | + if (empty($_POST['posts_require_captcha']) && !empty($_POST['guests_require_captcha'])) { |
|
| 705 | + $_POST['posts_require_captcha'] = -1; |
|
| 706 | + } |
|
| 690 | 707 | |
| 691 | 708 | $save_vars = $config_vars; |
| 692 | 709 | unset($save_vars['pm1'], $save_vars['pm2'], $save_vars['pm3'], $save_vars['guest_verify']); |
@@ -703,14 +720,16 @@ discard block |
||
| 703 | 720 | foreach ($context['qa_languages'] as $lang_id => $dummy) |
| 704 | 721 | { |
| 705 | 722 | // If we had some questions for this language before, but don't now, delete everything from that language. |
| 706 | - if ((!isset($_POST['question'][$lang_id]) || !is_array($_POST['question'][$lang_id])) && !empty($context['qa_by_lang'][$lang_id])) |
|
| 707 | - $changes['delete'] = array_merge($questions['delete'], $context['qa_by_lang'][$lang_id]); |
|
| 723 | + if ((!isset($_POST['question'][$lang_id]) || !is_array($_POST['question'][$lang_id])) && !empty($context['qa_by_lang'][$lang_id])) { |
|
| 724 | + $changes['delete'] = array_merge($questions['delete'], $context['qa_by_lang'][$lang_id]); |
|
| 725 | + } |
|
| 708 | 726 | |
| 709 | 727 | // Now step through and see if any existing questions no longer exist. |
| 710 | - if (!empty($context['qa_by_lang'][$lang_id])) |
|
| 711 | - foreach ($context['qa_by_lang'][$lang_id] as $q_id) |
|
| 728 | + if (!empty($context['qa_by_lang'][$lang_id])) { |
|
| 729 | + foreach ($context['qa_by_lang'][$lang_id] as $q_id) |
|
| 712 | 730 | if (empty($_POST['question'][$lang_id][$q_id])) |
| 713 | 731 | $changes['delete'][] = $q_id; |
| 732 | + } |
|
| 714 | 733 | |
| 715 | 734 | // Now let's see if there are new questions or ones that need updating. |
| 716 | 735 | if (isset($_POST['question'][$lang_id])) |
@@ -719,14 +738,16 @@ discard block |
||
| 719 | 738 | { |
| 720 | 739 | // Ignore junky ids. |
| 721 | 740 | $q_id = (int) $q_id; |
| 722 | - if ($q_id <= 0) |
|
| 723 | - continue; |
|
| 741 | + if ($q_id <= 0) { |
|
| 742 | + continue; |
|
| 743 | + } |
|
| 724 | 744 | |
| 725 | 745 | // Check the question isn't empty (because they want to delete it?) |
| 726 | 746 | if (empty($question) || trim($question) == '') |
| 727 | 747 | { |
| 728 | - if (isset($context['question_answers'][$q_id])) |
|
| 729 | - $changes['delete'][] = $q_id; |
|
| 748 | + if (isset($context['question_answers'][$q_id])) { |
|
| 749 | + $changes['delete'][] = $q_id; |
|
| 750 | + } |
|
| 730 | 751 | continue; |
| 731 | 752 | } |
| 732 | 753 | $question = $smcFunc['htmlspecialchars'](trim($question)); |
@@ -734,19 +755,22 @@ discard block |
||
| 734 | 755 | // Get the answers. Firstly check there actually might be some. |
| 735 | 756 | if (!isset($_POST['answer'][$lang_id][$q_id]) || !is_array($_POST['answer'][$lang_id][$q_id])) |
| 736 | 757 | { |
| 737 | - if (isset($context['question_answers'][$q_id])) |
|
| 738 | - $changes['delete'][] = $q_id; |
|
| 758 | + if (isset($context['question_answers'][$q_id])) { |
|
| 759 | + $changes['delete'][] = $q_id; |
|
| 760 | + } |
|
| 739 | 761 | continue; |
| 740 | 762 | } |
| 741 | 763 | // Now get them and check that they might be viable. |
| 742 | 764 | $answers = array(); |
| 743 | - foreach ($_POST['answer'][$lang_id][$q_id] as $answer) |
|
| 744 | - if (!empty($answer) && trim($answer) !== '') |
|
| 765 | + foreach ($_POST['answer'][$lang_id][$q_id] as $answer) { |
|
| 766 | + if (!empty($answer) && trim($answer) !== '') |
|
| 745 | 767 | $answers[] = $smcFunc['htmlspecialchars'](trim($answer)); |
| 768 | + } |
|
| 746 | 769 | if (empty($answers)) |
| 747 | 770 | { |
| 748 | - if (isset($context['question_answers'][$q_id])) |
|
| 749 | - $changes['delete'][] = $q_id; |
|
| 771 | + if (isset($context['question_answers'][$q_id])) { |
|
| 772 | + $changes['delete'][] = $q_id; |
|
| 773 | + } |
|
| 750 | 774 | continue; |
| 751 | 775 | } |
| 752 | 776 | $answers = $smcFunc['json_encode']($answers); |
@@ -756,16 +780,17 @@ discard block |
||
| 756 | 780 | { |
| 757 | 781 | // New question. Now, we don't want to randomly consume ids, so we'll set those, rather than trusting the browser's supplied ids. |
| 758 | 782 | $changes['insert'][] = array($lang_id, $question, $answers); |
| 759 | - } |
|
| 760 | - else |
|
| 783 | + } else |
|
| 761 | 784 | { |
| 762 | 785 | // It's an existing question. Let's see what's changed, if anything. |
| 763 | - if ($lang_id != $context['question_answers'][$q_id]['lngfile'] || $question != $context['question_answers'][$q_id]['question'] || $answers != $context['question_answers'][$q_id]['answers']) |
|
| 764 | - $changes['replace'][$q_id] = array('lngfile' => $lang_id, 'question' => $question, 'answers' => $answers); |
|
| 786 | + if ($lang_id != $context['question_answers'][$q_id]['lngfile'] || $question != $context['question_answers'][$q_id]['question'] || $answers != $context['question_answers'][$q_id]['answers']) { |
|
| 787 | + $changes['replace'][$q_id] = array('lngfile' => $lang_id, 'question' => $question, 'answers' => $answers); |
|
| 788 | + } |
|
| 765 | 789 | } |
| 766 | 790 | |
| 767 | - if (!isset($qs_per_lang[$lang_id])) |
|
| 768 | - $qs_per_lang[$lang_id] = 0; |
|
| 791 | + if (!isset($qs_per_lang[$lang_id])) { |
|
| 792 | + $qs_per_lang[$lang_id] = 0; |
|
| 793 | + } |
|
| 769 | 794 | $qs_per_lang[$lang_id]++; |
| 770 | 795 | } |
| 771 | 796 | } |
@@ -815,8 +840,9 @@ discard block |
||
| 815 | 840 | |
| 816 | 841 | // Lastly, the count of messages needs to be no more than the lowest number of questions for any one language. |
| 817 | 842 | $count_questions = empty($qs_per_lang) ? 0 : min($qs_per_lang); |
| 818 | - if (empty($count_questions) || $_POST['qa_verification_number'] > $count_questions) |
|
| 819 | - $_POST['qa_verification_number'] = $count_questions; |
|
| 843 | + if (empty($count_questions) || $_POST['qa_verification_number'] > $count_questions) { |
|
| 844 | + $_POST['qa_verification_number'] = $count_questions; |
|
| 845 | + } |
|
| 820 | 846 | |
| 821 | 847 | call_integration_hook('integrate_save_spam_settings', array(&$save_vars)); |
| 822 | 848 | |
@@ -831,24 +857,27 @@ discard block |
||
| 831 | 857 | |
| 832 | 858 | $character_range = array_merge(range('A', 'H'), array('K', 'M', 'N', 'P', 'R'), range('T', 'Y')); |
| 833 | 859 | $_SESSION['visual_verification_code'] = ''; |
| 834 | - for ($i = 0; $i < 6; $i++) |
|
| 835 | - $_SESSION['visual_verification_code'] .= $character_range[array_rand($character_range)]; |
|
| 860 | + for ($i = 0; $i < 6; $i++) { |
|
| 861 | + $_SESSION['visual_verification_code'] .= $character_range[array_rand($character_range)]; |
|
| 862 | + } |
|
| 836 | 863 | |
| 837 | 864 | // Some javascript for CAPTCHA. |
| 838 | 865 | $context['settings_post_javascript'] = ''; |
| 839 | - if ($context['use_graphic_library']) |
|
| 840 | - $context['settings_post_javascript'] .= ' |
|
| 866 | + if ($context['use_graphic_library']) { |
|
| 867 | + $context['settings_post_javascript'] .= ' |
|
| 841 | 868 | function refreshImages() |
| 842 | 869 | { |
| 843 | 870 | var imageType = document.getElementById(\'visual_verification_type\').value; |
| 844 | 871 | document.getElementById(\'verification_image\').src = \'' . $context['verification_image_href'] . ';type=\' + imageType; |
| 845 | 872 | }'; |
| 873 | + } |
|
| 846 | 874 | |
| 847 | 875 | // Show the image itself, or text saying we can't. |
| 848 | - if ($context['use_graphic_library']) |
|
| 849 | - $config_vars['vv']['postinput'] = '<br><img src="' . $context['verification_image_href'] . ';type=' . (empty($modSettings['visual_verification_type']) ? 0 : $modSettings['visual_verification_type']) . '" alt="' . $txt['setting_image_verification_sample'] . '" id="verification_image"><br>'; |
|
| 850 | - else |
|
| 851 | - $config_vars['vv']['postinput'] = '<br><span class="smalltext">' . $txt['setting_image_verification_nogd'] . '</span>'; |
|
| 876 | + if ($context['use_graphic_library']) { |
|
| 877 | + $config_vars['vv']['postinput'] = '<br><img src="' . $context['verification_image_href'] . ';type=' . (empty($modSettings['visual_verification_type']) ? 0 : $modSettings['visual_verification_type']) . '" alt="' . $txt['setting_image_verification_sample'] . '" id="verification_image"><br>'; |
|
| 878 | + } else { |
|
| 879 | + $config_vars['vv']['postinput'] = '<br><span class="smalltext">' . $txt['setting_image_verification_nogd'] . '</span>'; |
|
| 880 | + } |
|
| 852 | 881 | |
| 853 | 882 | // Hack for PM spam settings. |
| 854 | 883 | list ($modSettings['max_pm_recipients'], $modSettings['pm_posts_verification'], $modSettings['pm_posts_per_hour']) = explode(',', $modSettings['pm_spam_settings']); |
@@ -858,9 +887,10 @@ discard block |
||
| 858 | 887 | $modSettings['posts_require_captcha'] = !isset($modSettings['posts_require_captcha']) || $modSettings['posts_require_captcha'] == -1 ? 0 : $modSettings['posts_require_captcha']; |
| 859 | 888 | |
| 860 | 889 | // Some minor javascript for the guest post setting. |
| 861 | - if ($modSettings['posts_require_captcha']) |
|
| 862 | - $context['settings_post_javascript'] .= ' |
|
| 890 | + if ($modSettings['posts_require_captcha']) { |
|
| 891 | + $context['settings_post_javascript'] .= ' |
|
| 863 | 892 | document.getElementById(\'guests_require_captcha\').disabled = true;'; |
| 893 | + } |
|
| 864 | 894 | |
| 865 | 895 | // And everything else. |
| 866 | 896 | $context['post_url'] = $scripturl . '?action=admin;area=antispam;save'; |
@@ -907,8 +937,9 @@ discard block |
||
| 907 | 937 | |
| 908 | 938 | call_integration_hook('integrate_signature_settings', array(&$config_vars)); |
| 909 | 939 | |
| 910 | - if ($return_config) |
|
| 911 | - return $config_vars; |
|
| 940 | + if ($return_config) { |
|
| 941 | + return $config_vars; |
|
| 942 | + } |
|
| 912 | 943 | |
| 913 | 944 | // Setup the template. |
| 914 | 945 | $context['page_title'] = $txt['signature_settings']; |
@@ -963,8 +994,9 @@ discard block |
||
| 963 | 994 | $sig = strtr($row['signature'], array('<br>' => "\n")); |
| 964 | 995 | |
| 965 | 996 | // Max characters... |
| 966 | - if (!empty($sig_limits[1])) |
|
| 967 | - $sig = $smcFunc['substr']($sig, 0, $sig_limits[1]); |
|
| 997 | + if (!empty($sig_limits[1])) { |
|
| 998 | + $sig = $smcFunc['substr']($sig, 0, $sig_limits[1]); |
|
| 999 | + } |
|
| 968 | 1000 | // Max lines... |
| 969 | 1001 | if (!empty($sig_limits[2])) |
| 970 | 1002 | { |
@@ -974,8 +1006,9 @@ discard block |
||
| 974 | 1006 | if ($sig[$i] == "\n") |
| 975 | 1007 | { |
| 976 | 1008 | $count++; |
| 977 | - if ($count >= $sig_limits[2]) |
|
| 978 | - $sig = substr($sig, 0, $i) . strtr(substr($sig, $i), array("\n" => ' ')); |
|
| 1009 | + if ($count >= $sig_limits[2]) { |
|
| 1010 | + $sig = substr($sig, 0, $i) . strtr(substr($sig, $i), array("\n" => ' ')); |
|
| 1011 | + } |
|
| 979 | 1012 | } |
| 980 | 1013 | } |
| 981 | 1014 | } |
@@ -986,17 +1019,19 @@ discard block |
||
| 986 | 1019 | { |
| 987 | 1020 | $limit_broke = 0; |
| 988 | 1021 | // Attempt to allow all sizes of abuse, so to speak. |
| 989 | - if ($matches[2][$ind] == 'px' && $size > $sig_limits[7]) |
|
| 990 | - $limit_broke = $sig_limits[7] . 'px'; |
|
| 991 | - elseif ($matches[2][$ind] == 'pt' && $size > ($sig_limits[7] * 0.75)) |
|
| 992 | - $limit_broke = ((int) $sig_limits[7] * 0.75) . 'pt'; |
|
| 993 | - elseif ($matches[2][$ind] == 'em' && $size > ((float) $sig_limits[7] / 16)) |
|
| 994 | - $limit_broke = ((float) $sig_limits[7] / 16) . 'em'; |
|
| 995 | - elseif ($matches[2][$ind] != 'px' && $matches[2][$ind] != 'pt' && $matches[2][$ind] != 'em' && $sig_limits[7] < 18) |
|
| 996 | - $limit_broke = 'large'; |
|
| 997 | - |
|
| 998 | - if ($limit_broke) |
|
| 999 | - $sig = str_replace($matches[0][$ind], '[size=' . $sig_limits[7] . 'px', $sig); |
|
| 1022 | + if ($matches[2][$ind] == 'px' && $size > $sig_limits[7]) { |
|
| 1023 | + $limit_broke = $sig_limits[7] . 'px'; |
|
| 1024 | + } elseif ($matches[2][$ind] == 'pt' && $size > ($sig_limits[7] * 0.75)) { |
|
| 1025 | + $limit_broke = ((int) $sig_limits[7] * 0.75) . 'pt'; |
|
| 1026 | + } elseif ($matches[2][$ind] == 'em' && $size > ((float) $sig_limits[7] / 16)) { |
|
| 1027 | + $limit_broke = ((float) $sig_limits[7] / 16) . 'em'; |
|
| 1028 | + } elseif ($matches[2][$ind] != 'px' && $matches[2][$ind] != 'pt' && $matches[2][$ind] != 'em' && $sig_limits[7] < 18) { |
|
| 1029 | + $limit_broke = 'large'; |
|
| 1030 | + } |
|
| 1031 | + |
|
| 1032 | + if ($limit_broke) { |
|
| 1033 | + $sig = str_replace($matches[0][$ind], '[size=' . $sig_limits[7] . 'px', $sig); |
|
| 1034 | + } |
|
| 1000 | 1035 | } |
| 1001 | 1036 | } |
| 1002 | 1037 | |
@@ -1052,32 +1087,34 @@ discard block |
||
| 1052 | 1087 | $img_offset = false; |
| 1053 | 1088 | } |
| 1054 | 1089 | } |
| 1090 | + } else { |
|
| 1091 | + $replaces[$image] = ''; |
|
| 1055 | 1092 | } |
| 1056 | - else |
|
| 1057 | - $replaces[$image] = ''; |
|
| 1058 | 1093 | |
| 1059 | 1094 | continue; |
| 1060 | 1095 | } |
| 1061 | 1096 | |
| 1062 | 1097 | // Does it have predefined restraints? Width first. |
| 1063 | - if ($matches[6][$key]) |
|
| 1064 | - $matches[2][$key] = $matches[6][$key]; |
|
| 1098 | + if ($matches[6][$key]) { |
|
| 1099 | + $matches[2][$key] = $matches[6][$key]; |
|
| 1100 | + } |
|
| 1065 | 1101 | if ($matches[2][$key] && $sig_limits[5] && $matches[2][$key] > $sig_limits[5]) |
| 1066 | 1102 | { |
| 1067 | 1103 | $width = $sig_limits[5]; |
| 1068 | 1104 | $matches[4][$key] = $matches[4][$key] * ($width / $matches[2][$key]); |
| 1105 | + } elseif ($matches[2][$key]) { |
|
| 1106 | + $width = $matches[2][$key]; |
|
| 1069 | 1107 | } |
| 1070 | - elseif ($matches[2][$key]) |
|
| 1071 | - $width = $matches[2][$key]; |
|
| 1072 | 1108 | // ... and height. |
| 1073 | 1109 | if ($matches[4][$key] && $sig_limits[6] && $matches[4][$key] > $sig_limits[6]) |
| 1074 | 1110 | { |
| 1075 | 1111 | $height = $sig_limits[6]; |
| 1076 | - if ($width != -1) |
|
| 1077 | - $width = $width * ($height / $matches[4][$key]); |
|
| 1112 | + if ($width != -1) { |
|
| 1113 | + $width = $width * ($height / $matches[4][$key]); |
|
| 1114 | + } |
|
| 1115 | + } elseif ($matches[4][$key]) { |
|
| 1116 | + $height = $matches[4][$key]; |
|
| 1078 | 1117 | } |
| 1079 | - elseif ($matches[4][$key]) |
|
| 1080 | - $height = $matches[4][$key]; |
|
| 1081 | 1118 | |
| 1082 | 1119 | // If the dimensions are still not fixed - we need to check the actual image. |
| 1083 | 1120 | if (($width == -1 && $sig_limits[5]) || ($height == -1 && $sig_limits[6])) |
@@ -1095,12 +1132,13 @@ discard block |
||
| 1095 | 1132 | if ($sizes[1] > $sig_limits[6] && $sig_limits[6]) |
| 1096 | 1133 | { |
| 1097 | 1134 | $height = $sig_limits[6]; |
| 1098 | - if ($width == -1) |
|
| 1099 | - $width = $sizes[0]; |
|
| 1135 | + if ($width == -1) { |
|
| 1136 | + $width = $sizes[0]; |
|
| 1137 | + } |
|
| 1100 | 1138 | $width = $width * ($height / $sizes[1]); |
| 1139 | + } elseif ($width != -1) { |
|
| 1140 | + $height = $sizes[1]; |
|
| 1101 | 1141 | } |
| 1102 | - elseif ($width != -1) |
|
| 1103 | - $height = $sizes[1]; |
|
| 1104 | 1142 | } |
| 1105 | 1143 | } |
| 1106 | 1144 | |
@@ -1113,8 +1151,9 @@ discard block |
||
| 1113 | 1151 | // Record that we got one. |
| 1114 | 1152 | $image_count_holder[$image] = isset($image_count_holder[$image]) ? $image_count_holder[$image] + 1 : 1; |
| 1115 | 1153 | } |
| 1116 | - if (!empty($replaces)) |
|
| 1117 | - $sig = str_replace(array_keys($replaces), array_values($replaces), $sig); |
|
| 1154 | + if (!empty($replaces)) { |
|
| 1155 | + $sig = str_replace(array_keys($replaces), array_values($replaces), $sig); |
|
| 1156 | + } |
|
| 1118 | 1157 | } |
| 1119 | 1158 | } |
| 1120 | 1159 | // Try to fix disabled tags. |
@@ -1126,18 +1165,20 @@ discard block |
||
| 1126 | 1165 | |
| 1127 | 1166 | $sig = strtr($sig, array("\n" => '<br>')); |
| 1128 | 1167 | call_integration_hook('integrate_apply_signature_settings', array(&$sig, $sig_limits, $disabledTags)); |
| 1129 | - if ($sig != $row['signature']) |
|
| 1130 | - $changes[$row['id_member']] = $sig; |
|
| 1168 | + if ($sig != $row['signature']) { |
|
| 1169 | + $changes[$row['id_member']] = $sig; |
|
| 1170 | + } |
|
| 1171 | + } |
|
| 1172 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 1173 | + $done = true; |
|
| 1131 | 1174 | } |
| 1132 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 1133 | - $done = true; |
|
| 1134 | 1175 | $smcFunc['db_free_result']($request); |
| 1135 | 1176 | |
| 1136 | 1177 | // Do we need to delete what we have? |
| 1137 | 1178 | if (!empty($changes)) |
| 1138 | 1179 | { |
| 1139 | - foreach ($changes as $id => $sig) |
|
| 1140 | - $smcFunc['db_query']('', ' |
|
| 1180 | + foreach ($changes as $id => $sig) { |
|
| 1181 | + $smcFunc['db_query']('', ' |
|
| 1141 | 1182 | UPDATE {db_prefix}members |
| 1142 | 1183 | SET signature = {string:signature} |
| 1143 | 1184 | WHERE id_member = {int:id_member}', |
@@ -1146,11 +1187,13 @@ discard block |
||
| 1146 | 1187 | 'signature' => $sig, |
| 1147 | 1188 | ) |
| 1148 | 1189 | ); |
| 1190 | + } |
|
| 1149 | 1191 | } |
| 1150 | 1192 | |
| 1151 | 1193 | $_GET['step'] += 50; |
| 1152 | - if (!$done) |
|
| 1153 | - pauseSignatureApplySettings(); |
|
| 1194 | + if (!$done) { |
|
| 1195 | + pauseSignatureApplySettings(); |
|
| 1196 | + } |
|
| 1154 | 1197 | } |
| 1155 | 1198 | $settings_applied = true; |
| 1156 | 1199 | } |
@@ -1168,8 +1211,9 @@ discard block |
||
| 1168 | 1211 | ); |
| 1169 | 1212 | |
| 1170 | 1213 | // Temporarily make each setting a modSetting! |
| 1171 | - foreach ($context['signature_settings'] as $key => $value) |
|
| 1172 | - $modSettings['signature_' . $key] = $value; |
|
| 1214 | + foreach ($context['signature_settings'] as $key => $value) { |
|
| 1215 | + $modSettings['signature_' . $key] = $value; |
|
| 1216 | + } |
|
| 1173 | 1217 | |
| 1174 | 1218 | // Make sure we check the right tags! |
| 1175 | 1219 | $modSettings['bbc_disabled_signature_bbc'] = $disabledTags; |
@@ -1181,23 +1225,26 @@ discard block |
||
| 1181 | 1225 | |
| 1182 | 1226 | // Clean up the tag stuff! |
| 1183 | 1227 | $bbcTags = array(); |
| 1184 | - foreach (parse_bbc(false) as $tag) |
|
| 1185 | - $bbcTags[] = $tag['tag']; |
|
| 1228 | + foreach (parse_bbc(false) as $tag) { |
|
| 1229 | + $bbcTags[] = $tag['tag']; |
|
| 1230 | + } |
|
| 1186 | 1231 | |
| 1187 | - if (!isset($_POST['signature_bbc_enabledTags'])) |
|
| 1188 | - $_POST['signature_bbc_enabledTags'] = array(); |
|
| 1189 | - elseif (!is_array($_POST['signature_bbc_enabledTags'])) |
|
| 1190 | - $_POST['signature_bbc_enabledTags'] = array($_POST['signature_bbc_enabledTags']); |
|
| 1232 | + if (!isset($_POST['signature_bbc_enabledTags'])) { |
|
| 1233 | + $_POST['signature_bbc_enabledTags'] = array(); |
|
| 1234 | + } elseif (!is_array($_POST['signature_bbc_enabledTags'])) { |
|
| 1235 | + $_POST['signature_bbc_enabledTags'] = array($_POST['signature_bbc_enabledTags']); |
|
| 1236 | + } |
|
| 1191 | 1237 | |
| 1192 | 1238 | $sig_limits = array(); |
| 1193 | 1239 | foreach ($context['signature_settings'] as $key => $value) |
| 1194 | 1240 | { |
| 1195 | - if ($key == 'allow_smileys') |
|
| 1196 | - continue; |
|
| 1197 | - elseif ($key == 'max_smileys' && empty($_POST['signature_allow_smileys'])) |
|
| 1198 | - $sig_limits[] = -1; |
|
| 1199 | - else |
|
| 1200 | - $sig_limits[] = !empty($_POST['signature_' . $key]) ? max(1, (int) $_POST['signature_' . $key]) : 0; |
|
| 1241 | + if ($key == 'allow_smileys') { |
|
| 1242 | + continue; |
|
| 1243 | + } elseif ($key == 'max_smileys' && empty($_POST['signature_allow_smileys'])) { |
|
| 1244 | + $sig_limits[] = -1; |
|
| 1245 | + } else { |
|
| 1246 | + $sig_limits[] = !empty($_POST['signature_' . $key]) ? max(1, (int) $_POST['signature_' . $key]) : 0; |
|
| 1247 | + } |
|
| 1201 | 1248 | } |
| 1202 | 1249 | |
| 1203 | 1250 | call_integration_hook('integrate_save_signature_settings', array(&$sig_limits, &$bbcTags)); |
@@ -1230,12 +1277,14 @@ discard block |
||
| 1230 | 1277 | |
| 1231 | 1278 | // Try get more time... |
| 1232 | 1279 | @set_time_limit(600); |
| 1233 | - if (function_exists('apache_reset_timeout')) |
|
| 1234 | - @apache_reset_timeout(); |
|
| 1280 | + if (function_exists('apache_reset_timeout')) { |
|
| 1281 | + @apache_reset_timeout(); |
|
| 1282 | + } |
|
| 1235 | 1283 | |
| 1236 | 1284 | // Have we exhausted all the time we allowed? |
| 1237 | - if (time() - array_sum(explode(' ', $sig_start)) < 3) |
|
| 1238 | - return; |
|
| 1285 | + if (time() - array_sum(explode(' ', $sig_start)) < 3) { |
|
| 1286 | + return; |
|
| 1287 | + } |
|
| 1239 | 1288 | |
| 1240 | 1289 | $context['continue_get_data'] = '?action=admin;area=featuresettings;sa=sig;apply;step=' . $_GET['step'] . ';' . $context['session_var'] . '=' . $context['session_id']; |
| 1241 | 1290 | $context['page_title'] = $txt['not_done_title']; |
@@ -1281,9 +1330,10 @@ discard block |
||
| 1281 | 1330 | $disable_fields = array_flip($standard_fields); |
| 1282 | 1331 | if (!empty($_POST['active'])) |
| 1283 | 1332 | { |
| 1284 | - foreach ($_POST['active'] as $value) |
|
| 1285 | - if (isset($disable_fields[$value])) |
|
| 1333 | + foreach ($_POST['active'] as $value) { |
|
| 1334 | + if (isset($disable_fields[$value])) |
|
| 1286 | 1335 | unset($disable_fields[$value]); |
| 1336 | + } |
|
| 1287 | 1337 | } |
| 1288 | 1338 | // What we have left! |
| 1289 | 1339 | $changes['disabled_profile_fields'] = empty($disable_fields) ? '' : implode(',', array_keys($disable_fields)); |
@@ -1292,16 +1342,18 @@ discard block |
||
| 1292 | 1342 | $reg_fields = array(); |
| 1293 | 1343 | if (!empty($_POST['reg'])) |
| 1294 | 1344 | { |
| 1295 | - foreach ($_POST['reg'] as $value) |
|
| 1296 | - if (in_array($value, $standard_fields) && !isset($disable_fields[$value])) |
|
| 1345 | + foreach ($_POST['reg'] as $value) { |
|
| 1346 | + if (in_array($value, $standard_fields) && !isset($disable_fields[$value])) |
|
| 1297 | 1347 | $reg_fields[] = $value; |
| 1348 | + } |
|
| 1298 | 1349 | } |
| 1299 | 1350 | // What we have left! |
| 1300 | 1351 | $changes['registration_fields'] = empty($reg_fields) ? '' : implode(',', $reg_fields); |
| 1301 | 1352 | |
| 1302 | 1353 | $_SESSION['adm-save'] = true; |
| 1303 | - if (!empty($changes)) |
|
| 1304 | - updateSettings($changes); |
|
| 1354 | + if (!empty($changes)) { |
|
| 1355 | + updateSettings($changes); |
|
| 1356 | + } |
|
| 1305 | 1357 | } |
| 1306 | 1358 | |
| 1307 | 1359 | createToken('admin-scp'); |
@@ -1404,11 +1456,13 @@ discard block |
||
| 1404 | 1456 | { |
| 1405 | 1457 | $return = '<p class="centertext bold_text">'. $rowData['field_order'] .'<br>'; |
| 1406 | 1458 | |
| 1407 | - if ($rowData['field_order'] > 1) |
|
| 1408 | - $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=up"><span class="toggle_up" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_up'] .'"></span></a>'; |
|
| 1459 | + if ($rowData['field_order'] > 1) { |
|
| 1460 | + $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=up"><span class="toggle_up" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_up'] .'"></span></a>'; |
|
| 1461 | + } |
|
| 1409 | 1462 | |
| 1410 | - if ($rowData['field_order'] < $context['custFieldsMaxOrder']) |
|
| 1411 | - $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=down"><span class="toggle_down" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_down'] .'"></span></a>'; |
|
| 1463 | + if ($rowData['field_order'] < $context['custFieldsMaxOrder']) { |
|
| 1464 | + $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=down"><span class="toggle_down" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_down'] .'"></span></a>'; |
|
| 1465 | + } |
|
| 1412 | 1466 | |
| 1413 | 1467 | $return .= '</p>'; |
| 1414 | 1468 | |
@@ -1546,16 +1600,16 @@ discard block |
||
| 1546 | 1600 | $disabled_fields = isset($modSettings['disabled_profile_fields']) ? explode(',', $modSettings['disabled_profile_fields']) : array(); |
| 1547 | 1601 | $registration_fields = isset($modSettings['registration_fields']) ? explode(',', $modSettings['registration_fields']) : array(); |
| 1548 | 1602 | |
| 1549 | - foreach ($standard_fields as $field) |
|
| 1550 | - $list[] = array( |
|
| 1603 | + foreach ($standard_fields as $field) { |
|
| 1604 | + $list[] = array( |
|
| 1551 | 1605 | 'id' => $field, |
| 1552 | 1606 | 'label' => isset($txt['standard_profile_field_' . $field]) ? $txt['standard_profile_field_' . $field] : (isset($txt[$field]) ? $txt[$field] : $field), |
| 1553 | 1607 | 'disabled' => in_array($field, $disabled_fields), |
| 1554 | 1608 | 'on_register' => in_array($field, $registration_fields) && !in_array($field, $fields_no_registration), |
| 1555 | 1609 | 'can_show_register' => !in_array($field, $fields_no_registration), |
| 1556 | 1610 | ); |
| 1557 | - } |
|
| 1558 | - else |
|
| 1611 | + } |
|
| 1612 | + } else |
|
| 1559 | 1613 | { |
| 1560 | 1614 | // Load all the fields. |
| 1561 | 1615 | $request = $smcFunc['db_query']('', ' |
@@ -1569,8 +1623,9 @@ discard block |
||
| 1569 | 1623 | 'items_per_page' => $items_per_page, |
| 1570 | 1624 | ) |
| 1571 | 1625 | ); |
| 1572 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1573 | - $list[] = $row; |
|
| 1626 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1627 | + $list[] = $row; |
|
| 1628 | + } |
|
| 1574 | 1629 | $smcFunc['db_free_result']($request); |
| 1575 | 1630 | } |
| 1576 | 1631 | |
@@ -1636,9 +1691,9 @@ discard block |
||
| 1636 | 1691 | $context['field'] = array(); |
| 1637 | 1692 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1638 | 1693 | { |
| 1639 | - if ($row['field_type'] == 'textarea') |
|
| 1640 | - @list ($rows, $cols) = @explode(',', $row['default_value']); |
|
| 1641 | - else |
|
| 1694 | + if ($row['field_type'] == 'textarea') { |
|
| 1695 | + @list ($rows, $cols) = @explode(',', $row['default_value']); |
|
| 1696 | + } else |
|
| 1642 | 1697 | { |
| 1643 | 1698 | $rows = 3; |
| 1644 | 1699 | $cols = 30; |
@@ -1674,8 +1729,8 @@ discard block |
||
| 1674 | 1729 | } |
| 1675 | 1730 | |
| 1676 | 1731 | // Setup the default values as needed. |
| 1677 | - if (empty($context['field'])) |
|
| 1678 | - $context['field'] = array( |
|
| 1732 | + if (empty($context['field'])) { |
|
| 1733 | + $context['field'] = array( |
|
| 1679 | 1734 | 'name' => '', |
| 1680 | 1735 | 'col_name' => '???', |
| 1681 | 1736 | 'desc' => '', |
@@ -1700,6 +1755,7 @@ discard block |
||
| 1700 | 1755 | 'enclose' => '', |
| 1701 | 1756 | 'placement' => 0, |
| 1702 | 1757 | ); |
| 1758 | + } |
|
| 1703 | 1759 | |
| 1704 | 1760 | // Are we moving it? |
| 1705 | 1761 | if (isset($_GET['move']) && in_array($smcFunc['htmlspecialchars']($_GET['move']), $move_to)) |
@@ -1708,8 +1764,10 @@ discard block |
||
| 1708 | 1764 | $new_order = ($_GET['move'] == 'up' ? ($context['field']['order'] - 1) : ($context['field']['order'] + 1)); |
| 1709 | 1765 | |
| 1710 | 1766 | // Is this a valid position? |
| 1711 | - if ($new_order <= 0 || $new_order > $order_count) |
|
| 1712 | - redirectexit('action=admin;area=featuresettings;sa=profile'); // @todo implement an error handler |
|
| 1767 | + if ($new_order <= 0 || $new_order > $order_count) { |
|
| 1768 | + redirectexit('action=admin;area=featuresettings;sa=profile'); |
|
| 1769 | + } |
|
| 1770 | + // @todo implement an error handler |
|
| 1713 | 1771 | |
| 1714 | 1772 | // All good, proceed. |
| 1715 | 1773 | $smcFunc['db_query']('',' |
@@ -1740,12 +1798,14 @@ discard block |
||
| 1740 | 1798 | validateToken('admin-ecp'); |
| 1741 | 1799 | |
| 1742 | 1800 | // Everyone needs a name - even the (bracket) unknown... |
| 1743 | - if (trim($_POST['field_name']) == '') |
|
| 1744 | - redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $_GET['fid'] . ';msg=need_name'); |
|
| 1801 | + if (trim($_POST['field_name']) == '') { |
|
| 1802 | + redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $_GET['fid'] . ';msg=need_name'); |
|
| 1803 | + } |
|
| 1745 | 1804 | |
| 1746 | 1805 | // Regex you say? Do a very basic test to see if the pattern is valid |
| 1747 | - if (!empty($_POST['regex']) && @preg_match($_POST['regex'], 'dummy') === false) |
|
| 1748 | - redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $_GET['fid'] . ';msg=regex_error'); |
|
| 1806 | + if (!empty($_POST['regex']) && @preg_match($_POST['regex'], 'dummy') === false) { |
|
| 1807 | + redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $_GET['fid'] . ';msg=regex_error'); |
|
| 1808 | + } |
|
| 1749 | 1809 | |
| 1750 | 1810 | $_POST['field_name'] = $smcFunc['htmlspecialchars']($_POST['field_name']); |
| 1751 | 1811 | $_POST['field_desc'] = $smcFunc['htmlspecialchars']($_POST['field_desc']); |
@@ -1762,8 +1822,9 @@ discard block |
||
| 1762 | 1822 | |
| 1763 | 1823 | // Some masking stuff... |
| 1764 | 1824 | $mask = isset($_POST['mask']) ? $_POST['mask'] : ''; |
| 1765 | - if ($mask == 'regex' && isset($_POST['regex'])) |
|
| 1766 | - $mask .= $_POST['regex']; |
|
| 1825 | + if ($mask == 'regex' && isset($_POST['regex'])) { |
|
| 1826 | + $mask .= $_POST['regex']; |
|
| 1827 | + } |
|
| 1767 | 1828 | |
| 1768 | 1829 | $field_length = isset($_POST['max_length']) ? (int) $_POST['max_length'] : 255; |
| 1769 | 1830 | $enclose = isset($_POST['enclose']) ? $_POST['enclose'] : ''; |
@@ -1782,8 +1843,9 @@ discard block |
||
| 1782 | 1843 | $v = strtr($v, array(',' => '')); |
| 1783 | 1844 | |
| 1784 | 1845 | // Nada, zip, etc... |
| 1785 | - if (trim($v) == '') |
|
| 1786 | - continue; |
|
| 1846 | + if (trim($v) == '') { |
|
| 1847 | + continue; |
|
| 1848 | + } |
|
| 1787 | 1849 | |
| 1788 | 1850 | // Otherwise, save it boy. |
| 1789 | 1851 | $field_options .= $v . ','; |
@@ -1791,15 +1853,17 @@ discard block |
||
| 1791 | 1853 | $newOptions[$k] = $v; |
| 1792 | 1854 | |
| 1793 | 1855 | // Is it default? |
| 1794 | - if (isset($_POST['default_select']) && $_POST['default_select'] == $k) |
|
| 1795 | - $default = $v; |
|
| 1856 | + if (isset($_POST['default_select']) && $_POST['default_select'] == $k) { |
|
| 1857 | + $default = $v; |
|
| 1858 | + } |
|
| 1796 | 1859 | } |
| 1797 | 1860 | $field_options = substr($field_options, 0, -1); |
| 1798 | 1861 | } |
| 1799 | 1862 | |
| 1800 | 1863 | // Text area has default has dimensions |
| 1801 | - if ($_POST['field_type'] == 'textarea') |
|
| 1802 | - $default = (int) $_POST['rows'] . ',' . (int) $_POST['cols']; |
|
| 1864 | + if ($_POST['field_type'] == 'textarea') { |
|
| 1865 | + $default = (int) $_POST['rows'] . ',' . (int) $_POST['cols']; |
|
| 1866 | + } |
|
| 1803 | 1867 | |
| 1804 | 1868 | // Come up with the unique name? |
| 1805 | 1869 | if (empty($context['fid'])) |
@@ -1808,32 +1872,36 @@ discard block |
||
| 1808 | 1872 | preg_match('~([\w\d_-]+)~', $col_name, $matches); |
| 1809 | 1873 | |
| 1810 | 1874 | // If there is nothing to the name, then let's start out own - for foreign languages etc. |
| 1811 | - if (isset($matches[1])) |
|
| 1812 | - $col_name = $initial_col_name = 'cust_' . strtolower($matches[1]); |
|
| 1813 | - else |
|
| 1814 | - $col_name = $initial_col_name = 'cust_' . mt_rand(1, 9999); |
|
| 1875 | + if (isset($matches[1])) { |
|
| 1876 | + $col_name = $initial_col_name = 'cust_' . strtolower($matches[1]); |
|
| 1877 | + } else { |
|
| 1878 | + $col_name = $initial_col_name = 'cust_' . mt_rand(1, 9999); |
|
| 1879 | + } |
|
| 1815 | 1880 | |
| 1816 | 1881 | // Make sure this is unique. |
| 1817 | 1882 | $current_fields = array(); |
| 1818 | 1883 | $request = $smcFunc['db_query']('', ' |
| 1819 | 1884 | SELECT id_field, col_name |
| 1820 | 1885 | FROM {db_prefix}custom_fields'); |
| 1821 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1822 | - $current_fields[$row['id_field']] = $row['col_name']; |
|
| 1886 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1887 | + $current_fields[$row['id_field']] = $row['col_name']; |
|
| 1888 | + } |
|
| 1823 | 1889 | $smcFunc['db_free_result']($request); |
| 1824 | 1890 | |
| 1825 | 1891 | $unique = false; |
| 1826 | 1892 | for ($i = 0; !$unique && $i < 9; $i ++) |
| 1827 | 1893 | { |
| 1828 | - if (!in_array($col_name, $current_fields)) |
|
| 1829 | - $unique = true; |
|
| 1830 | - else |
|
| 1831 | - $col_name = $initial_col_name . $i; |
|
| 1894 | + if (!in_array($col_name, $current_fields)) { |
|
| 1895 | + $unique = true; |
|
| 1896 | + } else { |
|
| 1897 | + $col_name = $initial_col_name . $i; |
|
| 1898 | + } |
|
| 1832 | 1899 | } |
| 1833 | 1900 | |
| 1834 | 1901 | // Still not a unique column name? Leave it up to the user, then. |
| 1835 | - if (!$unique) |
|
| 1836 | - fatal_lang_error('custom_option_not_unique'); |
|
| 1902 | + if (!$unique) { |
|
| 1903 | + fatal_lang_error('custom_option_not_unique'); |
|
| 1904 | + } |
|
| 1837 | 1905 | } |
| 1838 | 1906 | // Work out what to do with the user data otherwise... |
| 1839 | 1907 | else |
@@ -1861,8 +1929,9 @@ discard block |
||
| 1861 | 1929 | // Work out what's changed! |
| 1862 | 1930 | foreach ($context['field']['options'] as $k => $option) |
| 1863 | 1931 | { |
| 1864 | - if (trim($option) == '') |
|
| 1865 | - continue; |
|
| 1932 | + if (trim($option) == '') { |
|
| 1933 | + continue; |
|
| 1934 | + } |
|
| 1866 | 1935 | |
| 1867 | 1936 | // Still exists? |
| 1868 | 1937 | if (in_array($option, $newOptions)) |
@@ -1876,8 +1945,8 @@ discard block |
||
| 1876 | 1945 | foreach ($optionChanges as $k => $option) |
| 1877 | 1946 | { |
| 1878 | 1947 | // Just been renamed? |
| 1879 | - if (!in_array($k, $takenKeys) && !empty($newOptions[$k])) |
|
| 1880 | - $smcFunc['db_query']('', ' |
|
| 1948 | + if (!in_array($k, $takenKeys) && !empty($newOptions[$k])) { |
|
| 1949 | + $smcFunc['db_query']('', ' |
|
| 1881 | 1950 | UPDATE {db_prefix}themes |
| 1882 | 1951 | SET value = {string:new_value} |
| 1883 | 1952 | WHERE variable = {string:current_column} |
@@ -1890,6 +1959,7 @@ discard block |
||
| 1890 | 1959 | 'old_value' => $option, |
| 1891 | 1960 | ) |
| 1892 | 1961 | ); |
| 1962 | + } |
|
| 1893 | 1963 | } |
| 1894 | 1964 | } |
| 1895 | 1965 | // @todo Maybe we should adjust based on new text length limits? |
@@ -1932,8 +2002,8 @@ discard block |
||
| 1932 | 2002 | ); |
| 1933 | 2003 | |
| 1934 | 2004 | // Just clean up any old selects - these are a pain! |
| 1935 | - if (($_POST['field_type'] == 'select' || $_POST['field_type'] == 'radio') && !empty($newOptions)) |
|
| 1936 | - $smcFunc['db_query']('', ' |
|
| 2005 | + if (($_POST['field_type'] == 'select' || $_POST['field_type'] == 'radio') && !empty($newOptions)) { |
|
| 2006 | + $smcFunc['db_query']('', ' |
|
| 1937 | 2007 | DELETE FROM {db_prefix}themes |
| 1938 | 2008 | WHERE variable = {string:current_column} |
| 1939 | 2009 | AND value NOT IN ({array_string:new_option_values}) |
@@ -1944,8 +2014,8 @@ discard block |
||
| 1944 | 2014 | 'current_column' => $context['field']['col_name'], |
| 1945 | 2015 | ) |
| 1946 | 2016 | ); |
| 1947 | - } |
|
| 1948 | - else |
|
| 2017 | + } |
|
| 2018 | + } else |
|
| 1949 | 2019 | { |
| 1950 | 2020 | // Gotta figure it out the order. |
| 1951 | 2021 | $new_order = $order_count > 1 ? ($order_count + 1) : 1; |
@@ -2120,11 +2190,13 @@ discard block |
||
| 2120 | 2190 | call_integration_hook('integrate_prune_settings', array(&$config_vars, &$prune_toggle, false)); |
| 2121 | 2191 | |
| 2122 | 2192 | $prune_toggle_dt = array(); |
| 2123 | - foreach ($prune_toggle as $item) |
|
| 2124 | - $prune_toggle_dt[] = 'setting_' . $item; |
|
| 2193 | + foreach ($prune_toggle as $item) { |
|
| 2194 | + $prune_toggle_dt[] = 'setting_' . $item; |
|
| 2195 | + } |
|
| 2125 | 2196 | |
| 2126 | - if ($return_config) |
|
| 2127 | - return $config_vars; |
|
| 2197 | + if ($return_config) { |
|
| 2198 | + return $config_vars; |
|
| 2199 | + } |
|
| 2128 | 2200 | |
| 2129 | 2201 | addInlineJavaScript(' |
| 2130 | 2202 | function togglePruned() |
@@ -2162,15 +2234,16 @@ discard block |
||
| 2162 | 2234 | $vals = array(); |
| 2163 | 2235 | foreach ($config_vars as $index => $dummy) |
| 2164 | 2236 | { |
| 2165 | - if (!is_array($dummy) || $index == 'pruningOptions' || !in_array($dummy[1], $prune_toggle)) |
|
| 2166 | - continue; |
|
| 2237 | + if (!is_array($dummy) || $index == 'pruningOptions' || !in_array($dummy[1], $prune_toggle)) { |
|
| 2238 | + continue; |
|
| 2239 | + } |
|
| 2167 | 2240 | |
| 2168 | 2241 | $vals[] = empty($_POST[$dummy[1]]) || $_POST[$dummy[1]] < 0 ? 0 : (int) $_POST[$dummy[1]]; |
| 2169 | 2242 | } |
| 2170 | 2243 | $_POST['pruningOptions'] = implode(',', $vals); |
| 2244 | + } else { |
|
| 2245 | + $_POST['pruningOptions'] = ''; |
|
| 2171 | 2246 | } |
| 2172 | - else |
|
| 2173 | - $_POST['pruningOptions'] = ''; |
|
| 2174 | 2247 | |
| 2175 | 2248 | saveDBSettings($savevar); |
| 2176 | 2249 | $_SESSION['adm-save'] = true; |
@@ -2182,10 +2255,11 @@ discard block |
||
| 2182 | 2255 | $context['sub_template'] = 'show_settings'; |
| 2183 | 2256 | |
| 2184 | 2257 | // Get the actual values |
| 2185 | - if (!empty($modSettings['pruningOptions'])) |
|
| 2186 | - @list ($modSettings['pruneErrorLog'], $modSettings['pruneModLog'], $modSettings['pruneBanLog'], $modSettings['pruneReportLog'], $modSettings['pruneScheduledTaskLog'], $modSettings['pruneSpiderHitLog']) = explode(',', $modSettings['pruningOptions']); |
|
| 2187 | - else |
|
| 2188 | - $modSettings['pruneErrorLog'] = $modSettings['pruneModLog'] = $modSettings['pruneBanLog'] = $modSettings['pruneReportLog'] = $modSettings['pruneScheduledTaskLog'] = $modSettings['pruneSpiderHitLog'] = 0; |
|
| 2258 | + if (!empty($modSettings['pruningOptions'])) { |
|
| 2259 | + @list ($modSettings['pruneErrorLog'], $modSettings['pruneModLog'], $modSettings['pruneBanLog'], $modSettings['pruneReportLog'], $modSettings['pruneScheduledTaskLog'], $modSettings['pruneSpiderHitLog']) = explode(',', $modSettings['pruningOptions']); |
|
| 2260 | + } else { |
|
| 2261 | + $modSettings['pruneErrorLog'] = $modSettings['pruneModLog'] = $modSettings['pruneBanLog'] = $modSettings['pruneReportLog'] = $modSettings['pruneScheduledTaskLog'] = $modSettings['pruneSpiderHitLog'] = 0; |
|
| 2262 | + } |
|
| 2189 | 2263 | |
| 2190 | 2264 | prepareDBSettingContext($config_vars); |
| 2191 | 2265 | } |
@@ -2207,8 +2281,9 @@ discard block |
||
| 2207 | 2281 | // Make it even easier to add new settings. |
| 2208 | 2282 | call_integration_hook('integrate_general_mod_settings', array(&$config_vars)); |
| 2209 | 2283 | |
| 2210 | - if ($return_config) |
|
| 2211 | - return $config_vars; |
|
| 2284 | + if ($return_config) { |
|
| 2285 | + return $config_vars; |
|
| 2286 | + } |
|
| 2212 | 2287 | |
| 2213 | 2288 | $context['post_url'] = $scripturl . '?action=admin;area=modsettings;save;sa=general'; |
| 2214 | 2289 | $context['settings_title'] = $txt['mods_cat_modifications_misc']; |
@@ -256,8 +256,8 @@ discard block |
||
| 256 | 256 | $time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
| 257 | 257 | |
| 258 | 258 | $js_time_string = str_replace( |
| 259 | - array('%H', '%k', '%I', '%l', '%M', '%p', '%P', '%r', '%R', '%S', '%T', '%X'), |
|
| 260 | - array('H', 'G', 'h', 'g', 'i', 'A', 'a', 'h:i:s A', 'H:i', 's', 'H:i:s', 'H:i:s'), |
|
| 259 | + array('%H', '%k', '%I', '%l', '%M', '%p', '%P', '%r', '%R', '%S', '%T', '%X'), |
|
| 260 | + array('H', 'G', 'h', 'g', 'i', 'A', 'a', 'h:i:s A', 'H:i', 's', 'H:i:s', 'H:i:s'), |
|
| 261 | 261 | $time_string |
| 262 | 262 | ); |
| 263 | 263 | |
@@ -1305,14 +1305,14 @@ discard block |
||
| 1305 | 1305 | if (isset($context['name']) && isset($context['email'])) |
| 1306 | 1306 | { |
| 1307 | 1307 | $context['posting_fields']['guestname'] = array( |
| 1308 | - 'dt' => '<span id="caption_guestname"' . (isset($context['post_error']['long_name']) || isset($context['post_error']['no_name']) || isset($context['post_error']['bad_name']) ? ' class="error"' : '') . '>' . $txt['name'] . '</span>', |
|
| 1308 | + 'dt' => '<span id="caption_guestname"' . (isset($context['post_error']['long_name']) || isset($context['post_error']['no_name']) || isset($context['post_error']['bad_name']) ? ' class="error"' : '') . '>' . $txt['name'] . '</span>', |
|
| 1309 | 1309 | 'dd' => '<input type="text" name="guestname" size="25" value="' . $context['name'] . '" required>', |
| 1310 | 1310 | ); |
| 1311 | 1311 | |
| 1312 | 1312 | if (empty($modSettings['guest_post_no_email'])) |
| 1313 | 1313 | { |
| 1314 | 1314 | $context['posting_fields']['email'] = array( |
| 1315 | - 'dt' => '<span id="caption_email"' . (isset($context['post_error']['no_email']) || isset($context['post_error']['bad_email']) ? ' class="error"' : '') . '>' . $txt['email'] . '</span>', |
|
| 1315 | + 'dt' => '<span id="caption_email"' . (isset($context['post_error']['no_email']) || isset($context['post_error']['bad_email']) ? ' class="error"' : '') . '>' . $txt['email'] . '</span>', |
|
| 1316 | 1316 | 'dd' => '<input type="email" name="email" size="25" value="' . $context['email'] . '" required>', |
| 1317 | 1317 | ); |
| 1318 | 1318 | } |
@@ -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 | * Handles showing the post screen, loading the post to be modified, and loading any post quoted. |
@@ -35,12 +36,14 @@ discard block |
||
| 35 | 36 | global $sourcedir, $smcFunc, $language; |
| 36 | 37 | |
| 37 | 38 | loadLanguage('Post'); |
| 38 | - if (!empty($modSettings['drafts_post_enabled'])) |
|
| 39 | - loadLanguage('Drafts'); |
|
| 39 | + if (!empty($modSettings['drafts_post_enabled'])) { |
|
| 40 | + loadLanguage('Drafts'); |
|
| 41 | + } |
|
| 40 | 42 | |
| 41 | 43 | // You can't reply with a poll... hacker. |
| 42 | - if (isset($_REQUEST['poll']) && !empty($topic) && !isset($_REQUEST['msg'])) |
|
| 43 | - unset($_REQUEST['poll']); |
|
| 44 | + if (isset($_REQUEST['poll']) && !empty($topic) && !isset($_REQUEST['msg'])) { |
|
| 45 | + unset($_REQUEST['poll']); |
|
| 46 | + } |
|
| 44 | 47 | |
| 45 | 48 | // Posting an event? |
| 46 | 49 | $context['make_event'] = isset($_REQUEST['calendar']); |
@@ -60,12 +63,14 @@ discard block |
||
| 60 | 63 | { |
| 61 | 64 | // Get ids of all the boards they can post in. |
| 62 | 65 | $post_permissions = array('post_new'); |
| 63 | - if ($modSettings['postmod_active']) |
|
| 64 | - $post_permissions[] = 'post_unapproved_topics'; |
|
| 66 | + if ($modSettings['postmod_active']) { |
|
| 67 | + $post_permissions[] = 'post_unapproved_topics'; |
|
| 68 | + } |
|
| 65 | 69 | |
| 66 | 70 | $boards = boardsAllowedTo($post_permissions); |
| 67 | - if (empty($boards)) |
|
| 68 | - fatal_lang_error('cannot_post_new', false); |
|
| 71 | + if (empty($boards)) { |
|
| 72 | + fatal_lang_error('cannot_post_new', false); |
|
| 73 | + } |
|
| 69 | 74 | |
| 70 | 75 | // Get a list of boards for the select menu |
| 71 | 76 | require_once($sourcedir . '/Subs-MessageIndex.php'); |
@@ -78,8 +83,9 @@ discard block |
||
| 78 | 83 | $board_list = getBoardList($boardListOptions); |
| 79 | 84 | } |
| 80 | 85 | // Let's keep things simple for ourselves below |
| 81 | - else |
|
| 82 | - $boards = array($board); |
|
| 86 | + else { |
|
| 87 | + $boards = array($board); |
|
| 88 | + } |
|
| 83 | 89 | |
| 84 | 90 | require_once($sourcedir . '/Subs-Post.php'); |
| 85 | 91 | |
@@ -102,10 +108,11 @@ discard block |
||
| 102 | 108 | array( |
| 103 | 109 | 'msg' => (int) $_REQUEST['msg'], |
| 104 | 110 | )); |
| 105 | - if ($smcFunc['db_num_rows']($request) != 1) |
|
| 106 | - unset($_REQUEST['msg'], $_POST['msg'], $_GET['msg']); |
|
| 107 | - else |
|
| 108 | - list ($topic) = $smcFunc['db_fetch_row']($request); |
|
| 111 | + if ($smcFunc['db_num_rows']($request) != 1) { |
|
| 112 | + unset($_REQUEST['msg'], $_POST['msg'], $_GET['msg']); |
|
| 113 | + } else { |
|
| 114 | + list ($topic) = $smcFunc['db_fetch_row']($request); |
|
| 115 | + } |
|
| 109 | 116 | $smcFunc['db_free_result']($request); |
| 110 | 117 | } |
| 111 | 118 | |
@@ -132,33 +139,36 @@ discard block |
||
| 132 | 139 | $smcFunc['db_free_result']($request); |
| 133 | 140 | |
| 134 | 141 | // If this topic already has a poll, they sure can't add another. |
| 135 | - if (isset($_REQUEST['poll']) && $pollID > 0) |
|
| 136 | - unset($_REQUEST['poll']); |
|
| 142 | + if (isset($_REQUEST['poll']) && $pollID > 0) { |
|
| 143 | + unset($_REQUEST['poll']); |
|
| 144 | + } |
|
| 137 | 145 | |
| 138 | 146 | if (empty($_REQUEST['msg'])) |
| 139 | 147 | { |
| 140 | - if ($user_info['is_guest'] && !allowedTo('post_reply_any') && (!$modSettings['postmod_active'] || !allowedTo('post_unapproved_replies_any'))) |
|
| 141 | - is_not_guest(); |
|
| 148 | + if ($user_info['is_guest'] && !allowedTo('post_reply_any') && (!$modSettings['postmod_active'] || !allowedTo('post_unapproved_replies_any'))) { |
|
| 149 | + is_not_guest(); |
|
| 150 | + } |
|
| 142 | 151 | |
| 143 | 152 | // By default the reply will be approved... |
| 144 | 153 | $context['becomes_approved'] = true; |
| 145 | 154 | if ($id_member_poster != $user_info['id'] || $user_info['is_guest']) |
| 146 | 155 | { |
| 147 | - if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any')) |
|
| 148 | - $context['becomes_approved'] = false; |
|
| 149 | - else |
|
| 150 | - isAllowedTo('post_reply_any'); |
|
| 151 | - } |
|
| 152 | - elseif (!allowedTo('post_reply_any')) |
|
| 156 | + if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any')) { |
|
| 157 | + $context['becomes_approved'] = false; |
|
| 158 | + } else { |
|
| 159 | + isAllowedTo('post_reply_any'); |
|
| 160 | + } |
|
| 161 | + } elseif (!allowedTo('post_reply_any')) |
|
| 153 | 162 | { |
| 154 | - if ($modSettings['postmod_active'] && ((allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) || allowedTo('post_unapproved_replies_any'))) |
|
| 155 | - $context['becomes_approved'] = false; |
|
| 156 | - else |
|
| 157 | - isAllowedTo('post_reply_own'); |
|
| 163 | + if ($modSettings['postmod_active'] && ((allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) || allowedTo('post_unapproved_replies_any'))) { |
|
| 164 | + $context['becomes_approved'] = false; |
|
| 165 | + } else { |
|
| 166 | + isAllowedTo('post_reply_own'); |
|
| 167 | + } |
|
| 158 | 168 | } |
| 169 | + } else { |
|
| 170 | + $context['becomes_approved'] = true; |
|
| 159 | 171 | } |
| 160 | - else |
|
| 161 | - $context['becomes_approved'] = true; |
|
| 162 | 172 | |
| 163 | 173 | $context['can_lock'] = allowedTo('lock_any') || ($user_info['id'] == $id_member_poster && allowedTo('lock_own')); |
| 164 | 174 | $context['can_sticky'] = allowedTo('make_sticky'); |
@@ -173,17 +183,18 @@ discard block |
||
| 173 | 183 | $context['sticky'] = isset($_REQUEST['sticky']) ? !empty($_REQUEST['sticky']) : $sticky; |
| 174 | 184 | |
| 175 | 185 | // Check whether this is a really old post being bumped... |
| 176 | - if (!empty($modSettings['oldTopicDays']) && $lastPostTime + $modSettings['oldTopicDays'] * 86400 < time() && empty($sticky) && !isset($_REQUEST['subject'])) |
|
| 177 | - $post_errors[] = array('old_topic', array($modSettings['oldTopicDays'])); |
|
| 178 | - } |
|
| 179 | - else |
|
| 186 | + if (!empty($modSettings['oldTopicDays']) && $lastPostTime + $modSettings['oldTopicDays'] * 86400 < time() && empty($sticky) && !isset($_REQUEST['subject'])) { |
|
| 187 | + $post_errors[] = array('old_topic', array($modSettings['oldTopicDays'])); |
|
| 188 | + } |
|
| 189 | + } else |
|
| 180 | 190 | { |
| 181 | 191 | // @todo Should use JavaScript to hide and show the warning based on the selection in the board select menu |
| 182 | 192 | $context['becomes_approved'] = true; |
| 183 | - if ($modSettings['postmod_active'] && !allowedTo('post_new', $boards, true) && allowedTo('post_unapproved_topics', $boards, true)) |
|
| 184 | - $context['becomes_approved'] = false; |
|
| 185 | - else |
|
| 186 | - isAllowedTo('post_new', $boards, true); |
|
| 193 | + if ($modSettings['postmod_active'] && !allowedTo('post_new', $boards, true) && allowedTo('post_unapproved_topics', $boards, true)) { |
|
| 194 | + $context['becomes_approved'] = false; |
|
| 195 | + } else { |
|
| 196 | + isAllowedTo('post_new', $boards, true); |
|
| 197 | + } |
|
| 187 | 198 | |
| 188 | 199 | $locked = 0; |
| 189 | 200 | $context['already_locked'] = 0; |
@@ -213,27 +224,32 @@ discard block |
||
| 213 | 224 | if (empty($_REQUEST['message']) && empty($_REQUEST['preview']) && !empty($_SESSION['already_attached'])) |
| 214 | 225 | { |
| 215 | 226 | require_once($sourcedir . '/ManageAttachments.php'); |
| 216 | - foreach ($_SESSION['already_attached'] as $attachID => $attachment) |
|
| 217 | - removeAttachments(array('id_attach' => $attachID)); |
|
| 227 | + foreach ($_SESSION['already_attached'] as $attachID => $attachment) { |
|
| 228 | + removeAttachments(array('id_attach' => $attachID)); |
|
| 229 | + } |
|
| 218 | 230 | |
| 219 | 231 | unset($_SESSION['already_attached']); |
| 220 | 232 | } |
| 221 | 233 | |
| 222 | 234 | // Don't allow a post if it's locked and you aren't all powerful. |
| 223 | - if ($locked && !allowedTo('moderate_board')) |
|
| 224 | - fatal_lang_error('topic_locked', false); |
|
| 235 | + if ($locked && !allowedTo('moderate_board')) { |
|
| 236 | + fatal_lang_error('topic_locked', false); |
|
| 237 | + } |
|
| 225 | 238 | // Check the users permissions - is the user allowed to add or post a poll? |
| 226 | 239 | if (isset($_REQUEST['poll']) && $modSettings['pollMode'] == '1') |
| 227 | 240 | { |
| 228 | 241 | // New topic, new poll. |
| 229 | - if (empty($topic)) |
|
| 230 | - isAllowedTo('poll_post'); |
|
| 242 | + if (empty($topic)) { |
|
| 243 | + isAllowedTo('poll_post'); |
|
| 244 | + } |
|
| 231 | 245 | // This is an old topic - but it is yours! Can you add to it? |
| 232 | - elseif ($user_info['id'] == $id_member_poster && !allowedTo('poll_add_any')) |
|
| 233 | - isAllowedTo('poll_add_own'); |
|
| 246 | + elseif ($user_info['id'] == $id_member_poster && !allowedTo('poll_add_any')) { |
|
| 247 | + isAllowedTo('poll_add_own'); |
|
| 248 | + } |
|
| 234 | 249 | // If you're not the owner, can you add to any poll? |
| 235 | - else |
|
| 236 | - isAllowedTo('poll_add_any'); |
|
| 250 | + else { |
|
| 251 | + isAllowedTo('poll_add_any'); |
|
| 252 | + } |
|
| 237 | 253 | |
| 238 | 254 | if (!empty($board)) |
| 239 | 255 | { |
@@ -242,8 +258,9 @@ discard block |
||
| 242 | 258 | $guest_vote_enabled = in_array(-1, $allowedVoteGroups['allowed']); |
| 243 | 259 | } |
| 244 | 260 | // No board, so we'll have to check this again in Post2 |
| 245 | - else |
|
| 246 | - $guest_vote_enabled = true; |
|
| 261 | + else { |
|
| 262 | + $guest_vote_enabled = true; |
|
| 263 | + } |
|
| 247 | 264 | |
| 248 | 265 | // Set up the poll options. |
| 249 | 266 | $context['poll_options'] = array( |
@@ -269,8 +286,9 @@ discard block |
||
| 269 | 286 | if ($context['make_event']) |
| 270 | 287 | { |
| 271 | 288 | // They might want to pick a board. |
| 272 | - if (!isset($context['current_board'])) |
|
| 273 | - $context['current_board'] = 0; |
|
| 289 | + if (!isset($context['current_board'])) { |
|
| 290 | + $context['current_board'] = 0; |
|
| 291 | + } |
|
| 274 | 292 | |
| 275 | 293 | // Start loading up the event info. |
| 276 | 294 | $context['event'] = array(); |
@@ -284,10 +302,11 @@ discard block |
||
| 284 | 302 | isAllowedTo('calendar_post'); |
| 285 | 303 | |
| 286 | 304 | // We want a fairly compact version of the time, but as close as possible to the user's settings. |
| 287 | - if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) |
|
| 288 | - $time_string = '%k:%M'; |
|
| 289 | - else |
|
| 290 | - $time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
|
| 305 | + if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) { |
|
| 306 | + $time_string = '%k:%M'; |
|
| 307 | + } else { |
|
| 308 | + $time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
|
| 309 | + } |
|
| 291 | 310 | |
| 292 | 311 | $js_time_string = str_replace( |
| 293 | 312 | array('%H', '%k', '%I', '%l', '%M', '%p', '%P', '%r', '%R', '%S', '%T', '%X'), |
@@ -309,8 +328,7 @@ discard block |
||
| 309 | 328 | require_once($sourcedir . '/Subs-Calendar.php'); |
| 310 | 329 | $eventProperties = getEventProperties($context['event']['id']); |
| 311 | 330 | $context['event'] = array_merge($context['event'], $eventProperties); |
| 312 | - } |
|
| 313 | - else |
|
| 331 | + } else |
|
| 314 | 332 | { |
| 315 | 333 | // Get the current event information. |
| 316 | 334 | require_once($sourcedir . '/Subs-Calendar.php'); |
@@ -318,10 +336,12 @@ discard block |
||
| 318 | 336 | $context['event'] = array_merge($context['event'], $eventProperties); |
| 319 | 337 | |
| 320 | 338 | // Make sure the year and month are in the valid range. |
| 321 | - if ($context['event']['month'] < 1 || $context['event']['month'] > 12) |
|
| 322 | - fatal_lang_error('invalid_month', false); |
|
| 323 | - if ($context['event']['year'] < $modSettings['cal_minyear'] || $context['event']['year'] > $modSettings['cal_maxyear']) |
|
| 324 | - fatal_lang_error('invalid_year', false); |
|
| 339 | + if ($context['event']['month'] < 1 || $context['event']['month'] > 12) { |
|
| 340 | + fatal_lang_error('invalid_month', false); |
|
| 341 | + } |
|
| 342 | + if ($context['event']['year'] < $modSettings['cal_minyear'] || $context['event']['year'] > $modSettings['cal_maxyear']) { |
|
| 343 | + fatal_lang_error('invalid_year', false); |
|
| 344 | + } |
|
| 325 | 345 | |
| 326 | 346 | $context['event']['categories'] = $board_list; |
| 327 | 347 | } |
@@ -432,10 +452,11 @@ discard block |
||
| 432 | 452 | |
| 433 | 453 | if (!empty($context['new_replies'])) |
| 434 | 454 | { |
| 435 | - if ($context['new_replies'] == 1) |
|
| 436 | - $txt['error_new_replies'] = isset($_GET['last_msg']) ? $txt['error_new_reply_reading'] : $txt['error_new_reply']; |
|
| 437 | - else |
|
| 438 | - $txt['error_new_replies'] = sprintf(isset($_GET['last_msg']) ? $txt['error_new_replies_reading'] : $txt['error_new_replies'], $context['new_replies']); |
|
| 455 | + if ($context['new_replies'] == 1) { |
|
| 456 | + $txt['error_new_replies'] = isset($_GET['last_msg']) ? $txt['error_new_reply_reading'] : $txt['error_new_reply']; |
|
| 457 | + } else { |
|
| 458 | + $txt['error_new_replies'] = sprintf(isset($_GET['last_msg']) ? $txt['error_new_replies_reading'] : $txt['error_new_replies'], $context['new_replies']); |
|
| 459 | + } |
|
| 439 | 460 | |
| 440 | 461 | $post_errors[] = 'new_replies'; |
| 441 | 462 | |
@@ -447,9 +468,9 @@ discard block |
||
| 447 | 468 | // Get a response prefix (like 'Re:') in the default forum language. |
| 448 | 469 | if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix'))) |
| 449 | 470 | { |
| 450 | - if ($language === $user_info['language']) |
|
| 451 | - $context['response_prefix'] = $txt['response_prefix']; |
|
| 452 | - else |
|
| 471 | + if ($language === $user_info['language']) { |
|
| 472 | + $context['response_prefix'] = $txt['response_prefix']; |
|
| 473 | + } else |
|
| 453 | 474 | { |
| 454 | 475 | loadLanguage('index', $language, false); |
| 455 | 476 | $context['response_prefix'] = $txt['response_prefix']; |
@@ -462,23 +483,26 @@ discard block |
||
| 462 | 483 | // Do we have a body, but an error happened. |
| 463 | 484 | if (isset($_REQUEST['message']) || isset($_REQUEST['quickReply']) || !empty($context['post_error'])) |
| 464 | 485 | { |
| 465 | - if (isset($_REQUEST['quickReply'])) |
|
| 466 | - $_REQUEST['message'] = $_REQUEST['quickReply']; |
|
| 486 | + if (isset($_REQUEST['quickReply'])) { |
|
| 487 | + $_REQUEST['message'] = $_REQUEST['quickReply']; |
|
| 488 | + } |
|
| 467 | 489 | |
| 468 | 490 | // Validate inputs. |
| 469 | 491 | if (empty($context['post_error'])) |
| 470 | 492 | { |
| 471 | 493 | // This means they didn't click Post and get an error. |
| 472 | 494 | $really_previewing = true; |
| 473 | - } |
|
| 474 | - else |
|
| 495 | + } else |
|
| 475 | 496 | { |
| 476 | - if (!isset($_REQUEST['subject'])) |
|
| 477 | - $_REQUEST['subject'] = ''; |
|
| 478 | - if (!isset($_REQUEST['message'])) |
|
| 479 | - $_REQUEST['message'] = ''; |
|
| 480 | - if (!isset($_REQUEST['icon'])) |
|
| 481 | - $_REQUEST['icon'] = 'xx'; |
|
| 497 | + if (!isset($_REQUEST['subject'])) { |
|
| 498 | + $_REQUEST['subject'] = ''; |
|
| 499 | + } |
|
| 500 | + if (!isset($_REQUEST['message'])) { |
|
| 501 | + $_REQUEST['message'] = ''; |
|
| 502 | + } |
|
| 503 | + if (!isset($_REQUEST['icon'])) { |
|
| 504 | + $_REQUEST['icon'] = 'xx'; |
|
| 505 | + } |
|
| 482 | 506 | |
| 483 | 507 | // They are previewing if they asked to preview (i.e. came from quick reply). |
| 484 | 508 | $really_previewing = !empty($_POST['preview']); |
@@ -494,8 +518,9 @@ discard block |
||
| 494 | 518 | $form_message = $smcFunc['htmlspecialchars']($_REQUEST['message'], ENT_QUOTES); |
| 495 | 519 | |
| 496 | 520 | // Make sure the subject isn't too long - taking into account special characters. |
| 497 | - if ($smcFunc['strlen']($form_subject) > 100) |
|
| 498 | - $form_subject = $smcFunc['substr']($form_subject, 0, 100); |
|
| 521 | + if ($smcFunc['strlen']($form_subject) > 100) { |
|
| 522 | + $form_subject = $smcFunc['substr']($form_subject, 0, 100); |
|
| 523 | + } |
|
| 499 | 524 | |
| 500 | 525 | if (isset($_REQUEST['poll'])) |
| 501 | 526 | { |
@@ -507,8 +532,9 @@ discard block |
||
| 507 | 532 | $_POST['options'] = empty($_POST['options']) ? array() : htmlspecialchars__recursive($_POST['options']); |
| 508 | 533 | foreach ($_POST['options'] as $option) |
| 509 | 534 | { |
| 510 | - if (trim($option) == '') |
|
| 511 | - continue; |
|
| 535 | + if (trim($option) == '') { |
|
| 536 | + continue; |
|
| 537 | + } |
|
| 512 | 538 | |
| 513 | 539 | $context['choices'][] = array( |
| 514 | 540 | 'id' => $choice_id++, |
@@ -570,13 +596,14 @@ discard block |
||
| 570 | 596 | $context['preview_subject'] = $form_subject; |
| 571 | 597 | |
| 572 | 598 | censorText($context['preview_subject']); |
| 599 | + } else { |
|
| 600 | + $context['preview_subject'] = '<em>' . $txt['no_subject'] . '</em>'; |
|
| 573 | 601 | } |
| 574 | - else |
|
| 575 | - $context['preview_subject'] = '<em>' . $txt['no_subject'] . '</em>'; |
|
| 576 | 602 | |
| 577 | 603 | // Protect any CDATA blocks. |
| 578 | - if (isset($_REQUEST['xml'])) |
|
| 579 | - $context['preview_message'] = strtr($context['preview_message'], array(']]>' => ']]]]><![CDATA[>')); |
|
| 604 | + if (isset($_REQUEST['xml'])) { |
|
| 605 | + $context['preview_message'] = strtr($context['preview_message'], array(']]>' => ']]]]>< == 0) |
|
| 619 | - fatal_lang_error('no_board', false); |
|
| 645 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 646 | + fatal_lang_error('no_board', false); |
|
| 647 | + } |
|
| 620 | 648 | $row = $smcFunc['db_fetch_assoc']($request); |
| 621 | 649 | |
| 622 | 650 | $attachment_stuff = array($row); |
| 623 | - while ($row2 = $smcFunc['db_fetch_assoc']($request)) |
|
| 624 | - $attachment_stuff[] = $row2; |
|
| 651 | + while ($row2 = $smcFunc['db_fetch_assoc']($request)) { |
|
| 652 | + $attachment_stuff[] = $row2; |
|
| 653 | + } |
|
| 625 | 654 | $smcFunc['db_free_result']($request); |
| 626 | 655 | |
| 627 | 656 | if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any')) |
| 628 | 657 | { |
| 629 | 658 | // Give an extra five minutes over the disable time threshold, so they can type - assuming the post is public. |
| 630 | - if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) |
|
| 631 | - fatal_lang_error('modify_post_time_passed', false); |
|
| 632 | - elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own')) |
|
| 633 | - isAllowedTo('modify_replies'); |
|
| 634 | - else |
|
| 635 | - isAllowedTo('modify_own'); |
|
| 659 | + if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) { |
|
| 660 | + fatal_lang_error('modify_post_time_passed', false); |
|
| 661 | + } elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own')) { |
|
| 662 | + isAllowedTo('modify_replies'); |
|
| 663 | + } else { |
|
| 664 | + isAllowedTo('modify_own'); |
|
| 665 | + } |
|
| 666 | + } elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any')) { |
|
| 667 | + isAllowedTo('modify_replies'); |
|
| 668 | + } else { |
|
| 669 | + isAllowedTo('modify_any'); |
|
| 636 | 670 | } |
| 637 | - elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any')) |
|
| 638 | - isAllowedTo('modify_replies'); |
|
| 639 | - else |
|
| 640 | - isAllowedTo('modify_any'); |
|
| 641 | 671 | |
| 642 | 672 | if ($context['can_announce'] && !empty($row['id_action'])) |
| 643 | 673 | { |
@@ -661,8 +691,9 @@ discard block |
||
| 661 | 691 | |
| 662 | 692 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 663 | 693 | { |
| 664 | - if ($row['filesize'] <= 0) |
|
| 665 | - continue; |
|
| 694 | + if ($row['filesize'] <= 0) { |
|
| 695 | + continue; |
|
| 696 | + } |
|
| 666 | 697 | $context['current_attachments'][$row['id_attach']] = array( |
| 667 | 698 | 'name' => $smcFunc['htmlspecialchars']($row['filename']), |
| 668 | 699 | 'size' => $row['filesize'], |
@@ -732,29 +763,32 @@ discard block |
||
| 732 | 763 | ) |
| 733 | 764 | ); |
| 734 | 765 | // The message they were trying to edit was most likely deleted. |
| 735 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 736 | - fatal_lang_error('no_message', false); |
|
| 766 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 767 | + fatal_lang_error('no_message', false); |
|
| 768 | + } |
|
| 737 | 769 | $row = $smcFunc['db_fetch_assoc']($request); |
| 738 | 770 | |
| 739 | 771 | $attachment_stuff = array($row); |
| 740 | - while ($row2 = $smcFunc['db_fetch_assoc']($request)) |
|
| 741 | - $attachment_stuff[] = $row2; |
|
| 772 | + while ($row2 = $smcFunc['db_fetch_assoc']($request)) { |
|
| 773 | + $attachment_stuff[] = $row2; |
|
| 774 | + } |
|
| 742 | 775 | $smcFunc['db_free_result']($request); |
| 743 | 776 | |
| 744 | 777 | if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any')) |
| 745 | 778 | { |
| 746 | 779 | // Give an extra five minutes over the disable time threshold, so they can type - assuming the post is public. |
| 747 | - if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) |
|
| 748 | - fatal_lang_error('modify_post_time_passed', false); |
|
| 749 | - elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own')) |
|
| 750 | - isAllowedTo('modify_replies'); |
|
| 751 | - else |
|
| 752 | - isAllowedTo('modify_own'); |
|
| 780 | + if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) { |
|
| 781 | + fatal_lang_error('modify_post_time_passed', false); |
|
| 782 | + } elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own')) { |
|
| 783 | + isAllowedTo('modify_replies'); |
|
| 784 | + } else { |
|
| 785 | + isAllowedTo('modify_own'); |
|
| 786 | + } |
|
| 787 | + } elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any')) { |
|
| 788 | + isAllowedTo('modify_replies'); |
|
| 789 | + } else { |
|
| 790 | + isAllowedTo('modify_any'); |
|
| 753 | 791 | } |
| 754 | - elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any')) |
|
| 755 | - isAllowedTo('modify_replies'); |
|
| 756 | - else |
|
| 757 | - isAllowedTo('modify_any'); |
|
| 758 | 792 | |
| 759 | 793 | if ($context['can_announce'] && !empty($row['id_action'])) |
| 760 | 794 | { |
@@ -781,15 +815,17 @@ discard block |
||
| 781 | 815 | $context['icon'] = $row['icon']; |
| 782 | 816 | |
| 783 | 817 | // Show an "approve" box if the user can approve it, and the message isn't approved. |
| 784 | - if (!$row['approved'] && !$context['show_approval']) |
|
| 785 | - $context['show_approval'] = allowedTo('approve_posts'); |
|
| 818 | + if (!$row['approved'] && !$context['show_approval']) { |
|
| 819 | + $context['show_approval'] = allowedTo('approve_posts'); |
|
| 820 | + } |
|
| 786 | 821 | |
| 787 | 822 | // Sort the attachments so they are in the order saved |
| 788 | 823 | $temp = array(); |
| 789 | 824 | foreach ($attachment_stuff as $attachment) |
| 790 | 825 | { |
| 791 | - if ($attachment['filesize'] >= 0 && !empty($modSettings['attachmentEnable'])) |
|
| 792 | - $temp[$attachment['id_attach']] = $attachment; |
|
| 826 | + if ($attachment['filesize'] >= 0 && !empty($modSettings['attachmentEnable'])) { |
|
| 827 | + $temp[$attachment['id_attach']] = $attachment; |
|
| 828 | + } |
|
| 793 | 829 | } |
| 794 | 830 | ksort($temp); |
| 795 | 831 | |
@@ -850,14 +886,16 @@ discard block |
||
| 850 | 886 | 'is_approved' => 1, |
| 851 | 887 | ) |
| 852 | 888 | ); |
| 853 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 854 | - fatal_lang_error('quoted_post_deleted', false); |
|
| 889 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 890 | + fatal_lang_error('quoted_post_deleted', false); |
|
| 891 | + } |
|
| 855 | 892 | list ($form_subject, $mname, $mdate, $form_message) = $smcFunc['db_fetch_row']($request); |
| 856 | 893 | $smcFunc['db_free_result']($request); |
| 857 | 894 | |
| 858 | 895 | // Add 'Re: ' to the front of the quoted subject. |
| 859 | - if (trim($context['response_prefix']) != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) |
|
| 860 | - $form_subject = $context['response_prefix'] . $form_subject; |
|
| 896 | + if (trim($context['response_prefix']) != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) { |
|
| 897 | + $form_subject = $context['response_prefix'] . $form_subject; |
|
| 898 | + } |
|
| 861 | 899 | |
| 862 | 900 | // Censor the message and subject. |
| 863 | 901 | censorText($form_message); |
@@ -870,10 +908,11 @@ discard block |
||
| 870 | 908 | for ($i = 0, $n = count($parts); $i < $n; $i++) |
| 871 | 909 | { |
| 872 | 910 | // It goes 0 = outside, 1 = begin tag, 2 = inside, 3 = close tag, repeat. |
| 873 | - if ($i % 4 == 0) |
|
| 874 | - $parts[$i] = preg_replace_callback('~\[html\](.+?)\[/html\]~is', function($m) |
|
| 911 | + if ($i % 4 == 0) { |
|
| 912 | + $parts[$i] = preg_replace_callback('~\[html\](.+?)\[/html\]~is', function($m) |
|
| 875 | 913 | { |
| 876 | 914 | return '[html]' . preg_replace('~<br\s?/?' . '>~i', '<br /><br>', "$m[1]") . '[/html]'; |
| 915 | + } |
|
| 877 | 916 | }, $parts[$i]); |
| 878 | 917 | } |
| 879 | 918 | $form_message = implode('', $parts); |
@@ -882,8 +921,9 @@ discard block |
||
| 882 | 921 | $form_message = preg_replace('~<br ?/?' . '>~i', "\n", $form_message); |
| 883 | 922 | |
| 884 | 923 | // Remove any nested quotes, if necessary. |
| 885 | - if (!empty($modSettings['removeNestedQuotes'])) |
|
| 886 | - $form_message = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $form_message); |
|
| 924 | + if (!empty($modSettings['removeNestedQuotes'])) { |
|
| 925 | + $form_message = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $form_message); |
|
| 926 | + } |
|
| 887 | 927 | |
| 888 | 928 | // Add a quote string on the front and end. |
| 889 | 929 | $form_message = '[quote author=' . $mname . ' link=msg=' . (int) $_REQUEST['quote'] . ' date=' . $mdate . ']' . "\n" . rtrim($form_message) . "\n" . '[/quote]'; |
@@ -895,15 +935,15 @@ discard block |
||
| 895 | 935 | $form_subject = $first_subject; |
| 896 | 936 | |
| 897 | 937 | // Add 'Re: ' to the front of the subject. |
| 898 | - if (trim($context['response_prefix']) != '' && $form_subject != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) |
|
| 899 | - $form_subject = $context['response_prefix'] . $form_subject; |
|
| 938 | + if (trim($context['response_prefix']) != '' && $form_subject != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) { |
|
| 939 | + $form_subject = $context['response_prefix'] . $form_subject; |
|
| 940 | + } |
|
| 900 | 941 | |
| 901 | 942 | // Censor the subject. |
| 902 | 943 | censorText($form_subject); |
| 903 | 944 | |
| 904 | 945 | $form_message = ''; |
| 905 | - } |
|
| 906 | - else |
|
| 946 | + } else |
|
| 907 | 947 | { |
| 908 | 948 | $form_subject = isset($_GET['subject']) ? $_GET['subject'] : ''; |
| 909 | 949 | $form_message = ''; |
@@ -922,13 +962,15 @@ discard block |
||
| 922 | 962 | if (isset($_REQUEST['msg'])) |
| 923 | 963 | { |
| 924 | 964 | $context['attachments']['quantity'] = count($context['current_attachments']); |
| 925 | - foreach ($context['current_attachments'] as $attachment) |
|
| 926 | - $context['attachments']['total_size'] += $attachment['size']; |
|
| 965 | + foreach ($context['current_attachments'] as $attachment) { |
|
| 966 | + $context['attachments']['total_size'] += $attachment['size']; |
|
| 967 | + } |
|
| 927 | 968 | } |
| 928 | 969 | |
| 929 | 970 | // A bit of house keeping first. |
| 930 | - if (!empty($_SESSION['temp_attachments']) && count($_SESSION['temp_attachments']) == 1) |
|
| 931 | - unset($_SESSION['temp_attachments']); |
|
| 971 | + if (!empty($_SESSION['temp_attachments']) && count($_SESSION['temp_attachments']) == 1) { |
|
| 972 | + unset($_SESSION['temp_attachments']); |
|
| 973 | + } |
|
| 932 | 974 | |
| 933 | 975 | if (!empty($_SESSION['temp_attachments'])) |
| 934 | 976 | { |
@@ -937,9 +979,10 @@ discard block |
||
| 937 | 979 | { |
| 938 | 980 | foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
| 939 | 981 | { |
| 940 | - if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false) |
|
| 941 | - if (file_exists($attachment['tmp_name'])) |
|
| 982 | + if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false) { |
|
| 983 | + if (file_exists($attachment['tmp_name'])) |
|
| 942 | 984 | unlink($attachment['tmp_name']); |
| 985 | + } |
|
| 943 | 986 | } |
| 944 | 987 | $post_errors[] = 'temp_attachments_gone'; |
| 945 | 988 | $_SESSION['temp_attachments'] = array(); |
@@ -953,8 +996,9 @@ discard block |
||
| 953 | 996 | // See if any files still exist before showing the warning message and the files attached. |
| 954 | 997 | foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
| 955 | 998 | { |
| 956 | - if (strpos($attachID, 'post_tmp_' . $user_info['id']) === false) |
|
| 957 | - continue; |
|
| 999 | + if (strpos($attachID, 'post_tmp_' . $user_info['id']) === false) { |
|
| 1000 | + continue; |
|
| 1001 | + } |
|
| 958 | 1002 | |
| 959 | 1003 | if (file_exists($attachment['tmp_name'])) |
| 960 | 1004 | { |
@@ -964,20 +1008,21 @@ discard block |
||
| 964 | 1008 | break; |
| 965 | 1009 | } |
| 966 | 1010 | } |
| 967 | - } |
|
| 968 | - else |
|
| 1011 | + } else |
|
| 969 | 1012 | { |
| 970 | 1013 | // Since, they don't belong here. Let's inform the user that they exist.. |
| 971 | - if (!empty($topic)) |
|
| 972 | - $delete_url = $scripturl . '?action=post' . (!empty($_REQUEST['msg']) ? (';msg=' . $_REQUEST['msg']) : '') . (!empty($_REQUEST['last_msg']) ? (';last_msg=' . $_REQUEST['last_msg']) : '') . ';topic=' . $topic . ';delete_temp'; |
|
| 973 | - else |
|
| 974 | - $delete_url = $scripturl . '?action=post' . (!empty($board) ? ';board=' . $board : '') . ';delete_temp'; |
|
| 1014 | + if (!empty($topic)) { |
|
| 1015 | + $delete_url = $scripturl . '?action=post' . (!empty($_REQUEST['msg']) ? (';msg=' . $_REQUEST['msg']) : '') . (!empty($_REQUEST['last_msg']) ? (';last_msg=' . $_REQUEST['last_msg']) : '') . ';topic=' . $topic . ';delete_temp'; |
|
| 1016 | + } else { |
|
| 1017 | + $delete_url = $scripturl . '?action=post' . (!empty($board) ? ';board=' . $board : '') . ';delete_temp'; |
|
| 1018 | + } |
|
| 975 | 1019 | |
| 976 | 1020 | // Compile a list of the files to show the user. |
| 977 | 1021 | $file_list = array(); |
| 978 | - foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
|
| 979 | - if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false) |
|
| 1022 | + foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) { |
|
| 1023 | + if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false) |
|
| 980 | 1024 | $file_list[] = $attachment['name']; |
| 1025 | + } |
|
| 981 | 1026 | |
| 982 | 1027 | $_SESSION['temp_attachments']['post']['files'] = $file_list; |
| 983 | 1028 | $file_list = '<div class="attachments">' . implode('<br>', $file_list) . '</div>'; |
@@ -989,8 +1034,7 @@ discard block |
||
| 989 | 1034 | |
| 990 | 1035 | $post_errors[] = array('temp_attachments_found', array($delete_url, $goback_url, $file_list)); |
| 991 | 1036 | $context['ignore_temp_attachments'] = true; |
| 992 | - } |
|
| 993 | - else |
|
| 1037 | + } else |
|
| 994 | 1038 | { |
| 995 | 1039 | $post_errors[] = array('temp_attachments_lost', array($delete_url, $file_list)); |
| 996 | 1040 | $context['ignore_temp_attachments'] = true; |
@@ -998,16 +1042,19 @@ discard block |
||
| 998 | 1042 | } |
| 999 | 1043 | } |
| 1000 | 1044 | |
| 1001 | - if (!empty($context['we_are_history'])) |
|
| 1002 | - $post_errors[] = $context['we_are_history']; |
|
| 1045 | + if (!empty($context['we_are_history'])) { |
|
| 1046 | + $post_errors[] = $context['we_are_history']; |
|
| 1047 | + } |
|
| 1003 | 1048 | |
| 1004 | 1049 | foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
| 1005 | 1050 | { |
| 1006 | - if (isset($context['ignore_temp_attachments']) || isset($_SESSION['temp_attachments']['post']['files'])) |
|
| 1007 | - break; |
|
| 1051 | + if (isset($context['ignore_temp_attachments']) || isset($_SESSION['temp_attachments']['post']['files'])) { |
|
| 1052 | + break; |
|
| 1053 | + } |
|
| 1008 | 1054 | |
| 1009 | - if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false) |
|
| 1010 | - continue; |
|
| 1055 | + if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false) { |
|
| 1056 | + continue; |
|
| 1057 | + } |
|
| 1011 | 1058 | |
| 1012 | 1059 | if ($attachID == 'initial_error') |
| 1013 | 1060 | { |
@@ -1022,15 +1069,17 @@ discard block |
||
| 1022 | 1069 | { |
| 1023 | 1070 | $txt['error_attach_errors'] = empty($txt['error_attach_errors']) ? '<br>' : ''; |
| 1024 | 1071 | $txt['error_attach_errors'] .= vsprintf($txt['attach_warning'], $attachment['name']) . '<div style="padding: 0 1em;">'; |
| 1025 | - foreach ($attachment['errors'] as $error) |
|
| 1026 | - $txt['error_attach_errors'] .= (is_array($error) ? vsprintf($txt[$error[0]], $error[1]) : $txt[$error]) . '<br >'; |
|
| 1072 | + foreach ($attachment['errors'] as $error) { |
|
| 1073 | + $txt['error_attach_errors'] .= (is_array($error) ? vsprintf($txt[$error[0]], $error[1]) : $txt[$error]) . '<br >'; |
|
| 1074 | + } |
|
| 1027 | 1075 | $txt['error_attach_errors'] .= '</div>'; |
| 1028 | 1076 | $post_errors[] = 'attach_errors'; |
| 1029 | 1077 | |
| 1030 | 1078 | // Take out the trash. |
| 1031 | 1079 | unset($_SESSION['temp_attachments'][$attachID]); |
| 1032 | - if (file_exists($attachment['tmp_name'])) |
|
| 1033 | - unlink($attachment['tmp_name']); |
|
| 1080 | + if (file_exists($attachment['tmp_name'])) { |
|
| 1081 | + unlink($attachment['tmp_name']); |
|
| 1082 | + } |
|
| 1034 | 1083 | continue; |
| 1035 | 1084 | } |
| 1036 | 1085 | |
@@ -1043,8 +1092,9 @@ discard block |
||
| 1043 | 1092 | |
| 1044 | 1093 | $context['attachments']['quantity']++; |
| 1045 | 1094 | $context['attachments']['total_size'] += $attachment['size']; |
| 1046 | - if (!isset($context['files_in_session_warning'])) |
|
| 1047 | - $context['files_in_session_warning'] = $txt['attached_files_in_session']; |
|
| 1095 | + if (!isset($context['files_in_session_warning'])) { |
|
| 1096 | + $context['files_in_session_warning'] = $txt['attached_files_in_session']; |
|
| 1097 | + } |
|
| 1048 | 1098 | |
| 1049 | 1099 | $context['current_attachments'][$attachID] = array( |
| 1050 | 1100 | 'name' => '<u>' . $smcFunc['htmlspecialchars']($attachment['name']) . '</u>', |
@@ -1072,8 +1122,9 @@ discard block |
||
| 1072 | 1122 | } |
| 1073 | 1123 | |
| 1074 | 1124 | // If they came from quick reply, and have to enter verification details, give them some notice. |
| 1075 | - if (!empty($_REQUEST['from_qr']) && !empty($context['require_verification'])) |
|
| 1076 | - $post_errors[] = 'need_qr_verification'; |
|
| 1125 | + if (!empty($_REQUEST['from_qr']) && !empty($context['require_verification'])) { |
|
| 1126 | + $post_errors[] = 'need_qr_verification'; |
|
| 1127 | + } |
|
| 1077 | 1128 | |
| 1078 | 1129 | /* |
| 1079 | 1130 | * There are two error types: serious and minor. Serious errors |
@@ -1090,52 +1141,56 @@ discard block |
||
| 1090 | 1141 | { |
| 1091 | 1142 | loadLanguage('Errors'); |
| 1092 | 1143 | $context['error_type'] = 'minor'; |
| 1093 | - foreach ($post_errors as $post_error) |
|
| 1094 | - if (is_array($post_error)) |
|
| 1144 | + foreach ($post_errors as $post_error) { |
|
| 1145 | + if (is_array($post_error)) |
|
| 1095 | 1146 | { |
| 1096 | 1147 | $post_error_id = $post_error[0]; |
| 1148 | + } |
|
| 1097 | 1149 | $context['post_error'][$post_error_id] = vsprintf($txt['error_' . $post_error_id], $post_error[1]); |
| 1098 | 1150 | |
| 1099 | 1151 | // If it's not a minor error flag it as such. |
| 1100 | - if (!in_array($post_error_id, $minor_errors)) |
|
| 1101 | - $context['error_type'] = 'serious'; |
|
| 1102 | - } |
|
| 1103 | - else |
|
| 1152 | + if (!in_array($post_error_id, $minor_errors)) { |
|
| 1153 | + $context['error_type'] = 'serious'; |
|
| 1154 | + } |
|
| 1155 | + } else |
|
| 1104 | 1156 | { |
| 1105 | 1157 | $context['post_error'][$post_error] = $txt['error_' . $post_error]; |
| 1106 | 1158 | |
| 1107 | 1159 | // If it's not a minor error flag it as such. |
| 1108 | - if (!in_array($post_error, $minor_errors)) |
|
| 1109 | - $context['error_type'] = 'serious'; |
|
| 1160 | + if (!in_array($post_error, $minor_errors)) { |
|
| 1161 | + $context['error_type'] = 'serious'; |
|
| 1162 | + } |
|
| 1110 | 1163 | } |
| 1111 | 1164 | } |
| 1112 | 1165 | |
| 1113 | 1166 | // What are you doing? Posting a poll, modifying, previewing, new post, or reply... |
| 1114 | - if (isset($_REQUEST['poll'])) |
|
| 1115 | - $context['page_title'] = $txt['new_poll']; |
|
| 1116 | - elseif ($context['make_event']) |
|
| 1117 | - $context['page_title'] = $context['event']['id'] == -1 ? $txt['calendar_post_event'] : $txt['calendar_edit']; |
|
| 1118 | - elseif (isset($_REQUEST['msg'])) |
|
| 1119 | - $context['page_title'] = $txt['modify_msg']; |
|
| 1120 | - elseif (isset($_REQUEST['subject'], $context['preview_subject'])) |
|
| 1121 | - $context['page_title'] = $txt['preview'] . ' - ' . strip_tags($context['preview_subject']); |
|
| 1122 | - elseif (empty($topic)) |
|
| 1123 | - $context['page_title'] = $txt['start_new_topic']; |
|
| 1124 | - else |
|
| 1125 | - $context['page_title'] = $txt['post_reply']; |
|
| 1167 | + if (isset($_REQUEST['poll'])) { |
|
| 1168 | + $context['page_title'] = $txt['new_poll']; |
|
| 1169 | + } elseif ($context['make_event']) { |
|
| 1170 | + $context['page_title'] = $context['event']['id'] == -1 ? $txt['calendar_post_event'] : $txt['calendar_edit']; |
|
| 1171 | + } elseif (isset($_REQUEST['msg'])) { |
|
| 1172 | + $context['page_title'] = $txt['modify_msg']; |
|
| 1173 | + } elseif (isset($_REQUEST['subject'], $context['preview_subject'])) { |
|
| 1174 | + $context['page_title'] = $txt['preview'] . ' - ' . strip_tags($context['preview_subject']); |
|
| 1175 | + } elseif (empty($topic)) { |
|
| 1176 | + $context['page_title'] = $txt['start_new_topic']; |
|
| 1177 | + } else { |
|
| 1178 | + $context['page_title'] = $txt['post_reply']; |
|
| 1179 | + } |
|
| 1126 | 1180 | |
| 1127 | 1181 | // Build the link tree. |
| 1128 | - if (empty($topic)) |
|
| 1129 | - $context['linktree'][] = array( |
|
| 1182 | + if (empty($topic)) { |
|
| 1183 | + $context['linktree'][] = array( |
|
| 1130 | 1184 | 'name' => '<em>' . $txt['start_new_topic'] . '</em>' |
| 1131 | 1185 | ); |
| 1132 | - else |
|
| 1133 | - $context['linktree'][] = array( |
|
| 1186 | + } else { |
|
| 1187 | + $context['linktree'][] = array( |
|
| 1134 | 1188 | 'url' => $scripturl . '?topic=' . $topic . '.' . $_REQUEST['start'], |
| 1135 | 1189 | 'name' => $form_subject, |
| 1136 | 1190 | 'extra_before' => '<span><strong class="nav">' . $context['page_title'] . ' (</strong></span>', |
| 1137 | 1191 | 'extra_after' => '<span><strong class="nav">)</strong></span>' |
| 1138 | 1192 | ); |
| 1193 | + } |
|
| 1139 | 1194 | |
| 1140 | 1195 | $context['subject'] = addcslashes($form_subject, '"'); |
| 1141 | 1196 | $context['message'] = str_replace(array('"', '<', '>', ' '), array('"', '<', '>', ' '), $form_message); |
@@ -1179,8 +1234,9 @@ discard block |
||
| 1179 | 1234 | // Message icons - customized icons are off? |
| 1180 | 1235 | $context['icons'] = getMessageIcons(!empty($board) ? $board : 0); |
| 1181 | 1236 | |
| 1182 | - if (!empty($context['icons'])) |
|
| 1183 | - $context['icons'][count($context['icons']) - 1]['is_last'] = true; |
|
| 1237 | + if (!empty($context['icons'])) { |
|
| 1238 | + $context['icons'][count($context['icons']) - 1]['is_last'] = true; |
|
| 1239 | + } |
|
| 1184 | 1240 | |
| 1185 | 1241 | // Are we starting a poll? if set the poll icon as selected if its available |
| 1186 | 1242 | if (isset($_REQUEST['poll'])) |
@@ -1200,8 +1256,9 @@ discard block |
||
| 1200 | 1256 | for ($i = 0, $n = count($context['icons']); $i < $n; $i++) |
| 1201 | 1257 | { |
| 1202 | 1258 | $context['icons'][$i]['selected'] = $context['icon'] == $context['icons'][$i]['value']; |
| 1203 | - if ($context['icons'][$i]['selected']) |
|
| 1204 | - $context['icon_url'] = $context['icons'][$i]['url']; |
|
| 1259 | + if ($context['icons'][$i]['selected']) { |
|
| 1260 | + $context['icon_url'] = $context['icons'][$i]['url']; |
|
| 1261 | + } |
|
| 1205 | 1262 | } |
| 1206 | 1263 | if (empty($context['icon_url'])) |
| 1207 | 1264 | { |
@@ -1215,8 +1272,9 @@ discard block |
||
| 1215 | 1272 | )); |
| 1216 | 1273 | } |
| 1217 | 1274 | |
| 1218 | - if (!empty($topic) && !empty($modSettings['topicSummaryPosts'])) |
|
| 1219 | - getTopic(); |
|
| 1275 | + if (!empty($topic) && !empty($modSettings['topicSummaryPosts'])) { |
|
| 1276 | + getTopic(); |
|
| 1277 | + } |
|
| 1220 | 1278 | |
| 1221 | 1279 | // If the user can post attachments prepare the warning labels. |
| 1222 | 1280 | if ($context['can_post_attachment']) |
@@ -1227,12 +1285,13 @@ discard block |
||
| 1227 | 1285 | $context['attachment_restrictions'] = array(); |
| 1228 | 1286 | $context['allowed_extensions'] = strtr(strtolower($modSettings['attachmentExtensions']), array(',' => ', ')); |
| 1229 | 1287 | $attachmentRestrictionTypes = array('attachmentNumPerPostLimit', 'attachmentPostLimit', 'attachmentSizeLimit'); |
| 1230 | - foreach ($attachmentRestrictionTypes as $type) |
|
| 1231 | - if (!empty($modSettings[$type])) |
|
| 1288 | + foreach ($attachmentRestrictionTypes as $type) { |
|
| 1289 | + if (!empty($modSettings[$type])) |
|
| 1232 | 1290 | { |
| 1233 | 1291 | // Show the max number of attachments if not 0. |
| 1234 | 1292 | if ($type == 'attachmentNumPerPostLimit') |
| 1235 | 1293 | $context['attachment_restrictions'][] = sprintf($txt['attach_remaining'], $modSettings['attachmentNumPerPostLimit'] - $context['attachments']['quantity']); |
| 1294 | + } |
|
| 1236 | 1295 | } |
| 1237 | 1296 | } |
| 1238 | 1297 | |
@@ -1266,8 +1325,8 @@ discard block |
||
| 1266 | 1325 | |
| 1267 | 1326 | if (!empty($context['current_attachments'])) |
| 1268 | 1327 | { |
| 1269 | - foreach ($context['current_attachments'] as $key => $mock) |
|
| 1270 | - addInlineJavaScript(' |
|
| 1328 | + foreach ($context['current_attachments'] as $key => $mock) { |
|
| 1329 | + addInlineJavaScript(' |
|
| 1271 | 1330 | current_attachments.push({ |
| 1272 | 1331 | name: '. JavaScriptEscape($mock['name']) . ', |
| 1273 | 1332 | size: '. $mock['size'] . ', |
@@ -1276,6 +1335,7 @@ discard block |
||
| 1276 | 1335 | type: '. JavaScriptEscape(!empty($mock['mime_type']) ? $mock['mime_type'] : '') . ', |
| 1277 | 1336 | thumbID: '. (!empty($mock['thumb']) ? $mock['thumb'] : 0) . ' |
| 1278 | 1337 | });'); |
| 1338 | + } |
|
| 1279 | 1339 | } |
| 1280 | 1340 | |
| 1281 | 1341 | // File Upload. |
@@ -1350,9 +1410,10 @@ discard block |
||
| 1350 | 1410 | $context['posting_fields']['board']['dd'] .= ' |
| 1351 | 1411 | <optgroup label="' . $category['name'] . '">'; |
| 1352 | 1412 | |
| 1353 | - foreach ($category['boards'] as $brd) |
|
| 1354 | - $context['posting_fields']['board']['dd'] .= ' |
|
| 1413 | + foreach ($category['boards'] as $brd) { |
|
| 1414 | + $context['posting_fields']['board']['dd'] .= ' |
|
| 1355 | 1415 | <option value="' . $brd['id'] . '"' . ($brd['selected'] ? ' selected' : '') . '>' . ($brd['child_level'] > 0 ? str_repeat('==', $brd['child_level'] - 1) . '=>' : '') . ' ' . $brd['name'] . '</option>'; |
| 1416 | + } |
|
| 1356 | 1417 | |
| 1357 | 1418 | $context['posting_fields']['board']['dd'] .= ' |
| 1358 | 1419 | </optgroup>'; |
@@ -1383,8 +1444,9 @@ discard block |
||
| 1383 | 1444 | |
| 1384 | 1445 | |
| 1385 | 1446 | // Finally, load the template. |
| 1386 | - if (!isset($_REQUEST['xml'])) |
|
| 1387 | - loadTemplate('Post'); |
|
| 1447 | + if (!isset($_REQUEST['xml'])) { |
|
| 1448 | + loadTemplate('Post'); |
|
| 1449 | + } |
|
| 1388 | 1450 | |
| 1389 | 1451 | call_integration_hook('integrate_post_end'); |
| 1390 | 1452 | } |
@@ -1405,13 +1467,14 @@ discard block |
||
| 1405 | 1467 | // Sneaking off, are we? |
| 1406 | 1468 | if (empty($_POST) && empty($topic)) |
| 1407 | 1469 | { |
| 1408 | - if (empty($_SERVER['CONTENT_LENGTH'])) |
|
| 1409 | - redirectexit('action=post;board=' . $board . '.0'); |
|
| 1410 | - else |
|
| 1411 | - fatal_lang_error('post_upload_error', false); |
|
| 1470 | + if (empty($_SERVER['CONTENT_LENGTH'])) { |
|
| 1471 | + redirectexit('action=post;board=' . $board . '.0'); |
|
| 1472 | + } else { |
|
| 1473 | + fatal_lang_error('post_upload_error', false); |
|
| 1474 | + } |
|
| 1475 | + } elseif (empty($_POST) && !empty($topic)) { |
|
| 1476 | + redirectexit('action=post;topic=' . $topic . '.0'); |
|
| 1412 | 1477 | } |
| 1413 | - elseif (empty($_POST) && !empty($topic)) |
|
| 1414 | - redirectexit('action=post;topic=' . $topic . '.0'); |
|
| 1415 | 1478 | |
| 1416 | 1479 | // No need! |
| 1417 | 1480 | $context['robot_no_index'] = true; |
@@ -1423,8 +1486,9 @@ discard block |
||
| 1423 | 1486 | $post_errors = array(); |
| 1424 | 1487 | |
| 1425 | 1488 | // If the session has timed out, let the user re-submit their form. |
| 1426 | - if (checkSession('post', '', false) != '') |
|
| 1427 | - $post_errors[] = 'session_timeout'; |
|
| 1489 | + if (checkSession('post', '', false) != '') { |
|
| 1490 | + $post_errors[] = 'session_timeout'; |
|
| 1491 | + } |
|
| 1428 | 1492 | |
| 1429 | 1493 | // Wrong verification code? |
| 1430 | 1494 | if (!$user_info['is_admin'] && !$user_info['is_mod'] && !empty($modSettings['posts_require_captcha']) && ($user_info['posts'] < $modSettings['posts_require_captcha'] || ($user_info['is_guest'] && $modSettings['posts_require_captcha'] == -1))) |
@@ -1434,8 +1498,9 @@ discard block |
||
| 1434 | 1498 | 'id' => 'post', |
| 1435 | 1499 | ); |
| 1436 | 1500 | $context['require_verification'] = create_control_verification($verificationOptions, true); |
| 1437 | - if (is_array($context['require_verification'])) |
|
| 1438 | - $post_errors = array_merge($post_errors, $context['require_verification']); |
|
| 1501 | + if (is_array($context['require_verification'])) { |
|
| 1502 | + $post_errors = array_merge($post_errors, $context['require_verification']); |
|
| 1503 | + } |
|
| 1439 | 1504 | } |
| 1440 | 1505 | |
| 1441 | 1506 | require_once($sourcedir . '/Subs-Post.php'); |
@@ -1444,25 +1509,29 @@ discard block |
||
| 1444 | 1509 | call_integration_hook('integrate_post2_start'); |
| 1445 | 1510 | |
| 1446 | 1511 | // Drafts enabled and needed? |
| 1447 | - if (!empty($modSettings['drafts_post_enabled']) && (isset($_POST['save_draft']) || isset($_POST['id_draft']))) |
|
| 1448 | - require_once($sourcedir . '/Drafts.php'); |
|
| 1512 | + if (!empty($modSettings['drafts_post_enabled']) && (isset($_POST['save_draft']) || isset($_POST['id_draft']))) { |
|
| 1513 | + require_once($sourcedir . '/Drafts.php'); |
|
| 1514 | + } |
|
| 1449 | 1515 | |
| 1450 | 1516 | // First check to see if they are trying to delete any current attachments. |
| 1451 | 1517 | if (isset($_POST['attach_del'])) |
| 1452 | 1518 | { |
| 1453 | 1519 | $keep_temp = array(); |
| 1454 | 1520 | $keep_ids = array(); |
| 1455 | - foreach ($_POST['attach_del'] as $dummy) |
|
| 1456 | - if (strpos($dummy, 'post_tmp_' . $user_info['id']) !== false) |
|
| 1521 | + foreach ($_POST['attach_del'] as $dummy) { |
|
| 1522 | + if (strpos($dummy, 'post_tmp_' . $user_info['id']) !== false) |
|
| 1457 | 1523 | $keep_temp[] = $dummy; |
| 1458 | - else |
|
| 1459 | - $keep_ids[] = (int) $dummy; |
|
| 1524 | + } |
|
| 1525 | + else { |
|
| 1526 | + $keep_ids[] = (int) $dummy; |
|
| 1527 | + } |
|
| 1460 | 1528 | |
| 1461 | - if (isset($_SESSION['temp_attachments'])) |
|
| 1462 | - foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
|
| 1529 | + if (isset($_SESSION['temp_attachments'])) { |
|
| 1530 | + foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
|
| 1463 | 1531 | { |
| 1464 | 1532 | if ((isset($_SESSION['temp_attachments']['post']['files'], $attachment['name']) && in_array($attachment['name'], $_SESSION['temp_attachments']['post']['files'])) || in_array($attachID, $keep_temp) || strpos($attachID, 'post_tmp_' . $user_info['id']) === false) |
| 1465 | 1533 | continue; |
| 1534 | + } |
|
| 1466 | 1535 | |
| 1467 | 1536 | unset($_SESSION['temp_attachments'][$attachID]); |
| 1468 | 1537 | unlink($attachment['tmp_name']); |
@@ -1494,8 +1563,9 @@ discard block |
||
| 1494 | 1563 | { |
| 1495 | 1564 | require_once($sourcedir . '/ManageAttachments.php'); |
| 1496 | 1565 | |
| 1497 | - foreach ($_SESSION['already_attached'] as $attachID => $attachment) |
|
| 1498 | - removeAttachments(array('id_attach' => $attachID)); |
|
| 1566 | + foreach ($_SESSION['already_attached'] as $attachID => $attachment) { |
|
| 1567 | + removeAttachments(array('id_attach' => $attachID)); |
|
| 1568 | + } |
|
| 1499 | 1569 | |
| 1500 | 1570 | unset($_SESSION['already_attached']); |
| 1501 | 1571 | |
@@ -1518,12 +1588,14 @@ discard block |
||
| 1518 | 1588 | $smcFunc['db_free_result']($request); |
| 1519 | 1589 | |
| 1520 | 1590 | // Though the topic should be there, it might have vanished. |
| 1521 | - if (!is_array($topic_info)) |
|
| 1522 | - fatal_lang_error('topic_doesnt_exist', 404); |
|
| 1591 | + if (!is_array($topic_info)) { |
|
| 1592 | + fatal_lang_error('topic_doesnt_exist', 404); |
|
| 1593 | + } |
|
| 1523 | 1594 | |
| 1524 | 1595 | // Did this topic suddenly move? Just checking... |
| 1525 | - if ($topic_info['id_board'] != $board) |
|
| 1526 | - fatal_lang_error('not_a_topic'); |
|
| 1596 | + if ($topic_info['id_board'] != $board) { |
|
| 1597 | + fatal_lang_error('not_a_topic'); |
|
| 1598 | + } |
|
| 1527 | 1599 | |
| 1528 | 1600 | // Do the permissions and approval stuff... |
| 1529 | 1601 | $becomesApproved = true; |
@@ -1546,49 +1618,50 @@ discard block |
||
| 1546 | 1618 | if (!empty($topic) && !isset($_REQUEST['msg'])) |
| 1547 | 1619 | { |
| 1548 | 1620 | // Don't allow a post if it's locked. |
| 1549 | - if ($topic_info['locked'] != 0 && !allowedTo('moderate_board')) |
|
| 1550 | - fatal_lang_error('topic_locked', false); |
|
| 1621 | + if ($topic_info['locked'] != 0 && !allowedTo('moderate_board')) { |
|
| 1622 | + fatal_lang_error('topic_locked', false); |
|
| 1623 | + } |
|
| 1551 | 1624 | |
| 1552 | 1625 | // Sorry, multiple polls aren't allowed... yet. You should stop giving me ideas :P. |
| 1553 | - if (isset($_REQUEST['poll']) && $topic_info['id_poll'] > 0) |
|
| 1554 | - unset($_REQUEST['poll']); |
|
| 1555 | - |
|
| 1556 | - elseif ($topic_info['id_member_started'] != $user_info['id']) |
|
| 1557 | - { |
|
| 1558 | - if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any')) |
|
| 1559 | - $becomesApproved = false; |
|
| 1560 | - |
|
| 1561 | - else |
|
| 1562 | - isAllowedTo('post_reply_any'); |
|
| 1563 | - } |
|
| 1564 | - elseif (!allowedTo('post_reply_any')) |
|
| 1626 | + if (isset($_REQUEST['poll']) && $topic_info['id_poll'] > 0) { |
|
| 1627 | + unset($_REQUEST['poll']); |
|
| 1628 | + } elseif ($topic_info['id_member_started'] != $user_info['id']) |
|
| 1629 | + { |
|
| 1630 | + if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any')) { |
|
| 1631 | + $becomesApproved = false; |
|
| 1632 | + } else { |
|
| 1633 | + isAllowedTo('post_reply_any'); |
|
| 1634 | + } |
|
| 1635 | + } elseif (!allowedTo('post_reply_any')) |
|
| 1565 | 1636 | { |
| 1566 | - if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) |
|
| 1567 | - $becomesApproved = false; |
|
| 1568 | - |
|
| 1569 | - else |
|
| 1570 | - isAllowedTo('post_reply_own'); |
|
| 1637 | + if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) { |
|
| 1638 | + $becomesApproved = false; |
|
| 1639 | + } else { |
|
| 1640 | + isAllowedTo('post_reply_own'); |
|
| 1641 | + } |
|
| 1571 | 1642 | } |
| 1572 | 1643 | |
| 1573 | 1644 | if (isset($_POST['lock'])) |
| 1574 | 1645 | { |
| 1575 | 1646 | // Nothing is changed to the lock. |
| 1576 | - if (empty($topic_info['locked']) == empty($_POST['lock'])) |
|
| 1577 | - unset($_POST['lock']); |
|
| 1647 | + if (empty($topic_info['locked']) == empty($_POST['lock'])) { |
|
| 1648 | + unset($_POST['lock']); |
|
| 1649 | + } |
|
| 1578 | 1650 | |
| 1579 | 1651 | // You're have no permission to lock this topic. |
| 1580 | - elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started'])) |
|
| 1581 | - unset($_POST['lock']); |
|
| 1652 | + elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started'])) { |
|
| 1653 | + unset($_POST['lock']); |
|
| 1654 | + } |
|
| 1582 | 1655 | |
| 1583 | 1656 | // You are allowed to (un)lock your own topic only. |
| 1584 | 1657 | elseif (!allowedTo('lock_any')) |
| 1585 | 1658 | { |
| 1586 | 1659 | // You cannot override a moderator lock. |
| 1587 | - if ($topic_info['locked'] == 1) |
|
| 1588 | - unset($_POST['lock']); |
|
| 1589 | - |
|
| 1590 | - else |
|
| 1591 | - $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
| 1660 | + if ($topic_info['locked'] == 1) { |
|
| 1661 | + unset($_POST['lock']); |
|
| 1662 | + } else { |
|
| 1663 | + $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
| 1664 | + } |
|
| 1592 | 1665 | } |
| 1593 | 1666 | // Hail mighty moderator, (un)lock this topic immediately. |
| 1594 | 1667 | else |
@@ -1596,19 +1669,21 @@ discard block |
||
| 1596 | 1669 | $_POST['lock'] = empty($_POST['lock']) ? 0 : 1; |
| 1597 | 1670 | |
| 1598 | 1671 | // Did someone (un)lock this while you were posting? |
| 1599 | - if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked']) |
|
| 1600 | - $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked'; |
|
| 1672 | + if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked']) { |
|
| 1673 | + $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked'; |
|
| 1674 | + } |
|
| 1601 | 1675 | } |
| 1602 | 1676 | } |
| 1603 | 1677 | |
| 1604 | 1678 | // So you wanna (un)sticky this...let's see. |
| 1605 | - if (isset($_POST['sticky']) && ($_POST['sticky'] == $topic_info['is_sticky'] || !allowedTo('make_sticky'))) |
|
| 1606 | - unset($_POST['sticky']); |
|
| 1607 | - elseif (isset($_POST['sticky'])) |
|
| 1679 | + if (isset($_POST['sticky']) && ($_POST['sticky'] == $topic_info['is_sticky'] || !allowedTo('make_sticky'))) { |
|
| 1680 | + unset($_POST['sticky']); |
|
| 1681 | + } elseif (isset($_POST['sticky'])) |
|
| 1608 | 1682 | { |
| 1609 | 1683 | // Did someone (un)sticky this while you were posting? |
| 1610 | - if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky']) |
|
| 1611 | - $post_errors[] = 'topic_' . (empty($topic_info['is_sticky']) ? 'un' : '') . 'sticky'; |
|
| 1684 | + if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky']) { |
|
| 1685 | + $post_errors[] = 'topic_' . (empty($topic_info['is_sticky']) ? 'un' : '') . 'sticky'; |
|
| 1686 | + } |
|
| 1612 | 1687 | } |
| 1613 | 1688 | |
| 1614 | 1689 | // If drafts are enabled, then pass this off |
@@ -1635,26 +1710,31 @@ discard block |
||
| 1635 | 1710 | |
| 1636 | 1711 | // Do like, the permissions, for safety and stuff... |
| 1637 | 1712 | $becomesApproved = true; |
| 1638 | - if ($modSettings['postmod_active'] && !allowedTo('post_new') && allowedTo('post_unapproved_topics')) |
|
| 1639 | - $becomesApproved = false; |
|
| 1640 | - else |
|
| 1641 | - isAllowedTo('post_new'); |
|
| 1713 | + if ($modSettings['postmod_active'] && !allowedTo('post_new') && allowedTo('post_unapproved_topics')) { |
|
| 1714 | + $becomesApproved = false; |
|
| 1715 | + } else { |
|
| 1716 | + isAllowedTo('post_new'); |
|
| 1717 | + } |
|
| 1642 | 1718 | |
| 1643 | 1719 | if (isset($_POST['lock'])) |
| 1644 | 1720 | { |
| 1645 | 1721 | // New topics are by default not locked. |
| 1646 | - if (empty($_POST['lock'])) |
|
| 1647 | - unset($_POST['lock']); |
|
| 1722 | + if (empty($_POST['lock'])) { |
|
| 1723 | + unset($_POST['lock']); |
|
| 1724 | + } |
|
| 1648 | 1725 | // Besides, you need permission. |
| 1649 | - elseif (!allowedTo(array('lock_any', 'lock_own'))) |
|
| 1650 | - unset($_POST['lock']); |
|
| 1726 | + elseif (!allowedTo(array('lock_any', 'lock_own'))) { |
|
| 1727 | + unset($_POST['lock']); |
|
| 1728 | + } |
|
| 1651 | 1729 | // A moderator-lock (1) can override a user-lock (2). |
| 1652 | - else |
|
| 1653 | - $_POST['lock'] = allowedTo('lock_any') ? 1 : 2; |
|
| 1730 | + else { |
|
| 1731 | + $_POST['lock'] = allowedTo('lock_any') ? 1 : 2; |
|
| 1732 | + } |
|
| 1654 | 1733 | } |
| 1655 | 1734 | |
| 1656 | - if (isset($_POST['sticky']) && (empty($_POST['sticky']) || !allowedTo('make_sticky'))) |
|
| 1657 | - unset($_POST['sticky']); |
|
| 1735 | + if (isset($_POST['sticky']) && (empty($_POST['sticky']) || !allowedTo('make_sticky'))) { |
|
| 1736 | + unset($_POST['sticky']); |
|
| 1737 | + } |
|
| 1658 | 1738 | |
| 1659 | 1739 | // Saving your new topic as a draft first? |
| 1660 | 1740 | if (!empty($modSettings['drafts_post_enabled']) && isset($_POST['save_draft'])) |
@@ -1679,31 +1759,37 @@ discard block |
||
| 1679 | 1759 | 'id_msg' => $_REQUEST['msg'], |
| 1680 | 1760 | ) |
| 1681 | 1761 | ); |
| 1682 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 1683 | - fatal_lang_error('cant_find_messages', false); |
|
| 1762 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 1763 | + fatal_lang_error('cant_find_messages', false); |
|
| 1764 | + } |
|
| 1684 | 1765 | $row = $smcFunc['db_fetch_assoc']($request); |
| 1685 | 1766 | $smcFunc['db_free_result']($request); |
| 1686 | 1767 | |
| 1687 | - if (!empty($topic_info['locked']) && !allowedTo('moderate_board')) |
|
| 1688 | - fatal_lang_error('topic_locked', false); |
|
| 1768 | + if (!empty($topic_info['locked']) && !allowedTo('moderate_board')) { |
|
| 1769 | + fatal_lang_error('topic_locked', false); |
|
| 1770 | + } |
|
| 1689 | 1771 | |
| 1690 | 1772 | if (isset($_POST['lock'])) |
| 1691 | 1773 | { |
| 1692 | 1774 | // Nothing changes to the lock status. |
| 1693 | - if ((empty($_POST['lock']) && empty($topic_info['locked'])) || (!empty($_POST['lock']) && !empty($topic_info['locked']))) |
|
| 1694 | - unset($_POST['lock']); |
|
| 1775 | + if ((empty($_POST['lock']) && empty($topic_info['locked'])) || (!empty($_POST['lock']) && !empty($topic_info['locked']))) { |
|
| 1776 | + unset($_POST['lock']); |
|
| 1777 | + } |
|
| 1695 | 1778 | // You're simply not allowed to (un)lock this. |
| 1696 | - elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started'])) |
|
| 1697 | - unset($_POST['lock']); |
|
| 1779 | + elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started'])) { |
|
| 1780 | + unset($_POST['lock']); |
|
| 1781 | + } |
|
| 1698 | 1782 | // You're only allowed to lock your own topics. |
| 1699 | 1783 | elseif (!allowedTo('lock_any')) |
| 1700 | 1784 | { |
| 1701 | 1785 | // You're not allowed to break a moderator's lock. |
| 1702 | - if ($topic_info['locked'] == 1) |
|
| 1703 | - unset($_POST['lock']); |
|
| 1786 | + if ($topic_info['locked'] == 1) { |
|
| 1787 | + unset($_POST['lock']); |
|
| 1788 | + } |
|
| 1704 | 1789 | // Lock it with a soft lock or unlock it. |
| 1705 | - else |
|
| 1706 | - $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
| 1790 | + else { |
|
| 1791 | + $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
| 1792 | + } |
|
| 1707 | 1793 | } |
| 1708 | 1794 | // You must be the moderator. |
| 1709 | 1795 | else |
@@ -1711,44 +1797,46 @@ discard block |
||
| 1711 | 1797 | $_POST['lock'] = empty($_POST['lock']) ? 0 : 1; |
| 1712 | 1798 | |
| 1713 | 1799 | // Did someone (un)lock this while you were posting? |
| 1714 | - if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked']) |
|
| 1715 | - $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked'; |
|
| 1800 | + if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked']) { |
|
| 1801 | + $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked'; |
|
| 1802 | + } |
|
| 1716 | 1803 | } |
| 1717 | 1804 | } |
| 1718 | 1805 | |
| 1719 | 1806 | // Change the sticky status of this topic? |
| 1720 | - if (isset($_POST['sticky']) && (!allowedTo('make_sticky') || $_POST['sticky'] == $topic_info['is_sticky'])) |
|
| 1721 | - unset($_POST['sticky']); |
|
| 1722 | - elseif (isset($_POST['sticky'])) |
|
| 1807 | + if (isset($_POST['sticky']) && (!allowedTo('make_sticky') || $_POST['sticky'] == $topic_info['is_sticky'])) { |
|
| 1808 | + unset($_POST['sticky']); |
|
| 1809 | + } elseif (isset($_POST['sticky'])) |
|
| 1723 | 1810 | { |
| 1724 | 1811 | // Did someone (un)sticky this while you were posting? |
| 1725 | - if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky']) |
|
| 1726 | - $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'stickied'; |
|
| 1812 | + if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky']) { |
|
| 1813 | + $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'stickied'; |
|
| 1814 | + } |
|
| 1727 | 1815 | } |
| 1728 | 1816 | |
| 1729 | 1817 | if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any')) |
| 1730 | 1818 | { |
| 1731 | - if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) |
|
| 1732 | - fatal_lang_error('modify_post_time_passed', false); |
|
| 1733 | - elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_own')) |
|
| 1734 | - isAllowedTo('modify_replies'); |
|
| 1735 | - else |
|
| 1736 | - isAllowedTo('modify_own'); |
|
| 1737 | - } |
|
| 1738 | - elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_any')) |
|
| 1819 | + if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) { |
|
| 1820 | + fatal_lang_error('modify_post_time_passed', false); |
|
| 1821 | + } elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_own')) { |
|
| 1822 | + isAllowedTo('modify_replies'); |
|
| 1823 | + } else { |
|
| 1824 | + isAllowedTo('modify_own'); |
|
| 1825 | + } |
|
| 1826 | + } elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_any')) |
|
| 1739 | 1827 | { |
| 1740 | 1828 | isAllowedTo('modify_replies'); |
| 1741 | 1829 | |
| 1742 | 1830 | // If you're modifying a reply, I say it better be logged... |
| 1743 | 1831 | $moderationAction = true; |
| 1744 | - } |
|
| 1745 | - else |
|
| 1832 | + } else |
|
| 1746 | 1833 | { |
| 1747 | 1834 | isAllowedTo('modify_any'); |
| 1748 | 1835 | |
| 1749 | 1836 | // Log it, assuming you're not modifying your own post. |
| 1750 | - if ($row['id_member'] != $user_info['id']) |
|
| 1751 | - $moderationAction = true; |
|
| 1837 | + if ($row['id_member'] != $user_info['id']) { |
|
| 1838 | + $moderationAction = true; |
|
| 1839 | + } |
|
| 1752 | 1840 | } |
| 1753 | 1841 | |
| 1754 | 1842 | // If drafts are enabled, then lets send this off to save |
@@ -1775,8 +1863,9 @@ discard block |
||
| 1775 | 1863 | // Update search api |
| 1776 | 1864 | require_once($sourcedir . '/Search.php'); |
| 1777 | 1865 | $searchAPI = findSearchAPI(); |
| 1778 | - if ($searchAPI->supportsMethod('postRemoved')) |
|
| 1779 | - $searchAPI->postRemoved($_REQUEST['msg']); |
|
| 1866 | + if ($searchAPI->supportsMethod('postRemoved')) { |
|
| 1867 | + $searchAPI->postRemoved($_REQUEST['msg']); |
|
| 1868 | + } |
|
| 1780 | 1869 | |
| 1781 | 1870 | } |
| 1782 | 1871 | |
@@ -1794,20 +1883,24 @@ discard block |
||
| 1794 | 1883 | $_POST['guestname'] = !isset($_POST['guestname']) ? '' : trim($_POST['guestname']); |
| 1795 | 1884 | $_POST['email'] = !isset($_POST['email']) ? '' : trim($_POST['email']); |
| 1796 | 1885 | |
| 1797 | - if ($_POST['guestname'] == '' || $_POST['guestname'] == '_') |
|
| 1798 | - $post_errors[] = 'no_name'; |
|
| 1799 | - if ($smcFunc['strlen']($_POST['guestname']) > 25) |
|
| 1800 | - $post_errors[] = 'long_name'; |
|
| 1886 | + if ($_POST['guestname'] == '' || $_POST['guestname'] == '_') { |
|
| 1887 | + $post_errors[] = 'no_name'; |
|
| 1888 | + } |
|
| 1889 | + if ($smcFunc['strlen']($_POST['guestname']) > 25) { |
|
| 1890 | + $post_errors[] = 'long_name'; |
|
| 1891 | + } |
|
| 1801 | 1892 | |
| 1802 | 1893 | if (empty($modSettings['guest_post_no_email'])) |
| 1803 | 1894 | { |
| 1804 | 1895 | // Only check if they changed it! |
| 1805 | 1896 | if (!isset($row) || $row['poster_email'] != $_POST['email']) |
| 1806 | 1897 | { |
| 1807 | - if (!allowedTo('moderate_forum') && (!isset($_POST['email']) || $_POST['email'] == '')) |
|
| 1808 | - $post_errors[] = 'no_email'; |
|
| 1809 | - if (!allowedTo('moderate_forum') && !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) |
|
| 1810 | - $post_errors[] = 'bad_email'; |
|
| 1898 | + if (!allowedTo('moderate_forum') && (!isset($_POST['email']) || $_POST['email'] == '')) { |
|
| 1899 | + $post_errors[] = 'no_email'; |
|
| 1900 | + } |
|
| 1901 | + if (!allowedTo('moderate_forum') && !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) { |
|
| 1902 | + $post_errors[] = 'bad_email'; |
|
| 1903 | + } |
|
| 1811 | 1904 | } |
| 1812 | 1905 | |
| 1813 | 1906 | // Now make sure this email address is not banned from posting. |
@@ -1823,81 +1916,95 @@ discard block |
||
| 1823 | 1916 | } |
| 1824 | 1917 | |
| 1825 | 1918 | // Coming from the quickReply? |
| 1826 | - if (isset($_POST['quickReply'])) |
|
| 1827 | - $_POST['message'] = $_POST['quickReply']; |
|
| 1919 | + if (isset($_POST['quickReply'])) { |
|
| 1920 | + $_POST['message'] = $_POST['quickReply']; |
|
| 1921 | + } |
|
| 1828 | 1922 | |
| 1829 | 1923 | // Check the subject and message. |
| 1830 | - if (!isset($_POST['subject']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['subject'])) === '') |
|
| 1831 | - $post_errors[] = 'no_subject'; |
|
| 1832 | - if (!isset($_POST['message']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['message']), ENT_QUOTES) === '') |
|
| 1833 | - $post_errors[] = 'no_message'; |
|
| 1834 | - elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength']) |
|
| 1835 | - $post_errors[] = array('long_message', array($modSettings['max_messageLength'])); |
|
| 1836 | - else |
|
| 1924 | + if (!isset($_POST['subject']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['subject'])) === '') { |
|
| 1925 | + $post_errors[] = 'no_subject'; |
|
| 1926 | + } |
|
| 1927 | + if (!isset($_POST['message']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['message']), ENT_QUOTES) === '') { |
|
| 1928 | + $post_errors[] = 'no_message'; |
|
| 1929 | + } elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength']) { |
|
| 1930 | + $post_errors[] = array('long_message', array($modSettings['max_messageLength'])); |
|
| 1931 | + } else |
|
| 1837 | 1932 | { |
| 1838 | 1933 | // Prepare the message a bit for some additional testing. |
| 1839 | 1934 | $_POST['message'] = $smcFunc['htmlspecialchars']($_POST['message'], ENT_QUOTES); |
| 1840 | 1935 | |
| 1841 | 1936 | // Preparse code. (Zef) |
| 1842 | - if ($user_info['is_guest']) |
|
| 1843 | - $user_info['name'] = $_POST['guestname']; |
|
| 1937 | + if ($user_info['is_guest']) { |
|
| 1938 | + $user_info['name'] = $_POST['guestname']; |
|
| 1939 | + } |
|
| 1844 | 1940 | preparsecode($_POST['message']); |
| 1845 | 1941 | |
| 1846 | 1942 | // Youtube BBC would be stripped out in the next check without this |
| 1847 | 1943 | $context['allowed_html_tags'][] = '<iframe>'; |
| 1848 | 1944 | |
| 1849 | 1945 | // Let's see if there's still some content left without the tags. |
| 1850 | - if ($smcFunc['htmltrim'](strip_tags(parse_bbc($_POST['message'], false), implode('', $context['allowed_html_tags']))) === '' && (!allowedTo('admin_forum') || strpos($_POST['message'], '[html]') === false)) |
|
| 1851 | - $post_errors[] = 'no_message'; |
|
| 1946 | + if ($smcFunc['htmltrim'](strip_tags(parse_bbc($_POST['message'], false), implode('', $context['allowed_html_tags']))) === '' && (!allowedTo('admin_forum') || strpos($_POST['message'], '[html]') === false)) { |
|
| 1947 | + $post_errors[] = 'no_message'; |
|
| 1948 | + } |
|
| 1852 | 1949 | |
| 1853 | 1950 | // Remove iframe from the list |
| 1854 | 1951 | array_pop($context['allowed_html_tags']); |
| 1855 | 1952 | } |
| 1856 | - if (isset($_POST['calendar']) && !isset($_REQUEST['deleteevent']) && $smcFunc['htmltrim']($_POST['evtitle']) === '') |
|
| 1857 | - $post_errors[] = 'no_event'; |
|
| 1953 | + if (isset($_POST['calendar']) && !isset($_REQUEST['deleteevent']) && $smcFunc['htmltrim']($_POST['evtitle']) === '') { |
|
| 1954 | + $post_errors[] = 'no_event'; |
|
| 1955 | + } |
|
| 1858 | 1956 | // You are not! |
| 1859 | - if (isset($_POST['message']) && strtolower($_POST['message']) == 'i am the administrator.' && !$user_info['is_admin']) |
|
| 1860 | - fatal_error('Knave! Masquerader! Charlatan!', false); |
|
| 1957 | + if (isset($_POST['message']) && strtolower($_POST['message']) == 'i am the administrator.' && !$user_info['is_admin']) { |
|
| 1958 | + fatal_error('Knave! Masquerader! Charlatan!', false); |
|
| 1959 | + } |
|
| 1861 | 1960 | |
| 1862 | 1961 | // Validate the poll... |
| 1863 | 1962 | if (isset($_REQUEST['poll']) && $modSettings['pollMode'] == '1') |
| 1864 | 1963 | { |
| 1865 | - if (!empty($topic) && !isset($_REQUEST['msg'])) |
|
| 1866 | - fatal_lang_error('no_access', false); |
|
| 1964 | + if (!empty($topic) && !isset($_REQUEST['msg'])) { |
|
| 1965 | + fatal_lang_error('no_access', false); |
|
| 1966 | + } |
|
| 1867 | 1967 | |
| 1868 | 1968 | // This is a new topic... so it's a new poll. |
| 1869 | - if (empty($topic)) |
|
| 1870 | - isAllowedTo('poll_post'); |
|
| 1969 | + if (empty($topic)) { |
|
| 1970 | + isAllowedTo('poll_post'); |
|
| 1971 | + } |
|
| 1871 | 1972 | // Can you add to your own topics? |
| 1872 | - elseif ($user_info['id'] == $topic_info['id_member_started'] && !allowedTo('poll_add_any')) |
|
| 1873 | - isAllowedTo('poll_add_own'); |
|
| 1973 | + elseif ($user_info['id'] == $topic_info['id_member_started'] && !allowedTo('poll_add_any')) { |
|
| 1974 | + isAllowedTo('poll_add_own'); |
|
| 1975 | + } |
|
| 1874 | 1976 | // Can you add polls to any topic, then? |
| 1875 | - else |
|
| 1876 | - isAllowedTo('poll_add_any'); |
|
| 1977 | + else { |
|
| 1978 | + isAllowedTo('poll_add_any'); |
|
| 1979 | + } |
|
| 1877 | 1980 | |
| 1878 | - if (!isset($_POST['question']) || trim($_POST['question']) == '') |
|
| 1879 | - $post_errors[] = 'no_question'; |
|
| 1981 | + if (!isset($_POST['question']) || trim($_POST['question']) == '') { |
|
| 1982 | + $post_errors[] = 'no_question'; |
|
| 1983 | + } |
|
| 1880 | 1984 | |
| 1881 | 1985 | $_POST['options'] = empty($_POST['options']) ? array() : htmltrim__recursive($_POST['options']); |
| 1882 | 1986 | |
| 1883 | 1987 | // Get rid of empty ones. |
| 1884 | - foreach ($_POST['options'] as $k => $option) |
|
| 1885 | - if ($option == '') |
|
| 1988 | + foreach ($_POST['options'] as $k => $option) { |
|
| 1989 | + if ($option == '') |
|
| 1886 | 1990 | unset($_POST['options'][$k], $_POST['options'][$k]); |
| 1991 | + } |
|
| 1887 | 1992 | |
| 1888 | 1993 | // What are you going to vote between with one choice?!? |
| 1889 | - if (count($_POST['options']) < 2) |
|
| 1890 | - $post_errors[] = 'poll_few'; |
|
| 1891 | - elseif (count($_POST['options']) > 256) |
|
| 1892 | - $post_errors[] = 'poll_many'; |
|
| 1994 | + if (count($_POST['options']) < 2) { |
|
| 1995 | + $post_errors[] = 'poll_few'; |
|
| 1996 | + } elseif (count($_POST['options']) > 256) { |
|
| 1997 | + $post_errors[] = 'poll_many'; |
|
| 1998 | + } |
|
| 1893 | 1999 | } |
| 1894 | 2000 | |
| 1895 | 2001 | if ($posterIsGuest) |
| 1896 | 2002 | { |
| 1897 | 2003 | // If user is a guest, make sure the chosen name isn't taken. |
| 1898 | 2004 | require_once($sourcedir . '/Subs-Members.php'); |
| 1899 | - if (isReservedName($_POST['guestname'], 0, true, false) && (!isset($row['poster_name']) || $_POST['guestname'] != $row['poster_name'])) |
|
| 1900 | - $post_errors[] = 'bad_name'; |
|
| 2005 | + if (isReservedName($_POST['guestname'], 0, true, false) && (!isset($row['poster_name']) || $_POST['guestname'] != $row['poster_name'])) { |
|
| 2006 | + $post_errors[] = 'bad_name'; |
|
| 2007 | + } |
|
| 1901 | 2008 | } |
| 1902 | 2009 | // If the user isn't a guest, get his or her name and email. |
| 1903 | 2010 | elseif (!isset($_REQUEST['msg'])) |
@@ -1928,8 +2035,9 @@ discard block |
||
| 1928 | 2035 | } |
| 1929 | 2036 | |
| 1930 | 2037 | // Make sure the user isn't spamming the board. |
| 1931 | - if (!isset($_REQUEST['msg'])) |
|
| 1932 | - spamProtection('post'); |
|
| 2038 | + if (!isset($_REQUEST['msg'])) { |
|
| 2039 | + spamProtection('post'); |
|
| 2040 | + } |
|
| 1933 | 2041 | |
| 1934 | 2042 | // At about this point, we're posting and that's that. |
| 1935 | 2043 | ignore_user_abort(true); |
@@ -1942,32 +2050,36 @@ discard block |
||
| 1942 | 2050 | $_POST['modify_reason'] = empty($_POST['modify_reason']) ? '' : strtr($smcFunc['htmlspecialchars']($_POST['modify_reason']), array("\r" => '', "\n" => '', "\t" => '')); |
| 1943 | 2051 | |
| 1944 | 2052 | // At this point, we want to make sure the subject isn't too long. |
| 1945 | - if ($smcFunc['strlen']($_POST['subject']) > 100) |
|
| 1946 | - $_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100); |
|
| 2053 | + if ($smcFunc['strlen']($_POST['subject']) > 100) { |
|
| 2054 | + $_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100); |
|
| 2055 | + } |
|
| 1947 | 2056 | |
| 1948 | 2057 | // Same with the "why did you edit this" text. |
| 1949 | - if ($smcFunc['strlen']($_POST['modify_reason']) > 100) |
|
| 1950 | - $_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100); |
|
| 2058 | + if ($smcFunc['strlen']($_POST['modify_reason']) > 100) { |
|
| 2059 | + $_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100); |
|
| 2060 | + } |
|
| 1951 | 2061 | |
| 1952 | 2062 | // Make the poll... |
| 1953 | 2063 | if (isset($_REQUEST['poll'])) |
| 1954 | 2064 | { |
| 1955 | 2065 | // Make sure that the user has not entered a ridiculous number of options.. |
| 1956 | - if (empty($_POST['poll_max_votes']) || $_POST['poll_max_votes'] <= 0) |
|
| 1957 | - $_POST['poll_max_votes'] = 1; |
|
| 1958 | - elseif ($_POST['poll_max_votes'] > count($_POST['options'])) |
|
| 1959 | - $_POST['poll_max_votes'] = count($_POST['options']); |
|
| 1960 | - else |
|
| 1961 | - $_POST['poll_max_votes'] = (int) $_POST['poll_max_votes']; |
|
| 2066 | + if (empty($_POST['poll_max_votes']) || $_POST['poll_max_votes'] <= 0) { |
|
| 2067 | + $_POST['poll_max_votes'] = 1; |
|
| 2068 | + } elseif ($_POST['poll_max_votes'] > count($_POST['options'])) { |
|
| 2069 | + $_POST['poll_max_votes'] = count($_POST['options']); |
|
| 2070 | + } else { |
|
| 2071 | + $_POST['poll_max_votes'] = (int) $_POST['poll_max_votes']; |
|
| 2072 | + } |
|
| 1962 | 2073 | |
| 1963 | 2074 | $_POST['poll_expire'] = (int) $_POST['poll_expire']; |
| 1964 | 2075 | $_POST['poll_expire'] = $_POST['poll_expire'] > 9999 ? 9999 : ($_POST['poll_expire'] < 0 ? 0 : $_POST['poll_expire']); |
| 1965 | 2076 | |
| 1966 | 2077 | // Just set it to zero if it's not there.. |
| 1967 | - if (!isset($_POST['poll_hide'])) |
|
| 1968 | - $_POST['poll_hide'] = 0; |
|
| 1969 | - else |
|
| 1970 | - $_POST['poll_hide'] = (int) $_POST['poll_hide']; |
|
| 2078 | + if (!isset($_POST['poll_hide'])) { |
|
| 2079 | + $_POST['poll_hide'] = 0; |
|
| 2080 | + } else { |
|
| 2081 | + $_POST['poll_hide'] = (int) $_POST['poll_hide']; |
|
| 2082 | + } |
|
| 1971 | 2083 | $_POST['poll_change_vote'] = isset($_POST['poll_change_vote']) ? 1 : 0; |
| 1972 | 2084 | |
| 1973 | 2085 | $_POST['poll_guest_vote'] = isset($_POST['poll_guest_vote']) ? 1 : 0; |
@@ -1976,16 +2088,19 @@ discard block |
||
| 1976 | 2088 | { |
| 1977 | 2089 | require_once($sourcedir . '/Subs-Members.php'); |
| 1978 | 2090 | $allowedVoteGroups = groupsAllowedTo('poll_vote', $board); |
| 1979 | - if (!in_array(-1, $allowedVoteGroups['allowed'])) |
|
| 1980 | - $_POST['poll_guest_vote'] = 0; |
|
| 2091 | + if (!in_array(-1, $allowedVoteGroups['allowed'])) { |
|
| 2092 | + $_POST['poll_guest_vote'] = 0; |
|
| 2093 | + } |
|
| 1981 | 2094 | } |
| 1982 | 2095 | |
| 1983 | 2096 | // If the user tries to set the poll too far in advance, don't let them. |
| 1984 | - if (!empty($_POST['poll_expire']) && $_POST['poll_expire'] < 1) |
|
| 1985 | - fatal_lang_error('poll_range_error', false); |
|
| 2097 | + if (!empty($_POST['poll_expire']) && $_POST['poll_expire'] < 1) { |
|
| 2098 | + fatal_lang_error('poll_range_error', false); |
|
| 2099 | + } |
|
| 1986 | 2100 | // Don't allow them to select option 2 for hidden results if it's not time limited. |
| 1987 | - elseif (empty($_POST['poll_expire']) && $_POST['poll_hide'] == 2) |
|
| 1988 | - $_POST['poll_hide'] = 1; |
|
| 2101 | + elseif (empty($_POST['poll_expire']) && $_POST['poll_hide'] == 2) { |
|
| 2102 | + $_POST['poll_hide'] = 1; |
|
| 2103 | + } |
|
| 1989 | 2104 | |
| 1990 | 2105 | // Clean up the question and answers. |
| 1991 | 2106 | $_POST['question'] = $smcFunc['htmlspecialchars']($_POST['question']); |
@@ -1999,13 +2114,15 @@ discard block |
||
| 1999 | 2114 | { |
| 2000 | 2115 | $attachIDs = array(); |
| 2001 | 2116 | $attach_errors = array(); |
| 2002 | - if (!empty($context['we_are_history'])) |
|
| 2003 | - $attach_errors[] = '<dd>' . $txt['error_temp_attachments_flushed'] . '<br><br></dd>'; |
|
| 2117 | + if (!empty($context['we_are_history'])) { |
|
| 2118 | + $attach_errors[] = '<dd>' . $txt['error_temp_attachments_flushed'] . '<br><br></dd>'; |
|
| 2119 | + } |
|
| 2004 | 2120 | |
| 2005 | 2121 | foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
| 2006 | 2122 | { |
| 2007 | - if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false) |
|
| 2008 | - continue; |
|
| 2123 | + if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false) { |
|
| 2124 | + continue; |
|
| 2125 | + } |
|
| 2009 | 2126 | |
| 2010 | 2127 | // If there was an initial error just show that message. |
| 2011 | 2128 | if ($attachID == 'initial_error') |
@@ -2034,12 +2151,13 @@ discard block |
||
| 2034 | 2151 | if (createAttachment($attachmentOptions)) |
| 2035 | 2152 | { |
| 2036 | 2153 | $attachIDs[] = $attachmentOptions['id']; |
| 2037 | - if (!empty($attachmentOptions['thumb'])) |
|
| 2038 | - $attachIDs[] = $attachmentOptions['thumb']; |
|
| 2154 | + if (!empty($attachmentOptions['thumb'])) { |
|
| 2155 | + $attachIDs[] = $attachmentOptions['thumb']; |
|
| 2156 | + } |
|
| 2039 | 2157 | } |
| 2158 | + } else { |
|
| 2159 | + $attach_errors[] = '<dt> </dt>'; |
|
| 2040 | 2160 | } |
| 2041 | - else |
|
| 2042 | - $attach_errors[] = '<dt> </dt>'; |
|
| 2043 | 2161 | |
| 2044 | 2162 | if (!empty($attachmentOptions['errors'])) |
| 2045 | 2163 | { |
@@ -2051,14 +2169,16 @@ discard block |
||
| 2051 | 2169 | if (!is_array($error)) |
| 2052 | 2170 | { |
| 2053 | 2171 | $attach_errors[] = '<dd>' . $txt[$error] . '</dd>'; |
| 2054 | - if (in_array($error, $log_these)) |
|
| 2055 | - log_error($attachment['name'] . ': ' . $txt[$error], 'critical'); |
|
| 2172 | + if (in_array($error, $log_these)) { |
|
| 2173 | + log_error($attachment['name'] . ': ' . $txt[$error], 'critical'); |
|
| 2174 | + } |
|
| 2175 | + } else { |
|
| 2176 | + $attach_errors[] = '<dd>' . vsprintf($txt[$error[0]], $error[1]) . '</dd>'; |
|
| 2056 | 2177 | } |
| 2057 | - else |
|
| 2058 | - $attach_errors[] = '<dd>' . vsprintf($txt[$error[0]], $error[1]) . '</dd>'; |
|
| 2059 | 2178 | } |
| 2060 | - if (file_exists($attachment['tmp_name'])) |
|
| 2061 | - unlink($attachment['tmp_name']); |
|
| 2179 | + if (file_exists($attachment['tmp_name'])) { |
|
| 2180 | + unlink($attachment['tmp_name']); |
|
| 2181 | + } |
|
| 2062 | 2182 | } |
| 2063 | 2183 | } |
| 2064 | 2184 | unset($_SESSION['temp_attachments']); |
@@ -2099,24 +2219,24 @@ discard block |
||
| 2099 | 2219 | ); |
| 2100 | 2220 | |
| 2101 | 2221 | call_integration_hook('integrate_poll_add_edit', array($id_poll, false)); |
| 2222 | + } else { |
|
| 2223 | + $id_poll = 0; |
|
| 2102 | 2224 | } |
| 2103 | - else |
|
| 2104 | - $id_poll = 0; |
|
| 2105 | 2225 | |
| 2106 | 2226 | // Creating a new topic? |
| 2107 | 2227 | $newTopic = empty($_REQUEST['msg']) && empty($topic); |
| 2108 | 2228 | |
| 2109 | 2229 | // Check the icon. |
| 2110 | - if (!isset($_POST['icon'])) |
|
| 2111 | - $_POST['icon'] = 'xx'; |
|
| 2112 | - |
|
| 2113 | - else |
|
| 2230 | + if (!isset($_POST['icon'])) { |
|
| 2231 | + $_POST['icon'] = 'xx'; |
|
| 2232 | + } else |
|
| 2114 | 2233 | { |
| 2115 | 2234 | $_POST['icon'] = $smcFunc['htmlspecialchars']($_POST['icon']); |
| 2116 | 2235 | |
| 2117 | 2236 | // Need to figure it out if this is a valid icon name. |
| 2118 | - if ((!file_exists($settings['theme_dir'] . '/images/post/' . $_POST['icon'] . '.png')) && (!file_exists($settings['default_theme_dir'] . '/images/post/' . $_POST['icon'] . '.png'))) |
|
| 2119 | - $_POST['icon'] = 'xx'; |
|
| 2237 | + if ((!file_exists($settings['theme_dir'] . '/images/post/' . $_POST['icon'] . '.png')) && (!file_exists($settings['default_theme_dir'] . '/images/post/' . $_POST['icon'] . '.png'))) { |
|
| 2238 | + $_POST['icon'] = 'xx'; |
|
| 2239 | + } |
|
| 2120 | 2240 | } |
| 2121 | 2241 | |
| 2122 | 2242 | // Collect all parameters for the creation or modification of a post. |
@@ -2157,8 +2277,9 @@ discard block |
||
| 2157 | 2277 | } |
| 2158 | 2278 | |
| 2159 | 2279 | // This will save some time... |
| 2160 | - if (empty($approve_has_changed)) |
|
| 2161 | - unset($msgOptions['approved']); |
|
| 2280 | + if (empty($approve_has_changed)) { |
|
| 2281 | + unset($msgOptions['approved']); |
|
| 2282 | + } |
|
| 2162 | 2283 | |
| 2163 | 2284 | modifyPost($msgOptions, $topicOptions, $posterOptions); |
| 2164 | 2285 | } |
@@ -2167,8 +2288,9 @@ discard block |
||
| 2167 | 2288 | { |
| 2168 | 2289 | createPost($msgOptions, $topicOptions, $posterOptions); |
| 2169 | 2290 | |
| 2170 | - if (isset($topicOptions['id'])) |
|
| 2171 | - $topic = $topicOptions['id']; |
|
| 2291 | + if (isset($topicOptions['id'])) { |
|
| 2292 | + $topic = $topicOptions['id']; |
|
| 2293 | + } |
|
| 2172 | 2294 | } |
| 2173 | 2295 | |
| 2174 | 2296 | // Are there attachments already uploaded and waiting to be assigned? |
@@ -2180,8 +2302,9 @@ discard block |
||
| 2180 | 2302 | } |
| 2181 | 2303 | |
| 2182 | 2304 | // If we had a draft for this, its time to remove it since it was just posted |
| 2183 | - if (!empty($modSettings['drafts_post_enabled']) && !empty($_POST['id_draft'])) |
|
| 2184 | - DeleteDraft($_POST['id_draft']); |
|
| 2305 | + if (!empty($modSettings['drafts_post_enabled']) && !empty($_POST['id_draft'])) { |
|
| 2306 | + DeleteDraft($_POST['id_draft']); |
|
| 2307 | + } |
|
| 2185 | 2308 | |
| 2186 | 2309 | // Editing or posting an event? |
| 2187 | 2310 | if (isset($_POST['calendar']) && (!isset($_REQUEST['eventid']) || $_REQUEST['eventid'] == -1)) |
@@ -2200,8 +2323,7 @@ discard block |
||
| 2200 | 2323 | 'member' => $user_info['id'], |
| 2201 | 2324 | ); |
| 2202 | 2325 | insertEvent($eventOptions); |
| 2203 | - } |
|
| 2204 | - elseif (isset($_POST['calendar'])) |
|
| 2326 | + } elseif (isset($_POST['calendar'])) |
|
| 2205 | 2327 | { |
| 2206 | 2328 | $_REQUEST['eventid'] = (int) $_REQUEST['eventid']; |
| 2207 | 2329 | |
@@ -2229,14 +2351,15 @@ discard block |
||
| 2229 | 2351 | } |
| 2230 | 2352 | |
| 2231 | 2353 | // Delete it? |
| 2232 | - if (isset($_REQUEST['deleteevent'])) |
|
| 2233 | - $smcFunc['db_query']('', ' |
|
| 2354 | + if (isset($_REQUEST['deleteevent'])) { |
|
| 2355 | + $smcFunc['db_query']('', ' |
|
| 2234 | 2356 | DELETE FROM {db_prefix}calendar |
| 2235 | 2357 | WHERE id_event = {int:id_event}', |
| 2236 | 2358 | array( |
| 2237 | 2359 | 'id_event' => $_REQUEST['eventid'], |
| 2238 | 2360 | ) |
| 2239 | 2361 | ); |
| 2362 | + } |
|
| 2240 | 2363 | // ... or just update it? |
| 2241 | 2364 | else |
| 2242 | 2365 | { |
@@ -2278,9 +2401,8 @@ discard block |
||
| 2278 | 2401 | array($user_info['id'], $topic, 0), |
| 2279 | 2402 | array('id_member', 'id_topic', 'id_board') |
| 2280 | 2403 | ); |
| 2281 | - } |
|
| 2282 | - elseif (!$newTopic) |
|
| 2283 | - $smcFunc['db_query']('', ' |
|
| 2404 | + } elseif (!$newTopic) { |
|
| 2405 | + $smcFunc['db_query']('', ' |
|
| 2284 | 2406 | DELETE FROM {db_prefix}log_notify |
| 2285 | 2407 | WHERE id_member = {int:current_member} |
| 2286 | 2408 | AND id_topic = {int:current_topic}', |
@@ -2289,16 +2411,20 @@ discard block |
||
| 2289 | 2411 | 'current_topic' => $topic, |
| 2290 | 2412 | ) |
| 2291 | 2413 | ); |
| 2414 | + } |
|
| 2292 | 2415 | |
| 2293 | 2416 | // Log an act of moderation - modifying. |
| 2294 | - if (!empty($moderationAction)) |
|
| 2295 | - logAction('modify', array('topic' => $topic, 'message' => (int) $_REQUEST['msg'], 'member' => $row['id_member'], 'board' => $board)); |
|
| 2417 | + if (!empty($moderationAction)) { |
|
| 2418 | + logAction('modify', array('topic' => $topic, 'message' => (int) $_REQUEST['msg'], 'member' => $row['id_member'], 'board' => $board)); |
|
| 2419 | + } |
|
| 2296 | 2420 | |
| 2297 | - if (isset($_POST['lock']) && $_POST['lock'] != 2) |
|
| 2298 | - logAction(empty($_POST['lock']) ? 'unlock' : 'lock', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board'])); |
|
| 2421 | + if (isset($_POST['lock']) && $_POST['lock'] != 2) { |
|
| 2422 | + logAction(empty($_POST['lock']) ? 'unlock' : 'lock', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board'])); |
|
| 2423 | + } |
|
| 2299 | 2424 | |
| 2300 | - if (isset($_POST['sticky'])) |
|
| 2301 | - logAction(empty($_POST['sticky']) ? 'unsticky' : 'sticky', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board'])); |
|
| 2425 | + if (isset($_POST['sticky'])) { |
|
| 2426 | + logAction(empty($_POST['sticky']) ? 'unsticky' : 'sticky', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board'])); |
|
| 2427 | + } |
|
| 2302 | 2428 | |
| 2303 | 2429 | // Returning to the topic? |
| 2304 | 2430 | if (!empty($_REQUEST['goback'])) |
@@ -2317,26 +2443,31 @@ discard block |
||
| 2317 | 2443 | ); |
| 2318 | 2444 | } |
| 2319 | 2445 | |
| 2320 | - if ($board_info['num_topics'] == 0) |
|
| 2321 | - cache_put_data('board-' . $board, null, 120); |
|
| 2446 | + if ($board_info['num_topics'] == 0) { |
|
| 2447 | + cache_put_data('board-' . $board, null, 120); |
|
| 2448 | + } |
|
| 2322 | 2449 | |
| 2323 | 2450 | call_integration_hook('integrate_post2_end'); |
| 2324 | 2451 | |
| 2325 | - if (!empty($_POST['announce_topic']) && allowedTo('announce_topic')) |
|
| 2326 | - redirectexit('action=announce;sa=selectgroup;topic=' . $topic . (!empty($_POST['move']) && allowedTo('move_any') ? ';move' : '') . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
| 2452 | + if (!empty($_POST['announce_topic']) && allowedTo('announce_topic')) { |
|
| 2453 | + redirectexit('action=announce;sa=selectgroup;topic=' . $topic . (!empty($_POST['move']) && allowedTo('move_any') ? ';move' : '') . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
| 2454 | + } |
|
| 2327 | 2455 | |
| 2328 | - if (!empty($_POST['move']) && allowedTo('move_any')) |
|
| 2329 | - redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
| 2456 | + if (!empty($_POST['move']) && allowedTo('move_any')) { |
|
| 2457 | + redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
| 2458 | + } |
|
| 2330 | 2459 | |
| 2331 | 2460 | // Return to post if the mod is on. |
| 2332 | - if (isset($_REQUEST['msg']) && !empty($_REQUEST['goback'])) |
|
| 2333 | - redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg'], isBrowser('ie')); |
|
| 2334 | - elseif (!empty($_REQUEST['goback'])) |
|
| 2335 | - redirectexit('topic=' . $topic . '.new#new', isBrowser('ie')); |
|
| 2461 | + if (isset($_REQUEST['msg']) && !empty($_REQUEST['goback'])) { |
|
| 2462 | + redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg'], isBrowser('ie')); |
|
| 2463 | + } elseif (!empty($_REQUEST['goback'])) { |
|
| 2464 | + redirectexit('topic=' . $topic . '.new#new', isBrowser('ie')); |
|
| 2465 | + } |
|
| 2336 | 2466 | // Dut-dut-duh-duh-DUH-duh-dut-duh-duh! *dances to the Final Fantasy Fanfare...* |
| 2337 | - else |
|
| 2338 | - redirectexit('board=' . $board . '.0'); |
|
| 2339 | -} |
|
| 2467 | + else { |
|
| 2468 | + redirectexit('board=' . $board . '.0'); |
|
| 2469 | + } |
|
| 2470 | + } |
|
| 2340 | 2471 | |
| 2341 | 2472 | /** |
| 2342 | 2473 | * Handle the announce topic function (action=announce). |
@@ -2354,8 +2485,9 @@ discard block |
||
| 2354 | 2485 | |
| 2355 | 2486 | validateSession(); |
| 2356 | 2487 | |
| 2357 | - if (empty($topic)) |
|
| 2358 | - fatal_lang_error('topic_gone', false); |
|
| 2488 | + if (empty($topic)) { |
|
| 2489 | + fatal_lang_error('topic_gone', false); |
|
| 2490 | + } |
|
| 2359 | 2491 | |
| 2360 | 2492 | loadLanguage('Post'); |
| 2361 | 2493 | loadTemplate('Post'); |
@@ -2382,8 +2514,9 @@ discard block |
||
| 2382 | 2514 | global $txt, $context, $topic, $board_info, $smcFunc; |
| 2383 | 2515 | |
| 2384 | 2516 | $groups = array_merge($board_info['groups'], array(1)); |
| 2385 | - foreach ($groups as $id => $group) |
|
| 2386 | - $groups[$id] = (int) $group; |
|
| 2517 | + foreach ($groups as $id => $group) { |
|
| 2518 | + $groups[$id] = (int) $group; |
|
| 2519 | + } |
|
| 2387 | 2520 | |
| 2388 | 2521 | $context['groups'] = array(); |
| 2389 | 2522 | if (in_array(0, $groups)) |
@@ -2426,8 +2559,9 @@ discard block |
||
| 2426 | 2559 | 'group_list' => $groups, |
| 2427 | 2560 | ) |
| 2428 | 2561 | ); |
| 2429 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2430 | - $context['groups'][$row['id_group']]['name'] = $row['group_name']; |
|
| 2562 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2563 | + $context['groups'][$row['id_group']]['name'] = $row['group_name']; |
|
| 2564 | + } |
|
| 2431 | 2565 | $smcFunc['db_free_result']($request); |
| 2432 | 2566 | |
| 2433 | 2567 | // Get the subject of the topic we're about to announce. |
@@ -2469,16 +2603,19 @@ discard block |
||
| 2469 | 2603 | $context['start'] = empty($_REQUEST['start']) ? 0 : (int) $_REQUEST['start']; |
| 2470 | 2604 | $groups = array_merge($board_info['groups'], array(1)); |
| 2471 | 2605 | |
| 2472 | - if (isset($_POST['membergroups'])) |
|
| 2473 | - $_POST['who'] = explode(',', $_POST['membergroups']); |
|
| 2606 | + if (isset($_POST['membergroups'])) { |
|
| 2607 | + $_POST['who'] = explode(',', $_POST['membergroups']); |
|
| 2608 | + } |
|
| 2474 | 2609 | |
| 2475 | 2610 | // Check whether at least one membergroup was selected. |
| 2476 | - if (empty($_POST['who'])) |
|
| 2477 | - fatal_lang_error('no_membergroup_selected'); |
|
| 2611 | + if (empty($_POST['who'])) { |
|
| 2612 | + fatal_lang_error('no_membergroup_selected'); |
|
| 2613 | + } |
|
| 2478 | 2614 | |
| 2479 | 2615 | // Make sure all membergroups are integers and can access the board of the announcement. |
| 2480 | - foreach ($_POST['who'] as $id => $mg) |
|
| 2481 | - $_POST['who'][$id] = in_array((int) $mg, $groups) ? (int) $mg : 0; |
|
| 2616 | + foreach ($_POST['who'] as $id => $mg) { |
|
| 2617 | + $_POST['who'][$id] = in_array((int) $mg, $groups) ? (int) $mg : 0; |
|
| 2618 | + } |
|
| 2482 | 2619 | |
| 2483 | 2620 | // Get the topic subject and censor it. |
| 2484 | 2621 | $request = $smcFunc['db_query']('', ' |
@@ -2524,12 +2661,13 @@ discard block |
||
| 2524 | 2661 | if ($smcFunc['db_num_rows']($request) == 0) |
| 2525 | 2662 | { |
| 2526 | 2663 | logAction('announce_topic', array('topic' => $topic), 'user'); |
| 2527 | - if (!empty($_REQUEST['move']) && allowedTo('move_any')) |
|
| 2528 | - redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
| 2529 | - elseif (!empty($_REQUEST['goback'])) |
|
| 2530 | - redirectexit('topic=' . $topic . '.new;boardseen#new', isBrowser('ie')); |
|
| 2531 | - else |
|
| 2532 | - redirectexit('board=' . $board . '.0'); |
|
| 2664 | + if (!empty($_REQUEST['move']) && allowedTo('move_any')) { |
|
| 2665 | + redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
| 2666 | + } elseif (!empty($_REQUEST['goback'])) { |
|
| 2667 | + redirectexit('topic=' . $topic . '.new;boardseen#new', isBrowser('ie')); |
|
| 2668 | + } else { |
|
| 2669 | + redirectexit('board=' . $board . '.0'); |
|
| 2670 | + } |
|
| 2533 | 2671 | } |
| 2534 | 2672 | |
| 2535 | 2673 | $announcements = array(); |
@@ -2548,8 +2686,9 @@ discard block |
||
| 2548 | 2686 | foreach ($rows as $row) |
| 2549 | 2687 | { |
| 2550 | 2688 | // Force them to have it? |
| 2551 | - if (empty($prefs[$row['id_member']]['announcements'])) |
|
| 2552 | - continue; |
|
| 2689 | + if (empty($prefs[$row['id_member']]['announcements'])) { |
|
| 2690 | + continue; |
|
| 2691 | + } |
|
| 2553 | 2692 | |
| 2554 | 2693 | $cur_language = empty($row['lngfile']) || empty($modSettings['userLanguage']) ? $language : $row['lngfile']; |
| 2555 | 2694 | |
@@ -2577,8 +2716,9 @@ discard block |
||
| 2577 | 2716 | } |
| 2578 | 2717 | |
| 2579 | 2718 | // For each language send a different mail - low priority... |
| 2580 | - foreach ($announcements as $lang => $mail) |
|
| 2581 | - sendmail($mail['recipients'], $mail['subject'], $mail['body'], null, 'ann-' . $lang, $mail['is_html'], 5); |
|
| 2719 | + foreach ($announcements as $lang => $mail) { |
|
| 2720 | + sendmail($mail['recipients'], $mail['subject'], $mail['body'], null, 'ann-' . $lang, $mail['is_html'], 5); |
|
| 2721 | + } |
|
| 2582 | 2722 | |
| 2583 | 2723 | $context['percentage_done'] = round(100 * $context['start'] / $modSettings['latestMember'], 1); |
| 2584 | 2724 | |
@@ -2588,9 +2728,10 @@ discard block |
||
| 2588 | 2728 | $context['sub_template'] = 'announcement_send'; |
| 2589 | 2729 | |
| 2590 | 2730 | // Go back to the correct language for the user ;). |
| 2591 | - if (!empty($modSettings['userLanguage'])) |
|
| 2592 | - loadLanguage('Post'); |
|
| 2593 | -} |
|
| 2731 | + if (!empty($modSettings['userLanguage'])) { |
|
| 2732 | + loadLanguage('Post'); |
|
| 2733 | + } |
|
| 2734 | + } |
|
| 2594 | 2735 | |
| 2595 | 2736 | /** |
| 2596 | 2737 | * Get the topic for display purposes. |
@@ -2603,12 +2744,13 @@ discard block |
||
| 2603 | 2744 | { |
| 2604 | 2745 | global $topic, $modSettings, $context, $smcFunc, $counter, $options; |
| 2605 | 2746 | |
| 2606 | - if (isset($_REQUEST['xml'])) |
|
| 2607 | - $limit = ' |
|
| 2747 | + if (isset($_REQUEST['xml'])) { |
|
| 2748 | + $limit = ' |
|
| 2608 | 2749 | LIMIT ' . (empty($context['new_replies']) ? '0' : $context['new_replies']); |
| 2609 | - else |
|
| 2610 | - $limit = empty($modSettings['topicSummaryPosts']) ? '' : ' |
|
| 2750 | + } else { |
|
| 2751 | + $limit = empty($modSettings['topicSummaryPosts']) ? '' : ' |
|
| 2611 | 2752 | LIMIT ' . (int) $modSettings['topicSummaryPosts']; |
| 2753 | + } |
|
| 2612 | 2754 | |
| 2613 | 2755 | // If you're modifying, get only those posts before the current one. (otherwise get all.) |
| 2614 | 2756 | $request = $smcFunc['db_query']('', ' |
@@ -2646,8 +2788,9 @@ discard block |
||
| 2646 | 2788 | 'is_ignored' => !empty($modSettings['enable_buddylist']) && !empty($options['posts_apply_ignore_list']) && in_array($row['id_member'], $context['user']['ignoreusers']), |
| 2647 | 2789 | ); |
| 2648 | 2790 | |
| 2649 | - if (!empty($context['new_replies'])) |
|
| 2650 | - $context['new_replies']--; |
|
| 2791 | + if (!empty($context['new_replies'])) { |
|
| 2792 | + $context['new_replies']--; |
|
| 2793 | + } |
|
| 2651 | 2794 | } |
| 2652 | 2795 | $smcFunc['db_free_result']($request); |
| 2653 | 2796 | } |
@@ -2664,8 +2807,9 @@ discard block |
||
| 2664 | 2807 | global $sourcedir, $smcFunc; |
| 2665 | 2808 | |
| 2666 | 2809 | loadLanguage('Post'); |
| 2667 | - if (!isset($_REQUEST['xml'])) |
|
| 2668 | - loadTemplate('Post'); |
|
| 2810 | + if (!isset($_REQUEST['xml'])) { |
|
| 2811 | + loadTemplate('Post'); |
|
| 2812 | + } |
|
| 2669 | 2813 | |
| 2670 | 2814 | include_once($sourcedir . '/Subs-Post.php'); |
| 2671 | 2815 | |
@@ -2696,8 +2840,9 @@ discard block |
||
| 2696 | 2840 | $smcFunc['db_free_result']($request); |
| 2697 | 2841 | |
| 2698 | 2842 | $context['sub_template'] = 'quotefast'; |
| 2699 | - if (!empty($row)) |
|
| 2700 | - $can_view_post = $row['approved'] || ($row['id_member'] != 0 && $row['id_member'] == $user_info['id']) || allowedTo('approve_posts', $row['id_board']); |
|
| 2843 | + if (!empty($row)) { |
|
| 2844 | + $can_view_post = $row['approved'] || ($row['id_member'] != 0 && $row['id_member'] == $user_info['id']) || allowedTo('approve_posts', $row['id_board']); |
|
| 2845 | + } |
|
| 2701 | 2846 | |
| 2702 | 2847 | if (!empty($can_view_post)) |
| 2703 | 2848 | { |
@@ -2730,8 +2875,9 @@ discard block |
||
| 2730 | 2875 | } |
| 2731 | 2876 | |
| 2732 | 2877 | // Remove any nested quotes. |
| 2733 | - if (!empty($modSettings['removeNestedQuotes'])) |
|
| 2734 | - $row['body'] = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $row['body']); |
|
| 2878 | + if (!empty($modSettings['removeNestedQuotes'])) { |
|
| 2879 | + $row['body'] = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $row['body']); |
|
| 2880 | + } |
|
| 2735 | 2881 | |
| 2736 | 2882 | $lb = "\n"; |
| 2737 | 2883 | |
@@ -2757,14 +2903,14 @@ discard block |
||
| 2757 | 2903 | 'time' => '', |
| 2758 | 2904 | ), |
| 2759 | 2905 | ); |
| 2760 | - } |
|
| 2761 | - else |
|
| 2762 | - $context['quote'] = array( |
|
| 2906 | + } else { |
|
| 2907 | + $context['quote'] = array( |
|
| 2763 | 2908 | 'xml' => '', |
| 2764 | 2909 | 'mozilla' => '', |
| 2765 | 2910 | 'text' => '', |
| 2766 | 2911 | ); |
| 2767 | -} |
|
| 2912 | + } |
|
| 2913 | + } |
|
| 2768 | 2914 | |
| 2769 | 2915 | /** |
| 2770 | 2916 | * Used to edit the body or subject of a message inline |
@@ -2776,8 +2922,9 @@ discard block |
||
| 2776 | 2922 | global $user_info, $context, $smcFunc, $language, $board_info; |
| 2777 | 2923 | |
| 2778 | 2924 | // We have to have a topic! |
| 2779 | - if (empty($topic)) |
|
| 2780 | - obExit(false); |
|
| 2925 | + if (empty($topic)) { |
|
| 2926 | + obExit(false); |
|
| 2927 | + } |
|
| 2781 | 2928 | |
| 2782 | 2929 | checkSession('get'); |
| 2783 | 2930 | require_once($sourcedir . '/Subs-Post.php'); |
@@ -2803,31 +2950,35 @@ discard block |
||
| 2803 | 2950 | 'guest_id' => 0, |
| 2804 | 2951 | ) |
| 2805 | 2952 | ); |
| 2806 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 2807 | - fatal_lang_error('no_board', false); |
|
| 2953 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 2954 | + fatal_lang_error('no_board', false); |
|
| 2955 | + } |
|
| 2808 | 2956 | $row = $smcFunc['db_fetch_assoc']($request); |
| 2809 | 2957 | $smcFunc['db_free_result']($request); |
| 2810 | 2958 | |
| 2811 | 2959 | // Change either body or subject requires permissions to modify messages. |
| 2812 | 2960 | if (isset($_POST['message']) || isset($_POST['subject']) || isset($_REQUEST['icon'])) |
| 2813 | 2961 | { |
| 2814 | - if (!empty($row['locked'])) |
|
| 2815 | - isAllowedTo('moderate_board'); |
|
| 2962 | + if (!empty($row['locked'])) { |
|
| 2963 | + isAllowedTo('moderate_board'); |
|
| 2964 | + } |
|
| 2816 | 2965 | |
| 2817 | 2966 | if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any')) |
| 2818 | 2967 | { |
| 2819 | - if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) |
|
| 2820 | - fatal_lang_error('modify_post_time_passed', false); |
|
| 2821 | - elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_own')) |
|
| 2822 | - isAllowedTo('modify_replies'); |
|
| 2823 | - else |
|
| 2824 | - isAllowedTo('modify_own'); |
|
| 2968 | + if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) { |
|
| 2969 | + fatal_lang_error('modify_post_time_passed', false); |
|
| 2970 | + } elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_own')) { |
|
| 2971 | + isAllowedTo('modify_replies'); |
|
| 2972 | + } else { |
|
| 2973 | + isAllowedTo('modify_own'); |
|
| 2974 | + } |
|
| 2825 | 2975 | } |
| 2826 | 2976 | // Otherwise, they're locked out; someone who can modify the replies is needed. |
| 2827 | - elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_any')) |
|
| 2828 | - isAllowedTo('modify_replies'); |
|
| 2829 | - else |
|
| 2830 | - isAllowedTo('modify_any'); |
|
| 2977 | + elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_any')) { |
|
| 2978 | + isAllowedTo('modify_replies'); |
|
| 2979 | + } else { |
|
| 2980 | + isAllowedTo('modify_any'); |
|
| 2981 | + } |
|
| 2831 | 2982 | |
| 2832 | 2983 | // Only log this action if it wasn't your message. |
| 2833 | 2984 | $moderationAction = $row['id_member'] != $user_info['id']; |
@@ -2839,10 +2990,10 @@ discard block |
||
| 2839 | 2990 | $_POST['subject'] = strtr($smcFunc['htmlspecialchars']($_POST['subject']), array("\r" => '', "\n" => '', "\t" => '')); |
| 2840 | 2991 | |
| 2841 | 2992 | // Maximum number of characters. |
| 2842 | - if ($smcFunc['strlen']($_POST['subject']) > 100) |
|
| 2843 | - $_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100); |
|
| 2844 | - } |
|
| 2845 | - elseif (isset($_POST['subject'])) |
|
| 2993 | + if ($smcFunc['strlen']($_POST['subject']) > 100) { |
|
| 2994 | + $_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100); |
|
| 2995 | + } |
|
| 2996 | + } elseif (isset($_POST['subject'])) |
|
| 2846 | 2997 | { |
| 2847 | 2998 | $post_errors[] = 'no_subject'; |
| 2848 | 2999 | unset($_POST['subject']); |
@@ -2854,13 +3005,11 @@ discard block |
||
| 2854 | 3005 | { |
| 2855 | 3006 | $post_errors[] = 'no_message'; |
| 2856 | 3007 | unset($_POST['message']); |
| 2857 | - } |
|
| 2858 | - elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength']) |
|
| 3008 | + } elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength']) |
|
| 2859 | 3009 | { |
| 2860 | 3010 | $post_errors[] = 'long_message'; |
| 2861 | 3011 | unset($_POST['message']); |
| 2862 | - } |
|
| 2863 | - else |
|
| 3012 | + } else |
|
| 2864 | 3013 | { |
| 2865 | 3014 | $_POST['message'] = $smcFunc['htmlspecialchars']($_POST['message'], ENT_QUOTES); |
| 2866 | 3015 | |
@@ -2876,31 +3025,34 @@ discard block |
||
| 2876 | 3025 | |
| 2877 | 3026 | if (isset($_POST['lock'])) |
| 2878 | 3027 | { |
| 2879 | - if (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $row['id_member'])) |
|
| 2880 | - unset($_POST['lock']); |
|
| 2881 | - elseif (!allowedTo('lock_any')) |
|
| 3028 | + if (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $row['id_member'])) { |
|
| 3029 | + unset($_POST['lock']); |
|
| 3030 | + } elseif (!allowedTo('lock_any')) |
|
| 2882 | 3031 | { |
| 2883 | - if ($row['locked'] == 1) |
|
| 2884 | - unset($_POST['lock']); |
|
| 2885 | - else |
|
| 2886 | - $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
| 3032 | + if ($row['locked'] == 1) { |
|
| 3033 | + unset($_POST['lock']); |
|
| 3034 | + } else { |
|
| 3035 | + $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
| 3036 | + } |
|
| 3037 | + } elseif (!empty($row['locked']) && !empty($_POST['lock']) || $_POST['lock'] == $row['locked']) { |
|
| 3038 | + unset($_POST['lock']); |
|
| 3039 | + } else { |
|
| 3040 | + $_POST['lock'] = empty($_POST['lock']) ? 0 : 1; |
|
| 2887 | 3041 | } |
| 2888 | - elseif (!empty($row['locked']) && !empty($_POST['lock']) || $_POST['lock'] == $row['locked']) |
|
| 2889 | - unset($_POST['lock']); |
|
| 2890 | - else |
|
| 2891 | - $_POST['lock'] = empty($_POST['lock']) ? 0 : 1; |
|
| 2892 | 3042 | } |
| 2893 | 3043 | |
| 2894 | - if (isset($_POST['sticky']) && !allowedTo('make_sticky')) |
|
| 2895 | - unset($_POST['sticky']); |
|
| 3044 | + if (isset($_POST['sticky']) && !allowedTo('make_sticky')) { |
|
| 3045 | + unset($_POST['sticky']); |
|
| 3046 | + } |
|
| 2896 | 3047 | |
| 2897 | 3048 | if (isset($_POST['modify_reason'])) |
| 2898 | 3049 | { |
| 2899 | 3050 | $_POST['modify_reason'] = strtr($smcFunc['htmlspecialchars']($_POST['modify_reason']), array("\r" => '', "\n" => '', "\t" => '')); |
| 2900 | 3051 | |
| 2901 | 3052 | // Maximum number of characters. |
| 2902 | - if ($smcFunc['strlen']($_POST['modify_reason']) > 100) |
|
| 2903 | - $_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100); |
|
| 3053 | + if ($smcFunc['strlen']($_POST['modify_reason']) > 100) { |
|
| 3054 | + $_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100); |
|
| 3055 | + } |
|
| 2904 | 3056 | } |
| 2905 | 3057 | |
| 2906 | 3058 | if (empty($post_errors)) |
@@ -2937,8 +3089,9 @@ discard block |
||
| 2937 | 3089 | } |
| 2938 | 3090 | } |
| 2939 | 3091 | // If nothing was changed there's no need to add an entry to the moderation log. |
| 2940 | - else |
|
| 2941 | - $moderationAction = false; |
|
| 3092 | + else { |
|
| 3093 | + $moderationAction = false; |
|
| 3094 | + } |
|
| 2942 | 3095 | |
| 2943 | 3096 | modifyPost($msgOptions, $topicOptions, $posterOptions); |
| 2944 | 3097 | |
@@ -2956,9 +3109,9 @@ discard block |
||
| 2956 | 3109 | // Get the proper (default language) response prefix first. |
| 2957 | 3110 | if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix'))) |
| 2958 | 3111 | { |
| 2959 | - if ($language === $user_info['language']) |
|
| 2960 | - $context['response_prefix'] = $txt['response_prefix']; |
|
| 2961 | - else |
|
| 3112 | + if ($language === $user_info['language']) { |
|
| 3113 | + $context['response_prefix'] = $txt['response_prefix']; |
|
| 3114 | + } else |
|
| 2962 | 3115 | { |
| 2963 | 3116 | loadLanguage('index', $language, false); |
| 2964 | 3117 | $context['response_prefix'] = $txt['response_prefix']; |
@@ -2980,8 +3133,9 @@ discard block |
||
| 2980 | 3133 | ); |
| 2981 | 3134 | } |
| 2982 | 3135 | |
| 2983 | - if (!empty($moderationAction)) |
|
| 2984 | - logAction('modify', array('topic' => $topic, 'message' => $row['id_msg'], 'member' => $row['id_member'], 'board' => $board)); |
|
| 3136 | + if (!empty($moderationAction)) { |
|
| 3137 | + logAction('modify', array('topic' => $topic, 'message' => $row['id_msg'], 'member' => $row['id_member'], 'board' => $board)); |
|
| 3138 | + } |
|
| 2985 | 3139 | } |
| 2986 | 3140 | |
| 2987 | 3141 | if (isset($_REQUEST['xml'])) |
@@ -3022,8 +3176,7 @@ discard block |
||
| 3022 | 3176 | ); |
| 3023 | 3177 | |
| 3024 | 3178 | censorText($context['message']['subject']); |
| 3025 | - } |
|
| 3026 | - else |
|
| 3179 | + } else |
|
| 3027 | 3180 | { |
| 3028 | 3181 | $context['message'] = array( |
| 3029 | 3182 | 'id' => $row['id_msg'], |
@@ -3035,15 +3188,16 @@ discard block |
||
| 3035 | 3188 | loadLanguage('Errors'); |
| 3036 | 3189 | foreach ($post_errors as $post_error) |
| 3037 | 3190 | { |
| 3038 | - if ($post_error == 'long_message') |
|
| 3039 | - $context['message']['errors'][] = sprintf($txt['error_' . $post_error], $modSettings['max_messageLength']); |
|
| 3040 | - else |
|
| 3041 | - $context['message']['errors'][] = $txt['error_' . $post_error]; |
|
| 3191 | + if ($post_error == 'long_message') { |
|
| 3192 | + $context['message']['errors'][] = sprintf($txt['error_' . $post_error], $modSettings['max_messageLength']); |
|
| 3193 | + } else { |
|
| 3194 | + $context['message']['errors'][] = $txt['error_' . $post_error]; |
|
| 3195 | + } |
|
| 3042 | 3196 | } |
| 3043 | 3197 | } |
| 3198 | + } else { |
|
| 3199 | + obExit(false); |
|
| 3200 | + } |
|
| 3044 | 3201 | } |
| 3045 | - else |
|
| 3046 | - obExit(false); |
|
| 3047 | -} |
|
| 3048 | 3202 | |
| 3049 | 3203 | ?> |
| 3050 | 3204 | \ No newline at end of file |
@@ -256,7 +256,7 @@ discard block |
||
| 256 | 256 | 'class' => 'centercol', |
| 257 | 257 | ), |
| 258 | 258 | 'data' => array( |
| 259 | - 'function' => function ($entry) |
|
| 259 | + 'function' => function($entry) |
|
| 260 | 260 | { |
| 261 | 261 | return '<input type="checkbox" name="delete[]" value="' . $entry['id'] . '"' . ($entry['editable'] ? '' : ' disabled') . '>'; |
| 262 | 262 | }, |
@@ -638,7 +638,7 @@ discard block |
||
| 638 | 638 | if (empty($entries[$k]['action_text'])) |
| 639 | 639 | $entries[$k]['action_text'] = isset($txt['modlog_ac_' . $entry['action']]) ? $txt['modlog_ac_' . $entry['action']] : $entry['action']; |
| 640 | 640 | $entries[$k]['action_text'] = preg_replace_callback('~\{([A-Za-z\d_]+)\}~i', |
| 641 | - function ($matches) use ($entries, $k) |
|
| 641 | + function($matches) use ($entries, $k) |
|
| 642 | 642 | { |
| 643 | 643 | return isset($entries[$k]['extra'][$matches[1]]) ? $entries[$k]['extra'][$matches[1]] : ''; |
| 644 | 644 | }, $entries[$k]['action_text']); |
@@ -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 | * Prepares the information from the moderation log for viewing. |
@@ -32,14 +33,16 @@ discard block |
||
| 32 | 33 | |
| 33 | 34 | // Are we looking at the moderation log or the administration log. |
| 34 | 35 | $context['log_type'] = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'adminlog' ? 3 : 1; |
| 35 | - if ($context['log_type'] == 3) |
|
| 36 | - isAllowedTo('admin_forum'); |
|
| 36 | + if ($context['log_type'] == 3) { |
|
| 37 | + isAllowedTo('admin_forum'); |
|
| 38 | + } |
|
| 37 | 39 | |
| 38 | 40 | // These change dependant on whether we are viewing the moderation or admin log. |
| 39 | - if ($context['log_type'] == 3 || $_REQUEST['action'] == 'admin') |
|
| 40 | - $context['url_start'] = '?action=admin;area=logs;sa=' . ($context['log_type'] == 3 ? 'adminlog' : 'modlog') . ';type=' . $context['log_type']; |
|
| 41 | - else |
|
| 42 | - $context['url_start'] = '?action=moderate;area=modlog;type=' . $context['log_type']; |
|
| 41 | + if ($context['log_type'] == 3 || $_REQUEST['action'] == 'admin') { |
|
| 42 | + $context['url_start'] = '?action=admin;area=logs;sa=' . ($context['log_type'] == 3 ? 'adminlog' : 'modlog') . ';type=' . $context['log_type']; |
|
| 43 | + } else { |
|
| 44 | + $context['url_start'] = '?action=moderate;area=modlog;type=' . $context['log_type']; |
|
| 45 | + } |
|
| 43 | 46 | |
| 44 | 47 | $context['can_delete'] = allowedTo('admin_forum'); |
| 45 | 48 | |
@@ -67,8 +70,7 @@ discard block |
||
| 67 | 70 | $log_type = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'adminlog' ? 'admin' : 'moderate'; |
| 68 | 71 | logAction('clearlog_' . $log_type, array(), $log_type); |
| 69 | 72 | |
| 70 | - } |
|
| 71 | - elseif (!empty($_POST['remove']) && isset($_POST['delete']) && $context['can_delete']) |
|
| 73 | + } elseif (!empty($_POST['remove']) && isset($_POST['delete']) && $context['can_delete']) |
|
| 72 | 74 | { |
| 73 | 75 | checkSession(); |
| 74 | 76 | validateToken('mod-ml'); |
@@ -114,15 +116,17 @@ discard block |
||
| 114 | 116 | 'ip' => array('sql' => 'lm.ip', 'label' => $txt['modlog_ip']) |
| 115 | 117 | ); |
| 116 | 118 | |
| 117 | - if (!isset($search_params['string']) || (!empty($_REQUEST['search']) && $search_params['string'] != $_REQUEST['search'])) |
|
| 118 | - $search_params_string = empty($_REQUEST['search']) ? '' : $_REQUEST['search']; |
|
| 119 | - else |
|
| 120 | - $search_params_string = $search_params['string']; |
|
| 119 | + if (!isset($search_params['string']) || (!empty($_REQUEST['search']) && $search_params['string'] != $_REQUEST['search'])) { |
|
| 120 | + $search_params_string = empty($_REQUEST['search']) ? '' : $_REQUEST['search']; |
|
| 121 | + } else { |
|
| 122 | + $search_params_string = $search_params['string']; |
|
| 123 | + } |
|
| 121 | 124 | |
| 122 | - if (isset($_REQUEST['search_type']) || empty($search_params['type']) || !isset($searchTypes[$search_params['type']])) |
|
| 123 | - $search_params_type = isset($_REQUEST['search_type']) && isset($searchTypes[$_REQUEST['search_type']]) ? $_REQUEST['search_type'] : (isset($searchTypes[$context['order']]) ? $context['order'] : 'member'); |
|
| 124 | - else |
|
| 125 | - $search_params_type = $search_params['type']; |
|
| 125 | + if (isset($_REQUEST['search_type']) || empty($search_params['type']) || !isset($searchTypes[$search_params['type']])) { |
|
| 126 | + $search_params_type = isset($_REQUEST['search_type']) && isset($searchTypes[$_REQUEST['search_type']]) ? $_REQUEST['search_type'] : (isset($searchTypes[$context['order']]) ? $context['order'] : 'member'); |
|
| 127 | + } else { |
|
| 128 | + $search_params_type = $search_params['type']; |
|
| 129 | + } |
|
| 126 | 130 | |
| 127 | 131 | $search_params_column = $searchTypes[$search_params_type]['sql']; |
| 128 | 132 | $search_params = array( |
@@ -301,15 +305,16 @@ discard block |
||
| 301 | 305 | $context['default_list'] = 'moderation_log_list'; |
| 302 | 306 | |
| 303 | 307 | // If a hook has changed this, respect it. |
| 304 | - if (!empty($moderation_menu_name)) |
|
| 305 | - $context[$context['moderation_menu_name']]['tab_data'] = $moderation_menu_name; |
|
| 306 | - elseif (isset($context['moderation_menu_name'])) |
|
| 307 | - $context[$context['moderation_menu_name']]['tab_data'] = array( |
|
| 308 | + if (!empty($moderation_menu_name)) { |
|
| 309 | + $context[$context['moderation_menu_name']]['tab_data'] = $moderation_menu_name; |
|
| 310 | + } elseif (isset($context['moderation_menu_name'])) { |
|
| 311 | + $context[$context['moderation_menu_name']]['tab_data'] = array( |
|
| 308 | 312 | 'title' => $txt['modlog_' . ($context['log_type'] == 3 ? 'admin' : 'moderation') . '_log'], |
| 309 | 313 | 'help' => $context['log_type'] == 3 ? 'adminlog' : 'modlog', |
| 310 | 314 | 'description' => $txt['modlog_' . ($context['log_type'] == 3 ? 'admin' : 'moderation') . '_log_desc'] |
| 311 | 315 | ); |
| 312 | -} |
|
| 316 | + } |
|
| 317 | + } |
|
| 313 | 318 | |
| 314 | 319 | /** |
| 315 | 320 | * Get the number of mod log entries. |
@@ -413,30 +418,35 @@ discard block |
||
| 413 | 418 | // Add on some of the column stuff info |
| 414 | 419 | if (!empty($row['id_board'])) |
| 415 | 420 | { |
| 416 | - if ($row['action'] == 'move') |
|
| 417 | - $row['extra']['board_to'] = $row['id_board']; |
|
| 418 | - else |
|
| 419 | - $row['extra']['board'] = $row['id_board']; |
|
| 421 | + if ($row['action'] == 'move') { |
|
| 422 | + $row['extra']['board_to'] = $row['id_board']; |
|
| 423 | + } else { |
|
| 424 | + $row['extra']['board'] = $row['id_board']; |
|
| 425 | + } |
|
| 420 | 426 | } |
| 421 | 427 | |
| 422 | - if (!empty($row['id_topic'])) |
|
| 423 | - $row['extra']['topic'] = $row['id_topic']; |
|
| 424 | - if (!empty($row['id_msg'])) |
|
| 425 | - $row['extra']['message'] = $row['id_msg']; |
|
| 428 | + if (!empty($row['id_topic'])) { |
|
| 429 | + $row['extra']['topic'] = $row['id_topic']; |
|
| 430 | + } |
|
| 431 | + if (!empty($row['id_msg'])) { |
|
| 432 | + $row['extra']['message'] = $row['id_msg']; |
|
| 433 | + } |
|
| 426 | 434 | |
| 427 | 435 | // Is this associated with a topic? |
| 428 | - if (isset($row['extra']['topic'])) |
|
| 429 | - $topics[(int) $row['extra']['topic']][] = $row['id_action']; |
|
| 430 | - if (isset($row['extra']['new_topic'])) |
|
| 431 | - $topics[(int) $row['extra']['new_topic']][] = $row['id_action']; |
|
| 436 | + if (isset($row['extra']['topic'])) { |
|
| 437 | + $topics[(int) $row['extra']['topic']][] = $row['id_action']; |
|
| 438 | + } |
|
| 439 | + if (isset($row['extra']['new_topic'])) { |
|
| 440 | + $topics[(int) $row['extra']['new_topic']][] = $row['id_action']; |
|
| 441 | + } |
|
| 432 | 442 | |
| 433 | 443 | // How about a member? |
| 434 | 444 | if (isset($row['extra']['member'])) |
| 435 | 445 | { |
| 436 | 446 | // Guests don't have names! |
| 437 | - if (empty($row['extra']['member'])) |
|
| 438 | - $row['extra']['member'] = $txt['modlog_parameter_guest']; |
|
| 439 | - else |
|
| 447 | + if (empty($row['extra']['member'])) { |
|
| 448 | + $row['extra']['member'] = $txt['modlog_parameter_guest']; |
|
| 449 | + } else |
|
| 440 | 450 | { |
| 441 | 451 | // Try to find it... |
| 442 | 452 | $members[(int) $row['extra']['member']][] = $row['id_action']; |
@@ -444,35 +454,42 @@ discard block |
||
| 444 | 454 | } |
| 445 | 455 | |
| 446 | 456 | // Associated with a board? |
| 447 | - if (isset($row['extra']['board_to'])) |
|
| 448 | - $boards[(int) $row['extra']['board_to']][] = $row['id_action']; |
|
| 449 | - if (isset($row['extra']['board_from'])) |
|
| 450 | - $boards[(int) $row['extra']['board_from']][] = $row['id_action']; |
|
| 451 | - if (isset($row['extra']['board'])) |
|
| 452 | - $boards[(int) $row['extra']['board']][] = $row['id_action']; |
|
| 457 | + if (isset($row['extra']['board_to'])) { |
|
| 458 | + $boards[(int) $row['extra']['board_to']][] = $row['id_action']; |
|
| 459 | + } |
|
| 460 | + if (isset($row['extra']['board_from'])) { |
|
| 461 | + $boards[(int) $row['extra']['board_from']][] = $row['id_action']; |
|
| 462 | + } |
|
| 463 | + if (isset($row['extra']['board'])) { |
|
| 464 | + $boards[(int) $row['extra']['board']][] = $row['id_action']; |
|
| 465 | + } |
|
| 453 | 466 | |
| 454 | 467 | // A message? |
| 455 | - if (isset($row['extra']['message'])) |
|
| 456 | - $messages[(int) $row['extra']['message']][] = $row['id_action']; |
|
| 468 | + if (isset($row['extra']['message'])) { |
|
| 469 | + $messages[(int) $row['extra']['message']][] = $row['id_action']; |
|
| 470 | + } |
|
| 457 | 471 | |
| 458 | 472 | // IP Info? |
| 459 | - if (isset($row['extra']['ip_range'])) |
|
| 460 | - if ($seeIP) |
|
| 473 | + if (isset($row['extra']['ip_range'])) { |
|
| 474 | + if ($seeIP) |
|
| 461 | 475 | $row['extra']['ip_range'] = '<a href="' . $scripturl . '?action=trackip;searchip=' . $row['extra']['ip_range'] . '">' . $row['extra']['ip_range'] . '</a>'; |
| 462 | - else |
|
| 463 | - $row['extra']['ip_range'] = $txt['logged']; |
|
| 476 | + } else { |
|
| 477 | + $row['extra']['ip_range'] = $txt['logged']; |
|
| 478 | + } |
|
| 464 | 479 | |
| 465 | 480 | // Email? |
| 466 | - if (isset($row['extra']['email'])) |
|
| 467 | - $row['extra']['email'] = '<a href="mailto:' . $row['extra']['email'] . '">' . $row['extra']['email'] . '</a>'; |
|
| 481 | + if (isset($row['extra']['email'])) { |
|
| 482 | + $row['extra']['email'] = '<a href="mailto:' . $row['extra']['email'] . '">' . $row['extra']['email'] . '</a>'; |
|
| 483 | + } |
|
| 468 | 484 | |
| 469 | 485 | // Bans are complex. |
| 470 | 486 | if ($row['action'] == 'ban' || $row['action'] == 'banremove') |
| 471 | 487 | { |
| 472 | 488 | $row['action_text'] = $txt['modlog_ac_ban' . ($row['action'] == 'banremove' ? '_remove' : '')]; |
| 473 | - foreach (array('member', 'email', 'ip_range', 'hostname') as $type) |
|
| 474 | - if (isset($row['extra'][$type])) |
|
| 489 | + foreach (array('member', 'email', 'ip_range', 'hostname') as $type) { |
|
| 490 | + if (isset($row['extra'][$type])) |
|
| 475 | 491 | $row['action_text'] .= $txt['modlog_ac_ban_trigger_' . $type]; |
| 492 | + } |
|
| 476 | 493 | } |
| 477 | 494 | |
| 478 | 495 | // The array to go to the template. Note here that action is set to a "default" value of the action doesn't match anything in the descriptions. Allows easy adding of logging events with basic details. |
@@ -508,12 +525,13 @@ discard block |
||
| 508 | 525 | foreach ($boards[$row['id_board']] as $action) |
| 509 | 526 | { |
| 510 | 527 | // Make the board number into a link - dealing with moving too. |
| 511 | - if (isset($entries[$action]['extra']['board_to']) && $entries[$action]['extra']['board_to'] == $row['id_board']) |
|
| 512 | - $entries[$action]['extra']['board_to'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
| 513 | - elseif (isset($entries[$action]['extra']['board_from']) && $entries[$action]['extra']['board_from'] == $row['id_board']) |
|
| 514 | - $entries[$action]['extra']['board_from'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
| 515 | - elseif (isset($entries[$action]['extra']['board']) && $entries[$action]['extra']['board'] == $row['id_board']) |
|
| 516 | - $entries[$action]['extra']['board'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
| 528 | + if (isset($entries[$action]['extra']['board_to']) && $entries[$action]['extra']['board_to'] == $row['id_board']) { |
|
| 529 | + $entries[$action]['extra']['board_to'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
| 530 | + } elseif (isset($entries[$action]['extra']['board_from']) && $entries[$action]['extra']['board_from'] == $row['id_board']) { |
|
| 531 | + $entries[$action]['extra']['board_from'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
| 532 | + } elseif (isset($entries[$action]['extra']['board']) && $entries[$action]['extra']['board'] == $row['id_board']) { |
|
| 533 | + $entries[$action]['extra']['board'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
| 534 | + } |
|
| 517 | 535 | } |
| 518 | 536 | } |
| 519 | 537 | $smcFunc['db_free_result']($request); |
@@ -547,10 +565,11 @@ discard block |
||
| 547 | 565 | ); |
| 548 | 566 | |
| 549 | 567 | // Make the topic number into a link - dealing with splitting too. |
| 550 | - if (isset($this_action['extra']['topic']) && $this_action['extra']['topic'] == $row['id_topic']) |
|
| 551 | - $this_action['extra']['topic'] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.' . (isset($this_action['extra']['message']) ? 'msg' . $this_action['extra']['message'] . '#msg' . $this_action['extra']['message'] : '0') . '">' . $row['subject'] . '</a>'; |
|
| 552 | - elseif (isset($this_action['extra']['new_topic']) && $this_action['extra']['new_topic'] == $row['id_topic']) |
|
| 553 | - $this_action['extra']['new_topic'] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.' . (isset($this_action['extra']['message']) ? 'msg' . $this_action['extra']['message'] . '#msg' . $this_action['extra']['message'] : '0') . '">' . $row['subject'] . '</a>'; |
|
| 568 | + if (isset($this_action['extra']['topic']) && $this_action['extra']['topic'] == $row['id_topic']) { |
|
| 569 | + $this_action['extra']['topic'] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.' . (isset($this_action['extra']['message']) ? 'msg' . $this_action['extra']['message'] . '#msg' . $this_action['extra']['message'] : '0') . '">' . $row['subject'] . '</a>'; |
|
| 570 | + } elseif (isset($this_action['extra']['new_topic']) && $this_action['extra']['new_topic'] == $row['id_topic']) { |
|
| 571 | + $this_action['extra']['new_topic'] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.' . (isset($this_action['extra']['message']) ? 'msg' . $this_action['extra']['message'] . '#msg' . $this_action['extra']['message'] : '0') . '">' . $row['subject'] . '</a>'; |
|
| 572 | + } |
|
| 554 | 573 | } |
| 555 | 574 | } |
| 556 | 575 | $smcFunc['db_free_result']($request); |
@@ -583,8 +602,9 @@ discard block |
||
| 583 | 602 | ); |
| 584 | 603 | |
| 585 | 604 | // Make the message number into a link. |
| 586 | - if (isset($this_action['extra']['message']) && $this_action['extra']['message'] == $row['id_msg']) |
|
| 587 | - $this_action['extra']['message'] = '<a href="' . $scripturl . '?msg=' . $row['id_msg'] . '">' . $row['subject'] . '</a>'; |
|
| 605 | + if (isset($this_action['extra']['message']) && $this_action['extra']['message'] == $row['id_msg']) { |
|
| 606 | + $this_action['extra']['message'] = '<a href="' . $scripturl . '?msg=' . $row['id_msg'] . '">' . $row['subject'] . '</a>'; |
|
| 607 | + } |
|
| 588 | 608 | } |
| 589 | 609 | } |
| 590 | 610 | $smcFunc['db_free_result']($request); |
@@ -624,25 +644,29 @@ discard block |
||
| 624 | 644 | foreach ($entries as $k => $entry) |
| 625 | 645 | { |
| 626 | 646 | // Make any message info links so its easier to go find that message. |
| 627 | - if (isset($entry['extra']['message']) && (empty($entry['message']) || empty($entry['message']['id']))) |
|
| 628 | - $entries[$k]['extra']['message'] = '<a href="' . $scripturl . '?msg=' . $entry['extra']['message'] . '">' . $entry['extra']['message'] . '</a>'; |
|
| 647 | + if (isset($entry['extra']['message']) && (empty($entry['message']) || empty($entry['message']['id']))) { |
|
| 648 | + $entries[$k]['extra']['message'] = '<a href="' . $scripturl . '?msg=' . $entry['extra']['message'] . '">' . $entry['extra']['message'] . '</a>'; |
|
| 649 | + } |
|
| 629 | 650 | |
| 630 | 651 | // Mark up any deleted members, topics and boards. |
| 631 | - foreach (array('board', 'board_from', 'board_to', 'member', 'topic', 'new_topic') as $type) |
|
| 632 | - if (!empty($entry['extra'][$type]) && is_numeric($entry['extra'][$type])) |
|
| 652 | + foreach (array('board', 'board_from', 'board_to', 'member', 'topic', 'new_topic') as $type) { |
|
| 653 | + if (!empty($entry['extra'][$type]) && is_numeric($entry['extra'][$type])) |
|
| 633 | 654 | $entries[$k]['extra'][$type] = sprintf($txt['modlog_id'], $entry['extra'][$type]); |
| 655 | + } |
|
| 634 | 656 | |
| 635 | 657 | if (isset($entry['extra']['report'])) |
| 636 | 658 | { |
| 637 | 659 | // Member profile reports go in a different area |
| 638 | - if (stristr($entry['action'], 'user_report')) |
|
| 639 | - $entries[$k]['extra']['report'] = '<a href="' . $scripturl . '?action=moderate;area=reportedmembers;sa=details;rid=' . $entry['extra']['report'] . '">' . $txt['modlog_report'] . '</a>'; |
|
| 640 | - else |
|
| 641 | - $entries[$k]['extra']['report'] = '<a href="' . $scripturl . '?action=moderate;area=reportedposts;sa=details;rid=' . $entry['extra']['report'] . '">' . $txt['modlog_report'] . '</a>'; |
|
| 660 | + if (stristr($entry['action'], 'user_report')) { |
|
| 661 | + $entries[$k]['extra']['report'] = '<a href="' . $scripturl . '?action=moderate;area=reportedmembers;sa=details;rid=' . $entry['extra']['report'] . '">' . $txt['modlog_report'] . '</a>'; |
|
| 662 | + } else { |
|
| 663 | + $entries[$k]['extra']['report'] = '<a href="' . $scripturl . '?action=moderate;area=reportedposts;sa=details;rid=' . $entry['extra']['report'] . '">' . $txt['modlog_report'] . '</a>'; |
|
| 664 | + } |
|
| 642 | 665 | } |
| 643 | 666 | |
| 644 | - if (empty($entries[$k]['action_text'])) |
|
| 645 | - $entries[$k]['action_text'] = isset($txt['modlog_ac_' . $entry['action']]) ? $txt['modlog_ac_' . $entry['action']] : $entry['action']; |
|
| 667 | + if (empty($entries[$k]['action_text'])) { |
|
| 668 | + $entries[$k]['action_text'] = isset($txt['modlog_ac_' . $entry['action']]) ? $txt['modlog_ac_' . $entry['action']] : $entry['action']; |
|
| 669 | + } |
|
| 646 | 670 | $entries[$k]['action_text'] = preg_replace_callback('~\{([A-Za-z\d_]+)\}~i', |
| 647 | 671 | function ($matches) use ($entries, $k) |
| 648 | 672 | { |
@@ -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 | * Class Likes |
@@ -106,8 +107,9 @@ discard block |
||
| 106 | 107 | $this->_extra = isset($_GET['extra']) ? $_GET['extra'] : false; |
| 107 | 108 | |
| 108 | 109 | // We do not want to output debug information here. |
| 109 | - if ($this->_js) |
|
| 110 | - $db_show_debug = false; |
|
| 110 | + if ($this->_js) { |
|
| 111 | + $db_show_debug = false; |
|
| 112 | + } |
|
| 111 | 113 | } |
| 112 | 114 | |
| 113 | 115 | /** |
@@ -141,8 +143,9 @@ discard block |
||
| 141 | 143 | $call = $this->_sa; |
| 142 | 144 | |
| 143 | 145 | // Guest can only view likes. |
| 144 | - if ($call != 'view') |
|
| 145 | - is_not_guest(); |
|
| 146 | + if ($call != 'view') { |
|
| 147 | + is_not_guest(); |
|
| 148 | + } |
|
| 146 | 149 | |
| 147 | 150 | checkSession('get'); |
| 148 | 151 | |
@@ -180,15 +183,17 @@ discard block |
||
| 180 | 183 | global $smcFunc, $modSettings; |
| 181 | 184 | |
| 182 | 185 | // This feature is currently disable. |
| 183 | - if (empty($modSettings['enable_likes'])) |
|
| 184 | - return $this->_error = 'like_disable'; |
|
| 186 | + if (empty($modSettings['enable_likes'])) { |
|
| 187 | + return $this->_error = 'like_disable'; |
|
| 188 | + } |
|
| 185 | 189 | |
| 186 | 190 | // Zerothly, they did indicate some kind of content to like, right? |
| 187 | 191 | preg_match('~^([a-z0-9\-\_]{1,6})~i', $this->_type, $matches); |
| 188 | 192 | $this->_type = isset($matches[1]) ? $matches[1] : ''; |
| 189 | 193 | |
| 190 | - if ($this->_type == '' || $this->_content <= 0) |
|
| 191 | - return $this->_error = 'cannot_'; |
|
| 194 | + if ($this->_type == '' || $this->_content <= 0) { |
|
| 195 | + return $this->_error = 'cannot_'; |
|
| 196 | + } |
|
| 192 | 197 | |
| 193 | 198 | // First we need to verify if the user can see the type of content or not. This is set up to be extensible, |
| 194 | 199 | // so we'll check for the one type we do know about, and if it's not that, we'll defer to any hooks. |
@@ -207,12 +212,14 @@ discard block |
||
| 207 | 212 | 'msg' => $this->_content, |
| 208 | 213 | ) |
| 209 | 214 | ); |
| 210 | - if ($smcFunc['db_num_rows']($request) == 1) |
|
| 211 | - list ($this->_idTopic, $topicOwner) = $smcFunc['db_fetch_row']($request); |
|
| 215 | + if ($smcFunc['db_num_rows']($request) == 1) { |
|
| 216 | + list ($this->_idTopic, $topicOwner) = $smcFunc['db_fetch_row']($request); |
|
| 217 | + } |
|
| 212 | 218 | |
| 213 | 219 | $smcFunc['db_free_result']($request); |
| 214 | - if (empty($this->_idTopic)) |
|
| 215 | - return $this->_error = 'cannot_'; |
|
| 220 | + if (empty($this->_idTopic)) { |
|
| 221 | + return $this->_error = 'cannot_'; |
|
| 222 | + } |
|
| 216 | 223 | |
| 217 | 224 | // So we know what topic it's in and more importantly we know the user can see it. |
| 218 | 225 | // If we're not viewing, we need some info set up. |
@@ -221,9 +228,7 @@ discard block |
||
| 221 | 228 | $this->_validLikes['redirect'] = 'topic=' . $this->_idTopic . '.msg' . $this->_content . '#msg' . $this->_content; |
| 222 | 229 | |
| 223 | 230 | $this->_validLikes['can_like'] = ($this->_user['id'] == $topicOwner ? 'cannot_like_content' : (allowedTo('likes_like') ? true : 'cannot_like_content')); |
| 224 | - } |
|
| 225 | - |
|
| 226 | - else |
|
| 231 | + } else |
|
| 227 | 232 | { |
| 228 | 233 | // Modders: This will give you whatever the user offers up in terms of liking, e.g. $this->_type=msg, $this->_content=1 |
| 229 | 234 | // When you hook this, check $this->_type first. If it is not something your mod worries about, return false. |
@@ -241,8 +246,9 @@ discard block |
||
| 241 | 246 | if ($result !== false) |
| 242 | 247 | { |
| 243 | 248 | // Match the type with what we already have. |
| 244 | - if (!isset($result['type']) || $result['type'] != $this->_type) |
|
| 245 | - return $this->_error = 'not_valid_like_type'; |
|
| 249 | + if (!isset($result['type']) || $result['type'] != $this->_type) { |
|
| 250 | + return $this->_error = 'not_valid_like_type'; |
|
| 251 | + } |
|
| 246 | 252 | |
| 247 | 253 | // Fill out the rest. |
| 248 | 254 | $this->_type = $result['type']; |
@@ -253,13 +259,15 @@ discard block |
||
| 253 | 259 | } |
| 254 | 260 | } |
| 255 | 261 | |
| 256 | - if (!$found) |
|
| 257 | - return $this->_error = 'cannot_'; |
|
| 262 | + if (!$found) { |
|
| 263 | + return $this->_error = 'cannot_'; |
|
| 264 | + } |
|
| 258 | 265 | } |
| 259 | 266 | |
| 260 | 267 | // Does the user can like this? Viewing a list of likes doesn't require this permission. |
| 261 | - if ($this->_sa != 'view' && isset($this->_validLikes['can_like']) && is_string($this->_validLikes['can_like'])) |
|
| 262 | - return $this->_error = $this->_validLikes['can_like']; |
|
| 268 | + if ($this->_sa != 'view' && isset($this->_validLikes['can_like']) && is_string($this->_validLikes['can_like'])) { |
|
| 269 | + return $this->_error = $this->_validLikes['can_like']; |
|
| 270 | + } |
|
| 263 | 271 | } |
| 264 | 272 | |
| 265 | 273 | /** |
@@ -284,8 +292,9 @@ discard block |
||
| 284 | 292 | ); |
| 285 | 293 | |
| 286 | 294 | // Are we calling this directly? if so, set a proper data for the response. Do note that __METHOD__ returns both the class name and the function name. |
| 287 | - if ($this->_sa == __FUNCTION__) |
|
| 288 | - $this->_data = __FUNCTION__; |
|
| 295 | + if ($this->_sa == __FUNCTION__) { |
|
| 296 | + $this->_data = __FUNCTION__; |
|
| 297 | + } |
|
| 289 | 298 | } |
| 290 | 299 | |
| 291 | 300 | /** |
@@ -315,8 +324,8 @@ discard block |
||
| 315 | 324 | |
| 316 | 325 | // Add a background task to process sending alerts. |
| 317 | 326 | // Mod author, you can add your own background task for your own custom like event using the "integrate_issue_like" hook or your callback, both are immediately called after this. |
| 318 | - if ($this->_type == 'msg') |
|
| 319 | - $smcFunc['db_insert']('insert', |
|
| 327 | + if ($this->_type == 'msg') { |
|
| 328 | + $smcFunc['db_insert']('insert', |
|
| 320 | 329 | '{db_prefix}background_tasks', |
| 321 | 330 | array('task_file' => 'string', 'task_class' => 'string', 'task_data' => 'string', 'claimed_time' => 'int'), |
| 322 | 331 | array('$sourcedir/tasks/Likes-Notify.php', 'Likes_Notify_Background', $smcFunc['json_encode'](array( |
@@ -328,10 +337,12 @@ discard block |
||
| 328 | 337 | )), 0), |
| 329 | 338 | array('id_task') |
| 330 | 339 | ); |
| 340 | + } |
|
| 331 | 341 | |
| 332 | 342 | // Are we calling this directly? if so, set a proper data for the response. Do note that __METHOD__ returns both the class name and the function name. |
| 333 | - if ($this->_sa == __FUNCTION__) |
|
| 334 | - $this->_data = __FUNCTION__; |
|
| 343 | + if ($this->_sa == __FUNCTION__) { |
|
| 344 | + $this->_data = __FUNCTION__; |
|
| 345 | + } |
|
| 335 | 346 | } |
| 336 | 347 | |
| 337 | 348 | /** |
@@ -357,8 +368,9 @@ discard block |
||
| 357 | 368 | $smcFunc['db_free_result']($request); |
| 358 | 369 | |
| 359 | 370 | // If you want to call this directly, fill out _data property too. |
| 360 | - if ($this->_sa == __FUNCTION__) |
|
| 361 | - $this->_data = $this->_numLikes; |
|
| 371 | + if ($this->_sa == __FUNCTION__) { |
|
| 372 | + $this->_data = $this->_numLikes; |
|
| 373 | + } |
|
| 362 | 374 | } |
| 363 | 375 | |
| 364 | 376 | /** |
@@ -371,8 +383,9 @@ discard block |
||
| 371 | 383 | global $smcFunc; |
| 372 | 384 | |
| 373 | 385 | // Safety first! |
| 374 | - if (empty($this->_type) || empty($this->_content)) |
|
| 375 | - return $this->_error = 'cannot_'; |
|
| 386 | + if (empty($this->_type) || empty($this->_content)) { |
|
| 387 | + return $this->_error = 'cannot_'; |
|
| 388 | + } |
|
| 376 | 389 | |
| 377 | 390 | // Do we already like this? |
| 378 | 391 | $request = $smcFunc['db_query']('', ' |
@@ -390,26 +403,28 @@ discard block |
||
| 390 | 403 | $this->_alreadyLiked = (bool) $smcFunc['db_num_rows']($request) != 0; |
| 391 | 404 | $smcFunc['db_free_result']($request); |
| 392 | 405 | |
| 393 | - if ($this->_alreadyLiked) |
|
| 394 | - $this->delete(); |
|
| 395 | - |
|
| 396 | - else |
|
| 397 | - $this->insert(); |
|
| 406 | + if ($this->_alreadyLiked) { |
|
| 407 | + $this->delete(); |
|
| 408 | + } else { |
|
| 409 | + $this->insert(); |
|
| 410 | + } |
|
| 398 | 411 | |
| 399 | 412 | // Now, how many people like this content now? We *could* just +1 / -1 the relevant container but that has proven to become unstable. |
| 400 | 413 | $this->_count(); |
| 401 | 414 | |
| 402 | 415 | // Update the likes count for messages. |
| 403 | - if ($this->_type == 'msg') |
|
| 404 | - $this->msgIssueLike(); |
|
| 416 | + if ($this->_type == 'msg') { |
|
| 417 | + $this->msgIssueLike(); |
|
| 418 | + } |
|
| 405 | 419 | |
| 406 | 420 | // Any callbacks? |
| 407 | 421 | elseif (!empty($this->_validLikes['callback'])) |
| 408 | 422 | { |
| 409 | 423 | $call = call_helper($this->_validLikes['callback'], true); |
| 410 | 424 | |
| 411 | - if (!empty($call)) |
|
| 412 | - call_user_func_array($call, array($this)); |
|
| 425 | + if (!empty($call)) { |
|
| 426 | + call_user_func_array($call, array($this)); |
|
| 427 | + } |
|
| 413 | 428 | } |
| 414 | 429 | |
| 415 | 430 | // Sometimes there might be other things that need updating after we do this like. |
@@ -418,8 +433,9 @@ discard block |
||
| 418 | 433 | // Now some clean up. This is provided here for any like handlers that want to do any cache flushing. |
| 419 | 434 | // This way a like handler doesn't need to explicitly declare anything in integrate_issue_like, but do so |
| 420 | 435 | // in integrate_valid_likes where it absolutely has to exist. |
| 421 | - if (!empty($this->_validLikes['flush_cache'])) |
|
| 422 | - cache_put_data($this->_validLikes['flush_cache'], null); |
|
| 436 | + if (!empty($this->_validLikes['flush_cache'])) { |
|
| 437 | + cache_put_data($this->_validLikes['flush_cache'], null); |
|
| 438 | + } |
|
| 423 | 439 | |
| 424 | 440 | // All done, start building the data to pass as response. |
| 425 | 441 | $this->_data = array( |
@@ -442,8 +458,9 @@ discard block |
||
| 442 | 458 | { |
| 443 | 459 | global $smcFunc; |
| 444 | 460 | |
| 445 | - if ($this->_type !== 'msg') |
|
| 446 | - return; |
|
| 461 | + if ($this->_type !== 'msg') { |
|
| 462 | + return; |
|
| 463 | + } |
|
| 447 | 464 | |
| 448 | 465 | $smcFunc['db_query']('', ' |
| 449 | 466 | UPDATE {db_prefix}messages |
@@ -484,8 +501,9 @@ discard block |
||
| 484 | 501 | 'like_type' => $this->_type, |
| 485 | 502 | ) |
| 486 | 503 | ); |
| 487 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 488 | - $context['likers'][$row['id_member']] = array('timestamp' => $row['like_time']); |
|
| 504 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 505 | + $context['likers'][$row['id_member']] = array('timestamp' => $row['like_time']); |
|
| 506 | + } |
|
| 489 | 507 | |
| 490 | 508 | // Now to get member data, including avatars and so on. |
| 491 | 509 | $members = array_keys($context['likers']); |
@@ -493,8 +511,9 @@ discard block |
||
| 493 | 511 | if (count($loaded) != count($members)) |
| 494 | 512 | { |
| 495 | 513 | $members = array_diff($members, $loaded); |
| 496 | - foreach ($members as $not_loaded) |
|
| 497 | - unset ($context['likers'][$not_loaded]); |
|
| 514 | + foreach ($members as $not_loaded) { |
|
| 515 | + unset ($context['likers'][$not_loaded]); |
|
| 516 | + } |
|
| 498 | 517 | } |
| 499 | 518 | |
| 500 | 519 | foreach ($context['likers'] as $liker => $dummy) |
@@ -536,12 +555,14 @@ discard block |
||
| 536 | 555 | global $context, $txt; |
| 537 | 556 | |
| 538 | 557 | // Don't do anything if someone else has already take care of the response. |
| 539 | - if (!$this->_setResponse) |
|
| 540 | - return; |
|
| 558 | + if (!$this->_setResponse) { |
|
| 559 | + return; |
|
| 560 | + } |
|
| 541 | 561 | |
| 542 | 562 | // Want a json response huh? |
| 543 | - if ($this->_validLikes['json']) |
|
| 544 | - return $this->jsonResponse(); |
|
| 563 | + if ($this->_validLikes['json']) { |
|
| 564 | + return $this->jsonResponse(); |
|
| 565 | + } |
|
| 545 | 566 | |
| 546 | 567 | // Set everything up for display. |
| 547 | 568 | loadTemplate('Likes'); |
@@ -551,8 +572,9 @@ discard block |
||
| 551 | 572 | if ($this->_error) |
| 552 | 573 | { |
| 553 | 574 | // If this is a generic error, set it up good. |
| 554 | - if ($this->_error == 'cannot_') |
|
| 555 | - $this->_error = $this->_sa == 'view' ? 'cannot_view_likes' : 'cannot_like_content'; |
|
| 575 | + if ($this->_error == 'cannot_') { |
|
| 576 | + $this->_error = $this->_sa == 'view' ? 'cannot_view_likes' : 'cannot_like_content'; |
|
| 577 | + } |
|
| 556 | 578 | |
| 557 | 579 | // Is this request coming from an ajax call? |
| 558 | 580 | if ($this->_js) |
@@ -562,8 +584,9 @@ discard block |
||
| 562 | 584 | } |
| 563 | 585 | |
| 564 | 586 | // Nope? then just do a redirect to whatever URL was provided. |
| 565 | - else |
|
| 566 | - redirectexit(!empty($this->_validLikes['redirect']) ? $this->_validLikes['redirect'] . ';error=' . $this->_error : ''); |
|
| 587 | + else { |
|
| 588 | + redirectexit(!empty($this->_validLikes['redirect']) ? $this->_validLikes['redirect'] . ';error=' . $this->_error : ''); |
|
| 589 | + } |
|
| 567 | 590 | |
| 568 | 591 | return; |
| 569 | 592 | } |
@@ -572,8 +595,9 @@ discard block |
||
| 572 | 595 | else |
| 573 | 596 | { |
| 574 | 597 | // Not an ajax request so send the user back to the previous location or the main page. |
| 575 | - if (!$this->_js) |
|
| 576 | - redirectexit(!empty($this->_validLikes['redirect']) ? $this->_validLikes['redirect'] : ''); |
|
| 598 | + if (!$this->_js) { |
|
| 599 | + redirectexit(!empty($this->_validLikes['redirect']) ? $this->_validLikes['redirect'] : ''); |
|
| 600 | + } |
|
| 577 | 601 | |
| 578 | 602 | // These fine gentlemen all share the same template. |
| 579 | 603 | $generic = array('delete', 'insert', '_count'); |
@@ -606,8 +630,9 @@ discard block |
||
| 606 | 630 | // If there is an error, send it. |
| 607 | 631 | if ($this->_error) |
| 608 | 632 | { |
| 609 | - if ($this->_error == 'cannot_') |
|
| 610 | - $this->_error = $this->_sa == 'view' ? 'cannot_view_likes' : 'cannot_like_content'; |
|
| 633 | + if ($this->_error == 'cannot_') { |
|
| 634 | + $this->_error = $this->_sa == 'view' ? 'cannot_view_likes' : 'cannot_like_content'; |
|
| 635 | + } |
|
| 611 | 636 | |
| 612 | 637 | $print['error'] = $this->_error; |
| 613 | 638 | } |
@@ -643,33 +668,36 @@ discard block |
||
| 643 | 668 | <body style="background-color: #444455; color: white; font-style: italic; font-family: serif;"> |
| 644 | 669 | <div style="margin-top: 12%; font-size: 1.1em; line-height: 1.4; text-align: center;">'; |
| 645 | 670 | |
| 646 | - if (!isset($_GET['verse']) || ($_GET['verse'] != '2:18' && $_GET['verse'] != '22:1-2')) |
|
| 647 | - $_GET['verse'] = '4:16'; |
|
| 671 | + if (!isset($_GET['verse']) || ($_GET['verse'] != '2:18' && $_GET['verse'] != '22:1-2')) { |
|
| 672 | + $_GET['verse'] = '4:16'; |
|
| 673 | + } |
|
| 648 | 674 | |
| 649 | - if ($_GET['verse'] == '2:18') |
|
| 650 | - echo ' |
|
| 675 | + if ($_GET['verse'] == '2:18') { |
|
| 676 | + echo ' |
|
| 651 | 677 | Woe, it was that his name wasn\'t <em>known</em>, that he came in mystery, and was recognized by none. And it became to be in those days <em>something</em>. Something not yet <em id="unknown" name="[Unknown]">unknown</em> to mankind. And thus what was to be known the <em>secret project</em> began into its existence. Henceforth the opposition was only <em>weary</em> and <em>fearful</em>, for now their match was at arms against them.'; |
| 652 | - elseif ($_GET['verse'] == '4:16') |
|
| 653 | - echo ' |
|
| 678 | + } elseif ($_GET['verse'] == '4:16') { |
|
| 679 | + echo ' |
|
| 654 | 680 | And it came to pass that the <em>unbelievers</em> dwindled in number and saw rise of many <em>proselytizers</em>, and the opposition found fear in the face of the <em>x</em> and the <em>j</em> while those who stood with the <em>something</em> grew stronger and came together. Still, this was only the <em>beginning</em>, and what lay in the future was <em id="unknown" name="[Unknown]">unknown</em> to all, even those on the right side.'; |
| 655 | - elseif ($_GET['verse'] == '22:1-2') |
|
| 656 | - echo ' |
|
| 681 | + } elseif ($_GET['verse'] == '22:1-2') { |
|
| 682 | + echo ' |
|
| 657 | 683 | <p>Now <em>behold</em>, that which was once the secret project was <em id="unknown" name="[Unknown]">unknown</em> no longer. Alas, it needed more than <em>only one</em>, but yet even thought otherwise. It became that the opposition <em>rumored</em> and lied, but still to no avail. Their match, though not <em>perfect</em>, had them outdone.</p> |
| 658 | 684 | <p style="margin: 2ex 1ex 0 1ex; font-size: 1.05em; line-height: 1.5; text-align: center;">Let it continue. <em>The end</em>.</p>'; |
| 685 | + } |
|
| 659 | 686 | |
| 660 | 687 | echo ' |
| 661 | 688 | </div> |
| 662 | 689 | <div style="margin-top: 2ex; font-size: 2em; text-align: right;">'; |
| 663 | 690 | |
| 664 | - if ($_GET['verse'] == '2:18') |
|
| 665 | - echo ' |
|
| 691 | + if ($_GET['verse'] == '2:18') { |
|
| 692 | + echo ' |
|
| 666 | 693 | from <span style="font-family: Georgia, serif;"><strong><a href="', $scripturl, '?action=about:unknown;verse=4:16" style="color: white; text-decoration: none; cursor: text;">The Book of Unknown</a></strong>, 2:18</span>'; |
| 667 | - elseif ($_GET['verse'] == '4:16') |
|
| 668 | - echo ' |
|
| 694 | + } elseif ($_GET['verse'] == '4:16') { |
|
| 695 | + echo ' |
|
| 669 | 696 | from <span style="font-family: Georgia, serif;"><strong><a href="', $scripturl, '?action=about:unknown;verse=22:1-2" style="color: white; text-decoration: none; cursor: text;">The Book of Unknown</a></strong>, 4:16</span>'; |
| 670 | - elseif ($_GET['verse'] == '22:1-2') |
|
| 671 | - echo ' |
|
| 697 | + } elseif ($_GET['verse'] == '22:1-2') { |
|
| 698 | + echo ' |
|
| 672 | 699 | from <span style="font-family: Georgia, serif;"><strong>The Book of Unknown</strong>, 22:1-2</span>'; |
| 700 | + } |
|
| 673 | 701 | |
| 674 | 702 | echo ' |
| 675 | 703 | </div> |