@@ -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 | * Update some basic statistics. |
@@ -122,10 +123,11 @@ discard block |
||
| 122 | 123 | $smcFunc['db_free_result']($result); |
| 123 | 124 | |
| 124 | 125 | // Add this to the number of unapproved members |
| 125 | - if (!empty($changes['unapprovedMembers'])) |
|
| 126 | - $changes['unapprovedMembers'] += $coppa_approvals; |
|
| 127 | - else |
|
| 128 | - $changes['unapprovedMembers'] = $coppa_approvals; |
|
| 126 | + if (!empty($changes['unapprovedMembers'])) { |
|
| 127 | + $changes['unapprovedMembers'] += $coppa_approvals; |
|
| 128 | + } else { |
|
| 129 | + $changes['unapprovedMembers'] = $coppa_approvals; |
|
| 130 | + } |
|
| 129 | 131 | } |
| 130 | 132 | } |
| 131 | 133 | } |
@@ -133,9 +135,9 @@ discard block |
||
| 133 | 135 | break; |
| 134 | 136 | |
| 135 | 137 | case 'message': |
| 136 | - if ($parameter1 === true && $parameter2 !== null) |
|
| 137 | - updateSettings(array('totalMessages' => true, 'maxMsgID' => $parameter2), true); |
|
| 138 | - else |
|
| 138 | + if ($parameter1 === true && $parameter2 !== null) { |
|
| 139 | + updateSettings(array('totalMessages' => true, 'maxMsgID' => $parameter2), true); |
|
| 140 | + } else |
|
| 139 | 141 | { |
| 140 | 142 | // SUM and MAX on a smaller table is better for InnoDB tables. |
| 141 | 143 | $result = $smcFunc['db_query']('', ' |
@@ -175,23 +177,25 @@ discard block |
||
| 175 | 177 | $parameter2 = text2words($parameter2); |
| 176 | 178 | |
| 177 | 179 | $inserts = array(); |
| 178 | - foreach ($parameter2 as $word) |
|
| 179 | - $inserts[] = array($word, $parameter1); |
|
| 180 | + foreach ($parameter2 as $word) { |
|
| 181 | + $inserts[] = array($word, $parameter1); |
|
| 182 | + } |
|
| 180 | 183 | |
| 181 | - if (!empty($inserts)) |
|
| 182 | - $smcFunc['db_insert']('ignore', |
|
| 184 | + if (!empty($inserts)) { |
|
| 185 | + $smcFunc['db_insert']('ignore', |
|
| 183 | 186 | '{db_prefix}log_search_subjects', |
| 184 | 187 | array('word' => 'string', 'id_topic' => 'int'), |
| 185 | 188 | $inserts, |
| 186 | 189 | array('word', 'id_topic') |
| 187 | 190 | ); |
| 191 | + } |
|
| 188 | 192 | } |
| 189 | 193 | break; |
| 190 | 194 | |
| 191 | 195 | case 'topic': |
| 192 | - if ($parameter1 === true) |
|
| 193 | - updateSettings(array('totalTopics' => true), true); |
|
| 194 | - else |
|
| 196 | + if ($parameter1 === true) { |
|
| 197 | + updateSettings(array('totalTopics' => true), true); |
|
| 198 | + } else |
|
| 195 | 199 | { |
| 196 | 200 | // Get the number of topics - a SUM is better for InnoDB tables. |
| 197 | 201 | // We also ignore the recycle bin here because there will probably be a bunch of one-post topics there. |
@@ -212,8 +216,9 @@ discard block |
||
| 212 | 216 | |
| 213 | 217 | case 'postgroups': |
| 214 | 218 | // Parameter two is the updated columns: we should check to see if we base groups off any of these. |
| 215 | - if ($parameter2 !== null && !in_array('posts', $parameter2)) |
|
| 216 | - return; |
|
| 219 | + if ($parameter2 !== null && !in_array('posts', $parameter2)) { |
|
| 220 | + return; |
|
| 221 | + } |
|
| 217 | 222 | |
| 218 | 223 | $postgroups = cache_get_data('updateStats:postgroups', 360); |
| 219 | 224 | if ($postgroups == null || $parameter1 == null) |
@@ -228,8 +233,9 @@ discard block |
||
| 228 | 233 | ) |
| 229 | 234 | ); |
| 230 | 235 | $postgroups = array(); |
| 231 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 232 | - $postgroups[$row['id_group']] = $row['min_posts']; |
|
| 236 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 237 | + $postgroups[$row['id_group']] = $row['min_posts']; |
|
| 238 | + } |
|
| 233 | 239 | $smcFunc['db_free_result']($request); |
| 234 | 240 | |
| 235 | 241 | // Sort them this way because if it's done with MySQL it causes a filesort :(. |
@@ -239,8 +245,9 @@ discard block |
||
| 239 | 245 | } |
| 240 | 246 | |
| 241 | 247 | // Oh great, they've screwed their post groups. |
| 242 | - if (empty($postgroups)) |
|
| 243 | - return; |
|
| 248 | + if (empty($postgroups)) { |
|
| 249 | + return; |
|
| 250 | + } |
|
| 244 | 251 | |
| 245 | 252 | // Set all membergroups from most posts to least posts. |
| 246 | 253 | $conditions = ''; |
@@ -298,10 +305,9 @@ discard block |
||
| 298 | 305 | { |
| 299 | 306 | $condition = 'id_member IN ({array_int:members})'; |
| 300 | 307 | $parameters['members'] = $members; |
| 301 | - } |
|
| 302 | - elseif ($members === null) |
|
| 303 | - $condition = '1=1'; |
|
| 304 | - else |
|
| 308 | + } elseif ($members === null) { |
|
| 309 | + $condition = '1=1'; |
|
| 310 | + } else |
|
| 305 | 311 | { |
| 306 | 312 | $condition = 'id_member = {int:member}'; |
| 307 | 313 | $parameters['member'] = $members; |
@@ -341,9 +347,9 @@ discard block |
||
| 341 | 347 | if (count($vars_to_integrate) != 0) |
| 342 | 348 | { |
| 343 | 349 | // Fetch a list of member_names if necessary |
| 344 | - if ((!is_array($members) && $members === $user_info['id']) || (is_array($members) && count($members) == 1 && in_array($user_info['id'], $members))) |
|
| 345 | - $member_names = array($user_info['username']); |
|
| 346 | - else |
|
| 350 | + if ((!is_array($members) && $members === $user_info['id']) || (is_array($members) && count($members) == 1 && in_array($user_info['id'], $members))) { |
|
| 351 | + $member_names = array($user_info['username']); |
|
| 352 | + } else |
|
| 347 | 353 | { |
| 348 | 354 | $member_names = array(); |
| 349 | 355 | $request = $smcFunc['db_query']('', ' |
@@ -352,14 +358,16 @@ discard block |
||
| 352 | 358 | WHERE ' . $condition, |
| 353 | 359 | $parameters |
| 354 | 360 | ); |
| 355 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 356 | - $member_names[] = $row['member_name']; |
|
| 361 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 362 | + $member_names[] = $row['member_name']; |
|
| 363 | + } |
|
| 357 | 364 | $smcFunc['db_free_result']($request); |
| 358 | 365 | } |
| 359 | 366 | |
| 360 | - if (!empty($member_names)) |
|
| 361 | - foreach ($vars_to_integrate as $var) |
|
| 367 | + if (!empty($member_names)) { |
|
| 368 | + foreach ($vars_to_integrate as $var) |
|
| 362 | 369 | call_integration_hook('integrate_change_member_data', array($member_names, $var, &$data[$var], &$knownInts, &$knownFloats)); |
| 370 | + } |
|
| 363 | 371 | } |
| 364 | 372 | } |
| 365 | 373 | |
@@ -367,16 +375,17 @@ discard block |
||
| 367 | 375 | foreach ($data as $var => $val) |
| 368 | 376 | { |
| 369 | 377 | $type = 'string'; |
| 370 | - if (in_array($var, $knownInts)) |
|
| 371 | - $type = 'int'; |
|
| 372 | - elseif (in_array($var, $knownFloats)) |
|
| 373 | - $type = 'float'; |
|
| 374 | - elseif ($var == 'birthdate') |
|
| 375 | - $type = 'date'; |
|
| 376 | - elseif ($var == 'member_ip') |
|
| 377 | - $type = 'inet'; |
|
| 378 | - elseif ($var == 'member_ip2') |
|
| 379 | - $type = 'inet'; |
|
| 378 | + if (in_array($var, $knownInts)) { |
|
| 379 | + $type = 'int'; |
|
| 380 | + } elseif (in_array($var, $knownFloats)) { |
|
| 381 | + $type = 'float'; |
|
| 382 | + } elseif ($var == 'birthdate') { |
|
| 383 | + $type = 'date'; |
|
| 384 | + } elseif ($var == 'member_ip') { |
|
| 385 | + $type = 'inet'; |
|
| 386 | + } elseif ($var == 'member_ip2') { |
|
| 387 | + $type = 'inet'; |
|
| 388 | + } |
|
| 380 | 389 | |
| 381 | 390 | // Doing an increment? |
| 382 | 391 | if ($type == 'int' && ($val === '+' || $val === '-')) |
@@ -390,8 +399,9 @@ discard block |
||
| 390 | 399 | { |
| 391 | 400 | if (preg_match('~^' . $var . ' (\+ |- |\+ -)([\d]+)~', $val, $match)) |
| 392 | 401 | { |
| 393 | - if ($match[1] != '+ ') |
|
| 394 | - $val = 'CASE WHEN ' . $var . ' <= ' . abs($match[2]) . ' THEN 0 ELSE ' . $val . ' END'; |
|
| 402 | + if ($match[1] != '+ ') { |
|
| 403 | + $val = 'CASE WHEN ' . $var . ' <= ' . abs($match[2]) . ' THEN 0 ELSE ' . $val . ' END'; |
|
| 404 | + } |
|
| 395 | 405 | $type = 'raw'; |
| 396 | 406 | } |
| 397 | 407 | } |
@@ -412,8 +422,9 @@ discard block |
||
| 412 | 422 | // Clear any caching? |
| 413 | 423 | if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2 && !empty($members)) |
| 414 | 424 | { |
| 415 | - if (!is_array($members)) |
|
| 416 | - $members = array($members); |
|
| 425 | + if (!is_array($members)) { |
|
| 426 | + $members = array($members); |
|
| 427 | + } |
|
| 417 | 428 | |
| 418 | 429 | foreach ($members as $member) |
| 419 | 430 | { |
@@ -446,29 +457,32 @@ discard block |
||
| 446 | 457 | { |
| 447 | 458 | global $modSettings, $smcFunc; |
| 448 | 459 | |
| 449 | - if (empty($changeArray) || !is_array($changeArray)) |
|
| 450 | - return; |
|
| 460 | + if (empty($changeArray) || !is_array($changeArray)) { |
|
| 461 | + return; |
|
| 462 | + } |
|
| 451 | 463 | |
| 452 | 464 | $toRemove = array(); |
| 453 | 465 | |
| 454 | 466 | // Go check if there is any setting to be removed. |
| 455 | - foreach ($changeArray as $k => $v) |
|
| 456 | - if ($v === null) |
|
| 467 | + foreach ($changeArray as $k => $v) { |
|
| 468 | + if ($v === null) |
|
| 457 | 469 | { |
| 458 | 470 | // Found some, remove them from the original array and add them to ours. |
| 459 | 471 | unset($changeArray[$k]); |
| 472 | + } |
|
| 460 | 473 | $toRemove[] = $k; |
| 461 | 474 | } |
| 462 | 475 | |
| 463 | 476 | // Proceed with the deletion. |
| 464 | - if (!empty($toRemove)) |
|
| 465 | - $smcFunc['db_query']('', ' |
|
| 477 | + if (!empty($toRemove)) { |
|
| 478 | + $smcFunc['db_query']('', ' |
|
| 466 | 479 | DELETE FROM {db_prefix}settings |
| 467 | 480 | WHERE variable IN ({array_string:remove})', |
| 468 | 481 | array( |
| 469 | 482 | 'remove' => $toRemove, |
| 470 | 483 | ) |
| 471 | 484 | ); |
| 485 | + } |
|
| 472 | 486 | |
| 473 | 487 | // In some cases, this may be better and faster, but for large sets we don't want so many UPDATEs. |
| 474 | 488 | if ($update) |
@@ -497,19 +511,22 @@ discard block |
||
| 497 | 511 | foreach ($changeArray as $variable => $value) |
| 498 | 512 | { |
| 499 | 513 | // Don't bother if it's already like that ;). |
| 500 | - if (isset($modSettings[$variable]) && $modSettings[$variable] == $value) |
|
| 501 | - continue; |
|
| 514 | + if (isset($modSettings[$variable]) && $modSettings[$variable] == $value) { |
|
| 515 | + continue; |
|
| 516 | + } |
|
| 502 | 517 | // If the variable isn't set, but would only be set to nothing'ness, then don't bother setting it. |
| 503 | - elseif (!isset($modSettings[$variable]) && empty($value)) |
|
| 504 | - continue; |
|
| 518 | + elseif (!isset($modSettings[$variable]) && empty($value)) { |
|
| 519 | + continue; |
|
| 520 | + } |
|
| 505 | 521 | |
| 506 | 522 | $replaceArray[] = array($variable, $value); |
| 507 | 523 | |
| 508 | 524 | $modSettings[$variable] = $value; |
| 509 | 525 | } |
| 510 | 526 | |
| 511 | - if (empty($replaceArray)) |
|
| 512 | - return; |
|
| 527 | + if (empty($replaceArray)) { |
|
| 528 | + return; |
|
| 529 | + } |
|
| 513 | 530 | |
| 514 | 531 | $smcFunc['db_insert']('replace', |
| 515 | 532 | '{db_prefix}settings', |
@@ -555,14 +572,17 @@ discard block |
||
| 555 | 572 | $start_invalid = $start < 0; |
| 556 | 573 | |
| 557 | 574 | // Make sure $start is a proper variable - not less than 0. |
| 558 | - if ($start_invalid) |
|
| 559 | - $start = 0; |
|
| 575 | + if ($start_invalid) { |
|
| 576 | + $start = 0; |
|
| 577 | + } |
|
| 560 | 578 | // Not greater than the upper bound. |
| 561 | - elseif ($start >= $max_value) |
|
| 562 | - $start = max(0, (int) $max_value - (((int) $max_value % (int) $num_per_page) == 0 ? $num_per_page : ((int) $max_value % (int) $num_per_page))); |
|
| 579 | + elseif ($start >= $max_value) { |
|
| 580 | + $start = max(0, (int) $max_value - (((int) $max_value % (int) $num_per_page) == 0 ? $num_per_page : ((int) $max_value % (int) $num_per_page))); |
|
| 581 | + } |
|
| 563 | 582 | // And it has to be a multiple of $num_per_page! |
| 564 | - else |
|
| 565 | - $start = max(0, (int) $start - ((int) $start % (int) $num_per_page)); |
|
| 583 | + else { |
|
| 584 | + $start = max(0, (int) $start - ((int) $start % (int) $num_per_page)); |
|
| 585 | + } |
|
| 566 | 586 | |
| 567 | 587 | $context['current_page'] = $start / $num_per_page; |
| 568 | 588 | |
@@ -592,77 +612,87 @@ discard block |
||
| 592 | 612 | |
| 593 | 613 | // Show all the pages. |
| 594 | 614 | $display_page = 1; |
| 595 | - for ($counter = 0; $counter < $max_value; $counter += $num_per_page) |
|
| 596 | - $pageindex .= $start == $counter && !$start_invalid ? sprintf($settings['page_index']['current_page'], $display_page++) : sprintf($base_link, $counter, $display_page++); |
|
| 615 | + for ($counter = 0; $counter < $max_value; $counter += $num_per_page) { |
|
| 616 | + $pageindex .= $start == $counter && !$start_invalid ? sprintf($settings['page_index']['current_page'], $display_page++) : sprintf($base_link, $counter, $display_page++); |
|
| 617 | + } |
|
| 597 | 618 | |
| 598 | 619 | // Show the right arrow. |
| 599 | 620 | $display_page = ($start + $num_per_page) > $max_value ? $max_value : ($start + $num_per_page); |
| 600 | - if ($start != $counter - $max_value && !$start_invalid) |
|
| 601 | - $pageindex .= $display_page > $counter - $num_per_page ? ' ' : sprintf($base_link, $display_page, $settings['page_index']['next_page']); |
|
| 602 | - } |
|
| 603 | - else |
|
| 621 | + if ($start != $counter - $max_value && !$start_invalid) { |
|
| 622 | + $pageindex .= $display_page > $counter - $num_per_page ? ' ' : sprintf($base_link, $display_page, $settings['page_index']['next_page']); |
|
| 623 | + } |
|
| 624 | + } else |
|
| 604 | 625 | { |
| 605 | 626 | // If they didn't enter an odd value, pretend they did. |
| 606 | 627 | $PageContiguous = (int) ($modSettings['compactTopicPagesContiguous'] - ($modSettings['compactTopicPagesContiguous'] % 2)) / 2; |
| 607 | 628 | |
| 608 | 629 | // Show the "prev page" link. (>prev page< 1 ... 6 7 [8] 9 10 ... 15 next page) |
| 609 | - if (!empty($start) && $show_prevnext) |
|
| 610 | - $pageindex .= sprintf($base_link, $start - $num_per_page, $settings['page_index']['previous_page']); |
|
| 611 | - else |
|
| 612 | - $pageindex .= ''; |
|
| 630 | + if (!empty($start) && $show_prevnext) { |
|
| 631 | + $pageindex .= sprintf($base_link, $start - $num_per_page, $settings['page_index']['previous_page']); |
|
| 632 | + } else { |
|
| 633 | + $pageindex .= ''; |
|
| 634 | + } |
|
| 613 | 635 | |
| 614 | 636 | // Show the first page. (prev page >1< ... 6 7 [8] 9 10 ... 15) |
| 615 | - if ($start > $num_per_page * $PageContiguous) |
|
| 616 | - $pageindex .= sprintf($base_link, 0, '1'); |
|
| 637 | + if ($start > $num_per_page * $PageContiguous) { |
|
| 638 | + $pageindex .= sprintf($base_link, 0, '1'); |
|
| 639 | + } |
|
| 617 | 640 | |
| 618 | 641 | // Show the ... after the first page. (prev page 1 >...< 6 7 [8] 9 10 ... 15 next page) |
| 619 | - if ($start > $num_per_page * ($PageContiguous + 1)) |
|
| 620 | - $pageindex .= strtr($settings['page_index']['expand_pages'], array( |
|
| 642 | + if ($start > $num_per_page * ($PageContiguous + 1)) { |
|
| 643 | + $pageindex .= strtr($settings['page_index']['expand_pages'], array( |
|
| 621 | 644 | '{LINK}' => JavaScriptEscape($smcFunc['htmlspecialchars']($base_link)), |
| 622 | 645 | '{FIRST_PAGE}' => $num_per_page, |
| 623 | 646 | '{LAST_PAGE}' => $start - $num_per_page * $PageContiguous, |
| 624 | 647 | '{PER_PAGE}' => $num_per_page, |
| 625 | 648 | )); |
| 649 | + } |
|
| 626 | 650 | |
| 627 | 651 | // Show the pages before the current one. (prev page 1 ... >6 7< [8] 9 10 ... 15 next page) |
| 628 | - for ($nCont = $PageContiguous; $nCont >= 1; $nCont--) |
|
| 629 | - if ($start >= $num_per_page * $nCont) |
|
| 652 | + for ($nCont = $PageContiguous; $nCont >= 1; $nCont--) { |
|
| 653 | + if ($start >= $num_per_page * $nCont) |
|
| 630 | 654 | { |
| 631 | 655 | $tmpStart = $start - $num_per_page * $nCont; |
| 656 | + } |
|
| 632 | 657 | $pageindex .= sprintf($base_link, $tmpStart, $tmpStart / $num_per_page + 1); |
| 633 | 658 | } |
| 634 | 659 | |
| 635 | 660 | // Show the current page. (prev page 1 ... 6 7 >[8]< 9 10 ... 15 next page) |
| 636 | - if (!$start_invalid) |
|
| 637 | - $pageindex .= sprintf($settings['page_index']['current_page'], $start / $num_per_page + 1); |
|
| 638 | - else |
|
| 639 | - $pageindex .= sprintf($base_link, $start, $start / $num_per_page + 1); |
|
| 661 | + if (!$start_invalid) { |
|
| 662 | + $pageindex .= sprintf($settings['page_index']['current_page'], $start / $num_per_page + 1); |
|
| 663 | + } else { |
|
| 664 | + $pageindex .= sprintf($base_link, $start, $start / $num_per_page + 1); |
|
| 665 | + } |
|
| 640 | 666 | |
| 641 | 667 | // Show the pages after the current one... (prev page 1 ... 6 7 [8] >9 10< ... 15 next page) |
| 642 | 668 | $tmpMaxPages = (int) (($max_value - 1) / $num_per_page) * $num_per_page; |
| 643 | - for ($nCont = 1; $nCont <= $PageContiguous; $nCont++) |
|
| 644 | - if ($start + $num_per_page * $nCont <= $tmpMaxPages) |
|
| 669 | + for ($nCont = 1; $nCont <= $PageContiguous; $nCont++) { |
|
| 670 | + if ($start + $num_per_page * $nCont <= $tmpMaxPages) |
|
| 645 | 671 | { |
| 646 | 672 | $tmpStart = $start + $num_per_page * $nCont; |
| 673 | + } |
|
| 647 | 674 | $pageindex .= sprintf($base_link, $tmpStart, $tmpStart / $num_per_page + 1); |
| 648 | 675 | } |
| 649 | 676 | |
| 650 | 677 | // Show the '...' part near the end. (prev page 1 ... 6 7 [8] 9 10 >...< 15 next page) |
| 651 | - if ($start + $num_per_page * ($PageContiguous + 1) < $tmpMaxPages) |
|
| 652 | - $pageindex .= strtr($settings['page_index']['expand_pages'], array( |
|
| 678 | + if ($start + $num_per_page * ($PageContiguous + 1) < $tmpMaxPages) { |
|
| 679 | + $pageindex .= strtr($settings['page_index']['expand_pages'], array( |
|
| 653 | 680 | '{LINK}' => JavaScriptEscape($smcFunc['htmlspecialchars']($base_link)), |
| 654 | 681 | '{FIRST_PAGE}' => $start + $num_per_page * ($PageContiguous + 1), |
| 655 | 682 | '{LAST_PAGE}' => $tmpMaxPages, |
| 656 | 683 | '{PER_PAGE}' => $num_per_page, |
| 657 | 684 | )); |
| 685 | + } |
|
| 658 | 686 | |
| 659 | 687 | // Show the last number in the list. (prev page 1 ... 6 7 [8] 9 10 ... >15< next page) |
| 660 | - if ($start + $num_per_page * $PageContiguous < $tmpMaxPages) |
|
| 661 | - $pageindex .= sprintf($base_link, $tmpMaxPages, $tmpMaxPages / $num_per_page + 1); |
|
| 688 | + if ($start + $num_per_page * $PageContiguous < $tmpMaxPages) { |
|
| 689 | + $pageindex .= sprintf($base_link, $tmpMaxPages, $tmpMaxPages / $num_per_page + 1); |
|
| 690 | + } |
|
| 662 | 691 | |
| 663 | 692 | // Show the "next page" link. (prev page 1 ... 6 7 [8] 9 10 ... 15 >next page<) |
| 664 | - if ($start != $tmpMaxPages && $show_prevnext) |
|
| 665 | - $pageindex .= sprintf($base_link, $start + $num_per_page, $settings['page_index']['next_page']); |
|
| 693 | + if ($start != $tmpMaxPages && $show_prevnext) { |
|
| 694 | + $pageindex .= sprintf($base_link, $start + $num_per_page, $settings['page_index']['next_page']); |
|
| 695 | + } |
|
| 666 | 696 | } |
| 667 | 697 | $pageindex .= $settings['page_index']['extra_after']; |
| 668 | 698 | |
@@ -688,8 +718,9 @@ discard block |
||
| 688 | 718 | if ($decimal_separator === null) |
| 689 | 719 | { |
| 690 | 720 | // Not set for whatever reason? |
| 691 | - if (empty($txt['number_format']) || preg_match('~^1([^\d]*)?234([^\d]*)(0*?)$~', $txt['number_format'], $matches) != 1) |
|
| 692 | - return $number; |
|
| 721 | + if (empty($txt['number_format']) || preg_match('~^1([^\d]*)?234([^\d]*)(0*?)$~', $txt['number_format'], $matches) != 1) { |
|
| 722 | + return $number; |
|
| 723 | + } |
|
| 693 | 724 | |
| 694 | 725 | // Cache these each load... |
| 695 | 726 | $thousands_separator = $matches[1]; |
@@ -721,17 +752,20 @@ discard block |
||
| 721 | 752 | static $non_twelve_hour; |
| 722 | 753 | |
| 723 | 754 | // Offset the time. |
| 724 | - if (!$offset_type) |
|
| 725 | - $time = $log_time + ($user_info['time_offset'] + $modSettings['time_offset']) * 3600; |
|
| 755 | + if (!$offset_type) { |
|
| 756 | + $time = $log_time + ($user_info['time_offset'] + $modSettings['time_offset']) * 3600; |
|
| 757 | + } |
|
| 726 | 758 | // Just the forum offset? |
| 727 | - elseif ($offset_type == 'forum') |
|
| 728 | - $time = $log_time + $modSettings['time_offset'] * 3600; |
|
| 729 | - else |
|
| 730 | - $time = $log_time; |
|
| 759 | + elseif ($offset_type == 'forum') { |
|
| 760 | + $time = $log_time + $modSettings['time_offset'] * 3600; |
|
| 761 | + } else { |
|
| 762 | + $time = $log_time; |
|
| 763 | + } |
|
| 731 | 764 | |
| 732 | 765 | // We can't have a negative date (on Windows, at least.) |
| 733 | - if ($log_time < 0) |
|
| 734 | - $log_time = 0; |
|
| 766 | + if ($log_time < 0) { |
|
| 767 | + $log_time = 0; |
|
| 768 | + } |
|
| 735 | 769 | |
| 736 | 770 | // Today and Yesterday? |
| 737 | 771 | if ($modSettings['todayMod'] >= 1 && $show_today === true) |
@@ -748,46 +782,53 @@ discard block |
||
| 748 | 782 | { |
| 749 | 783 | $h = strpos($user_info['time_format'], '%l') === false ? '%I' : '%l'; |
| 750 | 784 | $today_fmt = $h . ':%M' . $s . ' %p'; |
| 785 | + } else { |
|
| 786 | + $today_fmt = '%H:%M' . $s; |
|
| 751 | 787 | } |
| 752 | - else |
|
| 753 | - $today_fmt = '%H:%M' . $s; |
|
| 754 | 788 | |
| 755 | 789 | // Same day of the year, same year.... Today! |
| 756 | - if ($then['yday'] == $now['yday'] && $then['year'] == $now['year']) |
|
| 757 | - return $txt['today'] . timeformat($log_time, $today_fmt, $offset_type); |
|
| 790 | + if ($then['yday'] == $now['yday'] && $then['year'] == $now['year']) { |
|
| 791 | + return $txt['today'] . timeformat($log_time, $today_fmt, $offset_type); |
|
| 792 | + } |
|
| 758 | 793 | |
| 759 | 794 | // Day-of-year is one less and same year, or it's the first of the year and that's the last of the year... |
| 760 | - if ($modSettings['todayMod'] == '2' && (($then['yday'] == $now['yday'] - 1 && $then['year'] == $now['year']) || ($now['yday'] == 0 && $then['year'] == $now['year'] - 1) && $then['mon'] == 12 && $then['mday'] == 31)) |
|
| 761 | - return $txt['yesterday'] . timeformat($log_time, $today_fmt, $offset_type); |
|
| 795 | + if ($modSettings['todayMod'] == '2' && (($then['yday'] == $now['yday'] - 1 && $then['year'] == $now['year']) || ($now['yday'] == 0 && $then['year'] == $now['year'] - 1) && $then['mon'] == 12 && $then['mday'] == 31)) { |
|
| 796 | + return $txt['yesterday'] . timeformat($log_time, $today_fmt, $offset_type); |
|
| 797 | + } |
|
| 762 | 798 | } |
| 763 | 799 | |
| 764 | 800 | $str = !is_bool($show_today) ? $show_today : $user_info['time_format']; |
| 765 | 801 | |
| 766 | 802 | if (setlocale(LC_TIME, $txt['lang_locale'])) |
| 767 | 803 | { |
| 768 | - if (!isset($non_twelve_hour)) |
|
| 769 | - $non_twelve_hour = trim(strftime('%p')) === ''; |
|
| 770 | - if ($non_twelve_hour && strpos($str, '%p') !== false) |
|
| 771 | - $str = str_replace('%p', (strftime('%H', $time) < 12 ? $txt['time_am'] : $txt['time_pm']), $str); |
|
| 804 | + if (!isset($non_twelve_hour)) { |
|
| 805 | + $non_twelve_hour = trim(strftime('%p')) === ''; |
|
| 806 | + } |
|
| 807 | + if ($non_twelve_hour && strpos($str, '%p') !== false) { |
|
| 808 | + $str = str_replace('%p', (strftime('%H', $time) < 12 ? $txt['time_am'] : $txt['time_pm']), $str); |
|
| 809 | + } |
|
| 772 | 810 | |
| 773 | - foreach (array('%a', '%A', '%b', '%B') as $token) |
|
| 774 | - if (strpos($str, $token) !== false) |
|
| 811 | + foreach (array('%a', '%A', '%b', '%B') as $token) { |
|
| 812 | + if (strpos($str, $token) !== false) |
|
| 775 | 813 | $str = str_replace($token, strftime($token, $time), $str); |
| 776 | - } |
|
| 777 | - else |
|
| 814 | + } |
|
| 815 | + } else |
|
| 778 | 816 | { |
| 779 | 817 | // Do-it-yourself time localization. Fun. |
| 780 | - foreach (array('%a' => 'days_short', '%A' => 'days', '%b' => 'months_short', '%B' => 'months') as $token => $text_label) |
|
| 781 | - if (strpos($str, $token) !== false) |
|
| 818 | + foreach (array('%a' => 'days_short', '%A' => 'days', '%b' => 'months_short', '%B' => 'months') as $token => $text_label) { |
|
| 819 | + if (strpos($str, $token) !== false) |
|
| 782 | 820 | $str = str_replace($token, $txt[$text_label][(int) strftime($token === '%a' || $token === '%A' ? '%w' : '%m', $time)], $str); |
| 821 | + } |
|
| 783 | 822 | |
| 784 | - if (strpos($str, '%p') !== false) |
|
| 785 | - $str = str_replace('%p', (strftime('%H', $time) < 12 ? $txt['time_am'] : $txt['time_pm']), $str); |
|
| 823 | + if (strpos($str, '%p') !== false) { |
|
| 824 | + $str = str_replace('%p', (strftime('%H', $time) < 12 ? $txt['time_am'] : $txt['time_pm']), $str); |
|
| 825 | + } |
|
| 786 | 826 | } |
| 787 | 827 | |
| 788 | 828 | // Windows doesn't support %e; on some versions, strftime fails altogether if used, so let's prevent that. |
| 789 | - if ($context['server']['is_windows'] && strpos($str, '%e') !== false) |
|
| 790 | - $str = str_replace('%e', ltrim(strftime('%d', $time), '0'), $str); |
|
| 829 | + if ($context['server']['is_windows'] && strpos($str, '%e') !== false) { |
|
| 830 | + $str = str_replace('%e', ltrim(strftime('%d', $time), '0'), $str); |
|
| 831 | + } |
|
| 791 | 832 | |
| 792 | 833 | // Format any other characters.. |
| 793 | 834 | return strftime($str, $time); |
@@ -809,16 +850,19 @@ discard block |
||
| 809 | 850 | static $translation = array(); |
| 810 | 851 | |
| 811 | 852 | // Determine the character set... Default to UTF-8 |
| 812 | - if (empty($context['character_set'])) |
|
| 813 | - $charset = 'UTF-8'; |
|
| 853 | + if (empty($context['character_set'])) { |
|
| 854 | + $charset = 'UTF-8'; |
|
| 855 | + } |
|
| 814 | 856 | // Use ISO-8859-1 in place of non-supported ISO-8859 charsets... |
| 815 | - elseif (strpos($context['character_set'], 'ISO-8859-') !== false && !in_array($context['character_set'], array('ISO-8859-5', 'ISO-8859-15'))) |
|
| 816 | - $charset = 'ISO-8859-1'; |
|
| 817 | - else |
|
| 818 | - $charset = $context['character_set']; |
|
| 857 | + elseif (strpos($context['character_set'], 'ISO-8859-') !== false && !in_array($context['character_set'], array('ISO-8859-5', 'ISO-8859-15'))) { |
|
| 858 | + $charset = 'ISO-8859-1'; |
|
| 859 | + } else { |
|
| 860 | + $charset = $context['character_set']; |
|
| 861 | + } |
|
| 819 | 862 | |
| 820 | - if (empty($translation)) |
|
| 821 | - $translation = array_flip(get_html_translation_table(HTML_SPECIALCHARS, ENT_QUOTES, $charset)) + array(''' => '\'', ''' => '\'', ' ' => ' '); |
|
| 863 | + if (empty($translation)) { |
|
| 864 | + $translation = array_flip(get_html_translation_table(HTML_SPECIALCHARS, ENT_QUOTES, $charset)) + array(''' => '\'', ''' => '\'', ' ' => ' '); |
|
| 865 | + } |
|
| 822 | 866 | |
| 823 | 867 | return strtr($string, $translation); |
| 824 | 868 | } |
@@ -840,8 +884,9 @@ discard block |
||
| 840 | 884 | global $smcFunc; |
| 841 | 885 | |
| 842 | 886 | // It was already short enough! |
| 843 | - if ($smcFunc['strlen']($subject) <= $len) |
|
| 844 | - return $subject; |
|
| 887 | + if ($smcFunc['strlen']($subject) <= $len) { |
|
| 888 | + return $subject; |
|
| 889 | + } |
|
| 845 | 890 | |
| 846 | 891 | // Shorten it by the length it was too long, and strip off junk from the end. |
| 847 | 892 | return $smcFunc['substr']($subject, 0, $len) . '...'; |
@@ -860,10 +905,11 @@ discard block |
||
| 860 | 905 | { |
| 861 | 906 | global $user_info, $modSettings; |
| 862 | 907 | |
| 863 | - if ($timestamp === null) |
|
| 864 | - $timestamp = time(); |
|
| 865 | - elseif ($timestamp == 0) |
|
| 866 | - return 0; |
|
| 908 | + if ($timestamp === null) { |
|
| 909 | + $timestamp = time(); |
|
| 910 | + } elseif ($timestamp == 0) { |
|
| 911 | + return 0; |
|
| 912 | + } |
|
| 867 | 913 | |
| 868 | 914 | return $timestamp + ($modSettings['time_offset'] + ($use_user_offset ? $user_info['time_offset'] : 0)) * 3600; |
| 869 | 915 | } |
@@ -892,8 +938,9 @@ discard block |
||
| 892 | 938 | $array[$i] = $array[$j]; |
| 893 | 939 | $array[$j] = $temp; |
| 894 | 940 | |
| 895 | - for ($i = 1; $p[$i] == 0; $i++) |
|
| 896 | - $p[$i] = 1; |
|
| 941 | + for ($i = 1; $p[$i] == 0; $i++) { |
|
| 942 | + $p[$i] = 1; |
|
| 943 | + } |
|
| 897 | 944 | |
| 898 | 945 | $orders[] = $array; |
| 899 | 946 | } |
@@ -925,12 +972,14 @@ discard block |
||
| 925 | 972 | static $disabled; |
| 926 | 973 | |
| 927 | 974 | // Don't waste cycles |
| 928 | - if ($message === '') |
|
| 929 | - return ''; |
|
| 975 | + if ($message === '') { |
|
| 976 | + return ''; |
|
| 977 | + } |
|
| 930 | 978 | |
| 931 | 979 | // Just in case it wasn't determined yet whether UTF-8 is enabled. |
| 932 | - if (!isset($context['utf8'])) |
|
| 933 | - $context['utf8'] = (empty($modSettings['global_character_set']) ? $txt['lang_character_set'] : $modSettings['global_character_set']) === 'UTF-8'; |
|
| 980 | + if (!isset($context['utf8'])) { |
|
| 981 | + $context['utf8'] = (empty($modSettings['global_character_set']) ? $txt['lang_character_set'] : $modSettings['global_character_set']) === 'UTF-8'; |
|
| 982 | + } |
|
| 934 | 983 | |
| 935 | 984 | // Clean up any cut/paste issues we may have |
| 936 | 985 | $message = sanitizeMSCutPaste($message); |
@@ -942,13 +991,15 @@ discard block |
||
| 942 | 991 | return $message; |
| 943 | 992 | } |
| 944 | 993 | |
| 945 | - if ($smileys !== null && ($smileys == '1' || $smileys == '0')) |
|
| 946 | - $smileys = (bool) $smileys; |
|
| 994 | + if ($smileys !== null && ($smileys == '1' || $smileys == '0')) { |
|
| 995 | + $smileys = (bool) $smileys; |
|
| 996 | + } |
|
| 947 | 997 | |
| 948 | 998 | if (empty($modSettings['enableBBC']) && $message !== false) |
| 949 | 999 | { |
| 950 | - if ($smileys === true) |
|
| 951 | - parsesmileys($message); |
|
| 1000 | + if ($smileys === true) { |
|
| 1001 | + parsesmileys($message); |
|
| 1002 | + } |
|
| 952 | 1003 | |
| 953 | 1004 | return $message; |
| 954 | 1005 | } |
@@ -961,8 +1012,9 @@ discard block |
||
| 961 | 1012 | } |
| 962 | 1013 | |
| 963 | 1014 | // Ensure $modSettings['tld_regex'] contains a valid regex for the autolinker |
| 964 | - if (!empty($modSettings['autoLinkUrls'])) |
|
| 965 | - set_tld_regex(); |
|
| 1015 | + if (!empty($modSettings['autoLinkUrls'])) { |
|
| 1016 | + set_tld_regex(); |
|
| 1017 | + } |
|
| 966 | 1018 | |
| 967 | 1019 | // Allow mods access before entering the main parse_bbc loop |
| 968 | 1020 | call_integration_hook('integrate_pre_parsebbc', array(&$message, &$smileys, &$cache_id, &$parse_tags)); |
@@ -976,12 +1028,14 @@ discard block |
||
| 976 | 1028 | |
| 977 | 1029 | $temp = explode(',', strtolower($modSettings['disabledBBC'])); |
| 978 | 1030 | |
| 979 | - foreach ($temp as $tag) |
|
| 980 | - $disabled[trim($tag)] = true; |
|
| 1031 | + foreach ($temp as $tag) { |
|
| 1032 | + $disabled[trim($tag)] = true; |
|
| 1033 | + } |
|
| 981 | 1034 | } |
| 982 | 1035 | |
| 983 | - if (empty($modSettings['enableEmbeddedFlash'])) |
|
| 984 | - $disabled['flash'] = true; |
|
| 1036 | + if (empty($modSettings['enableEmbeddedFlash'])) { |
|
| 1037 | + $disabled['flash'] = true; |
|
| 1038 | + } |
|
| 985 | 1039 | |
| 986 | 1040 | /* The following bbc are formatted as an array, with keys as follows: |
| 987 | 1041 | |
@@ -1102,8 +1156,9 @@ discard block |
||
| 1102 | 1156 | $returnContext = ''; |
| 1103 | 1157 | |
| 1104 | 1158 | // BBC or the entire attachments feature is disabled |
| 1105 | - if (empty($modSettings['attachmentEnable']) || !empty($disabled['attach'])) |
|
| 1106 | - return $data; |
|
| 1159 | + if (empty($modSettings['attachmentEnable']) || !empty($disabled['attach'])) { |
|
| 1160 | + return $data; |
|
| 1161 | + } |
|
| 1107 | 1162 | |
| 1108 | 1163 | // Save the attach ID. |
| 1109 | 1164 | $attachID = $data; |
@@ -1114,8 +1169,9 @@ discard block |
||
| 1114 | 1169 | $currentAttachment = parseAttachBBC($attachID); |
| 1115 | 1170 | |
| 1116 | 1171 | // parseAttachBBC will return a string ($txt key) rather than diying with a fatal_error. Up to you to decide what to do. |
| 1117 | - if (is_string($currentAttachment)) |
|
| 1118 | - return $data = !empty($txt[$currentAttachment]) ? $txt[$currentAttachment] : $currentAttachment; |
|
| 1172 | + if (is_string($currentAttachment)) { |
|
| 1173 | + return $data = !empty($txt[$currentAttachment]) ? $txt[$currentAttachment] : $currentAttachment; |
|
| 1174 | + } |
|
| 1119 | 1175 | |
| 1120 | 1176 | if (!empty($currentAttachment['is_image'])) |
| 1121 | 1177 | { |
@@ -1128,15 +1184,17 @@ discard block |
||
| 1128 | 1184 | $height = ' height="' . $currentAttachment['height'] . '"'; |
| 1129 | 1185 | } |
| 1130 | 1186 | |
| 1131 | - if ($currentAttachment['thumbnail']['has_thumb'] && empty($params['{width}']) && empty($params['{height}'])) |
|
| 1132 | - $returnContext .= '<a href="'. $currentAttachment['href']. ';image" id="link_'. $currentAttachment['id']. '" onclick="'. $currentAttachment['thumbnail']['javascript']. '"><img src="'. $currentAttachment['thumbnail']['href']. '" alt="' . $currentAttachment['name'] . '" id="thumb_'. $currentAttachment['id']. '"></a>'; |
|
| 1133 | - else |
|
| 1134 | - $returnContext .= '<img src="' . $currentAttachment['href'] . ';image" alt="' . $currentAttachment['name'] . '"' . $width . $height . '/>'; |
|
| 1187 | + if ($currentAttachment['thumbnail']['has_thumb'] && empty($params['{width}']) && empty($params['{height}'])) { |
|
| 1188 | + $returnContext .= '<a href="'. $currentAttachment['href']. ';image" id="link_'. $currentAttachment['id']. '" onclick="'. $currentAttachment['thumbnail']['javascript']. '"><img src="'. $currentAttachment['thumbnail']['href']. '" alt="' . $currentAttachment['name'] . '" id="thumb_'. $currentAttachment['id']. '"></a>'; |
|
| 1189 | + } else { |
|
| 1190 | + $returnContext .= '<img src="' . $currentAttachment['href'] . ';image" alt="' . $currentAttachment['name'] . '"' . $width . $height . '/>'; |
|
| 1191 | + } |
|
| 1135 | 1192 | } |
| 1136 | 1193 | |
| 1137 | 1194 | // No image. Show a link. |
| 1138 | - else |
|
| 1139 | - $returnContext .= $currentAttachment['link']; |
|
| 1195 | + else { |
|
| 1196 | + $returnContext .= $currentAttachment['link']; |
|
| 1197 | + } |
|
| 1140 | 1198 | |
| 1141 | 1199 | // Gotta append what we just did. |
| 1142 | 1200 | $data = $returnContext; |
@@ -1167,8 +1225,9 @@ discard block |
||
| 1167 | 1225 | for ($php_i = 0, $php_n = count($php_parts); $php_i < $php_n; $php_i++) |
| 1168 | 1226 | { |
| 1169 | 1227 | // Do PHP code coloring? |
| 1170 | - if ($php_parts[$php_i] != '<?php') |
|
| 1171 | - continue; |
|
| 1228 | + if ($php_parts[$php_i] != '<?php') { |
|
| 1229 | + continue; |
|
| 1230 | + } |
|
| 1172 | 1231 | |
| 1173 | 1232 | $php_string = ''; |
| 1174 | 1233 | while ($php_i + 1 < count($php_parts) && $php_parts[$php_i] != '?>') |
@@ -1184,8 +1243,9 @@ discard block |
||
| 1184 | 1243 | $data = str_replace("\t", "<span style=\"white-space: pre;\">\t</span>", $data); |
| 1185 | 1244 | |
| 1186 | 1245 | // Recent Opera bug requiring temporary fix. &nsbp; is needed before </code> to avoid broken selection. |
| 1187 | - if ($context['browser']['is_opera']) |
|
| 1188 | - $data .= ' '; |
|
| 1246 | + if ($context['browser']['is_opera']) { |
|
| 1247 | + $data .= ' '; |
|
| 1248 | + } |
|
| 1189 | 1249 | } |
| 1190 | 1250 | }, |
| 1191 | 1251 | 'block_level' => true, |
@@ -1204,8 +1264,9 @@ discard block |
||
| 1204 | 1264 | for ($php_i = 0, $php_n = count($php_parts); $php_i < $php_n; $php_i++) |
| 1205 | 1265 | { |
| 1206 | 1266 | // Do PHP code coloring? |
| 1207 | - if ($php_parts[$php_i] != '<?php') |
|
| 1208 | - continue; |
|
| 1267 | + if ($php_parts[$php_i] != '<?php') { |
|
| 1268 | + continue; |
|
| 1269 | + } |
|
| 1209 | 1270 | |
| 1210 | 1271 | $php_string = ''; |
| 1211 | 1272 | while ($php_i + 1 < count($php_parts) && $php_parts[$php_i] != '?>') |
@@ -1221,8 +1282,9 @@ discard block |
||
| 1221 | 1282 | $data[0] = str_replace("\t", "<span style=\"white-space: pre;\">\t</span>", $data[0]); |
| 1222 | 1283 | |
| 1223 | 1284 | // Recent Opera bug requiring temporary fix. &nsbp; is needed before </code> to avoid broken selection. |
| 1224 | - if ($context['browser']['is_opera']) |
|
| 1225 | - $data[0] .= ' '; |
|
| 1285 | + if ($context['browser']['is_opera']) { |
|
| 1286 | + $data[0] .= ' '; |
|
| 1287 | + } |
|
| 1226 | 1288 | } |
| 1227 | 1289 | }, |
| 1228 | 1290 | 'block_level' => true, |
@@ -1260,11 +1322,13 @@ discard block |
||
| 1260 | 1322 | 'content' => '<embed type="application/x-shockwave-flash" src="$1" width="$2" height="$3" play="true" loop="true" quality="high" AllowScriptAccess="never">', |
| 1261 | 1323 | 'validate' => function (&$tag, &$data, $disabled) |
| 1262 | 1324 | { |
| 1263 | - if (isset($disabled['url'])) |
|
| 1264 | - $tag['content'] = '$1'; |
|
| 1325 | + if (isset($disabled['url'])) { |
|
| 1326 | + $tag['content'] = '$1'; |
|
| 1327 | + } |
|
| 1265 | 1328 | $scheme = parse_url($data[0], PHP_URL_SCHEME); |
| 1266 | - if (empty($scheme)) |
|
| 1267 | - $data[0] = '//' . ltrim($data[0], ':/'); |
|
| 1329 | + if (empty($scheme)) { |
|
| 1330 | + $data[0] = '//' . ltrim($data[0], ':/'); |
|
| 1331 | + } |
|
| 1268 | 1332 | }, |
| 1269 | 1333 | 'disabled_content' => '<a href="$1" target="_blank" class="new_win">$1</a>', |
| 1270 | 1334 | ), |
@@ -1311,14 +1375,16 @@ discard block |
||
| 1311 | 1375 | $scheme = parse_url($data, PHP_URL_SCHEME); |
| 1312 | 1376 | if ($image_proxy_enabled) |
| 1313 | 1377 | { |
| 1314 | - if (empty($scheme)) |
|
| 1315 | - $data = 'http://' . ltrim($data, ':/'); |
|
| 1378 | + if (empty($scheme)) { |
|
| 1379 | + $data = 'http://' . ltrim($data, ':/'); |
|
| 1380 | + } |
|
| 1316 | 1381 | |
| 1317 | - if ($scheme != 'https') |
|
| 1318 | - $data = $boardurl . '/proxy.php?request=' . urlencode($data) . '&hash=' . md5($data . $image_proxy_secret); |
|
| 1382 | + if ($scheme != 'https') { |
|
| 1383 | + $data = $boardurl . '/proxy.php?request=' . urlencode($data) . '&hash=' . md5($data . $image_proxy_secret); |
|
| 1384 | + } |
|
| 1385 | + } elseif (empty($scheme)) { |
|
| 1386 | + $data = '//' . ltrim($data, ':/'); |
|
| 1319 | 1387 | } |
| 1320 | - elseif (empty($scheme)) |
|
| 1321 | - $data = '//' . ltrim($data, ':/'); |
|
| 1322 | 1388 | }, |
| 1323 | 1389 | 'disabled_content' => '($1)', |
| 1324 | 1390 | ), |
@@ -1334,14 +1400,16 @@ discard block |
||
| 1334 | 1400 | $scheme = parse_url($data, PHP_URL_SCHEME); |
| 1335 | 1401 | if ($image_proxy_enabled) |
| 1336 | 1402 | { |
| 1337 | - if (empty($scheme)) |
|
| 1338 | - $data = 'http://' . ltrim($data, ':/'); |
|
| 1403 | + if (empty($scheme)) { |
|
| 1404 | + $data = 'http://' . ltrim($data, ':/'); |
|
| 1405 | + } |
|
| 1339 | 1406 | |
| 1340 | - if ($scheme != 'https') |
|
| 1341 | - $data = $boardurl . '/proxy.php?request=' . urlencode($data) . '&hash=' . md5($data . $image_proxy_secret); |
|
| 1407 | + if ($scheme != 'https') { |
|
| 1408 | + $data = $boardurl . '/proxy.php?request=' . urlencode($data) . '&hash=' . md5($data . $image_proxy_secret); |
|
| 1409 | + } |
|
| 1410 | + } elseif (empty($scheme)) { |
|
| 1411 | + $data = '//' . ltrim($data, ':/'); |
|
| 1342 | 1412 | } |
| 1343 | - elseif (empty($scheme)) |
|
| 1344 | - $data = '//' . ltrim($data, ':/'); |
|
| 1345 | 1413 | }, |
| 1346 | 1414 | 'disabled_content' => '($1)', |
| 1347 | 1415 | ), |
@@ -1353,8 +1421,9 @@ discard block |
||
| 1353 | 1421 | { |
| 1354 | 1422 | $data = strtr($data, array('<br>' => '')); |
| 1355 | 1423 | $scheme = parse_url($data, PHP_URL_SCHEME); |
| 1356 | - if (empty($scheme)) |
|
| 1357 | - $data = '//' . ltrim($data, ':/'); |
|
| 1424 | + if (empty($scheme)) { |
|
| 1425 | + $data = '//' . ltrim($data, ':/'); |
|
| 1426 | + } |
|
| 1358 | 1427 | }, |
| 1359 | 1428 | ), |
| 1360 | 1429 | array( |
@@ -1365,13 +1434,14 @@ discard block |
||
| 1365 | 1434 | 'after' => '</a>', |
| 1366 | 1435 | 'validate' => function (&$tag, &$data, $disabled) |
| 1367 | 1436 | { |
| 1368 | - if (substr($data, 0, 1) == '#') |
|
| 1369 | - $data = '#post_' . substr($data, 1); |
|
| 1370 | - else |
|
| 1437 | + if (substr($data, 0, 1) == '#') { |
|
| 1438 | + $data = '#post_' . substr($data, 1); |
|
| 1439 | + } else |
|
| 1371 | 1440 | { |
| 1372 | 1441 | $scheme = parse_url($data, PHP_URL_SCHEME); |
| 1373 | - if (empty($scheme)) |
|
| 1374 | - $data = '//' . ltrim($data, ':/'); |
|
| 1442 | + if (empty($scheme)) { |
|
| 1443 | + $data = '//' . ltrim($data, ':/'); |
|
| 1444 | + } |
|
| 1375 | 1445 | } |
| 1376 | 1446 | }, |
| 1377 | 1447 | 'disallow_children' => array('email', 'ftp', 'url', 'iurl'), |
@@ -1449,8 +1519,9 @@ discard block |
||
| 1449 | 1519 | { |
| 1450 | 1520 | $add_begin = substr(trim($data), 0, 5) != '<?'; |
| 1451 | 1521 | $data = highlight_php_code($add_begin ? '<?php ' . $data . '?>' : $data); |
| 1452 | - if ($add_begin) |
|
| 1453 | - $data = preg_replace(array('~^(.+?)<\?.{0,40}?php(?: |\s)~', '~\?>((?:</(font|span)>)*)$~'), '$1', $data, 2); |
|
| 1522 | + if ($add_begin) { |
|
| 1523 | + $data = preg_replace(array('~^(.+?)<\?.{0,40}?php(?: |\s)~', '~\?>((?:</(font|span)>)*)$~'), '$1', $data, 2); |
|
| 1524 | + } |
|
| 1454 | 1525 | } |
| 1455 | 1526 | }, |
| 1456 | 1527 | 'block_level' => false, |
@@ -1581,10 +1652,11 @@ discard block |
||
| 1581 | 1652 | 'content' => '$1', |
| 1582 | 1653 | 'validate' => function (&$tag, &$data, $disabled) |
| 1583 | 1654 | { |
| 1584 | - if (is_numeric($data)) |
|
| 1585 | - $data = timeformat($data); |
|
| 1586 | - else |
|
| 1587 | - $tag['content'] = '[time]$1[/time]'; |
|
| 1655 | + if (is_numeric($data)) { |
|
| 1656 | + $data = timeformat($data); |
|
| 1657 | + } else { |
|
| 1658 | + $tag['content'] = '[time]$1[/time]'; |
|
| 1659 | + } |
|
| 1588 | 1660 | }, |
| 1589 | 1661 | ), |
| 1590 | 1662 | array( |
@@ -1611,8 +1683,9 @@ discard block |
||
| 1611 | 1683 | { |
| 1612 | 1684 | $data = strtr($data, array('<br>' => '')); |
| 1613 | 1685 | $scheme = parse_url($data, PHP_URL_SCHEME); |
| 1614 | - if (empty($scheme)) |
|
| 1615 | - $data = '//' . ltrim($data, ':/'); |
|
| 1686 | + if (empty($scheme)) { |
|
| 1687 | + $data = '//' . ltrim($data, ':/'); |
|
| 1688 | + } |
|
| 1616 | 1689 | }, |
| 1617 | 1690 | ), |
| 1618 | 1691 | array( |
@@ -1624,8 +1697,9 @@ discard block |
||
| 1624 | 1697 | 'validate' => function (&$tag, &$data, $disabled) |
| 1625 | 1698 | { |
| 1626 | 1699 | $scheme = parse_url($data, PHP_URL_SCHEME); |
| 1627 | - if (empty($scheme)) |
|
| 1628 | - $data = '//' . ltrim($data, ':/'); |
|
| 1700 | + if (empty($scheme)) { |
|
| 1701 | + $data = '//' . ltrim($data, ':/'); |
|
| 1702 | + } |
|
| 1629 | 1703 | }, |
| 1630 | 1704 | 'disallow_children' => array('email', 'ftp', 'url', 'iurl'), |
| 1631 | 1705 | 'disabled_after' => ' ($1)', |
@@ -1645,8 +1719,9 @@ discard block |
||
| 1645 | 1719 | // This is mainly for the bbc manager, so it's easy to add tags above. Custom BBC should be added above this line. |
| 1646 | 1720 | if ($message === false) |
| 1647 | 1721 | { |
| 1648 | - if (isset($temp_bbc)) |
|
| 1649 | - $bbc_codes = $temp_bbc; |
|
| 1722 | + if (isset($temp_bbc)) { |
|
| 1723 | + $bbc_codes = $temp_bbc; |
|
| 1724 | + } |
|
| 1650 | 1725 | usort($codes, function ($a, $b) { |
| 1651 | 1726 | return strcmp($a['tag'], $b['tag']); |
| 1652 | 1727 | }); |
@@ -1666,8 +1741,9 @@ discard block |
||
| 1666 | 1741 | ); |
| 1667 | 1742 | if (!isset($disabled['li']) && !isset($disabled['list'])) |
| 1668 | 1743 | { |
| 1669 | - foreach ($itemcodes as $c => $dummy) |
|
| 1670 | - $bbc_codes[$c] = array(); |
|
| 1744 | + foreach ($itemcodes as $c => $dummy) { |
|
| 1745 | + $bbc_codes[$c] = array(); |
|
| 1746 | + } |
|
| 1671 | 1747 | } |
| 1672 | 1748 | |
| 1673 | 1749 | // Shhhh! |
@@ -1688,12 +1764,14 @@ discard block |
||
| 1688 | 1764 | foreach ($codes as $code) |
| 1689 | 1765 | { |
| 1690 | 1766 | // Make it easier to process parameters later |
| 1691 | - if (!empty($code['parameters'])) |
|
| 1692 | - ksort($code['parameters'], SORT_STRING); |
|
| 1767 | + if (!empty($code['parameters'])) { |
|
| 1768 | + ksort($code['parameters'], SORT_STRING); |
|
| 1769 | + } |
|
| 1693 | 1770 | |
| 1694 | 1771 | // If we are not doing every tag only do ones we are interested in. |
| 1695 | - if (empty($parse_tags) || in_array($code['tag'], $parse_tags)) |
|
| 1696 | - $bbc_codes[substr($code['tag'], 0, 1)][] = $code; |
|
| 1772 | + if (empty($parse_tags) || in_array($code['tag'], $parse_tags)) { |
|
| 1773 | + $bbc_codes[substr($code['tag'], 0, 1)][] = $code; |
|
| 1774 | + } |
|
| 1697 | 1775 | } |
| 1698 | 1776 | $codes = null; |
| 1699 | 1777 | } |
@@ -1704,8 +1782,9 @@ discard block |
||
| 1704 | 1782 | // It's likely this will change if the message is modified. |
| 1705 | 1783 | $cache_key = 'parse:' . $cache_id . '-' . md5(md5($message) . '-' . $smileys . (empty($disabled) ? '' : implode(',', array_keys($disabled))) . json_encode($context['browser']) . $txt['lang_locale'] . $user_info['time_offset'] . $user_info['time_format']); |
| 1706 | 1784 | |
| 1707 | - if (($temp = cache_get_data($cache_key, 240)) != null) |
|
| 1708 | - return $temp; |
|
| 1785 | + if (($temp = cache_get_data($cache_key, 240)) != null) { |
|
| 1786 | + return $temp; |
|
| 1787 | + } |
|
| 1709 | 1788 | |
| 1710 | 1789 | $cache_t = microtime(); |
| 1711 | 1790 | } |
@@ -1737,8 +1816,9 @@ discard block |
||
| 1737 | 1816 | $disabled['flash'] = true; |
| 1738 | 1817 | |
| 1739 | 1818 | // @todo Change maybe? |
| 1740 | - if (!isset($_GET['images'])) |
|
| 1741 | - $disabled['img'] = true; |
|
| 1819 | + if (!isset($_GET['images'])) { |
|
| 1820 | + $disabled['img'] = true; |
|
| 1821 | + } |
|
| 1742 | 1822 | |
| 1743 | 1823 | // @todo Interface/setting to add more? |
| 1744 | 1824 | } |
@@ -1762,8 +1842,9 @@ discard block |
||
| 1762 | 1842 | $pos = isset($matches[0][1]) ? $matches[0][1] : false; |
| 1763 | 1843 | |
| 1764 | 1844 | // Failsafe. |
| 1765 | - if ($pos === false || $last_pos > $pos) |
|
| 1766 | - $pos = strlen($message) + 1; |
|
| 1845 | + if ($pos === false || $last_pos > $pos) { |
|
| 1846 | + $pos = strlen($message) + 1; |
|
| 1847 | + } |
|
| 1767 | 1848 | |
| 1768 | 1849 | // Can't have a one letter smiley, URL, or email! (sorry.) |
| 1769 | 1850 | if ($last_pos < $pos - 1) |
@@ -1782,8 +1863,9 @@ discard block |
||
| 1782 | 1863 | |
| 1783 | 1864 | // <br> should be empty. |
| 1784 | 1865 | $empty_tags = array('br', 'hr'); |
| 1785 | - foreach ($empty_tags as $tag) |
|
| 1786 | - $data = str_replace(array('<' . $tag . '>', '<' . $tag . '/>', '<' . $tag . ' />'), '[' . $tag . ' /]', $data); |
|
| 1866 | + foreach ($empty_tags as $tag) { |
|
| 1867 | + $data = str_replace(array('<' . $tag . '>', '<' . $tag . '/>', '<' . $tag . ' />'), '[' . $tag . ' /]', $data); |
|
| 1868 | + } |
|
| 1787 | 1869 | |
| 1788 | 1870 | // b, u, i, s, pre... basic tags. |
| 1789 | 1871 | $closable_tags = array('b', 'u', 'i', 's', 'em', 'ins', 'del', 'pre', 'blockquote'); |
@@ -1792,8 +1874,9 @@ discard block |
||
| 1792 | 1874 | $diff = substr_count($data, '<' . $tag . '>') - substr_count($data, '</' . $tag . '>'); |
| 1793 | 1875 | $data = strtr($data, array('<' . $tag . '>' => '<' . $tag . '>', '</' . $tag . '>' => '</' . $tag . '>')); |
| 1794 | 1876 | |
| 1795 | - if ($diff > 0) |
|
| 1796 | - $data = substr($data, 0, -1) . str_repeat('</' . $tag . '>', $diff) . substr($data, -1); |
|
| 1877 | + if ($diff > 0) { |
|
| 1878 | + $data = substr($data, 0, -1) . str_repeat('</' . $tag . '>', $diff) . substr($data, -1); |
|
| 1879 | + } |
|
| 1797 | 1880 | } |
| 1798 | 1881 | |
| 1799 | 1882 | // Do <img ...> - with security... action= -> action-. |
@@ -1806,8 +1889,9 @@ discard block |
||
| 1806 | 1889 | $alt = empty($matches[3][$match]) ? '' : ' alt=' . preg_replace('~^"|"$~', '', $matches[3][$match]); |
| 1807 | 1890 | |
| 1808 | 1891 | // Remove action= from the URL - no funny business, now. |
| 1809 | - if (preg_match('~action(=|%3d)(?!dlattach)~i', $imgtag) != 0) |
|
| 1810 | - $imgtag = preg_replace('~action(?:=|%3d)(?!dlattach)~i', 'action-', $imgtag); |
|
| 1892 | + if (preg_match('~action(=|%3d)(?!dlattach)~i', $imgtag) != 0) { |
|
| 1893 | + $imgtag = preg_replace('~action(?:=|%3d)(?!dlattach)~i', 'action-', $imgtag); |
|
| 1894 | + } |
|
| 1811 | 1895 | |
| 1812 | 1896 | // Check if the image is larger than allowed. |
| 1813 | 1897 | if (!empty($modSettings['max_image_width']) && !empty($modSettings['max_image_height'])) |
@@ -1828,9 +1912,9 @@ discard block |
||
| 1828 | 1912 | |
| 1829 | 1913 | // Set the new image tag. |
| 1830 | 1914 | $replaces[$matches[0][$match]] = '[img width=' . $width . ' height=' . $height . $alt . ']' . $imgtag . '[/img]'; |
| 1915 | + } else { |
|
| 1916 | + $replaces[$matches[0][$match]] = '[img' . $alt . ']' . $imgtag . '[/img]'; |
|
| 1831 | 1917 | } |
| 1832 | - else |
|
| 1833 | - $replaces[$matches[0][$match]] = '[img' . $alt . ']' . $imgtag . '[/img]'; |
|
| 1834 | 1918 | } |
| 1835 | 1919 | |
| 1836 | 1920 | $data = strtr($data, $replaces); |
@@ -1843,16 +1927,18 @@ discard block |
||
| 1843 | 1927 | $no_autolink_area = false; |
| 1844 | 1928 | if (!empty($open_tags)) |
| 1845 | 1929 | { |
| 1846 | - foreach ($open_tags as $open_tag) |
|
| 1847 | - if (in_array($open_tag['tag'], $no_autolink_tags)) |
|
| 1930 | + foreach ($open_tags as $open_tag) { |
|
| 1931 | + if (in_array($open_tag['tag'], $no_autolink_tags)) |
|
| 1848 | 1932 | $no_autolink_area = true; |
| 1933 | + } |
|
| 1849 | 1934 | } |
| 1850 | 1935 | |
| 1851 | 1936 | // Don't go backwards. |
| 1852 | 1937 | // @todo Don't think is the real solution.... |
| 1853 | 1938 | $lastAutoPos = isset($lastAutoPos) ? $lastAutoPos : 0; |
| 1854 | - if ($pos < $lastAutoPos) |
|
| 1855 | - $no_autolink_area = true; |
|
| 1939 | + if ($pos < $lastAutoPos) { |
|
| 1940 | + $no_autolink_area = true; |
|
| 1941 | + } |
|
| 1856 | 1942 | $lastAutoPos = $pos; |
| 1857 | 1943 | |
| 1858 | 1944 | if (!$no_autolink_area) |
@@ -1961,17 +2047,19 @@ discard block |
||
| 1961 | 2047 | if ($scheme == 'mailto') |
| 1962 | 2048 | { |
| 1963 | 2049 | $email_address = str_replace('mailto:', '', $url); |
| 1964 | - if (!isset($disabled['email']) && filter_var($email_address, FILTER_VALIDATE_EMAIL) !== false) |
|
| 1965 | - return '[email=' . $email_address . ']' . $url . '[/email]'; |
|
| 1966 | - else |
|
| 1967 | - return $url; |
|
| 2050 | + if (!isset($disabled['email']) && filter_var($email_address, FILTER_VALIDATE_EMAIL) !== false) { |
|
| 2051 | + return '[email=' . $email_address . ']' . $url . '[/email]'; |
|
| 2052 | + } else { |
|
| 2053 | + return $url; |
|
| 2054 | + } |
|
| 1968 | 2055 | } |
| 1969 | 2056 | |
| 1970 | 2057 | // Are we linking a schemeless URL or naked domain name (e.g. "example.com")? |
| 1971 | - if (empty($scheme)) |
|
| 1972 | - $fullUrl = '//' . ltrim($url, ':/'); |
|
| 1973 | - else |
|
| 1974 | - $fullUrl = $url; |
|
| 2058 | + if (empty($scheme)) { |
|
| 2059 | + $fullUrl = '//' . ltrim($url, ':/'); |
|
| 2060 | + } else { |
|
| 2061 | + $fullUrl = $url; |
|
| 2062 | + } |
|
| 1975 | 2063 | |
| 1976 | 2064 | return '[url="' . str_replace(array('[', ']'), array('[', ']'), $fullUrl) . '"]' . $url . '[/url]'; |
| 1977 | 2065 | }, $data); |
@@ -2020,16 +2108,18 @@ discard block |
||
| 2020 | 2108 | } |
| 2021 | 2109 | |
| 2022 | 2110 | // Are we there yet? Are we there yet? |
| 2023 | - if ($pos >= strlen($message) - 1) |
|
| 2024 | - break; |
|
| 2111 | + if ($pos >= strlen($message) - 1) { |
|
| 2112 | + break; |
|
| 2113 | + } |
|
| 2025 | 2114 | |
| 2026 | 2115 | $tags = strtolower($message[$pos + 1]); |
| 2027 | 2116 | |
| 2028 | 2117 | if ($tags == '/' && !empty($open_tags)) |
| 2029 | 2118 | { |
| 2030 | 2119 | $pos2 = strpos($message, ']', $pos + 1); |
| 2031 | - if ($pos2 == $pos + 2) |
|
| 2032 | - continue; |
|
| 2120 | + if ($pos2 == $pos + 2) { |
|
| 2121 | + continue; |
|
| 2122 | + } |
|
| 2033 | 2123 | |
| 2034 | 2124 | $look_for = strtolower(substr($message, $pos + 2, $pos2 - $pos - 2)); |
| 2035 | 2125 | |
@@ -2039,8 +2129,9 @@ discard block |
||
| 2039 | 2129 | do |
| 2040 | 2130 | { |
| 2041 | 2131 | $tag = array_pop($open_tags); |
| 2042 | - if (!$tag) |
|
| 2043 | - break; |
|
| 2132 | + if (!$tag) { |
|
| 2133 | + break; |
|
| 2134 | + } |
|
| 2044 | 2135 | |
| 2045 | 2136 | if (!empty($tag['block_level'])) |
| 2046 | 2137 | { |
@@ -2054,10 +2145,11 @@ discard block |
||
| 2054 | 2145 | // The idea is, if we are LOOKING for a block level tag, we can close them on the way. |
| 2055 | 2146 | if (strlen($look_for) > 0 && isset($bbc_codes[$look_for[0]])) |
| 2056 | 2147 | { |
| 2057 | - foreach ($bbc_codes[$look_for[0]] as $temp) |
|
| 2058 | - if ($temp['tag'] == $look_for) |
|
| 2148 | + foreach ($bbc_codes[$look_for[0]] as $temp) { |
|
| 2149 | + if ($temp['tag'] == $look_for) |
|
| 2059 | 2150 | { |
| 2060 | 2151 | $block_level = !empty($temp['block_level']); |
| 2152 | + } |
|
| 2061 | 2153 | break; |
| 2062 | 2154 | } |
| 2063 | 2155 | } |
@@ -2079,15 +2171,15 @@ discard block |
||
| 2079 | 2171 | { |
| 2080 | 2172 | $open_tags = $to_close; |
| 2081 | 2173 | continue; |
| 2082 | - } |
|
| 2083 | - elseif (!empty($to_close) && $tag['tag'] != $look_for) |
|
| 2174 | + } elseif (!empty($to_close) && $tag['tag'] != $look_for) |
|
| 2084 | 2175 | { |
| 2085 | 2176 | if ($block_level === null && isset($look_for[0], $bbc_codes[$look_for[0]])) |
| 2086 | 2177 | { |
| 2087 | - foreach ($bbc_codes[$look_for[0]] as $temp) |
|
| 2088 | - if ($temp['tag'] == $look_for) |
|
| 2178 | + foreach ($bbc_codes[$look_for[0]] as $temp) { |
|
| 2179 | + if ($temp['tag'] == $look_for) |
|
| 2089 | 2180 | { |
| 2090 | 2181 | $block_level = !empty($temp['block_level']); |
| 2182 | + } |
|
| 2091 | 2183 | break; |
| 2092 | 2184 | } |
| 2093 | 2185 | } |
@@ -2095,8 +2187,9 @@ discard block |
||
| 2095 | 2187 | // We're not looking for a block level tag (or maybe even a tag that exists...) |
| 2096 | 2188 | if (!$block_level) |
| 2097 | 2189 | { |
| 2098 | - foreach ($to_close as $tag) |
|
| 2099 | - array_push($open_tags, $tag); |
|
| 2190 | + foreach ($to_close as $tag) { |
|
| 2191 | + array_push($open_tags, $tag); |
|
| 2192 | + } |
|
| 2100 | 2193 | continue; |
| 2101 | 2194 | } |
| 2102 | 2195 | } |
@@ -2108,10 +2201,12 @@ discard block |
||
| 2108 | 2201 | $pos2 = $pos - 1; |
| 2109 | 2202 | |
| 2110 | 2203 | // See the comment at the end of the big loop - just eating whitespace ;). |
| 2111 | - if (!empty($tag['block_level']) && substr($message, $pos, 4) == '<br>') |
|
| 2112 | - $message = substr($message, 0, $pos) . substr($message, $pos + 4); |
|
| 2113 | - if (!empty($tag['trim']) && $tag['trim'] != 'inside' && preg_match('~(<br>| |\s)*~', substr($message, $pos), $matches) != 0) |
|
| 2114 | - $message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0])); |
|
| 2204 | + if (!empty($tag['block_level']) && substr($message, $pos, 4) == '<br>') { |
|
| 2205 | + $message = substr($message, 0, $pos) . substr($message, $pos + 4); |
|
| 2206 | + } |
|
| 2207 | + if (!empty($tag['trim']) && $tag['trim'] != 'inside' && preg_match('~(<br>| |\s)*~', substr($message, $pos), $matches) != 0) { |
|
| 2208 | + $message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0])); |
|
| 2209 | + } |
|
| 2115 | 2210 | } |
| 2116 | 2211 | |
| 2117 | 2212 | if (!empty($to_close)) |
@@ -2124,8 +2219,9 @@ discard block |
||
| 2124 | 2219 | } |
| 2125 | 2220 | |
| 2126 | 2221 | // No tags for this character, so just keep going (fastest possible course.) |
| 2127 | - if (!isset($bbc_codes[$tags])) |
|
| 2128 | - continue; |
|
| 2222 | + if (!isset($bbc_codes[$tags])) { |
|
| 2223 | + continue; |
|
| 2224 | + } |
|
| 2129 | 2225 | |
| 2130 | 2226 | $inside = empty($open_tags) ? null : $open_tags[count($open_tags) - 1]; |
| 2131 | 2227 | $tag = null; |
@@ -2134,44 +2230,52 @@ discard block |
||
| 2134 | 2230 | $pt_strlen = strlen($possible['tag']); |
| 2135 | 2231 | |
| 2136 | 2232 | // Not a match? |
| 2137 | - if (strtolower(substr($message, $pos + 1, $pt_strlen)) != $possible['tag']) |
|
| 2138 | - continue; |
|
| 2233 | + if (strtolower(substr($message, $pos + 1, $pt_strlen)) != $possible['tag']) { |
|
| 2234 | + continue; |
|
| 2235 | + } |
|
| 2139 | 2236 | |
| 2140 | 2237 | $next_c = $message[$pos + 1 + $pt_strlen]; |
| 2141 | 2238 | |
| 2142 | 2239 | // A test validation? |
| 2143 | - if (isset($possible['test']) && preg_match('~^' . $possible['test'] . '~', substr($message, $pos + 1 + $pt_strlen + 1)) === 0) |
|
| 2144 | - continue; |
|
| 2240 | + if (isset($possible['test']) && preg_match('~^' . $possible['test'] . '~', substr($message, $pos + 1 + $pt_strlen + 1)) === 0) { |
|
| 2241 | + continue; |
|
| 2242 | + } |
|
| 2145 | 2243 | // Do we want parameters? |
| 2146 | 2244 | elseif (!empty($possible['parameters'])) |
| 2147 | 2245 | { |
| 2148 | - if ($next_c != ' ') |
|
| 2149 | - continue; |
|
| 2150 | - } |
|
| 2151 | - elseif (isset($possible['type'])) |
|
| 2246 | + if ($next_c != ' ') { |
|
| 2247 | + continue; |
|
| 2248 | + } |
|
| 2249 | + } elseif (isset($possible['type'])) |
|
| 2152 | 2250 | { |
| 2153 | 2251 | // Do we need an equal sign? |
| 2154 | - if (in_array($possible['type'], array('unparsed_equals', 'unparsed_commas', 'unparsed_commas_content', 'unparsed_equals_content', 'parsed_equals')) && $next_c != '=') |
|
| 2155 | - continue; |
|
| 2252 | + if (in_array($possible['type'], array('unparsed_equals', 'unparsed_commas', 'unparsed_commas_content', 'unparsed_equals_content', 'parsed_equals')) && $next_c != '=') { |
|
| 2253 | + continue; |
|
| 2254 | + } |
|
| 2156 | 2255 | // Maybe we just want a /... |
| 2157 | - if ($possible['type'] == 'closed' && $next_c != ']' && substr($message, $pos + 1 + $pt_strlen, 2) != '/]' && substr($message, $pos + 1 + $pt_strlen, 3) != ' /]') |
|
| 2158 | - continue; |
|
| 2256 | + if ($possible['type'] == 'closed' && $next_c != ']' && substr($message, $pos + 1 + $pt_strlen, 2) != '/]' && substr($message, $pos + 1 + $pt_strlen, 3) != ' /]') { |
|
| 2257 | + continue; |
|
| 2258 | + } |
|
| 2159 | 2259 | // An immediate ]? |
| 2160 | - if ($possible['type'] == 'unparsed_content' && $next_c != ']') |
|
| 2161 | - continue; |
|
| 2260 | + if ($possible['type'] == 'unparsed_content' && $next_c != ']') { |
|
| 2261 | + continue; |
|
| 2262 | + } |
|
| 2162 | 2263 | } |
| 2163 | 2264 | // No type means 'parsed_content', which demands an immediate ] without parameters! |
| 2164 | - elseif ($next_c != ']') |
|
| 2165 | - continue; |
|
| 2265 | + elseif ($next_c != ']') { |
|
| 2266 | + continue; |
|
| 2267 | + } |
|
| 2166 | 2268 | |
| 2167 | 2269 | // Check allowed tree? |
| 2168 | - if (isset($possible['require_parents']) && ($inside === null || !in_array($inside['tag'], $possible['require_parents']))) |
|
| 2169 | - continue; |
|
| 2170 | - elseif (isset($inside['require_children']) && !in_array($possible['tag'], $inside['require_children'])) |
|
| 2171 | - continue; |
|
| 2270 | + if (isset($possible['require_parents']) && ($inside === null || !in_array($inside['tag'], $possible['require_parents']))) { |
|
| 2271 | + continue; |
|
| 2272 | + } elseif (isset($inside['require_children']) && !in_array($possible['tag'], $inside['require_children'])) { |
|
| 2273 | + continue; |
|
| 2274 | + } |
|
| 2172 | 2275 | // If this is in the list of disallowed child tags, don't parse it. |
| 2173 | - elseif (isset($inside['disallow_children']) && in_array($possible['tag'], $inside['disallow_children'])) |
|
| 2174 | - continue; |
|
| 2276 | + elseif (isset($inside['disallow_children']) && in_array($possible['tag'], $inside['disallow_children'])) { |
|
| 2277 | + continue; |
|
| 2278 | + } |
|
| 2175 | 2279 | |
| 2176 | 2280 | $pos1 = $pos + 1 + $pt_strlen + 1; |
| 2177 | 2281 | |
@@ -2183,8 +2287,9 @@ discard block |
||
| 2183 | 2287 | foreach ($open_tags as $open_quote) |
| 2184 | 2288 | { |
| 2185 | 2289 | // Every parent quote this quote has flips the styling |
| 2186 | - if ($open_quote['tag'] == 'quote') |
|
| 2187 | - $quote_alt = !$quote_alt; |
|
| 2290 | + if ($open_quote['tag'] == 'quote') { |
|
| 2291 | + $quote_alt = !$quote_alt; |
|
| 2292 | + } |
|
| 2188 | 2293 | } |
| 2189 | 2294 | // Add a class to the quote to style alternating blockquotes |
| 2190 | 2295 | $possible['before'] = strtr($possible['before'], array('<blockquote>' => '<blockquote class="bbc_' . ($quote_alt ? 'alternate' : 'standard') . '_quote">')); |
@@ -2195,8 +2300,9 @@ discard block |
||
| 2195 | 2300 | { |
| 2196 | 2301 | // Build a regular expression for each parameter for the current tag. |
| 2197 | 2302 | $preg = array(); |
| 2198 | - foreach ($possible['parameters'] as $p => $info) |
|
| 2199 | - $preg[] = '(\s+' . $p . '=' . (empty($info['quoted']) ? '' : '"') . (isset($info['match']) ? $info['match'] : '(.+?)') . (empty($info['quoted']) ? '' : '"') . '\s*)' . (empty($info['optional']) ? '' : '?'); |
|
| 2303 | + foreach ($possible['parameters'] as $p => $info) { |
|
| 2304 | + $preg[] = '(\s+' . $p . '=' . (empty($info['quoted']) ? '' : '"') . (isset($info['match']) ? $info['match'] : '(.+?)') . (empty($info['quoted']) ? '' : '"') . '\s*)' . (empty($info['optional']) ? '' : '?'); |
|
| 2305 | + } |
|
| 2200 | 2306 | |
| 2201 | 2307 | // Extract the string that potentially holds our parameters. |
| 2202 | 2308 | $blob = preg_split('~\[/?(?:' . $alltags_regex . ')~i', substr($message, $pos)); |
@@ -2216,24 +2322,27 @@ discard block |
||
| 2216 | 2322 | |
| 2217 | 2323 | $match = preg_match('~^' . implode('', $preg) . '$~i', implode(' ', $given_params), $matches) !== 0; |
| 2218 | 2324 | |
| 2219 | - if ($match) |
|
| 2220 | - $blob_counter = count($blobs) + 1; |
|
| 2325 | + if ($match) { |
|
| 2326 | + $blob_counter = count($blobs) + 1; |
|
| 2327 | + } |
|
| 2221 | 2328 | } |
| 2222 | 2329 | |
| 2223 | 2330 | // Didn't match our parameter list, try the next possible. |
| 2224 | - if (!$match) |
|
| 2225 | - continue; |
|
| 2331 | + if (!$match) { |
|
| 2332 | + continue; |
|
| 2333 | + } |
|
| 2226 | 2334 | |
| 2227 | 2335 | $params = array(); |
| 2228 | 2336 | for ($i = 1, $n = count($matches); $i < $n; $i += 2) |
| 2229 | 2337 | { |
| 2230 | 2338 | $key = strtok(ltrim($matches[$i]), '='); |
| 2231 | - if (isset($possible['parameters'][$key]['value'])) |
|
| 2232 | - $params['{' . $key . '}'] = strtr($possible['parameters'][$key]['value'], array('$1' => $matches[$i + 1])); |
|
| 2233 | - elseif (isset($possible['parameters'][$key]['validate'])) |
|
| 2234 | - $params['{' . $key . '}'] = $possible['parameters'][$key]['validate']($matches[$i + 1]); |
|
| 2235 | - else |
|
| 2236 | - $params['{' . $key . '}'] = $matches[$i + 1]; |
|
| 2339 | + if (isset($possible['parameters'][$key]['value'])) { |
|
| 2340 | + $params['{' . $key . '}'] = strtr($possible['parameters'][$key]['value'], array('$1' => $matches[$i + 1])); |
|
| 2341 | + } elseif (isset($possible['parameters'][$key]['validate'])) { |
|
| 2342 | + $params['{' . $key . '}'] = $possible['parameters'][$key]['validate']($matches[$i + 1]); |
|
| 2343 | + } else { |
|
| 2344 | + $params['{' . $key . '}'] = $matches[$i + 1]; |
|
| 2345 | + } |
|
| 2237 | 2346 | |
| 2238 | 2347 | // Just to make sure: replace any $ or { so they can't interpolate wrongly. |
| 2239 | 2348 | $params['{' . $key . '}'] = strtr($params['{' . $key . '}'], array('$' => '$', '{' => '{')); |
@@ -2241,23 +2350,26 @@ discard block |
||
| 2241 | 2350 | |
| 2242 | 2351 | foreach ($possible['parameters'] as $p => $info) |
| 2243 | 2352 | { |
| 2244 | - if (!isset($params['{' . $p . '}'])) |
|
| 2245 | - $params['{' . $p . '}'] = ''; |
|
| 2353 | + if (!isset($params['{' . $p . '}'])) { |
|
| 2354 | + $params['{' . $p . '}'] = ''; |
|
| 2355 | + } |
|
| 2246 | 2356 | } |
| 2247 | 2357 | |
| 2248 | 2358 | $tag = $possible; |
| 2249 | 2359 | |
| 2250 | 2360 | // Put the parameters into the string. |
| 2251 | - if (isset($tag['before'])) |
|
| 2252 | - $tag['before'] = strtr($tag['before'], $params); |
|
| 2253 | - if (isset($tag['after'])) |
|
| 2254 | - $tag['after'] = strtr($tag['after'], $params); |
|
| 2255 | - if (isset($tag['content'])) |
|
| 2256 | - $tag['content'] = strtr($tag['content'], $params); |
|
| 2361 | + if (isset($tag['before'])) { |
|
| 2362 | + $tag['before'] = strtr($tag['before'], $params); |
|
| 2363 | + } |
|
| 2364 | + if (isset($tag['after'])) { |
|
| 2365 | + $tag['after'] = strtr($tag['after'], $params); |
|
| 2366 | + } |
|
| 2367 | + if (isset($tag['content'])) { |
|
| 2368 | + $tag['content'] = strtr($tag['content'], $params); |
|
| 2369 | + } |
|
| 2257 | 2370 | |
| 2258 | 2371 | $pos1 += strlen($given_param_string); |
| 2259 | - } |
|
| 2260 | - else |
|
| 2372 | + } else |
|
| 2261 | 2373 | { |
| 2262 | 2374 | $tag = $possible; |
| 2263 | 2375 | $params = array(); |
@@ -2268,8 +2380,9 @@ discard block |
||
| 2268 | 2380 | // Item codes are complicated buggers... they are implicit [li]s and can make [list]s! |
| 2269 | 2381 | if ($smileys !== false && $tag === null && isset($itemcodes[$message[$pos + 1]]) && $message[$pos + 2] == ']' && !isset($disabled['list']) && !isset($disabled['li'])) |
| 2270 | 2382 | { |
| 2271 | - if ($message[$pos + 1] == '0' && !in_array($message[$pos - 1], array(';', ' ', "\t", "\n", '>'))) |
|
| 2272 | - continue; |
|
| 2383 | + if ($message[$pos + 1] == '0' && !in_array($message[$pos - 1], array(';', ' ', "\t", "\n", '>'))) { |
|
| 2384 | + continue; |
|
| 2385 | + } |
|
| 2273 | 2386 | |
| 2274 | 2387 | $tag = $itemcodes[$message[$pos + 1]]; |
| 2275 | 2388 | |
@@ -2290,9 +2403,9 @@ discard block |
||
| 2290 | 2403 | { |
| 2291 | 2404 | array_pop($open_tags); |
| 2292 | 2405 | $code = '</li>'; |
| 2406 | + } else { |
|
| 2407 | + $code = ''; |
|
| 2293 | 2408 | } |
| 2294 | - else |
|
| 2295 | - $code = ''; |
|
| 2296 | 2409 | |
| 2297 | 2410 | // Now we open a new tag. |
| 2298 | 2411 | $open_tags[] = array( |
@@ -2339,12 +2452,14 @@ discard block |
||
| 2339 | 2452 | } |
| 2340 | 2453 | |
| 2341 | 2454 | // No tag? Keep looking, then. Silly people using brackets without actual tags. |
| 2342 | - if ($tag === null) |
|
| 2343 | - continue; |
|
| 2455 | + if ($tag === null) { |
|
| 2456 | + continue; |
|
| 2457 | + } |
|
| 2344 | 2458 | |
| 2345 | 2459 | // Propagate the list to the child (so wrapping the disallowed tag won't work either.) |
| 2346 | - if (isset($inside['disallow_children'])) |
|
| 2347 | - $tag['disallow_children'] = isset($tag['disallow_children']) ? array_unique(array_merge($tag['disallow_children'], $inside['disallow_children'])) : $inside['disallow_children']; |
|
| 2460 | + if (isset($inside['disallow_children'])) { |
|
| 2461 | + $tag['disallow_children'] = isset($tag['disallow_children']) ? array_unique(array_merge($tag['disallow_children'], $inside['disallow_children'])) : $inside['disallow_children']; |
|
| 2462 | + } |
|
| 2348 | 2463 | |
| 2349 | 2464 | // Is this tag disabled? |
| 2350 | 2465 | if (isset($disabled[$tag['tag']])) |
@@ -2354,14 +2469,13 @@ discard block |
||
| 2354 | 2469 | $tag['before'] = !empty($tag['block_level']) ? '<div>' : ''; |
| 2355 | 2470 | $tag['after'] = !empty($tag['block_level']) ? '</div>' : ''; |
| 2356 | 2471 | $tag['content'] = isset($tag['type']) && $tag['type'] == 'closed' ? '' : (!empty($tag['block_level']) ? '<div>$1</div>' : '$1'); |
| 2357 | - } |
|
| 2358 | - elseif (isset($tag['disabled_before']) || isset($tag['disabled_after'])) |
|
| 2472 | + } elseif (isset($tag['disabled_before']) || isset($tag['disabled_after'])) |
|
| 2359 | 2473 | { |
| 2360 | 2474 | $tag['before'] = isset($tag['disabled_before']) ? $tag['disabled_before'] : (!empty($tag['block_level']) ? '<div>' : ''); |
| 2361 | 2475 | $tag['after'] = isset($tag['disabled_after']) ? $tag['disabled_after'] : (!empty($tag['block_level']) ? '</div>' : ''); |
| 2476 | + } else { |
|
| 2477 | + $tag['content'] = $tag['disabled_content']; |
|
| 2362 | 2478 | } |
| 2363 | - else |
|
| 2364 | - $tag['content'] = $tag['disabled_content']; |
|
| 2365 | 2479 | } |
| 2366 | 2480 | |
| 2367 | 2481 | // we use this a lot |
@@ -2371,8 +2485,9 @@ discard block |
||
| 2371 | 2485 | if (!empty($tag['block_level']) && $tag['tag'] != 'html' && empty($inside['block_level'])) |
| 2372 | 2486 | { |
| 2373 | 2487 | $n = count($open_tags) - 1; |
| 2374 | - while (empty($open_tags[$n]['block_level']) && $n >= 0) |
|
| 2375 | - $n--; |
|
| 2488 | + while (empty($open_tags[$n]['block_level']) && $n >= 0) { |
|
| 2489 | + $n--; |
|
| 2490 | + } |
|
| 2376 | 2491 | |
| 2377 | 2492 | // Close all the non block level tags so this tag isn't surrounded by them. |
| 2378 | 2493 | for ($i = count($open_tags) - 1; $i > $n; $i--) |
@@ -2383,10 +2498,12 @@ discard block |
||
| 2383 | 2498 | $pos1 += $ot_strlen + 2; |
| 2384 | 2499 | |
| 2385 | 2500 | // Trim or eat trailing stuff... see comment at the end of the big loop. |
| 2386 | - if (!empty($open_tags[$i]['block_level']) && substr($message, $pos, 4) == '<br>') |
|
| 2387 | - $message = substr($message, 0, $pos) . substr($message, $pos + 4); |
|
| 2388 | - if (!empty($open_tags[$i]['trim']) && $tag['trim'] != 'inside' && preg_match('~(<br>| |\s)*~', substr($message, $pos), $matches) != 0) |
|
| 2389 | - $message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0])); |
|
| 2501 | + if (!empty($open_tags[$i]['block_level']) && substr($message, $pos, 4) == '<br>') { |
|
| 2502 | + $message = substr($message, 0, $pos) . substr($message, $pos + 4); |
|
| 2503 | + } |
|
| 2504 | + if (!empty($open_tags[$i]['trim']) && $tag['trim'] != 'inside' && preg_match('~(<br>| |\s)*~', substr($message, $pos), $matches) != 0) { |
|
| 2505 | + $message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0])); |
|
| 2506 | + } |
|
| 2390 | 2507 | |
| 2391 | 2508 | array_pop($open_tags); |
| 2392 | 2509 | } |
@@ -2404,16 +2521,19 @@ discard block |
||
| 2404 | 2521 | elseif ($tag['type'] == 'unparsed_content') |
| 2405 | 2522 | { |
| 2406 | 2523 | $pos2 = stripos($message, '[/' . substr($message, $pos + 1, $tag_strlen) . ']', $pos1); |
| 2407 | - if ($pos2 === false) |
|
| 2408 | - continue; |
|
| 2524 | + if ($pos2 === false) { |
|
| 2525 | + continue; |
|
| 2526 | + } |
|
| 2409 | 2527 | |
| 2410 | 2528 | $data = substr($message, $pos1, $pos2 - $pos1); |
| 2411 | 2529 | |
| 2412 | - if (!empty($tag['block_level']) && substr($data, 0, 4) == '<br>') |
|
| 2413 | - $data = substr($data, 4); |
|
| 2530 | + if (!empty($tag['block_level']) && substr($data, 0, 4) == '<br>') { |
|
| 2531 | + $data = substr($data, 4); |
|
| 2532 | + } |
|
| 2414 | 2533 | |
| 2415 | - if (isset($tag['validate'])) |
|
| 2416 | - $tag['validate']($tag, $data, $disabled, $params); |
|
| 2534 | + if (isset($tag['validate'])) { |
|
| 2535 | + $tag['validate']($tag, $data, $disabled, $params); |
|
| 2536 | + } |
|
| 2417 | 2537 | |
| 2418 | 2538 | $code = strtr($tag['content'], array('$1' => $data)); |
| 2419 | 2539 | $message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos2 + 3 + $tag_strlen); |
@@ -2429,34 +2549,40 @@ discard block |
||
| 2429 | 2549 | if (isset($tag['quoted'])) |
| 2430 | 2550 | { |
| 2431 | 2551 | $quoted = substr($message, $pos1, 6) == '"'; |
| 2432 | - if ($tag['quoted'] != 'optional' && !$quoted) |
|
| 2433 | - continue; |
|
| 2552 | + if ($tag['quoted'] != 'optional' && !$quoted) { |
|
| 2553 | + continue; |
|
| 2554 | + } |
|
| 2434 | 2555 | |
| 2435 | - if ($quoted) |
|
| 2436 | - $pos1 += 6; |
|
| 2556 | + if ($quoted) { |
|
| 2557 | + $pos1 += 6; |
|
| 2558 | + } |
|
| 2559 | + } else { |
|
| 2560 | + $quoted = false; |
|
| 2437 | 2561 | } |
| 2438 | - else |
|
| 2439 | - $quoted = false; |
|
| 2440 | 2562 | |
| 2441 | 2563 | $pos2 = strpos($message, $quoted == false ? ']' : '"]', $pos1); |
| 2442 | - if ($pos2 === false) |
|
| 2443 | - continue; |
|
| 2564 | + if ($pos2 === false) { |
|
| 2565 | + continue; |
|
| 2566 | + } |
|
| 2444 | 2567 | |
| 2445 | 2568 | $pos3 = stripos($message, '[/' . substr($message, $pos + 1, $tag_strlen) . ']', $pos2); |
| 2446 | - if ($pos3 === false) |
|
| 2447 | - continue; |
|
| 2569 | + if ($pos3 === false) { |
|
| 2570 | + continue; |
|
| 2571 | + } |
|
| 2448 | 2572 | |
| 2449 | 2573 | $data = array( |
| 2450 | 2574 | substr($message, $pos2 + ($quoted == false ? 1 : 7), $pos3 - ($pos2 + ($quoted == false ? 1 : 7))), |
| 2451 | 2575 | substr($message, $pos1, $pos2 - $pos1) |
| 2452 | 2576 | ); |
| 2453 | 2577 | |
| 2454 | - if (!empty($tag['block_level']) && substr($data[0], 0, 4) == '<br>') |
|
| 2455 | - $data[0] = substr($data[0], 4); |
|
| 2578 | + if (!empty($tag['block_level']) && substr($data[0], 0, 4) == '<br>') { |
|
| 2579 | + $data[0] = substr($data[0], 4); |
|
| 2580 | + } |
|
| 2456 | 2581 | |
| 2457 | 2582 | // Validation for my parking, please! |
| 2458 | - if (isset($tag['validate'])) |
|
| 2459 | - $tag['validate']($tag, $data, $disabled, $params); |
|
| 2583 | + if (isset($tag['validate'])) { |
|
| 2584 | + $tag['validate']($tag, $data, $disabled, $params); |
|
| 2585 | + } |
|
| 2460 | 2586 | |
| 2461 | 2587 | $code = strtr($tag['content'], array('$1' => $data[0], '$2' => $data[1])); |
| 2462 | 2588 | $message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos3 + 3 + $tag_strlen); |
@@ -2473,23 +2599,27 @@ discard block |
||
| 2473 | 2599 | elseif ($tag['type'] == 'unparsed_commas_content') |
| 2474 | 2600 | { |
| 2475 | 2601 | $pos2 = strpos($message, ']', $pos1); |
| 2476 | - if ($pos2 === false) |
|
| 2477 | - continue; |
|
| 2602 | + if ($pos2 === false) { |
|
| 2603 | + continue; |
|
| 2604 | + } |
|
| 2478 | 2605 | |
| 2479 | 2606 | $pos3 = stripos($message, '[/' . substr($message, $pos + 1, $tag_strlen) . ']', $pos2); |
| 2480 | - if ($pos3 === false) |
|
| 2481 | - continue; |
|
| 2607 | + if ($pos3 === false) { |
|
| 2608 | + continue; |
|
| 2609 | + } |
|
| 2482 | 2610 | |
| 2483 | 2611 | // We want $1 to be the content, and the rest to be csv. |
| 2484 | 2612 | $data = explode(',', ',' . substr($message, $pos1, $pos2 - $pos1)); |
| 2485 | 2613 | $data[0] = substr($message, $pos2 + 1, $pos3 - $pos2 - 1); |
| 2486 | 2614 | |
| 2487 | - if (isset($tag['validate'])) |
|
| 2488 | - $tag['validate']($tag, $data, $disabled, $params); |
|
| 2615 | + if (isset($tag['validate'])) { |
|
| 2616 | + $tag['validate']($tag, $data, $disabled, $params); |
|
| 2617 | + } |
|
| 2489 | 2618 | |
| 2490 | 2619 | $code = $tag['content']; |
| 2491 | - foreach ($data as $k => $d) |
|
| 2492 | - $code = strtr($code, array('$' . ($k + 1) => trim($d))); |
|
| 2620 | + foreach ($data as $k => $d) { |
|
| 2621 | + $code = strtr($code, array('$' . ($k + 1) => trim($d))); |
|
| 2622 | + } |
|
| 2493 | 2623 | $message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos3 + 3 + $tag_strlen); |
| 2494 | 2624 | $pos += strlen($code) - 1 + 2; |
| 2495 | 2625 | } |
@@ -2497,24 +2627,28 @@ discard block |
||
| 2497 | 2627 | elseif ($tag['type'] == 'unparsed_commas') |
| 2498 | 2628 | { |
| 2499 | 2629 | $pos2 = strpos($message, ']', $pos1); |
| 2500 | - if ($pos2 === false) |
|
| 2501 | - continue; |
|
| 2630 | + if ($pos2 === false) { |
|
| 2631 | + continue; |
|
| 2632 | + } |
|
| 2502 | 2633 | |
| 2503 | 2634 | $data = explode(',', substr($message, $pos1, $pos2 - $pos1)); |
| 2504 | 2635 | |
| 2505 | - if (isset($tag['validate'])) |
|
| 2506 | - $tag['validate']($tag, $data, $disabled, $params); |
|
| 2636 | + if (isset($tag['validate'])) { |
|
| 2637 | + $tag['validate']($tag, $data, $disabled, $params); |
|
| 2638 | + } |
|
| 2507 | 2639 | |
| 2508 | 2640 | // Fix after, for disabled code mainly. |
| 2509 | - foreach ($data as $k => $d) |
|
| 2510 | - $tag['after'] = strtr($tag['after'], array('$' . ($k + 1) => trim($d))); |
|
| 2641 | + foreach ($data as $k => $d) { |
|
| 2642 | + $tag['after'] = strtr($tag['after'], array('$' . ($k + 1) => trim($d))); |
|
| 2643 | + } |
|
| 2511 | 2644 | |
| 2512 | 2645 | $open_tags[] = $tag; |
| 2513 | 2646 | |
| 2514 | 2647 | // Replace them out, $1, $2, $3, $4, etc. |
| 2515 | 2648 | $code = $tag['before']; |
| 2516 | - foreach ($data as $k => $d) |
|
| 2517 | - $code = strtr($code, array('$' . ($k + 1) => trim($d))); |
|
| 2649 | + foreach ($data as $k => $d) { |
|
| 2650 | + $code = strtr($code, array('$' . ($k + 1) => trim($d))); |
|
| 2651 | + } |
|
| 2518 | 2652 | $message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos2 + 1); |
| 2519 | 2653 | $pos += strlen($code) - 1 + 2; |
| 2520 | 2654 | } |
@@ -2525,28 +2659,33 @@ discard block |
||
| 2525 | 2659 | if (isset($tag['quoted'])) |
| 2526 | 2660 | { |
| 2527 | 2661 | $quoted = substr($message, $pos1, 6) == '"'; |
| 2528 | - if ($tag['quoted'] != 'optional' && !$quoted) |
|
| 2529 | - continue; |
|
| 2662 | + if ($tag['quoted'] != 'optional' && !$quoted) { |
|
| 2663 | + continue; |
|
| 2664 | + } |
|
| 2530 | 2665 | |
| 2531 | - if ($quoted) |
|
| 2532 | - $pos1 += 6; |
|
| 2666 | + if ($quoted) { |
|
| 2667 | + $pos1 += 6; |
|
| 2668 | + } |
|
| 2669 | + } else { |
|
| 2670 | + $quoted = false; |
|
| 2533 | 2671 | } |
| 2534 | - else |
|
| 2535 | - $quoted = false; |
|
| 2536 | 2672 | |
| 2537 | 2673 | $pos2 = strpos($message, $quoted == false ? ']' : '"]', $pos1); |
| 2538 | - if ($pos2 === false) |
|
| 2539 | - continue; |
|
| 2674 | + if ($pos2 === false) { |
|
| 2675 | + continue; |
|
| 2676 | + } |
|
| 2540 | 2677 | |
| 2541 | 2678 | $data = substr($message, $pos1, $pos2 - $pos1); |
| 2542 | 2679 | |
| 2543 | 2680 | // Validation for my parking, please! |
| 2544 | - if (isset($tag['validate'])) |
|
| 2545 | - $tag['validate']($tag, $data, $disabled, $params); |
|
| 2681 | + if (isset($tag['validate'])) { |
|
| 2682 | + $tag['validate']($tag, $data, $disabled, $params); |
|
| 2683 | + } |
|
| 2546 | 2684 | |
| 2547 | 2685 | // For parsed content, we must recurse to avoid security problems. |
| 2548 | - if ($tag['type'] != 'unparsed_equals') |
|
| 2549 | - $data = parse_bbc($data, !empty($tag['parsed_tags_allowed']) ? false : true, '', !empty($tag['parsed_tags_allowed']) ? $tag['parsed_tags_allowed'] : array()); |
|
| 2686 | + if ($tag['type'] != 'unparsed_equals') { |
|
| 2687 | + $data = parse_bbc($data, !empty($tag['parsed_tags_allowed']) ? false : true, '', !empty($tag['parsed_tags_allowed']) ? $tag['parsed_tags_allowed'] : array()); |
|
| 2688 | + } |
|
| 2550 | 2689 | |
| 2551 | 2690 | $tag['after'] = strtr($tag['after'], array('$1' => $data)); |
| 2552 | 2691 | |
@@ -2558,34 +2697,40 @@ discard block |
||
| 2558 | 2697 | } |
| 2559 | 2698 | |
| 2560 | 2699 | // If this is block level, eat any breaks after it. |
| 2561 | - if (!empty($tag['block_level']) && substr($message, $pos + 1, 4) == '<br>') |
|
| 2562 | - $message = substr($message, 0, $pos + 1) . substr($message, $pos + 5); |
|
| 2700 | + if (!empty($tag['block_level']) && substr($message, $pos + 1, 4) == '<br>') { |
|
| 2701 | + $message = substr($message, 0, $pos + 1) . substr($message, $pos + 5); |
|
| 2702 | + } |
|
| 2563 | 2703 | |
| 2564 | 2704 | // Are we trimming outside this tag? |
| 2565 | - if (!empty($tag['trim']) && $tag['trim'] != 'outside' && preg_match('~(<br>| |\s)*~', substr($message, $pos + 1), $matches) != 0) |
|
| 2566 | - $message = substr($message, 0, $pos + 1) . substr($message, $pos + 1 + strlen($matches[0])); |
|
| 2705 | + if (!empty($tag['trim']) && $tag['trim'] != 'outside' && preg_match('~(<br>| |\s)*~', substr($message, $pos + 1), $matches) != 0) { |
|
| 2706 | + $message = substr($message, 0, $pos + 1) . substr($message, $pos + 1 + strlen($matches[0])); |
|
| 2707 | + } |
|
| 2567 | 2708 | } |
| 2568 | 2709 | |
| 2569 | 2710 | // Close any remaining tags. |
| 2570 | - while ($tag = array_pop($open_tags)) |
|
| 2571 | - $message .= "\n" . $tag['after'] . "\n"; |
|
| 2711 | + while ($tag = array_pop($open_tags)) { |
|
| 2712 | + $message .= "\n" . $tag['after'] . "\n"; |
|
| 2713 | + } |
|
| 2572 | 2714 | |
| 2573 | 2715 | // Parse the smileys within the parts where it can be done safely. |
| 2574 | 2716 | if ($smileys === true) |
| 2575 | 2717 | { |
| 2576 | 2718 | $message_parts = explode("\n", $message); |
| 2577 | - for ($i = 0, $n = count($message_parts); $i < $n; $i += 2) |
|
| 2578 | - parsesmileys($message_parts[$i]); |
|
| 2719 | + for ($i = 0, $n = count($message_parts); $i < $n; $i += 2) { |
|
| 2720 | + parsesmileys($message_parts[$i]); |
|
| 2721 | + } |
|
| 2579 | 2722 | |
| 2580 | 2723 | $message = implode('', $message_parts); |
| 2581 | 2724 | } |
| 2582 | 2725 | |
| 2583 | 2726 | // No smileys, just get rid of the markers. |
| 2584 | - else |
|
| 2585 | - $message = strtr($message, array("\n" => '')); |
|
| 2727 | + else { |
|
| 2728 | + $message = strtr($message, array("\n" => '')); |
|
| 2729 | + } |
|
| 2586 | 2730 | |
| 2587 | - if ($message !== '' && $message[0] === ' ') |
|
| 2588 | - $message = ' ' . substr($message, 1); |
|
| 2731 | + if ($message !== '' && $message[0] === ' ') { |
|
| 2732 | + $message = ' ' . substr($message, 1); |
|
| 2733 | + } |
|
| 2589 | 2734 | |
| 2590 | 2735 | // Cleanup whitespace. |
| 2591 | 2736 | $message = strtr($message, array(' ' => ' ', "\r" => '', "\n" => '<br>', '<br> ' => '<br> ', ' ' => "\n")); |
@@ -2594,15 +2739,16 @@ discard block |
||
| 2594 | 2739 | call_integration_hook('integrate_post_parsebbc', array(&$message, &$smileys, &$cache_id, &$parse_tags)); |
| 2595 | 2740 | |
| 2596 | 2741 | // Cache the output if it took some time... |
| 2597 | - if (isset($cache_key, $cache_t) && array_sum(explode(' ', microtime())) - array_sum(explode(' ', $cache_t)) > 0.05) |
|
| 2598 | - cache_put_data($cache_key, $message, 240); |
|
| 2742 | + if (isset($cache_key, $cache_t) && array_sum(explode(' ', microtime())) - array_sum(explode(' ', $cache_t)) > 0.05) { |
|
| 2743 | + cache_put_data($cache_key, $message, 240); |
|
| 2744 | + } |
|
| 2599 | 2745 | |
| 2600 | 2746 | // If this was a force parse revert if needed. |
| 2601 | 2747 | if (!empty($parse_tags)) |
| 2602 | 2748 | { |
| 2603 | - if (empty($temp_bbc)) |
|
| 2604 | - $bbc_codes = array(); |
|
| 2605 | - else |
|
| 2749 | + if (empty($temp_bbc)) { |
|
| 2750 | + $bbc_codes = array(); |
|
| 2751 | + } else |
|
| 2606 | 2752 | { |
| 2607 | 2753 | $bbc_codes = $temp_bbc; |
| 2608 | 2754 | unset($temp_bbc); |
@@ -2629,8 +2775,9 @@ discard block |
||
| 2629 | 2775 | static $smileyPregSearch = null, $smileyPregReplacements = array(); |
| 2630 | 2776 | |
| 2631 | 2777 | // No smiley set at all?! |
| 2632 | - if ($user_info['smiley_set'] == 'none' || trim($message) == '') |
|
| 2633 | - return; |
|
| 2778 | + if ($user_info['smiley_set'] == 'none' || trim($message) == '') { |
|
| 2779 | + return; |
|
| 2780 | + } |
|
| 2634 | 2781 | |
| 2635 | 2782 | // If smileyPregSearch hasn't been set, do it now. |
| 2636 | 2783 | if (empty($smileyPregSearch)) |
@@ -2641,8 +2788,7 @@ discard block |
||
| 2641 | 2788 | $smileysfrom = array('>:D', ':D', '::)', '>:(', ':))', ':)', ';)', ';D', ':(', ':o', '8)', ':P', '???', ':-[', ':-X', ':-*', ':\'(', ':-\\', '^-^', 'O0', 'C:-)', '0:)'); |
| 2642 | 2789 | $smileysto = array('evil.gif', 'cheesy.gif', 'rolleyes.gif', 'angry.gif', 'laugh.gif', 'smiley.gif', 'wink.gif', 'grin.gif', 'sad.gif', 'shocked.gif', 'cool.gif', 'tongue.gif', 'huh.gif', 'embarrassed.gif', 'lipsrsealed.gif', 'kiss.gif', 'cry.gif', 'undecided.gif', 'azn.gif', 'afro.gif', 'police.gif', 'angel.gif'); |
| 2643 | 2790 | $smileysdescs = array('', $txt['icon_cheesy'], $txt['icon_rolleyes'], $txt['icon_angry'], '', $txt['icon_smiley'], $txt['icon_wink'], $txt['icon_grin'], $txt['icon_sad'], $txt['icon_shocked'], $txt['icon_cool'], $txt['icon_tongue'], $txt['icon_huh'], $txt['icon_embarrassed'], $txt['icon_lips'], $txt['icon_kiss'], $txt['icon_cry'], $txt['icon_undecided'], '', '', '', ''); |
| 2644 | - } |
|
| 2645 | - else |
|
| 2791 | + } else |
|
| 2646 | 2792 | { |
| 2647 | 2793 | // Load the smileys in reverse order by length so they don't get parsed wrong. |
| 2648 | 2794 | if (($temp = cache_get_data('parsing_smileys', 480)) == null) |
@@ -2666,9 +2812,9 @@ discard block |
||
| 2666 | 2812 | $smcFunc['db_free_result']($result); |
| 2667 | 2813 | |
| 2668 | 2814 | cache_put_data('parsing_smileys', array($smileysfrom, $smileysto, $smileysdescs), 480); |
| 2815 | + } else { |
|
| 2816 | + list ($smileysfrom, $smileysto, $smileysdescs) = $temp; |
|
| 2669 | 2817 | } |
| 2670 | - else |
|
| 2671 | - list ($smileysfrom, $smileysto, $smileysdescs) = $temp; |
|
| 2672 | 2818 | } |
| 2673 | 2819 | |
| 2674 | 2820 | // The non-breaking-space is a complex thing... |
@@ -2745,35 +2891,41 @@ discard block |
||
| 2745 | 2891 | global $scripturl, $context, $modSettings, $db_show_debug, $db_cache; |
| 2746 | 2892 | |
| 2747 | 2893 | // In case we have mail to send, better do that - as obExit doesn't always quite make it... |
| 2748 | - if (!empty($context['flush_mail'])) |
|
| 2749 | - // @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\ |
|
| 2894 | + if (!empty($context['flush_mail'])) { |
|
| 2895 | + // @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\ |
|
| 2750 | 2896 | AddMailQueue(true); |
| 2897 | + } |
|
| 2751 | 2898 | |
| 2752 | 2899 | $add = preg_match('~^(ftp|http)[s]?://~', $setLocation) == 0 && substr($setLocation, 0, 6) != 'about:'; |
| 2753 | 2900 | |
| 2754 | - if ($add) |
|
| 2755 | - $setLocation = $scripturl . ($setLocation != '' ? '?' . $setLocation : ''); |
|
| 2901 | + if ($add) { |
|
| 2902 | + $setLocation = $scripturl . ($setLocation != '' ? '?' . $setLocation : ''); |
|
| 2903 | + } |
|
| 2756 | 2904 | |
| 2757 | 2905 | // Put the session ID in. |
| 2758 | - if (defined('SID') && SID != '') |
|
| 2759 | - $setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '(?!\?' . preg_quote(SID, '/') . ')\\??/', $scripturl . '?' . SID . ';', $setLocation); |
|
| 2906 | + if (defined('SID') && SID != '') { |
|
| 2907 | + $setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '(?!\?' . preg_quote(SID, '/') . ')\\??/', $scripturl . '?' . SID . ';', $setLocation); |
|
| 2908 | + } |
|
| 2760 | 2909 | // Keep that debug in their for template debugging! |
| 2761 | - elseif (isset($_GET['debug'])) |
|
| 2762 | - $setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '\\??/', $scripturl . '?debug;', $setLocation); |
|
| 2910 | + elseif (isset($_GET['debug'])) { |
|
| 2911 | + $setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '\\??/', $scripturl . '?debug;', $setLocation); |
|
| 2912 | + } |
|
| 2763 | 2913 | |
| 2764 | 2914 | if (!empty($modSettings['queryless_urls']) && (empty($context['server']['is_cgi']) || ini_get('cgi.fix_pathinfo') == 1 || @get_cfg_var('cgi.fix_pathinfo') == 1) && (!empty($context['server']['is_apache']) || !empty($context['server']['is_lighttpd']) || !empty($context['server']['is_litespeed']))) |
| 2765 | 2915 | { |
| 2766 | - if (defined('SID') && SID != '') |
|
| 2767 | - $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?(?:' . SID . '(?:;|&|&))((?:board|topic)=[^#]+?)(#[^"]*?)?$~', |
|
| 2916 | + if (defined('SID') && SID != '') { |
|
| 2917 | + $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?(?:' . SID . '(?:;|&|&))((?:board|topic)=[^#]+?)(#[^"]*?)?$~', |
|
| 2768 | 2918 | function ($m) use ($scripturl) |
| 2769 | 2919 | { |
| 2770 | 2920 | return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html?' . SID. (isset($m[2]) ? "$m[2]" : ""); |
| 2921 | + } |
|
| 2771 | 2922 | }, $setLocation); |
| 2772 | - else |
|
| 2773 | - $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?((?:board|topic)=[^#"]+?)(#[^"]*?)?$~', |
|
| 2923 | + else { |
|
| 2924 | + $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?((?:board|topic)=[^#"]+?)(#[^"]*?)?$~', |
|
| 2774 | 2925 | function ($m) use ($scripturl) |
| 2775 | 2926 | { |
| 2776 | 2927 | return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html' . (isset($m[2]) ? "$m[2]" : ""); |
| 2928 | + } |
|
| 2777 | 2929 | }, $setLocation); |
| 2778 | 2930 | } |
| 2779 | 2931 | |
@@ -2784,8 +2936,9 @@ discard block |
||
| 2784 | 2936 | header('Location: ' . str_replace(' ', '%20', $setLocation), true, $permanent ? 301 : 302); |
| 2785 | 2937 | |
| 2786 | 2938 | // Debugging. |
| 2787 | - if (isset($db_show_debug) && $db_show_debug === true) |
|
| 2788 | - $_SESSION['debug_redirect'] = $db_cache; |
|
| 2939 | + if (isset($db_show_debug) && $db_show_debug === true) { |
|
| 2940 | + $_SESSION['debug_redirect'] = $db_cache; |
|
| 2941 | + } |
|
| 2789 | 2942 | |
| 2790 | 2943 | obExit(false); |
| 2791 | 2944 | } |
@@ -2804,51 +2957,60 @@ discard block |
||
| 2804 | 2957 | |
| 2805 | 2958 | // Attempt to prevent a recursive loop. |
| 2806 | 2959 | ++$level; |
| 2807 | - if ($level > 1 && !$from_fatal_error && !$has_fatal_error) |
|
| 2808 | - exit; |
|
| 2809 | - if ($from_fatal_error) |
|
| 2810 | - $has_fatal_error = true; |
|
| 2960 | + if ($level > 1 && !$from_fatal_error && !$has_fatal_error) { |
|
| 2961 | + exit; |
|
| 2962 | + } |
|
| 2963 | + if ($from_fatal_error) { |
|
| 2964 | + $has_fatal_error = true; |
|
| 2965 | + } |
|
| 2811 | 2966 | |
| 2812 | 2967 | // Clear out the stat cache. |
| 2813 | 2968 | trackStats(); |
| 2814 | 2969 | |
| 2815 | 2970 | // If we have mail to send, send it. |
| 2816 | - if (!empty($context['flush_mail'])) |
|
| 2817 | - // @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\ |
|
| 2971 | + if (!empty($context['flush_mail'])) { |
|
| 2972 | + // @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\ |
|
| 2818 | 2973 | AddMailQueue(true); |
| 2974 | + } |
|
| 2819 | 2975 | |
| 2820 | 2976 | $do_header = $header === null ? !$header_done : $header; |
| 2821 | - if ($do_footer === null) |
|
| 2822 | - $do_footer = $do_header; |
|
| 2977 | + if ($do_footer === null) { |
|
| 2978 | + $do_footer = $do_header; |
|
| 2979 | + } |
|
| 2823 | 2980 | |
| 2824 | 2981 | // Has the template/header been done yet? |
| 2825 | 2982 | if ($do_header) |
| 2826 | 2983 | { |
| 2827 | 2984 | // Was the page title set last minute? Also update the HTML safe one. |
| 2828 | - if (!empty($context['page_title']) && empty($context['page_title_html_safe'])) |
|
| 2829 | - $context['page_title_html_safe'] = $smcFunc['htmlspecialchars'](un_htmlspecialchars($context['page_title'])) . (!empty($context['current_page']) ? ' - ' . $txt['page'] . ' ' . ($context['current_page'] + 1) : ''); |
|
| 2985 | + if (!empty($context['page_title']) && empty($context['page_title_html_safe'])) { |
|
| 2986 | + $context['page_title_html_safe'] = $smcFunc['htmlspecialchars'](un_htmlspecialchars($context['page_title'])) . (!empty($context['current_page']) ? ' - ' . $txt['page'] . ' ' . ($context['current_page'] + 1) : ''); |
|
| 2987 | + } |
|
| 2830 | 2988 | |
| 2831 | 2989 | // Start up the session URL fixer. |
| 2832 | 2990 | ob_start('ob_sessrewrite'); |
| 2833 | 2991 | |
| 2834 | - if (!empty($settings['output_buffers']) && is_string($settings['output_buffers'])) |
|
| 2835 | - $buffers = explode(',', $settings['output_buffers']); |
|
| 2836 | - elseif (!empty($settings['output_buffers'])) |
|
| 2837 | - $buffers = $settings['output_buffers']; |
|
| 2838 | - else |
|
| 2839 | - $buffers = array(); |
|
| 2992 | + if (!empty($settings['output_buffers']) && is_string($settings['output_buffers'])) { |
|
| 2993 | + $buffers = explode(',', $settings['output_buffers']); |
|
| 2994 | + } elseif (!empty($settings['output_buffers'])) { |
|
| 2995 | + $buffers = $settings['output_buffers']; |
|
| 2996 | + } else { |
|
| 2997 | + $buffers = array(); |
|
| 2998 | + } |
|
| 2840 | 2999 | |
| 2841 | - if (isset($modSettings['integrate_buffer'])) |
|
| 2842 | - $buffers = array_merge(explode(',', $modSettings['integrate_buffer']), $buffers); |
|
| 3000 | + if (isset($modSettings['integrate_buffer'])) { |
|
| 3001 | + $buffers = array_merge(explode(',', $modSettings['integrate_buffer']), $buffers); |
|
| 3002 | + } |
|
| 2843 | 3003 | |
| 2844 | - if (!empty($buffers)) |
|
| 2845 | - foreach ($buffers as $function) |
|
| 3004 | + if (!empty($buffers)) { |
|
| 3005 | + foreach ($buffers as $function) |
|
| 2846 | 3006 | { |
| 2847 | 3007 | $call = call_helper($function, true); |
| 3008 | + } |
|
| 2848 | 3009 | |
| 2849 | 3010 | // Is it valid? |
| 2850 | - if (!empty($call)) |
|
| 2851 | - ob_start($call); |
|
| 3011 | + if (!empty($call)) { |
|
| 3012 | + ob_start($call); |
|
| 3013 | + } |
|
| 2852 | 3014 | } |
| 2853 | 3015 | |
| 2854 | 3016 | // Display the screen in the logical order. |
@@ -2860,8 +3022,9 @@ discard block |
||
| 2860 | 3022 | loadSubTemplate(isset($context['sub_template']) ? $context['sub_template'] : 'main'); |
| 2861 | 3023 | |
| 2862 | 3024 | // Anything special to put out? |
| 2863 | - if (!empty($context['insert_after_template']) && !isset($_REQUEST['xml'])) |
|
| 2864 | - echo $context['insert_after_template']; |
|
| 3025 | + if (!empty($context['insert_after_template']) && !isset($_REQUEST['xml'])) { |
|
| 3026 | + echo $context['insert_after_template']; |
|
| 3027 | + } |
|
| 2865 | 3028 | |
| 2866 | 3029 | // Just so we don't get caught in an endless loop of errors from the footer... |
| 2867 | 3030 | if (!$footer_done) |
@@ -2870,14 +3033,16 @@ discard block |
||
| 2870 | 3033 | template_footer(); |
| 2871 | 3034 | |
| 2872 | 3035 | // (since this is just debugging... it's okay that it's after </html>.) |
| 2873 | - if (!isset($_REQUEST['xml'])) |
|
| 2874 | - displayDebug(); |
|
| 3036 | + if (!isset($_REQUEST['xml'])) { |
|
| 3037 | + displayDebug(); |
|
| 3038 | + } |
|
| 2875 | 3039 | } |
| 2876 | 3040 | } |
| 2877 | 3041 | |
| 2878 | 3042 | // Remember this URL in case someone doesn't like sending HTTP_REFERER. |
| 2879 | - if (strpos($_SERVER['REQUEST_URL'], 'action=dlattach') === false && strpos($_SERVER['REQUEST_URL'], 'action=viewsmfile') === false) |
|
| 2880 | - $_SESSION['old_url'] = $_SERVER['REQUEST_URL']; |
|
| 3043 | + if (strpos($_SERVER['REQUEST_URL'], 'action=dlattach') === false && strpos($_SERVER['REQUEST_URL'], 'action=viewsmfile') === false) { |
|
| 3044 | + $_SESSION['old_url'] = $_SERVER['REQUEST_URL']; |
|
| 3045 | + } |
|
| 2881 | 3046 | |
| 2882 | 3047 | // For session check verification.... don't switch browsers... |
| 2883 | 3048 | $_SESSION['USER_AGENT'] = empty($_SERVER['HTTP_USER_AGENT']) ? '' : $_SERVER['HTTP_USER_AGENT']; |
@@ -2886,9 +3051,10 @@ discard block |
||
| 2886 | 3051 | call_integration_hook('integrate_exit', array($do_footer)); |
| 2887 | 3052 | |
| 2888 | 3053 | // Don't exit if we're coming from index.php; that will pass through normally. |
| 2889 | - if (!$from_index) |
|
| 2890 | - exit; |
|
| 2891 | -} |
|
| 3054 | + if (!$from_index) { |
|
| 3055 | + exit; |
|
| 3056 | + } |
|
| 3057 | + } |
|
| 2892 | 3058 | |
| 2893 | 3059 | /** |
| 2894 | 3060 | * Get the size of a specified image with better error handling. |
@@ -2907,8 +3073,9 @@ discard block |
||
| 2907 | 3073 | $url = str_replace(' ', '%20', $url); |
| 2908 | 3074 | |
| 2909 | 3075 | // Can we pull this from the cache... please please? |
| 2910 | - if (($temp = cache_get_data('url_image_size-' . md5($url), 240)) !== null) |
|
| 2911 | - return $temp; |
|
| 3076 | + if (($temp = cache_get_data('url_image_size-' . md5($url), 240)) !== null) { |
|
| 3077 | + return $temp; |
|
| 3078 | + } |
|
| 2912 | 3079 | $t = microtime(); |
| 2913 | 3080 | |
| 2914 | 3081 | // Get the host to pester... |
@@ -2918,12 +3085,10 @@ discard block |
||
| 2918 | 3085 | if ($url == '' || $url == 'http://' || $url == 'https://') |
| 2919 | 3086 | { |
| 2920 | 3087 | return false; |
| 2921 | - } |
|
| 2922 | - elseif (!isset($match[1])) |
|
| 3088 | + } elseif (!isset($match[1])) |
|
| 2923 | 3089 | { |
| 2924 | 3090 | $size = @getimagesize($url); |
| 2925 | - } |
|
| 2926 | - else |
|
| 3091 | + } else |
|
| 2927 | 3092 | { |
| 2928 | 3093 | // Try to connect to the server... give it half a second. |
| 2929 | 3094 | $temp = 0; |
@@ -2962,12 +3127,14 @@ discard block |
||
| 2962 | 3127 | } |
| 2963 | 3128 | |
| 2964 | 3129 | // If we didn't get it, we failed. |
| 2965 | - if (!isset($size)) |
|
| 2966 | - $size = false; |
|
| 3130 | + if (!isset($size)) { |
|
| 3131 | + $size = false; |
|
| 3132 | + } |
|
| 2967 | 3133 | |
| 2968 | 3134 | // If this took a long time, we may never have to do it again, but then again we might... |
| 2969 | - if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $t)) > 0.8) |
|
| 2970 | - cache_put_data('url_image_size-' . md5($url), $size, 240); |
|
| 3135 | + if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $t)) > 0.8) { |
|
| 3136 | + cache_put_data('url_image_size-' . md5($url), $size, 240); |
|
| 3137 | + } |
|
| 2971 | 3138 | |
| 2972 | 3139 | // Didn't work. |
| 2973 | 3140 | return $size; |
@@ -2985,8 +3152,9 @@ discard block |
||
| 2985 | 3152 | |
| 2986 | 3153 | // Under SSI this function can be called more then once. That can cause some problems. |
| 2987 | 3154 | // So only run the function once unless we are forced to run it again. |
| 2988 | - if ($loaded && !$forceload) |
|
| 2989 | - return; |
|
| 3155 | + if ($loaded && !$forceload) { |
|
| 3156 | + return; |
|
| 3157 | + } |
|
| 2990 | 3158 | |
| 2991 | 3159 | $loaded = true; |
| 2992 | 3160 | |
@@ -2998,14 +3166,16 @@ discard block |
||
| 2998 | 3166 | $context['news_lines'] = array_filter(explode("\n", str_replace("\r", '', trim(addslashes($modSettings['news']))))); |
| 2999 | 3167 | for ($i = 0, $n = count($context['news_lines']); $i < $n; $i++) |
| 3000 | 3168 | { |
| 3001 | - if (trim($context['news_lines'][$i]) == '') |
|
| 3002 | - continue; |
|
| 3169 | + if (trim($context['news_lines'][$i]) == '') { |
|
| 3170 | + continue; |
|
| 3171 | + } |
|
| 3003 | 3172 | |
| 3004 | 3173 | // Clean it up for presentation ;). |
| 3005 | 3174 | $context['news_lines'][$i] = parse_bbc(stripslashes(trim($context['news_lines'][$i])), true, 'news' . $i); |
| 3006 | 3175 | } |
| 3007 | - if (!empty($context['news_lines'])) |
|
| 3008 | - $context['random_news_line'] = $context['news_lines'][mt_rand(0, count($context['news_lines']) - 1)]; |
|
| 3176 | + if (!empty($context['news_lines'])) { |
|
| 3177 | + $context['random_news_line'] = $context['news_lines'][mt_rand(0, count($context['news_lines']) - 1)]; |
|
| 3178 | + } |
|
| 3009 | 3179 | |
| 3010 | 3180 | if (!$user_info['is_guest']) |
| 3011 | 3181 | { |
@@ -3014,40 +3184,48 @@ discard block |
||
| 3014 | 3184 | $context['user']['alerts'] = &$user_info['alerts']; |
| 3015 | 3185 | |
| 3016 | 3186 | // Personal message popup... |
| 3017 | - if ($user_info['unread_messages'] > (isset($_SESSION['unread_messages']) ? $_SESSION['unread_messages'] : 0)) |
|
| 3018 | - $context['user']['popup_messages'] = true; |
|
| 3019 | - else |
|
| 3020 | - $context['user']['popup_messages'] = false; |
|
| 3187 | + if ($user_info['unread_messages'] > (isset($_SESSION['unread_messages']) ? $_SESSION['unread_messages'] : 0)) { |
|
| 3188 | + $context['user']['popup_messages'] = true; |
|
| 3189 | + } else { |
|
| 3190 | + $context['user']['popup_messages'] = false; |
|
| 3191 | + } |
|
| 3021 | 3192 | $_SESSION['unread_messages'] = $user_info['unread_messages']; |
| 3022 | 3193 | |
| 3023 | - if (allowedTo('moderate_forum')) |
|
| 3024 | - $context['unapproved_members'] = (!empty($modSettings['registration_method']) && ($modSettings['registration_method'] == 2 || (!empty($modSettings['coppaType']) && $modSettings['coppaType'] == 2))) || !empty($modSettings['approveAccountDeletion']) ? $modSettings['unapprovedMembers'] : 0; |
|
| 3194 | + if (allowedTo('moderate_forum')) { |
|
| 3195 | + $context['unapproved_members'] = (!empty($modSettings['registration_method']) && ($modSettings['registration_method'] == 2 || (!empty($modSettings['coppaType']) && $modSettings['coppaType'] == 2))) || !empty($modSettings['approveAccountDeletion']) ? $modSettings['unapprovedMembers'] : 0; |
|
| 3196 | + } |
|
| 3025 | 3197 | |
| 3026 | 3198 | $context['user']['avatar'] = array(); |
| 3027 | 3199 | |
| 3028 | 3200 | // Check for gravatar first since we might be forcing them... |
| 3029 | 3201 | if (($modSettings['gravatarEnabled'] && substr($user_info['avatar']['url'], 0, 11) == 'gravatar://') || !empty($modSettings['gravatarOverride'])) |
| 3030 | 3202 | { |
| 3031 | - if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($user_info['avatar']['url'], 'gravatar://') && strlen($user_info['avatar']['url']) > 11) |
|
| 3032 | - $context['user']['avatar']['href'] = get_gravatar_url($smcFunc['substr']($user_info['avatar']['url'], 11)); |
|
| 3033 | - else |
|
| 3034 | - $context['user']['avatar']['href'] = get_gravatar_url($user_info['email']); |
|
| 3203 | + if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($user_info['avatar']['url'], 'gravatar://') && strlen($user_info['avatar']['url']) > 11) { |
|
| 3204 | + $context['user']['avatar']['href'] = get_gravatar_url($smcFunc['substr']($user_info['avatar']['url'], 11)); |
|
| 3205 | + } else { |
|
| 3206 | + $context['user']['avatar']['href'] = get_gravatar_url($user_info['email']); |
|
| 3207 | + } |
|
| 3035 | 3208 | } |
| 3036 | 3209 | // Uploaded? |
| 3037 | - elseif ($user_info['avatar']['url'] == '' && !empty($user_info['avatar']['id_attach'])) |
|
| 3038 | - $context['user']['avatar']['href'] = $user_info['avatar']['custom_dir'] ? $modSettings['custom_avatar_url'] . '/' . $user_info['avatar']['filename'] : $scripturl . '?action=dlattach;attach=' . $user_info['avatar']['id_attach'] . ';type=avatar'; |
|
| 3210 | + elseif ($user_info['avatar']['url'] == '' && !empty($user_info['avatar']['id_attach'])) { |
|
| 3211 | + $context['user']['avatar']['href'] = $user_info['avatar']['custom_dir'] ? $modSettings['custom_avatar_url'] . '/' . $user_info['avatar']['filename'] : $scripturl . '?action=dlattach;attach=' . $user_info['avatar']['id_attach'] . ';type=avatar'; |
|
| 3212 | + } |
|
| 3039 | 3213 | // Full URL? |
| 3040 | - elseif (strpos($user_info['avatar']['url'], 'http://') === 0 || strpos($user_info['avatar']['url'], 'https://') === 0) |
|
| 3041 | - $context['user']['avatar']['href'] = $user_info['avatar']['url']; |
|
| 3214 | + elseif (strpos($user_info['avatar']['url'], 'http://') === 0 || strpos($user_info['avatar']['url'], 'https://') === 0) { |
|
| 3215 | + $context['user']['avatar']['href'] = $user_info['avatar']['url']; |
|
| 3216 | + } |
|
| 3042 | 3217 | // Otherwise we assume it's server stored. |
| 3043 | - elseif ($user_info['avatar']['url'] != '') |
|
| 3044 | - $context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/' . $smcFunc['htmlspecialchars']($user_info['avatar']['url']); |
|
| 3218 | + elseif ($user_info['avatar']['url'] != '') { |
|
| 3219 | + $context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/' . $smcFunc['htmlspecialchars']($user_info['avatar']['url']); |
|
| 3220 | + } |
|
| 3045 | 3221 | // No avatar at all? Fine, we have a big fat default avatar ;) |
| 3046 | - else |
|
| 3047 | - $context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/default.png'; |
|
| 3222 | + else { |
|
| 3223 | + $context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/default.png'; |
|
| 3224 | + } |
|
| 3048 | 3225 | |
| 3049 | - if (!empty($context['user']['avatar'])) |
|
| 3050 | - $context['user']['avatar']['image'] = '<img src="' . $context['user']['avatar']['href'] . '" alt="" class="avatar">'; |
|
| 3226 | + if (!empty($context['user']['avatar'])) { |
|
| 3227 | + $context['user']['avatar']['image'] = '<img src="' . $context['user']['avatar']['href'] . '" alt="" class="avatar">'; |
|
| 3228 | + } |
|
| 3051 | 3229 | |
| 3052 | 3230 | // Figure out how long they've been logged in. |
| 3053 | 3231 | $context['user']['total_time_logged_in'] = array( |
@@ -3055,8 +3233,7 @@ discard block |
||
| 3055 | 3233 | 'hours' => floor(($user_info['total_time_logged_in'] % 86400) / 3600), |
| 3056 | 3234 | 'minutes' => floor(($user_info['total_time_logged_in'] % 3600) / 60) |
| 3057 | 3235 | ); |
| 3058 | - } |
|
| 3059 | - else |
|
| 3236 | + } else |
|
| 3060 | 3237 | { |
| 3061 | 3238 | $context['user']['messages'] = 0; |
| 3062 | 3239 | $context['user']['unread_messages'] = 0; |
@@ -3064,12 +3241,14 @@ discard block |
||
| 3064 | 3241 | $context['user']['total_time_logged_in'] = array('days' => 0, 'hours' => 0, 'minutes' => 0); |
| 3065 | 3242 | $context['user']['popup_messages'] = false; |
| 3066 | 3243 | |
| 3067 | - if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 1) |
|
| 3068 | - $txt['welcome_guest'] .= $txt['welcome_guest_activate']; |
|
| 3244 | + if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 1) { |
|
| 3245 | + $txt['welcome_guest'] .= $txt['welcome_guest_activate']; |
|
| 3246 | + } |
|
| 3069 | 3247 | |
| 3070 | 3248 | // If we've upgraded recently, go easy on the passwords. |
| 3071 | - if (!empty($modSettings['disableHashTime']) && ($modSettings['disableHashTime'] == 1 || time() < $modSettings['disableHashTime'])) |
|
| 3072 | - $context['disable_login_hashing'] = true; |
|
| 3249 | + if (!empty($modSettings['disableHashTime']) && ($modSettings['disableHashTime'] == 1 || time() < $modSettings['disableHashTime'])) { |
|
| 3250 | + $context['disable_login_hashing'] = true; |
|
| 3251 | + } |
|
| 3073 | 3252 | } |
| 3074 | 3253 | |
| 3075 | 3254 | // Setup the main menu items. |
@@ -3082,8 +3261,8 @@ discard block |
||
| 3082 | 3261 | $context['show_pm_popup'] = $context['user']['popup_messages'] && !empty($options['popup_messages']) && (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'pm'); |
| 3083 | 3262 | |
| 3084 | 3263 | // 2.1+: Add the PM popup here instead. Theme authors can still override it simply by editing/removing the 'fPmPopup' in the array. |
| 3085 | - if ($context['show_pm_popup']) |
|
| 3086 | - addInlineJavaScript(' |
|
| 3264 | + if ($context['show_pm_popup']) { |
|
| 3265 | + addInlineJavaScript(' |
|
| 3087 | 3266 | jQuery(document).ready(function($) { |
| 3088 | 3267 | new smc_Popup({ |
| 3089 | 3268 | heading: ' . JavaScriptEscape($txt['show_personal_messages_heading']) . ', |
@@ -3091,15 +3270,17 @@ discard block |
||
| 3091 | 3270 | icon_class: \'generic_icons mail_new\' |
| 3092 | 3271 | }); |
| 3093 | 3272 | });'); |
| 3273 | + } |
|
| 3094 | 3274 | |
| 3095 | 3275 | // Add a generic "Are you sure?" confirmation message. |
| 3096 | 3276 | addInlineJavaScript(' |
| 3097 | 3277 | var smf_you_sure =' . JavaScriptEscape($txt['quickmod_confirm']) .';'); |
| 3098 | 3278 | |
| 3099 | 3279 | // Now add the capping code for avatars. |
| 3100 | - if (!empty($modSettings['avatar_max_width_external']) && !empty($modSettings['avatar_max_height_external']) && !empty($modSettings['avatar_action_too_large']) && $modSettings['avatar_action_too_large'] == 'option_css_resize') |
|
| 3101 | - addInlineCss(' |
|
| 3280 | + if (!empty($modSettings['avatar_max_width_external']) && !empty($modSettings['avatar_max_height_external']) && !empty($modSettings['avatar_action_too_large']) && $modSettings['avatar_action_too_large'] == 'option_css_resize') { |
|
| 3281 | + addInlineCss(' |
|
| 3102 | 3282 | img.avatar { max-width: ' . $modSettings['avatar_max_width_external'] . 'px; max-height: ' . $modSettings['avatar_max_height_external'] . 'px; }'); |
| 3283 | + } |
|
| 3103 | 3284 | |
| 3104 | 3285 | // This looks weird, but it's because BoardIndex.php references the variable. |
| 3105 | 3286 | $context['common_stats']['latest_member'] = array( |
@@ -3116,11 +3297,13 @@ discard block |
||
| 3116 | 3297 | ); |
| 3117 | 3298 | $context['common_stats']['boardindex_total_posts'] = sprintf($txt['boardindex_total_posts'], $context['common_stats']['total_posts'], $context['common_stats']['total_topics'], $context['common_stats']['total_members']); |
| 3118 | 3299 | |
| 3119 | - if (empty($settings['theme_version'])) |
|
| 3120 | - addJavaScriptVar('smf_scripturl', $scripturl); |
|
| 3300 | + if (empty($settings['theme_version'])) { |
|
| 3301 | + addJavaScriptVar('smf_scripturl', $scripturl); |
|
| 3302 | + } |
|
| 3121 | 3303 | |
| 3122 | - if (!isset($context['page_title'])) |
|
| 3123 | - $context['page_title'] = ''; |
|
| 3304 | + if (!isset($context['page_title'])) { |
|
| 3305 | + $context['page_title'] = ''; |
|
| 3306 | + } |
|
| 3124 | 3307 | |
| 3125 | 3308 | // Set some specific vars. |
| 3126 | 3309 | $context['page_title_html_safe'] = $smcFunc['htmlspecialchars'](un_htmlspecialchars($context['page_title'])) . (!empty($context['current_page']) ? ' - ' . $txt['page'] . ' ' . ($context['current_page'] + 1) : ''); |
@@ -3130,21 +3313,23 @@ discard block |
||
| 3130 | 3313 | $context['meta_tags'][] = array('property' => 'og:site_name', 'content' => $context['forum_name']); |
| 3131 | 3314 | $context['meta_tags'][] = array('property' => 'og:title', 'content' => $context['page_title_html_safe']); |
| 3132 | 3315 | |
| 3133 | - if (!empty($context['meta_keywords'])) |
|
| 3134 | - $context['meta_tags'][] = array('name' => 'keywords', 'content' => $context['meta_keywords']); |
|
| 3316 | + if (!empty($context['meta_keywords'])) { |
|
| 3317 | + $context['meta_tags'][] = array('name' => 'keywords', 'content' => $context['meta_keywords']); |
|
| 3318 | + } |
|
| 3135 | 3319 | |
| 3136 | - if (!empty($context['canonical_url'])) |
|
| 3137 | - $context['meta_tags'][] = array('property' => 'og:url', 'content' => $context['canonical_url']); |
|
| 3320 | + if (!empty($context['canonical_url'])) { |
|
| 3321 | + $context['meta_tags'][] = array('property' => 'og:url', 'content' => $context['canonical_url']); |
|
| 3322 | + } |
|
| 3138 | 3323 | |
| 3139 | - if (!empty($settings['og_image'])) |
|
| 3140 | - $context['meta_tags'][] = array('property' => 'og:image', 'content' => $settings['og_image']); |
|
| 3324 | + if (!empty($settings['og_image'])) { |
|
| 3325 | + $context['meta_tags'][] = array('property' => 'og:image', 'content' => $settings['og_image']); |
|
| 3326 | + } |
|
| 3141 | 3327 | |
| 3142 | 3328 | if (!empty($context['meta_description'])) |
| 3143 | 3329 | { |
| 3144 | 3330 | $context['meta_tags'][] = array('property' => 'og:description', 'content' => $context['meta_description']); |
| 3145 | 3331 | $context['meta_tags'][] = array('name' => 'description', 'content' => $context['meta_description']); |
| 3146 | - } |
|
| 3147 | - else |
|
| 3332 | + } else |
|
| 3148 | 3333 | { |
| 3149 | 3334 | $context['meta_tags'][] = array('property' => 'og:description', 'content' => $context['page_title_html_safe']); |
| 3150 | 3335 | $context['meta_tags'][] = array('name' => 'description', 'content' => $context['page_title_html_safe']); |
@@ -3169,8 +3354,9 @@ discard block |
||
| 3169 | 3354 | $memory_needed = memoryReturnBytes($needed); |
| 3170 | 3355 | |
| 3171 | 3356 | // should we account for how much is currently being used? |
| 3172 | - if ($in_use) |
|
| 3173 | - $memory_needed += function_exists('memory_get_usage') ? memory_get_usage() : (2 * 1048576); |
|
| 3357 | + if ($in_use) { |
|
| 3358 | + $memory_needed += function_exists('memory_get_usage') ? memory_get_usage() : (2 * 1048576); |
|
| 3359 | + } |
|
| 3174 | 3360 | |
| 3175 | 3361 | // if more is needed, request it |
| 3176 | 3362 | if ($memory_current < $memory_needed) |
@@ -3193,8 +3379,9 @@ discard block |
||
| 3193 | 3379 | */ |
| 3194 | 3380 | function memoryReturnBytes($val) |
| 3195 | 3381 | { |
| 3196 | - if (is_integer($val)) |
|
| 3197 | - return $val; |
|
| 3382 | + if (is_integer($val)) { |
|
| 3383 | + return $val; |
|
| 3384 | + } |
|
| 3198 | 3385 | |
| 3199 | 3386 | // Separate the number from the designator |
| 3200 | 3387 | $val = trim($val); |
@@ -3230,10 +3417,11 @@ discard block |
||
| 3230 | 3417 | header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); |
| 3231 | 3418 | |
| 3232 | 3419 | // Are we debugging the template/html content? |
| 3233 | - if (!isset($_REQUEST['xml']) && isset($_GET['debug']) && !isBrowser('ie')) |
|
| 3234 | - header('Content-Type: application/xhtml+xml'); |
|
| 3235 | - elseif (!isset($_REQUEST['xml'])) |
|
| 3236 | - header('Content-Type: text/html; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
| 3420 | + if (!isset($_REQUEST['xml']) && isset($_GET['debug']) && !isBrowser('ie')) { |
|
| 3421 | + header('Content-Type: application/xhtml+xml'); |
|
| 3422 | + } elseif (!isset($_REQUEST['xml'])) { |
|
| 3423 | + header('Content-Type: text/html; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
| 3424 | + } |
|
| 3237 | 3425 | } |
| 3238 | 3426 | |
| 3239 | 3427 | header('Content-Type: text/' . (isset($_REQUEST['xml']) ? 'xml' : 'html') . '; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
@@ -3242,8 +3430,9 @@ discard block |
||
| 3242 | 3430 | if ($context['in_maintenance'] && $context['user']['is_admin']) |
| 3243 | 3431 | { |
| 3244 | 3432 | $position = array_search('body', $context['template_layers']); |
| 3245 | - if ($position === false) |
|
| 3246 | - $position = array_search('main', $context['template_layers']); |
|
| 3433 | + if ($position === false) { |
|
| 3434 | + $position = array_search('main', $context['template_layers']); |
|
| 3435 | + } |
|
| 3247 | 3436 | |
| 3248 | 3437 | if ($position !== false) |
| 3249 | 3438 | { |
@@ -3271,23 +3460,25 @@ discard block |
||
| 3271 | 3460 | |
| 3272 | 3461 | foreach ($securityFiles as $i => $securityFile) |
| 3273 | 3462 | { |
| 3274 | - if (!file_exists($boarddir . '/' . $securityFile)) |
|
| 3275 | - unset($securityFiles[$i]); |
|
| 3463 | + if (!file_exists($boarddir . '/' . $securityFile)) { |
|
| 3464 | + unset($securityFiles[$i]); |
|
| 3465 | + } |
|
| 3276 | 3466 | } |
| 3277 | 3467 | |
| 3278 | 3468 | // We are already checking so many files...just few more doesn't make any difference! :P |
| 3279 | - if (!empty($modSettings['currentAttachmentUploadDir'])) |
|
| 3280 | - $path = $modSettings['attachmentUploadDir'][$modSettings['currentAttachmentUploadDir']]; |
|
| 3281 | - |
|
| 3282 | - else |
|
| 3283 | - $path = $modSettings['attachmentUploadDir']; |
|
| 3469 | + if (!empty($modSettings['currentAttachmentUploadDir'])) { |
|
| 3470 | + $path = $modSettings['attachmentUploadDir'][$modSettings['currentAttachmentUploadDir']]; |
|
| 3471 | + } else { |
|
| 3472 | + $path = $modSettings['attachmentUploadDir']; |
|
| 3473 | + } |
|
| 3284 | 3474 | |
| 3285 | 3475 | secureDirectory($path, true); |
| 3286 | 3476 | secureDirectory($cachedir); |
| 3287 | 3477 | |
| 3288 | 3478 | // If agreement is enabled, at least the english version shall exists |
| 3289 | - if ($modSettings['requireAgreement']) |
|
| 3290 | - $agreement = !file_exists($boarddir . '/agreement.txt'); |
|
| 3479 | + if ($modSettings['requireAgreement']) { |
|
| 3480 | + $agreement = !file_exists($boarddir . '/agreement.txt'); |
|
| 3481 | + } |
|
| 3291 | 3482 | |
| 3292 | 3483 | if (!empty($securityFiles) || (!empty($modSettings['cache_enable']) && !is_writable($cachedir)) || !empty($agreement)) |
| 3293 | 3484 | { |
@@ -3302,18 +3493,21 @@ discard block |
||
| 3302 | 3493 | echo ' |
| 3303 | 3494 | ', $txt['not_removed'], '<strong>', $securityFile, '</strong>!<br>'; |
| 3304 | 3495 | |
| 3305 | - if ($securityFile == 'Settings.php~' || $securityFile == 'Settings_bak.php~') |
|
| 3306 | - echo ' |
|
| 3496 | + if ($securityFile == 'Settings.php~' || $securityFile == 'Settings_bak.php~') { |
|
| 3497 | + echo ' |
|
| 3307 | 3498 | ', sprintf($txt['not_removed_extra'], $securityFile, substr($securityFile, 0, -1)), '<br>'; |
| 3499 | + } |
|
| 3308 | 3500 | } |
| 3309 | 3501 | |
| 3310 | - if (!empty($modSettings['cache_enable']) && !is_writable($cachedir)) |
|
| 3311 | - echo ' |
|
| 3502 | + if (!empty($modSettings['cache_enable']) && !is_writable($cachedir)) { |
|
| 3503 | + echo ' |
|
| 3312 | 3504 | <strong>', $txt['cache_writable'], '</strong><br>'; |
| 3505 | + } |
|
| 3313 | 3506 | |
| 3314 | - if (!empty($agreement)) |
|
| 3315 | - echo ' |
|
| 3507 | + if (!empty($agreement)) { |
|
| 3508 | + echo ' |
|
| 3316 | 3509 | <strong>', $txt['agreement_missing'], '</strong><br>'; |
| 3510 | + } |
|
| 3317 | 3511 | |
| 3318 | 3512 | echo ' |
| 3319 | 3513 | </p> |
@@ -3328,16 +3522,18 @@ discard block |
||
| 3328 | 3522 | <div class="windowbg alert" style="margin: 2ex; padding: 2ex; border: 2px dashed red;"> |
| 3329 | 3523 | ', sprintf($txt['you_are_post_banned'], $user_info['is_guest'] ? $txt['guest_title'] : $user_info['name']); |
| 3330 | 3524 | |
| 3331 | - if (!empty($_SESSION['ban']['cannot_post']['reason'])) |
|
| 3332 | - echo ' |
|
| 3525 | + if (!empty($_SESSION['ban']['cannot_post']['reason'])) { |
|
| 3526 | + echo ' |
|
| 3333 | 3527 | <div style="padding-left: 4ex; padding-top: 1ex;">', $_SESSION['ban']['cannot_post']['reason'], '</div>'; |
| 3528 | + } |
|
| 3334 | 3529 | |
| 3335 | - if (!empty($_SESSION['ban']['expire_time'])) |
|
| 3336 | - echo ' |
|
| 3530 | + if (!empty($_SESSION['ban']['expire_time'])) { |
|
| 3531 | + echo ' |
|
| 3337 | 3532 | <div>', sprintf($txt['your_ban_expires'], timeformat($_SESSION['ban']['expire_time'], false)), '</div>'; |
| 3338 | - else |
|
| 3339 | - echo ' |
|
| 3533 | + } else { |
|
| 3534 | + echo ' |
|
| 3340 | 3535 | <div>', $txt['your_ban_expires_never'], '</div>'; |
| 3536 | + } |
|
| 3341 | 3537 | |
| 3342 | 3538 | echo ' |
| 3343 | 3539 | </div>'; |
@@ -3353,8 +3549,9 @@ discard block |
||
| 3353 | 3549 | global $forum_copyright, $software_year, $forum_version; |
| 3354 | 3550 | |
| 3355 | 3551 | // Don't display copyright for things like SSI. |
| 3356 | - if (!isset($forum_version) || !isset($software_year)) |
|
| 3357 | - return; |
|
| 3552 | + if (!isset($forum_version) || !isset($software_year)) { |
|
| 3553 | + return; |
|
| 3554 | + } |
|
| 3358 | 3555 | |
| 3359 | 3556 | // Put in the version... |
| 3360 | 3557 | printf($forum_copyright, $forum_version, $software_year); |
@@ -3372,9 +3569,10 @@ discard block |
||
| 3372 | 3569 | $context['load_time'] = comma_format(round(array_sum(explode(' ', microtime())) - array_sum(explode(' ', $time_start)), 3)); |
| 3373 | 3570 | $context['load_queries'] = $db_count; |
| 3374 | 3571 | |
| 3375 | - foreach (array_reverse($context['template_layers']) as $layer) |
|
| 3376 | - loadSubTemplate($layer . '_below', true); |
|
| 3377 | -} |
|
| 3572 | + foreach (array_reverse($context['template_layers']) as $layer) { |
|
| 3573 | + loadSubTemplate($layer . '_below', true); |
|
| 3574 | + } |
|
| 3575 | + } |
|
| 3378 | 3576 | |
| 3379 | 3577 | /** |
| 3380 | 3578 | * Output the Javascript files |
@@ -3405,8 +3603,7 @@ discard block |
||
| 3405 | 3603 | { |
| 3406 | 3604 | echo ' |
| 3407 | 3605 | var ', $key, ';'; |
| 3408 | - } |
|
| 3409 | - else |
|
| 3606 | + } else |
|
| 3410 | 3607 | { |
| 3411 | 3608 | echo ' |
| 3412 | 3609 | var ', $key, ' = ', $value, ';'; |
@@ -3421,26 +3618,27 @@ discard block |
||
| 3421 | 3618 | foreach ($context['javascript_files'] as $id => $js_file) |
| 3422 | 3619 | { |
| 3423 | 3620 | // Last minute call! allow theme authors to disable single files. |
| 3424 | - if (!empty($settings['disable_files']) && in_array($id, $settings['disable_files'])) |
|
| 3425 | - continue; |
|
| 3621 | + if (!empty($settings['disable_files']) && in_array($id, $settings['disable_files'])) { |
|
| 3622 | + continue; |
|
| 3623 | + } |
|
| 3426 | 3624 | |
| 3427 | 3625 | // By default all files don't get minimized unless the file explicitly says so! |
| 3428 | 3626 | if (!empty($js_file['options']['minimize']) && !empty($modSettings['minimize_files'])) |
| 3429 | 3627 | { |
| 3430 | - if ($do_deferred && !empty($js_file['options']['defer'])) |
|
| 3431 | - $toMinifyDefer[] = $js_file; |
|
| 3432 | - |
|
| 3433 | - elseif (!$do_deferred && empty($js_file['options']['defer'])) |
|
| 3434 | - $toMinify[] = $js_file; |
|
| 3628 | + if ($do_deferred && !empty($js_file['options']['defer'])) { |
|
| 3629 | + $toMinifyDefer[] = $js_file; |
|
| 3630 | + } elseif (!$do_deferred && empty($js_file['options']['defer'])) { |
|
| 3631 | + $toMinify[] = $js_file; |
|
| 3632 | + } |
|
| 3435 | 3633 | |
| 3436 | 3634 | // Grab a random seed. |
| 3437 | - if (!isset($minSeed)) |
|
| 3438 | - $minSeed = $js_file['options']['seed']; |
|
| 3439 | - } |
|
| 3440 | - |
|
| 3441 | - elseif ((!$do_deferred && empty($js_file['options']['defer'])) || ($do_deferred && !empty($js_file['options']['defer']))) |
|
| 3442 | - echo ' |
|
| 3635 | + if (!isset($minSeed)) { |
|
| 3636 | + $minSeed = $js_file['options']['seed']; |
|
| 3637 | + } |
|
| 3638 | + } elseif ((!$do_deferred && empty($js_file['options']['defer'])) || ($do_deferred && !empty($js_file['options']['defer']))) { |
|
| 3639 | + echo ' |
|
| 3443 | 3640 | <script src="', $js_file['fileUrl'], '"', !empty($js_file['options']['async']) ? ' async="async"' : '', '></script>'; |
| 3641 | + } |
|
| 3444 | 3642 | } |
| 3445 | 3643 | |
| 3446 | 3644 | if ((!$do_deferred && !empty($toMinify)) || ($do_deferred && !empty($toMinifyDefer))) |
@@ -3448,14 +3646,14 @@ discard block |
||
| 3448 | 3646 | $result = custMinify(($do_deferred ? $toMinifyDefer : $toMinify), 'js', $do_deferred); |
| 3449 | 3647 | |
| 3450 | 3648 | // Minify process couldn't work, print each individual files. |
| 3451 | - if (!empty($result) && is_array($result)) |
|
| 3452 | - foreach ($result as $minFailedFile) |
|
| 3649 | + if (!empty($result) && is_array($result)) { |
|
| 3650 | + foreach ($result as $minFailedFile) |
|
| 3453 | 3651 | echo ' |
| 3454 | 3652 | <script src="', $minFailedFile['fileUrl'], '"', !empty($minFailedFile['options']['async']) ? ' async="async"' : '', '></script>'; |
| 3455 | - |
|
| 3456 | - else |
|
| 3457 | - echo ' |
|
| 3653 | + } else { |
|
| 3654 | + echo ' |
|
| 3458 | 3655 | <script src="', $settings['theme_url'] ,'/scripts/minified', ($do_deferred ? '_deferred' : '') ,'.js', $minSeed ,'"></script>'; |
| 3656 | + } |
|
| 3459 | 3657 | } |
| 3460 | 3658 | |
| 3461 | 3659 | // Inline JavaScript - Actually useful some times! |
@@ -3466,8 +3664,9 @@ discard block |
||
| 3466 | 3664 | echo ' |
| 3467 | 3665 | <script>'; |
| 3468 | 3666 | |
| 3469 | - foreach ($context['javascript_inline']['defer'] as $js_code) |
|
| 3470 | - echo $js_code; |
|
| 3667 | + foreach ($context['javascript_inline']['defer'] as $js_code) { |
|
| 3668 | + echo $js_code; |
|
| 3669 | + } |
|
| 3471 | 3670 | |
| 3472 | 3671 | echo ' |
| 3473 | 3672 | </script>'; |
@@ -3478,8 +3677,9 @@ discard block |
||
| 3478 | 3677 | echo ' |
| 3479 | 3678 | <script>'; |
| 3480 | 3679 | |
| 3481 | - foreach ($context['javascript_inline']['standard'] as $js_code) |
|
| 3482 | - echo $js_code; |
|
| 3680 | + foreach ($context['javascript_inline']['standard'] as $js_code) { |
|
| 3681 | + echo $js_code; |
|
| 3682 | + } |
|
| 3483 | 3683 | |
| 3484 | 3684 | echo ' |
| 3485 | 3685 | </script>'; |
@@ -3504,8 +3704,9 @@ discard block |
||
| 3504 | 3704 | foreach ($context['css_files'] as $id => $file) |
| 3505 | 3705 | { |
| 3506 | 3706 | // Last minute call! allow theme authors to disable single files. |
| 3507 | - if (!empty($settings['disable_files']) && in_array($id, $settings['disable_files'])) |
|
| 3508 | - continue; |
|
| 3707 | + if (!empty($settings['disable_files']) && in_array($id, $settings['disable_files'])) { |
|
| 3708 | + continue; |
|
| 3709 | + } |
|
| 3509 | 3710 | |
| 3510 | 3711 | // By default all files don't get minimized unless the file explicitly says so! |
| 3511 | 3712 | if (!empty($file['options']['minimize']) && !empty($modSettings['minimize_files'])) |
@@ -3513,12 +3714,12 @@ discard block |
||
| 3513 | 3714 | $toMinify[] = $file; |
| 3514 | 3715 | |
| 3515 | 3716 | // Grab a random seed. |
| 3516 | - if (!isset($minSeed)) |
|
| 3517 | - $minSeed = $file['options']['seed']; |
|
| 3717 | + if (!isset($minSeed)) { |
|
| 3718 | + $minSeed = $file['options']['seed']; |
|
| 3719 | + } |
|
| 3720 | + } else { |
|
| 3721 | + $normal[] = $file['fileUrl']; |
|
| 3518 | 3722 | } |
| 3519 | - |
|
| 3520 | - else |
|
| 3521 | - $normal[] = $file['fileUrl']; |
|
| 3522 | 3723 | } |
| 3523 | 3724 | |
| 3524 | 3725 | if (!empty($toMinify)) |
@@ -3526,28 +3727,30 @@ discard block |
||
| 3526 | 3727 | $result = custMinify($toMinify, 'css'); |
| 3527 | 3728 | |
| 3528 | 3729 | // Minify process couldn't work, print each individual files. |
| 3529 | - if (!empty($result) && is_array($result)) |
|
| 3530 | - foreach ($result as $minFailedFile) |
|
| 3730 | + if (!empty($result) && is_array($result)) { |
|
| 3731 | + foreach ($result as $minFailedFile) |
|
| 3531 | 3732 | echo ' |
| 3532 | 3733 | <link rel="stylesheet" href="', $minFailedFile['fileUrl'], '">'; |
| 3533 | - |
|
| 3534 | - else |
|
| 3535 | - echo ' |
|
| 3734 | + } else { |
|
| 3735 | + echo ' |
|
| 3536 | 3736 | <link rel="stylesheet" href="', $settings['theme_url'] ,'/css/minified.css', $minSeed ,'">'; |
| 3737 | + } |
|
| 3537 | 3738 | } |
| 3538 | 3739 | |
| 3539 | 3740 | // Print the rest after the minified files. |
| 3540 | - if (!empty($normal)) |
|
| 3541 | - foreach ($normal as $nf) |
|
| 3741 | + if (!empty($normal)) { |
|
| 3742 | + foreach ($normal as $nf) |
|
| 3542 | 3743 | echo ' |
| 3543 | 3744 | <link rel="stylesheet" href="', $nf ,'">'; |
| 3745 | + } |
|
| 3544 | 3746 | |
| 3545 | 3747 | if ($db_show_debug === true) |
| 3546 | 3748 | { |
| 3547 | 3749 | // Try to keep only what's useful. |
| 3548 | 3750 | $repl = array($boardurl . '/Themes/' => '', $boardurl . '/' => ''); |
| 3549 | - foreach ($context['css_files'] as $file) |
|
| 3550 | - $context['debug']['sheets'][] = strtr($file['fileName'], $repl); |
|
| 3751 | + foreach ($context['css_files'] as $file) { |
|
| 3752 | + $context['debug']['sheets'][] = strtr($file['fileName'], $repl); |
|
| 3753 | + } |
|
| 3551 | 3754 | } |
| 3552 | 3755 | |
| 3553 | 3756 | if (!empty($context['css_header'])) |
@@ -3555,9 +3758,10 @@ discard block |
||
| 3555 | 3758 | echo ' |
| 3556 | 3759 | <style>'; |
| 3557 | 3760 | |
| 3558 | - foreach ($context['css_header'] as $css) |
|
| 3559 | - echo $css .' |
|
| 3761 | + foreach ($context['css_header'] as $css) { |
|
| 3762 | + echo $css .' |
|
| 3560 | 3763 | '; |
| 3764 | + } |
|
| 3561 | 3765 | |
| 3562 | 3766 | echo' |
| 3563 | 3767 | </style>'; |
@@ -3581,15 +3785,17 @@ discard block |
||
| 3581 | 3785 | $type = !empty($type) && in_array($type, $types) ? $type : false; |
| 3582 | 3786 | $data = !empty($data) ? $data : false; |
| 3583 | 3787 | |
| 3584 | - if (empty($type) || empty($data)) |
|
| 3585 | - return false; |
|
| 3788 | + if (empty($type) || empty($data)) { |
|
| 3789 | + return false; |
|
| 3790 | + } |
|
| 3586 | 3791 | |
| 3587 | 3792 | // Did we already did this? |
| 3588 | 3793 | $toCache = cache_get_data('minimized_'. $settings['theme_id'] .'_'. $type, 86400); |
| 3589 | 3794 | |
| 3590 | 3795 | // Already done? |
| 3591 | - if (!empty($toCache)) |
|
| 3592 | - return true; |
|
| 3796 | + if (!empty($toCache)) { |
|
| 3797 | + return true; |
|
| 3798 | + } |
|
| 3593 | 3799 | |
| 3594 | 3800 | // Yep, need a bunch of files. |
| 3595 | 3801 | require_once($sourcedir . '/minify/src/Minify.php'); |
@@ -3677,8 +3883,9 @@ discard block |
||
| 3677 | 3883 | global $modSettings, $smcFunc; |
| 3678 | 3884 | |
| 3679 | 3885 | // Just make up a nice hash... |
| 3680 | - if ($new) |
|
| 3681 | - return sha1(md5($filename . time()) . mt_rand()); |
|
| 3886 | + if ($new) { |
|
| 3887 | + return sha1(md5($filename . time()) . mt_rand()); |
|
| 3888 | + } |
|
| 3682 | 3889 | |
| 3683 | 3890 | // Grab the file hash if it wasn't added. |
| 3684 | 3891 | // Left this for legacy. |
@@ -3692,23 +3899,25 @@ discard block |
||
| 3692 | 3899 | 'id_attach' => $attachment_id, |
| 3693 | 3900 | )); |
| 3694 | 3901 | |
| 3695 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
| 3696 | - return false; |
|
| 3902 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
| 3903 | + return false; |
|
| 3904 | + } |
|
| 3697 | 3905 | |
| 3698 | 3906 | list ($file_hash) = $smcFunc['db_fetch_row']($request); |
| 3699 | 3907 | $smcFunc['db_free_result']($request); |
| 3700 | 3908 | } |
| 3701 | 3909 | |
| 3702 | 3910 | // Still no hash? mmm... |
| 3703 | - if (empty($file_hash)) |
|
| 3704 | - $file_hash = sha1(md5($filename . time()) . mt_rand()); |
|
| 3911 | + if (empty($file_hash)) { |
|
| 3912 | + $file_hash = sha1(md5($filename . time()) . mt_rand()); |
|
| 3913 | + } |
|
| 3705 | 3914 | |
| 3706 | 3915 | // Are we using multiple directories? |
| 3707 | - if (!empty($modSettings['currentAttachmentUploadDir'])) |
|
| 3708 | - $path = $modSettings['attachmentUploadDir'][$dir]; |
|
| 3709 | - |
|
| 3710 | - else |
|
| 3711 | - $path = $modSettings['attachmentUploadDir']; |
|
| 3916 | + if (!empty($modSettings['currentAttachmentUploadDir'])) { |
|
| 3917 | + $path = $modSettings['attachmentUploadDir'][$dir]; |
|
| 3918 | + } else { |
|
| 3919 | + $path = $modSettings['attachmentUploadDir']; |
|
| 3920 | + } |
|
| 3712 | 3921 | |
| 3713 | 3922 | return $path . '/' . $attachment_id . '_' . $file_hash .'.dat'; |
| 3714 | 3923 | } |
@@ -3723,8 +3932,9 @@ discard block |
||
| 3723 | 3932 | function ip2range($fullip) |
| 3724 | 3933 | { |
| 3725 | 3934 | // Pretend that 'unknown' is 255.255.255.255. (since that can't be an IP anyway.) |
| 3726 | - if ($fullip == 'unknown') |
|
| 3727 | - $fullip = '255.255.255.255'; |
|
| 3935 | + if ($fullip == 'unknown') { |
|
| 3936 | + $fullip = '255.255.255.255'; |
|
| 3937 | + } |
|
| 3728 | 3938 | |
| 3729 | 3939 | $ip_parts = explode('-', $fullip); |
| 3730 | 3940 | $ip_array = array(); |
@@ -3748,10 +3958,11 @@ discard block |
||
| 3748 | 3958 | $ip_array['low'] = $ip_parts[0]; |
| 3749 | 3959 | $ip_array['high'] = $ip_parts[1]; |
| 3750 | 3960 | return $ip_array; |
| 3751 | - } |
|
| 3752 | - elseif (count($ip_parts) == 2) // if ip 22.22.*-22.22.* |
|
| 3961 | + } elseif (count($ip_parts) == 2) { |
|
| 3962 | + // if ip 22.22.*-22.22.* |
|
| 3753 | 3963 | { |
| 3754 | 3964 | $valid_low = isValidIP($ip_parts[0]); |
| 3965 | + } |
|
| 3755 | 3966 | $valid_high = isValidIP($ip_parts[1]); |
| 3756 | 3967 | $count = 0; |
| 3757 | 3968 | $mode = (preg_match('/:/',$ip_parts[0]) > 0 ? ':' : '.'); |
@@ -3766,7 +3977,9 @@ discard block |
||
| 3766 | 3977 | $ip_parts[0] .= $mode . $min; |
| 3767 | 3978 | $valid_low = isValidIP($ip_parts[0]); |
| 3768 | 3979 | $count++; |
| 3769 | - if ($count > 9) break; |
|
| 3980 | + if ($count > 9) { |
|
| 3981 | + break; |
|
| 3982 | + } |
|
| 3770 | 3983 | } |
| 3771 | 3984 | } |
| 3772 | 3985 | |
@@ -3780,7 +3993,9 @@ discard block |
||
| 3780 | 3993 | $ip_parts[1] .= $mode . $max; |
| 3781 | 3994 | $valid_high = isValidIP($ip_parts[1]); |
| 3782 | 3995 | $count++; |
| 3783 | - if ($count > 9) break; |
|
| 3996 | + if ($count > 9) { |
|
| 3997 | + break; |
|
| 3998 | + } |
|
| 3784 | 3999 | } |
| 3785 | 4000 | } |
| 3786 | 4001 | |
@@ -3805,46 +4020,54 @@ discard block |
||
| 3805 | 4020 | { |
| 3806 | 4021 | global $modSettings; |
| 3807 | 4022 | |
| 3808 | - if (($host = cache_get_data('hostlookup-' . $ip, 600)) !== null) |
|
| 3809 | - return $host; |
|
| 4023 | + if (($host = cache_get_data('hostlookup-' . $ip, 600)) !== null) { |
|
| 4024 | + return $host; |
|
| 4025 | + } |
|
| 3810 | 4026 | $t = microtime(); |
| 3811 | 4027 | |
| 3812 | 4028 | // Try the Linux host command, perhaps? |
| 3813 | 4029 | if (!isset($host) && (strpos(strtolower(PHP_OS), 'win') === false || strpos(strtolower(PHP_OS), 'darwin') !== false) && mt_rand(0, 1) == 1) |
| 3814 | 4030 | { |
| 3815 | - if (!isset($modSettings['host_to_dis'])) |
|
| 3816 | - $test = @shell_exec('host -W 1 ' . @escapeshellarg($ip)); |
|
| 3817 | - else |
|
| 3818 | - $test = @shell_exec('host ' . @escapeshellarg($ip)); |
|
| 4031 | + if (!isset($modSettings['host_to_dis'])) { |
|
| 4032 | + $test = @shell_exec('host -W 1 ' . @escapeshellarg($ip)); |
|
| 4033 | + } else { |
|
| 4034 | + $test = @shell_exec('host ' . @escapeshellarg($ip)); |
|
| 4035 | + } |
|
| 3819 | 4036 | |
| 3820 | 4037 | // Did host say it didn't find anything? |
| 3821 | - if (strpos($test, 'not found') !== false) |
|
| 3822 | - $host = ''; |
|
| 4038 | + if (strpos($test, 'not found') !== false) { |
|
| 4039 | + $host = ''; |
|
| 4040 | + } |
|
| 3823 | 4041 | // Invalid server option? |
| 3824 | - elseif ((strpos($test, 'invalid option') || strpos($test, 'Invalid query name 1')) && !isset($modSettings['host_to_dis'])) |
|
| 3825 | - updateSettings(array('host_to_dis' => 1)); |
|
| 4042 | + elseif ((strpos($test, 'invalid option') || strpos($test, 'Invalid query name 1')) && !isset($modSettings['host_to_dis'])) { |
|
| 4043 | + updateSettings(array('host_to_dis' => 1)); |
|
| 4044 | + } |
|
| 3826 | 4045 | // Maybe it found something, after all? |
| 3827 | - elseif (preg_match('~\s([^\s]+?)\.\s~', $test, $match) == 1) |
|
| 3828 | - $host = $match[1]; |
|
| 4046 | + elseif (preg_match('~\s([^\s]+?)\.\s~', $test, $match) == 1) { |
|
| 4047 | + $host = $match[1]; |
|
| 4048 | + } |
|
| 3829 | 4049 | } |
| 3830 | 4050 | |
| 3831 | 4051 | // This is nslookup; usually only Windows, but possibly some Unix? |
| 3832 | 4052 | if (!isset($host) && stripos(PHP_OS, 'win') !== false && strpos(strtolower(PHP_OS), 'darwin') === false && mt_rand(0, 1) == 1) |
| 3833 | 4053 | { |
| 3834 | 4054 | $test = @shell_exec('nslookup -timeout=1 ' . @escapeshellarg($ip)); |
| 3835 | - if (strpos($test, 'Non-existent domain') !== false) |
|
| 3836 | - $host = ''; |
|
| 3837 | - elseif (preg_match('~Name:\s+([^\s]+)~', $test, $match) == 1) |
|
| 3838 | - $host = $match[1]; |
|
| 4055 | + if (strpos($test, 'Non-existent domain') !== false) { |
|
| 4056 | + $host = ''; |
|
| 4057 | + } elseif (preg_match('~Name:\s+([^\s]+)~', $test, $match) == 1) { |
|
| 4058 | + $host = $match[1]; |
|
| 4059 | + } |
|
| 3839 | 4060 | } |
| 3840 | 4061 | |
| 3841 | 4062 | // This is the last try :/. |
| 3842 | - if (!isset($host) || $host === false) |
|
| 3843 | - $host = @gethostbyaddr($ip); |
|
| 4063 | + if (!isset($host) || $host === false) { |
|
| 4064 | + $host = @gethostbyaddr($ip); |
|
| 4065 | + } |
|
| 3844 | 4066 | |
| 3845 | 4067 | // It took a long time, so let's cache it! |
| 3846 | - if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $t)) > 0.5) |
|
| 3847 | - cache_put_data('hostlookup-' . $ip, $host, 600); |
|
| 4068 | + if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $t)) > 0.5) { |
|
| 4069 | + cache_put_data('hostlookup-' . $ip, $host, 600); |
|
| 4070 | + } |
|
| 3848 | 4071 | |
| 3849 | 4072 | return $host; |
| 3850 | 4073 | } |
@@ -3880,20 +4103,21 @@ discard block |
||
| 3880 | 4103 | { |
| 3881 | 4104 | $encrypted = substr(crypt($word, 'uk'), 2, $max_chars); |
| 3882 | 4105 | $total = 0; |
| 3883 | - for ($i = 0; $i < $max_chars; $i++) |
|
| 3884 | - $total += $possible_chars[ord($encrypted{$i})] * pow(63, $i); |
|
| 4106 | + for ($i = 0; $i < $max_chars; $i++) { |
|
| 4107 | + $total += $possible_chars[ord($encrypted{$i})] * pow(63, $i); |
|
| 4108 | + } |
|
| 3885 | 4109 | $returned_ints[] = $max_chars == 4 ? min($total, 16777215) : $total; |
| 3886 | 4110 | } |
| 3887 | 4111 | } |
| 3888 | 4112 | return array_unique($returned_ints); |
| 3889 | - } |
|
| 3890 | - else |
|
| 4113 | + } else |
|
| 3891 | 4114 | { |
| 3892 | 4115 | // Trim characters before and after and add slashes for database insertion. |
| 3893 | 4116 | $returned_words = array(); |
| 3894 | - foreach ($words as $word) |
|
| 3895 | - if (($word = trim($word, '-_\'')) !== '') |
|
| 4117 | + foreach ($words as $word) { |
|
| 4118 | + if (($word = trim($word, '-_\'')) !== '') |
|
| 3896 | 4119 | $returned_words[] = $max_chars === null ? $word : substr($word, 0, $max_chars); |
| 4120 | + } |
|
| 3897 | 4121 | |
| 3898 | 4122 | // Filter out all words that occur more than once. |
| 3899 | 4123 | return array_unique($returned_words); |
@@ -3915,16 +4139,18 @@ discard block |
||
| 3915 | 4139 | global $settings, $txt; |
| 3916 | 4140 | |
| 3917 | 4141 | // Does the current loaded theme have this and we are not forcing the usage of this function? |
| 3918 | - if (function_exists('template_create_button') && !$force_use) |
|
| 3919 | - return template_create_button($name, $alt, $label = '', $custom = ''); |
|
| 4142 | + if (function_exists('template_create_button') && !$force_use) { |
|
| 4143 | + return template_create_button($name, $alt, $label = '', $custom = ''); |
|
| 4144 | + } |
|
| 3920 | 4145 | |
| 3921 | - if (!$settings['use_image_buttons']) |
|
| 3922 | - return $txt[$alt]; |
|
| 3923 | - elseif (!empty($settings['use_buttons'])) |
|
| 3924 | - return '<span class="generic_icons ' . $name . '" alt="' . $txt[$alt] . '"></span>' . ($label != '' ? ' <strong>' . $txt[$label] . '</strong>' : ''); |
|
| 3925 | - else |
|
| 3926 | - return '<img src="' . $settings['lang_images_url'] . '/' . $name . '" alt="' . $txt[$alt] . '" ' . $custom . '>'; |
|
| 3927 | -} |
|
| 4146 | + if (!$settings['use_image_buttons']) { |
|
| 4147 | + return $txt[$alt]; |
|
| 4148 | + } elseif (!empty($settings['use_buttons'])) { |
|
| 4149 | + return '<span class="generic_icons ' . $name . '" alt="' . $txt[$alt] . '"></span>' . ($label != '' ? ' <strong>' . $txt[$label] . '</strong>' : ''); |
|
| 4150 | + } else { |
|
| 4151 | + return '<img src="' . $settings['lang_images_url'] . '/' . $name . '" alt="' . $txt[$alt] . '" ' . $custom . '>'; |
|
| 4152 | + } |
|
| 4153 | + } |
|
| 3928 | 4154 | |
| 3929 | 4155 | /** |
| 3930 | 4156 | * Sets up all of the top menu buttons |
@@ -3967,9 +4193,10 @@ discard block |
||
| 3967 | 4193 | var user_menus = new smc_PopupMenu(); |
| 3968 | 4194 | user_menus.add("profile", "' . $scripturl . '?action=profile;area=popup"); |
| 3969 | 4195 | user_menus.add("alerts", "' . $scripturl . '?action=profile;area=alerts_popup;u='. $context['user']['id'] .'");', true); |
| 3970 | - if ($context['allow_pm']) |
|
| 3971 | - addInlineJavaScript(' |
|
| 4196 | + if ($context['allow_pm']) { |
|
| 4197 | + addInlineJavaScript(' |
|
| 3972 | 4198 | user_menus.add("pm", "' . $scripturl . '?action=pm;sa=popup");', true); |
| 4199 | + } |
|
| 3973 | 4200 | |
| 3974 | 4201 | if (!empty($modSettings['enable_ajax_alerts'])) |
| 3975 | 4202 | { |
@@ -4129,88 +4356,96 @@ discard block |
||
| 4129 | 4356 | |
| 4130 | 4357 | // Now we put the buttons in the context so the theme can use them. |
| 4131 | 4358 | $menu_buttons = array(); |
| 4132 | - foreach ($buttons as $act => $button) |
|
| 4133 | - if (!empty($button['show'])) |
|
| 4359 | + foreach ($buttons as $act => $button) { |
|
| 4360 | + if (!empty($button['show'])) |
|
| 4134 | 4361 | { |
| 4135 | 4362 | $button['active_button'] = false; |
| 4363 | + } |
|
| 4136 | 4364 | |
| 4137 | 4365 | // This button needs some action. |
| 4138 | - if (isset($button['action_hook'])) |
|
| 4139 | - $needs_action_hook = true; |
|
| 4366 | + if (isset($button['action_hook'])) { |
|
| 4367 | + $needs_action_hook = true; |
|
| 4368 | + } |
|
| 4140 | 4369 | |
| 4141 | 4370 | // Make sure the last button truly is the last button. |
| 4142 | 4371 | if (!empty($button['is_last'])) |
| 4143 | 4372 | { |
| 4144 | - if (isset($last_button)) |
|
| 4145 | - unset($menu_buttons[$last_button]['is_last']); |
|
| 4373 | + if (isset($last_button)) { |
|
| 4374 | + unset($menu_buttons[$last_button]['is_last']); |
|
| 4375 | + } |
|
| 4146 | 4376 | $last_button = $act; |
| 4147 | 4377 | } |
| 4148 | 4378 | |
| 4149 | 4379 | // Go through the sub buttons if there are any. |
| 4150 | - if (!empty($button['sub_buttons'])) |
|
| 4151 | - foreach ($button['sub_buttons'] as $key => $subbutton) |
|
| 4380 | + if (!empty($button['sub_buttons'])) { |
|
| 4381 | + foreach ($button['sub_buttons'] as $key => $subbutton) |
|
| 4152 | 4382 | { |
| 4153 | 4383 | if (empty($subbutton['show'])) |
| 4154 | 4384 | unset($button['sub_buttons'][$key]); |
| 4385 | + } |
|
| 4155 | 4386 | |
| 4156 | 4387 | // 2nd level sub buttons next... |
| 4157 | 4388 | if (!empty($subbutton['sub_buttons'])) |
| 4158 | 4389 | { |
| 4159 | 4390 | foreach ($subbutton['sub_buttons'] as $key2 => $sub_button2) |
| 4160 | 4391 | { |
| 4161 | - if (empty($sub_button2['show'])) |
|
| 4162 | - unset($button['sub_buttons'][$key]['sub_buttons'][$key2]); |
|
| 4392 | + if (empty($sub_button2['show'])) { |
|
| 4393 | + unset($button['sub_buttons'][$key]['sub_buttons'][$key2]); |
|
| 4394 | + } |
|
| 4163 | 4395 | } |
| 4164 | 4396 | } |
| 4165 | 4397 | } |
| 4166 | 4398 | |
| 4167 | 4399 | // Does this button have its own icon? |
| 4168 | - if (isset($button['icon']) && file_exists($settings['theme_dir'] . '/images/' . $button['icon'])) |
|
| 4169 | - $button['icon'] = '<img src="' . $settings['images_url'] . '/' . $button['icon'] . '" alt="">'; |
|
| 4170 | - elseif (isset($button['icon']) && file_exists($settings['default_theme_dir'] . '/images/' . $button['icon'])) |
|
| 4171 | - $button['icon'] = '<img src="' . $settings['default_images_url'] . '/' . $button['icon'] . '" alt="">'; |
|
| 4172 | - elseif (isset($button['icon'])) |
|
| 4173 | - $button['icon'] = '<span class="generic_icons ' . $button['icon'] . '"></span>'; |
|
| 4174 | - else |
|
| 4175 | - $button['icon'] = '<span class="generic_icons ' . $act . '"></span>'; |
|
| 4400 | + if (isset($button['icon']) && file_exists($settings['theme_dir'] . '/images/' . $button['icon'])) { |
|
| 4401 | + $button['icon'] = '<img src="' . $settings['images_url'] . '/' . $button['icon'] . '" alt="">'; |
|
| 4402 | + } elseif (isset($button['icon']) && file_exists($settings['default_theme_dir'] . '/images/' . $button['icon'])) { |
|
| 4403 | + $button['icon'] = '<img src="' . $settings['default_images_url'] . '/' . $button['icon'] . '" alt="">'; |
|
| 4404 | + } elseif (isset($button['icon'])) { |
|
| 4405 | + $button['icon'] = '<span class="generic_icons ' . $button['icon'] . '"></span>'; |
|
| 4406 | + } else { |
|
| 4407 | + $button['icon'] = '<span class="generic_icons ' . $act . '"></span>'; |
|
| 4408 | + } |
|
| 4176 | 4409 | |
| 4177 | 4410 | $menu_buttons[$act] = $button; |
| 4178 | 4411 | } |
| 4179 | 4412 | |
| 4180 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
| 4181 | - cache_put_data('menu_buttons-' . implode('_', $user_info['groups']) . '-' . $user_info['language'], $menu_buttons, $cacheTime); |
|
| 4413 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
| 4414 | + cache_put_data('menu_buttons-' . implode('_', $user_info['groups']) . '-' . $user_info['language'], $menu_buttons, $cacheTime); |
|
| 4415 | + } |
|
| 4182 | 4416 | } |
| 4183 | 4417 | |
| 4184 | 4418 | $context['menu_buttons'] = $menu_buttons; |
| 4185 | 4419 | |
| 4186 | 4420 | // Logging out requires the session id in the url. |
| 4187 | - if (isset($context['menu_buttons']['logout'])) |
|
| 4188 | - $context['menu_buttons']['logout']['href'] = sprintf($context['menu_buttons']['logout']['href'], $context['session_var'], $context['session_id']); |
|
| 4421 | + if (isset($context['menu_buttons']['logout'])) { |
|
| 4422 | + $context['menu_buttons']['logout']['href'] = sprintf($context['menu_buttons']['logout']['href'], $context['session_var'], $context['session_id']); |
|
| 4423 | + } |
|
| 4189 | 4424 | |
| 4190 | 4425 | // Figure out which action we are doing so we can set the active tab. |
| 4191 | 4426 | // Default to home. |
| 4192 | 4427 | $current_action = 'home'; |
| 4193 | 4428 | |
| 4194 | - if (isset($context['menu_buttons'][$context['current_action']])) |
|
| 4195 | - $current_action = $context['current_action']; |
|
| 4196 | - elseif ($context['current_action'] == 'search2') |
|
| 4197 | - $current_action = 'search'; |
|
| 4198 | - elseif ($context['current_action'] == 'theme') |
|
| 4199 | - $current_action = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'pick' ? 'profile' : 'admin'; |
|
| 4200 | - elseif ($context['current_action'] == 'register2') |
|
| 4201 | - $current_action = 'register'; |
|
| 4202 | - elseif ($context['current_action'] == 'login2' || ($user_info['is_guest'] && $context['current_action'] == 'reminder')) |
|
| 4203 | - $current_action = 'login'; |
|
| 4204 | - elseif ($context['current_action'] == 'groups' && $context['allow_moderation_center']) |
|
| 4205 | - $current_action = 'moderate'; |
|
| 4429 | + if (isset($context['menu_buttons'][$context['current_action']])) { |
|
| 4430 | + $current_action = $context['current_action']; |
|
| 4431 | + } elseif ($context['current_action'] == 'search2') { |
|
| 4432 | + $current_action = 'search'; |
|
| 4433 | + } elseif ($context['current_action'] == 'theme') { |
|
| 4434 | + $current_action = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'pick' ? 'profile' : 'admin'; |
|
| 4435 | + } elseif ($context['current_action'] == 'register2') { |
|
| 4436 | + $current_action = 'register'; |
|
| 4437 | + } elseif ($context['current_action'] == 'login2' || ($user_info['is_guest'] && $context['current_action'] == 'reminder')) { |
|
| 4438 | + $current_action = 'login'; |
|
| 4439 | + } elseif ($context['current_action'] == 'groups' && $context['allow_moderation_center']) { |
|
| 4440 | + $current_action = 'moderate'; |
|
| 4441 | + } |
|
| 4206 | 4442 | |
| 4207 | 4443 | // There are certain exceptions to the above where we don't want anything on the menu highlighted. |
| 4208 | 4444 | if ($context['current_action'] == 'profile' && !empty($context['user']['is_owner'])) |
| 4209 | 4445 | { |
| 4210 | 4446 | $current_action = !empty($_GET['area']) && $_GET['area'] == 'showalerts' ? 'self_alerts' : 'self_profile'; |
| 4211 | 4447 | $context[$current_action] = true; |
| 4212 | - } |
|
| 4213 | - elseif ($context['current_action'] == 'pm') |
|
| 4448 | + } elseif ($context['current_action'] == 'pm') |
|
| 4214 | 4449 | { |
| 4215 | 4450 | $current_action = 'self_pm'; |
| 4216 | 4451 | $context['self_pm'] = true; |
@@ -4253,12 +4488,14 @@ discard block |
||
| 4253 | 4488 | } |
| 4254 | 4489 | |
| 4255 | 4490 | // Not all actions are simple. |
| 4256 | - if (!empty($needs_action_hook)) |
|
| 4257 | - call_integration_hook('integrate_current_action', array(&$current_action)); |
|
| 4491 | + if (!empty($needs_action_hook)) { |
|
| 4492 | + call_integration_hook('integrate_current_action', array(&$current_action)); |
|
| 4493 | + } |
|
| 4258 | 4494 | |
| 4259 | - if (isset($context['menu_buttons'][$current_action])) |
|
| 4260 | - $context['menu_buttons'][$current_action]['active_button'] = true; |
|
| 4261 | -} |
|
| 4495 | + if (isset($context['menu_buttons'][$current_action])) { |
|
| 4496 | + $context['menu_buttons'][$current_action]['active_button'] = true; |
|
| 4497 | + } |
|
| 4498 | + } |
|
| 4262 | 4499 | |
| 4263 | 4500 | /** |
| 4264 | 4501 | * Generate a random seed and ensure it's stored in settings. |
@@ -4282,16 +4519,19 @@ discard block |
||
| 4282 | 4519 | global $modSettings, $settings, $boarddir, $sourcedir, $db_show_debug; |
| 4283 | 4520 | global $context, $txt; |
| 4284 | 4521 | |
| 4285 | - if ($db_show_debug === true) |
|
| 4286 | - $context['debug']['hooks'][] = $hook; |
|
| 4522 | + if ($db_show_debug === true) { |
|
| 4523 | + $context['debug']['hooks'][] = $hook; |
|
| 4524 | + } |
|
| 4287 | 4525 | |
| 4288 | 4526 | // Need to have some control. |
| 4289 | - if (!isset($context['instances'])) |
|
| 4290 | - $context['instances'] = array(); |
|
| 4527 | + if (!isset($context['instances'])) { |
|
| 4528 | + $context['instances'] = array(); |
|
| 4529 | + } |
|
| 4291 | 4530 | |
| 4292 | 4531 | $results = array(); |
| 4293 | - if (empty($modSettings[$hook])) |
|
| 4294 | - return $results; |
|
| 4532 | + if (empty($modSettings[$hook])) { |
|
| 4533 | + return $results; |
|
| 4534 | + } |
|
| 4295 | 4535 | |
| 4296 | 4536 | // Define some needed vars. |
| 4297 | 4537 | $function = false; |
@@ -4301,14 +4541,16 @@ discard block |
||
| 4301 | 4541 | foreach ($functions as $function) |
| 4302 | 4542 | { |
| 4303 | 4543 | // Hook has been marked as "disabled". Skip it! |
| 4304 | - if (strpos($function, '!') !== false) |
|
| 4305 | - continue; |
|
| 4544 | + if (strpos($function, '!') !== false) { |
|
| 4545 | + continue; |
|
| 4546 | + } |
|
| 4306 | 4547 | |
| 4307 | 4548 | $call = call_helper($function, true); |
| 4308 | 4549 | |
| 4309 | 4550 | // Is it valid? |
| 4310 | - if (!empty($call)) |
|
| 4311 | - $results[$function] = call_user_func_array($call, $parameters); |
|
| 4551 | + if (!empty($call)) { |
|
| 4552 | + $results[$function] = call_user_func_array($call, $parameters); |
|
| 4553 | + } |
|
| 4312 | 4554 | |
| 4313 | 4555 | // Whatever it was suppose to call, it failed :( |
| 4314 | 4556 | elseif (!empty($function)) |
@@ -4324,8 +4566,9 @@ discard block |
||
| 4324 | 4566 | } |
| 4325 | 4567 | |
| 4326 | 4568 | // "Assume" the file resides on $boarddir somewhere... |
| 4327 | - else |
|
| 4328 | - log_error(sprintf($txt['hook_fail_call_to'], $function, $boarddir), 'general'); |
|
| 4569 | + else { |
|
| 4570 | + log_error(sprintf($txt['hook_fail_call_to'], $function, $boarddir), 'general'); |
|
| 4571 | + } |
|
| 4329 | 4572 | } |
| 4330 | 4573 | } |
| 4331 | 4574 | |
@@ -4347,12 +4590,14 @@ discard block |
||
| 4347 | 4590 | global $smcFunc, $modSettings; |
| 4348 | 4591 | |
| 4349 | 4592 | // Any objects? |
| 4350 | - if ($object) |
|
| 4351 | - $function = $function . '#'; |
|
| 4593 | + if ($object) { |
|
| 4594 | + $function = $function . '#'; |
|
| 4595 | + } |
|
| 4352 | 4596 | |
| 4353 | 4597 | // Any files to load? |
| 4354 | - if (!empty($file) && is_string($file)) |
|
| 4355 | - $function = $file . (!empty($function) ? '|' . $function : ''); |
|
| 4598 | + if (!empty($file) && is_string($file)) { |
|
| 4599 | + $function = $file . (!empty($function) ? '|' . $function : ''); |
|
| 4600 | + } |
|
| 4356 | 4601 | |
| 4357 | 4602 | // Get the correct string. |
| 4358 | 4603 | $integration_call = $function; |
@@ -4374,13 +4619,14 @@ discard block |
||
| 4374 | 4619 | if (!empty($current_functions)) |
| 4375 | 4620 | { |
| 4376 | 4621 | $current_functions = explode(',', $current_functions); |
| 4377 | - if (in_array($integration_call, $current_functions)) |
|
| 4378 | - return; |
|
| 4622 | + if (in_array($integration_call, $current_functions)) { |
|
| 4623 | + return; |
|
| 4624 | + } |
|
| 4379 | 4625 | |
| 4380 | 4626 | $permanent_functions = array_merge($current_functions, array($integration_call)); |
| 4627 | + } else { |
|
| 4628 | + $permanent_functions = array($integration_call); |
|
| 4381 | 4629 | } |
| 4382 | - else |
|
| 4383 | - $permanent_functions = array($integration_call); |
|
| 4384 | 4630 | |
| 4385 | 4631 | updateSettings(array($hook => implode(',', $permanent_functions))); |
| 4386 | 4632 | } |
@@ -4389,8 +4635,9 @@ discard block |
||
| 4389 | 4635 | $functions = empty($modSettings[$hook]) ? array() : explode(',', $modSettings[$hook]); |
| 4390 | 4636 | |
| 4391 | 4637 | // Do nothing, if it's already there. |
| 4392 | - if (in_array($integration_call, $functions)) |
|
| 4393 | - return; |
|
| 4638 | + if (in_array($integration_call, $functions)) { |
|
| 4639 | + return; |
|
| 4640 | + } |
|
| 4394 | 4641 | |
| 4395 | 4642 | $functions[] = $integration_call; |
| 4396 | 4643 | $modSettings[$hook] = implode(',', $functions); |
@@ -4413,12 +4660,14 @@ discard block |
||
| 4413 | 4660 | global $smcFunc, $modSettings; |
| 4414 | 4661 | |
| 4415 | 4662 | // Any objects? |
| 4416 | - if ($object) |
|
| 4417 | - $function = $function . '#'; |
|
| 4663 | + if ($object) { |
|
| 4664 | + $function = $function . '#'; |
|
| 4665 | + } |
|
| 4418 | 4666 | |
| 4419 | 4667 | // Any files to load? |
| 4420 | - if (!empty($file) && is_string($file)) |
|
| 4421 | - $function = $file . '|' . $function; |
|
| 4668 | + if (!empty($file) && is_string($file)) { |
|
| 4669 | + $function = $file . '|' . $function; |
|
| 4670 | + } |
|
| 4422 | 4671 | |
| 4423 | 4672 | // Get the correct string. |
| 4424 | 4673 | $integration_call = $function; |
@@ -4439,16 +4688,18 @@ discard block |
||
| 4439 | 4688 | { |
| 4440 | 4689 | $current_functions = explode(',', $current_functions); |
| 4441 | 4690 | |
| 4442 | - if (in_array($integration_call, $current_functions)) |
|
| 4443 | - updateSettings(array($hook => implode(',', array_diff($current_functions, array($integration_call))))); |
|
| 4691 | + if (in_array($integration_call, $current_functions)) { |
|
| 4692 | + updateSettings(array($hook => implode(',', array_diff($current_functions, array($integration_call))))); |
|
| 4693 | + } |
|
| 4444 | 4694 | } |
| 4445 | 4695 | |
| 4446 | 4696 | // Turn the function list into something usable. |
| 4447 | 4697 | $functions = empty($modSettings[$hook]) ? array() : explode(',', $modSettings[$hook]); |
| 4448 | 4698 | |
| 4449 | 4699 | // You can only remove it if it's available. |
| 4450 | - if (!in_array($integration_call, $functions)) |
|
| 4451 | - return; |
|
| 4700 | + if (!in_array($integration_call, $functions)) { |
|
| 4701 | + return; |
|
| 4702 | + } |
|
| 4452 | 4703 | |
| 4453 | 4704 | $functions = array_diff($functions, array($integration_call)); |
| 4454 | 4705 | $modSettings[$hook] = implode(',', $functions); |
@@ -4469,17 +4720,20 @@ discard block |
||
| 4469 | 4720 | global $context, $smcFunc, $txt, $db_show_debug; |
| 4470 | 4721 | |
| 4471 | 4722 | // Really? |
| 4472 | - if (empty($string)) |
|
| 4473 | - return false; |
|
| 4723 | + if (empty($string)) { |
|
| 4724 | + return false; |
|
| 4725 | + } |
|
| 4474 | 4726 | |
| 4475 | 4727 | // An array? should be a "callable" array IE array(object/class, valid_callable). |
| 4476 | 4728 | // A closure? should be a callable one. |
| 4477 | - if (is_array($string) || $string instanceof Closure) |
|
| 4478 | - return $return ? $string : (is_callable($string) ? call_user_func($string) : false); |
|
| 4729 | + if (is_array($string) || $string instanceof Closure) { |
|
| 4730 | + return $return ? $string : (is_callable($string) ? call_user_func($string) : false); |
|
| 4731 | + } |
|
| 4479 | 4732 | |
| 4480 | 4733 | // No full objects, sorry! pass a method or a property instead! |
| 4481 | - if (is_object($string)) |
|
| 4482 | - return false; |
|
| 4734 | + if (is_object($string)) { |
|
| 4735 | + return false; |
|
| 4736 | + } |
|
| 4483 | 4737 | |
| 4484 | 4738 | // Stay vitaminized my friends... |
| 4485 | 4739 | $string = $smcFunc['htmlspecialchars']($smcFunc['htmltrim']($string)); |
@@ -4488,8 +4742,9 @@ discard block |
||
| 4488 | 4742 | $string = load_file($string); |
| 4489 | 4743 | |
| 4490 | 4744 | // Loaded file failed |
| 4491 | - if (empty($string)) |
|
| 4492 | - return false; |
|
| 4745 | + if (empty($string)) { |
|
| 4746 | + return false; |
|
| 4747 | + } |
|
| 4493 | 4748 | |
| 4494 | 4749 | // Found a method. |
| 4495 | 4750 | if (strpos($string, '::') !== false) |
@@ -4510,8 +4765,9 @@ discard block |
||
| 4510 | 4765 | // Add another one to the list. |
| 4511 | 4766 | if ($db_show_debug === true) |
| 4512 | 4767 | { |
| 4513 | - if (!isset($context['debug']['instances'])) |
|
| 4514 | - $context['debug']['instances'] = array(); |
|
| 4768 | + if (!isset($context['debug']['instances'])) { |
|
| 4769 | + $context['debug']['instances'] = array(); |
|
| 4770 | + } |
|
| 4515 | 4771 | |
| 4516 | 4772 | $context['debug']['instances'][$class] = $class; |
| 4517 | 4773 | } |
@@ -4521,13 +4777,15 @@ discard block |
||
| 4521 | 4777 | } |
| 4522 | 4778 | |
| 4523 | 4779 | // Right then. This is a call to a static method. |
| 4524 | - else |
|
| 4525 | - $func = array($class, $method); |
|
| 4780 | + else { |
|
| 4781 | + $func = array($class, $method); |
|
| 4782 | + } |
|
| 4526 | 4783 | } |
| 4527 | 4784 | |
| 4528 | 4785 | // Nope! just a plain regular function. |
| 4529 | - else |
|
| 4530 | - $func = $string; |
|
| 4786 | + else { |
|
| 4787 | + $func = $string; |
|
| 4788 | + } |
|
| 4531 | 4789 | |
| 4532 | 4790 | // Right, we got what we need, time to do some checks. |
| 4533 | 4791 | if (!is_callable($func, false, $callable_name)) |
@@ -4543,17 +4801,18 @@ discard block |
||
| 4543 | 4801 | else |
| 4544 | 4802 | { |
| 4545 | 4803 | // What are we gonna do about it? |
| 4546 | - if ($return) |
|
| 4547 | - return $func; |
|
| 4804 | + if ($return) { |
|
| 4805 | + return $func; |
|
| 4806 | + } |
|
| 4548 | 4807 | |
| 4549 | 4808 | // If this is a plain function, avoid the heat of calling call_user_func(). |
| 4550 | 4809 | else |
| 4551 | 4810 | { |
| 4552 | - if (is_array($func)) |
|
| 4553 | - call_user_func($func); |
|
| 4554 | - |
|
| 4555 | - else |
|
| 4556 | - $func(); |
|
| 4811 | + if (is_array($func)) { |
|
| 4812 | + call_user_func($func); |
|
| 4813 | + } else { |
|
| 4814 | + $func(); |
|
| 4815 | + } |
|
| 4557 | 4816 | } |
| 4558 | 4817 | } |
| 4559 | 4818 | } |
@@ -4570,31 +4829,34 @@ discard block |
||
| 4570 | 4829 | { |
| 4571 | 4830 | global $sourcedir, $txt, $boarddir, $settings; |
| 4572 | 4831 | |
| 4573 | - if (empty($string)) |
|
| 4574 | - return false; |
|
| 4832 | + if (empty($string)) { |
|
| 4833 | + return false; |
|
| 4834 | + } |
|
| 4575 | 4835 | |
| 4576 | 4836 | if (strpos($string, '|') !== false) |
| 4577 | 4837 | { |
| 4578 | 4838 | list ($file, $string) = explode('|', $string); |
| 4579 | 4839 | |
| 4580 | 4840 | // Match the wildcards to their regular vars. |
| 4581 | - if (empty($settings['theme_dir'])) |
|
| 4582 | - $absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir)); |
|
| 4583 | - |
|
| 4584 | - else |
|
| 4585 | - $absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir'])); |
|
| 4841 | + if (empty($settings['theme_dir'])) { |
|
| 4842 | + $absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir)); |
|
| 4843 | + } else { |
|
| 4844 | + $absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir'])); |
|
| 4845 | + } |
|
| 4586 | 4846 | |
| 4587 | 4847 | // Load the file if it can be loaded. |
| 4588 | - if (file_exists($absPath)) |
|
| 4589 | - require_once($absPath); |
|
| 4848 | + if (file_exists($absPath)) { |
|
| 4849 | + require_once($absPath); |
|
| 4850 | + } |
|
| 4590 | 4851 | |
| 4591 | 4852 | // No? try a fallback to $sourcedir |
| 4592 | 4853 | else |
| 4593 | 4854 | { |
| 4594 | 4855 | $absPath = $sourcedir .'/'. $file; |
| 4595 | 4856 | |
| 4596 | - if (file_exists($absPath)) |
|
| 4597 | - require_once($absPath); |
|
| 4857 | + if (file_exists($absPath)) { |
|
| 4858 | + require_once($absPath); |
|
| 4859 | + } |
|
| 4598 | 4860 | |
| 4599 | 4861 | // Sorry, can't do much for you at this point. |
| 4600 | 4862 | else |
@@ -4621,8 +4883,9 @@ discard block |
||
| 4621 | 4883 | global $user_info, $smcFunc; |
| 4622 | 4884 | |
| 4623 | 4885 | // Make sure we have something to work with. |
| 4624 | - if (empty($topic)) |
|
| 4625 | - return array(); |
|
| 4886 | + if (empty($topic)) { |
|
| 4887 | + return array(); |
|
| 4888 | + } |
|
| 4626 | 4889 | |
| 4627 | 4890 | |
| 4628 | 4891 | // We already know the number of likes per message, we just want to know whether the current user liked it or not. |
@@ -4645,8 +4908,9 @@ discard block |
||
| 4645 | 4908 | 'topic' => $topic, |
| 4646 | 4909 | ) |
| 4647 | 4910 | ); |
| 4648 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 4649 | - $temp[] = (int) $row['content_id']; |
|
| 4911 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 4912 | + $temp[] = (int) $row['content_id']; |
|
| 4913 | + } |
|
| 4650 | 4914 | |
| 4651 | 4915 | cache_put_data($cache_key, $temp, $ttl); |
| 4652 | 4916 | } |
@@ -4667,8 +4931,9 @@ discard block |
||
| 4667 | 4931 | { |
| 4668 | 4932 | global $context; |
| 4669 | 4933 | |
| 4670 | - if (empty($string)) |
|
| 4671 | - return $string; |
|
| 4934 | + if (empty($string)) { |
|
| 4935 | + return $string; |
|
| 4936 | + } |
|
| 4672 | 4937 | |
| 4673 | 4938 | // UTF-8 occurences of MS special characters |
| 4674 | 4939 | $findchars_utf8 = array( |
@@ -4709,10 +4974,11 @@ discard block |
||
| 4709 | 4974 | '--', // — |
| 4710 | 4975 | ); |
| 4711 | 4976 | |
| 4712 | - if ($context['utf8']) |
|
| 4713 | - $string = str_replace($findchars_utf8, $replacechars, $string); |
|
| 4714 | - else |
|
| 4715 | - $string = str_replace($findchars_iso, $replacechars, $string); |
|
| 4977 | + if ($context['utf8']) { |
|
| 4978 | + $string = str_replace($findchars_utf8, $replacechars, $string); |
|
| 4979 | + } else { |
|
| 4980 | + $string = str_replace($findchars_iso, $replacechars, $string); |
|
| 4981 | + } |
|
| 4716 | 4982 | |
| 4717 | 4983 | return $string; |
| 4718 | 4984 | } |
@@ -4731,49 +4997,59 @@ discard block |
||
| 4731 | 4997 | { |
| 4732 | 4998 | global $context; |
| 4733 | 4999 | |
| 4734 | - if (!isset($matches[2])) |
|
| 4735 | - return ''; |
|
| 5000 | + if (!isset($matches[2])) { |
|
| 5001 | + return ''; |
|
| 5002 | + } |
|
| 4736 | 5003 | |
| 4737 | 5004 | $num = $matches[2][0] === 'x' ? hexdec(substr($matches[2], 1)) : (int) $matches[2]; |
| 4738 | 5005 | |
| 4739 | 5006 | // remove left to right / right to left overrides |
| 4740 | - if ($num === 0x202D || $num === 0x202E) |
|
| 4741 | - return ''; |
|
| 5007 | + if ($num === 0x202D || $num === 0x202E) { |
|
| 5008 | + return ''; |
|
| 5009 | + } |
|
| 4742 | 5010 | |
| 4743 | 5011 | // Quote, Ampersand, Apostrophe, Less/Greater Than get html replaced |
| 4744 | - if (in_array($num, array(0x22, 0x26, 0x27, 0x3C, 0x3E))) |
|
| 4745 | - return '&#' . $num . ';'; |
|
| 5012 | + if (in_array($num, array(0x22, 0x26, 0x27, 0x3C, 0x3E))) { |
|
| 5013 | + return '&#' . $num . ';'; |
|
| 5014 | + } |
|
| 4746 | 5015 | |
| 4747 | 5016 | if (empty($context['utf8'])) |
| 4748 | 5017 | { |
| 4749 | 5018 | // no control characters |
| 4750 | - if ($num < 0x20) |
|
| 4751 | - return ''; |
|
| 5019 | + if ($num < 0x20) { |
|
| 5020 | + return ''; |
|
| 5021 | + } |
|
| 4752 | 5022 | // text is text |
| 4753 | - elseif ($num < 0x80) |
|
| 4754 | - return chr($num); |
|
| 5023 | + elseif ($num < 0x80) { |
|
| 5024 | + return chr($num); |
|
| 5025 | + } |
|
| 4755 | 5026 | // all others get html-ised |
| 4756 | - else |
|
| 4757 | - return '&#' . $matches[2] . ';'; |
|
| 4758 | - } |
|
| 4759 | - else |
|
| 5027 | + else { |
|
| 5028 | + return '&#' . $matches[2] . ';'; |
|
| 5029 | + } |
|
| 5030 | + } else |
|
| 4760 | 5031 | { |
| 4761 | 5032 | // <0x20 are control characters, 0x20 is a space, > 0x10FFFF is past the end of the utf8 character set |
| 4762 | 5033 | // 0xD800 >= $num <= 0xDFFF are surrogate markers (not valid for utf8 text) |
| 4763 | - if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF)) |
|
| 4764 | - return ''; |
|
| 5034 | + if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF)) { |
|
| 5035 | + return ''; |
|
| 5036 | + } |
|
| 4765 | 5037 | // <0x80 (or less than 128) are standard ascii characters a-z A-Z 0-9 and punctuation |
| 4766 | - elseif ($num < 0x80) |
|
| 4767 | - return chr($num); |
|
| 5038 | + elseif ($num < 0x80) { |
|
| 5039 | + return chr($num); |
|
| 5040 | + } |
|
| 4768 | 5041 | // <0x800 (2048) |
| 4769 | - elseif ($num < 0x800) |
|
| 4770 | - return chr(($num >> 6) + 192) . chr(($num & 63) + 128); |
|
| 5042 | + elseif ($num < 0x800) { |
|
| 5043 | + return chr(($num >> 6) + 192) . chr(($num & 63) + 128); |
|
| 5044 | + } |
|
| 4771 | 5045 | // < 0x10000 (65536) |
| 4772 | - elseif ($num < 0x10000) |
|
| 4773 | - return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
| 5046 | + elseif ($num < 0x10000) { |
|
| 5047 | + return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
| 5048 | + } |
|
| 4774 | 5049 | // <= 0x10FFFF (1114111) |
| 4775 | - else |
|
| 4776 | - return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
| 5050 | + else { |
|
| 5051 | + return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
| 5052 | + } |
|
| 4777 | 5053 | } |
| 4778 | 5054 | } |
| 4779 | 5055 | |
@@ -4789,28 +5065,34 @@ discard block |
||
| 4789 | 5065 | */ |
| 4790 | 5066 | function fixchar__callback($matches) |
| 4791 | 5067 | { |
| 4792 | - if (!isset($matches[1])) |
|
| 4793 | - return ''; |
|
| 5068 | + if (!isset($matches[1])) { |
|
| 5069 | + return ''; |
|
| 5070 | + } |
|
| 4794 | 5071 | |
| 4795 | 5072 | $num = $matches[1][0] === 'x' ? hexdec(substr($matches[1], 1)) : (int) $matches[1]; |
| 4796 | 5073 | |
| 4797 | 5074 | // <0x20 are control characters, > 0x10FFFF is past the end of the utf8 character set |
| 4798 | 5075 | // 0xD800 >= $num <= 0xDFFF are surrogate markers (not valid for utf8 text), 0x202D-E are left to right overrides |
| 4799 | - if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num === 0x202D || $num === 0x202E) |
|
| 4800 | - return ''; |
|
| 5076 | + if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num === 0x202D || $num === 0x202E) { |
|
| 5077 | + return ''; |
|
| 5078 | + } |
|
| 4801 | 5079 | // <0x80 (or less than 128) are standard ascii characters a-z A-Z 0-9 and punctuation |
| 4802 | - elseif ($num < 0x80) |
|
| 4803 | - return chr($num); |
|
| 5080 | + elseif ($num < 0x80) { |
|
| 5081 | + return chr($num); |
|
| 5082 | + } |
|
| 4804 | 5083 | // <0x800 (2048) |
| 4805 | - elseif ($num < 0x800) |
|
| 4806 | - return chr(($num >> 6) + 192) . chr(($num & 63) + 128); |
|
| 5084 | + elseif ($num < 0x800) { |
|
| 5085 | + return chr(($num >> 6) + 192) . chr(($num & 63) + 128); |
|
| 5086 | + } |
|
| 4807 | 5087 | // < 0x10000 (65536) |
| 4808 | - elseif ($num < 0x10000) |
|
| 4809 | - return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
| 5088 | + elseif ($num < 0x10000) { |
|
| 5089 | + return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
| 5090 | + } |
|
| 4810 | 5091 | // <= 0x10FFFF (1114111) |
| 4811 | - else |
|
| 4812 | - return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
| 4813 | -} |
|
| 5092 | + else { |
|
| 5093 | + return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
| 5094 | + } |
|
| 5095 | + } |
|
| 4814 | 5096 | |
| 4815 | 5097 | /** |
| 4816 | 5098 | * Strips out invalid html entities, replaces others with html style { codes |
@@ -4823,17 +5105,19 @@ discard block |
||
| 4823 | 5105 | */ |
| 4824 | 5106 | function entity_fix__callback($matches) |
| 4825 | 5107 | { |
| 4826 | - if (!isset($matches[2])) |
|
| 4827 | - return ''; |
|
| 5108 | + if (!isset($matches[2])) { |
|
| 5109 | + return ''; |
|
| 5110 | + } |
|
| 4828 | 5111 | |
| 4829 | 5112 | $num = $matches[2][0] === 'x' ? hexdec(substr($matches[2], 1)) : (int) $matches[2]; |
| 4830 | 5113 | |
| 4831 | 5114 | // we don't allow control characters, characters out of range, byte markers, etc |
| 4832 | - if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num == 0x202D || $num == 0x202E) |
|
| 4833 | - return ''; |
|
| 4834 | - else |
|
| 4835 | - return '&#' . $num . ';'; |
|
| 4836 | -} |
|
| 5115 | + if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num == 0x202D || $num == 0x202E) { |
|
| 5116 | + return ''; |
|
| 5117 | + } else { |
|
| 5118 | + return '&#' . $num . ';'; |
|
| 5119 | + } |
|
| 5120 | + } |
|
| 4837 | 5121 | |
| 4838 | 5122 | /** |
| 4839 | 5123 | * Return a Gravatar URL based on |
@@ -4857,18 +5141,23 @@ discard block |
||
| 4857 | 5141 | $ratings = array('G', 'PG', 'R', 'X'); |
| 4858 | 5142 | $defaults = array('mm', 'identicon', 'monsterid', 'wavatar', 'retro', 'blank'); |
| 4859 | 5143 | $url_params = array(); |
| 4860 | - if (!empty($modSettings['gravatarMaxRating']) && in_array($modSettings['gravatarMaxRating'], $ratings)) |
|
| 4861 | - $url_params[] = 'rating=' . $modSettings['gravatarMaxRating']; |
|
| 4862 | - if (!empty($modSettings['gravatarDefault']) && in_array($modSettings['gravatarDefault'], $defaults)) |
|
| 4863 | - $url_params[] = 'default=' . $modSettings['gravatarDefault']; |
|
| 4864 | - if (!empty($modSettings['avatar_max_width_external'])) |
|
| 4865 | - $size_string = (int) $modSettings['avatar_max_width_external']; |
|
| 4866 | - if (!empty($modSettings['avatar_max_height_external']) && !empty($size_string)) |
|
| 4867 | - if ((int) $modSettings['avatar_max_height_external'] < $size_string) |
|
| 5144 | + if (!empty($modSettings['gravatarMaxRating']) && in_array($modSettings['gravatarMaxRating'], $ratings)) { |
|
| 5145 | + $url_params[] = 'rating=' . $modSettings['gravatarMaxRating']; |
|
| 5146 | + } |
|
| 5147 | + if (!empty($modSettings['gravatarDefault']) && in_array($modSettings['gravatarDefault'], $defaults)) { |
|
| 5148 | + $url_params[] = 'default=' . $modSettings['gravatarDefault']; |
|
| 5149 | + } |
|
| 5150 | + if (!empty($modSettings['avatar_max_width_external'])) { |
|
| 5151 | + $size_string = (int) $modSettings['avatar_max_width_external']; |
|
| 5152 | + } |
|
| 5153 | + if (!empty($modSettings['avatar_max_height_external']) && !empty($size_string)) { |
|
| 5154 | + if ((int) $modSettings['avatar_max_height_external'] < $size_string) |
|
| 4868 | 5155 | $size_string = $modSettings['avatar_max_height_external']; |
| 5156 | + } |
|
| 4869 | 5157 | |
| 4870 | - if (!empty($size_string)) |
|
| 4871 | - $url_params[] = 's=' . $size_string; |
|
| 5158 | + if (!empty($size_string)) { |
|
| 5159 | + $url_params[] = 's=' . $size_string; |
|
| 5160 | + } |
|
| 4872 | 5161 | } |
| 4873 | 5162 | $http_method = !empty($modSettings['force_ssl']) && $modSettings['force_ssl'] == 2 ? 'https://secure' : 'http://www'; |
| 4874 | 5163 | |
@@ -4887,22 +5176,26 @@ discard block |
||
| 4887 | 5176 | static $timezones = null, $lastwhen = null; |
| 4888 | 5177 | |
| 4889 | 5178 | // No point doing this over if we already did it once |
| 4890 | - if (!empty($timezones) && $when == $lastwhen) |
|
| 4891 | - return $timezones; |
|
| 4892 | - else |
|
| 4893 | - $lastwhen = $when; |
|
| 5179 | + if (!empty($timezones) && $when == $lastwhen) { |
|
| 5180 | + return $timezones; |
|
| 5181 | + } else { |
|
| 5182 | + $lastwhen = $when; |
|
| 5183 | + } |
|
| 4894 | 5184 | |
| 4895 | 5185 | // Parseable datetime string? |
| 4896 | - if (is_int($timestamp = strtotime($when))) |
|
| 4897 | - $when = $timestamp; |
|
| 5186 | + if (is_int($timestamp = strtotime($when))) { |
|
| 5187 | + $when = $timestamp; |
|
| 5188 | + } |
|
| 4898 | 5189 | |
| 4899 | 5190 | // A Unix timestamp? |
| 4900 | - elseif (is_numeric($when)) |
|
| 4901 | - $when = intval($when); |
|
| 5191 | + elseif (is_numeric($when)) { |
|
| 5192 | + $when = intval($when); |
|
| 5193 | + } |
|
| 4902 | 5194 | |
| 4903 | 5195 | // Invalid value? Just get current Unix timestamp. |
| 4904 | - else |
|
| 4905 | - $when = time(); |
|
| 5196 | + else { |
|
| 5197 | + $when = time(); |
|
| 5198 | + } |
|
| 4906 | 5199 | |
| 4907 | 5200 | // We'll need this too |
| 4908 | 5201 | $later = (int) date_format(date_add(date_create('@' . $when), date_interval_create_from_date_string('1 year')), 'U'); |
@@ -4965,8 +5258,9 @@ discard block |
||
| 4965 | 5258 | foreach ($priority_countries as $country) |
| 4966 | 5259 | { |
| 4967 | 5260 | $country_tzids = @timezone_identifiers_list(DateTimeZone::PER_COUNTRY, strtoupper(trim($country))); |
| 4968 | - if (!empty($country_tzids)) |
|
| 4969 | - $priority_tzids = array_merge($priority_tzids, $country_tzids); |
|
| 5261 | + if (!empty($country_tzids)) { |
|
| 5262 | + $priority_tzids = array_merge($priority_tzids, $country_tzids); |
|
| 5263 | + } |
|
| 4970 | 5264 | } |
| 4971 | 5265 | |
| 4972 | 5266 | // Process the preferred timezones first, then the rest. |
@@ -4976,8 +5270,9 @@ discard block |
||
| 4976 | 5270 | foreach ($tzids as $tzid) |
| 4977 | 5271 | { |
| 4978 | 5272 | // We don't want UTC right now |
| 4979 | - if ($tzid == 'UTC') |
|
| 4980 | - continue; |
|
| 5273 | + if ($tzid == 'UTC') { |
|
| 5274 | + continue; |
|
| 5275 | + } |
|
| 4981 | 5276 | |
| 4982 | 5277 | // First, get the set of transition rules for this tzid |
| 4983 | 5278 | $tzinfo = timezone_transitions_get(timezone_open($tzid), $when, $later); |
@@ -4988,8 +5283,9 @@ discard block |
||
| 4988 | 5283 | $tz_location = timezone_location_get(timezone_open($tzid)); |
| 4989 | 5284 | |
| 4990 | 5285 | // Kazakstan |
| 4991 | - if ($tz_location['country_code'] == 'KZ') |
|
| 4992 | - $tzinfo[0]['abbr'] = str_replace(array('+05', '+06'), array('AQTT', 'ALMT'), $tzinfo[0]['abbr']); |
|
| 5286 | + if ($tz_location['country_code'] == 'KZ') { |
|
| 5287 | + $tzinfo[0]['abbr'] = str_replace(array('+05', '+06'), array('AQTT', 'ALMT'), $tzinfo[0]['abbr']); |
|
| 5288 | + } |
|
| 4993 | 5289 | |
| 4994 | 5290 | // Russia likes to experiment with time zones |
| 4995 | 5291 | if ($tz_location['country_code'] == 'RU') |
@@ -5000,19 +5296,22 @@ discard block |
||
| 5000 | 5296 | } |
| 5001 | 5297 | |
| 5002 | 5298 | // Still no good? We'll just mark it as a UTC offset |
| 5003 | - if (strspn($tzinfo[0]['abbr'], '+-') > 0) |
|
| 5004 | - $tzinfo[0]['abbr'] = 'UTC' . $tzinfo[0]['abbr']; |
|
| 5299 | + if (strspn($tzinfo[0]['abbr'], '+-') > 0) { |
|
| 5300 | + $tzinfo[0]['abbr'] = 'UTC' . $tzinfo[0]['abbr']; |
|
| 5301 | + } |
|
| 5005 | 5302 | } |
| 5006 | 5303 | |
| 5007 | 5304 | $tzkey = serialize($tzinfo); |
| 5008 | 5305 | |
| 5009 | 5306 | // Don't overwrite our preferred tzids |
| 5010 | - if (empty($zones[$tzkey]['tzid'])) |
|
| 5011 | - $zones[$tzkey]['tzid'] = $tzid; |
|
| 5307 | + if (empty($zones[$tzkey]['tzid'])) { |
|
| 5308 | + $zones[$tzkey]['tzid'] = $tzid; |
|
| 5309 | + } |
|
| 5012 | 5310 | |
| 5013 | 5311 | // A time zone from a prioritized country? |
| 5014 | - if (in_array($tzid, $priority_tzids)) |
|
| 5015 | - $priority_zones[$tzkey] = true; |
|
| 5312 | + if (in_array($tzid, $priority_tzids)) { |
|
| 5313 | + $priority_zones[$tzkey] = true; |
|
| 5314 | + } |
|
| 5016 | 5315 | |
| 5017 | 5316 | // Keep track of the location and offset for this tzid |
| 5018 | 5317 | $tzid_parts = explode('/', $tzid); |
@@ -5030,15 +5329,17 @@ discard block |
||
| 5030 | 5329 | { |
| 5031 | 5330 | $tzinfo = unserialize($tzkey); |
| 5032 | 5331 | |
| 5033 | - if (!empty($timezone_descriptions[$tzvalue['tzid']])) |
|
| 5034 | - $desc = $timezone_descriptions[$tzvalue['tzid']]; |
|
| 5035 | - else |
|
| 5036 | - $desc = implode(', ', array_unique($tzvalue['locations'])); |
|
| 5332 | + if (!empty($timezone_descriptions[$tzvalue['tzid']])) { |
|
| 5333 | + $desc = $timezone_descriptions[$tzvalue['tzid']]; |
|
| 5334 | + } else { |
|
| 5335 | + $desc = implode(', ', array_unique($tzvalue['locations'])); |
|
| 5336 | + } |
|
| 5037 | 5337 | |
| 5038 | - if (isset($priority_zones[$tzkey])) |
|
| 5039 | - $priority_timezones[$tzvalue['tzid']] = $tzinfo[0]['abbr'] . ' - ' . $desc . ' [UTC' . date_format(date_create($tzvalue['tzid']), 'P') . ']'; |
|
| 5040 | - else |
|
| 5041 | - $timezones[$tzvalue['tzid']] = $tzinfo[0]['abbr'] . ' - ' . $desc . ' [UTC' . date_format(date_create($tzvalue['tzid']), 'P') . ']'; |
|
| 5338 | + if (isset($priority_zones[$tzkey])) { |
|
| 5339 | + $priority_timezones[$tzvalue['tzid']] = $tzinfo[0]['abbr'] . ' - ' . $desc . ' [UTC' . date_format(date_create($tzvalue['tzid']), 'P') . ']'; |
|
| 5340 | + } else { |
|
| 5341 | + $timezones[$tzvalue['tzid']] = $tzinfo[0]['abbr'] . ' - ' . $desc . ' [UTC' . date_format(date_create($tzvalue['tzid']), 'P') . ']'; |
|
| 5342 | + } |
|
| 5042 | 5343 | } |
| 5043 | 5344 | |
| 5044 | 5345 | $timezones = array_merge( |
@@ -5056,8 +5357,9 @@ discard block |
||
| 5056 | 5357 | */ |
| 5057 | 5358 | function inet_ptod($ip_address) |
| 5058 | 5359 | { |
| 5059 | - if (!isValidIP($ip_address)) |
|
| 5060 | - return $ip_address; |
|
| 5360 | + if (!isValidIP($ip_address)) { |
|
| 5361 | + return $ip_address; |
|
| 5362 | + } |
|
| 5061 | 5363 | |
| 5062 | 5364 | $bin = inet_pton($ip_address); |
| 5063 | 5365 | return $bin; |
@@ -5069,13 +5371,15 @@ discard block |
||
| 5069 | 5371 | */ |
| 5070 | 5372 | function inet_dtop($bin) |
| 5071 | 5373 | { |
| 5072 | - if(empty($bin)) |
|
| 5073 | - return ''; |
|
| 5374 | + if(empty($bin)) { |
|
| 5375 | + return ''; |
|
| 5376 | + } |
|
| 5074 | 5377 | |
| 5075 | 5378 | global $db_type; |
| 5076 | 5379 | |
| 5077 | - if ($db_type == 'postgresql') |
|
| 5078 | - return $bin; |
|
| 5380 | + if ($db_type == 'postgresql') { |
|
| 5381 | + return $bin; |
|
| 5382 | + } |
|
| 5079 | 5383 | |
| 5080 | 5384 | $ip_address = inet_ntop($bin); |
| 5081 | 5385 | |
@@ -5100,26 +5404,32 @@ discard block |
||
| 5100 | 5404 | */ |
| 5101 | 5405 | function _safe_serialize($value) |
| 5102 | 5406 | { |
| 5103 | - if(is_null($value)) |
|
| 5104 | - return 'N;'; |
|
| 5407 | + if(is_null($value)) { |
|
| 5408 | + return 'N;'; |
|
| 5409 | + } |
|
| 5105 | 5410 | |
| 5106 | - if(is_bool($value)) |
|
| 5107 | - return 'b:'. (int) $value .';'; |
|
| 5411 | + if(is_bool($value)) { |
|
| 5412 | + return 'b:'. (int) $value .';'; |
|
| 5413 | + } |
|
| 5108 | 5414 | |
| 5109 | - if(is_int($value)) |
|
| 5110 | - return 'i:'. $value .';'; |
|
| 5415 | + if(is_int($value)) { |
|
| 5416 | + return 'i:'. $value .';'; |
|
| 5417 | + } |
|
| 5111 | 5418 | |
| 5112 | - if(is_float($value)) |
|
| 5113 | - return 'd:'. str_replace(',', '.', $value) .';'; |
|
| 5419 | + if(is_float($value)) { |
|
| 5420 | + return 'd:'. str_replace(',', '.', $value) .';'; |
|
| 5421 | + } |
|
| 5114 | 5422 | |
| 5115 | - if(is_string($value)) |
|
| 5116 | - return 's:'. strlen($value) .':"'. $value .'";'; |
|
| 5423 | + if(is_string($value)) { |
|
| 5424 | + return 's:'. strlen($value) .':"'. $value .'";'; |
|
| 5425 | + } |
|
| 5117 | 5426 | |
| 5118 | 5427 | if(is_array($value)) |
| 5119 | 5428 | { |
| 5120 | 5429 | $out = ''; |
| 5121 | - foreach($value as $k => $v) |
|
| 5122 | - $out .= _safe_serialize($k) . _safe_serialize($v); |
|
| 5430 | + foreach($value as $k => $v) { |
|
| 5431 | + $out .= _safe_serialize($k) . _safe_serialize($v); |
|
| 5432 | + } |
|
| 5123 | 5433 | |
| 5124 | 5434 | return 'a:'. count($value) .':{'. $out .'}'; |
| 5125 | 5435 | } |
@@ -5145,8 +5455,9 @@ discard block |
||
| 5145 | 5455 | |
| 5146 | 5456 | $out = _safe_serialize($value); |
| 5147 | 5457 | |
| 5148 | - if (isset($mbIntEnc)) |
|
| 5149 | - mb_internal_encoding($mbIntEnc); |
|
| 5458 | + if (isset($mbIntEnc)) { |
|
| 5459 | + mb_internal_encoding($mbIntEnc); |
|
| 5460 | + } |
|
| 5150 | 5461 | |
| 5151 | 5462 | return $out; |
| 5152 | 5463 | } |
@@ -5163,8 +5474,9 @@ discard block |
||
| 5163 | 5474 | function _safe_unserialize($str) |
| 5164 | 5475 | { |
| 5165 | 5476 | // Input is not a string. |
| 5166 | - if(empty($str) || !is_string($str)) |
|
| 5167 | - return false; |
|
| 5477 | + if(empty($str) || !is_string($str)) { |
|
| 5478 | + return false; |
|
| 5479 | + } |
|
| 5168 | 5480 | |
| 5169 | 5481 | $stack = array(); |
| 5170 | 5482 | $expected = array(); |
@@ -5180,43 +5492,38 @@ discard block |
||
| 5180 | 5492 | while($state != 1) |
| 5181 | 5493 | { |
| 5182 | 5494 | $type = isset($str[0]) ? $str[0] : ''; |
| 5183 | - if($type == '}') |
|
| 5184 | - $str = substr($str, 1); |
|
| 5185 | - |
|
| 5186 | - else if($type == 'N' && $str[1] == ';') |
|
| 5495 | + if($type == '}') { |
|
| 5496 | + $str = substr($str, 1); |
|
| 5497 | + } else if($type == 'N' && $str[1] == ';') |
|
| 5187 | 5498 | { |
| 5188 | 5499 | $value = null; |
| 5189 | 5500 | $str = substr($str, 2); |
| 5190 | - } |
|
| 5191 | - else if($type == 'b' && preg_match('/^b:([01]);/', $str, $matches)) |
|
| 5501 | + } else if($type == 'b' && preg_match('/^b:([01]);/', $str, $matches)) |
|
| 5192 | 5502 | { |
| 5193 | 5503 | $value = $matches[1] == '1' ? true : false; |
| 5194 | 5504 | $str = substr($str, 4); |
| 5195 | - } |
|
| 5196 | - else if($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches)) |
|
| 5505 | + } else if($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches)) |
|
| 5197 | 5506 | { |
| 5198 | 5507 | $value = (int)$matches[1]; |
| 5199 | 5508 | $str = $matches[2]; |
| 5200 | - } |
|
| 5201 | - else if($type == 'd' && preg_match('/^d:(-?[0-9]+\.?[0-9]*(E[+-][0-9]+)?);(.*)/s', $str, $matches)) |
|
| 5509 | + } else if($type == 'd' && preg_match('/^d:(-?[0-9]+\.?[0-9]*(E[+-][0-9]+)?);(.*)/s', $str, $matches)) |
|
| 5202 | 5510 | { |
| 5203 | 5511 | $value = (float)$matches[1]; |
| 5204 | 5512 | $str = $matches[3]; |
| 5205 | - } |
|
| 5206 | - else if($type == 's' && preg_match('/^s:([0-9]+):"(.*)/s', $str, $matches) && substr($matches[2], (int)$matches[1], 2) == '";') |
|
| 5513 | + } else if($type == 's' && preg_match('/^s:([0-9]+):"(.*)/s', $str, $matches) && substr($matches[2], (int)$matches[1], 2) == '";') |
|
| 5207 | 5514 | { |
| 5208 | 5515 | $value = substr($matches[2], 0, (int)$matches[1]); |
| 5209 | 5516 | $str = substr($matches[2], (int)$matches[1] + 2); |
| 5210 | - } |
|
| 5211 | - else if($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches)) |
|
| 5517 | + } else if($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches)) |
|
| 5212 | 5518 | { |
| 5213 | 5519 | $expectedLength = (int)$matches[1]; |
| 5214 | 5520 | $str = $matches[2]; |
| 5215 | 5521 | } |
| 5216 | 5522 | |
| 5217 | 5523 | // Object or unknown/malformed type. |
| 5218 | - else |
|
| 5219 | - return false; |
|
| 5524 | + else { |
|
| 5525 | + return false; |
|
| 5526 | + } |
|
| 5220 | 5527 | |
| 5221 | 5528 | switch($state) |
| 5222 | 5529 | { |
@@ -5244,8 +5551,9 @@ discard block |
||
| 5244 | 5551 | if($type == '}') |
| 5245 | 5552 | { |
| 5246 | 5553 | // Array size is less than expected. |
| 5247 | - if(count($list) < end($expected)) |
|
| 5248 | - return false; |
|
| 5554 | + if(count($list) < end($expected)) { |
|
| 5555 | + return false; |
|
| 5556 | + } |
|
| 5249 | 5557 | |
| 5250 | 5558 | unset($list); |
| 5251 | 5559 | $list = &$stack[count($stack)-1]; |
@@ -5254,8 +5562,9 @@ discard block |
||
| 5254 | 5562 | // Go to terminal state if we're at the end of the root array. |
| 5255 | 5563 | array_pop($expected); |
| 5256 | 5564 | |
| 5257 | - if(count($expected) == 0) |
|
| 5258 | - $state = 1; |
|
| 5565 | + if(count($expected) == 0) { |
|
| 5566 | + $state = 1; |
|
| 5567 | + } |
|
| 5259 | 5568 | |
| 5260 | 5569 | break; |
| 5261 | 5570 | } |
@@ -5263,8 +5572,9 @@ discard block |
||
| 5263 | 5572 | if($type == 'i' || $type == 's') |
| 5264 | 5573 | { |
| 5265 | 5574 | // Array size exceeds expected length. |
| 5266 | - if(count($list) >= end($expected)) |
|
| 5267 | - return false; |
|
| 5575 | + if(count($list) >= end($expected)) { |
|
| 5576 | + return false; |
|
| 5577 | + } |
|
| 5268 | 5578 | |
| 5269 | 5579 | $key = $value; |
| 5270 | 5580 | $state = 3; |
@@ -5298,8 +5608,9 @@ discard block |
||
| 5298 | 5608 | } |
| 5299 | 5609 | |
| 5300 | 5610 | // Trailing data in input. |
| 5301 | - if(!empty($str)) |
|
| 5302 | - return false; |
|
| 5611 | + if(!empty($str)) { |
|
| 5612 | + return false; |
|
| 5613 | + } |
|
| 5303 | 5614 | |
| 5304 | 5615 | return $data; |
| 5305 | 5616 | } |
@@ -5322,8 +5633,9 @@ discard block |
||
| 5322 | 5633 | |
| 5323 | 5634 | $out = _safe_unserialize($str); |
| 5324 | 5635 | |
| 5325 | - if (isset($mbIntEnc)) |
|
| 5326 | - mb_internal_encoding($mbIntEnc); |
|
| 5636 | + if (isset($mbIntEnc)) { |
|
| 5637 | + mb_internal_encoding($mbIntEnc); |
|
| 5638 | + } |
|
| 5327 | 5639 | |
| 5328 | 5640 | return $out; |
| 5329 | 5641 | } |
@@ -5338,12 +5650,14 @@ discard block |
||
| 5338 | 5650 | function smf_chmod($file, $value = 0) |
| 5339 | 5651 | { |
| 5340 | 5652 | // No file? no checks! |
| 5341 | - if (empty($file)) |
|
| 5342 | - return false; |
|
| 5653 | + if (empty($file)) { |
|
| 5654 | + return false; |
|
| 5655 | + } |
|
| 5343 | 5656 | |
| 5344 | 5657 | // Already writable? |
| 5345 | - if (is_writable($file)) |
|
| 5346 | - return true; |
|
| 5658 | + if (is_writable($file)) { |
|
| 5659 | + return true; |
|
| 5660 | + } |
|
| 5347 | 5661 | |
| 5348 | 5662 | // Do we have a file or a dir? |
| 5349 | 5663 | $isDir = is_dir($file); |
@@ -5359,10 +5673,9 @@ discard block |
||
| 5359 | 5673 | { |
| 5360 | 5674 | $isWritable = true; |
| 5361 | 5675 | break; |
| 5676 | + } else { |
|
| 5677 | + @chmod($file, $val); |
|
| 5362 | 5678 | } |
| 5363 | - |
|
| 5364 | - else |
|
| 5365 | - @chmod($file, $val); |
|
| 5366 | 5679 | } |
| 5367 | 5680 | |
| 5368 | 5681 | return $isWritable; |
@@ -5381,8 +5694,9 @@ discard block |
||
| 5381 | 5694 | global $txt; |
| 5382 | 5695 | |
| 5383 | 5696 | // Come on... |
| 5384 | - if (empty($json) || !is_string($json)) |
|
| 5385 | - return array(); |
|
| 5697 | + if (empty($json) || !is_string($json)) { |
|
| 5698 | + return array(); |
|
| 5699 | + } |
|
| 5386 | 5700 | |
| 5387 | 5701 | $returnArray = @json_decode($json, $returnAsArray); |
| 5388 | 5702 | |
@@ -5420,11 +5734,11 @@ discard block |
||
| 5420 | 5734 | $jsonDebug = $jsonDebug[0]; |
| 5421 | 5735 | loadLanguage('Errors'); |
| 5422 | 5736 | |
| 5423 | - if (!empty($jsonDebug)) |
|
| 5424 | - log_error($txt['json_'. $jsonError], 'critical', $jsonDebug['file'], $jsonDebug['line']); |
|
| 5425 | - |
|
| 5426 | - else |
|
| 5427 | - log_error($txt['json_'. $jsonError], 'critical'); |
|
| 5737 | + if (!empty($jsonDebug)) { |
|
| 5738 | + log_error($txt['json_'. $jsonError], 'critical', $jsonDebug['file'], $jsonDebug['line']); |
|
| 5739 | + } else { |
|
| 5740 | + log_error($txt['json_'. $jsonError], 'critical'); |
|
| 5741 | + } |
|
| 5428 | 5742 | |
| 5429 | 5743 | // Everyone expects an array. |
| 5430 | 5744 | return array(); |
@@ -5454,8 +5768,9 @@ discard block |
||
| 5454 | 5768 | global $db_show_debug, $modSettings; |
| 5455 | 5769 | |
| 5456 | 5770 | // Defensive programming anyone? |
| 5457 | - if (empty($data)) |
|
| 5458 | - return false; |
|
| 5771 | + if (empty($data)) { |
|
| 5772 | + return false; |
|
| 5773 | + } |
|
| 5459 | 5774 | |
| 5460 | 5775 | // Don't need extra stuff... |
| 5461 | 5776 | $db_show_debug = false; |
@@ -5463,11 +5778,11 @@ discard block |
||
| 5463 | 5778 | // Kill anything else. |
| 5464 | 5779 | ob_end_clean(); |
| 5465 | 5780 | |
| 5466 | - if (!empty($modSettings['CompressedOutput'])) |
|
| 5467 | - @ob_start('ob_gzhandler'); |
|
| 5468 | - |
|
| 5469 | - else |
|
| 5470 | - ob_start(); |
|
| 5781 | + if (!empty($modSettings['CompressedOutput'])) { |
|
| 5782 | + @ob_start('ob_gzhandler'); |
|
| 5783 | + } else { |
|
| 5784 | + ob_start(); |
|
| 5785 | + } |
|
| 5471 | 5786 | |
| 5472 | 5787 | // Set the header. |
| 5473 | 5788 | header($type); |
@@ -5499,8 +5814,9 @@ discard block |
||
| 5499 | 5814 | static $done = false; |
| 5500 | 5815 | |
| 5501 | 5816 | // If we don't need to do anything, don't |
| 5502 | - if (!$update && $done) |
|
| 5503 | - return; |
|
| 5817 | + if (!$update && $done) { |
|
| 5818 | + return; |
|
| 5819 | + } |
|
| 5504 | 5820 | |
| 5505 | 5821 | // Should we get a new copy of the official list of TLDs? |
| 5506 | 5822 | if ($update) |
@@ -5521,10 +5837,11 @@ discard block |
||
| 5521 | 5837 | // Clean $tlds and convert it to an array |
| 5522 | 5838 | $tlds = array_filter(explode("\n", strtolower($tlds)), function($line) { |
| 5523 | 5839 | $line = trim($line); |
| 5524 | - if (empty($line) || strpos($line, '#') !== false || strpos($line, ' ') !== false) |
|
| 5525 | - return false; |
|
| 5526 | - else |
|
| 5527 | - return true; |
|
| 5840 | + if (empty($line) || strpos($line, '#') !== false || strpos($line, ' ') !== false) { |
|
| 5841 | + return false; |
|
| 5842 | + } else { |
|
| 5843 | + return true; |
|
| 5844 | + } |
|
| 5528 | 5845 | }); |
| 5529 | 5846 | |
| 5530 | 5847 | // Convert Punycode to Unicode |
@@ -5578,8 +5895,9 @@ discard block |
||
| 5578 | 5895 | $idx += $digit * $w; |
| 5579 | 5896 | $t = ($k <= $bias) ? $tmin : (($k >= $bias + $tmax) ? $tmax : ($k - $bias)); |
| 5580 | 5897 | |
| 5581 | - if ($digit < $t) |
|
| 5582 | - break; |
|
| 5898 | + if ($digit < $t) { |
|
| 5899 | + break; |
|
| 5900 | + } |
|
| 5583 | 5901 | |
| 5584 | 5902 | $w = (int) ($w * ($base - $t)); |
| 5585 | 5903 | } |
@@ -5588,8 +5906,9 @@ discard block |
||
| 5588 | 5906 | $delta = intval($is_first ? ($delta / $damp) : ($delta / 2)); |
| 5589 | 5907 | $delta += intval($delta / ($deco_len + 1)); |
| 5590 | 5908 | |
| 5591 | - for ($k = 0; $delta > (($base - $tmin) * $tmax) / 2; $k += $base) |
|
| 5592 | - $delta = intval($delta / ($base - $tmin)); |
|
| 5909 | + for ($k = 0; $delta > (($base - $tmin) * $tmax) / 2; $k += $base) { |
|
| 5910 | + $delta = intval($delta / ($base - $tmin)); |
|
| 5911 | + } |
|
| 5593 | 5912 | |
| 5594 | 5913 | $bias = intval($k + ($base - $tmin + 1) * $delta / ($delta + $skew)); |
| 5595 | 5914 | $is_first = false; |
@@ -5598,8 +5917,9 @@ discard block |
||
| 5598 | 5917 | |
| 5599 | 5918 | if ($deco_len > 0) |
| 5600 | 5919 | { |
| 5601 | - for ($i = $deco_len; $i > $idx; $i--) |
|
| 5602 | - $decoded[$i] = $decoded[($i - 1)]; |
|
| 5920 | + for ($i = $deco_len; $i > $idx; $i--) { |
|
| 5921 | + $decoded[$i] = $decoded[($i - 1)]; |
|
| 5922 | + } |
|
| 5603 | 5923 | } |
| 5604 | 5924 | $decoded[$idx++] = $char; |
| 5605 | 5925 | } |
@@ -5607,24 +5927,29 @@ discard block |
||
| 5607 | 5927 | foreach ($decoded as $k => $v) |
| 5608 | 5928 | { |
| 5609 | 5929 | // 7bit are transferred literally |
| 5610 | - if ($v < 128) |
|
| 5611 | - $output .= chr($v); |
|
| 5930 | + if ($v < 128) { |
|
| 5931 | + $output .= chr($v); |
|
| 5932 | + } |
|
| 5612 | 5933 | |
| 5613 | 5934 | // 2 bytes |
| 5614 | - elseif ($v < (1 << 11)) |
|
| 5615 | - $output .= chr(192+($v >> 6)) . chr(128+($v & 63)); |
|
| 5935 | + elseif ($v < (1 << 11)) { |
|
| 5936 | + $output .= chr(192+($v >> 6)) . chr(128+($v & 63)); |
|
| 5937 | + } |
|
| 5616 | 5938 | |
| 5617 | 5939 | // 3 bytes |
| 5618 | - elseif ($v < (1 << 16)) |
|
| 5619 | - $output .= chr(224+($v >> 12)) . chr(128+(($v >> 6) & 63)) . chr(128+($v & 63)); |
|
| 5940 | + elseif ($v < (1 << 16)) { |
|
| 5941 | + $output .= chr(224+($v >> 12)) . chr(128+(($v >> 6) & 63)) . chr(128+($v & 63)); |
|
| 5942 | + } |
|
| 5620 | 5943 | |
| 5621 | 5944 | // 4 bytes |
| 5622 | - elseif ($v < (1 << 21)) |
|
| 5623 | - $output .= chr(240+($v >> 18)) . chr(128+(($v >> 12) & 63)) . chr(128+(($v >> 6) & 63)) . chr(128+($v & 63)); |
|
| 5945 | + elseif ($v < (1 << 21)) { |
|
| 5946 | + $output .= chr(240+($v >> 18)) . chr(128+(($v >> 12) & 63)) . chr(128+(($v >> 6) & 63)) . chr(128+($v & 63)); |
|
| 5947 | + } |
|
| 5624 | 5948 | |
| 5625 | 5949 | // 'Conversion from UCS-4 to UTF-8 failed: malformed input at byte '.$k |
| 5626 | - else |
|
| 5627 | - $output .= $safe_char; |
|
| 5950 | + else { |
|
| 5951 | + $output .= $safe_char; |
|
| 5952 | + } |
|
| 5628 | 5953 | } |
| 5629 | 5954 | |
| 5630 | 5955 | $output_parts[] = $output; |
@@ -5719,8 +6044,7 @@ discard block |
||
| 5719 | 6044 | |
| 5720 | 6045 | $strlen = 'mb_strlen'; |
| 5721 | 6046 | $substr = 'mb_substr'; |
| 5722 | - } |
|
| 5723 | - else |
|
| 6047 | + } else |
|
| 5724 | 6048 | { |
| 5725 | 6049 | $strlen = $smcFunc['strlen']; |
| 5726 | 6050 | $substr = $smcFunc['substr']; |
@@ -5734,20 +6058,21 @@ discard block |
||
| 5734 | 6058 | |
| 5735 | 6059 | $first = $substr($string, 0, 1); |
| 5736 | 6060 | |
| 5737 | - if (empty($index[$first])) |
|
| 5738 | - $index[$first] = array(); |
|
| 6061 | + if (empty($index[$first])) { |
|
| 6062 | + $index[$first] = array(); |
|
| 6063 | + } |
|
| 5739 | 6064 | |
| 5740 | 6065 | if ($strlen($string) > 1) |
| 5741 | 6066 | { |
| 5742 | 6067 | // Sanity check on recursion |
| 5743 | - if ($depth > 99) |
|
| 5744 | - $index[$first][$substr($string, 1)] = ''; |
|
| 5745 | - |
|
| 5746 | - else |
|
| 5747 | - $index[$first] = $add_string_to_index($substr($string, 1), $index[$first]); |
|
| 6068 | + if ($depth > 99) { |
|
| 6069 | + $index[$first][$substr($string, 1)] = ''; |
|
| 6070 | + } else { |
|
| 6071 | + $index[$first] = $add_string_to_index($substr($string, 1), $index[$first]); |
|
| 6072 | + } |
|
| 6073 | + } else { |
|
| 6074 | + $index[$first][''] = ''; |
|
| 5748 | 6075 | } |
| 5749 | - else |
|
| 5750 | - $index[$first][''] = ''; |
|
| 5751 | 6076 | |
| 5752 | 6077 | $depth--; |
| 5753 | 6078 | return $index; |
@@ -5770,9 +6095,9 @@ discard block |
||
| 5770 | 6095 | $key_regex = preg_quote($key, $delim); |
| 5771 | 6096 | $new_key = $key; |
| 5772 | 6097 | |
| 5773 | - if (empty($value)) |
|
| 5774 | - $sub_regex = ''; |
|
| 5775 | - else |
|
| 6098 | + if (empty($value)) { |
|
| 6099 | + $sub_regex = ''; |
|
| 6100 | + } else |
|
| 5776 | 6101 | { |
| 5777 | 6102 | $sub_regex = $index_to_regex($value, $delim); |
| 5778 | 6103 | |
@@ -5780,22 +6105,22 @@ discard block |
||
| 5780 | 6105 | { |
| 5781 | 6106 | $new_key_array = explode('(?'.'>', $sub_regex); |
| 5782 | 6107 | $new_key .= $new_key_array[0]; |
| 6108 | + } else { |
|
| 6109 | + $sub_regex = '(?'.'>' . $sub_regex . ')'; |
|
| 5783 | 6110 | } |
| 5784 | - else |
|
| 5785 | - $sub_regex = '(?'.'>' . $sub_regex . ')'; |
|
| 5786 | 6111 | } |
| 5787 | 6112 | |
| 5788 | - if ($depth > 1) |
|
| 5789 | - $regex[$new_key] = $key_regex . $sub_regex; |
|
| 5790 | - else |
|
| 6113 | + if ($depth > 1) { |
|
| 6114 | + $regex[$new_key] = $key_regex . $sub_regex; |
|
| 6115 | + } else |
|
| 5791 | 6116 | { |
| 5792 | 6117 | if (($length += strlen($key_regex) + 1) < $max_length || empty($regex)) |
| 5793 | 6118 | { |
| 5794 | 6119 | $regex[$new_key] = $key_regex . $sub_regex; |
| 5795 | 6120 | unset($index[$key]); |
| 6121 | + } else { |
|
| 6122 | + break; |
|
| 5796 | 6123 | } |
| 5797 | - else |
|
| 5798 | - break; |
|
| 5799 | 6124 | } |
| 5800 | 6125 | } |
| 5801 | 6126 | |
@@ -5804,10 +6129,11 @@ discard block |
||
| 5804 | 6129 | $l1 = $strlen($k1); |
| 5805 | 6130 | $l2 = $strlen($k2); |
| 5806 | 6131 | |
| 5807 | - if ($l1 == $l2) |
|
| 5808 | - return strcmp($k1, $k2) > 0 ? 1 : -1; |
|
| 5809 | - else |
|
| 5810 | - return $l1 > $l2 ? -1 : 1; |
|
| 6132 | + if ($l1 == $l2) { |
|
| 6133 | + return strcmp($k1, $k2) > 0 ? 1 : -1; |
|
| 6134 | + } else { |
|
| 6135 | + return $l1 > $l2 ? -1 : 1; |
|
| 6136 | + } |
|
| 5811 | 6137 | }); |
| 5812 | 6138 | |
| 5813 | 6139 | $depth--; |
@@ -5818,15 +6144,18 @@ discard block |
||
| 5818 | 6144 | $index = array(); |
| 5819 | 6145 | $regexes = array(); |
| 5820 | 6146 | |
| 5821 | - foreach ($strings as $string) |
|
| 5822 | - $index = $add_string_to_index($string, $index); |
|
| 6147 | + foreach ($strings as $string) { |
|
| 6148 | + $index = $add_string_to_index($string, $index); |
|
| 6149 | + } |
|
| 5823 | 6150 | |
| 5824 | - while (!empty($index)) |
|
| 5825 | - $regexes[] = '(?'.'>' . $index_to_regex($index, $delim) . ')'; |
|
| 6151 | + while (!empty($index)) { |
|
| 6152 | + $regexes[] = '(?'.'>' . $index_to_regex($index, $delim) . ')'; |
|
| 6153 | + } |
|
| 5826 | 6154 | |
| 5827 | 6155 | // Restore PHP's internal character encoding to whatever it was originally |
| 5828 | - if (!empty($current_encoding)) |
|
| 5829 | - mb_internal_encoding($current_encoding); |
|
| 6156 | + if (!empty($current_encoding)) { |
|
| 6157 | + mb_internal_encoding($current_encoding); |
|
| 6158 | + } |
|
| 5830 | 6159 | |
| 5831 | 6160 | return $regexes; |
| 5832 | 6161 | } |
@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | * @version 2.1 Beta 3 |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | -if (!defined('SMF')) |
|
| 17 | +if (!defined('SMF')) { |
|
| 18 | 18 | die('No direct access...'); |
| 19 | +} |
|
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * This function allows to move a topic, making sure to ask the moderator |
@@ -32,8 +33,9 @@ discard block |
||
| 32 | 33 | { |
| 33 | 34 | global $txt, $board, $topic, $user_info, $context, $language, $scripturl, $smcFunc, $modSettings, $sourcedir; |
| 34 | 35 | |
| 35 | - if (empty($topic)) |
|
| 36 | - fatal_lang_error('no_access', false); |
|
| 36 | + if (empty($topic)) { |
|
| 37 | + fatal_lang_error('no_access', false); |
|
| 38 | + } |
|
| 37 | 39 | |
| 38 | 40 | $request = $smcFunc['db_query']('', ' |
| 39 | 41 | SELECT t.id_member_started, ms.subject, t.approved |
@@ -49,8 +51,9 @@ discard block |
||
| 49 | 51 | $smcFunc['db_free_result']($request); |
| 50 | 52 | |
| 51 | 53 | // Can they see it - if not approved? |
| 52 | - if ($modSettings['postmod_active'] && !$context['is_approved']) |
|
| 53 | - isAllowedTo('approve_posts'); |
|
| 54 | + if ($modSettings['postmod_active'] && !$context['is_approved']) { |
|
| 55 | + isAllowedTo('approve_posts'); |
|
| 56 | + } |
|
| 54 | 57 | |
| 55 | 58 | // Permission check! |
| 56 | 59 | // @todo |
@@ -59,9 +62,9 @@ discard block |
||
| 59 | 62 | if ($id_member_started == $user_info['id']) |
| 60 | 63 | { |
| 61 | 64 | isAllowedTo('move_own'); |
| 65 | + } else { |
|
| 66 | + isAllowedTo('move_any'); |
|
| 62 | 67 | } |
| 63 | - else |
|
| 64 | - isAllowedTo('move_any'); |
|
| 65 | 68 | } |
| 66 | 69 | |
| 67 | 70 | $context['move_any'] = $user_info['is_admin'] || $modSettings['topic_move_any']; |
@@ -83,11 +86,13 @@ discard block |
||
| 83 | 86 | 'not_redirection' => true, |
| 84 | 87 | ); |
| 85 | 88 | |
| 86 | - if (!empty($_SESSION['move_to_topic']) && $_SESSION['move_to_topic'] != $board) |
|
| 87 | - $options['selected_board'] = $_SESSION['move_to_topic']; |
|
| 89 | + if (!empty($_SESSION['move_to_topic']) && $_SESSION['move_to_topic'] != $board) { |
|
| 90 | + $options['selected_board'] = $_SESSION['move_to_topic']; |
|
| 91 | + } |
|
| 88 | 92 | |
| 89 | - if (!$context['move_any']) |
|
| 90 | - $options['included_boards'] = $boards; |
|
| 93 | + if (!$context['move_any']) { |
|
| 94 | + $options['included_boards'] = $boards; |
|
| 95 | + } |
|
| 91 | 96 | |
| 92 | 97 | require_once($sourcedir . '/Subs-MessageIndex.php'); |
| 93 | 98 | $context['categories'] = getBoardList($options); |
@@ -138,12 +143,14 @@ discard block |
||
| 138 | 143 | global $txt, $board, $topic, $scripturl, $sourcedir, $modSettings, $context; |
| 139 | 144 | global $board, $language, $user_info, $smcFunc; |
| 140 | 145 | |
| 141 | - if (empty($topic)) |
|
| 142 | - fatal_lang_error('no_access', false); |
|
| 146 | + if (empty($topic)) { |
|
| 147 | + fatal_lang_error('no_access', false); |
|
| 148 | + } |
|
| 143 | 149 | |
| 144 | 150 | // You can't choose to have a redirection topic and use an empty reason. |
| 145 | - if (isset($_POST['postRedirect']) && (!isset($_POST['reason']) || trim($_POST['reason']) == '')) |
|
| 146 | - fatal_lang_error('movetopic_no_reason', false); |
|
| 151 | + if (isset($_POST['postRedirect']) && (!isset($_POST['reason']) || trim($_POST['reason']) == '')) { |
|
| 152 | + fatal_lang_error('movetopic_no_reason', false); |
|
| 153 | + } |
|
| 147 | 154 | |
| 148 | 155 | moveTopicConcurrence(); |
| 149 | 156 | |
@@ -163,16 +170,18 @@ discard block |
||
| 163 | 170 | $smcFunc['db_free_result']($request); |
| 164 | 171 | |
| 165 | 172 | // Can they see it? |
| 166 | - if (!$context['is_approved']) |
|
| 167 | - isAllowedTo('approve_posts'); |
|
| 173 | + if (!$context['is_approved']) { |
|
| 174 | + isAllowedTo('approve_posts'); |
|
| 175 | + } |
|
| 168 | 176 | |
| 169 | 177 | // Can they move topics on this board? |
| 170 | 178 | if (!allowedTo('move_any')) |
| 171 | 179 | { |
| 172 | - if ($id_member_started == $user_info['id']) |
|
| 173 | - isAllowedTo('move_own'); |
|
| 174 | - else |
|
| 175 | - isAllowedTo('move_any'); |
|
| 180 | + if ($id_member_started == $user_info['id']) { |
|
| 181 | + isAllowedTo('move_own'); |
|
| 182 | + } else { |
|
| 183 | + isAllowedTo('move_any'); |
|
| 184 | + } |
|
| 176 | 185 | } |
| 177 | 186 | |
| 178 | 187 | checkSession(); |
@@ -197,8 +206,9 @@ discard block |
||
| 197 | 206 | 'blank_redirect' => '', |
| 198 | 207 | ) |
| 199 | 208 | ); |
| 200 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 201 | - fatal_lang_error('no_board'); |
|
| 209 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 210 | + fatal_lang_error('no_board'); |
|
| 211 | + } |
|
| 202 | 212 | list ($pcounter, $board_name, $subject) = $smcFunc['db_fetch_row']($request); |
| 203 | 213 | $smcFunc['db_free_result']($request); |
| 204 | 214 | |
@@ -210,8 +220,9 @@ discard block |
||
| 210 | 220 | { |
| 211 | 221 | $_POST['custom_subject'] = strtr($smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['custom_subject'])), array("\r" => '', "\n" => '', "\t" => '')); |
| 212 | 222 | // Keep checking the length. |
| 213 | - if ($smcFunc['strlen']($_POST['custom_subject']) > 100) |
|
| 214 | - $_POST['custom_subject'] = $smcFunc['substr']($_POST['custom_subject'], 0, 100); |
|
| 223 | + if ($smcFunc['strlen']($_POST['custom_subject']) > 100) { |
|
| 224 | + $_POST['custom_subject'] = $smcFunc['substr']($_POST['custom_subject'], 0, 100); |
|
| 225 | + } |
|
| 215 | 226 | |
| 216 | 227 | // If it's still valid move onwards and upwards. |
| 217 | 228 | if ($_POST['custom_subject'] != '') |
@@ -221,9 +232,9 @@ discard block |
||
| 221 | 232 | // Get a response prefix, but in the forum's default language. |
| 222 | 233 | if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix'))) |
| 223 | 234 | { |
| 224 | - if ($language === $user_info['language']) |
|
| 225 | - $context['response_prefix'] = $txt['response_prefix']; |
|
| 226 | - else |
|
| 235 | + if ($language === $user_info['language']) { |
|
| 236 | + $context['response_prefix'] = $txt['response_prefix']; |
|
| 237 | + } else |
|
| 227 | 238 | { |
| 228 | 239 | loadLanguage('index', $language, false); |
| 229 | 240 | $context['response_prefix'] = $txt['response_prefix']; |
@@ -263,8 +274,9 @@ discard block |
||
| 263 | 274 | if (isset($_POST['postRedirect'])) |
| 264 | 275 | { |
| 265 | 276 | // Should be in the boardwide language. |
| 266 | - if ($user_info['language'] != $language) |
|
| 267 | - loadLanguage('index', $language); |
|
| 277 | + if ($user_info['language'] != $language) { |
|
| 278 | + loadLanguage('index', $language); |
|
| 279 | + } |
|
| 268 | 280 | |
| 269 | 281 | $_POST['reason'] = $smcFunc['htmlspecialchars']($_POST['reason'], ENT_QUOTES); |
| 270 | 282 | preparsecode($_POST['reason']); |
@@ -328,8 +340,9 @@ discard block |
||
| 328 | 340 | $posters = array(); |
| 329 | 341 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 330 | 342 | { |
| 331 | - if (!isset($posters[$row['id_member']])) |
|
| 332 | - $posters[$row['id_member']] = 0; |
|
| 343 | + if (!isset($posters[$row['id_member']])) { |
|
| 344 | + $posters[$row['id_member']] = 0; |
|
| 345 | + } |
|
| 333 | 346 | |
| 334 | 347 | $posters[$row['id_member']]++; |
| 335 | 348 | } |
@@ -338,11 +351,13 @@ discard block |
||
| 338 | 351 | foreach ($posters as $id_member => $posts) |
| 339 | 352 | { |
| 340 | 353 | // The board we're moving from counted posts, but not to. |
| 341 | - if (empty($pcounter_from)) |
|
| 342 | - updateMemberData($id_member, array('posts' => 'posts - ' . $posts)); |
|
| 354 | + if (empty($pcounter_from)) { |
|
| 355 | + updateMemberData($id_member, array('posts' => 'posts - ' . $posts)); |
|
| 356 | + } |
|
| 343 | 357 | // The reverse: from didn't, to did. |
| 344 | - else |
|
| 345 | - updateMemberData($id_member, array('posts' => 'posts + ' . $posts)); |
|
| 358 | + else { |
|
| 359 | + updateMemberData($id_member, array('posts' => 'posts + ' . $posts)); |
|
| 360 | + } |
|
| 346 | 361 | } |
| 347 | 362 | } |
| 348 | 363 | |
@@ -350,17 +365,19 @@ discard block |
||
| 350 | 365 | moveTopics($topic, $_POST['toboard']); |
| 351 | 366 | |
| 352 | 367 | // Log that they moved this topic. |
| 353 | - if (!allowedTo('move_own') || $id_member_started != $user_info['id']) |
|
| 354 | - logAction('move', array('topic' => $topic, 'board_from' => $board, 'board_to' => $_POST['toboard'])); |
|
| 368 | + if (!allowedTo('move_own') || $id_member_started != $user_info['id']) { |
|
| 369 | + logAction('move', array('topic' => $topic, 'board_from' => $board, 'board_to' => $_POST['toboard'])); |
|
| 370 | + } |
|
| 355 | 371 | // Notify people that this topic has been moved? |
| 356 | 372 | sendNotifications($topic, 'move'); |
| 357 | 373 | |
| 358 | 374 | // Why not go back to the original board in case they want to keep moving? |
| 359 | - if (!isset($_REQUEST['goback'])) |
|
| 360 | - redirectexit('board=' . $board . '.0'); |
|
| 361 | - else |
|
| 362 | - redirectexit('topic=' . $topic . '.0'); |
|
| 363 | -} |
|
| 375 | + if (!isset($_REQUEST['goback'])) { |
|
| 376 | + redirectexit('board=' . $board . '.0'); |
|
| 377 | + } else { |
|
| 378 | + redirectexit('topic=' . $topic . '.0'); |
|
| 379 | + } |
|
| 380 | + } |
|
| 364 | 381 | |
| 365 | 382 | /** |
| 366 | 383 | * Moves one or more topics to a specific board. (doesn't check permissions.) |
@@ -376,18 +393,21 @@ discard block |
||
| 376 | 393 | global $sourcedir, $user_info, $modSettings, $smcFunc; |
| 377 | 394 | |
| 378 | 395 | // Empty array? |
| 379 | - if (empty($topics)) |
|
| 380 | - return; |
|
| 396 | + if (empty($topics)) { |
|
| 397 | + return; |
|
| 398 | + } |
|
| 381 | 399 | |
| 382 | 400 | // Only a single topic. |
| 383 | - if (is_numeric($topics)) |
|
| 384 | - $topics = array($topics); |
|
| 401 | + if (is_numeric($topics)) { |
|
| 402 | + $topics = array($topics); |
|
| 403 | + } |
|
| 385 | 404 | |
| 386 | 405 | $fromBoards = array(); |
| 387 | 406 | |
| 388 | 407 | // Destination board empty or equal to 0? |
| 389 | - if (empty($toBoard)) |
|
| 390 | - return; |
|
| 408 | + if (empty($toBoard)) { |
|
| 409 | + return; |
|
| 410 | + } |
|
| 391 | 411 | |
| 392 | 412 | // Are we moving to the recycle board? |
| 393 | 413 | $isRecycleDest = !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] == $toBoard; |
@@ -395,8 +415,9 @@ discard block |
||
| 395 | 415 | // Callback for search APIs to do their thing |
| 396 | 416 | require_once($sourcedir . '/Search.php'); |
| 397 | 417 | $searchAPI = findSearchAPI(); |
| 398 | - if ($searchAPI->supportsMethod('topicsMoved')) |
|
| 399 | - $searchAPI->topicsMoved($topics, $toBoard); |
|
| 418 | + if ($searchAPI->supportsMethod('topicsMoved')) { |
|
| 419 | + $searchAPI->topicsMoved($topics, $toBoard); |
|
| 420 | + } |
|
| 400 | 421 | |
| 401 | 422 | // Determine the source boards... |
| 402 | 423 | $request = $smcFunc['db_query']('', ' |
@@ -410,8 +431,9 @@ discard block |
||
| 410 | 431 | ) |
| 411 | 432 | ); |
| 412 | 433 | // Num of rows = 0 -> no topics found. Num of rows > 1 -> topics are on multiple boards. |
| 413 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 414 | - return; |
|
| 434 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 435 | + return; |
|
| 436 | + } |
|
| 415 | 437 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 416 | 438 | { |
| 417 | 439 | if (!isset($fromBoards[$row['id_board']]['num_posts'])) |
@@ -429,10 +451,11 @@ discard block |
||
| 429 | 451 | $fromBoards[$row['id_board']]['unapproved_posts'] += $row['unapproved_posts']; |
| 430 | 452 | |
| 431 | 453 | // Add the topics to the right type. |
| 432 | - if ($row['approved']) |
|
| 433 | - $fromBoards[$row['id_board']]['num_topics'] += $row['num_topics']; |
|
| 434 | - else |
|
| 435 | - $fromBoards[$row['id_board']]['unapproved_topics'] += $row['num_topics']; |
|
| 454 | + if ($row['approved']) { |
|
| 455 | + $fromBoards[$row['id_board']]['num_topics'] += $row['num_topics']; |
|
| 456 | + } else { |
|
| 457 | + $fromBoards[$row['id_board']]['unapproved_topics'] += $row['num_topics']; |
|
| 458 | + } |
|
| 436 | 459 | } |
| 437 | 460 | $smcFunc['db_free_result']($request); |
| 438 | 461 | |
@@ -558,13 +581,14 @@ discard block |
||
| 558 | 581 | ) |
| 559 | 582 | ); |
| 560 | 583 | $approval_msgs = array(); |
| 561 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 562 | - $approval_msgs[] = $row['id_msg']; |
|
| 584 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 585 | + $approval_msgs[] = $row['id_msg']; |
|
| 586 | + } |
|
| 563 | 587 | $smcFunc['db_free_result']($request); |
| 564 | 588 | |
| 565 | 589 | // Empty the approval queue for these, as we're going to approve them next. |
| 566 | - if (!empty($approval_msgs)) |
|
| 567 | - $smcFunc['db_query']('', ' |
|
| 590 | + if (!empty($approval_msgs)) { |
|
| 591 | + $smcFunc['db_query']('', ' |
|
| 568 | 592 | DELETE FROM {db_prefix}approval_queue |
| 569 | 593 | WHERE id_msg IN ({array_int:message_list}) |
| 570 | 594 | AND id_attach = {int:id_attach}', |
@@ -573,6 +597,7 @@ discard block |
||
| 573 | 597 | 'id_attach' => 0, |
| 574 | 598 | ) |
| 575 | 599 | ); |
| 600 | + } |
|
| 576 | 601 | |
| 577 | 602 | // Get all the current max and mins. |
| 578 | 603 | $request = $smcFunc['db_query']('', ' |
@@ -606,8 +631,8 @@ discard block |
||
| 606 | 631 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 607 | 632 | { |
| 608 | 633 | // If not, update. |
| 609 | - if ($row['first_msg'] != $topicMaxMin[$row['id_topic']]['min'] || $row['last_msg'] != $topicMaxMin[$row['id_topic']]['max']) |
|
| 610 | - $smcFunc['db_query']('', ' |
|
| 634 | + if ($row['first_msg'] != $topicMaxMin[$row['id_topic']]['min'] || $row['last_msg'] != $topicMaxMin[$row['id_topic']]['max']) { |
|
| 635 | + $smcFunc['db_query']('', ' |
|
| 611 | 636 | UPDATE {db_prefix}topics |
| 612 | 637 | SET id_first_msg = {int:first_msg}, id_last_msg = {int:last_msg} |
| 613 | 638 | WHERE id_topic = {int:selected_topic}', |
@@ -617,6 +642,7 @@ discard block |
||
| 617 | 642 | 'selected_topic' => $row['id_topic'], |
| 618 | 643 | ) |
| 619 | 644 | ); |
| 645 | + } |
|
| 620 | 646 | } |
| 621 | 647 | $smcFunc['db_free_result']($request); |
| 622 | 648 | } |
@@ -675,9 +701,10 @@ discard block |
||
| 675 | 701 | } |
| 676 | 702 | |
| 677 | 703 | // Update the cache? |
| 678 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 3) |
|
| 679 | - foreach ($topics as $topic_id) |
|
| 704 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 3) { |
|
| 705 | + foreach ($topics as $topic_id) |
|
| 680 | 706 | cache_put_data('topic_board-' . $topic_id, null, 120); |
| 707 | + } |
|
| 681 | 708 | |
| 682 | 709 | require_once($sourcedir . '/Subs-Post.php'); |
| 683 | 710 | |
@@ -701,15 +728,17 @@ discard block |
||
| 701 | 728 | { |
| 702 | 729 | global $board, $topic, $smcFunc, $scripturl; |
| 703 | 730 | |
| 704 | - if (isset($_GET['current_board'])) |
|
| 705 | - $move_from = (int) $_GET['current_board']; |
|
| 731 | + if (isset($_GET['current_board'])) { |
|
| 732 | + $move_from = (int) $_GET['current_board']; |
|
| 733 | + } |
|
| 706 | 734 | |
| 707 | - if (empty($move_from) || empty($board) || empty($topic)) |
|
| 708 | - return true; |
|
| 735 | + if (empty($move_from) || empty($board) || empty($topic)) { |
|
| 736 | + return true; |
|
| 737 | + } |
|
| 709 | 738 | |
| 710 | - if ($move_from == $board) |
|
| 711 | - return true; |
|
| 712 | - else |
|
| 739 | + if ($move_from == $board) { |
|
| 740 | + return true; |
|
| 741 | + } else |
|
| 713 | 742 | { |
| 714 | 743 | $request = $smcFunc['db_query']('', ' |
| 715 | 744 | SELECT m.subject, b.name |
@@ -17,8 +17,9 @@ discard block |
||
| 17 | 17 | * @version 2.1 Beta 3 |
| 18 | 18 | */ |
| 19 | 19 | |
| 20 | -if (!defined('SMF')) |
|
| 20 | +if (!defined('SMF')) { |
|
| 21 | 21 | die('No direct access...'); |
| 22 | +} |
|
| 22 | 23 | |
| 23 | 24 | /** |
| 24 | 25 | * Attempt to start the session, unless it already has been. |
@@ -38,8 +39,9 @@ discard block |
||
| 38 | 39 | { |
| 39 | 40 | $parsed_url = parse_url($boardurl); |
| 40 | 41 | |
| 41 | - if (preg_match('~^\d{1,3}(\.\d{1,3}){3}$~', $parsed_url['host']) == 0 && preg_match('~(?:[^\.]+\.)?([^\.]{2,}\..+)\z~i', $parsed_url['host'], $parts) == 1) |
|
| 42 | - @ini_set('session.cookie_domain', '.' . $parts[1]); |
|
| 42 | + if (preg_match('~^\d{1,3}(\.\d{1,3}){3}$~', $parsed_url['host']) == 0 && preg_match('~(?:[^\.]+\.)?([^\.]{2,}\..+)\z~i', $parsed_url['host'], $parts) == 1) { |
|
| 43 | + @ini_set('session.cookie_domain', '.' . $parts[1]); |
|
| 44 | + } |
|
| 43 | 45 | } |
| 44 | 46 | // @todo Set the session cookie path? |
| 45 | 47 | |
@@ -47,8 +49,9 @@ discard block |
||
| 47 | 49 | if ((ini_get('session.auto_start') == 1 && !empty($modSettings['databaseSession_enable'])) || session_id() == '') |
| 48 | 50 | { |
| 49 | 51 | // Attempt to end the already-started session. |
| 50 | - if (ini_get('session.auto_start') == 1) |
|
| 51 | - session_write_close(); |
|
| 52 | + if (ini_get('session.auto_start') == 1) { |
|
| 53 | + session_write_close(); |
|
| 54 | + } |
|
| 52 | 55 | |
| 53 | 56 | // This is here to stop people from using bad junky PHPSESSIDs. |
| 54 | 57 | if (isset($_REQUEST[session_name()]) && preg_match('~^[A-Za-z0-9,-]{16,64}$~', $_REQUEST[session_name()]) == 0 && !isset($_COOKIE[session_name()])) |
@@ -65,19 +68,21 @@ discard block |
||
| 65 | 68 | @ini_set('session.serialize_handler', 'php'); |
| 66 | 69 | session_set_save_handler('sessionOpen', 'sessionClose', 'sessionRead', 'sessionWrite', 'sessionDestroy', 'sessionGC'); |
| 67 | 70 | @ini_set('session.gc_probability', '1'); |
| 71 | + } elseif (ini_get('session.gc_maxlifetime') <= 1440 && !empty($modSettings['databaseSession_lifetime'])) { |
|
| 72 | + @ini_set('session.gc_maxlifetime', max($modSettings['databaseSession_lifetime'], 60)); |
|
| 68 | 73 | } |
| 69 | - elseif (ini_get('session.gc_maxlifetime') <= 1440 && !empty($modSettings['databaseSession_lifetime'])) |
|
| 70 | - @ini_set('session.gc_maxlifetime', max($modSettings['databaseSession_lifetime'], 60)); |
|
| 71 | 74 | |
| 72 | 75 | // Use cache setting sessions? |
| 73 | - if (empty($modSettings['databaseSession_enable']) && !empty($modSettings['cache_enable']) && php_sapi_name() != 'cli') |
|
| 74 | - call_integration_hook('integrate_session_handlers'); |
|
| 76 | + if (empty($modSettings['databaseSession_enable']) && !empty($modSettings['cache_enable']) && php_sapi_name() != 'cli') { |
|
| 77 | + call_integration_hook('integrate_session_handlers'); |
|
| 78 | + } |
|
| 75 | 79 | |
| 76 | 80 | session_start(); |
| 77 | 81 | |
| 78 | 82 | // Change it so the cache settings are a little looser than default. |
| 79 | - if (!empty($modSettings['databaseSession_loose'])) |
|
| 80 | - header('Cache-Control: private'); |
|
| 83 | + if (!empty($modSettings['databaseSession_loose'])) { |
|
| 84 | + header('Cache-Control: private'); |
|
| 85 | + } |
|
| 81 | 86 | } |
| 82 | 87 | |
| 83 | 88 | // Set the randomly generated code. |
@@ -123,8 +128,9 @@ discard block |
||
| 123 | 128 | { |
| 124 | 129 | global $smcFunc; |
| 125 | 130 | |
| 126 | - if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0) |
|
| 127 | - return ''; |
|
| 131 | + if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0) { |
|
| 132 | + return ''; |
|
| 133 | + } |
|
| 128 | 134 | |
| 129 | 135 | // Look for it in the database. |
| 130 | 136 | $result = $smcFunc['db_query']('', ' |
@@ -153,8 +159,9 @@ discard block |
||
| 153 | 159 | { |
| 154 | 160 | global $smcFunc; |
| 155 | 161 | |
| 156 | - if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0) |
|
| 157 | - return false; |
|
| 162 | + if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0) { |
|
| 163 | + return false; |
|
| 164 | + } |
|
| 158 | 165 | |
| 159 | 166 | // First try to update an existing row... |
| 160 | 167 | $smcFunc['db_query']('', ' |
@@ -169,13 +176,14 @@ discard block |
||
| 169 | 176 | ); |
| 170 | 177 | |
| 171 | 178 | // If that didn't work, try inserting a new one. |
| 172 | - if ($smcFunc['db_affected_rows']() == 0) |
|
| 173 | - $smcFunc['db_insert']('ignore', |
|
| 179 | + if ($smcFunc['db_affected_rows']() == 0) { |
|
| 180 | + $smcFunc['db_insert']('ignore', |
|
| 174 | 181 | '{db_prefix}sessions', |
| 175 | 182 | array('session_id' => 'string', 'data' => 'string', 'last_update' => 'int'), |
| 176 | 183 | array($session_id, $data, time()), |
| 177 | 184 | array('session_id') |
| 178 | 185 | ); |
| 186 | + } |
|
| 179 | 187 | |
| 180 | 188 | return ($smcFunc['db_affected_rows']() == 0 ? false : true); |
| 181 | 189 | } |
@@ -190,8 +198,9 @@ discard block |
||
| 190 | 198 | { |
| 191 | 199 | global $smcFunc; |
| 192 | 200 | |
| 193 | - if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0) |
|
| 194 | - return false; |
|
| 201 | + if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0) { |
|
| 202 | + return false; |
|
| 203 | + } |
|
| 195 | 204 | |
| 196 | 205 | // Just delete the row... |
| 197 | 206 | $smcFunc['db_query']('', ' |
@@ -217,8 +226,9 @@ discard block |
||
| 217 | 226 | global $modSettings, $smcFunc; |
| 218 | 227 | |
| 219 | 228 | // Just set to the default or lower? Ignore it for a higher value. (hopefully) |
| 220 | - if (!empty($modSettings['databaseSession_lifetime']) && ($max_lifetime <= 1440 || $modSettings['databaseSession_lifetime'] > $max_lifetime)) |
|
| 221 | - $max_lifetime = max($modSettings['databaseSession_lifetime'], 60); |
|
| 229 | + if (!empty($modSettings['databaseSession_lifetime']) && ($max_lifetime <= 1440 || $modSettings['databaseSession_lifetime'] > $max_lifetime)) { |
|
| 230 | + $max_lifetime = max($modSettings['databaseSession_lifetime'], 60); |
|
| 231 | + } |
|
| 222 | 232 | |
| 223 | 233 | // Clean up after yerself ;). |
| 224 | 234 | $smcFunc['db_query']('', ' |
@@ -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,14 @@ 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 | // Update the download counter (unless it's a thumbnail). |
| 184 | - if ($file['attachment_type'] != 3 && empty($showThumb)) |
|
| 185 | - $smcFunc['db_query']('attach_download_increase', ' |
|
| 186 | + if ($file['attachment_type'] != 3 && empty($showThumb)) { |
|
| 187 | + $smcFunc['db_query']('attach_download_increase', ' |
|
| 186 | 188 | UPDATE LOW_PRIORITY {db_prefix}attachments |
| 187 | 189 | SET downloads = downloads + 1 |
| 188 | 190 | WHERE id_attach = {int:id_attach}', |
@@ -190,10 +192,12 @@ discard block |
||
| 190 | 192 | 'id_attach' => $attachId, |
| 191 | 193 | ) |
| 192 | 194 | ); |
| 195 | + } |
|
| 193 | 196 | |
| 194 | 197 | // Replace the normal file with its thumbnail if it has one! |
| 195 | - if (!empty($showThumb) && !empty($thumbFile)) |
|
| 196 | - $file = $thumbFile; |
|
| 198 | + if (!empty($showThumb) && !empty($thumbFile)) { |
|
| 199 | + $file = $thumbFile; |
|
| 200 | + } |
|
| 197 | 201 | |
| 198 | 202 | // No point in a nicer message, because this is supposed to be an attachment anyway... |
| 199 | 203 | if (!file_exists($file['filePath'])) |
@@ -232,8 +236,9 @@ discard block |
||
| 232 | 236 | // Send the attachment headers. |
| 233 | 237 | header('Pragma: '); |
| 234 | 238 | |
| 235 | - if (!isBrowser('gecko')) |
|
| 236 | - header('Content-Transfer-Encoding: binary'); |
|
| 239 | + if (!isBrowser('gecko')) { |
|
| 240 | + header('Content-Transfer-Encoding: binary'); |
|
| 241 | + } |
|
| 237 | 242 | |
| 238 | 243 | header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 525600 * 60) . ' GMT'); |
| 239 | 244 | header('Last-Modified: ' . gmdate('D, d M Y H:i:s', filemtime($file['filePath'])) . ' GMT'); |
@@ -242,18 +247,19 @@ discard block |
||
| 242 | 247 | header('ETag: ' . $eTag); |
| 243 | 248 | |
| 244 | 249 | // Make sure the mime type warrants an inline display. |
| 245 | - if (isset($_REQUEST['image']) && !empty($file['mime_type']) && strpos($file['mime_type'], 'image/') !== 0) |
|
| 246 | - unset($_REQUEST['image']); |
|
| 250 | + if (isset($_REQUEST['image']) && !empty($file['mime_type']) && strpos($file['mime_type'], 'image/') !== 0) { |
|
| 251 | + unset($_REQUEST['image']); |
|
| 252 | + } |
|
| 247 | 253 | |
| 248 | 254 | // Does this have a mime type? |
| 249 | - elseif (!empty($file['mime_type']) && (isset($_REQUEST['image']) || !in_array($file['fileext'], array('jpg', 'gif', 'jpeg', 'x-ms-bmp', 'png', 'psd', 'tiff', 'iff')))) |
|
| 250 | - header('Content-Type: ' . strtr($file['mime_type'], array('image/bmp' => 'image/x-ms-bmp'))); |
|
| 251 | - |
|
| 252 | - else |
|
| 255 | + elseif (!empty($file['mime_type']) && (isset($_REQUEST['image']) || !in_array($file['fileext'], array('jpg', 'gif', 'jpeg', 'x-ms-bmp', 'png', 'psd', 'tiff', 'iff')))) { |
|
| 256 | + header('Content-Type: ' . strtr($file['mime_type'], array('image/bmp' => 'image/x-ms-bmp'))); |
|
| 257 | + } else |
|
| 253 | 258 | { |
| 254 | 259 | header('Content-Type: ' . (isBrowser('ie') || isBrowser('opera') ? 'application/octetstream' : 'application/octet-stream')); |
| 255 | - if (isset($_REQUEST['image'])) |
|
| 256 | - unset($_REQUEST['image']); |
|
| 260 | + if (isset($_REQUEST['image'])) { |
|
| 261 | + unset($_REQUEST['image']); |
|
| 262 | + } |
|
| 257 | 263 | } |
| 258 | 264 | |
| 259 | 265 | // Convert the file to UTF-8, cuz most browsers dig that. |
@@ -261,24 +267,22 @@ discard block |
||
| 261 | 267 | $disposition = !isset($_REQUEST['image']) ? 'attachment' : 'inline'; |
| 262 | 268 | |
| 263 | 269 | // Different browsers like different standards... |
| 264 | - if (isBrowser('firefox')) |
|
| 265 | - header('Content-Disposition: ' . $disposition . '; filename*=UTF-8\'\'' . rawurlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name))); |
|
| 266 | - |
|
| 267 | - elseif (isBrowser('opera')) |
|
| 268 | - header('Content-Disposition: ' . $disposition . '; filename="' . preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name) . '"'); |
|
| 269 | - |
|
| 270 | - elseif (isBrowser('ie')) |
|
| 271 | - header('Content-Disposition: ' . $disposition . '; filename="' . urlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name)) . '"'); |
|
| 272 | - |
|
| 273 | - else |
|
| 274 | - header('Content-Disposition: ' . $disposition . '; filename="' . $utf8name . '"'); |
|
| 270 | + if (isBrowser('firefox')) { |
|
| 271 | + header('Content-Disposition: ' . $disposition . '; filename*=UTF-8\'\'' . rawurlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name))); |
|
| 272 | + } elseif (isBrowser('opera')) { |
|
| 273 | + header('Content-Disposition: ' . $disposition . '; filename="' . preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name) . '"'); |
|
| 274 | + } elseif (isBrowser('ie')) { |
|
| 275 | + header('Content-Disposition: ' . $disposition . '; filename="' . urlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name)) . '"'); |
|
| 276 | + } else { |
|
| 277 | + header('Content-Disposition: ' . $disposition . '; filename="' . $utf8name . '"'); |
|
| 278 | + } |
|
| 275 | 279 | |
| 276 | 280 | // If this has an "image extension" - but isn't actually an image - then ensure it isn't cached cause of silly IE. |
| 277 | - if (!isset($_REQUEST['image']) && in_array($file['fileext'], array('gif', 'jpg', 'bmp', 'png', 'jpeg', 'tiff'))) |
|
| 278 | - header('Cache-Control: no-cache'); |
|
| 279 | - |
|
| 280 | - else |
|
| 281 | - header('Cache-Control: max-age=' . (525600 * 60) . ', private'); |
|
| 281 | + if (!isset($_REQUEST['image']) && in_array($file['fileext'], array('gif', 'jpg', 'bmp', 'png', 'jpeg', 'tiff'))) { |
|
| 282 | + header('Cache-Control: no-cache'); |
|
| 283 | + } else { |
|
| 284 | + header('Cache-Control: max-age=' . (525600 * 60) . ', private'); |
|
| 285 | + } |
|
| 282 | 286 | |
| 283 | 287 | header('Content-Length: ' . filesize($file['filePath'])); |
| 284 | 288 | |
@@ -289,8 +293,9 @@ discard block |
||
| 289 | 293 | if (filesize($file['filePath']) > 4194304) |
| 290 | 294 | { |
| 291 | 295 | // Forcibly end any output buffering going on. |
| 292 | - while (@ob_get_level() > 0) |
|
| 293 | - @ob_end_clean(); |
|
| 296 | + while (@ob_get_level() > 0) { |
|
| 297 | + @ob_end_clean(); |
|
| 298 | + } |
|
| 294 | 299 | |
| 295 | 300 | $fp = fopen($file['filePath'], 'rb'); |
| 296 | 301 | while (!feof($fp)) |
@@ -302,8 +307,9 @@ discard block |
||
| 302 | 307 | } |
| 303 | 308 | |
| 304 | 309 | // 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. |
| 305 | - elseif (@readfile($file['filePath']) === null) |
|
| 306 | - echo file_get_contents($file['filePath']); |
|
| 310 | + elseif (@readfile($file['filePath']) === null) { |
|
| 311 | + echo file_get_contents($file['filePath']); |
|
| 312 | + } |
|
| 307 | 313 | |
| 308 | 314 | die(); |
| 309 | 315 | } |
@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | * @version 2.1 Beta 3 |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | -if (!defined('SMF')) |
|
| 17 | +if (!defined('SMF')) { |
|
| 18 | 18 | die('No direct access...'); |
| 19 | +} |
|
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * Mark a board or multiple boards read. |
@@ -28,14 +29,16 @@ discard block |
||
| 28 | 29 | global $user_info, $modSettings, $smcFunc; |
| 29 | 30 | |
| 30 | 31 | // Force $boards to be an array. |
| 31 | - if (!is_array($boards)) |
|
| 32 | - $boards = array($boards); |
|
| 33 | - else |
|
| 34 | - $boards = array_unique($boards); |
|
| 32 | + if (!is_array($boards)) { |
|
| 33 | + $boards = array($boards); |
|
| 34 | + } else { |
|
| 35 | + $boards = array_unique($boards); |
|
| 36 | + } |
|
| 35 | 37 | |
| 36 | 38 | // No boards, nothing to mark as read. |
| 37 | - if (empty($boards)) |
|
| 38 | - return; |
|
| 39 | + if (empty($boards)) { |
|
| 40 | + return; |
|
| 41 | + } |
|
| 39 | 42 | |
| 40 | 43 | // Allow the user to mark a board as unread. |
| 41 | 44 | if ($unread) |
@@ -65,8 +68,9 @@ discard block |
||
| 65 | 68 | else |
| 66 | 69 | { |
| 67 | 70 | $markRead = array(); |
| 68 | - foreach ($boards as $board) |
|
| 69 | - $markRead[] = array($modSettings['maxMsgID'], $user_info['id'], $board); |
|
| 71 | + foreach ($boards as $board) { |
|
| 72 | + $markRead[] = array($modSettings['maxMsgID'], $user_info['id'], $board); |
|
| 73 | + } |
|
| 70 | 74 | |
| 71 | 75 | // Update log_mark_read and log_boards. |
| 72 | 76 | $smcFunc['db_insert']('replace', |
@@ -99,8 +103,9 @@ discard block |
||
| 99 | 103 | list ($lowest_topic) = $smcFunc['db_fetch_row']($result); |
| 100 | 104 | $smcFunc['db_free_result']($result); |
| 101 | 105 | |
| 102 | - if (empty($lowest_topic)) |
|
| 103 | - return; |
|
| 106 | + if (empty($lowest_topic)) { |
|
| 107 | + return; |
|
| 108 | + } |
|
| 104 | 109 | |
| 105 | 110 | // @todo SLOW This query seems to eat it sometimes. |
| 106 | 111 | $result = $smcFunc['db_query']('', ' |
@@ -118,12 +123,13 @@ discard block |
||
| 118 | 123 | ) |
| 119 | 124 | ); |
| 120 | 125 | $topics = array(); |
| 121 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
| 122 | - $topics[] = $row['id_topic']; |
|
| 126 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
| 127 | + $topics[] = $row['id_topic']; |
|
| 128 | + } |
|
| 123 | 129 | $smcFunc['db_free_result']($result); |
| 124 | 130 | |
| 125 | - if (!empty($topics)) |
|
| 126 | - $smcFunc['db_query']('', ' |
|
| 131 | + if (!empty($topics)) { |
|
| 132 | + $smcFunc['db_query']('', ' |
|
| 127 | 133 | DELETE FROM {db_prefix}log_topics |
| 128 | 134 | WHERE id_member = {int:current_member} |
| 129 | 135 | AND id_topic IN ({array_int:topic_list})', |
@@ -132,7 +138,8 @@ discard block |
||
| 132 | 138 | 'topic_list' => $topics, |
| 133 | 139 | ) |
| 134 | 140 | ); |
| 135 | -} |
|
| 141 | + } |
|
| 142 | + } |
|
| 136 | 143 | |
| 137 | 144 | /** |
| 138 | 145 | * Mark one or more boards as read. |
@@ -157,23 +164,26 @@ discard block |
||
| 157 | 164 | ) |
| 158 | 165 | ); |
| 159 | 166 | $boards = array(); |
| 160 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
| 161 | - $boards[] = $row['id_board']; |
|
| 167 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
| 168 | + $boards[] = $row['id_board']; |
|
| 169 | + } |
|
| 162 | 170 | $smcFunc['db_free_result']($result); |
| 163 | 171 | |
| 164 | - if (!empty($boards)) |
|
| 165 | - markBoardsRead($boards, isset($_REQUEST['unread'])); |
|
| 172 | + if (!empty($boards)) { |
|
| 173 | + markBoardsRead($boards, isset($_REQUEST['unread'])); |
|
| 174 | + } |
|
| 166 | 175 | |
| 167 | 176 | $_SESSION['id_msg_last_visit'] = $modSettings['maxMsgID']; |
| 168 | - if (!empty($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'action=unread') !== false) |
|
| 169 | - redirectexit('action=unread'); |
|
| 177 | + if (!empty($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'action=unread') !== false) { |
|
| 178 | + redirectexit('action=unread'); |
|
| 179 | + } |
|
| 170 | 180 | |
| 171 | - if (isset($_SESSION['topicseen_cache'])) |
|
| 172 | - $_SESSION['topicseen_cache'] = array(); |
|
| 181 | + if (isset($_SESSION['topicseen_cache'])) { |
|
| 182 | + $_SESSION['topicseen_cache'] = array(); |
|
| 183 | + } |
|
| 173 | 184 | |
| 174 | 185 | redirectexit(); |
| 175 | - } |
|
| 176 | - elseif (isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'unreadreplies') |
|
| 186 | + } elseif (isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'unreadreplies') |
|
| 177 | 187 | { |
| 178 | 188 | // Make sure all the topics are integers! |
| 179 | 189 | $topics = array_map('intval', explode('-', $_REQUEST['topics'])); |
@@ -189,13 +199,15 @@ discard block |
||
| 189 | 199 | ) |
| 190 | 200 | ); |
| 191 | 201 | $logged_topics = array(); |
| 192 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 193 | - $logged_topics[$row['id_topic']] = $row['unwatched']; |
|
| 202 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 203 | + $logged_topics[$row['id_topic']] = $row['unwatched']; |
|
| 204 | + } |
|
| 194 | 205 | $smcFunc['db_free_result']($request); |
| 195 | 206 | |
| 196 | 207 | $markRead = array(); |
| 197 | - foreach ($topics as $id_topic) |
|
| 198 | - $markRead[] = array($modSettings['maxMsgID'], $user_info['id'], $id_topic, (isset($logged_topics[$topic]) ? $logged_topics[$topic] : 0)); |
|
| 208 | + foreach ($topics as $id_topic) { |
|
| 209 | + $markRead[] = array($modSettings['maxMsgID'], $user_info['id'], $id_topic, (isset($logged_topics[$topic]) ? $logged_topics[$topic] : 0)); |
|
| 210 | + } |
|
| 199 | 211 | |
| 200 | 212 | $smcFunc['db_insert']('replace', |
| 201 | 213 | '{db_prefix}log_topics', |
@@ -204,8 +216,9 @@ discard block |
||
| 204 | 216 | array('id_member', 'id_topic') |
| 205 | 217 | ); |
| 206 | 218 | |
| 207 | - if (isset($_SESSION['topicseen_cache'])) |
|
| 208 | - $_SESSION['topicseen_cache'] = array(); |
|
| 219 | + if (isset($_SESSION['topicseen_cache'])) { |
|
| 220 | + $_SESSION['topicseen_cache'] = array(); |
|
| 221 | + } |
|
| 209 | 222 | |
| 210 | 223 | redirectexit('action=unreadreplies'); |
| 211 | 224 | } |
@@ -230,11 +243,13 @@ discard block |
||
| 230 | 243 | if (!empty($_GET['t'])) |
| 231 | 244 | { |
| 232 | 245 | // If they read the whole topic, go back to the beginning. |
| 233 | - if ($_GET['t'] >= $topicinfo['id_last_msg']) |
|
| 234 | - $earlyMsg = 0; |
|
| 246 | + if ($_GET['t'] >= $topicinfo['id_last_msg']) { |
|
| 247 | + $earlyMsg = 0; |
|
| 248 | + } |
|
| 235 | 249 | // If they want to mark the whole thing read, same. |
| 236 | - elseif ($_GET['t'] <= $topicinfo['id_first_msg']) |
|
| 237 | - $earlyMsg = 0; |
|
| 250 | + elseif ($_GET['t'] <= $topicinfo['id_first_msg']) { |
|
| 251 | + $earlyMsg = 0; |
|
| 252 | + } |
|
| 238 | 253 | // Otherwise, get the latest message before the named one. |
| 239 | 254 | else |
| 240 | 255 | { |
@@ -255,9 +270,9 @@ discard block |
||
| 255 | 270 | } |
| 256 | 271 | } |
| 257 | 272 | // Marking read from first page? That's the whole topic. |
| 258 | - elseif ($_REQUEST['start'] == 0) |
|
| 259 | - $earlyMsg = 0; |
|
| 260 | - else |
|
| 273 | + elseif ($_REQUEST['start'] == 0) { |
|
| 274 | + $earlyMsg = 0; |
|
| 275 | + } else |
|
| 261 | 276 | { |
| 262 | 277 | $result = $smcFunc['db_query']('', ' |
| 263 | 278 | SELECT id_msg |
@@ -285,8 +300,7 @@ discard block |
||
| 285 | 300 | ); |
| 286 | 301 | |
| 287 | 302 | redirectexit('board=' . $board . '.0'); |
| 288 | - } |
|
| 289 | - else |
|
| 303 | + } else |
|
| 290 | 304 | { |
| 291 | 305 | $categories = array(); |
| 292 | 306 | $boards = array(); |
@@ -294,17 +308,20 @@ discard block |
||
| 294 | 308 | if (isset($_REQUEST['c'])) |
| 295 | 309 | { |
| 296 | 310 | $_REQUEST['c'] = explode(',', $_REQUEST['c']); |
| 297 | - foreach ($_REQUEST['c'] as $c) |
|
| 298 | - $categories[] = (int) $c; |
|
| 311 | + foreach ($_REQUEST['c'] as $c) { |
|
| 312 | + $categories[] = (int) $c; |
|
| 313 | + } |
|
| 299 | 314 | } |
| 300 | 315 | if (isset($_REQUEST['boards'])) |
| 301 | 316 | { |
| 302 | 317 | $_REQUEST['boards'] = explode(',', $_REQUEST['boards']); |
| 303 | - foreach ($_REQUEST['boards'] as $b) |
|
| 304 | - $boards[] = (int) $b; |
|
| 318 | + foreach ($_REQUEST['boards'] as $b) { |
|
| 319 | + $boards[] = (int) $b; |
|
| 320 | + } |
|
| 321 | + } |
|
| 322 | + if (!empty($board)) { |
|
| 323 | + $boards[] = (int) $board; |
|
| 305 | 324 | } |
| 306 | - if (!empty($board)) |
|
| 307 | - $boards[] = (int) $board; |
|
| 308 | 325 | |
| 309 | 326 | if (isset($_REQUEST['children']) && !empty($boards)) |
| 310 | 327 | { |
@@ -324,9 +341,10 @@ discard block |
||
| 324 | 341 | 'board_list' => $boards, |
| 325 | 342 | ) |
| 326 | 343 | ); |
| 327 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 328 | - if (in_array($row['id_parent'], $boards)) |
|
| 344 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 345 | + if (in_array($row['id_parent'], $boards)) |
|
| 329 | 346 | $boards[] = $row['id_board']; |
| 347 | + } |
|
| 330 | 348 | $smcFunc['db_free_result']($request); |
| 331 | 349 | } |
| 332 | 350 | |
@@ -343,8 +361,9 @@ discard block |
||
| 343 | 361 | $clauseParameters['board_list'] = $boards; |
| 344 | 362 | } |
| 345 | 363 | |
| 346 | - if (empty($clauses)) |
|
| 347 | - redirectexit(); |
|
| 364 | + if (empty($clauses)) { |
|
| 365 | + redirectexit(); |
|
| 366 | + } |
|
| 348 | 367 | |
| 349 | 368 | $request = $smcFunc['db_query']('', ' |
| 350 | 369 | SELECT b.id_board |
@@ -355,19 +374,22 @@ discard block |
||
| 355 | 374 | )) |
| 356 | 375 | ); |
| 357 | 376 | $boards = array(); |
| 358 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 359 | - $boards[] = $row['id_board']; |
|
| 377 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 378 | + $boards[] = $row['id_board']; |
|
| 379 | + } |
|
| 360 | 380 | $smcFunc['db_free_result']($request); |
| 361 | 381 | |
| 362 | - if (empty($boards)) |
|
| 363 | - redirectexit(); |
|
| 382 | + if (empty($boards)) { |
|
| 383 | + redirectexit(); |
|
| 384 | + } |
|
| 364 | 385 | |
| 365 | 386 | markBoardsRead($boards, isset($_REQUEST['unread'])); |
| 366 | 387 | |
| 367 | 388 | foreach ($boards as $b) |
| 368 | 389 | { |
| 369 | - if (isset($_SESSION['topicseen_cache'][$b])) |
|
| 370 | - $_SESSION['topicseen_cache'][$b] = array(); |
|
| 390 | + if (isset($_SESSION['topicseen_cache'][$b])) { |
|
| 391 | + $_SESSION['topicseen_cache'][$b] = array(); |
|
| 392 | + } |
|
| 371 | 393 | } |
| 372 | 394 | |
| 373 | 395 | if (!isset($_REQUEST['unread'])) |
@@ -385,8 +407,9 @@ discard block |
||
| 385 | 407 | if ($smcFunc['db_num_rows']($result) > 0) |
| 386 | 408 | { |
| 387 | 409 | $logBoardInserts = ''; |
| 388 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
| 389 | - $logBoardInserts[] = array($modSettings['maxMsgID'], $user_info['id'], $row['id_board']); |
|
| 410 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
| 411 | + $logBoardInserts[] = array($modSettings['maxMsgID'], $user_info['id'], $row['id_board']); |
|
| 412 | + } |
|
| 390 | 413 | |
| 391 | 414 | $smcFunc['db_insert']('replace', |
| 392 | 415 | '{db_prefix}log_boards', |
@@ -397,17 +420,18 @@ discard block |
||
| 397 | 420 | } |
| 398 | 421 | $smcFunc['db_free_result']($result); |
| 399 | 422 | |
| 400 | - if (empty($board)) |
|
| 401 | - redirectexit(); |
|
| 402 | - else |
|
| 403 | - redirectexit('board=' . $board . '.0'); |
|
| 404 | - } |
|
| 405 | - else |
|
| 423 | + if (empty($board)) { |
|
| 424 | + redirectexit(); |
|
| 425 | + } else { |
|
| 426 | + redirectexit('board=' . $board . '.0'); |
|
| 427 | + } |
|
| 428 | + } else |
|
| 406 | 429 | { |
| 407 | - if (empty($board_info['parent'])) |
|
| 408 | - redirectexit(); |
|
| 409 | - else |
|
| 410 | - redirectexit('board=' . $board_info['parent'] . '.0'); |
|
| 430 | + if (empty($board_info['parent'])) { |
|
| 431 | + redirectexit(); |
|
| 432 | + } else { |
|
| 433 | + redirectexit('board=' . $board_info['parent'] . '.0'); |
|
| 434 | + } |
|
| 411 | 435 | } |
| 412 | 436 | } |
| 413 | 437 | } |
@@ -432,11 +456,13 @@ discard block |
||
| 432 | 456 | 'selected_message' => (int) $messageID, |
| 433 | 457 | ) |
| 434 | 458 | ); |
| 435 | - if ($smcFunc['db_num_rows']($result) > 0) |
|
| 436 | - list ($memberID) = $smcFunc['db_fetch_row']($result); |
|
| 459 | + if ($smcFunc['db_num_rows']($result) > 0) { |
|
| 460 | + list ($memberID) = $smcFunc['db_fetch_row']($result); |
|
| 461 | + } |
|
| 437 | 462 | // The message doesn't even exist. |
| 438 | - else |
|
| 439 | - $memberID = 0; |
|
| 463 | + else { |
|
| 464 | + $memberID = 0; |
|
| 465 | + } |
|
| 440 | 466 | $smcFunc['db_free_result']($result); |
| 441 | 467 | |
| 442 | 468 | return (int) $memberID; |
@@ -457,8 +483,9 @@ discard block |
||
| 457 | 483 | getBoardTree(); |
| 458 | 484 | |
| 459 | 485 | // Make sure given boards and categories exist. |
| 460 | - if (!isset($boards[$board_id]) || (isset($boardOptions['target_board']) && !isset($boards[$boardOptions['target_board']])) || (isset($boardOptions['target_category']) && !isset($cat_tree[$boardOptions['target_category']]))) |
|
| 461 | - fatal_lang_error('no_board'); |
|
| 486 | + if (!isset($boards[$board_id]) || (isset($boardOptions['target_board']) && !isset($boards[$boardOptions['target_board']])) || (isset($boardOptions['target_category']) && !isset($cat_tree[$boardOptions['target_category']]))) { |
|
| 487 | + fatal_lang_error('no_board'); |
|
| 488 | + } |
|
| 462 | 489 | |
| 463 | 490 | $id = $board_id; |
| 464 | 491 | call_integration_hook('integrate_pre_modify_board', array($id, &$boardOptions)); |
@@ -486,8 +513,9 @@ discard block |
||
| 486 | 513 | $child_level = 0; |
| 487 | 514 | $id_parent = 0; |
| 488 | 515 | $after = 0; |
| 489 | - foreach ($cat_tree[$id_cat]['children'] as $id_board => $dummy) |
|
| 490 | - $after = max($after, $boards[$id_board]['order']); |
|
| 516 | + foreach ($cat_tree[$id_cat]['children'] as $id_board => $dummy) { |
|
| 517 | + $after = max($after, $boards[$id_board]['order']); |
|
| 518 | + } |
|
| 491 | 519 | } |
| 492 | 520 | |
| 493 | 521 | // Make the board a child of a given board. |
@@ -498,17 +526,19 @@ discard block |
||
| 498 | 526 | $id_parent = $boardOptions['target_board']; |
| 499 | 527 | |
| 500 | 528 | // People can be creative, in many ways... |
| 501 | - if (isChildOf($id_parent, $board_id)) |
|
| 502 | - fatal_lang_error('mboards_parent_own_child_error', false); |
|
| 503 | - elseif ($id_parent == $board_id) |
|
| 504 | - fatal_lang_error('mboards_board_own_child_error', false); |
|
| 529 | + if (isChildOf($id_parent, $board_id)) { |
|
| 530 | + fatal_lang_error('mboards_parent_own_child_error', false); |
|
| 531 | + } elseif ($id_parent == $board_id) { |
|
| 532 | + fatal_lang_error('mboards_board_own_child_error', false); |
|
| 533 | + } |
|
| 505 | 534 | |
| 506 | 535 | $after = $boards[$boardOptions['target_board']]['order']; |
| 507 | 536 | |
| 508 | 537 | // Check if there are already children and (if so) get the max board order. |
| 509 | - if (!empty($boards[$id_parent]['tree']['children']) && empty($boardOptions['move_first_child'])) |
|
| 510 | - foreach ($boards[$id_parent]['tree']['children'] as $childBoard_id => $dummy) |
|
| 538 | + if (!empty($boards[$id_parent]['tree']['children']) && empty($boardOptions['move_first_child'])) { |
|
| 539 | + foreach ($boards[$id_parent]['tree']['children'] as $childBoard_id => $dummy) |
|
| 511 | 540 | $after = max($after, $boards[$childBoard_id]['order']); |
| 541 | + } |
|
| 512 | 542 | } |
| 513 | 543 | |
| 514 | 544 | // Place a board before or after another board, on the same child level. |
@@ -521,8 +551,9 @@ discard block |
||
| 521 | 551 | } |
| 522 | 552 | |
| 523 | 553 | // Oops...? |
| 524 | - else |
|
| 525 | - trigger_error('modifyBoard(): The move_to value \'' . $boardOptions['move_to'] . '\' is incorrect', E_USER_ERROR); |
|
| 554 | + else { |
|
| 555 | + trigger_error('modifyBoard(): The move_to value \'' . $boardOptions['move_to'] . '\' is incorrect', E_USER_ERROR); |
|
| 556 | + } |
|
| 526 | 557 | |
| 527 | 558 | // Get a list of children of this board. |
| 528 | 559 | $childList = array(); |
@@ -531,14 +562,16 @@ discard block |
||
| 531 | 562 | // See if there are changes that affect children. |
| 532 | 563 | $childUpdates = array(); |
| 533 | 564 | $levelDiff = $child_level - $boards[$board_id]['level']; |
| 534 | - if ($levelDiff != 0) |
|
| 535 | - $childUpdates[] = 'child_level = child_level ' . ($levelDiff > 0 ? '+ ' : '') . '{int:level_diff}'; |
|
| 536 | - if ($id_cat != $boards[$board_id]['category']) |
|
| 537 | - $childUpdates[] = 'id_cat = {int:category}'; |
|
| 565 | + if ($levelDiff != 0) { |
|
| 566 | + $childUpdates[] = 'child_level = child_level ' . ($levelDiff > 0 ? '+ ' : '') . '{int:level_diff}'; |
|
| 567 | + } |
|
| 568 | + if ($id_cat != $boards[$board_id]['category']) { |
|
| 569 | + $childUpdates[] = 'id_cat = {int:category}'; |
|
| 570 | + } |
|
| 538 | 571 | |
| 539 | 572 | // Fix the children of this board. |
| 540 | - if (!empty($childList) && !empty($childUpdates)) |
|
| 541 | - $smcFunc['db_query']('', ' |
|
| 573 | + if (!empty($childList) && !empty($childUpdates)) { |
|
| 574 | + $smcFunc['db_query']('', ' |
|
| 542 | 575 | UPDATE {db_prefix}boards |
| 543 | 576 | SET ' . implode(', |
| 544 | 577 | ', $childUpdates) . ' |
@@ -549,6 +582,7 @@ discard block |
||
| 549 | 582 | 'level_diff' => $levelDiff, |
| 550 | 583 | ) |
| 551 | 584 | ); |
| 585 | + } |
|
| 552 | 586 | |
| 553 | 587 | // Make some room for this spot. |
| 554 | 588 | $smcFunc['db_query']('', ' |
@@ -644,8 +678,8 @@ discard block |
||
| 644 | 678 | call_integration_hook('integrate_modify_board', array($id, &$boardUpdates, &$boardUpdateParameters)); |
| 645 | 679 | |
| 646 | 680 | // Do the updates (if any). |
| 647 | - if (!empty($boardUpdates)) |
|
| 648 | - $smcFunc['db_query']('', ' |
|
| 681 | + if (!empty($boardUpdates)) { |
|
| 682 | + $smcFunc['db_query']('', ' |
|
| 649 | 683 | UPDATE {db_prefix}boards |
| 650 | 684 | SET |
| 651 | 685 | ' . implode(', |
@@ -655,6 +689,7 @@ discard block |
||
| 655 | 689 | 'selected_board' => $board_id, |
| 656 | 690 | )) |
| 657 | 691 | ); |
| 692 | + } |
|
| 658 | 693 | |
| 659 | 694 | // Set moderators of this board. |
| 660 | 695 | if (isset($boardOptions['moderators']) || isset($boardOptions['moderator_string']) || isset($boardOptions['moderator_groups']) || isset($boardOptions['moderator_group_string'])) |
@@ -679,13 +714,15 @@ discard block |
||
| 679 | 714 | { |
| 680 | 715 | $moderators[$k] = trim($moderators[$k]); |
| 681 | 716 | |
| 682 | - if (strlen($moderators[$k]) == 0) |
|
| 683 | - unset($moderators[$k]); |
|
| 717 | + if (strlen($moderators[$k]) == 0) { |
|
| 718 | + unset($moderators[$k]); |
|
| 719 | + } |
|
| 684 | 720 | } |
| 685 | 721 | |
| 686 | 722 | // Find all the id_member's for the member_name's in the list. |
| 687 | - if (empty($boardOptions['moderators'])) |
|
| 688 | - $boardOptions['moderators'] = array(); |
|
| 723 | + if (empty($boardOptions['moderators'])) { |
|
| 724 | + $boardOptions['moderators'] = array(); |
|
| 725 | + } |
|
| 689 | 726 | if (!empty($moderators)) |
| 690 | 727 | { |
| 691 | 728 | $request = $smcFunc['db_query']('', ' |
@@ -698,8 +735,9 @@ discard block |
||
| 698 | 735 | 'limit' => count($moderators), |
| 699 | 736 | ) |
| 700 | 737 | ); |
| 701 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 702 | - $boardOptions['moderators'][] = $row['id_member']; |
|
| 738 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 739 | + $boardOptions['moderators'][] = $row['id_member']; |
|
| 740 | + } |
|
| 703 | 741 | $smcFunc['db_free_result']($request); |
| 704 | 742 | } |
| 705 | 743 | } |
@@ -708,8 +746,9 @@ discard block |
||
| 708 | 746 | if (!empty($boardOptions['moderators'])) |
| 709 | 747 | { |
| 710 | 748 | $inserts = array(); |
| 711 | - foreach ($boardOptions['moderators'] as $moderator) |
|
| 712 | - $inserts[] = array($board_id, $moderator); |
|
| 749 | + foreach ($boardOptions['moderators'] as $moderator) { |
|
| 750 | + $inserts[] = array($board_id, $moderator); |
|
| 751 | + } |
|
| 713 | 752 | |
| 714 | 753 | $smcFunc['db_insert']('insert', |
| 715 | 754 | '{db_prefix}moderators', |
@@ -739,14 +778,16 @@ discard block |
||
| 739 | 778 | { |
| 740 | 779 | $moderator_groups[$k] = trim($moderator_groups[$k]); |
| 741 | 780 | |
| 742 | - if (strlen($moderator_groups[$k]) == 0) |
|
| 743 | - unset($moderator_groups[$k]); |
|
| 781 | + if (strlen($moderator_groups[$k]) == 0) { |
|
| 782 | + unset($moderator_groups[$k]); |
|
| 783 | + } |
|
| 744 | 784 | } |
| 745 | 785 | |
| 746 | 786 | /* Find all the id_group's for all the group names in the list |
| 747 | 787 | But skip any invalid ones (invisible/post groups/Administrator/Moderator) */ |
| 748 | - if (empty($boardOptions['moderator_groups'])) |
|
| 749 | - $boardOptions['moderator_groups'] = array(); |
|
| 788 | + if (empty($boardOptions['moderator_groups'])) { |
|
| 789 | + $boardOptions['moderator_groups'] = array(); |
|
| 790 | + } |
|
| 750 | 791 | if (!empty($moderator_groups)) |
| 751 | 792 | { |
| 752 | 793 | $request = $smcFunc['db_query']('', ' |
@@ -777,8 +818,9 @@ discard block |
||
| 777 | 818 | if (!empty($boardOptions['moderator_groups'])) |
| 778 | 819 | { |
| 779 | 820 | $inserts = array(); |
| 780 | - foreach ($boardOptions['moderator_groups'] as $moderator_group) |
|
| 781 | - $inserts[] = array($board_id, $moderator_group); |
|
| 821 | + foreach ($boardOptions['moderator_groups'] as $moderator_group) { |
|
| 822 | + $inserts[] = array($board_id, $moderator_group); |
|
| 823 | + } |
|
| 782 | 824 | |
| 783 | 825 | $smcFunc['db_insert']('insert', |
| 784 | 826 | '{db_prefix}moderator_groups', |
@@ -792,14 +834,16 @@ discard block |
||
| 792 | 834 | updateSettings(array('settings_updated' => time())); |
| 793 | 835 | } |
| 794 | 836 | |
| 795 | - if (isset($boardOptions['move_to'])) |
|
| 796 | - reorderBoards(); |
|
| 837 | + if (isset($boardOptions['move_to'])) { |
|
| 838 | + reorderBoards(); |
|
| 839 | + } |
|
| 797 | 840 | |
| 798 | 841 | clean_cache('data'); |
| 799 | 842 | |
| 800 | - if (empty($boardOptions['dont_log'])) |
|
| 801 | - logAction('edit_board', array('board' => $board_id), 'admin'); |
|
| 802 | -} |
|
| 843 | + if (empty($boardOptions['dont_log'])) { |
|
| 844 | + logAction('edit_board', array('board' => $board_id), 'admin'); |
|
| 845 | + } |
|
| 846 | + } |
|
| 803 | 847 | |
| 804 | 848 | /** |
| 805 | 849 | * Create a new board and set its properties and position. |
@@ -815,11 +859,13 @@ discard block |
||
| 815 | 859 | global $boards, $smcFunc; |
| 816 | 860 | |
| 817 | 861 | // Trigger an error if one of the required values is not set. |
| 818 | - if (!isset($boardOptions['board_name']) || trim($boardOptions['board_name']) == '' || !isset($boardOptions['move_to']) || !isset($boardOptions['target_category'])) |
|
| 819 | - trigger_error('createBoard(): One or more of the required options is not set', E_USER_ERROR); |
|
| 862 | + if (!isset($boardOptions['board_name']) || trim($boardOptions['board_name']) == '' || !isset($boardOptions['move_to']) || !isset($boardOptions['target_category'])) { |
|
| 863 | + trigger_error('createBoard(): One or more of the required options is not set', E_USER_ERROR); |
|
| 864 | + } |
|
| 820 | 865 | |
| 821 | - if (in_array($boardOptions['move_to'], array('child', 'before', 'after')) && !isset($boardOptions['target_board'])) |
|
| 822 | - trigger_error('createBoard(): Target board is not set', E_USER_ERROR); |
|
| 866 | + if (in_array($boardOptions['move_to'], array('child', 'before', 'after')) && !isset($boardOptions['target_board'])) { |
|
| 867 | + trigger_error('createBoard(): Target board is not set', E_USER_ERROR); |
|
| 868 | + } |
|
| 823 | 869 | |
| 824 | 870 | // Set every optional value to its default value. |
| 825 | 871 | $boardOptions += array( |
@@ -853,8 +899,9 @@ discard block |
||
| 853 | 899 | ); |
| 854 | 900 | $board_id = $smcFunc['db_insert_id']('{db_prefix}boards', 'id_board'); |
| 855 | 901 | |
| 856 | - if (empty($board_id)) |
|
| 857 | - return 0; |
|
| 902 | + if (empty($board_id)) { |
|
| 903 | + return 0; |
|
| 904 | + } |
|
| 858 | 905 | |
| 859 | 906 | // Change the board according to the given specifications. |
| 860 | 907 | modifyBoard($board_id, $boardOptions); |
@@ -917,8 +964,9 @@ discard block |
||
| 917 | 964 | global $sourcedir, $boards, $smcFunc; |
| 918 | 965 | |
| 919 | 966 | // No boards to delete? Return! |
| 920 | - if (empty($boards_to_remove)) |
|
| 921 | - return; |
|
| 967 | + if (empty($boards_to_remove)) { |
|
| 968 | + return; |
|
| 969 | + } |
|
| 922 | 970 | |
| 923 | 971 | getBoardTree(); |
| 924 | 972 | |
@@ -929,12 +977,14 @@ discard block |
||
| 929 | 977 | { |
| 930 | 978 | // Get a list of the child boards that will also be removed. |
| 931 | 979 | $child_boards_to_remove = array(); |
| 932 | - foreach ($boards_to_remove as $board_to_remove) |
|
| 933 | - recursiveBoards($child_boards_to_remove, $boards[$board_to_remove]['tree']); |
|
| 980 | + foreach ($boards_to_remove as $board_to_remove) { |
|
| 981 | + recursiveBoards($child_boards_to_remove, $boards[$board_to_remove]['tree']); |
|
| 982 | + } |
|
| 934 | 983 | |
| 935 | 984 | // Merge the children with their parents. |
| 936 | - if (!empty($child_boards_to_remove)) |
|
| 937 | - $boards_to_remove = array_unique(array_merge($boards_to_remove, $child_boards_to_remove)); |
|
| 985 | + if (!empty($child_boards_to_remove)) { |
|
| 986 | + $boards_to_remove = array_unique(array_merge($boards_to_remove, $child_boards_to_remove)); |
|
| 987 | + } |
|
| 938 | 988 | } |
| 939 | 989 | // Move the children to a safe home. |
| 940 | 990 | else |
@@ -942,10 +992,11 @@ discard block |
||
| 942 | 992 | foreach ($boards_to_remove as $id_board) |
| 943 | 993 | { |
| 944 | 994 | // @todo Separate category? |
| 945 | - if ($moveChildrenTo === 0) |
|
| 946 | - fixChildren($id_board, 0, 0); |
|
| 947 | - else |
|
| 948 | - fixChildren($id_board, $boards[$moveChildrenTo]['level'] + 1, $moveChildrenTo); |
|
| 995 | + if ($moveChildrenTo === 0) { |
|
| 996 | + fixChildren($id_board, 0, 0); |
|
| 997 | + } else { |
|
| 998 | + fixChildren($id_board, $boards[$moveChildrenTo]['level'] + 1, $moveChildrenTo); |
|
| 999 | + } |
|
| 949 | 1000 | } |
| 950 | 1001 | } |
| 951 | 1002 | |
@@ -959,8 +1010,9 @@ discard block |
||
| 959 | 1010 | ) |
| 960 | 1011 | ); |
| 961 | 1012 | $topics = array(); |
| 962 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 963 | - $topics[] = $row['id_topic']; |
|
| 1013 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1014 | + $topics[] = $row['id_topic']; |
|
| 1015 | + } |
|
| 964 | 1016 | $smcFunc['db_free_result']($request); |
| 965 | 1017 | |
| 966 | 1018 | require_once($sourcedir . '/RemoveTopic.php'); |
@@ -1048,8 +1100,9 @@ discard block |
||
| 1048 | 1100 | clean_cache('data'); |
| 1049 | 1101 | |
| 1050 | 1102 | // Let's do some serious logging. |
| 1051 | - foreach ($boards_to_remove as $id_board) |
|
| 1052 | - logAction('delete_board', array('boardname' => $boards[$id_board]['name']), 'admin'); |
|
| 1103 | + foreach ($boards_to_remove as $id_board) { |
|
| 1104 | + logAction('delete_board', array('boardname' => $boards[$id_board]['name']), 'admin'); |
|
| 1105 | + } |
|
| 1053 | 1106 | |
| 1054 | 1107 | reorderBoards(); |
| 1055 | 1108 | } |
@@ -1068,8 +1121,8 @@ discard block |
||
| 1068 | 1121 | $board_order = 0; |
| 1069 | 1122 | foreach ($cat_tree as $catID => $dummy) |
| 1070 | 1123 | { |
| 1071 | - foreach ($boardList[$catID] as $boardID) |
|
| 1072 | - if ($boards[$boardID]['order'] != ++$board_order) |
|
| 1124 | + foreach ($boardList[$catID] as $boardID) { |
|
| 1125 | + if ($boards[$boardID]['order'] != ++$board_order) |
|
| 1073 | 1126 | $smcFunc['db_query']('', ' |
| 1074 | 1127 | UPDATE {db_prefix}boards |
| 1075 | 1128 | SET board_order = {int:new_order} |
@@ -1079,6 +1132,7 @@ discard block |
||
| 1079 | 1132 | 'selected_board' => $boardID, |
| 1080 | 1133 | ) |
| 1081 | 1134 | ); |
| 1135 | + } |
|
| 1082 | 1136 | } |
| 1083 | 1137 | |
| 1084 | 1138 | // Empty the board order cache |
@@ -1107,8 +1161,9 @@ discard block |
||
| 1107 | 1161 | ) |
| 1108 | 1162 | ); |
| 1109 | 1163 | $children = array(); |
| 1110 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
| 1111 | - $children[] = $row['id_board']; |
|
| 1164 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
| 1165 | + $children[] = $row['id_board']; |
|
| 1166 | + } |
|
| 1112 | 1167 | $smcFunc['db_free_result']($result); |
| 1113 | 1168 | |
| 1114 | 1169 | // ...and set it to a new parent and child_level. |
@@ -1124,9 +1179,10 @@ discard block |
||
| 1124 | 1179 | ); |
| 1125 | 1180 | |
| 1126 | 1181 | // Recursively fix the children of the children. |
| 1127 | - foreach ($children as $child) |
|
| 1128 | - fixChildren($child, $newLevel + 1, $child); |
|
| 1129 | -} |
|
| 1182 | + foreach ($children as $child) { |
|
| 1183 | + fixChildren($child, $newLevel + 1, $child); |
|
| 1184 | + } |
|
| 1185 | + } |
|
| 1130 | 1186 | |
| 1131 | 1187 | /** |
| 1132 | 1188 | * Tries to load up the entire board order and category very very quickly |
@@ -1143,8 +1199,9 @@ discard block |
||
| 1143 | 1199 | 'boards' => array(), |
| 1144 | 1200 | ); |
| 1145 | 1201 | |
| 1146 | - if (!empty($tree_order['boards'])) |
|
| 1147 | - return $tree_order; |
|
| 1202 | + if (!empty($tree_order['boards'])) { |
|
| 1203 | + return $tree_order; |
|
| 1204 | + } |
|
| 1148 | 1205 | |
| 1149 | 1206 | if (($cached = cache_get_data('board_order', 86400)) !== null) |
| 1150 | 1207 | { |
@@ -1160,8 +1217,9 @@ discard block |
||
| 1160 | 1217 | ); |
| 1161 | 1218 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1162 | 1219 | { |
| 1163 | - if (!in_array($row['id_cat'], $tree_order['cats'])) |
|
| 1164 | - $tree_order['cats'][] = $row['id_cat']; |
|
| 1220 | + if (!in_array($row['id_cat'], $tree_order['cats'])) { |
|
| 1221 | + $tree_order['cats'][] = $row['id_cat']; |
|
| 1222 | + } |
|
| 1165 | 1223 | $tree_order['boards'][] = $row['id_board']; |
| 1166 | 1224 | } |
| 1167 | 1225 | $smcFunc['db_free_result']($request); |
@@ -1181,16 +1239,19 @@ discard block |
||
| 1181 | 1239 | $tree = getTreeOrder(); |
| 1182 | 1240 | |
| 1183 | 1241 | $ordered = array(); |
| 1184 | - foreach ($tree['boards'] as $board) |
|
| 1185 | - if (!empty($boards[$board])) |
|
| 1242 | + foreach ($tree['boards'] as $board) { |
|
| 1243 | + if (!empty($boards[$board])) |
|
| 1186 | 1244 | { |
| 1187 | 1245 | $ordered[$board] = $boards[$board]; |
| 1246 | + } |
|
| 1188 | 1247 | |
| 1189 | - if (is_array($ordered[$board]) && !empty($ordered[$board]['boards'])) |
|
| 1190 | - sortBoards($ordered[$board]['boards']); |
|
| 1248 | + if (is_array($ordered[$board]) && !empty($ordered[$board]['boards'])) { |
|
| 1249 | + sortBoards($ordered[$board]['boards']); |
|
| 1250 | + } |
|
| 1191 | 1251 | |
| 1192 | - if (is_array($ordered[$board]) && !empty($ordered[$board]['children'])) |
|
| 1193 | - sortBoards($ordered[$board]['children']); |
|
| 1252 | + if (is_array($ordered[$board]) && !empty($ordered[$board]['children'])) { |
|
| 1253 | + sortBoards($ordered[$board]['children']); |
|
| 1254 | + } |
|
| 1194 | 1255 | } |
| 1195 | 1256 | |
| 1196 | 1257 | $boards = $ordered; |
@@ -1206,12 +1267,14 @@ discard block |
||
| 1206 | 1267 | $tree = getTreeOrder(); |
| 1207 | 1268 | |
| 1208 | 1269 | $ordered = array(); |
| 1209 | - foreach ($tree['cats'] as $cat) |
|
| 1210 | - if (!empty($categories[$cat])) |
|
| 1270 | + foreach ($tree['cats'] as $cat) { |
|
| 1271 | + if (!empty($categories[$cat])) |
|
| 1211 | 1272 | { |
| 1212 | 1273 | $ordered[$cat] = $categories[$cat]; |
| 1213 | - if (!empty($ordered[$cat]['boards'])) |
|
| 1214 | - sortBoards($ordered[$cat]['boards']); |
|
| 1274 | + } |
|
| 1275 | + if (!empty($ordered[$cat]['boards'])) { |
|
| 1276 | + sortBoards($ordered[$cat]['boards']); |
|
| 1277 | + } |
|
| 1215 | 1278 | } |
| 1216 | 1279 | |
| 1217 | 1280 | $categories = $ordered; |
@@ -1227,8 +1290,9 @@ discard block |
||
| 1227 | 1290 | { |
| 1228 | 1291 | global $smcFunc, $scripturl, $txt; |
| 1229 | 1292 | |
| 1230 | - if (empty($boards)) |
|
| 1231 | - return array(); |
|
| 1293 | + if (empty($boards)) { |
|
| 1294 | + return array(); |
|
| 1295 | + } |
|
| 1232 | 1296 | |
| 1233 | 1297 | $request = $smcFunc['db_query']('', ' |
| 1234 | 1298 | SELECT mem.id_member, mem.real_name, mo.id_board |
@@ -1242,8 +1306,9 @@ discard block |
||
| 1242 | 1306 | $moderators = array(); |
| 1243 | 1307 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1244 | 1308 | { |
| 1245 | - if (empty($moderators[$row['id_board']])) |
|
| 1246 | - $moderators[$row['id_board']] = array(); |
|
| 1309 | + if (empty($moderators[$row['id_board']])) { |
|
| 1310 | + $moderators[$row['id_board']] = array(); |
|
| 1311 | + } |
|
| 1247 | 1312 | |
| 1248 | 1313 | $moderators[$row['id_board']][] = array( |
| 1249 | 1314 | 'id' => $row['id_member'], |
@@ -1267,8 +1332,9 @@ discard block |
||
| 1267 | 1332 | { |
| 1268 | 1333 | global $smcFunc, $scripturl, $txt; |
| 1269 | 1334 | |
| 1270 | - if (empty($boards)) |
|
| 1271 | - return array(); |
|
| 1335 | + if (empty($boards)) { |
|
| 1336 | + return array(); |
|
| 1337 | + } |
|
| 1272 | 1338 | |
| 1273 | 1339 | $request = $smcFunc['db_query']('', ' |
| 1274 | 1340 | SELECT mg.id_group, mg.group_name, bg.id_board |
@@ -1282,8 +1348,9 @@ discard block |
||
| 1282 | 1348 | $groups = array(); |
| 1283 | 1349 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1284 | 1350 | { |
| 1285 | - if (empty($groups[$row['id_board']])) |
|
| 1286 | - $groups[$row['id_board']] = array(); |
|
| 1351 | + if (empty($groups[$row['id_board']])) { |
|
| 1352 | + $groups[$row['id_board']] = array(); |
|
| 1353 | + } |
|
| 1287 | 1354 | |
| 1288 | 1355 | $groups[$row['id_board']][] = array( |
| 1289 | 1356 | 'id' => $row['id_group'], |
@@ -1345,8 +1412,9 @@ discard block |
||
| 1345 | 1412 | |
| 1346 | 1413 | if (!empty($row['id_board'])) |
| 1347 | 1414 | { |
| 1348 | - if ($row['child_level'] != $curLevel) |
|
| 1349 | - $prevBoard = 0; |
|
| 1415 | + if ($row['child_level'] != $curLevel) { |
|
| 1416 | + $prevBoard = 0; |
|
| 1417 | + } |
|
| 1350 | 1418 | |
| 1351 | 1419 | $boards[$row['id_board']] = array( |
| 1352 | 1420 | 'id' => $row['id_board'], |
@@ -1378,16 +1446,16 @@ discard block |
||
| 1378 | 1446 | 'children' => array() |
| 1379 | 1447 | ); |
| 1380 | 1448 | $boards[$row['id_board']]['tree'] = &$cat_tree[$row['id_cat']]['children'][$row['id_board']]; |
| 1381 | - } |
|
| 1382 | - else |
|
| 1449 | + } else |
|
| 1383 | 1450 | { |
| 1384 | 1451 | // Parent doesn't exist! |
| 1385 | - if (!isset($boards[$row['id_parent']]['tree'])) |
|
| 1386 | - fatal_lang_error('no_valid_parent', false, array($row['board_name'])); |
|
| 1452 | + if (!isset($boards[$row['id_parent']]['tree'])) { |
|
| 1453 | + fatal_lang_error('no_valid_parent', false, array($row['board_name'])); |
|
| 1454 | + } |
|
| 1387 | 1455 | |
| 1388 | 1456 | // Wrong childlevel...we can silently fix this... |
| 1389 | - if ($boards[$row['id_parent']]['tree']['node']['level'] != $row['child_level'] - 1) |
|
| 1390 | - $smcFunc['db_query']('', ' |
|
| 1457 | + if ($boards[$row['id_parent']]['tree']['node']['level'] != $row['child_level'] - 1) { |
|
| 1458 | + $smcFunc['db_query']('', ' |
|
| 1391 | 1459 | UPDATE {db_prefix}boards |
| 1392 | 1460 | SET child_level = {int:new_child_level} |
| 1393 | 1461 | WHERE id_board = {int:selected_board}', |
@@ -1396,6 +1464,7 @@ discard block |
||
| 1396 | 1464 | 'selected_board' => $row['id_board'], |
| 1397 | 1465 | ) |
| 1398 | 1466 | ); |
| 1467 | + } |
|
| 1399 | 1468 | |
| 1400 | 1469 | $boards[$row['id_parent']]['tree']['children'][$row['id_board']] = array( |
| 1401 | 1470 | 'node' => &$boards[$row['id_board']], |
@@ -1426,8 +1495,9 @@ discard block |
||
| 1426 | 1495 | */ |
| 1427 | 1496 | function recursiveBoards(&$_boardList, &$_tree) |
| 1428 | 1497 | { |
| 1429 | - if (empty($_tree['children'])) |
|
| 1430 | - return; |
|
| 1498 | + if (empty($_tree['children'])) { |
|
| 1499 | + return; |
|
| 1500 | + } |
|
| 1431 | 1501 | |
| 1432 | 1502 | foreach ($_tree['children'] as $id => $node) |
| 1433 | 1503 | { |
@@ -1446,11 +1516,13 @@ discard block |
||
| 1446 | 1516 | { |
| 1447 | 1517 | global $boards; |
| 1448 | 1518 | |
| 1449 | - if (empty($boards[$child]['parent'])) |
|
| 1450 | - return false; |
|
| 1519 | + if (empty($boards[$child]['parent'])) { |
|
| 1520 | + return false; |
|
| 1521 | + } |
|
| 1451 | 1522 | |
| 1452 | - if ($boards[$child]['parent'] == $parent) |
|
| 1453 | - return true; |
|
| 1523 | + if ($boards[$child]['parent'] == $parent) { |
|
| 1524 | + return true; |
|
| 1525 | + } |
|
| 1454 | 1526 | |
| 1455 | 1527 | return isChildOf($boards[$child]['parent'], $parent); |
| 1456 | 1528 | } |
@@ -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 | * Load the $modSettings array. |
@@ -25,13 +26,14 @@ discard block |
||
| 25 | 26 | global $cache_enable, $sourcedir, $context; |
| 26 | 27 | |
| 27 | 28 | // Most database systems have not set UTF-8 as their default input charset. |
| 28 | - if (!empty($db_character_set)) |
|
| 29 | - $smcFunc['db_query']('', ' |
|
| 29 | + if (!empty($db_character_set)) { |
|
| 30 | + $smcFunc['db_query']('', ' |
|
| 30 | 31 | SET NAMES {string:db_character_set}', |
| 31 | 32 | array( |
| 32 | 33 | 'db_character_set' => $db_character_set, |
| 33 | 34 | ) |
| 34 | 35 | ); |
| 36 | + } |
|
| 35 | 37 | |
| 36 | 38 | // We need some caching support, maybe. |
| 37 | 39 | loadCacheAccelerator(); |
@@ -46,27 +48,35 @@ discard block |
||
| 46 | 48 | ) |
| 47 | 49 | ); |
| 48 | 50 | $modSettings = array(); |
| 49 | - if (!$request) |
|
| 50 | - display_db_error(); |
|
| 51 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
| 52 | - $modSettings[$row[0]] = $row[1]; |
|
| 51 | + if (!$request) { |
|
| 52 | + display_db_error(); |
|
| 53 | + } |
|
| 54 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
| 55 | + $modSettings[$row[0]] = $row[1]; |
|
| 56 | + } |
|
| 53 | 57 | $smcFunc['db_free_result']($request); |
| 54 | 58 | |
| 55 | 59 | // Do a few things to protect against missing settings or settings with invalid values... |
| 56 | - if (empty($modSettings['defaultMaxTopics']) || $modSettings['defaultMaxTopics'] <= 0 || $modSettings['defaultMaxTopics'] > 999) |
|
| 57 | - $modSettings['defaultMaxTopics'] = 20; |
|
| 58 | - if (empty($modSettings['defaultMaxMessages']) || $modSettings['defaultMaxMessages'] <= 0 || $modSettings['defaultMaxMessages'] > 999) |
|
| 59 | - $modSettings['defaultMaxMessages'] = 15; |
|
| 60 | - if (empty($modSettings['defaultMaxMembers']) || $modSettings['defaultMaxMembers'] <= 0 || $modSettings['defaultMaxMembers'] > 999) |
|
| 61 | - $modSettings['defaultMaxMembers'] = 30; |
|
| 62 | - if (empty($modSettings['defaultMaxListItems']) || $modSettings['defaultMaxListItems'] <= 0 || $modSettings['defaultMaxListItems'] > 999) |
|
| 63 | - $modSettings['defaultMaxListItems'] = 15; |
|
| 60 | + if (empty($modSettings['defaultMaxTopics']) || $modSettings['defaultMaxTopics'] <= 0 || $modSettings['defaultMaxTopics'] > 999) { |
|
| 61 | + $modSettings['defaultMaxTopics'] = 20; |
|
| 62 | + } |
|
| 63 | + if (empty($modSettings['defaultMaxMessages']) || $modSettings['defaultMaxMessages'] <= 0 || $modSettings['defaultMaxMessages'] > 999) { |
|
| 64 | + $modSettings['defaultMaxMessages'] = 15; |
|
| 65 | + } |
|
| 66 | + if (empty($modSettings['defaultMaxMembers']) || $modSettings['defaultMaxMembers'] <= 0 || $modSettings['defaultMaxMembers'] > 999) { |
|
| 67 | + $modSettings['defaultMaxMembers'] = 30; |
|
| 68 | + } |
|
| 69 | + if (empty($modSettings['defaultMaxListItems']) || $modSettings['defaultMaxListItems'] <= 0 || $modSettings['defaultMaxListItems'] > 999) { |
|
| 70 | + $modSettings['defaultMaxListItems'] = 15; |
|
| 71 | + } |
|
| 64 | 72 | |
| 65 | - if (!is_array($modSettings['attachmentUploadDir'])) |
|
| 66 | - $modSettings['attachmentUploadDir'] = smf_json_decode($modSettings['attachmentUploadDir'], true); |
|
| 73 | + if (!is_array($modSettings['attachmentUploadDir'])) { |
|
| 74 | + $modSettings['attachmentUploadDir'] = smf_json_decode($modSettings['attachmentUploadDir'], true); |
|
| 75 | + } |
|
| 67 | 76 | |
| 68 | - if (!empty($cache_enable)) |
|
| 69 | - cache_put_data('modSettings', $modSettings, 90); |
|
| 77 | + if (!empty($cache_enable)) { |
|
| 78 | + cache_put_data('modSettings', $modSettings, 90); |
|
| 79 | + } |
|
| 70 | 80 | } |
| 71 | 81 | |
| 72 | 82 | $modSettings['cache_enable'] = $cache_enable; |
@@ -86,8 +96,9 @@ discard block |
||
| 86 | 96 | }; |
| 87 | 97 | $fix_utf8mb4 = function($string) use ($utf8) |
| 88 | 98 | { |
| 89 | - if (!$utf8) |
|
| 90 | - return $string; |
|
| 99 | + if (!$utf8) { |
|
| 100 | + return $string; |
|
| 101 | + } |
|
| 91 | 102 | |
| 92 | 103 | $i = 0; |
| 93 | 104 | $len = strlen($string); |
@@ -99,18 +110,15 @@ discard block |
||
| 99 | 110 | { |
| 100 | 111 | $new_string .= $string[$i]; |
| 101 | 112 | $i++; |
| 102 | - } |
|
| 103 | - elseif ($ord < 224) |
|
| 113 | + } elseif ($ord < 224) |
|
| 104 | 114 | { |
| 105 | 115 | $new_string .= $string[$i] . $string[$i + 1]; |
| 106 | 116 | $i += 2; |
| 107 | - } |
|
| 108 | - elseif ($ord < 240) |
|
| 117 | + } elseif ($ord < 240) |
|
| 109 | 118 | { |
| 110 | 119 | $new_string .= $string[$i] . $string[$i + 1] . $string[$i + 2]; |
| 111 | 120 | $i += 3; |
| 112 | - } |
|
| 113 | - elseif ($ord < 248) |
|
| 121 | + } elseif ($ord < 248) |
|
| 114 | 122 | { |
| 115 | 123 | // Magic happens. |
| 116 | 124 | $val = (ord($string[$i]) & 0x07) << 18; |
@@ -154,8 +162,7 @@ discard block |
||
| 154 | 162 | { |
| 155 | 163 | $result = array_search($needle, array_slice($haystack_arr, $offset)); |
| 156 | 164 | return is_int($result) ? $result + $offset : false; |
| 157 | - } |
|
| 158 | - else |
|
| 165 | + } else |
|
| 159 | 166 | { |
| 160 | 167 | $needle_arr = preg_split('~(&#' . (empty($modSettings['disableEntityCheck']) ? '\d{1,7}' : '021') . ';|"|&|<|>| |.)~' . ($utf8 ? 'u' : '') . '', $ent_check($needle), -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); |
| 161 | 168 | $needle_size = count($needle_arr); |
@@ -164,8 +171,9 @@ discard block |
||
| 164 | 171 | while ((int) $result === $result) |
| 165 | 172 | { |
| 166 | 173 | $offset += $result; |
| 167 | - if (array_slice($haystack_arr, $offset, $needle_size) === $needle_arr) |
|
| 168 | - return $offset; |
|
| 174 | + if (array_slice($haystack_arr, $offset, $needle_size) === $needle_arr) { |
|
| 175 | + return $offset; |
|
| 176 | + } |
|
| 169 | 177 | $result = array_search($needle_arr[0], array_slice($haystack_arr, ++$offset)); |
| 170 | 178 | } |
| 171 | 179 | return false; |
@@ -203,8 +211,9 @@ discard block |
||
| 203 | 211 | $string = $ent_check($string); |
| 204 | 212 | preg_match('~^(' . $ent_list . '|.){' . $smcFunc['strlen'](substr($string, 0, $length)) . '}~' . ($utf8 ? 'u' : ''), $string, $matches); |
| 205 | 213 | $string = $matches[0]; |
| 206 | - while (strlen($string) > $length) |
|
| 207 | - $string = preg_replace('~(?:' . $ent_list . '|.)$~' . ($utf8 ? 'u' : ''), '', $string); |
|
| 214 | + while (strlen($string) > $length) { |
|
| 215 | + $string = preg_replace('~(?:' . $ent_list . '|.)$~' . ($utf8 ? 'u' : ''), '', $string); |
|
| 216 | + } |
|
| 208 | 217 | return $string; |
| 209 | 218 | }, |
| 210 | 219 | 'ucfirst' => $utf8 ? function($string) use (&$smcFunc) |
@@ -214,23 +223,25 @@ discard block |
||
| 214 | 223 | 'ucwords' => $utf8 ? function($string) use (&$smcFunc) |
| 215 | 224 | { |
| 216 | 225 | $words = preg_split('~([\s\r\n\t]+)~', $string, -1, PREG_SPLIT_DELIM_CAPTURE); |
| 217 | - for ($i = 0, $n = count($words); $i < $n; $i += 2) |
|
| 218 | - $words[$i] = $smcFunc['ucfirst']($words[$i]); |
|
| 226 | + for ($i = 0, $n = count($words); $i < $n; $i += 2) { |
|
| 227 | + $words[$i] = $smcFunc['ucfirst']($words[$i]); |
|
| 228 | + } |
|
| 219 | 229 | return implode('', $words); |
| 220 | 230 | } : 'ucwords', |
| 221 | 231 | ); |
| 222 | 232 | |
| 223 | 233 | // Setting the timezone is a requirement for some functions. |
| 224 | - if (isset($modSettings['default_timezone']) && in_array($modSettings['default_timezone'], timezone_identifiers_list())) |
|
| 225 | - date_default_timezone_set($modSettings['default_timezone']); |
|
| 226 | - else |
|
| 234 | + if (isset($modSettings['default_timezone']) && in_array($modSettings['default_timezone'], timezone_identifiers_list())) { |
|
| 235 | + date_default_timezone_set($modSettings['default_timezone']); |
|
| 236 | + } else |
|
| 227 | 237 | { |
| 228 | 238 | // Get PHP's default timezone, if set |
| 229 | 239 | $ini_tz = ini_get('date.timezone'); |
| 230 | - if (!empty($ini_tz)) |
|
| 231 | - $modSettings['default_timezone'] = $ini_tz; |
|
| 232 | - else |
|
| 233 | - $modSettings['default_timezone'] = ''; |
|
| 240 | + if (!empty($ini_tz)) { |
|
| 241 | + $modSettings['default_timezone'] = $ini_tz; |
|
| 242 | + } else { |
|
| 243 | + $modSettings['default_timezone'] = ''; |
|
| 244 | + } |
|
| 234 | 245 | |
| 235 | 246 | // If date.timezone is unset, invalid, or just plain weird, make a best guess |
| 236 | 247 | if (!in_array($modSettings['default_timezone'], timezone_identifiers_list())) |
@@ -248,22 +259,26 @@ discard block |
||
| 248 | 259 | if (($modSettings['load_average'] = cache_get_data('loadavg', 90)) == null) |
| 249 | 260 | { |
| 250 | 261 | $modSettings['load_average'] = @file_get_contents('/proc/loadavg'); |
| 251 | - if (!empty($modSettings['load_average']) && preg_match('~^([^ ]+?) ([^ ]+?) ([^ ]+)~', $modSettings['load_average'], $matches) != 0) |
|
| 252 | - $modSettings['load_average'] = (float) $matches[1]; |
|
| 253 | - elseif (($modSettings['load_average'] = @`uptime`) != null && preg_match('~load average[s]?: (\d+\.\d+), (\d+\.\d+), (\d+\.\d+)~i', $modSettings['load_average'], $matches) != 0) |
|
| 254 | - $modSettings['load_average'] = (float) $matches[1]; |
|
| 255 | - else |
|
| 256 | - unset($modSettings['load_average']); |
|
| 262 | + if (!empty($modSettings['load_average']) && preg_match('~^([^ ]+?) ([^ ]+?) ([^ ]+)~', $modSettings['load_average'], $matches) != 0) { |
|
| 263 | + $modSettings['load_average'] = (float) $matches[1]; |
|
| 264 | + } elseif (($modSettings['load_average'] = @`uptime`) != null && preg_match('~load average[s]?: (\d+\.\d+), (\d+\.\d+), (\d+\.\d+)~i', $modSettings['load_average'], $matches) != 0) { |
|
| 265 | + $modSettings['load_average'] = (float) $matches[1]; |
|
| 266 | + } else { |
|
| 267 | + unset($modSettings['load_average']); |
|
| 268 | + } |
|
| 257 | 269 | |
| 258 | - if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) |
|
| 259 | - cache_put_data('loadavg', $modSettings['load_average'], 90); |
|
| 270 | + if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) { |
|
| 271 | + cache_put_data('loadavg', $modSettings['load_average'], 90); |
|
| 272 | + } |
|
| 260 | 273 | } |
| 261 | 274 | |
| 262 | - if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) |
|
| 263 | - call_integration_hook('integrate_load_average', array($modSettings['load_average'])); |
|
| 275 | + if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) { |
|
| 276 | + call_integration_hook('integrate_load_average', array($modSettings['load_average'])); |
|
| 277 | + } |
|
| 264 | 278 | |
| 265 | - if (!empty($modSettings['loadavg_forum']) && !empty($modSettings['load_average']) && $modSettings['load_average'] >= $modSettings['loadavg_forum']) |
|
| 266 | - display_loadavg_error(); |
|
| 279 | + if (!empty($modSettings['loadavg_forum']) && !empty($modSettings['load_average']) && $modSettings['load_average'] >= $modSettings['loadavg_forum']) { |
|
| 280 | + display_loadavg_error(); |
|
| 281 | + } |
|
| 267 | 282 | } |
| 268 | 283 | |
| 269 | 284 | // Is post moderation alive and well? Everywhere else assumes this has been defined, so let's make sure it is. |
@@ -284,8 +299,9 @@ discard block |
||
| 284 | 299 | if (defined('SMF_INTEGRATION_SETTINGS')) |
| 285 | 300 | { |
| 286 | 301 | $integration_settings = smf_json_decode(SMF_INTEGRATION_SETTINGS, true); |
| 287 | - foreach ($integration_settings as $hook => $function) |
|
| 288 | - add_integration_function($hook, $function, '', false); |
|
| 302 | + foreach ($integration_settings as $hook => $function) { |
|
| 303 | + add_integration_function($hook, $function, '', false); |
|
| 304 | + } |
|
| 289 | 305 | } |
| 290 | 306 | |
| 291 | 307 | // Any files to pre include? |
@@ -295,8 +311,9 @@ discard block |
||
| 295 | 311 | foreach ($pre_includes as $include) |
| 296 | 312 | { |
| 297 | 313 | $include = strtr(trim($include), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir)); |
| 298 | - if (file_exists($include)) |
|
| 299 | - require_once($include); |
|
| 314 | + if (file_exists($include)) { |
|
| 315 | + require_once($include); |
|
| 316 | + } |
|
| 300 | 317 | } |
| 301 | 318 | } |
| 302 | 319 | |
@@ -400,27 +417,28 @@ discard block |
||
| 400 | 417 | break; |
| 401 | 418 | } |
| 402 | 419 | } |
| 420 | + } else { |
|
| 421 | + $id_member = 0; |
|
| 403 | 422 | } |
| 404 | - else |
|
| 405 | - $id_member = 0; |
|
| 406 | 423 | |
| 407 | 424 | if (empty($id_member) && isset($_COOKIE[$cookiename])) |
| 408 | 425 | { |
| 409 | 426 | $cookie_data = smf_json_decode($_COOKIE[$cookiename], true, false); |
| 410 | 427 | |
| 411 | - if (empty($cookie_data)) |
|
| 412 | - $cookie_data = safe_unserialize($_COOKIE[$cookiename]); |
|
| 428 | + if (empty($cookie_data)) { |
|
| 429 | + $cookie_data = safe_unserialize($_COOKIE[$cookiename]); |
|
| 430 | + } |
|
| 413 | 431 | |
| 414 | 432 | list ($id_member, $password) = $cookie_data; |
| 415 | 433 | $id_member = !empty($id_member) && strlen($password) > 0 ? (int) $id_member : 0; |
| 416 | - } |
|
| 417 | - elseif (empty($id_member) && isset($_SESSION['login_' . $cookiename]) && ($_SESSION['USER_AGENT'] == $_SERVER['HTTP_USER_AGENT'] || !empty($modSettings['disableCheckUA']))) |
|
| 434 | + } elseif (empty($id_member) && isset($_SESSION['login_' . $cookiename]) && ($_SESSION['USER_AGENT'] == $_SERVER['HTTP_USER_AGENT'] || !empty($modSettings['disableCheckUA']))) |
|
| 418 | 435 | { |
| 419 | 436 | // @todo Perhaps we can do some more checking on this, such as on the first octet of the IP? |
| 420 | 437 | $cookie_data = smf_json_decode($_SESSION['login_' . $cookiename]); |
| 421 | 438 | |
| 422 | - if (empty($cookie_data)) |
|
| 423 | - $cookie_data = safe_unserialize($_SESSION['login_' . $cookiename]); |
|
| 439 | + if (empty($cookie_data)) { |
|
| 440 | + $cookie_data = safe_unserialize($_SESSION['login_' . $cookiename]); |
|
| 441 | + } |
|
| 424 | 442 | |
| 425 | 443 | list ($id_member, $password, $login_span) = $cookie_data; |
| 426 | 444 | $id_member = !empty($id_member) && strlen($password) == 128 && $login_span > time() ? (int) $id_member : 0; |
@@ -445,30 +463,34 @@ discard block |
||
| 445 | 463 | $user_settings = $smcFunc['db_fetch_assoc']($request); |
| 446 | 464 | $smcFunc['db_free_result']($request); |
| 447 | 465 | |
| 448 | - if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($user_settings['avatar'], 'http://') !== false) |
|
| 449 | - $user_settings['avatar'] = strtr($boardurl, array('http://' => 'https://')) . '/proxy.php?request=' . urlencode($user_settings['avatar']) . '&hash=' . md5($user_settings['avatar'] . $image_proxy_secret); |
|
| 466 | + if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($user_settings['avatar'], 'http://') !== false) { |
|
| 467 | + $user_settings['avatar'] = strtr($boardurl, array('http://' => 'https://')) . '/proxy.php?request=' . urlencode($user_settings['avatar']) . '&hash=' . md5($user_settings['avatar'] . $image_proxy_secret); |
|
| 468 | + } |
|
| 450 | 469 | |
| 451 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
| 452 | - cache_put_data('user_settings-' . $id_member, $user_settings, 60); |
|
| 470 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
| 471 | + cache_put_data('user_settings-' . $id_member, $user_settings, 60); |
|
| 472 | + } |
|
| 453 | 473 | } |
| 454 | 474 | |
| 455 | 475 | // Did we find 'im? If not, junk it. |
| 456 | 476 | if (!empty($user_settings)) |
| 457 | 477 | { |
| 458 | 478 | // As much as the password should be right, we can assume the integration set things up. |
| 459 | - if (!empty($already_verified) && $already_verified === true) |
|
| 460 | - $check = true; |
|
| 479 | + if (!empty($already_verified) && $already_verified === true) { |
|
| 480 | + $check = true; |
|
| 481 | + } |
|
| 461 | 482 | // SHA-512 hash should be 128 characters long. |
| 462 | - elseif (strlen($password) == 128) |
|
| 463 | - $check = hash_salt($user_settings['passwd'], $user_settings['password_salt']) == $password; |
|
| 464 | - else |
|
| 465 | - $check = false; |
|
| 483 | + elseif (strlen($password) == 128) { |
|
| 484 | + $check = hash_salt($user_settings['passwd'], $user_settings['password_salt']) == $password; |
|
| 485 | + } else { |
|
| 486 | + $check = false; |
|
| 487 | + } |
|
| 466 | 488 | |
| 467 | 489 | // Wrong password or not activated - either way, you're going nowhere. |
| 468 | 490 | $id_member = $check && ($user_settings['is_activated'] == 1 || $user_settings['is_activated'] == 11) ? (int) $user_settings['id_member'] : 0; |
| 491 | + } else { |
|
| 492 | + $id_member = 0; |
|
| 469 | 493 | } |
| 470 | - else |
|
| 471 | - $id_member = 0; |
|
| 472 | 494 | |
| 473 | 495 | // If we no longer have the member maybe they're being all hackey, stop brute force! |
| 474 | 496 | if (!$id_member) |
@@ -490,13 +512,15 @@ discard block |
||
| 490 | 512 | { |
| 491 | 513 | $tfa_data = smf_json_decode($_COOKIE[$tfacookie]); |
| 492 | 514 | |
| 493 | - if (is_null($tfa_data)) |
|
| 494 | - $tfa_data = safe_unserialize($_COOKIE[$tfacookie]); |
|
| 515 | + if (is_null($tfa_data)) { |
|
| 516 | + $tfa_data = safe_unserialize($_COOKIE[$tfacookie]); |
|
| 517 | + } |
|
| 495 | 518 | |
| 496 | 519 | list ($tfamember, $tfasecret) = $tfa_data; |
| 497 | 520 | |
| 498 | - if ((int) $tfamember != $id_member) |
|
| 499 | - $tfasecret = null; |
|
| 521 | + if ((int) $tfamember != $id_member) { |
|
| 522 | + $tfasecret = null; |
|
| 523 | + } |
|
| 500 | 524 | } |
| 501 | 525 | |
| 502 | 526 | if (empty($tfasecret) || hash_salt($user_settings['tfa_backup'], $user_settings['password_salt']) != $tfasecret) |
@@ -516,10 +540,12 @@ discard block |
||
| 516 | 540 | // Are we forcing 2FA? Need to check if the user groups actually require 2FA |
| 517 | 541 | elseif (!empty($modSettings['tfa_mode']) && $modSettings['tfa_mode'] >= 2 && $id_member && empty($user_settings['tfa_secret'])) |
| 518 | 542 | { |
| 519 | - if ($modSettings['tfa_mode'] == 2) //only do this if we are just forcing SOME membergroups |
|
| 543 | + if ($modSettings['tfa_mode'] == 2) { |
|
| 544 | + //only do this if we are just forcing SOME membergroups |
|
| 520 | 545 | { |
| 521 | 546 | //Build an array of ALL user membergroups. |
| 522 | 547 | $full_groups = array($user_settings['id_group']); |
| 548 | + } |
|
| 523 | 549 | if (!empty($user_settings['additional_groups'])) |
| 524 | 550 | { |
| 525 | 551 | $full_groups = array_merge($full_groups, explode(',', $user_settings['additional_groups'])); |
@@ -539,15 +565,17 @@ discard block |
||
| 539 | 565 | ); |
| 540 | 566 | $row = $smcFunc['db_fetch_assoc']($request); |
| 541 | 567 | $smcFunc['db_free_result']($request); |
| 568 | + } else { |
|
| 569 | + $row['total'] = 1; |
|
| 542 | 570 | } |
| 543 | - else |
|
| 544 | - $row['total'] = 1; //simplifies logics in the next "if" |
|
| 571 | + //simplifies logics in the next "if" |
|
| 545 | 572 | |
| 546 | 573 | $area = !empty($_REQUEST['area']) ? $_REQUEST['area'] : ''; |
| 547 | 574 | $action = !empty($_REQUEST['action']) ? $_REQUEST['action'] : ''; |
| 548 | 575 | |
| 549 | - if ($row['total'] > 0 && !in_array($action, array('profile', 'logout')) || ($action == 'profile' && $area != 'tfasetup')) |
|
| 550 | - redirectexit('action=profile;area=tfasetup;forced'); |
|
| 576 | + if ($row['total'] > 0 && !in_array($action, array('profile', 'logout')) || ($action == 'profile' && $area != 'tfasetup')) { |
|
| 577 | + redirectexit('action=profile;area=tfasetup;forced'); |
|
| 578 | + } |
|
| 551 | 579 | } |
| 552 | 580 | } |
| 553 | 581 | |
@@ -584,33 +612,37 @@ discard block |
||
| 584 | 612 | updateMemberData($id_member, array('id_msg_last_visit' => (int) $modSettings['maxMsgID'], 'last_login' => time(), 'member_ip' => $_SERVER['REMOTE_ADDR'], 'member_ip2' => $_SERVER['BAN_CHECK_IP'])); |
| 585 | 613 | $user_settings['last_login'] = time(); |
| 586 | 614 | |
| 587 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
| 588 | - cache_put_data('user_settings-' . $id_member, $user_settings, 60); |
|
| 615 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
| 616 | + cache_put_data('user_settings-' . $id_member, $user_settings, 60); |
|
| 617 | + } |
|
| 589 | 618 | |
| 590 | - if (!empty($modSettings['cache_enable'])) |
|
| 591 | - cache_put_data('user_last_visit-' . $id_member, $_SESSION['id_msg_last_visit'], 5 * 3600); |
|
| 619 | + if (!empty($modSettings['cache_enable'])) { |
|
| 620 | + cache_put_data('user_last_visit-' . $id_member, $_SESSION['id_msg_last_visit'], 5 * 3600); |
|
| 621 | + } |
|
| 592 | 622 | } |
| 623 | + } elseif (empty($_SESSION['id_msg_last_visit'])) { |
|
| 624 | + $_SESSION['id_msg_last_visit'] = $user_settings['id_msg_last_visit']; |
|
| 593 | 625 | } |
| 594 | - elseif (empty($_SESSION['id_msg_last_visit'])) |
|
| 595 | - $_SESSION['id_msg_last_visit'] = $user_settings['id_msg_last_visit']; |
|
| 596 | 626 | |
| 597 | 627 | $username = $user_settings['member_name']; |
| 598 | 628 | |
| 599 | - if (empty($user_settings['additional_groups'])) |
|
| 600 | - $user_info = array( |
|
| 629 | + if (empty($user_settings['additional_groups'])) { |
|
| 630 | + $user_info = array( |
|
| 601 | 631 | 'groups' => array($user_settings['id_group'], $user_settings['id_post_group']) |
| 602 | 632 | ); |
| 603 | - else |
|
| 604 | - $user_info = array( |
|
| 633 | + } else { |
|
| 634 | + $user_info = array( |
|
| 605 | 635 | 'groups' => array_merge( |
| 606 | 636 | array($user_settings['id_group'], $user_settings['id_post_group']), |
| 607 | 637 | explode(',', $user_settings['additional_groups']) |
| 608 | 638 | ) |
| 609 | 639 | ); |
| 640 | + } |
|
| 610 | 641 | |
| 611 | 642 | // Because history has proven that it is possible for groups to go bad - clean up in case. |
| 612 | - foreach ($user_info['groups'] as $k => $v) |
|
| 613 | - $user_info['groups'][$k] = (int) $v; |
|
| 643 | + foreach ($user_info['groups'] as $k => $v) { |
|
| 644 | + $user_info['groups'][$k] = (int) $v; |
|
| 645 | + } |
|
| 614 | 646 | |
| 615 | 647 | // This is a logged in user, so definitely not a spider. |
| 616 | 648 | $user_info['possibly_robot'] = false; |
@@ -624,8 +656,7 @@ discard block |
||
| 624 | 656 | $time_system = new DateTime('now', $tz_system); |
| 625 | 657 | $time_user = new DateTime('now', $tz_user); |
| 626 | 658 | $user_info['time_offset'] = ($tz_user->getOffset($time_user) - $tz_system->getOffset($time_system)) / 3600; |
| 627 | - } |
|
| 628 | - else |
|
| 659 | + } else |
|
| 629 | 660 | { |
| 630 | 661 | // !!! Compatibility. |
| 631 | 662 | $user_info['time_offset'] = empty($user_settings['time_offset']) ? 0 : $user_settings['time_offset']; |
@@ -639,16 +670,18 @@ discard block |
||
| 639 | 670 | $user_info = array('groups' => array(-1)); |
| 640 | 671 | $user_settings = array(); |
| 641 | 672 | |
| 642 | - if (isset($_COOKIE[$cookiename]) && empty($context['tfa_member'])) |
|
| 643 | - $_COOKIE[$cookiename] = ''; |
|
| 673 | + if (isset($_COOKIE[$cookiename]) && empty($context['tfa_member'])) { |
|
| 674 | + $_COOKIE[$cookiename] = ''; |
|
| 675 | + } |
|
| 644 | 676 | |
| 645 | 677 | // Expire the 2FA cookie |
| 646 | 678 | if (isset($_COOKIE[$cookiename . '_tfa']) && empty($context['tfa_member'])) |
| 647 | 679 | { |
| 648 | 680 | $tfa_data = smf_json_decode($_COOKIE[$cookiename . '_tfa'], true); |
| 649 | 681 | |
| 650 | - if (is_null($tfa_data)) |
|
| 651 | - $tfa_data = safe_unserialize($_COOKIE[$cookiename . '_tfa']); |
|
| 682 | + if (is_null($tfa_data)) { |
|
| 683 | + $tfa_data = safe_unserialize($_COOKIE[$cookiename . '_tfa']); |
|
| 684 | + } |
|
| 652 | 685 | |
| 653 | 686 | list ($id, $user, $exp, $state, $preserve) = $tfa_data; |
| 654 | 687 | |
@@ -660,19 +693,20 @@ discard block |
||
| 660 | 693 | } |
| 661 | 694 | |
| 662 | 695 | // Create a login token if it doesn't exist yet. |
| 663 | - if (!isset($_SESSION['token']['post-login'])) |
|
| 664 | - createToken('login'); |
|
| 665 | - else |
|
| 666 | - list ($context['login_token_var'],,, $context['login_token']) = $_SESSION['token']['post-login']; |
|
| 696 | + if (!isset($_SESSION['token']['post-login'])) { |
|
| 697 | + createToken('login'); |
|
| 698 | + } else { |
|
| 699 | + list ($context['login_token_var'],,, $context['login_token']) = $_SESSION['token']['post-login']; |
|
| 700 | + } |
|
| 667 | 701 | |
| 668 | 702 | // Do we perhaps think this is a search robot? Check every five minutes just in case... |
| 669 | 703 | if ((!empty($modSettings['spider_mode']) || !empty($modSettings['spider_group'])) && (!isset($_SESSION['robot_check']) || $_SESSION['robot_check'] < time() - 300)) |
| 670 | 704 | { |
| 671 | 705 | require_once($sourcedir . '/ManageSearchEngines.php'); |
| 672 | 706 | $user_info['possibly_robot'] = SpiderCheck(); |
| 707 | + } elseif (!empty($modSettings['spider_mode'])) { |
|
| 708 | + $user_info['possibly_robot'] = isset($_SESSION['id_robot']) ? $_SESSION['id_robot'] : 0; |
|
| 673 | 709 | } |
| 674 | - elseif (!empty($modSettings['spider_mode'])) |
|
| 675 | - $user_info['possibly_robot'] = isset($_SESSION['id_robot']) ? $_SESSION['id_robot'] : 0; |
|
| 676 | 710 | // If we haven't turned on proper spider hunts then have a guess! |
| 677 | 711 | else |
| 678 | 712 | { |
@@ -720,8 +754,9 @@ discard block |
||
| 720 | 754 | $user_info['groups'] = array_unique($user_info['groups']); |
| 721 | 755 | |
| 722 | 756 | // Make sure that the last item in the ignore boards array is valid. If the list was too long it could have an ending comma that could cause problems. |
| 723 | - if (!empty($user_info['ignoreboards']) && empty($user_info['ignoreboards'][$tmp = count($user_info['ignoreboards']) - 1])) |
|
| 724 | - unset($user_info['ignoreboards'][$tmp]); |
|
| 757 | + if (!empty($user_info['ignoreboards']) && empty($user_info['ignoreboards'][$tmp = count($user_info['ignoreboards']) - 1])) { |
|
| 758 | + unset($user_info['ignoreboards'][$tmp]); |
|
| 759 | + } |
|
| 725 | 760 | |
| 726 | 761 | // Allow the user to change their language. |
| 727 | 762 | if (!empty($modSettings['userLanguage'])) |
@@ -734,31 +769,36 @@ discard block |
||
| 734 | 769 | $user_info['language'] = strtr($_GET['language'], './\\:', '____'); |
| 735 | 770 | |
| 736 | 771 | // Make it permanent for members. |
| 737 | - if (!empty($user_info['id'])) |
|
| 738 | - updateMemberData($user_info['id'], array('lngfile' => $user_info['language'])); |
|
| 739 | - else |
|
| 740 | - $_SESSION['language'] = $user_info['language']; |
|
| 772 | + if (!empty($user_info['id'])) { |
|
| 773 | + updateMemberData($user_info['id'], array('lngfile' => $user_info['language'])); |
|
| 774 | + } else { |
|
| 775 | + $_SESSION['language'] = $user_info['language']; |
|
| 776 | + } |
|
| 777 | + } elseif (!empty($_SESSION['language']) && isset($languages[strtr($_SESSION['language'], './\\:', '____')])) { |
|
| 778 | + $user_info['language'] = strtr($_SESSION['language'], './\\:', '____'); |
|
| 741 | 779 | } |
| 742 | - elseif (!empty($_SESSION['language']) && isset($languages[strtr($_SESSION['language'], './\\:', '____')])) |
|
| 743 | - $user_info['language'] = strtr($_SESSION['language'], './\\:', '____'); |
|
| 744 | 780 | } |
| 745 | 781 | |
| 746 | 782 | // Just build this here, it makes it easier to change/use - administrators can see all boards. |
| 747 | - if ($user_info['is_admin']) |
|
| 748 | - $user_info['query_see_board'] = '1=1'; |
|
| 783 | + if ($user_info['is_admin']) { |
|
| 784 | + $user_info['query_see_board'] = '1=1'; |
|
| 785 | + } |
|
| 749 | 786 | // Otherwise just the groups in $user_info['groups']. |
| 750 | - else |
|
| 751 | - $user_info['query_see_board'] = '((FIND_IN_SET(' . implode(', b.member_groups) != 0 OR FIND_IN_SET(', $user_info['groups']) . ', b.member_groups) != 0)' . (!empty($modSettings['deny_boards_access']) ? ' AND (FIND_IN_SET(' . implode(', b.deny_member_groups) = 0 AND FIND_IN_SET(', $user_info['groups']) . ', b.deny_member_groups) = 0)' : '') . (isset($user_info['mod_cache']) ? ' OR ' . $user_info['mod_cache']['mq'] : '') . ')'; |
|
| 787 | + else { |
|
| 788 | + $user_info['query_see_board'] = '((FIND_IN_SET(' . implode(', b.member_groups) != 0 OR FIND_IN_SET(', $user_info['groups']) . ', b.member_groups) != 0)' . (!empty($modSettings['deny_boards_access']) ? ' AND (FIND_IN_SET(' . implode(', b.deny_member_groups) = 0 AND FIND_IN_SET(', $user_info['groups']) . ', b.deny_member_groups) = 0)' : '') . (isset($user_info['mod_cache']) ? ' OR ' . $user_info['mod_cache']['mq'] : '') . ')'; |
|
| 789 | + } |
|
| 752 | 790 | |
| 753 | 791 | // Build the list of boards they WANT to see. |
| 754 | 792 | // This will take the place of query_see_boards in certain spots, so it better include the boards they can see also |
| 755 | 793 | |
| 756 | 794 | // If they aren't ignoring any boards then they want to see all the boards they can see |
| 757 | - if (empty($user_info['ignoreboards'])) |
|
| 758 | - $user_info['query_wanna_see_board'] = $user_info['query_see_board']; |
|
| 795 | + if (empty($user_info['ignoreboards'])) { |
|
| 796 | + $user_info['query_wanna_see_board'] = $user_info['query_see_board']; |
|
| 797 | + } |
|
| 759 | 798 | // Ok I guess they don't want to see all the boards |
| 760 | - else |
|
| 761 | - $user_info['query_wanna_see_board'] = '(' . $user_info['query_see_board'] . ' AND b.id_board NOT IN (' . implode(',', $user_info['ignoreboards']) . '))'; |
|
| 799 | + else { |
|
| 800 | + $user_info['query_wanna_see_board'] = '(' . $user_info['query_see_board'] . ' AND b.id_board NOT IN (' . implode(',', $user_info['ignoreboards']) . '))'; |
|
| 801 | + } |
|
| 762 | 802 | |
| 763 | 803 | call_integration_hook('integrate_user_info'); |
| 764 | 804 | } |
@@ -816,9 +856,9 @@ discard block |
||
| 816 | 856 | } |
| 817 | 857 | |
| 818 | 858 | // Remember redirection is the key to avoiding fallout from your bosses. |
| 819 | - if (!empty($topic)) |
|
| 820 | - redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg']); |
|
| 821 | - else |
|
| 859 | + if (!empty($topic)) { |
|
| 860 | + redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg']); |
|
| 861 | + } else |
|
| 822 | 862 | { |
| 823 | 863 | loadPermissions(); |
| 824 | 864 | loadTheme(); |
@@ -836,10 +876,11 @@ discard block |
||
| 836 | 876 | if (!empty($modSettings['cache_enable']) && (empty($topic) || $modSettings['cache_enable'] >= 3)) |
| 837 | 877 | { |
| 838 | 878 | // @todo SLOW? |
| 839 | - if (!empty($topic)) |
|
| 840 | - $temp = cache_get_data('topic_board-' . $topic, 120); |
|
| 841 | - else |
|
| 842 | - $temp = cache_get_data('board-' . $board, 120); |
|
| 879 | + if (!empty($topic)) { |
|
| 880 | + $temp = cache_get_data('topic_board-' . $topic, 120); |
|
| 881 | + } else { |
|
| 882 | + $temp = cache_get_data('board-' . $board, 120); |
|
| 883 | + } |
|
| 843 | 884 | |
| 844 | 885 | if (!empty($temp)) |
| 845 | 886 | { |
@@ -877,8 +918,9 @@ discard block |
||
| 877 | 918 | $row = $smcFunc['db_fetch_assoc']($request); |
| 878 | 919 | |
| 879 | 920 | // Set the current board. |
| 880 | - if (!empty($row['id_board'])) |
|
| 881 | - $board = $row['id_board']; |
|
| 921 | + if (!empty($row['id_board'])) { |
|
| 922 | + $board = $row['id_board']; |
|
| 923 | + } |
|
| 882 | 924 | |
| 883 | 925 | // Basic operating information. (globals... :/) |
| 884 | 926 | $board_info = array( |
@@ -914,21 +956,23 @@ discard block |
||
| 914 | 956 | |
| 915 | 957 | do |
| 916 | 958 | { |
| 917 | - if (!empty($row['id_moderator'])) |
|
| 918 | - $board_info['moderators'][$row['id_moderator']] = array( |
|
| 959 | + if (!empty($row['id_moderator'])) { |
|
| 960 | + $board_info['moderators'][$row['id_moderator']] = array( |
|
| 919 | 961 | 'id' => $row['id_moderator'], |
| 920 | 962 | 'name' => $row['real_name'], |
| 921 | 963 | 'href' => $scripturl . '?action=profile;u=' . $row['id_moderator'], |
| 922 | 964 | 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_moderator'] . '">' . $row['real_name'] . '</a>' |
| 923 | 965 | ); |
| 966 | + } |
|
| 924 | 967 | |
| 925 | - if (!empty($row['id_moderator_group'])) |
|
| 926 | - $board_info['moderator_groups'][$row['id_moderator_group']] = array( |
|
| 968 | + if (!empty($row['id_moderator_group'])) { |
|
| 969 | + $board_info['moderator_groups'][$row['id_moderator_group']] = array( |
|
| 927 | 970 | 'id' => $row['id_moderator_group'], |
| 928 | 971 | 'name' => $row['group_name'], |
| 929 | 972 | 'href' => $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'], |
| 930 | 973 | 'link' => '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'] . '">' . $row['group_name'] . '</a>' |
| 931 | 974 | ); |
| 975 | + } |
|
| 932 | 976 | } |
| 933 | 977 | while ($row = $smcFunc['db_fetch_assoc']($request)); |
| 934 | 978 | |
@@ -960,12 +1004,12 @@ discard block |
||
| 960 | 1004 | if (!empty($modSettings['cache_enable']) && (empty($topic) || $modSettings['cache_enable'] >= 3)) |
| 961 | 1005 | { |
| 962 | 1006 | // @todo SLOW? |
| 963 | - if (!empty($topic)) |
|
| 964 | - cache_put_data('topic_board-' . $topic, $board_info, 120); |
|
| 1007 | + if (!empty($topic)) { |
|
| 1008 | + cache_put_data('topic_board-' . $topic, $board_info, 120); |
|
| 1009 | + } |
|
| 965 | 1010 | cache_put_data('board-' . $board, $board_info, 120); |
| 966 | 1011 | } |
| 967 | - } |
|
| 968 | - else |
|
| 1012 | + } else |
|
| 969 | 1013 | { |
| 970 | 1014 | // Otherwise the topic is invalid, there are no moderators, etc. |
| 971 | 1015 | $board_info = array( |
@@ -979,8 +1023,9 @@ discard block |
||
| 979 | 1023 | $smcFunc['db_free_result']($request); |
| 980 | 1024 | } |
| 981 | 1025 | |
| 982 | - if (!empty($topic)) |
|
| 983 | - $_GET['board'] = (int) $board; |
|
| 1026 | + if (!empty($topic)) { |
|
| 1027 | + $_GET['board'] = (int) $board; |
|
| 1028 | + } |
|
| 984 | 1029 | |
| 985 | 1030 | if (!empty($board)) |
| 986 | 1031 | { |
@@ -990,10 +1035,12 @@ discard block |
||
| 990 | 1035 | // Now check if the user is a moderator. |
| 991 | 1036 | $user_info['is_mod'] = isset($board_info['moderators'][$user_info['id']]) || count(array_intersect($user_info['groups'], $moderator_groups)) != 0; |
| 992 | 1037 | |
| 993 | - if (count(array_intersect($user_info['groups'], $board_info['groups'])) == 0 && !$user_info['is_admin']) |
|
| 994 | - $board_info['error'] = 'access'; |
|
| 995 | - if (!empty($modSettings['deny_boards_access']) && count(array_intersect($user_info['groups'], $board_info['deny_groups'])) != 0 && !$user_info['is_admin']) |
|
| 996 | - $board_info['error'] = 'access'; |
|
| 1038 | + if (count(array_intersect($user_info['groups'], $board_info['groups'])) == 0 && !$user_info['is_admin']) { |
|
| 1039 | + $board_info['error'] = 'access'; |
|
| 1040 | + } |
|
| 1041 | + if (!empty($modSettings['deny_boards_access']) && count(array_intersect($user_info['groups'], $board_info['deny_groups'])) != 0 && !$user_info['is_admin']) { |
|
| 1042 | + $board_info['error'] = 'access'; |
|
| 1043 | + } |
|
| 997 | 1044 | |
| 998 | 1045 | // Build up the linktree. |
| 999 | 1046 | $context['linktree'] = array_merge( |
@@ -1016,8 +1063,9 @@ discard block |
||
| 1016 | 1063 | $context['current_board'] = $board; |
| 1017 | 1064 | |
| 1018 | 1065 | // No posting in redirection boards! |
| 1019 | - if (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'post' && !empty($board_info['redirect'])) |
|
| 1020 | - $board_info['error'] == 'post_in_redirect'; |
|
| 1066 | + if (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'post' && !empty($board_info['redirect'])) { |
|
| 1067 | + $board_info['error'] == 'post_in_redirect'; |
|
| 1068 | + } |
|
| 1021 | 1069 | |
| 1022 | 1070 | // Hacker... you can't see this topic, I'll tell you that. (but moderators can!) |
| 1023 | 1071 | if (!empty($board_info['error']) && (!empty($modSettings['deny_boards_access']) || $board_info['error'] != 'access' || !$user_info['is_mod'])) |
@@ -1043,24 +1091,23 @@ discard block |
||
| 1043 | 1091 | ob_end_clean(); |
| 1044 | 1092 | header('HTTP/1.1 403 Forbidden'); |
| 1045 | 1093 | die; |
| 1046 | - } |
|
| 1047 | - elseif ($board_info['error'] == 'post_in_redirect') |
|
| 1094 | + } elseif ($board_info['error'] == 'post_in_redirect') |
|
| 1048 | 1095 | { |
| 1049 | 1096 | // Slightly different error message here... |
| 1050 | 1097 | fatal_lang_error('cannot_post_redirect', false); |
| 1051 | - } |
|
| 1052 | - elseif ($user_info['is_guest']) |
|
| 1098 | + } elseif ($user_info['is_guest']) |
|
| 1053 | 1099 | { |
| 1054 | 1100 | loadLanguage('Errors'); |
| 1055 | 1101 | is_not_guest($txt['topic_gone']); |
| 1102 | + } else { |
|
| 1103 | + fatal_lang_error('topic_gone', false); |
|
| 1056 | 1104 | } |
| 1057 | - else |
|
| 1058 | - fatal_lang_error('topic_gone', false); |
|
| 1059 | 1105 | } |
| 1060 | 1106 | |
| 1061 | - if ($user_info['is_mod']) |
|
| 1062 | - $user_info['groups'][] = 3; |
|
| 1063 | -} |
|
| 1107 | + if ($user_info['is_mod']) { |
|
| 1108 | + $user_info['groups'][] = 3; |
|
| 1109 | + } |
|
| 1110 | + } |
|
| 1064 | 1111 | |
| 1065 | 1112 | /** |
| 1066 | 1113 | * Load this user's permissions. |
@@ -1081,8 +1128,9 @@ discard block |
||
| 1081 | 1128 | asort($cache_groups); |
| 1082 | 1129 | $cache_groups = implode(',', $cache_groups); |
| 1083 | 1130 | // If it's a spider then cache it different. |
| 1084 | - if ($user_info['possibly_robot']) |
|
| 1085 | - $cache_groups .= '-spider'; |
|
| 1131 | + if ($user_info['possibly_robot']) { |
|
| 1132 | + $cache_groups .= '-spider'; |
|
| 1133 | + } |
|
| 1086 | 1134 | |
| 1087 | 1135 | if ($modSettings['cache_enable'] >= 2 && !empty($board) && ($temp = cache_get_data('permissions:' . $cache_groups . ':' . $board, 240)) != null && time() - 240 > $modSettings['settings_updated']) |
| 1088 | 1136 | { |
@@ -1090,9 +1138,9 @@ discard block |
||
| 1090 | 1138 | banPermissions(); |
| 1091 | 1139 | |
| 1092 | 1140 | return; |
| 1141 | + } elseif (($temp = cache_get_data('permissions:' . $cache_groups, 240)) != null && time() - 240 > $modSettings['settings_updated']) { |
|
| 1142 | + list ($user_info['permissions'], $removals) = $temp; |
|
| 1093 | 1143 | } |
| 1094 | - elseif (($temp = cache_get_data('permissions:' . $cache_groups, 240)) != null && time() - 240 > $modSettings['settings_updated']) |
|
| 1095 | - list ($user_info['permissions'], $removals) = $temp; |
|
| 1096 | 1144 | } |
| 1097 | 1145 | |
| 1098 | 1146 | // If it is detected as a robot, and we are restricting permissions as a special group - then implement this. |
@@ -1114,23 +1162,26 @@ discard block |
||
| 1114 | 1162 | $removals = array(); |
| 1115 | 1163 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1116 | 1164 | { |
| 1117 | - if (empty($row['add_deny'])) |
|
| 1118 | - $removals[] = $row['permission']; |
|
| 1119 | - else |
|
| 1120 | - $user_info['permissions'][] = $row['permission']; |
|
| 1165 | + if (empty($row['add_deny'])) { |
|
| 1166 | + $removals[] = $row['permission']; |
|
| 1167 | + } else { |
|
| 1168 | + $user_info['permissions'][] = $row['permission']; |
|
| 1169 | + } |
|
| 1121 | 1170 | } |
| 1122 | 1171 | $smcFunc['db_free_result']($request); |
| 1123 | 1172 | |
| 1124 | - if (isset($cache_groups)) |
|
| 1125 | - cache_put_data('permissions:' . $cache_groups, array($user_info['permissions'], $removals), 240); |
|
| 1173 | + if (isset($cache_groups)) { |
|
| 1174 | + cache_put_data('permissions:' . $cache_groups, array($user_info['permissions'], $removals), 240); |
|
| 1175 | + } |
|
| 1126 | 1176 | } |
| 1127 | 1177 | |
| 1128 | 1178 | // Get the board permissions. |
| 1129 | 1179 | if (!empty($board)) |
| 1130 | 1180 | { |
| 1131 | 1181 | // Make sure the board (if any) has been loaded by loadBoard(). |
| 1132 | - if (!isset($board_info['profile'])) |
|
| 1133 | - fatal_lang_error('no_board'); |
|
| 1182 | + if (!isset($board_info['profile'])) { |
|
| 1183 | + fatal_lang_error('no_board'); |
|
| 1184 | + } |
|
| 1134 | 1185 | |
| 1135 | 1186 | $request = $smcFunc['db_query']('', ' |
| 1136 | 1187 | SELECT permission, add_deny |
@@ -1146,20 +1197,23 @@ discard block |
||
| 1146 | 1197 | ); |
| 1147 | 1198 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1148 | 1199 | { |
| 1149 | - if (empty($row['add_deny'])) |
|
| 1150 | - $removals[] = $row['permission']; |
|
| 1151 | - else |
|
| 1152 | - $user_info['permissions'][] = $row['permission']; |
|
| 1200 | + if (empty($row['add_deny'])) { |
|
| 1201 | + $removals[] = $row['permission']; |
|
| 1202 | + } else { |
|
| 1203 | + $user_info['permissions'][] = $row['permission']; |
|
| 1204 | + } |
|
| 1153 | 1205 | } |
| 1154 | 1206 | $smcFunc['db_free_result']($request); |
| 1155 | 1207 | } |
| 1156 | 1208 | |
| 1157 | 1209 | // Remove all the permissions they shouldn't have ;). |
| 1158 | - if (!empty($modSettings['permission_enable_deny'])) |
|
| 1159 | - $user_info['permissions'] = array_diff($user_info['permissions'], $removals); |
|
| 1210 | + if (!empty($modSettings['permission_enable_deny'])) { |
|
| 1211 | + $user_info['permissions'] = array_diff($user_info['permissions'], $removals); |
|
| 1212 | + } |
|
| 1160 | 1213 | |
| 1161 | - if (isset($cache_groups) && !empty($board) && $modSettings['cache_enable'] >= 2) |
|
| 1162 | - cache_put_data('permissions:' . $cache_groups . ':' . $board, array($user_info['permissions'], null), 240); |
|
| 1214 | + if (isset($cache_groups) && !empty($board) && $modSettings['cache_enable'] >= 2) { |
|
| 1215 | + cache_put_data('permissions:' . $cache_groups . ':' . $board, array($user_info['permissions'], null), 240); |
|
| 1216 | + } |
|
| 1163 | 1217 | |
| 1164 | 1218 | // Banned? Watch, don't touch.. |
| 1165 | 1219 | banPermissions(); |
@@ -1171,17 +1225,18 @@ discard block |
||
| 1171 | 1225 | { |
| 1172 | 1226 | require_once($sourcedir . '/Subs-Auth.php'); |
| 1173 | 1227 | rebuildModCache(); |
| 1228 | + } else { |
|
| 1229 | + $user_info['mod_cache'] = $_SESSION['mc']; |
|
| 1174 | 1230 | } |
| 1175 | - else |
|
| 1176 | - $user_info['mod_cache'] = $_SESSION['mc']; |
|
| 1177 | 1231 | |
| 1178 | 1232 | // This is a useful phantom permission added to the current user, and only the current user while they are logged in. |
| 1179 | 1233 | // For example this drastically simplifies certain changes to the profile area. |
| 1180 | 1234 | $user_info['permissions'][] = 'is_not_guest'; |
| 1181 | 1235 | // And now some backwards compatibility stuff for mods and whatnot that aren't expecting the new permissions. |
| 1182 | 1236 | $user_info['permissions'][] = 'profile_view_own'; |
| 1183 | - if (in_array('profile_view', $user_info['permissions'])) |
|
| 1184 | - $user_info['permissions'][] = 'profile_view_any'; |
|
| 1237 | + if (in_array('profile_view', $user_info['permissions'])) { |
|
| 1238 | + $user_info['permissions'][] = 'profile_view_any'; |
|
| 1239 | + } |
|
| 1185 | 1240 | } |
| 1186 | 1241 | } |
| 1187 | 1242 | |
@@ -1199,8 +1254,9 @@ discard block |
||
| 1199 | 1254 | global $image_proxy_enabled, $image_proxy_secret, $boardurl; |
| 1200 | 1255 | |
| 1201 | 1256 | // Can't just look for no users :P. |
| 1202 | - if (empty($users)) |
|
| 1203 | - return array(); |
|
| 1257 | + if (empty($users)) { |
|
| 1258 | + return array(); |
|
| 1259 | + } |
|
| 1204 | 1260 | |
| 1205 | 1261 | // Pass the set value |
| 1206 | 1262 | $context['loadMemberContext_set'] = $set; |
@@ -1215,8 +1271,9 @@ discard block |
||
| 1215 | 1271 | for ($i = 0, $n = count($users); $i < $n; $i++) |
| 1216 | 1272 | { |
| 1217 | 1273 | $data = cache_get_data('member_data-' . $set . '-' . $users[$i], 240); |
| 1218 | - if ($data == null) |
|
| 1219 | - continue; |
|
| 1274 | + if ($data == null) { |
|
| 1275 | + continue; |
|
| 1276 | + } |
|
| 1220 | 1277 | |
| 1221 | 1278 | $loaded_ids[] = $data['id_member']; |
| 1222 | 1279 | $user_profile[$data['id_member']] = $data; |
@@ -1280,13 +1337,16 @@ discard block |
||
| 1280 | 1337 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1281 | 1338 | { |
| 1282 | 1339 | // Take care of proxying avatar if required, do this here for maximum reach |
| 1283 | - if ($image_proxy_enabled && !empty($row['avatar']) && stripos($row['avatar'], 'http://') !== false) |
|
| 1284 | - $row['avatar'] = $boardurl . '/proxy.php?request=' . urlencode($row['avatar']) . '&hash=' . md5($row['avatar'] . $image_proxy_secret); |
|
| 1340 | + if ($image_proxy_enabled && !empty($row['avatar']) && stripos($row['avatar'], 'http://') !== false) { |
|
| 1341 | + $row['avatar'] = $boardurl . '/proxy.php?request=' . urlencode($row['avatar']) . '&hash=' . md5($row['avatar'] . $image_proxy_secret); |
|
| 1342 | + } |
|
| 1285 | 1343 | |
| 1286 | - if (isset($row['member_ip'])) |
|
| 1287 | - $row['member_ip'] = inet_dtop($row['member_ip']); |
|
| 1288 | - if (isset($row['member_ip2'])) |
|
| 1289 | - $row['member_ip2'] = inet_dtop($row['member_ip2']); |
|
| 1344 | + if (isset($row['member_ip'])) { |
|
| 1345 | + $row['member_ip'] = inet_dtop($row['member_ip']); |
|
| 1346 | + } |
|
| 1347 | + if (isset($row['member_ip2'])) { |
|
| 1348 | + $row['member_ip2'] = inet_dtop($row['member_ip2']); |
|
| 1349 | + } |
|
| 1290 | 1350 | $new_loaded_ids[] = $row['id_member']; |
| 1291 | 1351 | $loaded_ids[] = $row['id_member']; |
| 1292 | 1352 | $row['options'] = array(); |
@@ -1305,8 +1365,9 @@ discard block |
||
| 1305 | 1365 | 'loaded_ids' => $new_loaded_ids, |
| 1306 | 1366 | ) |
| 1307 | 1367 | ); |
| 1308 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1309 | - $user_profile[$row['id_member']]['options'][$row['variable']] = $row['value']; |
|
| 1368 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1369 | + $user_profile[$row['id_member']]['options'][$row['variable']] = $row['value']; |
|
| 1370 | + } |
|
| 1310 | 1371 | $smcFunc['db_free_result']($request); |
| 1311 | 1372 | } |
| 1312 | 1373 | |
@@ -1317,10 +1378,11 @@ discard block |
||
| 1317 | 1378 | { |
| 1318 | 1379 | foreach ($loaded_ids as $a_member) |
| 1319 | 1380 | { |
| 1320 | - if (!empty($user_profile[$a_member]['additional_groups'])) |
|
| 1321 | - $groups = array_merge(array($user_profile[$a_member]['id_group']), explode(',', $user_profile[$a_member]['additional_groups'])); |
|
| 1322 | - else |
|
| 1323 | - $groups = array($user_profile[$a_member]['id_group']); |
|
| 1381 | + if (!empty($user_profile[$a_member]['additional_groups'])) { |
|
| 1382 | + $groups = array_merge(array($user_profile[$a_member]['id_group']), explode(',', $user_profile[$a_member]['additional_groups'])); |
|
| 1383 | + } else { |
|
| 1384 | + $groups = array($user_profile[$a_member]['id_group']); |
|
| 1385 | + } |
|
| 1324 | 1386 | |
| 1325 | 1387 | $temp = array_intersect($groups, array_keys($board_info['moderator_groups'])); |
| 1326 | 1388 | |
@@ -1333,8 +1395,9 @@ discard block |
||
| 1333 | 1395 | |
| 1334 | 1396 | if (!empty($new_loaded_ids) && !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 3) |
| 1335 | 1397 | { |
| 1336 | - for ($i = 0, $n = count($new_loaded_ids); $i < $n; $i++) |
|
| 1337 | - cache_put_data('member_data-' . $set . '-' . $new_loaded_ids[$i], $user_profile[$new_loaded_ids[$i]], 240); |
|
| 1398 | + for ($i = 0, $n = count($new_loaded_ids); $i < $n; $i++) { |
|
| 1399 | + cache_put_data('member_data-' . $set . '-' . $new_loaded_ids[$i], $user_profile[$new_loaded_ids[$i]], 240); |
|
| 1400 | + } |
|
| 1338 | 1401 | } |
| 1339 | 1402 | |
| 1340 | 1403 | // Are we loading any moderators? If so, fix their group data... |
@@ -1360,14 +1423,17 @@ discard block |
||
| 1360 | 1423 | foreach ($temp_mods as $id) |
| 1361 | 1424 | { |
| 1362 | 1425 | // By popular demand, don't show admins or global moderators as moderators. |
| 1363 | - if ($user_profile[$id]['id_group'] != 1 && $user_profile[$id]['id_group'] != 2) |
|
| 1364 | - $user_profile[$id]['member_group'] = $row['member_group']; |
|
| 1426 | + if ($user_profile[$id]['id_group'] != 1 && $user_profile[$id]['id_group'] != 2) { |
|
| 1427 | + $user_profile[$id]['member_group'] = $row['member_group']; |
|
| 1428 | + } |
|
| 1365 | 1429 | |
| 1366 | 1430 | // If the Moderator group has no color or icons, but their group does... don't overwrite. |
| 1367 | - if (!empty($row['icons'])) |
|
| 1368 | - $user_profile[$id]['icons'] = $row['icons']; |
|
| 1369 | - if (!empty($row['member_group_color'])) |
|
| 1370 | - $user_profile[$id]['member_group_color'] = $row['member_group_color']; |
|
| 1431 | + if (!empty($row['icons'])) { |
|
| 1432 | + $user_profile[$id]['icons'] = $row['icons']; |
|
| 1433 | + } |
|
| 1434 | + if (!empty($row['member_group_color'])) { |
|
| 1435 | + $user_profile[$id]['member_group_color'] = $row['member_group_color']; |
|
| 1436 | + } |
|
| 1371 | 1437 | } |
| 1372 | 1438 | } |
| 1373 | 1439 | |
@@ -1389,12 +1455,14 @@ discard block |
||
| 1389 | 1455 | static $loadedLanguages = array(); |
| 1390 | 1456 | |
| 1391 | 1457 | // If this person's data is already loaded, skip it. |
| 1392 | - if (isset($dataLoaded[$user])) |
|
| 1393 | - return true; |
|
| 1458 | + if (isset($dataLoaded[$user])) { |
|
| 1459 | + return true; |
|
| 1460 | + } |
|
| 1394 | 1461 | |
| 1395 | 1462 | // We can't load guests or members not loaded by loadMemberData()! |
| 1396 | - if ($user == 0) |
|
| 1397 | - return false; |
|
| 1463 | + if ($user == 0) { |
|
| 1464 | + return false; |
|
| 1465 | + } |
|
| 1398 | 1466 | if (!isset($user_profile[$user])) |
| 1399 | 1467 | { |
| 1400 | 1468 | trigger_error('loadMemberContext(): member id ' . $user . ' not previously loaded by loadMemberData()', E_USER_WARNING); |
@@ -1420,12 +1488,16 @@ discard block |
||
| 1420 | 1488 | $buddy_list = !empty($profile['buddy_list']) ? explode(',', $profile['buddy_list']) : array(); |
| 1421 | 1489 | |
| 1422 | 1490 | //We need a little fallback for the membergroup icons. If it doesn't exist in the current theme, fallback to default theme |
| 1423 | - if (isset($profile['icons'][1]) && file_exists($settings['actual_theme_dir'] . '/images/membericons/' . $profile['icons'][1])) //icon is set and exists |
|
| 1491 | + if (isset($profile['icons'][1]) && file_exists($settings['actual_theme_dir'] . '/images/membericons/' . $profile['icons'][1])) { |
|
| 1492 | + //icon is set and exists |
|
| 1424 | 1493 | $group_icon_url = $settings['images_url'] . '/membericons/' . $profile['icons'][1]; |
| 1425 | - elseif (isset($profile['icons'][1])) //icon is set and doesn't exist, fallback to default |
|
| 1494 | + } elseif (isset($profile['icons'][1])) { |
|
| 1495 | + //icon is set and doesn't exist, fallback to default |
|
| 1426 | 1496 | $group_icon_url = $settings['default_images_url'] . '/membericons/' . $profile['icons'][1]; |
| 1427 | - else //not set, bye bye |
|
| 1497 | + } else { |
|
| 1498 | + //not set, bye bye |
|
| 1428 | 1499 | $group_icon_url = ''; |
| 1500 | + } |
|
| 1429 | 1501 | |
| 1430 | 1502 | // These minimal values are always loaded |
| 1431 | 1503 | $memberContext[$user] = array( |
@@ -1444,8 +1516,9 @@ discard block |
||
| 1444 | 1516 | if ($context['loadMemberContext_set'] != 'minimal') |
| 1445 | 1517 | { |
| 1446 | 1518 | // Go the extra mile and load the user's native language name. |
| 1447 | - if (empty($loadedLanguages)) |
|
| 1448 | - $loadedLanguages = getLanguages(); |
|
| 1519 | + if (empty($loadedLanguages)) { |
|
| 1520 | + $loadedLanguages = getLanguages(); |
|
| 1521 | + } |
|
| 1449 | 1522 | |
| 1450 | 1523 | $memberContext[$user] += array( |
| 1451 | 1524 | 'username_color' => '<span ' . (!empty($profile['member_group_color']) ? 'style="color:' . $profile['member_group_color'] . ';"' : '') . '>' . $profile['member_name'] . '</span>', |
@@ -1499,31 +1572,33 @@ discard block |
||
| 1499 | 1572 | { |
| 1500 | 1573 | if (!empty($modSettings['gravatarOverride']) || (!empty($modSettings['gravatarEnabled']) && stristr($profile['avatar'], 'gravatar://'))) |
| 1501 | 1574 | { |
| 1502 | - if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($profile['avatar'], 'gravatar://') && strlen($profile['avatar']) > 11) |
|
| 1503 | - $image = get_gravatar_url($smcFunc['substr']($profile['avatar'], 11)); |
|
| 1504 | - else |
|
| 1505 | - $image = get_gravatar_url($profile['email_address']); |
|
| 1506 | - } |
|
| 1507 | - else |
|
| 1575 | + if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($profile['avatar'], 'gravatar://') && strlen($profile['avatar']) > 11) { |
|
| 1576 | + $image = get_gravatar_url($smcFunc['substr']($profile['avatar'], 11)); |
|
| 1577 | + } else { |
|
| 1578 | + $image = get_gravatar_url($profile['email_address']); |
|
| 1579 | + } |
|
| 1580 | + } else |
|
| 1508 | 1581 | { |
| 1509 | 1582 | // So it's stored in the member table? |
| 1510 | 1583 | if (!empty($profile['avatar'])) |
| 1511 | 1584 | { |
| 1512 | 1585 | $image = (stristr($profile['avatar'], 'http://') || stristr($profile['avatar'], 'https://')) ? $profile['avatar'] : $modSettings['avatar_url'] . '/' . $profile['avatar']; |
| 1586 | + } elseif (!empty($profile['filename'])) { |
|
| 1587 | + $image = $modSettings['custom_avatar_url'] . '/' . $profile['filename']; |
|
| 1513 | 1588 | } |
| 1514 | - elseif (!empty($profile['filename'])) |
|
| 1515 | - $image = $modSettings['custom_avatar_url'] . '/' . $profile['filename']; |
|
| 1516 | 1589 | // Right... no avatar...use the default one |
| 1517 | - else |
|
| 1518 | - $image = $modSettings['avatar_url'] . '/default.png'; |
|
| 1590 | + else { |
|
| 1591 | + $image = $modSettings['avatar_url'] . '/default.png'; |
|
| 1592 | + } |
|
| 1519 | 1593 | } |
| 1520 | - if (!empty($image)) |
|
| 1521 | - $memberContext[$user]['avatar'] = array( |
|
| 1594 | + if (!empty($image)) { |
|
| 1595 | + $memberContext[$user]['avatar'] = array( |
|
| 1522 | 1596 | 'name' => $profile['avatar'], |
| 1523 | 1597 | 'image' => '<img class="avatar" src="' . $image . '" alt="avatar_' . $profile['member_name'] . '">', |
| 1524 | 1598 | 'href' => $image, |
| 1525 | 1599 | 'url' => $image, |
| 1526 | 1600 | ); |
| 1601 | + } |
|
| 1527 | 1602 | } |
| 1528 | 1603 | |
| 1529 | 1604 | // Are we also loading the members custom fields into context? |
@@ -1531,35 +1606,41 @@ discard block |
||
| 1531 | 1606 | { |
| 1532 | 1607 | $memberContext[$user]['custom_fields'] = array(); |
| 1533 | 1608 | |
| 1534 | - if (!isset($context['display_fields'])) |
|
| 1535 | - $context['display_fields'] = smf_json_decode($modSettings['displayFields'], true); |
|
| 1609 | + if (!isset($context['display_fields'])) { |
|
| 1610 | + $context['display_fields'] = smf_json_decode($modSettings['displayFields'], true); |
|
| 1611 | + } |
|
| 1536 | 1612 | |
| 1537 | 1613 | foreach ($context['display_fields'] as $custom) |
| 1538 | 1614 | { |
| 1539 | - if (!isset($custom['col_name']) || trim($custom['col_name']) == '' || empty($profile['options'][$custom['col_name']])) |
|
| 1540 | - continue; |
|
| 1615 | + if (!isset($custom['col_name']) || trim($custom['col_name']) == '' || empty($profile['options'][$custom['col_name']])) { |
|
| 1616 | + continue; |
|
| 1617 | + } |
|
| 1541 | 1618 | |
| 1542 | 1619 | $value = $profile['options'][$custom['col_name']]; |
| 1543 | 1620 | |
| 1544 | 1621 | // Don't show the "disabled" option for the "gender" field. |
| 1545 | - if ($custom['col_name'] == 'cust_gender' && $value == 'Disabled') |
|
| 1546 | - continue; |
|
| 1622 | + if ($custom['col_name'] == 'cust_gender' && $value == 'Disabled') { |
|
| 1623 | + continue; |
|
| 1624 | + } |
|
| 1547 | 1625 | |
| 1548 | 1626 | // BBC? |
| 1549 | - if ($custom['bbc']) |
|
| 1550 | - $value = parse_bbc($value); |
|
| 1627 | + if ($custom['bbc']) { |
|
| 1628 | + $value = parse_bbc($value); |
|
| 1629 | + } |
|
| 1551 | 1630 | // ... or checkbox? |
| 1552 | - elseif (isset($custom['type']) && $custom['type'] == 'check') |
|
| 1553 | - $value = $value ? $txt['yes'] : $txt['no']; |
|
| 1631 | + elseif (isset($custom['type']) && $custom['type'] == 'check') { |
|
| 1632 | + $value = $value ? $txt['yes'] : $txt['no']; |
|
| 1633 | + } |
|
| 1554 | 1634 | |
| 1555 | 1635 | // Enclosing the user input within some other text? |
| 1556 | - if (!empty($custom['enclose'])) |
|
| 1557 | - $value = strtr($custom['enclose'], array( |
|
| 1636 | + if (!empty($custom['enclose'])) { |
|
| 1637 | + $value = strtr($custom['enclose'], array( |
|
| 1558 | 1638 | '{SCRIPTURL}' => $scripturl, |
| 1559 | 1639 | '{IMAGES_URL}' => $settings['images_url'], |
| 1560 | 1640 | '{DEFAULT_IMAGES_URL}' => $settings['default_images_url'], |
| 1561 | 1641 | '{INPUT}' => $value, |
| 1562 | 1642 | )); |
| 1643 | + } |
|
| 1563 | 1644 | |
| 1564 | 1645 | $memberContext[$user]['custom_fields'][] = array( |
| 1565 | 1646 | 'title' => !empty($custom['title']) ? $custom['title'] : $custom['col_name'], |
@@ -1586,8 +1667,9 @@ discard block |
||
| 1586 | 1667 | global $smcFunc, $txt, $scripturl, $settings; |
| 1587 | 1668 | |
| 1588 | 1669 | // Do not waste my time... |
| 1589 | - if (empty($users) || empty($params)) |
|
| 1590 | - return false; |
|
| 1670 | + if (empty($users) || empty($params)) { |
|
| 1671 | + return false; |
|
| 1672 | + } |
|
| 1591 | 1673 | |
| 1592 | 1674 | // Make sure it's an array. |
| 1593 | 1675 | $users = !is_array($users) ? array($users) : array_unique($users); |
@@ -1611,31 +1693,36 @@ discard block |
||
| 1611 | 1693 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1612 | 1694 | { |
| 1613 | 1695 | // BBC? |
| 1614 | - if (!empty($row['bbc'])) |
|
| 1615 | - $row['value'] = parse_bbc($row['value']); |
|
| 1696 | + if (!empty($row['bbc'])) { |
|
| 1697 | + $row['value'] = parse_bbc($row['value']); |
|
| 1698 | + } |
|
| 1616 | 1699 | |
| 1617 | 1700 | // ... or checkbox? |
| 1618 | - elseif (isset($row['type']) && $row['type'] == 'check') |
|
| 1619 | - $row['value'] = !empty($row['value']) ? $txt['yes'] : $txt['no']; |
|
| 1701 | + elseif (isset($row['type']) && $row['type'] == 'check') { |
|
| 1702 | + $row['value'] = !empty($row['value']) ? $txt['yes'] : $txt['no']; |
|
| 1703 | + } |
|
| 1620 | 1704 | |
| 1621 | 1705 | // Enclosing the user input within some other text? |
| 1622 | - if (!empty($row['enclose'])) |
|
| 1623 | - $row['value'] = strtr($row['enclose'], array( |
|
| 1706 | + if (!empty($row['enclose'])) { |
|
| 1707 | + $row['value'] = strtr($row['enclose'], array( |
|
| 1624 | 1708 | '{SCRIPTURL}' => $scripturl, |
| 1625 | 1709 | '{IMAGES_URL}' => $settings['images_url'], |
| 1626 | 1710 | '{DEFAULT_IMAGES_URL}' => $settings['default_images_url'], |
| 1627 | 1711 | '{INPUT}' => un_htmlspecialchars($row['value']), |
| 1628 | 1712 | )); |
| 1713 | + } |
|
| 1629 | 1714 | |
| 1630 | 1715 | // Send a simple array if there is just 1 param |
| 1631 | - if (count($params) == 1) |
|
| 1632 | - $return[$row['id_member']] = $row; |
|
| 1716 | + if (count($params) == 1) { |
|
| 1717 | + $return[$row['id_member']] = $row; |
|
| 1718 | + } |
|
| 1633 | 1719 | |
| 1634 | 1720 | // More than 1? knock yourself out... |
| 1635 | 1721 | else |
| 1636 | 1722 | { |
| 1637 | - if (!isset($return[$row['id_member']])) |
|
| 1638 | - $return[$row['id_member']] = array(); |
|
| 1723 | + if (!isset($return[$row['id_member']])) { |
|
| 1724 | + $return[$row['id_member']] = array(); |
|
| 1725 | + } |
|
| 1639 | 1726 | |
| 1640 | 1727 | $return[$row['id_member']][$row['variable']] = $row; |
| 1641 | 1728 | } |
@@ -1669,8 +1756,9 @@ discard block |
||
| 1669 | 1756 | global $context; |
| 1670 | 1757 | |
| 1671 | 1758 | // Don't know any browser! |
| 1672 | - if (empty($context['browser'])) |
|
| 1673 | - detectBrowser(); |
|
| 1759 | + if (empty($context['browser'])) { |
|
| 1760 | + detectBrowser(); |
|
| 1761 | + } |
|
| 1674 | 1762 | |
| 1675 | 1763 | return !empty($context['browser'][$browser]) || !empty($context['browser']['is_' . $browser]) ? true : false; |
| 1676 | 1764 | } |
@@ -1688,8 +1776,9 @@ discard block |
||
| 1688 | 1776 | global $context, $settings, $options, $sourcedir, $ssi_theme, $smcFunc, $language, $board, $image_proxy_enabled; |
| 1689 | 1777 | |
| 1690 | 1778 | // The theme was specified by parameter. |
| 1691 | - if (!empty($id_theme)) |
|
| 1692 | - $id_theme = (int) $id_theme; |
|
| 1779 | + if (!empty($id_theme)) { |
|
| 1780 | + $id_theme = (int) $id_theme; |
|
| 1781 | + } |
|
| 1693 | 1782 | // The theme was specified by REQUEST. |
| 1694 | 1783 | elseif (!empty($_REQUEST['theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum'))) |
| 1695 | 1784 | { |
@@ -1697,51 +1786,58 @@ discard block |
||
| 1697 | 1786 | $_SESSION['id_theme'] = $id_theme; |
| 1698 | 1787 | } |
| 1699 | 1788 | // The theme was specified by REQUEST... previously. |
| 1700 | - elseif (!empty($_SESSION['id_theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum'))) |
|
| 1701 | - $id_theme = (int) $_SESSION['id_theme']; |
|
| 1789 | + elseif (!empty($_SESSION['id_theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum'))) { |
|
| 1790 | + $id_theme = (int) $_SESSION['id_theme']; |
|
| 1791 | + } |
|
| 1702 | 1792 | // The theme is just the user's choice. (might use ?board=1;theme=0 to force board theme.) |
| 1703 | - elseif (!empty($user_info['theme']) && !isset($_REQUEST['theme'])) |
|
| 1704 | - $id_theme = $user_info['theme']; |
|
| 1793 | + elseif (!empty($user_info['theme']) && !isset($_REQUEST['theme'])) { |
|
| 1794 | + $id_theme = $user_info['theme']; |
|
| 1795 | + } |
|
| 1705 | 1796 | // The theme was specified by the board. |
| 1706 | - elseif (!empty($board_info['theme'])) |
|
| 1707 | - $id_theme = $board_info['theme']; |
|
| 1797 | + elseif (!empty($board_info['theme'])) { |
|
| 1798 | + $id_theme = $board_info['theme']; |
|
| 1799 | + } |
|
| 1708 | 1800 | // The theme is the forum's default. |
| 1709 | - else |
|
| 1710 | - $id_theme = $modSettings['theme_guests']; |
|
| 1801 | + else { |
|
| 1802 | + $id_theme = $modSettings['theme_guests']; |
|
| 1803 | + } |
|
| 1711 | 1804 | |
| 1712 | 1805 | // Verify the id_theme... no foul play. |
| 1713 | 1806 | // Always allow the board specific theme, if they are overriding. |
| 1714 | - if (!empty($board_info['theme']) && $board_info['override_theme']) |
|
| 1715 | - $id_theme = $board_info['theme']; |
|
| 1807 | + if (!empty($board_info['theme']) && $board_info['override_theme']) { |
|
| 1808 | + $id_theme = $board_info['theme']; |
|
| 1809 | + } |
|
| 1716 | 1810 | // If they have specified a particular theme to use with SSI allow it to be used. |
| 1717 | - elseif (!empty($ssi_theme) && $id_theme == $ssi_theme) |
|
| 1718 | - $id_theme = (int) $id_theme; |
|
| 1719 | - elseif (!empty($modSettings['enableThemes']) && !allowedTo('admin_forum')) |
|
| 1811 | + elseif (!empty($ssi_theme) && $id_theme == $ssi_theme) { |
|
| 1812 | + $id_theme = (int) $id_theme; |
|
| 1813 | + } elseif (!empty($modSettings['enableThemes']) && !allowedTo('admin_forum')) |
|
| 1720 | 1814 | { |
| 1721 | 1815 | $themes = explode(',', $modSettings['enableThemes']); |
| 1722 | - if (!in_array($id_theme, $themes)) |
|
| 1723 | - $id_theme = $modSettings['theme_guests']; |
|
| 1724 | - else |
|
| 1816 | + if (!in_array($id_theme, $themes)) { |
|
| 1817 | + $id_theme = $modSettings['theme_guests']; |
|
| 1818 | + } else { |
|
| 1819 | + $id_theme = (int) $id_theme; |
|
| 1820 | + } |
|
| 1821 | + } else { |
|
| 1725 | 1822 | $id_theme = (int) $id_theme; |
| 1726 | 1823 | } |
| 1727 | - else |
|
| 1728 | - $id_theme = (int) $id_theme; |
|
| 1729 | 1824 | |
| 1730 | 1825 | $member = empty($user_info['id']) ? -1 : $user_info['id']; |
| 1731 | 1826 | |
| 1732 | 1827 | // Disable image proxy if we don't have SSL enabled |
| 1733 | - if (empty($modSettings['force_ssl']) || $modSettings['force_ssl'] < 2) |
|
| 1734 | - $image_proxy_enabled = false; |
|
| 1828 | + if (empty($modSettings['force_ssl']) || $modSettings['force_ssl'] < 2) { |
|
| 1829 | + $image_proxy_enabled = false; |
|
| 1830 | + } |
|
| 1735 | 1831 | |
| 1736 | 1832 | if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2 && ($temp = cache_get_data('theme_settings-' . $id_theme . ':' . $member, 60)) != null && time() - 60 > $modSettings['settings_updated']) |
| 1737 | 1833 | { |
| 1738 | 1834 | $themeData = $temp; |
| 1739 | 1835 | $flag = true; |
| 1836 | + } elseif (($temp = cache_get_data('theme_settings-' . $id_theme, 90)) != null && time() - 60 > $modSettings['settings_updated']) { |
|
| 1837 | + $themeData = $temp + array($member => array()); |
|
| 1838 | + } else { |
|
| 1839 | + $themeData = array(-1 => array(), 0 => array(), $member => array()); |
|
| 1740 | 1840 | } |
| 1741 | - elseif (($temp = cache_get_data('theme_settings-' . $id_theme, 90)) != null && time() - 60 > $modSettings['settings_updated']) |
|
| 1742 | - $themeData = $temp + array($member => array()); |
|
| 1743 | - else |
|
| 1744 | - $themeData = array(-1 => array(), 0 => array(), $member => array()); |
|
| 1745 | 1841 | |
| 1746 | 1842 | if (empty($flag)) |
| 1747 | 1843 | { |
@@ -1760,31 +1856,37 @@ discard block |
||
| 1760 | 1856 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 1761 | 1857 | { |
| 1762 | 1858 | // There are just things we shouldn't be able to change as members. |
| 1763 | - if ($row['id_member'] != 0 && in_array($row['variable'], array('actual_theme_url', 'actual_images_url', 'base_theme_dir', 'base_theme_url', 'default_images_url', 'default_theme_dir', 'default_theme_url', 'default_template', 'images_url', 'number_recent_posts', 'smiley_sets_default', 'theme_dir', 'theme_id', 'theme_layers', 'theme_templates', 'theme_url'))) |
|
| 1764 | - continue; |
|
| 1859 | + if ($row['id_member'] != 0 && in_array($row['variable'], array('actual_theme_url', 'actual_images_url', 'base_theme_dir', 'base_theme_url', 'default_images_url', 'default_theme_dir', 'default_theme_url', 'default_template', 'images_url', 'number_recent_posts', 'smiley_sets_default', 'theme_dir', 'theme_id', 'theme_layers', 'theme_templates', 'theme_url'))) { |
|
| 1860 | + continue; |
|
| 1861 | + } |
|
| 1765 | 1862 | |
| 1766 | 1863 | // If this is the theme_dir of the default theme, store it. |
| 1767 | - if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['id_theme'] == '1' && empty($row['id_member'])) |
|
| 1768 | - $themeData[0]['default_' . $row['variable']] = $row['value']; |
|
| 1864 | + if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['id_theme'] == '1' && empty($row['id_member'])) { |
|
| 1865 | + $themeData[0]['default_' . $row['variable']] = $row['value']; |
|
| 1866 | + } |
|
| 1769 | 1867 | |
| 1770 | 1868 | // If this isn't set yet, is a theme option, or is not the default theme.. |
| 1771 | - if (!isset($themeData[$row['id_member']][$row['variable']]) || $row['id_theme'] != '1') |
|
| 1772 | - $themeData[$row['id_member']][$row['variable']] = substr($row['variable'], 0, 5) == 'show_' ? $row['value'] == '1' : $row['value']; |
|
| 1869 | + if (!isset($themeData[$row['id_member']][$row['variable']]) || $row['id_theme'] != '1') { |
|
| 1870 | + $themeData[$row['id_member']][$row['variable']] = substr($row['variable'], 0, 5) == 'show_' ? $row['value'] == '1' : $row['value']; |
|
| 1871 | + } |
|
| 1773 | 1872 | } |
| 1774 | 1873 | $smcFunc['db_free_result']($result); |
| 1775 | 1874 | |
| 1776 | - if (!empty($themeData[-1])) |
|
| 1777 | - foreach ($themeData[-1] as $k => $v) |
|
| 1875 | + if (!empty($themeData[-1])) { |
|
| 1876 | + foreach ($themeData[-1] as $k => $v) |
|
| 1778 | 1877 | { |
| 1779 | 1878 | if (!isset($themeData[$member][$k])) |
| 1780 | 1879 | $themeData[$member][$k] = $v; |
| 1880 | + } |
|
| 1781 | 1881 | } |
| 1782 | 1882 | |
| 1783 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
| 1784 | - cache_put_data('theme_settings-' . $id_theme . ':' . $member, $themeData, 60); |
|
| 1883 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
| 1884 | + cache_put_data('theme_settings-' . $id_theme . ':' . $member, $themeData, 60); |
|
| 1885 | + } |
|
| 1785 | 1886 | // Only if we didn't already load that part of the cache... |
| 1786 | - elseif (!isset($temp)) |
|
| 1787 | - cache_put_data('theme_settings-' . $id_theme, array(-1 => $themeData[-1], 0 => $themeData[0]), 90); |
|
| 1887 | + elseif (!isset($temp)) { |
|
| 1888 | + cache_put_data('theme_settings-' . $id_theme, array(-1 => $themeData[-1], 0 => $themeData[0]), 90); |
|
| 1889 | + } |
|
| 1788 | 1890 | } |
| 1789 | 1891 | |
| 1790 | 1892 | $settings = $themeData[0]; |
@@ -1801,20 +1903,24 @@ discard block |
||
| 1801 | 1903 | $settings['template_dirs'][] = $settings['theme_dir']; |
| 1802 | 1904 | |
| 1803 | 1905 | // Based on theme (if there is one). |
| 1804 | - if (!empty($settings['base_theme_dir'])) |
|
| 1805 | - $settings['template_dirs'][] = $settings['base_theme_dir']; |
|
| 1906 | + if (!empty($settings['base_theme_dir'])) { |
|
| 1907 | + $settings['template_dirs'][] = $settings['base_theme_dir']; |
|
| 1908 | + } |
|
| 1806 | 1909 | |
| 1807 | 1910 | // Lastly the default theme. |
| 1808 | - if ($settings['theme_dir'] != $settings['default_theme_dir']) |
|
| 1809 | - $settings['template_dirs'][] = $settings['default_theme_dir']; |
|
| 1911 | + if ($settings['theme_dir'] != $settings['default_theme_dir']) { |
|
| 1912 | + $settings['template_dirs'][] = $settings['default_theme_dir']; |
|
| 1913 | + } |
|
| 1810 | 1914 | |
| 1811 | - if (!$initialize) |
|
| 1812 | - return; |
|
| 1915 | + if (!$initialize) { |
|
| 1916 | + return; |
|
| 1917 | + } |
|
| 1813 | 1918 | |
| 1814 | 1919 | // Check to see if we're forcing SSL |
| 1815 | 1920 | if (!empty($modSettings['force_ssl']) && $modSettings['force_ssl'] == 2 && empty($maintenance) && |
| 1816 | - (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == 'off') && SMF != 'SSI') |
|
| 1817 | - redirectexit(strtr($_SERVER['REQUEST_URL'], array('http://' => 'https://'))); |
|
| 1921 | + (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == 'off') && SMF != 'SSI') { |
|
| 1922 | + redirectexit(strtr($_SERVER['REQUEST_URL'], array('http://' => 'https://'))); |
|
| 1923 | + } |
|
| 1818 | 1924 | |
| 1819 | 1925 | // Check to see if they're accessing it from the wrong place. |
| 1820 | 1926 | if (isset($_SERVER['HTTP_HOST']) || isset($_SERVER['SERVER_NAME'])) |
@@ -1822,8 +1928,9 @@ discard block |
||
| 1822 | 1928 | $detected_url = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ? 'https://' : 'http://'; |
| 1823 | 1929 | $detected_url .= empty($_SERVER['HTTP_HOST']) ? $_SERVER['SERVER_NAME'] . (empty($_SERVER['SERVER_PORT']) || $_SERVER['SERVER_PORT'] == '80' ? '' : ':' . $_SERVER['SERVER_PORT']) : $_SERVER['HTTP_HOST']; |
| 1824 | 1930 | $temp = preg_replace('~/' . basename($scripturl) . '(/.+)?$~', '', strtr(dirname($_SERVER['PHP_SELF']), '\\', '/')); |
| 1825 | - if ($temp != '/') |
|
| 1826 | - $detected_url .= $temp; |
|
| 1931 | + if ($temp != '/') { |
|
| 1932 | + $detected_url .= $temp; |
|
| 1933 | + } |
|
| 1827 | 1934 | } |
| 1828 | 1935 | if (isset($detected_url) && $detected_url != $boardurl) |
| 1829 | 1936 | { |
@@ -1835,8 +1942,9 @@ discard block |
||
| 1835 | 1942 | foreach ($aliases as $alias) |
| 1836 | 1943 | { |
| 1837 | 1944 | // Rip off all the boring parts, spaces, etc. |
| 1838 | - if ($detected_url == trim($alias) || strtr($detected_url, array('http://' => '', 'https://' => '')) == trim($alias)) |
|
| 1839 | - $do_fix = true; |
|
| 1945 | + if ($detected_url == trim($alias) || strtr($detected_url, array('http://' => '', 'https://' => '')) == trim($alias)) { |
|
| 1946 | + $do_fix = true; |
|
| 1947 | + } |
|
| 1840 | 1948 | } |
| 1841 | 1949 | } |
| 1842 | 1950 | |
@@ -1844,20 +1952,22 @@ discard block |
||
| 1844 | 1952 | if (empty($do_fix) && strtr($detected_url, array('://' => '://www.')) == $boardurl && (empty($_GET) || count($_GET) == 1) && SMF != 'SSI') |
| 1845 | 1953 | { |
| 1846 | 1954 | // Okay, this seems weird, but we don't want an endless loop - this will make $_GET not empty ;). |
| 1847 | - if (empty($_GET)) |
|
| 1848 | - redirectexit('wwwRedirect'); |
|
| 1849 | - else |
|
| 1955 | + if (empty($_GET)) { |
|
| 1956 | + redirectexit('wwwRedirect'); |
|
| 1957 | + } else |
|
| 1850 | 1958 | { |
| 1851 | 1959 | list ($k, $v) = each($_GET); |
| 1852 | 1960 | |
| 1853 | - if ($k != 'wwwRedirect') |
|
| 1854 | - redirectexit('wwwRedirect;' . $k . '=' . $v); |
|
| 1961 | + if ($k != 'wwwRedirect') { |
|
| 1962 | + redirectexit('wwwRedirect;' . $k . '=' . $v); |
|
| 1963 | + } |
|
| 1855 | 1964 | } |
| 1856 | 1965 | } |
| 1857 | 1966 | |
| 1858 | 1967 | // #3 is just a check for SSL... |
| 1859 | - if (strtr($detected_url, array('https://' => 'http://')) == $boardurl) |
|
| 1860 | - $do_fix = true; |
|
| 1968 | + if (strtr($detected_url, array('https://' => 'http://')) == $boardurl) { |
|
| 1969 | + $do_fix = true; |
|
| 1970 | + } |
|
| 1861 | 1971 | |
| 1862 | 1972 | // Okay, #4 - perhaps it's an IP address? We're gonna want to use that one, then. (assuming it's the IP or something...) |
| 1863 | 1973 | if (!empty($do_fix) || preg_match('~^http[s]?://(?:[\d\.:]+|\[[\d:]+\](?::\d+)?)(?:$|/)~', $detected_url) == 1) |
@@ -1891,8 +2001,9 @@ discard block |
||
| 1891 | 2001 | $board_info['moderators'][$k]['link'] = strtr($dummy['link'], array('"' . $oldurl => '"' . $boardurl)); |
| 1892 | 2002 | } |
| 1893 | 2003 | } |
| 1894 | - foreach ($context['linktree'] as $k => $dummy) |
|
| 1895 | - $context['linktree'][$k]['url'] = strtr($dummy['url'], array($oldurl => $boardurl)); |
|
| 2004 | + foreach ($context['linktree'] as $k => $dummy) { |
|
| 2005 | + $context['linktree'][$k]['url'] = strtr($dummy['url'], array($oldurl => $boardurl)); |
|
| 2006 | + } |
|
| 1896 | 2007 | } |
| 1897 | 2008 | } |
| 1898 | 2009 | // Set up the contextual user array. |
@@ -1911,16 +2022,16 @@ discard block |
||
| 1911 | 2022 | 'email' => $user_info['email'], |
| 1912 | 2023 | 'ignoreusers' => $user_info['ignoreusers'], |
| 1913 | 2024 | ); |
| 1914 | - if (!$context['user']['is_guest']) |
|
| 1915 | - $context['user']['name'] = $user_info['name']; |
|
| 1916 | - elseif ($context['user']['is_guest'] && !empty($txt['guest_title'])) |
|
| 1917 | - $context['user']['name'] = $txt['guest_title']; |
|
| 2025 | + if (!$context['user']['is_guest']) { |
|
| 2026 | + $context['user']['name'] = $user_info['name']; |
|
| 2027 | + } elseif ($context['user']['is_guest'] && !empty($txt['guest_title'])) { |
|
| 2028 | + $context['user']['name'] = $txt['guest_title']; |
|
| 2029 | + } |
|
| 1918 | 2030 | |
| 1919 | 2031 | // Determine the current smiley set. |
| 1920 | 2032 | $user_info['smiley_set'] = (!in_array($user_info['smiley_set'], explode(',', $modSettings['smiley_sets_known'])) && $user_info['smiley_set'] != 'none') || empty($modSettings['smiley_sets_enable']) ? (!empty($settings['smiley_sets_default']) ? $settings['smiley_sets_default'] : $modSettings['smiley_sets_default']) : $user_info['smiley_set']; |
| 1921 | 2033 | $context['user']['smiley_set'] = $user_info['smiley_set']; |
| 1922 | - } |
|
| 1923 | - else |
|
| 2034 | + } else |
|
| 1924 | 2035 | { |
| 1925 | 2036 | $context['user'] = array( |
| 1926 | 2037 | 'id' => -1, |
@@ -1936,18 +2047,24 @@ discard block |
||
| 1936 | 2047 | } |
| 1937 | 2048 | |
| 1938 | 2049 | // Some basic information... |
| 1939 | - if (!isset($context['html_headers'])) |
|
| 1940 | - $context['html_headers'] = ''; |
|
| 1941 | - if (!isset($context['javascript_files'])) |
|
| 1942 | - $context['javascript_files'] = array(); |
|
| 1943 | - if (!isset($context['css_files'])) |
|
| 1944 | - $context['css_files'] = array(); |
|
| 1945 | - if (!isset($context['css_header'])) |
|
| 1946 | - $context['css_header'] = array(); |
|
| 1947 | - if (!isset($context['javascript_inline'])) |
|
| 1948 | - $context['javascript_inline'] = array('standard' => array(), 'defer' => array()); |
|
| 1949 | - if (!isset($context['javascript_vars'])) |
|
| 1950 | - $context['javascript_vars'] = array(); |
|
| 2050 | + if (!isset($context['html_headers'])) { |
|
| 2051 | + $context['html_headers'] = ''; |
|
| 2052 | + } |
|
| 2053 | + if (!isset($context['javascript_files'])) { |
|
| 2054 | + $context['javascript_files'] = array(); |
|
| 2055 | + } |
|
| 2056 | + if (!isset($context['css_files'])) { |
|
| 2057 | + $context['css_files'] = array(); |
|
| 2058 | + } |
|
| 2059 | + if (!isset($context['css_header'])) { |
|
| 2060 | + $context['css_header'] = array(); |
|
| 2061 | + } |
|
| 2062 | + if (!isset($context['javascript_inline'])) { |
|
| 2063 | + $context['javascript_inline'] = array('standard' => array(), 'defer' => array()); |
|
| 2064 | + } |
|
| 2065 | + if (!isset($context['javascript_vars'])) { |
|
| 2066 | + $context['javascript_vars'] = array(); |
|
| 2067 | + } |
|
| 1951 | 2068 | |
| 1952 | 2069 | $context['login_url'] = (!empty($modSettings['force_ssl']) && $modSettings['force_ssl'] < 2 ? strtr($scripturl, array('http://' => 'https://')) : $scripturl) . '?action=login2'; |
| 1953 | 2070 | $context['menu_separator'] = !empty($settings['use_image_buttons']) ? ' ' : ' | '; |
@@ -1959,8 +2076,9 @@ discard block |
||
| 1959 | 2076 | $context['current_action'] = isset($_REQUEST['action']) ? $smcFunc['htmlspecialchars']($_REQUEST['action']) : null; |
| 1960 | 2077 | $context['current_subaction'] = isset($_REQUEST['sa']) ? $_REQUEST['sa'] : null; |
| 1961 | 2078 | $context['can_register'] = empty($modSettings['registration_method']) || $modSettings['registration_method'] != 3; |
| 1962 | - if (isset($modSettings['load_average'])) |
|
| 1963 | - $context['load_average'] = $modSettings['load_average']; |
|
| 2079 | + if (isset($modSettings['load_average'])) { |
|
| 2080 | + $context['load_average'] = $modSettings['load_average']; |
|
| 2081 | + } |
|
| 1964 | 2082 | |
| 1965 | 2083 | // Detect the browser. This is separated out because it's also used in attachment downloads |
| 1966 | 2084 | detectBrowser(); |
@@ -1974,8 +2092,9 @@ discard block |
||
| 1974 | 2092 | // This allows sticking some HTML on the page output - useful for controls. |
| 1975 | 2093 | $context['insert_after_template'] = ''; |
| 1976 | 2094 | |
| 1977 | - if (!isset($txt)) |
|
| 1978 | - $txt = array(); |
|
| 2095 | + if (!isset($txt)) { |
|
| 2096 | + $txt = array(); |
|
| 2097 | + } |
|
| 1979 | 2098 | |
| 1980 | 2099 | $simpleActions = array( |
| 1981 | 2100 | 'findmember', |
@@ -2021,9 +2140,10 @@ discard block |
||
| 2021 | 2140 | |
| 2022 | 2141 | // See if theres any extra param to check. |
| 2023 | 2142 | $requiresXML = false; |
| 2024 | - foreach ($extraParams as $key => $extra) |
|
| 2025 | - if (isset($_REQUEST[$extra])) |
|
| 2143 | + foreach ($extraParams as $key => $extra) { |
|
| 2144 | + if (isset($_REQUEST[$extra])) |
|
| 2026 | 2145 | $requiresXML = true; |
| 2146 | + } |
|
| 2027 | 2147 | |
| 2028 | 2148 | // Output is fully XML, so no need for the index template. |
| 2029 | 2149 | if (isset($_REQUEST['xml']) && (in_array($context['current_action'], $xmlActions) || $requiresXML)) |
@@ -2038,37 +2158,39 @@ discard block |
||
| 2038 | 2158 | { |
| 2039 | 2159 | loadLanguage('index+Modifications'); |
| 2040 | 2160 | $context['template_layers'] = array(); |
| 2041 | - } |
|
| 2042 | - |
|
| 2043 | - else |
|
| 2161 | + } else |
|
| 2044 | 2162 | { |
| 2045 | 2163 | // Custom templates to load, or just default? |
| 2046 | - if (isset($settings['theme_templates'])) |
|
| 2047 | - $templates = explode(',', $settings['theme_templates']); |
|
| 2048 | - else |
|
| 2049 | - $templates = array('index'); |
|
| 2164 | + if (isset($settings['theme_templates'])) { |
|
| 2165 | + $templates = explode(',', $settings['theme_templates']); |
|
| 2166 | + } else { |
|
| 2167 | + $templates = array('index'); |
|
| 2168 | + } |
|
| 2050 | 2169 | |
| 2051 | 2170 | // Load each template... |
| 2052 | - foreach ($templates as $template) |
|
| 2053 | - loadTemplate($template); |
|
| 2171 | + foreach ($templates as $template) { |
|
| 2172 | + loadTemplate($template); |
|
| 2173 | + } |
|
| 2054 | 2174 | |
| 2055 | 2175 | // ...and attempt to load their associated language files. |
| 2056 | 2176 | $required_files = implode('+', array_merge($templates, array('Modifications'))); |
| 2057 | 2177 | loadLanguage($required_files, '', false); |
| 2058 | 2178 | |
| 2059 | 2179 | // Custom template layers? |
| 2060 | - if (isset($settings['theme_layers'])) |
|
| 2061 | - $context['template_layers'] = explode(',', $settings['theme_layers']); |
|
| 2062 | - else |
|
| 2063 | - $context['template_layers'] = array('html', 'body'); |
|
| 2180 | + if (isset($settings['theme_layers'])) { |
|
| 2181 | + $context['template_layers'] = explode(',', $settings['theme_layers']); |
|
| 2182 | + } else { |
|
| 2183 | + $context['template_layers'] = array('html', 'body'); |
|
| 2184 | + } |
|
| 2064 | 2185 | } |
| 2065 | 2186 | |
| 2066 | 2187 | // Initialize the theme. |
| 2067 | 2188 | loadSubTemplate('init', 'ignore'); |
| 2068 | 2189 | |
| 2069 | 2190 | // Allow overriding the board wide time/number formats. |
| 2070 | - if (empty($user_settings['time_format']) && !empty($txt['time_format'])) |
|
| 2071 | - $user_info['time_format'] = $txt['time_format']; |
|
| 2191 | + if (empty($user_settings['time_format']) && !empty($txt['time_format'])) { |
|
| 2192 | + $user_info['time_format'] = $txt['time_format']; |
|
| 2193 | + } |
|
| 2072 | 2194 | |
| 2073 | 2195 | // Set the character set from the template. |
| 2074 | 2196 | $context['character_set'] = empty($modSettings['global_character_set']) ? $txt['lang_character_set'] : $modSettings['global_character_set']; |
@@ -2076,12 +2198,14 @@ discard block |
||
| 2076 | 2198 | $context['right_to_left'] = !empty($txt['lang_rtl']); |
| 2077 | 2199 | |
| 2078 | 2200 | // Guests may still need a name. |
| 2079 | - if ($context['user']['is_guest'] && empty($context['user']['name'])) |
|
| 2080 | - $context['user']['name'] = $txt['guest_title']; |
|
| 2201 | + if ($context['user']['is_guest'] && empty($context['user']['name'])) { |
|
| 2202 | + $context['user']['name'] = $txt['guest_title']; |
|
| 2203 | + } |
|
| 2081 | 2204 | |
| 2082 | 2205 | // Any theme-related strings that need to be loaded? |
| 2083 | - if (!empty($settings['require_theme_strings'])) |
|
| 2084 | - loadLanguage('ThemeStrings', '', false); |
|
| 2206 | + if (!empty($settings['require_theme_strings'])) { |
|
| 2207 | + loadLanguage('ThemeStrings', '', false); |
|
| 2208 | + } |
|
| 2085 | 2209 | |
| 2086 | 2210 | // Make a special URL for the language. |
| 2087 | 2211 | $settings['lang_images_url'] = $settings['images_url'] . '/' . (!empty($txt['image_lang']) ? $txt['image_lang'] : $user_info['language']); |
@@ -2092,8 +2216,9 @@ discard block |
||
| 2092 | 2216 | // Here is my luvly Responsive CSS |
| 2093 | 2217 | loadCSSFile('responsive.css', array('force_current' => false, 'validate' => true, 'minimize' => true), 'smf_responsive'); |
| 2094 | 2218 | |
| 2095 | - if ($context['right_to_left']) |
|
| 2096 | - loadCSSFile('rtl.css', array(), 'smf_rtl'); |
|
| 2219 | + if ($context['right_to_left']) { |
|
| 2220 | + loadCSSFile('rtl.css', array(), 'smf_rtl'); |
|
| 2221 | + } |
|
| 2097 | 2222 | |
| 2098 | 2223 | // We allow theme variants, because we're cool. |
| 2099 | 2224 | $context['theme_variant'] = ''; |
@@ -2101,14 +2226,17 @@ discard block |
||
| 2101 | 2226 | if (!empty($settings['theme_variants'])) |
| 2102 | 2227 | { |
| 2103 | 2228 | // Overriding - for previews and that ilk. |
| 2104 | - if (!empty($_REQUEST['variant'])) |
|
| 2105 | - $_SESSION['id_variant'] = $_REQUEST['variant']; |
|
| 2229 | + if (!empty($_REQUEST['variant'])) { |
|
| 2230 | + $_SESSION['id_variant'] = $_REQUEST['variant']; |
|
| 2231 | + } |
|
| 2106 | 2232 | // User selection? |
| 2107 | - if (empty($settings['disable_user_variant']) || allowedTo('admin_forum')) |
|
| 2108 | - $context['theme_variant'] = !empty($_SESSION['id_variant']) ? $_SESSION['id_variant'] : (!empty($options['theme_variant']) ? $options['theme_variant'] : ''); |
|
| 2233 | + if (empty($settings['disable_user_variant']) || allowedTo('admin_forum')) { |
|
| 2234 | + $context['theme_variant'] = !empty($_SESSION['id_variant']) ? $_SESSION['id_variant'] : (!empty($options['theme_variant']) ? $options['theme_variant'] : ''); |
|
| 2235 | + } |
|
| 2109 | 2236 | // If not a user variant, select the default. |
| 2110 | - if ($context['theme_variant'] == '' || !in_array($context['theme_variant'], $settings['theme_variants'])) |
|
| 2111 | - $context['theme_variant'] = !empty($settings['default_variant']) && in_array($settings['default_variant'], $settings['theme_variants']) ? $settings['default_variant'] : $settings['theme_variants'][0]; |
|
| 2237 | + if ($context['theme_variant'] == '' || !in_array($context['theme_variant'], $settings['theme_variants'])) { |
|
| 2238 | + $context['theme_variant'] = !empty($settings['default_variant']) && in_array($settings['default_variant'], $settings['theme_variants']) ? $settings['default_variant'] : $settings['theme_variants'][0]; |
|
| 2239 | + } |
|
| 2112 | 2240 | |
| 2113 | 2241 | // Do this to keep things easier in the templates. |
| 2114 | 2242 | $context['theme_variant'] = '_' . $context['theme_variant']; |
@@ -2117,20 +2245,23 @@ discard block |
||
| 2117 | 2245 | if (!empty($context['theme_variant'])) |
| 2118 | 2246 | { |
| 2119 | 2247 | loadCSSFile('index' . $context['theme_variant'] . '.css', array(), 'smf_index' . $context['theme_variant']); |
| 2120 | - if ($context['right_to_left']) |
|
| 2121 | - loadCSSFile('rtl' . $context['theme_variant'] . '.css', array(), 'smf_rtl' . $context['theme_variant']); |
|
| 2248 | + if ($context['right_to_left']) { |
|
| 2249 | + loadCSSFile('rtl' . $context['theme_variant'] . '.css', array(), 'smf_rtl' . $context['theme_variant']); |
|
| 2250 | + } |
|
| 2122 | 2251 | } |
| 2123 | 2252 | } |
| 2124 | 2253 | |
| 2125 | 2254 | // Let's be compatible with old themes! |
| 2126 | - if (!function_exists('template_html_above') && in_array('html', $context['template_layers'])) |
|
| 2127 | - $context['template_layers'] = array('main'); |
|
| 2255 | + if (!function_exists('template_html_above') && in_array('html', $context['template_layers'])) { |
|
| 2256 | + $context['template_layers'] = array('main'); |
|
| 2257 | + } |
|
| 2128 | 2258 | |
| 2129 | 2259 | $context['tabindex'] = 1; |
| 2130 | 2260 | |
| 2131 | 2261 | // Compatibility. |
| 2132 | - if (!isset($settings['theme_version'])) |
|
| 2133 | - $modSettings['memberCount'] = $modSettings['totalMembers']; |
|
| 2262 | + if (!isset($settings['theme_version'])) { |
|
| 2263 | + $modSettings['memberCount'] = $modSettings['totalMembers']; |
|
| 2264 | + } |
|
| 2134 | 2265 | |
| 2135 | 2266 | // Default JS variables for use in every theme |
| 2136 | 2267 | $context['javascript_vars'] = array( |
@@ -2149,18 +2280,18 @@ discard block |
||
| 2149 | 2280 | ); |
| 2150 | 2281 | |
| 2151 | 2282 | // Add the JQuery library to the list of files to load. |
| 2152 | - if (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'cdn') |
|
| 2153 | - loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js', array('external' => true), 'smf_jquery'); |
|
| 2154 | - |
|
| 2155 | - elseif (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'local') |
|
| 2156 | - loadJavaScriptFile('jquery-2.1.4.min.js', array('seed' => false), 'smf_jquery'); |
|
| 2157 | - |
|
| 2158 | - elseif (isset($modSettings['jquery_source'], $modSettings['jquery_custom']) && $modSettings['jquery_source'] == 'custom') |
|
| 2159 | - loadJavaScriptFile($modSettings['jquery_custom'], array(), 'smf_jquery'); |
|
| 2283 | + if (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'cdn') { |
|
| 2284 | + loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js', array('external' => true), 'smf_jquery'); |
|
| 2285 | + } elseif (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'local') { |
|
| 2286 | + loadJavaScriptFile('jquery-2.1.4.min.js', array('seed' => false), 'smf_jquery'); |
|
| 2287 | + } elseif (isset($modSettings['jquery_source'], $modSettings['jquery_custom']) && $modSettings['jquery_source'] == 'custom') { |
|
| 2288 | + loadJavaScriptFile($modSettings['jquery_custom'], array(), 'smf_jquery'); |
|
| 2289 | + } |
|
| 2160 | 2290 | |
| 2161 | 2291 | // Auto loading? template_javascript() will take care of the local half of this. |
| 2162 | - else |
|
| 2163 | - loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js', array('external' => true), 'smf_jquery'); |
|
| 2292 | + else { |
|
| 2293 | + loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js', array('external' => true), 'smf_jquery'); |
|
| 2294 | + } |
|
| 2164 | 2295 | |
| 2165 | 2296 | // Queue our JQuery plugins! |
| 2166 | 2297 | loadJavaScriptFile('smf_jquery_plugins.js', array('minimize' => true), 'smf_jquery_plugins'); |
@@ -2183,12 +2314,12 @@ discard block |
||
| 2183 | 2314 | require_once($sourcedir . '/ScheduledTasks.php'); |
| 2184 | 2315 | |
| 2185 | 2316 | // What to do, what to do?! |
| 2186 | - if (empty($modSettings['next_task_time']) || $modSettings['next_task_time'] < time()) |
|
| 2187 | - AutoTask(); |
|
| 2188 | - else |
|
| 2189 | - ReduceMailQueue(); |
|
| 2190 | - } |
|
| 2191 | - else |
|
| 2317 | + if (empty($modSettings['next_task_time']) || $modSettings['next_task_time'] < time()) { |
|
| 2318 | + AutoTask(); |
|
| 2319 | + } else { |
|
| 2320 | + ReduceMailQueue(); |
|
| 2321 | + } |
|
| 2322 | + } else |
|
| 2192 | 2323 | { |
| 2193 | 2324 | $type = empty($modSettings['next_task_time']) || $modSettings['next_task_time'] < time() ? 'task' : 'mailq'; |
| 2194 | 2325 | $ts = $type == 'mailq' ? $modSettings['mail_next_send'] : $modSettings['next_task_time']; |
@@ -2239,8 +2370,9 @@ discard block |
||
| 2239 | 2370 | foreach ($theme_includes as $include) |
| 2240 | 2371 | { |
| 2241 | 2372 | $include = strtr(trim($include), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir'])); |
| 2242 | - if (file_exists($include)) |
|
| 2243 | - require_once($include); |
|
| 2373 | + if (file_exists($include)) { |
|
| 2374 | + require_once($include); |
|
| 2375 | + } |
|
| 2244 | 2376 | } |
| 2245 | 2377 | } |
| 2246 | 2378 | |
@@ -2270,16 +2402,19 @@ discard block |
||
| 2270 | 2402 | // Do any style sheets first, cause we're easy with those. |
| 2271 | 2403 | if (!empty($style_sheets)) |
| 2272 | 2404 | { |
| 2273 | - if (!is_array($style_sheets)) |
|
| 2274 | - $style_sheets = array($style_sheets); |
|
| 2405 | + if (!is_array($style_sheets)) { |
|
| 2406 | + $style_sheets = array($style_sheets); |
|
| 2407 | + } |
|
| 2275 | 2408 | |
| 2276 | - foreach ($style_sheets as $sheet) |
|
| 2277 | - loadCSSFile($sheet . '.css', array(), $sheet); |
|
| 2409 | + foreach ($style_sheets as $sheet) { |
|
| 2410 | + loadCSSFile($sheet . '.css', array(), $sheet); |
|
| 2411 | + } |
|
| 2278 | 2412 | } |
| 2279 | 2413 | |
| 2280 | 2414 | // No template to load? |
| 2281 | - if ($template_name === false) |
|
| 2282 | - return true; |
|
| 2415 | + if ($template_name === false) { |
|
| 2416 | + return true; |
|
| 2417 | + } |
|
| 2283 | 2418 | |
| 2284 | 2419 | $loaded = false; |
| 2285 | 2420 | foreach ($settings['template_dirs'] as $template_dir) |
@@ -2294,12 +2429,14 @@ discard block |
||
| 2294 | 2429 | |
| 2295 | 2430 | if ($loaded) |
| 2296 | 2431 | { |
| 2297 | - if ($db_show_debug === true) |
|
| 2298 | - $context['debug']['templates'][] = $template_name . ' (' . basename($template_dir) . ')'; |
|
| 2432 | + if ($db_show_debug === true) { |
|
| 2433 | + $context['debug']['templates'][] = $template_name . ' (' . basename($template_dir) . ')'; |
|
| 2434 | + } |
|
| 2299 | 2435 | |
| 2300 | 2436 | // If they have specified an initialization function for this template, go ahead and call it now. |
| 2301 | - if (function_exists('template_' . $template_name . '_init')) |
|
| 2302 | - call_user_func('template_' . $template_name . '_init'); |
|
| 2437 | + if (function_exists('template_' . $template_name . '_init')) { |
|
| 2438 | + call_user_func('template_' . $template_name . '_init'); |
|
| 2439 | + } |
|
| 2303 | 2440 | } |
| 2304 | 2441 | // Hmmm... doesn't exist?! I don't suppose the directory is wrong, is it? |
| 2305 | 2442 | elseif (!file_exists($settings['default_theme_dir']) && file_exists($boarddir . '/Themes/default')) |
@@ -2319,13 +2456,14 @@ discard block |
||
| 2319 | 2456 | loadTemplate($template_name); |
| 2320 | 2457 | } |
| 2321 | 2458 | // Cause an error otherwise. |
| 2322 | - elseif ($template_name != 'Errors' && $template_name != 'index' && $fatal) |
|
| 2323 | - fatal_lang_error('theme_template_error', 'template', array((string) $template_name)); |
|
| 2324 | - elseif ($fatal) |
|
| 2325 | - die(log_error(sprintf(isset($txt['theme_template_error']) ? $txt['theme_template_error'] : 'Unable to load Themes/default/%s.template.php!', (string) $template_name), 'template')); |
|
| 2326 | - else |
|
| 2327 | - return false; |
|
| 2328 | -} |
|
| 2459 | + elseif ($template_name != 'Errors' && $template_name != 'index' && $fatal) { |
|
| 2460 | + fatal_lang_error('theme_template_error', 'template', array((string) $template_name)); |
|
| 2461 | + } elseif ($fatal) { |
|
| 2462 | + die(log_error(sprintf(isset($txt['theme_template_error']) ? $txt['theme_template_error'] : 'Unable to load Themes/default/%s.template.php!', (string) $template_name), 'template')); |
|
| 2463 | + } else { |
|
| 2464 | + return false; |
|
| 2465 | + } |
|
| 2466 | + } |
|
| 2329 | 2467 | |
| 2330 | 2468 | /** |
| 2331 | 2469 | * Load a sub-template. |
@@ -2343,17 +2481,19 @@ discard block |
||
| 2343 | 2481 | { |
| 2344 | 2482 | global $context, $txt, $db_show_debug; |
| 2345 | 2483 | |
| 2346 | - if ($db_show_debug === true) |
|
| 2347 | - $context['debug']['sub_templates'][] = $sub_template_name; |
|
| 2484 | + if ($db_show_debug === true) { |
|
| 2485 | + $context['debug']['sub_templates'][] = $sub_template_name; |
|
| 2486 | + } |
|
| 2348 | 2487 | |
| 2349 | 2488 | // Figure out what the template function is named. |
| 2350 | 2489 | $theme_function = 'template_' . $sub_template_name; |
| 2351 | - if (function_exists($theme_function)) |
|
| 2352 | - $theme_function(); |
|
| 2353 | - elseif ($fatal === false) |
|
| 2354 | - fatal_lang_error('theme_template_error', 'template', array((string) $sub_template_name)); |
|
| 2355 | - elseif ($fatal !== 'ignore') |
|
| 2356 | - die(log_error(sprintf(isset($txt['theme_template_error']) ? $txt['theme_template_error'] : 'Unable to load the %s sub template!', (string) $sub_template_name), 'template')); |
|
| 2490 | + if (function_exists($theme_function)) { |
|
| 2491 | + $theme_function(); |
|
| 2492 | + } elseif ($fatal === false) { |
|
| 2493 | + fatal_lang_error('theme_template_error', 'template', array((string) $sub_template_name)); |
|
| 2494 | + } elseif ($fatal !== 'ignore') { |
|
| 2495 | + die(log_error(sprintf(isset($txt['theme_template_error']) ? $txt['theme_template_error'] : 'Unable to load the %s sub template!', (string) $sub_template_name), 'template')); |
|
| 2496 | + } |
|
| 2357 | 2497 | |
| 2358 | 2498 | // Are we showing debugging for templates? Just make sure not to do it before the doctype... |
| 2359 | 2499 | if (allowedTo('admin_forum') && isset($_REQUEST['debug']) && !in_array($sub_template_name, array('init', 'main_below')) && ob_get_length() > 0 && !isset($_REQUEST['xml'])) |
@@ -2390,8 +2530,9 @@ discard block |
||
| 2390 | 2530 | $params['validate'] = isset($params['validate']) ? $params['validate'] : true; |
| 2391 | 2531 | |
| 2392 | 2532 | // If this is an external file, automatically set this to false. |
| 2393 | - if (!empty($params['external'])) |
|
| 2394 | - $params['minimize'] = false; |
|
| 2533 | + if (!empty($params['external'])) { |
|
| 2534 | + $params['minimize'] = false; |
|
| 2535 | + } |
|
| 2395 | 2536 | |
| 2396 | 2537 | // Account for shorthand like admin.css?alp21 filenames |
| 2397 | 2538 | $has_seed = strpos($fileName, '.css?'); |
@@ -2408,13 +2549,10 @@ discard block |
||
| 2408 | 2549 | { |
| 2409 | 2550 | $fileUrl = $settings['default_theme_url'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']); |
| 2410 | 2551 | $filePath = $settings['default_theme_dir'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']); |
| 2552 | + } else { |
|
| 2553 | + $fileUrl = false; |
|
| 2411 | 2554 | } |
| 2412 | - |
|
| 2413 | - else |
|
| 2414 | - $fileUrl = false; |
|
| 2415 | - } |
|
| 2416 | - |
|
| 2417 | - else |
|
| 2555 | + } else |
|
| 2418 | 2556 | { |
| 2419 | 2557 | $fileUrl = $settings[$themeRef . '_url'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']); |
| 2420 | 2558 | $filePath = $settings[$themeRef . '_dir'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']); |
@@ -2429,12 +2567,14 @@ discard block |
||
| 2429 | 2567 | } |
| 2430 | 2568 | |
| 2431 | 2569 | // Add it to the array for use in the template |
| 2432 | - if (!empty($fileName)) |
|
| 2433 | - $context['css_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params); |
|
| 2570 | + if (!empty($fileName)) { |
|
| 2571 | + $context['css_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params); |
|
| 2572 | + } |
|
| 2434 | 2573 | |
| 2435 | - if (!empty($context['right_to_left']) && !empty($params['rtl'])) |
|
| 2436 | - loadCSSFile($params['rtl'], array_diff_key($params, array('rtl' => 0))); |
|
| 2437 | -} |
|
| 2574 | + if (!empty($context['right_to_left']) && !empty($params['rtl'])) { |
|
| 2575 | + loadCSSFile($params['rtl'], array_diff_key($params, array('rtl' => 0))); |
|
| 2576 | + } |
|
| 2577 | + } |
|
| 2438 | 2578 | |
| 2439 | 2579 | /** |
| 2440 | 2580 | * Add a block of inline css code to be executed later |
@@ -2451,8 +2591,9 @@ discard block |
||
| 2451 | 2591 | global $context; |
| 2452 | 2592 | |
| 2453 | 2593 | // Gotta add something... |
| 2454 | - if (empty($css)) |
|
| 2455 | - return false; |
|
| 2594 | + if (empty($css)) { |
|
| 2595 | + return false; |
|
| 2596 | + } |
|
| 2456 | 2597 | |
| 2457 | 2598 | $context['css_header'][] = $css; |
| 2458 | 2599 | } |
@@ -2487,8 +2628,9 @@ discard block |
||
| 2487 | 2628 | $params['validate'] = isset($params['validate']) ? $params['validate'] : true; |
| 2488 | 2629 | |
| 2489 | 2630 | // If this is an external file, automatically set this to false. |
| 2490 | - if (!empty($params['external'])) |
|
| 2491 | - $params['minimize'] = false; |
|
| 2631 | + if (!empty($params['external'])) { |
|
| 2632 | + $params['minimize'] = false; |
|
| 2633 | + } |
|
| 2492 | 2634 | |
| 2493 | 2635 | // Account for shorthand like admin.js?alp21 filenames |
| 2494 | 2636 | $has_seed = strpos($fileName, '.js?'); |
@@ -2505,16 +2647,12 @@ discard block |
||
| 2505 | 2647 | { |
| 2506 | 2648 | $fileUrl = $settings['default_theme_url'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']); |
| 2507 | 2649 | $filePath = $settings['default_theme_dir'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']); |
| 2508 | - } |
|
| 2509 | - |
|
| 2510 | - else |
|
| 2650 | + } else |
|
| 2511 | 2651 | { |
| 2512 | 2652 | $fileUrl = false; |
| 2513 | 2653 | $filePath = false; |
| 2514 | 2654 | } |
| 2515 | - } |
|
| 2516 | - |
|
| 2517 | - else |
|
| 2655 | + } else |
|
| 2518 | 2656 | { |
| 2519 | 2657 | $fileUrl = $settings[$themeRef . '_url'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']); |
| 2520 | 2658 | $filePath = $settings[$themeRef . '_dir'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']); |
@@ -2529,9 +2667,10 @@ discard block |
||
| 2529 | 2667 | } |
| 2530 | 2668 | |
| 2531 | 2669 | // Add it to the array for use in the template |
| 2532 | - if (!empty($fileName)) |
|
| 2533 | - $context['javascript_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params); |
|
| 2534 | -} |
|
| 2670 | + if (!empty($fileName)) { |
|
| 2671 | + $context['javascript_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params); |
|
| 2672 | + } |
|
| 2673 | + } |
|
| 2535 | 2674 | |
| 2536 | 2675 | /** |
| 2537 | 2676 | * Add a Javascript variable for output later (for feeding text strings and similar to JS) |
@@ -2545,9 +2684,10 @@ discard block |
||
| 2545 | 2684 | { |
| 2546 | 2685 | global $context; |
| 2547 | 2686 | |
| 2548 | - if (!empty($key) && (!empty($value) || $value === '0')) |
|
| 2549 | - $context['javascript_vars'][$key] = !empty($escape) ? JavaScriptEscape($value) : $value; |
|
| 2550 | -} |
|
| 2687 | + if (!empty($key) && (!empty($value) || $value === '0')) { |
|
| 2688 | + $context['javascript_vars'][$key] = !empty($escape) ? JavaScriptEscape($value) : $value; |
|
| 2689 | + } |
|
| 2690 | + } |
|
| 2551 | 2691 | |
| 2552 | 2692 | /** |
| 2553 | 2693 | * Add a block of inline Javascript code to be executed later |
@@ -2564,8 +2704,9 @@ discard block |
||
| 2564 | 2704 | { |
| 2565 | 2705 | global $context; |
| 2566 | 2706 | |
| 2567 | - if (empty($javascript)) |
|
| 2568 | - return false; |
|
| 2707 | + if (empty($javascript)) { |
|
| 2708 | + return false; |
|
| 2709 | + } |
|
| 2569 | 2710 | |
| 2570 | 2711 | $context['javascript_inline'][($defer === true ? 'defer' : 'standard')][] = $javascript; |
| 2571 | 2712 | } |
@@ -2586,15 +2727,18 @@ discard block |
||
| 2586 | 2727 | static $already_loaded = array(); |
| 2587 | 2728 | |
| 2588 | 2729 | // Default to the user's language. |
| 2589 | - if ($lang == '') |
|
| 2590 | - $lang = isset($user_info['language']) ? $user_info['language'] : $language; |
|
| 2730 | + if ($lang == '') { |
|
| 2731 | + $lang = isset($user_info['language']) ? $user_info['language'] : $language; |
|
| 2732 | + } |
|
| 2591 | 2733 | |
| 2592 | 2734 | // Do we want the English version of language file as fallback? |
| 2593 | - if (empty($modSettings['disable_language_fallback']) && $lang != 'english') |
|
| 2594 | - loadLanguage($template_name, 'english', false); |
|
| 2735 | + if (empty($modSettings['disable_language_fallback']) && $lang != 'english') { |
|
| 2736 | + loadLanguage($template_name, 'english', false); |
|
| 2737 | + } |
|
| 2595 | 2738 | |
| 2596 | - if (!$force_reload && isset($already_loaded[$template_name]) && $already_loaded[$template_name] == $lang) |
|
| 2597 | - return $lang; |
|
| 2739 | + if (!$force_reload && isset($already_loaded[$template_name]) && $already_loaded[$template_name] == $lang) { |
|
| 2740 | + return $lang; |
|
| 2741 | + } |
|
| 2598 | 2742 | |
| 2599 | 2743 | // Make sure we have $settings - if not we're in trouble and need to find it! |
| 2600 | 2744 | if (empty($settings['default_theme_dir'])) |
@@ -2605,8 +2749,9 @@ discard block |
||
| 2605 | 2749 | |
| 2606 | 2750 | // What theme are we in? |
| 2607 | 2751 | $theme_name = basename($settings['theme_url']); |
| 2608 | - if (empty($theme_name)) |
|
| 2609 | - $theme_name = 'unknown'; |
|
| 2752 | + if (empty($theme_name)) { |
|
| 2753 | + $theme_name = 'unknown'; |
|
| 2754 | + } |
|
| 2610 | 2755 | |
| 2611 | 2756 | // For each file open it up and write it out! |
| 2612 | 2757 | foreach (explode('+', $template_name) as $template) |
@@ -2685,8 +2830,9 @@ discard block |
||
| 2685 | 2830 | } |
| 2686 | 2831 | |
| 2687 | 2832 | // Keep track of what we're up to soldier. |
| 2688 | - if ($db_show_debug === true) |
|
| 2689 | - $context['debug']['language_files'][] = $template_name . '.' . $lang . ' (' . $theme_name . ')'; |
|
| 2833 | + if ($db_show_debug === true) { |
|
| 2834 | + $context['debug']['language_files'][] = $template_name . '.' . $lang . ' (' . $theme_name . ')'; |
|
| 2835 | + } |
|
| 2690 | 2836 | |
| 2691 | 2837 | // Remember what we have loaded, and in which language. |
| 2692 | 2838 | $already_loaded[$template_name] = $lang; |
@@ -2732,8 +2878,9 @@ discard block |
||
| 2732 | 2878 | ) |
| 2733 | 2879 | ); |
| 2734 | 2880 | // In the EXTREMELY unlikely event this happens, give an error message. |
| 2735 | - if ($smcFunc['db_num_rows']($result) == 0) |
|
| 2736 | - fatal_lang_error('parent_not_found', 'critical'); |
|
| 2881 | + if ($smcFunc['db_num_rows']($result) == 0) { |
|
| 2882 | + fatal_lang_error('parent_not_found', 'critical'); |
|
| 2883 | + } |
|
| 2737 | 2884 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 2738 | 2885 | { |
| 2739 | 2886 | if (!isset($boards[$row['id_board']])) |
@@ -2750,8 +2897,8 @@ discard block |
||
| 2750 | 2897 | ); |
| 2751 | 2898 | } |
| 2752 | 2899 | // If a moderator exists for this board, add that moderator for all children too. |
| 2753 | - if (!empty($row['id_moderator'])) |
|
| 2754 | - foreach ($boards as $id => $dummy) |
|
| 2900 | + if (!empty($row['id_moderator'])) { |
|
| 2901 | + foreach ($boards as $id => $dummy) |
|
| 2755 | 2902 | { |
| 2756 | 2903 | $boards[$id]['moderators'][$row['id_moderator']] = array( |
| 2757 | 2904 | 'id' => $row['id_moderator'], |
@@ -2759,11 +2906,12 @@ discard block |
||
| 2759 | 2906 | 'href' => $scripturl . '?action=profile;u=' . $row['id_moderator'], |
| 2760 | 2907 | 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_moderator'] . '">' . $row['real_name'] . '</a>' |
| 2761 | 2908 | ); |
| 2909 | + } |
|
| 2762 | 2910 | } |
| 2763 | 2911 | |
| 2764 | 2912 | // If a moderator group exists for this board, add that moderator group for all children too |
| 2765 | - if (!empty($row['id_moderator_group'])) |
|
| 2766 | - foreach ($boards as $id => $dummy) |
|
| 2913 | + if (!empty($row['id_moderator_group'])) { |
|
| 2914 | + foreach ($boards as $id => $dummy) |
|
| 2767 | 2915 | { |
| 2768 | 2916 | $boards[$id]['moderator_groups'][$row['id_moderator_group']] = array( |
| 2769 | 2917 | 'id' => $row['id_moderator_group'], |
@@ -2771,6 +2919,7 @@ discard block |
||
| 2771 | 2919 | 'href' => $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'], |
| 2772 | 2920 | 'link' => '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'] . '">' . $row['group_name'] . '</a>' |
| 2773 | 2921 | ); |
| 2922 | + } |
|
| 2774 | 2923 | } |
| 2775 | 2924 | } |
| 2776 | 2925 | $smcFunc['db_free_result']($result); |
@@ -2798,23 +2947,27 @@ discard block |
||
| 2798 | 2947 | if (!$use_cache || ($context['languages'] = cache_get_data('known_languages' . ($favor_utf8 ? '' : '_all'), !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600)) == null) |
| 2799 | 2948 | { |
| 2800 | 2949 | // If we don't have our ucwords function defined yet, let's load the settings data. |
| 2801 | - if (empty($smcFunc['ucwords'])) |
|
| 2802 | - reloadSettings(); |
|
| 2950 | + if (empty($smcFunc['ucwords'])) { |
|
| 2951 | + reloadSettings(); |
|
| 2952 | + } |
|
| 2803 | 2953 | |
| 2804 | 2954 | // If we don't have our theme information yet, let's get it. |
| 2805 | - if (empty($settings['default_theme_dir'])) |
|
| 2806 | - loadTheme(0, false); |
|
| 2955 | + if (empty($settings['default_theme_dir'])) { |
|
| 2956 | + loadTheme(0, false); |
|
| 2957 | + } |
|
| 2807 | 2958 | |
| 2808 | 2959 | // Default language directories to try. |
| 2809 | 2960 | $language_directories = array( |
| 2810 | 2961 | $settings['default_theme_dir'] . '/languages', |
| 2811 | 2962 | ); |
| 2812 | - if (!empty($settings['actual_theme_dir']) && $settings['actual_theme_dir'] != $settings['default_theme_dir']) |
|
| 2813 | - $language_directories[] = $settings['actual_theme_dir'] . '/languages'; |
|
| 2963 | + if (!empty($settings['actual_theme_dir']) && $settings['actual_theme_dir'] != $settings['default_theme_dir']) { |
|
| 2964 | + $language_directories[] = $settings['actual_theme_dir'] . '/languages'; |
|
| 2965 | + } |
|
| 2814 | 2966 | |
| 2815 | 2967 | // We possibly have a base theme directory. |
| 2816 | - if (!empty($settings['base_theme_dir'])) |
|
| 2817 | - $language_directories[] = $settings['base_theme_dir'] . '/languages'; |
|
| 2968 | + if (!empty($settings['base_theme_dir'])) { |
|
| 2969 | + $language_directories[] = $settings['base_theme_dir'] . '/languages'; |
|
| 2970 | + } |
|
| 2818 | 2971 | |
| 2819 | 2972 | // Remove any duplicates. |
| 2820 | 2973 | $language_directories = array_unique($language_directories); |
@@ -2828,20 +2981,21 @@ discard block |
||
| 2828 | 2981 | foreach ($language_directories as $language_dir) |
| 2829 | 2982 | { |
| 2830 | 2983 | // Can't look in here... doesn't exist! |
| 2831 | - if (!file_exists($language_dir)) |
|
| 2832 | - continue; |
|
| 2984 | + if (!file_exists($language_dir)) { |
|
| 2985 | + continue; |
|
| 2986 | + } |
|
| 2833 | 2987 | |
| 2834 | 2988 | $dir = dir($language_dir); |
| 2835 | 2989 | while ($entry = $dir->read()) |
| 2836 | 2990 | { |
| 2837 | 2991 | // Look for the index language file.... |
| 2838 | - if (!preg_match('~^index\.(.+)\.php$~', $entry, $matches)) |
|
| 2839 | - continue; |
|
| 2840 | - |
|
| 2841 | - if (!empty($langList) && !empty($langList[$matches[1]])) |
|
| 2842 | - $langName = $langList[$matches[1]]; |
|
| 2992 | + if (!preg_match('~^index\.(.+)\.php$~', $entry, $matches)) { |
|
| 2993 | + continue; |
|
| 2994 | + } |
|
| 2843 | 2995 | |
| 2844 | - else |
|
| 2996 | + if (!empty($langList) && !empty($langList[$matches[1]])) { |
|
| 2997 | + $langName = $langList[$matches[1]]; |
|
| 2998 | + } else |
|
| 2845 | 2999 | { |
| 2846 | 3000 | $langName = $smcFunc['ucwords'](strtr($matches[1], array('_' => ' '))); |
| 2847 | 3001 | |
@@ -2882,20 +3036,23 @@ discard block |
||
| 2882 | 3036 | } |
| 2883 | 3037 | |
| 2884 | 3038 | // Do we need to store the lang list? |
| 2885 | - if (empty($langList)) |
|
| 2886 | - updateSettings(array('langList' => json_encode($catchLang))); |
|
| 3039 | + if (empty($langList)) { |
|
| 3040 | + updateSettings(array('langList' => json_encode($catchLang))); |
|
| 3041 | + } |
|
| 2887 | 3042 | |
| 2888 | 3043 | // Favoring UTF8? Then prevent us from selecting non-UTF8 versions. |
| 2889 | 3044 | if ($favor_utf8) |
| 2890 | 3045 | { |
| 2891 | - foreach ($context['languages'] as $lang) |
|
| 2892 | - if (substr($lang['filename'], strlen($lang['filename']) - 5, 5) != '-utf8' && isset($context['languages'][$lang['filename'] . '-utf8'])) |
|
| 3046 | + foreach ($context['languages'] as $lang) { |
|
| 3047 | + if (substr($lang['filename'], strlen($lang['filename']) - 5, 5) != '-utf8' && isset($context['languages'][$lang['filename'] . '-utf8'])) |
|
| 2893 | 3048 | unset($context['languages'][$lang['filename']]); |
| 3049 | + } |
|
| 2894 | 3050 | } |
| 2895 | 3051 | |
| 2896 | 3052 | // Let's cash in on this deal. |
| 2897 | - if (!empty($modSettings['cache_enable'])) |
|
| 2898 | - cache_put_data('known_languages' . ($favor_utf8 ? '' : '_all'), $context['languages'], !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600); |
|
| 3053 | + if (!empty($modSettings['cache_enable'])) { |
|
| 3054 | + cache_put_data('known_languages' . ($favor_utf8 ? '' : '_all'), $context['languages'], !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600); |
|
| 3055 | + } |
|
| 2899 | 3056 | } |
| 2900 | 3057 | |
| 2901 | 3058 | return $context['languages']; |
@@ -2918,8 +3075,9 @@ discard block |
||
| 2918 | 3075 | global $modSettings, $options, $txt; |
| 2919 | 3076 | static $censor_vulgar = null, $censor_proper; |
| 2920 | 3077 | |
| 2921 | - if ((!empty($options['show_no_censored']) && !empty($modSettings['allow_no_censored']) && !$force) || empty($modSettings['censor_vulgar']) || trim($text) === '') |
|
| 2922 | - return $text; |
|
| 3078 | + if ((!empty($options['show_no_censored']) && !empty($modSettings['allow_no_censored']) && !$force) || empty($modSettings['censor_vulgar']) || trim($text) === '') { |
|
| 3079 | + return $text; |
|
| 3080 | + } |
|
| 2923 | 3081 | |
| 2924 | 3082 | // If they haven't yet been loaded, load them. |
| 2925 | 3083 | if ($censor_vulgar == null) |
@@ -2947,9 +3105,9 @@ discard block |
||
| 2947 | 3105 | { |
| 2948 | 3106 | $func = !empty($modSettings['censorIgnoreCase']) ? 'str_ireplace' : 'str_replace'; |
| 2949 | 3107 | $text = $func($censor_vulgar, $censor_proper, $text); |
| 3108 | + } else { |
|
| 3109 | + $text = preg_replace($censor_vulgar, $censor_proper, $text); |
|
| 2950 | 3110 | } |
| 2951 | - else |
|
| 2952 | - $text = preg_replace($censor_vulgar, $censor_proper, $text); |
|
| 2953 | 3111 | |
| 2954 | 3112 | return $text; |
| 2955 | 3113 | } |
@@ -2975,38 +3133,42 @@ discard block |
||
| 2975 | 3133 | @ini_set('track_errors', '1'); |
| 2976 | 3134 | |
| 2977 | 3135 | // Don't include the file more than once, if $once is true. |
| 2978 | - if ($once && in_array($filename, $templates)) |
|
| 2979 | - return; |
|
| 3136 | + if ($once && in_array($filename, $templates)) { |
|
| 3137 | + return; |
|
| 3138 | + } |
|
| 2980 | 3139 | // Add this file to the include list, whether $once is true or not. |
| 2981 | - else |
|
| 2982 | - $templates[] = $filename; |
|
| 3140 | + else { |
|
| 3141 | + $templates[] = $filename; |
|
| 3142 | + } |
|
| 2983 | 3143 | |
| 2984 | 3144 | // Are we going to use eval? |
| 2985 | 3145 | if (empty($modSettings['disableTemplateEval'])) |
| 2986 | 3146 | { |
| 2987 | 3147 | $file_found = file_exists($filename) && eval('?' . '>' . rtrim(file_get_contents($filename))) !== false; |
| 2988 | 3148 | $settings['current_include_filename'] = $filename; |
| 2989 | - } |
|
| 2990 | - else |
|
| 3149 | + } else |
|
| 2991 | 3150 | { |
| 2992 | 3151 | $file_found = file_exists($filename); |
| 2993 | 3152 | |
| 2994 | - if ($once && $file_found) |
|
| 2995 | - require_once($filename); |
|
| 2996 | - elseif ($file_found) |
|
| 2997 | - require($filename); |
|
| 3153 | + if ($once && $file_found) { |
|
| 3154 | + require_once($filename); |
|
| 3155 | + } elseif ($file_found) { |
|
| 3156 | + require($filename); |
|
| 3157 | + } |
|
| 2998 | 3158 | } |
| 2999 | 3159 | |
| 3000 | 3160 | if ($file_found !== true) |
| 3001 | 3161 | { |
| 3002 | 3162 | ob_end_clean(); |
| 3003 | - if (!empty($modSettings['enableCompressedOutput'])) |
|
| 3004 | - @ob_start('ob_gzhandler'); |
|
| 3005 | - else |
|
| 3006 | - ob_start(); |
|
| 3163 | + if (!empty($modSettings['enableCompressedOutput'])) { |
|
| 3164 | + @ob_start('ob_gzhandler'); |
|
| 3165 | + } else { |
|
| 3166 | + ob_start(); |
|
| 3167 | + } |
|
| 3007 | 3168 | |
| 3008 | - if (isset($_GET['debug'])) |
|
| 3009 | - header('Content-Type: application/xhtml+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
| 3169 | + if (isset($_GET['debug'])) { |
|
| 3170 | + header('Content-Type: application/xhtml+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
| 3171 | + } |
|
| 3010 | 3172 | |
| 3011 | 3173 | // Don't cache error pages!! |
| 3012 | 3174 | header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); |
@@ -3025,12 +3187,13 @@ discard block |
||
| 3025 | 3187 | echo '<!DOCTYPE html> |
| 3026 | 3188 | <html', !empty($context['right_to_left']) ? ' dir="rtl"' : '', '> |
| 3027 | 3189 | <head>'; |
| 3028 | - if (isset($context['character_set'])) |
|
| 3029 | - echo ' |
|
| 3190 | + if (isset($context['character_set'])) { |
|
| 3191 | + echo ' |
|
| 3030 | 3192 | <meta charset="', $context['character_set'], '">'; |
| 3193 | + } |
|
| 3031 | 3194 | |
| 3032 | - if (!empty($maintenance) && !allowedTo('admin_forum')) |
|
| 3033 | - echo ' |
|
| 3195 | + if (!empty($maintenance) && !allowedTo('admin_forum')) { |
|
| 3196 | + echo ' |
|
| 3034 | 3197 | <title>', $mtitle, '</title> |
| 3035 | 3198 | </head> |
| 3036 | 3199 | <body> |
@@ -3038,8 +3201,8 @@ discard block |
||
| 3038 | 3201 | ', $mmessage, ' |
| 3039 | 3202 | </body> |
| 3040 | 3203 | </html>'; |
| 3041 | - elseif (!allowedTo('admin_forum')) |
|
| 3042 | - echo ' |
|
| 3204 | + } elseif (!allowedTo('admin_forum')) { |
|
| 3205 | + echo ' |
|
| 3043 | 3206 | <title>', $txt['template_parse_error'], '</title> |
| 3044 | 3207 | </head> |
| 3045 | 3208 | <body> |
@@ -3047,15 +3210,17 @@ discard block |
||
| 3047 | 3210 | ', $txt['template_parse_error_message'], ' |
| 3048 | 3211 | </body> |
| 3049 | 3212 | </html>'; |
| 3050 | - else |
|
| 3213 | + } else |
|
| 3051 | 3214 | { |
| 3052 | 3215 | require_once($sourcedir . '/Subs-Package.php'); |
| 3053 | 3216 | |
| 3054 | 3217 | $error = fetch_web_data($boardurl . strtr($filename, array($boarddir => '', strtr($boarddir, '\\', '/') => ''))); |
| 3055 | - if (empty($error) && ini_get('track_errors') && !empty($php_errormsg)) |
|
| 3056 | - $error = $php_errormsg; |
|
| 3057 | - if (empty($error)) |
|
| 3058 | - $error = $txt['template_parse_errmsg']; |
|
| 3218 | + if (empty($error) && ini_get('track_errors') && !empty($php_errormsg)) { |
|
| 3219 | + $error = $php_errormsg; |
|
| 3220 | + } |
|
| 3221 | + if (empty($error)) { |
|
| 3222 | + $error = $txt['template_parse_errmsg']; |
|
| 3223 | + } |
|
| 3059 | 3224 | |
| 3060 | 3225 | $error = strtr($error, array('<b>' => '<strong>', '</b>' => '</strong>')); |
| 3061 | 3226 | |
@@ -3066,11 +3231,12 @@ discard block |
||
| 3066 | 3231 | <h3>', $txt['template_parse_error'], '</h3> |
| 3067 | 3232 | ', sprintf($txt['template_parse_error_details'], strtr($filename, array($boarddir => '', strtr($boarddir, '\\', '/') => ''))); |
| 3068 | 3233 | |
| 3069 | - if (!empty($error)) |
|
| 3070 | - echo ' |
|
| 3234 | + if (!empty($error)) { |
|
| 3235 | + echo ' |
|
| 3071 | 3236 | <hr> |
| 3072 | 3237 | |
| 3073 | 3238 | <div style="margin: 0 20px;"><pre>', strtr(strtr($error, array('<strong>' . $boarddir => '<strong>...', '<strong>' . strtr($boarddir, '\\', '/') => '<strong>...')), '\\', '/'), '</pre></div>'; |
| 3239 | + } |
|
| 3074 | 3240 | |
| 3075 | 3241 | // I know, I know... this is VERY COMPLICATED. Still, it's good. |
| 3076 | 3242 | if (preg_match('~ <strong>(\d+)</strong><br( /)?' . '>$~i', $error, $match) != 0) |
@@ -3080,10 +3246,11 @@ discard block |
||
| 3080 | 3246 | $data2 = preg_split('~\<br( /)?\>~', $data2); |
| 3081 | 3247 | |
| 3082 | 3248 | // Fix the PHP code stuff... |
| 3083 | - if (!isBrowser('gecko')) |
|
| 3084 | - $data2 = str_replace("\t", '<span style="white-space: pre;">' . "\t" . '</span>', $data2); |
|
| 3085 | - else |
|
| 3086 | - $data2 = str_replace('<pre style="display: inline;">' . "\t" . '</pre>', "\t", $data2); |
|
| 3249 | + if (!isBrowser('gecko')) { |
|
| 3250 | + $data2 = str_replace("\t", '<span style="white-space: pre;">' . "\t" . '</span>', $data2); |
|
| 3251 | + } else { |
|
| 3252 | + $data2 = str_replace('<pre style="display: inline;">' . "\t" . '</pre>', "\t", $data2); |
|
| 3253 | + } |
|
| 3087 | 3254 | |
| 3088 | 3255 | // Now we get to work around a bug in PHP where it doesn't escape <br>s! |
| 3089 | 3256 | $j = -1; |
@@ -3091,8 +3258,9 @@ discard block |
||
| 3091 | 3258 | { |
| 3092 | 3259 | $j++; |
| 3093 | 3260 | |
| 3094 | - if (substr_count($line, '<br>') == 0) |
|
| 3095 | - continue; |
|
| 3261 | + if (substr_count($line, '<br>') == 0) { |
|
| 3262 | + continue; |
|
| 3263 | + } |
|
| 3096 | 3264 | |
| 3097 | 3265 | $n = substr_count($line, '<br>'); |
| 3098 | 3266 | for ($i = 0; $i < $n; $i++) |
@@ -3111,38 +3279,42 @@ discard block |
||
| 3111 | 3279 | // Figure out what the color coding was before... |
| 3112 | 3280 | $line = max($match[1] - 9, 1); |
| 3113 | 3281 | $last_line = ''; |
| 3114 | - for ($line2 = $line - 1; $line2 > 1; $line2--) |
|
| 3115 | - if (strpos($data2[$line2], '<') !== false) |
|
| 3282 | + for ($line2 = $line - 1; $line2 > 1; $line2--) { |
|
| 3283 | + if (strpos($data2[$line2], '<') !== false) |
|
| 3116 | 3284 | { |
| 3117 | 3285 | if (preg_match('~(<[^/>]+>)[^<]*$~', $data2[$line2], $color_match) != 0) |
| 3118 | 3286 | $last_line = $color_match[1]; |
| 3287 | + } |
|
| 3119 | 3288 | break; |
| 3120 | 3289 | } |
| 3121 | 3290 | |
| 3122 | 3291 | // Show the relevant lines... |
| 3123 | 3292 | for ($n = min($match[1] + 4, count($data2) + 1); $line <= $n; $line++) |
| 3124 | 3293 | { |
| 3125 | - if ($line == $match[1]) |
|
| 3126 | - echo '</pre><div style="background-color: #ffb0b5;"><pre style="margin: 0;">'; |
|
| 3294 | + if ($line == $match[1]) { |
|
| 3295 | + echo '</pre><div style="background-color: #ffb0b5;"><pre style="margin: 0;">'; |
|
| 3296 | + } |
|
| 3127 | 3297 | |
| 3128 | 3298 | echo '<span style="color: black;">', sprintf('%' . strlen($n) . 's', $line), ':</span> '; |
| 3129 | - if (isset($data2[$line]) && $data2[$line] != '') |
|
| 3130 | - echo substr($data2[$line], 0, 2) == '</' ? preg_replace('~^</[^>]+>~', '', $data2[$line]) : $last_line . $data2[$line]; |
|
| 3299 | + if (isset($data2[$line]) && $data2[$line] != '') { |
|
| 3300 | + echo substr($data2[$line], 0, 2) == '</' ? preg_replace('~^</[^>]+>~', '', $data2[$line]) : $last_line . $data2[$line]; |
|
| 3301 | + } |
|
| 3131 | 3302 | |
| 3132 | 3303 | if (isset($data2[$line]) && preg_match('~(<[^/>]+>)[^<]*$~', $data2[$line], $color_match) != 0) |
| 3133 | 3304 | { |
| 3134 | 3305 | $last_line = $color_match[1]; |
| 3135 | 3306 | echo '</', substr($last_line, 1, 4), '>'; |
| 3307 | + } elseif ($last_line != '' && strpos($data2[$line], '<') !== false) { |
|
| 3308 | + $last_line = ''; |
|
| 3309 | + } elseif ($last_line != '' && $data2[$line] != '') { |
|
| 3310 | + echo '</', substr($last_line, 1, 4), '>'; |
|
| 3136 | 3311 | } |
| 3137 | - elseif ($last_line != '' && strpos($data2[$line], '<') !== false) |
|
| 3138 | - $last_line = ''; |
|
| 3139 | - elseif ($last_line != '' && $data2[$line] != '') |
|
| 3140 | - echo '</', substr($last_line, 1, 4), '>'; |
|
| 3141 | 3312 | |
| 3142 | - if ($line == $match[1]) |
|
| 3143 | - echo '</pre></div><pre style="margin: 0;">'; |
|
| 3144 | - else |
|
| 3145 | - echo "\n"; |
|
| 3313 | + if ($line == $match[1]) { |
|
| 3314 | + echo '</pre></div><pre style="margin: 0;">'; |
|
| 3315 | + } else { |
|
| 3316 | + echo "\n"; |
|
| 3317 | + } |
|
| 3146 | 3318 | } |
| 3147 | 3319 | |
| 3148 | 3320 | echo '</pre></div>'; |
@@ -3166,8 +3338,9 @@ discard block |
||
| 3166 | 3338 | global $db_type, $db_name, $ssi_db_user, $ssi_db_passwd, $sourcedir, $db_prefix, $db_port; |
| 3167 | 3339 | |
| 3168 | 3340 | // Figure out what type of database we are using. |
| 3169 | - if (empty($db_type) || !file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php')) |
|
| 3170 | - $db_type = 'mysql'; |
|
| 3341 | + if (empty($db_type) || !file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php')) { |
|
| 3342 | + $db_type = 'mysql'; |
|
| 3343 | + } |
|
| 3171 | 3344 | |
| 3172 | 3345 | // Load the file for the database. |
| 3173 | 3346 | require_once($sourcedir . '/Subs-Db-' . $db_type . '.php'); |
@@ -3175,8 +3348,9 @@ discard block |
||
| 3175 | 3348 | $db_options = array(); |
| 3176 | 3349 | |
| 3177 | 3350 | // Add in the port if needed |
| 3178 | - if (!empty($db_port)) |
|
| 3179 | - $db_options['port'] = $db_port; |
|
| 3351 | + if (!empty($db_port)) { |
|
| 3352 | + $db_options['port'] = $db_port; |
|
| 3353 | + } |
|
| 3180 | 3354 | |
| 3181 | 3355 | // If we are in SSI try them first, but don't worry if it doesn't work, we have the normal username and password we can use. |
| 3182 | 3356 | if (SMF == 'SSI' && !empty($ssi_db_user) && !empty($ssi_db_passwd)) |
@@ -3195,13 +3369,15 @@ discard block |
||
| 3195 | 3369 | } |
| 3196 | 3370 | |
| 3197 | 3371 | // Safe guard here, if there isn't a valid connection lets put a stop to it. |
| 3198 | - if (!$db_connection) |
|
| 3199 | - display_db_error(); |
|
| 3372 | + if (!$db_connection) { |
|
| 3373 | + display_db_error(); |
|
| 3374 | + } |
|
| 3200 | 3375 | |
| 3201 | 3376 | // If in SSI mode fix up the prefix. |
| 3202 | - if (SMF == 'SSI') |
|
| 3203 | - db_fix_prefix($db_prefix, $db_name); |
|
| 3204 | -} |
|
| 3377 | + if (SMF == 'SSI') { |
|
| 3378 | + db_fix_prefix($db_prefix, $db_name); |
|
| 3379 | + } |
|
| 3380 | + } |
|
| 3205 | 3381 | |
| 3206 | 3382 | /** |
| 3207 | 3383 | * Try to load up a supported caching method. This is saved in $cacheAPI if we are not overriding it. |
@@ -3215,10 +3391,11 @@ discard block |
||
| 3215 | 3391 | global $sourcedir, $cacheAPI, $cache_accelerator; |
| 3216 | 3392 | |
| 3217 | 3393 | // Not overriding this and we have a cacheAPI, send it back. |
| 3218 | - if (empty($overrideCache) && is_object($cacheAPI)) |
|
| 3219 | - return $cacheAPI; |
|
| 3220 | - elseif (is_null($cacheAPI)) |
|
| 3221 | - $cacheAPI = false; |
|
| 3394 | + if (empty($overrideCache) && is_object($cacheAPI)) { |
|
| 3395 | + return $cacheAPI; |
|
| 3396 | + } elseif (is_null($cacheAPI)) { |
|
| 3397 | + $cacheAPI = false; |
|
| 3398 | + } |
|
| 3222 | 3399 | |
| 3223 | 3400 | // Make sure our class is in session. |
| 3224 | 3401 | require_once($sourcedir . '/Class-CacheAPI.php'); |
@@ -3239,8 +3416,9 @@ discard block |
||
| 3239 | 3416 | if (!$testAPI->isSupported()) |
| 3240 | 3417 | { |
| 3241 | 3418 | // Can we save ourselves? |
| 3242 | - if (!empty($fallbackSMF) && is_null($overrideCache) && $tryAccelerator != 'smf') |
|
| 3243 | - return loadCacheAccelerator(null, false); |
|
| 3419 | + if (!empty($fallbackSMF) && is_null($overrideCache) && $tryAccelerator != 'smf') { |
|
| 3420 | + return loadCacheAccelerator(null, false); |
|
| 3421 | + } |
|
| 3244 | 3422 | return false; |
| 3245 | 3423 | } |
| 3246 | 3424 | |
@@ -3252,9 +3430,9 @@ discard block |
||
| 3252 | 3430 | { |
| 3253 | 3431 | $cacheAPI = $testAPI; |
| 3254 | 3432 | return $cacheAPI; |
| 3433 | + } else { |
|
| 3434 | + return $testAPI; |
|
| 3255 | 3435 | } |
| 3256 | - else |
|
| 3257 | - return $testAPI; |
|
| 3258 | 3436 | } |
| 3259 | 3437 | } |
| 3260 | 3438 | |
@@ -3274,8 +3452,9 @@ discard block |
||
| 3274 | 3452 | |
| 3275 | 3453 | // @todo Why are we doing this if caching is disabled? |
| 3276 | 3454 | |
| 3277 | - if (function_exists('call_integration_hook')) |
|
| 3278 | - call_integration_hook('pre_cache_quick_get', array(&$key, &$file, &$function, &$params, &$level)); |
|
| 3455 | + if (function_exists('call_integration_hook')) { |
|
| 3456 | + call_integration_hook('pre_cache_quick_get', array(&$key, &$file, &$function, &$params, &$level)); |
|
| 3457 | + } |
|
| 3279 | 3458 | |
| 3280 | 3459 | /* Refresh the cache if either: |
| 3281 | 3460 | 1. Caching is disabled. |
@@ -3289,16 +3468,19 @@ discard block |
||
| 3289 | 3468 | require_once($sourcedir . '/' . $file); |
| 3290 | 3469 | $cache_block = call_user_func_array($function, $params); |
| 3291 | 3470 | |
| 3292 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= $level) |
|
| 3293 | - cache_put_data($key, $cache_block, $cache_block['expires'] - time()); |
|
| 3471 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= $level) { |
|
| 3472 | + cache_put_data($key, $cache_block, $cache_block['expires'] - time()); |
|
| 3473 | + } |
|
| 3294 | 3474 | } |
| 3295 | 3475 | |
| 3296 | 3476 | // Some cached data may need a freshening up after retrieval. |
| 3297 | - if (!empty($cache_block['post_retri_eval'])) |
|
| 3298 | - eval($cache_block['post_retri_eval']); |
|
| 3477 | + if (!empty($cache_block['post_retri_eval'])) { |
|
| 3478 | + eval($cache_block['post_retri_eval']); |
|
| 3479 | + } |
|
| 3299 | 3480 | |
| 3300 | - if (function_exists('call_integration_hook')) |
|
| 3301 | - call_integration_hook('post_cache_quick_get', array(&$cache_block)); |
|
| 3481 | + if (function_exists('call_integration_hook')) { |
|
| 3482 | + call_integration_hook('post_cache_quick_get', array(&$cache_block)); |
|
| 3483 | + } |
|
| 3302 | 3484 | |
| 3303 | 3485 | return $cache_block['data']; |
| 3304 | 3486 | } |
@@ -3325,8 +3507,9 @@ discard block |
||
| 3325 | 3507 | global $boardurl, $modSettings, $cache_enable, $cacheAPI; |
| 3326 | 3508 | global $cache_hits, $cache_count, $db_show_debug; |
| 3327 | 3509 | |
| 3328 | - if (empty($cache_enable) || empty($cacheAPI)) |
|
| 3329 | - return; |
|
| 3510 | + if (empty($cache_enable) || empty($cacheAPI)) { |
|
| 3511 | + return; |
|
| 3512 | + } |
|
| 3330 | 3513 | |
| 3331 | 3514 | $cache_count = isset($cache_count) ? $cache_count + 1 : 1; |
| 3332 | 3515 | if (isset($db_show_debug) && $db_show_debug === true) |
@@ -3339,12 +3522,14 @@ discard block |
||
| 3339 | 3522 | $value = $value === null ? null : json_encode($value); |
| 3340 | 3523 | $cacheAPI->putData($key, $value, $ttl); |
| 3341 | 3524 | |
| 3342 | - if (function_exists('call_integration_hook')) |
|
| 3343 | - call_integration_hook('cache_put_data', array(&$key, &$value, &$ttl)); |
|
| 3525 | + if (function_exists('call_integration_hook')) { |
|
| 3526 | + call_integration_hook('cache_put_data', array(&$key, &$value, &$ttl)); |
|
| 3527 | + } |
|
| 3344 | 3528 | |
| 3345 | - if (isset($db_show_debug) && $db_show_debug === true) |
|
| 3346 | - $cache_hits[$cache_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st)); |
|
| 3347 | -} |
|
| 3529 | + if (isset($db_show_debug) && $db_show_debug === true) { |
|
| 3530 | + $cache_hits[$cache_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st)); |
|
| 3531 | + } |
|
| 3532 | + } |
|
| 3348 | 3533 | |
| 3349 | 3534 | /** |
| 3350 | 3535 | * Gets the value from the cache specified by key, so long as it is not older than ttl seconds. |
@@ -3360,8 +3545,9 @@ discard block |
||
| 3360 | 3545 | global $boardurl, $modSettings, $cache_enable, $cacheAPI; |
| 3361 | 3546 | global $cache_hits, $cache_count, $cache_misses, $cache_count_misses, $db_show_debug; |
| 3362 | 3547 | |
| 3363 | - if (empty($cache_enable) || empty($cacheAPI)) |
|
| 3364 | - return; |
|
| 3548 | + if (empty($cache_enable) || empty($cacheAPI)) { |
|
| 3549 | + return; |
|
| 3550 | + } |
|
| 3365 | 3551 | |
| 3366 | 3552 | $cache_count = isset($cache_count) ? $cache_count + 1 : 1; |
| 3367 | 3553 | if (isset($db_show_debug) && $db_show_debug === true) |
@@ -3381,16 +3567,18 @@ discard block |
||
| 3381 | 3567 | |
| 3382 | 3568 | if (empty($value)) |
| 3383 | 3569 | { |
| 3384 | - if (!is_array($cache_misses)) |
|
| 3385 | - $cache_misses = array(); |
|
| 3570 | + if (!is_array($cache_misses)) { |
|
| 3571 | + $cache_misses = array(); |
|
| 3572 | + } |
|
| 3386 | 3573 | |
| 3387 | 3574 | $cache_count_misses = isset($cache_count_misses) ? $cache_count_misses + 1 : 1; |
| 3388 | 3575 | $cache_misses[$cache_count_misses] = array('k' => $original_key, 'd' => 'get'); |
| 3389 | 3576 | } |
| 3390 | 3577 | } |
| 3391 | 3578 | |
| 3392 | - if (function_exists('call_integration_hook') && isset($value)) |
|
| 3393 | - call_integration_hook('cache_get_data', array(&$key, &$ttl, &$value)); |
|
| 3579 | + if (function_exists('call_integration_hook') && isset($value)) { |
|
| 3580 | + call_integration_hook('cache_get_data', array(&$key, &$ttl, &$value)); |
|
| 3581 | + } |
|
| 3394 | 3582 | |
| 3395 | 3583 | return empty($value) ? null : smf_json_decode($value, true); |
| 3396 | 3584 | } |
@@ -3412,8 +3600,9 @@ discard block |
||
| 3412 | 3600 | global $cacheAPI; |
| 3413 | 3601 | |
| 3414 | 3602 | // If we can't get to the API, can't do this. |
| 3415 | - if (empty($cacheAPI)) |
|
| 3416 | - return; |
|
| 3603 | + if (empty($cacheAPI)) { |
|
| 3604 | + return; |
|
| 3605 | + } |
|
| 3417 | 3606 | |
| 3418 | 3607 | // Ask the API to do the heavy lifting. cleanCache also calls invalidateCache to be sure. |
| 3419 | 3608 | $cacheAPI->cleanCache($type); |
@@ -3438,8 +3627,9 @@ discard block |
||
| 3438 | 3627 | global $modSettings, $boardurl, $smcFunc, $image_proxy_enabled, $image_proxy_secret; |
| 3439 | 3628 | |
| 3440 | 3629 | // Come on! |
| 3441 | - if (empty($data)) |
|
| 3442 | - return array(); |
|
| 3630 | + if (empty($data)) { |
|
| 3631 | + return array(); |
|
| 3632 | + } |
|
| 3443 | 3633 | |
| 3444 | 3634 | // Set a nice default var. |
| 3445 | 3635 | $image = ''; |
@@ -3447,11 +3637,11 @@ discard block |
||
| 3447 | 3637 | // Gravatar has been set as mandatory! |
| 3448 | 3638 | if (!empty($modSettings['gravatarOverride'])) |
| 3449 | 3639 | { |
| 3450 | - if (!empty($modSettings['gravatarAllowExtraEmail']) && !empty($data['avatar']) && stristr($data['avatar'], 'gravatar://')) |
|
| 3451 | - $image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11)); |
|
| 3452 | - |
|
| 3453 | - else if (!empty($data['email'])) |
|
| 3454 | - $image = get_gravatar_url($data['email']); |
|
| 3640 | + if (!empty($modSettings['gravatarAllowExtraEmail']) && !empty($data['avatar']) && stristr($data['avatar'], 'gravatar://')) { |
|
| 3641 | + $image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11)); |
|
| 3642 | + } else if (!empty($data['email'])) { |
|
| 3643 | + $image = get_gravatar_url($data['email']); |
|
| 3644 | + } |
|
| 3455 | 3645 | } |
| 3456 | 3646 | |
| 3457 | 3647 | // Look if the user has a gravatar field or has set an external url as avatar. |
@@ -3463,54 +3653,60 @@ discard block |
||
| 3463 | 3653 | // Gravatar. |
| 3464 | 3654 | if (stristr($data['avatar'], 'gravatar://')) |
| 3465 | 3655 | { |
| 3466 | - if ($data['avatar'] == 'gravatar://') |
|
| 3467 | - $image = get_gravatar_url($data['email']); |
|
| 3468 | - |
|
| 3469 | - elseif (!empty($modSettings['gravatarAllowExtraEmail'])) |
|
| 3470 | - $image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11)); |
|
| 3656 | + if ($data['avatar'] == 'gravatar://') { |
|
| 3657 | + $image = get_gravatar_url($data['email']); |
|
| 3658 | + } elseif (!empty($modSettings['gravatarAllowExtraEmail'])) { |
|
| 3659 | + $image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11)); |
|
| 3660 | + } |
|
| 3471 | 3661 | } |
| 3472 | 3662 | |
| 3473 | 3663 | // External url. |
| 3474 | 3664 | else |
| 3475 | 3665 | { |
| 3476 | 3666 | // Using ssl? |
| 3477 | - if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($data['avatar'], 'http://') !== false) |
|
| 3478 | - $image = strtr($boardurl, array('http://' => 'https://')) . '/proxy.php?request=' . urlencode($data['avatar']) . '&hash=' . md5($data['avatar'] . $image_proxy_secret); |
|
| 3667 | + if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($data['avatar'], 'http://') !== false) { |
|
| 3668 | + $image = strtr($boardurl, array('http://' => 'https://')) . '/proxy.php?request=' . urlencode($data['avatar']) . '&hash=' . md5($data['avatar'] . $image_proxy_secret); |
|
| 3669 | + } |
|
| 3479 | 3670 | |
| 3480 | 3671 | // Just a plain external url. |
| 3481 | - else |
|
| 3482 | - $image = (stristr($data['avatar'], 'http://') || stristr($data['avatar'], 'https://')) ? $data['avatar'] : $modSettings['avatar_url'] . '/' . $data['avatar']; |
|
| 3672 | + else { |
|
| 3673 | + $image = (stristr($data['avatar'], 'http://') || stristr($data['avatar'], 'https://')) ? $data['avatar'] : $modSettings['avatar_url'] . '/' . $data['avatar']; |
|
| 3674 | + } |
|
| 3483 | 3675 | } |
| 3484 | 3676 | } |
| 3485 | 3677 | |
| 3486 | 3678 | // Perhaps this user has an attachment as avatar... |
| 3487 | - else if (!empty($data['filename'])) |
|
| 3488 | - $image = $modSettings['custom_avatar_url'] . '/' . $data['filename']; |
|
| 3679 | + else if (!empty($data['filename'])) { |
|
| 3680 | + $image = $modSettings['custom_avatar_url'] . '/' . $data['filename']; |
|
| 3681 | + } |
|
| 3489 | 3682 | |
| 3490 | 3683 | // Right... no avatar... use our default image. |
| 3491 | - else |
|
| 3492 | - $image = $modSettings['avatar_url'] . '/default.png'; |
|
| 3684 | + else { |
|
| 3685 | + $image = $modSettings['avatar_url'] . '/default.png'; |
|
| 3686 | + } |
|
| 3493 | 3687 | } |
| 3494 | 3688 | |
| 3495 | 3689 | call_integration_hook('integrate_set_avatar_data', array(&$image, &$data)); |
| 3496 | 3690 | |
| 3497 | 3691 | // At this point in time $image has to be filled unless you chose to force gravatar and the user doesn't have the needed data to retrieve it... thus a check for !empty() is still needed. |
| 3498 | - if (!empty($image)) |
|
| 3499 | - return array( |
|
| 3692 | + if (!empty($image)) { |
|
| 3693 | + return array( |
|
| 3500 | 3694 | 'name' => !empty($data['avatar']) ? $data['avatar'] : '', |
| 3501 | 3695 | 'image' => '<img class="avatar" src="' . $image . '" />', |
| 3502 | 3696 | 'href' => $image, |
| 3503 | 3697 | 'url' => $image, |
| 3504 | 3698 | ); |
| 3699 | + } |
|
| 3505 | 3700 | |
| 3506 | 3701 | // Fallback to make life easier for everyone... |
| 3507 | - else |
|
| 3508 | - return array( |
|
| 3702 | + else { |
|
| 3703 | + return array( |
|
| 3509 | 3704 | 'name' => '', |
| 3510 | 3705 | 'image' => '', |
| 3511 | 3706 | 'href' => '', |
| 3512 | 3707 | 'url' => '', |
| 3513 | 3708 | ); |
| 3514 | -} |
|
| 3709 | + } |
|
| 3710 | + } |
|
| 3515 | 3711 | |
| 3516 | 3712 | ?> |
| 3517 | 3713 | \ No newline at end of file |
@@ -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 dispatcher of smileys administration. |
@@ -91,8 +92,9 @@ discard block |
||
| 91 | 92 | ); |
| 92 | 93 | |
| 93 | 94 | // Some settings may not be enabled, disallow these from the tabs as appropriate. |
| 94 | - if (empty($modSettings['messageIcons_enable'])) |
|
| 95 | - $context[$context['admin_menu_name']]['tab_data']['tabs']['editicons']['disabled'] = true; |
|
| 95 | + if (empty($modSettings['messageIcons_enable'])) { |
|
| 96 | + $context[$context['admin_menu_name']]['tab_data']['tabs']['editicons']['disabled'] = true; |
|
| 97 | + } |
|
| 96 | 98 | if (empty($modSettings['smiley_enable'])) |
| 97 | 99 | { |
| 98 | 100 | $context[$context['admin_menu_name']]['tab_data']['tabs']['addsmiley']['disabled'] = true; |
@@ -125,8 +127,9 @@ discard block |
||
| 125 | 127 | $set_names = explode("\n", $modSettings['smiley_sets_names']); |
| 126 | 128 | |
| 127 | 129 | $smiley_context = array(); |
| 128 | - foreach ($smiley_sets as $i => $set) |
|
| 129 | - $smiley_context[$set] = $set_names[$i]; |
|
| 130 | + foreach ($smiley_sets as $i => $set) { |
|
| 131 | + $smiley_context[$set] = $set_names[$i]; |
|
| 132 | + } |
|
| 130 | 133 | |
| 131 | 134 | // All the settings for the page... |
| 132 | 135 | $config_vars = array( |
@@ -147,8 +150,9 @@ discard block |
||
| 147 | 150 | |
| 148 | 151 | call_integration_hook('integrate_modify_smiley_settings', array(&$config_vars)); |
| 149 | 152 | |
| 150 | - if ($return_config) |
|
| 151 | - return $config_vars; |
|
| 153 | + if ($return_config) { |
|
| 154 | + return $config_vars; |
|
| 155 | + } |
|
| 152 | 156 | |
| 153 | 157 | // Setup the basics of the settings template. |
| 154 | 158 | require_once($sourcedir . '/ManageServer.php'); |
@@ -207,8 +211,9 @@ discard block |
||
| 207 | 211 | foreach ($_POST['smiley_set'] as $id => $val) |
| 208 | 212 | { |
| 209 | 213 | // If this is the set you've marked as default, or the only one remaining, you can't delete it |
| 210 | - if ($modSettings['smiley_sets_default'] != $set_paths[$id] && count($set_paths) != 1 && isset($set_paths[$id], $set_names[$id])) |
|
| 211 | - unset($set_paths[$id], $set_names[$id]); |
|
| 214 | + if ($modSettings['smiley_sets_default'] != $set_paths[$id] && count($set_paths) != 1 && isset($set_paths[$id], $set_names[$id])) { |
|
| 215 | + unset($set_paths[$id], $set_names[$id]); |
|
| 216 | + } |
|
| 212 | 217 | } |
| 213 | 218 | |
| 214 | 219 | // Shortcut... array_merge() on a single array resets the numeric keys |
@@ -222,8 +227,9 @@ discard block |
||
| 222 | 227 | )); |
| 223 | 228 | } |
| 224 | 229 | // Add a new smiley set. |
| 225 | - elseif (!empty($_POST['add'])) |
|
| 226 | - $context['sub_action'] = 'modifyset'; |
|
| 230 | + elseif (!empty($_POST['add'])) { |
|
| 231 | + $context['sub_action'] = 'modifyset'; |
|
| 232 | + } |
|
| 227 | 233 | // Create or modify a smiley set. |
| 228 | 234 | elseif (isset($_POST['set'])) |
| 229 | 235 | { |
@@ -233,8 +239,9 @@ discard block |
||
| 233 | 239 | // Create a new smiley set. |
| 234 | 240 | if ($_POST['set'] == -1 && isset($_POST['smiley_sets_path'])) |
| 235 | 241 | { |
| 236 | - if (in_array($_POST['smiley_sets_path'], $set_paths)) |
|
| 237 | - fatal_lang_error('smiley_set_already_exists'); |
|
| 242 | + if (in_array($_POST['smiley_sets_path'], $set_paths)) { |
|
| 243 | + fatal_lang_error('smiley_set_already_exists'); |
|
| 244 | + } |
|
| 238 | 245 | |
| 239 | 246 | updateSettings(array( |
| 240 | 247 | 'smiley_sets_known' => $modSettings['smiley_sets_known'] . ',' . $_POST['smiley_sets_path'], |
@@ -246,12 +253,14 @@ discard block |
||
| 246 | 253 | else |
| 247 | 254 | { |
| 248 | 255 | // Make sure the smiley set exists. |
| 249 | - if (!isset($set_paths[$_POST['set']]) || !isset($set_names[$_POST['set']])) |
|
| 250 | - fatal_lang_error('smiley_set_not_found'); |
|
| 256 | + if (!isset($set_paths[$_POST['set']]) || !isset($set_names[$_POST['set']])) { |
|
| 257 | + fatal_lang_error('smiley_set_not_found'); |
|
| 258 | + } |
|
| 251 | 259 | |
| 252 | 260 | // Make sure the path is not yet used by another smileyset. |
| 253 | - if (in_array($_POST['smiley_sets_path'], $set_paths) && $_POST['smiley_sets_path'] != $set_paths[$_POST['set']]) |
|
| 254 | - fatal_lang_error('smiley_set_path_already_used'); |
|
| 261 | + if (in_array($_POST['smiley_sets_path'], $set_paths) && $_POST['smiley_sets_path'] != $set_paths[$_POST['set']]) { |
|
| 262 | + fatal_lang_error('smiley_set_path_already_used'); |
|
| 263 | + } |
|
| 255 | 264 | |
| 256 | 265 | $set_paths[$_POST['set']] = $_POST['smiley_sets_path']; |
| 257 | 266 | $set_names[$_POST['set']] = $_POST['smiley_sets_name']; |
@@ -263,8 +272,9 @@ discard block |
||
| 263 | 272 | } |
| 264 | 273 | |
| 265 | 274 | // The user might have checked to also import smileys. |
| 266 | - if (!empty($_POST['smiley_sets_import'])) |
|
| 267 | - ImportSmileys($_POST['smiley_sets_path']); |
|
| 275 | + if (!empty($_POST['smiley_sets_import'])) { |
|
| 276 | + ImportSmileys($_POST['smiley_sets_path']); |
|
| 277 | + } |
|
| 268 | 278 | } |
| 269 | 279 | cache_put_data('parsing_smileys', null, 480); |
| 270 | 280 | cache_put_data('posting_smileys', null, 480); |
@@ -273,13 +283,14 @@ discard block |
||
| 273 | 283 | // Load all available smileysets... |
| 274 | 284 | $context['smiley_sets'] = explode(',', $modSettings['smiley_sets_known']); |
| 275 | 285 | $set_names = explode("\n", $modSettings['smiley_sets_names']); |
| 276 | - foreach ($context['smiley_sets'] as $i => $set) |
|
| 277 | - $context['smiley_sets'][$i] = array( |
|
| 286 | + foreach ($context['smiley_sets'] as $i => $set) { |
|
| 287 | + $context['smiley_sets'][$i] = array( |
|
| 278 | 288 | 'id' => $i, |
| 279 | 289 | 'path' => $smcFunc['htmlspecialchars']($set), |
| 280 | 290 | 'name' => $smcFunc['htmlspecialchars']($set_names[$i]), |
| 281 | 291 | 'selected' => $set == $modSettings['smiley_sets_default'] |
| 282 | 292 | ); |
| 293 | + } |
|
| 283 | 294 | |
| 284 | 295 | // Importing any smileys from an existing set? |
| 285 | 296 | if ($context['sub_action'] == 'import') |
@@ -290,8 +301,9 @@ discard block |
||
| 290 | 301 | $_GET['set'] = (int) $_GET['set']; |
| 291 | 302 | |
| 292 | 303 | // Sanity check - then import. |
| 293 | - if (isset($context['smiley_sets'][$_GET['set']])) |
|
| 294 | - ImportSmileys(un_htmlspecialchars($context['smiley_sets'][$_GET['set']]['path'])); |
|
| 304 | + if (isset($context['smiley_sets'][$_GET['set']])) { |
|
| 305 | + ImportSmileys(un_htmlspecialchars($context['smiley_sets'][$_GET['set']]['path'])); |
|
| 306 | + } |
|
| 295 | 307 | |
| 296 | 308 | // Force the process to continue. |
| 297 | 309 | $context['sub_action'] = 'modifyset'; |
@@ -301,15 +313,15 @@ discard block |
||
| 301 | 313 | if ($context['sub_action'] == 'modifyset') |
| 302 | 314 | { |
| 303 | 315 | $_GET['set'] = !isset($_GET['set']) ? -1 : (int) $_GET['set']; |
| 304 | - if ($_GET['set'] == -1 || !isset($context['smiley_sets'][$_GET['set']])) |
|
| 305 | - $context['current_set'] = array( |
|
| 316 | + if ($_GET['set'] == -1 || !isset($context['smiley_sets'][$_GET['set']])) { |
|
| 317 | + $context['current_set'] = array( |
|
| 306 | 318 | 'id' => '-1', |
| 307 | 319 | 'path' => '', |
| 308 | 320 | 'name' => '', |
| 309 | 321 | 'selected' => false, |
| 310 | 322 | 'is_new' => true, |
| 311 | 323 | ); |
| 312 | - else |
|
| 324 | + } else |
|
| 313 | 325 | { |
| 314 | 326 | $context['current_set'] = &$context['smiley_sets'][$_GET['set']]; |
| 315 | 327 | $context['current_set']['is_new'] = false; |
@@ -321,13 +333,15 @@ discard block |
||
| 321 | 333 | $dir = dir($modSettings['smileys_dir'] . '/' . $context['current_set']['path']); |
| 322 | 334 | while ($entry = $dir->read()) |
| 323 | 335 | { |
| 324 | - if (in_array(strrchr($entry, '.'), array('.jpg', '.gif', '.jpeg', '.png'))) |
|
| 325 | - $smileys[strtolower($entry)] = $entry; |
|
| 336 | + if (in_array(strrchr($entry, '.'), array('.jpg', '.gif', '.jpeg', '.png'))) { |
|
| 337 | + $smileys[strtolower($entry)] = $entry; |
|
| 338 | + } |
|
| 326 | 339 | } |
| 327 | 340 | $dir->close(); |
| 328 | 341 | |
| 329 | - if (empty($smileys)) |
|
| 330 | - fatal_lang_error('smiley_set_dir_not_found', false, array($context['current_set']['name'])); |
|
| 342 | + if (empty($smileys)) { |
|
| 343 | + fatal_lang_error('smiley_set_dir_not_found', false, array($context['current_set']['name'])); |
|
| 344 | + } |
|
| 331 | 345 | |
| 332 | 346 | // Exclude the smileys that are already in the database. |
| 333 | 347 | $request = $smcFunc['db_query']('', ' |
@@ -338,9 +352,10 @@ discard block |
||
| 338 | 352 | 'smiley_list' => $smileys, |
| 339 | 353 | ) |
| 340 | 354 | ); |
| 341 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 342 | - if (isset($smileys[strtolower($row['filename'])])) |
|
| 355 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 356 | + if (isset($smileys[strtolower($row['filename'])])) |
|
| 343 | 357 | unset($smileys[strtolower($row['filename'])]); |
| 358 | + } |
|
| 344 | 359 | $smcFunc['db_free_result']($request); |
| 345 | 360 | |
| 346 | 361 | $context['current_set']['can_import'] = count($smileys); |
@@ -355,13 +370,14 @@ discard block |
||
| 355 | 370 | $dir = dir($modSettings['smileys_dir']); |
| 356 | 371 | while ($entry = $dir->read()) |
| 357 | 372 | { |
| 358 | - if (!in_array($entry, array('.', '..')) && is_dir($modSettings['smileys_dir'] . '/' . $entry)) |
|
| 359 | - $context['smiley_set_dirs'][] = array( |
|
| 373 | + if (!in_array($entry, array('.', '..')) && is_dir($modSettings['smileys_dir'] . '/' . $entry)) { |
|
| 374 | + $context['smiley_set_dirs'][] = array( |
|
| 360 | 375 | 'id' => $entry, |
| 361 | 376 | 'path' => $modSettings['smileys_dir'] . '/' . $entry, |
| 362 | 377 | 'selectable' => $entry == $context['current_set']['path'] || !in_array($entry, explode(',', $modSettings['smiley_sets_known'])), |
| 363 | 378 | 'current' => $entry == $context['current_set']['path'], |
| 364 | 379 | ); |
| 380 | + } |
|
| 365 | 381 | } |
| 366 | 382 | $dir->close(); |
| 367 | 383 | } |
@@ -371,8 +387,9 @@ discard block |
||
| 371 | 387 | createToken('admin-mss', 'request'); |
| 372 | 388 | |
| 373 | 389 | // In case we need to import smileys, we need to add the token in now. |
| 374 | - if (isset($context['current_set']['import_url'])) |
|
| 375 | - $context['current_set']['import_url'] .= ';' . $context['admin-mss_token_var'] . '=' . $context['admin-mss_token']; |
|
| 390 | + if (isset($context['current_set']['import_url'])) { |
|
| 391 | + $context['current_set']['import_url'] .= ';' . $context['admin-mss_token_var'] . '=' . $context['admin-mss_token']; |
|
| 392 | + } |
|
| 376 | 393 | |
| 377 | 394 | $listOptions = array( |
| 378 | 395 | 'id' => 'smiley_set_list', |
@@ -510,21 +527,23 @@ discard block |
||
| 510 | 527 | $cols['name'][] = $set_names[$i]; |
| 511 | 528 | } |
| 512 | 529 | $sort_flag = strpos($sort, 'DESC') === false ? SORT_ASC : SORT_DESC; |
| 513 | - if (substr($sort, 0, 4) === 'name') |
|
| 514 | - array_multisort($cols['name'], $sort_flag, SORT_REGULAR, $cols['path'], $cols['selected'], $cols['id']); |
|
| 515 | - elseif (substr($sort, 0, 4) === 'path') |
|
| 516 | - array_multisort($cols['path'], $sort_flag, SORT_REGULAR, $cols['name'], $cols['selected'], $cols['id']); |
|
| 517 | - else |
|
| 518 | - array_multisort($cols['selected'], $sort_flag, SORT_REGULAR, $cols['path'], $cols['name'], $cols['id']); |
|
| 530 | + if (substr($sort, 0, 4) === 'name') { |
|
| 531 | + array_multisort($cols['name'], $sort_flag, SORT_REGULAR, $cols['path'], $cols['selected'], $cols['id']); |
|
| 532 | + } elseif (substr($sort, 0, 4) === 'path') { |
|
| 533 | + array_multisort($cols['path'], $sort_flag, SORT_REGULAR, $cols['name'], $cols['selected'], $cols['id']); |
|
| 534 | + } else { |
|
| 535 | + array_multisort($cols['selected'], $sort_flag, SORT_REGULAR, $cols['path'], $cols['name'], $cols['id']); |
|
| 536 | + } |
|
| 519 | 537 | |
| 520 | 538 | $smiley_sets = array(); |
| 521 | - foreach ($cols['id'] as $i => $id) |
|
| 522 | - $smiley_sets[] = array( |
|
| 539 | + foreach ($cols['id'] as $i => $id) { |
|
| 540 | + $smiley_sets[] = array( |
|
| 523 | 541 | 'id' => $id, |
| 524 | 542 | 'path' => $cols['path'][$i], |
| 525 | 543 | 'name' => $cols['name'][$i], |
| 526 | 544 | 'selected' => $cols['path'][$i] == $modSettings['smiley_sets_default'] |
| 527 | 545 | ); |
| 546 | + } |
|
| 528 | 547 | |
| 529 | 548 | return $smiley_sets; |
| 530 | 549 | } |
@@ -553,13 +572,14 @@ discard block |
||
| 553 | 572 | $context['smileys_dir_found'] = is_dir($context['smileys_dir']); |
| 554 | 573 | $context['smiley_sets'] = explode(',', $modSettings['smiley_sets_known']); |
| 555 | 574 | $set_names = explode("\n", $modSettings['smiley_sets_names']); |
| 556 | - foreach ($context['smiley_sets'] as $i => $set) |
|
| 557 | - $context['smiley_sets'][$i] = array( |
|
| 575 | + foreach ($context['smiley_sets'] as $i => $set) { |
|
| 576 | + $context['smiley_sets'][$i] = array( |
|
| 558 | 577 | 'id' => $i, |
| 559 | 578 | 'path' => $smcFunc['htmlspecialchars']($set), |
| 560 | 579 | 'name' => $smcFunc['htmlspecialchars']($set_names[$i]), |
| 561 | 580 | 'selected' => $set == $modSettings['smiley_sets_default'] |
| 562 | 581 | ); |
| 582 | + } |
|
| 563 | 583 | |
| 564 | 584 | // Submitting a form? |
| 565 | 585 | if (isset($_POST[$context['session_var']], $_POST['smiley_code'])) |
@@ -575,8 +595,9 @@ discard block |
||
| 575 | 595 | $_POST['smiley_filename'] = htmltrim__recursive($_POST['smiley_filename']); |
| 576 | 596 | |
| 577 | 597 | // Make sure some code was entered. |
| 578 | - if (empty($_POST['smiley_code'])) |
|
| 579 | - fatal_lang_error('smiley_has_no_code'); |
|
| 598 | + if (empty($_POST['smiley_code'])) { |
|
| 599 | + fatal_lang_error('smiley_has_no_code'); |
|
| 600 | + } |
|
| 580 | 601 | |
| 581 | 602 | // Check whether the new code has duplicates. It should be unique. |
| 582 | 603 | $request = $smcFunc['db_query']('', ' |
@@ -588,8 +609,9 @@ discard block |
||
| 588 | 609 | 'smiley_code' => $_POST['smiley_code'], |
| 589 | 610 | ) |
| 590 | 611 | ); |
| 591 | - if ($smcFunc['db_num_rows']($request) > 0) |
|
| 592 | - fatal_lang_error('smiley_not_unique'); |
|
| 612 | + if ($smcFunc['db_num_rows']($request) > 0) { |
|
| 613 | + fatal_lang_error('smiley_not_unique'); |
|
| 614 | + } |
|
| 593 | 615 | $smcFunc['db_free_result']($request); |
| 594 | 616 | |
| 595 | 617 | // If we are uploading - check all the smiley sets are writable! |
@@ -598,38 +620,44 @@ discard block |
||
| 598 | 620 | $writeErrors = array(); |
| 599 | 621 | foreach ($context['smiley_sets'] as $set) |
| 600 | 622 | { |
| 601 | - if (!is_writable($context['smileys_dir'] . '/' . un_htmlspecialchars($set['path']))) |
|
| 602 | - $writeErrors[] = $set['path']; |
|
| 623 | + if (!is_writable($context['smileys_dir'] . '/' . un_htmlspecialchars($set['path']))) { |
|
| 624 | + $writeErrors[] = $set['path']; |
|
| 625 | + } |
|
| 626 | + } |
|
| 627 | + if (!empty($writeErrors)) { |
|
| 628 | + fatal_lang_error('smileys_upload_error_notwritable', true, array(implode(', ', $writeErrors))); |
|
| 603 | 629 | } |
| 604 | - if (!empty($writeErrors)) |
|
| 605 | - fatal_lang_error('smileys_upload_error_notwritable', true, array(implode(', ', $writeErrors))); |
|
| 606 | 630 | } |
| 607 | 631 | |
| 608 | 632 | // Uploading just one smiley for all of them? |
| 609 | 633 | if (isset($_POST['sameall']) && isset($_FILES['uploadSmiley']['name']) && $_FILES['uploadSmiley']['name'] != '') |
| 610 | 634 | { |
| 611 | - if (!is_uploaded_file($_FILES['uploadSmiley']['tmp_name']) || (ini_get('open_basedir') == '' && !file_exists($_FILES['uploadSmiley']['tmp_name']))) |
|
| 612 | - fatal_lang_error('smileys_upload_error'); |
|
| 635 | + if (!is_uploaded_file($_FILES['uploadSmiley']['tmp_name']) || (ini_get('open_basedir') == '' && !file_exists($_FILES['uploadSmiley']['tmp_name']))) { |
|
| 636 | + fatal_lang_error('smileys_upload_error'); |
|
| 637 | + } |
|
| 613 | 638 | |
| 614 | 639 | // Sorry, no spaces, dots, or anything else but letters allowed. |
| 615 | 640 | $_FILES['uploadSmiley']['name'] = preg_replace(array('/\s/', '/\.[\.]+/', '/[^\w_\.\-]/'), array('_', '.', ''), $_FILES['uploadSmiley']['name']); |
| 616 | 641 | |
| 617 | 642 | // We only allow image files - it's THAT simple - no messing around here... |
| 618 | - if (!in_array(strtolower(substr(strrchr($_FILES['uploadSmiley']['name'], '.'), 1)), $allowedTypes)) |
|
| 619 | - fatal_lang_error('smileys_upload_error_types', false, array(implode(', ', $allowedTypes))); |
|
| 643 | + if (!in_array(strtolower(substr(strrchr($_FILES['uploadSmiley']['name'], '.'), 1)), $allowedTypes)) { |
|
| 644 | + fatal_lang_error('smileys_upload_error_types', false, array(implode(', ', $allowedTypes))); |
|
| 645 | + } |
|
| 620 | 646 | |
| 621 | 647 | // We only need the filename... |
| 622 | 648 | $destName = basename($_FILES['uploadSmiley']['name']); |
| 623 | 649 | |
| 624 | 650 | // Make sure they aren't trying to upload a nasty file - for their own good here! |
| 625 | - if (in_array(strtolower($destName), $disabledFiles)) |
|
| 626 | - fatal_lang_error('smileys_upload_error_illegal'); |
|
| 651 | + if (in_array(strtolower($destName), $disabledFiles)) { |
|
| 652 | + fatal_lang_error('smileys_upload_error_illegal'); |
|
| 653 | + } |
|
| 627 | 654 | |
| 628 | 655 | // Check if the file already exists... and if not move it to EVERY smiley set directory. |
| 629 | 656 | $i = 0; |
| 630 | 657 | // Keep going until we find a set the file doesn't exist in. (or maybe it exists in all of them?) |
| 631 | - while (isset($context['smiley_sets'][$i]) && file_exists($context['smileys_dir'] . '/' . un_htmlspecialchars($context['smiley_sets'][$i]['path']) . '/' . $destName)) |
|
| 632 | - $i++; |
|
| 658 | + while (isset($context['smiley_sets'][$i]) && file_exists($context['smileys_dir'] . '/' . un_htmlspecialchars($context['smiley_sets'][$i]['path']) . '/' . $destName)) { |
|
| 659 | + $i++; |
|
| 660 | + } |
|
| 633 | 661 | |
| 634 | 662 | // Okay, we're going to put the smiley right here, since it's not there yet! |
| 635 | 663 | if (isset($context['smiley_sets'][$i]['path'])) |
@@ -644,8 +672,9 @@ discard block |
||
| 644 | 672 | $currentPath = $context['smileys_dir'] . '/' . un_htmlspecialchars($context['smiley_sets'][$i]['path']) . '/' . $destName; |
| 645 | 673 | |
| 646 | 674 | // The file is already there! Don't overwrite it! |
| 647 | - if (file_exists($currentPath)) |
|
| 648 | - continue; |
|
| 675 | + if (file_exists($currentPath)) { |
|
| 676 | + continue; |
|
| 677 | + } |
|
| 649 | 678 | |
| 650 | 679 | // Okay, so copy the first one we made to here. |
| 651 | 680 | copy($smileyLocation, $currentPath); |
@@ -662,13 +691,15 @@ discard block |
||
| 662 | 691 | $newName = ''; |
| 663 | 692 | foreach ($_FILES as $name => $data) |
| 664 | 693 | { |
| 665 | - if ($_FILES[$name]['name'] == '') |
|
| 666 | - fatal_lang_error('smileys_upload_error_blank'); |
|
| 694 | + if ($_FILES[$name]['name'] == '') { |
|
| 695 | + fatal_lang_error('smileys_upload_error_blank'); |
|
| 696 | + } |
|
| 667 | 697 | |
| 668 | - if (empty($newName)) |
|
| 669 | - $newName = basename($_FILES[$name]['name']); |
|
| 670 | - elseif (basename($_FILES[$name]['name']) != $newName) |
|
| 671 | - fatal_lang_error('smileys_upload_error_name'); |
|
| 698 | + if (empty($newName)) { |
|
| 699 | + $newName = basename($_FILES[$name]['name']); |
|
| 700 | + } elseif (basename($_FILES[$name]['name']) != $newName) { |
|
| 701 | + fatal_lang_error('smileys_upload_error_name'); |
|
| 702 | + } |
|
| 672 | 703 | } |
| 673 | 704 | |
| 674 | 705 | foreach ($context['smiley_sets'] as $i => $set) |
@@ -676,31 +707,36 @@ discard block |
||
| 676 | 707 | $set['name'] = un_htmlspecialchars($set['name']); |
| 677 | 708 | $set['path'] = un_htmlspecialchars($set['path']); |
| 678 | 709 | |
| 679 | - if (!isset($_FILES['individual_' . $set['name']]['name']) || $_FILES['individual_' . $set['name']]['name'] == '') |
|
| 680 | - continue; |
|
| 710 | + if (!isset($_FILES['individual_' . $set['name']]['name']) || $_FILES['individual_' . $set['name']]['name'] == '') { |
|
| 711 | + continue; |
|
| 712 | + } |
|
| 681 | 713 | |
| 682 | 714 | // Got one... |
| 683 | - if (!is_uploaded_file($_FILES['individual_' . $set['name']]['tmp_name']) || (ini_get('open_basedir') == '' && !file_exists($_FILES['individual_' . $set['name']]['tmp_name']))) |
|
| 684 | - fatal_lang_error('smileys_upload_error'); |
|
| 715 | + if (!is_uploaded_file($_FILES['individual_' . $set['name']]['tmp_name']) || (ini_get('open_basedir') == '' && !file_exists($_FILES['individual_' . $set['name']]['tmp_name']))) { |
|
| 716 | + fatal_lang_error('smileys_upload_error'); |
|
| 717 | + } |
|
| 685 | 718 | |
| 686 | 719 | // Sorry, no spaces, dots, or anything else but letters allowed. |
| 687 | 720 | $_FILES['individual_' . $set['name']]['name'] = preg_replace(array('/\s/', '/\.[\.]+/', '/[^\w_\.\-]/'), array('_', '.', ''), $_FILES['individual_' . $set['name']]['name']); |
| 688 | 721 | |
| 689 | 722 | // We only allow image files - it's THAT simple - no messing around here... |
| 690 | - if (!in_array(strtolower(substr(strrchr($_FILES['individual_' . $set['name']]['name'], '.'), 1)), $allowedTypes)) |
|
| 691 | - fatal_lang_error('smileys_upload_error_types', false, array(implode(', ', $allowedTypes))); |
|
| 723 | + if (!in_array(strtolower(substr(strrchr($_FILES['individual_' . $set['name']]['name'], '.'), 1)), $allowedTypes)) { |
|
| 724 | + fatal_lang_error('smileys_upload_error_types', false, array(implode(', ', $allowedTypes))); |
|
| 725 | + } |
|
| 692 | 726 | |
| 693 | 727 | // We only need the filename... |
| 694 | 728 | $destName = basename($_FILES['individual_' . $set['name']]['name']); |
| 695 | 729 | |
| 696 | 730 | // Make sure they aren't trying to upload a nasty file - for their own good here! |
| 697 | - if (in_array(strtolower($destName), $disabledFiles)) |
|
| 698 | - fatal_lang_error('smileys_upload_error_illegal'); |
|
| 731 | + if (in_array(strtolower($destName), $disabledFiles)) { |
|
| 732 | + fatal_lang_error('smileys_upload_error_illegal'); |
|
| 733 | + } |
|
| 699 | 734 | |
| 700 | 735 | // If the file exists - ignore it. |
| 701 | 736 | $smileyLocation = $context['smileys_dir'] . '/' . $set['path'] . '/' . $destName; |
| 702 | - if (file_exists($smileyLocation)) |
|
| 703 | - continue; |
|
| 737 | + if (file_exists($smileyLocation)) { |
|
| 738 | + continue; |
|
| 739 | + } |
|
| 704 | 740 | |
| 705 | 741 | // Finally - move the image! |
| 706 | 742 | move_uploaded_file($_FILES['individual_' . $set['name']]['tmp_name'], $smileyLocation); |
@@ -712,8 +748,9 @@ discard block |
||
| 712 | 748 | } |
| 713 | 749 | |
| 714 | 750 | // Also make sure a filename was given. |
| 715 | - if (empty($_POST['smiley_filename'])) |
|
| 716 | - fatal_lang_error('smiley_has_no_filename'); |
|
| 751 | + if (empty($_POST['smiley_filename'])) { |
|
| 752 | + fatal_lang_error('smiley_has_no_filename'); |
|
| 753 | + } |
|
| 717 | 754 | |
| 718 | 755 | // Find the position on the right. |
| 719 | 756 | $smiley_order = '0'; |
@@ -732,8 +769,9 @@ discard block |
||
| 732 | 769 | list ($smiley_order) = $smcFunc['db_fetch_row']($request); |
| 733 | 770 | $smcFunc['db_free_result']($request); |
| 734 | 771 | |
| 735 | - if (empty($smiley_order)) |
|
| 736 | - $smiley_order = '0'; |
|
| 772 | + if (empty($smiley_order)) { |
|
| 773 | + $smiley_order = '0'; |
|
| 774 | + } |
|
| 737 | 775 | } |
| 738 | 776 | $smcFunc['db_insert']('', |
| 739 | 777 | '{db_prefix}smileys', |
@@ -761,17 +799,19 @@ discard block |
||
| 761 | 799 | { |
| 762 | 800 | foreach ($context['smiley_sets'] as $smiley_set) |
| 763 | 801 | { |
| 764 | - if (!file_exists($context['smileys_dir'] . '/' . un_htmlspecialchars($smiley_set['path']))) |
|
| 765 | - continue; |
|
| 802 | + if (!file_exists($context['smileys_dir'] . '/' . un_htmlspecialchars($smiley_set['path']))) { |
|
| 803 | + continue; |
|
| 804 | + } |
|
| 766 | 805 | |
| 767 | 806 | $dir = dir($context['smileys_dir'] . '/' . un_htmlspecialchars($smiley_set['path'])); |
| 768 | 807 | while ($entry = $dir->read()) |
| 769 | 808 | { |
| 770 | - if (!in_array($entry, $context['filenames']) && in_array(strrchr($entry, '.'), array('.jpg', '.gif', '.jpeg', '.png'))) |
|
| 771 | - $context['filenames'][strtolower($entry)] = array( |
|
| 809 | + if (!in_array($entry, $context['filenames']) && in_array(strrchr($entry, '.'), array('.jpg', '.gif', '.jpeg', '.png'))) { |
|
| 810 | + $context['filenames'][strtolower($entry)] = array( |
|
| 772 | 811 | 'id' => $smcFunc['htmlspecialchars']($entry), |
| 773 | 812 | 'selected' => false, |
| 774 | 813 | ); |
| 814 | + } |
|
| 775 | 815 | } |
| 776 | 816 | $dir->close(); |
| 777 | 817 | } |
@@ -809,17 +849,19 @@ discard block |
||
| 809 | 849 | // Changing the selected smileys? |
| 810 | 850 | if (isset($_POST['smiley_action']) && !empty($_POST['checked_smileys'])) |
| 811 | 851 | { |
| 812 | - foreach ($_POST['checked_smileys'] as $id => $smiley_id) |
|
| 813 | - $_POST['checked_smileys'][$id] = (int) $smiley_id; |
|
| 852 | + foreach ($_POST['checked_smileys'] as $id => $smiley_id) { |
|
| 853 | + $_POST['checked_smileys'][$id] = (int) $smiley_id; |
|
| 854 | + } |
|
| 814 | 855 | |
| 815 | - if ($_POST['smiley_action'] == 'delete') |
|
| 816 | - $smcFunc['db_query']('', ' |
|
| 856 | + if ($_POST['smiley_action'] == 'delete') { |
|
| 857 | + $smcFunc['db_query']('', ' |
|
| 817 | 858 | DELETE FROM {db_prefix}smileys |
| 818 | 859 | WHERE id_smiley IN ({array_int:checked_smileys})', |
| 819 | 860 | array( |
| 820 | 861 | 'checked_smileys' => $_POST['checked_smileys'], |
| 821 | 862 | ) |
| 822 | 863 | ); |
| 864 | + } |
|
| 823 | 865 | // Changing the status of the smiley? |
| 824 | 866 | else |
| 825 | 867 | { |
@@ -829,8 +871,8 @@ discard block |
||
| 829 | 871 | 'hidden' => 1, |
| 830 | 872 | 'popup' => 2 |
| 831 | 873 | ); |
| 832 | - if (isset($displayTypes[$_POST['smiley_action']])) |
|
| 833 | - $smcFunc['db_query']('', ' |
|
| 874 | + if (isset($displayTypes[$_POST['smiley_action']])) { |
|
| 875 | + $smcFunc['db_query']('', ' |
|
| 834 | 876 | UPDATE {db_prefix}smileys |
| 835 | 877 | SET hidden = {int:display_type} |
| 836 | 878 | WHERE id_smiley IN ({array_int:checked_smileys})', |
@@ -839,6 +881,7 @@ discard block |
||
| 839 | 881 | 'display_type' => $displayTypes[$_POST['smiley_action']], |
| 840 | 882 | ) |
| 841 | 883 | ); |
| 884 | + } |
|
| 842 | 885 | } |
| 843 | 886 | } |
| 844 | 887 | // Create/modify a smiley. |
@@ -864,12 +907,14 @@ discard block |
||
| 864 | 907 | $_POST['smiley_location'] = empty($_POST['smiley_location']) || $_POST['smiley_location'] > 2 || $_POST['smiley_location'] < 0 ? 0 : (int) $_POST['smiley_location']; |
| 865 | 908 | |
| 866 | 909 | // Make sure some code was entered. |
| 867 | - if (empty($_POST['smiley_code'])) |
|
| 868 | - fatal_lang_error('smiley_has_no_code'); |
|
| 910 | + if (empty($_POST['smiley_code'])) { |
|
| 911 | + fatal_lang_error('smiley_has_no_code'); |
|
| 912 | + } |
|
| 869 | 913 | |
| 870 | 914 | // Also make sure a filename was given. |
| 871 | - if (empty($_POST['smiley_filename'])) |
|
| 872 | - fatal_lang_error('smiley_has_no_filename'); |
|
| 915 | + if (empty($_POST['smiley_filename'])) { |
|
| 916 | + fatal_lang_error('smiley_has_no_filename'); |
|
| 917 | + } |
|
| 873 | 918 | |
| 874 | 919 | // Check whether the new code has duplicates. It should be unique. |
| 875 | 920 | $request = $smcFunc['db_query']('', ' |
@@ -883,8 +928,9 @@ discard block |
||
| 883 | 928 | 'smiley_code' => $_POST['smiley_code'], |
| 884 | 929 | ) |
| 885 | 930 | ); |
| 886 | - if ($smcFunc['db_num_rows']($request) > 0) |
|
| 887 | - fatal_lang_error('smiley_not_unique'); |
|
| 931 | + if ($smcFunc['db_num_rows']($request) > 0) { |
|
| 932 | + fatal_lang_error('smiley_not_unique'); |
|
| 933 | + } |
|
| 888 | 934 | $smcFunc['db_free_result']($request); |
| 889 | 935 | |
| 890 | 936 | $smcFunc['db_query']('', ' |
@@ -913,13 +959,14 @@ discard block |
||
| 913 | 959 | // Load all known smiley sets. |
| 914 | 960 | $context['smiley_sets'] = explode(',', $modSettings['smiley_sets_known']); |
| 915 | 961 | $set_names = explode("\n", $modSettings['smiley_sets_names']); |
| 916 | - foreach ($context['smiley_sets'] as $i => $set) |
|
| 917 | - $context['smiley_sets'][$i] = array( |
|
| 962 | + foreach ($context['smiley_sets'] as $i => $set) { |
|
| 963 | + $context['smiley_sets'][$i] = array( |
|
| 918 | 964 | 'id' => $i, |
| 919 | 965 | 'path' => $smcFunc['htmlspecialchars']($set), |
| 920 | 966 | 'name' => $smcFunc['htmlspecialchars']($set_names[$i]), |
| 921 | 967 | 'selected' => $set == $modSettings['smiley_sets_default'] |
| 922 | 968 | ); |
| 969 | + } |
|
| 923 | 970 | |
| 924 | 971 | // Prepare overview of all (custom) smileys. |
| 925 | 972 | if ($context['sub_action'] == 'editsmileys') |
@@ -935,9 +982,10 @@ discard block |
||
| 935 | 982 | // Create a list of options for selecting smiley sets. |
| 936 | 983 | $smileyset_option_list = ' |
| 937 | 984 | <select name="set" onchange="changeSet(this.options[this.selectedIndex].value);">'; |
| 938 | - foreach ($context['smiley_sets'] as $smiley_set) |
|
| 939 | - $smileyset_option_list .= ' |
|
| 985 | + foreach ($context['smiley_sets'] as $smiley_set) { |
|
| 986 | + $smileyset_option_list .= ' |
|
| 940 | 987 | <option value="' . $smiley_set['path'] . '"' . ($modSettings['smiley_sets_default'] == $smiley_set['path'] ? ' selected' : '') . '>' . $smiley_set['name'] . '</option>'; |
| 988 | + } |
|
| 941 | 989 | $smileyset_option_list .= ' |
| 942 | 990 | </select>'; |
| 943 | 991 | |
@@ -999,12 +1047,13 @@ discard block |
||
| 999 | 1047 | 'data' => array( |
| 1000 | 1048 | 'function' => function ($rowData) use ($txt) |
| 1001 | 1049 | { |
| 1002 | - if (empty($rowData['hidden'])) |
|
| 1003 | - return $txt['smileys_location_form']; |
|
| 1004 | - elseif ($rowData['hidden'] == 1) |
|
| 1005 | - return $txt['smileys_location_hidden']; |
|
| 1006 | - else |
|
| 1007 | - return $txt['smileys_location_popup']; |
|
| 1050 | + if (empty($rowData['hidden'])) { |
|
| 1051 | + return $txt['smileys_location_form']; |
|
| 1052 | + } elseif ($rowData['hidden'] == 1) { |
|
| 1053 | + return $txt['smileys_location_hidden']; |
|
| 1054 | + } else { |
|
| 1055 | + return $txt['smileys_location_popup']; |
|
| 1056 | + } |
|
| 1008 | 1057 | }, |
| 1009 | 1058 | ), |
| 1010 | 1059 | 'sort' => array( |
@@ -1019,19 +1068,22 @@ discard block |
||
| 1019 | 1068 | 'data' => array( |
| 1020 | 1069 | 'function' => function ($rowData) use ($context, $txt, $modSettings, $smcFunc) |
| 1021 | 1070 | { |
| 1022 | - if (empty($modSettings['smileys_dir']) || !is_dir($modSettings['smileys_dir'])) |
|
| 1023 | - return $smcFunc['htmlspecialchars']($rowData['description']); |
|
| 1071 | + if (empty($modSettings['smileys_dir']) || !is_dir($modSettings['smileys_dir'])) { |
|
| 1072 | + return $smcFunc['htmlspecialchars']($rowData['description']); |
|
| 1073 | + } |
|
| 1024 | 1074 | |
| 1025 | 1075 | // Check if there are smileys missing in some sets. |
| 1026 | 1076 | $missing_sets = array(); |
| 1027 | - foreach ($context['smiley_sets'] as $smiley_set) |
|
| 1028 | - if (!file_exists(sprintf('%1$s/%2$s/%3$s', $modSettings['smileys_dir'], $smiley_set['path'], $rowData['filename']))) |
|
| 1077 | + foreach ($context['smiley_sets'] as $smiley_set) { |
|
| 1078 | + if (!file_exists(sprintf('%1$s/%2$s/%3$s', $modSettings['smileys_dir'], $smiley_set['path'], $rowData['filename']))) |
|
| 1029 | 1079 | $missing_sets[] = $smiley_set['path']; |
| 1080 | + } |
|
| 1030 | 1081 | |
| 1031 | 1082 | $description = $smcFunc['htmlspecialchars']($rowData['description']); |
| 1032 | 1083 | |
| 1033 | - if (!empty($missing_sets)) |
|
| 1034 | - $description .= sprintf('<br><span class="smalltext"><strong>%1$s:</strong> %2$s</span>', $txt['smileys_not_found_in_set'], implode(', ', $missing_sets)); |
|
| 1084 | + if (!empty($missing_sets)) { |
|
| 1085 | + $description .= sprintf('<br><span class="smalltext"><strong>%1$s:</strong> %2$s</span>', $txt['smileys_not_found_in_set'], implode(', ', $missing_sets)); |
|
| 1086 | + } |
|
| 1035 | 1087 | |
| 1036 | 1088 | return $description; |
| 1037 | 1089 | }, |
@@ -1147,13 +1199,14 @@ discard block |
||
| 1147 | 1199 | $context['smileys_dir_found'] = is_dir($context['smileys_dir']); |
| 1148 | 1200 | $context['smiley_sets'] = explode(',', $modSettings['smiley_sets_known']); |
| 1149 | 1201 | $set_names = explode("\n", $modSettings['smiley_sets_names']); |
| 1150 | - foreach ($context['smiley_sets'] as $i => $set) |
|
| 1151 | - $context['smiley_sets'][$i] = array( |
|
| 1202 | + foreach ($context['smiley_sets'] as $i => $set) { |
|
| 1203 | + $context['smiley_sets'][$i] = array( |
|
| 1152 | 1204 | 'id' => $i, |
| 1153 | 1205 | 'path' => $smcFunc['htmlspecialchars']($set), |
| 1154 | 1206 | 'name' => $smcFunc['htmlspecialchars']($set_names[$i]), |
| 1155 | 1207 | 'selected' => $set == $modSettings['smiley_sets_default'] |
| 1156 | 1208 | ); |
| 1209 | + } |
|
| 1157 | 1210 | |
| 1158 | 1211 | $context['selected_set'] = $modSettings['smiley_sets_default']; |
| 1159 | 1212 | |
@@ -1163,17 +1216,19 @@ discard block |
||
| 1163 | 1216 | { |
| 1164 | 1217 | foreach ($context['smiley_sets'] as $smiley_set) |
| 1165 | 1218 | { |
| 1166 | - if (!file_exists($context['smileys_dir'] . '/' . un_htmlspecialchars($smiley_set['path']))) |
|
| 1167 | - continue; |
|
| 1219 | + if (!file_exists($context['smileys_dir'] . '/' . un_htmlspecialchars($smiley_set['path']))) { |
|
| 1220 | + continue; |
|
| 1221 | + } |
|
| 1168 | 1222 | |
| 1169 | 1223 | $dir = dir($context['smileys_dir'] . '/' . un_htmlspecialchars($smiley_set['path'])); |
| 1170 | 1224 | while ($entry = $dir->read()) |
| 1171 | 1225 | { |
| 1172 | - if (!in_array($entry, $context['filenames']) && in_array(strrchr($entry, '.'), array('.jpg', '.gif', '.jpeg', '.png'))) |
|
| 1173 | - $context['filenames'][strtolower($entry)] = array( |
|
| 1226 | + if (!in_array($entry, $context['filenames']) && in_array(strrchr($entry, '.'), array('.jpg', '.gif', '.jpeg', '.png'))) { |
|
| 1227 | + $context['filenames'][strtolower($entry)] = array( |
|
| 1174 | 1228 | 'id' => $smcFunc['htmlspecialchars']($entry), |
| 1175 | 1229 | 'selected' => false, |
| 1176 | 1230 | ); |
| 1231 | + } |
|
| 1177 | 1232 | } |
| 1178 | 1233 | $dir->close(); |
| 1179 | 1234 | } |
@@ -1188,8 +1243,9 @@ discard block |
||
| 1188 | 1243 | 'current_smiley' => (int) $_REQUEST['smiley'], |
| 1189 | 1244 | ) |
| 1190 | 1245 | ); |
| 1191 | - if ($smcFunc['db_num_rows']($request) != 1) |
|
| 1192 | - fatal_lang_error('smiley_not_found'); |
|
| 1246 | + if ($smcFunc['db_num_rows']($request) != 1) { |
|
| 1247 | + fatal_lang_error('smiley_not_found'); |
|
| 1248 | + } |
|
| 1193 | 1249 | $context['current_smiley'] = $smcFunc['db_fetch_assoc']($request); |
| 1194 | 1250 | $smcFunc['db_free_result']($request); |
| 1195 | 1251 | |
@@ -1197,8 +1253,9 @@ discard block |
||
| 1197 | 1253 | $context['current_smiley']['filename'] = $smcFunc['htmlspecialchars']($context['current_smiley']['filename']); |
| 1198 | 1254 | $context['current_smiley']['description'] = $smcFunc['htmlspecialchars']($context['current_smiley']['description']); |
| 1199 | 1255 | |
| 1200 | - if (isset($context['filenames'][strtolower($context['current_smiley']['filename'])])) |
|
| 1201 | - $context['filenames'][strtolower($context['current_smiley']['filename'])]['selected'] = true; |
|
| 1256 | + if (isset($context['filenames'][strtolower($context['current_smiley']['filename'])])) { |
|
| 1257 | + $context['filenames'][strtolower($context['current_smiley']['filename'])]['selected'] = true; |
|
| 1258 | + } |
|
| 1202 | 1259 | } |
| 1203 | 1260 | } |
| 1204 | 1261 | |
@@ -1223,8 +1280,9 @@ discard block |
||
| 1223 | 1280 | ) |
| 1224 | 1281 | ); |
| 1225 | 1282 | $smileys = array(); |
| 1226 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1227 | - $smileys[] = $row; |
|
| 1283 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1284 | + $smileys[] = $row; |
|
| 1285 | + } |
|
| 1228 | 1286 | $smcFunc['db_free_result']($request); |
| 1229 | 1287 | |
| 1230 | 1288 | return $smileys; |
@@ -1264,8 +1322,9 @@ discard block |
||
| 1264 | 1322 | $_GET['location'] = empty($_GET['location']) || $_GET['location'] != 'popup' ? 0 : 2; |
| 1265 | 1323 | $_GET['source'] = empty($_GET['source']) ? 0 : (int) $_GET['source']; |
| 1266 | 1324 | |
| 1267 | - if (empty($_GET['source'])) |
|
| 1268 | - fatal_lang_error('smiley_not_found'); |
|
| 1325 | + if (empty($_GET['source'])) { |
|
| 1326 | + fatal_lang_error('smiley_not_found'); |
|
| 1327 | + } |
|
| 1269 | 1328 | |
| 1270 | 1329 | if (!empty($_GET['after'])) |
| 1271 | 1330 | { |
@@ -1281,12 +1340,12 @@ discard block |
||
| 1281 | 1340 | 'after_smiley' => $_GET['after'], |
| 1282 | 1341 | ) |
| 1283 | 1342 | ); |
| 1284 | - if ($smcFunc['db_num_rows']($request) != 1) |
|
| 1285 | - fatal_lang_error('smiley_not_found'); |
|
| 1343 | + if ($smcFunc['db_num_rows']($request) != 1) { |
|
| 1344 | + fatal_lang_error('smiley_not_found'); |
|
| 1345 | + } |
|
| 1286 | 1346 | list ($smiley_row, $smiley_order, $smileyLocation) = $smcFunc['db_fetch_row']($request); |
| 1287 | 1347 | $smcFunc['db_free_result']($request); |
| 1288 | - } |
|
| 1289 | - else |
|
| 1348 | + } else |
|
| 1290 | 1349 | { |
| 1291 | 1350 | $smiley_row = (int) $_GET['row']; |
| 1292 | 1351 | $smiley_order = -1; |
@@ -1360,14 +1419,15 @@ discard block |
||
| 1360 | 1419 | $context['move_smiley'] = empty($_REQUEST['move']) ? 0 : (int) $_REQUEST['move']; |
| 1361 | 1420 | |
| 1362 | 1421 | // Make sure all rows are sequential. |
| 1363 | - foreach (array_keys($context['smileys']) as $location) |
|
| 1364 | - $context['smileys'][$location] = array( |
|
| 1422 | + foreach (array_keys($context['smileys']) as $location) { |
|
| 1423 | + $context['smileys'][$location] = array( |
|
| 1365 | 1424 | 'id' => $location, |
| 1366 | 1425 | 'title' => $location == 'postform' ? $txt['smileys_location_form'] : $txt['smileys_location_popup'], |
| 1367 | 1426 | 'description' => $location == 'postform' ? $txt['smileys_location_form_description'] : $txt['smileys_location_popup_description'], |
| 1368 | 1427 | 'last_row' => count($context['smileys'][$location]['rows']), |
| 1369 | 1428 | 'rows' => array_values($context['smileys'][$location]['rows']), |
| 1370 | 1429 | ); |
| 1430 | + } |
|
| 1371 | 1431 | |
| 1372 | 1432 | // Check & fix smileys that are not ordered properly in the database. |
| 1373 | 1433 | foreach (array_keys($context['smileys']) as $location) |
@@ -1392,8 +1452,8 @@ discard block |
||
| 1392 | 1452 | $context['smileys'][$location]['rows'][$id][0]['row'] = $id; |
| 1393 | 1453 | } |
| 1394 | 1454 | // Make sure the smiley order is always sequential. |
| 1395 | - foreach ($smiley_row as $order_id => $smiley) |
|
| 1396 | - if ($order_id != $smiley['order']) |
|
| 1455 | + foreach ($smiley_row as $order_id => $smiley) { |
|
| 1456 | + if ($order_id != $smiley['order']) |
|
| 1397 | 1457 | $smcFunc['db_query']('', ' |
| 1398 | 1458 | UPDATE {db_prefix}smileys |
| 1399 | 1459 | SET smiley_order = {int:new_order} |
@@ -1403,6 +1463,7 @@ discard block |
||
| 1403 | 1463 | 'current_smiley' => $smiley['id'], |
| 1404 | 1464 | ) |
| 1405 | 1465 | ); |
| 1466 | + } |
|
| 1406 | 1467 | } |
| 1407 | 1468 | } |
| 1408 | 1469 | |
@@ -1435,19 +1496,20 @@ discard block |
||
| 1435 | 1496 | $context['filename'] = $base_name; |
| 1436 | 1497 | |
| 1437 | 1498 | // Check that the smiley is from simplemachines.org, for now... maybe add mirroring later. |
| 1438 | - if (preg_match('~^http://[\w_\-]+\.simplemachines\.org/~', $_REQUEST['set_gz']) == 0 || strpos($_REQUEST['set_gz'], 'dlattach') !== false) |
|
| 1439 | - fatal_lang_error('not_on_simplemachines'); |
|
| 1499 | + if (preg_match('~^http://[\w_\-]+\.simplemachines\.org/~', $_REQUEST['set_gz']) == 0 || strpos($_REQUEST['set_gz'], 'dlattach') !== false) { |
|
| 1500 | + fatal_lang_error('not_on_simplemachines'); |
|
| 1501 | + } |
|
| 1440 | 1502 | |
| 1441 | 1503 | $destination = $packagesdir . '/' . $base_name; |
| 1442 | 1504 | |
| 1443 | - if (file_exists($destination)) |
|
| 1444 | - fatal_lang_error('package_upload_error_exists'); |
|
| 1505 | + if (file_exists($destination)) { |
|
| 1506 | + fatal_lang_error('package_upload_error_exists'); |
|
| 1507 | + } |
|
| 1445 | 1508 | |
| 1446 | 1509 | // Let's copy it to the Packages directory |
| 1447 | 1510 | file_put_contents($destination, fetch_web_data($_REQUEST['set_gz'])); |
| 1448 | 1511 | $testing = true; |
| 1449 | - } |
|
| 1450 | - elseif (isset($_REQUEST['package'])) |
|
| 1512 | + } elseif (isset($_REQUEST['package'])) |
|
| 1451 | 1513 | { |
| 1452 | 1514 | $base_name = basename($_REQUEST['package']); |
| 1453 | 1515 | $name = $smcFunc['htmlspecialchars'](strtok(basename($_REQUEST['package']), '.')); |
@@ -1456,12 +1518,14 @@ discard block |
||
| 1456 | 1518 | $destination = $packagesdir . '/' . basename($_REQUEST['package']); |
| 1457 | 1519 | } |
| 1458 | 1520 | |
| 1459 | - if (empty($destination) || !file_exists($destination)) |
|
| 1460 | - fatal_lang_error('package_no_file', false); |
|
| 1521 | + if (empty($destination) || !file_exists($destination)) { |
|
| 1522 | + fatal_lang_error('package_no_file', false); |
|
| 1523 | + } |
|
| 1461 | 1524 | |
| 1462 | 1525 | // Make sure temp directory exists and is empty. |
| 1463 | - if (file_exists($packagesdir . '/temp')) |
|
| 1464 | - deltree($packagesdir . '/temp', false); |
|
| 1526 | + if (file_exists($packagesdir . '/temp')) { |
|
| 1527 | + deltree($packagesdir . '/temp', false); |
|
| 1528 | + } |
|
| 1465 | 1529 | |
| 1466 | 1530 | if (!mktree($packagesdir . '/temp', 0755)) |
| 1467 | 1531 | { |
@@ -1473,31 +1537,37 @@ discard block |
||
| 1473 | 1537 | create_chmod_control(array($packagesdir . '/temp/delme.tmp'), array('destination_url' => $scripturl . '?action=admin;area=smileys;sa=install;set_gz=' . $_REQUEST['set_gz'], 'crash_on_error' => true)); |
| 1474 | 1538 | |
| 1475 | 1539 | deltree($packagesdir . '/temp', false); |
| 1476 | - if (!mktree($packagesdir . '/temp', 0777)) |
|
| 1477 | - fatal_lang_error('package_cant_download', false); |
|
| 1540 | + if (!mktree($packagesdir . '/temp', 0777)) { |
|
| 1541 | + fatal_lang_error('package_cant_download', false); |
|
| 1542 | + } |
|
| 1478 | 1543 | } |
| 1479 | 1544 | } |
| 1480 | 1545 | |
| 1481 | 1546 | $extracted = read_tgz_file($destination, $packagesdir . '/temp'); |
| 1482 | - if (!$extracted) |
|
| 1483 | - fatal_lang_error('packageget_unable', false, array('http://custom.simplemachines.org/mods/index.php?action=search;type=12;basic_search=' . $name)); |
|
| 1484 | - if ($extracted && !file_exists($packagesdir . '/temp/package-info.xml')) |
|
| 1485 | - foreach ($extracted as $file) |
|
| 1547 | + if (!$extracted) { |
|
| 1548 | + fatal_lang_error('packageget_unable', false, array('http://custom.simplemachines.org/mods/index.php?action=search;type=12;basic_search=' . $name)); |
|
| 1549 | + } |
|
| 1550 | + if ($extracted && !file_exists($packagesdir . '/temp/package-info.xml')) { |
|
| 1551 | + foreach ($extracted as $file) |
|
| 1486 | 1552 | if (basename($file['filename']) == 'package-info.xml') |
| 1487 | 1553 | { |
| 1488 | 1554 | $base_path = dirname($file['filename']) . '/'; |
| 1555 | + } |
|
| 1489 | 1556 | break; |
| 1490 | 1557 | } |
| 1491 | 1558 | |
| 1492 | - if (!isset($base_path)) |
|
| 1493 | - $base_path = ''; |
|
| 1559 | + if (!isset($base_path)) { |
|
| 1560 | + $base_path = ''; |
|
| 1561 | + } |
|
| 1494 | 1562 | |
| 1495 | - if (!file_exists($packagesdir . '/temp/' . $base_path . 'package-info.xml')) |
|
| 1496 | - fatal_lang_error('package_get_error_missing_xml', false); |
|
| 1563 | + if (!file_exists($packagesdir . '/temp/' . $base_path . 'package-info.xml')) { |
|
| 1564 | + fatal_lang_error('package_get_error_missing_xml', false); |
|
| 1565 | + } |
|
| 1497 | 1566 | |
| 1498 | 1567 | $smileyInfo = getPackageInfo($context['filename']); |
| 1499 | - if (!is_array($smileyInfo)) |
|
| 1500 | - fatal_lang_error($smileyInfo); |
|
| 1568 | + if (!is_array($smileyInfo)) { |
|
| 1569 | + fatal_lang_error($smileyInfo); |
|
| 1570 | + } |
|
| 1501 | 1571 | |
| 1502 | 1572 | // See if it is installed? |
| 1503 | 1573 | $request = $smcFunc['db_query']('', ' |
@@ -1513,8 +1583,9 @@ discard block |
||
| 1513 | 1583 | ) |
| 1514 | 1584 | ); |
| 1515 | 1585 | |
| 1516 | - if ($smcFunc['db_num_rows']($request) > 0) |
|
| 1517 | - fata_lang_error('package_installed_warning1'); |
|
| 1586 | + if ($smcFunc['db_num_rows']($request) > 0) { |
|
| 1587 | + fata_lang_error('package_installed_warning1'); |
|
| 1588 | + } |
|
| 1518 | 1589 | |
| 1519 | 1590 | // Everything is fine, now it's time to do something |
| 1520 | 1591 | $actions = parsePackageInfo($smileyInfo['xml'], true, 'install'); |
@@ -1531,23 +1602,23 @@ discard block |
||
| 1531 | 1602 | { |
| 1532 | 1603 | $has_readme = true; |
| 1533 | 1604 | $type = 'package_' . $action['type']; |
| 1534 | - if (file_exists($packagesdir . '/temp/' . $base_path . $action['filename'])) |
|
| 1535 | - $context[$type] = $smcFunc['htmlspecialchars'](trim(file_get_contents($packagesdir . '/temp/' . $base_path . $action['filename']), "\n\r")); |
|
| 1536 | - elseif (file_exists($action['filename'])) |
|
| 1537 | - $context[$type] = $smcFunc['htmlspecialchars'](trim(file_get_contents($action['filename']), "\n\r")); |
|
| 1605 | + if (file_exists($packagesdir . '/temp/' . $base_path . $action['filename'])) { |
|
| 1606 | + $context[$type] = $smcFunc['htmlspecialchars'](trim(file_get_contents($packagesdir . '/temp/' . $base_path . $action['filename']), "\n\r")); |
|
| 1607 | + } elseif (file_exists($action['filename'])) { |
|
| 1608 | + $context[$type] = $smcFunc['htmlspecialchars'](trim(file_get_contents($action['filename']), "\n\r")); |
|
| 1609 | + } |
|
| 1538 | 1610 | |
| 1539 | 1611 | if (!empty($action['parse_bbc'])) |
| 1540 | 1612 | { |
| 1541 | 1613 | require_once($sourcedir . '/Subs-Post.php'); |
| 1542 | 1614 | preparsecode($context[$type]); |
| 1543 | 1615 | $context[$type] = parse_bbc($context[$type]); |
| 1616 | + } else { |
|
| 1617 | + $context[$type] = nl2br($context[$type]); |
|
| 1544 | 1618 | } |
| 1545 | - else |
|
| 1546 | - $context[$type] = nl2br($context[$type]); |
|
| 1547 | 1619 | |
| 1548 | 1620 | continue; |
| 1549 | - } |
|
| 1550 | - elseif ($action['type'] == 'require-dir') |
|
| 1621 | + } elseif ($action['type'] == 'require-dir') |
|
| 1551 | 1622 | { |
| 1552 | 1623 | // Do this one... |
| 1553 | 1624 | $thisAction = array( |
@@ -1566,12 +1637,12 @@ discard block |
||
| 1566 | 1637 | ); |
| 1567 | 1638 | } |
| 1568 | 1639 | // @todo None given? |
| 1569 | - if (empty($thisAction['description'])) |
|
| 1570 | - $thisAction['description'] = isset($action['description']) ? $action['description'] : ''; |
|
| 1640 | + if (empty($thisAction['description'])) { |
|
| 1641 | + $thisAction['description'] = isset($action['description']) ? $action['description'] : ''; |
|
| 1642 | + } |
|
| 1571 | 1643 | |
| 1572 | 1644 | $context['actions'][] = $thisAction; |
| 1573 | - } |
|
| 1574 | - elseif ($action['type'] == 'credits') |
|
| 1645 | + } elseif ($action['type'] == 'credits') |
|
| 1575 | 1646 | { |
| 1576 | 1647 | // Time to build the billboard |
| 1577 | 1648 | $credits_tag = array( |
@@ -1630,12 +1701,14 @@ discard block |
||
| 1630 | 1701 | cache_put_data('posting_smileys', null, 480); |
| 1631 | 1702 | } |
| 1632 | 1703 | |
| 1633 | - if (file_exists($packagesdir . '/temp')) |
|
| 1634 | - deltree($packagesdir . '/temp'); |
|
| 1704 | + if (file_exists($packagesdir . '/temp')) { |
|
| 1705 | + deltree($packagesdir . '/temp'); |
|
| 1706 | + } |
|
| 1635 | 1707 | |
| 1636 | - if (!$testing) |
|
| 1637 | - redirectexit('action=admin;area=smileys'); |
|
| 1638 | -} |
|
| 1708 | + if (!$testing) { |
|
| 1709 | + redirectexit('action=admin;area=smileys'); |
|
| 1710 | + } |
|
| 1711 | + } |
|
| 1639 | 1712 | |
| 1640 | 1713 | /** |
| 1641 | 1714 | * A function to import new smileys from an existing directory into the database. |
@@ -1646,15 +1719,17 @@ discard block |
||
| 1646 | 1719 | { |
| 1647 | 1720 | global $modSettings, $smcFunc; |
| 1648 | 1721 | |
| 1649 | - if (empty($modSettings['smileys_dir']) || !is_dir($modSettings['smileys_dir'] . '/' . $smileyPath)) |
|
| 1650 | - fatal_lang_error('smiley_set_unable_to_import'); |
|
| 1722 | + if (empty($modSettings['smileys_dir']) || !is_dir($modSettings['smileys_dir'] . '/' . $smileyPath)) { |
|
| 1723 | + fatal_lang_error('smiley_set_unable_to_import'); |
|
| 1724 | + } |
|
| 1651 | 1725 | |
| 1652 | 1726 | $smileys = array(); |
| 1653 | 1727 | $dir = dir($modSettings['smileys_dir'] . '/' . $smileyPath); |
| 1654 | 1728 | while ($entry = $dir->read()) |
| 1655 | 1729 | { |
| 1656 | - if (in_array(strrchr($entry, '.'), array('.jpg', '.gif', '.jpeg', '.png'))) |
|
| 1657 | - $smileys[strtolower($entry)] = $entry; |
|
| 1730 | + if (in_array(strrchr($entry, '.'), array('.jpg', '.gif', '.jpeg', '.png'))) { |
|
| 1731 | + $smileys[strtolower($entry)] = $entry; |
|
| 1732 | + } |
|
| 1658 | 1733 | } |
| 1659 | 1734 | $dir->close(); |
| 1660 | 1735 | |
@@ -1667,9 +1742,10 @@ discard block |
||
| 1667 | 1742 | 'smiley_list' => $smileys, |
| 1668 | 1743 | ) |
| 1669 | 1744 | ); |
| 1670 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1671 | - if (isset($smileys[strtolower($row['filename'])])) |
|
| 1745 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1746 | + if (isset($smileys[strtolower($row['filename'])])) |
|
| 1672 | 1747 | unset($smileys[strtolower($row['filename'])]); |
| 1748 | + } |
|
| 1673 | 1749 | $smcFunc['db_free_result']($request); |
| 1674 | 1750 | |
| 1675 | 1751 | $request = $smcFunc['db_query']('', ' |
@@ -1686,9 +1762,10 @@ discard block |
||
| 1686 | 1762 | $smcFunc['db_free_result']($request); |
| 1687 | 1763 | |
| 1688 | 1764 | $new_smileys = array(); |
| 1689 | - foreach ($smileys as $smiley) |
|
| 1690 | - if (strlen($smiley) <= 48) |
|
| 1765 | + foreach ($smileys as $smiley) { |
|
| 1766 | + if (strlen($smiley) <= 48) |
|
| 1691 | 1767 | $new_smileys[] = array(':' . strtok($smiley, '.') . ':', $smiley, strtok($smiley, '.'), 0, ++$smiley_order); |
| 1768 | + } |
|
| 1692 | 1769 | |
| 1693 | 1770 | if (!empty($new_smileys)) |
| 1694 | 1771 | { |
@@ -1753,8 +1830,9 @@ discard block |
||
| 1753 | 1830 | if (isset($_POST['delete']) && !empty($_POST['checked_icons'])) |
| 1754 | 1831 | { |
| 1755 | 1832 | $deleteIcons = array(); |
| 1756 | - foreach ($_POST['checked_icons'] as $icon) |
|
| 1757 | - $deleteIcons[] = (int) $icon; |
|
| 1833 | + foreach ($_POST['checked_icons'] as $icon) { |
|
| 1834 | + $deleteIcons[] = (int) $icon; |
|
| 1835 | + } |
|
| 1758 | 1836 | |
| 1759 | 1837 | // Do the actual delete! |
| 1760 | 1838 | $smcFunc['db_query']('', ' |
@@ -1771,35 +1849,41 @@ discard block |
||
| 1771 | 1849 | $_GET['icon'] = (int) $_GET['icon']; |
| 1772 | 1850 | |
| 1773 | 1851 | // Do some preperation with the data... like check the icon exists *somewhere* |
| 1774 | - if (strpos($_POST['icon_filename'], '.png') !== false) |
|
| 1775 | - $_POST['icon_filename'] = substr($_POST['icon_filename'], 0, -4); |
|
| 1776 | - if (!file_exists($settings['default_theme_dir'] . '/images/post/' . $_POST['icon_filename'] . '.png')) |
|
| 1777 | - fatal_lang_error('icon_not_found'); |
|
| 1852 | + if (strpos($_POST['icon_filename'], '.png') !== false) { |
|
| 1853 | + $_POST['icon_filename'] = substr($_POST['icon_filename'], 0, -4); |
|
| 1854 | + } |
|
| 1855 | + if (!file_exists($settings['default_theme_dir'] . '/images/post/' . $_POST['icon_filename'] . '.png')) { |
|
| 1856 | + fatal_lang_error('icon_not_found'); |
|
| 1857 | + } |
|
| 1778 | 1858 | // There is a 16 character limit on message icons... |
| 1779 | - elseif (strlen($_POST['icon_filename']) > 16) |
|
| 1780 | - fatal_lang_error('icon_name_too_long'); |
|
| 1781 | - elseif ($_POST['icon_location'] == $_GET['icon'] && !empty($_GET['icon'])) |
|
| 1782 | - fatal_lang_error('icon_after_itself'); |
|
| 1859 | + elseif (strlen($_POST['icon_filename']) > 16) { |
|
| 1860 | + fatal_lang_error('icon_name_too_long'); |
|
| 1861 | + } elseif ($_POST['icon_location'] == $_GET['icon'] && !empty($_GET['icon'])) { |
|
| 1862 | + fatal_lang_error('icon_after_itself'); |
|
| 1863 | + } |
|
| 1783 | 1864 | |
| 1784 | 1865 | // First do the sorting... if this is an edit reduce the order of everything after it by one ;) |
| 1785 | 1866 | if ($_GET['icon'] != 0) |
| 1786 | 1867 | { |
| 1787 | 1868 | $oldOrder = $context['icons'][$_GET['icon']]['true_order']; |
| 1788 | - foreach ($context['icons'] as $id => $data) |
|
| 1789 | - if ($data['true_order'] > $oldOrder) |
|
| 1869 | + foreach ($context['icons'] as $id => $data) { |
|
| 1870 | + if ($data['true_order'] > $oldOrder) |
|
| 1790 | 1871 | $context['icons'][$id]['true_order']--; |
| 1872 | + } |
|
| 1791 | 1873 | } |
| 1792 | 1874 | |
| 1793 | 1875 | // If there are no existing icons and this is a new one, set the id to 1 (mainly for non-mysql) |
| 1794 | - if (empty($_GET['icon']) && empty($context['icons'])) |
|
| 1795 | - $_GET['icon'] = 1; |
|
| 1876 | + if (empty($_GET['icon']) && empty($context['icons'])) { |
|
| 1877 | + $_GET['icon'] = 1; |
|
| 1878 | + } |
|
| 1796 | 1879 | |
| 1797 | 1880 | // Get the new order. |
| 1798 | 1881 | $newOrder = $_POST['icon_location'] == 0 ? 0 : $context['icons'][$_POST['icon_location']]['true_order'] + 1; |
| 1799 | 1882 | // Do the same, but with the one that used to be after this icon, done to avoid conflict. |
| 1800 | - foreach ($context['icons'] as $id => $data) |
|
| 1801 | - if ($data['true_order'] >= $newOrder) |
|
| 1883 | + foreach ($context['icons'] as $id => $data) { |
|
| 1884 | + if ($data['true_order'] >= $newOrder) |
|
| 1802 | 1885 | $context['icons'][$id]['true_order']++; |
| 1886 | + } |
|
| 1803 | 1887 | |
| 1804 | 1888 | // Finally set the current icon's position! |
| 1805 | 1889 | $context['icons'][$_GET['icon']]['true_order'] = $newOrder; |
@@ -1817,8 +1901,7 @@ discard block |
||
| 1817 | 1901 | if ($id != 0) |
| 1818 | 1902 | { |
| 1819 | 1903 | $iconInsert[] = array($id, $icon['board_id'], $icon['title'], $icon['filename'], $icon['true_order']); |
| 1820 | - } |
|
| 1821 | - else |
|
| 1904 | + } else |
|
| 1822 | 1905 | { |
| 1823 | 1906 | $iconInsert_new[] = array($icon['board_id'], $icon['title'], $icon['filename'], $icon['true_order']); |
| 1824 | 1907 | } |
@@ -1843,8 +1926,9 @@ discard block |
||
| 1843 | 1926 | } |
| 1844 | 1927 | |
| 1845 | 1928 | // Unless we're adding a new thing, we'll escape |
| 1846 | - if (!isset($_POST['add'])) |
|
| 1847 | - redirectexit('action=admin;area=smileys;sa=editicons'); |
|
| 1929 | + if (!isset($_POST['add'])) { |
|
| 1930 | + redirectexit('action=admin;area=smileys;sa=editicons'); |
|
| 1931 | + } |
|
| 1848 | 1932 | } |
| 1849 | 1933 | |
| 1850 | 1934 | $context[$context['admin_menu_name']]['current_subsection'] = 'editicons'; |
@@ -1954,8 +2038,9 @@ discard block |
||
| 1954 | 2038 | $context['new_icon'] = !isset($_GET['icon']); |
| 1955 | 2039 | |
| 1956 | 2040 | // Get the properties of the current icon from the icon list. |
| 1957 | - if (!$context['new_icon']) |
|
| 1958 | - $context['icon'] = $context['icons'][$_GET['icon']]; |
|
| 2041 | + if (!$context['new_icon']) { |
|
| 2042 | + $context['icon'] = $context['icons'][$_GET['icon']]; |
|
| 2043 | + } |
|
| 1959 | 2044 | |
| 1960 | 2045 | // Get a list of boards needed for assigning this icon to a specific board. |
| 1961 | 2046 | $boardListOptions = array( |
@@ -1989,8 +2074,9 @@ discard block |
||
| 1989 | 2074 | ); |
| 1990 | 2075 | |
| 1991 | 2076 | $message_icons = array(); |
| 1992 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1993 | - $message_icons[] = $row; |
|
| 2077 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2078 | + $message_icons[] = $row; |
|
| 2079 | + } |
|
| 1994 | 2080 | $smcFunc['db_free_result']($request); |
| 1995 | 2081 | |
| 1996 | 2082 | return $message_icons; |
@@ -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 | * Add the file functions to the $smcFunc array. |
@@ -52,8 +53,9 @@ discard block |
||
| 52 | 53 | 'messages', 'moderators', 'package_servers', 'permission_profiles', 'permissions', 'personal_messages', |
| 53 | 54 | 'pm_recipients', 'poll_choices', 'polls', 'scheduled_tasks', 'sessions', 'settings', 'smileys', |
| 54 | 55 | 'themes', 'topics'); |
| 55 | - foreach ($reservedTables as $k => $table_name) |
|
| 56 | - $reservedTables[$k] = strtolower($db_prefix . $table_name); |
|
| 56 | + foreach ($reservedTables as $k => $table_name) { |
|
| 57 | + $reservedTables[$k] = strtolower($db_prefix . $table_name); |
|
| 58 | + } |
|
| 57 | 59 | |
| 58 | 60 | // We in turn may need the extra stuff. |
| 59 | 61 | db_extend('extra'); |
@@ -105,8 +107,9 @@ discard block |
||
| 105 | 107 | $table_name = str_replace('{db_prefix}', $db_prefix, $table_name); |
| 106 | 108 | |
| 107 | 109 | // First - no way do we touch SMF tables. |
| 108 | - if (in_array(strtolower($table_name), $reservedTables)) |
|
| 109 | - return false; |
|
| 110 | + if (in_array(strtolower($table_name), $reservedTables)) { |
|
| 111 | + return false; |
|
| 112 | + } |
|
| 110 | 113 | |
| 111 | 114 | // Log that we'll want to remove this on uninstall. |
| 112 | 115 | $db_package_log[] = array('remove_table', $table_name); |
@@ -116,16 +119,18 @@ discard block |
||
| 116 | 119 | if (in_array($full_table_name, $tables)) |
| 117 | 120 | { |
| 118 | 121 | // This is a sad day... drop the table? If not, return false (error) by default. |
| 119 | - if ($if_exists == 'overwrite') |
|
| 120 | - $smcFunc['db_drop_table']($table_name); |
|
| 121 | - else |
|
| 122 | - return $if_exists == 'ignore'; |
|
| 122 | + if ($if_exists == 'overwrite') { |
|
| 123 | + $smcFunc['db_drop_table']($table_name); |
|
| 124 | + } else { |
|
| 125 | + return $if_exists == 'ignore'; |
|
| 126 | + } |
|
| 123 | 127 | } |
| 124 | 128 | |
| 125 | 129 | // Righty - let's do the damn thing! |
| 126 | 130 | $table_query = 'CREATE TABLE ' . $table_name . "\n" . '('; |
| 127 | - foreach ($columns as $column) |
|
| 128 | - $table_query .= "\n\t" . smf_db_create_query_column($column) . ','; |
|
| 131 | + foreach ($columns as $column) { |
|
| 132 | + $table_query .= "\n\t" . smf_db_create_query_column($column) . ','; |
|
| 133 | + } |
|
| 129 | 134 | |
| 130 | 135 | // Loop through the indexes next... |
| 131 | 136 | foreach ($indexes as $index) |
@@ -133,19 +138,21 @@ discard block |
||
| 133 | 138 | $columns = implode(',', $index['columns']); |
| 134 | 139 | |
| 135 | 140 | // Is it the primary? |
| 136 | - if (isset($index['type']) && $index['type'] == 'primary') |
|
| 137 | - $table_query .= "\n\t" . 'PRIMARY KEY (' . implode(',', $index['columns']) . '),'; |
|
| 138 | - else |
|
| 141 | + if (isset($index['type']) && $index['type'] == 'primary') { |
|
| 142 | + $table_query .= "\n\t" . 'PRIMARY KEY (' . implode(',', $index['columns']) . '),'; |
|
| 143 | + } else |
|
| 139 | 144 | { |
| 140 | - if (empty($index['name'])) |
|
| 141 | - $index['name'] = implode('_', $index['columns']); |
|
| 145 | + if (empty($index['name'])) { |
|
| 146 | + $index['name'] = implode('_', $index['columns']); |
|
| 147 | + } |
|
| 142 | 148 | $table_query .= "\n\t" . (isset($index['type']) && $index['type'] == 'unique' ? 'UNIQUE' : 'KEY') . ' ' . $index['name'] . ' (' . $columns . '),'; |
| 143 | 149 | } |
| 144 | 150 | } |
| 145 | 151 | |
| 146 | 152 | // No trailing commas! |
| 147 | - if (substr($table_query, -1) == ',') |
|
| 148 | - $table_query = substr($table_query, 0, -1); |
|
| 153 | + if (substr($table_query, -1) == ',') { |
|
| 154 | + $table_query = substr($table_query, 0, -1); |
|
| 155 | + } |
|
| 149 | 156 | |
| 150 | 157 | // Which engine do we want here? |
| 151 | 158 | if (empty($engines)) |
@@ -155,8 +162,9 @@ discard block |
||
| 155 | 162 | |
| 156 | 163 | while ($row = $smcFunc['db_fetch_assoc']($get_engines)) |
| 157 | 164 | { |
| 158 | - if ($row['Support'] == 'YES' || $row['Support'] == 'DEFAULT') |
|
| 159 | - $engines[] = $row['Engine']; |
|
| 165 | + if ($row['Support'] == 'YES' || $row['Support'] == 'DEFAULT') { |
|
| 166 | + $engines[] = $row['Engine']; |
|
| 167 | + } |
|
| 160 | 168 | } |
| 161 | 169 | |
| 162 | 170 | $smcFunc['db_free_result']($get_engines); |
@@ -170,8 +178,9 @@ discard block |
||
| 170 | 178 | } |
| 171 | 179 | |
| 172 | 180 | $table_query .= ') ENGINE=' . $parameters['engine']; |
| 173 | - if (!empty($db_character_set) && $db_character_set == 'utf8') |
|
| 174 | - $table_query .= ' DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci'; |
|
| 181 | + if (!empty($db_character_set) && $db_character_set == 'utf8') { |
|
| 182 | + $table_query .= ' DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci'; |
|
| 183 | + } |
|
| 175 | 184 | |
| 176 | 185 | // Create the table! |
| 177 | 186 | $smcFunc['db_query']('', $table_query, |
@@ -203,8 +212,9 @@ discard block |
||
| 203 | 212 | $table_name = str_replace('{db_prefix}', $db_prefix, $table_name); |
| 204 | 213 | |
| 205 | 214 | // God no - dropping one of these = bad. |
| 206 | - if (in_array(strtolower($table_name), $reservedTables)) |
|
| 207 | - return false; |
|
| 215 | + if (in_array(strtolower($table_name), $reservedTables)) { |
|
| 216 | + return false; |
|
| 217 | + } |
|
| 208 | 218 | |
| 209 | 219 | // Does it exist? |
| 210 | 220 | if (in_array($full_table_name, $smcFunc['db_list_tables']())) |
@@ -245,14 +255,16 @@ discard block |
||
| 245 | 255 | |
| 246 | 256 | // Does it exist - if so don't add it again! |
| 247 | 257 | $columns = $smcFunc['db_list_columns']($table_name, false); |
| 248 | - foreach ($columns as $column) |
|
| 249 | - if ($column == $column_info['name']) |
|
| 258 | + foreach ($columns as $column) { |
|
| 259 | + if ($column == $column_info['name']) |
|
| 250 | 260 | { |
| 251 | 261 | // If we're going to overwrite then use change column. |
| 252 | 262 | if ($if_exists == 'update') |
| 253 | 263 | return $smcFunc['db_change_column']($table_name, $column_info['name'], $column_info); |
| 254 | - else |
|
| 255 | - return false; |
|
| 264 | + } |
|
| 265 | + else { |
|
| 266 | + return false; |
|
| 267 | + } |
|
| 256 | 268 | } |
| 257 | 269 | |
| 258 | 270 | // Get the specifics... |
@@ -288,8 +300,8 @@ discard block |
||
| 288 | 300 | |
| 289 | 301 | // Does it exist? |
| 290 | 302 | $columns = $smcFunc['db_list_columns']($table_name, true); |
| 291 | - foreach ($columns as $column) |
|
| 292 | - if ($column['name'] == $column_name) |
|
| 303 | + foreach ($columns as $column) { |
|
| 304 | + if ($column['name'] == $column_name) |
|
| 293 | 305 | { |
| 294 | 306 | $smcFunc['db_query']('', ' |
| 295 | 307 | ALTER TABLE ' . $table_name . ' |
@@ -298,6 +310,7 @@ discard block |
||
| 298 | 310 | 'security_override' => true, |
| 299 | 311 | ) |
| 300 | 312 | ); |
| 313 | + } |
|
| 301 | 314 | |
| 302 | 315 | return true; |
| 303 | 316 | } |
@@ -324,37 +337,47 @@ discard block |
||
| 324 | 337 | // Check it does exist! |
| 325 | 338 | $columns = $smcFunc['db_list_columns']($table_name, true); |
| 326 | 339 | $old_info = null; |
| 327 | - foreach ($columns as $column) |
|
| 328 | - if ($column['name'] == $old_column) |
|
| 340 | + foreach ($columns as $column) { |
|
| 341 | + if ($column['name'] == $old_column) |
|
| 329 | 342 | $old_info = $column; |
| 343 | + } |
|
| 330 | 344 | |
| 331 | 345 | // Nothing? |
| 332 | - if ($old_info == null) |
|
| 333 | - return false; |
|
| 346 | + if ($old_info == null) { |
|
| 347 | + return false; |
|
| 348 | + } |
|
| 334 | 349 | |
| 335 | 350 | // Get the right bits. |
| 336 | - if (!isset($column_info['name'])) |
|
| 337 | - $column_info['name'] = $old_column; |
|
| 338 | - if (!isset($column_info['default'])) |
|
| 339 | - $column_info['default'] = $old_info['default']; |
|
| 340 | - if (!isset($column_info['null'])) |
|
| 341 | - $column_info['null'] = $old_info['null']; |
|
| 342 | - if (!isset($column_info['auto'])) |
|
| 343 | - $column_info['auto'] = $old_info['auto']; |
|
| 344 | - if (!isset($column_info['type'])) |
|
| 345 | - $column_info['type'] = $old_info['type']; |
|
| 346 | - if (!isset($column_info['size']) || !is_numeric($column_info['size'])) |
|
| 347 | - $column_info['size'] = $old_info['size']; |
|
| 348 | - if (!isset($column_info['unsigned']) || !in_array($column_info['type'], array('int', 'tinyint', 'smallint', 'mediumint', 'bigint'))) |
|
| 349 | - $column_info['unsigned'] = ''; |
|
| 351 | + if (!isset($column_info['name'])) { |
|
| 352 | + $column_info['name'] = $old_column; |
|
| 353 | + } |
|
| 354 | + if (!isset($column_info['default'])) { |
|
| 355 | + $column_info['default'] = $old_info['default']; |
|
| 356 | + } |
|
| 357 | + if (!isset($column_info['null'])) { |
|
| 358 | + $column_info['null'] = $old_info['null']; |
|
| 359 | + } |
|
| 360 | + if (!isset($column_info['auto'])) { |
|
| 361 | + $column_info['auto'] = $old_info['auto']; |
|
| 362 | + } |
|
| 363 | + if (!isset($column_info['type'])) { |
|
| 364 | + $column_info['type'] = $old_info['type']; |
|
| 365 | + } |
|
| 366 | + if (!isset($column_info['size']) || !is_numeric($column_info['size'])) { |
|
| 367 | + $column_info['size'] = $old_info['size']; |
|
| 368 | + } |
|
| 369 | + if (!isset($column_info['unsigned']) || !in_array($column_info['type'], array('int', 'tinyint', 'smallint', 'mediumint', 'bigint'))) { |
|
| 370 | + $column_info['unsigned'] = ''; |
|
| 371 | + } |
|
| 350 | 372 | |
| 351 | 373 | list ($type, $size) = $smcFunc['db_calculate_type']($column_info['type'], $column_info['size']); |
| 352 | 374 | |
| 353 | 375 | // Allow for unsigned integers (mysql only) |
| 354 | 376 | $unsigned = in_array($type, array('int', 'tinyint', 'smallint', 'mediumint', 'bigint')) && !empty($column_info['unsigned']) ? 'unsigned ' : ''; |
| 355 | 377 | |
| 356 | - if ($size !== null) |
|
| 357 | - $type = $type . '(' . $size . ')'; |
|
| 378 | + if ($size !== null) { |
|
| 379 | + $type = $type . '(' . $size . ')'; |
|
| 380 | + } |
|
| 358 | 381 | |
| 359 | 382 | $smcFunc['db_query']('', ' |
| 360 | 383 | ALTER TABLE ' . $table_name . ' |
@@ -384,21 +407,23 @@ discard block |
||
| 384 | 407 | $table_name = str_replace('{db_prefix}', $db_prefix, $table_name); |
| 385 | 408 | |
| 386 | 409 | // No columns = no index. |
| 387 | - if (empty($index_info['columns'])) |
|
| 388 | - return false; |
|
| 410 | + if (empty($index_info['columns'])) { |
|
| 411 | + return false; |
|
| 412 | + } |
|
| 389 | 413 | $columns = implode(',', $index_info['columns']); |
| 390 | 414 | |
| 391 | 415 | // No name - make it up! |
| 392 | 416 | if (empty($index_info['name'])) |
| 393 | 417 | { |
| 394 | 418 | // No need for primary. |
| 395 | - if (isset($index_info['type']) && $index_info['type'] == 'primary') |
|
| 396 | - $index_info['name'] = ''; |
|
| 397 | - else |
|
| 398 | - $index_info['name'] = implode('_', $index_info['columns']); |
|
| 419 | + if (isset($index_info['type']) && $index_info['type'] == 'primary') { |
|
| 420 | + $index_info['name'] = ''; |
|
| 421 | + } else { |
|
| 422 | + $index_info['name'] = implode('_', $index_info['columns']); |
|
| 423 | + } |
|
| 424 | + } else { |
|
| 425 | + $index_info['name'] = $index_info['name']; |
|
| 399 | 426 | } |
| 400 | - else |
|
| 401 | - $index_info['name'] = $index_info['name']; |
|
| 402 | 427 | |
| 403 | 428 | // Log that we are going to want to remove this! |
| 404 | 429 | $db_package_log[] = array('remove_index', $table_name, $index_info['name']); |
@@ -411,10 +436,11 @@ discard block |
||
| 411 | 436 | if ($index['name'] == $index_info['name'] || ($index['type'] == 'primary' && isset($index_info['type']) && $index_info['type'] == 'primary')) |
| 412 | 437 | { |
| 413 | 438 | // If we want to overwrite simply remove the current one then continue. |
| 414 | - if ($if_exists != 'update' || $index['type'] == 'primary') |
|
| 415 | - return false; |
|
| 416 | - else |
|
| 417 | - $smcFunc['db_remove_index']($table_name, $index_info['name']); |
|
| 439 | + if ($if_exists != 'update' || $index['type'] == 'primary') { |
|
| 440 | + return false; |
|
| 441 | + } else { |
|
| 442 | + $smcFunc['db_remove_index']($table_name, $index_info['name']); |
|
| 443 | + } |
|
| 418 | 444 | } |
| 419 | 445 | } |
| 420 | 446 | |
@@ -428,8 +454,7 @@ discard block |
||
| 428 | 454 | 'security_override' => true, |
| 429 | 455 | ) |
| 430 | 456 | ); |
| 431 | - } |
|
| 432 | - else |
|
| 457 | + } else |
|
| 433 | 458 | { |
| 434 | 459 | $smcFunc['db_query']('', ' |
| 435 | 460 | ALTER TABLE ' . $table_name . ' |
@@ -513,8 +538,7 @@ discard block |
||
| 513 | 538 | $types = array( |
| 514 | 539 | 'inet' => 'varbinary', |
| 515 | 540 | ); |
| 516 | - } |
|
| 517 | - else |
|
| 541 | + } else |
|
| 518 | 542 | { |
| 519 | 543 | $types = array( |
| 520 | 544 | 'varbinary' => 'inet', |
@@ -528,16 +552,15 @@ discard block |
||
| 528 | 552 | { |
| 529 | 553 | $type_size = 16; |
| 530 | 554 | $type_name = 'varbinary'; |
| 531 | - } |
|
| 532 | - elseif ($type_name == 'varbinary' && $reverse && $type_size == 16) |
|
| 555 | + } elseif ($type_name == 'varbinary' && $reverse && $type_size == 16) |
|
| 533 | 556 | { |
| 534 | 557 | $type_name = 'inet'; |
| 535 | 558 | $type_size = null; |
| 559 | + } elseif ($type_name == 'varbinary') { |
|
| 560 | + $type_name = 'varbinary'; |
|
| 561 | + } else { |
|
| 562 | + $type_name = $types[$type_name]; |
|
| 536 | 563 | } |
| 537 | - elseif ($type_name == 'varbinary') |
|
| 538 | - $type_name = 'varbinary'; |
|
| 539 | - else |
|
| 540 | - $type_name = $types[$type_name]; |
|
| 541 | 564 | } |
| 542 | 565 | |
| 543 | 566 | return array($type_name, $type_size); |
@@ -605,8 +628,7 @@ discard block |
||
| 605 | 628 | if (!$detail) |
| 606 | 629 | { |
| 607 | 630 | $columns[] = $row['Field']; |
| 608 | - } |
|
| 609 | - else |
|
| 631 | + } else |
|
| 610 | 632 | { |
| 611 | 633 | // Is there an auto_increment? |
| 612 | 634 | $auto = strpos($row['Extra'], 'auto_increment') !== false ? true : false; |
@@ -616,10 +638,10 @@ discard block |
||
| 616 | 638 | { |
| 617 | 639 | $type = $matches[1]; |
| 618 | 640 | $size = $matches[2]; |
| 619 | - if (!empty($matches[3]) && $matches[3] == 'unsigned') |
|
| 620 | - $unsigned = true; |
|
| 621 | - } |
|
| 622 | - else |
|
| 641 | + if (!empty($matches[3]) && $matches[3] == 'unsigned') { |
|
| 642 | + $unsigned = true; |
|
| 643 | + } |
|
| 644 | + } else |
|
| 623 | 645 | { |
| 624 | 646 | $type = $row['Type']; |
| 625 | 647 | $size = null; |
@@ -670,19 +692,20 @@ discard block |
||
| 670 | 692 | $indexes = array(); |
| 671 | 693 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 672 | 694 | { |
| 673 | - if (!$detail) |
|
| 674 | - $indexes[] = $row['Key_name']; |
|
| 675 | - else |
|
| 695 | + if (!$detail) { |
|
| 696 | + $indexes[] = $row['Key_name']; |
|
| 697 | + } else |
|
| 676 | 698 | { |
| 677 | 699 | // What is the type? |
| 678 | - if ($row['Key_name'] == 'PRIMARY') |
|
| 679 | - $type = 'primary'; |
|
| 680 | - elseif (empty($row['Non_unique'])) |
|
| 681 | - $type = 'unique'; |
|
| 682 | - elseif (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT') |
|
| 683 | - $type = 'fulltext'; |
|
| 684 | - else |
|
| 685 | - $type = 'index'; |
|
| 700 | + if ($row['Key_name'] == 'PRIMARY') { |
|
| 701 | + $type = 'primary'; |
|
| 702 | + } elseif (empty($row['Non_unique'])) { |
|
| 703 | + $type = 'unique'; |
|
| 704 | + } elseif (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT') { |
|
| 705 | + $type = 'fulltext'; |
|
| 706 | + } else { |
|
| 707 | + $type = 'index'; |
|
| 708 | + } |
|
| 686 | 709 | |
| 687 | 710 | // This is the first column we've seen? |
| 688 | 711 | if (empty($indexes[$row['Key_name']])) |
@@ -695,10 +718,11 @@ discard block |
||
| 695 | 718 | } |
| 696 | 719 | |
| 697 | 720 | // Is it a partial index? |
| 698 | - if (!empty($row['Sub_part'])) |
|
| 699 | - $indexes[$row['Key_name']]['columns'][] = $row['Column_name'] . '(' . $row['Sub_part'] . ')'; |
|
| 700 | - else |
|
| 701 | - $indexes[$row['Key_name']]['columns'][] = $row['Column_name']; |
|
| 721 | + if (!empty($row['Sub_part'])) { |
|
| 722 | + $indexes[$row['Key_name']]['columns'][] = $row['Column_name'] . '(' . $row['Sub_part'] . ')'; |
|
| 723 | + } else { |
|
| 724 | + $indexes[$row['Key_name']]['columns'][] = $row['Column_name']; |
|
| 725 | + } |
|
| 702 | 726 | } |
| 703 | 727 | } |
| 704 | 728 | $smcFunc['db_free_result']($result); |
@@ -720,11 +744,11 @@ discard block |
||
| 720 | 744 | if (!empty($column['auto'])) |
| 721 | 745 | { |
| 722 | 746 | $default = 'auto_increment'; |
| 747 | + } elseif (isset($column['default']) && $column['default'] !== null) { |
|
| 748 | + $default = 'default \'' . $smcFunc['db_escape_string']($column['default']) . '\''; |
|
| 749 | + } else { |
|
| 750 | + $default = ''; |
|
| 723 | 751 | } |
| 724 | - elseif (isset($column['default']) && $column['default'] !== null) |
|
| 725 | - $default = 'default \'' . $smcFunc['db_escape_string']($column['default']) . '\''; |
|
| 726 | - else |
|
| 727 | - $default = ''; |
|
| 728 | 752 | |
| 729 | 753 | // Sort out the size... and stuff... |
| 730 | 754 | $column['size'] = isset($column['size']) && is_numeric($column['size']) ? $column['size'] : null; |
@@ -733,8 +757,9 @@ discard block |
||
| 733 | 757 | // Allow unsigned integers (mysql only) |
| 734 | 758 | $unsigned = in_array($type, array('int', 'tinyint', 'smallint', 'mediumint', 'bigint')) && !empty($column['unsigned']) ? 'unsigned ' : ''; |
| 735 | 759 | |
| 736 | - if ($size !== null) |
|
| 737 | - $type = $type . '(' . $size . ')'; |
|
| 760 | + if ($size !== null) { |
|
| 761 | + $type = $type . '(' . $size . ')'; |
|
| 762 | + } |
|
| 738 | 763 | |
| 739 | 764 | // Now just put it together! |
| 740 | 765 | return '`' . $column['name'] . '` ' . $type . ' ' . (!empty($unsigned) ? $unsigned : '') . (!empty($column['null']) ? '' : 'NOT NULL') . ' ' . $default; |
@@ -15,8 +15,9 @@ discard block |
||
| 15 | 15 | * @version 2.1 Beta 3 |
| 16 | 16 | */ |
| 17 | 17 | |
| 18 | -if (!defined('SMF')) |
|
| 18 | +if (!defined('SMF')) { |
|
| 19 | 19 | die('No direct access...'); |
| 20 | +} |
|
| 20 | 21 | |
| 21 | 22 | /** |
| 22 | 23 | * This defines every profile field known to man. |
@@ -29,8 +30,9 @@ discard block |
||
| 29 | 30 | global $sourcedir, $profile_vars; |
| 30 | 31 | |
| 31 | 32 | // Don't load this twice! |
| 32 | - if (!empty($profile_fields) && !$force_reload) |
|
| 33 | - return; |
|
| 33 | + if (!empty($profile_fields) && !$force_reload) { |
|
| 34 | + return; |
|
| 35 | + } |
|
| 34 | 36 | |
| 35 | 37 | /* This horrific array defines all the profile fields in the whole world! |
| 36 | 38 | In general each "field" has one array - the key of which is the database column name associated with said field. Each item |
@@ -103,13 +105,14 @@ discard block |
||
| 103 | 105 | if (isset($_POST['bday2'], $_POST['bday3']) && $value > 0 && $_POST['bday2'] > 0) |
| 104 | 106 | { |
| 105 | 107 | // Set to blank? |
| 106 | - if ((int) $_POST['bday3'] == 1 && (int) $_POST['bday2'] == 1 && (int) $value == 1) |
|
| 107 | - $value = '0001-01-01'; |
|
| 108 | - else |
|
| 109 | - $value = checkdate($value, $_POST['bday2'], $_POST['bday3'] < 4 ? 4 : $_POST['bday3']) ? sprintf('%04d-%02d-%02d', $_POST['bday3'] < 4 ? 4 : $_POST['bday3'], $_POST['bday1'], $_POST['bday2']) : '0001-01-01'; |
|
| 108 | + if ((int) $_POST['bday3'] == 1 && (int) $_POST['bday2'] == 1 && (int) $value == 1) { |
|
| 109 | + $value = '0001-01-01'; |
|
| 110 | + } else { |
|
| 111 | + $value = checkdate($value, $_POST['bday2'], $_POST['bday3'] < 4 ? 4 : $_POST['bday3']) ? sprintf('%04d-%02d-%02d', $_POST['bday3'] < 4 ? 4 : $_POST['bday3'], $_POST['bday1'], $_POST['bday2']) : '0001-01-01'; |
|
| 112 | + } |
|
| 113 | + } else { |
|
| 114 | + $value = '0001-01-01'; |
|
| 110 | 115 | } |
| 111 | - else |
|
| 112 | - $value = '0001-01-01'; |
|
| 113 | 116 | |
| 114 | 117 | $profile_vars['birthdate'] = $value; |
| 115 | 118 | $cur_profile['birthdate'] = $value; |
@@ -127,8 +130,7 @@ discard block |
||
| 127 | 130 | { |
| 128 | 131 | $value = checkdate($dates[2], $dates[3], $dates[1] < 4 ? 4 : $dates[1]) ? sprintf('%04d-%02d-%02d', $dates[1] < 4 ? 4 : $dates[1], $dates[2], $dates[3]) : '0001-01-01'; |
| 129 | 132 | return true; |
| 130 | - } |
|
| 131 | - else |
|
| 133 | + } else |
|
| 132 | 134 | { |
| 133 | 135 | $value = empty($cur_profile['birthdate']) ? '0001-01-01' : $cur_profile['birthdate']; |
| 134 | 136 | return false; |
@@ -150,10 +152,11 @@ discard block |
||
| 150 | 152 | return $txt['invalid_registration'] . ' ' . strftime('%d %b %Y ' . (strpos($user_info['time_format'], '%H') !== false ? '%I:%M:%S %p' : '%H:%M:%S'), forum_time(false)); |
| 151 | 153 | } |
| 152 | 154 | // As long as it doesn't equal "N/A"... |
| 153 | - elseif ($value != $txt['not_applicable'] && $value != strtotime(strftime('%Y-%m-%d', $cur_profile['date_registered'] + ($user_info['time_offset'] + $modSettings['time_offset']) * 3600))) |
|
| 154 | - $value = $value - ($user_info['time_offset'] + $modSettings['time_offset']) * 3600; |
|
| 155 | - else |
|
| 156 | - $value = $cur_profile['date_registered']; |
|
| 155 | + elseif ($value != $txt['not_applicable'] && $value != strtotime(strftime('%Y-%m-%d', $cur_profile['date_registered'] + ($user_info['time_offset'] + $modSettings['time_offset']) * 3600))) { |
|
| 156 | + $value = $value - ($user_info['time_offset'] + $modSettings['time_offset']) * 3600; |
|
| 157 | + } else { |
|
| 158 | + $value = $cur_profile['date_registered']; |
|
| 159 | + } |
|
| 157 | 160 | |
| 158 | 161 | return true; |
| 159 | 162 | }, |
@@ -177,8 +180,9 @@ discard block |
||
| 177 | 180 | { |
| 178 | 181 | global $context, $old_profile, $profile_vars, $sourcedir, $modSettings; |
| 179 | 182 | |
| 180 | - if (strtolower($value) == strtolower($old_profile['email_address'])) |
|
| 181 | - return false; |
|
| 183 | + if (strtolower($value) == strtolower($old_profile['email_address'])) { |
|
| 184 | + return false; |
|
| 185 | + } |
|
| 182 | 186 | |
| 183 | 187 | $isValid = profileValidateEmail($value, $context['id_member']); |
| 184 | 188 | |
@@ -254,11 +258,11 @@ discard block |
||
| 254 | 258 | |
| 255 | 259 | if (isset($context['profile_languages'][$value])) |
| 256 | 260 | { |
| 257 | - if ($context['user']['is_owner'] && empty($context['password_auth_failed'])) |
|
| 258 | - $_SESSION['language'] = $value; |
|
| 261 | + if ($context['user']['is_owner'] && empty($context['password_auth_failed'])) { |
|
| 262 | + $_SESSION['language'] = $value; |
|
| 263 | + } |
|
| 259 | 264 | return true; |
| 260 | - } |
|
| 261 | - else |
|
| 265 | + } else |
|
| 262 | 266 | { |
| 263 | 267 | $value = $cur_profile['lngfile']; |
| 264 | 268 | return false; |
@@ -282,13 +286,14 @@ discard block |
||
| 282 | 286 | |
| 283 | 287 | // Maybe they are trying to change their password as well? |
| 284 | 288 | $resetPassword = true; |
| 285 | - if (isset($_POST['passwrd1']) && $_POST['passwrd1'] != '' && isset($_POST['passwrd2']) && $_POST['passwrd1'] == $_POST['passwrd2'] && validatePassword($_POST['passwrd1'], $value, array($cur_profile['real_name'], $user_info['username'], $user_info['name'], $user_info['email'])) == null) |
|
| 286 | - $resetPassword = false; |
|
| 289 | + if (isset($_POST['passwrd1']) && $_POST['passwrd1'] != '' && isset($_POST['passwrd2']) && $_POST['passwrd1'] == $_POST['passwrd2'] && validatePassword($_POST['passwrd1'], $value, array($cur_profile['real_name'], $user_info['username'], $user_info['name'], $user_info['email'])) == null) { |
|
| 290 | + $resetPassword = false; |
|
| 291 | + } |
|
| 287 | 292 | |
| 288 | 293 | // Do the reset... this will send them an email too. |
| 289 | - if ($resetPassword) |
|
| 290 | - resetPassword($context['id_member'], $value); |
|
| 291 | - elseif ($value !== null) |
|
| 294 | + if ($resetPassword) { |
|
| 295 | + resetPassword($context['id_member'], $value); |
|
| 296 | + } elseif ($value !== null) |
|
| 292 | 297 | { |
| 293 | 298 | validateUsername($context['id_member'], trim(preg_replace('~[\t\n\r \x0B\0' . ($context['utf8'] ? '\x{A0}\x{AD}\x{2000}-\x{200F}\x{201F}\x{202F}\x{3000}\x{FEFF}' : '\x00-\x08\x0B\x0C\x0E-\x19\xA0') . ']+~' . ($context['utf8'] ? 'u' : ''), ' ', $value))); |
| 294 | 299 | updateMemberData($context['id_member'], array('member_name' => $value)); |
@@ -312,20 +317,23 @@ discard block |
||
| 312 | 317 | 'input_validate' => function(&$value) use ($sourcedir, $user_info, $smcFunc, $cur_profile) |
| 313 | 318 | { |
| 314 | 319 | // If we didn't try it then ignore it! |
| 315 | - if ($value == '') |
|
| 316 | - return false; |
|
| 320 | + if ($value == '') { |
|
| 321 | + return false; |
|
| 322 | + } |
|
| 317 | 323 | |
| 318 | 324 | // Do the two entries for the password even match? |
| 319 | - if (!isset($_POST['passwrd2']) || $value != $_POST['passwrd2']) |
|
| 320 | - return 'bad_new_password'; |
|
| 325 | + if (!isset($_POST['passwrd2']) || $value != $_POST['passwrd2']) { |
|
| 326 | + return 'bad_new_password'; |
|
| 327 | + } |
|
| 321 | 328 | |
| 322 | 329 | // Let's get the validation function into play... |
| 323 | 330 | require_once($sourcedir . '/Subs-Auth.php'); |
| 324 | 331 | $passwordErrors = validatePassword($value, $cur_profile['member_name'], array($cur_profile['real_name'], $user_info['username'], $user_info['name'], $user_info['email'])); |
| 325 | 332 | |
| 326 | 333 | // Were there errors? |
| 327 | - if ($passwordErrors != null) |
|
| 328 | - return 'password_' . $passwordErrors; |
|
| 334 | + if ($passwordErrors != null) { |
|
| 335 | + return 'password_' . $passwordErrors; |
|
| 336 | + } |
|
| 329 | 337 | |
| 330 | 338 | // Set up the new password variable... ready for storage. |
| 331 | 339 | $value = hash_password($cur_profile['member_name'], un_htmlspecialchars($value)); |
@@ -350,8 +358,9 @@ discard block |
||
| 350 | 358 | 'permission' => 'profile_blurb', |
| 351 | 359 | 'input_validate' => function(&$value) use ($smcFunc) |
| 352 | 360 | { |
| 353 | - if ($smcFunc['strlen']($value) > 50) |
|
| 354 | - return 'personal_text_too_long'; |
|
| 361 | + if ($smcFunc['strlen']($value) > 50) { |
|
| 362 | + return 'personal_text_too_long'; |
|
| 363 | + } |
|
| 355 | 364 | |
| 356 | 365 | return true; |
| 357 | 366 | }, |
@@ -386,10 +395,11 @@ discard block |
||
| 386 | 395 | 'permission' => 'moderate_forum', |
| 387 | 396 | 'input_validate' => function(&$value) |
| 388 | 397 | { |
| 389 | - if (!is_numeric($value)) |
|
| 390 | - return 'digits_only'; |
|
| 391 | - else |
|
| 392 | - $value = $value != '' ? strtr($value, array(',' => '', '.' => '', ' ' => '')) : 0; |
|
| 398 | + if (!is_numeric($value)) { |
|
| 399 | + return 'digits_only'; |
|
| 400 | + } else { |
|
| 401 | + $value = $value != '' ? strtr($value, array(',' => '', '.' => '', ' ' => '')) : 0; |
|
| 402 | + } |
|
| 393 | 403 | return true; |
| 394 | 404 | }, |
| 395 | 405 | ), |
@@ -405,15 +415,16 @@ discard block |
||
| 405 | 415 | { |
| 406 | 416 | $value = trim(preg_replace('~[\t\n\r \x0B\0' . ($context['utf8'] ? '\x{A0}\x{AD}\x{2000}-\x{200F}\x{201F}\x{202F}\x{3000}\x{FEFF}' : '\x00-\x08\x0B\x0C\x0E-\x19\xA0') . ']+~' . ($context['utf8'] ? 'u' : ''), ' ', $value)); |
| 407 | 417 | |
| 408 | - if (trim($value) == '') |
|
| 409 | - return 'no_name'; |
|
| 410 | - elseif ($smcFunc['strlen']($value) > 60) |
|
| 411 | - return 'name_too_long'; |
|
| 412 | - elseif ($cur_profile['real_name'] != $value) |
|
| 418 | + if (trim($value) == '') { |
|
| 419 | + return 'no_name'; |
|
| 420 | + } elseif ($smcFunc['strlen']($value) > 60) { |
|
| 421 | + return 'name_too_long'; |
|
| 422 | + } elseif ($cur_profile['real_name'] != $value) |
|
| 413 | 423 | { |
| 414 | 424 | require_once($sourcedir . '/Subs-Members.php'); |
| 415 | - if (isReservedName($value, $context['id_member'])) |
|
| 416 | - return 'name_taken'; |
|
| 425 | + if (isReservedName($value, $context['id_member'])) { |
|
| 426 | + return 'name_taken'; |
|
| 427 | + } |
|
| 417 | 428 | } |
| 418 | 429 | return true; |
| 419 | 430 | }, |
@@ -471,8 +482,9 @@ discard block |
||
| 471 | 482 | 'selected' => $set == $context['member']['smiley_set']['id'] |
| 472 | 483 | ); |
| 473 | 484 | |
| 474 | - if ($context['smiley_sets'][$i]['selected']) |
|
| 475 | - $context['member']['smiley_set']['name'] = $set_names[$i]; |
|
| 485 | + if ($context['smiley_sets'][$i]['selected']) { |
|
| 486 | + $context['member']['smiley_set']['name'] = $set_names[$i]; |
|
| 487 | + } |
|
| 476 | 488 | } |
| 477 | 489 | return true; |
| 478 | 490 | }, |
@@ -481,8 +493,9 @@ discard block |
||
| 481 | 493 | global $modSettings; |
| 482 | 494 | |
| 483 | 495 | $smiley_sets = explode(',', $modSettings['smiley_sets_known']); |
| 484 | - if (!in_array($value, $smiley_sets) && $value != 'none') |
|
| 485 | - $value = ''; |
|
| 496 | + if (!in_array($value, $smiley_sets) && $value != 'none') { |
|
| 497 | + $value = ''; |
|
| 498 | + } |
|
| 486 | 499 | return true; |
| 487 | 500 | }, |
| 488 | 501 | ), |
@@ -497,8 +510,9 @@ discard block |
||
| 497 | 510 | loadLanguage('Settings'); |
| 498 | 511 | |
| 499 | 512 | $context['allow_no_censored'] = false; |
| 500 | - if ($user_info['is_admin'] || $context['user']['is_owner']) |
|
| 501 | - $context['allow_no_censored'] = !empty($modSettings['allow_no_censored']); |
|
| 513 | + if ($user_info['is_admin'] || $context['user']['is_owner']) { |
|
| 514 | + $context['allow_no_censored'] = !empty($modSettings['allow_no_censored']); |
|
| 515 | + } |
|
| 502 | 516 | |
| 503 | 517 | return true; |
| 504 | 518 | }, |
@@ -545,8 +559,9 @@ discard block |
||
| 545 | 559 | 'input_validate' => function($value) |
| 546 | 560 | { |
| 547 | 561 | $tz = smf_list_timezones(); |
| 548 | - if (!isset($tz[$value])) |
|
| 549 | - return 'bad_timezone'; |
|
| 562 | + if (!isset($tz[$value])) { |
|
| 563 | + return 'bad_timezone'; |
|
| 564 | + } |
|
| 550 | 565 | |
| 551 | 566 | return true; |
| 552 | 567 | }, |
@@ -561,8 +576,9 @@ discard block |
||
| 561 | 576 | 'enabled' => !empty($modSettings['titlesEnable']), |
| 562 | 577 | 'input_validate' => function(&$value) use ($smcFunc) |
| 563 | 578 | { |
| 564 | - if ($smcFunc['strlen']($value) > 50) |
|
| 565 | - return 'user_title_too_long'; |
|
| 579 | + if ($smcFunc['strlen']($value) > 50) { |
|
| 580 | + return 'user_title_too_long'; |
|
| 581 | + } |
|
| 566 | 582 | |
| 567 | 583 | return true; |
| 568 | 584 | }, |
@@ -584,10 +600,12 @@ discard block |
||
| 584 | 600 | // Fix the URL... |
| 585 | 601 | 'input_validate' => function(&$value) |
| 586 | 602 | { |
| 587 | - if (strlen(trim($value)) > 0 && strpos($value, '://') === false) |
|
| 588 | - $value = 'http://' . $value; |
|
| 589 | - if (strlen($value) < 8 || (substr($value, 0, 7) !== 'http://' && substr($value, 0, 8) !== 'https://')) |
|
| 590 | - $value = ''; |
|
| 603 | + if (strlen(trim($value)) > 0 && strpos($value, '://') === false) { |
|
| 604 | + $value = 'http://' . $value; |
|
| 605 | + } |
|
| 606 | + if (strlen($value) < 8 || (substr($value, 0, 7) !== 'http://' && substr($value, 0, 8) !== 'https://')) { |
|
| 607 | + $value = ''; |
|
| 608 | + } |
|
| 591 | 609 | return true; |
| 592 | 610 | }, |
| 593 | 611 | 'link_with' => 'website', |
@@ -601,16 +619,19 @@ discard block |
||
| 601 | 619 | foreach ($profile_fields as $key => $field) |
| 602 | 620 | { |
| 603 | 621 | // Do we have permission to do this? |
| 604 | - if (isset($field['permission']) && !allowedTo(($context['user']['is_owner'] ? array($field['permission'] . '_own', $field['permission'] . '_any') : $field['permission'] . '_any')) && !allowedTo($field['permission'])) |
|
| 605 | - unset($profile_fields[$key]); |
|
| 622 | + if (isset($field['permission']) && !allowedTo(($context['user']['is_owner'] ? array($field['permission'] . '_own', $field['permission'] . '_any') : $field['permission'] . '_any')) && !allowedTo($field['permission'])) { |
|
| 623 | + unset($profile_fields[$key]); |
|
| 624 | + } |
|
| 606 | 625 | |
| 607 | 626 | // Is it enabled? |
| 608 | - if (isset($field['enabled']) && !$field['enabled']) |
|
| 609 | - unset($profile_fields[$key]); |
|
| 627 | + if (isset($field['enabled']) && !$field['enabled']) { |
|
| 628 | + unset($profile_fields[$key]); |
|
| 629 | + } |
|
| 610 | 630 | |
| 611 | 631 | // Is it specifically disabled? |
| 612 | - if (in_array($key, $disabled_fields) || (isset($field['link_with']) && in_array($field['link_with'], $disabled_fields))) |
|
| 613 | - unset($profile_fields[$key]); |
|
| 632 | + if (in_array($key, $disabled_fields) || (isset($field['link_with']) && in_array($field['link_with'], $disabled_fields))) { |
|
| 633 | + unset($profile_fields[$key]); |
|
| 634 | + } |
|
| 614 | 635 | } |
| 615 | 636 | } |
| 616 | 637 | |
@@ -635,9 +656,10 @@ discard block |
||
| 635 | 656 | loadProfileFields(true); |
| 636 | 657 | |
| 637 | 658 | // First check for any linked sets. |
| 638 | - foreach ($profile_fields as $key => $field) |
|
| 639 | - if (isset($field['link_with']) && in_array($field['link_with'], $fields)) |
|
| 659 | + foreach ($profile_fields as $key => $field) { |
|
| 660 | + if (isset($field['link_with']) && in_array($field['link_with'], $fields)) |
|
| 640 | 661 | $fields[] = $key; |
| 662 | + } |
|
| 641 | 663 | |
| 642 | 664 | $i = 0; |
| 643 | 665 | $last_type = ''; |
@@ -649,38 +671,46 @@ discard block |
||
| 649 | 671 | $cur_field = &$profile_fields[$field]; |
| 650 | 672 | |
| 651 | 673 | // Does it have a preload and does that preload succeed? |
| 652 | - if (isset($cur_field['preload']) && !$cur_field['preload']()) |
|
| 653 | - continue; |
|
| 674 | + if (isset($cur_field['preload']) && !$cur_field['preload']()) { |
|
| 675 | + continue; |
|
| 676 | + } |
|
| 654 | 677 | |
| 655 | 678 | // If this is anything but complex we need to do more cleaning! |
| 656 | 679 | if ($cur_field['type'] != 'callback' && $cur_field['type'] != 'hidden') |
| 657 | 680 | { |
| 658 | - if (!isset($cur_field['label'])) |
|
| 659 | - $cur_field['label'] = isset($txt[$field]) ? $txt[$field] : $field; |
|
| 681 | + if (!isset($cur_field['label'])) { |
|
| 682 | + $cur_field['label'] = isset($txt[$field]) ? $txt[$field] : $field; |
|
| 683 | + } |
|
| 660 | 684 | |
| 661 | 685 | // Everything has a value! |
| 662 | - if (!isset($cur_field['value'])) |
|
| 663 | - $cur_field['value'] = isset($cur_profile[$field]) ? $cur_profile[$field] : ''; |
|
| 686 | + if (!isset($cur_field['value'])) { |
|
| 687 | + $cur_field['value'] = isset($cur_profile[$field]) ? $cur_profile[$field] : ''; |
|
| 688 | + } |
|
| 664 | 689 | |
| 665 | 690 | // Any input attributes? |
| 666 | 691 | $cur_field['input_attr'] = !empty($cur_field['input_attr']) ? implode(',', $cur_field['input_attr']) : ''; |
| 667 | 692 | } |
| 668 | 693 | |
| 669 | 694 | // Was there an error with this field on posting? |
| 670 | - if (isset($context['profile_errors'][$field])) |
|
| 671 | - $cur_field['is_error'] = true; |
|
| 695 | + if (isset($context['profile_errors'][$field])) { |
|
| 696 | + $cur_field['is_error'] = true; |
|
| 697 | + } |
|
| 672 | 698 | |
| 673 | 699 | // Any javascript stuff? |
| 674 | - if (!empty($cur_field['js_submit'])) |
|
| 675 | - $context['profile_onsubmit_javascript'] .= $cur_field['js_submit']; |
|
| 676 | - if (!empty($cur_field['js'])) |
|
| 677 | - $context['profile_javascript'] .= $cur_field['js']; |
|
| 700 | + if (!empty($cur_field['js_submit'])) { |
|
| 701 | + $context['profile_onsubmit_javascript'] .= $cur_field['js_submit']; |
|
| 702 | + } |
|
| 703 | + if (!empty($cur_field['js'])) { |
|
| 704 | + $context['profile_javascript'] .= $cur_field['js']; |
|
| 705 | + } |
|
| 678 | 706 | |
| 679 | 707 | // Any template stuff? |
| 680 | - if (!empty($cur_field['prehtml'])) |
|
| 681 | - $context['profile_prehtml'] .= $cur_field['prehtml']; |
|
| 682 | - if (!empty($cur_field['posthtml'])) |
|
| 683 | - $context['profile_posthtml'] .= $cur_field['posthtml']; |
|
| 708 | + if (!empty($cur_field['prehtml'])) { |
|
| 709 | + $context['profile_prehtml'] .= $cur_field['prehtml']; |
|
| 710 | + } |
|
| 711 | + if (!empty($cur_field['posthtml'])) { |
|
| 712 | + $context['profile_posthtml'] .= $cur_field['posthtml']; |
|
| 713 | + } |
|
| 684 | 714 | |
| 685 | 715 | // Finally put it into context? |
| 686 | 716 | if ($cur_field['type'] != 'hidden') |
@@ -713,12 +743,14 @@ discard block |
||
| 713 | 743 | }, false);' : ''), true); |
| 714 | 744 | |
| 715 | 745 | // Any onsubmit javascript? |
| 716 | - if (!empty($context['profile_onsubmit_javascript'])) |
|
| 717 | - addInlineJavaScript($context['profile_onsubmit_javascript'], true); |
|
| 746 | + if (!empty($context['profile_onsubmit_javascript'])) { |
|
| 747 | + addInlineJavaScript($context['profile_onsubmit_javascript'], true); |
|
| 748 | + } |
|
| 718 | 749 | |
| 719 | 750 | // Any totally custom stuff? |
| 720 | - if (!empty($context['profile_javascript'])) |
|
| 721 | - addInlineJavaScript($context['profile_javascript'], true); |
|
| 751 | + if (!empty($context['profile_javascript'])) { |
|
| 752 | + addInlineJavaScript($context['profile_javascript'], true); |
|
| 753 | + } |
|
| 722 | 754 | |
| 723 | 755 | // Free up some memory. |
| 724 | 756 | unset($profile_fields); |
@@ -739,8 +771,9 @@ discard block |
||
| 739 | 771 | |
| 740 | 772 | // This allows variables to call activities when they save - by default just to reload their settings |
| 741 | 773 | $context['profile_execute_on_save'] = array(); |
| 742 | - if ($context['user']['is_owner']) |
|
| 743 | - $context['profile_execute_on_save']['reload_user'] = 'profileReloadUser'; |
|
| 774 | + if ($context['user']['is_owner']) { |
|
| 775 | + $context['profile_execute_on_save']['reload_user'] = 'profileReloadUser'; |
|
| 776 | + } |
|
| 744 | 777 | |
| 745 | 778 | // Assume we log nothing. |
| 746 | 779 | $context['log_changes'] = array(); |
@@ -748,8 +781,9 @@ discard block |
||
| 748 | 781 | // Cycle through the profile fields working out what to do! |
| 749 | 782 | foreach ($profile_fields as $key => $field) |
| 750 | 783 | { |
| 751 | - if (!isset($_POST[$key]) || !empty($field['is_dummy']) || (isset($_POST['preview_signature']) && $key == 'signature')) |
|
| 752 | - continue; |
|
| 784 | + if (!isset($_POST[$key]) || !empty($field['is_dummy']) || (isset($_POST['preview_signature']) && $key == 'signature')) { |
|
| 785 | + continue; |
|
| 786 | + } |
|
| 753 | 787 | |
| 754 | 788 | // What gets updated? |
| 755 | 789 | $db_key = isset($field['save_key']) ? $field['save_key'] : $key; |
@@ -777,12 +811,13 @@ discard block |
||
| 777 | 811 | $field['cast_type'] = empty($field['cast_type']) ? $field['type'] : $field['cast_type']; |
| 778 | 812 | |
| 779 | 813 | // Finally, clean up certain types. |
| 780 | - if ($field['cast_type'] == 'int') |
|
| 781 | - $_POST[$key] = (int) $_POST[$key]; |
|
| 782 | - elseif ($field['cast_type'] == 'float') |
|
| 783 | - $_POST[$key] = (float) $_POST[$key]; |
|
| 784 | - elseif ($field['cast_type'] == 'check') |
|
| 785 | - $_POST[$key] = !empty($_POST[$key]) ? 1 : 0; |
|
| 814 | + if ($field['cast_type'] == 'int') { |
|
| 815 | + $_POST[$key] = (int) $_POST[$key]; |
|
| 816 | + } elseif ($field['cast_type'] == 'float') { |
|
| 817 | + $_POST[$key] = (float) $_POST[$key]; |
|
| 818 | + } elseif ($field['cast_type'] == 'check') { |
|
| 819 | + $_POST[$key] = !empty($_POST[$key]) ? 1 : 0; |
|
| 820 | + } |
|
| 786 | 821 | |
| 787 | 822 | // If we got here we're doing OK. |
| 788 | 823 | if ($field['type'] != 'hidden' && (!isset($old_profile[$key]) || $_POST[$key] != $old_profile[$key])) |
@@ -793,11 +828,12 @@ discard block |
||
| 793 | 828 | $cur_profile[$key] = $_POST[$key]; |
| 794 | 829 | |
| 795 | 830 | // Are we logging it? |
| 796 | - if (!empty($field['log_change']) && isset($old_profile[$key])) |
|
| 797 | - $context['log_changes'][$key] = array( |
|
| 831 | + if (!empty($field['log_change']) && isset($old_profile[$key])) { |
|
| 832 | + $context['log_changes'][$key] = array( |
|
| 798 | 833 | 'previous' => $old_profile[$key], |
| 799 | 834 | 'new' => $_POST[$key], |
| 800 | 835 | ); |
| 836 | + } |
|
| 801 | 837 | } |
| 802 | 838 | |
| 803 | 839 | // Logging group changes are a bit different... |
@@ -830,10 +866,11 @@ discard block |
||
| 830 | 866 | { |
| 831 | 867 | foreach ($groups as $id => $group) |
| 832 | 868 | { |
| 833 | - if (isset($context['member_groups'][$group])) |
|
| 834 | - $additional_groups[$type][$id] = $context['member_groups'][$group]['name']; |
|
| 835 | - else |
|
| 836 | - unset($additional_groups[$type][$id]); |
|
| 869 | + if (isset($context['member_groups'][$group])) { |
|
| 870 | + $additional_groups[$type][$id] = $context['member_groups'][$group]['name']; |
|
| 871 | + } else { |
|
| 872 | + unset($additional_groups[$type][$id]); |
|
| 873 | + } |
|
| 837 | 874 | } |
| 838 | 875 | $additional_groups[$type] = implode(', ', $additional_groups[$type]); |
| 839 | 876 | } |
@@ -844,10 +881,11 @@ discard block |
||
| 844 | 881 | } |
| 845 | 882 | |
| 846 | 883 | // @todo Temporary |
| 847 | - if ($context['user']['is_owner']) |
|
| 848 | - $changeOther = allowedTo(array('profile_extra_any', 'profile_extra_own')); |
|
| 849 | - else |
|
| 850 | - $changeOther = allowedTo('profile_extra_any'); |
|
| 884 | + if ($context['user']['is_owner']) { |
|
| 885 | + $changeOther = allowedTo(array('profile_extra_any', 'profile_extra_own')); |
|
| 886 | + } else { |
|
| 887 | + $changeOther = allowedTo('profile_extra_any'); |
|
| 888 | + } |
|
| 851 | 889 | if ($changeOther && empty($post_errors)) |
| 852 | 890 | { |
| 853 | 891 | makeThemeChanges($context['id_member'], isset($_POST['id_theme']) ? (int) $_POST['id_theme'] : $old_profile['id_theme']); |
@@ -855,8 +893,9 @@ discard block |
||
| 855 | 893 | { |
| 856 | 894 | $custom_fields_errors = makeCustomFieldChanges($context['id_member'], $_REQUEST['sa'], false, true); |
| 857 | 895 | |
| 858 | - if (!empty($custom_fields_errors)) |
|
| 859 | - $post_errors = array_merge($post_errors, $custom_fields_errors); |
|
| 896 | + if (!empty($custom_fields_errors)) { |
|
| 897 | + $post_errors = array_merge($post_errors, $custom_fields_errors); |
|
| 898 | + } |
|
| 860 | 899 | } |
| 861 | 900 | } |
| 862 | 901 | |
@@ -882,9 +921,9 @@ discard block |
||
| 882 | 921 | if ($context['user']['is_owner']) |
| 883 | 922 | { |
| 884 | 923 | $changeOther = allowedTo(array('profile_extra_any', 'profile_extra_own', 'profile_website_any', 'profile_website_own', 'profile_signature_any', 'profile_signature_own')); |
| 924 | + } else { |
|
| 925 | + $changeOther = allowedTo(array('profile_extra_any', 'profile_website_any', 'profile_signature_any')); |
|
| 885 | 926 | } |
| 886 | - else |
|
| 887 | - $changeOther = allowedTo(array('profile_extra_any', 'profile_website_any', 'profile_signature_any')); |
|
| 888 | 927 | |
| 889 | 928 | // Arrays of all the changes - makes things easier. |
| 890 | 929 | $profile_bools = array(); |
@@ -895,22 +934,25 @@ discard block |
||
| 895 | 934 | 'ignore_boards', |
| 896 | 935 | ); |
| 897 | 936 | |
| 898 | - if (isset($_POST['sa']) && $_POST['sa'] == 'ignoreboards' && empty($_POST['ignore_brd'])) |
|
| 899 | - $_POST['ignore_brd'] = array(); |
|
| 937 | + if (isset($_POST['sa']) && $_POST['sa'] == 'ignoreboards' && empty($_POST['ignore_brd'])) { |
|
| 938 | + $_POST['ignore_brd'] = array(); |
|
| 939 | + } |
|
| 900 | 940 | |
| 901 | 941 | unset($_POST['ignore_boards']); // Whatever it is set to is a dirty filthy thing. Kinda like our minds. |
| 902 | 942 | if (isset($_POST['ignore_brd'])) |
| 903 | 943 | { |
| 904 | - if (!is_array($_POST['ignore_brd'])) |
|
| 905 | - $_POST['ignore_brd'] = array($_POST['ignore_brd']); |
|
| 944 | + if (!is_array($_POST['ignore_brd'])) { |
|
| 945 | + $_POST['ignore_brd'] = array($_POST['ignore_brd']); |
|
| 946 | + } |
|
| 906 | 947 | |
| 907 | 948 | foreach ($_POST['ignore_brd'] as $k => $d) |
| 908 | 949 | { |
| 909 | 950 | $d = (int) $d; |
| 910 | - if ($d != 0) |
|
| 911 | - $_POST['ignore_brd'][$k] = $d; |
|
| 912 | - else |
|
| 913 | - unset($_POST['ignore_brd'][$k]); |
|
| 951 | + if ($d != 0) { |
|
| 952 | + $_POST['ignore_brd'][$k] = $d; |
|
| 953 | + } else { |
|
| 954 | + unset($_POST['ignore_brd'][$k]); |
|
| 955 | + } |
|
| 914 | 956 | } |
| 915 | 957 | $_POST['ignore_boards'] = implode(',', $_POST['ignore_brd']); |
| 916 | 958 | unset($_POST['ignore_brd']); |
@@ -923,21 +965,26 @@ discard block |
||
| 923 | 965 | makeThemeChanges($memID, isset($_POST['id_theme']) ? (int) $_POST['id_theme'] : $old_profile['id_theme']); |
| 924 | 966 | //makeAvatarChanges($memID, $post_errors); |
| 925 | 967 | |
| 926 | - if (!empty($_REQUEST['sa'])) |
|
| 927 | - makeCustomFieldChanges($memID, $_REQUEST['sa'], false); |
|
| 968 | + if (!empty($_REQUEST['sa'])) { |
|
| 969 | + makeCustomFieldChanges($memID, $_REQUEST['sa'], false); |
|
| 970 | + } |
|
| 928 | 971 | |
| 929 | - foreach ($profile_bools as $var) |
|
| 930 | - if (isset($_POST[$var])) |
|
| 972 | + foreach ($profile_bools as $var) { |
|
| 973 | + if (isset($_POST[$var])) |
|
| 931 | 974 | $profile_vars[$var] = empty($_POST[$var]) ? '0' : '1'; |
| 932 | - foreach ($profile_ints as $var) |
|
| 933 | - if (isset($_POST[$var])) |
|
| 975 | + } |
|
| 976 | + foreach ($profile_ints as $var) { |
|
| 977 | + if (isset($_POST[$var])) |
|
| 934 | 978 | $profile_vars[$var] = $_POST[$var] != '' ? (int) $_POST[$var] : ''; |
| 935 | - foreach ($profile_floats as $var) |
|
| 936 | - if (isset($_POST[$var])) |
|
| 979 | + } |
|
| 980 | + foreach ($profile_floats as $var) { |
|
| 981 | + if (isset($_POST[$var])) |
|
| 937 | 982 | $profile_vars[$var] = (float) $_POST[$var]; |
| 938 | - foreach ($profile_strings as $var) |
|
| 939 | - if (isset($_POST[$var])) |
|
| 983 | + } |
|
| 984 | + foreach ($profile_strings as $var) { |
|
| 985 | + if (isset($_POST[$var])) |
|
| 940 | 986 | $profile_vars[$var] = $_POST[$var]; |
| 987 | + } |
|
| 941 | 988 | } |
| 942 | 989 | } |
| 943 | 990 | |
@@ -971,8 +1018,9 @@ discard block |
||
| 971 | 1018 | ); |
| 972 | 1019 | |
| 973 | 1020 | // Can't change reserved vars. |
| 974 | - if ((isset($_POST['options']) && count(array_intersect(array_keys($_POST['options']), $reservedVars)) != 0) || (isset($_POST['default_options']) && count(array_intersect(array_keys($_POST['default_options']), $reservedVars)) != 0)) |
|
| 975 | - fatal_lang_error('no_access', false); |
|
| 1021 | + if ((isset($_POST['options']) && count(array_intersect(array_keys($_POST['options']), $reservedVars)) != 0) || (isset($_POST['default_options']) && count(array_intersect(array_keys($_POST['default_options']), $reservedVars)) != 0)) { |
|
| 1022 | + fatal_lang_error('no_access', false); |
|
| 1023 | + } |
|
| 976 | 1024 | |
| 977 | 1025 | // Don't allow any overriding of custom fields with default or non-default options. |
| 978 | 1026 | $request = $smcFunc['db_query']('', ' |
@@ -984,8 +1032,9 @@ discard block |
||
| 984 | 1032 | ) |
| 985 | 1033 | ); |
| 986 | 1034 | $custom_fields = array(); |
| 987 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 988 | - $custom_fields[] = $row['col_name']; |
|
| 1035 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1036 | + $custom_fields[] = $row['col_name']; |
|
| 1037 | + } |
|
| 989 | 1038 | $smcFunc['db_free_result']($request); |
| 990 | 1039 | |
| 991 | 1040 | // These are the theme changes... |
@@ -994,33 +1043,39 @@ discard block |
||
| 994 | 1043 | { |
| 995 | 1044 | foreach ($_POST['options'] as $opt => $val) |
| 996 | 1045 | { |
| 997 | - if (in_array($opt, $custom_fields)) |
|
| 998 | - continue; |
|
| 1046 | + if (in_array($opt, $custom_fields)) { |
|
| 1047 | + continue; |
|
| 1048 | + } |
|
| 999 | 1049 | |
| 1000 | 1050 | // These need to be controlled. |
| 1001 | - if ($opt == 'topics_per_page' || $opt == 'messages_per_page') |
|
| 1002 | - $val = max(0, min($val, 50)); |
|
| 1051 | + if ($opt == 'topics_per_page' || $opt == 'messages_per_page') { |
|
| 1052 | + $val = max(0, min($val, 50)); |
|
| 1053 | + } |
|
| 1003 | 1054 | // We don't set this per theme anymore. |
| 1004 | - elseif ($opt == 'allow_no_censored') |
|
| 1005 | - continue; |
|
| 1055 | + elseif ($opt == 'allow_no_censored') { |
|
| 1056 | + continue; |
|
| 1057 | + } |
|
| 1006 | 1058 | |
| 1007 | 1059 | $themeSetArray[] = array($memID, $id_theme, $opt, is_array($val) ? implode(',', $val) : $val); |
| 1008 | 1060 | } |
| 1009 | 1061 | } |
| 1010 | 1062 | |
| 1011 | 1063 | $erase_options = array(); |
| 1012 | - if (isset($_POST['default_options']) && is_array($_POST['default_options'])) |
|
| 1013 | - foreach ($_POST['default_options'] as $opt => $val) |
|
| 1064 | + if (isset($_POST['default_options']) && is_array($_POST['default_options'])) { |
|
| 1065 | + foreach ($_POST['default_options'] as $opt => $val) |
|
| 1014 | 1066 | { |
| 1015 | 1067 | if (in_array($opt, $custom_fields)) |
| 1016 | 1068 | continue; |
| 1069 | + } |
|
| 1017 | 1070 | |
| 1018 | 1071 | // These need to be controlled. |
| 1019 | - if ($opt == 'topics_per_page' || $opt == 'messages_per_page') |
|
| 1020 | - $val = max(0, min($val, 50)); |
|
| 1072 | + if ($opt == 'topics_per_page' || $opt == 'messages_per_page') { |
|
| 1073 | + $val = max(0, min($val, 50)); |
|
| 1074 | + } |
|
| 1021 | 1075 | // Only let admins and owners change the censor. |
| 1022 | - elseif ($opt == 'allow_no_censored' && !$user_info['is_admin'] && !$context['user']['is_owner']) |
|
| 1023 | - continue; |
|
| 1076 | + elseif ($opt == 'allow_no_censored' && !$user_info['is_admin'] && !$context['user']['is_owner']) { |
|
| 1077 | + continue; |
|
| 1078 | + } |
|
| 1024 | 1079 | |
| 1025 | 1080 | $themeSetArray[] = array($memID, 1, $opt, is_array($val) ? implode(',', $val) : $val); |
| 1026 | 1081 | $erase_options[] = $opt; |
@@ -1056,8 +1111,9 @@ discard block |
||
| 1056 | 1111 | |
| 1057 | 1112 | // Admins can choose any theme, even if it's not enabled... |
| 1058 | 1113 | $themes = allowedTo('admin_forum') ? explode(',', $modSettings['knownThemes']) : explode(',', $modSettings['enableThemes']); |
| 1059 | - foreach ($themes as $t) |
|
| 1060 | - cache_put_data('theme_settings-' . $t . ':' . $memID, null, 60); |
|
| 1114 | + foreach ($themes as $t) { |
|
| 1115 | + cache_put_data('theme_settings-' . $t . ':' . $memID, null, 60); |
|
| 1116 | + } |
|
| 1061 | 1117 | } |
| 1062 | 1118 | } |
| 1063 | 1119 | |
@@ -1076,8 +1132,9 @@ discard block |
||
| 1076 | 1132 | if (isset($_POST['edit_notify_boards']) && !empty($_POST['notify_boards'])) |
| 1077 | 1133 | { |
| 1078 | 1134 | // Make sure only integers are deleted. |
| 1079 | - foreach ($_POST['notify_boards'] as $index => $id) |
|
| 1080 | - $_POST['notify_boards'][$index] = (int) $id; |
|
| 1135 | + foreach ($_POST['notify_boards'] as $index => $id) { |
|
| 1136 | + $_POST['notify_boards'][$index] = (int) $id; |
|
| 1137 | + } |
|
| 1081 | 1138 | |
| 1082 | 1139 | // id_board = 0 is reserved for topic notifications. |
| 1083 | 1140 | $_POST['notify_boards'] = array_diff($_POST['notify_boards'], array(0)); |
@@ -1096,8 +1153,9 @@ discard block |
||
| 1096 | 1153 | // We are editing topic notifications...... |
| 1097 | 1154 | elseif (isset($_POST['edit_notify_topics']) && !empty($_POST['notify_topics'])) |
| 1098 | 1155 | { |
| 1099 | - foreach ($_POST['notify_topics'] as $index => $id) |
|
| 1100 | - $_POST['notify_topics'][$index] = (int) $id; |
|
| 1156 | + foreach ($_POST['notify_topics'] as $index => $id) { |
|
| 1157 | + $_POST['notify_topics'][$index] = (int) $id; |
|
| 1158 | + } |
|
| 1101 | 1159 | |
| 1102 | 1160 | // Make sure there are no zeros left. |
| 1103 | 1161 | $_POST['notify_topics'] = array_diff($_POST['notify_topics'], array(0)); |
@@ -1111,16 +1169,18 @@ discard block |
||
| 1111 | 1169 | 'selected_member' => $memID, |
| 1112 | 1170 | ) |
| 1113 | 1171 | ); |
| 1114 | - foreach ($_POST['notify_topics'] as $topic) |
|
| 1115 | - setNotifyPrefs($memID, array('topic_notify_' . $topic => 0)); |
|
| 1172 | + foreach ($_POST['notify_topics'] as $topic) { |
|
| 1173 | + setNotifyPrefs($memID, array('topic_notify_' . $topic => 0)); |
|
| 1174 | + } |
|
| 1116 | 1175 | } |
| 1117 | 1176 | |
| 1118 | 1177 | // We are removing topic preferences |
| 1119 | 1178 | elseif (isset($_POST['remove_notify_topics']) && !empty($_POST['notify_topics'])) |
| 1120 | 1179 | { |
| 1121 | 1180 | $prefs = array(); |
| 1122 | - foreach ($_POST['notify_topics'] as $topic) |
|
| 1123 | - $prefs[] = 'topic_notify_' . $topic; |
|
| 1181 | + foreach ($_POST['notify_topics'] as $topic) { |
|
| 1182 | + $prefs[] = 'topic_notify_' . $topic; |
|
| 1183 | + } |
|
| 1124 | 1184 | deleteNotifyPrefs($memID, $prefs); |
| 1125 | 1185 | } |
| 1126 | 1186 | |
@@ -1128,8 +1188,9 @@ discard block |
||
| 1128 | 1188 | elseif (isset($_POST['remove_notify_board']) && !empty($_POST['notify_boards'])) |
| 1129 | 1189 | { |
| 1130 | 1190 | $prefs = array(); |
| 1131 | - foreach ($_POST['notify_boards'] as $board) |
|
| 1132 | - $prefs[] = 'board_notify_' . $board; |
|
| 1191 | + foreach ($_POST['notify_boards'] as $board) { |
|
| 1192 | + $prefs[] = 'board_notify_' . $board; |
|
| 1193 | + } |
|
| 1133 | 1194 | deleteNotifyPrefs($memID, $prefs); |
| 1134 | 1195 | } |
| 1135 | 1196 | } |
@@ -1150,8 +1211,9 @@ discard block |
||
| 1150 | 1211 | |
| 1151 | 1212 | $errors = array(); |
| 1152 | 1213 | |
| 1153 | - if ($sanitize && isset($_POST['customfield'])) |
|
| 1154 | - $_POST['customfield'] = htmlspecialchars__recursive($_POST['customfield']); |
|
| 1214 | + if ($sanitize && isset($_POST['customfield'])) { |
|
| 1215 | + $_POST['customfield'] = htmlspecialchars__recursive($_POST['customfield']); |
|
| 1216 | + } |
|
| 1155 | 1217 | |
| 1156 | 1218 | $where = $area == 'register' ? 'show_reg != 0' : 'show_profile = {string:area}'; |
| 1157 | 1219 | |
@@ -1176,48 +1238,49 @@ discard block |
||
| 1176 | 1238 | - The data is not invisible to users but editable by the owner (or if it is the user is not the owner) |
| 1177 | 1239 | - The area isn't registration, and if it is that the field is not supposed to be shown there. |
| 1178 | 1240 | */ |
| 1179 | - if ($row['private'] != 0 && !allowedTo('admin_forum') && ($memID != $user_info['id'] || $row['private'] != 2) && ($area != 'register' || $row['show_reg'] == 0)) |
|
| 1180 | - continue; |
|
| 1241 | + if ($row['private'] != 0 && !allowedTo('admin_forum') && ($memID != $user_info['id'] || $row['private'] != 2) && ($area != 'register' || $row['show_reg'] == 0)) { |
|
| 1242 | + continue; |
|
| 1243 | + } |
|
| 1181 | 1244 | |
| 1182 | 1245 | // Validate the user data. |
| 1183 | - if ($row['field_type'] == 'check') |
|
| 1184 | - $value = isset($_POST['customfield'][$row['col_name']]) ? 1 : 0; |
|
| 1185 | - elseif ($row['field_type'] == 'select' || $row['field_type'] == 'radio') |
|
| 1246 | + if ($row['field_type'] == 'check') { |
|
| 1247 | + $value = isset($_POST['customfield'][$row['col_name']]) ? 1 : 0; |
|
| 1248 | + } elseif ($row['field_type'] == 'select' || $row['field_type'] == 'radio') |
|
| 1186 | 1249 | { |
| 1187 | 1250 | $value = $row['default_value']; |
| 1188 | - foreach (explode(',', $row['field_options']) as $k => $v) |
|
| 1189 | - if (isset($_POST['customfield'][$row['col_name']]) && $_POST['customfield'][$row['col_name']] == $k) |
|
| 1251 | + foreach (explode(',', $row['field_options']) as $k => $v) { |
|
| 1252 | + if (isset($_POST['customfield'][$row['col_name']]) && $_POST['customfield'][$row['col_name']] == $k) |
|
| 1190 | 1253 | $value = $v; |
| 1254 | + } |
|
| 1191 | 1255 | } |
| 1192 | 1256 | // Otherwise some form of text! |
| 1193 | 1257 | else |
| 1194 | 1258 | { |
| 1195 | 1259 | $value = isset($_POST['customfield'][$row['col_name']]) ? $_POST['customfield'][$row['col_name']] : ''; |
| 1196 | - if ($row['field_length']) |
|
| 1197 | - $value = $smcFunc['substr']($value, 0, $row['field_length']); |
|
| 1260 | + if ($row['field_length']) { |
|
| 1261 | + $value = $smcFunc['substr']($value, 0, $row['field_length']); |
|
| 1262 | + } |
|
| 1198 | 1263 | |
| 1199 | 1264 | // Any masks? |
| 1200 | 1265 | if ($row['field_type'] == 'text' && !empty($row['mask']) && $row['mask'] != 'none') |
| 1201 | 1266 | { |
| 1202 | 1267 | if ($row['mask'] == 'email' && (!filter_var($value, FILTER_VALIDATE_EMAIL) || strlen($value) > 255)) |
| 1203 | 1268 | { |
| 1204 | - if ($returnErrors) |
|
| 1205 | - $errors[] = 'custom_field_mail_fail'; |
|
| 1206 | - |
|
| 1207 | - else |
|
| 1208 | - $value = ''; |
|
| 1209 | - } |
|
| 1210 | - elseif ($row['mask'] == 'number') |
|
| 1269 | + if ($returnErrors) { |
|
| 1270 | + $errors[] = 'custom_field_mail_fail'; |
|
| 1271 | + } else { |
|
| 1272 | + $value = ''; |
|
| 1273 | + } |
|
| 1274 | + } elseif ($row['mask'] == 'number') |
|
| 1211 | 1275 | { |
| 1212 | 1276 | $value = (int) $value; |
| 1213 | - } |
|
| 1214 | - elseif (substr($row['mask'], 0, 5) == 'regex' && trim($value) != '' && preg_match(substr($row['mask'], 5), $value) === 0) |
|
| 1277 | + } elseif (substr($row['mask'], 0, 5) == 'regex' && trim($value) != '' && preg_match(substr($row['mask'], 5), $value) === 0) |
|
| 1215 | 1278 | { |
| 1216 | - if ($returnErrors) |
|
| 1217 | - $errors[] = 'custom_field_regex_fail'; |
|
| 1218 | - |
|
| 1219 | - else |
|
| 1220 | - $value = ''; |
|
| 1279 | + if ($returnErrors) { |
|
| 1280 | + $errors[] = 'custom_field_regex_fail'; |
|
| 1281 | + } else { |
|
| 1282 | + $value = ''; |
|
| 1283 | + } |
|
| 1221 | 1284 | } |
| 1222 | 1285 | } |
| 1223 | 1286 | } |
@@ -1243,8 +1306,9 @@ discard block |
||
| 1243 | 1306 | |
| 1244 | 1307 | $hook_errors = call_integration_hook('integrate_save_custom_profile_fields', array(&$changes, &$log_changes, &$errors, $returnErrors, $memID, $area, $sanitize)); |
| 1245 | 1308 | |
| 1246 | - if (!empty($hook_errors) && is_array($hook_errors)) |
|
| 1247 | - $errors = array_merge($errors, $hook_errors); |
|
| 1309 | + if (!empty($hook_errors) && is_array($hook_errors)) { |
|
| 1310 | + $errors = array_merge($errors, $hook_errors); |
|
| 1311 | + } |
|
| 1248 | 1312 | |
| 1249 | 1313 | // Make those changes! |
| 1250 | 1314 | if (!empty($changes) && empty($context['password_auth_failed']) && empty($errors)) |
@@ -1262,9 +1326,10 @@ discard block |
||
| 1262 | 1326 | } |
| 1263 | 1327 | } |
| 1264 | 1328 | |
| 1265 | - if ($returnErrors) |
|
| 1266 | - return $errors; |
|
| 1267 | -} |
|
| 1329 | + if ($returnErrors) { |
|
| 1330 | + return $errors; |
|
| 1331 | + } |
|
| 1332 | + } |
|
| 1268 | 1333 | |
| 1269 | 1334 | /** |
| 1270 | 1335 | * Show all the users buddies, as well as a add/delete interface. |
@@ -1276,8 +1341,9 @@ discard block |
||
| 1276 | 1341 | global $context, $txt, $modSettings; |
| 1277 | 1342 | |
| 1278 | 1343 | // Do a quick check to ensure people aren't getting here illegally! |
| 1279 | - if (!$context['user']['is_owner'] || empty($modSettings['enable_buddylist'])) |
|
| 1280 | - fatal_lang_error('no_access', false); |
|
| 1344 | + if (!$context['user']['is_owner'] || empty($modSettings['enable_buddylist'])) { |
|
| 1345 | + fatal_lang_error('no_access', false); |
|
| 1346 | + } |
|
| 1281 | 1347 | |
| 1282 | 1348 | // Can we email the user direct? |
| 1283 | 1349 | $context['can_moderate_forum'] = allowedTo('moderate_forum'); |
@@ -1307,9 +1373,10 @@ discard block |
||
| 1307 | 1373 | $context['sub_template'] = $subActions[$context['list_area']][0]; |
| 1308 | 1374 | $call = call_helper($subActions[$context['list_area']][0], true); |
| 1309 | 1375 | |
| 1310 | - if (!empty($call)) |
|
| 1311 | - call_user_func($call, $memID); |
|
| 1312 | -} |
|
| 1376 | + if (!empty($call)) { |
|
| 1377 | + call_user_func($call, $memID); |
|
| 1378 | + } |
|
| 1379 | + } |
|
| 1313 | 1380 | |
| 1314 | 1381 | /** |
| 1315 | 1382 | * Show all the users buddies, as well as a add/delete interface. |
@@ -1323,9 +1390,10 @@ discard block |
||
| 1323 | 1390 | |
| 1324 | 1391 | // For making changes! |
| 1325 | 1392 | $buddiesArray = explode(',', $user_profile[$memID]['buddy_list']); |
| 1326 | - foreach ($buddiesArray as $k => $dummy) |
|
| 1327 | - if ($dummy == '') |
|
| 1393 | + foreach ($buddiesArray as $k => $dummy) { |
|
| 1394 | + if ($dummy == '') |
|
| 1328 | 1395 | unset($buddiesArray[$k]); |
| 1396 | + } |
|
| 1329 | 1397 | |
| 1330 | 1398 | // Removing a buddy? |
| 1331 | 1399 | if (isset($_GET['remove'])) |
@@ -1337,10 +1405,11 @@ discard block |
||
| 1337 | 1405 | $_SESSION['prf-save'] = $txt['could_not_remove_person']; |
| 1338 | 1406 | |
| 1339 | 1407 | // Heh, I'm lazy, do it the easy way... |
| 1340 | - foreach ($buddiesArray as $key => $buddy) |
|
| 1341 | - if ($buddy == (int) $_GET['remove']) |
|
| 1408 | + foreach ($buddiesArray as $key => $buddy) { |
|
| 1409 | + if ($buddy == (int) $_GET['remove']) |
|
| 1342 | 1410 | { |
| 1343 | 1411 | unset($buddiesArray[$key]); |
| 1412 | + } |
|
| 1344 | 1413 | $_SESSION['prf-save'] = true; |
| 1345 | 1414 | } |
| 1346 | 1415 | |
@@ -1350,8 +1419,7 @@ discard block |
||
| 1350 | 1419 | |
| 1351 | 1420 | // Redirect off the page because we don't like all this ugly query stuff to stick in the history. |
| 1352 | 1421 | redirectexit('action=profile;area=lists;sa=buddies;u=' . $memID); |
| 1353 | - } |
|
| 1354 | - elseif (isset($_POST['new_buddy'])) |
|
| 1422 | + } elseif (isset($_POST['new_buddy'])) |
|
| 1355 | 1423 | { |
| 1356 | 1424 | checkSession(); |
| 1357 | 1425 | |
@@ -1364,8 +1432,9 @@ discard block |
||
| 1364 | 1432 | { |
| 1365 | 1433 | $new_buddies[$k] = strtr(trim($new_buddies[$k]), array('\'' => ''')); |
| 1366 | 1434 | |
| 1367 | - if (strlen($new_buddies[$k]) == 0 || in_array($new_buddies[$k], array($user_profile[$memID]['member_name'], $user_profile[$memID]['real_name']))) |
|
| 1368 | - unset($new_buddies[$k]); |
|
| 1435 | + if (strlen($new_buddies[$k]) == 0 || in_array($new_buddies[$k], array($user_profile[$memID]['member_name'], $user_profile[$memID]['real_name']))) { |
|
| 1436 | + unset($new_buddies[$k]); |
|
| 1437 | + } |
|
| 1369 | 1438 | } |
| 1370 | 1439 | |
| 1371 | 1440 | call_integration_hook('integrate_add_buddies', array($memID, &$new_buddies)); |
@@ -1385,16 +1454,18 @@ discard block |
||
| 1385 | 1454 | ) |
| 1386 | 1455 | ); |
| 1387 | 1456 | |
| 1388 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
| 1389 | - $_SESSION['prf-save'] = true; |
|
| 1457 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
| 1458 | + $_SESSION['prf-save'] = true; |
|
| 1459 | + } |
|
| 1390 | 1460 | |
| 1391 | 1461 | // Add the new member to the buddies array. |
| 1392 | 1462 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1393 | 1463 | { |
| 1394 | - if (in_array($row['id_member'], $buddiesArray)) |
|
| 1395 | - continue; |
|
| 1396 | - else |
|
| 1397 | - $buddiesArray[] = (int) $row['id_member']; |
|
| 1464 | + if (in_array($row['id_member'], $buddiesArray)) { |
|
| 1465 | + continue; |
|
| 1466 | + } else { |
|
| 1467 | + $buddiesArray[] = (int) $row['id_member']; |
|
| 1468 | + } |
|
| 1398 | 1469 | } |
| 1399 | 1470 | $smcFunc['db_free_result']($request); |
| 1400 | 1471 | |
@@ -1424,18 +1495,20 @@ discard block |
||
| 1424 | 1495 | |
| 1425 | 1496 | $context['custom_pf'] = array(); |
| 1426 | 1497 | $disabled_fields = isset($modSettings['disabled_profile_fields']) ? array_flip(explode(',', $modSettings['disabled_profile_fields'])) : array(); |
| 1427 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1428 | - if (!isset($disabled_fields[$row['col_name']])) |
|
| 1498 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1499 | + if (!isset($disabled_fields[$row['col_name']])) |
|
| 1429 | 1500 | $context['custom_pf'][$row['col_name']] = array( |
| 1430 | 1501 | 'label' => $row['field_name'], |
| 1431 | 1502 | 'type' => $row['field_type'], |
| 1432 | 1503 | 'bbc' => !empty($row['bbc']), |
| 1433 | 1504 | 'enclose' => $row['enclose'], |
| 1434 | 1505 | ); |
| 1506 | + } |
|
| 1435 | 1507 | |
| 1436 | 1508 | // Gotta disable the gender option. |
| 1437 | - if (isset($context['custom_pf']['cust_gender']) && $context['custom_pf']['cust_gender'] == 'Disabled') |
|
| 1438 | - unset($context['custom_pf']['cust_gender']); |
|
| 1509 | + if (isset($context['custom_pf']['cust_gender']) && $context['custom_pf']['cust_gender'] == 'Disabled') { |
|
| 1510 | + unset($context['custom_pf']['cust_gender']); |
|
| 1511 | + } |
|
| 1439 | 1512 | |
| 1440 | 1513 | $smcFunc['db_free_result']($request); |
| 1441 | 1514 | |
@@ -1452,8 +1525,9 @@ discard block |
||
| 1452 | 1525 | 'buddy_list_count' => substr_count($user_profile[$memID]['buddy_list'], ',') + 1, |
| 1453 | 1526 | ) |
| 1454 | 1527 | ); |
| 1455 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
| 1456 | - $buddies[] = $row['id_member']; |
|
| 1528 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
| 1529 | + $buddies[] = $row['id_member']; |
|
| 1530 | + } |
|
| 1457 | 1531 | $smcFunc['db_free_result']($result); |
| 1458 | 1532 | } |
| 1459 | 1533 | |
@@ -1481,30 +1555,32 @@ discard block |
||
| 1481 | 1555 | continue; |
| 1482 | 1556 | } |
| 1483 | 1557 | |
| 1484 | - if ($column['bbc'] && !empty($context['buddies'][$buddy]['options'][$key])) |
|
| 1485 | - $context['buddies'][$buddy]['options'][$key] = strip_tags(parse_bbc($context['buddies'][$buddy]['options'][$key])); |
|
| 1486 | - |
|
| 1487 | - elseif ($column['type'] == 'check') |
|
| 1488 | - $context['buddies'][$buddy]['options'][$key] = $context['buddies'][$buddy]['options'][$key] == 0 ? $txt['no'] : $txt['yes']; |
|
| 1558 | + if ($column['bbc'] && !empty($context['buddies'][$buddy]['options'][$key])) { |
|
| 1559 | + $context['buddies'][$buddy]['options'][$key] = strip_tags(parse_bbc($context['buddies'][$buddy]['options'][$key])); |
|
| 1560 | + } elseif ($column['type'] == 'check') { |
|
| 1561 | + $context['buddies'][$buddy]['options'][$key] = $context['buddies'][$buddy]['options'][$key] == 0 ? $txt['no'] : $txt['yes']; |
|
| 1562 | + } |
|
| 1489 | 1563 | |
| 1490 | 1564 | // Enclosing the user input within some other text? |
| 1491 | - if (!empty($column['enclose']) && !empty($context['buddies'][$buddy]['options'][$key])) |
|
| 1492 | - $context['buddies'][$buddy]['options'][$key] = strtr($column['enclose'], array( |
|
| 1565 | + if (!empty($column['enclose']) && !empty($context['buddies'][$buddy]['options'][$key])) { |
|
| 1566 | + $context['buddies'][$buddy]['options'][$key] = strtr($column['enclose'], array( |
|
| 1493 | 1567 | '{SCRIPTURL}' => $scripturl, |
| 1494 | 1568 | '{IMAGES_URL}' => $settings['images_url'], |
| 1495 | 1569 | '{DEFAULT_IMAGES_URL}' => $settings['default_images_url'], |
| 1496 | 1570 | '{INPUT}' => $context['buddies'][$buddy]['options'][$key], |
| 1497 | 1571 | )); |
| 1572 | + } |
|
| 1498 | 1573 | } |
| 1499 | 1574 | } |
| 1500 | 1575 | } |
| 1501 | 1576 | |
| 1502 | 1577 | if (isset($_SESSION['prf-save'])) |
| 1503 | 1578 | { |
| 1504 | - if ($_SESSION['prf-save'] === true) |
|
| 1505 | - $context['saved_successful'] = true; |
|
| 1506 | - else |
|
| 1507 | - $context['saved_failed'] = $_SESSION['prf-save']; |
|
| 1579 | + if ($_SESSION['prf-save'] === true) { |
|
| 1580 | + $context['saved_successful'] = true; |
|
| 1581 | + } else { |
|
| 1582 | + $context['saved_failed'] = $_SESSION['prf-save']; |
|
| 1583 | + } |
|
| 1508 | 1584 | |
| 1509 | 1585 | unset($_SESSION['prf-save']); |
| 1510 | 1586 | } |
@@ -1524,9 +1600,10 @@ discard block |
||
| 1524 | 1600 | |
| 1525 | 1601 | // For making changes! |
| 1526 | 1602 | $ignoreArray = explode(',', $user_profile[$memID]['pm_ignore_list']); |
| 1527 | - foreach ($ignoreArray as $k => $dummy) |
|
| 1528 | - if ($dummy == '') |
|
| 1603 | + foreach ($ignoreArray as $k => $dummy) { |
|
| 1604 | + if ($dummy == '') |
|
| 1529 | 1605 | unset($ignoreArray[$k]); |
| 1606 | + } |
|
| 1530 | 1607 | |
| 1531 | 1608 | // Removing a member from the ignore list? |
| 1532 | 1609 | if (isset($_GET['remove'])) |
@@ -1536,10 +1613,11 @@ discard block |
||
| 1536 | 1613 | $_SESSION['prf-save'] = $txt['could_not_remove_person']; |
| 1537 | 1614 | |
| 1538 | 1615 | // Heh, I'm lazy, do it the easy way... |
| 1539 | - foreach ($ignoreArray as $key => $id_remove) |
|
| 1540 | - if ($id_remove == (int) $_GET['remove']) |
|
| 1616 | + foreach ($ignoreArray as $key => $id_remove) { |
|
| 1617 | + if ($id_remove == (int) $_GET['remove']) |
|
| 1541 | 1618 | { |
| 1542 | 1619 | unset($ignoreArray[$key]); |
| 1620 | + } |
|
| 1543 | 1621 | $_SESSION['prf-save'] = true; |
| 1544 | 1622 | } |
| 1545 | 1623 | |
@@ -1549,8 +1627,7 @@ discard block |
||
| 1549 | 1627 | |
| 1550 | 1628 | // Redirect off the page because we don't like all this ugly query stuff to stick in the history. |
| 1551 | 1629 | redirectexit('action=profile;area=lists;sa=ignore;u=' . $memID); |
| 1552 | - } |
|
| 1553 | - elseif (isset($_POST['new_ignore'])) |
|
| 1630 | + } elseif (isset($_POST['new_ignore'])) |
|
| 1554 | 1631 | { |
| 1555 | 1632 | checkSession(); |
| 1556 | 1633 | // Prepare the string for extraction... |
@@ -1562,8 +1639,9 @@ discard block |
||
| 1562 | 1639 | { |
| 1563 | 1640 | $new_entries[$k] = strtr(trim($new_entries[$k]), array('\'' => ''')); |
| 1564 | 1641 | |
| 1565 | - if (strlen($new_entries[$k]) == 0 || in_array($new_entries[$k], array($user_profile[$memID]['member_name'], $user_profile[$memID]['real_name']))) |
|
| 1566 | - unset($new_entries[$k]); |
|
| 1642 | + if (strlen($new_entries[$k]) == 0 || in_array($new_entries[$k], array($user_profile[$memID]['member_name'], $user_profile[$memID]['real_name']))) { |
|
| 1643 | + unset($new_entries[$k]); |
|
| 1644 | + } |
|
| 1567 | 1645 | } |
| 1568 | 1646 | |
| 1569 | 1647 | $_SESSION['prf-save'] = $txt['could_not_add_person']; |
@@ -1581,16 +1659,18 @@ discard block |
||
| 1581 | 1659 | ) |
| 1582 | 1660 | ); |
| 1583 | 1661 | |
| 1584 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
| 1585 | - $_SESSION['prf-save'] = true; |
|
| 1662 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
| 1663 | + $_SESSION['prf-save'] = true; |
|
| 1664 | + } |
|
| 1586 | 1665 | |
| 1587 | 1666 | // Add the new member to the buddies array. |
| 1588 | 1667 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1589 | 1668 | { |
| 1590 | - if (in_array($row['id_member'], $ignoreArray)) |
|
| 1591 | - continue; |
|
| 1592 | - else |
|
| 1593 | - $ignoreArray[] = (int) $row['id_member']; |
|
| 1669 | + if (in_array($row['id_member'], $ignoreArray)) { |
|
| 1670 | + continue; |
|
| 1671 | + } else { |
|
| 1672 | + $ignoreArray[] = (int) $row['id_member']; |
|
| 1673 | + } |
|
| 1594 | 1674 | } |
| 1595 | 1675 | $smcFunc['db_free_result']($request); |
| 1596 | 1676 | |
@@ -1619,8 +1699,9 @@ discard block |
||
| 1619 | 1699 | 'ignore_list_count' => substr_count($user_profile[$memID]['pm_ignore_list'], ',') + 1, |
| 1620 | 1700 | ) |
| 1621 | 1701 | ); |
| 1622 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
| 1623 | - $ignored[] = $row['id_member']; |
|
| 1702 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
| 1703 | + $ignored[] = $row['id_member']; |
|
| 1704 | + } |
|
| 1624 | 1705 | $smcFunc['db_free_result']($result); |
| 1625 | 1706 | } |
| 1626 | 1707 | |
@@ -1639,10 +1720,11 @@ discard block |
||
| 1639 | 1720 | |
| 1640 | 1721 | if (isset($_SESSION['prf-save'])) |
| 1641 | 1722 | { |
| 1642 | - if ($_SESSION['prf-save'] === true) |
|
| 1643 | - $context['saved_successful'] = true; |
|
| 1644 | - else |
|
| 1645 | - $context['saved_failed'] = $_SESSION['prf-save']; |
|
| 1723 | + if ($_SESSION['prf-save'] === true) { |
|
| 1724 | + $context['saved_successful'] = true; |
|
| 1725 | + } else { |
|
| 1726 | + $context['saved_failed'] = $_SESSION['prf-save']; |
|
| 1727 | + } |
|
| 1646 | 1728 | |
| 1647 | 1729 | unset($_SESSION['prf-save']); |
| 1648 | 1730 | } |
@@ -1658,8 +1740,9 @@ discard block |
||
| 1658 | 1740 | global $context, $txt; |
| 1659 | 1741 | |
| 1660 | 1742 | loadThemeOptions($memID); |
| 1661 | - if (allowedTo(array('profile_identity_own', 'profile_identity_any', 'profile_password_own', 'profile_password_any'))) |
|
| 1662 | - loadCustomFields($memID, 'account'); |
|
| 1743 | + if (allowedTo(array('profile_identity_own', 'profile_identity_any', 'profile_password_own', 'profile_password_any'))) { |
|
| 1744 | + loadCustomFields($memID, 'account'); |
|
| 1745 | + } |
|
| 1663 | 1746 | |
| 1664 | 1747 | $context['sub_template'] = 'edit_options'; |
| 1665 | 1748 | $context['page_desc'] = $txt['account_info']; |
@@ -1686,8 +1769,9 @@ discard block |
||
| 1686 | 1769 | global $context, $txt; |
| 1687 | 1770 | |
| 1688 | 1771 | loadThemeOptions($memID); |
| 1689 | - if (allowedTo(array('profile_forum_own', 'profile_forum_any'))) |
|
| 1690 | - loadCustomFields($memID, 'forumprofile'); |
|
| 1772 | + if (allowedTo(array('profile_forum_own', 'profile_forum_any'))) { |
|
| 1773 | + loadCustomFields($memID, 'forumprofile'); |
|
| 1774 | + } |
|
| 1691 | 1775 | |
| 1692 | 1776 | $context['sub_template'] = 'edit_options'; |
| 1693 | 1777 | $context['page_desc'] = $txt['forumProfile_info']; |
@@ -1720,18 +1804,21 @@ discard block |
||
| 1720 | 1804 | $dirs = array(); |
| 1721 | 1805 | $files = array(); |
| 1722 | 1806 | |
| 1723 | - if (!$dir) |
|
| 1724 | - return array(); |
|
| 1807 | + if (!$dir) { |
|
| 1808 | + return array(); |
|
| 1809 | + } |
|
| 1725 | 1810 | |
| 1726 | 1811 | while ($line = $dir->read()) |
| 1727 | 1812 | { |
| 1728 | - if (in_array($line, array('.', '..', 'blank.png', 'index.php'))) |
|
| 1729 | - continue; |
|
| 1813 | + if (in_array($line, array('.', '..', 'blank.png', 'index.php'))) { |
|
| 1814 | + continue; |
|
| 1815 | + } |
|
| 1730 | 1816 | |
| 1731 | - if (is_dir($modSettings['avatar_directory'] . '/' . $directory . (!empty($directory) ? '/' : '') . $line)) |
|
| 1732 | - $dirs[] = $line; |
|
| 1733 | - else |
|
| 1734 | - $files[] = $line; |
|
| 1817 | + if (is_dir($modSettings['avatar_directory'] . '/' . $directory . (!empty($directory) ? '/' : '') . $line)) { |
|
| 1818 | + $dirs[] = $line; |
|
| 1819 | + } else { |
|
| 1820 | + $files[] = $line; |
|
| 1821 | + } |
|
| 1735 | 1822 | } |
| 1736 | 1823 | $dir->close(); |
| 1737 | 1824 | |
@@ -1752,14 +1839,15 @@ discard block |
||
| 1752 | 1839 | foreach ($dirs as $line) |
| 1753 | 1840 | { |
| 1754 | 1841 | $tmp = getAvatars($directory . (!empty($directory) ? '/' : '') . $line, $level + 1); |
| 1755 | - if (!empty($tmp)) |
|
| 1756 | - $result[] = array( |
|
| 1842 | + if (!empty($tmp)) { |
|
| 1843 | + $result[] = array( |
|
| 1757 | 1844 | 'filename' => $smcFunc['htmlspecialchars']($line), |
| 1758 | 1845 | 'checked' => strpos($context['member']['avatar']['server_pic'], $line . '/') !== false, |
| 1759 | 1846 | 'name' => '[' . $smcFunc['htmlspecialchars'](str_replace('_', ' ', $line)) . ']', |
| 1760 | 1847 | 'is_dir' => true, |
| 1761 | 1848 | 'files' => $tmp |
| 1762 | 1849 | ); |
| 1850 | + } |
|
| 1763 | 1851 | unset($tmp); |
| 1764 | 1852 | } |
| 1765 | 1853 | |
@@ -1769,8 +1857,9 @@ discard block |
||
| 1769 | 1857 | $extension = substr(strrchr($line, '.'), 1); |
| 1770 | 1858 | |
| 1771 | 1859 | // Make sure it is an image. |
| 1772 | - if (strcasecmp($extension, 'gif') != 0 && strcasecmp($extension, 'jpg') != 0 && strcasecmp($extension, 'jpeg') != 0 && strcasecmp($extension, 'png') != 0 && strcasecmp($extension, 'bmp') != 0) |
|
| 1773 | - continue; |
|
| 1860 | + if (strcasecmp($extension, 'gif') != 0 && strcasecmp($extension, 'jpg') != 0 && strcasecmp($extension, 'jpeg') != 0 && strcasecmp($extension, 'png') != 0 && strcasecmp($extension, 'bmp') != 0) { |
|
| 1861 | + continue; |
|
| 1862 | + } |
|
| 1774 | 1863 | |
| 1775 | 1864 | $result[] = array( |
| 1776 | 1865 | 'filename' => $smcFunc['htmlspecialchars']($line), |
@@ -1778,8 +1867,9 @@ discard block |
||
| 1778 | 1867 | 'name' => $smcFunc['htmlspecialchars'](str_replace('_', ' ', $filename)), |
| 1779 | 1868 | 'is_dir' => false |
| 1780 | 1869 | ); |
| 1781 | - if ($level == 1) |
|
| 1782 | - $context['avatar_list'][] = $directory . '/' . $line; |
|
| 1870 | + if ($level == 1) { |
|
| 1871 | + $context['avatar_list'][] = $directory . '/' . $line; |
|
| 1872 | + } |
|
| 1783 | 1873 | } |
| 1784 | 1874 | |
| 1785 | 1875 | return $result; |
@@ -1795,8 +1885,9 @@ discard block |
||
| 1795 | 1885 | global $txt, $context; |
| 1796 | 1886 | |
| 1797 | 1887 | loadThemeOptions($memID); |
| 1798 | - if (allowedTo(array('profile_extra_own', 'profile_extra_any'))) |
|
| 1799 | - loadCustomFields($memID, 'theme'); |
|
| 1888 | + if (allowedTo(array('profile_extra_own', 'profile_extra_any'))) { |
|
| 1889 | + loadCustomFields($memID, 'theme'); |
|
| 1890 | + } |
|
| 1800 | 1891 | |
| 1801 | 1892 | $context['sub_template'] = 'edit_options'; |
| 1802 | 1893 | $context['page_desc'] = $txt['theme_info']; |
@@ -1850,16 +1941,19 @@ discard block |
||
| 1850 | 1941 | { |
| 1851 | 1942 | global $txt, $user_profile, $context, $modSettings, $smcFunc, $sourcedir; |
| 1852 | 1943 | |
| 1853 | - if (!isset($context['token_check'])) |
|
| 1854 | - $context['token_check'] = 'profile-nt' . $memID; |
|
| 1944 | + if (!isset($context['token_check'])) { |
|
| 1945 | + $context['token_check'] = 'profile-nt' . $memID; |
|
| 1946 | + } |
|
| 1855 | 1947 | |
| 1856 | 1948 | is_not_guest(); |
| 1857 | - if (!$context['user']['is_owner']) |
|
| 1858 | - isAllowedTo('profile_extra_any'); |
|
| 1949 | + if (!$context['user']['is_owner']) { |
|
| 1950 | + isAllowedTo('profile_extra_any'); |
|
| 1951 | + } |
|
| 1859 | 1952 | |
| 1860 | 1953 | // Set the post action if we're coming from the profile... |
| 1861 | - if (!isset($context['action'])) |
|
| 1862 | - $context['action'] = 'action=profile;area=notification;sa=alerts;u=' . $memID; |
|
| 1954 | + if (!isset($context['action'])) { |
|
| 1955 | + $context['action'] = 'action=profile;area=notification;sa=alerts;u=' . $memID; |
|
| 1956 | + } |
|
| 1863 | 1957 | |
| 1864 | 1958 | // What options are set |
| 1865 | 1959 | loadThemeOptions($memID); |
@@ -1946,28 +2040,34 @@ discard block |
||
| 1946 | 2040 | ); |
| 1947 | 2041 | |
| 1948 | 2042 | // There are certain things that are disabled at the group level. |
| 1949 | - if (empty($modSettings['cal_enabled'])) |
|
| 1950 | - unset($alert_types['calendar']); |
|
| 2043 | + if (empty($modSettings['cal_enabled'])) { |
|
| 2044 | + unset($alert_types['calendar']); |
|
| 2045 | + } |
|
| 1951 | 2046 | |
| 1952 | 2047 | // Disable paid subscriptions at group level if they're disabled |
| 1953 | - if (empty($modSettings['paid_enabled'])) |
|
| 1954 | - unset($alert_types['paidsubs']); |
|
| 2048 | + if (empty($modSettings['paid_enabled'])) { |
|
| 2049 | + unset($alert_types['paidsubs']); |
|
| 2050 | + } |
|
| 1955 | 2051 | |
| 1956 | 2052 | // Disable membergroup requests at group level if they're disabled |
| 1957 | - if (empty($modSettings['show_group_membership'])) |
|
| 1958 | - unset($alert_types['groupr'], $alert_types['members']['request_group']); |
|
| 2053 | + if (empty($modSettings['show_group_membership'])) { |
|
| 2054 | + unset($alert_types['groupr'], $alert_types['members']['request_group']); |
|
| 2055 | + } |
|
| 1959 | 2056 | |
| 1960 | 2057 | // Disable mentions if they're disabled |
| 1961 | - if (empty($modSettings['enable_mentions'])) |
|
| 1962 | - unset($alert_types['msg']['msg_mention']); |
|
| 2058 | + if (empty($modSettings['enable_mentions'])) { |
|
| 2059 | + unset($alert_types['msg']['msg_mention']); |
|
| 2060 | + } |
|
| 1963 | 2061 | |
| 1964 | 2062 | // Disable likes if they're disabled |
| 1965 | - if (empty($modSettings['enable_likes'])) |
|
| 1966 | - unset($alert_types['msg']['msg_like']); |
|
| 2063 | + if (empty($modSettings['enable_likes'])) { |
|
| 2064 | + unset($alert_types['msg']['msg_like']); |
|
| 2065 | + } |
|
| 1967 | 2066 | |
| 1968 | 2067 | // Disable buddy requests if they're disabled |
| 1969 | - if (empty($modSettings['enable_buddylist'])) |
|
| 1970 | - unset($alert_types['members']['buddy_request']); |
|
| 2068 | + if (empty($modSettings['enable_buddylist'])) { |
|
| 2069 | + unset($alert_types['members']['buddy_request']); |
|
| 2070 | + } |
|
| 1971 | 2071 | |
| 1972 | 2072 | // Now, now, we could pass this through global but we should really get into the habit of |
| 1973 | 2073 | // passing content to hooks, not expecting hooks to splatter everything everywhere. |
@@ -1995,15 +2095,17 @@ discard block |
||
| 1995 | 2095 | $perms_cache['manage_membergroups'] = in_array($memID, $members); |
| 1996 | 2096 | } |
| 1997 | 2097 | |
| 1998 | - if (!($perms_cache['manage_membergroups'] || $can_mod != 0)) |
|
| 1999 | - unset($alert_types['members']['request_group']); |
|
| 2098 | + if (!($perms_cache['manage_membergroups'] || $can_mod != 0)) { |
|
| 2099 | + unset($alert_types['members']['request_group']); |
|
| 2100 | + } |
|
| 2000 | 2101 | |
| 2001 | 2102 | foreach ($alert_types as $group => $items) |
| 2002 | 2103 | { |
| 2003 | 2104 | foreach ($items as $alert_key => $alert_value) |
| 2004 | 2105 | { |
| 2005 | - if (!isset($alert_value['permission'])) |
|
| 2006 | - continue; |
|
| 2106 | + if (!isset($alert_value['permission'])) { |
|
| 2107 | + continue; |
|
| 2108 | + } |
|
| 2007 | 2109 | if (!isset($perms_cache[$alert_value['permission']['name']])) |
| 2008 | 2110 | { |
| 2009 | 2111 | $in_board = !empty($alert_value['permission']['is_board']) ? 0 : null; |
@@ -2011,12 +2113,14 @@ discard block |
||
| 2011 | 2113 | $perms_cache[$alert_value['permission']['name']] = in_array($memID, $members); |
| 2012 | 2114 | } |
| 2013 | 2115 | |
| 2014 | - if (!$perms_cache[$alert_value['permission']['name']]) |
|
| 2015 | - unset ($alert_types[$group][$alert_key]); |
|
| 2116 | + if (!$perms_cache[$alert_value['permission']['name']]) { |
|
| 2117 | + unset ($alert_types[$group][$alert_key]); |
|
| 2118 | + } |
|
| 2016 | 2119 | } |
| 2017 | 2120 | |
| 2018 | - if (empty($alert_types[$group])) |
|
| 2019 | - unset ($alert_types[$group]); |
|
| 2121 | + if (empty($alert_types[$group])) { |
|
| 2122 | + unset ($alert_types[$group]); |
|
| 2123 | + } |
|
| 2020 | 2124 | } |
| 2021 | 2125 | } |
| 2022 | 2126 | |
@@ -2048,9 +2152,9 @@ discard block |
||
| 2048 | 2152 | $update_prefs[$this_option[1]] = !empty($_POST['opt_' . $this_option[1]]) ? 1 : 0; |
| 2049 | 2153 | break; |
| 2050 | 2154 | case 'select': |
| 2051 | - if (isset($_POST['opt_' . $this_option[1]], $this_option['opts'][$_POST['opt_' . $this_option[1]]])) |
|
| 2052 | - $update_prefs[$this_option[1]] = $_POST['opt_' . $this_option[1]]; |
|
| 2053 | - else |
|
| 2155 | + if (isset($_POST['opt_' . $this_option[1]], $this_option['opts'][$_POST['opt_' . $this_option[1]]])) { |
|
| 2156 | + $update_prefs[$this_option[1]] = $_POST['opt_' . $this_option[1]]; |
|
| 2157 | + } else |
|
| 2054 | 2158 | { |
| 2055 | 2159 | // We didn't have a sane value. Let's grab the first item from the possibles. |
| 2056 | 2160 | $keys = array_keys($this_option['opts']); |
@@ -2070,23 +2174,28 @@ discard block |
||
| 2070 | 2174 | $this_value = 0; |
| 2071 | 2175 | foreach ($context['alert_bits'] as $type => $bitvalue) |
| 2072 | 2176 | { |
| 2073 | - if ($this_options[$type] == 'yes' && !empty($_POST[$type . '_' . $item_key]) || $this_options[$type] == 'always') |
|
| 2074 | - $this_value |= $bitvalue; |
|
| 2177 | + if ($this_options[$type] == 'yes' && !empty($_POST[$type . '_' . $item_key]) || $this_options[$type] == 'always') { |
|
| 2178 | + $this_value |= $bitvalue; |
|
| 2179 | + } |
|
| 2180 | + } |
|
| 2181 | + if (!isset($context['alert_prefs'][$item_key]) || $context['alert_prefs'][$item_key] != $this_value) { |
|
| 2182 | + $update_prefs[$item_key] = $this_value; |
|
| 2075 | 2183 | } |
| 2076 | - if (!isset($context['alert_prefs'][$item_key]) || $context['alert_prefs'][$item_key] != $this_value) |
|
| 2077 | - $update_prefs[$item_key] = $this_value; |
|
| 2078 | 2184 | } |
| 2079 | 2185 | } |
| 2080 | 2186 | |
| 2081 | - if (!empty($_POST['opt_alert_timeout'])) |
|
| 2082 | - $update_prefs['alert_timeout'] = $context['member']['alert_timeout'] = (int) $_POST['opt_alert_timeout']; |
|
| 2187 | + if (!empty($_POST['opt_alert_timeout'])) { |
|
| 2188 | + $update_prefs['alert_timeout'] = $context['member']['alert_timeout'] = (int) $_POST['opt_alert_timeout']; |
|
| 2189 | + } |
|
| 2083 | 2190 | |
| 2084 | - if (!empty($_POST['notify_announcements'])) |
|
| 2085 | - $update_prefs['announcements'] = $context['member']['notify_announcements'] = (int) $_POST['notify_announcements']; |
|
| 2191 | + if (!empty($_POST['notify_announcements'])) { |
|
| 2192 | + $update_prefs['announcements'] = $context['member']['notify_announcements'] = (int) $_POST['notify_announcements']; |
|
| 2193 | + } |
|
| 2086 | 2194 | |
| 2087 | 2195 | setNotifyPrefs((int) $memID, $update_prefs); |
| 2088 | - foreach ($update_prefs as $pref => $value) |
|
| 2089 | - $context['alert_prefs'][$pref] = $value; |
|
| 2196 | + foreach ($update_prefs as $pref => $value) { |
|
| 2197 | + $context['alert_prefs'][$pref] = $value; |
|
| 2198 | + } |
|
| 2090 | 2199 | |
| 2091 | 2200 | makeNotificationChanges($memID); |
| 2092 | 2201 | |
@@ -2116,8 +2225,9 @@ discard block |
||
| 2116 | 2225 | |
| 2117 | 2226 | // Now we're all set up. |
| 2118 | 2227 | is_not_guest(); |
| 2119 | - if (!$context['user']['is_owner']) |
|
| 2120 | - fatal_error('no_access'); |
|
| 2228 | + if (!$context['user']['is_owner']) { |
|
| 2229 | + fatal_error('no_access'); |
|
| 2230 | + } |
|
| 2121 | 2231 | |
| 2122 | 2232 | checkSession('get'); |
| 2123 | 2233 | |
@@ -2149,8 +2259,9 @@ discard block |
||
| 2149 | 2259 | { |
| 2150 | 2260 | global $smcFunc; |
| 2151 | 2261 | |
| 2152 | - if (empty($toMark) || empty($memID)) |
|
| 2153 | - return false; |
|
| 2262 | + if (empty($toMark) || empty($memID)) { |
|
| 2263 | + return false; |
|
| 2264 | + } |
|
| 2154 | 2265 | |
| 2155 | 2266 | $toMark = (array) $toMark; |
| 2156 | 2267 | |
@@ -2184,8 +2295,9 @@ discard block |
||
| 2184 | 2295 | { |
| 2185 | 2296 | global $smcFunc; |
| 2186 | 2297 | |
| 2187 | - if (empty($toDelete)) |
|
| 2188 | - return false; |
|
| 2298 | + if (empty($toDelete)) { |
|
| 2299 | + return false; |
|
| 2300 | + } |
|
| 2189 | 2301 | |
| 2190 | 2302 | $toDelete = (array) $toDelete; |
| 2191 | 2303 | |
@@ -2220,8 +2332,9 @@ discard block |
||
| 2220 | 2332 | { |
| 2221 | 2333 | global $smcFunc; |
| 2222 | 2334 | |
| 2223 | - if (empty($memID)) |
|
| 2224 | - return false; |
|
| 2335 | + if (empty($memID)) { |
|
| 2336 | + return false; |
|
| 2337 | + } |
|
| 2225 | 2338 | |
| 2226 | 2339 | $request = $smcFunc['db_query']('', ' |
| 2227 | 2340 | SELECT id_alert |
@@ -2298,8 +2411,9 @@ discard block |
||
| 2298 | 2411 | { |
| 2299 | 2412 | $link = $topic['link']; |
| 2300 | 2413 | |
| 2301 | - if ($topic['new']) |
|
| 2302 | - $link .= ' <a href="' . $topic['new_href'] . '"><span class="new_posts">' . $txt['new'] . '</span></a>'; |
|
| 2414 | + if ($topic['new']) { |
|
| 2415 | + $link .= ' <a href="' . $topic['new_href'] . '"><span class="new_posts">' . $txt['new'] . '</span></a>'; |
|
| 2416 | + } |
|
| 2303 | 2417 | |
| 2304 | 2418 | $link .= '<br><span class="smalltext"><em>' . $txt['in'] . ' ' . $topic['board_link'] . '</em></span>'; |
| 2305 | 2419 | |
@@ -2450,8 +2564,9 @@ discard block |
||
| 2450 | 2564 | { |
| 2451 | 2565 | $link = $board['link']; |
| 2452 | 2566 | |
| 2453 | - if ($board['new']) |
|
| 2454 | - $link .= ' <a href="' . $board['href'] . '"><span class="new_posts">' . $txt['new'] . '</span></a>'; |
|
| 2567 | + if ($board['new']) { |
|
| 2568 | + $link .= ' <a href="' . $board['href'] . '"><span class="new_posts">' . $txt['new'] . '</span></a>'; |
|
| 2569 | + } |
|
| 2455 | 2570 | |
| 2456 | 2571 | return $link; |
| 2457 | 2572 | }, |
@@ -2651,8 +2766,8 @@ discard block |
||
| 2651 | 2766 | ) |
| 2652 | 2767 | ); |
| 2653 | 2768 | $notification_boards = array(); |
| 2654 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2655 | - $notification_boards[] = array( |
|
| 2769 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2770 | + $notification_boards[] = array( |
|
| 2656 | 2771 | 'id' => $row['id_board'], |
| 2657 | 2772 | 'name' => $row['name'], |
| 2658 | 2773 | 'href' => $scripturl . '?board=' . $row['id_board'] . '.0', |
@@ -2660,6 +2775,7 @@ discard block |
||
| 2660 | 2775 | 'new' => $row['board_read'] < $row['id_msg_updated'], |
| 2661 | 2776 | 'notify_pref' => isset($prefs['board_notify_' . $row['id_board']]) ? $prefs['board_notify_' . $row['id_board']] : (!empty($prefs['board_notify']) ? $prefs['board_notify'] : 0), |
| 2662 | 2777 | ); |
| 2778 | + } |
|
| 2663 | 2779 | $smcFunc['db_free_result']($request); |
| 2664 | 2780 | |
| 2665 | 2781 | return $notification_boards; |
@@ -2674,17 +2790,18 @@ discard block |
||
| 2674 | 2790 | { |
| 2675 | 2791 | global $context, $options, $cur_profile, $smcFunc; |
| 2676 | 2792 | |
| 2677 | - if (isset($_POST['default_options'])) |
|
| 2678 | - $_POST['options'] = isset($_POST['options']) ? $_POST['options'] + $_POST['default_options'] : $_POST['default_options']; |
|
| 2793 | + if (isset($_POST['default_options'])) { |
|
| 2794 | + $_POST['options'] = isset($_POST['options']) ? $_POST['options'] + $_POST['default_options'] : $_POST['default_options']; |
|
| 2795 | + } |
|
| 2679 | 2796 | |
| 2680 | 2797 | if ($context['user']['is_owner']) |
| 2681 | 2798 | { |
| 2682 | 2799 | $context['member']['options'] = $options; |
| 2683 | - if (isset($_POST['options']) && is_array($_POST['options'])) |
|
| 2684 | - foreach ($_POST['options'] as $k => $v) |
|
| 2800 | + if (isset($_POST['options']) && is_array($_POST['options'])) { |
|
| 2801 | + foreach ($_POST['options'] as $k => $v) |
|
| 2685 | 2802 | $context['member']['options'][$k] = $v; |
| 2686 | - } |
|
| 2687 | - else |
|
| 2803 | + } |
|
| 2804 | + } else |
|
| 2688 | 2805 | { |
| 2689 | 2806 | $request = $smcFunc['db_query']('', ' |
| 2690 | 2807 | SELECT id_member, variable, value |
@@ -2705,8 +2822,9 @@ discard block |
||
| 2705 | 2822 | continue; |
| 2706 | 2823 | } |
| 2707 | 2824 | |
| 2708 | - if (isset($_POST['options'][$row['variable']])) |
|
| 2709 | - $row['value'] = $_POST['options'][$row['variable']]; |
|
| 2825 | + if (isset($_POST['options'][$row['variable']])) { |
|
| 2826 | + $row['value'] = $_POST['options'][$row['variable']]; |
|
| 2827 | + } |
|
| 2710 | 2828 | $context['member']['options'][$row['variable']] = $row['value']; |
| 2711 | 2829 | } |
| 2712 | 2830 | $smcFunc['db_free_result']($request); |
@@ -2714,8 +2832,9 @@ discard block |
||
| 2714 | 2832 | // Load up the default theme options for any missing. |
| 2715 | 2833 | foreach ($temp as $k => $v) |
| 2716 | 2834 | { |
| 2717 | - if (!isset($context['member']['options'][$k])) |
|
| 2718 | - $context['member']['options'][$k] = $v; |
|
| 2835 | + if (!isset($context['member']['options'][$k])) { |
|
| 2836 | + $context['member']['options'][$k] = $v; |
|
| 2837 | + } |
|
| 2719 | 2838 | } |
| 2720 | 2839 | } |
| 2721 | 2840 | } |
@@ -2730,8 +2849,9 @@ discard block |
||
| 2730 | 2849 | global $context, $modSettings, $smcFunc, $cur_profile, $sourcedir; |
| 2731 | 2850 | |
| 2732 | 2851 | // Have the admins enabled this option? |
| 2733 | - if (empty($modSettings['allow_ignore_boards'])) |
|
| 2734 | - fatal_lang_error('ignoreboards_disallowed', 'user'); |
|
| 2852 | + if (empty($modSettings['allow_ignore_boards'])) { |
|
| 2853 | + fatal_lang_error('ignoreboards_disallowed', 'user'); |
|
| 2854 | + } |
|
| 2735 | 2855 | |
| 2736 | 2856 | // Find all the boards this user is allowed to see. |
| 2737 | 2857 | $request = $smcFunc['db_query']('order_by_board_order', ' |
@@ -2751,12 +2871,13 @@ discard block |
||
| 2751 | 2871 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2752 | 2872 | { |
| 2753 | 2873 | // This category hasn't been set up yet.. |
| 2754 | - if (!isset($context['categories'][$row['id_cat']])) |
|
| 2755 | - $context['categories'][$row['id_cat']] = array( |
|
| 2874 | + if (!isset($context['categories'][$row['id_cat']])) { |
|
| 2875 | + $context['categories'][$row['id_cat']] = array( |
|
| 2756 | 2876 | 'id' => $row['id_cat'], |
| 2757 | 2877 | 'name' => $row['cat_name'], |
| 2758 | 2878 | 'boards' => array() |
| 2759 | 2879 | ); |
| 2880 | + } |
|
| 2760 | 2881 | |
| 2761 | 2882 | // Set this board up, and let the template know when it's a child. (indent them..) |
| 2762 | 2883 | $context['categories'][$row['id_cat']]['boards'][$row['id_board']] = array( |
@@ -2786,18 +2907,20 @@ discard block |
||
| 2786 | 2907 | } |
| 2787 | 2908 | |
| 2788 | 2909 | $max_boards = ceil(count($temp_boards) / 2); |
| 2789 | - if ($max_boards == 1) |
|
| 2790 | - $max_boards = 2; |
|
| 2910 | + if ($max_boards == 1) { |
|
| 2911 | + $max_boards = 2; |
|
| 2912 | + } |
|
| 2791 | 2913 | |
| 2792 | 2914 | // Now, alternate them so they can be shown left and right ;). |
| 2793 | 2915 | $context['board_columns'] = array(); |
| 2794 | 2916 | for ($i = 0; $i < $max_boards; $i++) |
| 2795 | 2917 | { |
| 2796 | 2918 | $context['board_columns'][] = $temp_boards[$i]; |
| 2797 | - if (isset($temp_boards[$i + $max_boards])) |
|
| 2798 | - $context['board_columns'][] = $temp_boards[$i + $max_boards]; |
|
| 2799 | - else |
|
| 2800 | - $context['board_columns'][] = array(); |
|
| 2919 | + if (isset($temp_boards[$i + $max_boards])) { |
|
| 2920 | + $context['board_columns'][] = $temp_boards[$i + $max_boards]; |
|
| 2921 | + } else { |
|
| 2922 | + $context['board_columns'][] = array(); |
|
| 2923 | + } |
|
| 2801 | 2924 | } |
| 2802 | 2925 | |
| 2803 | 2926 | loadThemeOptions($memID); |
@@ -2866,8 +2989,9 @@ discard block |
||
| 2866 | 2989 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2867 | 2990 | { |
| 2868 | 2991 | // We should skip the administrator group if they don't have the admin_forum permission! |
| 2869 | - if ($row['id_group'] == 1 && !allowedTo('admin_forum')) |
|
| 2870 | - continue; |
|
| 2992 | + if ($row['id_group'] == 1 && !allowedTo('admin_forum')) { |
|
| 2993 | + continue; |
|
| 2994 | + } |
|
| 2871 | 2995 | |
| 2872 | 2996 | $context['member_groups'][$row['id_group']] = array( |
| 2873 | 2997 | 'id' => $row['id_group'], |
@@ -2913,16 +3037,17 @@ discard block |
||
| 2913 | 3037 | $context['max_signature_length'] = $context['signature_limits']['max_length']; |
| 2914 | 3038 | // Warning message for signature image limits? |
| 2915 | 3039 | $context['signature_warning'] = ''; |
| 2916 | - if ($context['signature_limits']['max_image_width'] && $context['signature_limits']['max_image_height']) |
|
| 2917 | - $context['signature_warning'] = sprintf($txt['profile_error_signature_max_image_size'], $context['signature_limits']['max_image_width'], $context['signature_limits']['max_image_height']); |
|
| 2918 | - elseif ($context['signature_limits']['max_image_width'] || $context['signature_limits']['max_image_height']) |
|
| 2919 | - $context['signature_warning'] = sprintf($txt['profile_error_signature_max_image_' . ($context['signature_limits']['max_image_width'] ? 'width' : 'height')], $context['signature_limits'][$context['signature_limits']['max_image_width'] ? 'max_image_width' : 'max_image_height']); |
|
| 3040 | + if ($context['signature_limits']['max_image_width'] && $context['signature_limits']['max_image_height']) { |
|
| 3041 | + $context['signature_warning'] = sprintf($txt['profile_error_signature_max_image_size'], $context['signature_limits']['max_image_width'], $context['signature_limits']['max_image_height']); |
|
| 3042 | + } elseif ($context['signature_limits']['max_image_width'] || $context['signature_limits']['max_image_height']) { |
|
| 3043 | + $context['signature_warning'] = sprintf($txt['profile_error_signature_max_image_' . ($context['signature_limits']['max_image_width'] ? 'width' : 'height')], $context['signature_limits'][$context['signature_limits']['max_image_width'] ? 'max_image_width' : 'max_image_height']); |
|
| 3044 | + } |
|
| 2920 | 3045 | |
| 2921 | 3046 | $context['show_spellchecking'] = !empty($modSettings['enableSpellChecking']) && (function_exists('pspell_new') || (function_exists('enchant_broker_init') && ($txt['lang_charset'] == 'UTF-8' || function_exists('iconv')))); |
| 2922 | 3047 | |
| 2923 | - if (empty($context['do_preview'])) |
|
| 2924 | - $context['member']['signature'] = empty($cur_profile['signature']) ? '' : str_replace(array('<br>', '<', '>', '"', '\''), array("\n", '<', '>', '"', '''), $cur_profile['signature']); |
|
| 2925 | - else |
|
| 3048 | + if (empty($context['do_preview'])) { |
|
| 3049 | + $context['member']['signature'] = empty($cur_profile['signature']) ? '' : str_replace(array('<br>', '<', '>', '"', '\''), array("\n", '<', '>', '"', '''), $cur_profile['signature']); |
|
| 3050 | + } else |
|
| 2926 | 3051 | { |
| 2927 | 3052 | $signature = !empty($_POST['signature']) ? $_POST['signature'] : ''; |
| 2928 | 3053 | $validation = profileValidateSignature($signature); |
@@ -2932,8 +3057,9 @@ discard block |
||
| 2932 | 3057 | $context['post_errors'] = array(); |
| 2933 | 3058 | } |
| 2934 | 3059 | $context['post_errors'][] = 'signature_not_yet_saved'; |
| 2935 | - if ($validation !== true && $validation !== false) |
|
| 2936 | - $context['post_errors'][] = $validation; |
|
| 3060 | + if ($validation !== true && $validation !== false) { |
|
| 3061 | + $context['post_errors'][] = $validation; |
|
| 3062 | + } |
|
| 2937 | 3063 | |
| 2938 | 3064 | censorText($context['member']['signature']); |
| 2939 | 3065 | $context['member']['current_signature'] = $context['member']['signature']; |
@@ -2943,8 +3069,9 @@ discard block |
||
| 2943 | 3069 | } |
| 2944 | 3070 | |
| 2945 | 3071 | // Load the spell checker? |
| 2946 | - if ($context['show_spellchecking']) |
|
| 2947 | - loadJavaScriptFile('spellcheck.js', array('defer' => false), 'smf_spellcheck'); |
|
| 3072 | + if ($context['show_spellchecking']) { |
|
| 3073 | + loadJavaScriptFile('spellcheck.js', array('defer' => false), 'smf_spellcheck'); |
|
| 3074 | + } |
|
| 2948 | 3075 | |
| 2949 | 3076 | return true; |
| 2950 | 3077 | } |
@@ -2978,8 +3105,7 @@ discard block |
||
| 2978 | 3105 | 'external' => $cur_profile['avatar'] == 'gravatar://' || empty($modSettings['gravatarAllowExtraEmail']) || !empty($modSettings['gravatarOverride']) ? $cur_profile['email_address'] : substr($cur_profile['avatar'], 11) |
| 2979 | 3106 | ); |
| 2980 | 3107 | $context['member']['avatar']['href'] = get_gravatar_url($context['member']['avatar']['external']); |
| 2981 | - } |
|
| 2982 | - elseif ($cur_profile['avatar'] == '' && $cur_profile['id_attach'] > 0 && $context['member']['avatar']['allow_upload']) |
|
| 3108 | + } elseif ($cur_profile['avatar'] == '' && $cur_profile['id_attach'] > 0 && $context['member']['avatar']['allow_upload']) |
|
| 2983 | 3109 | { |
| 2984 | 3110 | $context['member']['avatar'] += array( |
| 2985 | 3111 | 'choice' => 'upload', |
@@ -2987,34 +3113,34 @@ discard block |
||
| 2987 | 3113 | 'external' => 'http://' |
| 2988 | 3114 | ); |
| 2989 | 3115 | $context['member']['avatar']['href'] = empty($cur_profile['attachment_type']) ? $scripturl . '?action=dlattach;attach=' . $cur_profile['id_attach'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $cur_profile['filename']; |
| 2990 | - } |
|
| 2991 | - elseif ((stristr($cur_profile['avatar'], 'http://') || stristr($cur_profile['avatar'], 'https://')) && $context['member']['avatar']['allow_external']) |
|
| 2992 | - $context['member']['avatar'] += array( |
|
| 3116 | + } elseif ((stristr($cur_profile['avatar'], 'http://') || stristr($cur_profile['avatar'], 'https://')) && $context['member']['avatar']['allow_external']) { |
|
| 3117 | + $context['member']['avatar'] += array( |
|
| 2993 | 3118 | 'choice' => 'external', |
| 2994 | 3119 | 'server_pic' => 'blank.png', |
| 2995 | 3120 | 'external' => $cur_profile['avatar'] |
| 2996 | 3121 | ); |
| 2997 | - elseif ($cur_profile['avatar'] != '' && file_exists($modSettings['avatar_directory'] . '/' . $cur_profile['avatar']) && $context['member']['avatar']['allow_server_stored']) |
|
| 2998 | - $context['member']['avatar'] += array( |
|
| 3122 | + } elseif ($cur_profile['avatar'] != '' && file_exists($modSettings['avatar_directory'] . '/' . $cur_profile['avatar']) && $context['member']['avatar']['allow_server_stored']) { |
|
| 3123 | + $context['member']['avatar'] += array( |
|
| 2999 | 3124 | 'choice' => 'server_stored', |
| 3000 | 3125 | 'server_pic' => $cur_profile['avatar'] == '' ? 'blank.png' : $cur_profile['avatar'], |
| 3001 | 3126 | 'external' => 'http://' |
| 3002 | 3127 | ); |
| 3003 | - else |
|
| 3004 | - $context['member']['avatar'] += array( |
|
| 3128 | + } else { |
|
| 3129 | + $context['member']['avatar'] += array( |
|
| 3005 | 3130 | 'choice' => 'none', |
| 3006 | 3131 | 'server_pic' => 'blank.png', |
| 3007 | 3132 | 'external' => 'http://' |
| 3008 | 3133 | ); |
| 3134 | + } |
|
| 3009 | 3135 | |
| 3010 | 3136 | // Get a list of all the avatars. |
| 3011 | 3137 | if ($context['member']['avatar']['allow_server_stored']) |
| 3012 | 3138 | { |
| 3013 | 3139 | $context['avatar_list'] = array(); |
| 3014 | 3140 | $context['avatars'] = is_dir($modSettings['avatar_directory']) ? getAvatars('', 0) : array(); |
| 3141 | + } else { |
|
| 3142 | + $context['avatars'] = array(); |
|
| 3015 | 3143 | } |
| 3016 | - else |
|
| 3017 | - $context['avatars'] = array(); |
|
| 3018 | 3144 | |
| 3019 | 3145 | // Second level selected avatar... |
| 3020 | 3146 | $context['avatar_selected'] = substr(strrchr($context['member']['avatar']['server_pic'], '/'), 1); |
@@ -3043,19 +3169,22 @@ discard block |
||
| 3043 | 3169 | ) |
| 3044 | 3170 | ); |
| 3045 | 3171 | $protected_groups = array(1); |
| 3046 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 3047 | - $protected_groups[] = $row['id_group']; |
|
| 3172 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 3173 | + $protected_groups[] = $row['id_group']; |
|
| 3174 | + } |
|
| 3048 | 3175 | $smcFunc['db_free_result']($request); |
| 3049 | 3176 | |
| 3050 | 3177 | $protected_groups = array_unique($protected_groups); |
| 3051 | 3178 | } |
| 3052 | 3179 | |
| 3053 | 3180 | // The account page allows the change of your id_group - but not to a protected group! |
| 3054 | - if (empty($protected_groups) || count(array_intersect(array((int) $value, $old_profile['id_group']), $protected_groups)) == 0) |
|
| 3055 | - $value = (int) $value; |
|
| 3181 | + if (empty($protected_groups) || count(array_intersect(array((int) $value, $old_profile['id_group']), $protected_groups)) == 0) { |
|
| 3182 | + $value = (int) $value; |
|
| 3183 | + } |
|
| 3056 | 3184 | // ... otherwise it's the old group sir. |
| 3057 | - else |
|
| 3058 | - $value = $old_profile['id_group']; |
|
| 3185 | + else { |
|
| 3186 | + $value = $old_profile['id_group']; |
|
| 3187 | + } |
|
| 3059 | 3188 | |
| 3060 | 3189 | // Find the additional membergroups (if any) |
| 3061 | 3190 | if (isset($_POST['additional_groups']) && is_array($_POST['additional_groups'])) |
@@ -3064,16 +3193,18 @@ discard block |
||
| 3064 | 3193 | foreach ($_POST['additional_groups'] as $group_id) |
| 3065 | 3194 | { |
| 3066 | 3195 | $group_id = (int) $group_id; |
| 3067 | - if (!empty($group_id) && (empty($protected_groups) || !in_array($group_id, $protected_groups))) |
|
| 3068 | - $additional_groups[] = $group_id; |
|
| 3196 | + if (!empty($group_id) && (empty($protected_groups) || !in_array($group_id, $protected_groups))) { |
|
| 3197 | + $additional_groups[] = $group_id; |
|
| 3198 | + } |
|
| 3069 | 3199 | } |
| 3070 | 3200 | |
| 3071 | 3201 | // Put the protected groups back in there if you don't have permission to take them away. |
| 3072 | 3202 | $old_additional_groups = explode(',', $old_profile['additional_groups']); |
| 3073 | 3203 | foreach ($old_additional_groups as $group_id) |
| 3074 | 3204 | { |
| 3075 | - if (!empty($protected_groups) && in_array($group_id, $protected_groups)) |
|
| 3076 | - $additional_groups[] = $group_id; |
|
| 3205 | + if (!empty($protected_groups) && in_array($group_id, $protected_groups)) { |
|
| 3206 | + $additional_groups[] = $group_id; |
|
| 3207 | + } |
|
| 3077 | 3208 | } |
| 3078 | 3209 | |
| 3079 | 3210 | if (implode(',', $additional_groups) !== $old_profile['additional_groups']) |
@@ -3105,18 +3236,20 @@ discard block |
||
| 3105 | 3236 | list ($another) = $smcFunc['db_fetch_row']($request); |
| 3106 | 3237 | $smcFunc['db_free_result']($request); |
| 3107 | 3238 | |
| 3108 | - if (empty($another)) |
|
| 3109 | - fatal_lang_error('at_least_one_admin', 'critical'); |
|
| 3239 | + if (empty($another)) { |
|
| 3240 | + fatal_lang_error('at_least_one_admin', 'critical'); |
|
| 3241 | + } |
|
| 3110 | 3242 | } |
| 3111 | 3243 | } |
| 3112 | 3244 | |
| 3113 | 3245 | // If we are changing group status, update permission cache as necessary. |
| 3114 | 3246 | if ($value != $old_profile['id_group'] || isset($profile_vars['additional_groups'])) |
| 3115 | 3247 | { |
| 3116 | - if ($context['user']['is_owner']) |
|
| 3117 | - $_SESSION['mc']['time'] = 0; |
|
| 3118 | - else |
|
| 3119 | - updateSettings(array('settings_updated' => time())); |
|
| 3248 | + if ($context['user']['is_owner']) { |
|
| 3249 | + $_SESSION['mc']['time'] = 0; |
|
| 3250 | + } else { |
|
| 3251 | + updateSettings(array('settings_updated' => time())); |
|
| 3252 | + } |
|
| 3120 | 3253 | } |
| 3121 | 3254 | |
| 3122 | 3255 | // Announce to any hooks that we have changed groups, but don't allow them to change it. |
@@ -3137,8 +3270,9 @@ discard block |
||
| 3137 | 3270 | global $modSettings, $sourcedir, $smcFunc, $profile_vars, $cur_profile, $context; |
| 3138 | 3271 | |
| 3139 | 3272 | $memID = $context['id_member']; |
| 3140 | - if (empty($memID) && !empty($context['password_auth_failed'])) |
|
| 3141 | - return false; |
|
| 3273 | + if (empty($memID) && !empty($context['password_auth_failed'])) { |
|
| 3274 | + return false; |
|
| 3275 | + } |
|
| 3142 | 3276 | |
| 3143 | 3277 | require_once($sourcedir . '/ManageAttachments.php'); |
| 3144 | 3278 | |
@@ -3149,8 +3283,9 @@ discard block |
||
| 3149 | 3283 | $downloadedExternalAvatar = false; |
| 3150 | 3284 | if ($value == 'external' && allowedTo('profile_remote_avatar') && (stripos($_POST['userpicpersonal'], 'http://') === 0 || stripos($_POST['userpicpersonal'], 'https://') === 0) && strlen($_POST['userpicpersonal']) > 7 && !empty($modSettings['avatar_download_external'])) |
| 3151 | 3285 | { |
| 3152 | - if (!is_writable($uploadDir)) |
|
| 3153 | - fatal_lang_error('attachments_no_write', 'critical'); |
|
| 3286 | + if (!is_writable($uploadDir)) { |
|
| 3287 | + fatal_lang_error('attachments_no_write', 'critical'); |
|
| 3288 | + } |
|
| 3154 | 3289 | |
| 3155 | 3290 | require_once($sourcedir . '/Subs-Package.php'); |
| 3156 | 3291 | |
@@ -3194,19 +3329,18 @@ discard block |
||
| 3194 | 3329 | |
| 3195 | 3330 | // Get rid of their old avatar. (if uploaded.) |
| 3196 | 3331 | removeAttachments(array('id_member' => $memID)); |
| 3197 | - } |
|
| 3198 | - elseif ($value == 'gravatar' && !empty($modSettings['gravatarEnabled'])) |
|
| 3332 | + } elseif ($value == 'gravatar' && !empty($modSettings['gravatarEnabled'])) |
|
| 3199 | 3333 | { |
| 3200 | 3334 | // One wasn't specified, or it's not allowed to use extra email addresses, or it's not a valid one, reset to default Gravatar. |
| 3201 | - if (empty($_POST['gravatarEmail']) || empty($modSettings['gravatarAllowExtraEmail']) || !filter_var($_POST['gravatarEmail'], FILTER_VALIDATE_EMAIL)) |
|
| 3202 | - $profile_vars['avatar'] = 'gravatar://'; |
|
| 3203 | - else |
|
| 3204 | - $profile_vars['avatar'] = 'gravatar://' . ($_POST['gravatarEmail'] != $cur_profile['email_address'] ? $_POST['gravatarEmail'] : ''); |
|
| 3335 | + if (empty($_POST['gravatarEmail']) || empty($modSettings['gravatarAllowExtraEmail']) || !filter_var($_POST['gravatarEmail'], FILTER_VALIDATE_EMAIL)) { |
|
| 3336 | + $profile_vars['avatar'] = 'gravatar://'; |
|
| 3337 | + } else { |
|
| 3338 | + $profile_vars['avatar'] = 'gravatar://' . ($_POST['gravatarEmail'] != $cur_profile['email_address'] ? $_POST['gravatarEmail'] : ''); |
|
| 3339 | + } |
|
| 3205 | 3340 | |
| 3206 | 3341 | // Get rid of their old avatar. (if uploaded.) |
| 3207 | 3342 | removeAttachments(array('id_member' => $memID)); |
| 3208 | - } |
|
| 3209 | - elseif ($value == 'external' && allowedTo('profile_remote_avatar') && (stripos($_POST['userpicpersonal'], 'http://') === 0 || stripos($_POST['userpicpersonal'], 'https://') === 0) && empty($modSettings['avatar_download_external'])) |
|
| 3343 | + } elseif ($value == 'external' && allowedTo('profile_remote_avatar') && (stripos($_POST['userpicpersonal'], 'http://') === 0 || stripos($_POST['userpicpersonal'], 'https://') === 0) && empty($modSettings['avatar_download_external'])) |
|
| 3210 | 3344 | { |
| 3211 | 3345 | // We need these clean... |
| 3212 | 3346 | $cur_profile['id_attach'] = 0; |
@@ -3218,11 +3352,13 @@ discard block |
||
| 3218 | 3352 | |
| 3219 | 3353 | $profile_vars['avatar'] = str_replace(' ', '%20', preg_replace('~action(?:=|%3d)(?!dlattach)~i', 'action-', $_POST['userpicpersonal'])); |
| 3220 | 3354 | |
| 3221 | - if ($profile_vars['avatar'] == 'http://' || $profile_vars['avatar'] == 'http:///') |
|
| 3222 | - $profile_vars['avatar'] = ''; |
|
| 3355 | + if ($profile_vars['avatar'] == 'http://' || $profile_vars['avatar'] == 'http:///') { |
|
| 3356 | + $profile_vars['avatar'] = ''; |
|
| 3357 | + } |
|
| 3223 | 3358 | // Trying to make us do something we'll regret? |
| 3224 | - elseif (substr($profile_vars['avatar'], 0, 7) != 'http://' && substr($profile_vars['avatar'], 0, 8) != 'https://') |
|
| 3225 | - return 'bad_avatar_invalid_url'; |
|
| 3359 | + elseif (substr($profile_vars['avatar'], 0, 7) != 'http://' && substr($profile_vars['avatar'], 0, 8) != 'https://') { |
|
| 3360 | + return 'bad_avatar_invalid_url'; |
|
| 3361 | + } |
|
| 3226 | 3362 | // Should we check dimensions? |
| 3227 | 3363 | elseif (!empty($modSettings['avatar_max_height_external']) || !empty($modSettings['avatar_max_width_external'])) |
| 3228 | 3364 | { |
@@ -3232,9 +3368,9 @@ discard block |
||
| 3232 | 3368 | if (is_array($sizes) && (($sizes[0] > $modSettings['avatar_max_width_external'] && !empty($modSettings['avatar_max_width_external'])) || ($sizes[1] > $modSettings['avatar_max_height_external'] && !empty($modSettings['avatar_max_height_external'])))) |
| 3233 | 3369 | { |
| 3234 | 3370 | // Houston, we have a problem. The avatar is too large!! |
| 3235 | - if ($modSettings['avatar_action_too_large'] == 'option_refuse') |
|
| 3236 | - return 'bad_avatar_too_large'; |
|
| 3237 | - elseif ($modSettings['avatar_action_too_large'] == 'option_download_and_resize') |
|
| 3371 | + if ($modSettings['avatar_action_too_large'] == 'option_refuse') { |
|
| 3372 | + return 'bad_avatar_too_large'; |
|
| 3373 | + } elseif ($modSettings['avatar_action_too_large'] == 'option_download_and_resize') |
|
| 3238 | 3374 | { |
| 3239 | 3375 | // @todo remove this if appropriate |
| 3240 | 3376 | require_once($sourcedir . '/Subs-Graphics.php'); |
@@ -3244,26 +3380,27 @@ discard block |
||
| 3244 | 3380 | $cur_profile['id_attach'] = $modSettings['new_avatar_data']['id']; |
| 3245 | 3381 | $cur_profile['filename'] = $modSettings['new_avatar_data']['filename']; |
| 3246 | 3382 | $cur_profile['attachment_type'] = $modSettings['new_avatar_data']['type']; |
| 3383 | + } else { |
|
| 3384 | + return 'bad_avatar'; |
|
| 3247 | 3385 | } |
| 3248 | - else |
|
| 3249 | - return 'bad_avatar'; |
|
| 3250 | 3386 | } |
| 3251 | 3387 | } |
| 3252 | 3388 | } |
| 3253 | - } |
|
| 3254 | - elseif (($value == 'upload' && allowedTo('profile_upload_avatar')) || $downloadedExternalAvatar) |
|
| 3389 | + } elseif (($value == 'upload' && allowedTo('profile_upload_avatar')) || $downloadedExternalAvatar) |
|
| 3255 | 3390 | { |
| 3256 | 3391 | if ((isset($_FILES['attachment']['name']) && $_FILES['attachment']['name'] != '') || $downloadedExternalAvatar) |
| 3257 | 3392 | { |
| 3258 | 3393 | // Get the dimensions of the image. |
| 3259 | 3394 | if (!$downloadedExternalAvatar) |
| 3260 | 3395 | { |
| 3261 | - if (!is_writable($uploadDir)) |
|
| 3262 | - fatal_lang_error('attachments_no_write', 'critical'); |
|
| 3396 | + if (!is_writable($uploadDir)) { |
|
| 3397 | + fatal_lang_error('attachments_no_write', 'critical'); |
|
| 3398 | + } |
|
| 3263 | 3399 | |
| 3264 | 3400 | $new_filename = $uploadDir . '/' . getAttachmentFilename('avatar_tmp_' . $memID, false, null, true); |
| 3265 | - if (!move_uploaded_file($_FILES['attachment']['tmp_name'], $new_filename)) |
|
| 3266 | - fatal_lang_error('attach_timeout', 'critical'); |
|
| 3401 | + if (!move_uploaded_file($_FILES['attachment']['tmp_name'], $new_filename)) { |
|
| 3402 | + fatal_lang_error('attach_timeout', 'critical'); |
|
| 3403 | + } |
|
| 3267 | 3404 | |
| 3268 | 3405 | $_FILES['attachment']['tmp_name'] = $new_filename; |
| 3269 | 3406 | } |
@@ -3376,17 +3513,19 @@ discard block |
||
| 3376 | 3513 | $profile_vars['avatar'] = ''; |
| 3377 | 3514 | |
| 3378 | 3515 | // Delete any temporary file. |
| 3379 | - if (file_exists($_FILES['attachment']['tmp_name'])) |
|
| 3380 | - @unlink($_FILES['attachment']['tmp_name']); |
|
| 3516 | + if (file_exists($_FILES['attachment']['tmp_name'])) { |
|
| 3517 | + @unlink($_FILES['attachment']['tmp_name']); |
|
| 3518 | + } |
|
| 3381 | 3519 | } |
| 3382 | 3520 | // Selected the upload avatar option and had one already uploaded before or didn't upload one. |
| 3383 | - else |
|
| 3521 | + else { |
|
| 3522 | + $profile_vars['avatar'] = ''; |
|
| 3523 | + } |
|
| 3524 | + } elseif ($value == 'gravatar' && allowedTo('profile_gravatar_avatar')) { |
|
| 3525 | + $profile_vars['avatar'] = 'gravatar://www.gravatar.com/avatar/' . md5(strtolower(trim($cur_profile['email_address']))); |
|
| 3526 | + } else { |
|
| 3384 | 3527 | $profile_vars['avatar'] = ''; |
| 3385 | 3528 | } |
| 3386 | - elseif ($value == 'gravatar' && allowedTo('profile_gravatar_avatar')) |
|
| 3387 | - $profile_vars['avatar'] = 'gravatar://www.gravatar.com/avatar/' . md5(strtolower(trim($cur_profile['email_address']))); |
|
| 3388 | - else |
|
| 3389 | - $profile_vars['avatar'] = ''; |
|
| 3390 | 3529 | |
| 3391 | 3530 | // Setup the profile variables so it shows things right on display! |
| 3392 | 3531 | $cur_profile['avatar'] = $profile_vars['avatar']; |
@@ -3434,9 +3573,9 @@ discard block |
||
| 3434 | 3573 | $smiley_parsed = $unparsed_signature; |
| 3435 | 3574 | parsesmileys($smiley_parsed); |
| 3436 | 3575 | $smiley_count = substr_count(strtolower($smiley_parsed), '<img') - substr_count(strtolower($unparsed_signature), '<img'); |
| 3437 | - if (!empty($sig_limits[4]) && $sig_limits[4] == -1 && $smiley_count > 0) |
|
| 3438 | - return 'signature_allow_smileys'; |
|
| 3439 | - elseif (!empty($sig_limits[4]) && $sig_limits[4] > 0 && $smiley_count > $sig_limits[4]) |
|
| 3576 | + if (!empty($sig_limits[4]) && $sig_limits[4] == -1 && $smiley_count > 0) { |
|
| 3577 | + return 'signature_allow_smileys'; |
|
| 3578 | + } elseif (!empty($sig_limits[4]) && $sig_limits[4] > 0 && $smiley_count > $sig_limits[4]) |
|
| 3440 | 3579 | { |
| 3441 | 3580 | $txt['profile_error_signature_max_smileys'] = sprintf($txt['profile_error_signature_max_smileys'], $sig_limits[4]); |
| 3442 | 3581 | return 'signature_max_smileys'; |
@@ -3449,14 +3588,15 @@ discard block |
||
| 3449 | 3588 | { |
| 3450 | 3589 | $limit_broke = 0; |
| 3451 | 3590 | // Attempt to allow all sizes of abuse, so to speak. |
| 3452 | - if ($matches[2][$ind] == 'px' && $size > $sig_limits[7]) |
|
| 3453 | - $limit_broke = $sig_limits[7] . 'px'; |
|
| 3454 | - elseif ($matches[2][$ind] == 'pt' && $size > ($sig_limits[7] * 0.75)) |
|
| 3455 | - $limit_broke = ((int) $sig_limits[7] * 0.75) . 'pt'; |
|
| 3456 | - elseif ($matches[2][$ind] == 'em' && $size > ((float) $sig_limits[7] / 16)) |
|
| 3457 | - $limit_broke = ((float) $sig_limits[7] / 16) . 'em'; |
|
| 3458 | - elseif ($matches[2][$ind] != 'px' && $matches[2][$ind] != 'pt' && $matches[2][$ind] != 'em' && $sig_limits[7] < 18) |
|
| 3459 | - $limit_broke = 'large'; |
|
| 3591 | + if ($matches[2][$ind] == 'px' && $size > $sig_limits[7]) { |
|
| 3592 | + $limit_broke = $sig_limits[7] . 'px'; |
|
| 3593 | + } elseif ($matches[2][$ind] == 'pt' && $size > ($sig_limits[7] * 0.75)) { |
|
| 3594 | + $limit_broke = ((int) $sig_limits[7] * 0.75) . 'pt'; |
|
| 3595 | + } elseif ($matches[2][$ind] == 'em' && $size > ((float) $sig_limits[7] / 16)) { |
|
| 3596 | + $limit_broke = ((float) $sig_limits[7] / 16) . 'em'; |
|
| 3597 | + } elseif ($matches[2][$ind] != 'px' && $matches[2][$ind] != 'pt' && $matches[2][$ind] != 'em' && $sig_limits[7] < 18) { |
|
| 3598 | + $limit_broke = 'large'; |
|
| 3599 | + } |
|
| 3460 | 3600 | |
| 3461 | 3601 | if ($limit_broke) |
| 3462 | 3602 | { |
@@ -3498,24 +3638,26 @@ discard block |
||
| 3498 | 3638 | $width = -1; $height = -1; |
| 3499 | 3639 | |
| 3500 | 3640 | // Does it have predefined restraints? Width first. |
| 3501 | - if ($matches[6][$key]) |
|
| 3502 | - $matches[2][$key] = $matches[6][$key]; |
|
| 3641 | + if ($matches[6][$key]) { |
|
| 3642 | + $matches[2][$key] = $matches[6][$key]; |
|
| 3643 | + } |
|
| 3503 | 3644 | if ($matches[2][$key] && $sig_limits[5] && $matches[2][$key] > $sig_limits[5]) |
| 3504 | 3645 | { |
| 3505 | 3646 | $width = $sig_limits[5]; |
| 3506 | 3647 | $matches[4][$key] = $matches[4][$key] * ($width / $matches[2][$key]); |
| 3648 | + } elseif ($matches[2][$key]) { |
|
| 3649 | + $width = $matches[2][$key]; |
|
| 3507 | 3650 | } |
| 3508 | - elseif ($matches[2][$key]) |
|
| 3509 | - $width = $matches[2][$key]; |
|
| 3510 | 3651 | // ... and height. |
| 3511 | 3652 | if ($matches[4][$key] && $sig_limits[6] && $matches[4][$key] > $sig_limits[6]) |
| 3512 | 3653 | { |
| 3513 | 3654 | $height = $sig_limits[6]; |
| 3514 | - if ($width != -1) |
|
| 3515 | - $width = $width * ($height / $matches[4][$key]); |
|
| 3655 | + if ($width != -1) { |
|
| 3656 | + $width = $width * ($height / $matches[4][$key]); |
|
| 3657 | + } |
|
| 3658 | + } elseif ($matches[4][$key]) { |
|
| 3659 | + $height = $matches[4][$key]; |
|
| 3516 | 3660 | } |
| 3517 | - elseif ($matches[4][$key]) |
|
| 3518 | - $height = $matches[4][$key]; |
|
| 3519 | 3661 | |
| 3520 | 3662 | // If the dimensions are still not fixed - we need to check the actual image. |
| 3521 | 3663 | if (($width == -1 && $sig_limits[5]) || ($height == -1 && $sig_limits[6])) |
@@ -3533,21 +3675,24 @@ discard block |
||
| 3533 | 3675 | if ($sizes[1] > $sig_limits[6] && $sig_limits[6]) |
| 3534 | 3676 | { |
| 3535 | 3677 | $height = $sig_limits[6]; |
| 3536 | - if ($width == -1) |
|
| 3537 | - $width = $sizes[0]; |
|
| 3678 | + if ($width == -1) { |
|
| 3679 | + $width = $sizes[0]; |
|
| 3680 | + } |
|
| 3538 | 3681 | $width = $width * ($height / $sizes[1]); |
| 3682 | + } elseif ($width != -1) { |
|
| 3683 | + $height = $sizes[1]; |
|
| 3539 | 3684 | } |
| 3540 | - elseif ($width != -1) |
|
| 3541 | - $height = $sizes[1]; |
|
| 3542 | 3685 | } |
| 3543 | 3686 | } |
| 3544 | 3687 | |
| 3545 | 3688 | // Did we come up with some changes? If so remake the string. |
| 3546 | - if ($width != -1 || $height != -1) |
|
| 3547 | - $replaces[$image] = '[img' . ($width != -1 ? ' width=' . round($width) : '') . ($height != -1 ? ' height=' . round($height) : '') . ']' . $matches[7][$key] . '[/img]'; |
|
| 3689 | + if ($width != -1 || $height != -1) { |
|
| 3690 | + $replaces[$image] = '[img' . ($width != -1 ? ' width=' . round($width) : '') . ($height != -1 ? ' height=' . round($height) : '') . ']' . $matches[7][$key] . '[/img]'; |
|
| 3691 | + } |
|
| 3692 | + } |
|
| 3693 | + if (!empty($replaces)) { |
|
| 3694 | + $value = str_replace(array_keys($replaces), array_values($replaces), $value); |
|
| 3548 | 3695 | } |
| 3549 | - if (!empty($replaces)) |
|
| 3550 | - $value = str_replace(array_keys($replaces), array_values($replaces), $value); |
|
| 3551 | 3696 | } |
| 3552 | 3697 | } |
| 3553 | 3698 | |
@@ -3591,10 +3736,12 @@ discard block |
||
| 3591 | 3736 | $email = strtr($email, array(''' => '\'')); |
| 3592 | 3737 | |
| 3593 | 3738 | // Check the name and email for validity. |
| 3594 | - if (trim($email) == '') |
|
| 3595 | - return 'no_email'; |
|
| 3596 | - if (!filter_var($email, FILTER_VALIDATE_EMAIL)) |
|
| 3597 | - return 'bad_email'; |
|
| 3739 | + if (trim($email) == '') { |
|
| 3740 | + return 'no_email'; |
|
| 3741 | + } |
|
| 3742 | + if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { |
|
| 3743 | + return 'bad_email'; |
|
| 3744 | + } |
|
| 3598 | 3745 | |
| 3599 | 3746 | // Email addresses should be and stay unique. |
| 3600 | 3747 | $request = $smcFunc['db_query']('', ' |
@@ -3609,8 +3756,9 @@ discard block |
||
| 3609 | 3756 | ) |
| 3610 | 3757 | ); |
| 3611 | 3758 | |
| 3612 | - if ($smcFunc['db_num_rows']($request) > 0) |
|
| 3613 | - return 'email_taken'; |
|
| 3759 | + if ($smcFunc['db_num_rows']($request) > 0) { |
|
| 3760 | + return 'email_taken'; |
|
| 3761 | + } |
|
| 3614 | 3762 | $smcFunc['db_free_result']($request); |
| 3615 | 3763 | |
| 3616 | 3764 | return true; |
@@ -3623,8 +3771,9 @@ discard block |
||
| 3623 | 3771 | { |
| 3624 | 3772 | global $modSettings, $context, $cur_profile; |
| 3625 | 3773 | |
| 3626 | - if (isset($_POST['passwrd2']) && $_POST['passwrd2'] != '') |
|
| 3627 | - setLoginCookie(60 * $modSettings['cookieTime'], $context['id_member'], hash_salt($_POST['passwrd1'], $cur_profile['password_salt'])); |
|
| 3774 | + if (isset($_POST['passwrd2']) && $_POST['passwrd2'] != '') { |
|
| 3775 | + setLoginCookie(60 * $modSettings['cookieTime'], $context['id_member'], hash_salt($_POST['passwrd1'], $cur_profile['password_salt'])); |
|
| 3776 | + } |
|
| 3628 | 3777 | |
| 3629 | 3778 | loadUserSettings(); |
| 3630 | 3779 | writeLog(); |
@@ -3640,8 +3789,9 @@ discard block |
||
| 3640 | 3789 | require_once($sourcedir . '/Subs-Post.php'); |
| 3641 | 3790 | |
| 3642 | 3791 | // Shouldn't happen but just in case. |
| 3643 | - if (empty($profile_vars['email_address'])) |
|
| 3644 | - return; |
|
| 3792 | + if (empty($profile_vars['email_address'])) { |
|
| 3793 | + return; |
|
| 3794 | + } |
|
| 3645 | 3795 | |
| 3646 | 3796 | $replacements = array( |
| 3647 | 3797 | 'ACTIVATIONLINK' => $scripturl . '?action=activate;u=' . $context['id_member'] . ';code=' . $profile_vars['validation_code'], |
@@ -3664,8 +3814,9 @@ discard block |
||
| 3664 | 3814 | $_SESSION['log_time'] = 0; |
| 3665 | 3815 | $_SESSION['login_' . $cookiename] = json_encode(array(0, '', 0)); |
| 3666 | 3816 | |
| 3667 | - if (isset($_COOKIE[$cookiename])) |
|
| 3668 | - $_COOKIE[$cookiename] = ''; |
|
| 3817 | + if (isset($_COOKIE[$cookiename])) { |
|
| 3818 | + $_COOKIE[$cookiename] = ''; |
|
| 3819 | + } |
|
| 3669 | 3820 | |
| 3670 | 3821 | loadUserSettings(); |
| 3671 | 3822 | |
@@ -3698,11 +3849,13 @@ discard block |
||
| 3698 | 3849 | $groups[] = $curMember['id_group']; |
| 3699 | 3850 | |
| 3700 | 3851 | // Ensure the query doesn't croak! |
| 3701 | - if (empty($groups)) |
|
| 3702 | - $groups = array(0); |
|
| 3852 | + if (empty($groups)) { |
|
| 3853 | + $groups = array(0); |
|
| 3854 | + } |
|
| 3703 | 3855 | // Just to be sure... |
| 3704 | - foreach ($groups as $k => $v) |
|
| 3705 | - $groups[$k] = (int) $v; |
|
| 3856 | + foreach ($groups as $k => $v) { |
|
| 3857 | + $groups[$k] = (int) $v; |
|
| 3858 | + } |
|
| 3706 | 3859 | |
| 3707 | 3860 | // Get all the membergroups they can join. |
| 3708 | 3861 | $request = $smcFunc['db_query']('', ' |
@@ -3732,12 +3885,14 @@ discard block |
||
| 3732 | 3885 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 3733 | 3886 | { |
| 3734 | 3887 | // Can they edit their primary group? |
| 3735 | - if (($row['id_group'] == $context['primary_group'] && $row['group_type'] > 1) || ($row['hidden'] != 2 && $context['primary_group'] == 0 && in_array($row['id_group'], $groups))) |
|
| 3736 | - $context['can_edit_primary'] = true; |
|
| 3888 | + if (($row['id_group'] == $context['primary_group'] && $row['group_type'] > 1) || ($row['hidden'] != 2 && $context['primary_group'] == 0 && in_array($row['id_group'], $groups))) { |
|
| 3889 | + $context['can_edit_primary'] = true; |
|
| 3890 | + } |
|
| 3737 | 3891 | |
| 3738 | 3892 | // If they can't manage (protected) groups, and it's not publically joinable or already assigned, they can't see it. |
| 3739 | - if (((!$context['can_manage_protected'] && $row['group_type'] == 1) || (!$context['can_manage_membergroups'] && $row['group_type'] == 0)) && $row['id_group'] != $context['primary_group']) |
|
| 3740 | - continue; |
|
| 3893 | + if (((!$context['can_manage_protected'] && $row['group_type'] == 1) || (!$context['can_manage_membergroups'] && $row['group_type'] == 0)) && $row['id_group'] != $context['primary_group']) { |
|
| 3894 | + continue; |
|
| 3895 | + } |
|
| 3741 | 3896 | |
| 3742 | 3897 | $context['groups'][in_array($row['id_group'], $groups) ? 'member' : 'available'][$row['id_group']] = array( |
| 3743 | 3898 | 'id' => $row['id_group'], |
@@ -3766,13 +3921,15 @@ discard block |
||
| 3766 | 3921 | ); |
| 3767 | 3922 | |
| 3768 | 3923 | // No changing primary one unless you have enough groups! |
| 3769 | - if (count($context['groups']['member']) < 2) |
|
| 3770 | - $context['can_edit_primary'] = false; |
|
| 3924 | + if (count($context['groups']['member']) < 2) { |
|
| 3925 | + $context['can_edit_primary'] = false; |
|
| 3926 | + } |
|
| 3771 | 3927 | |
| 3772 | 3928 | // In the special case that someone is requesting membership of a group, setup some special context vars. |
| 3773 | - if (isset($_REQUEST['request']) && isset($context['groups']['available'][(int) $_REQUEST['request']]) && $context['groups']['available'][(int) $_REQUEST['request']]['type'] == 2) |
|
| 3774 | - $context['group_request'] = $context['groups']['available'][(int) $_REQUEST['request']]; |
|
| 3775 | -} |
|
| 3929 | + if (isset($_REQUEST['request']) && isset($context['groups']['available'][(int) $_REQUEST['request']]) && $context['groups']['available'][(int) $_REQUEST['request']]['type'] == 2) { |
|
| 3930 | + $context['group_request'] = $context['groups']['available'][(int) $_REQUEST['request']]; |
|
| 3931 | + } |
|
| 3932 | + } |
|
| 3776 | 3933 | |
| 3777 | 3934 | /** |
| 3778 | 3935 | * This function actually makes all the group changes |
@@ -3787,10 +3944,12 @@ discard block |
||
| 3787 | 3944 | global $user_info, $context, $user_profile, $modSettings, $smcFunc; |
| 3788 | 3945 | |
| 3789 | 3946 | // Let's be extra cautious... |
| 3790 | - if (!$context['user']['is_owner'] || empty($modSettings['show_group_membership'])) |
|
| 3791 | - isAllowedTo('manage_membergroups'); |
|
| 3792 | - if (!isset($_REQUEST['gid']) && !isset($_POST['primary'])) |
|
| 3793 | - fatal_lang_error('no_access', false); |
|
| 3947 | + if (!$context['user']['is_owner'] || empty($modSettings['show_group_membership'])) { |
|
| 3948 | + isAllowedTo('manage_membergroups'); |
|
| 3949 | + } |
|
| 3950 | + if (!isset($_REQUEST['gid']) && !isset($_POST['primary'])) { |
|
| 3951 | + fatal_lang_error('no_access', false); |
|
| 3952 | + } |
|
| 3794 | 3953 | |
| 3795 | 3954 | checkSession(isset($_GET['gid']) ? 'get' : 'post'); |
| 3796 | 3955 | |
@@ -3809,8 +3968,9 @@ discard block |
||
| 3809 | 3968 | $foundTarget = $changeType == 'primary' && $group_id == 0 ? true : false; |
| 3810 | 3969 | |
| 3811 | 3970 | // Sanity check!! |
| 3812 | - if ($group_id == 1) |
|
| 3813 | - isAllowedTo('admin_forum'); |
|
| 3971 | + if ($group_id == 1) { |
|
| 3972 | + isAllowedTo('admin_forum'); |
|
| 3973 | + } |
|
| 3814 | 3974 | // Protected groups too! |
| 3815 | 3975 | else |
| 3816 | 3976 | { |
@@ -3827,8 +3987,9 @@ discard block |
||
| 3827 | 3987 | list ($is_protected) = $smcFunc['db_fetch_row']($request); |
| 3828 | 3988 | $smcFunc['db_free_result']($request); |
| 3829 | 3989 | |
| 3830 | - if ($is_protected == 1) |
|
| 3831 | - isAllowedTo('admin_forum'); |
|
| 3990 | + if ($is_protected == 1) { |
|
| 3991 | + isAllowedTo('admin_forum'); |
|
| 3992 | + } |
|
| 3832 | 3993 | } |
| 3833 | 3994 | |
| 3834 | 3995 | // What ever we are doing, we need to determine if changing primary is possible! |
@@ -3850,36 +4011,43 @@ discard block |
||
| 3850 | 4011 | $group_name = $row['group_name']; |
| 3851 | 4012 | |
| 3852 | 4013 | // Does the group type match what we're doing - are we trying to request a non-requestable group? |
| 3853 | - if ($changeType == 'request' && $row['group_type'] != 2) |
|
| 3854 | - fatal_lang_error('no_access', false); |
|
| 4014 | + if ($changeType == 'request' && $row['group_type'] != 2) { |
|
| 4015 | + fatal_lang_error('no_access', false); |
|
| 4016 | + } |
|
| 3855 | 4017 | // What about leaving a requestable group we are not a member of? |
| 3856 | - elseif ($changeType == 'free' && $row['group_type'] == 2 && $old_profile['id_group'] != $row['id_group'] && !isset($addGroups[$row['id_group']])) |
|
| 3857 | - fatal_lang_error('no_access', false); |
|
| 3858 | - elseif ($changeType == 'free' && $row['group_type'] != 3 && $row['group_type'] != 2) |
|
| 3859 | - fatal_lang_error('no_access', false); |
|
| 4018 | + elseif ($changeType == 'free' && $row['group_type'] == 2 && $old_profile['id_group'] != $row['id_group'] && !isset($addGroups[$row['id_group']])) { |
|
| 4019 | + fatal_lang_error('no_access', false); |
|
| 4020 | + } elseif ($changeType == 'free' && $row['group_type'] != 3 && $row['group_type'] != 2) { |
|
| 4021 | + fatal_lang_error('no_access', false); |
|
| 4022 | + } |
|
| 3860 | 4023 | |
| 3861 | 4024 | // We can't change the primary group if this is hidden! |
| 3862 | - if ($row['hidden'] == 2) |
|
| 3863 | - $canChangePrimary = false; |
|
| 4025 | + if ($row['hidden'] == 2) { |
|
| 4026 | + $canChangePrimary = false; |
|
| 4027 | + } |
|
| 3864 | 4028 | } |
| 3865 | 4029 | |
| 3866 | 4030 | // If this is their old primary, can we change it? |
| 3867 | - if ($row['id_group'] == $old_profile['id_group'] && ($row['group_type'] > 1 || $context['can_manage_membergroups']) && $canChangePrimary !== false) |
|
| 3868 | - $canChangePrimary = 1; |
|
| 4031 | + if ($row['id_group'] == $old_profile['id_group'] && ($row['group_type'] > 1 || $context['can_manage_membergroups']) && $canChangePrimary !== false) { |
|
| 4032 | + $canChangePrimary = 1; |
|
| 4033 | + } |
|
| 3869 | 4034 | |
| 3870 | 4035 | // If we are not doing a force primary move, don't do it automatically if current primary is not 0. |
| 3871 | - if ($changeType != 'primary' && $old_profile['id_group'] != 0) |
|
| 3872 | - $canChangePrimary = false; |
|
| 4036 | + if ($changeType != 'primary' && $old_profile['id_group'] != 0) { |
|
| 4037 | + $canChangePrimary = false; |
|
| 4038 | + } |
|
| 3873 | 4039 | |
| 3874 | 4040 | // If this is the one we are acting on, can we even act? |
| 3875 | - if ((!$context['can_manage_protected'] && $row['group_type'] == 1) || (!$context['can_manage_membergroups'] && $row['group_type'] == 0)) |
|
| 3876 | - $canChangePrimary = false; |
|
| 4041 | + if ((!$context['can_manage_protected'] && $row['group_type'] == 1) || (!$context['can_manage_membergroups'] && $row['group_type'] == 0)) { |
|
| 4042 | + $canChangePrimary = false; |
|
| 4043 | + } |
|
| 3877 | 4044 | } |
| 3878 | 4045 | $smcFunc['db_free_result']($request); |
| 3879 | 4046 | |
| 3880 | 4047 | // Didn't find the target? |
| 3881 | - if (!$foundTarget) |
|
| 3882 | - fatal_lang_error('no_access', false); |
|
| 4048 | + if (!$foundTarget) { |
|
| 4049 | + fatal_lang_error('no_access', false); |
|
| 4050 | + } |
|
| 3883 | 4051 | |
| 3884 | 4052 | // Final security check, don't allow users to promote themselves to admin. |
| 3885 | 4053 | if ($context['can_manage_membergroups'] && !allowedTo('admin_forum')) |
@@ -3899,8 +4067,9 @@ discard block |
||
| 3899 | 4067 | list ($disallow) = $smcFunc['db_fetch_row']($request); |
| 3900 | 4068 | $smcFunc['db_free_result']($request); |
| 3901 | 4069 | |
| 3902 | - if ($disallow) |
|
| 3903 | - isAllowedTo('admin_forum'); |
|
| 4070 | + if ($disallow) { |
|
| 4071 | + isAllowedTo('admin_forum'); |
|
| 4072 | + } |
|
| 3904 | 4073 | } |
| 3905 | 4074 | |
| 3906 | 4075 | // If we're requesting, add the note then return. |
@@ -3918,8 +4087,9 @@ discard block |
||
| 3918 | 4087 | 'status_open' => 0, |
| 3919 | 4088 | ) |
| 3920 | 4089 | ); |
| 3921 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
| 3922 | - fatal_lang_error('profile_error_already_requested_group'); |
|
| 4090 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
| 4091 | + fatal_lang_error('profile_error_already_requested_group'); |
|
| 4092 | + } |
|
| 3923 | 4093 | $smcFunc['db_free_result']($request); |
| 3924 | 4094 | |
| 3925 | 4095 | // Log the request. |
@@ -3953,10 +4123,11 @@ discard block |
||
| 3953 | 4123 | // Are we leaving? |
| 3954 | 4124 | if ($old_profile['id_group'] == $group_id || isset($addGroups[$group_id])) |
| 3955 | 4125 | { |
| 3956 | - if ($old_profile['id_group'] == $group_id) |
|
| 3957 | - $newPrimary = 0; |
|
| 3958 | - else |
|
| 3959 | - unset($addGroups[$group_id]); |
|
| 4126 | + if ($old_profile['id_group'] == $group_id) { |
|
| 4127 | + $newPrimary = 0; |
|
| 4128 | + } else { |
|
| 4129 | + unset($addGroups[$group_id]); |
|
| 4130 | + } |
|
| 3960 | 4131 | } |
| 3961 | 4132 | // ... if not, must be joining. |
| 3962 | 4133 | else |
@@ -3964,36 +4135,42 @@ discard block |
||
| 3964 | 4135 | // Can we change the primary, and do we want to? |
| 3965 | 4136 | if ($canChangePrimary) |
| 3966 | 4137 | { |
| 3967 | - if ($old_profile['id_group'] != 0) |
|
| 3968 | - $addGroups[$old_profile['id_group']] = -1; |
|
| 4138 | + if ($old_profile['id_group'] != 0) { |
|
| 4139 | + $addGroups[$old_profile['id_group']] = -1; |
|
| 4140 | + } |
|
| 3969 | 4141 | $newPrimary = $group_id; |
| 3970 | 4142 | } |
| 3971 | 4143 | // Otherwise it's an additional group... |
| 3972 | - else |
|
| 3973 | - $addGroups[$group_id] = -1; |
|
| 4144 | + else { |
|
| 4145 | + $addGroups[$group_id] = -1; |
|
| 4146 | + } |
|
| 3974 | 4147 | } |
| 3975 | 4148 | } |
| 3976 | 4149 | // Finally, we must be setting the primary. |
| 3977 | 4150 | elseif ($canChangePrimary) |
| 3978 | 4151 | { |
| 3979 | - if ($old_profile['id_group'] != 0) |
|
| 3980 | - $addGroups[$old_profile['id_group']] = -1; |
|
| 3981 | - if (isset($addGroups[$group_id])) |
|
| 3982 | - unset($addGroups[$group_id]); |
|
| 4152 | + if ($old_profile['id_group'] != 0) { |
|
| 4153 | + $addGroups[$old_profile['id_group']] = -1; |
|
| 4154 | + } |
|
| 4155 | + if (isset($addGroups[$group_id])) { |
|
| 4156 | + unset($addGroups[$group_id]); |
|
| 4157 | + } |
|
| 3983 | 4158 | $newPrimary = $group_id; |
| 3984 | 4159 | } |
| 3985 | 4160 | |
| 3986 | 4161 | // Finally, we can make the changes! |
| 3987 | - foreach ($addGroups as $id => $dummy) |
|
| 3988 | - if (empty($id)) |
|
| 4162 | + foreach ($addGroups as $id => $dummy) { |
|
| 4163 | + if (empty($id)) |
|
| 3989 | 4164 | unset($addGroups[$id]); |
| 4165 | + } |
|
| 3990 | 4166 | $addGroups = implode(',', array_flip($addGroups)); |
| 3991 | 4167 | |
| 3992 | 4168 | // Ensure that we don't cache permissions if the group is changing. |
| 3993 | - if ($context['user']['is_owner']) |
|
| 3994 | - $_SESSION['mc']['time'] = 0; |
|
| 3995 | - else |
|
| 3996 | - updateSettings(array('settings_updated' => time())); |
|
| 4169 | + if ($context['user']['is_owner']) { |
|
| 4170 | + $_SESSION['mc']['time'] = 0; |
|
| 4171 | + } else { |
|
| 4172 | + updateSettings(array('settings_updated' => time())); |
|
| 4173 | + } |
|
| 3997 | 4174 | |
| 3998 | 4175 | updateMemberData($memID, array('id_group' => $newPrimary, 'additional_groups' => $addGroups)); |
| 3999 | 4176 | |
@@ -4016,8 +4193,9 @@ discard block |
||
| 4016 | 4193 | if (empty($user_settings['tfa_secret']) && $context['user']['is_owner']) |
| 4017 | 4194 | { |
| 4018 | 4195 | // Check to ensure we're forcing SSL for authentication |
| 4019 | - if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) |
|
| 4020 | - fatal_lang_error('login_ssl_required'); |
|
| 4196 | + if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) { |
|
| 4197 | + fatal_lang_error('login_ssl_required'); |
|
| 4198 | + } |
|
| 4021 | 4199 | |
| 4022 | 4200 | // In some cases (forced 2FA or backup code) they would be forced to be redirected here, |
| 4023 | 4201 | // we do not want too much AJAX to confuse them. |
@@ -4054,8 +4232,7 @@ discard block |
||
| 4054 | 4232 | $context['sub_template'] = 'tfasetup_backup'; |
| 4055 | 4233 | |
| 4056 | 4234 | return; |
| 4057 | - } |
|
| 4058 | - else |
|
| 4235 | + } else |
|
| 4059 | 4236 | { |
| 4060 | 4237 | $context['tfa_secret'] = $_SESSION['tfa_secret']; |
| 4061 | 4238 | $context['tfa_error'] = !$valid_code; |
@@ -4063,8 +4240,7 @@ discard block |
||
| 4063 | 4240 | $context['tfa_pass_value'] = $_POST['passwd']; |
| 4064 | 4241 | $context['tfa_value'] = $_POST['tfa_code']; |
| 4065 | 4242 | } |
| 4066 | - } |
|
| 4067 | - else |
|
| 4243 | + } else |
|
| 4068 | 4244 | { |
| 4069 | 4245 | $totp = new \TOTP\Auth(); |
| 4070 | 4246 | $secret = $totp->generateCode(); |
@@ -4074,17 +4250,16 @@ discard block |
||
| 4074 | 4250 | } |
| 4075 | 4251 | |
| 4076 | 4252 | $context['tfa_qr_url'] = $totp->getQrCodeUrl($context['forum_name'] . ':' . $user_info['name'], $context['tfa_secret']); |
| 4077 | - } |
|
| 4078 | - elseif (isset($_REQUEST['disable'])) |
|
| 4253 | + } elseif (isset($_REQUEST['disable'])) |
|
| 4079 | 4254 | { |
| 4080 | 4255 | updateMemberData($memID, array( |
| 4081 | 4256 | 'tfa_secret' => '', |
| 4082 | 4257 | 'tfa_backup' => '', |
| 4083 | 4258 | )); |
| 4084 | 4259 | redirectexit('action=profile;area=account;u=' . $memID); |
| 4260 | + } else { |
|
| 4261 | + redirectexit('action=profile;area=account;u=' . $memID); |
|
| 4262 | + } |
|
| 4085 | 4263 | } |
| 4086 | - else |
|
| 4087 | - redirectexit('action=profile;area=account;u=' . $memID); |
|
| 4088 | -} |
|
| 4089 | 4264 | |
| 4090 | 4265 | ?> |
| 4091 | 4266 | \ No newline at end of file |