@@ -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 |
@@ -48,17 +48,19 @@ discard block |
||
48 | 48 | </a>'; |
49 | 49 | |
50 | 50 | // Has it outstanding posts for approval? |
51 | - if ($board['can_approve_posts'] && ($board['unapproved_posts'] || $board['unapproved_topics'])) |
|
52 | - echo ' |
|
51 | + if ($board['can_approve_posts'] && ($board['unapproved_posts'] || $board['unapproved_topics'])) { |
|
52 | + echo ' |
|
53 | 53 | <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>'; |
54 | + } |
|
54 | 55 | |
55 | 56 | echo ' |
56 | 57 | <p class="board_description">', $board['description'], '</p>'; |
57 | 58 | |
58 | 59 | // Show the "Moderators: ". Each has name, href, link, and id. (but we're gonna use link_moderators.) |
59 | - if (!empty($board['moderators']) || !empty($board['moderator_groups'])) |
|
60 | - echo ' |
|
60 | + if (!empty($board['moderators']) || !empty($board['moderator_groups'])) { |
|
61 | + echo ' |
|
61 | 62 | <p class="moderators">', count($board['link_moderators']) === 1 ? $txt['moderator'] : $txt['moderators'], ': ', implode(', ', $board['link_moderators']), '</p>'; |
63 | + } |
|
62 | 64 | |
63 | 65 | // Show some basic information about the number of posts, etc. |
64 | 66 | echo ' |
@@ -70,9 +72,10 @@ discard block |
||
70 | 72 | </div> |
71 | 73 | <div class="lastpost lpr_border">'; |
72 | 74 | |
73 | - if (!empty($board['last_post']['id'])) |
|
74 | - echo ' |
|
75 | + if (!empty($board['last_post']['id'])) { |
|
76 | + echo ' |
|
75 | 77 | <p>', $board['last_post']['last_post_message'], '</p>'; |
78 | + } |
|
76 | 79 | |
77 | 80 | echo ' |
78 | 81 | </div>'; |
@@ -87,14 +90,16 @@ discard block |
||
87 | 90 | |
88 | 91 | foreach ($board['children'] as $child) |
89 | 92 | { |
90 | - if (!$child['is_redirect']) |
|
91 | - $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>'; |
|
92 | - else |
|
93 | - $child['link'] = '<a href="' . $child['href'] . '" title="' . comma_format($child['posts']) . ' ' . $txt['redirects'] . '">' . $child['name'] . '</a>'; |
|
93 | + if (!$child['is_redirect']) { |
|
94 | + $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>'; |
|
95 | + } else { |
|
96 | + $child['link'] = '<a href="' . $child['href'] . '" title="' . comma_format($child['posts']) . ' ' . $txt['redirects'] . '">' . $child['name'] . '</a>'; |
|
97 | + } |
|
94 | 98 | |
95 | 99 | // Has it posts awaiting approval? |
96 | - if ($child['can_approve_posts'] && ($child['unapproved_posts'] | $child['unapproved_topics'])) |
|
97 | - $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 | + if ($child['can_approve_posts'] && ($child['unapproved_posts'] | $child['unapproved_topics'])) { |
|
101 | + $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>'; |
|
102 | + } |
|
98 | 103 | |
99 | 104 | $children[] = $child['new'] ? '<span class="strong">' . $child['link'] . '</span>' : '<span>' . $child['link'] . '</span>'; |
100 | 105 | } |
@@ -114,8 +119,9 @@ discard block |
||
114 | 119 | } |
115 | 120 | |
116 | 121 | // They can only mark read if they are logged in and it's enabled! |
117 | - if (!$context['user']['is_logged']) |
|
118 | - unset($context['normal_buttons']['markread']); |
|
122 | + if (!$context['user']['is_logged']) { |
|
123 | + unset($context['normal_buttons']['markread']); |
|
124 | + } |
|
119 | 125 | |
120 | 126 | if (!$context['no_topic_listing']) |
121 | 127 | { |
@@ -142,13 +148,15 @@ discard block |
||
142 | 148 | <h3>', $context['name'], '</h3> |
143 | 149 | <p>'; |
144 | 150 | |
145 | - if ($context['description'] != '') |
|
146 | - echo ' |
|
151 | + if ($context['description'] != '') { |
|
152 | + echo ' |
|
147 | 153 | ', $context['description'], ' '; |
154 | + } |
|
148 | 155 | |
149 | - if (!empty($context['moderators'])) |
|
150 | - echo ' |
|
156 | + if (!empty($context['moderators'])) { |
|
157 | + echo ' |
|
151 | 158 | ', count($context['moderators']) === 1 ? $txt['moderator'] : $txt['moderators'], ': ', implode(', ', $context['link_moderators']), '.'; |
159 | + } |
|
152 | 160 | |
153 | 161 | echo ' |
154 | 162 | </p> |
@@ -156,9 +164,10 @@ discard block |
||
156 | 164 | } |
157 | 165 | |
158 | 166 | // If Quick Moderation is enabled start the form. |
159 | - if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] > 0 && !empty($context['topics'])) |
|
160 | - echo ' |
|
167 | + if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] > 0 && !empty($context['topics'])) { |
|
168 | + echo ' |
|
161 | 169 | <form action="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], '" method="post" accept-charset="', $context['character_set'], '" class="clear" name="quickModForm" id="quickModForm">'; |
170 | + } |
|
162 | 171 | |
163 | 172 | echo ' |
164 | 173 | <div id="messageindex">'; |
@@ -168,11 +177,11 @@ discard block |
||
168 | 177 | echo ' |
169 | 178 | <div class="information">'; |
170 | 179 | |
171 | - if ($settings['display_who_viewing'] == 1) |
|
172 | - echo count($context['view_members']), ' ', count($context['view_members']) === 1 ? $txt['who_member'] : $txt['members']; |
|
173 | - |
|
174 | - else |
|
175 | - 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'] . ')'); |
|
180 | + if ($settings['display_who_viewing'] == 1) { |
|
181 | + echo count($context['view_members']), ' ', count($context['view_members']) === 1 ? $txt['who_member'] : $txt['members']; |
|
182 | + } else { |
|
183 | + 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'] . ')'); |
|
184 | + } |
|
176 | 185 | echo $txt['who_and'], $context['view_num_guests'], ' ', $context['view_num_guests'] == 1 ? $txt['guest'] : $txt['guests'], $txt['who_viewing_board']; |
177 | 186 | |
178 | 187 | echo ' |
@@ -192,22 +201,25 @@ discard block |
||
192 | 201 | <div class="lastpost">', $context['topics_headers']['last_post'], '</div>'; |
193 | 202 | |
194 | 203 | // Show a "select all" box for quick moderation? |
195 | - if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] == 1) |
|
196 | - echo ' |
|
204 | + if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] == 1) { |
|
205 | + echo ' |
|
197 | 206 | <div class="moderation"> |
198 | 207 | <input type="checkbox" onclick="invertAll(this, this.form, \'topics[]\');"> |
199 | 208 | </div>'; |
209 | + } |
|
200 | 210 | |
201 | 211 | // If it's on in "image" mode, don't show anything but the column. |
202 | - elseif (!empty($context['can_quick_mod'])) |
|
203 | - echo ' |
|
212 | + elseif (!empty($context['can_quick_mod'])) { |
|
213 | + echo ' |
|
204 | 214 | <div class="moderation"> </div>'; |
215 | + } |
|
205 | 216 | } |
206 | 217 | |
207 | 218 | // No topics.... just say, "sorry bub". |
208 | - else |
|
209 | - echo ' |
|
219 | + else { |
|
220 | + echo ' |
|
210 | 221 | <h3 class="titlebg">', $txt['topic_alert_none'], '</h3>'; |
222 | + } |
|
211 | 223 | |
212 | 224 | echo ' |
213 | 225 | </div><!-- #topic_header -->'; |
@@ -240,21 +252,26 @@ discard block |
||
240 | 252 | echo ' |
241 | 253 | <div class="icons floatright">'; |
242 | 254 | |
243 | - if ($topic['is_watched']) |
|
244 | - echo ' |
|
255 | + if ($topic['is_watched']) { |
|
256 | + echo ' |
|
245 | 257 | <span class="generic_icons watch" title="', $txt['watching_this_topic'], '"></span>'; |
246 | - if ($topic['is_locked']) |
|
247 | - echo ' |
|
258 | + } |
|
259 | + if ($topic['is_locked']) { |
|
260 | + echo ' |
|
248 | 261 | <span class="generic_icons lock"></span>'; |
249 | - if ($topic['is_sticky']) |
|
250 | - echo ' |
|
262 | + } |
|
263 | + if ($topic['is_sticky']) { |
|
264 | + echo ' |
|
251 | 265 | <span class="generic_icons sticky"></span>'; |
252 | - if ($topic['is_redirect']) |
|
253 | - echo ' |
|
266 | + } |
|
267 | + if ($topic['is_redirect']) { |
|
268 | + echo ' |
|
254 | 269 | <span class="generic_icons move"></span>'; |
255 | - if ($topic['is_poll']) |
|
256 | - echo ' |
|
270 | + } |
|
271 | + if ($topic['is_poll']) { |
|
272 | + echo ' |
|
257 | 273 | <span class="generic_icons poll"></span>'; |
274 | + } |
|
258 | 275 | |
259 | 276 | echo ' |
260 | 277 | </div>'; |
@@ -284,26 +301,31 @@ discard block |
||
284 | 301 | echo ' |
285 | 302 | <div class="moderation">'; |
286 | 303 | |
287 | - if ($options['display_quick_mod'] == 1) |
|
288 | - echo ' |
|
304 | + if ($options['display_quick_mod'] == 1) { |
|
305 | + echo ' |
|
289 | 306 | <input type="checkbox" name="topics[]" value="', $topic['id'], '">'; |
290 | - else |
|
307 | + } else |
|
291 | 308 | { |
292 | 309 | // Check permissions on each and show only the ones they are allowed to use. |
293 | - if ($topic['quick_mod']['remove']) |
|
294 | - 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 | + if ($topic['quick_mod']['remove']) { |
|
311 | + 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>'; |
|
312 | + } |
|
295 | 313 | |
296 | - if ($topic['quick_mod']['lock']) |
|
297 | - 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 | + if ($topic['quick_mod']['lock']) { |
|
315 | + 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>'; |
|
316 | + } |
|
298 | 317 | |
299 | - if ($topic['quick_mod']['lock'] || $topic['quick_mod']['remove']) |
|
300 | - echo '<br>'; |
|
318 | + if ($topic['quick_mod']['lock'] || $topic['quick_mod']['remove']) { |
|
319 | + echo '<br>'; |
|
320 | + } |
|
301 | 321 | |
302 | - if ($topic['quick_mod']['sticky']) |
|
303 | - 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 | + if ($topic['quick_mod']['sticky']) { |
|
323 | + 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>'; |
|
324 | + } |
|
304 | 325 | |
305 | - if ($topic['quick_mod']['move']) |
|
306 | - 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 | + if ($topic['quick_mod']['move']) { |
|
327 | + 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>'; |
|
328 | + } |
|
307 | 329 | } |
308 | 330 | echo ' |
309 | 331 | </div><!-- .moderation -->'; |
@@ -321,18 +343,20 @@ discard block |
||
321 | 343 | <select class="qaction" name="qaction"', $context['can_move'] ? ' onchange="this.form.move_to.disabled = (this.options[this.selectedIndex].value != \'move\');"' : '', '> |
322 | 344 | <option value="">--------</option>'; |
323 | 345 | |
324 | - foreach ($context['qmod_actions'] as $qmod_action) |
|
325 | - if ($context['can_' . $qmod_action]) |
|
346 | + foreach ($context['qmod_actions'] as $qmod_action) { |
|
347 | + if ($context['can_' . $qmod_action]) |
|
326 | 348 | echo ' |
327 | 349 | <option value="' . $qmod_action . '">' . $txt['quick_mod_' . $qmod_action] . '</option>'; |
350 | + } |
|
328 | 351 | |
329 | 352 | echo ' |
330 | 353 | </select>'; |
331 | 354 | |
332 | 355 | // Show a list of boards they can move the topic to. |
333 | - if ($context['can_move']) |
|
334 | - echo ' |
|
356 | + if ($context['can_move']) { |
|
357 | + echo ' |
|
335 | 358 | <span id="quick_mod_jump_to"> </span>'; |
359 | + } |
|
336 | 360 | |
337 | 361 | echo ' |
338 | 362 | <input type="submit" value="', $txt['quick_mod_go'], '" onclick="return document.forms.quickModForm.qaction.value != \'\' && confirm(\'', $txt['quickmod_confirm'], '\');" class="button qaction"> |
@@ -343,10 +367,11 @@ discard block |
||
343 | 367 | </div><!-- #messageindex -->'; |
344 | 368 | |
345 | 369 | // Finish off the form - again. |
346 | - if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] > 0 && !empty($context['topics'])) |
|
347 | - echo ' |
|
370 | + if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] > 0 && !empty($context['topics'])) { |
|
371 | + echo ' |
|
348 | 372 | <input type="hidden" name="' . $context['session_var'] . '" value="' . $context['session_id'] . '"> |
349 | 373 | </form>'; |
374 | + } |
|
350 | 375 | |
351 | 376 | // Mobile action buttons (bottom) |
352 | 377 | echo ' |
@@ -368,8 +393,8 @@ discard block |
||
368 | 393 | // Show breadcrumbs at the bottom too. |
369 | 394 | theme_linktree(); |
370 | 395 | |
371 | - if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics']) && $context['can_move']) |
|
372 | - echo ' |
|
396 | + if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics']) && $context['can_move']) { |
|
397 | + echo ' |
|
373 | 398 | <script> |
374 | 399 | if (typeof(window.XMLHttpRequest) != "undefined") |
375 | 400 | aJumpTo[aJumpTo.length] = new JumpTo({ |
@@ -388,6 +413,7 @@ discard block |
||
388 | 413 | sCustomName: "move_to" |
389 | 414 | }); |
390 | 415 | </script>'; |
416 | + } |
|
391 | 417 | |
392 | 418 | // Javascript for inline editing. |
393 | 419 | echo ' |
@@ -424,8 +450,8 @@ discard block |
||
424 | 450 | <div class="information"> |
425 | 451 | <p class="floatright" id="message_index_jump_to"> </p>'; |
426 | 452 | |
427 | - if (empty($context['no_topic_listing'])) |
|
428 | - echo ' |
|
453 | + if (empty($context['no_topic_listing'])) { |
|
454 | + echo ' |
|
429 | 455 | <p class="floatleft">', !empty($modSettings['enableParticipation']) && $context['user']['is_logged'] ? ' |
430 | 456 | <img src="' . $settings['images_url'] . '/icons/profile_sm.png" alt="" class="centericon"> ' . $txt['participation_caption'] . '<br>' : '', ' |
431 | 457 | '. ($modSettings['pollMode'] == '1' ? '<span class="generic_icons poll centericon"></span> ' . $txt['poll'] : '') . '<br> |
@@ -435,9 +461,10 @@ discard block |
||
435 | 461 | <span class="generic_icons lock centericon"></span> ' . $txt['locked_topic'] . '<br> |
436 | 462 | <span class="generic_icons sticky centericon"></span> ' . $txt['sticky_topic'] . '<br> |
437 | 463 | </p>'; |
464 | + } |
|
438 | 465 | |
439 | - if (!empty($context['jump_to'])) |
|
440 | - echo ' |
|
466 | + if (!empty($context['jump_to'])) { |
|
467 | + echo ' |
|
441 | 468 | <script> |
442 | 469 | if (typeof(window.XMLHttpRequest) != "undefined") |
443 | 470 | aJumpTo[aJumpTo.length] = new JumpTo({ |
@@ -453,6 +480,7 @@ discard block |
||
453 | 480 | sGoButtonLabel: "', $txt['quick_mod_go'], '" |
454 | 481 | }); |
455 | 482 | </script>'; |
483 | + } |
|
456 | 484 | |
457 | 485 | echo ' |
458 | 486 | <br class="clear"> |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 4 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * The main dispatcher; doesn't do anything, just delegates. |
@@ -92,18 +93,19 @@ discard block |
||
92 | 93 | checkSession('get'); |
93 | 94 | validateToken('admin-bm-' . (int) $_REQUEST['src_board'], 'request'); |
94 | 95 | |
95 | - if ($_REQUEST['move_to'] === 'top') |
|
96 | - $boardOptions = array( |
|
96 | + if ($_REQUEST['move_to'] === 'top') { |
|
97 | + $boardOptions = array( |
|
97 | 98 | 'move_to' => $_REQUEST['move_to'], |
98 | 99 | 'target_category' => (int) $_REQUEST['target_cat'], |
99 | 100 | 'move_first_child' => true, |
100 | 101 | ); |
101 | - else |
|
102 | - $boardOptions = array( |
|
102 | + } else { |
|
103 | + $boardOptions = array( |
|
103 | 104 | 'move_to' => $_REQUEST['move_to'], |
104 | 105 | 'target_board' => (int) $_REQUEST['target_board'], |
105 | 106 | 'move_first_child' => true, |
106 | 107 | ); |
108 | + } |
|
107 | 109 | modifyBoard((int) $_REQUEST['src_board'], $boardOptions); |
108 | 110 | } |
109 | 111 | |
@@ -148,15 +150,16 @@ discard block |
||
148 | 150 | $security = $context['session_var'] . '=' . $context['session_id'] . ';' . $context['admin-bm-' . $context['move_board'] . '_token_var'] . '=' . $context['admin-bm-' . $context['move_board'] . '_token']; |
149 | 151 | foreach ($boardList[$catid] as $boardid) |
150 | 152 | { |
151 | - if (!isset($context['categories'][$catid]['move_link'])) |
|
152 | - $context['categories'][$catid]['move_link'] = array( |
|
153 | + if (!isset($context['categories'][$catid]['move_link'])) { |
|
154 | + $context['categories'][$catid]['move_link'] = array( |
|
153 | 155 | 'child_level' => 0, |
154 | 156 | 'label' => $txt['mboards_order_before'] . ' \'' . $smcFunc['htmlspecialchars']($boards[$boardid]['name']) . '\'', |
155 | 157 | 'href' => $scripturl . '?action=admin;area=manageboards;sa=move;src_board=' . $context['move_board'] . ';target_board=' . $boardid . ';move_to=before;' . $security, |
156 | 158 | ); |
159 | + } |
|
157 | 160 | |
158 | - if (!$context['categories'][$catid]['boards'][$boardid]['move']) |
|
159 | - $context['categories'][$catid]['boards'][$boardid]['move_links'] = array( |
|
161 | + if (!$context['categories'][$catid]['boards'][$boardid]['move']) { |
|
162 | + $context['categories'][$catid]['boards'][$boardid]['move_links'] = array( |
|
160 | 163 | array( |
161 | 164 | 'child_level' => $boards[$boardid]['level'], |
162 | 165 | 'label' => $txt['mboards_order_after'] . '\'' . $smcFunc['htmlspecialchars']($boards[$boardid]['name']) . '\'', |
@@ -170,34 +173,39 @@ discard block |
||
170 | 173 | 'class' => 'here', |
171 | 174 | ), |
172 | 175 | ); |
176 | + } |
|
173 | 177 | |
174 | 178 | $difference = $boards[$boardid]['level'] - $prev_child_level; |
175 | - if ($difference == 1) |
|
176 | - array_push($stack, !empty($context['categories'][$catid]['boards'][$prev_board]['move_links']) ? array_shift($context['categories'][$catid]['boards'][$prev_board]['move_links']) : null); |
|
177 | - elseif ($difference < 0) |
|
179 | + if ($difference == 1) { |
|
180 | + array_push($stack, !empty($context['categories'][$catid]['boards'][$prev_board]['move_links']) ? array_shift($context['categories'][$catid]['boards'][$prev_board]['move_links']) : null); |
|
181 | + } elseif ($difference < 0) |
|
178 | 182 | { |
179 | - if (empty($context['categories'][$catid]['boards'][$prev_board]['move_links'])) |
|
180 | - $context['categories'][$catid]['boards'][$prev_board]['move_links'] = array(); |
|
181 | - for ($i = 0; $i < -$difference; $i++) |
|
182 | - if (($temp = array_pop($stack)) != null) |
|
183 | + if (empty($context['categories'][$catid]['boards'][$prev_board]['move_links'])) { |
|
184 | + $context['categories'][$catid]['boards'][$prev_board]['move_links'] = array(); |
|
185 | + } |
|
186 | + for ($i = 0; $i < -$difference; $i++) { |
|
187 | + if (($temp = array_pop($stack)) != null) |
|
183 | 188 | array_unshift($context['categories'][$catid]['boards'][$prev_board]['move_links'], $temp); |
189 | + } |
|
184 | 190 | } |
185 | 191 | |
186 | 192 | $prev_board = $boardid; |
187 | 193 | $prev_child_level = $boards[$boardid]['level']; |
188 | 194 | |
189 | 195 | } |
190 | - if (!empty($stack) && !empty($context['categories'][$catid]['boards'][$prev_board]['move_links'])) |
|
191 | - $context['categories'][$catid]['boards'][$prev_board]['move_links'] = array_merge($stack, $context['categories'][$catid]['boards'][$prev_board]['move_links']); |
|
192 | - elseif (!empty($stack)) |
|
193 | - $context['categories'][$catid]['boards'][$prev_board]['move_links'] = $stack; |
|
196 | + if (!empty($stack) && !empty($context['categories'][$catid]['boards'][$prev_board]['move_links'])) { |
|
197 | + $context['categories'][$catid]['boards'][$prev_board]['move_links'] = array_merge($stack, $context['categories'][$catid]['boards'][$prev_board]['move_links']); |
|
198 | + } elseif (!empty($stack)) { |
|
199 | + $context['categories'][$catid]['boards'][$prev_board]['move_links'] = $stack; |
|
200 | + } |
|
194 | 201 | |
195 | - if (empty($boardList[$catid])) |
|
196 | - $context['categories'][$catid]['move_link'] = array( |
|
202 | + if (empty($boardList[$catid])) { |
|
203 | + $context['categories'][$catid]['move_link'] = array( |
|
197 | 204 | 'child_level' => 0, |
198 | 205 | 'label' => $txt['mboards_order_before'] . ' \'' . $smcFunc['htmlspecialchars']($tree['node']['name']) . '\'', |
199 | 206 | 'href' => $scripturl . '?action=admin;area=manageboards;sa=move;src_board=' . $context['move_board'] . ';target_cat=' . $catid . ';move_to=top;' . $security, |
200 | 207 | ); |
208 | + } |
|
201 | 209 | } |
202 | 210 | } |
203 | 211 | |
@@ -253,9 +261,9 @@ discard block |
||
253 | 261 | ); |
254 | 262 | } |
255 | 263 | // Category doesn't exist, man... sorry. |
256 | - elseif (!isset($cat_tree[$_REQUEST['cat']])) |
|
257 | - redirectexit('action=admin;area=manageboards'); |
|
258 | - else |
|
264 | + elseif (!isset($cat_tree[$_REQUEST['cat']])) { |
|
265 | + redirectexit('action=admin;area=manageboards'); |
|
266 | + } else |
|
259 | 267 | { |
260 | 268 | $context['category'] = array( |
261 | 269 | 'id' => $_REQUEST['cat'], |
@@ -267,30 +275,31 @@ discard block |
||
267 | 275 | 'is_empty' => empty($cat_tree[$_REQUEST['cat']]['children']) |
268 | 276 | ); |
269 | 277 | |
270 | - foreach ($boardList[$_REQUEST['cat']] as $child_board) |
|
271 | - $context['category']['children'][] = str_repeat('-', $boards[$child_board]['level']) . ' ' . $boards[$child_board]['name']; |
|
278 | + foreach ($boardList[$_REQUEST['cat']] as $child_board) { |
|
279 | + $context['category']['children'][] = str_repeat('-', $boards[$child_board]['level']) . ' ' . $boards[$child_board]['name']; |
|
280 | + } |
|
272 | 281 | } |
273 | 282 | |
274 | 283 | $prevCat = 0; |
275 | 284 | foreach ($cat_tree as $catid => $tree) |
276 | 285 | { |
277 | - if ($catid == $_REQUEST['cat'] && $prevCat > 0) |
|
278 | - $context['category_order'][$prevCat]['selected'] = true; |
|
279 | - elseif ($catid != $_REQUEST['cat']) |
|
280 | - $context['category_order'][$catid] = array( |
|
286 | + if ($catid == $_REQUEST['cat'] && $prevCat > 0) { |
|
287 | + $context['category_order'][$prevCat]['selected'] = true; |
|
288 | + } elseif ($catid != $_REQUEST['cat']) { |
|
289 | + $context['category_order'][$catid] = array( |
|
281 | 290 | 'id' => $catid, |
282 | 291 | 'name' => $txt['mboards_order_after'] . $tree['node']['name'], |
283 | 292 | 'selected' => false, |
284 | 293 | 'true_name' => $tree['node']['name'] |
285 | 294 | ); |
295 | + } |
|
286 | 296 | $prevCat = $catid; |
287 | 297 | } |
288 | 298 | if (!isset($_REQUEST['delete'])) |
289 | 299 | { |
290 | 300 | $context['sub_template'] = 'modify_category'; |
291 | 301 | $context['page_title'] = $_REQUEST['sa'] == 'newcat' ? $txt['mboards_new_cat_name'] : $txt['catEdit']; |
292 | - } |
|
293 | - else |
|
302 | + } else |
|
294 | 303 | { |
295 | 304 | $context['sub_template'] = 'confirm_category_delete'; |
296 | 305 | $context['page_title'] = $txt['mboards_delete_cat']; |
@@ -327,8 +336,9 @@ discard block |
||
327 | 336 | { |
328 | 337 | $catOptions = array(); |
329 | 338 | |
330 | - if (isset($_POST['cat_order'])) |
|
331 | - $catOptions['move_after'] = (int) $_POST['cat_order']; |
|
339 | + if (isset($_POST['cat_order'])) { |
|
340 | + $catOptions['move_after'] = (int) $_POST['cat_order']; |
|
341 | + } |
|
332 | 342 | |
333 | 343 | // Change "This & That" to "This & That" but don't change "¢" to "&cent;"... |
334 | 344 | $catOptions['cat_name'] = parse_bbc($smcFunc['htmlspecialchars']($_POST['cat_name']), false, '', $context['description_allowed_tags']); |
@@ -336,10 +346,11 @@ discard block |
||
336 | 346 | |
337 | 347 | $catOptions['is_collapsible'] = isset($_POST['collapse']); |
338 | 348 | |
339 | - if (isset($_POST['add'])) |
|
340 | - createCategory($catOptions); |
|
341 | - else |
|
342 | - modifyCategory($_POST['cat'], $catOptions); |
|
349 | + if (isset($_POST['add'])) { |
|
350 | + createCategory($catOptions); |
|
351 | + } else { |
|
352 | + modifyCategory($_POST['cat'], $catOptions); |
|
353 | + } |
|
343 | 354 | } |
344 | 355 | // If they want to delete - first give them confirmation. |
345 | 356 | elseif (isset($_POST['delete']) && !isset($_POST['confirmation']) && !isset($_POST['empty'])) |
@@ -353,13 +364,14 @@ discard block |
||
353 | 364 | // First off - check if we are moving all the current boards first - before we start deleting! |
354 | 365 | if (isset($_POST['delete_action']) && $_POST['delete_action'] == 1) |
355 | 366 | { |
356 | - if (empty($_POST['cat_to'])) |
|
357 | - fatal_lang_error('mboards_delete_error'); |
|
367 | + if (empty($_POST['cat_to'])) { |
|
368 | + fatal_lang_error('mboards_delete_error'); |
|
369 | + } |
|
358 | 370 | |
359 | 371 | deleteCategories(array($_POST['cat']), (int) $_POST['cat_to']); |
372 | + } else { |
|
373 | + deleteCategories(array($_POST['cat'])); |
|
360 | 374 | } |
361 | - else |
|
362 | - deleteCategories(array($_POST['cat'])); |
|
363 | 375 | } |
364 | 376 | |
365 | 377 | redirectexit('action=admin;area=manageboards'); |
@@ -404,8 +416,9 @@ discard block |
||
404 | 416 | if ($_REQUEST['sa'] == 'newboard') |
405 | 417 | { |
406 | 418 | // Category doesn't exist, man... sorry. |
407 | - if (empty($_REQUEST['cat'])) |
|
408 | - redirectexit('action=admin;area=manageboards'); |
|
419 | + if (empty($_REQUEST['cat'])) { |
|
420 | + redirectexit('action=admin;area=manageboards'); |
|
421 | + } |
|
409 | 422 | |
410 | 423 | // Some things that need to be setup for a new board. |
411 | 424 | $curBoard = array( |
@@ -429,8 +442,7 @@ discard block |
||
429 | 442 | 'category' => (int) $_REQUEST['cat'], |
430 | 443 | 'no_children' => true, |
431 | 444 | ); |
432 | - } |
|
433 | - else |
|
445 | + } else |
|
434 | 446 | { |
435 | 447 | // Just some easy shortcuts. |
436 | 448 | $curBoard = &$boards[$_REQUEST['boardid']]; |
@@ -478,8 +490,9 @@ discard block |
||
478 | 490 | ); |
479 | 491 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
480 | 492 | { |
481 | - if ($_REQUEST['sa'] == 'newboard' && $row['min_posts'] == -1) |
|
482 | - $curBoard['member_groups'][] = $row['id_group']; |
|
493 | + if ($_REQUEST['sa'] == 'newboard' && $row['min_posts'] == -1) { |
|
494 | + $curBoard['member_groups'][] = $row['id_group']; |
|
495 | + } |
|
483 | 496 | |
484 | 497 | $context['groups'][(int) $row['id_group']] = array( |
485 | 498 | 'id' => $row['id_group'], |
@@ -492,8 +505,9 @@ discard block |
||
492 | 505 | $smcFunc['db_free_result']($request); |
493 | 506 | |
494 | 507 | // Category doesn't exist, man... sorry. |
495 | - if (!isset($boardList[$curBoard['category']])) |
|
496 | - redirectexit('action=admin;area=manageboards'); |
|
508 | + if (!isset($boardList[$curBoard['category']])) { |
|
509 | + redirectexit('action=admin;area=manageboards'); |
|
510 | + } |
|
497 | 511 | |
498 | 512 | foreach ($boardList[$curBoard['category']] as $boardid) |
499 | 513 | { |
@@ -507,8 +521,7 @@ discard block |
||
507 | 521 | 'is_child' => false, |
508 | 522 | 'selected' => true |
509 | 523 | ); |
510 | - } |
|
511 | - else |
|
524 | + } else |
|
512 | 525 | { |
513 | 526 | $context['board_order'][] = array( |
514 | 527 | 'id' => $boardid, |
@@ -525,19 +538,21 @@ discard block |
||
525 | 538 | $context['can_move_children'] = false; |
526 | 539 | $context['children'] = $boards[$_REQUEST['boardid']]['tree']['children']; |
527 | 540 | |
528 | - foreach ($context['board_order'] as $lBoard) |
|
529 | - if ($lBoard['is_child'] == false && $lBoard['selected'] == false) |
|
541 | + foreach ($context['board_order'] as $lBoard) { |
|
542 | + if ($lBoard['is_child'] == false && $lBoard['selected'] == false) |
|
530 | 543 | $context['can_move_children'] = true; |
544 | + } |
|
531 | 545 | } |
532 | 546 | |
533 | 547 | // Get other available categories. |
534 | 548 | $context['categories'] = array(); |
535 | - foreach ($cat_tree as $catID => $tree) |
|
536 | - $context['categories'][] = array( |
|
549 | + foreach ($cat_tree as $catID => $tree) { |
|
550 | + $context['categories'][] = array( |
|
537 | 551 | 'id' => $catID == $curBoard['category'] ? 0 : $catID, |
538 | 552 | 'name' => $tree['node']['name'], |
539 | 553 | 'selected' => $catID == $curBoard['category'] |
540 | 554 | ); |
555 | + } |
|
541 | 556 | |
542 | 557 | $request = $smcFunc['db_query']('', ' |
543 | 558 | SELECT mem.id_member, mem.real_name |
@@ -549,14 +564,16 @@ discard block |
||
549 | 564 | ) |
550 | 565 | ); |
551 | 566 | $context['board']['moderators'] = array(); |
552 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
553 | - $context['board']['moderators'][$row['id_member']] = $row['real_name']; |
|
567 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
568 | + $context['board']['moderators'][$row['id_member']] = $row['real_name']; |
|
569 | + } |
|
554 | 570 | $smcFunc['db_free_result']($request); |
555 | 571 | |
556 | 572 | $context['board']['moderator_list'] = empty($context['board']['moderators']) ? '' : '"' . implode('", "', $context['board']['moderators']) . '"'; |
557 | 573 | |
558 | - if (!empty($context['board']['moderators'])) |
|
559 | - list ($context['board']['last_moderator_id']) = array_slice(array_keys($context['board']['moderators']), -1); |
|
574 | + if (!empty($context['board']['moderators'])) { |
|
575 | + list ($context['board']['last_moderator_id']) = array_slice(array_keys($context['board']['moderators']), -1); |
|
576 | + } |
|
560 | 577 | |
561 | 578 | // Get all the groups assigned as moderators |
562 | 579 | $request = $smcFunc['db_query']('', ' |
@@ -568,14 +585,16 @@ discard block |
||
568 | 585 | ) |
569 | 586 | ); |
570 | 587 | $context['board']['moderator_groups'] = array(); |
571 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
572 | - $context['board']['moderator_groups'][$row['id_group']] = $context['groups'][$row['id_group']]['name']; |
|
588 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
589 | + $context['board']['moderator_groups'][$row['id_group']] = $context['groups'][$row['id_group']]['name']; |
|
590 | + } |
|
573 | 591 | $smcFunc['db_free_result']($request); |
574 | 592 | |
575 | 593 | $context['board']['moderator_groups_list'] = empty($context['board']['moderator_groups']) ? '' : '"' . implode('", &qout;', $context['board']['moderator_groups']) . '"'; |
576 | 594 | |
577 | - if (!empty($context['board']['moderator_groups'])) |
|
578 | - list ($context['board']['last_moderator_group_id']) = array_slice(array_keys($context['board']['moderator_groups']), -1); |
|
595 | + if (!empty($context['board']['moderator_groups'])) { |
|
596 | + list ($context['board']['last_moderator_group_id']) = array_slice(array_keys($context['board']['moderator_groups']), -1); |
|
597 | + } |
|
579 | 598 | |
580 | 599 | // Get all the themes... |
581 | 600 | $request = $smcFunc['db_query']('', ' |
@@ -587,8 +606,9 @@ discard block |
||
587 | 606 | ) |
588 | 607 | ); |
589 | 608 | $context['themes'] = array(); |
590 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
591 | - $context['themes'][] = $row; |
|
609 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
610 | + $context['themes'][] = $row; |
|
611 | + } |
|
592 | 612 | $smcFunc['db_free_result']($request); |
593 | 613 | |
594 | 614 | if (!isset($_REQUEST['delete'])) |
@@ -596,8 +616,7 @@ discard block |
||
596 | 616 | $context['sub_template'] = 'modify_board'; |
597 | 617 | $context['page_title'] = $txt['boardsEdit']; |
598 | 618 | loadJavaScriptFile('suggest.js', array('defer' => false), 'smf_suggest'); |
599 | - } |
|
600 | - else |
|
619 | + } else |
|
601 | 620 | { |
602 | 621 | $context['sub_template'] = 'confirm_board_delete'; |
603 | 622 | $context['page_title'] = $txt['mboards_delete_board']; |
@@ -641,8 +660,9 @@ discard block |
||
641 | 660 | // Change the boardorder of this board? |
642 | 661 | elseif (!empty($_POST['placement']) && !empty($_POST['board_order'])) |
643 | 662 | { |
644 | - if (!in_array($_POST['placement'], array('before', 'after', 'child'))) |
|
645 | - fatal_lang_error('mangled_post', false); |
|
663 | + if (!in_array($_POST['placement'], array('before', 'after', 'child'))) { |
|
664 | + fatal_lang_error('mangled_post', false); |
|
665 | + } |
|
646 | 666 | |
647 | 667 | $boardOptions['move_to'] = $_POST['placement']; |
648 | 668 | $boardOptions['target_board'] = (int) $_POST['board_order']; |
@@ -655,13 +675,14 @@ discard block |
||
655 | 675 | $boardOptions['access_groups'] = array(); |
656 | 676 | $boardOptions['deny_groups'] = array(); |
657 | 677 | |
658 | - if (!empty($_POST['groups'])) |
|
659 | - foreach ($_POST['groups'] as $group => $action) |
|
678 | + if (!empty($_POST['groups'])) { |
|
679 | + foreach ($_POST['groups'] as $group => $action) |
|
660 | 680 | { |
661 | 681 | if ($action == 'allow') |
662 | 682 | $boardOptions['access_groups'][] = (int) $group; |
663 | - elseif ($action == 'deny') |
|
664 | - $boardOptions['deny_groups'][] = (int) $group; |
|
683 | + } elseif ($action == 'deny') { |
|
684 | + $boardOptions['deny_groups'][] = (int) $group; |
|
685 | + } |
|
665 | 686 | } |
666 | 687 | |
667 | 688 | // People with manage-boards are special. |
@@ -673,8 +694,9 @@ discard block |
||
673 | 694 | // Secondly, make sure those with super cow powers (like apt-get, or in this case manage boards) are upgraded. |
674 | 695 | $boardOptions['access_groups'] = array_unique(array_merge($boardOptions['access_groups'], $board_managers)); |
675 | 696 | |
676 | - if (strlen(implode(',', $boardOptions['access_groups'])) > 255 || strlen(implode(',', $boardOptions['deny_groups'])) > 255) |
|
677 | - fatal_lang_error('too_many_groups', false); |
|
697 | + if (strlen(implode(',', $boardOptions['access_groups'])) > 255 || strlen(implode(',', $boardOptions['deny_groups'])) > 255) { |
|
698 | + fatal_lang_error('too_many_groups', false); |
|
699 | + } |
|
678 | 700 | |
679 | 701 | // Do not allow HTML tags. Parse the string. |
680 | 702 | $boardOptions['board_name'] = parse_bbc($smcFunc['htmlspecialchars']($_POST['board_name']), false, '', $context['description_allowed_tags']); |
@@ -685,8 +707,9 @@ discard block |
||
685 | 707 | if (isset($_POST['moderator_list']) && is_array($_POST['moderator_list'])) |
686 | 708 | { |
687 | 709 | $moderators = array(); |
688 | - foreach ($_POST['moderator_list'] as $moderator) |
|
689 | - $moderators[(int) $moderator] = (int) $moderator; |
|
710 | + foreach ($_POST['moderator_list'] as $moderator) { |
|
711 | + $moderators[(int) $moderator] = (int) $moderator; |
|
712 | + } |
|
690 | 713 | $boardOptions['moderators'] = $moderators; |
691 | 714 | } |
692 | 715 | |
@@ -695,8 +718,9 @@ discard block |
||
695 | 718 | if (isset($_POST['moderator_group_list']) && is_array($_POST['moderator_group_list'])) |
696 | 719 | { |
697 | 720 | $moderator_groups = array(); |
698 | - foreach ($_POST['moderator_group_list'] as $moderator_group) |
|
699 | - $moderator_groups[(int) $moderator_group] = (int) $moderator_group; |
|
721 | + foreach ($_POST['moderator_group_list'] as $moderator_group) { |
|
722 | + $moderator_groups[(int) $moderator_group] = (int) $moderator_group; |
|
723 | + } |
|
700 | 724 | $boardOptions['moderator_groups'] = $moderator_groups; |
701 | 725 | } |
702 | 726 | |
@@ -722,56 +746,62 @@ discard block |
||
722 | 746 | $smcFunc['db_free_result']($request); |
723 | 747 | |
724 | 748 | // If we're turning redirection on check the board doesn't have posts in it - if it does don't make it a redirection board. |
725 | - if ($boardOptions['redirect'] && empty($oldRedirect) && $numPosts) |
|
726 | - unset($boardOptions['redirect']); |
|
749 | + if ($boardOptions['redirect'] && empty($oldRedirect) && $numPosts) { |
|
750 | + unset($boardOptions['redirect']); |
|
751 | + } |
|
727 | 752 | // Reset the redirection count when switching on/off. |
728 | - elseif (empty($boardOptions['redirect']) != empty($oldRedirect)) |
|
729 | - $boardOptions['num_posts'] = 0; |
|
753 | + elseif (empty($boardOptions['redirect']) != empty($oldRedirect)) { |
|
754 | + $boardOptions['num_posts'] = 0; |
|
755 | + } |
|
730 | 756 | // Resetting the count? |
731 | - elseif ($boardOptions['redirect'] && !empty($_POST['reset_redirect'])) |
|
732 | - $boardOptions['num_posts'] = 0; |
|
757 | + elseif ($boardOptions['redirect'] && !empty($_POST['reset_redirect'])) { |
|
758 | + $boardOptions['num_posts'] = 0; |
|
759 | + } |
|
733 | 760 | } |
734 | 761 | |
735 | 762 | // Create a new board... |
736 | 763 | if (isset($_POST['add'])) |
737 | 764 | { |
738 | 765 | // New boards by default go to the bottom of the category. |
739 | - if (empty($_POST['new_cat'])) |
|
740 | - $boardOptions['target_category'] = (int) $_POST['cur_cat']; |
|
741 | - if (!isset($boardOptions['move_to'])) |
|
742 | - $boardOptions['move_to'] = 'bottom'; |
|
766 | + if (empty($_POST['new_cat'])) { |
|
767 | + $boardOptions['target_category'] = (int) $_POST['cur_cat']; |
|
768 | + } |
|
769 | + if (!isset($boardOptions['move_to'])) { |
|
770 | + $boardOptions['move_to'] = 'bottom'; |
|
771 | + } |
|
743 | 772 | |
744 | 773 | createBoard($boardOptions); |
745 | 774 | } |
746 | 775 | |
747 | 776 | // ...or update an existing board. |
748 | - else |
|
749 | - modifyBoard($_POST['boardid'], $boardOptions); |
|
750 | - } |
|
751 | - elseif (isset($_POST['delete']) && !isset($_POST['confirmation']) && !isset($_POST['no_children'])) |
|
777 | + else { |
|
778 | + modifyBoard($_POST['boardid'], $boardOptions); |
|
779 | + } |
|
780 | + } elseif (isset($_POST['delete']) && !isset($_POST['confirmation']) && !isset($_POST['no_children'])) |
|
752 | 781 | { |
753 | 782 | EditBoard(); |
754 | 783 | return; |
755 | - } |
|
756 | - elseif (isset($_POST['delete'])) |
|
784 | + } elseif (isset($_POST['delete'])) |
|
757 | 785 | { |
758 | 786 | // First off - check if we are moving all the current child boards first - before we start deleting! |
759 | 787 | if (isset($_POST['delete_action']) && $_POST['delete_action'] == 1) |
760 | 788 | { |
761 | - if (empty($_POST['board_to'])) |
|
762 | - fatal_lang_error('mboards_delete_board_error'); |
|
789 | + if (empty($_POST['board_to'])) { |
|
790 | + fatal_lang_error('mboards_delete_board_error'); |
|
791 | + } |
|
763 | 792 | |
764 | 793 | deleteBoards(array($_POST['boardid']), (int) $_POST['board_to']); |
794 | + } else { |
|
795 | + deleteBoards(array($_POST['boardid']), 0); |
|
765 | 796 | } |
766 | - else |
|
767 | - deleteBoards(array($_POST['boardid']), 0); |
|
768 | 797 | } |
769 | 798 | |
770 | - if (isset($_REQUEST['rid']) && $_REQUEST['rid'] == 'permissions') |
|
771 | - redirectexit('action=admin;area=permissions;sa=board;' . $context['session_var'] . '=' . $context['session_id']); |
|
772 | - else |
|
773 | - redirectexit('action=admin;area=manageboards'); |
|
774 | -} |
|
799 | + if (isset($_REQUEST['rid']) && $_REQUEST['rid'] == 'permissions') { |
|
800 | + redirectexit('action=admin;area=permissions;sa=board;' . $context['session_var'] . '=' . $context['session_id']); |
|
801 | + } else { |
|
802 | + redirectexit('action=admin;area=manageboards'); |
|
803 | + } |
|
804 | + } |
|
775 | 805 | |
776 | 806 | /** |
777 | 807 | * Used to retrieve data for modifying a board category |
@@ -808,8 +838,9 @@ discard block |
||
808 | 838 | $smcFunc['db_free_result']($request); |
809 | 839 | |
810 | 840 | // This would probably never happen, but just to be sure. |
811 | - if ($cat .= $allowed_sa[1]) |
|
812 | - die(str_replace(',', ' to', $cat)); |
|
841 | + if ($cat .= $allowed_sa[1]) { |
|
842 | + die(str_replace(',', ' to', $cat)); |
|
843 | + } |
|
813 | 844 | |
814 | 845 | redirectexit(); |
815 | 846 | } |
@@ -835,8 +866,9 @@ discard block |
||
835 | 866 | 'empty_string' => '', |
836 | 867 | ) |
837 | 868 | ); |
838 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
839 | - $recycle_boards[$row['id_board']] = $row['cat_name'] . ' - ' . $row['board_name']; |
|
869 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
870 | + $recycle_boards[$row['id_board']] = $row['cat_name'] . ' - ' . $row['board_name']; |
|
871 | + } |
|
840 | 872 | $smcFunc['db_free_result']($request); |
841 | 873 | |
842 | 874 | if (!empty($recycle_boards)) |
@@ -844,9 +876,9 @@ discard block |
||
844 | 876 | require_once($sourcedir . '/Subs-Boards.php'); |
845 | 877 | sortBoards($recycle_boards); |
846 | 878 | $recycle_boards = array('') + $recycle_boards; |
879 | + } else { |
|
880 | + $recycle_boards = array(''); |
|
847 | 881 | } |
848 | - else |
|
849 | - $recycle_boards = array(''); |
|
850 | 882 | |
851 | 883 | // Here and the board settings... |
852 | 884 | $config_vars = array( |
@@ -864,8 +896,9 @@ discard block |
||
864 | 896 | |
865 | 897 | call_integration_hook('integrate_modify_board_settings', array(&$config_vars)); |
866 | 898 | |
867 | - if ($return_config) |
|
868 | - return $config_vars; |
|
899 | + if ($return_config) { |
|
900 | + return $config_vars; |
|
901 | + } |
|
869 | 902 | |
870 | 903 | // Needed for the settings template. |
871 | 904 | require_once($sourcedir . '/ManageServer.php'); |
@@ -2259,9 +2259,9 @@ discard block |
||
2259 | 2259 | * |
2260 | 2260 | * @uses the template_include() function to include the file. |
2261 | 2261 | * @param string $template_name The name of the template to load |
2262 | - * @param array|string $style_sheets The name of a single stylesheet or an array of names of stylesheets to load |
|
2262 | + * @param string $style_sheets The name of a single stylesheet or an array of names of stylesheets to load |
|
2263 | 2263 | * @param bool $fatal If true, dies with an error message if the template cannot be found |
2264 | - * @return boolean Whether or not the template was loaded |
|
2264 | + * @return boolean|null Whether or not the template was loaded |
|
2265 | 2265 | */ |
2266 | 2266 | function loadTemplate($template_name, $style_sheets = array(), $fatal = true) |
2267 | 2267 | { |
@@ -2444,7 +2444,7 @@ discard block |
||
2444 | 2444 | * - all code added with this function is added to the same <style> tag so do make sure your css is valid! |
2445 | 2445 | * |
2446 | 2446 | * @param string $css Some css code |
2447 | - * @return void|bool Adds the CSS to the $context['css_header'] array or returns if no CSS is specified |
|
2447 | + * @return false|null Adds the CSS to the $context['css_header'] array or returns if no CSS is specified |
|
2448 | 2448 | */ |
2449 | 2449 | function addInlineCss($css) |
2450 | 2450 | { |
@@ -2558,7 +2558,7 @@ discard block |
||
2558 | 2558 | * |
2559 | 2559 | * @param string $javascript Some JS code |
2560 | 2560 | * @param bool $defer Whether the script should load in <head> or before the closing <html> tag |
2561 | - * @return void|bool Adds the code to one of the $context['javascript_inline'] arrays or returns if no JS was specified |
|
2561 | + * @return false|null Adds the code to one of the $context['javascript_inline'] arrays or returns if no JS was specified |
|
2562 | 2562 | */ |
2563 | 2563 | function addInlineJavaScript($javascript, $defer = false) |
2564 | 2564 | { |
@@ -2791,7 +2791,7 @@ discard block |
||
2791 | 2791 | * It will try to choose only utf8 or non-utf8 languages. |
2792 | 2792 | * |
2793 | 2793 | * @param bool $use_cache Whether or not to use the cache |
2794 | - * @return array An array of information about available languages |
|
2794 | + * @return string An array of information about available languages |
|
2795 | 2795 | */ |
2796 | 2796 | function getLanguages($use_cache = true) |
2797 | 2797 | { |
@@ -1719,7 +1719,7 @@ |
||
1719 | 1719 | $id_theme = $modSettings['theme_guests']; |
1720 | 1720 | |
1721 | 1721 | // We already load the basic stuff? |
1722 | - if (empty($settings['theme_id']) || $settings['theme_id'] != $id_theme ) |
|
1722 | + if (empty($settings['theme_id']) || $settings['theme_id'] != $id_theme) |
|
1723 | 1723 | { |
1724 | 1724 | // Verify the id_theme... no foul play. |
1725 | 1725 | // Always allow the board specific theme, if they are overriding. |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 4 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Load the $modSettings array. |
@@ -25,13 +26,14 @@ discard block |
||
25 | 26 | global $cache_enable, $sourcedir, $context; |
26 | 27 | |
27 | 28 | // Most database systems have not set UTF-8 as their default input charset. |
28 | - if (!empty($db_character_set)) |
|
29 | - $smcFunc['db_query']('', ' |
|
29 | + if (!empty($db_character_set)) { |
|
30 | + $smcFunc['db_query']('', ' |
|
30 | 31 | SET NAMES {string:db_character_set}', |
31 | 32 | array( |
32 | 33 | 'db_character_set' => $db_character_set, |
33 | 34 | ) |
34 | 35 | ); |
36 | + } |
|
35 | 37 | |
36 | 38 | // We need some caching support, maybe. |
37 | 39 | loadCacheAccelerator(); |
@@ -46,28 +48,36 @@ discard block |
||
46 | 48 | ) |
47 | 49 | ); |
48 | 50 | $modSettings = array(); |
49 | - if (!$request) |
|
50 | - display_db_error(); |
|
51 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
52 | - $modSettings[$row[0]] = $row[1]; |
|
51 | + if (!$request) { |
|
52 | + display_db_error(); |
|
53 | + } |
|
54 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
55 | + $modSettings[$row[0]] = $row[1]; |
|
56 | + } |
|
53 | 57 | $smcFunc['db_free_result']($request); |
54 | 58 | |
55 | 59 | // Do a few things to protect against missing settings or settings with invalid values... |
56 | - if (empty($modSettings['defaultMaxTopics']) || $modSettings['defaultMaxTopics'] <= 0 || $modSettings['defaultMaxTopics'] > 999) |
|
57 | - $modSettings['defaultMaxTopics'] = 20; |
|
58 | - if (empty($modSettings['defaultMaxMessages']) || $modSettings['defaultMaxMessages'] <= 0 || $modSettings['defaultMaxMessages'] > 999) |
|
59 | - $modSettings['defaultMaxMessages'] = 15; |
|
60 | - if (empty($modSettings['defaultMaxMembers']) || $modSettings['defaultMaxMembers'] <= 0 || $modSettings['defaultMaxMembers'] > 999) |
|
61 | - $modSettings['defaultMaxMembers'] = 30; |
|
62 | - if (empty($modSettings['defaultMaxListItems']) || $modSettings['defaultMaxListItems'] <= 0 || $modSettings['defaultMaxListItems'] > 999) |
|
63 | - $modSettings['defaultMaxListItems'] = 15; |
|
60 | + if (empty($modSettings['defaultMaxTopics']) || $modSettings['defaultMaxTopics'] <= 0 || $modSettings['defaultMaxTopics'] > 999) { |
|
61 | + $modSettings['defaultMaxTopics'] = 20; |
|
62 | + } |
|
63 | + if (empty($modSettings['defaultMaxMessages']) || $modSettings['defaultMaxMessages'] <= 0 || $modSettings['defaultMaxMessages'] > 999) { |
|
64 | + $modSettings['defaultMaxMessages'] = 15; |
|
65 | + } |
|
66 | + if (empty($modSettings['defaultMaxMembers']) || $modSettings['defaultMaxMembers'] <= 0 || $modSettings['defaultMaxMembers'] > 999) { |
|
67 | + $modSettings['defaultMaxMembers'] = 30; |
|
68 | + } |
|
69 | + if (empty($modSettings['defaultMaxListItems']) || $modSettings['defaultMaxListItems'] <= 0 || $modSettings['defaultMaxListItems'] > 999) { |
|
70 | + $modSettings['defaultMaxListItems'] = 15; |
|
71 | + } |
|
64 | 72 | |
65 | 73 | // We excpiclity do not use $smcFunc['json_decode'] here yet, as $smcFunc is not fully loaded. |
66 | - if (!is_array($modSettings['attachmentUploadDir'])) |
|
67 | - $modSettings['attachmentUploadDir'] = smf_json_decode($modSettings['attachmentUploadDir'], true); |
|
74 | + if (!is_array($modSettings['attachmentUploadDir'])) { |
|
75 | + $modSettings['attachmentUploadDir'] = smf_json_decode($modSettings['attachmentUploadDir'], true); |
|
76 | + } |
|
68 | 77 | |
69 | - if (!empty($cache_enable)) |
|
70 | - cache_put_data('modSettings', $modSettings, 90); |
|
78 | + if (!empty($cache_enable)) { |
|
79 | + cache_put_data('modSettings', $modSettings, 90); |
|
80 | + } |
|
71 | 81 | } |
72 | 82 | |
73 | 83 | $modSettings['cache_enable'] = $cache_enable; |
@@ -87,8 +97,9 @@ discard block |
||
87 | 97 | }; |
88 | 98 | $fix_utf8mb4 = function($string) use ($utf8, $smcFunc) |
89 | 99 | { |
90 | - if (!$utf8 || $smcFunc['db_mb4']) |
|
91 | - return $string; |
|
100 | + if (!$utf8 || $smcFunc['db_mb4']) { |
|
101 | + return $string; |
|
102 | + } |
|
92 | 103 | |
93 | 104 | $i = 0; |
94 | 105 | $len = strlen($string); |
@@ -100,18 +111,15 @@ discard block |
||
100 | 111 | { |
101 | 112 | $new_string .= $string[$i]; |
102 | 113 | $i++; |
103 | - } |
|
104 | - elseif ($ord < 224) |
|
114 | + } elseif ($ord < 224) |
|
105 | 115 | { |
106 | 116 | $new_string .= $string[$i] . $string[$i + 1]; |
107 | 117 | $i += 2; |
108 | - } |
|
109 | - elseif ($ord < 240) |
|
118 | + } elseif ($ord < 240) |
|
110 | 119 | { |
111 | 120 | $new_string .= $string[$i] . $string[$i + 1] . $string[$i + 2]; |
112 | 121 | $i += 3; |
113 | - } |
|
114 | - elseif ($ord < 248) |
|
122 | + } elseif ($ord < 248) |
|
115 | 123 | { |
116 | 124 | // Magic happens. |
117 | 125 | $val = (ord($string[$i]) & 0x07) << 18; |
@@ -155,8 +163,7 @@ discard block |
||
155 | 163 | { |
156 | 164 | $result = array_search($needle, array_slice($haystack_arr, $offset)); |
157 | 165 | return is_int($result) ? $result + $offset : false; |
158 | - } |
|
159 | - else |
|
166 | + } else |
|
160 | 167 | { |
161 | 168 | $needle_arr = preg_split('~(&#' . (empty($modSettings['disableEntityCheck']) ? '\d{1,7}' : '021') . ';|"|&|<|>| |.)~' . ($utf8 ? 'u' : '') . '', $ent_check($needle), -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); |
162 | 169 | $needle_size = count($needle_arr); |
@@ -165,8 +172,9 @@ discard block |
||
165 | 172 | while ((int) $result === $result) |
166 | 173 | { |
167 | 174 | $offset += $result; |
168 | - if (array_slice($haystack_arr, $offset, $needle_size) === $needle_arr) |
|
169 | - return $offset; |
|
175 | + if (array_slice($haystack_arr, $offset, $needle_size) === $needle_arr) { |
|
176 | + return $offset; |
|
177 | + } |
|
170 | 178 | $result = array_search($needle_arr[0], array_slice($haystack_arr, ++$offset)); |
171 | 179 | } |
172 | 180 | return false; |
@@ -204,8 +212,9 @@ discard block |
||
204 | 212 | $string = $ent_check($string); |
205 | 213 | preg_match('~^(' . $ent_list . '|.){' . $smcFunc['strlen'](substr($string, 0, $length)) . '}~' . ($utf8 ? 'u' : ''), $string, $matches); |
206 | 214 | $string = $matches[0]; |
207 | - while (strlen($string) > $length) |
|
208 | - $string = preg_replace('~(?:' . $ent_list . '|.)$~' . ($utf8 ? 'u' : ''), '', $string); |
|
215 | + while (strlen($string) > $length) { |
|
216 | + $string = preg_replace('~(?:' . $ent_list . '|.)$~' . ($utf8 ? 'u' : ''), '', $string); |
|
217 | + } |
|
209 | 218 | return $string; |
210 | 219 | }, |
211 | 220 | 'ucfirst' => $utf8 ? function($string) use (&$smcFunc) |
@@ -215,8 +224,9 @@ discard block |
||
215 | 224 | 'ucwords' => $utf8 ? function($string) use (&$smcFunc) |
216 | 225 | { |
217 | 226 | $words = preg_split('~([\s\r\n\t]+)~', $string, -1, PREG_SPLIT_DELIM_CAPTURE); |
218 | - for ($i = 0, $n = count($words); $i < $n; $i += 2) |
|
219 | - $words[$i] = $smcFunc['ucfirst']($words[$i]); |
|
227 | + for ($i = 0, $n = count($words); $i < $n; $i += 2) { |
|
228 | + $words[$i] = $smcFunc['ucfirst']($words[$i]); |
|
229 | + } |
|
220 | 230 | return implode('', $words); |
221 | 231 | } : 'ucwords', |
222 | 232 | 'json_decode' => 'smf_json_decode', |
@@ -224,16 +234,17 @@ discard block |
||
224 | 234 | ); |
225 | 235 | |
226 | 236 | // Setting the timezone is a requirement for some functions. |
227 | - if (isset($modSettings['default_timezone']) && in_array($modSettings['default_timezone'], timezone_identifiers_list())) |
|
228 | - date_default_timezone_set($modSettings['default_timezone']); |
|
229 | - else |
|
237 | + if (isset($modSettings['default_timezone']) && in_array($modSettings['default_timezone'], timezone_identifiers_list())) { |
|
238 | + date_default_timezone_set($modSettings['default_timezone']); |
|
239 | + } else |
|
230 | 240 | { |
231 | 241 | // Get PHP's default timezone, if set |
232 | 242 | $ini_tz = ini_get('date.timezone'); |
233 | - if (!empty($ini_tz)) |
|
234 | - $modSettings['default_timezone'] = $ini_tz; |
|
235 | - else |
|
236 | - $modSettings['default_timezone'] = ''; |
|
243 | + if (!empty($ini_tz)) { |
|
244 | + $modSettings['default_timezone'] = $ini_tz; |
|
245 | + } else { |
|
246 | + $modSettings['default_timezone'] = ''; |
|
247 | + } |
|
237 | 248 | |
238 | 249 | // If date.timezone is unset, invalid, or just plain weird, make a best guess |
239 | 250 | if (!in_array($modSettings['default_timezone'], timezone_identifiers_list())) |
@@ -251,22 +262,26 @@ discard block |
||
251 | 262 | if (($modSettings['load_average'] = cache_get_data('loadavg', 90)) == null) |
252 | 263 | { |
253 | 264 | $modSettings['load_average'] = @file_get_contents('/proc/loadavg'); |
254 | - if (!empty($modSettings['load_average']) && preg_match('~^([^ ]+?) ([^ ]+?) ([^ ]+)~', $modSettings['load_average'], $matches) != 0) |
|
255 | - $modSettings['load_average'] = (float) $matches[1]; |
|
256 | - elseif (($modSettings['load_average'] = @`uptime`) != null && preg_match('~load average[s]?: (\d+\.\d+), (\d+\.\d+), (\d+\.\d+)~i', $modSettings['load_average'], $matches) != 0) |
|
257 | - $modSettings['load_average'] = (float) $matches[1]; |
|
258 | - else |
|
259 | - unset($modSettings['load_average']); |
|
265 | + if (!empty($modSettings['load_average']) && preg_match('~^([^ ]+?) ([^ ]+?) ([^ ]+)~', $modSettings['load_average'], $matches) != 0) { |
|
266 | + $modSettings['load_average'] = (float) $matches[1]; |
|
267 | + } elseif (($modSettings['load_average'] = @`uptime`) != null && preg_match('~load average[s]?: (\d+\.\d+), (\d+\.\d+), (\d+\.\d+)~i', $modSettings['load_average'], $matches) != 0) { |
|
268 | + $modSettings['load_average'] = (float) $matches[1]; |
|
269 | + } else { |
|
270 | + unset($modSettings['load_average']); |
|
271 | + } |
|
260 | 272 | |
261 | - if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) |
|
262 | - cache_put_data('loadavg', $modSettings['load_average'], 90); |
|
273 | + if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) { |
|
274 | + cache_put_data('loadavg', $modSettings['load_average'], 90); |
|
275 | + } |
|
263 | 276 | } |
264 | 277 | |
265 | - if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) |
|
266 | - call_integration_hook('integrate_load_average', array($modSettings['load_average'])); |
|
278 | + if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) { |
|
279 | + call_integration_hook('integrate_load_average', array($modSettings['load_average'])); |
|
280 | + } |
|
267 | 281 | |
268 | - if (!empty($modSettings['loadavg_forum']) && !empty($modSettings['load_average']) && $modSettings['load_average'] >= $modSettings['loadavg_forum']) |
|
269 | - display_loadavg_error(); |
|
282 | + if (!empty($modSettings['loadavg_forum']) && !empty($modSettings['load_average']) && $modSettings['load_average'] >= $modSettings['loadavg_forum']) { |
|
283 | + display_loadavg_error(); |
|
284 | + } |
|
270 | 285 | } |
271 | 286 | |
272 | 287 | // Is post moderation alive and well? Everywhere else assumes this has been defined, so let's make sure it is. |
@@ -287,8 +302,9 @@ discard block |
||
287 | 302 | if (defined('SMF_INTEGRATION_SETTINGS')) |
288 | 303 | { |
289 | 304 | $integration_settings = $smcFunc['json_decode'](SMF_INTEGRATION_SETTINGS, true); |
290 | - foreach ($integration_settings as $hook => $function) |
|
291 | - add_integration_function($hook, $function, '', false); |
|
305 | + foreach ($integration_settings as $hook => $function) { |
|
306 | + add_integration_function($hook, $function, '', false); |
|
307 | + } |
|
292 | 308 | } |
293 | 309 | |
294 | 310 | // Any files to pre include? |
@@ -298,8 +314,9 @@ discard block |
||
298 | 314 | foreach ($pre_includes as $include) |
299 | 315 | { |
300 | 316 | $include = strtr(trim($include), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir)); |
301 | - if (file_exists($include)) |
|
302 | - require_once($include); |
|
317 | + if (file_exists($include)) { |
|
318 | + require_once($include); |
|
319 | + } |
|
303 | 320 | } |
304 | 321 | } |
305 | 322 | |
@@ -405,27 +422,28 @@ discard block |
||
405 | 422 | break; |
406 | 423 | } |
407 | 424 | } |
425 | + } else { |
|
426 | + $id_member = 0; |
|
408 | 427 | } |
409 | - else |
|
410 | - $id_member = 0; |
|
411 | 428 | |
412 | 429 | if (empty($id_member) && isset($_COOKIE[$cookiename])) |
413 | 430 | { |
414 | 431 | $cookie_data = $smcFunc['json_decode']($_COOKIE[$cookiename], true, false); |
415 | 432 | |
416 | - if (empty($cookie_data)) |
|
417 | - $cookie_data = safe_unserialize($_COOKIE[$cookiename]); |
|
433 | + if (empty($cookie_data)) { |
|
434 | + $cookie_data = safe_unserialize($_COOKIE[$cookiename]); |
|
435 | + } |
|
418 | 436 | |
419 | 437 | list ($id_member, $password) = $cookie_data; |
420 | 438 | $id_member = !empty($id_member) && strlen($password) > 0 ? (int) $id_member : 0; |
421 | - } |
|
422 | - elseif (empty($id_member) && isset($_SESSION['login_' . $cookiename]) && ($_SESSION['USER_AGENT'] == $_SERVER['HTTP_USER_AGENT'] || !empty($modSettings['disableCheckUA']))) |
|
439 | + } elseif (empty($id_member) && isset($_SESSION['login_' . $cookiename]) && ($_SESSION['USER_AGENT'] == $_SERVER['HTTP_USER_AGENT'] || !empty($modSettings['disableCheckUA']))) |
|
423 | 440 | { |
424 | 441 | // @todo Perhaps we can do some more checking on this, such as on the first octet of the IP? |
425 | 442 | $cookie_data = $smcFunc['json_decode']($_SESSION['login_' . $cookiename]); |
426 | 443 | |
427 | - if (empty($cookie_data)) |
|
428 | - $cookie_data = safe_unserialize($_SESSION['login_' . $cookiename]); |
|
444 | + if (empty($cookie_data)) { |
|
445 | + $cookie_data = safe_unserialize($_SESSION['login_' . $cookiename]); |
|
446 | + } |
|
429 | 447 | |
430 | 448 | list ($id_member, $password, $login_span) = $cookie_data; |
431 | 449 | $id_member = !empty($id_member) && strlen($password) == 128 && $login_span > time() ? (int) $id_member : 0; |
@@ -450,30 +468,34 @@ discard block |
||
450 | 468 | $user_settings = $smcFunc['db_fetch_assoc']($request); |
451 | 469 | $smcFunc['db_free_result']($request); |
452 | 470 | |
453 | - if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($user_settings['avatar'], 'http://') !== false) |
|
454 | - $user_settings['avatar'] = strtr($boardurl, array('http://' => 'https://')) . '/proxy.php?request=' . urlencode($user_settings['avatar']) . '&hash=' . md5($user_settings['avatar'] . $image_proxy_secret); |
|
471 | + if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($user_settings['avatar'], 'http://') !== false) { |
|
472 | + $user_settings['avatar'] = strtr($boardurl, array('http://' => 'https://')) . '/proxy.php?request=' . urlencode($user_settings['avatar']) . '&hash=' . md5($user_settings['avatar'] . $image_proxy_secret); |
|
473 | + } |
|
455 | 474 | |
456 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
457 | - cache_put_data('user_settings-' . $id_member, $user_settings, 60); |
|
475 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
476 | + cache_put_data('user_settings-' . $id_member, $user_settings, 60); |
|
477 | + } |
|
458 | 478 | } |
459 | 479 | |
460 | 480 | // Did we find 'im? If not, junk it. |
461 | 481 | if (!empty($user_settings)) |
462 | 482 | { |
463 | 483 | // As much as the password should be right, we can assume the integration set things up. |
464 | - if (!empty($already_verified) && $already_verified === true) |
|
465 | - $check = true; |
|
484 | + if (!empty($already_verified) && $already_verified === true) { |
|
485 | + $check = true; |
|
486 | + } |
|
466 | 487 | // SHA-512 hash should be 128 characters long. |
467 | - elseif (strlen($password) == 128) |
|
468 | - $check = hash_salt($user_settings['passwd'], $user_settings['password_salt']) == $password; |
|
469 | - else |
|
470 | - $check = false; |
|
488 | + elseif (strlen($password) == 128) { |
|
489 | + $check = hash_salt($user_settings['passwd'], $user_settings['password_salt']) == $password; |
|
490 | + } else { |
|
491 | + $check = false; |
|
492 | + } |
|
471 | 493 | |
472 | 494 | // Wrong password or not activated - either way, you're going nowhere. |
473 | 495 | $id_member = $check && ($user_settings['is_activated'] == 1 || $user_settings['is_activated'] == 11) ? (int) $user_settings['id_member'] : 0; |
496 | + } else { |
|
497 | + $id_member = 0; |
|
474 | 498 | } |
475 | - else |
|
476 | - $id_member = 0; |
|
477 | 499 | |
478 | 500 | // If we no longer have the member maybe they're being all hackey, stop brute force! |
479 | 501 | if (!$id_member) |
@@ -502,8 +524,9 @@ discard block |
||
502 | 524 | |
503 | 525 | list ($tfamember, $tfasecret) = $tfa_data; |
504 | 526 | |
505 | - if (!isset($tfamember, $tfasecret) || (int) $tfamember != $id_member) |
|
506 | - $tfasecret = null; |
|
527 | + if (!isset($tfamember, $tfasecret) || (int) $tfamember != $id_member) { |
|
528 | + $tfasecret = null; |
|
529 | + } |
|
507 | 530 | } |
508 | 531 | |
509 | 532 | if (empty($tfasecret) || hash_salt($user_settings['tfa_backup'], $user_settings['password_salt']) != $tfasecret) |
@@ -523,10 +546,12 @@ discard block |
||
523 | 546 | // Are we forcing 2FA? Need to check if the user groups actually require 2FA |
524 | 547 | elseif (!empty($modSettings['tfa_mode']) && $modSettings['tfa_mode'] >= 2 && $id_member && empty($user_settings['tfa_secret'])) |
525 | 548 | { |
526 | - if ($modSettings['tfa_mode'] == 2) //only do this if we are just forcing SOME membergroups |
|
549 | + if ($modSettings['tfa_mode'] == 2) { |
|
550 | + //only do this if we are just forcing SOME membergroups |
|
527 | 551 | { |
528 | 552 | //Build an array of ALL user membergroups. |
529 | 553 | $full_groups = array($user_settings['id_group']); |
554 | + } |
|
530 | 555 | if (!empty($user_settings['additional_groups'])) |
531 | 556 | { |
532 | 557 | $full_groups = array_merge($full_groups, explode(',', $user_settings['additional_groups'])); |
@@ -546,15 +571,17 @@ discard block |
||
546 | 571 | ); |
547 | 572 | $row = $smcFunc['db_fetch_assoc']($request); |
548 | 573 | $smcFunc['db_free_result']($request); |
574 | + } else { |
|
575 | + $row['total'] = 1; |
|
549 | 576 | } |
550 | - else |
|
551 | - $row['total'] = 1; //simplifies logics in the next "if" |
|
577 | + //simplifies logics in the next "if" |
|
552 | 578 | |
553 | 579 | $area = !empty($_REQUEST['area']) ? $_REQUEST['area'] : ''; |
554 | 580 | $action = !empty($_REQUEST['action']) ? $_REQUEST['action'] : ''; |
555 | 581 | |
556 | - if ($row['total'] > 0 && !in_array($action, array('profile', 'logout')) || ($action == 'profile' && $area != 'tfasetup')) |
|
557 | - redirectexit('action=profile;area=tfasetup;forced'); |
|
582 | + if ($row['total'] > 0 && !in_array($action, array('profile', 'logout')) || ($action == 'profile' && $area != 'tfasetup')) { |
|
583 | + redirectexit('action=profile;area=tfasetup;forced'); |
|
584 | + } |
|
558 | 585 | } |
559 | 586 | } |
560 | 587 | |
@@ -591,33 +618,37 @@ discard block |
||
591 | 618 | 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'])); |
592 | 619 | $user_settings['last_login'] = time(); |
593 | 620 | |
594 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
595 | - cache_put_data('user_settings-' . $id_member, $user_settings, 60); |
|
621 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
622 | + cache_put_data('user_settings-' . $id_member, $user_settings, 60); |
|
623 | + } |
|
596 | 624 | |
597 | - if (!empty($modSettings['cache_enable'])) |
|
598 | - cache_put_data('user_last_visit-' . $id_member, $_SESSION['id_msg_last_visit'], 5 * 3600); |
|
625 | + if (!empty($modSettings['cache_enable'])) { |
|
626 | + cache_put_data('user_last_visit-' . $id_member, $_SESSION['id_msg_last_visit'], 5 * 3600); |
|
627 | + } |
|
599 | 628 | } |
629 | + } elseif (empty($_SESSION['id_msg_last_visit'])) { |
|
630 | + $_SESSION['id_msg_last_visit'] = $user_settings['id_msg_last_visit']; |
|
600 | 631 | } |
601 | - elseif (empty($_SESSION['id_msg_last_visit'])) |
|
602 | - $_SESSION['id_msg_last_visit'] = $user_settings['id_msg_last_visit']; |
|
603 | 632 | |
604 | 633 | $username = $user_settings['member_name']; |
605 | 634 | |
606 | - if (empty($user_settings['additional_groups'])) |
|
607 | - $user_info = array( |
|
635 | + if (empty($user_settings['additional_groups'])) { |
|
636 | + $user_info = array( |
|
608 | 637 | 'groups' => array($user_settings['id_group'], $user_settings['id_post_group']) |
609 | 638 | ); |
610 | - else |
|
611 | - $user_info = array( |
|
639 | + } else { |
|
640 | + $user_info = array( |
|
612 | 641 | 'groups' => array_merge( |
613 | 642 | array($user_settings['id_group'], $user_settings['id_post_group']), |
614 | 643 | explode(',', $user_settings['additional_groups']) |
615 | 644 | ) |
616 | 645 | ); |
646 | + } |
|
617 | 647 | |
618 | 648 | // Because history has proven that it is possible for groups to go bad - clean up in case. |
619 | - foreach ($user_info['groups'] as $k => $v) |
|
620 | - $user_info['groups'][$k] = (int) $v; |
|
649 | + foreach ($user_info['groups'] as $k => $v) { |
|
650 | + $user_info['groups'][$k] = (int) $v; |
|
651 | + } |
|
621 | 652 | |
622 | 653 | // This is a logged in user, so definitely not a spider. |
623 | 654 | $user_info['possibly_robot'] = false; |
@@ -631,8 +662,7 @@ discard block |
||
631 | 662 | $time_system = new DateTime('now', $tz_system); |
632 | 663 | $time_user = new DateTime('now', $tz_user); |
633 | 664 | $user_info['time_offset'] = ($tz_user->getOffset($time_user) - $tz_system->getOffset($time_system)) / 3600; |
634 | - } |
|
635 | - else |
|
665 | + } else |
|
636 | 666 | { |
637 | 667 | // !!! Compatibility. |
638 | 668 | $user_info['time_offset'] = empty($user_settings['time_offset']) ? 0 : $user_settings['time_offset']; |
@@ -646,8 +676,9 @@ discard block |
||
646 | 676 | $user_info = array('groups' => array(-1)); |
647 | 677 | $user_settings = array(); |
648 | 678 | |
649 | - if (isset($_COOKIE[$cookiename]) && empty($context['tfa_member'])) |
|
650 | - $_COOKIE[$cookiename] = ''; |
|
679 | + if (isset($_COOKIE[$cookiename]) && empty($context['tfa_member'])) { |
|
680 | + $_COOKIE[$cookiename] = ''; |
|
681 | + } |
|
651 | 682 | |
652 | 683 | // Expire the 2FA cookie |
653 | 684 | if (isset($_COOKIE[$cookiename . '_tfa']) && empty($context['tfa_member'])) |
@@ -664,19 +695,20 @@ discard block |
||
664 | 695 | } |
665 | 696 | |
666 | 697 | // Create a login token if it doesn't exist yet. |
667 | - if (!isset($_SESSION['token']['post-login'])) |
|
668 | - createToken('login'); |
|
669 | - else |
|
670 | - list ($context['login_token_var'],,, $context['login_token']) = $_SESSION['token']['post-login']; |
|
698 | + if (!isset($_SESSION['token']['post-login'])) { |
|
699 | + createToken('login'); |
|
700 | + } else { |
|
701 | + list ($context['login_token_var'],,, $context['login_token']) = $_SESSION['token']['post-login']; |
|
702 | + } |
|
671 | 703 | |
672 | 704 | // Do we perhaps think this is a search robot? Check every five minutes just in case... |
673 | 705 | if ((!empty($modSettings['spider_mode']) || !empty($modSettings['spider_group'])) && (!isset($_SESSION['robot_check']) || $_SESSION['robot_check'] < time() - 300)) |
674 | 706 | { |
675 | 707 | require_once($sourcedir . '/ManageSearchEngines.php'); |
676 | 708 | $user_info['possibly_robot'] = SpiderCheck(); |
709 | + } elseif (!empty($modSettings['spider_mode'])) { |
|
710 | + $user_info['possibly_robot'] = isset($_SESSION['id_robot']) ? $_SESSION['id_robot'] : 0; |
|
677 | 711 | } |
678 | - elseif (!empty($modSettings['spider_mode'])) |
|
679 | - $user_info['possibly_robot'] = isset($_SESSION['id_robot']) ? $_SESSION['id_robot'] : 0; |
|
680 | 712 | // If we haven't turned on proper spider hunts then have a guess! |
681 | 713 | else |
682 | 714 | { |
@@ -724,8 +756,9 @@ discard block |
||
724 | 756 | $user_info['groups'] = array_unique($user_info['groups']); |
725 | 757 | |
726 | 758 | // 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. |
727 | - if (!empty($user_info['ignoreboards']) && empty($user_info['ignoreboards'][$tmp = count($user_info['ignoreboards']) - 1])) |
|
728 | - unset($user_info['ignoreboards'][$tmp]); |
|
759 | + if (!empty($user_info['ignoreboards']) && empty($user_info['ignoreboards'][$tmp = count($user_info['ignoreboards']) - 1])) { |
|
760 | + unset($user_info['ignoreboards'][$tmp]); |
|
761 | + } |
|
729 | 762 | |
730 | 763 | // Allow the user to change their language. |
731 | 764 | if (!empty($modSettings['userLanguage'])) |
@@ -738,13 +771,14 @@ discard block |
||
738 | 771 | $user_info['language'] = strtr($_GET['language'], './\\:', '____'); |
739 | 772 | |
740 | 773 | // Make it permanent for members. |
741 | - if (!empty($user_info['id'])) |
|
742 | - updateMemberData($user_info['id'], array('lngfile' => $user_info['language'])); |
|
743 | - else |
|
744 | - $_SESSION['language'] = $user_info['language']; |
|
774 | + if (!empty($user_info['id'])) { |
|
775 | + updateMemberData($user_info['id'], array('lngfile' => $user_info['language'])); |
|
776 | + } else { |
|
777 | + $_SESSION['language'] = $user_info['language']; |
|
778 | + } |
|
779 | + } elseif (!empty($_SESSION['language']) && isset($languages[strtr($_SESSION['language'], './\\:', '____')])) { |
|
780 | + $user_info['language'] = strtr($_SESSION['language'], './\\:', '____'); |
|
745 | 781 | } |
746 | - elseif (!empty($_SESSION['language']) && isset($languages[strtr($_SESSION['language'], './\\:', '____')])) |
|
747 | - $user_info['language'] = strtr($_SESSION['language'], './\\:', '____'); |
|
748 | 782 | } |
749 | 783 | |
750 | 784 | $temp = build_query_board($user_info['id']); |
@@ -807,9 +841,9 @@ discard block |
||
807 | 841 | } |
808 | 842 | |
809 | 843 | // Remember redirection is the key to avoiding fallout from your bosses. |
810 | - if (!empty($topic)) |
|
811 | - redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg']); |
|
812 | - else |
|
844 | + if (!empty($topic)) { |
|
845 | + redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg']); |
|
846 | + } else |
|
813 | 847 | { |
814 | 848 | loadPermissions(); |
815 | 849 | loadTheme(); |
@@ -827,10 +861,11 @@ discard block |
||
827 | 861 | if (!empty($modSettings['cache_enable']) && (empty($topic) || $modSettings['cache_enable'] >= 3)) |
828 | 862 | { |
829 | 863 | // @todo SLOW? |
830 | - if (!empty($topic)) |
|
831 | - $temp = cache_get_data('topic_board-' . $topic, 120); |
|
832 | - else |
|
833 | - $temp = cache_get_data('board-' . $board, 120); |
|
864 | + if (!empty($topic)) { |
|
865 | + $temp = cache_get_data('topic_board-' . $topic, 120); |
|
866 | + } else { |
|
867 | + $temp = cache_get_data('board-' . $board, 120); |
|
868 | + } |
|
834 | 869 | |
835 | 870 | if (!empty($temp)) |
836 | 871 | { |
@@ -868,8 +903,9 @@ discard block |
||
868 | 903 | $row = $smcFunc['db_fetch_assoc']($request); |
869 | 904 | |
870 | 905 | // Set the current board. |
871 | - if (!empty($row['id_board'])) |
|
872 | - $board = $row['id_board']; |
|
906 | + if (!empty($row['id_board'])) { |
|
907 | + $board = $row['id_board']; |
|
908 | + } |
|
873 | 909 | |
874 | 910 | // Basic operating information. (globals... :/) |
875 | 911 | $board_info = array( |
@@ -905,21 +941,23 @@ discard block |
||
905 | 941 | |
906 | 942 | do |
907 | 943 | { |
908 | - if (!empty($row['id_moderator'])) |
|
909 | - $board_info['moderators'][$row['id_moderator']] = array( |
|
944 | + if (!empty($row['id_moderator'])) { |
|
945 | + $board_info['moderators'][$row['id_moderator']] = array( |
|
910 | 946 | 'id' => $row['id_moderator'], |
911 | 947 | 'name' => $row['real_name'], |
912 | 948 | 'href' => $scripturl . '?action=profile;u=' . $row['id_moderator'], |
913 | 949 | 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_moderator'] . '">' . $row['real_name'] . '</a>' |
914 | 950 | ); |
951 | + } |
|
915 | 952 | |
916 | - if (!empty($row['id_moderator_group'])) |
|
917 | - $board_info['moderator_groups'][$row['id_moderator_group']] = array( |
|
953 | + if (!empty($row['id_moderator_group'])) { |
|
954 | + $board_info['moderator_groups'][$row['id_moderator_group']] = array( |
|
918 | 955 | 'id' => $row['id_moderator_group'], |
919 | 956 | 'name' => $row['group_name'], |
920 | 957 | 'href' => $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'], |
921 | 958 | 'link' => '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'] . '">' . $row['group_name'] . '</a>' |
922 | 959 | ); |
960 | + } |
|
923 | 961 | } |
924 | 962 | while ($row = $smcFunc['db_fetch_assoc']($request)); |
925 | 963 | |
@@ -951,12 +989,12 @@ discard block |
||
951 | 989 | if (!empty($modSettings['cache_enable']) && (empty($topic) || $modSettings['cache_enable'] >= 3)) |
952 | 990 | { |
953 | 991 | // @todo SLOW? |
954 | - if (!empty($topic)) |
|
955 | - cache_put_data('topic_board-' . $topic, $board_info, 120); |
|
992 | + if (!empty($topic)) { |
|
993 | + cache_put_data('topic_board-' . $topic, $board_info, 120); |
|
994 | + } |
|
956 | 995 | cache_put_data('board-' . $board, $board_info, 120); |
957 | 996 | } |
958 | - } |
|
959 | - else |
|
997 | + } else |
|
960 | 998 | { |
961 | 999 | // Otherwise the topic is invalid, there are no moderators, etc. |
962 | 1000 | $board_info = array( |
@@ -970,8 +1008,9 @@ discard block |
||
970 | 1008 | $smcFunc['db_free_result']($request); |
971 | 1009 | } |
972 | 1010 | |
973 | - if (!empty($topic)) |
|
974 | - $_GET['board'] = (int) $board; |
|
1011 | + if (!empty($topic)) { |
|
1012 | + $_GET['board'] = (int) $board; |
|
1013 | + } |
|
975 | 1014 | |
976 | 1015 | if (!empty($board)) |
977 | 1016 | { |
@@ -981,10 +1020,12 @@ discard block |
||
981 | 1020 | // Now check if the user is a moderator. |
982 | 1021 | $user_info['is_mod'] = isset($board_info['moderators'][$user_info['id']]) || count(array_intersect($user_info['groups'], $moderator_groups)) != 0; |
983 | 1022 | |
984 | - if (count(array_intersect($user_info['groups'], $board_info['groups'])) == 0 && !$user_info['is_admin']) |
|
985 | - $board_info['error'] = 'access'; |
|
986 | - if (!empty($modSettings['deny_boards_access']) && count(array_intersect($user_info['groups'], $board_info['deny_groups'])) != 0 && !$user_info['is_admin']) |
|
987 | - $board_info['error'] = 'access'; |
|
1023 | + if (count(array_intersect($user_info['groups'], $board_info['groups'])) == 0 && !$user_info['is_admin']) { |
|
1024 | + $board_info['error'] = 'access'; |
|
1025 | + } |
|
1026 | + if (!empty($modSettings['deny_boards_access']) && count(array_intersect($user_info['groups'], $board_info['deny_groups'])) != 0 && !$user_info['is_admin']) { |
|
1027 | + $board_info['error'] = 'access'; |
|
1028 | + } |
|
988 | 1029 | |
989 | 1030 | // Build up the linktree. |
990 | 1031 | $context['linktree'] = array_merge( |
@@ -1007,8 +1048,9 @@ discard block |
||
1007 | 1048 | $context['current_board'] = $board; |
1008 | 1049 | |
1009 | 1050 | // No posting in redirection boards! |
1010 | - if (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'post' && !empty($board_info['redirect'])) |
|
1011 | - $board_info['error'] == 'post_in_redirect'; |
|
1051 | + if (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'post' && !empty($board_info['redirect'])) { |
|
1052 | + $board_info['error'] == 'post_in_redirect'; |
|
1053 | + } |
|
1012 | 1054 | |
1013 | 1055 | // Hacker... you can't see this topic, I'll tell you that. (but moderators can!) |
1014 | 1056 | if (!empty($board_info['error']) && (!empty($modSettings['deny_boards_access']) || $board_info['error'] != 'access' || !$user_info['is_mod'])) |
@@ -1034,24 +1076,23 @@ discard block |
||
1034 | 1076 | ob_end_clean(); |
1035 | 1077 | header('HTTP/1.1 403 Forbidden'); |
1036 | 1078 | die; |
1037 | - } |
|
1038 | - elseif ($board_info['error'] == 'post_in_redirect') |
|
1079 | + } elseif ($board_info['error'] == 'post_in_redirect') |
|
1039 | 1080 | { |
1040 | 1081 | // Slightly different error message here... |
1041 | 1082 | fatal_lang_error('cannot_post_redirect', false); |
1042 | - } |
|
1043 | - elseif ($user_info['is_guest']) |
|
1083 | + } elseif ($user_info['is_guest']) |
|
1044 | 1084 | { |
1045 | 1085 | loadLanguage('Errors'); |
1046 | 1086 | is_not_guest($txt['topic_gone']); |
1087 | + } else { |
|
1088 | + fatal_lang_error('topic_gone', false); |
|
1047 | 1089 | } |
1048 | - else |
|
1049 | - fatal_lang_error('topic_gone', false); |
|
1050 | 1090 | } |
1051 | 1091 | |
1052 | - if ($user_info['is_mod']) |
|
1053 | - $user_info['groups'][] = 3; |
|
1054 | -} |
|
1092 | + if ($user_info['is_mod']) { |
|
1093 | + $user_info['groups'][] = 3; |
|
1094 | + } |
|
1095 | + } |
|
1055 | 1096 | |
1056 | 1097 | /** |
1057 | 1098 | * Load this user's permissions. |
@@ -1072,8 +1113,9 @@ discard block |
||
1072 | 1113 | asort($cache_groups); |
1073 | 1114 | $cache_groups = implode(',', $cache_groups); |
1074 | 1115 | // If it's a spider then cache it different. |
1075 | - if ($user_info['possibly_robot']) |
|
1076 | - $cache_groups .= '-spider'; |
|
1116 | + if ($user_info['possibly_robot']) { |
|
1117 | + $cache_groups .= '-spider'; |
|
1118 | + } |
|
1077 | 1119 | |
1078 | 1120 | if ($modSettings['cache_enable'] >= 2 && !empty($board) && ($temp = cache_get_data('permissions:' . $cache_groups . ':' . $board, 240)) != null && time() - 240 > $modSettings['settings_updated']) |
1079 | 1121 | { |
@@ -1081,9 +1123,9 @@ discard block |
||
1081 | 1123 | banPermissions(); |
1082 | 1124 | |
1083 | 1125 | return; |
1126 | + } elseif (($temp = cache_get_data('permissions:' . $cache_groups, 240)) != null && time() - 240 > $modSettings['settings_updated']) { |
|
1127 | + list ($user_info['permissions'], $removals) = $temp; |
|
1084 | 1128 | } |
1085 | - elseif (($temp = cache_get_data('permissions:' . $cache_groups, 240)) != null && time() - 240 > $modSettings['settings_updated']) |
|
1086 | - list ($user_info['permissions'], $removals) = $temp; |
|
1087 | 1129 | } |
1088 | 1130 | |
1089 | 1131 | // If it is detected as a robot, and we are restricting permissions as a special group - then implement this. |
@@ -1105,23 +1147,26 @@ discard block |
||
1105 | 1147 | $removals = array(); |
1106 | 1148 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1107 | 1149 | { |
1108 | - if (empty($row['add_deny'])) |
|
1109 | - $removals[] = $row['permission']; |
|
1110 | - else |
|
1111 | - $user_info['permissions'][] = $row['permission']; |
|
1150 | + if (empty($row['add_deny'])) { |
|
1151 | + $removals[] = $row['permission']; |
|
1152 | + } else { |
|
1153 | + $user_info['permissions'][] = $row['permission']; |
|
1154 | + } |
|
1112 | 1155 | } |
1113 | 1156 | $smcFunc['db_free_result']($request); |
1114 | 1157 | |
1115 | - if (isset($cache_groups)) |
|
1116 | - cache_put_data('permissions:' . $cache_groups, array($user_info['permissions'], $removals), 240); |
|
1158 | + if (isset($cache_groups)) { |
|
1159 | + cache_put_data('permissions:' . $cache_groups, array($user_info['permissions'], $removals), 240); |
|
1160 | + } |
|
1117 | 1161 | } |
1118 | 1162 | |
1119 | 1163 | // Get the board permissions. |
1120 | 1164 | if (!empty($board)) |
1121 | 1165 | { |
1122 | 1166 | // Make sure the board (if any) has been loaded by loadBoard(). |
1123 | - if (!isset($board_info['profile'])) |
|
1124 | - fatal_lang_error('no_board'); |
|
1167 | + if (!isset($board_info['profile'])) { |
|
1168 | + fatal_lang_error('no_board'); |
|
1169 | + } |
|
1125 | 1170 | |
1126 | 1171 | $request = $smcFunc['db_query']('', ' |
1127 | 1172 | SELECT permission, add_deny |
@@ -1137,20 +1182,23 @@ discard block |
||
1137 | 1182 | ); |
1138 | 1183 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1139 | 1184 | { |
1140 | - if (empty($row['add_deny'])) |
|
1141 | - $removals[] = $row['permission']; |
|
1142 | - else |
|
1143 | - $user_info['permissions'][] = $row['permission']; |
|
1185 | + if (empty($row['add_deny'])) { |
|
1186 | + $removals[] = $row['permission']; |
|
1187 | + } else { |
|
1188 | + $user_info['permissions'][] = $row['permission']; |
|
1189 | + } |
|
1144 | 1190 | } |
1145 | 1191 | $smcFunc['db_free_result']($request); |
1146 | 1192 | } |
1147 | 1193 | |
1148 | 1194 | // Remove all the permissions they shouldn't have ;). |
1149 | - if (!empty($modSettings['permission_enable_deny'])) |
|
1150 | - $user_info['permissions'] = array_diff($user_info['permissions'], $removals); |
|
1195 | + if (!empty($modSettings['permission_enable_deny'])) { |
|
1196 | + $user_info['permissions'] = array_diff($user_info['permissions'], $removals); |
|
1197 | + } |
|
1151 | 1198 | |
1152 | - if (isset($cache_groups) && !empty($board) && $modSettings['cache_enable'] >= 2) |
|
1153 | - cache_put_data('permissions:' . $cache_groups . ':' . $board, array($user_info['permissions'], null), 240); |
|
1199 | + if (isset($cache_groups) && !empty($board) && $modSettings['cache_enable'] >= 2) { |
|
1200 | + cache_put_data('permissions:' . $cache_groups . ':' . $board, array($user_info['permissions'], null), 240); |
|
1201 | + } |
|
1154 | 1202 | |
1155 | 1203 | // Banned? Watch, don't touch.. |
1156 | 1204 | banPermissions(); |
@@ -1162,17 +1210,18 @@ discard block |
||
1162 | 1210 | { |
1163 | 1211 | require_once($sourcedir . '/Subs-Auth.php'); |
1164 | 1212 | rebuildModCache(); |
1213 | + } else { |
|
1214 | + $user_info['mod_cache'] = $_SESSION['mc']; |
|
1165 | 1215 | } |
1166 | - else |
|
1167 | - $user_info['mod_cache'] = $_SESSION['mc']; |
|
1168 | 1216 | |
1169 | 1217 | // This is a useful phantom permission added to the current user, and only the current user while they are logged in. |
1170 | 1218 | // For example this drastically simplifies certain changes to the profile area. |
1171 | 1219 | $user_info['permissions'][] = 'is_not_guest'; |
1172 | 1220 | // And now some backwards compatibility stuff for mods and whatnot that aren't expecting the new permissions. |
1173 | 1221 | $user_info['permissions'][] = 'profile_view_own'; |
1174 | - if (in_array('profile_view', $user_info['permissions'])) |
|
1175 | - $user_info['permissions'][] = 'profile_view_any'; |
|
1222 | + if (in_array('profile_view', $user_info['permissions'])) { |
|
1223 | + $user_info['permissions'][] = 'profile_view_any'; |
|
1224 | + } |
|
1176 | 1225 | } |
1177 | 1226 | } |
1178 | 1227 | |
@@ -1190,8 +1239,9 @@ discard block |
||
1190 | 1239 | global $image_proxy_enabled, $image_proxy_secret, $boardurl; |
1191 | 1240 | |
1192 | 1241 | // Can't just look for no users :P. |
1193 | - if (empty($users)) |
|
1194 | - return array(); |
|
1242 | + if (empty($users)) { |
|
1243 | + return array(); |
|
1244 | + } |
|
1195 | 1245 | |
1196 | 1246 | // Pass the set value |
1197 | 1247 | $context['loadMemberContext_set'] = $set; |
@@ -1206,8 +1256,9 @@ discard block |
||
1206 | 1256 | for ($i = 0, $n = count($users); $i < $n; $i++) |
1207 | 1257 | { |
1208 | 1258 | $data = cache_get_data('member_data-' . $set . '-' . $users[$i], 240); |
1209 | - if ($data == null) |
|
1210 | - continue; |
|
1259 | + if ($data == null) { |
|
1260 | + continue; |
|
1261 | + } |
|
1211 | 1262 | |
1212 | 1263 | $loaded_ids[] = $data['id_member']; |
1213 | 1264 | $user_profile[$data['id_member']] = $data; |
@@ -1274,16 +1325,19 @@ discard block |
||
1274 | 1325 | $row['avatar_original'] = !empty($row['avatar']) ? $row['avatar'] : ''; |
1275 | 1326 | |
1276 | 1327 | // Take care of proxying avatar if required, do this here for maximum reach |
1277 | - if ($image_proxy_enabled && !empty($row['avatar']) && stripos($row['avatar'], 'http://') !== false) |
|
1278 | - $row['avatar'] = $boardurl . '/proxy.php?request=' . urlencode($row['avatar']) . '&hash=' . md5($row['avatar'] . $image_proxy_secret); |
|
1328 | + if ($image_proxy_enabled && !empty($row['avatar']) && stripos($row['avatar'], 'http://') !== false) { |
|
1329 | + $row['avatar'] = $boardurl . '/proxy.php?request=' . urlencode($row['avatar']) . '&hash=' . md5($row['avatar'] . $image_proxy_secret); |
|
1330 | + } |
|
1279 | 1331 | |
1280 | 1332 | // Keep track of the member's normal member group |
1281 | 1333 | $row['primary_group'] = $row['member_group']; |
1282 | 1334 | |
1283 | - if (isset($row['member_ip'])) |
|
1284 | - $row['member_ip'] = inet_dtop($row['member_ip']); |
|
1285 | - if (isset($row['member_ip2'])) |
|
1286 | - $row['member_ip2'] = inet_dtop($row['member_ip2']); |
|
1335 | + if (isset($row['member_ip'])) { |
|
1336 | + $row['member_ip'] = inet_dtop($row['member_ip']); |
|
1337 | + } |
|
1338 | + if (isset($row['member_ip2'])) { |
|
1339 | + $row['member_ip2'] = inet_dtop($row['member_ip2']); |
|
1340 | + } |
|
1287 | 1341 | $new_loaded_ids[] = $row['id_member']; |
1288 | 1342 | $loaded_ids[] = $row['id_member']; |
1289 | 1343 | $row['options'] = array(); |
@@ -1302,8 +1356,9 @@ discard block |
||
1302 | 1356 | 'loaded_ids' => $new_loaded_ids, |
1303 | 1357 | ) |
1304 | 1358 | ); |
1305 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1306 | - $user_profile[$row['id_member']]['options'][$row['variable']] = $row['value']; |
|
1359 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1360 | + $user_profile[$row['id_member']]['options'][$row['variable']] = $row['value']; |
|
1361 | + } |
|
1307 | 1362 | $smcFunc['db_free_result']($request); |
1308 | 1363 | } |
1309 | 1364 | |
@@ -1314,10 +1369,11 @@ discard block |
||
1314 | 1369 | { |
1315 | 1370 | foreach ($loaded_ids as $a_member) |
1316 | 1371 | { |
1317 | - if (!empty($user_profile[$a_member]['additional_groups'])) |
|
1318 | - $groups = array_merge(array($user_profile[$a_member]['id_group']), explode(',', $user_profile[$a_member]['additional_groups'])); |
|
1319 | - else |
|
1320 | - $groups = array($user_profile[$a_member]['id_group']); |
|
1372 | + if (!empty($user_profile[$a_member]['additional_groups'])) { |
|
1373 | + $groups = array_merge(array($user_profile[$a_member]['id_group']), explode(',', $user_profile[$a_member]['additional_groups'])); |
|
1374 | + } else { |
|
1375 | + $groups = array($user_profile[$a_member]['id_group']); |
|
1376 | + } |
|
1321 | 1377 | |
1322 | 1378 | $temp = array_intersect($groups, array_keys($board_info['moderator_groups'])); |
1323 | 1379 | |
@@ -1330,8 +1386,9 @@ discard block |
||
1330 | 1386 | |
1331 | 1387 | if (!empty($new_loaded_ids) && !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 3) |
1332 | 1388 | { |
1333 | - for ($i = 0, $n = count($new_loaded_ids); $i < $n; $i++) |
|
1334 | - cache_put_data('member_data-' . $set . '-' . $new_loaded_ids[$i], $user_profile[$new_loaded_ids[$i]], 240); |
|
1389 | + for ($i = 0, $n = count($new_loaded_ids); $i < $n; $i++) { |
|
1390 | + cache_put_data('member_data-' . $set . '-' . $new_loaded_ids[$i], $user_profile[$new_loaded_ids[$i]], 240); |
|
1391 | + } |
|
1335 | 1392 | } |
1336 | 1393 | |
1337 | 1394 | // Are we loading any moderators? If so, fix their group data... |
@@ -1357,14 +1414,17 @@ discard block |
||
1357 | 1414 | foreach ($temp_mods as $id) |
1358 | 1415 | { |
1359 | 1416 | // By popular demand, don't show admins or global moderators as moderators. |
1360 | - if ($user_profile[$id]['id_group'] != 1 && $user_profile[$id]['id_group'] != 2) |
|
1361 | - $user_profile[$id]['member_group'] = $row['member_group']; |
|
1417 | + if ($user_profile[$id]['id_group'] != 1 && $user_profile[$id]['id_group'] != 2) { |
|
1418 | + $user_profile[$id]['member_group'] = $row['member_group']; |
|
1419 | + } |
|
1362 | 1420 | |
1363 | 1421 | // If the Moderator group has no color or icons, but their group does... don't overwrite. |
1364 | - if (!empty($row['icons'])) |
|
1365 | - $user_profile[$id]['icons'] = $row['icons']; |
|
1366 | - if (!empty($row['member_group_color'])) |
|
1367 | - $user_profile[$id]['member_group_color'] = $row['member_group_color']; |
|
1422 | + if (!empty($row['icons'])) { |
|
1423 | + $user_profile[$id]['icons'] = $row['icons']; |
|
1424 | + } |
|
1425 | + if (!empty($row['member_group_color'])) { |
|
1426 | + $user_profile[$id]['member_group_color'] = $row['member_group_color']; |
|
1427 | + } |
|
1368 | 1428 | } |
1369 | 1429 | } |
1370 | 1430 | |
@@ -1386,12 +1446,14 @@ discard block |
||
1386 | 1446 | static $loadedLanguages = array(); |
1387 | 1447 | |
1388 | 1448 | // If this person's data is already loaded, skip it. |
1389 | - if (isset($dataLoaded[$user])) |
|
1390 | - return true; |
|
1449 | + if (isset($dataLoaded[$user])) { |
|
1450 | + return true; |
|
1451 | + } |
|
1391 | 1452 | |
1392 | 1453 | // We can't load guests or members not loaded by loadMemberData()! |
1393 | - if ($user == 0) |
|
1394 | - return false; |
|
1454 | + if ($user == 0) { |
|
1455 | + return false; |
|
1456 | + } |
|
1395 | 1457 | if (!isset($user_profile[$user])) |
1396 | 1458 | { |
1397 | 1459 | trigger_error('loadMemberContext(): member id ' . $user . ' not previously loaded by loadMemberData()', E_USER_WARNING); |
@@ -1417,12 +1479,16 @@ discard block |
||
1417 | 1479 | $buddy_list = !empty($profile['buddy_list']) ? explode(',', $profile['buddy_list']) : array(); |
1418 | 1480 | |
1419 | 1481 | //We need a little fallback for the membergroup icons. If it doesn't exist in the current theme, fallback to default theme |
1420 | - if (isset($profile['icons'][1]) && file_exists($settings['actual_theme_dir'] . '/images/membericons/' . $profile['icons'][1])) //icon is set and exists |
|
1482 | + if (isset($profile['icons'][1]) && file_exists($settings['actual_theme_dir'] . '/images/membericons/' . $profile['icons'][1])) { |
|
1483 | + //icon is set and exists |
|
1421 | 1484 | $group_icon_url = $settings['images_url'] . '/membericons/' . $profile['icons'][1]; |
1422 | - elseif (isset($profile['icons'][1])) //icon is set and doesn't exist, fallback to default |
|
1485 | + } elseif (isset($profile['icons'][1])) { |
|
1486 | + //icon is set and doesn't exist, fallback to default |
|
1423 | 1487 | $group_icon_url = $settings['default_images_url'] . '/membericons/' . $profile['icons'][1]; |
1424 | - else //not set, bye bye |
|
1488 | + } else { |
|
1489 | + //not set, bye bye |
|
1425 | 1490 | $group_icon_url = ''; |
1491 | + } |
|
1426 | 1492 | |
1427 | 1493 | // These minimal values are always loaded |
1428 | 1494 | $memberContext[$user] = array( |
@@ -1441,8 +1507,9 @@ discard block |
||
1441 | 1507 | if ($context['loadMemberContext_set'] != 'minimal') |
1442 | 1508 | { |
1443 | 1509 | // Go the extra mile and load the user's native language name. |
1444 | - if (empty($loadedLanguages)) |
|
1445 | - $loadedLanguages = getLanguages(); |
|
1510 | + if (empty($loadedLanguages)) { |
|
1511 | + $loadedLanguages = getLanguages(); |
|
1512 | + } |
|
1446 | 1513 | |
1447 | 1514 | $memberContext[$user] += array( |
1448 | 1515 | 'username_color' => '<span ' . (!empty($profile['member_group_color']) ? 'style="color:' . $profile['member_group_color'] . ';"' : '') . '>' . $profile['member_name'] . '</span>', |
@@ -1497,31 +1564,33 @@ discard block |
||
1497 | 1564 | { |
1498 | 1565 | if (!empty($modSettings['gravatarOverride']) || (!empty($modSettings['gravatarEnabled']) && stristr($profile['avatar'], 'gravatar://'))) |
1499 | 1566 | { |
1500 | - if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($profile['avatar'], 'gravatar://') && strlen($profile['avatar']) > 11) |
|
1501 | - $image = get_gravatar_url($smcFunc['substr']($profile['avatar'], 11)); |
|
1502 | - else |
|
1503 | - $image = get_gravatar_url($profile['email_address']); |
|
1504 | - } |
|
1505 | - else |
|
1567 | + if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($profile['avatar'], 'gravatar://') && strlen($profile['avatar']) > 11) { |
|
1568 | + $image = get_gravatar_url($smcFunc['substr']($profile['avatar'], 11)); |
|
1569 | + } else { |
|
1570 | + $image = get_gravatar_url($profile['email_address']); |
|
1571 | + } |
|
1572 | + } else |
|
1506 | 1573 | { |
1507 | 1574 | // So it's stored in the member table? |
1508 | 1575 | if (!empty($profile['avatar'])) |
1509 | 1576 | { |
1510 | 1577 | $image = (stristr($profile['avatar'], 'http://') || stristr($profile['avatar'], 'https://')) ? $profile['avatar'] : $modSettings['avatar_url'] . '/' . $profile['avatar']; |
1578 | + } elseif (!empty($profile['filename'])) { |
|
1579 | + $image = $modSettings['custom_avatar_url'] . '/' . $profile['filename']; |
|
1511 | 1580 | } |
1512 | - elseif (!empty($profile['filename'])) |
|
1513 | - $image = $modSettings['custom_avatar_url'] . '/' . $profile['filename']; |
|
1514 | 1581 | // Right... no avatar...use the default one |
1515 | - else |
|
1516 | - $image = $modSettings['avatar_url'] . '/default.png'; |
|
1582 | + else { |
|
1583 | + $image = $modSettings['avatar_url'] . '/default.png'; |
|
1584 | + } |
|
1517 | 1585 | } |
1518 | - if (!empty($image)) |
|
1519 | - $memberContext[$user]['avatar'] = array( |
|
1586 | + if (!empty($image)) { |
|
1587 | + $memberContext[$user]['avatar'] = array( |
|
1520 | 1588 | 'name' => $profile['avatar'], |
1521 | 1589 | 'image' => '<img class="avatar" src="' . $image . '" alt="avatar_' . $profile['member_name'] . '">', |
1522 | 1590 | 'href' => $image, |
1523 | 1591 | 'url' => $image, |
1524 | 1592 | ); |
1593 | + } |
|
1525 | 1594 | } |
1526 | 1595 | |
1527 | 1596 | // Are we also loading the members custom fields into context? |
@@ -1529,35 +1598,41 @@ discard block |
||
1529 | 1598 | { |
1530 | 1599 | $memberContext[$user]['custom_fields'] = array(); |
1531 | 1600 | |
1532 | - if (!isset($context['display_fields'])) |
|
1533 | - $context['display_fields'] = $smcFunc['json_decode']($modSettings['displayFields'], true); |
|
1601 | + if (!isset($context['display_fields'])) { |
|
1602 | + $context['display_fields'] = $smcFunc['json_decode']($modSettings['displayFields'], true); |
|
1603 | + } |
|
1534 | 1604 | |
1535 | 1605 | foreach ($context['display_fields'] as $custom) |
1536 | 1606 | { |
1537 | - if (!isset($custom['col_name']) || trim($custom['col_name']) == '' || empty($profile['options'][$custom['col_name']])) |
|
1538 | - continue; |
|
1607 | + if (!isset($custom['col_name']) || trim($custom['col_name']) == '' || empty($profile['options'][$custom['col_name']])) { |
|
1608 | + continue; |
|
1609 | + } |
|
1539 | 1610 | |
1540 | 1611 | $value = $profile['options'][$custom['col_name']]; |
1541 | 1612 | |
1542 | 1613 | // Don't show the "disabled" option for the "gender" field. |
1543 | - if ($custom['col_name'] == 'cust_gender' && $value == 'Disabled') |
|
1544 | - continue; |
|
1614 | + if ($custom['col_name'] == 'cust_gender' && $value == 'Disabled') { |
|
1615 | + continue; |
|
1616 | + } |
|
1545 | 1617 | |
1546 | 1618 | // BBC? |
1547 | - if ($custom['bbc']) |
|
1548 | - $value = parse_bbc($value); |
|
1619 | + if ($custom['bbc']) { |
|
1620 | + $value = parse_bbc($value); |
|
1621 | + } |
|
1549 | 1622 | // ... or checkbox? |
1550 | - elseif (isset($custom['type']) && $custom['type'] == 'check') |
|
1551 | - $value = $value ? $txt['yes'] : $txt['no']; |
|
1623 | + elseif (isset($custom['type']) && $custom['type'] == 'check') { |
|
1624 | + $value = $value ? $txt['yes'] : $txt['no']; |
|
1625 | + } |
|
1552 | 1626 | |
1553 | 1627 | // Enclosing the user input within some other text? |
1554 | - if (!empty($custom['enclose'])) |
|
1555 | - $value = strtr($custom['enclose'], array( |
|
1628 | + if (!empty($custom['enclose'])) { |
|
1629 | + $value = strtr($custom['enclose'], array( |
|
1556 | 1630 | '{SCRIPTURL}' => $scripturl, |
1557 | 1631 | '{IMAGES_URL}' => $settings['images_url'], |
1558 | 1632 | '{DEFAULT_IMAGES_URL}' => $settings['default_images_url'], |
1559 | 1633 | '{INPUT}' => $value, |
1560 | 1634 | )); |
1635 | + } |
|
1561 | 1636 | |
1562 | 1637 | $memberContext[$user]['custom_fields'][] = array( |
1563 | 1638 | 'title' => !empty($custom['title']) ? $custom['title'] : $custom['col_name'], |
@@ -1584,8 +1659,9 @@ discard block |
||
1584 | 1659 | global $smcFunc, $txt, $scripturl, $settings; |
1585 | 1660 | |
1586 | 1661 | // Do not waste my time... |
1587 | - if (empty($users) || empty($params)) |
|
1588 | - return false; |
|
1662 | + if (empty($users) || empty($params)) { |
|
1663 | + return false; |
|
1664 | + } |
|
1589 | 1665 | |
1590 | 1666 | // Make sure it's an array. |
1591 | 1667 | $users = !is_array($users) ? array($users) : array_unique($users); |
@@ -1609,31 +1685,36 @@ discard block |
||
1609 | 1685 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1610 | 1686 | { |
1611 | 1687 | // BBC? |
1612 | - if (!empty($row['bbc'])) |
|
1613 | - $row['value'] = parse_bbc($row['value']); |
|
1688 | + if (!empty($row['bbc'])) { |
|
1689 | + $row['value'] = parse_bbc($row['value']); |
|
1690 | + } |
|
1614 | 1691 | |
1615 | 1692 | // ... or checkbox? |
1616 | - elseif (isset($row['type']) && $row['type'] == 'check') |
|
1617 | - $row['value'] = !empty($row['value']) ? $txt['yes'] : $txt['no']; |
|
1693 | + elseif (isset($row['type']) && $row['type'] == 'check') { |
|
1694 | + $row['value'] = !empty($row['value']) ? $txt['yes'] : $txt['no']; |
|
1695 | + } |
|
1618 | 1696 | |
1619 | 1697 | // Enclosing the user input within some other text? |
1620 | - if (!empty($row['enclose'])) |
|
1621 | - $row['value'] = strtr($row['enclose'], array( |
|
1698 | + if (!empty($row['enclose'])) { |
|
1699 | + $row['value'] = strtr($row['enclose'], array( |
|
1622 | 1700 | '{SCRIPTURL}' => $scripturl, |
1623 | 1701 | '{IMAGES_URL}' => $settings['images_url'], |
1624 | 1702 | '{DEFAULT_IMAGES_URL}' => $settings['default_images_url'], |
1625 | 1703 | '{INPUT}' => un_htmlspecialchars($row['value']), |
1626 | 1704 | )); |
1705 | + } |
|
1627 | 1706 | |
1628 | 1707 | // Send a simple array if there is just 1 param |
1629 | - if (count($params) == 1) |
|
1630 | - $return[$row['id_member']] = $row; |
|
1708 | + if (count($params) == 1) { |
|
1709 | + $return[$row['id_member']] = $row; |
|
1710 | + } |
|
1631 | 1711 | |
1632 | 1712 | // More than 1? knock yourself out... |
1633 | 1713 | else |
1634 | 1714 | { |
1635 | - if (!isset($return[$row['id_member']])) |
|
1636 | - $return[$row['id_member']] = array(); |
|
1715 | + if (!isset($return[$row['id_member']])) { |
|
1716 | + $return[$row['id_member']] = array(); |
|
1717 | + } |
|
1637 | 1718 | |
1638 | 1719 | $return[$row['id_member']][$row['variable']] = $row; |
1639 | 1720 | } |
@@ -1667,8 +1748,9 @@ discard block |
||
1667 | 1748 | global $context; |
1668 | 1749 | |
1669 | 1750 | // Don't know any browser! |
1670 | - if (empty($context['browser'])) |
|
1671 | - detectBrowser(); |
|
1751 | + if (empty($context['browser'])) { |
|
1752 | + detectBrowser(); |
|
1753 | + } |
|
1672 | 1754 | |
1673 | 1755 | return !empty($context['browser'][$browser]) || !empty($context['browser']['is_' . $browser]) ? true : false; |
1674 | 1756 | } |
@@ -1686,8 +1768,9 @@ discard block |
||
1686 | 1768 | global $context, $settings, $options, $sourcedir, $ssi_theme, $smcFunc, $language, $board, $image_proxy_enabled; |
1687 | 1769 | |
1688 | 1770 | // The theme was specified by parameter. |
1689 | - if (!empty($id_theme)) |
|
1690 | - $id_theme = (int) $id_theme; |
|
1771 | + if (!empty($id_theme)) { |
|
1772 | + $id_theme = (int) $id_theme; |
|
1773 | + } |
|
1691 | 1774 | // The theme was specified by REQUEST. |
1692 | 1775 | elseif (!empty($_REQUEST['theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum'))) |
1693 | 1776 | { |
@@ -1695,54 +1778,61 @@ discard block |
||
1695 | 1778 | $_SESSION['id_theme'] = $id_theme; |
1696 | 1779 | } |
1697 | 1780 | // The theme was specified by REQUEST... previously. |
1698 | - elseif (!empty($_SESSION['id_theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum'))) |
|
1699 | - $id_theme = (int) $_SESSION['id_theme']; |
|
1781 | + elseif (!empty($_SESSION['id_theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum'))) { |
|
1782 | + $id_theme = (int) $_SESSION['id_theme']; |
|
1783 | + } |
|
1700 | 1784 | // The theme is just the user's choice. (might use ?board=1;theme=0 to force board theme.) |
1701 | - elseif (!empty($user_info['theme']) && !isset($_REQUEST['theme'])) |
|
1702 | - $id_theme = $user_info['theme']; |
|
1785 | + elseif (!empty($user_info['theme']) && !isset($_REQUEST['theme'])) { |
|
1786 | + $id_theme = $user_info['theme']; |
|
1787 | + } |
|
1703 | 1788 | // The theme was specified by the board. |
1704 | - elseif (!empty($board_info['theme'])) |
|
1705 | - $id_theme = $board_info['theme']; |
|
1789 | + elseif (!empty($board_info['theme'])) { |
|
1790 | + $id_theme = $board_info['theme']; |
|
1791 | + } |
|
1706 | 1792 | // The theme is the forum's default. |
1707 | - else |
|
1708 | - $id_theme = $modSettings['theme_guests']; |
|
1793 | + else { |
|
1794 | + $id_theme = $modSettings['theme_guests']; |
|
1795 | + } |
|
1709 | 1796 | |
1710 | 1797 | // We already load the basic stuff? |
1711 | 1798 | if (empty($settings['theme_id']) || $settings['theme_id'] != $id_theme ) |
1712 | 1799 | { |
1713 | 1800 | // Verify the id_theme... no foul play. |
1714 | 1801 | // Always allow the board specific theme, if they are overriding. |
1715 | - if (!empty($board_info['theme']) && $board_info['override_theme']) |
|
1716 | - $id_theme = $board_info['theme']; |
|
1802 | + if (!empty($board_info['theme']) && $board_info['override_theme']) { |
|
1803 | + $id_theme = $board_info['theme']; |
|
1804 | + } |
|
1717 | 1805 | // If they have specified a particular theme to use with SSI allow it to be used. |
1718 | - elseif (!empty($ssi_theme) && $id_theme == $ssi_theme) |
|
1719 | - $id_theme = (int) $id_theme; |
|
1720 | - elseif (!empty($modSettings['enableThemes']) && !allowedTo('admin_forum')) |
|
1806 | + elseif (!empty($ssi_theme) && $id_theme == $ssi_theme) { |
|
1807 | + $id_theme = (int) $id_theme; |
|
1808 | + } elseif (!empty($modSettings['enableThemes']) && !allowedTo('admin_forum')) |
|
1721 | 1809 | { |
1722 | 1810 | $themes = explode(',', $modSettings['enableThemes']); |
1723 | - if (!in_array($id_theme, $themes)) |
|
1724 | - $id_theme = $modSettings['theme_guests']; |
|
1725 | - else |
|
1726 | - $id_theme = (int) $id_theme; |
|
1811 | + if (!in_array($id_theme, $themes)) { |
|
1812 | + $id_theme = $modSettings['theme_guests']; |
|
1813 | + } else { |
|
1814 | + $id_theme = (int) $id_theme; |
|
1815 | + } |
|
1816 | + } else { |
|
1817 | + $id_theme = (int) $id_theme; |
|
1727 | 1818 | } |
1728 | - else |
|
1729 | - $id_theme = (int) $id_theme; |
|
1730 | 1819 | |
1731 | 1820 | $member = empty($user_info['id']) ? -1 : $user_info['id']; |
1732 | 1821 | |
1733 | 1822 | // Disable image proxy if we don't have SSL enabled |
1734 | - if (empty($modSettings['force_ssl']) || $modSettings['force_ssl'] < 2) |
|
1735 | - $image_proxy_enabled = false; |
|
1823 | + if (empty($modSettings['force_ssl']) || $modSettings['force_ssl'] < 2) { |
|
1824 | + $image_proxy_enabled = false; |
|
1825 | + } |
|
1736 | 1826 | |
1737 | 1827 | 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']) |
1738 | 1828 | { |
1739 | 1829 | $themeData = $temp; |
1740 | 1830 | $flag = true; |
1831 | + } elseif (($temp = cache_get_data('theme_settings-' . $id_theme, 90)) != null && time() - 60 > $modSettings['settings_updated']) { |
|
1832 | + $themeData = $temp + array($member => array()); |
|
1833 | + } else { |
|
1834 | + $themeData = array(-1 => array(), 0 => array(), $member => array()); |
|
1741 | 1835 | } |
1742 | - elseif (($temp = cache_get_data('theme_settings-' . $id_theme, 90)) != null && time() - 60 > $modSettings['settings_updated']) |
|
1743 | - $themeData = $temp + array($member => array()); |
|
1744 | - else |
|
1745 | - $themeData = array(-1 => array(), 0 => array(), $member => array()); |
|
1746 | 1836 | |
1747 | 1837 | if (empty($flag)) |
1748 | 1838 | { |
@@ -1761,31 +1851,37 @@ discard block |
||
1761 | 1851 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
1762 | 1852 | { |
1763 | 1853 | // There are just things we shouldn't be able to change as members. |
1764 | - 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'))) |
|
1765 | - continue; |
|
1854 | + 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'))) { |
|
1855 | + continue; |
|
1856 | + } |
|
1766 | 1857 | |
1767 | 1858 | // If this is the theme_dir of the default theme, store it. |
1768 | - if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['id_theme'] == '1' && empty($row['id_member'])) |
|
1769 | - $themeData[0]['default_' . $row['variable']] = $row['value']; |
|
1859 | + if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['id_theme'] == '1' && empty($row['id_member'])) { |
|
1860 | + $themeData[0]['default_' . $row['variable']] = $row['value']; |
|
1861 | + } |
|
1770 | 1862 | |
1771 | 1863 | // If this isn't set yet, is a theme option, or is not the default theme.. |
1772 | - if (!isset($themeData[$row['id_member']][$row['variable']]) || $row['id_theme'] != '1') |
|
1773 | - $themeData[$row['id_member']][$row['variable']] = substr($row['variable'], 0, 5) == 'show_' ? $row['value'] == '1' : $row['value']; |
|
1864 | + if (!isset($themeData[$row['id_member']][$row['variable']]) || $row['id_theme'] != '1') { |
|
1865 | + $themeData[$row['id_member']][$row['variable']] = substr($row['variable'], 0, 5) == 'show_' ? $row['value'] == '1' : $row['value']; |
|
1866 | + } |
|
1774 | 1867 | } |
1775 | 1868 | $smcFunc['db_free_result']($result); |
1776 | 1869 | |
1777 | - if (!empty($themeData[-1])) |
|
1778 | - foreach ($themeData[-1] as $k => $v) |
|
1870 | + if (!empty($themeData[-1])) { |
|
1871 | + foreach ($themeData[-1] as $k => $v) |
|
1779 | 1872 | { |
1780 | 1873 | if (!isset($themeData[$member][$k])) |
1781 | 1874 | $themeData[$member][$k] = $v; |
1875 | + } |
|
1782 | 1876 | } |
1783 | 1877 | |
1784 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
1785 | - cache_put_data('theme_settings-' . $id_theme . ':' . $member, $themeData, 60); |
|
1878 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
1879 | + cache_put_data('theme_settings-' . $id_theme . ':' . $member, $themeData, 60); |
|
1880 | + } |
|
1786 | 1881 | // Only if we didn't already load that part of the cache... |
1787 | - elseif (!isset($temp)) |
|
1788 | - cache_put_data('theme_settings-' . $id_theme, array(-1 => $themeData[-1], 0 => $themeData[0]), 90); |
|
1882 | + elseif (!isset($temp)) { |
|
1883 | + cache_put_data('theme_settings-' . $id_theme, array(-1 => $themeData[-1], 0 => $themeData[0]), 90); |
|
1884 | + } |
|
1789 | 1885 | } |
1790 | 1886 | |
1791 | 1887 | $settings = $themeData[0]; |
@@ -1802,22 +1898,26 @@ discard block |
||
1802 | 1898 | $settings['template_dirs'][] = $settings['theme_dir']; |
1803 | 1899 | |
1804 | 1900 | // Based on theme (if there is one). |
1805 | - if (!empty($settings['base_theme_dir'])) |
|
1806 | - $settings['template_dirs'][] = $settings['base_theme_dir']; |
|
1901 | + if (!empty($settings['base_theme_dir'])) { |
|
1902 | + $settings['template_dirs'][] = $settings['base_theme_dir']; |
|
1903 | + } |
|
1807 | 1904 | |
1808 | 1905 | // Lastly the default theme. |
1809 | - if ($settings['theme_dir'] != $settings['default_theme_dir']) |
|
1810 | - $settings['template_dirs'][] = $settings['default_theme_dir']; |
|
1906 | + if ($settings['theme_dir'] != $settings['default_theme_dir']) { |
|
1907 | + $settings['template_dirs'][] = $settings['default_theme_dir']; |
|
1908 | + } |
|
1811 | 1909 | } |
1812 | 1910 | |
1813 | 1911 | |
1814 | - if (!$initialize) |
|
1815 | - return; |
|
1912 | + if (!$initialize) { |
|
1913 | + return; |
|
1914 | + } |
|
1816 | 1915 | |
1817 | 1916 | // Check to see if we're forcing SSL |
1818 | 1917 | if (!empty($modSettings['force_ssl']) && $modSettings['force_ssl'] == 2 && empty($maintenance) && |
1819 | - (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == 'off') && SMF != 'SSI') |
|
1820 | - redirectexit(strtr($_SERVER['REQUEST_URL'], array('http://' => 'https://'))); |
|
1918 | + (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == 'off') && SMF != 'SSI') { |
|
1919 | + redirectexit(strtr($_SERVER['REQUEST_URL'], array('http://' => 'https://'))); |
|
1920 | + } |
|
1821 | 1921 | |
1822 | 1922 | // Check to see if they're accessing it from the wrong place. |
1823 | 1923 | if (isset($_SERVER['HTTP_HOST']) || isset($_SERVER['SERVER_NAME'])) |
@@ -1825,8 +1925,9 @@ discard block |
||
1825 | 1925 | $detected_url = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ? 'https://' : 'http://'; |
1826 | 1926 | $detected_url .= empty($_SERVER['HTTP_HOST']) ? $_SERVER['SERVER_NAME'] . (empty($_SERVER['SERVER_PORT']) || $_SERVER['SERVER_PORT'] == '80' ? '' : ':' . $_SERVER['SERVER_PORT']) : $_SERVER['HTTP_HOST']; |
1827 | 1927 | $temp = preg_replace('~/' . basename($scripturl) . '(/.+)?$~', '', strtr(dirname($_SERVER['PHP_SELF']), '\\', '/')); |
1828 | - if ($temp != '/') |
|
1829 | - $detected_url .= $temp; |
|
1928 | + if ($temp != '/') { |
|
1929 | + $detected_url .= $temp; |
|
1930 | + } |
|
1830 | 1931 | } |
1831 | 1932 | if (isset($detected_url) && $detected_url != $boardurl) |
1832 | 1933 | { |
@@ -1838,8 +1939,9 @@ discard block |
||
1838 | 1939 | foreach ($aliases as $alias) |
1839 | 1940 | { |
1840 | 1941 | // Rip off all the boring parts, spaces, etc. |
1841 | - if ($detected_url == trim($alias) || strtr($detected_url, array('http://' => '', 'https://' => '')) == trim($alias)) |
|
1842 | - $do_fix = true; |
|
1942 | + if ($detected_url == trim($alias) || strtr($detected_url, array('http://' => '', 'https://' => '')) == trim($alias)) { |
|
1943 | + $do_fix = true; |
|
1944 | + } |
|
1843 | 1945 | } |
1844 | 1946 | } |
1845 | 1947 | |
@@ -1847,21 +1949,23 @@ discard block |
||
1847 | 1949 | if (empty($do_fix) && strtr($detected_url, array('://' => '://www.')) == $boardurl && (empty($_GET) || count($_GET) == 1) && SMF != 'SSI') |
1848 | 1950 | { |
1849 | 1951 | // Okay, this seems weird, but we don't want an endless loop - this will make $_GET not empty ;). |
1850 | - if (empty($_GET)) |
|
1851 | - redirectexit('wwwRedirect'); |
|
1852 | - else |
|
1952 | + if (empty($_GET)) { |
|
1953 | + redirectexit('wwwRedirect'); |
|
1954 | + } else |
|
1853 | 1955 | { |
1854 | 1956 | $k = key($_GET); |
1855 | 1957 | $v = current($_GET); |
1856 | 1958 | |
1857 | - if ($k != 'wwwRedirect') |
|
1858 | - redirectexit('wwwRedirect;' . $k . '=' . $v); |
|
1959 | + if ($k != 'wwwRedirect') { |
|
1960 | + redirectexit('wwwRedirect;' . $k . '=' . $v); |
|
1961 | + } |
|
1859 | 1962 | } |
1860 | 1963 | } |
1861 | 1964 | |
1862 | 1965 | // #3 is just a check for SSL... |
1863 | - if (strtr($detected_url, array('https://' => 'http://')) == $boardurl) |
|
1864 | - $do_fix = true; |
|
1966 | + if (strtr($detected_url, array('https://' => 'http://')) == $boardurl) { |
|
1967 | + $do_fix = true; |
|
1968 | + } |
|
1865 | 1969 | |
1866 | 1970 | // Okay, #4 - perhaps it's an IP address? We're gonna want to use that one, then. (assuming it's the IP or something...) |
1867 | 1971 | if (!empty($do_fix) || preg_match('~^http[s]?://(?:[\d\.:]+|\[[\d:]+\](?::\d+)?)(?:$|/)~', $detected_url) == 1) |
@@ -1896,8 +2000,9 @@ discard block |
||
1896 | 2000 | $board_info['moderators'][$k]['link'] = strtr($dummy['link'], array('"' . $oldurl => '"' . $boardurl)); |
1897 | 2001 | } |
1898 | 2002 | } |
1899 | - foreach ($context['linktree'] as $k => $dummy) |
|
1900 | - $context['linktree'][$k]['url'] = strtr($dummy['url'], array($oldurl => $boardurl)); |
|
2003 | + foreach ($context['linktree'] as $k => $dummy) { |
|
2004 | + $context['linktree'][$k]['url'] = strtr($dummy['url'], array($oldurl => $boardurl)); |
|
2005 | + } |
|
1901 | 2006 | } |
1902 | 2007 | } |
1903 | 2008 | // Set up the contextual user array. |
@@ -1916,16 +2021,16 @@ discard block |
||
1916 | 2021 | 'email' => $user_info['email'], |
1917 | 2022 | 'ignoreusers' => $user_info['ignoreusers'], |
1918 | 2023 | ); |
1919 | - if (!$context['user']['is_guest']) |
|
1920 | - $context['user']['name'] = $user_info['name']; |
|
1921 | - elseif ($context['user']['is_guest'] && !empty($txt['guest_title'])) |
|
1922 | - $context['user']['name'] = $txt['guest_title']; |
|
2024 | + if (!$context['user']['is_guest']) { |
|
2025 | + $context['user']['name'] = $user_info['name']; |
|
2026 | + } elseif ($context['user']['is_guest'] && !empty($txt['guest_title'])) { |
|
2027 | + $context['user']['name'] = $txt['guest_title']; |
|
2028 | + } |
|
1923 | 2029 | |
1924 | 2030 | // Determine the current smiley set. |
1925 | 2031 | $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']; |
1926 | 2032 | $context['user']['smiley_set'] = $user_info['smiley_set']; |
1927 | - } |
|
1928 | - else |
|
2033 | + } else |
|
1929 | 2034 | { |
1930 | 2035 | // What to do when there is no $user_info (e.g., an error very early in the login process) |
1931 | 2036 | $context['user'] = array( |
@@ -1959,18 +2064,24 @@ discard block |
||
1959 | 2064 | } |
1960 | 2065 | |
1961 | 2066 | // Some basic information... |
1962 | - if (!isset($context['html_headers'])) |
|
1963 | - $context['html_headers'] = ''; |
|
1964 | - if (!isset($context['javascript_files'])) |
|
1965 | - $context['javascript_files'] = array(); |
|
1966 | - if (!isset($context['css_files'])) |
|
1967 | - $context['css_files'] = array(); |
|
1968 | - if (!isset($context['css_header'])) |
|
1969 | - $context['css_header'] = array(); |
|
1970 | - if (!isset($context['javascript_inline'])) |
|
1971 | - $context['javascript_inline'] = array('standard' => array(), 'defer' => array()); |
|
1972 | - if (!isset($context['javascript_vars'])) |
|
1973 | - $context['javascript_vars'] = array(); |
|
2067 | + if (!isset($context['html_headers'])) { |
|
2068 | + $context['html_headers'] = ''; |
|
2069 | + } |
|
2070 | + if (!isset($context['javascript_files'])) { |
|
2071 | + $context['javascript_files'] = array(); |
|
2072 | + } |
|
2073 | + if (!isset($context['css_files'])) { |
|
2074 | + $context['css_files'] = array(); |
|
2075 | + } |
|
2076 | + if (!isset($context['css_header'])) { |
|
2077 | + $context['css_header'] = array(); |
|
2078 | + } |
|
2079 | + if (!isset($context['javascript_inline'])) { |
|
2080 | + $context['javascript_inline'] = array('standard' => array(), 'defer' => array()); |
|
2081 | + } |
|
2082 | + if (!isset($context['javascript_vars'])) { |
|
2083 | + $context['javascript_vars'] = array(); |
|
2084 | + } |
|
1974 | 2085 | |
1975 | 2086 | $context['login_url'] = (!empty($modSettings['force_ssl']) && $modSettings['force_ssl'] < 2 ? strtr($scripturl, array('http://' => 'https://')) : $scripturl) . '?action=login2'; |
1976 | 2087 | $context['menu_separator'] = !empty($settings['use_image_buttons']) ? ' ' : ' | '; |
@@ -1982,16 +2093,18 @@ discard block |
||
1982 | 2093 | $context['current_action'] = isset($_REQUEST['action']) ? $smcFunc['htmlspecialchars']($_REQUEST['action']) : null; |
1983 | 2094 | $context['current_subaction'] = isset($_REQUEST['sa']) ? $_REQUEST['sa'] : null; |
1984 | 2095 | $context['can_register'] = empty($modSettings['registration_method']) || $modSettings['registration_method'] != 3; |
1985 | - if (isset($modSettings['load_average'])) |
|
1986 | - $context['load_average'] = $modSettings['load_average']; |
|
2096 | + if (isset($modSettings['load_average'])) { |
|
2097 | + $context['load_average'] = $modSettings['load_average']; |
|
2098 | + } |
|
1987 | 2099 | |
1988 | 2100 | // Detect the browser. This is separated out because it's also used in attachment downloads |
1989 | 2101 | detectBrowser(); |
1990 | 2102 | |
1991 | 2103 | // Set the top level linktree up. |
1992 | 2104 | // Note that if we're dealing with certain very early errors (e.g., login) the linktree might not be set yet... |
1993 | - if (empty($context['linktree'])) |
|
1994 | - $context['linktree'] = array(); |
|
2105 | + if (empty($context['linktree'])) { |
|
2106 | + $context['linktree'] = array(); |
|
2107 | + } |
|
1995 | 2108 | array_unshift($context['linktree'], array( |
1996 | 2109 | 'url' => $scripturl, |
1997 | 2110 | 'name' => $context['forum_name_html_safe'] |
@@ -2000,8 +2113,9 @@ discard block |
||
2000 | 2113 | // This allows sticking some HTML on the page output - useful for controls. |
2001 | 2114 | $context['insert_after_template'] = ''; |
2002 | 2115 | |
2003 | - if (!isset($txt)) |
|
2004 | - $txt = array(); |
|
2116 | + if (!isset($txt)) { |
|
2117 | + $txt = array(); |
|
2118 | + } |
|
2005 | 2119 | |
2006 | 2120 | $simpleActions = array( |
2007 | 2121 | 'findmember', |
@@ -2047,9 +2161,10 @@ discard block |
||
2047 | 2161 | |
2048 | 2162 | // See if theres any extra param to check. |
2049 | 2163 | $requiresXML = false; |
2050 | - foreach ($extraParams as $key => $extra) |
|
2051 | - if (isset($_REQUEST[$extra])) |
|
2164 | + foreach ($extraParams as $key => $extra) { |
|
2165 | + if (isset($_REQUEST[$extra])) |
|
2052 | 2166 | $requiresXML = true; |
2167 | + } |
|
2053 | 2168 | |
2054 | 2169 | // Output is fully XML, so no need for the index template. |
2055 | 2170 | if (isset($_REQUEST['xml']) && (in_array($context['current_action'], $xmlActions) || $requiresXML)) |
@@ -2064,37 +2179,39 @@ discard block |
||
2064 | 2179 | { |
2065 | 2180 | loadLanguage('index+Modifications'); |
2066 | 2181 | $context['template_layers'] = array(); |
2067 | - } |
|
2068 | - |
|
2069 | - else |
|
2182 | + } else |
|
2070 | 2183 | { |
2071 | 2184 | // Custom templates to load, or just default? |
2072 | - if (isset($settings['theme_templates'])) |
|
2073 | - $templates = explode(',', $settings['theme_templates']); |
|
2074 | - else |
|
2075 | - $templates = array('index'); |
|
2185 | + if (isset($settings['theme_templates'])) { |
|
2186 | + $templates = explode(',', $settings['theme_templates']); |
|
2187 | + } else { |
|
2188 | + $templates = array('index'); |
|
2189 | + } |
|
2076 | 2190 | |
2077 | 2191 | // Load each template... |
2078 | - foreach ($templates as $template) |
|
2079 | - loadTemplate($template); |
|
2192 | + foreach ($templates as $template) { |
|
2193 | + loadTemplate($template); |
|
2194 | + } |
|
2080 | 2195 | |
2081 | 2196 | // ...and attempt to load their associated language files. |
2082 | 2197 | $required_files = implode('+', array_merge($templates, array('Modifications'))); |
2083 | 2198 | loadLanguage($required_files, '', false); |
2084 | 2199 | |
2085 | 2200 | // Custom template layers? |
2086 | - if (isset($settings['theme_layers'])) |
|
2087 | - $context['template_layers'] = explode(',', $settings['theme_layers']); |
|
2088 | - else |
|
2089 | - $context['template_layers'] = array('html', 'body'); |
|
2201 | + if (isset($settings['theme_layers'])) { |
|
2202 | + $context['template_layers'] = explode(',', $settings['theme_layers']); |
|
2203 | + } else { |
|
2204 | + $context['template_layers'] = array('html', 'body'); |
|
2205 | + } |
|
2090 | 2206 | } |
2091 | 2207 | |
2092 | 2208 | // Initialize the theme. |
2093 | 2209 | loadSubTemplate('init', 'ignore'); |
2094 | 2210 | |
2095 | 2211 | // Allow overriding the board wide time/number formats. |
2096 | - if (empty($user_settings['time_format']) && !empty($txt['time_format'])) |
|
2097 | - $user_info['time_format'] = $txt['time_format']; |
|
2212 | + if (empty($user_settings['time_format']) && !empty($txt['time_format'])) { |
|
2213 | + $user_info['time_format'] = $txt['time_format']; |
|
2214 | + } |
|
2098 | 2215 | |
2099 | 2216 | // Set the character set from the template. |
2100 | 2217 | $context['character_set'] = empty($modSettings['global_character_set']) ? $txt['lang_character_set'] : $modSettings['global_character_set']; |
@@ -2102,12 +2219,14 @@ discard block |
||
2102 | 2219 | $context['right_to_left'] = !empty($txt['lang_rtl']); |
2103 | 2220 | |
2104 | 2221 | // Guests may still need a name. |
2105 | - if ($context['user']['is_guest'] && empty($context['user']['name'])) |
|
2106 | - $context['user']['name'] = $txt['guest_title']; |
|
2222 | + if ($context['user']['is_guest'] && empty($context['user']['name'])) { |
|
2223 | + $context['user']['name'] = $txt['guest_title']; |
|
2224 | + } |
|
2107 | 2225 | |
2108 | 2226 | // Any theme-related strings that need to be loaded? |
2109 | - if (!empty($settings['require_theme_strings'])) |
|
2110 | - loadLanguage('ThemeStrings', '', false); |
|
2227 | + if (!empty($settings['require_theme_strings'])) { |
|
2228 | + loadLanguage('ThemeStrings', '', false); |
|
2229 | + } |
|
2111 | 2230 | |
2112 | 2231 | // Make a special URL for the language. |
2113 | 2232 | $settings['lang_images_url'] = $settings['images_url'] . '/' . (!empty($txt['image_lang']) ? $txt['image_lang'] : $user_info['language']); |
@@ -2118,8 +2237,9 @@ discard block |
||
2118 | 2237 | // Here is my luvly Responsive CSS |
2119 | 2238 | loadCSSFile('responsive.css', array('force_current' => false, 'validate' => true, 'minimize' => true), 'smf_responsive'); |
2120 | 2239 | |
2121 | - if ($context['right_to_left']) |
|
2122 | - loadCSSFile('rtl.css', array(), 'smf_rtl'); |
|
2240 | + if ($context['right_to_left']) { |
|
2241 | + loadCSSFile('rtl.css', array(), 'smf_rtl'); |
|
2242 | + } |
|
2123 | 2243 | |
2124 | 2244 | // We allow theme variants, because we're cool. |
2125 | 2245 | $context['theme_variant'] = ''; |
@@ -2127,14 +2247,17 @@ discard block |
||
2127 | 2247 | if (!empty($settings['theme_variants'])) |
2128 | 2248 | { |
2129 | 2249 | // Overriding - for previews and that ilk. |
2130 | - if (!empty($_REQUEST['variant'])) |
|
2131 | - $_SESSION['id_variant'] = $_REQUEST['variant']; |
|
2250 | + if (!empty($_REQUEST['variant'])) { |
|
2251 | + $_SESSION['id_variant'] = $_REQUEST['variant']; |
|
2252 | + } |
|
2132 | 2253 | // User selection? |
2133 | - if (empty($settings['disable_user_variant']) || allowedTo('admin_forum')) |
|
2134 | - $context['theme_variant'] = !empty($_SESSION['id_variant']) ? $_SESSION['id_variant'] : (!empty($options['theme_variant']) ? $options['theme_variant'] : ''); |
|
2254 | + if (empty($settings['disable_user_variant']) || allowedTo('admin_forum')) { |
|
2255 | + $context['theme_variant'] = !empty($_SESSION['id_variant']) ? $_SESSION['id_variant'] : (!empty($options['theme_variant']) ? $options['theme_variant'] : ''); |
|
2256 | + } |
|
2135 | 2257 | // If not a user variant, select the default. |
2136 | - if ($context['theme_variant'] == '' || !in_array($context['theme_variant'], $settings['theme_variants'])) |
|
2137 | - $context['theme_variant'] = !empty($settings['default_variant']) && in_array($settings['default_variant'], $settings['theme_variants']) ? $settings['default_variant'] : $settings['theme_variants'][0]; |
|
2258 | + if ($context['theme_variant'] == '' || !in_array($context['theme_variant'], $settings['theme_variants'])) { |
|
2259 | + $context['theme_variant'] = !empty($settings['default_variant']) && in_array($settings['default_variant'], $settings['theme_variants']) ? $settings['default_variant'] : $settings['theme_variants'][0]; |
|
2260 | + } |
|
2138 | 2261 | |
2139 | 2262 | // Do this to keep things easier in the templates. |
2140 | 2263 | $context['theme_variant'] = '_' . $context['theme_variant']; |
@@ -2143,20 +2266,23 @@ discard block |
||
2143 | 2266 | if (!empty($context['theme_variant'])) |
2144 | 2267 | { |
2145 | 2268 | loadCSSFile('index' . $context['theme_variant'] . '.css', array(), 'smf_index' . $context['theme_variant']); |
2146 | - if ($context['right_to_left']) |
|
2147 | - loadCSSFile('rtl' . $context['theme_variant'] . '.css', array(), 'smf_rtl' . $context['theme_variant']); |
|
2269 | + if ($context['right_to_left']) { |
|
2270 | + loadCSSFile('rtl' . $context['theme_variant'] . '.css', array(), 'smf_rtl' . $context['theme_variant']); |
|
2271 | + } |
|
2148 | 2272 | } |
2149 | 2273 | } |
2150 | 2274 | |
2151 | 2275 | // Let's be compatible with old themes! |
2152 | - if (!function_exists('template_html_above') && in_array('html', $context['template_layers'])) |
|
2153 | - $context['template_layers'] = array('main'); |
|
2276 | + if (!function_exists('template_html_above') && in_array('html', $context['template_layers'])) { |
|
2277 | + $context['template_layers'] = array('main'); |
|
2278 | + } |
|
2154 | 2279 | |
2155 | 2280 | $context['tabindex'] = 1; |
2156 | 2281 | |
2157 | 2282 | // Compatibility. |
2158 | - if (!isset($settings['theme_version'])) |
|
2159 | - $modSettings['memberCount'] = $modSettings['totalMembers']; |
|
2283 | + if (!isset($settings['theme_version'])) { |
|
2284 | + $modSettings['memberCount'] = $modSettings['totalMembers']; |
|
2285 | + } |
|
2160 | 2286 | |
2161 | 2287 | // Default JS variables for use in every theme |
2162 | 2288 | $context['javascript_vars'] = array( |
@@ -2175,18 +2301,18 @@ discard block |
||
2175 | 2301 | ); |
2176 | 2302 | |
2177 | 2303 | // Add the JQuery library to the list of files to load. |
2178 | - if (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'cdn') |
|
2179 | - loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js', array('external' => true), 'smf_jquery'); |
|
2180 | - |
|
2181 | - elseif (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'local') |
|
2182 | - loadJavaScriptFile('jquery-3.1.1.min.js', array('seed' => false), 'smf_jquery'); |
|
2183 | - |
|
2184 | - elseif (isset($modSettings['jquery_source'], $modSettings['jquery_custom']) && $modSettings['jquery_source'] == 'custom') |
|
2185 | - loadJavaScriptFile($modSettings['jquery_custom'], array('external' => true), 'smf_jquery'); |
|
2304 | + if (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'cdn') { |
|
2305 | + loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js', array('external' => true), 'smf_jquery'); |
|
2306 | + } elseif (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'local') { |
|
2307 | + loadJavaScriptFile('jquery-3.1.1.min.js', array('seed' => false), 'smf_jquery'); |
|
2308 | + } elseif (isset($modSettings['jquery_source'], $modSettings['jquery_custom']) && $modSettings['jquery_source'] == 'custom') { |
|
2309 | + loadJavaScriptFile($modSettings['jquery_custom'], array('external' => true), 'smf_jquery'); |
|
2310 | + } |
|
2186 | 2311 | |
2187 | 2312 | // Auto loading? template_javascript() will take care of the local half of this. |
2188 | - else |
|
2189 | - loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js', array('external' => true), 'smf_jquery'); |
|
2313 | + else { |
|
2314 | + loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js', array('external' => true), 'smf_jquery'); |
|
2315 | + } |
|
2190 | 2316 | |
2191 | 2317 | // Queue our JQuery plugins! |
2192 | 2318 | loadJavaScriptFile('smf_jquery_plugins.js', array('minimize' => true), 'smf_jquery_plugins'); |
@@ -2209,12 +2335,12 @@ discard block |
||
2209 | 2335 | require_once($sourcedir . '/ScheduledTasks.php'); |
2210 | 2336 | |
2211 | 2337 | // What to do, what to do?! |
2212 | - if (empty($modSettings['next_task_time']) || $modSettings['next_task_time'] < time()) |
|
2213 | - AutoTask(); |
|
2214 | - else |
|
2215 | - ReduceMailQueue(); |
|
2216 | - } |
|
2217 | - else |
|
2338 | + if (empty($modSettings['next_task_time']) || $modSettings['next_task_time'] < time()) { |
|
2339 | + AutoTask(); |
|
2340 | + } else { |
|
2341 | + ReduceMailQueue(); |
|
2342 | + } |
|
2343 | + } else |
|
2218 | 2344 | { |
2219 | 2345 | $type = empty($modSettings['next_task_time']) || $modSettings['next_task_time'] < time() ? 'task' : 'mailq'; |
2220 | 2346 | $ts = $type == 'mailq' ? $modSettings['mail_next_send'] : $modSettings['next_task_time']; |
@@ -2265,8 +2391,9 @@ discard block |
||
2265 | 2391 | foreach ($theme_includes as $include) |
2266 | 2392 | { |
2267 | 2393 | $include = strtr(trim($include), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir'])); |
2268 | - if (file_exists($include)) |
|
2269 | - require_once($include); |
|
2394 | + if (file_exists($include)) { |
|
2395 | + require_once($include); |
|
2396 | + } |
|
2270 | 2397 | } |
2271 | 2398 | } |
2272 | 2399 | |
@@ -2296,16 +2423,19 @@ discard block |
||
2296 | 2423 | // Do any style sheets first, cause we're easy with those. |
2297 | 2424 | if (!empty($style_sheets)) |
2298 | 2425 | { |
2299 | - if (!is_array($style_sheets)) |
|
2300 | - $style_sheets = array($style_sheets); |
|
2426 | + if (!is_array($style_sheets)) { |
|
2427 | + $style_sheets = array($style_sheets); |
|
2428 | + } |
|
2301 | 2429 | |
2302 | - foreach ($style_sheets as $sheet) |
|
2303 | - loadCSSFile($sheet . '.css', array(), $sheet); |
|
2430 | + foreach ($style_sheets as $sheet) { |
|
2431 | + loadCSSFile($sheet . '.css', array(), $sheet); |
|
2432 | + } |
|
2304 | 2433 | } |
2305 | 2434 | |
2306 | 2435 | // No template to load? |
2307 | - if ($template_name === false) |
|
2308 | - return true; |
|
2436 | + if ($template_name === false) { |
|
2437 | + return true; |
|
2438 | + } |
|
2309 | 2439 | |
2310 | 2440 | $loaded = false; |
2311 | 2441 | foreach ($settings['template_dirs'] as $template_dir) |
@@ -2320,12 +2450,14 @@ discard block |
||
2320 | 2450 | |
2321 | 2451 | if ($loaded) |
2322 | 2452 | { |
2323 | - if ($db_show_debug === true) |
|
2324 | - $context['debug']['templates'][] = $template_name . ' (' . basename($template_dir) . ')'; |
|
2453 | + if ($db_show_debug === true) { |
|
2454 | + $context['debug']['templates'][] = $template_name . ' (' . basename($template_dir) . ')'; |
|
2455 | + } |
|
2325 | 2456 | |
2326 | 2457 | // If they have specified an initialization function for this template, go ahead and call it now. |
2327 | - if (function_exists('template_' . $template_name . '_init')) |
|
2328 | - call_user_func('template_' . $template_name . '_init'); |
|
2458 | + if (function_exists('template_' . $template_name . '_init')) { |
|
2459 | + call_user_func('template_' . $template_name . '_init'); |
|
2460 | + } |
|
2329 | 2461 | } |
2330 | 2462 | // Hmmm... doesn't exist?! I don't suppose the directory is wrong, is it? |
2331 | 2463 | elseif (!file_exists($settings['default_theme_dir']) && file_exists($boarddir . '/Themes/default')) |
@@ -2345,13 +2477,14 @@ discard block |
||
2345 | 2477 | loadTemplate($template_name); |
2346 | 2478 | } |
2347 | 2479 | // Cause an error otherwise. |
2348 | - elseif ($template_name != 'Errors' && $template_name != 'index' && $fatal) |
|
2349 | - fatal_lang_error('theme_template_error', 'template', array((string) $template_name)); |
|
2350 | - elseif ($fatal) |
|
2351 | - 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')); |
|
2352 | - else |
|
2353 | - return false; |
|
2354 | -} |
|
2480 | + elseif ($template_name != 'Errors' && $template_name != 'index' && $fatal) { |
|
2481 | + fatal_lang_error('theme_template_error', 'template', array((string) $template_name)); |
|
2482 | + } elseif ($fatal) { |
|
2483 | + 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')); |
|
2484 | + } else { |
|
2485 | + return false; |
|
2486 | + } |
|
2487 | + } |
|
2355 | 2488 | |
2356 | 2489 | /** |
2357 | 2490 | * Load a sub-template. |
@@ -2369,17 +2502,19 @@ discard block |
||
2369 | 2502 | { |
2370 | 2503 | global $context, $txt, $db_show_debug; |
2371 | 2504 | |
2372 | - if ($db_show_debug === true) |
|
2373 | - $context['debug']['sub_templates'][] = $sub_template_name; |
|
2505 | + if ($db_show_debug === true) { |
|
2506 | + $context['debug']['sub_templates'][] = $sub_template_name; |
|
2507 | + } |
|
2374 | 2508 | |
2375 | 2509 | // Figure out what the template function is named. |
2376 | 2510 | $theme_function = 'template_' . $sub_template_name; |
2377 | - if (function_exists($theme_function)) |
|
2378 | - $theme_function(); |
|
2379 | - elseif ($fatal === false) |
|
2380 | - fatal_lang_error('theme_template_error', 'template', array((string) $sub_template_name)); |
|
2381 | - elseif ($fatal !== 'ignore') |
|
2382 | - 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')); |
|
2511 | + if (function_exists($theme_function)) { |
|
2512 | + $theme_function(); |
|
2513 | + } elseif ($fatal === false) { |
|
2514 | + fatal_lang_error('theme_template_error', 'template', array((string) $sub_template_name)); |
|
2515 | + } elseif ($fatal !== 'ignore') { |
|
2516 | + 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')); |
|
2517 | + } |
|
2383 | 2518 | |
2384 | 2519 | // Are we showing debugging for templates? Just make sure not to do it before the doctype... |
2385 | 2520 | if (allowedTo('admin_forum') && isset($_REQUEST['debug']) && !in_array($sub_template_name, array('init', 'main_below')) && ob_get_length() > 0 && !isset($_REQUEST['xml'])) |
@@ -2416,8 +2551,9 @@ discard block |
||
2416 | 2551 | $params['validate'] = isset($params['validate']) ? $params['validate'] : true; |
2417 | 2552 | |
2418 | 2553 | // If this is an external file, automatically set this to false. |
2419 | - if (!empty($params['external'])) |
|
2420 | - $params['minimize'] = false; |
|
2554 | + if (!empty($params['external'])) { |
|
2555 | + $params['minimize'] = false; |
|
2556 | + } |
|
2421 | 2557 | |
2422 | 2558 | // Account for shorthand like admin.css?alp21 filenames |
2423 | 2559 | $has_seed = strpos($fileName, '.css?'); |
@@ -2434,13 +2570,10 @@ discard block |
||
2434 | 2570 | { |
2435 | 2571 | $fileUrl = $settings['default_theme_url'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']); |
2436 | 2572 | $filePath = $settings['default_theme_dir'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']); |
2573 | + } else { |
|
2574 | + $fileUrl = false; |
|
2437 | 2575 | } |
2438 | - |
|
2439 | - else |
|
2440 | - $fileUrl = false; |
|
2441 | - } |
|
2442 | - |
|
2443 | - else |
|
2576 | + } else |
|
2444 | 2577 | { |
2445 | 2578 | $fileUrl = $settings[$themeRef . '_url'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']); |
2446 | 2579 | $filePath = $settings[$themeRef . '_dir'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']); |
@@ -2455,12 +2588,14 @@ discard block |
||
2455 | 2588 | } |
2456 | 2589 | |
2457 | 2590 | // Add it to the array for use in the template |
2458 | - if (!empty($fileName)) |
|
2459 | - $context['css_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params); |
|
2591 | + if (!empty($fileName)) { |
|
2592 | + $context['css_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params); |
|
2593 | + } |
|
2460 | 2594 | |
2461 | - if (!empty($context['right_to_left']) && !empty($params['rtl'])) |
|
2462 | - loadCSSFile($params['rtl'], array_diff_key($params, array('rtl' => 0))); |
|
2463 | -} |
|
2595 | + if (!empty($context['right_to_left']) && !empty($params['rtl'])) { |
|
2596 | + loadCSSFile($params['rtl'], array_diff_key($params, array('rtl' => 0))); |
|
2597 | + } |
|
2598 | + } |
|
2464 | 2599 | |
2465 | 2600 | /** |
2466 | 2601 | * Add a block of inline css code to be executed later |
@@ -2477,8 +2612,9 @@ discard block |
||
2477 | 2612 | global $context; |
2478 | 2613 | |
2479 | 2614 | // Gotta add something... |
2480 | - if (empty($css)) |
|
2481 | - return false; |
|
2615 | + if (empty($css)) { |
|
2616 | + return false; |
|
2617 | + } |
|
2482 | 2618 | |
2483 | 2619 | $context['css_header'][] = $css; |
2484 | 2620 | } |
@@ -2513,8 +2649,9 @@ discard block |
||
2513 | 2649 | $params['validate'] = isset($params['validate']) ? $params['validate'] : true; |
2514 | 2650 | |
2515 | 2651 | // If this is an external file, automatically set this to false. |
2516 | - if (!empty($params['external'])) |
|
2517 | - $params['minimize'] = false; |
|
2652 | + if (!empty($params['external'])) { |
|
2653 | + $params['minimize'] = false; |
|
2654 | + } |
|
2518 | 2655 | |
2519 | 2656 | // Account for shorthand like admin.js?alp21 filenames |
2520 | 2657 | $has_seed = strpos($fileName, '.js?'); |
@@ -2531,16 +2668,12 @@ discard block |
||
2531 | 2668 | { |
2532 | 2669 | $fileUrl = $settings['default_theme_url'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']); |
2533 | 2670 | $filePath = $settings['default_theme_dir'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']); |
2534 | - } |
|
2535 | - |
|
2536 | - else |
|
2671 | + } else |
|
2537 | 2672 | { |
2538 | 2673 | $fileUrl = false; |
2539 | 2674 | $filePath = false; |
2540 | 2675 | } |
2541 | - } |
|
2542 | - |
|
2543 | - else |
|
2676 | + } else |
|
2544 | 2677 | { |
2545 | 2678 | $fileUrl = $settings[$themeRef . '_url'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']); |
2546 | 2679 | $filePath = $settings[$themeRef . '_dir'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']); |
@@ -2555,9 +2688,10 @@ discard block |
||
2555 | 2688 | } |
2556 | 2689 | |
2557 | 2690 | // Add it to the array for use in the template |
2558 | - if (!empty($fileName)) |
|
2559 | - $context['javascript_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params); |
|
2560 | -} |
|
2691 | + if (!empty($fileName)) { |
|
2692 | + $context['javascript_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params); |
|
2693 | + } |
|
2694 | + } |
|
2561 | 2695 | |
2562 | 2696 | /** |
2563 | 2697 | * Add a Javascript variable for output later (for feeding text strings and similar to JS) |
@@ -2571,9 +2705,10 @@ discard block |
||
2571 | 2705 | { |
2572 | 2706 | global $context; |
2573 | 2707 | |
2574 | - if (!empty($key) && (!empty($value) || $value === '0')) |
|
2575 | - $context['javascript_vars'][$key] = !empty($escape) ? JavaScriptEscape($value) : $value; |
|
2576 | -} |
|
2708 | + if (!empty($key) && (!empty($value) || $value === '0')) { |
|
2709 | + $context['javascript_vars'][$key] = !empty($escape) ? JavaScriptEscape($value) : $value; |
|
2710 | + } |
|
2711 | + } |
|
2577 | 2712 | |
2578 | 2713 | /** |
2579 | 2714 | * Add a block of inline Javascript code to be executed later |
@@ -2590,8 +2725,9 @@ discard block |
||
2590 | 2725 | { |
2591 | 2726 | global $context; |
2592 | 2727 | |
2593 | - if (empty($javascript)) |
|
2594 | - return false; |
|
2728 | + if (empty($javascript)) { |
|
2729 | + return false; |
|
2730 | + } |
|
2595 | 2731 | |
2596 | 2732 | $context['javascript_inline'][($defer === true ? 'defer' : 'standard')][] = $javascript; |
2597 | 2733 | } |
@@ -2612,15 +2748,18 @@ discard block |
||
2612 | 2748 | static $already_loaded = array(); |
2613 | 2749 | |
2614 | 2750 | // Default to the user's language. |
2615 | - if ($lang == '') |
|
2616 | - $lang = isset($user_info['language']) ? $user_info['language'] : $language; |
|
2751 | + if ($lang == '') { |
|
2752 | + $lang = isset($user_info['language']) ? $user_info['language'] : $language; |
|
2753 | + } |
|
2617 | 2754 | |
2618 | 2755 | // Do we want the English version of language file as fallback? |
2619 | - if (empty($modSettings['disable_language_fallback']) && $lang != 'english') |
|
2620 | - loadLanguage($template_name, 'english', false); |
|
2756 | + if (empty($modSettings['disable_language_fallback']) && $lang != 'english') { |
|
2757 | + loadLanguage($template_name, 'english', false); |
|
2758 | + } |
|
2621 | 2759 | |
2622 | - if (!$force_reload && isset($already_loaded[$template_name]) && $already_loaded[$template_name] == $lang) |
|
2623 | - return $lang; |
|
2760 | + if (!$force_reload && isset($already_loaded[$template_name]) && $already_loaded[$template_name] == $lang) { |
|
2761 | + return $lang; |
|
2762 | + } |
|
2624 | 2763 | |
2625 | 2764 | // Make sure we have $settings - if not we're in trouble and need to find it! |
2626 | 2765 | if (empty($settings['default_theme_dir'])) |
@@ -2631,8 +2770,9 @@ discard block |
||
2631 | 2770 | |
2632 | 2771 | // What theme are we in? |
2633 | 2772 | $theme_name = basename($settings['theme_url']); |
2634 | - if (empty($theme_name)) |
|
2635 | - $theme_name = 'unknown'; |
|
2773 | + if (empty($theme_name)) { |
|
2774 | + $theme_name = 'unknown'; |
|
2775 | + } |
|
2636 | 2776 | |
2637 | 2777 | // For each file open it up and write it out! |
2638 | 2778 | foreach (explode('+', $template_name) as $template) |
@@ -2674,8 +2814,9 @@ discard block |
||
2674 | 2814 | $found = true; |
2675 | 2815 | |
2676 | 2816 | // setlocale is required for basename() & pathinfo() to work properly on the selected language |
2677 | - if (!empty($txt['lang_locale']) && !empty($modSettings['global_character_set'])) |
|
2678 | - setlocale(LC_CTYPE, $txt['lang_locale'] . '.' . $modSettings['global_character_set']); |
|
2817 | + if (!empty($txt['lang_locale']) && !empty($modSettings['global_character_set'])) { |
|
2818 | + setlocale(LC_CTYPE, $txt['lang_locale'] . '.' . $modSettings['global_character_set']); |
|
2819 | + } |
|
2679 | 2820 | |
2680 | 2821 | break; |
2681 | 2822 | } |
@@ -2715,8 +2856,9 @@ discard block |
||
2715 | 2856 | } |
2716 | 2857 | |
2717 | 2858 | // Keep track of what we're up to soldier. |
2718 | - if ($db_show_debug === true) |
|
2719 | - $context['debug']['language_files'][] = $template_name . '.' . $lang . ' (' . $theme_name . ')'; |
|
2859 | + if ($db_show_debug === true) { |
|
2860 | + $context['debug']['language_files'][] = $template_name . '.' . $lang . ' (' . $theme_name . ')'; |
|
2861 | + } |
|
2720 | 2862 | |
2721 | 2863 | // Remember what we have loaded, and in which language. |
2722 | 2864 | $already_loaded[$template_name] = $lang; |
@@ -2762,8 +2904,9 @@ discard block |
||
2762 | 2904 | ) |
2763 | 2905 | ); |
2764 | 2906 | // In the EXTREMELY unlikely event this happens, give an error message. |
2765 | - if ($smcFunc['db_num_rows']($result) == 0) |
|
2766 | - fatal_lang_error('parent_not_found', 'critical'); |
|
2907 | + if ($smcFunc['db_num_rows']($result) == 0) { |
|
2908 | + fatal_lang_error('parent_not_found', 'critical'); |
|
2909 | + } |
|
2767 | 2910 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
2768 | 2911 | { |
2769 | 2912 | if (!isset($boards[$row['id_board']])) |
@@ -2780,8 +2923,8 @@ discard block |
||
2780 | 2923 | ); |
2781 | 2924 | } |
2782 | 2925 | // If a moderator exists for this board, add that moderator for all children too. |
2783 | - if (!empty($row['id_moderator'])) |
|
2784 | - foreach ($boards as $id => $dummy) |
|
2926 | + if (!empty($row['id_moderator'])) { |
|
2927 | + foreach ($boards as $id => $dummy) |
|
2785 | 2928 | { |
2786 | 2929 | $boards[$id]['moderators'][$row['id_moderator']] = array( |
2787 | 2930 | 'id' => $row['id_moderator'], |
@@ -2789,11 +2932,12 @@ discard block |
||
2789 | 2932 | 'href' => $scripturl . '?action=profile;u=' . $row['id_moderator'], |
2790 | 2933 | 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_moderator'] . '">' . $row['real_name'] . '</a>' |
2791 | 2934 | ); |
2935 | + } |
|
2792 | 2936 | } |
2793 | 2937 | |
2794 | 2938 | // If a moderator group exists for this board, add that moderator group for all children too |
2795 | - if (!empty($row['id_moderator_group'])) |
|
2796 | - foreach ($boards as $id => $dummy) |
|
2939 | + if (!empty($row['id_moderator_group'])) { |
|
2940 | + foreach ($boards as $id => $dummy) |
|
2797 | 2941 | { |
2798 | 2942 | $boards[$id]['moderator_groups'][$row['id_moderator_group']] = array( |
2799 | 2943 | 'id' => $row['id_moderator_group'], |
@@ -2801,6 +2945,7 @@ discard block |
||
2801 | 2945 | 'href' => $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'], |
2802 | 2946 | 'link' => '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'] . '">' . $row['group_name'] . '</a>' |
2803 | 2947 | ); |
2948 | + } |
|
2804 | 2949 | } |
2805 | 2950 | } |
2806 | 2951 | $smcFunc['db_free_result']($result); |
@@ -2827,23 +2972,27 @@ discard block |
||
2827 | 2972 | if (!$use_cache || ($context['languages'] = cache_get_data('known_languages', !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600)) == null) |
2828 | 2973 | { |
2829 | 2974 | // If we don't have our ucwords function defined yet, let's load the settings data. |
2830 | - if (empty($smcFunc['ucwords'])) |
|
2831 | - reloadSettings(); |
|
2975 | + if (empty($smcFunc['ucwords'])) { |
|
2976 | + reloadSettings(); |
|
2977 | + } |
|
2832 | 2978 | |
2833 | 2979 | // If we don't have our theme information yet, let's get it. |
2834 | - if (empty($settings['default_theme_dir'])) |
|
2835 | - loadTheme(0, false); |
|
2980 | + if (empty($settings['default_theme_dir'])) { |
|
2981 | + loadTheme(0, false); |
|
2982 | + } |
|
2836 | 2983 | |
2837 | 2984 | // Default language directories to try. |
2838 | 2985 | $language_directories = array( |
2839 | 2986 | $settings['default_theme_dir'] . '/languages', |
2840 | 2987 | ); |
2841 | - if (!empty($settings['actual_theme_dir']) && $settings['actual_theme_dir'] != $settings['default_theme_dir']) |
|
2842 | - $language_directories[] = $settings['actual_theme_dir'] . '/languages'; |
|
2988 | + if (!empty($settings['actual_theme_dir']) && $settings['actual_theme_dir'] != $settings['default_theme_dir']) { |
|
2989 | + $language_directories[] = $settings['actual_theme_dir'] . '/languages'; |
|
2990 | + } |
|
2843 | 2991 | |
2844 | 2992 | // We possibly have a base theme directory. |
2845 | - if (!empty($settings['base_theme_dir'])) |
|
2846 | - $language_directories[] = $settings['base_theme_dir'] . '/languages'; |
|
2993 | + if (!empty($settings['base_theme_dir'])) { |
|
2994 | + $language_directories[] = $settings['base_theme_dir'] . '/languages'; |
|
2995 | + } |
|
2847 | 2996 | |
2848 | 2997 | // Remove any duplicates. |
2849 | 2998 | $language_directories = array_unique($language_directories); |
@@ -2857,20 +3006,21 @@ discard block |
||
2857 | 3006 | foreach ($language_directories as $language_dir) |
2858 | 3007 | { |
2859 | 3008 | // Can't look in here... doesn't exist! |
2860 | - if (!file_exists($language_dir)) |
|
2861 | - continue; |
|
3009 | + if (!file_exists($language_dir)) { |
|
3010 | + continue; |
|
3011 | + } |
|
2862 | 3012 | |
2863 | 3013 | $dir = dir($language_dir); |
2864 | 3014 | while ($entry = $dir->read()) |
2865 | 3015 | { |
2866 | 3016 | // Look for the index language file... For good measure skip any "index.language-utf8.php" files |
2867 | - if (!preg_match('~^index\.(.+[^-utf8])\.php$~', $entry, $matches)) |
|
2868 | - continue; |
|
2869 | - |
|
2870 | - if (!empty($langList) && !empty($langList[$matches[1]])) |
|
2871 | - $langName = $langList[$matches[1]]; |
|
3017 | + if (!preg_match('~^index\.(.+[^-utf8])\.php$~', $entry, $matches)) { |
|
3018 | + continue; |
|
3019 | + } |
|
2872 | 3020 | |
2873 | - else |
|
3021 | + if (!empty($langList) && !empty($langList[$matches[1]])) { |
|
3022 | + $langName = $langList[$matches[1]]; |
|
3023 | + } else |
|
2874 | 3024 | { |
2875 | 3025 | $langName = $smcFunc['ucwords'](strtr($matches[1], array('_' => ' '))); |
2876 | 3026 | |
@@ -2911,12 +3061,14 @@ discard block |
||
2911 | 3061 | } |
2912 | 3062 | |
2913 | 3063 | // Do we need to store the lang list? |
2914 | - if (empty($langList)) |
|
2915 | - updateSettings(array('langList' => $smcFunc['json_encode']($catchLang))); |
|
3064 | + if (empty($langList)) { |
|
3065 | + updateSettings(array('langList' => $smcFunc['json_encode']($catchLang))); |
|
3066 | + } |
|
2916 | 3067 | |
2917 | 3068 | // Let's cash in on this deal. |
2918 | - if (!empty($modSettings['cache_enable'])) |
|
2919 | - cache_put_data('known_languages', $context['languages'], !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600); |
|
3069 | + if (!empty($modSettings['cache_enable'])) { |
|
3070 | + cache_put_data('known_languages', $context['languages'], !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600); |
|
3071 | + } |
|
2920 | 3072 | } |
2921 | 3073 | |
2922 | 3074 | return $context['languages']; |
@@ -2939,8 +3091,9 @@ discard block |
||
2939 | 3091 | global $modSettings, $options, $txt; |
2940 | 3092 | static $censor_vulgar = null, $censor_proper; |
2941 | 3093 | |
2942 | - if ((!empty($options['show_no_censored']) && !empty($modSettings['allow_no_censored']) && !$force) || empty($modSettings['censor_vulgar']) || trim($text) === '') |
|
2943 | - return $text; |
|
3094 | + if ((!empty($options['show_no_censored']) && !empty($modSettings['allow_no_censored']) && !$force) || empty($modSettings['censor_vulgar']) || trim($text) === '') { |
|
3095 | + return $text; |
|
3096 | + } |
|
2944 | 3097 | |
2945 | 3098 | // If they haven't yet been loaded, load them. |
2946 | 3099 | if ($censor_vulgar == null) |
@@ -2968,9 +3121,9 @@ discard block |
||
2968 | 3121 | { |
2969 | 3122 | $func = !empty($modSettings['censorIgnoreCase']) ? 'str_ireplace' : 'str_replace'; |
2970 | 3123 | $text = $func($censor_vulgar, $censor_proper, $text); |
3124 | + } else { |
|
3125 | + $text = preg_replace($censor_vulgar, $censor_proper, $text); |
|
2971 | 3126 | } |
2972 | - else |
|
2973 | - $text = preg_replace($censor_vulgar, $censor_proper, $text); |
|
2974 | 3127 | |
2975 | 3128 | return $text; |
2976 | 3129 | } |
@@ -2996,38 +3149,42 @@ discard block |
||
2996 | 3149 | @ini_set('track_errors', '1'); |
2997 | 3150 | |
2998 | 3151 | // Don't include the file more than once, if $once is true. |
2999 | - if ($once && in_array($filename, $templates)) |
|
3000 | - return; |
|
3152 | + if ($once && in_array($filename, $templates)) { |
|
3153 | + return; |
|
3154 | + } |
|
3001 | 3155 | // Add this file to the include list, whether $once is true or not. |
3002 | - else |
|
3003 | - $templates[] = $filename; |
|
3156 | + else { |
|
3157 | + $templates[] = $filename; |
|
3158 | + } |
|
3004 | 3159 | |
3005 | 3160 | // Are we going to use eval? |
3006 | 3161 | if (empty($modSettings['disableTemplateEval'])) |
3007 | 3162 | { |
3008 | 3163 | $file_found = file_exists($filename) && eval('?' . '>' . rtrim(file_get_contents($filename))) !== false; |
3009 | 3164 | $settings['current_include_filename'] = $filename; |
3010 | - } |
|
3011 | - else |
|
3165 | + } else |
|
3012 | 3166 | { |
3013 | 3167 | $file_found = file_exists($filename); |
3014 | 3168 | |
3015 | - if ($once && $file_found) |
|
3016 | - require_once($filename); |
|
3017 | - elseif ($file_found) |
|
3018 | - require($filename); |
|
3169 | + if ($once && $file_found) { |
|
3170 | + require_once($filename); |
|
3171 | + } elseif ($file_found) { |
|
3172 | + require($filename); |
|
3173 | + } |
|
3019 | 3174 | } |
3020 | 3175 | |
3021 | 3176 | if ($file_found !== true) |
3022 | 3177 | { |
3023 | 3178 | ob_end_clean(); |
3024 | - if (!empty($modSettings['enableCompressedOutput'])) |
|
3025 | - @ob_start('ob_gzhandler'); |
|
3026 | - else |
|
3027 | - ob_start(); |
|
3179 | + if (!empty($modSettings['enableCompressedOutput'])) { |
|
3180 | + @ob_start('ob_gzhandler'); |
|
3181 | + } else { |
|
3182 | + ob_start(); |
|
3183 | + } |
|
3028 | 3184 | |
3029 | - if (isset($_GET['debug'])) |
|
3030 | - header('Content-Type: application/xhtml+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
3185 | + if (isset($_GET['debug'])) { |
|
3186 | + header('Content-Type: application/xhtml+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
3187 | + } |
|
3031 | 3188 | |
3032 | 3189 | // Don't cache error pages!! |
3033 | 3190 | header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); |
@@ -3046,12 +3203,13 @@ discard block |
||
3046 | 3203 | echo '<!DOCTYPE html> |
3047 | 3204 | <html', !empty($context['right_to_left']) ? ' dir="rtl"' : '', '> |
3048 | 3205 | <head>'; |
3049 | - if (isset($context['character_set'])) |
|
3050 | - echo ' |
|
3206 | + if (isset($context['character_set'])) { |
|
3207 | + echo ' |
|
3051 | 3208 | <meta charset="', $context['character_set'], '">'; |
3209 | + } |
|
3052 | 3210 | |
3053 | - if (!empty($maintenance) && !allowedTo('admin_forum')) |
|
3054 | - echo ' |
|
3211 | + if (!empty($maintenance) && !allowedTo('admin_forum')) { |
|
3212 | + echo ' |
|
3055 | 3213 | <title>', $mtitle, '</title> |
3056 | 3214 | </head> |
3057 | 3215 | <body> |
@@ -3059,8 +3217,8 @@ discard block |
||
3059 | 3217 | ', $mmessage, ' |
3060 | 3218 | </body> |
3061 | 3219 | </html>'; |
3062 | - elseif (!allowedTo('admin_forum')) |
|
3063 | - echo ' |
|
3220 | + } elseif (!allowedTo('admin_forum')) { |
|
3221 | + echo ' |
|
3064 | 3222 | <title>', $txt['template_parse_error'], '</title> |
3065 | 3223 | </head> |
3066 | 3224 | <body> |
@@ -3068,16 +3226,18 @@ discard block |
||
3068 | 3226 | ', $txt['template_parse_error_message'], ' |
3069 | 3227 | </body> |
3070 | 3228 | </html>'; |
3071 | - else |
|
3229 | + } else |
|
3072 | 3230 | { |
3073 | 3231 | require_once($sourcedir . '/Subs-Package.php'); |
3074 | 3232 | |
3075 | 3233 | $error = fetch_web_data($boardurl . strtr($filename, array($boarddir => '', strtr($boarddir, '\\', '/') => ''))); |
3076 | 3234 | $error_array = error_get_last(); |
3077 | - if (empty($error) && ini_get('track_errors') && !empty($error_array)) |
|
3078 | - $error = $error_array['message']; |
|
3079 | - if (empty($error)) |
|
3080 | - $error = $txt['template_parse_errmsg']; |
|
3235 | + if (empty($error) && ini_get('track_errors') && !empty($error_array)) { |
|
3236 | + $error = $error_array['message']; |
|
3237 | + } |
|
3238 | + if (empty($error)) { |
|
3239 | + $error = $txt['template_parse_errmsg']; |
|
3240 | + } |
|
3081 | 3241 | |
3082 | 3242 | $error = strtr($error, array('<b>' => '<strong>', '</b>' => '</strong>')); |
3083 | 3243 | |
@@ -3088,11 +3248,12 @@ discard block |
||
3088 | 3248 | <h3>', $txt['template_parse_error'], '</h3> |
3089 | 3249 | ', sprintf($txt['template_parse_error_details'], strtr($filename, array($boarddir => '', strtr($boarddir, '\\', '/') => ''))); |
3090 | 3250 | |
3091 | - if (!empty($error)) |
|
3092 | - echo ' |
|
3251 | + if (!empty($error)) { |
|
3252 | + echo ' |
|
3093 | 3253 | <hr> |
3094 | 3254 | |
3095 | 3255 | <div style="margin: 0 20px;"><pre>', strtr(strtr($error, array('<strong>' . $boarddir => '<strong>...', '<strong>' . strtr($boarddir, '\\', '/') => '<strong>...')), '\\', '/'), '</pre></div>'; |
3256 | + } |
|
3096 | 3257 | |
3097 | 3258 | // I know, I know... this is VERY COMPLICATED. Still, it's good. |
3098 | 3259 | if (preg_match('~ <strong>(\d+)</strong><br( /)?' . '>$~i', $error, $match) != 0) |
@@ -3102,10 +3263,11 @@ discard block |
||
3102 | 3263 | $data2 = preg_split('~\<br( /)?\>~', $data2); |
3103 | 3264 | |
3104 | 3265 | // Fix the PHP code stuff... |
3105 | - if (!isBrowser('gecko')) |
|
3106 | - $data2 = str_replace("\t", '<span style="white-space: pre;">' . "\t" . '</span>', $data2); |
|
3107 | - else |
|
3108 | - $data2 = str_replace('<pre style="display: inline;">' . "\t" . '</pre>', "\t", $data2); |
|
3266 | + if (!isBrowser('gecko')) { |
|
3267 | + $data2 = str_replace("\t", '<span style="white-space: pre;">' . "\t" . '</span>', $data2); |
|
3268 | + } else { |
|
3269 | + $data2 = str_replace('<pre style="display: inline;">' . "\t" . '</pre>', "\t", $data2); |
|
3270 | + } |
|
3109 | 3271 | |
3110 | 3272 | // Now we get to work around a bug in PHP where it doesn't escape <br>s! |
3111 | 3273 | $j = -1; |
@@ -3113,8 +3275,9 @@ discard block |
||
3113 | 3275 | { |
3114 | 3276 | $j++; |
3115 | 3277 | |
3116 | - if (substr_count($line, '<br>') == 0) |
|
3117 | - continue; |
|
3278 | + if (substr_count($line, '<br>') == 0) { |
|
3279 | + continue; |
|
3280 | + } |
|
3118 | 3281 | |
3119 | 3282 | $n = substr_count($line, '<br>'); |
3120 | 3283 | for ($i = 0; $i < $n; $i++) |
@@ -3133,38 +3296,42 @@ discard block |
||
3133 | 3296 | // Figure out what the color coding was before... |
3134 | 3297 | $line = max($match[1] - 9, 1); |
3135 | 3298 | $last_line = ''; |
3136 | - for ($line2 = $line - 1; $line2 > 1; $line2--) |
|
3137 | - if (strpos($data2[$line2], '<') !== false) |
|
3299 | + for ($line2 = $line - 1; $line2 > 1; $line2--) { |
|
3300 | + if (strpos($data2[$line2], '<') !== false) |
|
3138 | 3301 | { |
3139 | 3302 | if (preg_match('~(<[^/>]+>)[^<]*$~', $data2[$line2], $color_match) != 0) |
3140 | 3303 | $last_line = $color_match[1]; |
3304 | + } |
|
3141 | 3305 | break; |
3142 | 3306 | } |
3143 | 3307 | |
3144 | 3308 | // Show the relevant lines... |
3145 | 3309 | for ($n = min($match[1] + 4, count($data2) + 1); $line <= $n; $line++) |
3146 | 3310 | { |
3147 | - if ($line == $match[1]) |
|
3148 | - echo '</pre><div style="background-color: #ffb0b5;"><pre style="margin: 0;">'; |
|
3311 | + if ($line == $match[1]) { |
|
3312 | + echo '</pre><div style="background-color: #ffb0b5;"><pre style="margin: 0;">'; |
|
3313 | + } |
|
3149 | 3314 | |
3150 | 3315 | echo '<span style="color: black;">', sprintf('%' . strlen($n) . 's', $line), ':</span> '; |
3151 | - if (isset($data2[$line]) && $data2[$line] != '') |
|
3152 | - echo substr($data2[$line], 0, 2) == '</' ? preg_replace('~^</[^>]+>~', '', $data2[$line]) : $last_line . $data2[$line]; |
|
3316 | + if (isset($data2[$line]) && $data2[$line] != '') { |
|
3317 | + echo substr($data2[$line], 0, 2) == '</' ? preg_replace('~^</[^>]+>~', '', $data2[$line]) : $last_line . $data2[$line]; |
|
3318 | + } |
|
3153 | 3319 | |
3154 | 3320 | if (isset($data2[$line]) && preg_match('~(<[^/>]+>)[^<]*$~', $data2[$line], $color_match) != 0) |
3155 | 3321 | { |
3156 | 3322 | $last_line = $color_match[1]; |
3157 | 3323 | echo '</', substr($last_line, 1, 4), '>'; |
3324 | + } elseif ($last_line != '' && strpos($data2[$line], '<') !== false) { |
|
3325 | + $last_line = ''; |
|
3326 | + } elseif ($last_line != '' && $data2[$line] != '') { |
|
3327 | + echo '</', substr($last_line, 1, 4), '>'; |
|
3158 | 3328 | } |
3159 | - elseif ($last_line != '' && strpos($data2[$line], '<') !== false) |
|
3160 | - $last_line = ''; |
|
3161 | - elseif ($last_line != '' && $data2[$line] != '') |
|
3162 | - echo '</', substr($last_line, 1, 4), '>'; |
|
3163 | 3329 | |
3164 | - if ($line == $match[1]) |
|
3165 | - echo '</pre></div><pre style="margin: 0;">'; |
|
3166 | - else |
|
3167 | - echo "\n"; |
|
3330 | + if ($line == $match[1]) { |
|
3331 | + echo '</pre></div><pre style="margin: 0;">'; |
|
3332 | + } else { |
|
3333 | + echo "\n"; |
|
3334 | + } |
|
3168 | 3335 | } |
3169 | 3336 | |
3170 | 3337 | echo '</pre></div>'; |
@@ -3188,8 +3355,9 @@ discard block |
||
3188 | 3355 | global $db_type, $db_name, $ssi_db_user, $ssi_db_passwd, $sourcedir, $db_prefix, $db_port; |
3189 | 3356 | |
3190 | 3357 | // Figure out what type of database we are using. |
3191 | - if (empty($db_type) || !file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php')) |
|
3192 | - $db_type = 'mysql'; |
|
3358 | + if (empty($db_type) || !file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php')) { |
|
3359 | + $db_type = 'mysql'; |
|
3360 | + } |
|
3193 | 3361 | |
3194 | 3362 | // Load the file for the database. |
3195 | 3363 | require_once($sourcedir . '/Subs-Db-' . $db_type . '.php'); |
@@ -3197,8 +3365,9 @@ discard block |
||
3197 | 3365 | $db_options = array(); |
3198 | 3366 | |
3199 | 3367 | // Add in the port if needed |
3200 | - if (!empty($db_port)) |
|
3201 | - $db_options['port'] = $db_port; |
|
3368 | + if (!empty($db_port)) { |
|
3369 | + $db_options['port'] = $db_port; |
|
3370 | + } |
|
3202 | 3371 | |
3203 | 3372 | // 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. |
3204 | 3373 | if (SMF == 'SSI' && !empty($ssi_db_user) && !empty($ssi_db_passwd)) |
@@ -3217,13 +3386,15 @@ discard block |
||
3217 | 3386 | } |
3218 | 3387 | |
3219 | 3388 | // Safe guard here, if there isn't a valid connection lets put a stop to it. |
3220 | - if (!$db_connection) |
|
3221 | - display_db_error(); |
|
3389 | + if (!$db_connection) { |
|
3390 | + display_db_error(); |
|
3391 | + } |
|
3222 | 3392 | |
3223 | 3393 | // If in SSI mode fix up the prefix. |
3224 | - if (SMF == 'SSI') |
|
3225 | - db_fix_prefix($db_prefix, $db_name); |
|
3226 | -} |
|
3394 | + if (SMF == 'SSI') { |
|
3395 | + db_fix_prefix($db_prefix, $db_name); |
|
3396 | + } |
|
3397 | + } |
|
3227 | 3398 | |
3228 | 3399 | /** |
3229 | 3400 | * Try to load up a supported caching method. This is saved in $cacheAPI if we are not overriding it. |
@@ -3237,10 +3408,11 @@ discard block |
||
3237 | 3408 | global $sourcedir, $cacheAPI, $cache_accelerator; |
3238 | 3409 | |
3239 | 3410 | // Not overriding this and we have a cacheAPI, send it back. |
3240 | - if (empty($overrideCache) && is_object($cacheAPI)) |
|
3241 | - return $cacheAPI; |
|
3242 | - elseif (is_null($cacheAPI)) |
|
3243 | - $cacheAPI = false; |
|
3411 | + if (empty($overrideCache) && is_object($cacheAPI)) { |
|
3412 | + return $cacheAPI; |
|
3413 | + } elseif (is_null($cacheAPI)) { |
|
3414 | + $cacheAPI = false; |
|
3415 | + } |
|
3244 | 3416 | |
3245 | 3417 | // Make sure our class is in session. |
3246 | 3418 | require_once($sourcedir . '/Class-CacheAPI.php'); |
@@ -3261,8 +3433,9 @@ discard block |
||
3261 | 3433 | if (!$testAPI->isSupported()) |
3262 | 3434 | { |
3263 | 3435 | // Can we save ourselves? |
3264 | - if (!empty($fallbackSMF) && is_null($overrideCache) && $tryAccelerator != 'smf') |
|
3265 | - return loadCacheAccelerator(null, false); |
|
3436 | + if (!empty($fallbackSMF) && is_null($overrideCache) && $tryAccelerator != 'smf') { |
|
3437 | + return loadCacheAccelerator(null, false); |
|
3438 | + } |
|
3266 | 3439 | return false; |
3267 | 3440 | } |
3268 | 3441 | |
@@ -3274,9 +3447,9 @@ discard block |
||
3274 | 3447 | { |
3275 | 3448 | $cacheAPI = $testAPI; |
3276 | 3449 | return $cacheAPI; |
3450 | + } else { |
|
3451 | + return $testAPI; |
|
3277 | 3452 | } |
3278 | - else |
|
3279 | - return $testAPI; |
|
3280 | 3453 | } |
3281 | 3454 | } |
3282 | 3455 | |
@@ -3296,8 +3469,9 @@ discard block |
||
3296 | 3469 | |
3297 | 3470 | // @todo Why are we doing this if caching is disabled? |
3298 | 3471 | |
3299 | - if (function_exists('call_integration_hook')) |
|
3300 | - call_integration_hook('pre_cache_quick_get', array(&$key, &$file, &$function, &$params, &$level)); |
|
3472 | + if (function_exists('call_integration_hook')) { |
|
3473 | + call_integration_hook('pre_cache_quick_get', array(&$key, &$file, &$function, &$params, &$level)); |
|
3474 | + } |
|
3301 | 3475 | |
3302 | 3476 | /* Refresh the cache if either: |
3303 | 3477 | 1. Caching is disabled. |
@@ -3311,16 +3485,19 @@ discard block |
||
3311 | 3485 | require_once($sourcedir . '/' . $file); |
3312 | 3486 | $cache_block = call_user_func_array($function, $params); |
3313 | 3487 | |
3314 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= $level) |
|
3315 | - cache_put_data($key, $cache_block, $cache_block['expires'] - time()); |
|
3488 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= $level) { |
|
3489 | + cache_put_data($key, $cache_block, $cache_block['expires'] - time()); |
|
3490 | + } |
|
3316 | 3491 | } |
3317 | 3492 | |
3318 | 3493 | // Some cached data may need a freshening up after retrieval. |
3319 | - if (!empty($cache_block['post_retri_eval'])) |
|
3320 | - eval($cache_block['post_retri_eval']); |
|
3494 | + if (!empty($cache_block['post_retri_eval'])) { |
|
3495 | + eval($cache_block['post_retri_eval']); |
|
3496 | + } |
|
3321 | 3497 | |
3322 | - if (function_exists('call_integration_hook')) |
|
3323 | - call_integration_hook('post_cache_quick_get', array(&$cache_block)); |
|
3498 | + if (function_exists('call_integration_hook')) { |
|
3499 | + call_integration_hook('post_cache_quick_get', array(&$cache_block)); |
|
3500 | + } |
|
3324 | 3501 | |
3325 | 3502 | return $cache_block['data']; |
3326 | 3503 | } |
@@ -3347,8 +3524,9 @@ discard block |
||
3347 | 3524 | global $smcFunc, $cache_enable, $cacheAPI; |
3348 | 3525 | global $cache_hits, $cache_count, $db_show_debug; |
3349 | 3526 | |
3350 | - if (empty($cache_enable) || empty($cacheAPI)) |
|
3351 | - return; |
|
3527 | + if (empty($cache_enable) || empty($cacheAPI)) { |
|
3528 | + return; |
|
3529 | + } |
|
3352 | 3530 | |
3353 | 3531 | $cache_count = isset($cache_count) ? $cache_count + 1 : 1; |
3354 | 3532 | if (isset($db_show_debug) && $db_show_debug === true) |
@@ -3361,12 +3539,14 @@ discard block |
||
3361 | 3539 | $value = $value === null ? null : (isset($smcFunc['json_encode']) ? $smcFunc['json_encode']($value) : json_encode($value)); |
3362 | 3540 | $cacheAPI->putData($key, $value, $ttl); |
3363 | 3541 | |
3364 | - if (function_exists('call_integration_hook')) |
|
3365 | - call_integration_hook('cache_put_data', array(&$key, &$value, &$ttl)); |
|
3542 | + if (function_exists('call_integration_hook')) { |
|
3543 | + call_integration_hook('cache_put_data', array(&$key, &$value, &$ttl)); |
|
3544 | + } |
|
3366 | 3545 | |
3367 | - if (isset($db_show_debug) && $db_show_debug === true) |
|
3368 | - $cache_hits[$cache_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st)); |
|
3369 | -} |
|
3546 | + if (isset($db_show_debug) && $db_show_debug === true) { |
|
3547 | + $cache_hits[$cache_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st)); |
|
3548 | + } |
|
3549 | + } |
|
3370 | 3550 | |
3371 | 3551 | /** |
3372 | 3552 | * Gets the value from the cache specified by key, so long as it is not older than ttl seconds. |
@@ -3382,8 +3562,9 @@ discard block |
||
3382 | 3562 | global $smcFunc, $cache_enable, $cacheAPI; |
3383 | 3563 | global $cache_hits, $cache_count, $cache_misses, $cache_count_misses, $db_show_debug; |
3384 | 3564 | |
3385 | - if (empty($cache_enable) || empty($cacheAPI)) |
|
3386 | - return; |
|
3565 | + if (empty($cache_enable) || empty($cacheAPI)) { |
|
3566 | + return; |
|
3567 | + } |
|
3387 | 3568 | |
3388 | 3569 | $cache_count = isset($cache_count) ? $cache_count + 1 : 1; |
3389 | 3570 | if (isset($db_show_debug) && $db_show_debug === true) |
@@ -3403,16 +3584,18 @@ discard block |
||
3403 | 3584 | |
3404 | 3585 | if (empty($value)) |
3405 | 3586 | { |
3406 | - if (!is_array($cache_misses)) |
|
3407 | - $cache_misses = array(); |
|
3587 | + if (!is_array($cache_misses)) { |
|
3588 | + $cache_misses = array(); |
|
3589 | + } |
|
3408 | 3590 | |
3409 | 3591 | $cache_count_misses = isset($cache_count_misses) ? $cache_count_misses + 1 : 1; |
3410 | 3592 | $cache_misses[$cache_count_misses] = array('k' => $original_key, 'd' => 'get'); |
3411 | 3593 | } |
3412 | 3594 | } |
3413 | 3595 | |
3414 | - if (function_exists('call_integration_hook') && isset($value)) |
|
3415 | - call_integration_hook('cache_get_data', array(&$key, &$ttl, &$value)); |
|
3596 | + if (function_exists('call_integration_hook') && isset($value)) { |
|
3597 | + call_integration_hook('cache_get_data', array(&$key, &$ttl, &$value)); |
|
3598 | + } |
|
3416 | 3599 | |
3417 | 3600 | return empty($value) ? null : (isset($smcFunc['json_encode']) ? $smcFunc['json_decode']($value, true) : smf_json_decode($value, true)); |
3418 | 3601 | } |
@@ -3434,8 +3617,9 @@ discard block |
||
3434 | 3617 | global $cacheAPI; |
3435 | 3618 | |
3436 | 3619 | // If we can't get to the API, can't do this. |
3437 | - if (empty($cacheAPI)) |
|
3438 | - return; |
|
3620 | + if (empty($cacheAPI)) { |
|
3621 | + return; |
|
3622 | + } |
|
3439 | 3623 | |
3440 | 3624 | // Ask the API to do the heavy lifting. cleanCache also calls invalidateCache to be sure. |
3441 | 3625 | $cacheAPI->cleanCache($type); |
@@ -3460,8 +3644,9 @@ discard block |
||
3460 | 3644 | global $modSettings, $boardurl, $smcFunc, $image_proxy_enabled, $image_proxy_secret; |
3461 | 3645 | |
3462 | 3646 | // Come on! |
3463 | - if (empty($data)) |
|
3464 | - return array(); |
|
3647 | + if (empty($data)) { |
|
3648 | + return array(); |
|
3649 | + } |
|
3465 | 3650 | |
3466 | 3651 | // Set a nice default var. |
3467 | 3652 | $image = ''; |
@@ -3469,11 +3654,11 @@ discard block |
||
3469 | 3654 | // Gravatar has been set as mandatory! |
3470 | 3655 | if (!empty($modSettings['gravatarOverride'])) |
3471 | 3656 | { |
3472 | - if (!empty($modSettings['gravatarAllowExtraEmail']) && !empty($data['avatar']) && stristr($data['avatar'], 'gravatar://')) |
|
3473 | - $image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11)); |
|
3474 | - |
|
3475 | - else if (!empty($data['email'])) |
|
3476 | - $image = get_gravatar_url($data['email']); |
|
3657 | + if (!empty($modSettings['gravatarAllowExtraEmail']) && !empty($data['avatar']) && stristr($data['avatar'], 'gravatar://')) { |
|
3658 | + $image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11)); |
|
3659 | + } else if (!empty($data['email'])) { |
|
3660 | + $image = get_gravatar_url($data['email']); |
|
3661 | + } |
|
3477 | 3662 | } |
3478 | 3663 | |
3479 | 3664 | // Look if the user has a gravatar field or has set an external url as avatar. |
@@ -3485,54 +3670,60 @@ discard block |
||
3485 | 3670 | // Gravatar. |
3486 | 3671 | if (stristr($data['avatar'], 'gravatar://')) |
3487 | 3672 | { |
3488 | - if ($data['avatar'] == 'gravatar://') |
|
3489 | - $image = get_gravatar_url($data['email']); |
|
3490 | - |
|
3491 | - elseif (!empty($modSettings['gravatarAllowExtraEmail'])) |
|
3492 | - $image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11)); |
|
3673 | + if ($data['avatar'] == 'gravatar://') { |
|
3674 | + $image = get_gravatar_url($data['email']); |
|
3675 | + } elseif (!empty($modSettings['gravatarAllowExtraEmail'])) { |
|
3676 | + $image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11)); |
|
3677 | + } |
|
3493 | 3678 | } |
3494 | 3679 | |
3495 | 3680 | // External url. |
3496 | 3681 | else |
3497 | 3682 | { |
3498 | 3683 | // Using ssl? |
3499 | - if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($data['avatar'], 'http://') !== false) |
|
3500 | - $image = strtr($boardurl, array('http://' => 'https://')) . '/proxy.php?request=' . urlencode($data['avatar']) . '&hash=' . md5($data['avatar'] . $image_proxy_secret); |
|
3684 | + if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($data['avatar'], 'http://') !== false) { |
|
3685 | + $image = strtr($boardurl, array('http://' => 'https://')) . '/proxy.php?request=' . urlencode($data['avatar']) . '&hash=' . md5($data['avatar'] . $image_proxy_secret); |
|
3686 | + } |
|
3501 | 3687 | |
3502 | 3688 | // Just a plain external url. |
3503 | - else |
|
3504 | - $image = (stristr($data['avatar'], 'http://') || stristr($data['avatar'], 'https://')) ? $data['avatar'] : $modSettings['avatar_url'] . '/' . $data['avatar']; |
|
3689 | + else { |
|
3690 | + $image = (stristr($data['avatar'], 'http://') || stristr($data['avatar'], 'https://')) ? $data['avatar'] : $modSettings['avatar_url'] . '/' . $data['avatar']; |
|
3691 | + } |
|
3505 | 3692 | } |
3506 | 3693 | } |
3507 | 3694 | |
3508 | 3695 | // Perhaps this user has an attachment as avatar... |
3509 | - else if (!empty($data['filename'])) |
|
3510 | - $image = $modSettings['custom_avatar_url'] . '/' . $data['filename']; |
|
3696 | + else if (!empty($data['filename'])) { |
|
3697 | + $image = $modSettings['custom_avatar_url'] . '/' . $data['filename']; |
|
3698 | + } |
|
3511 | 3699 | |
3512 | 3700 | // Right... no avatar... use our default image. |
3513 | - else |
|
3514 | - $image = $modSettings['avatar_url'] . '/default.png'; |
|
3701 | + else { |
|
3702 | + $image = $modSettings['avatar_url'] . '/default.png'; |
|
3703 | + } |
|
3515 | 3704 | } |
3516 | 3705 | |
3517 | 3706 | call_integration_hook('integrate_set_avatar_data', array(&$image, &$data)); |
3518 | 3707 | |
3519 | 3708 | // 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. |
3520 | - if (!empty($image)) |
|
3521 | - return array( |
|
3709 | + if (!empty($image)) { |
|
3710 | + return array( |
|
3522 | 3711 | 'name' => !empty($data['avatar']) ? $data['avatar'] : '', |
3523 | 3712 | 'image' => '<img class="avatar" src="' . $image . '" />', |
3524 | 3713 | 'href' => $image, |
3525 | 3714 | 'url' => $image, |
3526 | 3715 | ); |
3716 | + } |
|
3527 | 3717 | |
3528 | 3718 | // Fallback to make life easier for everyone... |
3529 | - else |
|
3530 | - return array( |
|
3719 | + else { |
|
3720 | + return array( |
|
3531 | 3721 | 'name' => '', |
3532 | 3722 | 'image' => '', |
3533 | 3723 | 'href' => '', |
3534 | 3724 | 'url' => '', |
3535 | 3725 | ); |
3536 | -} |
|
3726 | + } |
|
3727 | + } |
|
3537 | 3728 | |
3538 | 3729 | ?> |
3539 | 3730 | \ No newline at end of file |
@@ -1334,7 +1334,7 @@ discard block |
||
1334 | 1334 | 'class' => 'centercol', |
1335 | 1335 | ), |
1336 | 1336 | 'data' => array( |
1337 | - 'function' => function ($rowData) |
|
1337 | + 'function' => function($rowData) |
|
1338 | 1338 | { |
1339 | 1339 | $isChecked = $rowData['disabled'] ? '' : ' checked'; |
1340 | 1340 | $onClickHandler = $rowData['can_show_register'] ? sprintf(' onclick="document.getElementById(\'reg_%1$s\').disabled = !this.checked;"', $rowData['id']) : ''; |
@@ -1350,7 +1350,7 @@ discard block |
||
1350 | 1350 | 'class' => 'centercol', |
1351 | 1351 | ), |
1352 | 1352 | 'data' => array( |
1353 | - 'function' => function ($rowData) |
|
1353 | + 'function' => function($rowData) |
|
1354 | 1354 | { |
1355 | 1355 | $isChecked = $rowData['on_register'] && !$rowData['disabled'] ? ' checked' : ''; |
1356 | 1356 | $isDisabled = $rowData['can_show_register'] ? '' : ' disabled'; |
@@ -1397,15 +1397,15 @@ discard block |
||
1397 | 1397 | 'value' => $txt['custom_profile_fieldorder'], |
1398 | 1398 | ), |
1399 | 1399 | 'data' => array( |
1400 | - 'function' => function ($rowData) use ($context, $txt, $scripturl) |
|
1400 | + 'function' => function($rowData) use ($context, $txt, $scripturl) |
|
1401 | 1401 | { |
1402 | - $return = '<p class="centertext bold_text">'. $rowData['field_order'] .'<br>'; |
|
1402 | + $return = '<p class="centertext bold_text">' . $rowData['field_order'] . '<br>'; |
|
1403 | 1403 | |
1404 | 1404 | if ($rowData['field_order'] > 1) |
1405 | - $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=up"><span class="toggle_up" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_up'] .'"></span></a>'; |
|
1405 | + $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=up"><span class="toggle_up" title="' . $txt['custom_edit_order_move'] . ' ' . $txt['custom_edit_order_up'] . '"></span></a>'; |
|
1406 | 1406 | |
1407 | 1407 | if ($rowData['field_order'] < $context['custFieldsMaxOrder']) |
1408 | - $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=down"><span class="toggle_down" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_down'] .'"></span></a>'; |
|
1408 | + $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=down"><span class="toggle_down" title="' . $txt['custom_edit_order_move'] . ' ' . $txt['custom_edit_order_down'] . '"></span></a>'; |
|
1409 | 1409 | |
1410 | 1410 | $return .= '</p>'; |
1411 | 1411 | |
@@ -1423,7 +1423,7 @@ discard block |
||
1423 | 1423 | 'value' => $txt['custom_profile_fieldname'], |
1424 | 1424 | ), |
1425 | 1425 | 'data' => array( |
1426 | - 'function' => function ($rowData) use ($scripturl) |
|
1426 | + 'function' => function($rowData) use ($scripturl) |
|
1427 | 1427 | { |
1428 | 1428 | return sprintf('<a href="%1$s?action=admin;area=featuresettings;sa=profileedit;fid=%2$d">%3$s</a><div class="smalltext">%4$s</div>', $scripturl, $rowData['id_field'], $rowData['field_name'], $rowData['field_desc']); |
1429 | 1429 | }, |
@@ -1439,7 +1439,7 @@ discard block |
||
1439 | 1439 | 'value' => $txt['custom_profile_fieldtype'], |
1440 | 1440 | ), |
1441 | 1441 | 'data' => array( |
1442 | - 'function' => function ($rowData) use ($txt) |
|
1442 | + 'function' => function($rowData) use ($txt) |
|
1443 | 1443 | { |
1444 | 1444 | $textKey = sprintf('custom_profile_type_%1$s', $rowData['field_type']); |
1445 | 1445 | return isset($txt[$textKey]) ? $txt[$textKey] : $textKey; |
@@ -1457,7 +1457,7 @@ discard block |
||
1457 | 1457 | 'value' => $txt['custom_profile_active'], |
1458 | 1458 | ), |
1459 | 1459 | 'data' => array( |
1460 | - 'function' => function ($rowData) use ($txt) |
|
1460 | + 'function' => function($rowData) use ($txt) |
|
1461 | 1461 | { |
1462 | 1462 | return $rowData['active'] ? $txt['yes'] : $txt['no']; |
1463 | 1463 | }, |
@@ -1474,7 +1474,7 @@ discard block |
||
1474 | 1474 | 'value' => $txt['custom_profile_placement'], |
1475 | 1475 | ), |
1476 | 1476 | 'data' => array( |
1477 | - 'function' => function ($rowData) |
|
1477 | + 'function' => function($rowData) |
|
1478 | 1478 | { |
1479 | 1479 | global $txt, $context; |
1480 | 1480 | |
@@ -1709,7 +1709,7 @@ discard block |
||
1709 | 1709 | redirectexit('action=admin;area=featuresettings;sa=profile'); // @todo implement an error handler |
1710 | 1710 | |
1711 | 1711 | // All good, proceed. |
1712 | - $smcFunc['db_query']('',' |
|
1712 | + $smcFunc['db_query']('', ' |
|
1713 | 1713 | UPDATE {db_prefix}custom_fields |
1714 | 1714 | SET field_order = {int:old_order} |
1715 | 1715 | WHERE field_order = {int:new_order}', |
@@ -1718,7 +1718,7 @@ discard block |
||
1718 | 1718 | 'old_order' => $context['field']['order'], |
1719 | 1719 | ) |
1720 | 1720 | ); |
1721 | - $smcFunc['db_query']('',' |
|
1721 | + $smcFunc['db_query']('', ' |
|
1722 | 1722 | UPDATE {db_prefix}custom_fields |
1723 | 1723 | SET field_order = {int:new_order} |
1724 | 1724 | WHERE id_field = {int:id_field}', |
@@ -1820,7 +1820,7 @@ discard block |
||
1820 | 1820 | $smcFunc['db_free_result']($request); |
1821 | 1821 | |
1822 | 1822 | $unique = false; |
1823 | - for ($i = 0; !$unique && $i < 9; $i ++) |
|
1823 | + for ($i = 0; !$unique && $i < 9; $i++) |
|
1824 | 1824 | { |
1825 | 1825 | if (!in_array($col_name, $current_fields)) |
1826 | 1826 | $unique = true; |
@@ -1993,7 +1993,7 @@ discard block |
||
1993 | 1993 | ); |
1994 | 1994 | |
1995 | 1995 | // Re-arrange the order. |
1996 | - $smcFunc['db_query']('',' |
|
1996 | + $smcFunc['db_query']('', ' |
|
1997 | 1997 | UPDATE {db_prefix}custom_fields |
1998 | 1998 | SET field_order = field_order - 1 |
1999 | 1999 | WHERE field_order > {int:current_order}', |
@@ -2257,7 +2257,7 @@ discard block |
||
2257 | 2257 | $context['token_check'] = 'noti-admin'; |
2258 | 2258 | |
2259 | 2259 | // Specify our action since we'll want to post back here instead of the profile |
2260 | - $context['action'] = 'action=admin;area=featuresettings;sa=alerts;'. $context['session_var'] .'='. $context['session_id']; |
|
2260 | + $context['action'] = 'action=admin;area=featuresettings;sa=alerts;' . $context['session_var'] . '=' . $context['session_id']; |
|
2261 | 2261 | |
2262 | 2262 | loadTemplate('Profile'); |
2263 | 2263 | loadLanguage('Profile'); |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | * @version 2.1 Beta 4 |
15 | 15 | */ |
16 | 16 | |
17 | -if (!defined('SMF')) |
|
17 | +if (!defined('SMF')) { |
|
18 | 18 | die('No direct access...'); |
19 | +} |
|
19 | 20 | |
20 | 21 | /** |
21 | 22 | * This function makes sure the requested subaction does exists, if it doesn't, it sets a default action or. |
@@ -206,16 +207,18 @@ discard block |
||
206 | 207 | { |
207 | 208 | $all_zones = timezone_identifiers_list(); |
208 | 209 | // Make sure we set the value to the same as the printed value. |
209 | - foreach ($all_zones as $zone) |
|
210 | - $config_vars['default_timezone'][2][$zone] = $zone; |
|
210 | + foreach ($all_zones as $zone) { |
|
211 | + $config_vars['default_timezone'][2][$zone] = $zone; |
|
212 | + } |
|
213 | + } else { |
|
214 | + unset($config_vars['default_timezone']); |
|
211 | 215 | } |
212 | - else |
|
213 | - unset($config_vars['default_timezone']); |
|
214 | 216 | |
215 | 217 | call_integration_hook('integrate_modify_basic_settings', array(&$config_vars)); |
216 | 218 | |
217 | - if ($return_config) |
|
218 | - return $config_vars; |
|
219 | + if ($return_config) { |
|
220 | + return $config_vars; |
|
221 | + } |
|
219 | 222 | |
220 | 223 | // Saving? |
221 | 224 | if (isset($_GET['save'])) |
@@ -223,8 +226,9 @@ discard block |
||
223 | 226 | checkSession(); |
224 | 227 | |
225 | 228 | // Prevent absurd boundaries here - make it a day tops. |
226 | - if (isset($_POST['lastActive'])) |
|
227 | - $_POST['lastActive'] = min((int) $_POST['lastActive'], 1440); |
|
229 | + if (isset($_POST['lastActive'])) { |
|
230 | + $_POST['lastActive'] = min((int) $_POST['lastActive'], 1440); |
|
231 | + } |
|
228 | 232 | |
229 | 233 | call_integration_hook('integrate_save_basic_settings'); |
230 | 234 | |
@@ -269,8 +273,9 @@ discard block |
||
269 | 273 | |
270 | 274 | call_integration_hook('integrate_modify_bbc_settings', array(&$config_vars)); |
271 | 275 | |
272 | - if ($return_config) |
|
273 | - return $config_vars; |
|
276 | + if ($return_config) { |
|
277 | + return $config_vars; |
|
278 | + } |
|
274 | 279 | |
275 | 280 | // Setup the template. |
276 | 281 | require_once($sourcedir . '/ManageServer.php'); |
@@ -287,13 +292,15 @@ discard block |
||
287 | 292 | |
288 | 293 | // Clean up the tags. |
289 | 294 | $bbcTags = array(); |
290 | - foreach (parse_bbc(false) as $tag) |
|
291 | - $bbcTags[] = $tag['tag']; |
|
295 | + foreach (parse_bbc(false) as $tag) { |
|
296 | + $bbcTags[] = $tag['tag']; |
|
297 | + } |
|
292 | 298 | |
293 | - if (!isset($_POST['disabledBBC_enabledTags'])) |
|
294 | - $_POST['disabledBBC_enabledTags'] = array(); |
|
295 | - elseif (!is_array($_POST['disabledBBC_enabledTags'])) |
|
296 | - $_POST['disabledBBC_enabledTags'] = array($_POST['disabledBBC_enabledTags']); |
|
299 | + if (!isset($_POST['disabledBBC_enabledTags'])) { |
|
300 | + $_POST['disabledBBC_enabledTags'] = array(); |
|
301 | + } elseif (!is_array($_POST['disabledBBC_enabledTags'])) { |
|
302 | + $_POST['disabledBBC_enabledTags'] = array($_POST['disabledBBC_enabledTags']); |
|
303 | + } |
|
297 | 304 | // Work out what is actually disabled! |
298 | 305 | $_POST['disabledBBC'] = implode(',', array_diff($bbcTags, $_POST['disabledBBC_enabledTags'])); |
299 | 306 | |
@@ -337,8 +344,9 @@ discard block |
||
337 | 344 | |
338 | 345 | call_integration_hook('integrate_layout_settings', array(&$config_vars)); |
339 | 346 | |
340 | - if ($return_config) |
|
341 | - return $config_vars; |
|
347 | + if ($return_config) { |
|
348 | + return $config_vars; |
|
349 | + } |
|
342 | 350 | |
343 | 351 | // Saving? |
344 | 352 | if (isset($_GET['save'])) |
@@ -379,8 +387,9 @@ discard block |
||
379 | 387 | |
380 | 388 | call_integration_hook('integrate_likes_settings', array(&$config_vars)); |
381 | 389 | |
382 | - if ($return_config) |
|
383 | - return $config_vars; |
|
390 | + if ($return_config) { |
|
391 | + return $config_vars; |
|
392 | + } |
|
384 | 393 | |
385 | 394 | // Saving? |
386 | 395 | if (isset($_GET['save'])) |
@@ -418,8 +427,9 @@ discard block |
||
418 | 427 | |
419 | 428 | call_integration_hook('integrate_mentions_settings', array(&$config_vars)); |
420 | 429 | |
421 | - if ($return_config) |
|
422 | - return $config_vars; |
|
430 | + if ($return_config) { |
|
431 | + return $config_vars; |
|
432 | + } |
|
423 | 433 | |
424 | 434 | // Saving? |
425 | 435 | if (isset($_GET['save'])) |
@@ -463,8 +473,8 @@ discard block |
||
463 | 473 | 'enable' => array('check', 'warning_enable'), |
464 | 474 | ); |
465 | 475 | |
466 | - if (!empty($modSettings['warning_settings']) && $currently_enabled) |
|
467 | - $config_vars += array( |
|
476 | + if (!empty($modSettings['warning_settings']) && $currently_enabled) { |
|
477 | + $config_vars += array( |
|
468 | 478 | '', |
469 | 479 | array('int', 'warning_watch', 'subtext' => $txt['setting_warning_watch_note'] . ' ' . $txt['zero_to_disable']), |
470 | 480 | 'moderate' => array('int', 'warning_moderate', 'subtext' => $txt['setting_warning_moderate_note'] . ' ' . $txt['zero_to_disable']), |
@@ -473,15 +483,18 @@ discard block |
||
473 | 483 | 'rem2' => array('int', 'warning_decrement', 'subtext' => $txt['setting_warning_decrement_note'] . ' ' . $txt['zero_to_disable']), |
474 | 484 | array('permissions', 'view_warning'), |
475 | 485 | ); |
486 | + } |
|
476 | 487 | |
477 | 488 | call_integration_hook('integrate_warning_settings', array(&$config_vars)); |
478 | 489 | |
479 | - if ($return_config) |
|
480 | - return $config_vars; |
|
490 | + if ($return_config) { |
|
491 | + return $config_vars; |
|
492 | + } |
|
481 | 493 | |
482 | 494 | // Cannot use moderation if post moderation is not enabled. |
483 | - if (!$modSettings['postmod_active']) |
|
484 | - unset($config_vars['moderate']); |
|
495 | + if (!$modSettings['postmod_active']) { |
|
496 | + unset($config_vars['moderate']); |
|
497 | + } |
|
485 | 498 | |
486 | 499 | // Will need the utility functions from here. |
487 | 500 | require_once($sourcedir . '/ManageServer.php'); |
@@ -506,16 +519,16 @@ discard block |
||
506 | 519 | 'warning_watch' => 10, |
507 | 520 | 'warning_mute' => 60, |
508 | 521 | ); |
509 | - if ($modSettings['postmod_active']) |
|
510 | - $vars['warning_moderate'] = 35; |
|
522 | + if ($modSettings['postmod_active']) { |
|
523 | + $vars['warning_moderate'] = 35; |
|
524 | + } |
|
511 | 525 | |
512 | 526 | foreach ($vars as $var => $value) |
513 | 527 | { |
514 | 528 | $config_vars[] = array('int', $var); |
515 | 529 | $_POST[$var] = $value; |
516 | 530 | } |
517 | - } |
|
518 | - else |
|
531 | + } else |
|
519 | 532 | { |
520 | 533 | $_POST['warning_watch'] = min($_POST['warning_watch'], 100); |
521 | 534 | $_POST['warning_moderate'] = $modSettings['postmod_active'] ? min($_POST['warning_moderate'], 100) : 0; |
@@ -603,8 +616,9 @@ discard block |
||
603 | 616 | |
604 | 617 | call_integration_hook('integrate_spam_settings', array(&$config_vars)); |
605 | 618 | |
606 | - if ($return_config) |
|
607 | - return $config_vars; |
|
619 | + if ($return_config) { |
|
620 | + return $config_vars; |
|
621 | + } |
|
608 | 622 | |
609 | 623 | // You need to be an admin to edit settings! |
610 | 624 | isAllowedTo('admin_forum'); |
@@ -638,8 +652,9 @@ discard block |
||
638 | 652 | |
639 | 653 | if (empty($context['qa_by_lang'][strtr($language, array('-utf8' => ''))]) && !empty($context['question_answers'])) |
640 | 654 | { |
641 | - if (empty($context['settings_insert_above'])) |
|
642 | - $context['settings_insert_above'] = ''; |
|
655 | + if (empty($context['settings_insert_above'])) { |
|
656 | + $context['settings_insert_above'] = ''; |
|
657 | + } |
|
643 | 658 | |
644 | 659 | $context['settings_insert_above'] .= '<div class="noticebox">' . sprintf($txt['question_not_defined'], $context['languages'][$language]['name']) . '</div>'; |
645 | 660 | } |
@@ -682,8 +697,9 @@ discard block |
||
682 | 697 | $_POST['pm_spam_settings'] = (int) $_POST['max_pm_recipients'] . ',' . (int) $_POST['pm_posts_verification'] . ',' . (int) $_POST['pm_posts_per_hour']; |
683 | 698 | |
684 | 699 | // Hack in guest requiring verification! |
685 | - if (empty($_POST['posts_require_captcha']) && !empty($_POST['guests_require_captcha'])) |
|
686 | - $_POST['posts_require_captcha'] = -1; |
|
700 | + if (empty($_POST['posts_require_captcha']) && !empty($_POST['guests_require_captcha'])) { |
|
701 | + $_POST['posts_require_captcha'] = -1; |
|
702 | + } |
|
687 | 703 | |
688 | 704 | $save_vars = $config_vars; |
689 | 705 | unset($save_vars['pm1'], $save_vars['pm2'], $save_vars['pm3'], $save_vars['guest_verify']); |
@@ -700,14 +716,16 @@ discard block |
||
700 | 716 | foreach ($context['qa_languages'] as $lang_id => $dummy) |
701 | 717 | { |
702 | 718 | // If we had some questions for this language before, but don't now, delete everything from that language. |
703 | - if ((!isset($_POST['question'][$lang_id]) || !is_array($_POST['question'][$lang_id])) && !empty($context['qa_by_lang'][$lang_id])) |
|
704 | - $changes['delete'] = array_merge($questions['delete'], $context['qa_by_lang'][$lang_id]); |
|
719 | + if ((!isset($_POST['question'][$lang_id]) || !is_array($_POST['question'][$lang_id])) && !empty($context['qa_by_lang'][$lang_id])) { |
|
720 | + $changes['delete'] = array_merge($questions['delete'], $context['qa_by_lang'][$lang_id]); |
|
721 | + } |
|
705 | 722 | |
706 | 723 | // Now step through and see if any existing questions no longer exist. |
707 | - if (!empty($context['qa_by_lang'][$lang_id])) |
|
708 | - foreach ($context['qa_by_lang'][$lang_id] as $q_id) |
|
724 | + if (!empty($context['qa_by_lang'][$lang_id])) { |
|
725 | + foreach ($context['qa_by_lang'][$lang_id] as $q_id) |
|
709 | 726 | if (empty($_POST['question'][$lang_id][$q_id])) |
710 | 727 | $changes['delete'][] = $q_id; |
728 | + } |
|
711 | 729 | |
712 | 730 | // Now let's see if there are new questions or ones that need updating. |
713 | 731 | if (isset($_POST['question'][$lang_id])) |
@@ -716,14 +734,16 @@ discard block |
||
716 | 734 | { |
717 | 735 | // Ignore junky ids. |
718 | 736 | $q_id = (int) $q_id; |
719 | - if ($q_id <= 0) |
|
720 | - continue; |
|
737 | + if ($q_id <= 0) { |
|
738 | + continue; |
|
739 | + } |
|
721 | 740 | |
722 | 741 | // Check the question isn't empty (because they want to delete it?) |
723 | 742 | if (empty($question) || trim($question) == '') |
724 | 743 | { |
725 | - if (isset($context['question_answers'][$q_id])) |
|
726 | - $changes['delete'][] = $q_id; |
|
744 | + if (isset($context['question_answers'][$q_id])) { |
|
745 | + $changes['delete'][] = $q_id; |
|
746 | + } |
|
727 | 747 | continue; |
728 | 748 | } |
729 | 749 | $question = $smcFunc['htmlspecialchars'](trim($question)); |
@@ -731,19 +751,22 @@ discard block |
||
731 | 751 | // Get the answers. Firstly check there actually might be some. |
732 | 752 | if (!isset($_POST['answer'][$lang_id][$q_id]) || !is_array($_POST['answer'][$lang_id][$q_id])) |
733 | 753 | { |
734 | - if (isset($context['question_answers'][$q_id])) |
|
735 | - $changes['delete'][] = $q_id; |
|
754 | + if (isset($context['question_answers'][$q_id])) { |
|
755 | + $changes['delete'][] = $q_id; |
|
756 | + } |
|
736 | 757 | continue; |
737 | 758 | } |
738 | 759 | // Now get them and check that they might be viable. |
739 | 760 | $answers = array(); |
740 | - foreach ($_POST['answer'][$lang_id][$q_id] as $answer) |
|
741 | - if (!empty($answer) && trim($answer) !== '') |
|
761 | + foreach ($_POST['answer'][$lang_id][$q_id] as $answer) { |
|
762 | + if (!empty($answer) && trim($answer) !== '') |
|
742 | 763 | $answers[] = $smcFunc['htmlspecialchars'](trim($answer)); |
764 | + } |
|
743 | 765 | if (empty($answers)) |
744 | 766 | { |
745 | - if (isset($context['question_answers'][$q_id])) |
|
746 | - $changes['delete'][] = $q_id; |
|
767 | + if (isset($context['question_answers'][$q_id])) { |
|
768 | + $changes['delete'][] = $q_id; |
|
769 | + } |
|
747 | 770 | continue; |
748 | 771 | } |
749 | 772 | $answers = $smcFunc['json_encode']($answers); |
@@ -753,16 +776,17 @@ discard block |
||
753 | 776 | { |
754 | 777 | // New question. Now, we don't want to randomly consume ids, so we'll set those, rather than trusting the browser's supplied ids. |
755 | 778 | $changes['insert'][] = array($lang_id, $question, $answers); |
756 | - } |
|
757 | - else |
|
779 | + } else |
|
758 | 780 | { |
759 | 781 | // It's an existing question. Let's see what's changed, if anything. |
760 | - if ($lang_id != $context['question_answers'][$q_id]['lngfile'] || $question != $context['question_answers'][$q_id]['question'] || $answers != $context['question_answers'][$q_id]['answers']) |
|
761 | - $changes['replace'][$q_id] = array('lngfile' => $lang_id, 'question' => $question, 'answers' => $answers); |
|
782 | + if ($lang_id != $context['question_answers'][$q_id]['lngfile'] || $question != $context['question_answers'][$q_id]['question'] || $answers != $context['question_answers'][$q_id]['answers']) { |
|
783 | + $changes['replace'][$q_id] = array('lngfile' => $lang_id, 'question' => $question, 'answers' => $answers); |
|
784 | + } |
|
762 | 785 | } |
763 | 786 | |
764 | - if (!isset($qs_per_lang[$lang_id])) |
|
765 | - $qs_per_lang[$lang_id] = 0; |
|
787 | + if (!isset($qs_per_lang[$lang_id])) { |
|
788 | + $qs_per_lang[$lang_id] = 0; |
|
789 | + } |
|
766 | 790 | $qs_per_lang[$lang_id]++; |
767 | 791 | } |
768 | 792 | } |
@@ -812,8 +836,9 @@ discard block |
||
812 | 836 | |
813 | 837 | // Lastly, the count of messages needs to be no more than the lowest number of questions for any one language. |
814 | 838 | $count_questions = empty($qs_per_lang) ? 0 : min($qs_per_lang); |
815 | - if (empty($count_questions) || $_POST['qa_verification_number'] > $count_questions) |
|
816 | - $_POST['qa_verification_number'] = $count_questions; |
|
839 | + if (empty($count_questions) || $_POST['qa_verification_number'] > $count_questions) { |
|
840 | + $_POST['qa_verification_number'] = $count_questions; |
|
841 | + } |
|
817 | 842 | |
818 | 843 | call_integration_hook('integrate_save_spam_settings', array(&$save_vars)); |
819 | 844 | |
@@ -828,24 +853,27 @@ discard block |
||
828 | 853 | |
829 | 854 | $character_range = array_merge(range('A', 'H'), array('K', 'M', 'N', 'P', 'R'), range('T', 'Y')); |
830 | 855 | $_SESSION['visual_verification_code'] = ''; |
831 | - for ($i = 0; $i < 6; $i++) |
|
832 | - $_SESSION['visual_verification_code'] .= $character_range[array_rand($character_range)]; |
|
856 | + for ($i = 0; $i < 6; $i++) { |
|
857 | + $_SESSION['visual_verification_code'] .= $character_range[array_rand($character_range)]; |
|
858 | + } |
|
833 | 859 | |
834 | 860 | // Some javascript for CAPTCHA. |
835 | 861 | $context['settings_post_javascript'] = ''; |
836 | - if ($context['use_graphic_library']) |
|
837 | - $context['settings_post_javascript'] .= ' |
|
862 | + if ($context['use_graphic_library']) { |
|
863 | + $context['settings_post_javascript'] .= ' |
|
838 | 864 | function refreshImages() |
839 | 865 | { |
840 | 866 | var imageType = document.getElementById(\'visual_verification_type\').value; |
841 | 867 | document.getElementById(\'verification_image\').src = \'' . $context['verification_image_href'] . ';type=\' + imageType; |
842 | 868 | }'; |
869 | + } |
|
843 | 870 | |
844 | 871 | // Show the image itself, or text saying we can't. |
845 | - if ($context['use_graphic_library']) |
|
846 | - $config_vars['vv']['postinput'] = '<br><img src="' . $context['verification_image_href'] . ';type=' . (empty($modSettings['visual_verification_type']) ? 0 : $modSettings['visual_verification_type']) . '" alt="' . $txt['setting_image_verification_sample'] . '" id="verification_image"><br>'; |
|
847 | - else |
|
848 | - $config_vars['vv']['postinput'] = '<br><span class="smalltext">' . $txt['setting_image_verification_nogd'] . '</span>'; |
|
872 | + if ($context['use_graphic_library']) { |
|
873 | + $config_vars['vv']['postinput'] = '<br><img src="' . $context['verification_image_href'] . ';type=' . (empty($modSettings['visual_verification_type']) ? 0 : $modSettings['visual_verification_type']) . '" alt="' . $txt['setting_image_verification_sample'] . '" id="verification_image"><br>'; |
|
874 | + } else { |
|
875 | + $config_vars['vv']['postinput'] = '<br><span class="smalltext">' . $txt['setting_image_verification_nogd'] . '</span>'; |
|
876 | + } |
|
849 | 877 | |
850 | 878 | // Hack for PM spam settings. |
851 | 879 | list ($modSettings['max_pm_recipients'], $modSettings['pm_posts_verification'], $modSettings['pm_posts_per_hour']) = explode(',', $modSettings['pm_spam_settings']); |
@@ -855,9 +883,10 @@ discard block |
||
855 | 883 | $modSettings['posts_require_captcha'] = !isset($modSettings['posts_require_captcha']) || $modSettings['posts_require_captcha'] == -1 ? 0 : $modSettings['posts_require_captcha']; |
856 | 884 | |
857 | 885 | // Some minor javascript for the guest post setting. |
858 | - if ($modSettings['posts_require_captcha']) |
|
859 | - $context['settings_post_javascript'] .= ' |
|
886 | + if ($modSettings['posts_require_captcha']) { |
|
887 | + $context['settings_post_javascript'] .= ' |
|
860 | 888 | document.getElementById(\'guests_require_captcha\').disabled = true;'; |
889 | + } |
|
861 | 890 | |
862 | 891 | // And everything else. |
863 | 892 | $context['post_url'] = $scripturl . '?action=admin;area=antispam;save'; |
@@ -904,8 +933,9 @@ discard block |
||
904 | 933 | |
905 | 934 | call_integration_hook('integrate_signature_settings', array(&$config_vars)); |
906 | 935 | |
907 | - if ($return_config) |
|
908 | - return $config_vars; |
|
936 | + if ($return_config) { |
|
937 | + return $config_vars; |
|
938 | + } |
|
909 | 939 | |
910 | 940 | // Setup the template. |
911 | 941 | $context['page_title'] = $txt['signature_settings']; |
@@ -960,8 +990,9 @@ discard block |
||
960 | 990 | $sig = strtr($row['signature'], array('<br>' => "\n")); |
961 | 991 | |
962 | 992 | // Max characters... |
963 | - if (!empty($sig_limits[1])) |
|
964 | - $sig = $smcFunc['substr']($sig, 0, $sig_limits[1]); |
|
993 | + if (!empty($sig_limits[1])) { |
|
994 | + $sig = $smcFunc['substr']($sig, 0, $sig_limits[1]); |
|
995 | + } |
|
965 | 996 | // Max lines... |
966 | 997 | if (!empty($sig_limits[2])) |
967 | 998 | { |
@@ -971,8 +1002,9 @@ discard block |
||
971 | 1002 | if ($sig[$i] == "\n") |
972 | 1003 | { |
973 | 1004 | $count++; |
974 | - if ($count >= $sig_limits[2]) |
|
975 | - $sig = substr($sig, 0, $i) . strtr(substr($sig, $i), array("\n" => ' ')); |
|
1005 | + if ($count >= $sig_limits[2]) { |
|
1006 | + $sig = substr($sig, 0, $i) . strtr(substr($sig, $i), array("\n" => ' ')); |
|
1007 | + } |
|
976 | 1008 | } |
977 | 1009 | } |
978 | 1010 | } |
@@ -983,17 +1015,19 @@ discard block |
||
983 | 1015 | { |
984 | 1016 | $limit_broke = 0; |
985 | 1017 | // Attempt to allow all sizes of abuse, so to speak. |
986 | - if ($matches[2][$ind] == 'px' && $size > $sig_limits[7]) |
|
987 | - $limit_broke = $sig_limits[7] . 'px'; |
|
988 | - elseif ($matches[2][$ind] == 'pt' && $size > ($sig_limits[7] * 0.75)) |
|
989 | - $limit_broke = ((int) $sig_limits[7] * 0.75) . 'pt'; |
|
990 | - elseif ($matches[2][$ind] == 'em' && $size > ((float) $sig_limits[7] / 16)) |
|
991 | - $limit_broke = ((float) $sig_limits[7] / 16) . 'em'; |
|
992 | - elseif ($matches[2][$ind] != 'px' && $matches[2][$ind] != 'pt' && $matches[2][$ind] != 'em' && $sig_limits[7] < 18) |
|
993 | - $limit_broke = 'large'; |
|
994 | - |
|
995 | - if ($limit_broke) |
|
996 | - $sig = str_replace($matches[0][$ind], '[size=' . $sig_limits[7] . 'px', $sig); |
|
1018 | + if ($matches[2][$ind] == 'px' && $size > $sig_limits[7]) { |
|
1019 | + $limit_broke = $sig_limits[7] . 'px'; |
|
1020 | + } elseif ($matches[2][$ind] == 'pt' && $size > ($sig_limits[7] * 0.75)) { |
|
1021 | + $limit_broke = ((int) $sig_limits[7] * 0.75) . 'pt'; |
|
1022 | + } elseif ($matches[2][$ind] == 'em' && $size > ((float) $sig_limits[7] / 16)) { |
|
1023 | + $limit_broke = ((float) $sig_limits[7] / 16) . 'em'; |
|
1024 | + } elseif ($matches[2][$ind] != 'px' && $matches[2][$ind] != 'pt' && $matches[2][$ind] != 'em' && $sig_limits[7] < 18) { |
|
1025 | + $limit_broke = 'large'; |
|
1026 | + } |
|
1027 | + |
|
1028 | + if ($limit_broke) { |
|
1029 | + $sig = str_replace($matches[0][$ind], '[size=' . $sig_limits[7] . 'px', $sig); |
|
1030 | + } |
|
997 | 1031 | } |
998 | 1032 | } |
999 | 1033 | |
@@ -1049,32 +1083,34 @@ discard block |
||
1049 | 1083 | $img_offset = false; |
1050 | 1084 | } |
1051 | 1085 | } |
1086 | + } else { |
|
1087 | + $replaces[$image] = ''; |
|
1052 | 1088 | } |
1053 | - else |
|
1054 | - $replaces[$image] = ''; |
|
1055 | 1089 | |
1056 | 1090 | continue; |
1057 | 1091 | } |
1058 | 1092 | |
1059 | 1093 | // Does it have predefined restraints? Width first. |
1060 | - if ($matches[6][$key]) |
|
1061 | - $matches[2][$key] = $matches[6][$key]; |
|
1094 | + if ($matches[6][$key]) { |
|
1095 | + $matches[2][$key] = $matches[6][$key]; |
|
1096 | + } |
|
1062 | 1097 | if ($matches[2][$key] && $sig_limits[5] && $matches[2][$key] > $sig_limits[5]) |
1063 | 1098 | { |
1064 | 1099 | $width = $sig_limits[5]; |
1065 | 1100 | $matches[4][$key] = $matches[4][$key] * ($width / $matches[2][$key]); |
1101 | + } elseif ($matches[2][$key]) { |
|
1102 | + $width = $matches[2][$key]; |
|
1066 | 1103 | } |
1067 | - elseif ($matches[2][$key]) |
|
1068 | - $width = $matches[2][$key]; |
|
1069 | 1104 | // ... and height. |
1070 | 1105 | if ($matches[4][$key] && $sig_limits[6] && $matches[4][$key] > $sig_limits[6]) |
1071 | 1106 | { |
1072 | 1107 | $height = $sig_limits[6]; |
1073 | - if ($width != -1) |
|
1074 | - $width = $width * ($height / $matches[4][$key]); |
|
1108 | + if ($width != -1) { |
|
1109 | + $width = $width * ($height / $matches[4][$key]); |
|
1110 | + } |
|
1111 | + } elseif ($matches[4][$key]) { |
|
1112 | + $height = $matches[4][$key]; |
|
1075 | 1113 | } |
1076 | - elseif ($matches[4][$key]) |
|
1077 | - $height = $matches[4][$key]; |
|
1078 | 1114 | |
1079 | 1115 | // If the dimensions are still not fixed - we need to check the actual image. |
1080 | 1116 | if (($width == -1 && $sig_limits[5]) || ($height == -1 && $sig_limits[6])) |
@@ -1092,12 +1128,13 @@ discard block |
||
1092 | 1128 | if ($sizes[1] > $sig_limits[6] && $sig_limits[6]) |
1093 | 1129 | { |
1094 | 1130 | $height = $sig_limits[6]; |
1095 | - if ($width == -1) |
|
1096 | - $width = $sizes[0]; |
|
1131 | + if ($width == -1) { |
|
1132 | + $width = $sizes[0]; |
|
1133 | + } |
|
1097 | 1134 | $width = $width * ($height / $sizes[1]); |
1135 | + } elseif ($width != -1) { |
|
1136 | + $height = $sizes[1]; |
|
1098 | 1137 | } |
1099 | - elseif ($width != -1) |
|
1100 | - $height = $sizes[1]; |
|
1101 | 1138 | } |
1102 | 1139 | } |
1103 | 1140 | |
@@ -1110,8 +1147,9 @@ discard block |
||
1110 | 1147 | // Record that we got one. |
1111 | 1148 | $image_count_holder[$image] = isset($image_count_holder[$image]) ? $image_count_holder[$image] + 1 : 1; |
1112 | 1149 | } |
1113 | - if (!empty($replaces)) |
|
1114 | - $sig = str_replace(array_keys($replaces), array_values($replaces), $sig); |
|
1150 | + if (!empty($replaces)) { |
|
1151 | + $sig = str_replace(array_keys($replaces), array_values($replaces), $sig); |
|
1152 | + } |
|
1115 | 1153 | } |
1116 | 1154 | } |
1117 | 1155 | // Try to fix disabled tags. |
@@ -1123,18 +1161,20 @@ discard block |
||
1123 | 1161 | |
1124 | 1162 | $sig = strtr($sig, array("\n" => '<br>')); |
1125 | 1163 | call_integration_hook('integrate_apply_signature_settings', array(&$sig, $sig_limits, $disabledTags)); |
1126 | - if ($sig != $row['signature']) |
|
1127 | - $changes[$row['id_member']] = $sig; |
|
1164 | + if ($sig != $row['signature']) { |
|
1165 | + $changes[$row['id_member']] = $sig; |
|
1166 | + } |
|
1167 | + } |
|
1168 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
1169 | + $done = true; |
|
1128 | 1170 | } |
1129 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
1130 | - $done = true; |
|
1131 | 1171 | $smcFunc['db_free_result']($request); |
1132 | 1172 | |
1133 | 1173 | // Do we need to delete what we have? |
1134 | 1174 | if (!empty($changes)) |
1135 | 1175 | { |
1136 | - foreach ($changes as $id => $sig) |
|
1137 | - $smcFunc['db_query']('', ' |
|
1176 | + foreach ($changes as $id => $sig) { |
|
1177 | + $smcFunc['db_query']('', ' |
|
1138 | 1178 | UPDATE {db_prefix}members |
1139 | 1179 | SET signature = {string:signature} |
1140 | 1180 | WHERE id_member = {int:id_member}', |
@@ -1143,11 +1183,13 @@ discard block |
||
1143 | 1183 | 'signature' => $sig, |
1144 | 1184 | ) |
1145 | 1185 | ); |
1186 | + } |
|
1146 | 1187 | } |
1147 | 1188 | |
1148 | 1189 | $_GET['step'] += 50; |
1149 | - if (!$done) |
|
1150 | - pauseSignatureApplySettings(); |
|
1190 | + if (!$done) { |
|
1191 | + pauseSignatureApplySettings(); |
|
1192 | + } |
|
1151 | 1193 | } |
1152 | 1194 | $settings_applied = true; |
1153 | 1195 | } |
@@ -1165,8 +1207,9 @@ discard block |
||
1165 | 1207 | ); |
1166 | 1208 | |
1167 | 1209 | // Temporarily make each setting a modSetting! |
1168 | - foreach ($context['signature_settings'] as $key => $value) |
|
1169 | - $modSettings['signature_' . $key] = $value; |
|
1210 | + foreach ($context['signature_settings'] as $key => $value) { |
|
1211 | + $modSettings['signature_' . $key] = $value; |
|
1212 | + } |
|
1170 | 1213 | |
1171 | 1214 | // Make sure we check the right tags! |
1172 | 1215 | $modSettings['bbc_disabled_signature_bbc'] = $disabledTags; |
@@ -1178,23 +1221,26 @@ discard block |
||
1178 | 1221 | |
1179 | 1222 | // Clean up the tag stuff! |
1180 | 1223 | $bbcTags = array(); |
1181 | - foreach (parse_bbc(false) as $tag) |
|
1182 | - $bbcTags[] = $tag['tag']; |
|
1224 | + foreach (parse_bbc(false) as $tag) { |
|
1225 | + $bbcTags[] = $tag['tag']; |
|
1226 | + } |
|
1183 | 1227 | |
1184 | - if (!isset($_POST['signature_bbc_enabledTags'])) |
|
1185 | - $_POST['signature_bbc_enabledTags'] = array(); |
|
1186 | - elseif (!is_array($_POST['signature_bbc_enabledTags'])) |
|
1187 | - $_POST['signature_bbc_enabledTags'] = array($_POST['signature_bbc_enabledTags']); |
|
1228 | + if (!isset($_POST['signature_bbc_enabledTags'])) { |
|
1229 | + $_POST['signature_bbc_enabledTags'] = array(); |
|
1230 | + } elseif (!is_array($_POST['signature_bbc_enabledTags'])) { |
|
1231 | + $_POST['signature_bbc_enabledTags'] = array($_POST['signature_bbc_enabledTags']); |
|
1232 | + } |
|
1188 | 1233 | |
1189 | 1234 | $sig_limits = array(); |
1190 | 1235 | foreach ($context['signature_settings'] as $key => $value) |
1191 | 1236 | { |
1192 | - if ($key == 'allow_smileys') |
|
1193 | - continue; |
|
1194 | - elseif ($key == 'max_smileys' && empty($_POST['signature_allow_smileys'])) |
|
1195 | - $sig_limits[] = -1; |
|
1196 | - else |
|
1197 | - $sig_limits[] = !empty($_POST['signature_' . $key]) ? max(1, (int) $_POST['signature_' . $key]) : 0; |
|
1237 | + if ($key == 'allow_smileys') { |
|
1238 | + continue; |
|
1239 | + } elseif ($key == 'max_smileys' && empty($_POST['signature_allow_smileys'])) { |
|
1240 | + $sig_limits[] = -1; |
|
1241 | + } else { |
|
1242 | + $sig_limits[] = !empty($_POST['signature_' . $key]) ? max(1, (int) $_POST['signature_' . $key]) : 0; |
|
1243 | + } |
|
1198 | 1244 | } |
1199 | 1245 | |
1200 | 1246 | call_integration_hook('integrate_save_signature_settings', array(&$sig_limits, &$bbcTags)); |
@@ -1227,12 +1273,14 @@ discard block |
||
1227 | 1273 | |
1228 | 1274 | // Try get more time... |
1229 | 1275 | @set_time_limit(600); |
1230 | - if (function_exists('apache_reset_timeout')) |
|
1231 | - @apache_reset_timeout(); |
|
1276 | + if (function_exists('apache_reset_timeout')) { |
|
1277 | + @apache_reset_timeout(); |
|
1278 | + } |
|
1232 | 1279 | |
1233 | 1280 | // Have we exhausted all the time we allowed? |
1234 | - if (time() - array_sum(explode(' ', $sig_start)) < 3) |
|
1235 | - return; |
|
1281 | + if (time() - array_sum(explode(' ', $sig_start)) < 3) { |
|
1282 | + return; |
|
1283 | + } |
|
1236 | 1284 | |
1237 | 1285 | $context['continue_get_data'] = '?action=admin;area=featuresettings;sa=sig;apply;step=' . $_GET['step'] . ';' . $context['session_var'] . '=' . $context['session_id']; |
1238 | 1286 | $context['page_title'] = $txt['not_done_title']; |
@@ -1278,9 +1326,10 @@ discard block |
||
1278 | 1326 | $disable_fields = array_flip($standard_fields); |
1279 | 1327 | if (!empty($_POST['active'])) |
1280 | 1328 | { |
1281 | - foreach ($_POST['active'] as $value) |
|
1282 | - if (isset($disable_fields[$value])) |
|
1329 | + foreach ($_POST['active'] as $value) { |
|
1330 | + if (isset($disable_fields[$value])) |
|
1283 | 1331 | unset($disable_fields[$value]); |
1332 | + } |
|
1284 | 1333 | } |
1285 | 1334 | // What we have left! |
1286 | 1335 | $changes['disabled_profile_fields'] = empty($disable_fields) ? '' : implode(',', array_keys($disable_fields)); |
@@ -1289,16 +1338,18 @@ discard block |
||
1289 | 1338 | $reg_fields = array(); |
1290 | 1339 | if (!empty($_POST['reg'])) |
1291 | 1340 | { |
1292 | - foreach ($_POST['reg'] as $value) |
|
1293 | - if (in_array($value, $standard_fields) && !isset($disable_fields[$value])) |
|
1341 | + foreach ($_POST['reg'] as $value) { |
|
1342 | + if (in_array($value, $standard_fields) && !isset($disable_fields[$value])) |
|
1294 | 1343 | $reg_fields[] = $value; |
1344 | + } |
|
1295 | 1345 | } |
1296 | 1346 | // What we have left! |
1297 | 1347 | $changes['registration_fields'] = empty($reg_fields) ? '' : implode(',', $reg_fields); |
1298 | 1348 | |
1299 | 1349 | $_SESSION['adm-save'] = true; |
1300 | - if (!empty($changes)) |
|
1301 | - updateSettings($changes); |
|
1350 | + if (!empty($changes)) { |
|
1351 | + updateSettings($changes); |
|
1352 | + } |
|
1302 | 1353 | } |
1303 | 1354 | |
1304 | 1355 | createToken('admin-scp'); |
@@ -1401,11 +1452,13 @@ discard block |
||
1401 | 1452 | { |
1402 | 1453 | $return = '<p class="centertext bold_text">'. $rowData['field_order'] .'<br>'; |
1403 | 1454 | |
1404 | - if ($rowData['field_order'] > 1) |
|
1405 | - $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=up"><span class="toggle_up" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_up'] .'"></span></a>'; |
|
1455 | + if ($rowData['field_order'] > 1) { |
|
1456 | + $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=up"><span class="toggle_up" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_up'] .'"></span></a>'; |
|
1457 | + } |
|
1406 | 1458 | |
1407 | - if ($rowData['field_order'] < $context['custFieldsMaxOrder']) |
|
1408 | - $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=down"><span class="toggle_down" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_down'] .'"></span></a>'; |
|
1459 | + if ($rowData['field_order'] < $context['custFieldsMaxOrder']) { |
|
1460 | + $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=down"><span class="toggle_down" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_down'] .'"></span></a>'; |
|
1461 | + } |
|
1409 | 1462 | |
1410 | 1463 | $return .= '</p>'; |
1411 | 1464 | |
@@ -1543,16 +1596,16 @@ discard block |
||
1543 | 1596 | $disabled_fields = isset($modSettings['disabled_profile_fields']) ? explode(',', $modSettings['disabled_profile_fields']) : array(); |
1544 | 1597 | $registration_fields = isset($modSettings['registration_fields']) ? explode(',', $modSettings['registration_fields']) : array(); |
1545 | 1598 | |
1546 | - foreach ($standard_fields as $field) |
|
1547 | - $list[] = array( |
|
1599 | + foreach ($standard_fields as $field) { |
|
1600 | + $list[] = array( |
|
1548 | 1601 | 'id' => $field, |
1549 | 1602 | 'label' => isset($txt['standard_profile_field_' . $field]) ? $txt['standard_profile_field_' . $field] : (isset($txt[$field]) ? $txt[$field] : $field), |
1550 | 1603 | 'disabled' => in_array($field, $disabled_fields), |
1551 | 1604 | 'on_register' => in_array($field, $registration_fields) && !in_array($field, $fields_no_registration), |
1552 | 1605 | 'can_show_register' => !in_array($field, $fields_no_registration), |
1553 | 1606 | ); |
1554 | - } |
|
1555 | - else |
|
1607 | + } |
|
1608 | + } else |
|
1556 | 1609 | { |
1557 | 1610 | // Load all the fields. |
1558 | 1611 | $request = $smcFunc['db_query']('', ' |
@@ -1566,8 +1619,9 @@ discard block |
||
1566 | 1619 | 'items_per_page' => $items_per_page, |
1567 | 1620 | ) |
1568 | 1621 | ); |
1569 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1570 | - $list[] = $row; |
|
1622 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1623 | + $list[] = $row; |
|
1624 | + } |
|
1571 | 1625 | $smcFunc['db_free_result']($request); |
1572 | 1626 | } |
1573 | 1627 | |
@@ -1633,9 +1687,9 @@ discard block |
||
1633 | 1687 | $context['field'] = array(); |
1634 | 1688 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1635 | 1689 | { |
1636 | - if ($row['field_type'] == 'textarea') |
|
1637 | - @list ($rows, $cols) = @explode(',', $row['default_value']); |
|
1638 | - else |
|
1690 | + if ($row['field_type'] == 'textarea') { |
|
1691 | + @list ($rows, $cols) = @explode(',', $row['default_value']); |
|
1692 | + } else |
|
1639 | 1693 | { |
1640 | 1694 | $rows = 3; |
1641 | 1695 | $cols = 30; |
@@ -1671,8 +1725,8 @@ discard block |
||
1671 | 1725 | } |
1672 | 1726 | |
1673 | 1727 | // Setup the default values as needed. |
1674 | - if (empty($context['field'])) |
|
1675 | - $context['field'] = array( |
|
1728 | + if (empty($context['field'])) { |
|
1729 | + $context['field'] = array( |
|
1676 | 1730 | 'name' => '', |
1677 | 1731 | 'col_name' => '???', |
1678 | 1732 | 'desc' => '', |
@@ -1697,6 +1751,7 @@ discard block |
||
1697 | 1751 | 'enclose' => '', |
1698 | 1752 | 'placement' => 0, |
1699 | 1753 | ); |
1754 | + } |
|
1700 | 1755 | |
1701 | 1756 | // Are we moving it? |
1702 | 1757 | if (isset($_GET['move']) && in_array($smcFunc['htmlspecialchars']($_GET['move']), $move_to)) |
@@ -1705,8 +1760,10 @@ discard block |
||
1705 | 1760 | $new_order = ($_GET['move'] == 'up' ? ($context['field']['order'] - 1) : ($context['field']['order'] + 1)); |
1706 | 1761 | |
1707 | 1762 | // Is this a valid position? |
1708 | - if ($new_order <= 0 || $new_order > $order_count) |
|
1709 | - redirectexit('action=admin;area=featuresettings;sa=profile'); // @todo implement an error handler |
|
1763 | + if ($new_order <= 0 || $new_order > $order_count) { |
|
1764 | + redirectexit('action=admin;area=featuresettings;sa=profile'); |
|
1765 | + } |
|
1766 | + // @todo implement an error handler |
|
1710 | 1767 | |
1711 | 1768 | // All good, proceed. |
1712 | 1769 | $smcFunc['db_query']('',' |
@@ -1737,12 +1794,14 @@ discard block |
||
1737 | 1794 | validateToken('admin-ecp'); |
1738 | 1795 | |
1739 | 1796 | // Everyone needs a name - even the (bracket) unknown... |
1740 | - if (trim($_POST['field_name']) == '') |
|
1741 | - redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $_GET['fid'] . ';msg=need_name'); |
|
1797 | + if (trim($_POST['field_name']) == '') { |
|
1798 | + redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $_GET['fid'] . ';msg=need_name'); |
|
1799 | + } |
|
1742 | 1800 | |
1743 | 1801 | // Regex you say? Do a very basic test to see if the pattern is valid |
1744 | - if (!empty($_POST['regex']) && @preg_match($_POST['regex'], 'dummy') === false) |
|
1745 | - redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $_GET['fid'] . ';msg=regex_error'); |
|
1802 | + if (!empty($_POST['regex']) && @preg_match($_POST['regex'], 'dummy') === false) { |
|
1803 | + redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $_GET['fid'] . ';msg=regex_error'); |
|
1804 | + } |
|
1746 | 1805 | |
1747 | 1806 | $_POST['field_name'] = $smcFunc['htmlspecialchars']($_POST['field_name']); |
1748 | 1807 | $_POST['field_desc'] = $smcFunc['htmlspecialchars']($_POST['field_desc']); |
@@ -1759,8 +1818,9 @@ discard block |
||
1759 | 1818 | |
1760 | 1819 | // Some masking stuff... |
1761 | 1820 | $mask = isset($_POST['mask']) ? $_POST['mask'] : ''; |
1762 | - if ($mask == 'regex' && isset($_POST['regex'])) |
|
1763 | - $mask .= $_POST['regex']; |
|
1821 | + if ($mask == 'regex' && isset($_POST['regex'])) { |
|
1822 | + $mask .= $_POST['regex']; |
|
1823 | + } |
|
1764 | 1824 | |
1765 | 1825 | $field_length = isset($_POST['max_length']) ? (int) $_POST['max_length'] : 255; |
1766 | 1826 | $enclose = isset($_POST['enclose']) ? $_POST['enclose'] : ''; |
@@ -1779,8 +1839,9 @@ discard block |
||
1779 | 1839 | $v = strtr($v, array(',' => '')); |
1780 | 1840 | |
1781 | 1841 | // Nada, zip, etc... |
1782 | - if (trim($v) == '') |
|
1783 | - continue; |
|
1842 | + if (trim($v) == '') { |
|
1843 | + continue; |
|
1844 | + } |
|
1784 | 1845 | |
1785 | 1846 | // Otherwise, save it boy. |
1786 | 1847 | $field_options .= $v . ','; |
@@ -1788,15 +1849,17 @@ discard block |
||
1788 | 1849 | $newOptions[$k] = $v; |
1789 | 1850 | |
1790 | 1851 | // Is it default? |
1791 | - if (isset($_POST['default_select']) && $_POST['default_select'] == $k) |
|
1792 | - $default = $v; |
|
1852 | + if (isset($_POST['default_select']) && $_POST['default_select'] == $k) { |
|
1853 | + $default = $v; |
|
1854 | + } |
|
1793 | 1855 | } |
1794 | 1856 | $field_options = substr($field_options, 0, -1); |
1795 | 1857 | } |
1796 | 1858 | |
1797 | 1859 | // Text area has default has dimensions |
1798 | - if ($_POST['field_type'] == 'textarea') |
|
1799 | - $default = (int) $_POST['rows'] . ',' . (int) $_POST['cols']; |
|
1860 | + if ($_POST['field_type'] == 'textarea') { |
|
1861 | + $default = (int) $_POST['rows'] . ',' . (int) $_POST['cols']; |
|
1862 | + } |
|
1800 | 1863 | |
1801 | 1864 | // Come up with the unique name? |
1802 | 1865 | if (empty($context['fid'])) |
@@ -1805,32 +1868,36 @@ discard block |
||
1805 | 1868 | preg_match('~([\w\d_-]+)~', $col_name, $matches); |
1806 | 1869 | |
1807 | 1870 | // If there is nothing to the name, then let's start out own - for foreign languages etc. |
1808 | - if (isset($matches[1])) |
|
1809 | - $col_name = $initial_col_name = 'cust_' . strtolower($matches[1]); |
|
1810 | - else |
|
1811 | - $col_name = $initial_col_name = 'cust_' . mt_rand(1, 9999); |
|
1871 | + if (isset($matches[1])) { |
|
1872 | + $col_name = $initial_col_name = 'cust_' . strtolower($matches[1]); |
|
1873 | + } else { |
|
1874 | + $col_name = $initial_col_name = 'cust_' . mt_rand(1, 9999); |
|
1875 | + } |
|
1812 | 1876 | |
1813 | 1877 | // Make sure this is unique. |
1814 | 1878 | $current_fields = array(); |
1815 | 1879 | $request = $smcFunc['db_query']('', ' |
1816 | 1880 | SELECT id_field, col_name |
1817 | 1881 | FROM {db_prefix}custom_fields'); |
1818 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1819 | - $current_fields[$row['id_field']] = $row['col_name']; |
|
1882 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1883 | + $current_fields[$row['id_field']] = $row['col_name']; |
|
1884 | + } |
|
1820 | 1885 | $smcFunc['db_free_result']($request); |
1821 | 1886 | |
1822 | 1887 | $unique = false; |
1823 | 1888 | for ($i = 0; !$unique && $i < 9; $i ++) |
1824 | 1889 | { |
1825 | - if (!in_array($col_name, $current_fields)) |
|
1826 | - $unique = true; |
|
1827 | - else |
|
1828 | - $col_name = $initial_col_name . $i; |
|
1890 | + if (!in_array($col_name, $current_fields)) { |
|
1891 | + $unique = true; |
|
1892 | + } else { |
|
1893 | + $col_name = $initial_col_name . $i; |
|
1894 | + } |
|
1829 | 1895 | } |
1830 | 1896 | |
1831 | 1897 | // Still not a unique column name? Leave it up to the user, then. |
1832 | - if (!$unique) |
|
1833 | - fatal_lang_error('custom_option_not_unique'); |
|
1898 | + if (!$unique) { |
|
1899 | + fatal_lang_error('custom_option_not_unique'); |
|
1900 | + } |
|
1834 | 1901 | } |
1835 | 1902 | // Work out what to do with the user data otherwise... |
1836 | 1903 | else |
@@ -1858,8 +1925,9 @@ discard block |
||
1858 | 1925 | // Work out what's changed! |
1859 | 1926 | foreach ($context['field']['options'] as $k => $option) |
1860 | 1927 | { |
1861 | - if (trim($option) == '') |
|
1862 | - continue; |
|
1928 | + if (trim($option) == '') { |
|
1929 | + continue; |
|
1930 | + } |
|
1863 | 1931 | |
1864 | 1932 | // Still exists? |
1865 | 1933 | if (in_array($option, $newOptions)) |
@@ -1873,8 +1941,8 @@ discard block |
||
1873 | 1941 | foreach ($optionChanges as $k => $option) |
1874 | 1942 | { |
1875 | 1943 | // Just been renamed? |
1876 | - if (!in_array($k, $takenKeys) && !empty($newOptions[$k])) |
|
1877 | - $smcFunc['db_query']('', ' |
|
1944 | + if (!in_array($k, $takenKeys) && !empty($newOptions[$k])) { |
|
1945 | + $smcFunc['db_query']('', ' |
|
1878 | 1946 | UPDATE {db_prefix}themes |
1879 | 1947 | SET value = {string:new_value} |
1880 | 1948 | WHERE variable = {string:current_column} |
@@ -1887,6 +1955,7 @@ discard block |
||
1887 | 1955 | 'old_value' => $option, |
1888 | 1956 | ) |
1889 | 1957 | ); |
1958 | + } |
|
1890 | 1959 | } |
1891 | 1960 | } |
1892 | 1961 | // @todo Maybe we should adjust based on new text length limits? |
@@ -1929,8 +1998,8 @@ discard block |
||
1929 | 1998 | ); |
1930 | 1999 | |
1931 | 2000 | // Just clean up any old selects - these are a pain! |
1932 | - if (($_POST['field_type'] == 'select' || $_POST['field_type'] == 'radio') && !empty($newOptions)) |
|
1933 | - $smcFunc['db_query']('', ' |
|
2001 | + if (($_POST['field_type'] == 'select' || $_POST['field_type'] == 'radio') && !empty($newOptions)) { |
|
2002 | + $smcFunc['db_query']('', ' |
|
1934 | 2003 | DELETE FROM {db_prefix}themes |
1935 | 2004 | WHERE variable = {string:current_column} |
1936 | 2005 | AND value NOT IN ({array_string:new_option_values}) |
@@ -1941,8 +2010,8 @@ discard block |
||
1941 | 2010 | 'current_column' => $context['field']['col_name'], |
1942 | 2011 | ) |
1943 | 2012 | ); |
1944 | - } |
|
1945 | - else |
|
2013 | + } |
|
2014 | + } else |
|
1946 | 2015 | { |
1947 | 2016 | // Gotta figure it out the order. |
1948 | 2017 | $new_order = $order_count > 1 ? ($order_count + 1) : 1; |
@@ -2116,11 +2185,13 @@ discard block |
||
2116 | 2185 | call_integration_hook('integrate_prune_settings', array(&$config_vars, &$prune_toggle, false)); |
2117 | 2186 | |
2118 | 2187 | $prune_toggle_dt = array(); |
2119 | - foreach ($prune_toggle as $item) |
|
2120 | - $prune_toggle_dt[] = 'setting_' . $item; |
|
2188 | + foreach ($prune_toggle as $item) { |
|
2189 | + $prune_toggle_dt[] = 'setting_' . $item; |
|
2190 | + } |
|
2121 | 2191 | |
2122 | - if ($return_config) |
|
2123 | - return $config_vars; |
|
2192 | + if ($return_config) { |
|
2193 | + return $config_vars; |
|
2194 | + } |
|
2124 | 2195 | |
2125 | 2196 | addInlineJavaScript(' |
2126 | 2197 | function togglePruned() |
@@ -2158,15 +2229,16 @@ discard block |
||
2158 | 2229 | $vals = array(); |
2159 | 2230 | foreach ($config_vars as $index => $dummy) |
2160 | 2231 | { |
2161 | - if (!is_array($dummy) || $index == 'pruningOptions' || !in_array($dummy[1], $prune_toggle)) |
|
2162 | - continue; |
|
2232 | + if (!is_array($dummy) || $index == 'pruningOptions' || !in_array($dummy[1], $prune_toggle)) { |
|
2233 | + continue; |
|
2234 | + } |
|
2163 | 2235 | |
2164 | 2236 | $vals[] = empty($_POST[$dummy[1]]) || $_POST[$dummy[1]] < 0 ? 0 : (int) $_POST[$dummy[1]]; |
2165 | 2237 | } |
2166 | 2238 | $_POST['pruningOptions'] = implode(',', $vals); |
2239 | + } else { |
|
2240 | + $_POST['pruningOptions'] = ''; |
|
2167 | 2241 | } |
2168 | - else |
|
2169 | - $_POST['pruningOptions'] = ''; |
|
2170 | 2242 | |
2171 | 2243 | saveDBSettings($savevar); |
2172 | 2244 | $_SESSION['adm-save'] = true; |
@@ -2178,10 +2250,11 @@ discard block |
||
2178 | 2250 | $context['sub_template'] = 'show_settings'; |
2179 | 2251 | |
2180 | 2252 | // Get the actual values |
2181 | - if (!empty($modSettings['pruningOptions'])) |
|
2182 | - @list ($modSettings['pruneErrorLog'], $modSettings['pruneModLog'], $modSettings['pruneBanLog'], $modSettings['pruneReportLog'], $modSettings['pruneScheduledTaskLog'], $modSettings['pruneSpiderHitLog']) = explode(',', $modSettings['pruningOptions']); |
|
2183 | - else |
|
2184 | - $modSettings['pruneErrorLog'] = $modSettings['pruneModLog'] = $modSettings['pruneBanLog'] = $modSettings['pruneReportLog'] = $modSettings['pruneScheduledTaskLog'] = $modSettings['pruneSpiderHitLog'] = 0; |
|
2253 | + if (!empty($modSettings['pruningOptions'])) { |
|
2254 | + @list ($modSettings['pruneErrorLog'], $modSettings['pruneModLog'], $modSettings['pruneBanLog'], $modSettings['pruneReportLog'], $modSettings['pruneScheduledTaskLog'], $modSettings['pruneSpiderHitLog']) = explode(',', $modSettings['pruningOptions']); |
|
2255 | + } else { |
|
2256 | + $modSettings['pruneErrorLog'] = $modSettings['pruneModLog'] = $modSettings['pruneBanLog'] = $modSettings['pruneReportLog'] = $modSettings['pruneScheduledTaskLog'] = $modSettings['pruneSpiderHitLog'] = 0; |
|
2257 | + } |
|
2185 | 2258 | |
2186 | 2259 | prepareDBSettingContext($config_vars); |
2187 | 2260 | } |
@@ -2203,8 +2276,9 @@ discard block |
||
2203 | 2276 | // Make it even easier to add new settings. |
2204 | 2277 | call_integration_hook('integrate_general_mod_settings', array(&$config_vars)); |
2205 | 2278 | |
2206 | - if ($return_config) |
|
2207 | - return $config_vars; |
|
2279 | + if ($return_config) { |
|
2280 | + return $config_vars; |
|
2281 | + } |
|
2208 | 2282 | |
2209 | 2283 | $context['post_url'] = $scripturl . '?action=admin;area=modsettings;save;sa=general'; |
2210 | 2284 | $context['settings_title'] = $txt['mods_cat_modifications_misc']; |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | $query_where = array(); |
167 | 167 | $query_params = $search_data['params']; |
168 | 168 | |
169 | - if( $smcFunc['db_title'] == "PostgreSQL") |
|
169 | + if ($smcFunc['db_title'] == "PostgreSQL") |
|
170 | 170 | $modSettings['search_simple_fulltext'] = true; |
171 | 171 | |
172 | 172 | if ($query_params['id_search']) |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | |
210 | 210 | if (!empty($modSettings['search_simple_fulltext'])) |
211 | 211 | { |
212 | - if($smcFunc['db_title'] == "PostgreSQL") |
|
212 | + if ($smcFunc['db_title'] == "PostgreSQL") |
|
213 | 213 | { |
214 | 214 | $language_ftx = $smcFunc['db_search_language'](); |
215 | 215 | |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | // remove any indexed words that are used in the complex body search terms |
228 | 228 | $words['indexed_words'] = array_diff($words['indexed_words'], $words['complex_words']); |
229 | 229 | |
230 | - if($smcFunc['db_title'] == "PostgreSQL"){ |
|
230 | + if ($smcFunc['db_title'] == "PostgreSQL") { |
|
231 | 231 | $row = 0; |
232 | 232 | foreach ($words['indexed_words'] as $fulltextWord) { |
233 | 233 | $query_params['boolean_match'] .= ($row <> 0 ? '&' : ''); |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | |
244 | 244 | // if we have bool terms to search, add them in |
245 | 245 | if ($query_params['boolean_match']) { |
246 | - if($smcFunc['db_title'] == "PostgreSQL") |
|
246 | + if ($smcFunc['db_title'] == "PostgreSQL") |
|
247 | 247 | { |
248 | 248 | $language_ftx = $smcFunc['db_search_language'](); |
249 | 249 | |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | |
257 | 257 | } |
258 | 258 | |
259 | - $ignoreRequest = $smcFunc['db_search_query']('insert_into_log_messages_fulltext', ($smcFunc['db_support_ignore'] ? ( ' |
|
259 | + $ignoreRequest = $smcFunc['db_search_query']('insert_into_log_messages_fulltext', ($smcFunc['db_support_ignore'] ? (' |
|
260 | 260 | INSERT IGNORE INTO {db_prefix}' . $search_data['insert_into'] . ' |
261 | 261 | (' . implode(', ', array_keys($query_select)) . ')') : '') . ' |
262 | 262 | SELECT ' . implode(', ', $query_select) . ' |
@@ -11,8 +11,9 @@ discard block |
||
11 | 11 | * @version 2.1 Beta 4 |
12 | 12 | */ |
13 | 13 | |
14 | -if (!defined('SMF')) |
|
14 | +if (!defined('SMF')) { |
|
15 | 15 | die('No direct access...'); |
16 | +} |
|
16 | 17 | |
17 | 18 | /** |
18 | 19 | * Class fulltext_search |
@@ -98,8 +99,9 @@ discard block |
||
98 | 99 | $smcFunc['db_free_result']($request); |
99 | 100 | } |
100 | 101 | // 4 is the MySQL default... |
101 | - else |
|
102 | - $min_word_length = 4; |
|
102 | + else { |
|
103 | + $min_word_length = 4; |
|
104 | + } |
|
103 | 105 | |
104 | 106 | return $min_word_length; |
105 | 107 | } |
@@ -138,8 +140,7 @@ discard block |
||
138 | 140 | $wordsSearch['words'][] = trim($word, "/*- "); |
139 | 141 | $wordsSearch['complex_words'][] = count($subwords) === 1 ? $word : '"' . $word . '"'; |
140 | 142 | } |
141 | - } |
|
142 | - elseif ($smcFunc['strlen'](trim($word, "/*- ")) < $this->min_word_length) |
|
143 | + } elseif ($smcFunc['strlen'](trim($word, "/*- ")) < $this->min_word_length) |
|
143 | 144 | { |
144 | 145 | // short words have feelings too |
145 | 146 | $wordsSearch['words'][] = trim($word, "/*- "); |
@@ -149,8 +150,9 @@ discard block |
||
149 | 150 | |
150 | 151 | $fulltextWord = count($subwords) === 1 ? $word : '"' . $word . '"'; |
151 | 152 | $wordsSearch['indexed_words'][] = $fulltextWord; |
152 | - if ($isExcluded) |
|
153 | - $wordsExclude[] = $fulltextWord; |
|
153 | + if ($isExcluded) { |
|
154 | + $wordsExclude[] = $fulltextWord; |
|
155 | + } |
|
154 | 156 | } |
155 | 157 | |
156 | 158 | /** |
@@ -166,44 +168,54 @@ discard block |
||
166 | 168 | $query_where = array(); |
167 | 169 | $query_params = $search_data['params']; |
168 | 170 | |
169 | - if( $smcFunc['db_title'] == "PostgreSQL") |
|
170 | - $modSettings['search_simple_fulltext'] = true; |
|
171 | + if( $smcFunc['db_title'] == "PostgreSQL") { |
|
172 | + $modSettings['search_simple_fulltext'] = true; |
|
173 | + } |
|
171 | 174 | |
172 | - if ($query_params['id_search']) |
|
173 | - $query_select['id_search'] = '{int:id_search}'; |
|
175 | + if ($query_params['id_search']) { |
|
176 | + $query_select['id_search'] = '{int:id_search}'; |
|
177 | + } |
|
174 | 178 | |
175 | 179 | $count = 0; |
176 | - if (empty($modSettings['search_simple_fulltext'])) |
|
177 | - foreach ($words['words'] as $regularWord) |
|
180 | + if (empty($modSettings['search_simple_fulltext'])) { |
|
181 | + foreach ($words['words'] as $regularWord) |
|
178 | 182 | { |
179 | 183 | $query_where[] = 'm.body' . (in_array($regularWord, $query_params['excluded_words']) ? ' NOT' : '') . (empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? ' LIKE ' : 'RLIKE') . '{string:complex_body_' . $count . '}'; |
184 | + } |
|
180 | 185 | $query_params['complex_body_' . $count++] = empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? '%' . strtr($regularWord, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $regularWord), '\\\'') . '[[:>:]]'; |
181 | 186 | } |
182 | 187 | |
183 | - if ($query_params['user_query']) |
|
184 | - $query_where[] = '{raw:user_query}'; |
|
185 | - if ($query_params['board_query']) |
|
186 | - $query_where[] = 'm.id_board {raw:board_query}'; |
|
188 | + if ($query_params['user_query']) { |
|
189 | + $query_where[] = '{raw:user_query}'; |
|
190 | + } |
|
191 | + if ($query_params['board_query']) { |
|
192 | + $query_where[] = 'm.id_board {raw:board_query}'; |
|
193 | + } |
|
187 | 194 | |
188 | - if ($query_params['topic']) |
|
189 | - $query_where[] = 'm.id_topic = {int:topic}'; |
|
190 | - if ($query_params['min_msg_id']) |
|
191 | - $query_where[] = 'm.id_msg >= {int:min_msg_id}'; |
|
192 | - if ($query_params['max_msg_id']) |
|
193 | - $query_where[] = 'm.id_msg <= {int:max_msg_id}'; |
|
195 | + if ($query_params['topic']) { |
|
196 | + $query_where[] = 'm.id_topic = {int:topic}'; |
|
197 | + } |
|
198 | + if ($query_params['min_msg_id']) { |
|
199 | + $query_where[] = 'm.id_msg >= {int:min_msg_id}'; |
|
200 | + } |
|
201 | + if ($query_params['max_msg_id']) { |
|
202 | + $query_where[] = 'm.id_msg <= {int:max_msg_id}'; |
|
203 | + } |
|
194 | 204 | |
195 | 205 | $count = 0; |
196 | - if (!empty($query_params['excluded_phrases']) && empty($modSettings['search_force_index'])) |
|
197 | - foreach ($query_params['excluded_phrases'] as $phrase) |
|
206 | + if (!empty($query_params['excluded_phrases']) && empty($modSettings['search_force_index'])) { |
|
207 | + foreach ($query_params['excluded_phrases'] as $phrase) |
|
198 | 208 | { |
199 | 209 | $query_where[] = 'subject NOT ' . (empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? ' LIKE ' : 'RLIKE') . '{string:exclude_subject_phrase_' . $count . '}'; |
210 | + } |
|
200 | 211 | $query_params['exclude_subject_phrase_' . $count++] = empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? '%' . strtr($phrase, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $phrase), '\\\'') . '[[:>:]]'; |
201 | 212 | } |
202 | 213 | $count = 0; |
203 | - if (!empty($query_params['excluded_subject_words']) && empty($modSettings['search_force_index'])) |
|
204 | - foreach ($query_params['excluded_subject_words'] as $excludedWord) |
|
214 | + if (!empty($query_params['excluded_subject_words']) && empty($modSettings['search_force_index'])) { |
|
215 | + foreach ($query_params['excluded_subject_words'] as $excludedWord) |
|
205 | 216 | { |
206 | 217 | $query_where[] = 'subject NOT ' . (empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? ' LIKE ' : 'RLIKE') . '{string:exclude_subject_words_' . $count . '}'; |
218 | + } |
|
207 | 219 | $query_params['exclude_subject_words_' . $count++] = empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? '%' . strtr($excludedWord, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $excludedWord), '\\\'') . '[[:>:]]'; |
208 | 220 | } |
209 | 221 | |
@@ -215,12 +227,11 @@ discard block |
||
215 | 227 | |
216 | 228 | $query_where[] = 'to_tsvector({string:language_ftx},body) @@ to_tsquery({string:language_ftx},{string:body_match})'; |
217 | 229 | $query_params['language_ftx'] = $language_ftx; |
230 | + } else { |
|
231 | + $query_where[] = 'MATCH (body) AGAINST ({string:body_match})'; |
|
218 | 232 | } |
219 | - else |
|
220 | - $query_where[] = 'MATCH (body) AGAINST ({string:body_match})'; |
|
221 | 233 | $query_params['body_match'] = implode(' ', array_diff($words['indexed_words'], $query_params['excluded_index_words'])); |
222 | - } |
|
223 | - else |
|
234 | + } else |
|
224 | 235 | { |
225 | 236 | $query_params['boolean_match'] = ''; |
226 | 237 | |
@@ -234,10 +245,10 @@ discard block |
||
234 | 245 | $query_params['boolean_match'] .= (in_array($fulltextWord, $query_params['excluded_index_words']) ? '!' : '') . $fulltextWord . ' '; |
235 | 246 | $row++; |
236 | 247 | } |
237 | - } |
|
238 | - else |
|
239 | - foreach ($words['indexed_words'] as $fulltextWord) |
|
248 | + } else { |
|
249 | + foreach ($words['indexed_words'] as $fulltextWord) |
|
240 | 250 | $query_params['boolean_match'] .= (in_array($fulltextWord, $query_params['excluded_index_words']) ? '-' : '+') . $fulltextWord . ' '; |
251 | + } |
|
241 | 252 | |
242 | 253 | $query_params['boolean_match'] = substr($query_params['boolean_match'], 0, -1); |
243 | 254 | |
@@ -249,9 +260,9 @@ discard block |
||
249 | 260 | |
250 | 261 | $query_where[] = 'to_tsvector({string:language_ftx},body) @@ to_tsquery({string:language_ftx},{string:boolean_match})'; |
251 | 262 | $query_params['language_ftx'] = $language_ftx; |
263 | + } else { |
|
264 | + $query_where[] = 'MATCH (body) AGAINST ({string:boolean_match} IN BOOLEAN MODE)'; |
|
252 | 265 | } |
253 | - else |
|
254 | - $query_where[] = 'MATCH (body) AGAINST ({string:boolean_match} IN BOOLEAN MODE)'; |
|
255 | 266 | } |
256 | 267 | |
257 | 268 | } |
@@ -29,9 +29,10 @@ discard block |
||
29 | 29 | // Go through each type of report they can run. |
30 | 30 | foreach ($context['report_types'] as $type) |
31 | 31 | { |
32 | - if (isset($type['description'])) |
|
33 | - echo ' |
|
32 | + if (isset($type['description'])) { |
|
33 | + echo ' |
|
34 | 34 | <dt>', $type['description'], '</dt>'; |
35 | + } |
|
35 | 36 | echo ' |
36 | 37 | <dd> |
37 | 38 | <input type="radio" id="rt_', $type['id'], '" name="rt" value="', $type['id'], '"', $type['is_first'] ? ' checked' : '', '> |
@@ -61,8 +62,9 @@ discard block |
||
61 | 62 | </div> |
62 | 63 | <div id="report_buttons">'; |
63 | 64 | |
64 | - if (!empty($context['report_buttons'])) |
|
65 | - template_button_strip($context['report_buttons'], 'right'); |
|
65 | + if (!empty($context['report_buttons'])) { |
|
66 | + template_button_strip($context['report_buttons'], 'right'); |
|
67 | + } |
|
66 | 68 | |
67 | 69 | echo ' |
68 | 70 | </div>'; |
@@ -73,25 +75,27 @@ discard block |
||
73 | 75 | echo ' |
74 | 76 | <table class="table_grid report_results">'; |
75 | 77 | |
76 | - if (!empty($table['title'])) |
|
77 | - echo ' |
|
78 | + if (!empty($table['title'])) { |
|
79 | + echo ' |
|
78 | 80 | <thead> |
79 | 81 | <tr class="title_bar"> |
80 | 82 | <th scope="col" colspan="', $table['column_count'], '">', $table['title'], '</th> |
81 | 83 | </tr> |
82 | 84 | </thead> |
83 | 85 | <tbody>'; |
86 | + } |
|
84 | 87 | |
85 | 88 | // Now do each row! |
86 | 89 | $row_number = 0; |
87 | 90 | foreach ($table['data'] as $row) |
88 | 91 | { |
89 | - if ($row_number == 0 && !empty($table['shading']['top'])) |
|
90 | - echo ' |
|
92 | + if ($row_number == 0 && !empty($table['shading']['top'])) { |
|
93 | + echo ' |
|
91 | 94 | <tr class="windowbg table_caption">'; |
92 | - else |
|
93 | - echo ' |
|
95 | + } else { |
|
96 | + echo ' |
|
94 | 97 | <tr class="', !empty($row[0]['separator']) ? 'title_bar' : 'windowbg', '">'; |
98 | + } |
|
95 | 99 | |
96 | 100 | // Now do each column. |
97 | 101 | $column_number = 0; |
@@ -109,16 +113,17 @@ discard block |
||
109 | 113 | } |
110 | 114 | |
111 | 115 | // Shaded? |
112 | - if ($column_number == 0 && !empty($table['shading']['left'])) |
|
113 | - echo ' |
|
116 | + if ($column_number == 0 && !empty($table['shading']['left'])) { |
|
117 | + echo ' |
|
114 | 118 | <td class="table_caption ', $table['align']['shaded'], 'text"', $table['width']['shaded'] != 'auto' ? ' width="' . $table['width']['shaded'] . '"' : '', '> |
115 | 119 | ', $data['v'] == $table['default_value'] ? '' : ($data['v'] . (empty($data['v']) ? '' : ':')), ' |
116 | 120 | </td>'; |
117 | - else |
|
118 | - echo ' |
|
121 | + } else { |
|
122 | + echo ' |
|
119 | 123 | <td class="smalltext centertext" ', $table['width']['normal'] != 'auto' ? ' width="' . $table['width']['normal'] . '"' : '', !empty($data['style']) ? ' style="' . $data['style'] . '"' : '', '> |
120 | 124 | ', $data['v'], ' |
121 | 125 | </td>'; |
126 | + } |
|
122 | 127 | |
123 | 128 | $column_number++; |
124 | 129 | } |
@@ -167,24 +172,26 @@ discard block |
||
167 | 172 | <div style="overflow: visible;', $table['max_width'] != 'auto' ? ' width: ' . $table['max_width'] . 'px;' : '', '"> |
168 | 173 | <table class="bordercolor">'; |
169 | 174 | |
170 | - if (!empty($table['title'])) |
|
171 | - echo ' |
|
175 | + if (!empty($table['title'])) { |
|
176 | + echo ' |
|
172 | 177 | <tr class="title_bar"> |
173 | 178 | <td colspan="', $table['column_count'], '"> |
174 | 179 | ', $table['title'], ' |
175 | 180 | </td> |
176 | 181 | </tr>'; |
182 | + } |
|
177 | 183 | |
178 | 184 | // Now do each row! |
179 | 185 | $row_number = 0; |
180 | 186 | foreach ($table['data'] as $row) |
181 | 187 | { |
182 | - if ($row_number == 0 && !empty($table['shading']['top'])) |
|
183 | - echo ' |
|
188 | + if ($row_number == 0 && !empty($table['shading']['top'])) { |
|
189 | + echo ' |
|
184 | 190 | <tr class="titlebg">'; |
185 | - else |
|
186 | - echo ' |
|
191 | + } else { |
|
192 | + echo ' |
|
187 | 193 | <tr class="windowbg">'; |
194 | + } |
|
188 | 195 | |
189 | 196 | // Now do each column!! |
190 | 197 | $column_number = 0; |
@@ -201,16 +208,17 @@ discard block |
||
201 | 208 | } |
202 | 209 | |
203 | 210 | // Shaded? |
204 | - if ($column_number == 0 && !empty($table['shading']['left'])) |
|
205 | - echo ' |
|
211 | + if ($column_number == 0 && !empty($table['shading']['left'])) { |
|
212 | + echo ' |
|
206 | 213 | <td class="titlebg ', $table['align']['shaded'], 'text"', $table['width']['shaded'] != 'auto' ? ' width="' . $table['width']['shaded'] . '"' : '', '> |
207 | 214 | ', $data['v'] == $table['default_value'] ? '' : ($data['v'] . (empty($data['v']) ? '' : ':')), ' |
208 | 215 | </td>'; |
209 | - else |
|
210 | - echo ' |
|
216 | + } else { |
|
217 | + echo ' |
|
211 | 218 | <td class="centertext" ', $table['width']['normal'] != 'auto' ? ' width="' . $table['width']['normal'] . '"' : '', !empty($data['style']) ? ' style="' . $data['style'] . '"' : '', '> |
212 | 219 | ', $data['v'], ' |
213 | 220 | </td>'; |
221 | + } |
|
214 | 222 | |
215 | 223 | $column_number++; |
216 | 224 | } |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 4 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * The news dispatcher; doesn't do anything, just delegates. |
@@ -67,8 +68,9 @@ discard block |
||
67 | 68 | ); |
68 | 69 | |
69 | 70 | // Force the right area... |
70 | - if (substr($_REQUEST['sa'], 0, 7) == 'mailing') |
|
71 | - $context[$context['admin_menu_name']]['current_subsection'] = 'mailingmembers'; |
|
71 | + if (substr($_REQUEST['sa'], 0, 7) == 'mailing') { |
|
72 | + $context[$context['admin_menu_name']]['current_subsection'] = 'mailingmembers'; |
|
73 | + } |
|
72 | 74 | |
73 | 75 | call_helper($subActions[$_REQUEST['sa']][0]); |
74 | 76 | } |
@@ -99,9 +101,10 @@ discard block |
||
99 | 101 | $temp_news = explode("\n", $modSettings['news']); |
100 | 102 | |
101 | 103 | // Remove the items that were selected. |
102 | - foreach ($temp_news as $i => $news) |
|
103 | - if (in_array($i, $_POST['remove'])) |
|
104 | + foreach ($temp_news as $i => $news) { |
|
105 | + if (in_array($i, $_POST['remove'])) |
|
104 | 106 | unset($temp_news[$i]); |
107 | + } |
|
105 | 108 | |
106 | 109 | // Update the database. |
107 | 110 | updateSettings(array('news' => implode("\n", $temp_news))); |
@@ -117,9 +120,9 @@ discard block |
||
117 | 120 | |
118 | 121 | foreach ($_POST['news'] as $i => $news) |
119 | 122 | { |
120 | - if (trim($news) == '') |
|
121 | - unset($_POST['news'][$i]); |
|
122 | - else |
|
123 | + if (trim($news) == '') { |
|
124 | + unset($_POST['news'][$i]); |
|
125 | + } else |
|
123 | 126 | { |
124 | 127 | $_POST['news'][$i] = $smcFunc['htmlspecialchars']($_POST['news'][$i], ENT_QUOTES); |
125 | 128 | preparsecode($_POST['news'][$i]); |
@@ -154,11 +157,12 @@ discard block |
||
154 | 157 | 'data' => array( |
155 | 158 | 'function' => function($news) |
156 | 159 | { |
157 | - if (is_numeric($news['id'])) |
|
158 | - return '<textarea id="data_' . $news['id'] . '" rows="3" cols="50" name="news[]" class="padding block">' . $news['unparsed'] . '</textarea> |
|
160 | + if (is_numeric($news['id'])) { |
|
161 | + return '<textarea id="data_' . $news['id'] . '" rows="3" cols="50" name="news[]" class="padding block">' . $news['unparsed'] . '</textarea> |
|
159 | 162 | <div class="floatleft" id="preview_' . $news['id'] . '"></div>'; |
160 | - else |
|
161 | - return $news['unparsed']; |
|
163 | + } else { |
|
164 | + return $news['unparsed']; |
|
165 | + } |
|
162 | 166 | }, |
163 | 167 | 'style' => 'width: 50%;', |
164 | 168 | ), |
@@ -183,10 +187,11 @@ discard block |
||
183 | 187 | 'data' => array( |
184 | 188 | 'function' => function($news) |
185 | 189 | { |
186 | - if (is_numeric($news['id'])) |
|
187 | - return '<input type="checkbox" name="remove[]" value="' . $news['id'] . '">'; |
|
188 | - else |
|
189 | - return ''; |
|
190 | + if (is_numeric($news['id'])) { |
|
191 | + return '<input type="checkbox" name="remove[]" value="' . $news['id'] . '">'; |
|
192 | + } else { |
|
193 | + return ''; |
|
194 | + } |
|
190 | 195 | }, |
191 | 196 | 'class' => 'centercol', |
192 | 197 | ), |
@@ -280,12 +285,13 @@ discard block |
||
280 | 285 | |
281 | 286 | $admin_current_news = array(); |
282 | 287 | // Ready the current news. |
283 | - foreach (explode("\n", $modSettings['news']) as $id => $line) |
|
284 | - $admin_current_news[$id] = array( |
|
288 | + foreach (explode("\n", $modSettings['news']) as $id => $line) { |
|
289 | + $admin_current_news[$id] = array( |
|
285 | 290 | 'id' => $id, |
286 | 291 | 'unparsed' => un_preparsecode($line), |
287 | 292 | 'parsed' => preg_replace('~<([/]?)form[^>]*?[>]*>~i', '<em class="smalltext"><$1form></em>', parse_bbc($line)), |
288 | 293 | ); |
294 | + } |
|
289 | 295 | |
290 | 296 | $admin_current_news['last'] = array( |
291 | 297 | 'id' => 'last', |
@@ -352,10 +358,11 @@ discard block |
||
352 | 358 | 'member_count' => 0, |
353 | 359 | ); |
354 | 360 | |
355 | - if ($row['min_posts'] == -1) |
|
356 | - $normalGroups[$row['id_group']] = $row['id_group']; |
|
357 | - else |
|
358 | - $postGroups[$row['id_group']] = $row['id_group']; |
|
361 | + if ($row['min_posts'] == -1) { |
|
362 | + $normalGroups[$row['id_group']] = $row['id_group']; |
|
363 | + } else { |
|
364 | + $postGroups[$row['id_group']] = $row['id_group']; |
|
365 | + } |
|
359 | 366 | } |
360 | 367 | $smcFunc['db_free_result']($request); |
361 | 368 | |
@@ -371,8 +378,9 @@ discard block |
||
371 | 378 | 'post_group_list' => $postGroups, |
372 | 379 | ) |
373 | 380 | ); |
374 | - while ($row = $smcFunc['db_fetch_assoc']($query)) |
|
375 | - $context['groups'][$row['id_group']]['member_count'] += $row['member_count']; |
|
381 | + while ($row = $smcFunc['db_fetch_assoc']($query)) { |
|
382 | + $context['groups'][$row['id_group']]['member_count'] += $row['member_count']; |
|
383 | + } |
|
376 | 384 | $smcFunc['db_free_result']($query); |
377 | 385 | } |
378 | 386 | |
@@ -388,8 +396,9 @@ discard block |
||
388 | 396 | 'normal_group_list' => $normalGroups, |
389 | 397 | ) |
390 | 398 | ); |
391 | - while ($row = $smcFunc['db_fetch_assoc']($query)) |
|
392 | - $context['groups'][$row['id_group']]['member_count'] += $row['member_count']; |
|
399 | + while ($row = $smcFunc['db_fetch_assoc']($query)) { |
|
400 | + $context['groups'][$row['id_group']]['member_count'] += $row['member_count']; |
|
401 | + } |
|
393 | 402 | $smcFunc['db_free_result']($query); |
394 | 403 | |
395 | 404 | // Also do those who have it as an additional membergroup - this ones more yucky... |
@@ -406,8 +415,9 @@ discard block |
||
406 | 415 | 'blank_string' => '', |
407 | 416 | ) |
408 | 417 | ); |
409 | - while ($row = $smcFunc['db_fetch_assoc']($query)) |
|
410 | - $context['groups'][$row['id_group']]['member_count'] += $row['member_count']; |
|
418 | + while ($row = $smcFunc['db_fetch_assoc']($query)) { |
|
419 | + $context['groups'][$row['id_group']]['member_count'] += $row['member_count']; |
|
420 | + } |
|
411 | 421 | $smcFunc['db_free_result']($query); |
412 | 422 | } |
413 | 423 | |
@@ -458,10 +468,11 @@ discard block |
||
458 | 468 | { |
459 | 469 | $context[$key] = !empty($_REQUEST[$post]) ? $_REQUEST[$post] : ''; |
460 | 470 | |
461 | - if (empty($context[$key]) && empty($_REQUEST['xml'])) |
|
462 | - $context['post_error']['messages'][] = $txt['error_no_' . $post]; |
|
463 | - elseif (!empty($_REQUEST['xml'])) |
|
464 | - continue; |
|
471 | + if (empty($context[$key]) && empty($_REQUEST['xml'])) { |
|
472 | + $context['post_error']['messages'][] = $txt['error_no_' . $post]; |
|
473 | + } elseif (!empty($_REQUEST['xml'])) { |
|
474 | + continue; |
|
475 | + } |
|
465 | 476 | |
466 | 477 | preparsecode($context[$key]); |
467 | 478 | if ($html) |
@@ -540,10 +551,12 @@ discard block |
||
540 | 551 | |
541 | 552 | // Start by finding any members! |
542 | 553 | $toClean = array(); |
543 | - if (!empty($_POST['members'])) |
|
544 | - $toClean[] = 'members'; |
|
545 | - if (!empty($_POST['exclude_members'])) |
|
546 | - $toClean[] = 'exclude_members'; |
|
554 | + if (!empty($_POST['members'])) { |
|
555 | + $toClean[] = 'members'; |
|
556 | + } |
|
557 | + if (!empty($_POST['exclude_members'])) { |
|
558 | + $toClean[] = 'exclude_members'; |
|
559 | + } |
|
547 | 560 | if (!empty($toClean)) |
548 | 561 | { |
549 | 562 | require_once($sourcedir . '/Subs-Auth.php'); |
@@ -555,11 +568,13 @@ discard block |
||
555 | 568 | preg_match_all('~"([^"]+)"~', $_POST[$type], $matches); |
556 | 569 | $_POST[$type] = array_unique(array_merge($matches[1], explode(',', preg_replace('~"[^"]+"~', '', $_POST[$type])))); |
557 | 570 | |
558 | - foreach ($_POST[$type] as $index => $member) |
|
559 | - if (strlen(trim($member)) > 0) |
|
571 | + foreach ($_POST[$type] as $index => $member) { |
|
572 | + if (strlen(trim($member)) > 0) |
|
560 | 573 | $_POST[$type][$index] = $smcFunc['htmlspecialchars']($smcFunc['strtolower'](trim($member))); |
561 | - else |
|
562 | - unset($_POST[$type][$index]); |
|
574 | + } |
|
575 | + else { |
|
576 | + unset($_POST[$type][$index]); |
|
577 | + } |
|
563 | 578 | |
564 | 579 | // Find the members |
565 | 580 | $_POST[$type] = implode(',', array_keys(findMembers($_POST[$type]))); |
@@ -569,16 +584,18 @@ discard block |
||
569 | 584 | if (isset($_POST['member_list']) && is_array($_POST['member_list'])) |
570 | 585 | { |
571 | 586 | $members = array(); |
572 | - foreach ($_POST['member_list'] as $member_id) |
|
573 | - $members[] = (int) $member_id; |
|
587 | + foreach ($_POST['member_list'] as $member_id) { |
|
588 | + $members[] = (int) $member_id; |
|
589 | + } |
|
574 | 590 | $_POST['members'] = implode(',', $members); |
575 | 591 | } |
576 | 592 | |
577 | 593 | if (isset($_POST['exclude_member_list']) && is_array($_POST['exclude_member_list'])) |
578 | 594 | { |
579 | 595 | $members = array(); |
580 | - foreach ($_POST['exclude_member_list'] as $member_id) |
|
581 | - $members[] = (int) $member_id; |
|
596 | + foreach ($_POST['exclude_member_list'] as $member_id) { |
|
597 | + $members[] = (int) $member_id; |
|
598 | + } |
|
582 | 599 | $_POST['exclude_members'] = implode(',', $members); |
583 | 600 | } |
584 | 601 | |
@@ -602,8 +619,9 @@ discard block |
||
602 | 619 | 'current_time' => time(), |
603 | 620 | ) |
604 | 621 | ); |
605 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
606 | - $context['recipients']['exclude_members'][] = $row['id_member']; |
|
622 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
623 | + $context['recipients']['exclude_members'][] = $row['id_member']; |
|
624 | + } |
|
607 | 625 | $smcFunc['db_free_result']($request); |
608 | 626 | |
609 | 627 | $request = $smcFunc['db_query']('', ' |
@@ -638,8 +656,9 @@ discard block |
||
638 | 656 | WHERE email_address IN(' . implode(', ', $condition_array) . ')', |
639 | 657 | $condition_array_params |
640 | 658 | ); |
641 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
642 | - $context['recipients']['exclude_members'][] = $row['id_member']; |
|
659 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
660 | + $context['recipients']['exclude_members'][] = $row['id_member']; |
|
661 | + } |
|
643 | 662 | $smcFunc['db_free_result']($request); |
644 | 663 | } |
645 | 664 | |
@@ -657,10 +676,11 @@ discard block |
||
657 | 676 | ); |
658 | 677 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
659 | 678 | { |
660 | - if (in_array(3, $context['recipients'])) |
|
661 | - $context['recipients']['exclude_members'][] = $row['identifier']; |
|
662 | - else |
|
663 | - $context['recipients']['members'][] = $row['identifier']; |
|
679 | + if (in_array(3, $context['recipients'])) { |
|
680 | + $context['recipients']['exclude_members'][] = $row['identifier']; |
|
681 | + } else { |
|
682 | + $context['recipients']['members'][] = $row['identifier']; |
|
683 | + } |
|
664 | 684 | } |
665 | 685 | $smcFunc['db_free_result']($request); |
666 | 686 | } |
@@ -707,8 +727,9 @@ discard block |
||
707 | 727 | $num_at_once = 1000; |
708 | 728 | |
709 | 729 | // If by PM's I suggest we half the above number. |
710 | - if (!empty($_POST['send_pm'])) |
|
711 | - $num_at_once /= 2; |
|
730 | + if (!empty($_POST['send_pm'])) { |
|
731 | + $num_at_once /= 2; |
|
732 | + } |
|
712 | 733 | |
713 | 734 | checkSession(); |
714 | 735 | |
@@ -731,8 +752,7 @@ discard block |
||
731 | 752 | ); |
732 | 753 | list ($context['total_members']) = $smcFunc['db_fetch_row']($request); |
733 | 754 | $smcFunc['db_free_result']($request); |
734 | - } |
|
735 | - else |
|
755 | + } else |
|
736 | 756 | { |
737 | 757 | $context['total_members'] = (int) $_REQUEST['total_members']; |
738 | 758 | } |
@@ -750,32 +770,35 @@ discard block |
||
750 | 770 | if (!empty($_POST['exclude_members'])) |
751 | 771 | { |
752 | 772 | $members = explode(',', $_POST['exclude_members']); |
753 | - foreach ($members as $member) |
|
754 | - if ($member >= $context['start']) |
|
773 | + foreach ($members as $member) { |
|
774 | + if ($member >= $context['start']) |
|
755 | 775 | $context['recipients']['exclude_members'][] = (int) $member; |
776 | + } |
|
756 | 777 | } |
757 | 778 | |
758 | 779 | // What about members we *must* do? |
759 | 780 | if (!empty($_POST['members'])) |
760 | 781 | { |
761 | 782 | $members = explode(',', $_POST['members']); |
762 | - foreach ($members as $member) |
|
763 | - if ($member >= $context['start']) |
|
783 | + foreach ($members as $member) { |
|
784 | + if ($member >= $context['start']) |
|
764 | 785 | $context['recipients']['members'][] = (int) $member; |
786 | + } |
|
765 | 787 | } |
766 | 788 | // Cleaning groups is simple - although deal with both checkbox and commas. |
767 | 789 | if (isset($_POST['groups'])) |
768 | 790 | { |
769 | 791 | if (is_array($_POST['groups'])) |
770 | 792 | { |
771 | - foreach ($_POST['groups'] as $group => $dummy) |
|
772 | - $context['recipients']['groups'][] = (int) $group; |
|
773 | - } |
|
774 | - else |
|
793 | + foreach ($_POST['groups'] as $group => $dummy) { |
|
794 | + $context['recipients']['groups'][] = (int) $group; |
|
795 | + } |
|
796 | + } else |
|
775 | 797 | { |
776 | 798 | $groups = explode(',', $_POST['groups']); |
777 | - foreach ($groups as $group) |
|
778 | - $context['recipients']['groups'][] = (int) $group; |
|
799 | + foreach ($groups as $group) { |
|
800 | + $context['recipients']['groups'][] = (int) $group; |
|
801 | + } |
|
779 | 802 | } |
780 | 803 | } |
781 | 804 | // Same for excluded groups |
@@ -783,15 +806,17 @@ discard block |
||
783 | 806 | { |
784 | 807 | if (is_array($_POST['exclude_groups'])) |
785 | 808 | { |
786 | - foreach ($_POST['exclude_groups'] as $group => $dummy) |
|
787 | - $context['recipients']['exclude_groups'][] = (int) $group; |
|
809 | + foreach ($_POST['exclude_groups'] as $group => $dummy) { |
|
810 | + $context['recipients']['exclude_groups'][] = (int) $group; |
|
811 | + } |
|
788 | 812 | } |
789 | 813 | // Ignore an empty string - we don't want to exclude "Regular Members" unless it's specifically selected |
790 | 814 | elseif ($_POST['exclude_groups'] != '') |
791 | 815 | { |
792 | 816 | $groups = explode(',', $_POST['exclude_groups']); |
793 | - foreach ($groups as $group) |
|
794 | - $context['recipients']['exclude_groups'][] = (int) $group; |
|
817 | + foreach ($groups as $group) { |
|
818 | + $context['recipients']['exclude_groups'][] = (int) $group; |
|
819 | + } |
|
795 | 820 | } |
796 | 821 | } |
797 | 822 | // Finally - emails! |
@@ -801,14 +826,16 @@ discard block |
||
801 | 826 | foreach ($addressed as $curmem) |
802 | 827 | { |
803 | 828 | $curmem = trim($curmem); |
804 | - if ($curmem != '' && filter_var($curmem, FILTER_VALIDATE_EMAIL)) |
|
805 | - $context['recipients']['emails'][$curmem] = $curmem; |
|
829 | + if ($curmem != '' && filter_var($curmem, FILTER_VALIDATE_EMAIL)) { |
|
830 | + $context['recipients']['emails'][$curmem] = $curmem; |
|
831 | + } |
|
806 | 832 | } |
807 | 833 | } |
808 | 834 | |
809 | 835 | // If we're only cleaning drop out here. |
810 | - if ($clean_only) |
|
811 | - return; |
|
836 | + if ($clean_only) { |
|
837 | + return; |
|
838 | + } |
|
812 | 839 | |
813 | 840 | require_once($sourcedir . '/Subs-Post.php'); |
814 | 841 | |
@@ -824,16 +851,18 @@ discard block |
||
824 | 851 | if (!$context['send_pm'] && !empty($_POST['send_html'])) |
825 | 852 | { |
826 | 853 | // Prepare the message for HTML. |
827 | - if (!empty($_POST['parse_html'])) |
|
828 | - $_POST['message'] = str_replace(array("\n", ' '), array('<br>' . "\n", ' '), $_POST['message']); |
|
854 | + if (!empty($_POST['parse_html'])) { |
|
855 | + $_POST['message'] = str_replace(array("\n", ' '), array('<br>' . "\n", ' '), $_POST['message']); |
|
856 | + } |
|
829 | 857 | |
830 | 858 | // This is here to prevent spam filters from tagging this as spam. |
831 | 859 | if (preg_match('~\<html~i', $_POST['message']) == 0) |
832 | 860 | { |
833 | - if (preg_match('~\<body~i', $_POST['message']) == 0) |
|
834 | - $_POST['message'] = '<html><head><title>' . $_POST['subject'] . '</title></head>' . "\n" . '<body>' . $_POST['message'] . '</body></html>'; |
|
835 | - else |
|
836 | - $_POST['message'] = '<html>' . $_POST['message'] . '</html>'; |
|
861 | + if (preg_match('~\<body~i', $_POST['message']) == 0) { |
|
862 | + $_POST['message'] = '<html><head><title>' . $_POST['subject'] . '</title></head>' . "\n" . '<body>' . $_POST['message'] . '</body></html>'; |
|
863 | + } else { |
|
864 | + $_POST['message'] = '<html>' . $_POST['message'] . '</html>'; |
|
865 | + } |
|
837 | 866 | } |
838 | 867 | } |
839 | 868 | |
@@ -887,15 +916,17 @@ discard block |
||
887 | 916 | foreach ($context['recipients']['emails'] as $k => $email) |
888 | 917 | { |
889 | 918 | // Done as many as we can? |
890 | - if ($i >= $num_at_once) |
|
891 | - break; |
|
919 | + if ($i >= $num_at_once) { |
|
920 | + break; |
|
921 | + } |
|
892 | 922 | |
893 | 923 | // Don't sent it twice! |
894 | 924 | unset($context['recipients']['emails'][$k]); |
895 | 925 | |
896 | 926 | // Dammit - can't PM emails! |
897 | - if ($context['send_pm']) |
|
898 | - continue; |
|
927 | + if ($context['send_pm']) { |
|
928 | + continue; |
|
929 | + } |
|
899 | 930 | |
900 | 931 | $to_member = array( |
901 | 932 | $email, |
@@ -929,8 +960,9 @@ discard block |
||
929 | 960 | $queryBuild[] = 'mem.id_post_group = {int:group_' . $group . '}'; |
930 | 961 | } |
931 | 962 | } |
932 | - if (!empty($queryBuild)) |
|
933 | - $sendQuery .= implode(' OR ', $queryBuild); |
|
963 | + if (!empty($queryBuild)) { |
|
964 | + $sendQuery .= implode(' OR ', $queryBuild); |
|
965 | + } |
|
934 | 966 | } |
935 | 967 | if (!empty($context['recipients']['members'])) |
936 | 968 | { |
@@ -949,8 +981,9 @@ discard block |
||
949 | 981 | } |
950 | 982 | |
951 | 983 | // Anything to exclude? |
952 | - if (!empty($context['recipients']['exclude_groups']) && in_array(0, $context['recipients']['exclude_groups'])) |
|
953 | - $sendQuery .= ' AND mem.id_group != {int:regular_group}'; |
|
984 | + if (!empty($context['recipients']['exclude_groups']) && in_array(0, $context['recipients']['exclude_groups'])) { |
|
985 | + $sendQuery .= ' AND mem.id_group != {int:regular_group}'; |
|
986 | + } |
|
954 | 987 | if (!empty($context['recipients']['exclude_members'])) |
955 | 988 | { |
956 | 989 | $sendQuery .= ' AND mem.id_member NOT IN ({array_int:exclude_members})'; |
@@ -986,21 +1019,24 @@ discard block |
||
986 | 1019 | foreach ($rows as $row) |
987 | 1020 | { |
988 | 1021 | // Force them to have it? |
989 | - if (empty($context['email_force']) && empty($prefs[$row['id_member']]['announcements'])) |
|
990 | - continue; |
|
1022 | + if (empty($context['email_force']) && empty($prefs[$row['id_member']]['announcements'])) { |
|
1023 | + continue; |
|
1024 | + } |
|
991 | 1025 | |
992 | 1026 | // What groups are we looking at here? |
993 | - if (empty($row['additional_groups'])) |
|
994 | - $groups = array($row['id_group'], $row['id_post_group']); |
|
995 | - else |
|
996 | - $groups = array_merge( |
|
1027 | + if (empty($row['additional_groups'])) { |
|
1028 | + $groups = array($row['id_group'], $row['id_post_group']); |
|
1029 | + } else { |
|
1030 | + $groups = array_merge( |
|
997 | 1031 | array($row['id_group'], $row['id_post_group']), |
998 | 1032 | explode(',', $row['additional_groups']) |
999 | 1033 | ); |
1034 | + } |
|
1000 | 1035 | |
1001 | 1036 | // Excluded groups? |
1002 | - if (array_intersect($groups, $context['recipients']['exclude_groups'])) |
|
1003 | - continue; |
|
1037 | + if (array_intersect($groups, $context['recipients']['exclude_groups'])) { |
|
1038 | + continue; |
|
1039 | + } |
|
1004 | 1040 | |
1005 | 1041 | // We might need this |
1006 | 1042 | $cleanMemberName = empty($_POST['send_html']) || $context['send_pm'] ? un_htmlspecialchars($row['real_name']) : $row['real_name']; |
@@ -1023,10 +1059,11 @@ discard block |
||
1023 | 1059 | ), $_POST['subject']); |
1024 | 1060 | |
1025 | 1061 | // Send the actual email - or a PM! |
1026 | - if (!$context['send_pm']) |
|
1027 | - sendmail($row['email_address'], $subject, $message, null, 'news', !empty($_POST['send_html']), 5); |
|
1028 | - else |
|
1029 | - sendpm(array('to' => array($row['id_member']), 'bcc' => array()), $subject, $message); |
|
1062 | + if (!$context['send_pm']) { |
|
1063 | + sendmail($row['email_address'], $subject, $message, null, 'news', !empty($_POST['send_html']), 5); |
|
1064 | + } else { |
|
1065 | + sendpm(array('to' => array($row['id_member']), 'bcc' => array()), $subject, $message); |
|
1066 | + } |
|
1030 | 1067 | } |
1031 | 1068 | } |
1032 | 1069 | |
@@ -1076,8 +1113,9 @@ discard block |
||
1076 | 1113 | |
1077 | 1114 | call_integration_hook('integrate_modify_news_settings', array(&$config_vars)); |
1078 | 1115 | |
1079 | - if ($return_config) |
|
1080 | - return $config_vars; |
|
1116 | + if ($return_config) { |
|
1117 | + return $config_vars; |
|
1118 | + } |
|
1081 | 1119 | |
1082 | 1120 | $context['page_title'] = $txt['admin_edit_news'] . ' - ' . $txt['settings']; |
1083 | 1121 | $context['sub_template'] = 'show_settings'; |