@@ -25,18 +25,20 @@ discard block |
||
| 25 | 25 | </div> |
| 26 | 26 | <div class="windowbg2 noup">'; |
| 27 | 27 | |
| 28 | - if (!empty($context['move_board'])) |
|
| 29 | - echo ' |
|
| 28 | + if (!empty($context['move_board'])) { |
|
| 29 | + echo ' |
|
| 30 | 30 | <div class="noticebox"> |
| 31 | 31 | ', $context['move_title'], ' [<a href="', $scripturl, '?action=admin;area=manageboards">', $txt['mboards_cancel_moving'], '</a>]', ' |
| 32 | 32 | </div>'; |
| 33 | + } |
|
| 33 | 34 | |
| 34 | 35 | // No categories so show a label. |
| 35 | - if (empty($context['categories'])) |
|
| 36 | - echo ' |
|
| 36 | + if (empty($context['categories'])) { |
|
| 37 | + echo ' |
|
| 37 | 38 | <div class="windowbg centertext"> |
| 38 | 39 | ', $txt['mboards_no_cats'], ' |
| 39 | 40 | </div>'; |
| 41 | + } |
|
| 40 | 42 | |
| 41 | 43 | // Loop through every category, listing the boards in each as we go. |
| 42 | 44 | foreach ($context['categories'] as $category) |
@@ -54,9 +56,10 @@ discard block |
||
| 54 | 56 | <form action="', $scripturl, '?action=admin;area=manageboards;sa=newboard;cat=', $category['id'], '" method="post" accept-charset="', $context['character_set'], '"> |
| 55 | 57 | <ul id="category_', $category['id'], '" class="nolist">'; |
| 56 | 58 | |
| 57 | - if (!empty($category['move_link'])) |
|
| 58 | - echo ' |
|
| 59 | + if (!empty($category['move_link'])) { |
|
| 60 | + echo ' |
|
| 59 | 61 | <li><a href="', $category['move_link']['href'], '" title="', $category['move_link']['label'], '"><span class="generic_icons select_above"></span></a></li>'; |
| 62 | + } |
|
| 60 | 63 | |
| 61 | 64 | $recycle_board = '<a href="' . $scripturl . '?action=admin;area=manageboards;sa=settings"> <img src="' . $settings['images_url'] . '/post/recycled.png" alt="' . $txt['recycle_board'] . '" title="' . $txt['recycle_board'] . '"></a>'; |
| 62 | 65 | $redirect_board = '<img src="' . $settings['images_url'] . '/new_redirect.png" alt="' . $txt['redirect_board_desc'] . '" title="' . $txt['redirect_board_desc'] . '">'; |
@@ -81,9 +84,10 @@ discard block |
||
| 81 | 84 | echo ' |
| 82 | 85 | <li class="windowbg" style="padding-', $context['right_to_left'] ? 'right' : 'left', ': ', 5 + 30 * $board['move_links'][0]['child_level'], 'px;">'; |
| 83 | 86 | |
| 84 | - foreach ($board['move_links'] as $link) |
|
| 85 | - echo ' |
|
| 87 | + foreach ($board['move_links'] as $link) { |
|
| 88 | + echo ' |
|
| 86 | 89 | <a href="', $link['href'], '" class="move_links" title="', $link['label'], '"><span class="generic_icons select_', $link['class'], '" title="', $link['label'], '"></span></a>'; |
| 90 | + } |
|
| 87 | 91 | |
| 88 | 92 | echo ' |
| 89 | 93 | </li>'; |
@@ -132,9 +136,10 @@ discard block |
||
| 132 | 136 | <select name="cat_order">'; |
| 133 | 137 | |
| 134 | 138 | // Print every existing category into a select box. |
| 135 | - foreach ($context['category_order'] as $order) |
|
| 136 | - echo ' |
|
| 139 | + foreach ($context['category_order'] as $order) { |
|
| 140 | + echo ' |
|
| 137 | 141 | <option', $order['selected'] ? ' selected' : '', ' value="', $order['id'], '">', $order['name'], '</option>'; |
| 142 | + } |
|
| 138 | 143 | echo ' |
| 139 | 144 | </select> |
| 140 | 145 | </dd>'; |
@@ -169,14 +174,15 @@ discard block |
||
| 169 | 174 | { |
| 170 | 175 | foreach ($context['custom_category_settings'] as $catset_id => $catset) |
| 171 | 176 | { |
| 172 | - if (!empty($catset['dt']) && !empty($catset['dd'])) |
|
| 173 | - echo ' |
|
| 177 | + if (!empty($catset['dt']) && !empty($catset['dd'])) { |
|
| 178 | + echo ' |
|
| 174 | 179 | <dt class="clear', !is_numeric($catset_id) ? ' catset_' . $catset_id : '', '"> |
| 175 | 180 | ', $catset['dt'], ' |
| 176 | 181 | </dt> |
| 177 | 182 | <dd', !is_numeric($catset_id) ? ' class="catset_' . $catset_id . '"' : '', '> |
| 178 | 183 | ', $catset['dd'], ' |
| 179 | 184 | </dd>'; |
| 185 | + } |
|
| 180 | 186 | } |
| 181 | 187 | } |
| 182 | 188 | |
@@ -184,21 +190,23 @@ discard block |
||
| 184 | 190 | echo ' |
| 185 | 191 | </dl>'; |
| 186 | 192 | |
| 187 | - if (isset($context['category']['is_new'])) |
|
| 188 | - echo ' |
|
| 193 | + if (isset($context['category']['is_new'])) { |
|
| 194 | + echo ' |
|
| 189 | 195 | <input type="submit" name="add" value="', $txt['mboards_add_cat_button'], '" onclick="return !isEmptyText(this.form.cat_name);" tabindex="', $context['tabindex']++, '" class="button_submit">'; |
| 190 | - else |
|
| 191 | - echo ' |
|
| 196 | + } else { |
|
| 197 | + echo ' |
|
| 192 | 198 | <input type="submit" name="edit" value="', $txt['modify'], '" onclick="return !isEmptyText(this.form.cat_name);" tabindex="', $context['tabindex']++, '" class="button_submit"> |
| 193 | 199 | <input type="submit" name="delete" value="', $txt['mboards_delete_cat'], '" data-confirm="', $txt['catConfirm'], '" class="button_submit you_sure">'; |
| 200 | + } |
|
| 194 | 201 | echo ' |
| 195 | 202 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
| 196 | 203 | <input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">'; |
| 197 | 204 | |
| 198 | 205 | // If this category is empty we don't bother with the next confirmation screen. |
| 199 | - if ($context['category']['is_empty']) |
|
| 200 | - echo ' |
|
| 206 | + if ($context['category']['is_empty']) { |
|
| 207 | + echo ' |
|
| 201 | 208 | <input type="hidden" name="empty" value="1">'; |
| 209 | + } |
|
| 202 | 210 | |
| 203 | 211 | echo ' |
| 204 | 212 | </div> |
@@ -225,9 +233,10 @@ discard block |
||
| 225 | 233 | <p>', $txt['mboards_delete_cat_contains'], ':</p> |
| 226 | 234 | <ul>'; |
| 227 | 235 | |
| 228 | - foreach ($context['category']['children'] as $child) |
|
| 229 | - echo ' |
|
| 236 | + foreach ($context['category']['children'] as $child) { |
|
| 237 | + echo ' |
|
| 230 | 238 | <li>', $child, '</li>'; |
| 239 | + } |
|
| 231 | 240 | |
| 232 | 241 | echo ' |
| 233 | 242 | </ul> |
@@ -241,10 +250,11 @@ discard block |
||
| 241 | 250 | <label for="delete_action1"><input type="radio" id="delete_action1" name="delete_action" value="1" class="input_radio"', count($context['category_order']) == 1 ? ' disabled' : '', '>', $txt['mboards_delete_option2'], '</label>: |
| 242 | 251 | <select name="cat_to"', count($context['category_order']) == 1 ? ' disabled' : '', '>'; |
| 243 | 252 | |
| 244 | - foreach ($context['category_order'] as $cat) |
|
| 245 | - if ($cat['id'] != 0) |
|
| 253 | + foreach ($context['category_order'] as $cat) { |
|
| 254 | + if ($cat['id'] != 0) |
|
| 246 | 255 | echo ' |
| 247 | 256 | <option value="', $cat['id'], '">', $cat['true_name'], '</option>'; |
| 257 | + } |
|
| 248 | 258 | |
| 249 | 259 | echo ' |
| 250 | 260 | </select> |
@@ -288,9 +298,10 @@ discard block |
||
| 288 | 298 | </dt> |
| 289 | 299 | <dd> |
| 290 | 300 | <select name="new_cat" onchange="if (this.form.order) {this.form.order.disabled = this.options[this.selectedIndex].value != 0; this.form.board_order.disabled = this.options[this.selectedIndex].value != 0 || this.form.order.options[this.form.order.selectedIndex].value == \'\';}">'; |
| 291 | - foreach ($context['categories'] as $category) |
|
| 292 | - echo ' |
|
| 301 | + foreach ($context['categories'] as $category) { |
|
| 302 | + echo ' |
|
| 293 | 303 | <option', $category['selected'] ? ' selected' : '', ' value="', $category['id'], '">', $category['name'], '</option>'; |
| 304 | + } |
|
| 294 | 305 | echo ' |
| 295 | 306 | </select> |
| 296 | 307 | </dd>'; |
@@ -317,9 +328,10 @@ discard block |
||
| 317 | 328 | echo ' |
| 318 | 329 | <select id="board_order" name="board_order"', !isset($context['board']['is_new']) ? ' disabled' : '', '> |
| 319 | 330 | ', !isset($context['board']['is_new']) ? '<option value="">(' . $txt['mboards_unchanged'] . ')</option>' : ''; |
| 320 | - foreach ($context['board_order'] as $order) |
|
| 321 | - echo ' |
|
| 331 | + foreach ($context['board_order'] as $order) { |
|
| 332 | + echo ' |
|
| 322 | 333 | <option', $order['selected'] ? ' selected' : '', ' value="', $order['id'], '">', $order['name'], '</option>'; |
| 334 | + } |
|
| 323 | 335 | echo ' |
| 324 | 336 | </select> |
| 325 | 337 | </dd>'; |
@@ -348,13 +360,15 @@ discard block |
||
| 348 | 360 | <dd> |
| 349 | 361 | <select name="profile">'; |
| 350 | 362 | |
| 351 | - if (isset($context['board']['is_new'])) |
|
| 352 | - echo ' |
|
| 363 | + if (isset($context['board']['is_new'])) { |
|
| 364 | + echo ' |
|
| 353 | 365 | <option value="-1">[', $txt['permission_profile_inherit'], ']</option>'; |
| 366 | + } |
|
| 354 | 367 | |
| 355 | - foreach ($context['profiles'] as $id => $profile) |
|
| 356 | - echo ' |
|
| 368 | + foreach ($context['profiles'] as $id => $profile) { |
|
| 369 | + echo ' |
|
| 357 | 370 | <option value="', $id, '"', $id == $context['board']['profile'] ? ' selected' : '', '>', $profile['name'], '</option>'; |
| 371 | + } |
|
| 358 | 372 | |
| 359 | 373 | echo ' |
| 360 | 374 | </select> |
@@ -367,8 +381,8 @@ discard block |
||
| 367 | 381 | </dt> |
| 368 | 382 | <dd>'; |
| 369 | 383 | |
| 370 | - if (!empty($modSettings['deny_boards_access'])) |
|
| 371 | - echo ' |
|
| 384 | + if (!empty($modSettings['deny_boards_access'])) { |
|
| 385 | + echo ' |
|
| 372 | 386 | <table> |
| 373 | 387 | <tr> |
| 374 | 388 | <td></td> |
@@ -376,10 +390,11 @@ discard block |
||
| 376 | 390 | <th>', $txt['permissions_option_off'], '</th> |
| 377 | 391 | <th>', $txt['permissions_option_deny'], '</th> |
| 378 | 392 | </tr>'; |
| 393 | + } |
|
| 379 | 394 | |
| 380 | 395 | // List all the membergroups so the user can choose who may access this board. |
| 381 | - foreach ($context['groups'] as $group) |
|
| 382 | - if (empty($modSettings['deny_boards_access'])) |
|
| 396 | + foreach ($context['groups'] as $group) { |
|
| 397 | + if (empty($modSettings['deny_boards_access'])) |
|
| 383 | 398 | echo ' |
| 384 | 399 | <label for="groups_', $group['id'], '"> |
| 385 | 400 | <input type="checkbox" name="groups[', $group['id'], ']" value="allow" id="groups_', $group['id'], '"', in_array($group['id'], $context['board_managers']) ? ' checked disabled' : ($group['allow'] ? ' checked' : ''), ' class="input_check"> |
@@ -387,8 +402,9 @@ discard block |
||
| 387 | 402 | ', $group['name'], ' |
| 388 | 403 | </span> |
| 389 | 404 | </label><br>'; |
| 390 | - else |
|
| 391 | - echo ' |
|
| 405 | + } |
|
| 406 | + else { |
|
| 407 | + echo ' |
|
| 392 | 408 | <tr> |
| 393 | 409 | <td> |
| 394 | 410 | <label for="groups_', $group['id'], '_a"> |
@@ -408,16 +424,17 @@ discard block |
||
| 408 | 424 | </td> |
| 409 | 425 | <td></td> |
| 410 | 426 | </tr>'; |
| 427 | + } |
|
| 411 | 428 | |
| 412 | - if (empty($modSettings['deny_boards_access'])) |
|
| 413 | - echo ' |
|
| 429 | + if (empty($modSettings['deny_boards_access'])) { |
|
| 430 | + echo ' |
|
| 414 | 431 | <span class="select_all_box"> |
| 415 | 432 | <em>', $txt['check_all'], '</em> <input type="checkbox" class="input_check" onclick="invertAll(this, this.form, \'groups[\');"> |
| 416 | 433 | </span> |
| 417 | 434 | <br><br> |
| 418 | 435 | </dd>'; |
| 419 | - else |
|
| 420 | - echo ' |
|
| 436 | + } else { |
|
| 437 | + echo ' |
|
| 421 | 438 | <tr class="select_all_box"> |
| 422 | 439 | <td> |
| 423 | 440 | </td> |
@@ -436,6 +453,7 @@ discard block |
||
| 436 | 453 | </tr> |
| 437 | 454 | </table> |
| 438 | 455 | </dd>'; |
| 456 | + } |
|
| 439 | 457 | |
| 440 | 458 | // Options to choose moderators, specify as announcement board and choose whether to count posts here. |
| 441 | 459 | echo ' |
@@ -490,8 +508,8 @@ discard block |
||
| 490 | 508 | </dl> |
| 491 | 509 | </div>'; |
| 492 | 510 | |
| 493 | - if ($context['board']['redirect']) |
|
| 494 | - echo ' |
|
| 511 | + if ($context['board']['redirect']) { |
|
| 512 | + echo ' |
|
| 495 | 513 | <div id="reset_redirect_div"> |
| 496 | 514 | <dl class="settings"> |
| 497 | 515 | <dt> |
@@ -504,6 +522,7 @@ discard block |
||
| 504 | 522 | </dd> |
| 505 | 523 | </dl> |
| 506 | 524 | </div>'; |
| 525 | + } |
|
| 507 | 526 | } |
| 508 | 527 | |
| 509 | 528 | echo ' |
@@ -531,9 +550,10 @@ discard block |
||
| 531 | 550 | <select name="boardtheme" id="boardtheme" onchange="refreshOptions();"> |
| 532 | 551 | <option value="0"', $context['board']['theme'] == 0 ? ' selected' : '', '>', $txt['mboards_theme_default'], '</option>'; |
| 533 | 552 | |
| 534 | - foreach ($context['themes'] as $theme) |
|
| 535 | - echo ' |
|
| 553 | + foreach ($context['themes'] as $theme) { |
|
| 554 | + echo ' |
|
| 536 | 555 | <option value="', $theme['id'], '"', $context['board']['theme'] == $theme['id'] ? ' selected' : '', '>', $theme['name'], '</option>'; |
| 556 | + } |
|
| 537 | 557 | |
| 538 | 558 | echo ' |
| 539 | 559 | </select> |
@@ -562,14 +582,15 @@ discard block |
||
| 562 | 582 | |
| 563 | 583 | foreach ($context['custom_board_settings'] as $cbs_id => $cbs) |
| 564 | 584 | { |
| 565 | - if (!empty($cbs['dt']) && !empty($cbs['dd'])) |
|
| 566 | - echo ' |
|
| 585 | + if (!empty($cbs['dt']) && !empty($cbs['dd'])) { |
|
| 586 | + echo ' |
|
| 567 | 587 | <dt class="clear', !is_numeric($cbs_id) ? ' cbs_' . $cbs_id : '', '"> |
| 568 | 588 | ', $cbs['dt'], ' |
| 569 | 589 | </dt> |
| 570 | 590 | <dd', !is_numeric($cbs_id) ? ' class="cbs_' . $cbs_id . '"' : '', '> |
| 571 | 591 | ', $cbs['dd'], ' |
| 572 | 592 | </dd>'; |
| 593 | + } |
|
| 573 | 594 | } |
| 574 | 595 | |
| 575 | 596 | echo ' |
@@ -577,9 +598,10 @@ discard block |
||
| 577 | 598 | </div>'; |
| 578 | 599 | } |
| 579 | 600 | |
| 580 | - if (!empty($context['board']['is_recycle'])) |
|
| 581 | - echo ' |
|
| 601 | + if (!empty($context['board']['is_recycle'])) { |
|
| 602 | + echo ' |
|
| 582 | 603 | <div class="noticebox">', $txt['mboards_recycle_disabled_delete'], '</div>'; |
| 604 | + } |
|
| 583 | 605 | |
| 584 | 606 | echo ' |
| 585 | 607 | <input type="hidden" name="rid" value="', $context['redirect_location'], '"> |
@@ -587,21 +609,24 @@ discard block |
||
| 587 | 609 | <input type="hidden" name="', $context['admin-be-' . $context['board']['id'] . '_token_var'], '" value="', $context['admin-be-' . $context['board']['id'] . '_token'], '">'; |
| 588 | 610 | |
| 589 | 611 | // If this board has no children don't bother with the next confirmation screen. |
| 590 | - if ($context['board']['no_children']) |
|
| 591 | - echo ' |
|
| 612 | + if ($context['board']['no_children']) { |
|
| 613 | + echo ' |
|
| 592 | 614 | <input type="hidden" name="no_children" value="1">'; |
| 615 | + } |
|
| 593 | 616 | |
| 594 | - if (isset($context['board']['is_new'])) |
|
| 595 | - echo ' |
|
| 617 | + if (isset($context['board']['is_new'])) { |
|
| 618 | + echo ' |
|
| 596 | 619 | <input type="hidden" name="cur_cat" value="', $context['board']['category'], '"> |
| 597 | 620 | <input type="submit" name="add" value="', $txt['mboards_new_board'], '" onclick="return !isEmptyText(this.form.board_name);" class="button_submit">'; |
| 598 | - else |
|
| 599 | - echo ' |
|
| 621 | + } else { |
|
| 622 | + echo ' |
|
| 600 | 623 | <input type="submit" name="edit" value="', $txt['modify'], '" onclick="return !isEmptyText(this.form.board_name);" class="button_submit">'; |
| 624 | + } |
|
| 601 | 625 | |
| 602 | - if (!isset($context['board']['is_new']) && empty($context['board']['is_recycle'])) |
|
| 603 | - echo ' |
|
| 626 | + if (!isset($context['board']['is_new']) && empty($context['board']['is_recycle'])) { |
|
| 627 | + echo ' |
|
| 604 | 628 | <input type="submit" name="delete" value="', $txt['mboards_delete_board'], '" data-confirm="', $txt['boardConfirm'], '" class="button_submit you_sure">'; |
| 629 | + } |
|
| 605 | 630 | echo ' |
| 606 | 631 | </div> |
| 607 | 632 | </form> |
@@ -622,12 +647,13 @@ discard block |
||
| 622 | 647 | sItemListContainerId: \'moderator_container\', |
| 623 | 648 | aListItems: ['; |
| 624 | 649 | |
| 625 | - foreach ($context['board']['moderators'] as $id_member => $member_name) |
|
| 626 | - echo ' |
|
| 650 | + foreach ($context['board']['moderators'] as $id_member => $member_name) { |
|
| 651 | + echo ' |
|
| 627 | 652 | { |
| 628 | 653 | sItemId: ', JavaScriptEscape($id_member), ', |
| 629 | 654 | sItemName: ', JavaScriptEscape($member_name), ' |
| 630 | 655 | }', $id_member == $context['board']['last_moderator_id'] ? '' : ','; |
| 656 | + } |
|
| 631 | 657 | |
| 632 | 658 | echo ' |
| 633 | 659 | ] |
@@ -647,12 +673,13 @@ discard block |
||
| 647 | 673 | sItemListContainerId: \'moderator_group_container\', |
| 648 | 674 | aListItems: ['; |
| 649 | 675 | |
| 650 | - foreach ($context['board']['moderator_groups'] as $id_group => $group_name) |
|
| 651 | - echo ' |
|
| 676 | + foreach ($context['board']['moderator_groups'] as $id_group => $group_name) { |
|
| 677 | + echo ' |
|
| 652 | 678 | { |
| 653 | 679 | sItemId: ', JavaScriptEscape($id_group), ', |
| 654 | 680 | sItemName: ', JavaScriptEscape($group_name), ' |
| 655 | 681 | }', $id_group == $context['board']['last_moderator_group_id'] ? '' : ','; |
| 682 | + } |
|
| 656 | 683 | |
| 657 | 684 | echo ' |
| 658 | 685 | ] |
@@ -678,17 +705,19 @@ discard block |
||
| 678 | 705 | echo ' |
| 679 | 706 | document.getElementById("redirect_address_div").style.display = redirectEnabled ? "" : "none";'; |
| 680 | 707 | |
| 681 | - if ($context['board']['redirect']) |
|
| 682 | - echo ' |
|
| 708 | + if ($context['board']['redirect']) { |
|
| 709 | + echo ' |
|
| 683 | 710 | document.getElementById("reset_redirect_div").style.display = redirectEnabled ? "" : "none";'; |
| 711 | + } |
|
| 684 | 712 | } |
| 685 | 713 | |
| 686 | 714 | // Include any JavaScript added by mods using the 'integrate_edit_board' hook. |
| 687 | 715 | if (!empty($context['custom_refreshOptions']) && is_array($context['custom_refreshOptions'])) |
| 688 | 716 | { |
| 689 | - foreach ($context['custom_refreshOptions'] as $refreshOption) |
|
| 690 | - echo ' |
|
| 717 | + foreach ($context['custom_refreshOptions'] as $refreshOption) { |
|
| 718 | + echo ' |
|
| 691 | 719 | ', $refreshOption; |
| 720 | + } |
|
| 692 | 721 | } |
| 693 | 722 | |
| 694 | 723 | echo ' |
@@ -717,9 +746,10 @@ discard block |
||
| 717 | 746 | <p>', $txt['mboards_delete_board_contains'], '</p> |
| 718 | 747 | <ul>'; |
| 719 | 748 | |
| 720 | - foreach ($context['children'] as $child) |
|
| 721 | - echo ' |
|
| 749 | + foreach ($context['children'] as $child) { |
|
| 750 | + echo ' |
|
| 722 | 751 | <li>', $child['node']['name'], '</li>'; |
| 752 | + } |
|
| 723 | 753 | |
| 724 | 754 | echo ' |
| 725 | 755 | </ul> |
@@ -733,10 +763,11 @@ discard block |
||
| 733 | 763 | <label for="delete_action1"><input type="radio" id="delete_action1" name="delete_action" value="1" class="input_radio"', empty($context['can_move_children']) ? ' disabled' : '', '>', $txt['mboards_delete_board_option2'], '</label>: |
| 734 | 764 | <select name="board_to"', empty($context['can_move_children']) ? ' disabled' : '', '>'; |
| 735 | 765 | |
| 736 | - foreach ($context['board_order'] as $board) |
|
| 737 | - if ($board['id'] != $context['board']['id'] && empty($board['is_child'])) |
|
| 766 | + foreach ($context['board_order'] as $board) { |
|
| 767 | + if ($board['id'] != $context['board']['id'] && empty($board['is_child'])) |
|
| 738 | 768 | echo ' |
| 739 | 769 | <option value="', $board['id'], '">', $board['name'], '</option>'; |
| 770 | + } |
|
| 740 | 771 | |
| 741 | 772 | echo ' |
| 742 | 773 | </select> |
@@ -51,11 +51,13 @@ discard block |
||
| 51 | 51 | <p>'; |
| 52 | 52 | |
| 53 | 53 | // Show just numbers...? |
| 54 | - if ($settings['display_who_viewing'] == 1) |
|
| 55 | - echo count($context['view_members']), ' ', count($context['view_members']) == 1 ? $txt['who_member'] : $txt['members']; |
|
| 54 | + if ($settings['display_who_viewing'] == 1) { |
|
| 55 | + echo count($context['view_members']), ' ', count($context['view_members']) == 1 ? $txt['who_member'] : $txt['members']; |
|
| 56 | + } |
|
| 56 | 57 | // Or show the actual people viewing the topic? |
| 57 | - else |
|
| 58 | - 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'] . ')'); |
|
| 58 | + else { |
|
| 59 | + 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'] . ')'); |
|
| 60 | + } |
|
| 59 | 61 | |
| 60 | 62 | // Now show how many guests are here too. |
| 61 | 63 | echo $txt['who_and'], $context['view_num_guests'], ' ', $context['view_num_guests'] == 1 ? $txt['guest'] : $txt['guests'], $txt['who_viewing_topic'], ' |
@@ -93,10 +95,11 @@ discard block |
||
| 93 | 95 | <dt class="', $option['voted_this'] ? ' voted' : '', '">', $option['option'], '</dt> |
| 94 | 96 | <dd class="statsbar', $option['voted_this'] ? ' voted' : '', '">'; |
| 95 | 97 | |
| 96 | - if ($context['allow_results_view']) |
|
| 97 | - echo ' |
|
| 98 | + if ($context['allow_results_view']) { |
|
| 99 | + echo ' |
|
| 98 | 100 | ', $option['bar_ndt'], ' |
| 99 | 101 | <span class="percentage">', $option['votes'], ' (', $option['percent'], '%)</span>'; |
| 102 | + } |
|
| 100 | 103 | |
| 101 | 104 | echo ' |
| 102 | 105 | </dd>'; |
@@ -105,9 +108,10 @@ discard block |
||
| 105 | 108 | echo ' |
| 106 | 109 | </dl>'; |
| 107 | 110 | |
| 108 | - if ($context['allow_results_view']) |
|
| 109 | - echo ' |
|
| 111 | + if ($context['allow_results_view']) { |
|
| 112 | + echo ' |
|
| 110 | 113 | <p><strong>', $txt['poll_total_voters'], ':</strong> ', $context['poll']['total_votes'], '</p>'; |
| 114 | + } |
|
| 111 | 115 | } |
| 112 | 116 | // They are allowed to vote! Go to it! |
| 113 | 117 | else |
@@ -116,17 +120,19 @@ discard block |
||
| 116 | 120 | <form action="', $scripturl, '?action=vote;topic=', $context['current_topic'], '.', $context['start'], ';poll=', $context['poll']['id'], '" method="post" accept-charset="', $context['character_set'], '">'; |
| 117 | 121 | |
| 118 | 122 | // Show a warning if they are allowed more than one option. |
| 119 | - if ($context['poll']['allowed_warning']) |
|
| 120 | - echo ' |
|
| 123 | + if ($context['poll']['allowed_warning']) { |
|
| 124 | + echo ' |
|
| 121 | 125 | <p class="smallpadding">', $context['poll']['allowed_warning'], '</p>'; |
| 126 | + } |
|
| 122 | 127 | |
| 123 | 128 | echo ' |
| 124 | 129 | <ul class="options">'; |
| 125 | 130 | |
| 126 | 131 | // Show each option with its button - a radio likely. |
| 127 | - foreach ($context['poll']['options'] as $option) |
|
| 128 | - echo ' |
|
| 132 | + foreach ($context['poll']['options'] as $option) { |
|
| 133 | + echo ' |
|
| 129 | 134 | <li>', $option['vote_button'], ' <label for="', $option['id'], '">', $option['option'], '</label></li>'; |
| 135 | + } |
|
| 130 | 136 | |
| 131 | 137 | echo ' |
| 132 | 138 | </ul> |
@@ -138,9 +144,10 @@ discard block |
||
| 138 | 144 | } |
| 139 | 145 | |
| 140 | 146 | // Is the clock ticking? |
| 141 | - if (!empty($context['poll']['expire_time'])) |
|
| 142 | - echo ' |
|
| 147 | + if (!empty($context['poll']['expire_time'])) { |
|
| 148 | + echo ' |
|
| 143 | 149 | <p><strong>', ($context['poll']['is_expired'] ? $txt['poll_expired_on'] : $txt['poll_expires_on']), ':</strong> ', $context['poll']['expire_time'], '</p>'; |
| 150 | + } |
|
| 144 | 151 | |
| 145 | 152 | echo ' |
| 146 | 153 | </div> |
@@ -170,11 +177,13 @@ discard block |
||
| 170 | 177 | <li> |
| 171 | 178 | <b class="event_title"><a href="', $scripturl, '?action=calendar;event=', $event['id'], '">', $event['title'], '</a></b>'; |
| 172 | 179 | |
| 173 | - if ($event['can_edit']) |
|
| 174 | - echo ' <a href="' . $event['modify_href'] . '"><span class="generic_icons calendar_modify" title="', $txt['calendar_edit'], '"></span></a>'; |
|
| 180 | + if ($event['can_edit']) { |
|
| 181 | + echo ' <a href="' . $event['modify_href'] . '"><span class="generic_icons calendar_modify" title="', $txt['calendar_edit'], '"></span></a>'; |
|
| 182 | + } |
|
| 175 | 183 | |
| 176 | - if ($event['can_export']) |
|
| 177 | - echo ' <a href="' . $event['export_href'] . '"><span class="generic_icons calendar_export" title="', $txt['calendar_export'], '"></span></a>'; |
|
| 184 | + if ($event['can_export']) { |
|
| 185 | + echo ' <a href="' . $event['export_href'] . '"><span class="generic_icons calendar_export" title="', $txt['calendar_export'], '"></span></a>'; |
|
| 186 | + } |
|
| 178 | 187 | |
| 179 | 188 | echo ' |
| 180 | 189 | <br>'; |
@@ -182,14 +191,14 @@ discard block |
||
| 182 | 191 | if (!empty($event['allday'])) |
| 183 | 192 | { |
| 184 | 193 | echo '<time datetime="' . $event['start_iso_gmdate'] . '">', trim($event['start_date_local']), '</time>', ($event['start_date'] != $event['end_date']) ? ' – <time datetime="' . $event['end_iso_gmdate'] . '">' . trim($event['end_date_local']) . '</time>' : ''; |
| 185 | - } |
|
| 186 | - else |
|
| 194 | + } else |
|
| 187 | 195 | { |
| 188 | 196 | // Display event info relative to user's local timezone |
| 189 | 197 | echo '<time datetime="' . $event['start_iso_gmdate'] . '">', trim($event['start_date_local']), ', ', trim($event['start_time_local']), '</time> – <time datetime="' . $event['end_iso_gmdate'] . '">'; |
| 190 | 198 | |
| 191 | - if ($event['start_date_local'] != $event['end_date_local']) |
|
| 192 | - echo trim($event['end_date_local']) . ', '; |
|
| 199 | + if ($event['start_date_local'] != $event['end_date_local']) { |
|
| 200 | + echo trim($event['end_date_local']) . ', '; |
|
| 201 | + } |
|
| 193 | 202 | |
| 194 | 203 | echo trim($event['end_time_local']); |
| 195 | 204 | |
@@ -198,23 +207,27 @@ discard block |
||
| 198 | 207 | { |
| 199 | 208 | echo '</time> (<time datetime="' . $event['start_iso_gmdate'] . '">'; |
| 200 | 209 | |
| 201 | - if ($event['start_date_orig'] != $event['start_date_local'] || $event['end_date_orig'] != $event['end_date_local'] || $event['start_date_orig'] != $event['end_date_orig']) |
|
| 202 | - echo trim($event['start_date_orig']), ', '; |
|
| 210 | + if ($event['start_date_orig'] != $event['start_date_local'] || $event['end_date_orig'] != $event['end_date_local'] || $event['start_date_orig'] != $event['end_date_orig']) { |
|
| 211 | + echo trim($event['start_date_orig']), ', '; |
|
| 212 | + } |
|
| 203 | 213 | |
| 204 | 214 | echo trim($event['start_time_orig']), '</time> – <time datetime="' . $event['end_iso_gmdate'] . '">'; |
| 205 | 215 | |
| 206 | - if ($event['start_date_orig'] != $event['end_date_orig']) |
|
| 207 | - echo trim($event['end_date_orig']) . ', '; |
|
| 216 | + if ($event['start_date_orig'] != $event['end_date_orig']) { |
|
| 217 | + echo trim($event['end_date_orig']) . ', '; |
|
| 218 | + } |
|
| 208 | 219 | |
| 209 | 220 | echo trim($event['end_time_orig']), ' ', $event['tz_abbrev'], '</time>)'; |
| 210 | 221 | } |
| 211 | 222 | // Event is scheduled in the user's own timezone? Let 'em know, just to avoid confusion |
| 212 | - else |
|
| 213 | - echo ' ', $event['tz_abbrev'], '</time>'; |
|
| 223 | + else { |
|
| 224 | + echo ' ', $event['tz_abbrev'], '</time>'; |
|
| 225 | + } |
|
| 214 | 226 | } |
| 215 | 227 | |
| 216 | - if (!empty($event['location'])) |
|
| 217 | - echo '<br>', $event['location']; |
|
| 228 | + if (!empty($event['location'])) { |
|
| 229 | + echo '<br>', $event['location']; |
|
| 230 | + } |
|
| 218 | 231 | |
| 219 | 232 | echo ' |
| 220 | 233 | </li>'; |
@@ -252,8 +265,9 @@ discard block |
||
| 252 | 265 | $context['removableMessageIDs'] = array(); |
| 253 | 266 | |
| 254 | 267 | // Get all the messages... |
| 255 | - while ($message = $context['get_message']()) |
|
| 256 | - template_single_post($message); |
|
| 268 | + while ($message = $context['get_message']()) { |
|
| 269 | + template_single_post($message); |
|
| 270 | + } |
|
| 257 | 271 | |
| 258 | 272 | echo ' |
| 259 | 273 | </form> |
@@ -290,8 +304,9 @@ discard block |
||
| 290 | 304 | <div id="display_jump_to"> </div>'; |
| 291 | 305 | |
| 292 | 306 | // Show quickreply |
| 293 | - if ($context['can_reply']) |
|
| 294 | - template_quickreply(); |
|
| 307 | + if ($context['can_reply']) { |
|
| 308 | + template_quickreply(); |
|
| 309 | + } |
|
| 295 | 310 | |
| 296 | 311 | // User action pop on mobile screen (or actually small screen), this uses responsive css does not check mobile device. |
| 297 | 312 | echo ' |
@@ -304,8 +319,8 @@ discard block |
||
| 304 | 319 | </div>'; |
| 305 | 320 | |
| 306 | 321 | // Show the moderation button & pop only if user can moderate |
| 307 | - if ($context['can_moderate_forum'] || $context['user']['is_mod']) |
|
| 308 | - echo ' |
|
| 322 | + if ($context['can_moderate_forum'] || $context['user']['is_mod']) { |
|
| 323 | + echo ' |
|
| 309 | 324 | <div id="mobile_moderation" class="popup_container"> |
| 310 | 325 | <div class="popup_window description"> |
| 311 | 326 | <div class="popup_heading">', $txt['mobile_moderation'], ' |
@@ -315,6 +330,7 @@ discard block |
||
| 315 | 330 | </div> |
| 316 | 331 | </div> |
| 317 | 332 | </div>'; |
| 333 | + } |
|
| 318 | 334 | |
| 319 | 335 | echo ' |
| 320 | 336 | <script>'; |
@@ -438,9 +454,10 @@ discard block |
||
| 438 | 454 | }); |
| 439 | 455 | }'; |
| 440 | 456 | |
| 441 | - if (!empty($context['ignoredMsgs'])) |
|
| 442 | - echo ' |
|
| 457 | + if (!empty($context['ignoredMsgs'])) { |
|
| 458 | + echo ' |
|
| 443 | 459 | ignore_toggles([', implode(', ', $context['ignoredMsgs']), '], ', JavaScriptEscape($txt['show_ignore_user_post']), ');'; |
| 460 | + } |
|
| 444 | 461 | |
| 445 | 462 | echo ' |
| 446 | 463 | </script>'; |
@@ -457,8 +474,9 @@ discard block |
||
| 457 | 474 | |
| 458 | 475 | $ignoring = false; |
| 459 | 476 | |
| 460 | - if ($message['can_remove']) |
|
| 461 | - $context['removableMessageIDs'][] = $message['id']; |
|
| 477 | + if ($message['can_remove']) { |
|
| 478 | + $context['removableMessageIDs'][] = $message['id']; |
|
| 479 | + } |
|
| 462 | 480 | |
| 463 | 481 | // Are we ignoring this message? |
| 464 | 482 | if (!empty($message['is_ignored'])) |
@@ -484,9 +502,10 @@ discard block |
||
| 484 | 502 | <div class="custom_fields_above_member"> |
| 485 | 503 | <ul class="nolist">'; |
| 486 | 504 | |
| 487 | - foreach ($message['custom_fields']['above_member'] as $custom) |
|
| 488 | - echo ' |
|
| 505 | + foreach ($message['custom_fields']['above_member'] as $custom) { |
|
| 506 | + echo ' |
|
| 489 | 507 | <li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>'; |
| 508 | + } |
|
| 490 | 509 | |
| 491 | 510 | echo ' |
| 492 | 511 | </ul> |
@@ -497,9 +516,10 @@ discard block |
||
| 497 | 516 | <h4>'; |
| 498 | 517 | |
| 499 | 518 | // Show online and offline buttons? |
| 500 | - if (!empty($modSettings['onlineEnable']) && !$message['member']['is_guest']) |
|
| 501 | - echo ' |
|
| 519 | + if (!empty($modSettings['onlineEnable']) && !$message['member']['is_guest']) { |
|
| 520 | + echo ' |
|
| 502 | 521 | ', $context['can_send_pm'] ? '<a href="' . $message['member']['online']['href'] . '" title="' . $message['member']['online']['label'] . '">' : '', '<span class="' . ($message['member']['online']['is_online'] == 1 ? 'on' : 'off') . '" title="' . $message['member']['online']['text'] . '"></span>', $context['can_send_pm'] ? '</a>' : ''; |
| 522 | + } |
|
| 503 | 523 | |
| 504 | 524 | |
| 505 | 525 | // Show a link to the member's profile. |
@@ -512,51 +532,59 @@ discard block |
||
| 512 | 532 | |
| 513 | 533 | |
| 514 | 534 | // Show the user's avatar. |
| 515 | - if (!empty($modSettings['show_user_images']) && empty($options['show_no_avatars']) && !empty($message['member']['avatar']['image'])) |
|
| 516 | - echo ' |
|
| 535 | + if (!empty($modSettings['show_user_images']) && empty($options['show_no_avatars']) && !empty($message['member']['avatar']['image'])) { |
|
| 536 | + echo ' |
|
| 517 | 537 | <li class="avatar"> |
| 518 | 538 | <a href="', $message['member']['href'], '">', $message['member']['avatar']['image'], '</a> |
| 519 | 539 | </li>'; |
| 540 | + } |
|
| 520 | 541 | |
| 521 | 542 | // Are there any custom fields below the avatar? |
| 522 | - if (!empty($message['custom_fields']['below_avatar'])) |
|
| 523 | - foreach ($message['custom_fields']['below_avatar'] as $custom) |
|
| 543 | + if (!empty($message['custom_fields']['below_avatar'])) { |
|
| 544 | + foreach ($message['custom_fields']['below_avatar'] as $custom) |
|
| 524 | 545 | echo ' |
| 525 | 546 | <li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>'; |
| 547 | + } |
|
| 526 | 548 | |
| 527 | 549 | // Show the post group icons, but not for guests. |
| 528 | - if (!$message['member']['is_guest']) |
|
| 529 | - echo ' |
|
| 550 | + if (!$message['member']['is_guest']) { |
|
| 551 | + echo ' |
|
| 530 | 552 | <li class="icons">', $message['member']['group_icons'], '</li>'; |
| 553 | + } |
|
| 531 | 554 | |
| 532 | 555 | // Show the member's primary group (like 'Administrator') if they have one. |
| 533 | - if (!empty($message['member']['group'])) |
|
| 534 | - echo ' |
|
| 556 | + if (!empty($message['member']['group'])) { |
|
| 557 | + echo ' |
|
| 535 | 558 | <li class="membergroup">', $message['member']['group'], '</li>'; |
| 559 | + } |
|
| 536 | 560 | |
| 537 | 561 | // Show the member's custom title, if they have one. |
| 538 | - if (!empty($message['member']['title'])) |
|
| 539 | - echo ' |
|
| 562 | + if (!empty($message['member']['title'])) { |
|
| 563 | + echo ' |
|
| 540 | 564 | <li class="title">', $message['member']['title'], '</li>'; |
| 565 | + } |
|
| 541 | 566 | |
| 542 | 567 | // Don't show these things for guests. |
| 543 | 568 | if (!$message['member']['is_guest']) |
| 544 | 569 | { |
| 545 | 570 | |
| 546 | 571 | // Show the post group if and only if they have no other group or the option is on, and they are in a post group. |
| 547 | - if ((empty($modSettings['hide_post_group']) || empty($message['member']['group'])) && !empty($message['member']['post_group'])) |
|
| 548 | - echo ' |
|
| 572 | + if ((empty($modSettings['hide_post_group']) || empty($message['member']['group'])) && !empty($message['member']['post_group'])) { |
|
| 573 | + echo ' |
|
| 549 | 574 | <li class="postgroup">', $message['member']['post_group'], '</li>'; |
| 575 | + } |
|
| 550 | 576 | |
| 551 | 577 | // Show how many posts they have made. |
| 552 | - if (!isset($context['disabled_fields']['posts'])) |
|
| 553 | - echo ' |
|
| 578 | + if (!isset($context['disabled_fields']['posts'])) { |
|
| 579 | + echo ' |
|
| 554 | 580 | <li class="postcount">', $txt['member_postcount'], ': ', $message['member']['posts'], '</li>'; |
| 581 | + } |
|
| 555 | 582 | |
| 556 | 583 | // Show their personal text? |
| 557 | - if (!empty($modSettings['show_blurb']) && !empty($message['member']['blurb'])) |
|
| 558 | - echo ' |
|
| 584 | + if (!empty($modSettings['show_blurb']) && !empty($message['member']['blurb'])) { |
|
| 585 | + echo ' |
|
| 559 | 586 | <li class="blurb">', $message['member']['blurb'], '</li>'; |
| 587 | + } |
|
| 560 | 588 | |
| 561 | 589 | // Any custom fields to show as icons? |
| 562 | 590 | if (!empty($message['custom_fields']['icons'])) |
@@ -565,9 +593,10 @@ discard block |
||
| 565 | 593 | <li class="im_icons"> |
| 566 | 594 | <ol>'; |
| 567 | 595 | |
| 568 | - foreach ($message['custom_fields']['icons'] as $custom) |
|
| 569 | - echo ' |
|
| 596 | + foreach ($message['custom_fields']['icons'] as $custom) { |
|
| 597 | + echo ' |
|
| 570 | 598 | <li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>'; |
| 599 | + } |
|
| 571 | 600 | |
| 572 | 601 | echo ' |
| 573 | 602 | </ol> |
@@ -582,19 +611,22 @@ discard block |
||
| 582 | 611 | <ol class="profile_icons">'; |
| 583 | 612 | |
| 584 | 613 | // Don't show an icon if they haven't specified a website. |
| 585 | - if (!empty($message['member']['website']['url']) && !isset($context['disabled_fields']['website'])) |
|
| 586 | - echo ' |
|
| 614 | + if (!empty($message['member']['website']['url']) && !isset($context['disabled_fields']['website'])) { |
|
| 615 | + echo ' |
|
| 587 | 616 | <li><a href="', $message['member']['website']['url'], '" title="' . $message['member']['website']['title'] . '" target="_blank" class="new_win">', ($settings['use_image_buttons'] ? '<span class="generic_icons www centericon" title="' . $message['member']['website']['title'] . '"></span>' : $txt['www']), '</a></li>'; |
| 617 | + } |
|
| 588 | 618 | |
| 589 | 619 | // Since we know this person isn't a guest, you *can* message them. |
| 590 | - if ($context['can_send_pm']) |
|
| 591 | - echo ' |
|
| 620 | + if ($context['can_send_pm']) { |
|
| 621 | + echo ' |
|
| 592 | 622 | <li><a href="', $scripturl, '?action=pm;sa=send;u=', $message['member']['id'], '" title="', $message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline'], '">', $settings['use_image_buttons'] ? '<span class="generic_icons im_' . ($message['member']['online']['is_online'] ? 'on' : 'off') . ' centericon" title="' . ($message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline']) . '"></span> ' : ($message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline']), '</a></li>'; |
| 623 | + } |
|
| 593 | 624 | |
| 594 | 625 | // Show the email if necessary |
| 595 | - if (!empty($message['member']['email']) && $message['member']['show_email']) |
|
| 596 | - echo ' |
|
| 626 | + if (!empty($message['member']['email']) && $message['member']['show_email']) { |
|
| 627 | + echo ' |
|
| 597 | 628 | <li class="email"><a href="mailto:' . $message['member']['email'] . '" rel="nofollow">', ($settings['use_image_buttons'] ? '<span class="generic_icons mail centericon" title="' . $txt['email'] . '"></span>' : $txt['email']), '</a></li>'; |
| 629 | + } |
|
| 598 | 630 | |
| 599 | 631 | echo ' |
| 600 | 632 | </ol> |
@@ -602,48 +634,56 @@ discard block |
||
| 602 | 634 | } |
| 603 | 635 | |
| 604 | 636 | // Any custom fields for standard placement? |
| 605 | - if (!empty($message['custom_fields']['standard'])) |
|
| 606 | - foreach ($message['custom_fields']['standard'] as $custom) |
|
| 637 | + if (!empty($message['custom_fields']['standard'])) { |
|
| 638 | + foreach ($message['custom_fields']['standard'] as $custom) |
|
| 607 | 639 | echo ' |
| 608 | 640 | <li class="custom ', $custom['col_name'], '">', $custom['title'], ': ', $custom['value'], '</li>'; |
| 641 | + } |
|
| 609 | 642 | |
| 610 | 643 | } |
| 611 | 644 | // Otherwise, show the guest's email. |
| 612 | - elseif (!empty($message['member']['email']) && $message['member']['show_email']) |
|
| 613 | - echo ' |
|
| 645 | + elseif (!empty($message['member']['email']) && $message['member']['show_email']) { |
|
| 646 | + echo ' |
|
| 614 | 647 | <li class="email"><a href="mailto:' . $message['member']['email'] . '" rel="nofollow">', ($settings['use_image_buttons'] ? '<span class="generic_icons mail centericon" title="' . $txt['email'] . '"></span>' : $txt['email']), '</a></li>'; |
| 648 | + } |
|
| 615 | 649 | |
| 616 | 650 | // Show the IP to this user for this post - because you can moderate? |
| 617 | - if (!empty($context['can_moderate_forum']) && !empty($message['member']['ip'])) |
|
| 618 | - echo ' |
|
| 651 | + if (!empty($context['can_moderate_forum']) && !empty($message['member']['ip'])) { |
|
| 652 | + echo ' |
|
| 619 | 653 | <li class="poster_ip"><a href="', $scripturl, '?action=', !empty($message['member']['is_guest']) ? 'trackip' : 'profile;area=tracking;sa=ip;u=' . $message['member']['id'], ';searchip=', $message['member']['ip'], '">', $message['member']['ip'], '</a> <a href="', $scripturl, '?action=helpadmin;help=see_admin_ip" onclick="return reqOverlayDiv(this.href);" class="help">(?)</a></li>'; |
| 654 | + } |
|
| 620 | 655 | |
| 621 | 656 | // Or, should we show it because this is you? |
| 622 | - elseif ($message['can_see_ip']) |
|
| 623 | - echo ' |
|
| 657 | + elseif ($message['can_see_ip']) { |
|
| 658 | + echo ' |
|
| 624 | 659 | <li class="poster_ip"><a href="', $scripturl, '?action=helpadmin;help=see_member_ip" onclick="return reqOverlayDiv(this.href);" class="help">', $message['member']['ip'], '</a></li>'; |
| 660 | + } |
|
| 625 | 661 | |
| 626 | 662 | // Okay, are you at least logged in? Then we can show something about why IPs are logged... |
| 627 | - elseif (!$context['user']['is_guest']) |
|
| 628 | - echo ' |
|
| 663 | + elseif (!$context['user']['is_guest']) { |
|
| 664 | + echo ' |
|
| 629 | 665 | <li class="poster_ip"><a href="', $scripturl, '?action=helpadmin;help=see_member_ip" onclick="return reqOverlayDiv(this.href);" class="help">', $txt['logged'], '</a></li>'; |
| 666 | + } |
|
| 630 | 667 | |
| 631 | 668 | // Otherwise, you see NOTHING! |
| 632 | - else |
|
| 633 | - echo ' |
|
| 669 | + else { |
|
| 670 | + echo ' |
|
| 634 | 671 | <li class="poster_ip">', $txt['logged'], '</li>'; |
| 672 | + } |
|
| 635 | 673 | |
| 636 | 674 | // Are we showing the warning status? |
| 637 | 675 | // Don't show these things for guests. |
| 638 | - if (!$message['member']['is_guest'] && $message['member']['can_see_warning']) |
|
| 639 | - echo ' |
|
| 676 | + if (!$message['member']['is_guest'] && $message['member']['can_see_warning']) { |
|
| 677 | + echo ' |
|
| 640 | 678 | <li class="warning">', $context['can_issue_warning'] ? '<a href="' . $scripturl . '?action=profile;area=issuewarning;u=' . $message['member']['id'] . '">' : '', '<span class="generic_icons warning_', $message['member']['warning_status'], '"></span> ', $context['can_issue_warning'] ? '</a>' : '', '<span class="warn_', $message['member']['warning_status'], '">', $txt['warn_' . $message['member']['warning_status']], '</span></li>'; |
| 679 | + } |
|
| 641 | 680 | |
| 642 | 681 | // Are there any custom fields to show at the bottom of the poster info? |
| 643 | - if (!empty($message['custom_fields']['bottom_poster'])) |
|
| 644 | - foreach ($message['custom_fields']['bottom_poster'] as $custom) |
|
| 682 | + if (!empty($message['custom_fields']['bottom_poster'])) { |
|
| 683 | + foreach ($message['custom_fields']['bottom_poster'] as $custom) |
|
| 645 | 684 | echo ' |
| 646 | 685 | <li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>'; |
| 686 | + } |
|
| 647 | 687 | |
| 648 | 688 | // Poster info ends. |
| 649 | 689 | echo ' |
@@ -672,9 +712,10 @@ discard block |
||
| 672 | 712 | echo ' |
| 673 | 713 | <span class="smalltext modified floatright', !empty($modSettings['show_modify']) && !empty($message['modified']['name']) ? ' mvisible' : '','" id="modified_', $message['id'], '">'; |
| 674 | 714 | |
| 675 | - if (!empty($modSettings['show_modify']) && !empty($message['modified']['name'])) |
|
| 676 | - echo |
|
| 715 | + if (!empty($modSettings['show_modify']) && !empty($message['modified']['name'])) { |
|
| 716 | + echo |
|
| 677 | 717 | $message['modified']['last_edit_text']; |
| 718 | + } |
|
| 678 | 719 | |
| 679 | 720 | echo ' |
| 680 | 721 | </span> |
@@ -683,22 +724,24 @@ discard block |
||
| 683 | 724 | </div>'; |
| 684 | 725 | |
| 685 | 726 | // Ignoring this user? Hide the post. |
| 686 | - if ($ignoring) |
|
| 687 | - echo ' |
|
| 727 | + if ($ignoring) { |
|
| 728 | + echo ' |
|
| 688 | 729 | <div id="msg_', $message['id'], '_ignored_prompt"> |
| 689 | 730 | ', $txt['ignoring_user'], ' |
| 690 | 731 | <a href="#" id="msg_', $message['id'], '_ignored_link" style="display: none;">', $txt['show_ignore_user_post'], '</a> |
| 691 | 732 | </div>'; |
| 733 | + } |
|
| 692 | 734 | |
| 693 | 735 | // Show the post itself, finally! |
| 694 | 736 | echo ' |
| 695 | 737 | <div class="post">'; |
| 696 | 738 | |
| 697 | - if (!$message['approved'] && $message['member']['id'] != 0 && $message['member']['id'] == $context['user']['id']) |
|
| 698 | - echo ' |
|
| 739 | + if (!$message['approved'] && $message['member']['id'] != 0 && $message['member']['id'] == $context['user']['id']) { |
|
| 740 | + echo ' |
|
| 699 | 741 | <div class="approve_post"> |
| 700 | 742 | ', $txt['post_awaiting_approval'], ' |
| 701 | 743 | </div>'; |
| 744 | + } |
|
| 702 | 745 | echo ' |
| 703 | 746 | <div class="inner" data-msgid="', $message['id'], '" id="msg_', $message['id'], '"', $ignoring ? ' style="display:none;"' : '', '>', $message['body'], '</div> |
| 704 | 747 | </div>'; |
@@ -715,9 +758,9 @@ discard block |
||
| 715 | 758 | foreach ($message['attachment'] as $attachment) |
| 716 | 759 | { |
| 717 | 760 | // Do we want this attachment to not be showed here? |
| 718 | - if (!empty($modSettings['dont_show_attach_under_post']) && !empty($context['show_attach_under_post'][$attachment['id']])) |
|
| 719 | - continue; |
|
| 720 | - elseif (!$div_output) |
|
| 761 | + if (!empty($modSettings['dont_show_attach_under_post']) && !empty($context['show_attach_under_post'][$attachment['id']])) { |
|
| 762 | + continue; |
|
| 763 | + } elseif (!$div_output) |
|
| 721 | 764 | { |
| 722 | 765 | $div_output = true; |
| 723 | 766 | |
@@ -733,9 +776,10 @@ discard block |
||
| 733 | 776 | <fieldset> |
| 734 | 777 | <legend>', $txt['attach_awaiting_approve']; |
| 735 | 778 | |
| 736 | - if ($context['can_approve']) |
|
| 737 | - echo ' |
|
| 779 | + if ($context['can_approve']) { |
|
| 780 | + echo ' |
|
| 738 | 781 | [<a href="', $scripturl, '?action=attachapprove;sa=all;mid=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['approve_all'], '</a>]'; |
| 782 | + } |
|
| 739 | 783 | |
| 740 | 784 | echo ' |
| 741 | 785 | </legend>'; |
@@ -749,12 +793,13 @@ discard block |
||
| 749 | 793 | echo ' |
| 750 | 794 | <div class="attachments_top">'; |
| 751 | 795 | |
| 752 | - if ($attachment['thumbnail']['has_thumb']) |
|
| 753 | - echo ' |
|
| 796 | + if ($attachment['thumbnail']['has_thumb']) { |
|
| 797 | + echo ' |
|
| 754 | 798 | <a href="', $attachment['href'], ';image" id="link_', $attachment['id'], '" onclick="', $attachment['thumbnail']['javascript'], '"><img src="', $attachment['thumbnail']['href'], '" alt="" id="thumb_', $attachment['id'], '" class="atc_img"></a>'; |
| 755 | - else |
|
| 756 | - echo ' |
|
| 799 | + } else { |
|
| 800 | + echo ' |
|
| 757 | 801 | <img src="' . $attachment['href'] . ';image" alt="" width="' . $attachment['width'] . '" height="' . $attachment['height'] . '" class="atc_img">'; |
| 802 | + } |
|
| 758 | 803 | |
| 759 | 804 | echo ' |
| 760 | 805 | </div>'; |
@@ -764,9 +809,10 @@ discard block |
||
| 764 | 809 | <div class="attachments_bot"> |
| 765 | 810 | <a href="' . $attachment['href'] . '"><img src="' . $settings['images_url'] . '/icons/clip.png" class="centericon" alt="*"> ' . $attachment['name'] . '</a> '; |
| 766 | 811 | |
| 767 | - if (!$attachment['is_approved'] && $context['can_approve']) |
|
| 768 | - echo ' |
|
| 812 | + if (!$attachment['is_approved'] && $context['can_approve']) { |
|
| 813 | + echo ' |
|
| 769 | 814 | [<a href="', $scripturl, '?action=attachapprove;sa=approve;aid=', $attachment['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['approve'], '</a>] | [<a href="', $scripturl, '?action=attachapprove;sa=reject;aid=', $attachment['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['delete'], '</a>] '; |
| 815 | + } |
|
| 770 | 816 | echo ' |
| 771 | 817 | <br>', $attachment['size'], ($attachment['is_image'] ? ', ' . $attachment['real_width'] . 'x' . $attachment['real_height'] . '<br>' . sprintf($txt['attach_viewed'], $attachment['downloads']) : '<br>' . sprintf($txt['attach_downloaded'], $attachment['downloads'])), ' |
| 772 | 818 | </div>'; |
@@ -775,33 +821,38 @@ discard block |
||
| 775 | 821 | </div>'; |
| 776 | 822 | |
| 777 | 823 | // Next attachment line ? |
| 778 | - if (++$i % $attachments_per_line === 0) |
|
| 779 | - echo ' |
|
| 824 | + if (++$i % $attachments_per_line === 0) { |
|
| 825 | + echo ' |
|
| 780 | 826 | <br>'; |
| 827 | + } |
|
| 781 | 828 | } |
| 782 | 829 | |
| 783 | 830 | // If we had unapproved attachments clean up. |
| 784 | - if ($last_approved_state == 0) |
|
| 785 | - echo ' |
|
| 831 | + if ($last_approved_state == 0) { |
|
| 832 | + echo ' |
|
| 786 | 833 | </fieldset>'; |
| 834 | + } |
|
| 787 | 835 | |
| 788 | 836 | // Only do this if we output a div above - otherwise it'll break things |
| 789 | - if ($div_output) |
|
| 790 | - echo ' |
|
| 837 | + if ($div_output) { |
|
| 838 | + echo ' |
|
| 791 | 839 | </div>'; |
| 840 | + } |
|
| 792 | 841 | } |
| 793 | 842 | |
| 794 | 843 | // And stuff below the attachments. |
| 795 | - if ($context['can_report_moderator'] || !empty($context['can_see_likes']) || !empty($context['can_like']) || $message['can_approve'] || $message['can_unapprove'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'] || $context['can_quote']) |
|
| 796 | - echo ' |
|
| 844 | + if ($context['can_report_moderator'] || !empty($context['can_see_likes']) || !empty($context['can_like']) || $message['can_approve'] || $message['can_unapprove'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'] || $context['can_quote']) { |
|
| 845 | + echo ' |
|
| 797 | 846 | <div class="under_message">'; |
| 847 | + } |
|
| 798 | 848 | |
| 799 | 849 | // Maybe they want to report this post to the moderator(s)? |
| 800 | - if ($context['can_report_moderator']) |
|
| 801 | - echo ' |
|
| 850 | + if ($context['can_report_moderator']) { |
|
| 851 | + echo ' |
|
| 802 | 852 | <ul class="floatright smalltext"> |
| 803 | 853 | <li class="report_link"><a href="', $scripturl, '?action=reporttm;topic=', $context['current_topic'], '.', $message['counter'], ';msg=', $message['id'], '">', $txt['report_to_mod'], '</a></li> |
| 804 | 854 | </ul>'; |
| 855 | + } |
|
| 805 | 856 | |
| 806 | 857 | // What about likes? |
| 807 | 858 | if (!empty($modSettings['enable_likes'])) |
@@ -842,78 +893,91 @@ discard block |
||
| 842 | 893 | <ul class="quickbuttons">'; |
| 843 | 894 | |
| 844 | 895 | // Can they quote? if so they can select and quote as well! |
| 845 | - if ($context['can_quote']) |
|
| 846 | - echo ' |
|
| 896 | + if ($context['can_quote']) { |
|
| 897 | + echo ' |
|
| 847 | 898 | <li><a href="', $scripturl, '?action=post;quote=', $message['id'], ';topic=', $context['current_topic'], '.', $context['start'], ';last_msg=', $context['topic_last_message'], '" onclick="return oQuickReply.quote(', $message['id'], ');"><span class="generic_icons quote"></span>', $txt['quote_action'], '</a></li> |
| 848 | 899 | <li style="display:none;" id="quoteSelected_', $message['id'], '"><a href="javascript:void(0)"><span class="generic_icons quote_selected"></span>', $txt['quote_selected_action'], '</a></li>'; |
| 900 | + } |
|
| 849 | 901 | |
| 850 | 902 | // Can the user modify the contents of this post? Show the modify inline image. |
| 851 | - if ($message['can_modify']) |
|
| 852 | - echo ' |
|
| 903 | + if ($message['can_modify']) { |
|
| 904 | + echo ' |
|
| 853 | 905 | <li class="quick_edit"><a title="', $txt['modify_msg'], '" class="modifybutton" id="modify_button_', $message['id'], '" onclick="oQuickModify.modifyMsg(\'', $message['id'], '\', \'', !empty($modSettings['toggle_subject']), '\')"><span class="generic_icons quick_edit_button"></span>', $txt['quick_edit'], '</a></li>'; |
| 906 | + } |
|
| 854 | 907 | |
| 855 | - if ($message['can_approve'] || $message['can_unapprove'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg']) |
|
| 856 | - echo ' |
|
| 908 | + if ($message['can_approve'] || $message['can_unapprove'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg']) { |
|
| 909 | + echo ' |
|
| 857 | 910 | <li class="post_options">', $txt['post_options']; |
| 911 | + } |
|
| 858 | 912 | |
| 859 | 913 | echo ' |
| 860 | 914 | <ul>'; |
| 861 | 915 | |
| 862 | 916 | // Can the user modify the contents of this post? |
| 863 | - if ($message['can_modify']) |
|
| 864 | - echo ' |
|
| 917 | + if ($message['can_modify']) { |
|
| 918 | + echo ' |
|
| 865 | 919 | <li><a href="', $scripturl, '?action=post;msg=', $message['id'], ';topic=', $context['current_topic'], '.', $context['start'], '"><span class="generic_icons modify_button"></span>', $txt['modify'], '</a></li>'; |
| 920 | + } |
|
| 866 | 921 | |
| 867 | 922 | // How about... even... remove it entirely?! |
| 868 | - if ($context['can_delete'] && ($context['topic_first_message'] == $message['id'])) |
|
| 869 | - echo ' |
|
| 923 | + if ($context['can_delete'] && ($context['topic_first_message'] == $message['id'])) { |
|
| 924 | + echo ' |
|
| 870 | 925 | <li><a href="', $scripturl, '?action=removetopic2;topic=', $context['current_topic'], '.', $context['start'], ';', $context['session_var'], '=', $context['session_id'], '" data-confirm="', $txt['are_sure_remove_topic'], '" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['remove_topic'], '</a></li>'; |
| 871 | - elseif ($message['can_remove'] && ($context['topic_first_message'] != $message['id'])) |
|
| 872 | - echo ' |
|
| 926 | + } elseif ($message['can_remove'] && ($context['topic_first_message'] != $message['id'])) { |
|
| 927 | + echo ' |
|
| 873 | 928 | <li><a href="', $scripturl, '?action=deletemsg;topic=', $context['current_topic'], '.', $context['start'], ';msg=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '" data-confirm="', $txt['remove_message_question'], '" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['remove'], '</a></li>'; |
| 929 | + } |
|
| 874 | 930 | |
| 875 | 931 | // What about splitting it off the rest of the topic? |
| 876 | - if ($context['can_split'] && !empty($context['real_num_replies'])) |
|
| 877 | - echo ' |
|
| 932 | + if ($context['can_split'] && !empty($context['real_num_replies'])) { |
|
| 933 | + echo ' |
|
| 878 | 934 | <li><a href="', $scripturl, '?action=splittopics;topic=', $context['current_topic'], '.0;at=', $message['id'], '"><span class="generic_icons split_button"></span>', $txt['split'], '</a></li>'; |
| 935 | + } |
|
| 879 | 936 | |
| 880 | 937 | // Can we issue a warning because of this post? Remember, we can't give guests warnings. |
| 881 | - if ($context['can_issue_warning'] && !$message['is_message_author'] && !$message['member']['is_guest']) |
|
| 882 | - echo ' |
|
| 938 | + if ($context['can_issue_warning'] && !$message['is_message_author'] && !$message['member']['is_guest']) { |
|
| 939 | + echo ' |
|
| 883 | 940 | <li><a href="', $scripturl, '?action=profile;area=issuewarning;u=', $message['member']['id'], ';msg=', $message['id'], '"><span class="generic_icons warn_button"></span>', $txt['issue_warning'], '</a></li>'; |
| 941 | + } |
|
| 884 | 942 | |
| 885 | 943 | // Can we restore topics? |
| 886 | - if ($context['can_restore_msg']) |
|
| 887 | - echo ' |
|
| 944 | + if ($context['can_restore_msg']) { |
|
| 945 | + echo ' |
|
| 888 | 946 | <li><a href="', $scripturl, '?action=restoretopic;msgs=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons restore_button"></span>', $txt['restore_message'], '</a></li>'; |
| 947 | + } |
|
| 889 | 948 | |
| 890 | 949 | // Maybe we can approve it, maybe we should? |
| 891 | - if ($message['can_approve']) |
|
| 892 | - echo ' |
|
| 950 | + if ($message['can_approve']) { |
|
| 951 | + echo ' |
|
| 893 | 952 | <li><a href="', $scripturl, '?action=moderate;area=postmod;sa=approve;topic=', $context['current_topic'], '.', $context['start'], ';msg=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons approve_button"></span>', $txt['approve'], '</a></li>'; |
| 953 | + } |
|
| 894 | 954 | |
| 895 | 955 | // Maybe we can unapprove it? |
| 896 | - if ($message['can_unapprove']) |
|
| 897 | - echo ' |
|
| 956 | + if ($message['can_unapprove']) { |
|
| 957 | + echo ' |
|
| 898 | 958 | <li><a href="', $scripturl, '?action=moderate;area=postmod;sa=approve;topic=', $context['current_topic'], '.', $context['start'], ';msg=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons unapprove_button"></span>', $txt['unapprove'], '</a></li>'; |
| 959 | + } |
|
| 899 | 960 | |
| 900 | 961 | echo ' |
| 901 | 962 | </ul> |
| 902 | 963 | </li>'; |
| 903 | 964 | |
| 904 | 965 | // Show a checkbox for quick moderation? |
| 905 | - if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && $message['can_remove']) |
|
| 906 | - echo ' |
|
| 966 | + if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && $message['can_remove']) { |
|
| 967 | + echo ' |
|
| 907 | 968 | <li style="display: none;" id="in_topic_mod_check_', $message['id'], '"></li>'; |
| 969 | + } |
|
| 908 | 970 | |
| 909 | - if ($message['can_approve'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg']) |
|
| 910 | - echo ' |
|
| 971 | + if ($message['can_approve'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg']) { |
|
| 972 | + echo ' |
|
| 911 | 973 | </ul>'; |
| 974 | + } |
|
| 912 | 975 | } |
| 913 | 976 | |
| 914 | - if ($context['can_report_moderator'] || !empty($context['can_see_likes']) || !empty($context['can_like']) || $message['can_approve'] || $message['can_unapprove'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'] || $context['can_quote']) |
|
| 915 | - echo ' |
|
| 977 | + if ($context['can_report_moderator'] || !empty($context['can_see_likes']) || !empty($context['can_like']) || $message['can_approve'] || $message['can_unapprove'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'] || $context['can_quote']) { |
|
| 978 | + echo ' |
|
| 916 | 979 | </div>'; |
| 980 | + } |
|
| 917 | 981 | |
| 918 | 982 | echo ' |
| 919 | 983 | </div> |
@@ -926,9 +990,10 @@ discard block |
||
| 926 | 990 | <div class="custom_fields_above_signature"> |
| 927 | 991 | <ul class="nolist">'; |
| 928 | 992 | |
| 929 | - foreach ($message['custom_fields']['above_signature'] as $custom) |
|
| 930 | - echo ' |
|
| 993 | + foreach ($message['custom_fields']['above_signature'] as $custom) { |
|
| 994 | + echo ' |
|
| 931 | 995 | <li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>'; |
| 996 | + } |
|
| 932 | 997 | |
| 933 | 998 | echo ' |
| 934 | 999 | </ul> |
@@ -936,9 +1001,10 @@ discard block |
||
| 936 | 1001 | } |
| 937 | 1002 | |
| 938 | 1003 | // Show the member's signature? |
| 939 | - if (!empty($message['member']['signature']) && empty($options['show_no_signatures']) && $context['signature_enabled']) |
|
| 940 | - echo ' |
|
| 1004 | + if (!empty($message['member']['signature']) && empty($options['show_no_signatures']) && $context['signature_enabled']) { |
|
| 1005 | + echo ' |
|
| 941 | 1006 | <div class="signature" id="msg_', $message['id'], '_signature"', $ignoring ? ' style="display:none;"' : '', '>', $message['member']['signature'], '</div>'; |
| 1007 | + } |
|
| 942 | 1008 | |
| 943 | 1009 | |
| 944 | 1010 | // Are there any custom profile fields for below the signature? |
@@ -948,9 +1014,10 @@ discard block |
||
| 948 | 1014 | <div class="custom_fields_below_signature"> |
| 949 | 1015 | <ul class="nolist">'; |
| 950 | 1016 | |
| 951 | - foreach ($message['custom_fields']['below_signature'] as $custom) |
|
| 952 | - echo ' |
|
| 1017 | + foreach ($message['custom_fields']['below_signature'] as $custom) { |
|
| 1018 | + echo ' |
|
| 953 | 1019 | <li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>'; |
| 1020 | + } |
|
| 954 | 1021 | |
| 955 | 1022 | echo ' |
| 956 | 1023 | </ul> |
@@ -998,8 +1065,8 @@ discard block |
||
| 998 | 1065 | <input type="hidden" name="seqnum" value="', $context['form_sequence_number'], '">'; |
| 999 | 1066 | |
| 1000 | 1067 | // Guests just need more. |
| 1001 | - if ($context['user']['is_guest']) |
|
| 1002 | - echo ' |
|
| 1068 | + if ($context['user']['is_guest']) { |
|
| 1069 | + echo ' |
|
| 1003 | 1070 | <dl id="post_header"> |
| 1004 | 1071 | <dt> |
| 1005 | 1072 | ', $txt['name'], ': |
@@ -1014,6 +1081,7 @@ discard block |
||
| 1014 | 1081 | <input type="email" name="email" size="25" value="', $context['email'], '" tabindex="', $context['tabindex']++, '" class="input_text" required> |
| 1015 | 1082 | </dd> |
| 1016 | 1083 | </dl>'; |
| 1084 | + } |
|
| 1017 | 1085 | |
| 1018 | 1086 | echo ' |
| 1019 | 1087 | ', template_control_richedit($context['post_box_name'], 'smileyBox_message', 'bbcBox_message'), ' |
@@ -1061,8 +1129,8 @@ discard block |
||
| 1061 | 1129 | <br class="clear">'; |
| 1062 | 1130 | |
| 1063 | 1131 | // draft autosave available and the user has it enabled? |
| 1064 | - if (!empty($context['drafts_autosave'])) |
|
| 1065 | - echo ' |
|
| 1132 | + if (!empty($context['drafts_autosave'])) { |
|
| 1133 | + echo ' |
|
| 1066 | 1134 | <script> |
| 1067 | 1135 | var oDraftAutoSave = new smf_DraftAutoSave({ |
| 1068 | 1136 | sSelf: \'oDraftAutoSave\', |
@@ -1074,10 +1142,12 @@ discard block |
||
| 1074 | 1142 | iFreq: ', (empty($modSettings['masterAutoSaveDraftsDelay']) ? 60000 : $modSettings['masterAutoSaveDraftsDelay'] * 1000), ' |
| 1075 | 1143 | }); |
| 1076 | 1144 | </script>'; |
| 1145 | + } |
|
| 1077 | 1146 | |
| 1078 | - if ($context['show_spellchecking']) |
|
| 1079 | - echo ' |
|
| 1147 | + if ($context['show_spellchecking']) { |
|
| 1148 | + echo ' |
|
| 1080 | 1149 | <form action="', $scripturl, '?action=spellcheck" method="post" accept-charset="', $context['character_set'], '" name="spell_form" id="spell_form" target="spellWindow"><input type="hidden" name="spellstring" value=""></form>'; |
| 1150 | + } |
|
| 1081 | 1151 | |
| 1082 | 1152 | echo ' |
| 1083 | 1153 | <script> |
@@ -63,26 +63,31 @@ discard block |
||
| 63 | 63 | */ |
| 64 | 64 | public function checkRequest() |
| 65 | 65 | { |
| 66 | - if (!$this->enabled) |
|
| 67 | - return false; |
|
| 66 | + if (!$this->enabled) { |
|
| 67 | + return false; |
|
| 68 | + } |
|
| 68 | 69 | |
| 69 | 70 | // Try to create the image cache directory if it doesn't exist |
| 70 | - if (!file_exists($this->cache)) |
|
| 71 | - if (!mkdir($this->cache) || !copy(dirname($this->cache) . '/index.php', $this->cache . '/index.php')) |
|
| 71 | + if (!file_exists($this->cache)) { |
|
| 72 | + if (!mkdir($this->cache) || !copy(dirname($this->cache) . '/index.php', $this->cache . '/index.php')) |
|
| 72 | 73 | return false; |
| 74 | + } |
|
| 73 | 75 | |
| 74 | - if (empty($_GET['hash']) || empty($_GET['request'])) |
|
| 75 | - return false; |
|
| 76 | + if (empty($_GET['hash']) || empty($_GET['request'])) { |
|
| 77 | + return false; |
|
| 78 | + } |
|
| 76 | 79 | |
| 77 | 80 | $hash = $_GET['hash']; |
| 78 | 81 | $request = $_GET['request']; |
| 79 | 82 | |
| 80 | - if (md5($request . $this->secret) != $hash) |
|
| 81 | - return false; |
|
| 83 | + if (md5($request . $this->secret) != $hash) { |
|
| 84 | + return false; |
|
| 85 | + } |
|
| 82 | 86 | |
| 83 | 87 | // Attempt to cache the request if it doesn't exist |
| 84 | - if (!$this->isCached($request)) |
|
| 85 | - return $this->cacheImage($request); |
|
| 88 | + if (!$this->isCached($request)) { |
|
| 89 | + return $this->cacheImage($request); |
|
| 90 | + } |
|
| 86 | 91 | |
| 87 | 92 | return true; |
| 88 | 93 | } |
@@ -111,19 +116,22 @@ discard block |
||
| 111 | 116 | if (!$cached || time() - $cached['time'] > (5 * 86400)) |
| 112 | 117 | { |
| 113 | 118 | @unlink($cached_file); |
| 114 | - if ($this->checkRequest()) |
|
| 115 | - $this->serve(); |
|
| 119 | + if ($this->checkRequest()) { |
|
| 120 | + $this->serve(); |
|
| 121 | + } |
|
| 116 | 122 | redirectexit($request); |
| 117 | 123 | } |
| 118 | 124 | |
| 119 | 125 | // Right, image not cached? Simply redirect, then. |
| 120 | - if (!$response) |
|
| 121 | - redirectexit($request); |
|
| 126 | + if (!$response) { |
|
| 127 | + redirectexit($request); |
|
| 128 | + } |
|
| 122 | 129 | |
| 123 | 130 | // Make sure we're serving an image |
| 124 | 131 | $contentParts = explode('/', !empty($cached['content_type']) ? $cached['content_type'] : ''); |
| 125 | - if ($contentParts[0] != 'image') |
|
| 126 | - exit; |
|
| 132 | + if ($contentParts[0] != 'image') { |
|
| 133 | + exit; |
|
| 134 | + } |
|
| 127 | 135 | |
| 128 | 136 | header('Content-type: ' . $cached['content_type']); |
| 129 | 137 | header('Content-length: ' . $cached['size']); |
@@ -170,8 +178,9 @@ discard block |
||
| 170 | 178 | $responseCode = $request->result('code'); |
| 171 | 179 | $response = $request->result(); |
| 172 | 180 | |
| 173 | - if (empty($response)) |
|
| 174 | - return false; |
|
| 181 | + if (empty($response)) { |
|
| 182 | + return false; |
|
| 183 | + } |
|
| 175 | 184 | |
| 176 | 185 | if ($responseCode != 200) { |
| 177 | 186 | return $request->result('code'); |
@@ -181,12 +190,14 @@ discard block |
||
| 181 | 190 | |
| 182 | 191 | // Make sure the url is returning an image |
| 183 | 192 | $contentParts = explode('/', !empty($headers['content-type']) ? $headers['content-type'] : ''); |
| 184 | - if ($contentParts[0] != 'image') |
|
| 185 | - return false; |
|
| 193 | + if ($contentParts[0] != 'image') { |
|
| 194 | + return false; |
|
| 195 | + } |
|
| 186 | 196 | |
| 187 | 197 | // Validate the filesize |
| 188 | - if ($response['size'] > ($this->maxSize * 1024)) |
|
| 189 | - return false; |
|
| 198 | + if ($response['size'] > ($this->maxSize * 1024)) { |
|
| 199 | + return false; |
|
| 200 | + } |
|
| 190 | 201 | |
| 191 | 202 | return file_put_contents($dest, json_encode(array( |
| 192 | 203 | 'content_type' => $headers['content-type'], |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 3 |
| 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 | * Outputs xml data representing recent information or a profile. |
@@ -37,8 +38,9 @@ discard block |
||
| 37 | 38 | global $query_this_board, $smcFunc, $forum_version, $settings; |
| 38 | 39 | |
| 39 | 40 | // If it's not enabled, die. |
| 40 | - if (empty($modSettings['xmlnews_enable'])) |
|
| 41 | - obExit(false); |
|
| 41 | + if (empty($modSettings['xmlnews_enable'])) { |
|
| 42 | + obExit(false); |
|
| 43 | + } |
|
| 42 | 44 | |
| 43 | 45 | loadLanguage('Stats'); |
| 44 | 46 | |
@@ -64,8 +66,9 @@ discard block |
||
| 64 | 66 | if (!empty($_REQUEST['c']) && empty($board)) |
| 65 | 67 | { |
| 66 | 68 | $_REQUEST['c'] = explode(',', $_REQUEST['c']); |
| 67 | - foreach ($_REQUEST['c'] as $i => $c) |
|
| 68 | - $_REQUEST['c'][$i] = (int) $c; |
|
| 69 | + foreach ($_REQUEST['c'] as $i => $c) { |
|
| 70 | + $_REQUEST['c'][$i] = (int) $c; |
|
| 71 | + } |
|
| 69 | 72 | |
| 70 | 73 | if (count($_REQUEST['c']) == 1) |
| 71 | 74 | { |
@@ -101,18 +104,20 @@ discard block |
||
| 101 | 104 | } |
| 102 | 105 | $smcFunc['db_free_result']($request); |
| 103 | 106 | |
| 104 | - if (!empty($boards)) |
|
| 105 | - $query_this_board = 'b.id_board IN (' . implode(', ', $boards) . ')'; |
|
| 107 | + if (!empty($boards)) { |
|
| 108 | + $query_this_board = 'b.id_board IN (' . implode(', ', $boards) . ')'; |
|
| 109 | + } |
|
| 106 | 110 | |
| 107 | 111 | // Try to limit the number of messages we look through. |
| 108 | - if ($total_cat_posts > 100 && $total_cat_posts > $modSettings['totalMessages'] / 15) |
|
| 109 | - $context['optimize_msg']['lowest'] = 'm.id_msg >= ' . max(0, $modSettings['maxMsgID'] - 400 - $_GET['limit'] * 5); |
|
| 110 | - } |
|
| 111 | - elseif (!empty($_REQUEST['boards'])) |
|
| 112 | + if ($total_cat_posts > 100 && $total_cat_posts > $modSettings['totalMessages'] / 15) { |
|
| 113 | + $context['optimize_msg']['lowest'] = 'm.id_msg >= ' . max(0, $modSettings['maxMsgID'] - 400 - $_GET['limit'] * 5); |
|
| 114 | + } |
|
| 115 | + } elseif (!empty($_REQUEST['boards'])) |
|
| 112 | 116 | { |
| 113 | 117 | $_REQUEST['boards'] = explode(',', $_REQUEST['boards']); |
| 114 | - foreach ($_REQUEST['boards'] as $i => $b) |
|
| 115 | - $_REQUEST['boards'][$i] = (int) $b; |
|
| 118 | + foreach ($_REQUEST['boards'] as $i => $b) { |
|
| 119 | + $_REQUEST['boards'][$i] = (int) $b; |
|
| 120 | + } |
|
| 116 | 121 | |
| 117 | 122 | $request = $smcFunc['db_query']('', ' |
| 118 | 123 | SELECT b.id_board, b.num_posts, b.name |
@@ -128,29 +133,32 @@ discard block |
||
| 128 | 133 | |
| 129 | 134 | // Either the board specified doesn't exist or you have no access. |
| 130 | 135 | $num_boards = $smcFunc['db_num_rows']($request); |
| 131 | - if ($num_boards == 0) |
|
| 132 | - fatal_lang_error('no_board'); |
|
| 136 | + if ($num_boards == 0) { |
|
| 137 | + fatal_lang_error('no_board'); |
|
| 138 | + } |
|
| 133 | 139 | |
| 134 | 140 | $total_posts = 0; |
| 135 | 141 | $boards = array(); |
| 136 | 142 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 137 | 143 | { |
| 138 | - if ($num_boards == 1) |
|
| 139 | - $feed_meta['title'] = ' - ' . strip_tags($row['name']); |
|
| 144 | + if ($num_boards == 1) { |
|
| 145 | + $feed_meta['title'] = ' - ' . strip_tags($row['name']); |
|
| 146 | + } |
|
| 140 | 147 | |
| 141 | 148 | $boards[] = $row['id_board']; |
| 142 | 149 | $total_posts += $row['num_posts']; |
| 143 | 150 | } |
| 144 | 151 | $smcFunc['db_free_result']($request); |
| 145 | 152 | |
| 146 | - if (!empty($boards)) |
|
| 147 | - $query_this_board = 'b.id_board IN (' . implode(', ', $boards) . ')'; |
|
| 153 | + if (!empty($boards)) { |
|
| 154 | + $query_this_board = 'b.id_board IN (' . implode(', ', $boards) . ')'; |
|
| 155 | + } |
|
| 148 | 156 | |
| 149 | 157 | // The more boards, the more we're going to look through... |
| 150 | - if ($total_posts > 100 && $total_posts > $modSettings['totalMessages'] / 12) |
|
| 151 | - $context['optimize_msg']['lowest'] = 'm.id_msg >= ' . max(0, $modSettings['maxMsgID'] - 500 - $_GET['limit'] * 5); |
|
| 152 | - } |
|
| 153 | - elseif (!empty($board)) |
|
| 158 | + if ($total_posts > 100 && $total_posts > $modSettings['totalMessages'] / 12) { |
|
| 159 | + $context['optimize_msg']['lowest'] = 'm.id_msg >= ' . max(0, $modSettings['maxMsgID'] - 500 - $_GET['limit'] * 5); |
|
| 160 | + } |
|
| 161 | + } elseif (!empty($board)) |
|
| 154 | 162 | { |
| 155 | 163 | $request = $smcFunc['db_query']('', ' |
| 156 | 164 | SELECT num_posts |
@@ -170,10 +178,10 @@ discard block |
||
| 170 | 178 | $query_this_board = 'b.id_board = ' . $board; |
| 171 | 179 | |
| 172 | 180 | // Try to look through just a few messages, if at all possible. |
| 173 | - if ($total_posts > 80 && $total_posts > $modSettings['totalMessages'] / 10) |
|
| 174 | - $context['optimize_msg']['lowest'] = 'm.id_msg >= ' . max(0, $modSettings['maxMsgID'] - 600 - $_GET['limit'] * 5); |
|
| 175 | - } |
|
| 176 | - else |
|
| 181 | + if ($total_posts > 80 && $total_posts > $modSettings['totalMessages'] / 10) { |
|
| 182 | + $context['optimize_msg']['lowest'] = 'm.id_msg >= ' . max(0, $modSettings['maxMsgID'] - 600 - $_GET['limit'] * 5); |
|
| 183 | + } |
|
| 184 | + } else |
|
| 177 | 185 | { |
| 178 | 186 | $query_this_board = '{query_see_board}' . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? ' |
| 179 | 187 | AND b.id_board != ' . $modSettings['recycle_board'] : ''); |
@@ -196,30 +204,35 @@ discard block |
||
| 196 | 204 | // Easy adding of sub actions |
| 197 | 205 | call_integration_hook('integrate_xmlfeeds', array(&$subActions)); |
| 198 | 206 | |
| 199 | - if (empty($_GET['sa']) || !isset($subActions[$_GET['sa']])) |
|
| 200 | - $_GET['sa'] = 'recent'; |
|
| 207 | + if (empty($_GET['sa']) || !isset($subActions[$_GET['sa']])) { |
|
| 208 | + $_GET['sa'] = 'recent'; |
|
| 209 | + } |
|
| 201 | 210 | |
| 202 | 211 | // We only want some information, not all of it. |
| 203 | 212 | $cachekey = array($xml_format, $_GET['action'], $_GET['limit'], $_GET['sa']); |
| 204 | - foreach (array('board', 'boards', 'c') as $var) |
|
| 205 | - if (isset($_REQUEST[$var])) |
|
| 213 | + foreach (array('board', 'boards', 'c') as $var) { |
|
| 214 | + if (isset($_REQUEST[$var])) |
|
| 206 | 215 | $cachekey[] = $_REQUEST[$var]; |
| 216 | + } |
|
| 207 | 217 | $cachekey = md5(json_encode($cachekey) . (!empty($query_this_board) ? $query_this_board : '')); |
| 208 | 218 | $cache_t = microtime(); |
| 209 | 219 | |
| 210 | 220 | // Get the associative array representing the xml. |
| 211 | - if (!empty($modSettings['cache_enable']) && (!$user_info['is_guest'] || $modSettings['cache_enable'] >= 3)) |
|
| 212 | - $xml_data = cache_get_data('xmlfeed-' . $xml_format . ':' . ($user_info['is_guest'] ? '' : $user_info['id'] . '-') . $cachekey, 240); |
|
| 221 | + if (!empty($modSettings['cache_enable']) && (!$user_info['is_guest'] || $modSettings['cache_enable'] >= 3)) { |
|
| 222 | + $xml_data = cache_get_data('xmlfeed-' . $xml_format . ':' . ($user_info['is_guest'] ? '' : $user_info['id'] . '-') . $cachekey, 240); |
|
| 223 | + } |
|
| 213 | 224 | if (empty($xml_data)) |
| 214 | 225 | { |
| 215 | 226 | $call = call_helper($subActions[$_GET['sa']][0], true); |
| 216 | 227 | |
| 217 | - if (!empty($call)) |
|
| 218 | - $xml_data = call_user_func($call, $xml_format); |
|
| 228 | + if (!empty($call)) { |
|
| 229 | + $xml_data = call_user_func($call, $xml_format); |
|
| 230 | + } |
|
| 219 | 231 | |
| 220 | 232 | if (!empty($modSettings['cache_enable']) && (($user_info['is_guest'] && $modSettings['cache_enable'] >= 3) |
| 221 | - || (!$user_info['is_guest'] && (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $cache_t)) > 0.2)))) |
|
| 222 | - cache_put_data('xmlfeed-' . $xml_format . ':' . ($user_info['is_guest'] ? '' : $user_info['id'] . '-') . $cachekey, $xml_data, 240); |
|
| 233 | + || (!$user_info['is_guest'] && (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $cache_t)) > 0.2)))) { |
|
| 234 | + cache_put_data('xmlfeed-' . $xml_format . ':' . ($user_info['is_guest'] ? '' : $user_info['id'] . '-') . $cachekey, $xml_data, 240); |
|
| 235 | + } |
|
| 223 | 236 | } |
| 224 | 237 | |
| 225 | 238 | $feed_meta['title'] = $smcFunc['htmlspecialchars'](strip_tags($context['forum_name'])) . (isset($feed_meta['title']) ? $feed_meta['title'] : ''); |
@@ -259,43 +272,49 @@ discard block |
||
| 259 | 272 | call_integration_hook('integrate_xml_data', array(&$xml_data, &$feed_meta, &$namespaces, &$extraFeedTags, &$forceCdataKeys, &$nsKeys, $xml_format, $_GET['sa'])); |
| 260 | 273 | |
| 261 | 274 | // These can't be empty |
| 262 | - foreach (array('title', 'desc', 'source') as $mkey) |
|
| 263 | - $feed_meta[$mkey] = !empty($feed_meta[$mkey]) ? $feed_meta[$mkey] : $orig_feed_meta[$mkey]; |
|
| 275 | + foreach (array('title', 'desc', 'source') as $mkey) { |
|
| 276 | + $feed_meta[$mkey] = !empty($feed_meta[$mkey]) ? $feed_meta[$mkey] : $orig_feed_meta[$mkey]; |
|
| 277 | + } |
|
| 264 | 278 | |
| 265 | 279 | // Sanitize basic feed metadata values |
| 266 | - foreach ($feed_meta as $mkey => $mvalue) |
|
| 267 | - $feed_meta[$mkey] = cdata_parse(strip_tags(fix_possible_url($feed_meta[$mkey]))); |
|
| 280 | + foreach ($feed_meta as $mkey => $mvalue) { |
|
| 281 | + $feed_meta[$mkey] = cdata_parse(strip_tags(fix_possible_url($feed_meta[$mkey]))); |
|
| 282 | + } |
|
| 268 | 283 | |
| 269 | 284 | $ns_string = ''; |
| 270 | 285 | if (!empty($namespaces[$xml_format])) |
| 271 | 286 | { |
| 272 | - foreach ($namespaces[$xml_format] as $nsprefix => $nsurl) |
|
| 273 | - $ns_string .= ' xmlns' . ($nsprefix !== '' ? ':' : '') . $nsprefix . '="' . $nsurl . '"'; |
|
| 287 | + foreach ($namespaces[$xml_format] as $nsprefix => $nsurl) { |
|
| 288 | + $ns_string .= ' xmlns' . ($nsprefix !== '' ? ':' : '') . $nsprefix . '="' . $nsurl . '"'; |
|
| 289 | + } |
|
| 274 | 290 | } |
| 275 | 291 | |
| 276 | 292 | $extraFeedTags_string = ''; |
| 277 | 293 | if (!empty($extraFeedTags[$xml_format])) |
| 278 | 294 | { |
| 279 | 295 | $indent = "\t" . ($xml_format !== 'atom' ? "\t" : ''); |
| 280 | - foreach ($extraFeedTags[$xml_format] as $extraTag) |
|
| 281 | - $extraFeedTags_string .= "\n" . $indent . $extraTag; |
|
| 296 | + foreach ($extraFeedTags[$xml_format] as $extraTag) { |
|
| 297 | + $extraFeedTags_string .= "\n" . $indent . $extraTag; |
|
| 298 | + } |
|
| 282 | 299 | } |
| 283 | 300 | |
| 284 | 301 | // This is an xml file.... |
| 285 | 302 | ob_end_clean(); |
| 286 | - if (!empty($modSettings['enableCompressedOutput'])) |
|
| 287 | - @ob_start('ob_gzhandler'); |
|
| 288 | - else |
|
| 289 | - ob_start(); |
|
| 303 | + if (!empty($modSettings['enableCompressedOutput'])) { |
|
| 304 | + @ob_start('ob_gzhandler'); |
|
| 305 | + } else { |
|
| 306 | + ob_start(); |
|
| 307 | + } |
|
| 290 | 308 | |
| 291 | - if ($xml_format == 'smf' || isset($_REQUEST['debug'])) |
|
| 292 | - header('Content-Type: text/xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
| 293 | - elseif ($xml_format == 'rss' || $xml_format == 'rss2') |
|
| 294 | - header('Content-Type: application/rss+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
| 295 | - elseif ($xml_format == 'atom') |
|
| 296 | - header('Content-Type: application/atom+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
| 297 | - elseif ($xml_format == 'rdf') |
|
| 298 | - header('Content-Type: ' . (isBrowser('ie') ? 'text/xml' : 'application/rdf+xml') . '; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
| 309 | + if ($xml_format == 'smf' || isset($_REQUEST['debug'])) { |
|
| 310 | + header('Content-Type: text/xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
| 311 | + } elseif ($xml_format == 'rss' || $xml_format == 'rss2') { |
|
| 312 | + header('Content-Type: application/rss+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
| 313 | + } elseif ($xml_format == 'atom') { |
|
| 314 | + header('Content-Type: application/atom+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
| 315 | + } elseif ($xml_format == 'rdf') { |
|
| 316 | + header('Content-Type: ' . (isBrowser('ie') ? 'text/xml' : 'application/rdf+xml') . '; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
| 317 | + } |
|
| 299 | 318 | |
| 300 | 319 | // First, output the xml header. |
| 301 | 320 | echo '<?xml version="1.0" encoding="', $context['character_set'], '"?' . '>'; |
@@ -303,10 +322,11 @@ discard block |
||
| 303 | 322 | // Are we outputting an rss feed or one with more information? |
| 304 | 323 | if ($xml_format == 'rss' || $xml_format == 'rss2') |
| 305 | 324 | { |
| 306 | - if ($xml_format == 'rss2') |
|
| 307 | - foreach ($_REQUEST as $var => $val) |
|
| 325 | + if ($xml_format == 'rss2') { |
|
| 326 | + foreach ($_REQUEST as $var => $val) |
|
| 308 | 327 | if (in_array($var, array('action', 'sa', 'type', 'board', 'boards', 'c', 'u', 'limit'))) |
| 309 | 328 | $url_parts[] = $var . '=' . (is_array($val) ? implode(',', $val) : $val); |
| 329 | + } |
|
| 310 | 330 | |
| 311 | 331 | // Start with an RSS 2.0 header. |
| 312 | 332 | echo ' |
@@ -327,9 +347,10 @@ discard block |
||
| 327 | 347 | <language>' . $feed_meta['language'] . '</language>' : ''; |
| 328 | 348 | |
| 329 | 349 | // RSS2 calls for this. |
| 330 | - if ($xml_format == 'rss2') |
|
| 331 | - echo ' |
|
| 350 | + if ($xml_format == 'rss2') { |
|
| 351 | + echo ' |
|
| 332 | 352 | <atom:link rel="self" type="application/rss+xml" href="', $scripturl, !empty($url_parts) ? '?' . implode(';', $url_parts) : '', '" />'; |
| 353 | + } |
|
| 333 | 354 | |
| 334 | 355 | echo $extraFeedTags_string; |
| 335 | 356 | |
@@ -340,12 +361,12 @@ discard block |
||
| 340 | 361 | echo ' |
| 341 | 362 | </channel> |
| 342 | 363 | </rss>'; |
| 343 | - } |
|
| 344 | - elseif ($xml_format == 'atom') |
|
| 364 | + } elseif ($xml_format == 'atom') |
|
| 345 | 365 | { |
| 346 | - foreach ($_REQUEST as $var => $val) |
|
| 347 | - if (in_array($var, array('action', 'sa', 'type', 'board', 'boards', 'c', 'u', 'limit'))) |
|
| 366 | + foreach ($_REQUEST as $var => $val) { |
|
| 367 | + if (in_array($var, array('action', 'sa', 'type', 'board', 'boards', 'c', 'u', 'limit'))) |
|
| 348 | 368 | $url_parts[] = $var . '=' . (is_array($val) ? implode(',', $val) : $val); |
| 369 | + } |
|
| 349 | 370 | |
| 350 | 371 | echo ' |
| 351 | 372 | <feed', $ns_string, !empty($feed_meta['language']) ? ' xml:lang="' . $feed_meta['language'] . '"' : '', '> |
@@ -371,8 +392,7 @@ discard block |
||
| 371 | 392 | |
| 372 | 393 | echo ' |
| 373 | 394 | </feed>'; |
| 374 | - } |
|
| 375 | - elseif ($xml_format == 'rdf') |
|
| 395 | + } elseif ($xml_format == 'rdf') |
|
| 376 | 396 | { |
| 377 | 397 | echo ' |
| 378 | 398 | <rdf:RDF', $ns_string, '> |
@@ -437,13 +457,15 @@ discard block |
||
| 437 | 457 | { |
| 438 | 458 | global $modSettings, $context, $scripturl; |
| 439 | 459 | |
| 440 | - if (substr($val, 0, strlen($scripturl)) != $scripturl) |
|
| 441 | - return $val; |
|
| 460 | + if (substr($val, 0, strlen($scripturl)) != $scripturl) { |
|
| 461 | + return $val; |
|
| 462 | + } |
|
| 442 | 463 | |
| 443 | 464 | call_integration_hook('integrate_fix_url', array(&$val)); |
| 444 | 465 | |
| 445 | - if (empty($modSettings['queryless_urls']) || ($context['server']['is_cgi'] && ini_get('cgi.fix_pathinfo') == 0 && @get_cfg_var('cgi.fix_pathinfo') == 0) || (!$context['server']['is_apache'] && !$context['server']['is_lighttpd'])) |
|
| 446 | - return $val; |
|
| 466 | + if (empty($modSettings['queryless_urls']) || ($context['server']['is_cgi'] && ini_get('cgi.fix_pathinfo') == 0 && @get_cfg_var('cgi.fix_pathinfo') == 0) || (!$context['server']['is_apache'] && !$context['server']['is_lighttpd'])) { |
|
| 467 | + return $val; |
|
| 468 | + } |
|
| 447 | 469 | |
| 448 | 470 | $val = preg_replace_callback('~\b' . preg_quote($scripturl, '~') . '\?((?:board|topic)=[^#"]+)(#[^"]*)?$~', function($m) use ($scripturl) |
| 449 | 471 | { |
@@ -466,8 +488,9 @@ discard block |
||
| 466 | 488 | global $smcFunc; |
| 467 | 489 | |
| 468 | 490 | // Do we even need to do this? |
| 469 | - if (strpbrk($data, '<>&') == false && $force !== true) |
|
| 470 | - return $data; |
|
| 491 | + if (strpbrk($data, '<>&') == false && $force !== true) { |
|
| 492 | + return $data; |
|
| 493 | + } |
|
| 471 | 494 | |
| 472 | 495 | $cdata = '<, |
| 478 | 501 | $smcFunc['strpos']($data, ']', $pos), |
| 479 | 502 | ); |
| 480 | - if ($ns != '') |
|
| 481 | - $positions[] = $smcFunc['strpos']($data, '<', $pos); |
|
| 503 | + if ($ns != '') { |
|
| 504 | + $positions[] = $smcFunc['strpos']($data, '<', $pos); |
|
| 505 | + } |
|
| 482 | 506 | foreach ($positions as $k => $dummy) |
| 483 | 507 | { |
| 484 | - if ($dummy === false) |
|
| 485 | - unset($positions[$k]); |
|
| 508 | + if ($dummy === false) { |
|
| 509 | + unset($positions[$k]); |
|
| 510 | + } |
|
| 486 | 511 | } |
| 487 | 512 | |
| 488 | 513 | $old = $pos; |
| 489 | 514 | $pos = empty($positions) ? $n : min($positions); |
| 490 | 515 | |
| 491 | - if ($pos - $old > 0) |
|
| 492 | - $cdata .= $smcFunc['substr']($data, $old, $pos - $old); |
|
| 493 | - if ($pos >= $n) |
|
| 494 | - break; |
|
| 516 | + if ($pos - $old > 0) { |
|
| 517 | + $cdata .= $smcFunc['substr']($data, $old, $pos - $old); |
|
| 518 | + } |
|
| 519 | + if ($pos >= $n) { |
|
| 520 | + break; |
|
| 521 | + } |
|
| 495 | 522 | |
| 496 | 523 | if ($smcFunc['substr']($data, $pos, 1) == '<') |
| 497 | 524 | { |
| 498 | 525 | $pos2 = $smcFunc['strpos']($data, '>', $pos); |
| 499 | - if ($pos2 === false) |
|
| 500 | - $pos2 = $n; |
|
| 501 | - if ($smcFunc['substr']($data, $pos + 1, 1) == '/') |
|
| 502 | - $cdata .= ']]></' . $ns . ':' . $smcFunc['substr']($data, $pos + 2, $pos2 - $pos - 1) . '<![CDATA['; |
|
| 503 | - else |
|
| 504 | - $cdata .= ']]><' . $ns . ':' . $smcFunc['substr']($data, $pos + 1, $pos2 - $pos) . '< == '/') { |
|
| 530 | + $cdata .= ']]></' . $ns . ':' . $smcFunc['substr']($data, $pos + 2, $pos2 - $pos - 1) . '<![CDATA['; |
|
| 531 | + } else { |
|
| 532 | + $cdata .= ']]><' . $ns . ':' . $smcFunc['substr']($data, $pos + 1, $pos2 - $pos) . '< == ']') |
|
| 535 | + } elseif ($smcFunc['substr']($data, $pos, 1) == ']') |
|
| 508 | 536 | { |
| 509 | 537 | $cdata .= ']]>]< == '&') |
|
| 539 | + } elseif ($smcFunc['substr']($data, $pos, 1) == '&') |
|
| 513 | 540 | { |
| 514 | 541 | $pos2 = $smcFunc['strpos']($data, ';', $pos); |
| 515 | - if ($pos2 === false) |
|
| 516 | - $pos2 = $n; |
|
| 542 | + if ($pos2 === false) { |
|
| 543 | + $pos2 = $n; |
|
| 544 | + } |
|
| 517 | 545 | $ent = $smcFunc['substr']($data, $pos + 1, $pos2 - $pos - 1); |
| 518 | 546 | |
| 519 | - if ($smcFunc['substr']($data, $pos + 1, 1) == '#') |
|
| 520 | - $cdata .= ']]>' . $smcFunc['substr']($data, $pos, $pos2 - $pos + 1) . '<![CDATA['; |
|
| 521 | - elseif (in_array($ent, array('amp', 'lt', 'gt', 'quot'))) |
|
| 522 | - $cdata .= ']]>' . $smcFunc['substr']($data, $pos, $pos2 - $pos + 1) . '< == '#') { |
|
| 548 | + $cdata .= ']]>' . $smcFunc['substr']($data, $pos, $pos2 - $pos + 1) . '<![CDATA['; |
|
| 549 | + } elseif (in_array($ent, array('amp', 'lt', 'gt', 'quot'))) { |
|
| 550 | + $cdata .= ']]>' . $smcFunc['substr']($data, $pos, $pos2 - $pos + 1) . '<![CDATA['; |
|
| 551 | + } |
|
| 523 | 552 | |
| 524 | 553 | $pos = $pos2 + 1; |
| 525 | 554 | } |
@@ -558,8 +587,9 @@ discard block |
||
| 558 | 587 | 'gender', |
| 559 | 588 | 'blurb', |
| 560 | 589 | ); |
| 561 | - if ($xml_format != 'atom') |
|
| 562 | - $keysToCdata[] = 'category'; |
|
| 590 | + if ($xml_format != 'atom') { |
|
| 591 | + $keysToCdata[] = 'category'; |
|
| 592 | + } |
|
| 563 | 593 | |
| 564 | 594 | if (!empty($forceCdataKeys)) |
| 565 | 595 | { |
@@ -576,8 +606,9 @@ discard block |
||
| 576 | 606 | $attrs = isset($element['attributes']) ? $element['attributes'] : null; |
| 577 | 607 | |
| 578 | 608 | // Skip it, it's been set to null. |
| 579 | - if ($key === null || ($val === null && $attrs === null)) |
|
| 580 | - continue; |
|
| 609 | + if ($key === null || ($val === null && $attrs === null)) { |
|
| 610 | + continue; |
|
| 611 | + } |
|
| 581 | 612 | |
| 582 | 613 | $forceCdata = in_array($key, $forceCdataKeys); |
| 583 | 614 | $ns = !empty($nsKeys[$key]) ? $nsKeys[$key] : ''; |
@@ -590,16 +621,16 @@ discard block |
||
| 590 | 621 | |
| 591 | 622 | if (!empty($attrs)) |
| 592 | 623 | { |
| 593 | - foreach ($attrs as $attr_key => $attr_value) |
|
| 594 | - echo ' ', $attr_key, '="', fix_possible_url($attr_value), '"'; |
|
| 624 | + foreach ($attrs as $attr_key => $attr_value) { |
|
| 625 | + echo ' ', $attr_key, '="', fix_possible_url($attr_value), '"'; |
|
| 626 | + } |
|
| 595 | 627 | } |
| 596 | 628 | |
| 597 | 629 | // If it's empty, simply output an empty element. |
| 598 | 630 | if (empty($val)) |
| 599 | 631 | { |
| 600 | 632 | echo ' />'; |
| 601 | - } |
|
| 602 | - else |
|
| 633 | + } else |
|
| 603 | 634 | { |
| 604 | 635 | echo '>'; |
| 605 | 636 | |
@@ -611,11 +642,13 @@ discard block |
||
| 611 | 642 | echo "\n", str_repeat("\t", $i); |
| 612 | 643 | } |
| 613 | 644 | // A string with returns in it.... show this as a multiline element. |
| 614 | - elseif (strpos($val, "\n") !== false) |
|
| 615 | - echo "\n", in_array($key, $keysToCdata) ? cdata_parse(fix_possible_url($val), $ns, $forceCdata) : fix_possible_url($val), "\n", str_repeat("\t", $i); |
|
| 645 | + elseif (strpos($val, "\n") !== false) { |
|
| 646 | + echo "\n", in_array($key, $keysToCdata) ? cdata_parse(fix_possible_url($val), $ns, $forceCdata) : fix_possible_url($val), "\n", str_repeat("\t", $i); |
|
| 647 | + } |
|
| 616 | 648 | // A simple string. |
| 617 | - else |
|
| 618 | - echo in_array($key, $keysToCdata) ? cdata_parse(fix_possible_url($val), $ns, $forceCdata) : fix_possible_url($val); |
|
| 649 | + else { |
|
| 650 | + echo in_array($key, $keysToCdata) ? cdata_parse(fix_possible_url($val), $ns, $forceCdata) : fix_possible_url($val); |
|
| 651 | + } |
|
| 619 | 652 | |
| 620 | 653 | // Ending tag. |
| 621 | 654 | echo '</', $key, '>'; |
@@ -635,8 +668,9 @@ discard block |
||
| 635 | 668 | { |
| 636 | 669 | global $scripturl, $smcFunc; |
| 637 | 670 | |
| 638 | - if (!allowedTo('view_mlist')) |
|
| 639 | - return array(); |
|
| 671 | + if (!allowedTo('view_mlist')) { |
|
| 672 | + return array(); |
|
| 673 | + } |
|
| 640 | 674 | |
| 641 | 675 | // Find the most recent members. |
| 642 | 676 | $request = $smcFunc['db_query']('', ' |
@@ -655,8 +689,8 @@ discard block |
||
| 655 | 689 | $guid = 'tag:' . parse_url($scripturl, PHP_URL_HOST) . ',' . gmdate('Y-m-d', $row['date_registered']) . ':member=' . $row['id_member']; |
| 656 | 690 | |
| 657 | 691 | // Make the data look rss-ish. |
| 658 | - if ($xml_format == 'rss' || $xml_format == 'rss2') |
|
| 659 | - $data[] = array( |
|
| 692 | + if ($xml_format == 'rss' || $xml_format == 'rss2') { |
|
| 693 | + $data[] = array( |
|
| 660 | 694 | 'tag' => 'item', |
| 661 | 695 | 'content' => array( |
| 662 | 696 | array( |
@@ -684,8 +718,8 @@ discard block |
||
| 684 | 718 | ), |
| 685 | 719 | ), |
| 686 | 720 | ); |
| 687 | - elseif ($xml_format == 'rdf') |
|
| 688 | - $data[] = array( |
|
| 721 | + } elseif ($xml_format == 'rdf') { |
|
| 722 | + $data[] = array( |
|
| 689 | 723 | 'tag' => 'item', |
| 690 | 724 | 'attributes' => array('rdf:about' => $scripturl . '?action=profile;u=' . $row['id_member']), |
| 691 | 725 | 'content' => array( |
@@ -703,8 +737,8 @@ discard block |
||
| 703 | 737 | ), |
| 704 | 738 | ), |
| 705 | 739 | ); |
| 706 | - elseif ($xml_format == 'atom') |
|
| 707 | - $data[] = array( |
|
| 740 | + } elseif ($xml_format == 'atom') { |
|
| 741 | + $data[] = array( |
|
| 708 | 742 | 'tag' => 'entry', |
| 709 | 743 | 'content' => array( |
| 710 | 744 | array( |
@@ -733,9 +767,10 @@ discard block |
||
| 733 | 767 | ), |
| 734 | 768 | ), |
| 735 | 769 | ); |
| 770 | + } |
|
| 736 | 771 | // More logical format for the data, but harder to apply. |
| 737 | - else |
|
| 738 | - $data[] = array( |
|
| 772 | + else { |
|
| 773 | + $data[] = array( |
|
| 739 | 774 | 'tag' => 'member', |
| 740 | 775 | 'content' => array( |
| 741 | 776 | array( |
@@ -756,6 +791,7 @@ discard block |
||
| 756 | 791 | ), |
| 757 | 792 | ), |
| 758 | 793 | ); |
| 794 | + } |
|
| 759 | 795 | } |
| 760 | 796 | $smcFunc['db_free_result']($request); |
| 761 | 797 | |
@@ -816,22 +852,24 @@ discard block |
||
| 816 | 852 | if ($loops < 2 && $smcFunc['db_num_rows']($request) < $_GET['limit']) |
| 817 | 853 | { |
| 818 | 854 | $smcFunc['db_free_result']($request); |
| 819 | - if (empty($_REQUEST['boards']) && empty($board)) |
|
| 820 | - unset($context['optimize_msg']['lowest']); |
|
| 821 | - else |
|
| 822 | - $context['optimize_msg']['lowest'] = 'm.id_msg >= t.id_first_msg'; |
|
| 855 | + if (empty($_REQUEST['boards']) && empty($board)) { |
|
| 856 | + unset($context['optimize_msg']['lowest']); |
|
| 857 | + } else { |
|
| 858 | + $context['optimize_msg']['lowest'] = 'm.id_msg >= t.id_first_msg'; |
|
| 859 | + } |
|
| 823 | 860 | $context['optimize_msg']['highest'] = 'm.id_msg <= t.id_last_msg'; |
| 824 | 861 | $loops++; |
| 862 | + } else { |
|
| 863 | + $done = true; |
|
| 825 | 864 | } |
| 826 | - else |
|
| 827 | - $done = true; |
|
| 828 | 865 | } |
| 829 | 866 | $data = array(); |
| 830 | 867 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 831 | 868 | { |
| 832 | 869 | // Limit the length of the message, if the option is set. |
| 833 | - if (!empty($modSettings['xmlnews_maxlen']) && $smcFunc['strlen'](str_replace('<br>', "\n", $row['body'])) > $modSettings['xmlnews_maxlen']) |
|
| 834 | - $row['body'] = strtr($smcFunc['substr'](str_replace('<br>', "\n", $row['body']), 0, $modSettings['xmlnews_maxlen'] - 3), array("\n" => '<br>')) . '...'; |
|
| 870 | + if (!empty($modSettings['xmlnews_maxlen']) && $smcFunc['strlen'](str_replace('<br>', "\n", $row['body'])) > $modSettings['xmlnews_maxlen']) { |
|
| 871 | + $row['body'] = strtr($smcFunc['substr'](str_replace('<br>', "\n", $row['body']), 0, $modSettings['xmlnews_maxlen'] - 3), array("\n" => '<br>')) . '...'; |
|
| 872 | + } |
|
| 835 | 873 | |
| 836 | 874 | $row['body'] = parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']); |
| 837 | 875 | |
@@ -858,8 +896,9 @@ discard block |
||
| 858 | 896 | while ($attach = $smcFunc['db_fetch_assoc']($attach_request)) |
| 859 | 897 | { |
| 860 | 898 | // Include approved attachments only |
| 861 | - if ($attach['approved']) |
|
| 862 | - $loaded_attachments['attachment_' . $attach['id_attach']] = $attach; |
|
| 899 | + if ($attach['approved']) { |
|
| 900 | + $loaded_attachments['attachment_' . $attach['id_attach']] = $attach; |
|
| 901 | + } |
|
| 863 | 902 | } |
| 864 | 903 | $smcFunc['db_free_result']($attach_request); |
| 865 | 904 | |
@@ -867,16 +906,17 @@ discard block |
||
| 867 | 906 | if (!empty($loaded_attachments)) |
| 868 | 907 | { |
| 869 | 908 | uasort($loaded_attachments, function($a, $b) { |
| 870 | - if ($a['filesize'] == $b['filesize']) |
|
| 871 | - return 0; |
|
| 909 | + if ($a['filesize'] == $b['filesize']) { |
|
| 910 | + return 0; |
|
| 911 | + } |
|
| 872 | 912 | return ($a['filesize'] < $b['filesize']) ? -1 : 1; |
| 873 | 913 | }); |
| 914 | + } else { |
|
| 915 | + $loaded_attachments = null; |
|
| 874 | 916 | } |
| 875 | - else |
|
| 876 | - $loaded_attachments = null; |
|
| 917 | + } else { |
|
| 918 | + $loaded_attachments = null; |
|
| 877 | 919 | } |
| 878 | - else |
|
| 879 | - $loaded_attachments = null; |
|
| 880 | 920 | |
| 881 | 921 | // Create a GUID for this topic using the tag URI scheme |
| 882 | 922 | $guid = 'tag:' . parse_url($scripturl, PHP_URL_HOST) . ',' . gmdate('Y-m-d', $row['poster_time']) . ':topic=' . $row['id_topic']; |
@@ -893,9 +933,9 @@ discard block |
||
| 893 | 933 | 'length' => $attachment['filesize'], |
| 894 | 934 | 'type' => $attachment['mime_type'], |
| 895 | 935 | ); |
| 936 | + } else { |
|
| 937 | + $enclosure = null; |
|
| 896 | 938 | } |
| 897 | - else |
|
| 898 | - $enclosure = null; |
|
| 899 | 939 | |
| 900 | 940 | $data[] = array( |
| 901 | 941 | 'tag' => 'item', |
@@ -941,8 +981,7 @@ discard block |
||
| 941 | 981 | ), |
| 942 | 982 | ), |
| 943 | 983 | ); |
| 944 | - } |
|
| 945 | - elseif ($xml_format == 'rdf') |
|
| 984 | + } elseif ($xml_format == 'rdf') |
|
| 946 | 985 | { |
| 947 | 986 | $data[] = array( |
| 948 | 987 | 'tag' => 'item', |
@@ -966,8 +1005,7 @@ discard block |
||
| 966 | 1005 | ), |
| 967 | 1006 | ), |
| 968 | 1007 | ); |
| 969 | - } |
|
| 970 | - elseif ($xml_format == 'atom') |
|
| 1008 | + } elseif ($xml_format == 'atom') |
|
| 971 | 1009 | { |
| 972 | 1010 | // Only one attachment allowed |
| 973 | 1011 | if (!empty($loaded_attachments)) |
@@ -979,9 +1017,9 @@ discard block |
||
| 979 | 1017 | 'length' => $attachment['filesize'], |
| 980 | 1018 | 'type' => $attachment['mime_type'], |
| 981 | 1019 | ); |
| 1020 | + } else { |
|
| 1021 | + $enclosure = null; |
|
| 982 | 1022 | } |
| 983 | - else |
|
| 984 | - $enclosure = null; |
|
| 985 | 1023 | |
| 986 | 1024 | $data[] = array( |
| 987 | 1025 | 'tag' => 'entry', |
@@ -1081,9 +1119,9 @@ discard block |
||
| 1081 | 1119 | ) |
| 1082 | 1120 | ); |
| 1083 | 1121 | } |
| 1122 | + } else { |
|
| 1123 | + $attachments = null; |
|
| 1084 | 1124 | } |
| 1085 | - else |
|
| 1086 | - $attachments = null; |
|
| 1087 | 1125 | |
| 1088 | 1126 | $data[] = array( |
| 1089 | 1127 | 'tag' => 'article', |
@@ -1201,22 +1239,25 @@ discard block |
||
| 1201 | 1239 | if ($loops < 2 && $smcFunc['db_num_rows']($request) < $_GET['limit']) |
| 1202 | 1240 | { |
| 1203 | 1241 | $smcFunc['db_free_result']($request); |
| 1204 | - if (empty($_REQUEST['boards']) && empty($board)) |
|
| 1205 | - unset($context['optimize_msg']['lowest']); |
|
| 1206 | - else |
|
| 1207 | - $context['optimize_msg']['lowest'] = $loops ? 'm.id_msg >= t.id_first_msg' : 'm.id_msg >= (t.id_last_msg - t.id_first_msg) / 2'; |
|
| 1242 | + if (empty($_REQUEST['boards']) && empty($board)) { |
|
| 1243 | + unset($context['optimize_msg']['lowest']); |
|
| 1244 | + } else { |
|
| 1245 | + $context['optimize_msg']['lowest'] = $loops ? 'm.id_msg >= t.id_first_msg' : 'm.id_msg >= (t.id_last_msg - t.id_first_msg) / 2'; |
|
| 1246 | + } |
|
| 1208 | 1247 | $loops++; |
| 1248 | + } else { |
|
| 1249 | + $done = true; |
|
| 1209 | 1250 | } |
| 1210 | - else |
|
| 1211 | - $done = true; |
|
| 1212 | 1251 | } |
| 1213 | 1252 | $messages = array(); |
| 1214 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1215 | - $messages[] = $row['id_msg']; |
|
| 1253 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1254 | + $messages[] = $row['id_msg']; |
|
| 1255 | + } |
|
| 1216 | 1256 | $smcFunc['db_free_result']($request); |
| 1217 | 1257 | |
| 1218 | - if (empty($messages)) |
|
| 1219 | - return array(); |
|
| 1258 | + if (empty($messages)) { |
|
| 1259 | + return array(); |
|
| 1260 | + } |
|
| 1220 | 1261 | |
| 1221 | 1262 | // Find the most recent posts this user can see. |
| 1222 | 1263 | $request = $smcFunc['db_query']('', ' |
@@ -1246,8 +1287,9 @@ discard block |
||
| 1246 | 1287 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1247 | 1288 | { |
| 1248 | 1289 | // Limit the length of the message, if the option is set. |
| 1249 | - if (!empty($modSettings['xmlnews_maxlen']) && $smcFunc['strlen'](str_replace('<br>', "\n", $row['body'])) > $modSettings['xmlnews_maxlen']) |
|
| 1250 | - $row['body'] = strtr($smcFunc['substr'](str_replace('<br>', "\n", $row['body']), 0, $modSettings['xmlnews_maxlen'] - 3), array("\n" => '<br>')) . '...'; |
|
| 1290 | + if (!empty($modSettings['xmlnews_maxlen']) && $smcFunc['strlen'](str_replace('<br>', "\n", $row['body'])) > $modSettings['xmlnews_maxlen']) { |
|
| 1291 | + $row['body'] = strtr($smcFunc['substr'](str_replace('<br>', "\n", $row['body']), 0, $modSettings['xmlnews_maxlen'] - 3), array("\n" => '<br>')) . '...'; |
|
| 1292 | + } |
|
| 1251 | 1293 | |
| 1252 | 1294 | $row['body'] = parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']); |
| 1253 | 1295 | |
@@ -1274,8 +1316,9 @@ discard block |
||
| 1274 | 1316 | while ($attach = $smcFunc['db_fetch_assoc']($attach_request)) |
| 1275 | 1317 | { |
| 1276 | 1318 | // Include approved attachments only |
| 1277 | - if ($attach['approved']) |
|
| 1278 | - $loaded_attachments['attachment_' . $attach['id_attach']] = $attach; |
|
| 1319 | + if ($attach['approved']) { |
|
| 1320 | + $loaded_attachments['attachment_' . $attach['id_attach']] = $attach; |
|
| 1321 | + } |
|
| 1279 | 1322 | } |
| 1280 | 1323 | $smcFunc['db_free_result']($attach_request); |
| 1281 | 1324 | |
@@ -1283,16 +1326,17 @@ discard block |
||
| 1283 | 1326 | if (!empty($loaded_attachments)) |
| 1284 | 1327 | { |
| 1285 | 1328 | uasort($loaded_attachments, function($a, $b) { |
| 1286 | - if ($a['filesize'] == $b['filesize']) |
|
| 1287 | - return 0; |
|
| 1329 | + if ($a['filesize'] == $b['filesize']) { |
|
| 1330 | + return 0; |
|
| 1331 | + } |
|
| 1288 | 1332 | return ($a['filesize'] < $b['filesize']) ? -1 : 1; |
| 1289 | 1333 | }); |
| 1334 | + } else { |
|
| 1335 | + $loaded_attachments = null; |
|
| 1290 | 1336 | } |
| 1291 | - else |
|
| 1292 | - $loaded_attachments = null; |
|
| 1337 | + } else { |
|
| 1338 | + $loaded_attachments = null; |
|
| 1293 | 1339 | } |
| 1294 | - else |
|
| 1295 | - $loaded_attachments = null; |
|
| 1296 | 1340 | |
| 1297 | 1341 | // Create a GUID for this post using the tag URI scheme |
| 1298 | 1342 | $guid = 'tag:' . parse_url($scripturl, PHP_URL_HOST) . ',' . gmdate('Y-m-d', $row['poster_time']) . ':msg=' . $row['id_msg']; |
@@ -1309,9 +1353,9 @@ discard block |
||
| 1309 | 1353 | 'length' => $attachment['filesize'], |
| 1310 | 1354 | 'type' => $attachment['mime_type'], |
| 1311 | 1355 | ); |
| 1356 | + } else { |
|
| 1357 | + $enclosure = null; |
|
| 1312 | 1358 | } |
| 1313 | - else |
|
| 1314 | - $enclosure = null; |
|
| 1315 | 1359 | |
| 1316 | 1360 | $data[] = array( |
| 1317 | 1361 | 'tag' => 'item', |
@@ -1357,8 +1401,7 @@ discard block |
||
| 1357 | 1401 | ), |
| 1358 | 1402 | ), |
| 1359 | 1403 | ); |
| 1360 | - } |
|
| 1361 | - elseif ($xml_format == 'rdf') |
|
| 1404 | + } elseif ($xml_format == 'rdf') |
|
| 1362 | 1405 | { |
| 1363 | 1406 | $data[] = array( |
| 1364 | 1407 | 'tag' => 'item', |
@@ -1382,8 +1425,7 @@ discard block |
||
| 1382 | 1425 | ), |
| 1383 | 1426 | ), |
| 1384 | 1427 | ); |
| 1385 | - } |
|
| 1386 | - elseif ($xml_format == 'atom') |
|
| 1428 | + } elseif ($xml_format == 'atom') |
|
| 1387 | 1429 | { |
| 1388 | 1430 | // Only one attachment allowed |
| 1389 | 1431 | if (!empty($loaded_attachments)) |
@@ -1395,9 +1437,9 @@ discard block |
||
| 1395 | 1437 | 'length' => $attachment['filesize'], |
| 1396 | 1438 | 'type' => $attachment['mime_type'], |
| 1397 | 1439 | ); |
| 1440 | + } else { |
|
| 1441 | + $enclosure = null; |
|
| 1398 | 1442 | } |
| 1399 | - else |
|
| 1400 | - $enclosure = null; |
|
| 1401 | 1443 | |
| 1402 | 1444 | $data[] = array( |
| 1403 | 1445 | 'tag' => 'entry', |
@@ -1497,9 +1539,9 @@ discard block |
||
| 1497 | 1539 | ) |
| 1498 | 1540 | ); |
| 1499 | 1541 | } |
| 1542 | + } else { |
|
| 1543 | + $attachments = null; |
|
| 1500 | 1544 | } |
| 1501 | - else |
|
| 1502 | - $attachments = null; |
|
| 1503 | 1545 | |
| 1504 | 1546 | $data[] = array( |
| 1505 | 1547 | 'tag' => 'recent-post', |
@@ -1618,14 +1660,16 @@ discard block |
||
| 1618 | 1660 | global $scripturl, $memberContext, $user_profile, $user_info; |
| 1619 | 1661 | |
| 1620 | 1662 | // You must input a valid user.... |
| 1621 | - if (empty($_GET['u']) || !loadMemberData((int) $_GET['u'])) |
|
| 1622 | - return array(); |
|
| 1663 | + if (empty($_GET['u']) || !loadMemberData((int) $_GET['u'])) { |
|
| 1664 | + return array(); |
|
| 1665 | + } |
|
| 1623 | 1666 | |
| 1624 | 1667 | // Make sure the id is a number and not "I like trying to hack the database". |
| 1625 | 1668 | $_GET['u'] = (int) $_GET['u']; |
| 1626 | 1669 | // Load the member's contextual information! |
| 1627 | - if (!loadMemberContext($_GET['u']) || !allowedTo('profile_view')) |
|
| 1628 | - return array(); |
|
| 1670 | + if (!loadMemberContext($_GET['u']) || !allowedTo('profile_view')) { |
|
| 1671 | + return array(); |
|
| 1672 | + } |
|
| 1629 | 1673 | |
| 1630 | 1674 | // Okay, I admit it, I'm lazy. Stupid $_GET['u'] is long and hard to type. |
| 1631 | 1675 | $profile = &$memberContext[$_GET['u']]; |
@@ -1667,8 +1711,7 @@ discard block |
||
| 1667 | 1711 | ), |
| 1668 | 1712 | ) |
| 1669 | 1713 | ); |
| 1670 | - } |
|
| 1671 | - elseif ($xml_format == 'rdf') |
|
| 1714 | + } elseif ($xml_format == 'rdf') |
|
| 1672 | 1715 | { |
| 1673 | 1716 | $data[] = array( |
| 1674 | 1717 | 'tag' => 'item', |
@@ -1692,8 +1735,7 @@ discard block |
||
| 1692 | 1735 | ), |
| 1693 | 1736 | ) |
| 1694 | 1737 | ); |
| 1695 | - } |
|
| 1696 | - elseif ($xml_format == 'atom') |
|
| 1738 | + } elseif ($xml_format == 'atom') |
|
| 1697 | 1739 | { |
| 1698 | 1740 | $data[] = array( |
| 1699 | 1741 | 'tag' => 'entry', |
@@ -1746,8 +1788,7 @@ discard block |
||
| 1746 | 1788 | ), |
| 1747 | 1789 | ) |
| 1748 | 1790 | ); |
| 1749 | - } |
|
| 1750 | - else |
|
| 1791 | + } else |
|
| 1751 | 1792 | { |
| 1752 | 1793 | $data = array( |
| 1753 | 1794 | array( |
@@ -72,9 +72,10 @@ discard block |
||
| 72 | 72 | |
| 73 | 73 | // Allow css/js files to be disable for this specific theme. |
| 74 | 74 | // Add the identifier as an array key. IE array('smf_script'); Some external files might not add identifiers, on those cases SMF uses its filename as reference. |
| 75 | - if (!isset($settings['disable_files'])) |
|
| 76 | - $settings['disable_files'] = array(); |
|
| 77 | -} |
|
| 75 | + if (!isset($settings['disable_files'])) { |
|
| 76 | + $settings['disable_files'] = array(); |
|
| 77 | + } |
|
| 78 | + } |
|
| 78 | 79 | |
| 79 | 80 | /** |
| 80 | 81 | * The main sub template above the content. |
@@ -111,8 +112,9 @@ discard block |
||
| 111 | 112 | echo ' |
| 112 | 113 | <meta'; |
| 113 | 114 | |
| 114 | - foreach ($meta_tag as $meta_key => $meta_value) |
|
| 115 | - echo ' ', $meta_key, '="', $meta_value, '"'; |
|
| 115 | + foreach ($meta_tag as $meta_key => $meta_value) { |
|
| 116 | + echo ' ', $meta_key, '="', $meta_value, '"'; |
|
| 117 | + } |
|
| 116 | 118 | |
| 117 | 119 | echo '>'; |
| 118 | 120 | } |
@@ -123,14 +125,16 @@ discard block |
||
| 123 | 125 | <meta name="theme-color" content="#557EA0">'; |
| 124 | 126 | |
| 125 | 127 | // Please don't index these Mr Robot. |
| 126 | - if (!empty($context['robot_no_index'])) |
|
| 127 | - echo ' |
|
| 128 | + if (!empty($context['robot_no_index'])) { |
|
| 129 | + echo ' |
|
| 128 | 130 | <meta name="robots" content="noindex">'; |
| 131 | + } |
|
| 129 | 132 | |
| 130 | 133 | // Present a canonical url for search engines to prevent duplicate content in their indices. |
| 131 | - if (!empty($context['canonical_url'])) |
|
| 132 | - echo ' |
|
| 134 | + if (!empty($context['canonical_url'])) { |
|
| 135 | + echo ' |
|
| 133 | 136 | <link rel="canonical" href="', $context['canonical_url'], '">'; |
| 137 | + } |
|
| 134 | 138 | |
| 135 | 139 | // Show all the relative links, such as help, search, contents, and the like. |
| 136 | 140 | echo ' |
@@ -139,10 +143,11 @@ discard block |
||
| 139 | 143 | <link rel="search" href="' . $scripturl . '?action=search">' : ''); |
| 140 | 144 | |
| 141 | 145 | // If RSS feeds are enabled, advertise the presence of one. |
| 142 | - if (!empty($modSettings['xmlnews_enable']) && (!empty($modSettings['allow_guestAccess']) || $context['user']['is_logged'])) |
|
| 143 | - echo ' |
|
| 146 | + if (!empty($modSettings['xmlnews_enable']) && (!empty($modSettings['allow_guestAccess']) || $context['user']['is_logged'])) { |
|
| 147 | + echo ' |
|
| 144 | 148 | <link rel="alternate feed" type="application/rss+xml" title="', $context['forum_name_html_safe'], ' - ', $txt['rss'], '" href="', $scripturl, '?action=.xml;type=rss2', !empty($context['current_board']) ? ';board=' . $context['current_board'] : '', '"> |
| 145 | 149 | <link rel="alternate feed" type="application/atom+xml" title="', $context['forum_name_html_safe'], ' - ', $txt['atom'], '" href="', $scripturl, '?action=.xml;type=atom', !empty($context['current_board']) ? ';board=' . $context['current_board'] : '', '">'; |
| 150 | + } |
|
| 146 | 151 | |
| 147 | 152 | // If we're viewing a topic, these should be the previous and next topics, respectively. |
| 148 | 153 | if (!empty($context['links']['next'])) |
@@ -158,9 +163,10 @@ discard block |
||
| 158 | 163 | } |
| 159 | 164 | |
| 160 | 165 | // If we're in a board, or a topic for that matter, the index will be the board's index. |
| 161 | - if (!empty($context['current_board'])) |
|
| 162 | - echo ' |
|
| 166 | + if (!empty($context['current_board'])) { |
|
| 167 | + echo ' |
|
| 163 | 168 | <link rel="index" href="', $scripturl, '?board=', $context['current_board'], '.0">'; |
| 169 | + } |
|
| 164 | 170 | |
| 165 | 171 | // Output any remaining HTML headers. (from mods, maybe?) |
| 166 | 172 | echo $context['html_headers']; |
@@ -191,8 +197,9 @@ discard block |
||
| 191 | 197 | <ul class="floatleft" id="top_info"> |
| 192 | 198 | <li> |
| 193 | 199 | <a href="', $scripturl, '?action=profile"', !empty($context['self_profile']) ? ' class="active"' : '', ' id="profile_menu_top" onclick="return false;">'; |
| 194 | - if (!empty($context['user']['avatar'])) |
|
| 195 | - echo $context['user']['avatar']['image']; |
|
| 200 | + if (!empty($context['user']['avatar'])) { |
|
| 201 | + echo $context['user']['avatar']['image']; |
|
| 202 | + } |
|
| 196 | 203 | echo $context['user']['name'], '</a> |
| 197 | 204 | <div id="profile_menu" class="top_menu"></div> |
| 198 | 205 | </li>'; |
@@ -220,17 +227,18 @@ discard block |
||
| 220 | 227 | } |
| 221 | 228 | // Otherwise they're a guest. Ask them to either register or login. |
| 222 | 229 | else |
| 223 | - if (empty($maintenance)) |
|
| 224 | - echo ' |
|
| 230 | + if (empty($maintenance)) { |
|
| 231 | + echo ' |
|
| 225 | 232 | <ul class="floatleft welcome"> |
| 226 | 233 | <li>', sprintf($txt[$context['can_register'] ? 'welcome_guest_register' : 'welcome_guest'], $txt['guest_title'], $context['forum_name_html_safe'], $scripturl . '?action=login', 'return reqOverlayDiv(this.href, ' . JavaScriptEscape($txt['login']) . ');', $scripturl . '?action=signup'), '</li> |
| 227 | 234 | </ul>'; |
| 228 | - else |
|
| 229 | - //In maintenance mode, only login is allowed and don't show OverlayDiv |
|
| 235 | + } else { |
|
| 236 | + //In maintenance mode, only login is allowed and don't show OverlayDiv |
|
| 230 | 237 | echo ' |
| 231 | 238 | <ul class="floatleft welcome"> |
| 232 | 239 | <li>', sprintf($txt['welcome_guest'], $txt['guest_title'], '', $scripturl. '?action=login', 'return true;'), '</li> |
| 233 | 240 | </ul>'; |
| 241 | + } |
|
| 234 | 242 | |
| 235 | 243 | if (!empty($modSettings['userLanguage']) && !empty($context['languages']) && count($context['languages']) > 1) |
| 236 | 244 | { |
@@ -238,9 +246,10 @@ discard block |
||
| 238 | 246 | <form id="languages_form" method="get" class="floatright"> |
| 239 | 247 | <select id="language_select" name="language" onchange="this.form.submit()">'; |
| 240 | 248 | |
| 241 | - foreach ($context['languages'] as $language) |
|
| 242 | - echo ' |
|
| 249 | + foreach ($context['languages'] as $language) { |
|
| 250 | + echo ' |
|
| 243 | 251 | <option value="', $language['filename'], '"', isset($context['user']['language']) && $context['user']['language'] == $language['filename'] ? ' selected="selected"' : '', '>', str_replace('-utf8', '', $language['name']), '</option>'; |
| 252 | + } |
|
| 244 | 253 | |
| 245 | 254 | echo ' |
| 246 | 255 | </select> |
@@ -264,31 +273,36 @@ discard block |
||
| 264 | 273 | <option value="all"', ($selected == 'all' ? ' selected' : ''), '>', $txt['search_entireforum'], ' </option>'; |
| 265 | 274 | |
| 266 | 275 | // Can't limit it to a specific topic if we are not in one |
| 267 | - if (!empty($context['current_topic'])) |
|
| 268 | - echo ' |
|
| 276 | + if (!empty($context['current_topic'])) { |
|
| 277 | + echo ' |
|
| 269 | 278 | <option value="topic"', ($selected == 'current_topic' ? ' selected' : ''), '>', $txt['search_thistopic'], '</option>'; |
| 279 | + } |
|
| 270 | 280 | |
| 271 | 281 | // Can't limit it to a specific board if we are not in one |
| 272 | - if (!empty($context['current_board'])) |
|
| 273 | - echo ' |
|
| 282 | + if (!empty($context['current_board'])) { |
|
| 283 | + echo ' |
|
| 274 | 284 | <option value="board"', ($selected == 'current_board' ? ' selected' : ''), '>', $txt['search_thisbrd'], '</option>'; |
| 285 | + } |
|
| 275 | 286 | |
| 276 | 287 | // Can't search for members if we can't see the memberlist |
| 277 | - if (!empty($context['allow_memberlist'])) |
|
| 278 | - echo ' |
|
| 288 | + if (!empty($context['allow_memberlist'])) { |
|
| 289 | + echo ' |
|
| 279 | 290 | <option value="members"', ($selected == 'members' ? ' selected' : ''), '>', $txt['search_members'], ' </option>'; |
| 291 | + } |
|
| 280 | 292 | |
| 281 | 293 | echo ' |
| 282 | 294 | </select>'; |
| 283 | 295 | |
| 284 | 296 | // Search within current topic? |
| 285 | - if (!empty($context['current_topic'])) |
|
| 286 | - echo ' |
|
| 297 | + if (!empty($context['current_topic'])) { |
|
| 298 | + echo ' |
|
| 287 | 299 | <input type="hidden" name="sd_topic" value="', $context['current_topic'], '">'; |
| 300 | + } |
|
| 288 | 301 | // If we're on a certain board, limit it to this board ;). |
| 289 | - elseif (!empty($context['current_board'])) |
|
| 290 | - echo ' |
|
| 302 | + elseif (!empty($context['current_board'])) { |
|
| 303 | + echo ' |
|
| 291 | 304 | <input type="hidden" name="sd_brd" value="', $context['current_board'], '">'; |
| 305 | + } |
|
| 292 | 306 | |
| 293 | 307 | echo ' |
| 294 | 308 | <input type="submit" name="search2" value="', $txt['search'], '" class="button_submit"> |
@@ -318,12 +332,13 @@ discard block |
||
| 318 | 332 | ', $context['current_time'], ' |
| 319 | 333 | </div>'; |
| 320 | 334 | // Show a random news item? (or you could pick one from news_lines...) |
| 321 | - if (!empty($settings['enable_news']) && !empty($context['random_news_line'])) |
|
| 322 | - echo ' |
|
| 335 | + if (!empty($settings['enable_news']) && !empty($context['random_news_line'])) { |
|
| 336 | + echo ' |
|
| 323 | 337 | <div class="news"> |
| 324 | 338 | <h2>', $txt['news'], ': </h2> |
| 325 | 339 | <p>', $context['random_news_line'], '</p> |
| 326 | 340 | </div>'; |
| 341 | + } |
|
| 327 | 342 | |
| 328 | 343 | echo ' |
| 329 | 344 | <hr class="clear"> |
@@ -386,9 +401,10 @@ discard block |
||
| 386 | 401 | </ul>'; |
| 387 | 402 | |
| 388 | 403 | // Show the load time? |
| 389 | - if ($context['show_load_time']) |
|
| 390 | - echo ' |
|
| 404 | + if ($context['show_load_time']) { |
|
| 405 | + echo ' |
|
| 391 | 406 | <p>', sprintf($txt['page_created_full'], $context['load_time'], $context['load_queries']), '</p>'; |
| 407 | + } |
|
| 392 | 408 | |
| 393 | 409 | echo ' |
| 394 | 410 | </div>'; |
@@ -418,19 +434,21 @@ discard block |
||
| 418 | 434 | global $context, $shown_linktree, $scripturl, $txt; |
| 419 | 435 | |
| 420 | 436 | // If linktree is empty, just return - also allow an override. |
| 421 | - if (empty($context['linktree']) || (!empty($context['dont_default_linktree']) && !$force_show)) |
|
| 422 | - return; |
|
| 437 | + if (empty($context['linktree']) || (!empty($context['dont_default_linktree']) && !$force_show)) { |
|
| 438 | + return; |
|
| 439 | + } |
|
| 423 | 440 | |
| 424 | 441 | echo ' |
| 425 | 442 | <div class="navigate_section"> |
| 426 | 443 | <ul>'; |
| 427 | 444 | |
| 428 | - if ($context['user']['is_logged']) |
|
| 429 | - echo ' |
|
| 445 | + if ($context['user']['is_logged']) { |
|
| 446 | + echo ' |
|
| 430 | 447 | <li class="unread_links"> |
| 431 | 448 | <a href="', $scripturl, '?action=unread" title="', $txt['unread_since_visit'], '">', $txt['view_unread_category'], '</a> |
| 432 | 449 | <a href="', $scripturl, '?action=unreadreplies" title="', $txt['show_unread_replies'], '">', $txt['unread_replies'], '</a> |
| 433 | 450 | </li>'; |
| 451 | + } |
|
| 434 | 452 | |
| 435 | 453 | // Each tree item has a URL and name. Some may have extra_before and extra_after. |
| 436 | 454 | foreach ($context['linktree'] as $link_num => $tree) |
@@ -441,25 +459,29 @@ discard block |
||
| 441 | 459 | // Don't show a separator for the first one. |
| 442 | 460 | // Better here. Always points to the next level when the linktree breaks to a second line. |
| 443 | 461 | // Picked a better looking HTML entity, and added support for RTL plus a span for styling. |
| 444 | - if ($link_num != 0) |
|
| 445 | - echo ' |
|
| 462 | + if ($link_num != 0) { |
|
| 463 | + echo ' |
|
| 446 | 464 | <span class="dividers">', $context['right_to_left'] ? ' ◄ ' : ' ► ', '</span>'; |
| 465 | + } |
|
| 447 | 466 | |
| 448 | 467 | // Show something before the link? |
| 449 | - if (isset($tree['extra_before'])) |
|
| 450 | - echo $tree['extra_before'], ' '; |
|
| 468 | + if (isset($tree['extra_before'])) { |
|
| 469 | + echo $tree['extra_before'], ' '; |
|
| 470 | + } |
|
| 451 | 471 | |
| 452 | 472 | // Show the link, including a URL if it should have one. |
| 453 | - if (isset($tree['url'])) |
|
| 454 | - echo ' |
|
| 473 | + if (isset($tree['url'])) { |
|
| 474 | + echo ' |
|
| 455 | 475 | <a href="' . $tree['url'] . '"><span>' . $tree['name'] . '</span></a>'; |
| 456 | - else |
|
| 457 | - echo ' |
|
| 476 | + } else { |
|
| 477 | + echo ' |
|
| 458 | 478 | <span>' . $tree['name'] . '</span>'; |
| 479 | + } |
|
| 459 | 480 | |
| 460 | 481 | // Show something after the link...? |
| 461 | - if (isset($tree['extra_after'])) |
|
| 462 | - echo ' ', $tree['extra_after']; |
|
| 482 | + if (isset($tree['extra_after'])) { |
|
| 483 | + echo ' ', $tree['extra_after']; |
|
| 484 | + } |
|
| 463 | 485 | |
| 464 | 486 | echo ' |
| 465 | 487 | </li>'; |
@@ -509,13 +531,14 @@ discard block |
||
| 509 | 531 | echo ' |
| 510 | 532 | <ul>'; |
| 511 | 533 | |
| 512 | - foreach ($childbutton['sub_buttons'] as $grandchildbutton) |
|
| 513 | - echo ' |
|
| 534 | + foreach ($childbutton['sub_buttons'] as $grandchildbutton) { |
|
| 535 | + echo ' |
|
| 514 | 536 | <li> |
| 515 | 537 | <a href="', $grandchildbutton['href'], '"', isset($grandchildbutton['target']) ? ' target="' . $grandchildbutton['target'] . '"' : '', '> |
| 516 | 538 | ', $grandchildbutton['title'], ' |
| 517 | 539 | </a> |
| 518 | 540 | </li>'; |
| 541 | + } |
|
| 519 | 542 | |
| 520 | 543 | echo ' |
| 521 | 544 | </ul>'; |
@@ -546,8 +569,9 @@ discard block |
||
| 546 | 569 | { |
| 547 | 570 | global $context, $txt; |
| 548 | 571 | |
| 549 | - if (!is_array($strip_options)) |
|
| 550 | - $strip_options = array(); |
|
| 572 | + if (!is_array($strip_options)) { |
|
| 573 | + $strip_options = array(); |
|
| 574 | + } |
|
| 551 | 575 | |
| 552 | 576 | // Create the buttons... |
| 553 | 577 | $buttons = array(); |
@@ -556,8 +580,9 @@ discard block |
||
| 556 | 580 | // As of 2.1, the 'test' for each button happens while the array is being generated. The extra 'test' check here is deprecated but kept for backward compatibility (update your mods, folks!) |
| 557 | 581 | if (!isset($value['test']) || !empty($context[$value['test']])) |
| 558 | 582 | { |
| 559 | - if (!isset($value['id'])) |
|
| 560 | - $value['id'] = $key; |
|
| 583 | + if (!isset($value['id'])) { |
|
| 584 | + $value['id'] = $key; |
|
| 585 | + } |
|
| 561 | 586 | |
| 562 | 587 | $button = ' |
| 563 | 588 | <a class="button button_strip_' . $key . (!empty($value['active']) ? ' active' : '') . (isset($value['class']) ? ' ' . $value['class'] : '') . '" ' . (!empty($value['url']) ? 'href="' . $value['url'] . '"' : '') . ' ' . (isset($value['custom']) ? ' ' . $value['custom'] : '') . '>' . $txt[$value['text']] . '</a>'; |
@@ -570,13 +595,15 @@ discard block |
||
| 570 | 595 | <div class="overview">'; |
| 571 | 596 | foreach ($value['sub_buttons'] as $element) |
| 572 | 597 | { |
| 573 | - if (isset($element['test']) && empty($context[$element['test']])) |
|
| 574 | - continue; |
|
| 598 | + if (isset($element['test']) && empty($context[$element['test']])) { |
|
| 599 | + continue; |
|
| 600 | + } |
|
| 575 | 601 | |
| 576 | 602 | $button .= ' |
| 577 | 603 | <a href="' . $element['url'] . '"><strong>' . $txt[$element['text']] . '</strong>'; |
| 578 | - if (isset($txt[$element['text'] . '_desc'])) |
|
| 579 | - $button .= '<br /><span>' . $txt[$element['text'] . '_desc'] . '</span>'; |
|
| 604 | + if (isset($txt[$element['text'] . '_desc'])) { |
|
| 605 | + $button .= '<br /><span>' . $txt[$element['text'] . '_desc'] . '</span>'; |
|
| 606 | + } |
|
| 580 | 607 | $button .= '</a>'; |
| 581 | 608 | } |
| 582 | 609 | $button .= ' |
@@ -590,8 +617,9 @@ discard block |
||
| 590 | 617 | } |
| 591 | 618 | |
| 592 | 619 | // No buttons? No button strip either. |
| 593 | - if (empty($buttons)) |
|
| 594 | - return; |
|
| 620 | + if (empty($buttons)) { |
|
| 621 | + return; |
|
| 622 | + } |
|
| 595 | 623 | |
| 596 | 624 | echo ' |
| 597 | 625 | <div class="buttonlist', !empty($direction) ? ' float' . $direction : '', '"', (empty($buttons) ? ' style="display: none;"' : ''), (!empty($strip_options['id']) ? ' id="' . $strip_options['id'] . '"' : ''), '> |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 3 |
| 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 | * Shows an avatar based on $_GET['attach'] |
@@ -35,11 +36,11 @@ discard block |
||
| 35 | 36 | |
| 36 | 37 | if (!empty($modSettings['enableCompressedOutput']) && !headers_sent() && ob_get_length() == 0) |
| 37 | 38 | { |
| 38 | - if (@ini_get('zlib.output_compression') == '1' || @ini_get('output_handler') == 'ob_gzhandler') |
|
| 39 | - $modSettings['enableCompressedOutput'] = 0; |
|
| 40 | - |
|
| 41 | - else |
|
| 42 | - ob_start('ob_gzhandler'); |
|
| 39 | + if (@ini_get('zlib.output_compression') == '1' || @ini_get('output_handler') == 'ob_gzhandler') { |
|
| 40 | + $modSettings['enableCompressedOutput'] = 0; |
|
| 41 | + } else { |
|
| 42 | + ob_start('ob_gzhandler'); |
|
| 43 | + } |
|
| 43 | 44 | } |
| 44 | 45 | |
| 45 | 46 | if (empty($modSettings['enableCompressedOutput'])) |
@@ -71,8 +72,9 @@ discard block |
||
| 71 | 72 | } |
| 72 | 73 | |
| 73 | 74 | // Use cache when possible. |
| 74 | - if (($cache = cache_get_data('attachment_lookup_id-' . $attachId)) != null) |
|
| 75 | - list($file, $thumbFile) = $cache; |
|
| 75 | + if (($cache = cache_get_data('attachment_lookup_id-' . $attachId)) != null) { |
|
| 76 | + list($file, $thumbFile) = $cache; |
|
| 77 | + } |
|
| 76 | 78 | |
| 77 | 79 | // Get the info from the DB. |
| 78 | 80 | if (empty($file) || empty($thumbFile) && !empty($file['id_thumb'])) |
@@ -80,10 +82,9 @@ discard block |
||
| 80 | 82 | // Do we have a hook wanting to use our attachment system? We use $attachRequest to prevent accidental usage of $request. |
| 81 | 83 | $attachRequest = null; |
| 82 | 84 | call_integration_hook('integrate_download_request', array(&$attachRequest)); |
| 83 | - if (!is_null($attachRequest) && $smcFunc['db_is_resource']($attachRequest)) |
|
| 84 | - $request = $attachRequest; |
|
| 85 | - |
|
| 86 | - else |
|
| 85 | + if (!is_null($attachRequest) && $smcFunc['db_is_resource']($attachRequest)) { |
|
| 86 | + $request = $attachRequest; |
|
| 87 | + } else |
|
| 87 | 88 | { |
| 88 | 89 | // Make sure this attachment is on this board and load its info while we are at it. |
| 89 | 90 | $request = $smcFunc['db_query']('', ' |
@@ -176,13 +177,15 @@ discard block |
||
| 176 | 177 | } |
| 177 | 178 | |
| 178 | 179 | // Cache it. |
| 179 | - if (!empty($file) || !empty($thumbFile)) |
|
| 180 | - cache_put_data('attachment_lookup_id-' . $file['id_attach'], array($file, $thumbFile), mt_rand(850, 900)); |
|
| 180 | + if (!empty($file) || !empty($thumbFile)) { |
|
| 181 | + cache_put_data('attachment_lookup_id-' . $file['id_attach'], array($file, $thumbFile), mt_rand(850, 900)); |
|
| 182 | + } |
|
| 181 | 183 | } |
| 182 | 184 | |
| 183 | 185 | // Replace the normal file with its thumbnail if it has one! |
| 184 | - if (!empty($showThumb) && !empty($thumbFile)) |
|
| 185 | - $file = $thumbFile; |
|
| 186 | + if (!empty($showThumb) && !empty($thumbFile)) { |
|
| 187 | + $file = $thumbFile; |
|
| 188 | + } |
|
| 186 | 189 | |
| 187 | 190 | // No point in a nicer message, because this is supposed to be an attachment anyway... |
| 188 | 191 | if (!file_exists($file['filePath'])) |
@@ -232,8 +235,8 @@ discard block |
||
| 232 | 235 | } |
| 233 | 236 | |
| 234 | 237 | // Update the download counter (unless it's a thumbnail or resuming an incomplete download). |
| 235 | - if ($file['attachment_type'] != 3 && empty($showThumb) && $range === 0) |
|
| 236 | - $smcFunc['db_query']('attach_download_increase', ' |
|
| 238 | + if ($file['attachment_type'] != 3 && empty($showThumb) && $range === 0) { |
|
| 239 | + $smcFunc['db_query']('attach_download_increase', ' |
|
| 237 | 240 | UPDATE LOW_PRIORITY {db_prefix}attachments |
| 238 | 241 | SET downloads = downloads + 1 |
| 239 | 242 | WHERE id_attach = {int:id_attach}', |
@@ -241,12 +244,14 @@ discard block |
||
| 241 | 244 | 'id_attach' => $attachId, |
| 242 | 245 | ) |
| 243 | 246 | ); |
| 247 | + } |
|
| 244 | 248 | |
| 245 | 249 | // Send the attachment headers. |
| 246 | 250 | header('Pragma: '); |
| 247 | 251 | |
| 248 | - if (!isBrowser('gecko')) |
|
| 249 | - header('Content-Transfer-Encoding: binary'); |
|
| 252 | + if (!isBrowser('gecko')) { |
|
| 253 | + header('Content-Transfer-Encoding: binary'); |
|
| 254 | + } |
|
| 250 | 255 | |
| 251 | 256 | header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 525600 * 60) . ' GMT'); |
| 252 | 257 | header('Last-Modified: ' . gmdate('D, d M Y H:i:s', filemtime($file['filePath'])) . ' GMT'); |
@@ -255,18 +260,19 @@ discard block |
||
| 255 | 260 | header('ETag: ' . $eTag); |
| 256 | 261 | |
| 257 | 262 | // Make sure the mime type warrants an inline display. |
| 258 | - if (isset($_REQUEST['image']) && !empty($file['mime_type']) && strpos($file['mime_type'], 'image/') !== 0) |
|
| 259 | - unset($_REQUEST['image']); |
|
| 263 | + if (isset($_REQUEST['image']) && !empty($file['mime_type']) && strpos($file['mime_type'], 'image/') !== 0) { |
|
| 264 | + unset($_REQUEST['image']); |
|
| 265 | + } |
|
| 260 | 266 | |
| 261 | 267 | // Does this have a mime type? |
| 262 | - elseif (!empty($file['mime_type']) && (isset($_REQUEST['image']) || !in_array($file['fileext'], array('jpg', 'gif', 'jpeg', 'x-ms-bmp', 'png', 'psd', 'tiff', 'iff')))) |
|
| 263 | - header('Content-Type: ' . strtr($file['mime_type'], array('image/bmp' => 'image/x-ms-bmp'))); |
|
| 264 | - |
|
| 265 | - else |
|
| 268 | + elseif (!empty($file['mime_type']) && (isset($_REQUEST['image']) || !in_array($file['fileext'], array('jpg', 'gif', 'jpeg', 'x-ms-bmp', 'png', 'psd', 'tiff', 'iff')))) { |
|
| 269 | + header('Content-Type: ' . strtr($file['mime_type'], array('image/bmp' => 'image/x-ms-bmp'))); |
|
| 270 | + } else |
|
| 266 | 271 | { |
| 267 | 272 | header('Content-Type: ' . (isBrowser('ie') || isBrowser('opera') ? 'application/octetstream' : 'application/octet-stream')); |
| 268 | - if (isset($_REQUEST['image'])) |
|
| 269 | - unset($_REQUEST['image']); |
|
| 273 | + if (isset($_REQUEST['image'])) { |
|
| 274 | + unset($_REQUEST['image']); |
|
| 275 | + } |
|
| 270 | 276 | } |
| 271 | 277 | |
| 272 | 278 | // Convert the file to UTF-8, cuz most browsers dig that. |
@@ -274,24 +280,22 @@ discard block |
||
| 274 | 280 | $disposition = !isset($_REQUEST['image']) ? 'attachment' : 'inline'; |
| 275 | 281 | |
| 276 | 282 | // Different browsers like different standards... |
| 277 | - if (isBrowser('firefox')) |
|
| 278 | - header('Content-Disposition: ' . $disposition . '; filename*=UTF-8\'\'' . rawurlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name))); |
|
| 279 | - |
|
| 280 | - elseif (isBrowser('opera')) |
|
| 281 | - header('Content-Disposition: ' . $disposition . '; filename="' . preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name) . '"'); |
|
| 282 | - |
|
| 283 | - elseif (isBrowser('ie')) |
|
| 284 | - header('Content-Disposition: ' . $disposition . '; filename="' . urlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name)) . '"'); |
|
| 285 | - |
|
| 286 | - else |
|
| 287 | - header('Content-Disposition: ' . $disposition . '; filename="' . $utf8name . '"'); |
|
| 283 | + if (isBrowser('firefox')) { |
|
| 284 | + header('Content-Disposition: ' . $disposition . '; filename*=UTF-8\'\'' . rawurlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name))); |
|
| 285 | + } elseif (isBrowser('opera')) { |
|
| 286 | + header('Content-Disposition: ' . $disposition . '; filename="' . preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name) . '"'); |
|
| 287 | + } elseif (isBrowser('ie')) { |
|
| 288 | + header('Content-Disposition: ' . $disposition . '; filename="' . urlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name)) . '"'); |
|
| 289 | + } else { |
|
| 290 | + header('Content-Disposition: ' . $disposition . '; filename="' . $utf8name . '"'); |
|
| 291 | + } |
|
| 288 | 292 | |
| 289 | 293 | // If this has an "image extension" - but isn't actually an image - then ensure it isn't cached cause of silly IE. |
| 290 | - if (!isset($_REQUEST['image']) && in_array($file['fileext'], array('gif', 'jpg', 'bmp', 'png', 'jpeg', 'tiff'))) |
|
| 291 | - header('Cache-Control: no-cache'); |
|
| 292 | - |
|
| 293 | - else |
|
| 294 | - header('Cache-Control: max-age=' . (525600 * 60) . ', private'); |
|
| 294 | + if (!isset($_REQUEST['image']) && in_array($file['fileext'], array('gif', 'jpg', 'bmp', 'png', 'jpeg', 'tiff'))) { |
|
| 295 | + header('Cache-Control: no-cache'); |
|
| 296 | + } else { |
|
| 297 | + header('Cache-Control: max-age=' . (525600 * 60) . ', private'); |
|
| 298 | + } |
|
| 295 | 299 | |
| 296 | 300 | // Multipart and resuming support |
| 297 | 301 | if (isset($_SERVER['HTTP_RANGE'])) |
@@ -299,9 +303,9 @@ discard block |
||
| 299 | 303 | header("HTTP/1.1 206 Partial Content"); |
| 300 | 304 | header("Content-Length: $new_length"); |
| 301 | 305 | header("Content-Range: bytes $range-$range_end/$size"); |
| 306 | + } else { |
|
| 307 | + header("Content-Length: " . $size); |
|
| 302 | 308 | } |
| 303 | - else |
|
| 304 | - header("Content-Length: " . $size); |
|
| 305 | 309 | |
| 306 | 310 | |
| 307 | 311 | // Try to buy some time... |
@@ -310,8 +314,9 @@ discard block |
||
| 310 | 314 | // For multipart/resumable downloads, send the requested chunk(s) of the file |
| 311 | 315 | if (isset($_SERVER['HTTP_RANGE'])) |
| 312 | 316 | { |
| 313 | - while (@ob_get_level() > 0) |
|
| 314 | - @ob_end_clean(); |
|
| 317 | + while (@ob_get_level() > 0) { |
|
| 318 | + @ob_end_clean(); |
|
| 319 | + } |
|
| 315 | 320 | |
| 316 | 321 | // 40 kilobytes is a good-ish amount |
| 317 | 322 | $chunksize = 40 * 1024; |
@@ -335,8 +340,9 @@ discard block |
||
| 335 | 340 | elseif ($size > 4194304) |
| 336 | 341 | { |
| 337 | 342 | // Forcibly end any output buffering going on. |
| 338 | - while (@ob_get_level() > 0) |
|
| 339 | - @ob_end_clean(); |
|
| 343 | + while (@ob_get_level() > 0) { |
|
| 344 | + @ob_end_clean(); |
|
| 345 | + } |
|
| 340 | 346 | |
| 341 | 347 | $fp = fopen($file['filePath'], 'rb'); |
| 342 | 348 | while (!feof($fp)) |
@@ -348,8 +354,9 @@ discard block |
||
| 348 | 354 | } |
| 349 | 355 | |
| 350 | 356 | // On some of the less-bright hosts, readfile() is disabled. It's just a faster, more byte safe, version of what's in the if. |
| 351 | - elseif (@readfile($file['filePath']) === null) |
|
| 352 | - echo file_get_contents($file['filePath']); |
|
| 357 | + elseif (@readfile($file['filePath']) === null) { |
|
| 358 | + echo file_get_contents($file['filePath']); |
|
| 359 | + } |
|
| 353 | 360 | |
| 354 | 361 | die(); |
| 355 | 362 | } |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 3 |
| 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 | * This is the main function for the languages area. |
@@ -153,11 +154,11 @@ discard block |
||
| 153 | 154 | $language_list = new xmlArray(fetch_web_data($url), true); |
| 154 | 155 | |
| 155 | 156 | // Check that the site responded and that the language exists. |
| 156 | - if (!$language_list->exists('languages')) |
|
| 157 | - $context['smf_error'] = 'no_response'; |
|
| 158 | - elseif (!$language_list->exists('languages/language')) |
|
| 159 | - $context['smf_error'] = 'no_files'; |
|
| 160 | - else |
|
| 157 | + if (!$language_list->exists('languages')) { |
|
| 158 | + $context['smf_error'] = 'no_response'; |
|
| 159 | + } elseif (!$language_list->exists('languages/language')) { |
|
| 160 | + $context['smf_error'] = 'no_files'; |
|
| 161 | + } else |
|
| 161 | 162 | { |
| 162 | 163 | $language_list = $language_list->path('languages[0]'); |
| 163 | 164 | $lang_files = $language_list->set('language'); |
@@ -165,8 +166,9 @@ discard block |
||
| 165 | 166 | foreach ($lang_files as $file) |
| 166 | 167 | { |
| 167 | 168 | // Were we searching? |
| 168 | - if (!empty($context['smf_search_term']) && strpos($file->fetch('name'), $smcFunc['strtolower']($context['smf_search_term'])) === false) |
|
| 169 | - continue; |
|
| 169 | + if (!empty($context['smf_search_term']) && strpos($file->fetch('name'), $smcFunc['strtolower']($context['smf_search_term'])) === false) { |
|
| 170 | + continue; |
|
| 171 | + } |
|
| 170 | 172 | |
| 171 | 173 | $smf_languages[] = array( |
| 172 | 174 | 'id' => $file->fetch('id'), |
@@ -177,10 +179,11 @@ discard block |
||
| 177 | 179 | 'install_link' => '<a href="' . $scripturl . '?action=admin;area=languages;sa=downloadlang;did=' . $file->fetch('id') . ';' . $context['session_var'] . '=' . $context['session_id'] . '">' . $txt['add_language_smf_install'] . '</a>', |
| 178 | 180 | ); |
| 179 | 181 | } |
| 180 | - if (empty($smf_languages)) |
|
| 181 | - $context['smf_error'] = 'no_files'; |
|
| 182 | - else |
|
| 183 | - return $smf_languages; |
|
| 182 | + if (empty($smf_languages)) { |
|
| 183 | + $context['smf_error'] = 'no_files'; |
|
| 184 | + } else { |
|
| 185 | + return $smf_languages; |
|
| 186 | + } |
|
| 184 | 187 | } |
| 185 | 188 | } |
| 186 | 189 | |
@@ -202,8 +205,9 @@ discard block |
||
| 202 | 205 | require_once($sourcedir . '/Subs-Package.php'); |
| 203 | 206 | |
| 204 | 207 | // Clearly we need to know what to request. |
| 205 | - if (!isset($_GET['did'])) |
|
| 206 | - fatal_lang_error('no_access', false); |
|
| 208 | + if (!isset($_GET['did'])) { |
|
| 209 | + fatal_lang_error('no_access', false); |
|
| 210 | + } |
|
| 207 | 211 | |
| 208 | 212 | // Some lovely context. |
| 209 | 213 | $context['download_id'] = $_GET['did']; |
@@ -223,8 +227,9 @@ discard block |
||
| 223 | 227 | foreach ($_POST['copy_file'] as $file) |
| 224 | 228 | { |
| 225 | 229 | // Check it's not very bad. |
| 226 | - if (strpos($file, '..') !== false || (strpos($file, 'Themes') !== 0 && !preg_match('~agreement\.[A-Za-z-_0-9]+\.txt$~', $file))) |
|
| 227 | - fatal_error($txt['languages_download_illegal_paths']); |
|
| 230 | + if (strpos($file, '..') !== false || (strpos($file, 'Themes') !== 0 && !preg_match('~agreement\.[A-Za-z-_0-9]+\.txt$~', $file))) { |
|
| 231 | + fatal_error($txt['languages_download_illegal_paths']); |
|
| 232 | + } |
|
| 228 | 233 | |
| 229 | 234 | $chmod_files[] = $boarddir . '/' . $file; |
| 230 | 235 | $install_files[] = $file; |
@@ -235,8 +240,9 @@ discard block |
||
| 235 | 240 | $files_left = $file_status['files']['notwritable']; |
| 236 | 241 | |
| 237 | 242 | // Something not writable? |
| 238 | - if (!empty($files_left)) |
|
| 239 | - $context['error_message'] = $txt['languages_download_not_chmod']; |
|
| 243 | + if (!empty($files_left)) { |
|
| 244 | + $context['error_message'] = $txt['languages_download_not_chmod']; |
|
| 245 | + } |
|
| 240 | 246 | // Otherwise, go go go! |
| 241 | 247 | elseif (!empty($install_files)) |
| 242 | 248 | { |
@@ -251,11 +257,13 @@ discard block |
||
| 251 | 257 | } |
| 252 | 258 | |
| 253 | 259 | // Open up the old china. |
| 254 | - if (!isset($archive_content)) |
|
| 255 | - $archive_content = read_tgz_file('https://download.simplemachines.org/fetch_language.php?version=' . urlencode(strtr($forum_version, array('SMF ' => ''))) . ';fetch=' . urlencode($_GET['did']), null); |
|
| 260 | + if (!isset($archive_content)) { |
|
| 261 | + $archive_content = read_tgz_file('https://download.simplemachines.org/fetch_language.php?version=' . urlencode(strtr($forum_version, array('SMF ' => ''))) . ';fetch=' . urlencode($_GET['did']), null); |
|
| 262 | + } |
|
| 256 | 263 | |
| 257 | - if (empty($archive_content)) |
|
| 258 | - fatal_error($txt['add_language_error_no_response']); |
|
| 264 | + if (empty($archive_content)) { |
|
| 265 | + fatal_error($txt['add_language_error_no_response']); |
|
| 266 | + } |
|
| 259 | 267 | |
| 260 | 268 | // Now for each of the files, let's do some *stuff* |
| 261 | 269 | $context['files'] = array( |
@@ -270,8 +278,9 @@ discard block |
||
| 270 | 278 | $extension = substr($filename, strrpos($filename, '.') + 1); |
| 271 | 279 | |
| 272 | 280 | // Don't do anything with files we don't understand. |
| 273 | - if (!in_array($extension, array('php', 'jpg', 'gif', 'jpeg', 'png', 'txt'))) |
|
| 274 | - continue; |
|
| 281 | + if (!in_array($extension, array('php', 'jpg', 'gif', 'jpeg', 'png', 'txt'))) { |
|
| 282 | + continue; |
|
| 283 | + } |
|
| 275 | 284 | |
| 276 | 285 | // Basic data. |
| 277 | 286 | $context_data = array( |
@@ -290,8 +299,9 @@ discard block |
||
| 290 | 299 | // Does the file exist, is it different and can we overwrite? |
| 291 | 300 | if (file_exists($boarddir . '/' . $file['filename'])) |
| 292 | 301 | { |
| 293 | - if (is_writable($boarddir . '/' . $file['filename'])) |
|
| 294 | - $context_data['writable'] = true; |
|
| 302 | + if (is_writable($boarddir . '/' . $file['filename'])) { |
|
| 303 | + $context_data['writable'] = true; |
|
| 304 | + } |
|
| 295 | 305 | |
| 296 | 306 | // Finally, do we actually think the content has changed? |
| 297 | 307 | if ($file['size'] == filesize($boarddir . '/' . $file['filename']) && $file['md5'] == md5_file($boarddir . '/' . $file['filename'])) |
@@ -304,16 +314,17 @@ discard block |
||
| 304 | 314 | { |
| 305 | 315 | $context_data['exists'] = 'same'; |
| 306 | 316 | $context_data['default_copy'] = false; |
| 317 | + } else { |
|
| 318 | + $context_data['exists'] = 'different'; |
|
| 307 | 319 | } |
| 308 | - else |
|
| 309 | - $context_data['exists'] = 'different'; |
|
| 310 | 320 | } |
| 311 | 321 | // No overwrite? |
| 312 | 322 | else |
| 313 | 323 | { |
| 314 | 324 | // Can we at least stick it in the directory... |
| 315 | - if (is_writable($boarddir . '/' . $dirname)) |
|
| 316 | - $context_data['writable'] = true; |
|
| 325 | + if (is_writable($boarddir . '/' . $dirname)) { |
|
| 326 | + $context_data['writable'] = true; |
|
| 327 | + } |
|
| 317 | 328 | } |
| 318 | 329 | |
| 319 | 330 | // I love PHP files, that's why I'm a developer and not an artistic type spending my time drinking absinth and living a life of sin... |
@@ -328,8 +339,9 @@ discard block |
||
| 328 | 339 | list ($name, $language) = explode('.', $filename); |
| 329 | 340 | |
| 330 | 341 | // Let's get the new version, I like versions, they tell me that I'm up to date. |
| 331 | - if (preg_match('~\s*Version:\s+(.+?);\s*' . preg_quote($name, '~') . '~i', $file['preview'], $match) == 1) |
|
| 332 | - $context_data['version'] = $match[1]; |
|
| 342 | + if (preg_match('~\s*Version:\s+(.+?);\s*' . preg_quote($name, '~') . '~i', $file['preview'], $match) == 1) { |
|
| 343 | + $context_data['version'] = $match[1]; |
|
| 344 | + } |
|
| 333 | 345 | |
| 334 | 346 | // Now does the old file exist - if so what is it's version? |
| 335 | 347 | if (file_exists($boarddir . '/' . $file['filename'])) |
@@ -345,34 +357,35 @@ discard block |
||
| 345 | 357 | $context_data['cur_version'] = $match[1]; |
| 346 | 358 | |
| 347 | 359 | // How does this compare? |
| 348 | - if ($context_data['cur_version'] == $context_data['version']) |
|
| 349 | - $context_data['version_compare'] = 'same'; |
|
| 350 | - elseif ($context_data['cur_version'] > $context_data['version']) |
|
| 351 | - $context_data['version_compare'] = 'older'; |
|
| 360 | + if ($context_data['cur_version'] == $context_data['version']) { |
|
| 361 | + $context_data['version_compare'] = 'same'; |
|
| 362 | + } elseif ($context_data['cur_version'] > $context_data['version']) { |
|
| 363 | + $context_data['version_compare'] = 'older'; |
|
| 364 | + } |
|
| 352 | 365 | |
| 353 | 366 | // Don't recommend copying if the version is the same. |
| 354 | - if ($context_data['version_compare'] != 'newer') |
|
| 355 | - $context_data['default_copy'] = false; |
|
| 367 | + if ($context_data['version_compare'] != 'newer') { |
|
| 368 | + $context_data['default_copy'] = false; |
|
| 369 | + } |
|
| 356 | 370 | } |
| 357 | 371 | } |
| 358 | 372 | |
| 359 | 373 | // Add the context data to the main set. |
| 360 | 374 | $context['files']['lang'][] = $context_data; |
| 361 | - } |
|
| 362 | - elseif ($extension == '.txt' && stripos($filename, 'agreement') !== false) |
|
| 375 | + } elseif ($extension == '.txt' && stripos($filename, 'agreement') !== false) |
|
| 363 | 376 | { |
| 364 | 377 | // Registration agreement is a primary file |
| 365 | 378 | $context['files']['lang'][] = $context_data; |
| 366 | - } |
|
| 367 | - else |
|
| 379 | + } else |
|
| 368 | 380 | { |
| 369 | 381 | // There shouldn't be anything else, but load this into "other" in case we decide to handle it in the future |
| 370 | 382 | $context['files']['other'][] = $context_data; |
| 371 | 383 | } |
| 372 | 384 | |
| 373 | 385 | // Collect together all non-writable areas. |
| 374 | - if (!$context_data['writable']) |
|
| 375 | - $context['make_writable'][] = $context_data['destination']; |
|
| 386 | + if (!$context_data['writable']) { |
|
| 387 | + $context['make_writable'][] = $context_data['destination']; |
|
| 388 | + } |
|
| 376 | 389 | } |
| 377 | 390 | |
| 378 | 391 | // Before we go to far can we make anything writable, eh, eh? |
@@ -387,22 +400,24 @@ discard block |
||
| 387 | 400 | { |
| 388 | 401 | if ($type == 'lang') |
| 389 | 402 | { |
| 390 | - foreach ($data as $k => $file) |
|
| 391 | - if (!$file['writable'] && !in_array($file['destination'], $context['still_not_writable'])) |
|
| 403 | + foreach ($data as $k => $file) { |
|
| 404 | + if (!$file['writable'] && !in_array($file['destination'], $context['still_not_writable'])) |
|
| 392 | 405 | $context['files'][$type][$k]['writable'] = true; |
| 393 | - } |
|
| 394 | - else |
|
| 406 | + } |
|
| 407 | + } else |
|
| 395 | 408 | { |
| 396 | - foreach ($data as $theme => $files) |
|
| 397 | - foreach ($files as $k => $file) |
|
| 409 | + foreach ($data as $theme => $files) { |
|
| 410 | + foreach ($files as $k => $file) |
|
| 398 | 411 | if (!$file['writable'] && !in_array($file['destination'], $context['still_not_writable'])) |
| 399 | 412 | $context['files'][$type][$theme][$k]['writable'] = true; |
| 413 | + } |
|
| 400 | 414 | } |
| 401 | 415 | } |
| 402 | 416 | |
| 403 | 417 | // Are we going to need more language stuff? |
| 404 | - if (!empty($context['still_not_writable'])) |
|
| 405 | - loadLanguage('Packages'); |
|
| 418 | + if (!empty($context['still_not_writable'])) { |
|
| 419 | + loadLanguage('Packages'); |
|
| 420 | + } |
|
| 406 | 421 | } |
| 407 | 422 | |
| 408 | 423 | // This is the list for the main files. |
@@ -615,12 +630,13 @@ discard block |
||
| 615 | 630 | highlightSelected("list_language_list_' . ($language == '' ? 'english' : $language) . '");', true); |
| 616 | 631 | |
| 617 | 632 | // Display a warning if we cannot edit the default setting. |
| 618 | - if (!is_writable($boarddir . '/Settings.php')) |
|
| 619 | - $listOptions['additional_rows'][] = array( |
|
| 633 | + if (!is_writable($boarddir . '/Settings.php')) { |
|
| 634 | + $listOptions['additional_rows'][] = array( |
|
| 620 | 635 | 'position' => 'after_title', |
| 621 | 636 | 'value' => $txt['language_settings_writable'], |
| 622 | 637 | 'class' => 'smalltext alert', |
| 623 | 638 | ); |
| 639 | + } |
|
| 624 | 640 | |
| 625 | 641 | require_once($sourcedir . '/Subs-List.php'); |
| 626 | 642 | createList($listOptions); |
@@ -662,10 +678,11 @@ discard block |
||
| 662 | 678 | |
| 663 | 679 | // Put them back. |
| 664 | 680 | $settings['actual_theme_dir'] = $backup_actual_theme_dir; |
| 665 | - if (!empty($backup_base_theme_dir)) |
|
| 666 | - $settings['base_theme_dir'] = $backup_base_theme_dir; |
|
| 667 | - else |
|
| 668 | - unset($settings['base_theme_dir']); |
|
| 681 | + if (!empty($backup_base_theme_dir)) { |
|
| 682 | + $settings['base_theme_dir'] = $backup_base_theme_dir; |
|
| 683 | + } else { |
|
| 684 | + unset($settings['base_theme_dir']); |
|
| 685 | + } |
|
| 669 | 686 | |
| 670 | 687 | // Get the language files and data... |
| 671 | 688 | foreach ($context['languages'] as $lang) |
@@ -694,13 +711,15 @@ discard block |
||
| 694 | 711 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 695 | 712 | { |
| 696 | 713 | // Default? |
| 697 | - if (empty($row['lngfile']) || !isset($languages[$row['lngfile']])) |
|
| 698 | - $row['lngfile'] = $language; |
|
| 714 | + if (empty($row['lngfile']) || !isset($languages[$row['lngfile']])) { |
|
| 715 | + $row['lngfile'] = $language; |
|
| 716 | + } |
|
| 699 | 717 | |
| 700 | - if (!isset($languages[$row['lngfile']]) && isset($languages['english'])) |
|
| 701 | - $languages['english']['count'] += $row['num_users']; |
|
| 702 | - elseif (isset($languages[$row['lngfile']])) |
|
| 703 | - $languages[$row['lngfile']]['count'] += $row['num_users']; |
|
| 718 | + if (!isset($languages[$row['lngfile']]) && isset($languages['english'])) { |
|
| 719 | + $languages['english']['count'] += $row['num_users']; |
|
| 720 | + } elseif (isset($languages[$row['lngfile']])) { |
|
| 721 | + $languages[$row['lngfile']]['count'] += $row['num_users']; |
|
| 722 | + } |
|
| 704 | 723 | } |
| 705 | 724 | $smcFunc['db_free_result']($request); |
| 706 | 725 | |
@@ -740,13 +759,15 @@ discard block |
||
| 740 | 759 | |
| 741 | 760 | call_integration_hook('integrate_language_settings', array(&$config_vars)); |
| 742 | 761 | |
| 743 | - if ($return_config) |
|
| 744 | - return $config_vars; |
|
| 762 | + if ($return_config) { |
|
| 763 | + return $config_vars; |
|
| 764 | + } |
|
| 745 | 765 | |
| 746 | 766 | // Get our languages. No cache |
| 747 | 767 | getLanguages(false); |
| 748 | - foreach ($context['languages'] as $lang) |
|
| 749 | - $config_vars['language'][4][$lang['filename']] = array($lang['filename'], $lang['name']); |
|
| 768 | + foreach ($context['languages'] as $lang) { |
|
| 769 | + $config_vars['language'][4][$lang['filename']] = array($lang['filename'], $lang['name']); |
|
| 770 | + } |
|
| 750 | 771 | |
| 751 | 772 | // Saving settings? |
| 752 | 773 | if (isset($_REQUEST['save'])) |
@@ -756,8 +777,9 @@ discard block |
||
| 756 | 777 | call_integration_hook('integrate_save_language_settings', array(&$config_vars)); |
| 757 | 778 | |
| 758 | 779 | saveSettings($config_vars); |
| 759 | - if (!$settings_not_writable && !$settings_backup_fail) |
|
| 760 | - $_SESSION['adm-save'] = true; |
|
| 780 | + if (!$settings_not_writable && !$settings_backup_fail) { |
|
| 781 | + $_SESSION['adm-save'] = true; |
|
| 782 | + } |
|
| 761 | 783 | redirectexit('action=admin;area=languages;sa=settings'); |
| 762 | 784 | } |
| 763 | 785 | |
@@ -766,10 +788,11 @@ discard block |
||
| 766 | 788 | $context['settings_title'] = $txt['language_settings']; |
| 767 | 789 | $context['save_disabled'] = $settings_not_writable; |
| 768 | 790 | |
| 769 | - if ($settings_not_writable) |
|
| 770 | - $context['settings_message'] = '<div class="centertext"><strong>' . $txt['settings_not_writable'] . '</strong></div><br>'; |
|
| 771 | - elseif ($settings_backup_fail) |
|
| 772 | - $context['settings_message'] = '<div class="centertext"><strong>' . $txt['admin_backup_fail'] . '</strong></div><br>'; |
|
| 791 | + if ($settings_not_writable) { |
|
| 792 | + $context['settings_message'] = '<div class="centertext"><strong>' . $txt['settings_not_writable'] . '</strong></div><br>'; |
|
| 793 | + } elseif ($settings_backup_fail) { |
|
| 794 | + $context['settings_message'] = '<div class="centertext"><strong>' . $txt['admin_backup_fail'] . '</strong></div><br>'; |
|
| 795 | + } |
|
| 773 | 796 | |
| 774 | 797 | // Fill the config array. |
| 775 | 798 | prepareServerSettingsContext($config_vars); |
@@ -816,8 +839,9 @@ discard block |
||
| 816 | 839 | 'theme_dir' => $settings['default_theme_dir'], |
| 817 | 840 | ), |
| 818 | 841 | ); |
| 819 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 820 | - $themes[$row['id_theme']][$row['variable']] = $row['value']; |
|
| 842 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 843 | + $themes[$row['id_theme']][$row['variable']] = $row['value']; |
|
| 844 | + } |
|
| 821 | 845 | $smcFunc['db_free_result']($request); |
| 822 | 846 | |
| 823 | 847 | // This will be where we look |
@@ -829,14 +853,16 @@ discard block |
||
| 829 | 853 | // Check we have themes with a path and a name - just in case - and add the path. |
| 830 | 854 | foreach ($themes as $id => $data) |
| 831 | 855 | { |
| 832 | - if (count($data) != 2) |
|
| 833 | - unset($themes[$id]); |
|
| 834 | - elseif (is_dir($data['theme_dir'] . '/languages')) |
|
| 835 | - $lang_dirs[$id] = $data['theme_dir'] . '/languages'; |
|
| 856 | + if (count($data) != 2) { |
|
| 857 | + unset($themes[$id]); |
|
| 858 | + } elseif (is_dir($data['theme_dir'] . '/languages')) { |
|
| 859 | + $lang_dirs[$id] = $data['theme_dir'] . '/languages'; |
|
| 860 | + } |
|
| 836 | 861 | |
| 837 | 862 | // How about image directories? |
| 838 | - if (is_dir($data['theme_dir'] . '/images/' . $context['lang_id'])) |
|
| 839 | - $images_dirs[$id] = $data['theme_dir'] . '/images/' . $context['lang_id']; |
|
| 863 | + if (is_dir($data['theme_dir'] . '/images/' . $context['lang_id'])) { |
|
| 864 | + $images_dirs[$id] = $data['theme_dir'] . '/images/' . $context['lang_id']; |
|
| 865 | + } |
|
| 840 | 866 | } |
| 841 | 867 | |
| 842 | 868 | $current_file = $file_id ? $lang_dirs[$theme_id] . '/' . $file_id . '.' . $context['lang_id'] . '.php' : ''; |
@@ -850,15 +876,17 @@ discard block |
||
| 850 | 876 | while ($entry = $dir->read()) |
| 851 | 877 | { |
| 852 | 878 | // We're only after the files for this language. |
| 853 | - if (preg_match('~^([A-Za-z]+)\.' . $context['lang_id'] . '\.php$~', $entry, $matches) == 0) |
|
| 854 | - continue; |
|
| 879 | + if (preg_match('~^([A-Za-z]+)\.' . $context['lang_id'] . '\.php$~', $entry, $matches) == 0) { |
|
| 880 | + continue; |
|
| 881 | + } |
|
| 855 | 882 | |
| 856 | - if (!isset($context['possible_files'][$theme])) |
|
| 857 | - $context['possible_files'][$theme] = array( |
|
| 883 | + if (!isset($context['possible_files'][$theme])) { |
|
| 884 | + $context['possible_files'][$theme] = array( |
|
| 858 | 885 | 'id' => $theme, |
| 859 | 886 | 'name' => $themes[$theme]['name'], |
| 860 | 887 | 'files' => array(), |
| 861 | 888 | ); |
| 889 | + } |
|
| 862 | 890 | |
| 863 | 891 | $context['possible_files'][$theme]['files'][] = array( |
| 864 | 892 | 'id' => $matches[1], |
@@ -887,31 +915,36 @@ discard block |
||
| 887 | 915 | { |
| 888 | 916 | $_SESSION['last_backup_for'] = $context['lang_id'] . '$$$'; |
| 889 | 917 | $result = package_create_backup('backup_lang_' . $context['lang_id']); |
| 890 | - if (!$result) |
|
| 891 | - fatal_lang_error('could_not_language_backup', false); |
|
| 918 | + if (!$result) { |
|
| 919 | + fatal_lang_error('could_not_language_backup', false); |
|
| 920 | + } |
|
| 892 | 921 | } |
| 893 | 922 | |
| 894 | 923 | // Second, loop through the array to remove the files. |
| 895 | 924 | foreach ($lang_dirs as $curPath) |
| 896 | 925 | { |
| 897 | - foreach ($context['possible_files'][1]['files'] as $lang) |
|
| 898 | - if (file_exists($curPath . '/' . $lang['id'] . '.' . $context['lang_id'] . '.php')) |
|
| 926 | + foreach ($context['possible_files'][1]['files'] as $lang) { |
|
| 927 | + if (file_exists($curPath . '/' . $lang['id'] . '.' . $context['lang_id'] . '.php')) |
|
| 899 | 928 | unlink($curPath . '/' . $lang['id'] . '.' . $context['lang_id'] . '.php'); |
| 929 | + } |
|
| 900 | 930 | |
| 901 | 931 | // Check for the email template. |
| 902 | - if (file_exists($curPath . '/EmailTemplates.' . $context['lang_id'] . '.php')) |
|
| 903 | - unlink($curPath . '/EmailTemplates.' . $context['lang_id'] . '.php'); |
|
| 932 | + if (file_exists($curPath . '/EmailTemplates.' . $context['lang_id'] . '.php')) { |
|
| 933 | + unlink($curPath . '/EmailTemplates.' . $context['lang_id'] . '.php'); |
|
| 934 | + } |
|
| 904 | 935 | } |
| 905 | 936 | |
| 906 | 937 | // Third, the agreement file. |
| 907 | - if (file_exists($boarddir . '/agreement.' . $context['lang_id'] . '.txt')) |
|
| 908 | - unlink($boarddir . '/agreement.' . $context['lang_id'] . '.txt'); |
|
| 938 | + if (file_exists($boarddir . '/agreement.' . $context['lang_id'] . '.txt')) { |
|
| 939 | + unlink($boarddir . '/agreement.' . $context['lang_id'] . '.txt'); |
|
| 940 | + } |
|
| 909 | 941 | |
| 910 | 942 | // Fourth, a related images folder, if it exists... |
| 911 | - if (!empty($images_dirs)) |
|
| 912 | - foreach ($images_dirs as $curPath) |
|
| 943 | + if (!empty($images_dirs)) { |
|
| 944 | + foreach ($images_dirs as $curPath) |
|
| 913 | 945 | if (is_dir($curPath)) |
| 914 | 946 | deltree($curPath); |
| 947 | + } |
|
| 915 | 948 | |
| 916 | 949 | // Members can no longer use this language. |
| 917 | 950 | $smcFunc['db_query']('', ' |
@@ -995,8 +1028,9 @@ discard block |
||
| 995 | 1028 | foreach ($_POST['entry'] as $k => $v) |
| 996 | 1029 | { |
| 997 | 1030 | // Only try to save if it's changed! |
| 998 | - if ($_POST['entry'][$k] != $_POST['comp'][$k]) |
|
| 999 | - $save_strings[$k] = cleanLangString($v, false); |
|
| 1031 | + if ($_POST['entry'][$k] != $_POST['comp'][$k]) { |
|
| 1032 | + $save_strings[$k] = cleanLangString($v, false); |
|
| 1033 | + } |
|
| 1000 | 1034 | } |
| 1001 | 1035 | } |
| 1002 | 1036 | |
@@ -1030,12 +1064,13 @@ discard block |
||
| 1030 | 1064 | if ($multiline_cache) |
| 1031 | 1065 | { |
| 1032 | 1066 | preg_match('~\$(helptxt|txt|editortxt)\[\'(.+)\'\]\s?=\s?(.+);~ms', strtr($multiline_cache, array("\r" => '')), $matches); |
| 1033 | - if (!empty($matches[3])) |
|
| 1034 | - $entries[$matches[2]] = array( |
|
| 1067 | + if (!empty($matches[3])) { |
|
| 1068 | + $entries[$matches[2]] = array( |
|
| 1035 | 1069 | 'type' => $matches[1], |
| 1036 | 1070 | 'full' => $matches[0], |
| 1037 | 1071 | 'entry' => $matches[3], |
| 1038 | 1072 | ); |
| 1073 | + } |
|
| 1039 | 1074 | } |
| 1040 | 1075 | |
| 1041 | 1076 | // These are the entries we can definitely save. |
@@ -1046,8 +1081,9 @@ discard block |
||
| 1046 | 1081 | { |
| 1047 | 1082 | // Ignore some things we set separately. |
| 1048 | 1083 | $ignore_files = array('lang_character_set', 'lang_locale', 'lang_dictionary', 'lang_spelling', 'lang_rtl'); |
| 1049 | - if (in_array($entryKey, $ignore_files)) |
|
| 1050 | - continue; |
|
| 1084 | + if (in_array($entryKey, $ignore_files)) { |
|
| 1085 | + continue; |
|
| 1086 | + } |
|
| 1051 | 1087 | |
| 1052 | 1088 | // These are arrays that need breaking out. |
| 1053 | 1089 | $arrays = array('days', 'days_short', 'months', 'months_titles', 'months_short', 'happy_birthday_author', 'karlbenson1_author', 'nite0859_author', 'zwaldowski_author', 'geezmo_author', 'karlbenson2_author'); |
@@ -1080,9 +1116,9 @@ discard block |
||
| 1080 | 1116 | { |
| 1081 | 1117 | $save_cache['entries'][$cur_index] = strtr($save_strings[$entryKey . '-+- ' . $cur_index], array('\'' => '')); |
| 1082 | 1118 | $save_cache['enabled'] = true; |
| 1119 | + } else { |
|
| 1120 | + $save_cache['entries'][$cur_index] = $subValue; |
|
| 1083 | 1121 | } |
| 1084 | - else |
|
| 1085 | - $save_cache['entries'][$cur_index] = $subValue; |
|
| 1086 | 1122 | |
| 1087 | 1123 | $context['file_entries'][] = array( |
| 1088 | 1124 | 'key' => $entryKey . '-+- ' . $cur_index, |
@@ -1105,9 +1141,9 @@ discard block |
||
| 1105 | 1141 | { |
| 1106 | 1142 | $items[] = $k2 . ' => \'' . $v2 . '\''; |
| 1107 | 1143 | $cur_index = $k2; |
| 1144 | + } else { |
|
| 1145 | + $items[] = '\'' . $v2 . '\''; |
|
| 1108 | 1146 | } |
| 1109 | - else |
|
| 1110 | - $items[] = '\'' . $v2 . '\''; |
|
| 1111 | 1147 | |
| 1112 | 1148 | $cur_index++; |
| 1113 | 1149 | } |
@@ -1117,15 +1153,15 @@ discard block |
||
| 1117 | 1153 | 'replace' => '$' . $entryValue['type'] . '[\'' . $entryKey . '\'] = array(' . implode(', ', $items) . ');', |
| 1118 | 1154 | ); |
| 1119 | 1155 | } |
| 1120 | - } |
|
| 1121 | - else |
|
| 1156 | + } else |
|
| 1122 | 1157 | { |
| 1123 | 1158 | // Saving? |
| 1124 | 1159 | if (isset($save_strings[$entryKey]) && $save_strings[$entryKey] != $entryValue['entry']) |
| 1125 | 1160 | { |
| 1126 | 1161 | // @todo Fix this properly. |
| 1127 | - if ($save_strings[$entryKey] == '') |
|
| 1128 | - $save_strings[$entryKey] = '\'\''; |
|
| 1162 | + if ($save_strings[$entryKey] == '') { |
|
| 1163 | + $save_strings[$entryKey] = '\'\''; |
|
| 1164 | + } |
|
| 1129 | 1165 | |
| 1130 | 1166 | // Set the new value. |
| 1131 | 1167 | $entryValue['entry'] = $save_strings[$entryKey]; |
@@ -1151,8 +1187,9 @@ discard block |
||
| 1151 | 1187 | checkSession(); |
| 1152 | 1188 | |
| 1153 | 1189 | $file_contents = implode('', file($current_file)); |
| 1154 | - foreach ($final_saves as $save) |
|
| 1155 | - $file_contents = strtr($file_contents, array($save['find'] => $save['replace'])); |
|
| 1190 | + foreach ($final_saves as $save) { |
|
| 1191 | + $file_contents = strtr($file_contents, array($save['find'] => $save['replace'])); |
|
| 1192 | + } |
|
| 1156 | 1193 | |
| 1157 | 1194 | // Save the actual changes. |
| 1158 | 1195 | $fp = fopen($current_file, 'w+'); |
@@ -1167,8 +1204,9 @@ discard block |
||
| 1167 | 1204 | } |
| 1168 | 1205 | |
| 1169 | 1206 | // If we saved, redirect. |
| 1170 | - if ($madeSave) |
|
| 1171 | - redirectexit('action=admin;area=languages;sa=editlang;lid=' . $context['lang_id']); |
|
| 1207 | + if ($madeSave) { |
|
| 1208 | + redirectexit('action=admin;area=languages;sa=editlang;lid=' . $context['lang_id']); |
|
| 1209 | + } |
|
| 1172 | 1210 | |
| 1173 | 1211 | createToken('admin-mlang'); |
| 1174 | 1212 | } |
@@ -1200,8 +1238,9 @@ discard block |
||
| 1200 | 1238 | // Toggle the escape. |
| 1201 | 1239 | $is_escape = !$is_escape; |
| 1202 | 1240 | // If we're now escaped don't add this string. |
| 1203 | - if ($is_escape) |
|
| 1204 | - continue; |
|
| 1241 | + if ($is_escape) { |
|
| 1242 | + continue; |
|
| 1243 | + } |
|
| 1205 | 1244 | } |
| 1206 | 1245 | // Special case - parsed string with line break etc? |
| 1207 | 1246 | elseif (($string{$i} == 'n' || $string{$i} == 't') && $in_string == 2 && $is_escape) |
@@ -1218,11 +1257,13 @@ discard block |
||
| 1218 | 1257 | if ($in_string != 2 && ($in_string != 1 || !$is_escape)) |
| 1219 | 1258 | { |
| 1220 | 1259 | // Is it the end of a single quote string? |
| 1221 | - if ($in_string == 1) |
|
| 1222 | - $in_string = 0; |
|
| 1260 | + if ($in_string == 1) { |
|
| 1261 | + $in_string = 0; |
|
| 1262 | + } |
|
| 1223 | 1263 | // Otherwise it's the start! |
| 1224 | - else |
|
| 1225 | - $in_string = 1; |
|
| 1264 | + else { |
|
| 1265 | + $in_string = 1; |
|
| 1266 | + } |
|
| 1226 | 1267 | |
| 1227 | 1268 | // Don't actually include this character! |
| 1228 | 1269 | continue; |
@@ -1235,19 +1276,22 @@ discard block |
||
| 1235 | 1276 | if ($in_string != 1 && ($in_string != 2 || !$is_escape)) |
| 1236 | 1277 | { |
| 1237 | 1278 | // Is it the end of a double quote string? |
| 1238 | - if ($in_string == 2) |
|
| 1239 | - $in_string = 0; |
|
| 1279 | + if ($in_string == 2) { |
|
| 1280 | + $in_string = 0; |
|
| 1281 | + } |
|
| 1240 | 1282 | // Otherwise it's the start! |
| 1241 | - else |
|
| 1242 | - $in_string = 2; |
|
| 1283 | + else { |
|
| 1284 | + $in_string = 2; |
|
| 1285 | + } |
|
| 1243 | 1286 | |
| 1244 | 1287 | // Don't actually include this character! |
| 1245 | 1288 | continue; |
| 1246 | 1289 | } |
| 1247 | 1290 | } |
| 1248 | 1291 | // A join/space outside of a string is simply removed. |
| 1249 | - elseif ($in_string == 0 && (empty($string{$i}) || $string{$i} == '.')) |
|
| 1250 | - continue; |
|
| 1292 | + elseif ($in_string == 0 && (empty($string{$i}) || $string{$i} == '.')) { |
|
| 1293 | + continue; |
|
| 1294 | + } |
|
| 1251 | 1295 | // Start of a variable? |
| 1252 | 1296 | elseif ($in_string == 0 && $string{$i} == '$') |
| 1253 | 1297 | { |
@@ -1281,8 +1325,7 @@ discard block |
||
| 1281 | 1325 | |
| 1282 | 1326 | // Unhtml then rehtml the whole thing! |
| 1283 | 1327 | $new_string = $smcFunc['htmlspecialchars'](un_htmlspecialchars($new_string)); |
| 1284 | - } |
|
| 1285 | - else |
|
| 1328 | + } else |
|
| 1286 | 1329 | { |
| 1287 | 1330 | // Keep track of what we're doing... |
| 1288 | 1331 | $in_string = 0; |
@@ -1311,10 +1354,11 @@ discard block |
||
| 1311 | 1354 | preg_match('~\{%([\$A-Za-z0-9\'\[\]_-]+)%\}~', substr($string, $i), $matches); |
| 1312 | 1355 | if (!empty($matches[1])) |
| 1313 | 1356 | { |
| 1314 | - if ($in_string == 1) |
|
| 1315 | - $new_string .= '\' . '; |
|
| 1316 | - elseif ($new_string) |
|
| 1317 | - $new_string .= ' . '; |
|
| 1357 | + if ($in_string == 1) { |
|
| 1358 | + $new_string .= '\' . '; |
|
| 1359 | + } elseif ($new_string) { |
|
| 1360 | + $new_string .= ' . '; |
|
| 1361 | + } |
|
| 1318 | 1362 | |
| 1319 | 1363 | $new_string .= $matches[1]; |
| 1320 | 1364 | $i += strlen($matches[1]) + 3; |
@@ -1327,8 +1371,9 @@ discard block |
||
| 1327 | 1371 | elseif ($string{$i} == '<') |
| 1328 | 1372 | { |
| 1329 | 1373 | // Probably HTML? |
| 1330 | - if ($string{$i + 1} != ' ') |
|
| 1331 | - $in_html = true; |
|
| 1374 | + if ($string{$i + 1} != ' ') { |
|
| 1375 | + $in_html = true; |
|
| 1376 | + } |
|
| 1332 | 1377 | // Assume we need an entity... |
| 1333 | 1378 | else |
| 1334 | 1379 | { |
@@ -1340,8 +1385,9 @@ discard block |
||
| 1340 | 1385 | elseif ($string{$i} == '>') |
| 1341 | 1386 | { |
| 1342 | 1387 | // Will it be HTML? |
| 1343 | - if ($in_html) |
|
| 1344 | - $in_html = false; |
|
| 1388 | + if ($in_html) { |
|
| 1389 | + $in_html = false; |
|
| 1390 | + } |
|
| 1345 | 1391 | // Otherwise we need an entity... |
| 1346 | 1392 | else |
| 1347 | 1393 | { |
@@ -1350,8 +1396,9 @@ discard block |
||
| 1350 | 1396 | } |
| 1351 | 1397 | } |
| 1352 | 1398 | // Is it a slash? If so escape it... |
| 1353 | - if ($string{$i} == '\\') |
|
| 1354 | - $new_string .= '\\'; |
|
| 1399 | + if ($string{$i} == '\\') { |
|
| 1400 | + $new_string .= '\\'; |
|
| 1401 | + } |
|
| 1355 | 1402 | // The infamous double quote? |
| 1356 | 1403 | elseif ($string{$i} == '"') |
| 1357 | 1404 | { |
@@ -1374,10 +1421,11 @@ discard block |
||
| 1374 | 1421 | } |
| 1375 | 1422 | |
| 1376 | 1423 | // If we ended as a string then close it off. |
| 1377 | - if ($in_string == 1) |
|
| 1378 | - $new_string .= '\''; |
|
| 1379 | - elseif ($in_string == 2) |
|
| 1380 | - $new_string .= '"'; |
|
| 1424 | + if ($in_string == 1) { |
|
| 1425 | + $new_string .= '\''; |
|
| 1426 | + } elseif ($in_string == 2) { |
|
| 1427 | + $new_string .= '"'; |
|
| 1428 | + } |
|
| 1381 | 1429 | } |
| 1382 | 1430 | |
| 1383 | 1431 | return $new_string; |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 3 |
| 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 admin handling function.<br> |
@@ -444,8 +445,9 @@ discard block |
||
| 444 | 445 | foreach ($admin_includes as $include) |
| 445 | 446 | { |
| 446 | 447 | $include = strtr(trim($include), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir'])); |
| 447 | - if (file_exists($include)) |
|
| 448 | - require_once($include); |
|
| 448 | + if (file_exists($include)) { |
|
| 449 | + require_once($include); |
|
| 450 | + } |
|
| 449 | 451 | } |
| 450 | 452 | } |
| 451 | 453 | |
@@ -457,24 +459,27 @@ discard block |
||
| 457 | 459 | unset($admin_areas); |
| 458 | 460 | |
| 459 | 461 | // Nothing valid? |
| 460 | - if ($admin_include_data == false) |
|
| 461 | - fatal_lang_error('no_access', false); |
|
| 462 | + if ($admin_include_data == false) { |
|
| 463 | + fatal_lang_error('no_access', false); |
|
| 464 | + } |
|
| 462 | 465 | |
| 463 | 466 | // Build the link tree. |
| 464 | 467 | $context['linktree'][] = array( |
| 465 | 468 | 'url' => $scripturl . '?action=admin', |
| 466 | 469 | 'name' => $txt['admin_center'], |
| 467 | 470 | ); |
| 468 | - if (isset($admin_include_data['current_area']) && $admin_include_data['current_area'] != 'index') |
|
| 469 | - $context['linktree'][] = array( |
|
| 471 | + if (isset($admin_include_data['current_area']) && $admin_include_data['current_area'] != 'index') { |
|
| 472 | + $context['linktree'][] = array( |
|
| 470 | 473 | 'url' => $scripturl . '?action=admin;area=' . $admin_include_data['current_area'] . ';' . $context['session_var'] . '=' . $context['session_id'], |
| 471 | 474 | 'name' => $admin_include_data['label'], |
| 472 | 475 | ); |
| 473 | - if (!empty($admin_include_data['current_subsection']) && $admin_include_data['subsections'][$admin_include_data['current_subsection']][0] != $admin_include_data['label']) |
|
| 474 | - $context['linktree'][] = array( |
|
| 476 | + } |
|
| 477 | + if (!empty($admin_include_data['current_subsection']) && $admin_include_data['subsections'][$admin_include_data['current_subsection']][0] != $admin_include_data['label']) { |
|
| 478 | + $context['linktree'][] = array( |
|
| 475 | 479 | 'url' => $scripturl . '?action=admin;area=' . $admin_include_data['current_area'] . ';sa=' . $admin_include_data['current_subsection'] . ';' . $context['session_var'] . '=' . $context['session_id'], |
| 476 | 480 | 'name' => $admin_include_data['subsections'][$admin_include_data['current_subsection']][0], |
| 477 | 481 | ); |
| 482 | + } |
|
| 478 | 483 | |
| 479 | 484 | // Make a note of the Unique ID for this menu. |
| 480 | 485 | $context['admin_menu_id'] = $context['max_menu_id']; |
@@ -484,16 +489,18 @@ discard block |
||
| 484 | 489 | $context['admin_area'] = $admin_include_data['current_area']; |
| 485 | 490 | |
| 486 | 491 | // Now - finally - call the right place! |
| 487 | - if (isset($admin_include_data['file'])) |
|
| 488 | - require_once($sourcedir . '/' . $admin_include_data['file']); |
|
| 492 | + if (isset($admin_include_data['file'])) { |
|
| 493 | + require_once($sourcedir . '/' . $admin_include_data['file']); |
|
| 494 | + } |
|
| 489 | 495 | |
| 490 | 496 | // Get the right callable. |
| 491 | 497 | $call = call_helper($admin_include_data['function'], true); |
| 492 | 498 | |
| 493 | 499 | // Is it valid? |
| 494 | - if (!empty($call)) |
|
| 495 | - call_user_func($call); |
|
| 496 | -} |
|
| 500 | + if (!empty($call)) { |
|
| 501 | + call_user_func($call); |
|
| 502 | + } |
|
| 503 | + } |
|
| 497 | 504 | |
| 498 | 505 | /** |
| 499 | 506 | * The main administration section. |
@@ -547,13 +554,14 @@ discard block |
||
| 547 | 554 | |
| 548 | 555 | $context['sub_template'] = $context['admin_area'] == 'credits' ? 'credits' : 'admin'; |
| 549 | 556 | $context['page_title'] = $context['admin_area'] == 'credits' ? $txt['support_credits_title'] : $txt['admin_center']; |
| 550 | - if ($context['admin_area'] != 'credits') |
|
| 551 | - $context[$context['admin_menu_name']]['tab_data'] = array( |
|
| 557 | + if ($context['admin_area'] != 'credits') { |
|
| 558 | + $context[$context['admin_menu_name']]['tab_data'] = array( |
|
| 552 | 559 | 'title' => $txt['admin_center'], |
| 553 | 560 | 'help' => '', |
| 554 | 561 | 'description' => '<strong>' . $txt['hello_guest'] . ' ' . $context['user']['name'] . '!</strong> |
| 555 | 562 | ' . sprintf($txt['admin_main_welcome'], $txt['admin_center'], $txt['help'], $txt['help']), |
| 556 | 563 | ); |
| 564 | + } |
|
| 557 | 565 | |
| 558 | 566 | // Lastly, fill in the blanks in the support resources paragraphs. |
| 559 | 567 | $txt['support_resources_p1'] = sprintf($txt['support_resources_p1'], |
@@ -571,9 +579,10 @@ discard block |
||
| 571 | 579 | 'https://www.simplemachines.org/redirect/customize_support' |
| 572 | 580 | ); |
| 573 | 581 | |
| 574 | - if ($context['admin_area'] == 'admin') |
|
| 575 | - loadJavaScriptFile('admin.js', array('defer' => false), 'smf_admin'); |
|
| 576 | -} |
|
| 582 | + if ($context['admin_area'] == 'admin') { |
|
| 583 | + loadJavaScriptFile('admin.js', array('defer' => false), 'smf_admin'); |
|
| 584 | + } |
|
| 585 | + } |
|
| 577 | 586 | |
| 578 | 587 | /** |
| 579 | 588 | * Get one of the admin information files from Simple Machines. |
@@ -584,8 +593,9 @@ discard block |
||
| 584 | 593 | |
| 585 | 594 | setMemoryLimit('32M'); |
| 586 | 595 | |
| 587 | - if (empty($_REQUEST['filename']) || !is_string($_REQUEST['filename'])) |
|
| 588 | - fatal_lang_error('no_access', false); |
|
| 596 | + if (empty($_REQUEST['filename']) || !is_string($_REQUEST['filename'])) { |
|
| 597 | + fatal_lang_error('no_access', false); |
|
| 598 | + } |
|
| 589 | 599 | |
| 590 | 600 | // Strip off the forum cache part or we won't find it... |
| 591 | 601 | $_REQUEST['filename'] = str_replace($modSettings['browser_cache'], '', $_REQUEST['filename']); |
@@ -600,27 +610,30 @@ discard block |
||
| 600 | 610 | ) |
| 601 | 611 | ); |
| 602 | 612 | |
| 603 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 604 | - fatal_lang_error('admin_file_not_found', true, array($_REQUEST['filename']), 404); |
|
| 613 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 614 | + fatal_lang_error('admin_file_not_found', true, array($_REQUEST['filename']), 404); |
|
| 615 | + } |
|
| 605 | 616 | |
| 606 | 617 | list ($file_data, $filetype) = $smcFunc['db_fetch_row']($request); |
| 607 | 618 | $smcFunc['db_free_result']($request); |
| 608 | 619 | |
| 609 | 620 | // @todo Temp |
| 610 | 621 | // Figure out if sesc is still being used. |
| 611 | - if (strpos($file_data, ';sesc=') !== false && $filetype == 'text/javascript') |
|
| 612 | - $file_data = ' |
|
| 622 | + if (strpos($file_data, ';sesc=') !== false && $filetype == 'text/javascript') { |
|
| 623 | + $file_data = ' |
|
| 613 | 624 | if (!(\'smfForum_sessionvar\' in window)) |
| 614 | 625 | window.smfForum_sessionvar = \'sesc\'; |
| 615 | 626 | ' . strtr($file_data, array(';sesc=' => ';\' + window.smfForum_sessionvar + \'=')); |
| 627 | + } |
|
| 616 | 628 | |
| 617 | 629 | $context['template_layers'] = array(); |
| 618 | 630 | // Lets make sure we aren't going to output anything nasty. |
| 619 | 631 | @ob_end_clean(); |
| 620 | - if (!empty($modSettings['enableCompressedOutput'])) |
|
| 621 | - @ob_start('ob_gzhandler'); |
|
| 622 | - else |
|
| 623 | - @ob_start(); |
|
| 632 | + if (!empty($modSettings['enableCompressedOutput'])) { |
|
| 633 | + @ob_start('ob_gzhandler'); |
|
| 634 | + } else { |
|
| 635 | + @ob_start(); |
|
| 636 | + } |
|
| 624 | 637 | |
| 625 | 638 | // Make sure they know what type of file we are. |
| 626 | 639 | header('Content-Type: ' . $filetype); |
@@ -660,11 +673,12 @@ discard block |
||
| 660 | 673 | updateAdminPreferences(); |
| 661 | 674 | } |
| 662 | 675 | |
| 663 | - if (trim($context['search_term']) == '') |
|
| 664 | - $context['search_results'] = array(); |
|
| 665 | - else |
|
| 666 | - call_helper($subActions[$context['search_type']]); |
|
| 667 | -} |
|
| 676 | + if (trim($context['search_term']) == '') { |
|
| 677 | + $context['search_results'] = array(); |
|
| 678 | + } else { |
|
| 679 | + call_helper($subActions[$context['search_type']]); |
|
| 680 | + } |
|
| 681 | + } |
|
| 668 | 682 | |
| 669 | 683 | /** |
| 670 | 684 | * A complicated but relatively quick internal search. |
@@ -728,8 +742,9 @@ discard block |
||
| 728 | 742 | |
| 729 | 743 | loadLanguage(implode('+', $language_files)); |
| 730 | 744 | |
| 731 | - foreach ($include_files as $file) |
|
| 732 | - require_once($sourcedir . '/' . $file . '.php'); |
|
| 745 | + foreach ($include_files as $file) { |
|
| 746 | + require_once($sourcedir . '/' . $file . '.php'); |
|
| 747 | + } |
|
| 733 | 748 | |
| 734 | 749 | /* This is the huge array that defines everything... it's a huge array of items formatted as follows: |
| 735 | 750 | 0 = Language index (Can be array of indexes) to search through for this setting. |
@@ -753,11 +768,12 @@ discard block |
||
| 753 | 768 | foreach ($section['areas'] as $menu_key => $menu_item) |
| 754 | 769 | { |
| 755 | 770 | $search_data['sections'][] = array($menu_item['label'], 'area=' . $menu_key); |
| 756 | - if (!empty($menu_item['subsections'])) |
|
| 757 | - foreach ($menu_item['subsections'] as $key => $sublabel) |
|
| 771 | + if (!empty($menu_item['subsections'])) { |
|
| 772 | + foreach ($menu_item['subsections'] as $key => $sublabel) |
|
| 758 | 773 | { |
| 759 | 774 | if (isset($sublabel['label'])) |
| 760 | 775 | $search_data['sections'][] = array($sublabel['label'], 'area=' . $menu_key . ';sa=' . $key); |
| 776 | + } |
|
| 761 | 777 | } |
| 762 | 778 | } |
| 763 | 779 | } |
@@ -767,9 +783,10 @@ discard block |
||
| 767 | 783 | // Get a list of their variables. |
| 768 | 784 | $config_vars = $setting_area[0](true); |
| 769 | 785 | |
| 770 | - foreach ($config_vars as $var) |
|
| 771 | - if (!empty($var[1]) && !in_array($var[0], array('permissions', 'switch', 'desc'))) |
|
| 786 | + foreach ($config_vars as $var) { |
|
| 787 | + if (!empty($var[1]) && !in_array($var[0], array('permissions', 'switch', 'desc'))) |
|
| 772 | 788 | $search_data['settings'][] = array($var[(isset($var[2]) && in_array($var[2], array('file', 'db'))) ? 0 : 1], $setting_area[1]); |
| 789 | + } |
|
| 773 | 790 | } |
| 774 | 791 | |
| 775 | 792 | $context['page_title'] = $txt['admin_search_results']; |
@@ -782,8 +799,9 @@ discard block |
||
| 782 | 799 | foreach ($data as $item) |
| 783 | 800 | { |
| 784 | 801 | $found = false; |
| 785 | - if (!is_array($item[0])) |
|
| 786 | - $item[0] = array($item[0]); |
|
| 802 | + if (!is_array($item[0])) { |
|
| 803 | + $item[0] = array($item[0]); |
|
| 804 | + } |
|
| 787 | 805 | foreach ($item[0] as $term) |
| 788 | 806 | { |
| 789 | 807 | if (stripos($term, $search_term) !== false || (isset($txt[$term]) && stripos($txt[$term], $search_term) !== false) || (isset($txt['setting_' . $term]) && stripos($txt['setting_' . $term], $search_term) !== false)) |
@@ -841,8 +859,9 @@ discard block |
||
| 841 | 859 | $postVars = explode(' ', $context['search_term']); |
| 842 | 860 | |
| 843 | 861 | // Encode the search data. |
| 844 | - foreach ($postVars as $k => $v) |
|
| 845 | - $postVars[$k] = urlencode($v); |
|
| 862 | + foreach ($postVars as $k => $v) { |
|
| 863 | + $postVars[$k] = urlencode($v); |
|
| 864 | + } |
|
| 846 | 865 | |
| 847 | 866 | // This is what we will send. |
| 848 | 867 | $postVars = implode('+', $postVars); |
@@ -854,8 +873,9 @@ discard block |
||
| 854 | 873 | $search_results = fetch_web_data($context['doc_apiurl'] . '?action=query&list=search&srprop=timestamp|snippet&format=xml&srwhat=text&srsearch=' . $postVars); |
| 855 | 874 | |
| 856 | 875 | // If we didn't get any xml back we are in trouble - perhaps the doc site is overloaded? |
| 857 | - if (!$search_results || preg_match('~<' . '\?xml\sversion="\d+\.\d+"\?' . '>\s*(<api>.+?</api>)~is', $search_results, $matches) != true) |
|
| 858 | - fatal_lang_error('cannot_connect_doc_site'); |
|
| 876 | + if (!$search_results || preg_match('~<' . '\?xml\sversion="\d+\.\d+"\?' . '>\s*(<api>.+?</api>)~is', $search_results, $matches) != true) { |
|
| 877 | + fatal_lang_error('cannot_connect_doc_site'); |
|
| 878 | + } |
|
| 859 | 879 | |
| 860 | 880 | $search_results = $matches[1]; |
| 861 | 881 | |
@@ -867,8 +887,9 @@ discard block |
||
| 867 | 887 | $results = new xmlArray($search_results, false); |
| 868 | 888 | |
| 869 | 889 | // Move through the api layer. |
| 870 | - if (!$results->exists('api')) |
|
| 871 | - fatal_lang_error('cannot_connect_doc_site'); |
|
| 890 | + if (!$results->exists('api')) { |
|
| 891 | + fatal_lang_error('cannot_connect_doc_site'); |
|
| 892 | + } |
|
| 872 | 893 | |
| 873 | 894 | // Are there actually some results? |
| 874 | 895 | if ($results->exists('api/query/search/p')) |
@@ -904,8 +925,9 @@ discard block |
||
| 904 | 925 | ); |
| 905 | 926 | |
| 906 | 927 | // If it's not got a sa set it must have come here for first time, pretend error log should be reversed. |
| 907 | - if (!isset($_REQUEST['sa'])) |
|
| 908 | - $_REQUEST['desc'] = true; |
|
| 928 | + if (!isset($_REQUEST['sa'])) { |
|
| 929 | + $_REQUEST['desc'] = true; |
|
| 930 | + } |
|
| 909 | 931 | |
| 910 | 932 | // Setup some tab stuff. |
| 911 | 933 | $context[$context['admin_menu_name']]['tab_data'] = array( |
@@ -955,9 +977,10 @@ discard block |
||
| 955 | 977 | unset($_SESSION['admin_time']); |
| 956 | 978 | |
| 957 | 979 | // Clean any admin tokens as well. |
| 958 | - foreach ($_SESSION['token'] as $key => $token) |
|
| 959 | - if (strpos($key, '-admin') !== false) |
|
| 980 | + foreach ($_SESSION['token'] as $key => $token) { |
|
| 981 | + if (strpos($key, '-admin') !== false) |
|
| 960 | 982 | unset($_SESSION['token'][$key]); |
| 983 | + } |
|
| 961 | 984 | |
| 962 | 985 | redirectexit(); |
| 963 | 986 | } |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 3 |
| 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 | * Browse the list of package servers, add servers... |
@@ -43,13 +44,15 @@ discard block |
||
| 43 | 44 | ); |
| 44 | 45 | |
| 45 | 46 | // Now let's decide where we are taking this... |
| 46 | - if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']])) |
|
| 47 | - $context['sub_action'] = $_REQUEST['sa']; |
|
| 47 | + if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']])) { |
|
| 48 | + $context['sub_action'] = $_REQUEST['sa']; |
|
| 49 | + } |
|
| 48 | 50 | // We need to support possible old javascript links... |
| 49 | - elseif (isset($_GET['pgdownload'])) |
|
| 50 | - $context['sub_action'] = 'download'; |
|
| 51 | - else |
|
| 52 | - $context['sub_action'] = 'servers'; |
|
| 51 | + elseif (isset($_GET['pgdownload'])) { |
|
| 52 | + $context['sub_action'] = 'download'; |
|
| 53 | + } else { |
|
| 54 | + $context['sub_action'] = 'servers'; |
|
| 55 | + } |
|
| 53 | 56 | |
| 54 | 57 | // We need to force the "Download" tab as selected. |
| 55 | 58 | $context['menu_data_' . $context['admin_menu_id']]['current_subsection'] = 'packageget'; |
@@ -141,17 +144,19 @@ discard block |
||
| 141 | 144 | { |
| 142 | 145 | require_once($sourcedir . '/Class-Package.php'); |
| 143 | 146 | $ftp = new ftp_connection(null); |
| 147 | + } elseif ($ftp->error !== false && !isset($ftp_error)) { |
|
| 148 | + $ftp_error = $ftp->last_message === null ? '' : $ftp->last_message; |
|
| 144 | 149 | } |
| 145 | - elseif ($ftp->error !== false && !isset($ftp_error)) |
|
| 146 | - $ftp_error = $ftp->last_message === null ? '' : $ftp->last_message; |
|
| 147 | 150 | |
| 148 | 151 | list ($username, $detect_path, $found_path) = $ftp->detect_path($packagesdir); |
| 149 | 152 | |
| 150 | - if ($found_path || !isset($_POST['ftp_path'])) |
|
| 151 | - $_POST['ftp_path'] = $detect_path; |
|
| 153 | + if ($found_path || !isset($_POST['ftp_path'])) { |
|
| 154 | + $_POST['ftp_path'] = $detect_path; |
|
| 155 | + } |
|
| 152 | 156 | |
| 153 | - if (!isset($_POST['ftp_username'])) |
|
| 154 | - $_POST['ftp_username'] = $username; |
|
| 157 | + if (!isset($_POST['ftp_username'])) { |
|
| 158 | + $_POST['ftp_username'] = $username; |
|
| 159 | + } |
|
| 155 | 160 | |
| 156 | 161 | $context['package_ftp'] = array( |
| 157 | 162 | 'server' => isset($_POST['ftp_server']) ? $_POST['ftp_server'] : (isset($modSettings['package_server']) ? $modSettings['package_server'] : 'localhost'), |
@@ -160,8 +165,7 @@ discard block |
||
| 160 | 165 | 'path' => $_POST['ftp_path'], |
| 161 | 166 | 'error' => empty($ftp_error) ? null : $ftp_error, |
| 162 | 167 | ); |
| 163 | - } |
|
| 164 | - else |
|
| 168 | + } else |
|
| 165 | 169 | { |
| 166 | 170 | $context['package_download_broken'] = false; |
| 167 | 171 | |
@@ -203,8 +207,9 @@ discard block |
||
| 203 | 207 | |
| 204 | 208 | if (isset($_GET['server'])) |
| 205 | 209 | { |
| 206 | - if ($_GET['server'] == '') |
|
| 207 | - redirectexit('action=admin;area=packages;get'); |
|
| 210 | + if ($_GET['server'] == '') { |
|
| 211 | + redirectexit('action=admin;area=packages;get'); |
|
| 212 | + } |
|
| 208 | 213 | |
| 209 | 214 | $server = (int) $_GET['server']; |
| 210 | 215 | |
@@ -222,17 +227,18 @@ discard block |
||
| 222 | 227 | $smcFunc['db_free_result']($request); |
| 223 | 228 | |
| 224 | 229 | // If the server does not exist, dump out. |
| 225 | - if (empty($url)) |
|
| 226 | - fatal_lang_error('couldnt_connect', false); |
|
| 230 | + if (empty($url)) { |
|
| 231 | + fatal_lang_error('couldnt_connect', false); |
|
| 232 | + } |
|
| 227 | 233 | |
| 228 | 234 | // If there is a relative link, append to the stored server url. |
| 229 | - if (isset($_GET['relative'])) |
|
| 230 | - $url = $url . (substr($url, -1) == '/' ? '' : '/') . $_GET['relative']; |
|
| 235 | + if (isset($_GET['relative'])) { |
|
| 236 | + $url = $url . (substr($url, -1) == '/' ? '' : '/') . $_GET['relative']; |
|
| 237 | + } |
|
| 231 | 238 | |
| 232 | 239 | // Clear any "absolute" URL. Since "server" is present, "absolute" is garbage. |
| 233 | 240 | unset($_GET['absolute']); |
| 234 | - } |
|
| 235 | - elseif (isset($_GET['absolute']) && $_GET['absolute'] != '') |
|
| 241 | + } elseif (isset($_GET['absolute']) && $_GET['absolute'] != '') |
|
| 236 | 242 | { |
| 237 | 243 | // Initialize the requried variables. |
| 238 | 244 | $server = ''; |
@@ -256,16 +262,19 @@ discard block |
||
| 256 | 262 | } |
| 257 | 263 | } |
| 258 | 264 | // Minimum required parameter did not exist so dump out. |
| 259 | - else |
|
| 260 | - fatal_lang_error('couldnt_connect', false); |
|
| 265 | + else { |
|
| 266 | + fatal_lang_error('couldnt_connect', false); |
|
| 267 | + } |
|
| 261 | 268 | |
| 262 | 269 | // Attempt to connect. If unsuccessful... try the URL. |
| 263 | - if (!isset($_GET['package']) || file_exists($_GET['package'])) |
|
| 264 | - $_GET['package'] = $url . '/packages.xml?language=' . $context['user']['language']; |
|
| 270 | + if (!isset($_GET['package']) || file_exists($_GET['package'])) { |
|
| 271 | + $_GET['package'] = $url . '/packages.xml?language=' . $context['user']['language']; |
|
| 272 | + } |
|
| 265 | 273 | |
| 266 | 274 | // Check to be sure the packages.xml file actually exists where it is should be... or dump out. |
| 267 | - if ((isset($_GET['absolute']) || isset($_GET['relative'])) && !url_exists($_GET['package'])) |
|
| 268 | - fatal_lang_error('packageget_unable', false, array($url . '/index.php')); |
|
| 275 | + if ((isset($_GET['absolute']) || isset($_GET['relative'])) && !url_exists($_GET['package'])) { |
|
| 276 | + fatal_lang_error('packageget_unable', false, array($url . '/index.php')); |
|
| 277 | + } |
|
| 269 | 278 | |
| 270 | 279 | // Might take some time. |
| 271 | 280 | @set_time_limit(600); |
@@ -275,8 +284,9 @@ discard block |
||
| 275 | 284 | $listing = new xmlArray(fetch_web_data($_GET['package']), true); |
| 276 | 285 | |
| 277 | 286 | // Errm.... empty file? Try the URL.... |
| 278 | - if (!$listing->exists('package-list')) |
|
| 279 | - fatal_lang_error('packageget_unable', false, array($url . '/index.php')); |
|
| 287 | + if (!$listing->exists('package-list')) { |
|
| 288 | + fatal_lang_error('packageget_unable', false, array($url . '/index.php')); |
|
| 289 | + } |
|
| 280 | 290 | |
| 281 | 291 | // List out the packages... |
| 282 | 292 | $context['package_list'] = array(); |
@@ -284,8 +294,9 @@ discard block |
||
| 284 | 294 | $listing = $listing->path('package-list[0]'); |
| 285 | 295 | |
| 286 | 296 | // Use the package list's name if it exists. |
| 287 | - if ($listing->exists('list-title')) |
|
| 288 | - $name = $smcFunc['htmlspecialchars']($listing->fetch('list-title')); |
|
| 297 | + if ($listing->exists('list-title')) { |
|
| 298 | + $name = $smcFunc['htmlspecialchars']($listing->fetch('list-title')); |
|
| 299 | + } |
|
| 289 | 300 | |
| 290 | 301 | // Pick the correct template. |
| 291 | 302 | $context['sub_template'] = 'package_list'; |
@@ -300,28 +311,32 @@ discard block |
||
| 300 | 311 | |
| 301 | 312 | $installed_mods = array(); |
| 302 | 313 | // Look through the list of installed mods... |
| 303 | - foreach ($instmods as $installed_mod) |
|
| 304 | - $installed_mods[$installed_mod['package_id']] = $installed_mod['version']; |
|
| 314 | + foreach ($instmods as $installed_mod) { |
|
| 315 | + $installed_mods[$installed_mod['package_id']] = $installed_mod['version']; |
|
| 316 | + } |
|
| 305 | 317 | |
| 306 | 318 | // Get default author and email if they exist. |
| 307 | 319 | if ($listing->exists('default-author')) |
| 308 | 320 | { |
| 309 | 321 | $default_author = $smcFunc['htmlspecialchars']($listing->fetch('default-author')); |
| 310 | - if ($listing->exists('default-author/@email') && filter_var($listing->fetch('default-author/@email'), FILTER_VALIDATE_EMAIL)) |
|
| 311 | - $default_email = $smcFunc['htmlspecialchars']($listing->fetch('default-author/@email')); |
|
| 322 | + if ($listing->exists('default-author/@email') && filter_var($listing->fetch('default-author/@email'), FILTER_VALIDATE_EMAIL)) { |
|
| 323 | + $default_email = $smcFunc['htmlspecialchars']($listing->fetch('default-author/@email')); |
|
| 324 | + } |
|
| 312 | 325 | } |
| 313 | 326 | |
| 314 | 327 | // Get default web site if it exists. |
| 315 | 328 | if ($listing->exists('default-website')) |
| 316 | 329 | { |
| 317 | 330 | $default_website = $smcFunc['htmlspecialchars']($listing->fetch('default-website')); |
| 318 | - if ($listing->exists('default-website/@title')) |
|
| 319 | - $default_title = $smcFunc['htmlspecialchars']($listing->fetch('default-website/@title')); |
|
| 331 | + if ($listing->exists('default-website/@title')) { |
|
| 332 | + $default_title = $smcFunc['htmlspecialchars']($listing->fetch('default-website/@title')); |
|
| 333 | + } |
|
| 320 | 334 | } |
| 321 | 335 | |
| 322 | 336 | $the_version = strtr($forum_version, array('SMF ' => '')); |
| 323 | - if (!empty($_SESSION['version_emulate'])) |
|
| 324 | - $the_version = $_SESSION['version_emulate']; |
|
| 337 | + if (!empty($_SESSION['version_emulate'])) { |
|
| 338 | + $the_version = $_SESSION['version_emulate']; |
|
| 339 | + } |
|
| 325 | 340 | |
| 326 | 341 | $packageNum = 0; |
| 327 | 342 | $packageSection = 0; |
@@ -342,11 +357,13 @@ discard block |
||
| 342 | 357 | 'type' => $thisPackage->name(), |
| 343 | 358 | ); |
| 344 | 359 | |
| 345 | - if (in_array($package['type'], array('title', 'text'))) |
|
| 346 | - $context['package_list'][$packageSection][$package['type']] = $smcFunc['htmlspecialchars']($thisPackage->fetch('.')); |
|
| 360 | + if (in_array($package['type'], array('title', 'text'))) { |
|
| 361 | + $context['package_list'][$packageSection][$package['type']] = $smcFunc['htmlspecialchars']($thisPackage->fetch('.')); |
|
| 362 | + } |
|
| 347 | 363 | // It's a Title, Heading, Rule or Text. |
| 348 | - elseif (in_array($package['type'], array('heading', 'rule'))) |
|
| 349 | - $package['name'] = $smcFunc['htmlspecialchars']($thisPackage->fetch('.')); |
|
| 364 | + elseif (in_array($package['type'], array('heading', 'rule'))) { |
|
| 365 | + $package['name'] = $smcFunc['htmlspecialchars']($thisPackage->fetch('.')); |
|
| 366 | + } |
|
| 350 | 367 | // It's a Remote link. |
| 351 | 368 | elseif ($package['type'] == 'remote') |
| 352 | 369 | { |
@@ -354,20 +371,21 @@ discard block |
||
| 354 | 371 | |
| 355 | 372 | if ($remote_type == 'relative' && substr($thisPackage->fetch('@href'), 0, 7) != 'http://' && substr($thisPackage->fetch('@href'), 0, 8) != 'https://') |
| 356 | 373 | { |
| 357 | - if (isset($_GET['absolute'])) |
|
| 358 | - $current_url = $_GET['absolute'] . '/'; |
|
| 359 | - elseif (isset($_GET['relative'])) |
|
| 360 | - $current_url = $_GET['relative'] . '/'; |
|
| 361 | - else |
|
| 362 | - $current_url = ''; |
|
| 374 | + if (isset($_GET['absolute'])) { |
|
| 375 | + $current_url = $_GET['absolute'] . '/'; |
|
| 376 | + } elseif (isset($_GET['relative'])) { |
|
| 377 | + $current_url = $_GET['relative'] . '/'; |
|
| 378 | + } else { |
|
| 379 | + $current_url = ''; |
|
| 380 | + } |
|
| 363 | 381 | |
| 364 | 382 | $current_url .= $thisPackage->fetch('@href'); |
| 365 | - if (isset($_GET['absolute'])) |
|
| 366 | - $package['href'] = $scripturl . '?action=admin;area=packages;get;sa=browse;absolute=' . $current_url; |
|
| 367 | - else |
|
| 368 | - $package['href'] = $scripturl . '?action=admin;area=packages;get;sa=browse;server=' . $context['package_server'] . ';relative=' . $current_url; |
|
| 369 | - } |
|
| 370 | - else |
|
| 383 | + if (isset($_GET['absolute'])) { |
|
| 384 | + $package['href'] = $scripturl . '?action=admin;area=packages;get;sa=browse;absolute=' . $current_url; |
|
| 385 | + } else { |
|
| 386 | + $package['href'] = $scripturl . '?action=admin;area=packages;get;sa=browse;server=' . $context['package_server'] . ';relative=' . $current_url; |
|
| 387 | + } |
|
| 388 | + } else |
|
| 371 | 389 | { |
| 372 | 390 | $current_url = $thisPackage->fetch('@href'); |
| 373 | 391 | $package['href'] = $scripturl . '?action=admin;area=packages;get;sa=browse;absolute=' . $current_url; |
@@ -379,25 +397,28 @@ discard block |
||
| 379 | 397 | // It's a package... |
| 380 | 398 | else |
| 381 | 399 | { |
| 382 | - if (isset($_GET['absolute'])) |
|
| 383 | - $current_url = $_GET['absolute'] . '/'; |
|
| 384 | - elseif (isset($_GET['relative'])) |
|
| 385 | - $current_url = $_GET['relative'] . '/'; |
|
| 386 | - else |
|
| 387 | - $current_url = ''; |
|
| 400 | + if (isset($_GET['absolute'])) { |
|
| 401 | + $current_url = $_GET['absolute'] . '/'; |
|
| 402 | + } elseif (isset($_GET['relative'])) { |
|
| 403 | + $current_url = $_GET['relative'] . '/'; |
|
| 404 | + } else { |
|
| 405 | + $current_url = ''; |
|
| 406 | + } |
|
| 388 | 407 | |
| 389 | 408 | $server_att = $server != '' ? ';server=' . $server : ''; |
| 390 | 409 | |
| 391 | 410 | $package += $thisPackage->to_array(); |
| 392 | 411 | |
| 393 | - if (isset($package['website'])) |
|
| 394 | - unset($package['website']); |
|
| 412 | + if (isset($package['website'])) { |
|
| 413 | + unset($package['website']); |
|
| 414 | + } |
|
| 395 | 415 | $package['author'] = array(); |
| 396 | 416 | |
| 397 | - if ($package['description'] == '') |
|
| 398 | - $package['description'] = $txt['package_no_description']; |
|
| 399 | - else |
|
| 400 | - $package['description'] = parse_bbc(preg_replace('~\[[/]?html\]~i', '', $smcFunc['htmlspecialchars']($package['description']))); |
|
| 417 | + if ($package['description'] == '') { |
|
| 418 | + $package['description'] = $txt['package_no_description']; |
|
| 419 | + } else { |
|
| 420 | + $package['description'] = parse_bbc(preg_replace('~\[[/]?html\]~i', '', $smcFunc['htmlspecialchars']($package['description']))); |
|
| 421 | + } |
|
| 401 | 422 | |
| 402 | 423 | $package['is_installed'] = isset($installed_mods[$package['id']]); |
| 403 | 424 | $package['is_current'] = $package['is_installed'] && ($installed_mods[$package['id']] == $package['version']); |
@@ -406,12 +427,14 @@ discard block |
||
| 406 | 427 | // This package is either not installed, or installed but old. Is it supported on this version of SMF? |
| 407 | 428 | if (!$package['is_installed'] || (!$package['is_current'] && !$package['is_newer'])) |
| 408 | 429 | { |
| 409 | - if ($thisPackage->exists('version/@for')) |
|
| 410 | - $package['can_install'] = matchPackageVersion($the_version, $thisPackage->fetch('version/@for')); |
|
| 430 | + if ($thisPackage->exists('version/@for')) { |
|
| 431 | + $package['can_install'] = matchPackageVersion($the_version, $thisPackage->fetch('version/@for')); |
|
| 432 | + } |
|
| 411 | 433 | } |
| 412 | 434 | // Okay, it's already installed AND up to date. |
| 413 | - else |
|
| 414 | - $package['can_install'] = false; |
|
| 435 | + else { |
|
| 436 | + $package['can_install'] = false; |
|
| 437 | + } |
|
| 415 | 438 | |
| 416 | 439 | $already_exists = getPackageInfo(basename($package['filename'])); |
| 417 | 440 | $package['download_conflict'] = is_array($already_exists) && $already_exists['id'] == $package['id'] && $already_exists['version'] != $package['version']; |
@@ -423,40 +446,44 @@ discard block |
||
| 423 | 446 | |
| 424 | 447 | if ($thisPackage->exists('author') || isset($default_author)) |
| 425 | 448 | { |
| 426 | - if ($thisPackage->exists('author/@email') && filter_var($thisPackage->fetch('author/@email'), FILTER_VALIDATE_EMAIL)) |
|
| 427 | - $package['author']['email'] = $thisPackage->fetch('author/@email'); |
|
| 428 | - elseif (isset($default_email)) |
|
| 429 | - $package['author']['email'] = $default_email; |
|
| 430 | - |
|
| 431 | - if ($thisPackage->exists('author') && $thisPackage->fetch('author') != '') |
|
| 432 | - $package['author']['name'] = $smcFunc['htmlspecialchars']($thisPackage->fetch('author')); |
|
| 433 | - else |
|
| 434 | - $package['author']['name'] = $default_author; |
|
| 435 | - |
|
| 436 | - if (!empty($package['author']['email'])) |
|
| 437 | - $package['author']['link'] = '<a href="mailto:' . $package['author']['email'] . '">' . $package['author']['name'] . '</a>'; |
|
| 449 | + if ($thisPackage->exists('author/@email') && filter_var($thisPackage->fetch('author/@email'), FILTER_VALIDATE_EMAIL)) { |
|
| 450 | + $package['author']['email'] = $thisPackage->fetch('author/@email'); |
|
| 451 | + } elseif (isset($default_email)) { |
|
| 452 | + $package['author']['email'] = $default_email; |
|
| 453 | + } |
|
| 454 | + |
|
| 455 | + if ($thisPackage->exists('author') && $thisPackage->fetch('author') != '') { |
|
| 456 | + $package['author']['name'] = $smcFunc['htmlspecialchars']($thisPackage->fetch('author')); |
|
| 457 | + } else { |
|
| 458 | + $package['author']['name'] = $default_author; |
|
| 459 | + } |
|
| 460 | + |
|
| 461 | + if (!empty($package['author']['email'])) { |
|
| 462 | + $package['author']['link'] = '<a href="mailto:' . $package['author']['email'] . '">' . $package['author']['name'] . '</a>'; |
|
| 463 | + } |
|
| 438 | 464 | } |
| 439 | 465 | |
| 440 | 466 | if ($thisPackage->exists('website') || isset($default_website)) |
| 441 | 467 | { |
| 442 | - if ($thisPackage->exists('website') && $thisPackage->exists('website/@title')) |
|
| 443 | - $package['author']['website']['name'] = $smcFunc['htmlspecialchars']($thisPackage->fetch('website/@title')); |
|
| 444 | - elseif (isset($default_title)) |
|
| 445 | - $package['author']['website']['name'] = $default_title; |
|
| 446 | - elseif ($thisPackage->exists('website')) |
|
| 447 | - $package['author']['website']['name'] = $smcFunc['htmlspecialchars']($thisPackage->fetch('website')); |
|
| 448 | - else |
|
| 449 | - $package['author']['website']['name'] = $default_website; |
|
| 450 | - |
|
| 451 | - if ($thisPackage->exists('website') && $thisPackage->fetch('website') != '') |
|
| 452 | - $authorhompage = $smcFunc['htmlspecialchars']($thisPackage->fetch('website')); |
|
| 453 | - else |
|
| 454 | - $authorhompage = $default_website; |
|
| 468 | + if ($thisPackage->exists('website') && $thisPackage->exists('website/@title')) { |
|
| 469 | + $package['author']['website']['name'] = $smcFunc['htmlspecialchars']($thisPackage->fetch('website/@title')); |
|
| 470 | + } elseif (isset($default_title)) { |
|
| 471 | + $package['author']['website']['name'] = $default_title; |
|
| 472 | + } elseif ($thisPackage->exists('website')) { |
|
| 473 | + $package['author']['website']['name'] = $smcFunc['htmlspecialchars']($thisPackage->fetch('website')); |
|
| 474 | + } else { |
|
| 475 | + $package['author']['website']['name'] = $default_website; |
|
| 476 | + } |
|
| 477 | + |
|
| 478 | + if ($thisPackage->exists('website') && $thisPackage->fetch('website') != '') { |
|
| 479 | + $authorhompage = $smcFunc['htmlspecialchars']($thisPackage->fetch('website')); |
|
| 480 | + } else { |
|
| 481 | + $authorhompage = $default_website; |
|
| 482 | + } |
|
| 455 | 483 | |
| 456 | 484 | $package['author']['website']['href'] = $authorhompage; |
| 457 | 485 | $package['author']['website']['link'] = '<a href="' . $authorhompage . '">' . $package['author']['website']['name'] . '</a>'; |
| 458 | - } |
|
| 459 | - else |
|
| 486 | + } else |
|
| 460 | 487 | { |
| 461 | 488 | $package['author']['website']['href'] = ''; |
| 462 | 489 | $package['author']['website']['link'] = ''; |
@@ -472,11 +499,13 @@ discard block |
||
| 472 | 499 | $packageNum = in_array($package['type'], array('title', 'heading', 'text', 'remote', 'rule')) ? 0 : $packageNum + 1; |
| 473 | 500 | $package['count'] = $packageNum; |
| 474 | 501 | |
| 475 | - if (!in_array($package['type'], array('title', 'text'))) |
|
| 476 | - $context['package_list'][$packageSection]['items'][] = $package; |
|
| 502 | + if (!in_array($package['type'], array('title', 'text'))) { |
|
| 503 | + $context['package_list'][$packageSection]['items'][] = $package; |
|
| 504 | + } |
|
| 477 | 505 | |
| 478 | - if ($package['count'] > 1) |
|
| 479 | - $context['list_type'] = 'ol'; |
|
| 506 | + if ($package['count'] > 1) { |
|
| 507 | + $context['list_type'] = 'ol'; |
|
| 508 | + } |
|
| 480 | 509 | } |
| 481 | 510 | |
| 482 | 511 | $packageSection++; |
@@ -489,8 +518,9 @@ discard block |
||
| 489 | 518 | { |
| 490 | 519 | foreach ($packageSection['items'] as $i => $package) |
| 491 | 520 | { |
| 492 | - if ($package['count'] == 0 || isset($package['can_install'])) |
|
| 493 | - continue; |
|
| 521 | + if ($package['count'] == 0 || isset($package['can_install'])) { |
|
| 522 | + continue; |
|
| 523 | + } |
|
| 494 | 524 | |
| 495 | 525 | $context['package_list'][$ps_id]['items'][$i]['can_install'] = false; |
| 496 | 526 | |
@@ -539,8 +569,9 @@ discard block |
||
| 539 | 569 | checkSession('get'); |
| 540 | 570 | |
| 541 | 571 | // To download something, we need a valid server or url. |
| 542 | - if (empty($_GET['server']) && (!empty($_GET['get']) && !empty($_REQUEST['package']))) |
|
| 543 | - fatal_lang_error('package_get_error_is_zero', false); |
|
| 572 | + if (empty($_GET['server']) && (!empty($_GET['get']) && !empty($_REQUEST['package']))) { |
|
| 573 | + fatal_lang_error('package_get_error_is_zero', false); |
|
| 574 | + } |
|
| 544 | 575 | |
| 545 | 576 | if (isset($_GET['server'])) |
| 546 | 577 | { |
@@ -560,22 +591,23 @@ discard block |
||
| 560 | 591 | $smcFunc['db_free_result']($request); |
| 561 | 592 | |
| 562 | 593 | // If server does not exist then dump out. |
| 563 | - if (empty($url)) |
|
| 564 | - fatal_lang_error('couldnt_connect', false); |
|
| 594 | + if (empty($url)) { |
|
| 595 | + fatal_lang_error('couldnt_connect', false); |
|
| 596 | + } |
|
| 565 | 597 | |
| 566 | 598 | $url = $url . '/'; |
| 567 | - } |
|
| 568 | - else |
|
| 599 | + } else |
|
| 569 | 600 | { |
| 570 | 601 | // Initialize the requried variables. |
| 571 | 602 | $server = ''; |
| 572 | 603 | $url = ''; |
| 573 | 604 | } |
| 574 | 605 | |
| 575 | - if (isset($_REQUEST['byurl']) && !empty($_POST['filename'])) |
|
| 576 | - $package_name = basename($_REQUEST['filename']); |
|
| 577 | - else |
|
| 578 | - $package_name = basename($_REQUEST['package']); |
|
| 606 | + if (isset($_REQUEST['byurl']) && !empty($_POST['filename'])) { |
|
| 607 | + $package_name = basename($_REQUEST['filename']); |
|
| 608 | + } else { |
|
| 609 | + $package_name = basename($_REQUEST['package']); |
|
| 610 | + } |
|
| 579 | 611 | |
| 580 | 612 | if (isset($_REQUEST['conflict']) || (isset($_REQUEST['auto']) && file_exists($packagesdir . '/' . $package_name))) |
| 581 | 613 | { |
@@ -584,14 +616,15 @@ discard block |
||
| 584 | 616 | { |
| 585 | 617 | $ext = substr($package_name, strrpos(substr($package_name, 0, -3), '.')); |
| 586 | 618 | $package_name = substr($package_name, 0, strrpos(substr($package_name, 0, -3), '.')) . '_'; |
| 619 | + } else { |
|
| 620 | + $ext = ''; |
|
| 587 | 621 | } |
| 588 | - else |
|
| 589 | - $ext = ''; |
|
| 590 | 622 | |
| 591 | 623 | // Find the first available. |
| 592 | 624 | $i = 1; |
| 593 | - while (file_exists($packagesdir . '/' . $package_name . $i . $ext)) |
|
| 594 | - $i++; |
|
| 625 | + while (file_exists($packagesdir . '/' . $package_name . $i . $ext)) { |
|
| 626 | + $i++; |
|
| 627 | + } |
|
| 595 | 628 | |
| 596 | 629 | $package_name = $package_name . $i . $ext; |
| 597 | 630 | } |
@@ -602,25 +635,28 @@ discard block |
||
| 602 | 635 | |
| 603 | 636 | // Done! Did we get this package automatically? |
| 604 | 637 | // @ TODO: These are usually update packages. Allowing both for now until more testing has been done. |
| 605 | - if (preg_match('~^https?://[\w_\-]+\.simplemachines\.org/~', $_REQUEST['package']) == 1 && strpos($_REQUEST['package'], 'dlattach') === false && isset($_REQUEST['auto'])) |
|
| 606 | - redirectexit('action=admin;area=packages;sa=install;package=' . $package_name); |
|
| 638 | + if (preg_match('~^https?://[\w_\-]+\.simplemachines\.org/~', $_REQUEST['package']) == 1 && strpos($_REQUEST['package'], 'dlattach') === false && isset($_REQUEST['auto'])) { |
|
| 639 | + redirectexit('action=admin;area=packages;sa=install;package=' . $package_name); |
|
| 640 | + } |
|
| 607 | 641 | |
| 608 | 642 | // You just downloaded a mod from SERVER_NAME_GOES_HERE. |
| 609 | 643 | $context['package_server'] = $server; |
| 610 | 644 | |
| 611 | 645 | $context['package'] = getPackageInfo($package_name); |
| 612 | 646 | |
| 613 | - if (!is_array($context['package'])) |
|
| 614 | - fatal_lang_error('package_cant_download', false); |
|
| 647 | + if (!is_array($context['package'])) { |
|
| 648 | + fatal_lang_error('package_cant_download', false); |
|
| 649 | + } |
|
| 615 | 650 | |
| 616 | - if ($context['package']['type'] == 'modification') |
|
| 617 | - $context['package']['install']['link'] = '<a href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $context['package']['filename'] . '">[ ' . $txt['install_mod'] . ' ]</a>'; |
|
| 618 | - elseif ($context['package']['type'] == 'avatar') |
|
| 619 | - $context['package']['install']['link'] = '<a href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $context['package']['filename'] . '">[ ' . $txt['use_avatars'] . ' ]</a>'; |
|
| 620 | - elseif ($context['package']['type'] == 'language') |
|
| 621 | - $context['package']['install']['link'] = '<a href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $context['package']['filename'] . '">[ ' . $txt['add_languages'] . ' ]</a>'; |
|
| 622 | - else |
|
| 623 | - $context['package']['install']['link'] = ''; |
|
| 651 | + if ($context['package']['type'] == 'modification') { |
|
| 652 | + $context['package']['install']['link'] = '<a href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $context['package']['filename'] . '">[ ' . $txt['install_mod'] . ' ]</a>'; |
|
| 653 | + } elseif ($context['package']['type'] == 'avatar') { |
|
| 654 | + $context['package']['install']['link'] = '<a href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $context['package']['filename'] . '">[ ' . $txt['use_avatars'] . ' ]</a>'; |
|
| 655 | + } elseif ($context['package']['type'] == 'language') { |
|
| 656 | + $context['package']['install']['link'] = '<a href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $context['package']['filename'] . '">[ ' . $txt['add_languages'] . ' ]</a>'; |
|
| 657 | + } else { |
|
| 658 | + $context['package']['install']['link'] = ''; |
|
| 659 | + } |
|
| 624 | 660 | |
| 625 | 661 | // Does a 3rd party hook want to do some additional changes? |
| 626 | 662 | call_integration_hook('integrate_package_download'); |
@@ -646,10 +682,11 @@ discard block |
||
| 646 | 682 | // @todo Use FTP if the Packages directory is not writable. |
| 647 | 683 | |
| 648 | 684 | // Check the file was even sent! |
| 649 | - if (!isset($_FILES['package']['name']) || $_FILES['package']['name'] == '') |
|
| 650 | - fatal_lang_error('package_upload_error_nofile'); |
|
| 651 | - elseif (!is_uploaded_file($_FILES['package']['tmp_name']) || (ini_get('open_basedir') == '' && !file_exists($_FILES['package']['tmp_name']))) |
|
| 652 | - fatal_lang_error('package_upload_error_failed'); |
|
| 685 | + if (!isset($_FILES['package']['name']) || $_FILES['package']['name'] == '') { |
|
| 686 | + fatal_lang_error('package_upload_error_nofile'); |
|
| 687 | + } elseif (!is_uploaded_file($_FILES['package']['tmp_name']) || (ini_get('open_basedir') == '' && !file_exists($_FILES['package']['tmp_name']))) { |
|
| 688 | + fatal_lang_error('package_upload_error_failed'); |
|
| 689 | + } |
|
| 653 | 690 | |
| 654 | 691 | // Make sure it has a sane filename. |
| 655 | 692 | $_FILES['package']['name'] = preg_replace(array('/\s/', '/\.[\.]+/', '/[^\w_\.\-]/'), array('_', '.', ''), $_FILES['package']['name']); |
@@ -666,8 +703,9 @@ discard block |
||
| 666 | 703 | // Setup the destination and throw an error if the file is already there! |
| 667 | 704 | $destination = $packagesdir . '/' . $packageName; |
| 668 | 705 | // @todo Maybe just roll it like we do for downloads? |
| 669 | - if (file_exists($destination)) |
|
| 670 | - fatal_lang_error('package_upload_error_exists'); |
|
| 706 | + if (file_exists($destination)) { |
|
| 707 | + fatal_lang_error('package_upload_error_exists'); |
|
| 708 | + } |
|
| 671 | 709 | |
| 672 | 710 | // Now move the file. |
| 673 | 711 | move_uploaded_file($_FILES['package']['tmp_name'], $destination); |
@@ -690,12 +728,14 @@ discard block |
||
| 690 | 728 | { |
| 691 | 729 | while ($package = readdir($dir)) |
| 692 | 730 | { |
| 693 | - if ($package == '.' || $package == '..' || $package == 'temp' || $package == $packageName || (!(is_dir($packagesdir . '/' . $package) && file_exists($packagesdir . '/' . $package . '/package-info.xml')) && substr(strtolower($package), -7) != '.tar.gz' && substr(strtolower($package), -4) != '.tgz' && substr(strtolower($package), -4) != '.zip')) |
|
| 694 | - continue; |
|
| 731 | + if ($package == '.' || $package == '..' || $package == 'temp' || $package == $packageName || (!(is_dir($packagesdir . '/' . $package) && file_exists($packagesdir . '/' . $package . '/package-info.xml')) && substr(strtolower($package), -7) != '.tar.gz' && substr(strtolower($package), -4) != '.tgz' && substr(strtolower($package), -4) != '.zip')) { |
|
| 732 | + continue; |
|
| 733 | + } |
|
| 695 | 734 | |
| 696 | 735 | $packageInfo = getPackageInfo($package); |
| 697 | - if (!is_array($packageInfo)) |
|
| 698 | - continue; |
|
| 736 | + if (!is_array($packageInfo)) { |
|
| 737 | + continue; |
|
| 738 | + } |
|
| 699 | 739 | |
| 700 | 740 | if ($packageInfo['id'] == $context['package']['id'] && $packageInfo['version'] == $context['package']['version']) |
| 701 | 741 | { |
@@ -707,14 +747,15 @@ discard block |
||
| 707 | 747 | closedir($dir); |
| 708 | 748 | } |
| 709 | 749 | |
| 710 | - if ($context['package']['type'] == 'modification') |
|
| 711 | - $context['package']['install']['link'] = '<a href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $context['package']['filename'] . '">[ ' . $txt['install_mod'] . ' ]</a>'; |
|
| 712 | - elseif ($context['package']['type'] == 'avatar') |
|
| 713 | - $context['package']['install']['link'] = '<a href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $context['package']['filename'] . '">[ ' . $txt['use_avatars'] . ' ]</a>'; |
|
| 714 | - elseif ($context['package']['type'] == 'language') |
|
| 715 | - $context['package']['install']['link'] = '<a href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $context['package']['filename'] . '">[ ' . $txt['add_languages'] . ' ]</a>'; |
|
| 716 | - else |
|
| 717 | - $context['package']['install']['link'] = ''; |
|
| 750 | + if ($context['package']['type'] == 'modification') { |
|
| 751 | + $context['package']['install']['link'] = '<a href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $context['package']['filename'] . '">[ ' . $txt['install_mod'] . ' ]</a>'; |
|
| 752 | + } elseif ($context['package']['type'] == 'avatar') { |
|
| 753 | + $context['package']['install']['link'] = '<a href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $context['package']['filename'] . '">[ ' . $txt['use_avatars'] . ' ]</a>'; |
|
| 754 | + } elseif ($context['package']['type'] == 'language') { |
|
| 755 | + $context['package']['install']['link'] = '<a href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $context['package']['filename'] . '">[ ' . $txt['add_languages'] . ' ]</a>'; |
|
| 756 | + } else { |
|
| 757 | + $context['package']['install']['link'] = ''; |
|
| 758 | + } |
|
| 718 | 759 | |
| 719 | 760 | // Does a 3rd party hook want to do some additional changes? |
| 720 | 761 | call_integration_hook('integrate_package_upload'); |
@@ -737,16 +778,18 @@ discard block |
||
| 737 | 778 | checkSession(); |
| 738 | 779 | |
| 739 | 780 | // If they put a slash on the end, get rid of it. |
| 740 | - if (substr($_POST['serverurl'], -1) == '/') |
|
| 741 | - $_POST['serverurl'] = substr($_POST['serverurl'], 0, -1); |
|
| 781 | + if (substr($_POST['serverurl'], -1) == '/') { |
|
| 782 | + $_POST['serverurl'] = substr($_POST['serverurl'], 0, -1); |
|
| 783 | + } |
|
| 742 | 784 | |
| 743 | 785 | // Are they both nice and clean? |
| 744 | 786 | $servername = trim($smcFunc['htmlspecialchars']($_POST['servername'])); |
| 745 | 787 | $serverurl = trim($smcFunc['htmlspecialchars']($_POST['serverurl'])); |
| 746 | 788 | |
| 747 | 789 | // Make sure the URL has the correct prefix. |
| 748 | - if (strpos($serverurl, 'http://') !== 0 && strpos($serverurl, 'https://') !== 0) |
|
| 749 | - $serverurl = 'http://' . $serverurl; |
|
| 790 | + if (strpos($serverurl, 'http://') !== 0 && strpos($serverurl, 'https://') !== 0) { |
|
| 791 | + $serverurl = 'http://' . $serverurl; |
|
| 792 | + } |
|
| 750 | 793 | |
| 751 | 794 | $smcFunc['db_insert']('', |
| 752 | 795 | '{db_prefix}package_servers', |