@@ -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']; |
@@ -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. |
@@ -11,8 +11,9 @@ discard block |
||
| 11 | 11 | * @version 2.1 Beta 4 |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | -if (!defined('SMF')) |
|
| 14 | +if (!defined('SMF')) { |
|
| 15 | 15 | die('Hacking attempt...'); |
| 16 | +} |
|
| 16 | 17 | |
| 17 | 18 | /** |
| 18 | 19 | * Our Cache API class |
@@ -34,8 +35,9 @@ discard block |
||
| 34 | 35 | |
| 35 | 36 | $supported = class_exists('memcached'); |
| 36 | 37 | |
| 37 | - if ($test) |
|
| 38 | - return $supported; |
|
| 38 | + if ($test) { |
|
| 39 | + return $supported; |
|
| 40 | + } |
|
| 39 | 41 | return parent::isSupported() && $supported && !empty($cache_memcached); |
| 40 | 42 | } |
| 41 | 43 | |
@@ -53,9 +55,9 @@ discard block |
||
| 53 | 55 | $currentServers = $this->memcached->getServerList(); |
| 54 | 56 | foreach ($servers as $server) |
| 55 | 57 | { |
| 56 | - if (strpos($server,'/') !== false) |
|
| 57 | - $tempServer = array($server, 0); |
|
| 58 | - else |
|
| 58 | + if (strpos($server,'/') !== false) { |
|
| 59 | + $tempServer = array($server, 0); |
|
| 60 | + } else |
|
| 59 | 61 | { |
| 60 | 62 | $server = explode(':', $server); |
| 61 | 63 | $tempServer = array($server[0], isset($server[1]) ? $server[1] : 11211); |
@@ -73,8 +75,9 @@ discard block |
||
| 73 | 75 | } |
| 74 | 76 | |
| 75 | 77 | // Found it? |
| 76 | - if (empty($foundServer)) |
|
| 77 | - $this->memcached->addServer($tempServer[0], $tempServer[1]); |
|
| 78 | + if (empty($foundServer)) { |
|
| 79 | + $this->memcached->addServer($tempServer[0], $tempServer[1]); |
|
| 80 | + } |
|
| 78 | 81 | } |
| 79 | 82 | |
| 80 | 83 | // Best guess is this worked. |
@@ -91,8 +94,9 @@ discard block |
||
| 91 | 94 | $value = $this->memcached->get($key); |
| 92 | 95 | |
| 93 | 96 | // $value should return either data or false (from failure, key not found or empty array). |
| 94 | - if ($value === false) |
|
| 95 | - return null; |
|
| 97 | + if ($value === false) { |
|
| 98 | + return null; |
|
| 99 | + } |
|
| 96 | 100 | return $value; |
| 97 | 101 | } |
| 98 | 102 | |
@@ -135,8 +139,9 @@ discard block |
||
| 135 | 139 | $config_vars[] = $txt['cache_memcache_settings']; |
| 136 | 140 | $config_vars[] = array('cache_memcached', $txt['cache_memcache_servers'], 'file', 'text', 0, 'cache_memcached', 'postinput' => '<br><div class="smalltext"><em>' . $txt['cache_memcache_servers_subtext'] . '</em></div>'); |
| 137 | 141 | |
| 138 | - if (!isset($context['settings_post_javascript'])) |
|
| 139 | - $context['settings_post_javascript'] = ''; |
|
| 142 | + if (!isset($context['settings_post_javascript'])) { |
|
| 143 | + $context['settings_post_javascript'] = ''; |
|
| 144 | + } |
|
| 140 | 145 | |
| 141 | 146 | $context['settings_post_javascript'] .= ' |
| 142 | 147 | $("#cache_accelerator").change(function (e) { |
@@ -11,8 +11,9 @@ discard block |
||
| 11 | 11 | * @version 2.1 Beta 4 |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | -if (!defined('SMF')) |
|
| 14 | +if (!defined('SMF')) { |
|
| 15 | 15 | die('Hacking attempt...'); |
| 16 | +} |
|
| 16 | 17 | |
| 17 | 18 | /** |
| 18 | 19 | * Our Cache API class |
@@ -34,8 +35,9 @@ discard block |
||
| 34 | 35 | |
| 35 | 36 | $supported = class_exists('memcache'); |
| 36 | 37 | |
| 37 | - if ($test) |
|
| 38 | - return $supported; |
|
| 38 | + if ($test) { |
|
| 39 | + return $supported; |
|
| 40 | + } |
|
| 39 | 41 | return parent::isSupported() && $supported && !empty($cache_memcached); |
| 40 | 42 | } |
| 41 | 43 | |
@@ -61,9 +63,9 @@ discard block |
||
| 61 | 63 | $server = trim($servers[array_rand($servers)]); |
| 62 | 64 | |
| 63 | 65 | // Normal host names do not contain slashes, while e.g. unix sockets do. Assume alternative transport pipe with port 0. |
| 64 | - if (strpos($server,'/') !== false) |
|
| 65 | - $host = $server; |
|
| 66 | - else |
|
| 66 | + if (strpos($server,'/') !== false) { |
|
| 67 | + $host = $server; |
|
| 68 | + } else |
|
| 67 | 69 | { |
| 68 | 70 | $server = explode(':', $server); |
| 69 | 71 | $host = $server[0]; |
@@ -71,10 +73,11 @@ discard block |
||
| 71 | 73 | } |
| 72 | 74 | |
| 73 | 75 | // Don't wait too long: yes, we want the server, but we might be able to run the query faster! |
| 74 | - if (empty($db_persist)) |
|
| 75 | - $connected = $this->memcache->connect($host, $port); |
|
| 76 | - else |
|
| 77 | - $connected = $this->memcache->pconnect($host, $port); |
|
| 76 | + if (empty($db_persist)) { |
|
| 77 | + $connected = $this->memcache->connect($host, $port); |
|
| 78 | + } else { |
|
| 79 | + $connected = $this->memcache->pconnect($host, $port); |
|
| 80 | + } |
|
| 78 | 81 | } |
| 79 | 82 | |
| 80 | 83 | return $connected; |
@@ -90,8 +93,9 @@ discard block |
||
| 90 | 93 | $value = $this->memcache->get($key); |
| 91 | 94 | |
| 92 | 95 | // $value should return either data or false (from failure, key not found or empty array). |
| 93 | - if ($value === false) |
|
| 94 | - return null; |
|
| 96 | + if ($value === false) { |
|
| 97 | + return null; |
|
| 98 | + } |
|
| 95 | 99 | return $value; |
| 96 | 100 | } |
| 97 | 101 | |
@@ -132,8 +136,9 @@ discard block |
||
| 132 | 136 | $config_vars[] = $txt['cache_memcache_settings']; |
| 133 | 137 | $config_vars[] = array('cache_memcached', $txt['cache_memcache_servers'], 'file', 'text', 0, 'cache_memcached', 'postinput' => '<br><div class="smalltext"><em>' . $txt['cache_memcache_servers_subtext'] . '</em></div>'); |
| 134 | 138 | |
| 135 | - if (!isset($context['settings_post_javascript'])) |
|
| 136 | - $context['settings_post_javascript'] = ''; |
|
| 139 | + if (!isset($context['settings_post_javascript'])) { |
|
| 140 | + $context['settings_post_javascript'] = ''; |
|
| 141 | + } |
|
| 137 | 142 | |
| 138 | 143 | $context['settings_post_javascript'] .= ' |
| 139 | 144 | $("#cache_accelerator").change(function (e) { |
@@ -32,16 +32,18 @@ discard block |
||
| 32 | 32 | ob_start(); |
| 33 | 33 | |
| 34 | 34 | // Do some cleaning, just in case. |
| 35 | -foreach (array('db_character_set', 'cachedir') as $variable) |
|
| 35 | +foreach (array('db_character_set', 'cachedir') as $variable) { |
|
| 36 | 36 | if (isset($GLOBALS[$variable])) |
| 37 | 37 | unset($GLOBALS[$variable], $GLOBALS[$variable]); |
| 38 | +} |
|
| 38 | 39 | |
| 39 | 40 | // Load the settings... |
| 40 | 41 | require_once(dirname(__FILE__) . '/Settings.php'); |
| 41 | 42 | |
| 42 | 43 | // Make absolutely sure the cache directory is defined. |
| 43 | -if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) |
|
| 44 | +if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) { |
|
| 44 | 45 | $cachedir = $boarddir . '/cache'; |
| 46 | +} |
|
| 45 | 47 | |
| 46 | 48 | // Without those we can't go anywhere |
| 47 | 49 | require_once($sourcedir . '/QueryString.php'); |
@@ -51,8 +53,9 @@ discard block |
||
| 51 | 53 | require_once($sourcedir . '/Load.php'); |
| 52 | 54 | |
| 53 | 55 | // If $maintenance is set specifically to 2, then we're upgrading or something. |
| 54 | -if (!empty($maintenance) && $maintenance == 2) |
|
| 56 | +if (!empty($maintenance) && $maintenance == 2) { |
|
| 55 | 57 | display_maintenance_message(); |
| 58 | +} |
|
| 56 | 59 | |
| 57 | 60 | // Create a variable to store some SMF specific functions in. |
| 58 | 61 | $smcFunc = array(); |
@@ -67,8 +70,9 @@ discard block |
||
| 67 | 70 | cleanRequest(); |
| 68 | 71 | |
| 69 | 72 | // Seed the random generator. |
| 70 | -if (empty($modSettings['rand_seed']) || mt_rand(1, 250) == 69) |
|
| 73 | +if (empty($modSettings['rand_seed']) || mt_rand(1, 250) == 69) { |
|
| 71 | 74 | smf_seed_generator(); |
| 75 | +} |
|
| 72 | 76 | |
| 73 | 77 | // Before we get carried away, are we doing a scheduled task? If so save CPU cycles by jumping out! |
| 74 | 78 | if (isset($_GET['scheduled'])) |
@@ -88,9 +92,9 @@ discard block |
||
| 88 | 92 | if (!empty($modSettings['enableCompressedOutput']) && !headers_sent()) |
| 89 | 93 | { |
| 90 | 94 | // If zlib is being used, turn off output compression. |
| 91 | - if (ini_get('zlib.output_compression') >= 1 || ini_get('output_handler') == 'ob_gzhandler') |
|
| 92 | - $modSettings['enableCompressedOutput'] = '0'; |
|
| 93 | - else |
|
| 95 | + if (ini_get('zlib.output_compression') >= 1 || ini_get('output_handler') == 'ob_gzhandler') { |
|
| 96 | + $modSettings['enableCompressedOutput'] = '0'; |
|
| 97 | + } else |
|
| 94 | 98 | { |
| 95 | 99 | ob_end_clean(); |
| 96 | 100 | ob_start('ob_gzhandler'); |
@@ -182,18 +186,21 @@ discard block |
||
| 182 | 186 | loadPermissions(); |
| 183 | 187 | |
| 184 | 188 | // Attachments don't require the entire theme to be loaded. |
| 185 | - if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'dlattach') |
|
| 186 | - detectBrowser(); |
|
| 189 | + if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'dlattach') { |
|
| 190 | + detectBrowser(); |
|
| 191 | + } |
|
| 187 | 192 | // Load the current theme. (note that ?theme=1 will also work, may be used for guest theming.) |
| 188 | - else |
|
| 189 | - loadTheme(); |
|
| 193 | + else { |
|
| 194 | + loadTheme(); |
|
| 195 | + } |
|
| 190 | 196 | |
| 191 | 197 | // Check if the user should be disallowed access. |
| 192 | 198 | is_not_banned(); |
| 193 | 199 | |
| 194 | 200 | // If we are in a topic and don't have permission to approve it then duck out now. |
| 195 | - if (!empty($topic) && empty($board_info['cur_topic_approved']) && !allowedTo('approve_posts') && ($user_info['id'] != $board_info['cur_topic_starter'] || $user_info['is_guest'])) |
|
| 196 | - fatal_lang_error('not_a_topic', false); |
|
| 201 | + if (!empty($topic) && empty($board_info['cur_topic_approved']) && !allowedTo('approve_posts') && ($user_info['id'] != $board_info['cur_topic_starter'] || $user_info['is_guest'])) { |
|
| 202 | + fatal_lang_error('not_a_topic', false); |
|
| 203 | + } |
|
| 197 | 204 | |
| 198 | 205 | $no_stat_actions = array('clock', 'dlattach', 'findmember', 'jsoption', 'likes', 'loadeditorlocale', 'modifycat', 'requestmembers', 'smstats', 'suggest', 'about:unknown', '.xml', 'xmlhttp', 'verificationcode', 'viewquery', 'viewsmfile'); |
| 199 | 206 | call_integration_hook('integrate_pre_log_stats', array(&$no_stat_actions)); |
@@ -204,8 +211,9 @@ discard block |
||
| 204 | 211 | writeLog(); |
| 205 | 212 | |
| 206 | 213 | // Track forum statistics and hits...? |
| 207 | - if (!empty($modSettings['hitStats'])) |
|
| 208 | - trackStats(array('hits' => '+')); |
|
| 214 | + if (!empty($modSettings['hitStats'])) { |
|
| 215 | + trackStats(array('hits' => '+')); |
|
| 216 | + } |
|
| 209 | 217 | } |
| 210 | 218 | unset($no_stat_actions); |
| 211 | 219 | |
@@ -219,13 +227,14 @@ discard block |
||
| 219 | 227 | return ($_REQUEST['action'] == 'login2' ? 'Login2' : ($_REQUEST['action'] == 'logintfa' ? 'LoginTFA' : 'Logout')); |
| 220 | 228 | } |
| 221 | 229 | // Don't even try it, sonny. |
| 222 | - else |
|
| 223 | - return 'InMaintenance'; |
|
| 230 | + else { |
|
| 231 | + return 'InMaintenance'; |
|
| 232 | + } |
|
| 224 | 233 | } |
| 225 | 234 | // If guest access is off, a guest can only do one of the very few following actions. |
| 226 | - elseif (empty($modSettings['allow_guestAccess']) && $user_info['is_guest'] && (!isset($_REQUEST['action']) || !in_array($_REQUEST['action'], array('coppa', 'login', 'login2', 'logintfa', 'reminder', 'activate', 'help', 'helpadmin', 'smstats', 'verificationcode', 'signup', 'signup2')))) |
|
| 227 | - return 'KickGuest'; |
|
| 228 | - elseif (empty($_REQUEST['action'])) |
|
| 235 | + elseif (empty($modSettings['allow_guestAccess']) && $user_info['is_guest'] && (!isset($_REQUEST['action']) || !in_array($_REQUEST['action'], array('coppa', 'login', 'login2', 'logintfa', 'reminder', 'activate', 'help', 'helpadmin', 'smstats', 'verificationcode', 'signup', 'signup2')))) { |
|
| 236 | + return 'KickGuest'; |
|
| 237 | + } elseif (empty($_REQUEST['action'])) |
|
| 229 | 238 | { |
| 230 | 239 | // Action and board are both empty... BoardIndex! Unless someone else wants to do something different. |
| 231 | 240 | if (empty($board) && empty($topic)) |
@@ -239,8 +248,9 @@ discard block |
||
| 239 | 248 | |
| 240 | 249 | $call = call_helper($defaultAction, true); |
| 241 | 250 | |
| 242 | - if (!empty($call)) |
|
| 243 | - return $call; |
|
| 251 | + if (!empty($call)) { |
|
| 252 | + return $call; |
|
| 253 | + } |
|
| 244 | 254 | } |
| 245 | 255 | |
| 246 | 256 | // No default action huh? then go to our good old BoardIndex. |
@@ -370,8 +380,9 @@ discard block |
||
| 370 | 380 | |
| 371 | 381 | $call = call_helper($fallbackAction, true); |
| 372 | 382 | |
| 373 | - if (!empty($call)) |
|
| 374 | - return $call; |
|
| 383 | + if (!empty($call)) { |
|
| 384 | + return $call; |
|
| 385 | + } |
|
| 375 | 386 | } |
| 376 | 387 | |
| 377 | 388 | // No fallback action, huh? |
@@ -382,8 +393,9 @@ discard block |
||
| 382 | 393 | } |
| 383 | 394 | |
| 384 | 395 | // Otherwise, it was set - so let's go to that action. |
| 385 | - if (!empty($actionArray[$_REQUEST['action']][0])) |
|
| 386 | - require_once($sourcedir . '/' . $actionArray[$_REQUEST['action']][0]); |
|
| 396 | + if (!empty($actionArray[$_REQUEST['action']][0])) { |
|
| 397 | + require_once($sourcedir . '/' . $actionArray[$_REQUEST['action']][0]); |
|
| 398 | + } |
|
| 387 | 399 | |
| 388 | 400 | // Do the right thing. |
| 389 | 401 | return call_helper($actionArray[$_REQUEST['action']][1], true); |
@@ -11,8 +11,9 @@ |
||
| 11 | 11 | * @version 2.1 Beta 4 |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | -if (!defined('SMF')) |
|
| 14 | +if (!defined('SMF')) { |
|
| 15 | 15 | die('No direct access...'); |
| 16 | +} |
|
| 16 | 17 | |
| 17 | 18 | /** |
| 18 | 19 | * Converts the given UTF-8 string into lowercase. |
@@ -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> |
@@ -11,8 +11,9 @@ discard block |
||
| 11 | 11 | * @version 2.1 Beta 4 |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | -if (!defined('SMF')) |
|
| 14 | +if (!defined('SMF')) { |
|
| 15 | 15 | die('Hacking attempt...'); |
| 16 | +} |
|
| 16 | 17 | |
| 17 | 18 | /** |
| 18 | 19 | * Interface cache_api_interface |
@@ -182,8 +183,9 @@ discard block |
||
| 182 | 183 | { |
| 183 | 184 | global $cache_enable; |
| 184 | 185 | |
| 185 | - if ($test) |
|
| 186 | - return true; |
|
| 186 | + if ($test) { |
|
| 187 | + return true; |
|
| 188 | + } |
|
| 187 | 189 | return !empty($cache_enable); |
| 188 | 190 | } |
| 189 | 191 | |
@@ -202,18 +204,20 @@ discard block |
||
| 202 | 204 | global $boardurl, $cachedir; |
| 203 | 205 | |
| 204 | 206 | // Find a valid good file to do mtime checks on. |
| 205 | - if (file_exists($cachedir . '/' . 'index.php')) |
|
| 206 | - $filemtime = $cachedir . '/' . 'index.php'; |
|
| 207 | - elseif (is_dir($cachedir . '/')) |
|
| 208 | - $filemtime = $cachedir . '/'; |
|
| 209 | - else |
|
| 210 | - $filemtime = $boardurl . '/index.php'; |
|
| 207 | + if (file_exists($cachedir . '/' . 'index.php')) { |
|
| 208 | + $filemtime = $cachedir . '/' . 'index.php'; |
|
| 209 | + } elseif (is_dir($cachedir . '/')) { |
|
| 210 | + $filemtime = $cachedir . '/'; |
|
| 211 | + } else { |
|
| 212 | + $filemtime = $boardurl . '/index.php'; |
|
| 213 | + } |
|
| 211 | 214 | |
| 212 | 215 | // Set the default if no prefix was specified. |
| 213 | - if (empty($prefix)) |
|
| 214 | - $this->prefix = md5($boardurl . filemtime($filemtime)) . '-SMF-'; |
|
| 215 | - else |
|
| 216 | - $this->prefix = $prefix; |
|
| 216 | + if (empty($prefix)) { |
|
| 217 | + $this->prefix = md5($boardurl . filemtime($filemtime)) . '-SMF-'; |
|
| 218 | + } else { |
|
| 219 | + $this->prefix = $prefix; |
|
| 220 | + } |
|
| 217 | 221 | |
| 218 | 222 | return true; |
| 219 | 223 | } |
@@ -276,8 +280,9 @@ discard block |
||
| 276 | 280 | |
| 277 | 281 | // Invalidate cache, to be sure! |
| 278 | 282 | // ... as long as index.php can be modified, anyway. |
| 279 | - if (is_writable($cachedir . '/' . 'index.php')) |
|
| 280 | - @touch($cachedir . '/' . 'index.php'); |
|
| 283 | + if (is_writable($cachedir . '/' . 'index.php')) { |
|
| 284 | + @touch($cachedir . '/' . 'index.php'); |
|
| 285 | + } |
|
| 281 | 286 | |
| 282 | 287 | return true; |
| 283 | 288 | } |
@@ -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 | { |