@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 4 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * 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,24 +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 | - |
|
| 195 | - else |
|
| 196 | + if ($parameter1 === true) { |
|
| 197 | + updateSettings(array('totalTopics' => true), true); |
|
| 198 | + } else |
|
| 196 | 199 | { |
| 197 | 200 | // Get the number of topics - a SUM is better for InnoDB tables. |
| 198 | 201 | // We also ignore the recycle bin here because there will probably be a bunch of one-post topics there. |
@@ -213,8 +216,9 @@ discard block |
||
| 213 | 216 | |
| 214 | 217 | case 'postgroups': |
| 215 | 218 | // Parameter two is the updated columns: we should check to see if we base groups off any of these. |
| 216 | - if ($parameter2 !== null && !in_array('posts', $parameter2)) |
|
| 217 | - return; |
|
| 219 | + if ($parameter2 !== null && !in_array('posts', $parameter2)) { |
|
| 220 | + return; |
|
| 221 | + } |
|
| 218 | 222 | |
| 219 | 223 | $postgroups = cache_get_data('updateStats:postgroups', 360); |
| 220 | 224 | if ($postgroups == null || $parameter1 == null) |
@@ -229,8 +233,9 @@ discard block |
||
| 229 | 233 | ) |
| 230 | 234 | ); |
| 231 | 235 | $postgroups = array(); |
| 232 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 233 | - $postgroups[$row['id_group']] = $row['min_posts']; |
|
| 236 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 237 | + $postgroups[$row['id_group']] = $row['min_posts']; |
|
| 238 | + } |
|
| 234 | 239 | |
| 235 | 240 | $smcFunc['db_free_result']($request); |
| 236 | 241 | |
@@ -241,8 +246,9 @@ discard block |
||
| 241 | 246 | } |
| 242 | 247 | |
| 243 | 248 | // Oh great, they've screwed their post groups. |
| 244 | - if (empty($postgroups)) |
|
| 245 | - return; |
|
| 249 | + if (empty($postgroups)) { |
|
| 250 | + return; |
|
| 251 | + } |
|
| 246 | 252 | |
| 247 | 253 | // Set all membergroups from most posts to least posts. |
| 248 | 254 | $conditions = ''; |
@@ -301,12 +307,9 @@ discard block |
||
| 301 | 307 | { |
| 302 | 308 | $condition = 'id_member IN ({array_int:members})'; |
| 303 | 309 | $parameters['members'] = $members; |
| 304 | - } |
|
| 305 | - |
|
| 306 | - elseif ($members === null) |
|
| 307 | - $condition = '1=1'; |
|
| 308 | - |
|
| 309 | - else |
|
| 310 | + } elseif ($members === null) { |
|
| 311 | + $condition = '1=1'; |
|
| 312 | + } else |
|
| 310 | 313 | { |
| 311 | 314 | $condition = 'id_member = {int:member}'; |
| 312 | 315 | $parameters['member'] = $members; |
@@ -346,9 +349,9 @@ discard block |
||
| 346 | 349 | if (count($vars_to_integrate) != 0) |
| 347 | 350 | { |
| 348 | 351 | // Fetch a list of member_names if necessary |
| 349 | - if ((!is_array($members) && $members === $user_info['id']) || (is_array($members) && count($members) == 1 && in_array($user_info['id'], $members))) |
|
| 350 | - $member_names = array($user_info['username']); |
|
| 351 | - else |
|
| 352 | + if ((!is_array($members) && $members === $user_info['id']) || (is_array($members) && count($members) == 1 && in_array($user_info['id'], $members))) { |
|
| 353 | + $member_names = array($user_info['username']); |
|
| 354 | + } else |
|
| 352 | 355 | { |
| 353 | 356 | $member_names = array(); |
| 354 | 357 | $request = $smcFunc['db_query']('', ' |
@@ -357,14 +360,16 @@ discard block |
||
| 357 | 360 | WHERE ' . $condition, |
| 358 | 361 | $parameters |
| 359 | 362 | ); |
| 360 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 361 | - $member_names[] = $row['member_name']; |
|
| 363 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 364 | + $member_names[] = $row['member_name']; |
|
| 365 | + } |
|
| 362 | 366 | $smcFunc['db_free_result']($request); |
| 363 | 367 | } |
| 364 | 368 | |
| 365 | - if (!empty($member_names)) |
|
| 366 | - foreach ($vars_to_integrate as $var) |
|
| 369 | + if (!empty($member_names)) { |
|
| 370 | + foreach ($vars_to_integrate as $var) |
|
| 367 | 371 | call_integration_hook('integrate_change_member_data', array($member_names, $var, &$data[$var], &$knownInts, &$knownFloats)); |
| 372 | + } |
|
| 368 | 373 | } |
| 369 | 374 | } |
| 370 | 375 | |
@@ -372,16 +377,17 @@ discard block |
||
| 372 | 377 | foreach ($data as $var => $val) |
| 373 | 378 | { |
| 374 | 379 | $type = 'string'; |
| 375 | - if (in_array($var, $knownInts)) |
|
| 376 | - $type = 'int'; |
|
| 377 | - elseif (in_array($var, $knownFloats)) |
|
| 378 | - $type = 'float'; |
|
| 379 | - elseif ($var == 'birthdate') |
|
| 380 | - $type = 'date'; |
|
| 381 | - elseif ($var == 'member_ip') |
|
| 382 | - $type = 'inet'; |
|
| 383 | - elseif ($var == 'member_ip2') |
|
| 384 | - $type = 'inet'; |
|
| 380 | + if (in_array($var, $knownInts)) { |
|
| 381 | + $type = 'int'; |
|
| 382 | + } elseif (in_array($var, $knownFloats)) { |
|
| 383 | + $type = 'float'; |
|
| 384 | + } elseif ($var == 'birthdate') { |
|
| 385 | + $type = 'date'; |
|
| 386 | + } elseif ($var == 'member_ip') { |
|
| 387 | + $type = 'inet'; |
|
| 388 | + } elseif ($var == 'member_ip2') { |
|
| 389 | + $type = 'inet'; |
|
| 390 | + } |
|
| 385 | 391 | |
| 386 | 392 | // Doing an increment? |
| 387 | 393 | if ($var == 'alerts' && ($val === '+' || $val === '-')) |
@@ -390,18 +396,17 @@ discard block |
||
| 390 | 396 | if (is_array($members)) |
| 391 | 397 | { |
| 392 | 398 | $val = 'CASE '; |
| 393 | - foreach ($members as $k => $v) |
|
| 394 | - $val .= 'WHEN id_member = ' . $v . ' THEN '. count(fetch_alerts($v, false, 0, array(), false)) . ' '; |
|
| 399 | + foreach ($members as $k => $v) { |
|
| 400 | + $val .= 'WHEN id_member = ' . $v . ' THEN '. count(fetch_alerts($v, false, 0, array(), false)) . ' '; |
|
| 401 | + } |
|
| 395 | 402 | $val = $val . ' END'; |
| 396 | 403 | $type = 'raw'; |
| 397 | - } |
|
| 398 | - else |
|
| 404 | + } else |
|
| 399 | 405 | { |
| 400 | 406 | $blub = fetch_alerts($members, false, 0, array(), false); |
| 401 | 407 | $val = count($blub); |
| 402 | 408 | } |
| 403 | - } |
|
| 404 | - else if ($type == 'int' && ($val === '+' || $val === '-')) |
|
| 409 | + } else if ($type == 'int' && ($val === '+' || $val === '-')) |
|
| 405 | 410 | { |
| 406 | 411 | $val = $var . ' ' . $val . ' 1'; |
| 407 | 412 | $type = 'raw'; |
@@ -412,8 +417,9 @@ discard block |
||
| 412 | 417 | { |
| 413 | 418 | if (preg_match('~^' . $var . ' (\+ |- |\+ -)([\d]+)~', $val, $match)) |
| 414 | 419 | { |
| 415 | - if ($match[1] != '+ ') |
|
| 416 | - $val = 'CASE WHEN ' . $var . ' <= ' . abs($match[2]) . ' THEN 0 ELSE ' . $val . ' END'; |
|
| 420 | + if ($match[1] != '+ ') { |
|
| 421 | + $val = 'CASE WHEN ' . $var . ' <= ' . abs($match[2]) . ' THEN 0 ELSE ' . $val . ' END'; |
|
| 422 | + } |
|
| 417 | 423 | $type = 'raw'; |
| 418 | 424 | } |
| 419 | 425 | } |
@@ -434,8 +440,9 @@ discard block |
||
| 434 | 440 | // Clear any caching? |
| 435 | 441 | if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2 && !empty($members)) |
| 436 | 442 | { |
| 437 | - if (!is_array($members)) |
|
| 438 | - $members = array($members); |
|
| 443 | + if (!is_array($members)) { |
|
| 444 | + $members = array($members); |
|
| 445 | + } |
|
| 439 | 446 | |
| 440 | 447 | foreach ($members as $member) |
| 441 | 448 | { |
@@ -468,29 +475,32 @@ discard block |
||
| 468 | 475 | { |
| 469 | 476 | global $modSettings, $smcFunc; |
| 470 | 477 | |
| 471 | - if (empty($changeArray) || !is_array($changeArray)) |
|
| 472 | - return; |
|
| 478 | + if (empty($changeArray) || !is_array($changeArray)) { |
|
| 479 | + return; |
|
| 480 | + } |
|
| 473 | 481 | |
| 474 | 482 | $toRemove = array(); |
| 475 | 483 | |
| 476 | 484 | // Go check if there is any setting to be removed. |
| 477 | - foreach ($changeArray as $k => $v) |
|
| 478 | - if ($v === null) |
|
| 485 | + foreach ($changeArray as $k => $v) { |
|
| 486 | + if ($v === null) |
|
| 479 | 487 | { |
| 480 | 488 | // Found some, remove them from the original array and add them to ours. |
| 481 | 489 | unset($changeArray[$k]); |
| 490 | + } |
|
| 482 | 491 | $toRemove[] = $k; |
| 483 | 492 | } |
| 484 | 493 | |
| 485 | 494 | // Proceed with the deletion. |
| 486 | - if (!empty($toRemove)) |
|
| 487 | - $smcFunc['db_query']('', ' |
|
| 495 | + if (!empty($toRemove)) { |
|
| 496 | + $smcFunc['db_query']('', ' |
|
| 488 | 497 | DELETE FROM {db_prefix}settings |
| 489 | 498 | WHERE variable IN ({array_string:remove})', |
| 490 | 499 | array( |
| 491 | 500 | 'remove' => $toRemove, |
| 492 | 501 | ) |
| 493 | 502 | ); |
| 503 | + } |
|
| 494 | 504 | |
| 495 | 505 | // In some cases, this may be better and faster, but for large sets we don't want so many UPDATEs. |
| 496 | 506 | if ($update) |
@@ -519,19 +529,22 @@ discard block |
||
| 519 | 529 | foreach ($changeArray as $variable => $value) |
| 520 | 530 | { |
| 521 | 531 | // Don't bother if it's already like that ;). |
| 522 | - if (isset($modSettings[$variable]) && $modSettings[$variable] == $value) |
|
| 523 | - continue; |
|
| 532 | + if (isset($modSettings[$variable]) && $modSettings[$variable] == $value) { |
|
| 533 | + continue; |
|
| 534 | + } |
|
| 524 | 535 | // If the variable isn't set, but would only be set to nothing'ness, then don't bother setting it. |
| 525 | - elseif (!isset($modSettings[$variable]) && empty($value)) |
|
| 526 | - continue; |
|
| 536 | + elseif (!isset($modSettings[$variable]) && empty($value)) { |
|
| 537 | + continue; |
|
| 538 | + } |
|
| 527 | 539 | |
| 528 | 540 | $replaceArray[] = array($variable, $value); |
| 529 | 541 | |
| 530 | 542 | $modSettings[$variable] = $value; |
| 531 | 543 | } |
| 532 | 544 | |
| 533 | - if (empty($replaceArray)) |
|
| 534 | - return; |
|
| 545 | + if (empty($replaceArray)) { |
|
| 546 | + return; |
|
| 547 | + } |
|
| 535 | 548 | |
| 536 | 549 | $smcFunc['db_insert']('replace', |
| 537 | 550 | '{db_prefix}settings', |
@@ -577,14 +590,17 @@ discard block |
||
| 577 | 590 | $start_invalid = $start < 0; |
| 578 | 591 | |
| 579 | 592 | // Make sure $start is a proper variable - not less than 0. |
| 580 | - if ($start_invalid) |
|
| 581 | - $start = 0; |
|
| 593 | + if ($start_invalid) { |
|
| 594 | + $start = 0; |
|
| 595 | + } |
|
| 582 | 596 | // Not greater than the upper bound. |
| 583 | - elseif ($start >= $max_value) |
|
| 584 | - $start = max(0, (int) $max_value - (((int) $max_value % (int) $num_per_page) == 0 ? $num_per_page : ((int) $max_value % (int) $num_per_page))); |
|
| 597 | + elseif ($start >= $max_value) { |
|
| 598 | + $start = max(0, (int) $max_value - (((int) $max_value % (int) $num_per_page) == 0 ? $num_per_page : ((int) $max_value % (int) $num_per_page))); |
|
| 599 | + } |
|
| 585 | 600 | // And it has to be a multiple of $num_per_page! |
| 586 | - else |
|
| 587 | - $start = max(0, (int) $start - ((int) $start % (int) $num_per_page)); |
|
| 601 | + else { |
|
| 602 | + $start = max(0, (int) $start - ((int) $start % (int) $num_per_page)); |
|
| 603 | + } |
|
| 588 | 604 | |
| 589 | 605 | $context['current_page'] = $start / $num_per_page; |
| 590 | 606 | |
@@ -614,77 +630,87 @@ discard block |
||
| 614 | 630 | |
| 615 | 631 | // Show all the pages. |
| 616 | 632 | $display_page = 1; |
| 617 | - for ($counter = 0; $counter < $max_value; $counter += $num_per_page) |
|
| 618 | - $pageindex .= $start == $counter && !$start_invalid ? sprintf($settings['page_index']['current_page'], $display_page++) : sprintf($base_link, $counter, $display_page++); |
|
| 633 | + for ($counter = 0; $counter < $max_value; $counter += $num_per_page) { |
|
| 634 | + $pageindex .= $start == $counter && !$start_invalid ? sprintf($settings['page_index']['current_page'], $display_page++) : sprintf($base_link, $counter, $display_page++); |
|
| 635 | + } |
|
| 619 | 636 | |
| 620 | 637 | // Show the right arrow. |
| 621 | 638 | $display_page = ($start + $num_per_page) > $max_value ? $max_value : ($start + $num_per_page); |
| 622 | - if ($start != $counter - $max_value && !$start_invalid) |
|
| 623 | - $pageindex .= $display_page > $counter - $num_per_page ? ' ' : sprintf($base_link, $display_page, $settings['page_index']['next_page']); |
|
| 624 | - } |
|
| 625 | - else |
|
| 639 | + if ($start != $counter - $max_value && !$start_invalid) { |
|
| 640 | + $pageindex .= $display_page > $counter - $num_per_page ? ' ' : sprintf($base_link, $display_page, $settings['page_index']['next_page']); |
|
| 641 | + } |
|
| 642 | + } else |
|
| 626 | 643 | { |
| 627 | 644 | // If they didn't enter an odd value, pretend they did. |
| 628 | 645 | $PageContiguous = (int) ($modSettings['compactTopicPagesContiguous'] - ($modSettings['compactTopicPagesContiguous'] % 2)) / 2; |
| 629 | 646 | |
| 630 | 647 | // Show the "prev page" link. (>prev page< 1 ... 6 7 [8] 9 10 ... 15 next page) |
| 631 | - if (!empty($start) && $show_prevnext) |
|
| 632 | - $pageindex .= sprintf($base_link, $start - $num_per_page, $settings['page_index']['previous_page']); |
|
| 633 | - else |
|
| 634 | - $pageindex .= ''; |
|
| 648 | + if (!empty($start) && $show_prevnext) { |
|
| 649 | + $pageindex .= sprintf($base_link, $start - $num_per_page, $settings['page_index']['previous_page']); |
|
| 650 | + } else { |
|
| 651 | + $pageindex .= ''; |
|
| 652 | + } |
|
| 635 | 653 | |
| 636 | 654 | // Show the first page. (prev page >1< ... 6 7 [8] 9 10 ... 15) |
| 637 | - if ($start > $num_per_page * $PageContiguous) |
|
| 638 | - $pageindex .= sprintf($base_link, 0, '1'); |
|
| 655 | + if ($start > $num_per_page * $PageContiguous) { |
|
| 656 | + $pageindex .= sprintf($base_link, 0, '1'); |
|
| 657 | + } |
|
| 639 | 658 | |
| 640 | 659 | // Show the ... after the first page. (prev page 1 >...< 6 7 [8] 9 10 ... 15 next page) |
| 641 | - if ($start > $num_per_page * ($PageContiguous + 1)) |
|
| 642 | - $pageindex .= strtr($settings['page_index']['expand_pages'], array( |
|
| 660 | + if ($start > $num_per_page * ($PageContiguous + 1)) { |
|
| 661 | + $pageindex .= strtr($settings['page_index']['expand_pages'], array( |
|
| 643 | 662 | '{LINK}' => JavaScriptEscape($smcFunc['htmlspecialchars']($base_link)), |
| 644 | 663 | '{FIRST_PAGE}' => $num_per_page, |
| 645 | 664 | '{LAST_PAGE}' => $start - $num_per_page * $PageContiguous, |
| 646 | 665 | '{PER_PAGE}' => $num_per_page, |
| 647 | 666 | )); |
| 667 | + } |
|
| 648 | 668 | |
| 649 | 669 | // Show the pages before the current one. (prev page 1 ... >6 7< [8] 9 10 ... 15 next page) |
| 650 | - for ($nCont = $PageContiguous; $nCont >= 1; $nCont--) |
|
| 651 | - if ($start >= $num_per_page * $nCont) |
|
| 670 | + for ($nCont = $PageContiguous; $nCont >= 1; $nCont--) { |
|
| 671 | + if ($start >= $num_per_page * $nCont) |
|
| 652 | 672 | { |
| 653 | 673 | $tmpStart = $start - $num_per_page * $nCont; |
| 674 | + } |
|
| 654 | 675 | $pageindex .= sprintf($base_link, $tmpStart, $tmpStart / $num_per_page + 1); |
| 655 | 676 | } |
| 656 | 677 | |
| 657 | 678 | // Show the current page. (prev page 1 ... 6 7 >[8]< 9 10 ... 15 next page) |
| 658 | - if (!$start_invalid) |
|
| 659 | - $pageindex .= sprintf($settings['page_index']['current_page'], $start / $num_per_page + 1); |
|
| 660 | - else |
|
| 661 | - $pageindex .= sprintf($base_link, $start, $start / $num_per_page + 1); |
|
| 679 | + if (!$start_invalid) { |
|
| 680 | + $pageindex .= sprintf($settings['page_index']['current_page'], $start / $num_per_page + 1); |
|
| 681 | + } else { |
|
| 682 | + $pageindex .= sprintf($base_link, $start, $start / $num_per_page + 1); |
|
| 683 | + } |
|
| 662 | 684 | |
| 663 | 685 | // Show the pages after the current one... (prev page 1 ... 6 7 [8] >9 10< ... 15 next page) |
| 664 | 686 | $tmpMaxPages = (int) (($max_value - 1) / $num_per_page) * $num_per_page; |
| 665 | - for ($nCont = 1; $nCont <= $PageContiguous; $nCont++) |
|
| 666 | - if ($start + $num_per_page * $nCont <= $tmpMaxPages) |
|
| 687 | + for ($nCont = 1; $nCont <= $PageContiguous; $nCont++) { |
|
| 688 | + if ($start + $num_per_page * $nCont <= $tmpMaxPages) |
|
| 667 | 689 | { |
| 668 | 690 | $tmpStart = $start + $num_per_page * $nCont; |
| 691 | + } |
|
| 669 | 692 | $pageindex .= sprintf($base_link, $tmpStart, $tmpStart / $num_per_page + 1); |
| 670 | 693 | } |
| 671 | 694 | |
| 672 | 695 | // Show the '...' part near the end. (prev page 1 ... 6 7 [8] 9 10 >...< 15 next page) |
| 673 | - if ($start + $num_per_page * ($PageContiguous + 1) < $tmpMaxPages) |
|
| 674 | - $pageindex .= strtr($settings['page_index']['expand_pages'], array( |
|
| 696 | + if ($start + $num_per_page * ($PageContiguous + 1) < $tmpMaxPages) { |
|
| 697 | + $pageindex .= strtr($settings['page_index']['expand_pages'], array( |
|
| 675 | 698 | '{LINK}' => JavaScriptEscape($smcFunc['htmlspecialchars']($base_link)), |
| 676 | 699 | '{FIRST_PAGE}' => $start + $num_per_page * ($PageContiguous + 1), |
| 677 | 700 | '{LAST_PAGE}' => $tmpMaxPages, |
| 678 | 701 | '{PER_PAGE}' => $num_per_page, |
| 679 | 702 | )); |
| 703 | + } |
|
| 680 | 704 | |
| 681 | 705 | // Show the last number in the list. (prev page 1 ... 6 7 [8] 9 10 ... >15< next page) |
| 682 | - if ($start + $num_per_page * $PageContiguous < $tmpMaxPages) |
|
| 683 | - $pageindex .= sprintf($base_link, $tmpMaxPages, $tmpMaxPages / $num_per_page + 1); |
|
| 706 | + if ($start + $num_per_page * $PageContiguous < $tmpMaxPages) { |
|
| 707 | + $pageindex .= sprintf($base_link, $tmpMaxPages, $tmpMaxPages / $num_per_page + 1); |
|
| 708 | + } |
|
| 684 | 709 | |
| 685 | 710 | // Show the "next page" link. (prev page 1 ... 6 7 [8] 9 10 ... 15 >next page<) |
| 686 | - if ($start != $tmpMaxPages && $show_prevnext) |
|
| 687 | - $pageindex .= sprintf($base_link, $start + $num_per_page, $settings['page_index']['next_page']); |
|
| 711 | + if ($start != $tmpMaxPages && $show_prevnext) { |
|
| 712 | + $pageindex .= sprintf($base_link, $start + $num_per_page, $settings['page_index']['next_page']); |
|
| 713 | + } |
|
| 688 | 714 | } |
| 689 | 715 | $pageindex .= $settings['page_index']['extra_after']; |
| 690 | 716 | |
@@ -710,8 +736,9 @@ discard block |
||
| 710 | 736 | if ($decimal_separator === null) |
| 711 | 737 | { |
| 712 | 738 | // Not set for whatever reason? |
| 713 | - if (empty($txt['number_format']) || preg_match('~^1([^\d]*)?234([^\d]*)(0*?)$~', $txt['number_format'], $matches) != 1) |
|
| 714 | - return $number; |
|
| 739 | + if (empty($txt['number_format']) || preg_match('~^1([^\d]*)?234([^\d]*)(0*?)$~', $txt['number_format'], $matches) != 1) { |
|
| 740 | + return $number; |
|
| 741 | + } |
|
| 715 | 742 | |
| 716 | 743 | // Cache these each load... |
| 717 | 744 | $thousands_separator = $matches[1]; |
@@ -752,17 +779,20 @@ discard block |
||
| 752 | 779 | $user_info['time_format'] = !empty($user_info['time_format']) ? $user_info['time_format'] : (!empty($modSettings['time_format']) ? $modSettings['time_format'] : '%F %H:%M'); |
| 753 | 780 | |
| 754 | 781 | // Offset the time. |
| 755 | - if (!$offset_type) |
|
| 756 | - $time = $log_time + ($user_info['time_offset'] + $modSettings['time_offset']) * 3600; |
|
| 782 | + if (!$offset_type) { |
|
| 783 | + $time = $log_time + ($user_info['time_offset'] + $modSettings['time_offset']) * 3600; |
|
| 784 | + } |
|
| 757 | 785 | // Just the forum offset? |
| 758 | - elseif ($offset_type == 'forum') |
|
| 759 | - $time = $log_time + $modSettings['time_offset'] * 3600; |
|
| 760 | - else |
|
| 761 | - $time = $log_time; |
|
| 786 | + elseif ($offset_type == 'forum') { |
|
| 787 | + $time = $log_time + $modSettings['time_offset'] * 3600; |
|
| 788 | + } else { |
|
| 789 | + $time = $log_time; |
|
| 790 | + } |
|
| 762 | 791 | |
| 763 | 792 | // We can't have a negative date (on Windows, at least.) |
| 764 | - if ($log_time < 0) |
|
| 765 | - $log_time = 0; |
|
| 793 | + if ($log_time < 0) { |
|
| 794 | + $log_time = 0; |
|
| 795 | + } |
|
| 766 | 796 | |
| 767 | 797 | // Today and Yesterday? |
| 768 | 798 | if ($modSettings['todayMod'] >= 1 && $show_today === true) |
@@ -779,24 +809,27 @@ discard block |
||
| 779 | 809 | { |
| 780 | 810 | $h = strpos($user_info['time_format'], '%l') === false ? '%I' : '%l'; |
| 781 | 811 | $today_fmt = $h . ':%M' . $s . ' %p'; |
| 812 | + } else { |
|
| 813 | + $today_fmt = '%H:%M' . $s; |
|
| 782 | 814 | } |
| 783 | - else |
|
| 784 | - $today_fmt = '%H:%M' . $s; |
|
| 785 | 815 | |
| 786 | 816 | // Same day of the year, same year.... Today! |
| 787 | - if ($then['yday'] == $now['yday'] && $then['year'] == $now['year']) |
|
| 788 | - return $txt['today'] . timeformat($log_time, $today_fmt, $offset_type); |
|
| 817 | + if ($then['yday'] == $now['yday'] && $then['year'] == $now['year']) { |
|
| 818 | + return $txt['today'] . timeformat($log_time, $today_fmt, $offset_type); |
|
| 819 | + } |
|
| 789 | 820 | |
| 790 | 821 | // 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... |
| 791 | - 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)) |
|
| 792 | - return $txt['yesterday'] . timeformat($log_time, $today_fmt, $offset_type); |
|
| 822 | + 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)) { |
|
| 823 | + return $txt['yesterday'] . timeformat($log_time, $today_fmt, $offset_type); |
|
| 824 | + } |
|
| 793 | 825 | } |
| 794 | 826 | |
| 795 | 827 | $str = !is_bool($show_today) ? $show_today : $user_info['time_format']; |
| 796 | 828 | |
| 797 | 829 | // Use the cached formats if available |
| 798 | - if (is_null($finalizedFormats)) |
|
| 799 | - $finalizedFormats = (array) cache_get_data('timeformatstrings', 86400); |
|
| 830 | + if (is_null($finalizedFormats)) { |
|
| 831 | + $finalizedFormats = (array) cache_get_data('timeformatstrings', 86400); |
|
| 832 | + } |
|
| 800 | 833 | |
| 801 | 834 | // Make a supported version for this format if we don't already have one |
| 802 | 835 | if (empty($finalizedFormats[$str])) |
@@ -825,8 +858,9 @@ discard block |
||
| 825 | 858 | ); |
| 826 | 859 | |
| 827 | 860 | // No need to do this part again if we already did it once |
| 828 | - if (is_null($unsupportedFormats)) |
|
| 829 | - $unsupportedFormats = (array) cache_get_data('unsupportedtimeformats', 86400); |
|
| 861 | + if (is_null($unsupportedFormats)) { |
|
| 862 | + $unsupportedFormats = (array) cache_get_data('unsupportedtimeformats', 86400); |
|
| 863 | + } |
|
| 830 | 864 | if (empty($unsupportedFormats)) |
| 831 | 865 | { |
| 832 | 866 | foreach($strftimeFormatSubstitutions as $format => $substitution) |
@@ -842,20 +876,23 @@ discard block |
||
| 842 | 876 | |
| 843 | 877 | // Windows will return false for unsupported formats |
| 844 | 878 | // Other operating systems return the format string as a literal |
| 845 | - if ($value === false || $value === $format) |
|
| 846 | - $unsupportedFormats[] = $format; |
|
| 879 | + if ($value === false || $value === $format) { |
|
| 880 | + $unsupportedFormats[] = $format; |
|
| 881 | + } |
|
| 847 | 882 | } |
| 848 | 883 | cache_put_data('unsupportedtimeformats', $unsupportedFormats, 86400); |
| 849 | 884 | } |
| 850 | 885 | |
| 851 | 886 | // Windows needs extra help if $timeformat contains something completely invalid, e.g. '%Q' |
| 852 | - if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') |
|
| 853 | - $timeformat = preg_replace('~%(?!' . implode('|', array_keys($strftimeFormatSubstitutions)) . ')~', '%', $timeformat); |
|
| 887 | + if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') { |
|
| 888 | + $timeformat = preg_replace('~%(?!' . implode('|', array_keys($strftimeFormatSubstitutions)) . ')~', '%', $timeformat); |
|
| 889 | + } |
|
| 854 | 890 | |
| 855 | 891 | // Substitute unsupported formats with supported ones |
| 856 | - if (!empty($unsupportedFormats)) |
|
| 857 | - while (preg_match('~%(' . implode('|', $unsupportedFormats) . ')~', $timeformat, $matches)) |
|
| 892 | + if (!empty($unsupportedFormats)) { |
|
| 893 | + while (preg_match('~%(' . implode('|', $unsupportedFormats) . ')~', $timeformat, $matches)) |
|
| 858 | 894 | $timeformat = str_replace($matches[0], $strftimeFormatSubstitutions[$matches[1]], $timeformat); |
| 895 | + } |
|
| 859 | 896 | |
| 860 | 897 | // Remember this so we don't need to do it again |
| 861 | 898 | $finalizedFormats[$str] = $timeformat; |
@@ -864,33 +901,39 @@ discard block |
||
| 864 | 901 | |
| 865 | 902 | $str = $finalizedFormats[$str]; |
| 866 | 903 | |
| 867 | - if (!isset($locale_cache)) |
|
| 868 | - $locale_cache = setlocale(LC_TIME, $txt['lang_locale'] . !empty($modSettings['global_character_set']) ? '.' . $modSettings['global_character_set'] : ''); |
|
| 904 | + if (!isset($locale_cache)) { |
|
| 905 | + $locale_cache = setlocale(LC_TIME, $txt['lang_locale'] . !empty($modSettings['global_character_set']) ? '.' . $modSettings['global_character_set'] : ''); |
|
| 906 | + } |
|
| 869 | 907 | |
| 870 | 908 | if ($locale_cache !== false) |
| 871 | 909 | { |
| 872 | 910 | // Check if another process changed the locale |
| 873 | - if ($process_safe === true && setlocale(LC_TIME, '0') != $locale_cache) |
|
| 874 | - setlocale(LC_TIME, $txt['lang_locale'] . !empty($modSettings['global_character_set']) ? '.' . $modSettings['global_character_set'] : ''); |
|
| 911 | + if ($process_safe === true && setlocale(LC_TIME, '0') != $locale_cache) { |
|
| 912 | + setlocale(LC_TIME, $txt['lang_locale'] . !empty($modSettings['global_character_set']) ? '.' . $modSettings['global_character_set'] : ''); |
|
| 913 | + } |
|
| 875 | 914 | |
| 876 | - if (!isset($non_twelve_hour)) |
|
| 877 | - $non_twelve_hour = trim(strftime('%p')) === ''; |
|
| 878 | - if ($non_twelve_hour && strpos($str, '%p') !== false) |
|
| 879 | - $str = str_replace('%p', (strftime('%H', $time) < 12 ? $txt['time_am'] : $txt['time_pm']), $str); |
|
| 915 | + if (!isset($non_twelve_hour)) { |
|
| 916 | + $non_twelve_hour = trim(strftime('%p')) === ''; |
|
| 917 | + } |
|
| 918 | + if ($non_twelve_hour && strpos($str, '%p') !== false) { |
|
| 919 | + $str = str_replace('%p', (strftime('%H', $time) < 12 ? $txt['time_am'] : $txt['time_pm']), $str); |
|
| 920 | + } |
|
| 880 | 921 | |
| 881 | - foreach (array('%a', '%A', '%b', '%B') as $token) |
|
| 882 | - if (strpos($str, $token) !== false) |
|
| 922 | + foreach (array('%a', '%A', '%b', '%B') as $token) { |
|
| 923 | + if (strpos($str, $token) !== false) |
|
| 883 | 924 | $str = str_replace($token, strftime($token, $time), $str); |
| 884 | - } |
|
| 885 | - else |
|
| 925 | + } |
|
| 926 | + } else |
|
| 886 | 927 | { |
| 887 | 928 | // Do-it-yourself time localization. Fun. |
| 888 | - foreach (array('%a' => 'days_short', '%A' => 'days', '%b' => 'months_short', '%B' => 'months') as $token => $text_label) |
|
| 889 | - if (strpos($str, $token) !== false) |
|
| 929 | + foreach (array('%a' => 'days_short', '%A' => 'days', '%b' => 'months_short', '%B' => 'months') as $token => $text_label) { |
|
| 930 | + if (strpos($str, $token) !== false) |
|
| 890 | 931 | $str = str_replace($token, $txt[$text_label][(int) strftime($token === '%a' || $token === '%A' ? '%w' : '%m', $time)], $str); |
| 932 | + } |
|
| 891 | 933 | |
| 892 | - if (strpos($str, '%p') !== false) |
|
| 893 | - $str = str_replace('%p', (strftime('%H', $time) < 12 ? $txt['time_am'] : $txt['time_pm']), $str); |
|
| 934 | + if (strpos($str, '%p') !== false) { |
|
| 935 | + $str = str_replace('%p', (strftime('%H', $time) < 12 ? $txt['time_am'] : $txt['time_pm']), $str); |
|
| 936 | + } |
|
| 894 | 937 | } |
| 895 | 938 | |
| 896 | 939 | // Format the time and then restore any literal percent characters |
@@ -913,16 +956,19 @@ discard block |
||
| 913 | 956 | static $translation = array(); |
| 914 | 957 | |
| 915 | 958 | // Determine the character set... Default to UTF-8 |
| 916 | - if (empty($context['character_set'])) |
|
| 917 | - $charset = 'UTF-8'; |
|
| 959 | + if (empty($context['character_set'])) { |
|
| 960 | + $charset = 'UTF-8'; |
|
| 961 | + } |
|
| 918 | 962 | // Use ISO-8859-1 in place of non-supported ISO-8859 charsets... |
| 919 | - elseif (strpos($context['character_set'], 'ISO-8859-') !== false && !in_array($context['character_set'], array('ISO-8859-5', 'ISO-8859-15'))) |
|
| 920 | - $charset = 'ISO-8859-1'; |
|
| 921 | - else |
|
| 922 | - $charset = $context['character_set']; |
|
| 963 | + elseif (strpos($context['character_set'], 'ISO-8859-') !== false && !in_array($context['character_set'], array('ISO-8859-5', 'ISO-8859-15'))) { |
|
| 964 | + $charset = 'ISO-8859-1'; |
|
| 965 | + } else { |
|
| 966 | + $charset = $context['character_set']; |
|
| 967 | + } |
|
| 923 | 968 | |
| 924 | - if (empty($translation)) |
|
| 925 | - $translation = array_flip(get_html_translation_table(HTML_SPECIALCHARS, ENT_QUOTES, $charset)) + array(''' => '\'', ''' => '\'', ' ' => ' '); |
|
| 969 | + if (empty($translation)) { |
|
| 970 | + $translation = array_flip(get_html_translation_table(HTML_SPECIALCHARS, ENT_QUOTES, $charset)) + array(''' => '\'', ''' => '\'', ' ' => ' '); |
|
| 971 | + } |
|
| 926 | 972 | |
| 927 | 973 | return strtr($string, $translation); |
| 928 | 974 | } |
@@ -944,8 +990,9 @@ discard block |
||
| 944 | 990 | global $smcFunc; |
| 945 | 991 | |
| 946 | 992 | // It was already short enough! |
| 947 | - if ($smcFunc['strlen']($subject) <= $len) |
|
| 948 | - return $subject; |
|
| 993 | + if ($smcFunc['strlen']($subject) <= $len) { |
|
| 994 | + return $subject; |
|
| 995 | + } |
|
| 949 | 996 | |
| 950 | 997 | // Shorten it by the length it was too long, and strip off junk from the end. |
| 951 | 998 | return $smcFunc['substr']($subject, 0, $len) . '...'; |
@@ -964,10 +1011,11 @@ discard block |
||
| 964 | 1011 | { |
| 965 | 1012 | global $user_info, $modSettings; |
| 966 | 1013 | |
| 967 | - if ($timestamp === null) |
|
| 968 | - $timestamp = time(); |
|
| 969 | - elseif ($timestamp == 0) |
|
| 970 | - return 0; |
|
| 1014 | + if ($timestamp === null) { |
|
| 1015 | + $timestamp = time(); |
|
| 1016 | + } elseif ($timestamp == 0) { |
|
| 1017 | + return 0; |
|
| 1018 | + } |
|
| 971 | 1019 | |
| 972 | 1020 | return $timestamp + ($modSettings['time_offset'] + ($use_user_offset ? $user_info['time_offset'] : 0)) * 3600; |
| 973 | 1021 | } |
@@ -996,8 +1044,9 @@ discard block |
||
| 996 | 1044 | $array[$i] = $array[$j]; |
| 997 | 1045 | $array[$j] = $temp; |
| 998 | 1046 | |
| 999 | - for ($i = 1; $p[$i] == 0; $i++) |
|
| 1000 | - $p[$i] = 1; |
|
| 1047 | + for ($i = 1; $p[$i] == 0; $i++) { |
|
| 1048 | + $p[$i] = 1; |
|
| 1049 | + } |
|
| 1001 | 1050 | |
| 1002 | 1051 | $orders[] = $array; |
| 1003 | 1052 | } |
@@ -1029,12 +1078,14 @@ discard block |
||
| 1029 | 1078 | static $disabled; |
| 1030 | 1079 | |
| 1031 | 1080 | // Don't waste cycles |
| 1032 | - if ($message === '') |
|
| 1033 | - return ''; |
|
| 1081 | + if ($message === '') { |
|
| 1082 | + return ''; |
|
| 1083 | + } |
|
| 1034 | 1084 | |
| 1035 | 1085 | // Just in case it wasn't determined yet whether UTF-8 is enabled. |
| 1036 | - if (!isset($context['utf8'])) |
|
| 1037 | - $context['utf8'] = (empty($modSettings['global_character_set']) ? $txt['lang_character_set'] : $modSettings['global_character_set']) === 'UTF-8'; |
|
| 1086 | + if (!isset($context['utf8'])) { |
|
| 1087 | + $context['utf8'] = (empty($modSettings['global_character_set']) ? $txt['lang_character_set'] : $modSettings['global_character_set']) === 'UTF-8'; |
|
| 1088 | + } |
|
| 1038 | 1089 | |
| 1039 | 1090 | // Clean up any cut/paste issues we may have |
| 1040 | 1091 | $message = sanitizeMSCutPaste($message); |
@@ -1046,13 +1097,15 @@ discard block |
||
| 1046 | 1097 | return $message; |
| 1047 | 1098 | } |
| 1048 | 1099 | |
| 1049 | - if ($smileys !== null && ($smileys == '1' || $smileys == '0')) |
|
| 1050 | - $smileys = (bool) $smileys; |
|
| 1100 | + if ($smileys !== null && ($smileys == '1' || $smileys == '0')) { |
|
| 1101 | + $smileys = (bool) $smileys; |
|
| 1102 | + } |
|
| 1051 | 1103 | |
| 1052 | 1104 | if (empty($modSettings['enableBBC']) && $message !== false) |
| 1053 | 1105 | { |
| 1054 | - if ($smileys === true) |
|
| 1055 | - parsesmileys($message); |
|
| 1106 | + if ($smileys === true) { |
|
| 1107 | + parsesmileys($message); |
|
| 1108 | + } |
|
| 1056 | 1109 | |
| 1057 | 1110 | return $message; |
| 1058 | 1111 | } |
@@ -1065,8 +1118,9 @@ discard block |
||
| 1065 | 1118 | } |
| 1066 | 1119 | |
| 1067 | 1120 | // Ensure $modSettings['tld_regex'] contains a valid regex for the autolinker |
| 1068 | - if (!empty($modSettings['autoLinkUrls'])) |
|
| 1069 | - set_tld_regex(); |
|
| 1121 | + if (!empty($modSettings['autoLinkUrls'])) { |
|
| 1122 | + set_tld_regex(); |
|
| 1123 | + } |
|
| 1070 | 1124 | |
| 1071 | 1125 | // Allow mods access before entering the main parse_bbc loop |
| 1072 | 1126 | call_integration_hook('integrate_pre_parsebbc', array(&$message, &$smileys, &$cache_id, &$parse_tags)); |
@@ -1080,12 +1134,14 @@ discard block |
||
| 1080 | 1134 | |
| 1081 | 1135 | $temp = explode(',', strtolower($modSettings['disabledBBC'])); |
| 1082 | 1136 | |
| 1083 | - foreach ($temp as $tag) |
|
| 1084 | - $disabled[trim($tag)] = true; |
|
| 1137 | + foreach ($temp as $tag) { |
|
| 1138 | + $disabled[trim($tag)] = true; |
|
| 1139 | + } |
|
| 1085 | 1140 | } |
| 1086 | 1141 | |
| 1087 | - if (empty($modSettings['enableEmbeddedFlash'])) |
|
| 1088 | - $disabled['flash'] = true; |
|
| 1142 | + if (empty($modSettings['enableEmbeddedFlash'])) { |
|
| 1143 | + $disabled['flash'] = true; |
|
| 1144 | + } |
|
| 1089 | 1145 | |
| 1090 | 1146 | /* The following bbc are formatted as an array, with keys as follows: |
| 1091 | 1147 | |
@@ -1214,8 +1270,9 @@ discard block |
||
| 1214 | 1270 | $returnContext = ''; |
| 1215 | 1271 | |
| 1216 | 1272 | // BBC or the entire attachments feature is disabled |
| 1217 | - if (empty($modSettings['attachmentEnable']) || !empty($disabled['attach'])) |
|
| 1218 | - return $data; |
|
| 1273 | + if (empty($modSettings['attachmentEnable']) || !empty($disabled['attach'])) { |
|
| 1274 | + return $data; |
|
| 1275 | + } |
|
| 1219 | 1276 | |
| 1220 | 1277 | // Save the attach ID. |
| 1221 | 1278 | $attachID = $data; |
@@ -1226,8 +1283,9 @@ discard block |
||
| 1226 | 1283 | $currentAttachment = parseAttachBBC($attachID); |
| 1227 | 1284 | |
| 1228 | 1285 | // parseAttachBBC will return a string ($txt key) rather than dying with a fatal_error. Up to you to decide what to do. |
| 1229 | - if (is_string($currentAttachment)) |
|
| 1230 | - return $data = !empty($txt[$currentAttachment]) ? $txt[$currentAttachment] : $currentAttachment; |
|
| 1286 | + if (is_string($currentAttachment)) { |
|
| 1287 | + return $data = !empty($txt[$currentAttachment]) ? $txt[$currentAttachment] : $currentAttachment; |
|
| 1288 | + } |
|
| 1231 | 1289 | |
| 1232 | 1290 | if (!empty($currentAttachment['is_image'])) |
| 1233 | 1291 | { |
@@ -1243,15 +1301,17 @@ discard block |
||
| 1243 | 1301 | $height = ' height="' . $currentAttachment['height'] . '"'; |
| 1244 | 1302 | } |
| 1245 | 1303 | |
| 1246 | - if ($currentAttachment['thumbnail']['has_thumb'] && empty($params['{width}']) && empty($params['{height}'])) |
|
| 1247 | - $returnContext .= '<a href="'. $currentAttachment['href']. ';image" id="link_'. $currentAttachment['id']. '" onclick="'. $currentAttachment['thumbnail']['javascript']. '"><img src="'. $currentAttachment['thumbnail']['href']. '"' . $alt . $title . ' id="thumb_'. $currentAttachment['id']. '" class="atc_img"></a>'; |
|
| 1248 | - else |
|
| 1249 | - $returnContext .= '<img src="' . $currentAttachment['href'] . ';image"' . $alt . $title . $width . $height . ' class="bbc_img"/>'; |
|
| 1304 | + if ($currentAttachment['thumbnail']['has_thumb'] && empty($params['{width}']) && empty($params['{height}'])) { |
|
| 1305 | + $returnContext .= '<a href="'. $currentAttachment['href']. ';image" id="link_'. $currentAttachment['id']. '" onclick="'. $currentAttachment['thumbnail']['javascript']. '"><img src="'. $currentAttachment['thumbnail']['href']. '"' . $alt . $title . ' id="thumb_'. $currentAttachment['id']. '" class="atc_img"></a>'; |
|
| 1306 | + } else { |
|
| 1307 | + $returnContext .= '<img src="' . $currentAttachment['href'] . ';image"' . $alt . $title . $width . $height . ' class="bbc_img"/>'; |
|
| 1308 | + } |
|
| 1250 | 1309 | } |
| 1251 | 1310 | |
| 1252 | 1311 | // No image. Show a link. |
| 1253 | - else |
|
| 1254 | - $returnContext .= $currentAttachment['link']; |
|
| 1312 | + else { |
|
| 1313 | + $returnContext .= $currentAttachment['link']; |
|
| 1314 | + } |
|
| 1255 | 1315 | |
| 1256 | 1316 | // Gotta append what we just did. |
| 1257 | 1317 | $data = $returnContext; |
@@ -1305,8 +1365,9 @@ discard block |
||
| 1305 | 1365 | for ($php_i = 0, $php_n = count($php_parts); $php_i < $php_n; $php_i++) |
| 1306 | 1366 | { |
| 1307 | 1367 | // Do PHP code coloring? |
| 1308 | - if ($php_parts[$php_i] != '<?php') |
|
| 1309 | - continue; |
|
| 1368 | + if ($php_parts[$php_i] != '<?php') { |
|
| 1369 | + continue; |
|
| 1370 | + } |
|
| 1310 | 1371 | |
| 1311 | 1372 | $php_string = ''; |
| 1312 | 1373 | while ($php_i + 1 < count($php_parts) && $php_parts[$php_i] != '?>') |
@@ -1322,8 +1383,9 @@ discard block |
||
| 1322 | 1383 | $data = str_replace("\t", "<span style=\"white-space: pre;\">\t</span>", $data); |
| 1323 | 1384 | |
| 1324 | 1385 | // Recent Opera bug requiring temporary fix. &nsbp; is needed before </code> to avoid broken selection. |
| 1325 | - if ($context['browser']['is_opera']) |
|
| 1326 | - $data .= ' '; |
|
| 1386 | + if ($context['browser']['is_opera']) { |
|
| 1387 | + $data .= ' '; |
|
| 1388 | + } |
|
| 1327 | 1389 | } |
| 1328 | 1390 | }, |
| 1329 | 1391 | 'block_level' => true, |
@@ -1342,8 +1404,9 @@ discard block |
||
| 1342 | 1404 | for ($php_i = 0, $php_n = count($php_parts); $php_i < $php_n; $php_i++) |
| 1343 | 1405 | { |
| 1344 | 1406 | // Do PHP code coloring? |
| 1345 | - if ($php_parts[$php_i] != '<?php') |
|
| 1346 | - continue; |
|
| 1407 | + if ($php_parts[$php_i] != '<?php') { |
|
| 1408 | + continue; |
|
| 1409 | + } |
|
| 1347 | 1410 | |
| 1348 | 1411 | $php_string = ''; |
| 1349 | 1412 | while ($php_i + 1 < count($php_parts) && $php_parts[$php_i] != '?>') |
@@ -1359,8 +1422,9 @@ discard block |
||
| 1359 | 1422 | $data[0] = str_replace("\t", "<span style=\"white-space: pre;\">\t</span>", $data[0]); |
| 1360 | 1423 | |
| 1361 | 1424 | // Recent Opera bug requiring temporary fix. &nsbp; is needed before </code> to avoid broken selection. |
| 1362 | - if ($context['browser']['is_opera']) |
|
| 1363 | - $data[0] .= ' '; |
|
| 1425 | + if ($context['browser']['is_opera']) { |
|
| 1426 | + $data[0] .= ' '; |
|
| 1427 | + } |
|
| 1364 | 1428 | } |
| 1365 | 1429 | }, |
| 1366 | 1430 | 'block_level' => true, |
@@ -1398,11 +1462,13 @@ discard block |
||
| 1398 | 1462 | 'content' => '<embed type="application/x-shockwave-flash" src="$1" width="$2" height="$3" play="true" loop="true" quality="high" AllowScriptAccess="never">', |
| 1399 | 1463 | 'validate' => function (&$tag, &$data, $disabled) |
| 1400 | 1464 | { |
| 1401 | - if (isset($disabled['url'])) |
|
| 1402 | - $tag['content'] = '$1'; |
|
| 1465 | + if (isset($disabled['url'])) { |
|
| 1466 | + $tag['content'] = '$1'; |
|
| 1467 | + } |
|
| 1403 | 1468 | $scheme = parse_url($data[0], PHP_URL_SCHEME); |
| 1404 | - if (empty($scheme)) |
|
| 1405 | - $data[0] = '//' . ltrim($data[0], ':/'); |
|
| 1469 | + if (empty($scheme)) { |
|
| 1470 | + $data[0] = '//' . ltrim($data[0], ':/'); |
|
| 1471 | + } |
|
| 1406 | 1472 | }, |
| 1407 | 1473 | 'disabled_content' => '<a href="$1" target="_blank" rel="noopener">$1</a>', |
| 1408 | 1474 | ), |
@@ -1416,10 +1482,11 @@ discard block |
||
| 1416 | 1482 | { |
| 1417 | 1483 | $class = 'class="bbc_float float' . (strpos($data, 'left') === 0 ? 'left' : 'right') . '"'; |
| 1418 | 1484 | |
| 1419 | - if (preg_match('~\bmax=(\d+(?:%|px|em|rem|ex|pt|pc|ch|vw|vh|vmin|vmax|cm|mm|in)?)~', $data, $matches)) |
|
| 1420 | - $css = ' style="max-width:' . $matches[1] . (is_numeric($matches[1]) ? 'px' : '') . '"'; |
|
| 1421 | - else |
|
| 1422 | - $css = ''; |
|
| 1485 | + if (preg_match('~\bmax=(\d+(?:%|px|em|rem|ex|pt|pc|ch|vw|vh|vmin|vmax|cm|mm|in)?)~', $data, $matches)) { |
|
| 1486 | + $css = ' style="max-width:' . $matches[1] . (is_numeric($matches[1]) ? 'px' : '') . '"'; |
|
| 1487 | + } else { |
|
| 1488 | + $css = ''; |
|
| 1489 | + } |
|
| 1423 | 1490 | |
| 1424 | 1491 | $data = $class . $css; |
| 1425 | 1492 | }, |
@@ -1434,8 +1501,9 @@ discard block |
||
| 1434 | 1501 | { |
| 1435 | 1502 | $data = strtr($data, array('<br />' => '')); |
| 1436 | 1503 | |
| 1437 | - if (strpos($data, 'ftp://') !== 0 && strpos($data, 'ftps://') !== 0) |
|
| 1438 | - $data = 'ftp://' . $data; |
|
| 1504 | + if (strpos($data, 'ftp://') !== 0 && strpos($data, 'ftps://') !== 0) { |
|
| 1505 | + $data = 'ftp://' . $data; |
|
| 1506 | + } |
|
| 1439 | 1507 | }, |
| 1440 | 1508 | ), |
| 1441 | 1509 | array( |
@@ -1445,8 +1513,9 @@ discard block |
||
| 1445 | 1513 | 'after' => '</a>', |
| 1446 | 1514 | 'validate' => function(&$tag, &$data, $disabled) |
| 1447 | 1515 | { |
| 1448 | - if (strpos($data, 'ftp://') !== 0 && strpos($data, 'ftps://') !== 0) |
|
| 1449 | - $data = 'ftp://' . $data; |
|
| 1516 | + if (strpos($data, 'ftp://') !== 0 && strpos($data, 'ftps://') !== 0) { |
|
| 1517 | + $data = 'ftp://' . $data; |
|
| 1518 | + } |
|
| 1450 | 1519 | }, |
| 1451 | 1520 | 'disallow_children' => array('email', 'ftp', 'url', 'iurl'), |
| 1452 | 1521 | 'disabled_after' => ' ($1)', |
@@ -1506,17 +1575,20 @@ discard block |
||
| 1506 | 1575 | $scheme = parse_url($data, PHP_URL_SCHEME); |
| 1507 | 1576 | if ($image_proxy_enabled) |
| 1508 | 1577 | { |
| 1509 | - if (!empty($user_info['possibly_robot'])) |
|
| 1510 | - return; |
|
| 1578 | + if (!empty($user_info['possibly_robot'])) { |
|
| 1579 | + return; |
|
| 1580 | + } |
|
| 1511 | 1581 | |
| 1512 | - if (empty($scheme)) |
|
| 1513 | - $data = 'http://' . ltrim($data, ':/'); |
|
| 1582 | + if (empty($scheme)) { |
|
| 1583 | + $data = 'http://' . ltrim($data, ':/'); |
|
| 1584 | + } |
|
| 1514 | 1585 | |
| 1515 | - if ($scheme != 'https') |
|
| 1516 | - $data = get_proxied_url($data); |
|
| 1586 | + if ($scheme != 'https') { |
|
| 1587 | + $data = get_proxied_url($data); |
|
| 1588 | + } |
|
| 1589 | + } elseif (empty($scheme)) { |
|
| 1590 | + $data = '//' . ltrim($data, ':/'); |
|
| 1517 | 1591 | } |
| 1518 | - elseif (empty($scheme)) |
|
| 1519 | - $data = '//' . ltrim($data, ':/'); |
|
| 1520 | 1592 | }, |
| 1521 | 1593 | 'disabled_content' => '($1)', |
| 1522 | 1594 | ), |
@@ -1532,17 +1604,20 @@ discard block |
||
| 1532 | 1604 | $scheme = parse_url($data, PHP_URL_SCHEME); |
| 1533 | 1605 | if ($image_proxy_enabled) |
| 1534 | 1606 | { |
| 1535 | - if (!empty($user_info['possibly_robot'])) |
|
| 1536 | - return; |
|
| 1607 | + if (!empty($user_info['possibly_robot'])) { |
|
| 1608 | + return; |
|
| 1609 | + } |
|
| 1537 | 1610 | |
| 1538 | - if (empty($scheme)) |
|
| 1539 | - $data = 'http://' . ltrim($data, ':/'); |
|
| 1611 | + if (empty($scheme)) { |
|
| 1612 | + $data = 'http://' . ltrim($data, ':/'); |
|
| 1613 | + } |
|
| 1540 | 1614 | |
| 1541 | - if ($scheme != 'https') |
|
| 1542 | - $data = get_proxied_url($data); |
|
| 1615 | + if ($scheme != 'https') { |
|
| 1616 | + $data = get_proxied_url($data); |
|
| 1617 | + } |
|
| 1618 | + } elseif (empty($scheme)) { |
|
| 1619 | + $data = '//' . ltrim($data, ':/'); |
|
| 1543 | 1620 | } |
| 1544 | - elseif (empty($scheme)) |
|
| 1545 | - $data = '//' . ltrim($data, ':/'); |
|
| 1546 | 1621 | }, |
| 1547 | 1622 | 'disabled_content' => '($1)', |
| 1548 | 1623 | ), |
@@ -1554,8 +1629,9 @@ discard block |
||
| 1554 | 1629 | { |
| 1555 | 1630 | $data = strtr($data, array('<br>' => '')); |
| 1556 | 1631 | $scheme = parse_url($data, PHP_URL_SCHEME); |
| 1557 | - if (empty($scheme)) |
|
| 1558 | - $data = '//' . ltrim($data, ':/'); |
|
| 1632 | + if (empty($scheme)) { |
|
| 1633 | + $data = '//' . ltrim($data, ':/'); |
|
| 1634 | + } |
|
| 1559 | 1635 | }, |
| 1560 | 1636 | ), |
| 1561 | 1637 | array( |
@@ -1566,13 +1642,14 @@ discard block |
||
| 1566 | 1642 | 'after' => '</a>', |
| 1567 | 1643 | 'validate' => function (&$tag, &$data, $disabled) |
| 1568 | 1644 | { |
| 1569 | - if (substr($data, 0, 1) == '#') |
|
| 1570 | - $data = '#post_' . substr($data, 1); |
|
| 1571 | - else |
|
| 1645 | + if (substr($data, 0, 1) == '#') { |
|
| 1646 | + $data = '#post_' . substr($data, 1); |
|
| 1647 | + } else |
|
| 1572 | 1648 | { |
| 1573 | 1649 | $scheme = parse_url($data, PHP_URL_SCHEME); |
| 1574 | - if (empty($scheme)) |
|
| 1575 | - $data = '//' . ltrim($data, ':/'); |
|
| 1650 | + if (empty($scheme)) { |
|
| 1651 | + $data = '//' . ltrim($data, ':/'); |
|
| 1652 | + } |
|
| 1576 | 1653 | } |
| 1577 | 1654 | }, |
| 1578 | 1655 | 'disallow_children' => array('email', 'ftp', 'url', 'iurl'), |
@@ -1663,8 +1740,9 @@ discard block |
||
| 1663 | 1740 | { |
| 1664 | 1741 | $add_begin = substr(trim($data), 0, 5) != '<?'; |
| 1665 | 1742 | $data = highlight_php_code($add_begin ? '<?php ' . $data . '?>' : $data); |
| 1666 | - if ($add_begin) |
|
| 1667 | - $data = preg_replace(array('~^(.+?)<\?.{0,40}?php(?: |\s)~', '~\?>((?:</(font|span)>)*)$~'), '$1', $data, 2); |
|
| 1743 | + if ($add_begin) { |
|
| 1744 | + $data = preg_replace(array('~^(.+?)<\?.{0,40}?php(?: |\s)~', '~\?>((?:</(font|span)>)*)$~'), '$1', $data, 2); |
|
| 1745 | + } |
|
| 1668 | 1746 | } |
| 1669 | 1747 | }, |
| 1670 | 1748 | 'block_level' => false, |
@@ -1777,20 +1855,17 @@ discard block |
||
| 1777 | 1855 | : function(&$tag, &$data, $disabled) |
| 1778 | 1856 | { |
| 1779 | 1857 | |
| 1780 | - if ($data[1] == 'top' || (is_numeric($data[1]) && $data[1] < 50)) |
|
| 1781 | - $data[1] = '0 -2px 1px'; |
|
| 1782 | - |
|
| 1783 | - elseif ($data[1] == 'right' || (is_numeric($data[1]) && $data[1] < 100)) |
|
| 1784 | - $data[1] = '2px 0 1px'; |
|
| 1785 | - |
|
| 1786 | - elseif ($data[1] == 'bottom' || (is_numeric($data[1]) && $data[1] < 190)) |
|
| 1787 | - $data[1] = '0 2px 1px'; |
|
| 1788 | - |
|
| 1789 | - elseif ($data[1] == 'left' || (is_numeric($data[1]) && $data[1] < 280)) |
|
| 1790 | - $data[1] = '-2px 0 1px'; |
|
| 1791 | - |
|
| 1792 | - else |
|
| 1793 | - $data[1] = '1px 1px 1px'; |
|
| 1858 | + if ($data[1] == 'top' || (is_numeric($data[1]) && $data[1] < 50)) { |
|
| 1859 | + $data[1] = '0 -2px 1px'; |
|
| 1860 | + } elseif ($data[1] == 'right' || (is_numeric($data[1]) && $data[1] < 100)) { |
|
| 1861 | + $data[1] = '2px 0 1px'; |
|
| 1862 | + } elseif ($data[1] == 'bottom' || (is_numeric($data[1]) && $data[1] < 190)) { |
|
| 1863 | + $data[1] = '0 2px 1px'; |
|
| 1864 | + } elseif ($data[1] == 'left' || (is_numeric($data[1]) && $data[1] < 280)) { |
|
| 1865 | + $data[1] = '-2px 0 1px'; |
|
| 1866 | + } else { |
|
| 1867 | + $data[1] = '1px 1px 1px'; |
|
| 1868 | + } |
|
| 1794 | 1869 | }, |
| 1795 | 1870 | ), |
| 1796 | 1871 | array( |
@@ -1846,10 +1921,11 @@ discard block |
||
| 1846 | 1921 | 'content' => '$1', |
| 1847 | 1922 | 'validate' => function (&$tag, &$data, $disabled) |
| 1848 | 1923 | { |
| 1849 | - if (is_numeric($data)) |
|
| 1850 | - $data = timeformat($data); |
|
| 1851 | - else |
|
| 1852 | - $tag['content'] = '[time]$1[/time]'; |
|
| 1924 | + if (is_numeric($data)) { |
|
| 1925 | + $data = timeformat($data); |
|
| 1926 | + } else { |
|
| 1927 | + $tag['content'] = '[time]$1[/time]'; |
|
| 1928 | + } |
|
| 1853 | 1929 | }, |
| 1854 | 1930 | ), |
| 1855 | 1931 | array( |
@@ -1881,8 +1957,9 @@ discard block |
||
| 1881 | 1957 | { |
| 1882 | 1958 | $data = strtr($data, array('<br>' => '')); |
| 1883 | 1959 | $scheme = parse_url($data, PHP_URL_SCHEME); |
| 1884 | - if (empty($scheme)) |
|
| 1885 | - $data = '//' . ltrim($data, ':/'); |
|
| 1960 | + if (empty($scheme)) { |
|
| 1961 | + $data = '//' . ltrim($data, ':/'); |
|
| 1962 | + } |
|
| 1886 | 1963 | }, |
| 1887 | 1964 | ), |
| 1888 | 1965 | array( |
@@ -1894,8 +1971,9 @@ discard block |
||
| 1894 | 1971 | 'validate' => function (&$tag, &$data, $disabled) |
| 1895 | 1972 | { |
| 1896 | 1973 | $scheme = parse_url($data, PHP_URL_SCHEME); |
| 1897 | - if (empty($scheme)) |
|
| 1898 | - $data = '//' . ltrim($data, ':/'); |
|
| 1974 | + if (empty($scheme)) { |
|
| 1975 | + $data = '//' . ltrim($data, ':/'); |
|
| 1976 | + } |
|
| 1899 | 1977 | }, |
| 1900 | 1978 | 'disallow_children' => array('email', 'ftp', 'url', 'iurl'), |
| 1901 | 1979 | 'disabled_after' => ' ($1)', |
@@ -1915,12 +1993,13 @@ discard block |
||
| 1915 | 1993 | ); |
| 1916 | 1994 | |
| 1917 | 1995 | // Handle legacy bbc codes. |
| 1918 | - foreach ($context['legacy_bbc'] as $bbc) |
|
| 1919 | - $codes[] = array( |
|
| 1996 | + foreach ($context['legacy_bbc'] as $bbc) { |
|
| 1997 | + $codes[] = array( |
|
| 1920 | 1998 | 'tag' => $bbc, |
| 1921 | 1999 | 'before' => '', |
| 1922 | 2000 | 'after' => '', |
| 1923 | 2001 | ); |
| 2002 | + } |
|
| 1924 | 2003 | |
| 1925 | 2004 | // Let mods add new BBC without hassle. |
| 1926 | 2005 | call_integration_hook('integrate_bbc_codes', array(&$codes, &$no_autolink_tags)); |
@@ -1928,8 +2007,9 @@ discard block |
||
| 1928 | 2007 | // This is mainly for the bbc manager, so it's easy to add tags above. Custom BBC should be added above this line. |
| 1929 | 2008 | if ($message === false) |
| 1930 | 2009 | { |
| 1931 | - if (isset($temp_bbc)) |
|
| 1932 | - $bbc_codes = $temp_bbc; |
|
| 2010 | + if (isset($temp_bbc)) { |
|
| 2011 | + $bbc_codes = $temp_bbc; |
|
| 2012 | + } |
|
| 1933 | 2013 | usort($codes, function ($a, $b) { |
| 1934 | 2014 | return strcmp($a['tag'], $b['tag']); |
| 1935 | 2015 | }); |
@@ -1949,8 +2029,9 @@ discard block |
||
| 1949 | 2029 | ); |
| 1950 | 2030 | if (!isset($disabled['li']) && !isset($disabled['list'])) |
| 1951 | 2031 | { |
| 1952 | - foreach ($itemcodes as $c => $dummy) |
|
| 1953 | - $bbc_codes[$c] = array(); |
|
| 2032 | + foreach ($itemcodes as $c => $dummy) { |
|
| 2033 | + $bbc_codes[$c] = array(); |
|
| 2034 | + } |
|
| 1954 | 2035 | } |
| 1955 | 2036 | |
| 1956 | 2037 | // Shhhh! |
@@ -1971,12 +2052,14 @@ discard block |
||
| 1971 | 2052 | foreach ($codes as $code) |
| 1972 | 2053 | { |
| 1973 | 2054 | // Make it easier to process parameters later |
| 1974 | - if (!empty($code['parameters'])) |
|
| 1975 | - ksort($code['parameters'], SORT_STRING); |
|
| 2055 | + if (!empty($code['parameters'])) { |
|
| 2056 | + ksort($code['parameters'], SORT_STRING); |
|
| 2057 | + } |
|
| 1976 | 2058 | |
| 1977 | 2059 | // If we are not doing every tag only do ones we are interested in. |
| 1978 | - if (empty($parse_tags) || in_array($code['tag'], $parse_tags)) |
|
| 1979 | - $bbc_codes[substr($code['tag'], 0, 1)][] = $code; |
|
| 2060 | + if (empty($parse_tags) || in_array($code['tag'], $parse_tags)) { |
|
| 2061 | + $bbc_codes[substr($code['tag'], 0, 1)][] = $code; |
|
| 2062 | + } |
|
| 1980 | 2063 | } |
| 1981 | 2064 | $codes = null; |
| 1982 | 2065 | } |
@@ -1987,8 +2070,9 @@ discard block |
||
| 1987 | 2070 | // It's likely this will change if the message is modified. |
| 1988 | 2071 | $cache_key = 'parse:' . $cache_id . '-' . md5(md5($message) . '-' . $smileys . (empty($disabled) ? '' : implode(',', array_keys($disabled))) . $smcFunc['json_encode']($context['browser']) . $txt['lang_locale'] . $user_info['time_offset'] . $user_info['time_format']); |
| 1989 | 2072 | |
| 1990 | - if (($temp = cache_get_data($cache_key, 240)) != null) |
|
| 1991 | - return $temp; |
|
| 2073 | + if (($temp = cache_get_data($cache_key, 240)) != null) { |
|
| 2074 | + return $temp; |
|
| 2075 | + } |
|
| 1992 | 2076 | |
| 1993 | 2077 | $cache_t = microtime(); |
| 1994 | 2078 | } |
@@ -2020,8 +2104,9 @@ discard block |
||
| 2020 | 2104 | $disabled['flash'] = true; |
| 2021 | 2105 | |
| 2022 | 2106 | // @todo Change maybe? |
| 2023 | - if (!isset($_GET['images'])) |
|
| 2024 | - $disabled['img'] = true; |
|
| 2107 | + if (!isset($_GET['images'])) { |
|
| 2108 | + $disabled['img'] = true; |
|
| 2109 | + } |
|
| 2025 | 2110 | |
| 2026 | 2111 | // @todo Interface/setting to add more? |
| 2027 | 2112 | } |
@@ -2032,8 +2117,9 @@ discard block |
||
| 2032 | 2117 | $alltags = array(); |
| 2033 | 2118 | foreach ($bbc_codes as $section) |
| 2034 | 2119 | { |
| 2035 | - foreach ($section as $code) |
|
| 2036 | - $alltags[] = $code['tag']; |
|
| 2120 | + foreach ($section as $code) { |
|
| 2121 | + $alltags[] = $code['tag']; |
|
| 2122 | + } |
|
| 2037 | 2123 | } |
| 2038 | 2124 | $alltags_regex = '\b' . implode("\b|\b", array_unique($alltags)) . '\b'; |
| 2039 | 2125 | |
@@ -2045,8 +2131,9 @@ discard block |
||
| 2045 | 2131 | $pos = isset($matches[0][1]) ? $matches[0][1] : false; |
| 2046 | 2132 | |
| 2047 | 2133 | // Failsafe. |
| 2048 | - if ($pos === false || $last_pos > $pos) |
|
| 2049 | - $pos = strlen($message) + 1; |
|
| 2134 | + if ($pos === false || $last_pos > $pos) { |
|
| 2135 | + $pos = strlen($message) + 1; |
|
| 2136 | + } |
|
| 2050 | 2137 | |
| 2051 | 2138 | // Can't have a one letter smiley, URL, or email! (sorry.) |
| 2052 | 2139 | if ($last_pos < $pos - 1) |
@@ -2064,8 +2151,9 @@ discard block |
||
| 2064 | 2151 | |
| 2065 | 2152 | // <br> should be empty. |
| 2066 | 2153 | $empty_tags = array('br', 'hr'); |
| 2067 | - foreach ($empty_tags as $tag) |
|
| 2068 | - $data = str_replace(array('<' . $tag . '>', '<' . $tag . '/>', '<' . $tag . ' />'), '<' . $tag . '>', $data); |
|
| 2154 | + foreach ($empty_tags as $tag) { |
|
| 2155 | + $data = str_replace(array('<' . $tag . '>', '<' . $tag . '/>', '<' . $tag . ' />'), '<' . $tag . '>', $data); |
|
| 2156 | + } |
|
| 2069 | 2157 | |
| 2070 | 2158 | // b, u, i, s, pre... basic tags. |
| 2071 | 2159 | $closable_tags = array('b', 'u', 'i', 's', 'em', 'ins', 'del', 'pre', 'blockquote', 'strong'); |
@@ -2074,8 +2162,9 @@ discard block |
||
| 2074 | 2162 | $diff = substr_count($data, '<' . $tag . '>') - substr_count($data, '</' . $tag . '>'); |
| 2075 | 2163 | $data = strtr($data, array('<' . $tag . '>' => '<' . $tag . '>', '</' . $tag . '>' => '</' . $tag . '>')); |
| 2076 | 2164 | |
| 2077 | - if ($diff > 0) |
|
| 2078 | - $data = substr($data, 0, -1) . str_repeat('</' . $tag . '>', $diff) . substr($data, -1); |
|
| 2165 | + if ($diff > 0) { |
|
| 2166 | + $data = substr($data, 0, -1) . str_repeat('</' . $tag . '>', $diff) . substr($data, -1); |
|
| 2167 | + } |
|
| 2079 | 2168 | } |
| 2080 | 2169 | |
| 2081 | 2170 | // Do <img ...> - with security... action= -> action-. |
@@ -2088,8 +2177,9 @@ discard block |
||
| 2088 | 2177 | $alt = empty($matches[3][$match]) ? '' : ' alt=' . preg_replace('~^"|"$~', '', $matches[3][$match]); |
| 2089 | 2178 | |
| 2090 | 2179 | // Remove action= from the URL - no funny business, now. |
| 2091 | - if (preg_match('~action(=|%3d)(?!dlattach)~i', $imgtag) != 0) |
|
| 2092 | - $imgtag = preg_replace('~action(?:=|%3d)(?!dlattach)~i', 'action-', $imgtag); |
|
| 2180 | + if (preg_match('~action(=|%3d)(?!dlattach)~i', $imgtag) != 0) { |
|
| 2181 | + $imgtag = preg_replace('~action(?:=|%3d)(?!dlattach)~i', 'action-', $imgtag); |
|
| 2182 | + } |
|
| 2093 | 2183 | |
| 2094 | 2184 | $replaces[$matches[0][$match]] = '[img' . $alt . ']' . $imgtag . '[/img]'; |
| 2095 | 2185 | } |
@@ -2104,16 +2194,18 @@ discard block |
||
| 2104 | 2194 | $no_autolink_area = false; |
| 2105 | 2195 | if (!empty($open_tags)) |
| 2106 | 2196 | { |
| 2107 | - foreach ($open_tags as $open_tag) |
|
| 2108 | - if (in_array($open_tag['tag'], $no_autolink_tags)) |
|
| 2197 | + foreach ($open_tags as $open_tag) { |
|
| 2198 | + if (in_array($open_tag['tag'], $no_autolink_tags)) |
|
| 2109 | 2199 | $no_autolink_area = true; |
| 2200 | + } |
|
| 2110 | 2201 | } |
| 2111 | 2202 | |
| 2112 | 2203 | // Don't go backwards. |
| 2113 | 2204 | // @todo Don't think is the real solution.... |
| 2114 | 2205 | $lastAutoPos = isset($lastAutoPos) ? $lastAutoPos : 0; |
| 2115 | - if ($pos < $lastAutoPos) |
|
| 2116 | - $no_autolink_area = true; |
|
| 2206 | + if ($pos < $lastAutoPos) { |
|
| 2207 | + $no_autolink_area = true; |
|
| 2208 | + } |
|
| 2117 | 2209 | $lastAutoPos = $pos; |
| 2118 | 2210 | |
| 2119 | 2211 | if (!$no_autolink_area) |
@@ -2218,29 +2310,33 @@ discard block |
||
| 2218 | 2310 | $url = array_shift($matches); |
| 2219 | 2311 | |
| 2220 | 2312 | // If this isn't a clean URL, bail out |
| 2221 | - if ($url != sanitize_iri($url)) |
|
| 2222 | - return $url; |
|
| 2313 | + if ($url != sanitize_iri($url)) { |
|
| 2314 | + return $url; |
|
| 2315 | + } |
|
| 2223 | 2316 | |
| 2224 | 2317 | $scheme = parse_url($url, PHP_URL_SCHEME); |
| 2225 | 2318 | |
| 2226 | 2319 | if ($scheme == 'mailto') |
| 2227 | 2320 | { |
| 2228 | 2321 | $email_address = str_replace('mailto:', '', $url); |
| 2229 | - if (!isset($disabled['email']) && filter_var($email_address, FILTER_VALIDATE_EMAIL) !== false) |
|
| 2230 | - return '[email=' . $email_address . ']' . $url . '[/email]'; |
|
| 2231 | - else |
|
| 2232 | - return $url; |
|
| 2322 | + if (!isset($disabled['email']) && filter_var($email_address, FILTER_VALIDATE_EMAIL) !== false) { |
|
| 2323 | + return '[email=' . $email_address . ']' . $url . '[/email]'; |
|
| 2324 | + } else { |
|
| 2325 | + return $url; |
|
| 2326 | + } |
|
| 2233 | 2327 | } |
| 2234 | 2328 | |
| 2235 | 2329 | // Are we linking a schemeless URL or naked domain name (e.g. "example.com")? |
| 2236 | - if (empty($scheme)) |
|
| 2237 | - $fullUrl = '//' . ltrim($url, ':/'); |
|
| 2238 | - else |
|
| 2239 | - $fullUrl = $url; |
|
| 2330 | + if (empty($scheme)) { |
|
| 2331 | + $fullUrl = '//' . ltrim($url, ':/'); |
|
| 2332 | + } else { |
|
| 2333 | + $fullUrl = $url; |
|
| 2334 | + } |
|
| 2240 | 2335 | |
| 2241 | 2336 | // Make sure that $fullUrl really is valid |
| 2242 | - if (validate_iri((strpos($fullUrl, '//') === 0 ? 'http:' : '' ) . $fullUrl) === false) |
|
| 2243 | - return $url; |
|
| 2337 | + if (validate_iri((strpos($fullUrl, '//') === 0 ? 'http:' : '' ) . $fullUrl) === false) { |
|
| 2338 | + return $url; |
|
| 2339 | + } |
|
| 2244 | 2340 | |
| 2245 | 2341 | return '[url="' . str_replace(array('[', ']'), array('[', ']'), $fullUrl) . '"]' . $url . '[/url]'; |
| 2246 | 2342 | }, $data); |
@@ -2289,22 +2385,25 @@ discard block |
||
| 2289 | 2385 | } |
| 2290 | 2386 | |
| 2291 | 2387 | // Are we there yet? Are we there yet? |
| 2292 | - if ($pos >= strlen($message) - 1) |
|
| 2293 | - break; |
|
| 2388 | + if ($pos >= strlen($message) - 1) { |
|
| 2389 | + break; |
|
| 2390 | + } |
|
| 2294 | 2391 | |
| 2295 | 2392 | $tags = strtolower($message[$pos + 1]); |
| 2296 | 2393 | |
| 2297 | 2394 | if ($tags == '/' && !empty($open_tags)) |
| 2298 | 2395 | { |
| 2299 | 2396 | $pos2 = strpos($message, ']', $pos + 1); |
| 2300 | - if ($pos2 == $pos + 2) |
|
| 2301 | - continue; |
|
| 2397 | + if ($pos2 == $pos + 2) { |
|
| 2398 | + continue; |
|
| 2399 | + } |
|
| 2302 | 2400 | |
| 2303 | 2401 | $look_for = strtolower(substr($message, $pos + 2, $pos2 - $pos - 2)); |
| 2304 | 2402 | |
| 2305 | 2403 | // A closing tag that doesn't match any open tags? Skip it. |
| 2306 | - if (!in_array($look_for, array_map(function($code){return $code['tag'];}, $open_tags))) |
|
| 2307 | - continue; |
|
| 2404 | + if (!in_array($look_for, array_map(function($code){return $code['tag'];}, $open_tags))) { |
|
| 2405 | + continue; |
|
| 2406 | + } |
|
| 2308 | 2407 | |
| 2309 | 2408 | $to_close = array(); |
| 2310 | 2409 | $block_level = null; |
@@ -2312,8 +2411,9 @@ discard block |
||
| 2312 | 2411 | do |
| 2313 | 2412 | { |
| 2314 | 2413 | $tag = array_pop($open_tags); |
| 2315 | - if (!$tag) |
|
| 2316 | - break; |
|
| 2414 | + if (!$tag) { |
|
| 2415 | + break; |
|
| 2416 | + } |
|
| 2317 | 2417 | |
| 2318 | 2418 | if (!empty($tag['block_level'])) |
| 2319 | 2419 | { |
@@ -2327,10 +2427,11 @@ discard block |
||
| 2327 | 2427 | // The idea is, if we are LOOKING for a block level tag, we can close them on the way. |
| 2328 | 2428 | if (strlen($look_for) > 0 && isset($bbc_codes[$look_for[0]])) |
| 2329 | 2429 | { |
| 2330 | - foreach ($bbc_codes[$look_for[0]] as $temp) |
|
| 2331 | - if ($temp['tag'] == $look_for) |
|
| 2430 | + foreach ($bbc_codes[$look_for[0]] as $temp) { |
|
| 2431 | + if ($temp['tag'] == $look_for) |
|
| 2332 | 2432 | { |
| 2333 | 2433 | $block_level = !empty($temp['block_level']); |
| 2434 | + } |
|
| 2334 | 2435 | break; |
| 2335 | 2436 | } |
| 2336 | 2437 | } |
@@ -2352,15 +2453,15 @@ discard block |
||
| 2352 | 2453 | { |
| 2353 | 2454 | $open_tags = $to_close; |
| 2354 | 2455 | continue; |
| 2355 | - } |
|
| 2356 | - elseif (!empty($to_close) && $tag['tag'] != $look_for) |
|
| 2456 | + } elseif (!empty($to_close) && $tag['tag'] != $look_for) |
|
| 2357 | 2457 | { |
| 2358 | 2458 | if ($block_level === null && isset($look_for[0], $bbc_codes[$look_for[0]])) |
| 2359 | 2459 | { |
| 2360 | - foreach ($bbc_codes[$look_for[0]] as $temp) |
|
| 2361 | - if ($temp['tag'] == $look_for) |
|
| 2460 | + foreach ($bbc_codes[$look_for[0]] as $temp) { |
|
| 2461 | + if ($temp['tag'] == $look_for) |
|
| 2362 | 2462 | { |
| 2363 | 2463 | $block_level = !empty($temp['block_level']); |
| 2464 | + } |
|
| 2364 | 2465 | break; |
| 2365 | 2466 | } |
| 2366 | 2467 | } |
@@ -2368,8 +2469,9 @@ discard block |
||
| 2368 | 2469 | // We're not looking for a block level tag (or maybe even a tag that exists...) |
| 2369 | 2470 | if (!$block_level) |
| 2370 | 2471 | { |
| 2371 | - foreach ($to_close as $tag) |
|
| 2372 | - array_push($open_tags, $tag); |
|
| 2472 | + foreach ($to_close as $tag) { |
|
| 2473 | + array_push($open_tags, $tag); |
|
| 2474 | + } |
|
| 2373 | 2475 | continue; |
| 2374 | 2476 | } |
| 2375 | 2477 | } |
@@ -2382,14 +2484,17 @@ discard block |
||
| 2382 | 2484 | |
| 2383 | 2485 | // See the comment at the end of the big loop - just eating whitespace ;). |
| 2384 | 2486 | $whitespace_regex = ''; |
| 2385 | - if (!empty($tag['block_level'])) |
|
| 2386 | - $whitespace_regex .= '( |\s)*(<br>)?'; |
|
| 2487 | + if (!empty($tag['block_level'])) { |
|
| 2488 | + $whitespace_regex .= '( |\s)*(<br>)?'; |
|
| 2489 | + } |
|
| 2387 | 2490 | // Trim one line of whitespace after unnested tags, but all of it after nested ones |
| 2388 | - if (!empty($tag['trim']) && $tag['trim'] != 'inside') |
|
| 2389 | - $whitespace_regex .= empty($tag['require_parents']) ? '( |\s)*' : '(<br>| |\s)*'; |
|
| 2491 | + if (!empty($tag['trim']) && $tag['trim'] != 'inside') { |
|
| 2492 | + $whitespace_regex .= empty($tag['require_parents']) ? '( |\s)*' : '(<br>| |\s)*'; |
|
| 2493 | + } |
|
| 2390 | 2494 | |
| 2391 | - if (!empty($whitespace_regex) && preg_match('~' . $whitespace_regex . '~', substr($message, $pos), $matches) != 0) |
|
| 2392 | - $message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0])); |
|
| 2495 | + if (!empty($whitespace_regex) && preg_match('~' . $whitespace_regex . '~', substr($message, $pos), $matches) != 0) { |
|
| 2496 | + $message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0])); |
|
| 2497 | + } |
|
| 2393 | 2498 | } |
| 2394 | 2499 | |
| 2395 | 2500 | if (!empty($to_close)) |
@@ -2402,8 +2507,9 @@ discard block |
||
| 2402 | 2507 | } |
| 2403 | 2508 | |
| 2404 | 2509 | // No tags for this character, so just keep going (fastest possible course.) |
| 2405 | - if (!isset($bbc_codes[$tags])) |
|
| 2406 | - continue; |
|
| 2510 | + if (!isset($bbc_codes[$tags])) { |
|
| 2511 | + continue; |
|
| 2512 | + } |
|
| 2407 | 2513 | |
| 2408 | 2514 | $inside = empty($open_tags) ? null : $open_tags[count($open_tags) - 1]; |
| 2409 | 2515 | $tag = null; |
@@ -2412,48 +2518,57 @@ discard block |
||
| 2412 | 2518 | $pt_strlen = strlen($possible['tag']); |
| 2413 | 2519 | |
| 2414 | 2520 | // Not a match? |
| 2415 | - if (strtolower(substr($message, $pos + 1, $pt_strlen)) != $possible['tag']) |
|
| 2416 | - continue; |
|
| 2521 | + if (strtolower(substr($message, $pos + 1, $pt_strlen)) != $possible['tag']) { |
|
| 2522 | + continue; |
|
| 2523 | + } |
|
| 2417 | 2524 | |
| 2418 | 2525 | $next_c = isset($message[$pos + 1 + $pt_strlen]) ? $message[$pos + 1 + $pt_strlen] : ''; |
| 2419 | 2526 | |
| 2420 | 2527 | // A tag is the last char maybe |
| 2421 | - if ($next_c == '') |
|
| 2422 | - break; |
|
| 2528 | + if ($next_c == '') { |
|
| 2529 | + break; |
|
| 2530 | + } |
|
| 2423 | 2531 | |
| 2424 | 2532 | // A test validation? |
| 2425 | - if (isset($possible['test']) && preg_match('~^' . $possible['test'] . '~', substr($message, $pos + 1 + $pt_strlen + 1)) === 0) |
|
| 2426 | - continue; |
|
| 2533 | + if (isset($possible['test']) && preg_match('~^' . $possible['test'] . '~', substr($message, $pos + 1 + $pt_strlen + 1)) === 0) { |
|
| 2534 | + continue; |
|
| 2535 | + } |
|
| 2427 | 2536 | // Do we want parameters? |
| 2428 | 2537 | elseif (!empty($possible['parameters'])) |
| 2429 | 2538 | { |
| 2430 | - if ($next_c != ' ') |
|
| 2431 | - continue; |
|
| 2432 | - } |
|
| 2433 | - elseif (isset($possible['type'])) |
|
| 2539 | + if ($next_c != ' ') { |
|
| 2540 | + continue; |
|
| 2541 | + } |
|
| 2542 | + } elseif (isset($possible['type'])) |
|
| 2434 | 2543 | { |
| 2435 | 2544 | // Do we need an equal sign? |
| 2436 | - if (in_array($possible['type'], array('unparsed_equals', 'unparsed_commas', 'unparsed_commas_content', 'unparsed_equals_content', 'parsed_equals')) && $next_c != '=') |
|
| 2437 | - continue; |
|
| 2545 | + if (in_array($possible['type'], array('unparsed_equals', 'unparsed_commas', 'unparsed_commas_content', 'unparsed_equals_content', 'parsed_equals')) && $next_c != '=') { |
|
| 2546 | + continue; |
|
| 2547 | + } |
|
| 2438 | 2548 | // Maybe we just want a /... |
| 2439 | - if ($possible['type'] == 'closed' && $next_c != ']' && substr($message, $pos + 1 + $pt_strlen, 2) != '/]' && substr($message, $pos + 1 + $pt_strlen, 3) != ' /]') |
|
| 2440 | - continue; |
|
| 2549 | + if ($possible['type'] == 'closed' && $next_c != ']' && substr($message, $pos + 1 + $pt_strlen, 2) != '/]' && substr($message, $pos + 1 + $pt_strlen, 3) != ' /]') { |
|
| 2550 | + continue; |
|
| 2551 | + } |
|
| 2441 | 2552 | // An immediate ]? |
| 2442 | - if ($possible['type'] == 'unparsed_content' && $next_c != ']') |
|
| 2443 | - continue; |
|
| 2553 | + if ($possible['type'] == 'unparsed_content' && $next_c != ']') { |
|
| 2554 | + continue; |
|
| 2555 | + } |
|
| 2444 | 2556 | } |
| 2445 | 2557 | // No type means 'parsed_content', which demands an immediate ] without parameters! |
| 2446 | - elseif ($next_c != ']') |
|
| 2447 | - continue; |
|
| 2558 | + elseif ($next_c != ']') { |
|
| 2559 | + continue; |
|
| 2560 | + } |
|
| 2448 | 2561 | |
| 2449 | 2562 | // Check allowed tree? |
| 2450 | - if (isset($possible['require_parents']) && ($inside === null || !in_array($inside['tag'], $possible['require_parents']))) |
|
| 2451 | - continue; |
|
| 2452 | - elseif (isset($inside['require_children']) && !in_array($possible['tag'], $inside['require_children'])) |
|
| 2453 | - continue; |
|
| 2563 | + if (isset($possible['require_parents']) && ($inside === null || !in_array($inside['tag'], $possible['require_parents']))) { |
|
| 2564 | + continue; |
|
| 2565 | + } elseif (isset($inside['require_children']) && !in_array($possible['tag'], $inside['require_children'])) { |
|
| 2566 | + continue; |
|
| 2567 | + } |
|
| 2454 | 2568 | // If this is in the list of disallowed child tags, don't parse it. |
| 2455 | - elseif (isset($inside['disallow_children']) && in_array($possible['tag'], $inside['disallow_children'])) |
|
| 2456 | - continue; |
|
| 2569 | + elseif (isset($inside['disallow_children']) && in_array($possible['tag'], $inside['disallow_children'])) { |
|
| 2570 | + continue; |
|
| 2571 | + } |
|
| 2457 | 2572 | |
| 2458 | 2573 | $pos1 = $pos + 1 + $pt_strlen + 1; |
| 2459 | 2574 | |
@@ -2465,8 +2580,9 @@ discard block |
||
| 2465 | 2580 | foreach ($open_tags as $open_quote) |
| 2466 | 2581 | { |
| 2467 | 2582 | // Every parent quote this quote has flips the styling |
| 2468 | - if ($open_quote['tag'] == 'quote') |
|
| 2469 | - $quote_alt = !$quote_alt; |
|
| 2583 | + if ($open_quote['tag'] == 'quote') { |
|
| 2584 | + $quote_alt = !$quote_alt; |
|
| 2585 | + } |
|
| 2470 | 2586 | } |
| 2471 | 2587 | // Add a class to the quote to style alternating blockquotes |
| 2472 | 2588 | $possible['before'] = strtr($possible['before'], array('<blockquote>' => '<blockquote class="bbc_' . ($quote_alt ? 'alternate' : 'standard') . '_quote">')); |
@@ -2477,8 +2593,9 @@ discard block |
||
| 2477 | 2593 | { |
| 2478 | 2594 | // Build a regular expression for each parameter for the current tag. |
| 2479 | 2595 | $preg = array(); |
| 2480 | - foreach ($possible['parameters'] as $p => $info) |
|
| 2481 | - $preg[] = '(\s+' . $p . '=' . (empty($info['quoted']) ? '' : '"') . (isset($info['match']) ? $info['match'] : '(.+?)') . (empty($info['quoted']) ? '' : '"') . '\s*)' . (empty($info['optional']) ? '' : '?'); |
|
| 2596 | + foreach ($possible['parameters'] as $p => $info) { |
|
| 2597 | + $preg[] = '(\s+' . $p . '=' . (empty($info['quoted']) ? '' : '"') . (isset($info['match']) ? $info['match'] : '(.+?)') . (empty($info['quoted']) ? '' : '"') . '\s*)' . (empty($info['optional']) ? '' : '?'); |
|
| 2598 | + } |
|
| 2482 | 2599 | |
| 2483 | 2600 | // Extract the string that potentially holds our parameters. |
| 2484 | 2601 | $blob = preg_split('~\[/?(?:' . $alltags_regex . ')~i', substr($message, $pos)); |
@@ -2497,24 +2614,27 @@ discard block |
||
| 2497 | 2614 | |
| 2498 | 2615 | $match = preg_match('~^' . implode('', $preg) . '$~i', implode(' ', $given_params), $matches) !== 0; |
| 2499 | 2616 | |
| 2500 | - if ($match) |
|
| 2501 | - $blob_counter = count($blobs) + 1; |
|
| 2617 | + if ($match) { |
|
| 2618 | + $blob_counter = count($blobs) + 1; |
|
| 2619 | + } |
|
| 2502 | 2620 | } |
| 2503 | 2621 | |
| 2504 | 2622 | // Didn't match our parameter list, try the next possible. |
| 2505 | - if (!$match) |
|
| 2506 | - continue; |
|
| 2623 | + if (!$match) { |
|
| 2624 | + continue; |
|
| 2625 | + } |
|
| 2507 | 2626 | |
| 2508 | 2627 | $params = array(); |
| 2509 | 2628 | for ($i = 1, $n = count($matches); $i < $n; $i += 2) |
| 2510 | 2629 | { |
| 2511 | 2630 | $key = strtok(ltrim($matches[$i]), '='); |
| 2512 | - if (isset($possible['parameters'][$key]['value'])) |
|
| 2513 | - $params['{' . $key . '}'] = strtr($possible['parameters'][$key]['value'], array('$1' => $matches[$i + 1])); |
|
| 2514 | - elseif (isset($possible['parameters'][$key]['validate'])) |
|
| 2515 | - $params['{' . $key . '}'] = $possible['parameters'][$key]['validate']($matches[$i + 1]); |
|
| 2516 | - else |
|
| 2517 | - $params['{' . $key . '}'] = $matches[$i + 1]; |
|
| 2631 | + if (isset($possible['parameters'][$key]['value'])) { |
|
| 2632 | + $params['{' . $key . '}'] = strtr($possible['parameters'][$key]['value'], array('$1' => $matches[$i + 1])); |
|
| 2633 | + } elseif (isset($possible['parameters'][$key]['validate'])) { |
|
| 2634 | + $params['{' . $key . '}'] = $possible['parameters'][$key]['validate']($matches[$i + 1]); |
|
| 2635 | + } else { |
|
| 2636 | + $params['{' . $key . '}'] = $matches[$i + 1]; |
|
| 2637 | + } |
|
| 2518 | 2638 | |
| 2519 | 2639 | // Just to make sure: replace any $ or { so they can't interpolate wrongly. |
| 2520 | 2640 | $params['{' . $key . '}'] = strtr($params['{' . $key . '}'], array('$' => '$', '{' => '{')); |
@@ -2522,23 +2642,26 @@ discard block |
||
| 2522 | 2642 | |
| 2523 | 2643 | foreach ($possible['parameters'] as $p => $info) |
| 2524 | 2644 | { |
| 2525 | - if (!isset($params['{' . $p . '}'])) |
|
| 2526 | - $params['{' . $p . '}'] = ''; |
|
| 2645 | + if (!isset($params['{' . $p . '}'])) { |
|
| 2646 | + $params['{' . $p . '}'] = ''; |
|
| 2647 | + } |
|
| 2527 | 2648 | } |
| 2528 | 2649 | |
| 2529 | 2650 | $tag = $possible; |
| 2530 | 2651 | |
| 2531 | 2652 | // Put the parameters into the string. |
| 2532 | - if (isset($tag['before'])) |
|
| 2533 | - $tag['before'] = strtr($tag['before'], $params); |
|
| 2534 | - if (isset($tag['after'])) |
|
| 2535 | - $tag['after'] = strtr($tag['after'], $params); |
|
| 2536 | - if (isset($tag['content'])) |
|
| 2537 | - $tag['content'] = strtr($tag['content'], $params); |
|
| 2653 | + if (isset($tag['before'])) { |
|
| 2654 | + $tag['before'] = strtr($tag['before'], $params); |
|
| 2655 | + } |
|
| 2656 | + if (isset($tag['after'])) { |
|
| 2657 | + $tag['after'] = strtr($tag['after'], $params); |
|
| 2658 | + } |
|
| 2659 | + if (isset($tag['content'])) { |
|
| 2660 | + $tag['content'] = strtr($tag['content'], $params); |
|
| 2661 | + } |
|
| 2538 | 2662 | |
| 2539 | 2663 | $pos1 += strlen($given_param_string); |
| 2540 | - } |
|
| 2541 | - else |
|
| 2664 | + } else |
|
| 2542 | 2665 | { |
| 2543 | 2666 | $tag = $possible; |
| 2544 | 2667 | $params = array(); |
@@ -2549,8 +2672,9 @@ discard block |
||
| 2549 | 2672 | // Item codes are complicated buggers... they are implicit [li]s and can make [list]s! |
| 2550 | 2673 | if ($smileys !== false && $tag === null && isset($itemcodes[$message[$pos + 1]]) && $message[$pos + 2] == ']' && !isset($disabled['list']) && !isset($disabled['li'])) |
| 2551 | 2674 | { |
| 2552 | - if ($message[$pos + 1] == '0' && !in_array($message[$pos - 1], array(';', ' ', "\t", "\n", '>'))) |
|
| 2553 | - continue; |
|
| 2675 | + if ($message[$pos + 1] == '0' && !in_array($message[$pos - 1], array(';', ' ', "\t", "\n", '>'))) { |
|
| 2676 | + continue; |
|
| 2677 | + } |
|
| 2554 | 2678 | |
| 2555 | 2679 | $tag = $itemcodes[$message[$pos + 1]]; |
| 2556 | 2680 | |
@@ -2571,9 +2695,9 @@ discard block |
||
| 2571 | 2695 | { |
| 2572 | 2696 | array_pop($open_tags); |
| 2573 | 2697 | $code = '</li>'; |
| 2698 | + } else { |
|
| 2699 | + $code = ''; |
|
| 2574 | 2700 | } |
| 2575 | - else |
|
| 2576 | - $code = ''; |
|
| 2577 | 2701 | |
| 2578 | 2702 | // Now we open a new tag. |
| 2579 | 2703 | $open_tags[] = array( |
@@ -2620,12 +2744,14 @@ discard block |
||
| 2620 | 2744 | } |
| 2621 | 2745 | |
| 2622 | 2746 | // No tag? Keep looking, then. Silly people using brackets without actual tags. |
| 2623 | - if ($tag === null) |
|
| 2624 | - continue; |
|
| 2747 | + if ($tag === null) { |
|
| 2748 | + continue; |
|
| 2749 | + } |
|
| 2625 | 2750 | |
| 2626 | 2751 | // Propagate the list to the child (so wrapping the disallowed tag won't work either.) |
| 2627 | - if (isset($inside['disallow_children'])) |
|
| 2628 | - $tag['disallow_children'] = isset($tag['disallow_children']) ? array_unique(array_merge($tag['disallow_children'], $inside['disallow_children'])) : $inside['disallow_children']; |
|
| 2752 | + if (isset($inside['disallow_children'])) { |
|
| 2753 | + $tag['disallow_children'] = isset($tag['disallow_children']) ? array_unique(array_merge($tag['disallow_children'], $inside['disallow_children'])) : $inside['disallow_children']; |
|
| 2754 | + } |
|
| 2629 | 2755 | |
| 2630 | 2756 | // Is this tag disabled? |
| 2631 | 2757 | if (isset($disabled[$tag['tag']])) |
@@ -2635,14 +2761,13 @@ discard block |
||
| 2635 | 2761 | $tag['before'] = !empty($tag['block_level']) ? '<div>' : ''; |
| 2636 | 2762 | $tag['after'] = !empty($tag['block_level']) ? '</div>' : ''; |
| 2637 | 2763 | $tag['content'] = isset($tag['type']) && $tag['type'] == 'closed' ? '' : (!empty($tag['block_level']) ? '<div>$1</div>' : '$1'); |
| 2638 | - } |
|
| 2639 | - elseif (isset($tag['disabled_before']) || isset($tag['disabled_after'])) |
|
| 2764 | + } elseif (isset($tag['disabled_before']) || isset($tag['disabled_after'])) |
|
| 2640 | 2765 | { |
| 2641 | 2766 | $tag['before'] = isset($tag['disabled_before']) ? $tag['disabled_before'] : (!empty($tag['block_level']) ? '<div>' : ''); |
| 2642 | 2767 | $tag['after'] = isset($tag['disabled_after']) ? $tag['disabled_after'] : (!empty($tag['block_level']) ? '</div>' : ''); |
| 2768 | + } else { |
|
| 2769 | + $tag['content'] = $tag['disabled_content']; |
|
| 2643 | 2770 | } |
| 2644 | - else |
|
| 2645 | - $tag['content'] = $tag['disabled_content']; |
|
| 2646 | 2771 | } |
| 2647 | 2772 | |
| 2648 | 2773 | // we use this a lot |
@@ -2652,8 +2777,9 @@ discard block |
||
| 2652 | 2777 | if (!empty($tag['block_level']) && $tag['tag'] != 'html' && empty($inside['block_level'])) |
| 2653 | 2778 | { |
| 2654 | 2779 | $n = count($open_tags) - 1; |
| 2655 | - while (empty($open_tags[$n]['block_level']) && $n >= 0) |
|
| 2656 | - $n--; |
|
| 2780 | + while (empty($open_tags[$n]['block_level']) && $n >= 0) { |
|
| 2781 | + $n--; |
|
| 2782 | + } |
|
| 2657 | 2783 | |
| 2658 | 2784 | // Close all the non block level tags so this tag isn't surrounded by them. |
| 2659 | 2785 | for ($i = count($open_tags) - 1; $i > $n; $i--) |
@@ -2665,12 +2791,15 @@ discard block |
||
| 2665 | 2791 | |
| 2666 | 2792 | // Trim or eat trailing stuff... see comment at the end of the big loop. |
| 2667 | 2793 | $whitespace_regex = ''; |
| 2668 | - if (!empty($tag['block_level'])) |
|
| 2669 | - $whitespace_regex .= '( |\s)*(<br>)?'; |
|
| 2670 | - if (!empty($tag['trim']) && $tag['trim'] != 'inside') |
|
| 2671 | - $whitespace_regex .= empty($tag['require_parents']) ? '( |\s)*' : '(<br>| |\s)*'; |
|
| 2672 | - if (!empty($whitespace_regex) && preg_match('~' . $whitespace_regex . '~', substr($message, $pos), $matches) != 0) |
|
| 2673 | - $message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0])); |
|
| 2794 | + if (!empty($tag['block_level'])) { |
|
| 2795 | + $whitespace_regex .= '( |\s)*(<br>)?'; |
|
| 2796 | + } |
|
| 2797 | + if (!empty($tag['trim']) && $tag['trim'] != 'inside') { |
|
| 2798 | + $whitespace_regex .= empty($tag['require_parents']) ? '( |\s)*' : '(<br>| |\s)*'; |
|
| 2799 | + } |
|
| 2800 | + if (!empty($whitespace_regex) && preg_match('~' . $whitespace_regex . '~', substr($message, $pos), $matches) != 0) { |
|
| 2801 | + $message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0])); |
|
| 2802 | + } |
|
| 2674 | 2803 | |
| 2675 | 2804 | array_pop($open_tags); |
| 2676 | 2805 | } |
@@ -2691,16 +2820,19 @@ discard block |
||
| 2691 | 2820 | elseif ($tag['type'] == 'unparsed_content') |
| 2692 | 2821 | { |
| 2693 | 2822 | $pos2 = stripos($message, '[/' . substr($message, $pos + 1, $tag_strlen) . ']', $pos1); |
| 2694 | - if ($pos2 === false) |
|
| 2695 | - continue; |
|
| 2823 | + if ($pos2 === false) { |
|
| 2824 | + continue; |
|
| 2825 | + } |
|
| 2696 | 2826 | |
| 2697 | 2827 | $data = substr($message, $pos1, $pos2 - $pos1); |
| 2698 | 2828 | |
| 2699 | - if (!empty($tag['block_level']) && substr($data, 0, 4) == '<br>') |
|
| 2700 | - $data = substr($data, 4); |
|
| 2829 | + if (!empty($tag['block_level']) && substr($data, 0, 4) == '<br>') { |
|
| 2830 | + $data = substr($data, 4); |
|
| 2831 | + } |
|
| 2701 | 2832 | |
| 2702 | - if (isset($tag['validate'])) |
|
| 2703 | - $tag['validate']($tag, $data, $disabled, $params); |
|
| 2833 | + if (isset($tag['validate'])) { |
|
| 2834 | + $tag['validate']($tag, $data, $disabled, $params); |
|
| 2835 | + } |
|
| 2704 | 2836 | |
| 2705 | 2837 | $code = strtr($tag['content'], array('$1' => $data)); |
| 2706 | 2838 | $message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos2 + 3 + $tag_strlen); |
@@ -2715,34 +2847,40 @@ discard block |
||
| 2715 | 2847 | if (isset($tag['quoted'])) |
| 2716 | 2848 | { |
| 2717 | 2849 | $quoted = substr($message, $pos1, 6) == '"'; |
| 2718 | - if ($tag['quoted'] != 'optional' && !$quoted) |
|
| 2719 | - continue; |
|
| 2850 | + if ($tag['quoted'] != 'optional' && !$quoted) { |
|
| 2851 | + continue; |
|
| 2852 | + } |
|
| 2720 | 2853 | |
| 2721 | - if ($quoted) |
|
| 2722 | - $pos1 += 6; |
|
| 2854 | + if ($quoted) { |
|
| 2855 | + $pos1 += 6; |
|
| 2856 | + } |
|
| 2857 | + } else { |
|
| 2858 | + $quoted = false; |
|
| 2723 | 2859 | } |
| 2724 | - else |
|
| 2725 | - $quoted = false; |
|
| 2726 | 2860 | |
| 2727 | 2861 | $pos2 = strpos($message, $quoted == false ? ']' : '"]', $pos1); |
| 2728 | - if ($pos2 === false) |
|
| 2729 | - continue; |
|
| 2862 | + if ($pos2 === false) { |
|
| 2863 | + continue; |
|
| 2864 | + } |
|
| 2730 | 2865 | |
| 2731 | 2866 | $pos3 = stripos($message, '[/' . substr($message, $pos + 1, $tag_strlen) . ']', $pos2); |
| 2732 | - if ($pos3 === false) |
|
| 2733 | - continue; |
|
| 2867 | + if ($pos3 === false) { |
|
| 2868 | + continue; |
|
| 2869 | + } |
|
| 2734 | 2870 | |
| 2735 | 2871 | $data = array( |
| 2736 | 2872 | substr($message, $pos2 + ($quoted == false ? 1 : 7), $pos3 - ($pos2 + ($quoted == false ? 1 : 7))), |
| 2737 | 2873 | substr($message, $pos1, $pos2 - $pos1) |
| 2738 | 2874 | ); |
| 2739 | 2875 | |
| 2740 | - if (!empty($tag['block_level']) && substr($data[0], 0, 4) == '<br>') |
|
| 2741 | - $data[0] = substr($data[0], 4); |
|
| 2876 | + if (!empty($tag['block_level']) && substr($data[0], 0, 4) == '<br>') { |
|
| 2877 | + $data[0] = substr($data[0], 4); |
|
| 2878 | + } |
|
| 2742 | 2879 | |
| 2743 | 2880 | // Validation for my parking, please! |
| 2744 | - if (isset($tag['validate'])) |
|
| 2745 | - $tag['validate']($tag, $data, $disabled, $params); |
|
| 2881 | + if (isset($tag['validate'])) { |
|
| 2882 | + $tag['validate']($tag, $data, $disabled, $params); |
|
| 2883 | + } |
|
| 2746 | 2884 | |
| 2747 | 2885 | $code = strtr($tag['content'], array('$1' => $data[0], '$2' => $data[1])); |
| 2748 | 2886 | $message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos3 + 3 + $tag_strlen); |
@@ -2759,23 +2897,27 @@ discard block |
||
| 2759 | 2897 | elseif ($tag['type'] == 'unparsed_commas_content') |
| 2760 | 2898 | { |
| 2761 | 2899 | $pos2 = strpos($message, ']', $pos1); |
| 2762 | - if ($pos2 === false) |
|
| 2763 | - continue; |
|
| 2900 | + if ($pos2 === false) { |
|
| 2901 | + continue; |
|
| 2902 | + } |
|
| 2764 | 2903 | |
| 2765 | 2904 | $pos3 = stripos($message, '[/' . substr($message, $pos + 1, $tag_strlen) . ']', $pos2); |
| 2766 | - if ($pos3 === false) |
|
| 2767 | - continue; |
|
| 2905 | + if ($pos3 === false) { |
|
| 2906 | + continue; |
|
| 2907 | + } |
|
| 2768 | 2908 | |
| 2769 | 2909 | // We want $1 to be the content, and the rest to be csv. |
| 2770 | 2910 | $data = explode(',', ',' . substr($message, $pos1, $pos2 - $pos1)); |
| 2771 | 2911 | $data[0] = substr($message, $pos2 + 1, $pos3 - $pos2 - 1); |
| 2772 | 2912 | |
| 2773 | - if (isset($tag['validate'])) |
|
| 2774 | - $tag['validate']($tag, $data, $disabled, $params); |
|
| 2913 | + if (isset($tag['validate'])) { |
|
| 2914 | + $tag['validate']($tag, $data, $disabled, $params); |
|
| 2915 | + } |
|
| 2775 | 2916 | |
| 2776 | 2917 | $code = $tag['content']; |
| 2777 | - foreach ($data as $k => $d) |
|
| 2778 | - $code = strtr($code, array('$' . ($k + 1) => trim($d))); |
|
| 2918 | + foreach ($data as $k => $d) { |
|
| 2919 | + $code = strtr($code, array('$' . ($k + 1) => trim($d))); |
|
| 2920 | + } |
|
| 2779 | 2921 | $message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos3 + 3 + $tag_strlen); |
| 2780 | 2922 | $pos += strlen($code) - 1 + 2; |
| 2781 | 2923 | } |
@@ -2783,24 +2925,28 @@ discard block |
||
| 2783 | 2925 | elseif ($tag['type'] == 'unparsed_commas') |
| 2784 | 2926 | { |
| 2785 | 2927 | $pos2 = strpos($message, ']', $pos1); |
| 2786 | - if ($pos2 === false) |
|
| 2787 | - continue; |
|
| 2928 | + if ($pos2 === false) { |
|
| 2929 | + continue; |
|
| 2930 | + } |
|
| 2788 | 2931 | |
| 2789 | 2932 | $data = explode(',', substr($message, $pos1, $pos2 - $pos1)); |
| 2790 | 2933 | |
| 2791 | - if (isset($tag['validate'])) |
|
| 2792 | - $tag['validate']($tag, $data, $disabled, $params); |
|
| 2934 | + if (isset($tag['validate'])) { |
|
| 2935 | + $tag['validate']($tag, $data, $disabled, $params); |
|
| 2936 | + } |
|
| 2793 | 2937 | |
| 2794 | 2938 | // Fix after, for disabled code mainly. |
| 2795 | - foreach ($data as $k => $d) |
|
| 2796 | - $tag['after'] = strtr($tag['after'], array('$' . ($k + 1) => trim($d))); |
|
| 2939 | + foreach ($data as $k => $d) { |
|
| 2940 | + $tag['after'] = strtr($tag['after'], array('$' . ($k + 1) => trim($d))); |
|
| 2941 | + } |
|
| 2797 | 2942 | |
| 2798 | 2943 | $open_tags[] = $tag; |
| 2799 | 2944 | |
| 2800 | 2945 | // Replace them out, $1, $2, $3, $4, etc. |
| 2801 | 2946 | $code = $tag['before']; |
| 2802 | - foreach ($data as $k => $d) |
|
| 2803 | - $code = strtr($code, array('$' . ($k + 1) => trim($d))); |
|
| 2947 | + foreach ($data as $k => $d) { |
|
| 2948 | + $code = strtr($code, array('$' . ($k + 1) => trim($d))); |
|
| 2949 | + } |
|
| 2804 | 2950 | $message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos2 + 1); |
| 2805 | 2951 | $pos += strlen($code) - 1 + 2; |
| 2806 | 2952 | } |
@@ -2811,28 +2957,33 @@ discard block |
||
| 2811 | 2957 | if (isset($tag['quoted'])) |
| 2812 | 2958 | { |
| 2813 | 2959 | $quoted = substr($message, $pos1, 6) == '"'; |
| 2814 | - if ($tag['quoted'] != 'optional' && !$quoted) |
|
| 2815 | - continue; |
|
| 2960 | + if ($tag['quoted'] != 'optional' && !$quoted) { |
|
| 2961 | + continue; |
|
| 2962 | + } |
|
| 2816 | 2963 | |
| 2817 | - if ($quoted) |
|
| 2818 | - $pos1 += 6; |
|
| 2964 | + if ($quoted) { |
|
| 2965 | + $pos1 += 6; |
|
| 2966 | + } |
|
| 2967 | + } else { |
|
| 2968 | + $quoted = false; |
|
| 2819 | 2969 | } |
| 2820 | - else |
|
| 2821 | - $quoted = false; |
|
| 2822 | 2970 | |
| 2823 | 2971 | $pos2 = strpos($message, $quoted == false ? ']' : '"]', $pos1); |
| 2824 | - if ($pos2 === false) |
|
| 2825 | - continue; |
|
| 2972 | + if ($pos2 === false) { |
|
| 2973 | + continue; |
|
| 2974 | + } |
|
| 2826 | 2975 | |
| 2827 | 2976 | $data = substr($message, $pos1, $pos2 - $pos1); |
| 2828 | 2977 | |
| 2829 | 2978 | // Validation for my parking, please! |
| 2830 | - if (isset($tag['validate'])) |
|
| 2831 | - $tag['validate']($tag, $data, $disabled, $params); |
|
| 2979 | + if (isset($tag['validate'])) { |
|
| 2980 | + $tag['validate']($tag, $data, $disabled, $params); |
|
| 2981 | + } |
|
| 2832 | 2982 | |
| 2833 | 2983 | // For parsed content, we must recurse to avoid security problems. |
| 2834 | - if ($tag['type'] != 'unparsed_equals') |
|
| 2835 | - $data = parse_bbc($data, !empty($tag['parsed_tags_allowed']) ? false : true, '', !empty($tag['parsed_tags_allowed']) ? $tag['parsed_tags_allowed'] : array()); |
|
| 2984 | + if ($tag['type'] != 'unparsed_equals') { |
|
| 2985 | + $data = parse_bbc($data, !empty($tag['parsed_tags_allowed']) ? false : true, '', !empty($tag['parsed_tags_allowed']) ? $tag['parsed_tags_allowed'] : array()); |
|
| 2986 | + } |
|
| 2836 | 2987 | |
| 2837 | 2988 | $tag['after'] = strtr($tag['after'], array('$1' => $data)); |
| 2838 | 2989 | |
@@ -2844,34 +2995,40 @@ discard block |
||
| 2844 | 2995 | } |
| 2845 | 2996 | |
| 2846 | 2997 | // If this is block level, eat any breaks after it. |
| 2847 | - if (!empty($tag['block_level']) && substr($message, $pos + 1, 4) == '<br>') |
|
| 2848 | - $message = substr($message, 0, $pos + 1) . substr($message, $pos + 5); |
|
| 2998 | + if (!empty($tag['block_level']) && substr($message, $pos + 1, 4) == '<br>') { |
|
| 2999 | + $message = substr($message, 0, $pos + 1) . substr($message, $pos + 5); |
|
| 3000 | + } |
|
| 2849 | 3001 | |
| 2850 | 3002 | // Are we trimming outside this tag? |
| 2851 | - if (!empty($tag['trim']) && $tag['trim'] != 'outside' && preg_match('~(<br>| |\s)*~', substr($message, $pos + 1), $matches) != 0) |
|
| 2852 | - $message = substr($message, 0, $pos + 1) . substr($message, $pos + 1 + strlen($matches[0])); |
|
| 3003 | + if (!empty($tag['trim']) && $tag['trim'] != 'outside' && preg_match('~(<br>| |\s)*~', substr($message, $pos + 1), $matches) != 0) { |
|
| 3004 | + $message = substr($message, 0, $pos + 1) . substr($message, $pos + 1 + strlen($matches[0])); |
|
| 3005 | + } |
|
| 2853 | 3006 | } |
| 2854 | 3007 | |
| 2855 | 3008 | // Close any remaining tags. |
| 2856 | - while ($tag = array_pop($open_tags)) |
|
| 2857 | - $message .= "\n" . $tag['after'] . "\n"; |
|
| 3009 | + while ($tag = array_pop($open_tags)) { |
|
| 3010 | + $message .= "\n" . $tag['after'] . "\n"; |
|
| 3011 | + } |
|
| 2858 | 3012 | |
| 2859 | 3013 | // Parse the smileys within the parts where it can be done safely. |
| 2860 | 3014 | if ($smileys === true) |
| 2861 | 3015 | { |
| 2862 | 3016 | $message_parts = explode("\n", $message); |
| 2863 | - for ($i = 0, $n = count($message_parts); $i < $n; $i += 2) |
|
| 2864 | - parsesmileys($message_parts[$i]); |
|
| 3017 | + for ($i = 0, $n = count($message_parts); $i < $n; $i += 2) { |
|
| 3018 | + parsesmileys($message_parts[$i]); |
|
| 3019 | + } |
|
| 2865 | 3020 | |
| 2866 | 3021 | $message = implode('', $message_parts); |
| 2867 | 3022 | } |
| 2868 | 3023 | |
| 2869 | 3024 | // No smileys, just get rid of the markers. |
| 2870 | - else |
|
| 2871 | - $message = strtr($message, array("\n" => '')); |
|
| 3025 | + else { |
|
| 3026 | + $message = strtr($message, array("\n" => '')); |
|
| 3027 | + } |
|
| 2872 | 3028 | |
| 2873 | - if ($message !== '' && $message[0] === ' ') |
|
| 2874 | - $message = ' ' . substr($message, 1); |
|
| 3029 | + if ($message !== '' && $message[0] === ' ') { |
|
| 3030 | + $message = ' ' . substr($message, 1); |
|
| 3031 | + } |
|
| 2875 | 3032 | |
| 2876 | 3033 | // Cleanup whitespace. |
| 2877 | 3034 | $message = strtr($message, array(' ' => ' ', "\r" => '', "\n" => '<br>', '<br> ' => '<br> ', ' ' => "\n")); |
@@ -2880,15 +3037,16 @@ discard block |
||
| 2880 | 3037 | call_integration_hook('integrate_post_parsebbc', array(&$message, &$smileys, &$cache_id, &$parse_tags)); |
| 2881 | 3038 | |
| 2882 | 3039 | // Cache the output if it took some time... |
| 2883 | - if (isset($cache_key, $cache_t) && array_sum(explode(' ', microtime())) - array_sum(explode(' ', $cache_t)) > 0.05) |
|
| 2884 | - cache_put_data($cache_key, $message, 240); |
|
| 3040 | + if (isset($cache_key, $cache_t) && array_sum(explode(' ', microtime())) - array_sum(explode(' ', $cache_t)) > 0.05) { |
|
| 3041 | + cache_put_data($cache_key, $message, 240); |
|
| 3042 | + } |
|
| 2885 | 3043 | |
| 2886 | 3044 | // If this was a force parse revert if needed. |
| 2887 | 3045 | if (!empty($parse_tags)) |
| 2888 | 3046 | { |
| 2889 | - if (empty($temp_bbc)) |
|
| 2890 | - $bbc_codes = array(); |
|
| 2891 | - else |
|
| 3047 | + if (empty($temp_bbc)) { |
|
| 3048 | + $bbc_codes = array(); |
|
| 3049 | + } else |
|
| 2892 | 3050 | { |
| 2893 | 3051 | $bbc_codes = $temp_bbc; |
| 2894 | 3052 | unset($temp_bbc); |
@@ -2915,8 +3073,9 @@ discard block |
||
| 2915 | 3073 | static $smileyPregSearch = null, $smileyPregReplacements = array(); |
| 2916 | 3074 | |
| 2917 | 3075 | // No smiley set at all?! |
| 2918 | - if ($user_info['smiley_set'] == 'none' || trim($message) == '') |
|
| 2919 | - return; |
|
| 3076 | + if ($user_info['smiley_set'] == 'none' || trim($message) == '') { |
|
| 3077 | + return; |
|
| 3078 | + } |
|
| 2920 | 3079 | |
| 2921 | 3080 | // Maybe a mod wants to implement an alternative method (e.g. emojis instead of images) |
| 2922 | 3081 | call_integration_hook('integrate_smileys', array(&$smileyPregSearch, &$smileyPregReplacements)); |
@@ -2930,8 +3089,7 @@ discard block |
||
| 2930 | 3089 | $smileysfrom = array('>:D', ':D', '::)', '>:(', ':))', ':)', ';)', ';D', ':(', ':o', '8)', ':P', '???', ':-[', ':-X', ':-*', ':\'(', ':-\\', '^-^', 'O0', 'C:-)', 'O:-)'); |
| 2931 | 3090 | $smileysto = array('evil.png', 'cheesy.png', 'rolleyes.png', 'angry.png', 'laugh.png', 'smiley.png', 'wink.png', 'grin.png', 'sad.png', 'shocked.png', 'cool.png', 'tongue.png', 'huh.png', 'embarrassed.png', 'lipsrsealed.png', 'kiss.png', 'cry.png', 'undecided.png', 'azn.png', 'afro.png', 'police.png', 'angel.png'); |
| 2932 | 3091 | $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'], '', '', '', ''); |
| 2933 | - } |
|
| 2934 | - else |
|
| 3092 | + } else |
|
| 2935 | 3093 | { |
| 2936 | 3094 | // Load the smileys in reverse order by length so they don't get parsed wrong. |
| 2937 | 3095 | if (($temp = cache_get_data('parsing_smileys', 480)) == null) |
@@ -2955,9 +3113,9 @@ discard block |
||
| 2955 | 3113 | $smcFunc['db_free_result']($result); |
| 2956 | 3114 | |
| 2957 | 3115 | cache_put_data('parsing_smileys', array($smileysfrom, $smileysto, $smileysdescs), 480); |
| 3116 | + } else { |
|
| 3117 | + list ($smileysfrom, $smileysto, $smileysdescs) = $temp; |
|
| 2958 | 3118 | } |
| 2959 | - else |
|
| 2960 | - list ($smileysfrom, $smileysto, $smileysdescs) = $temp; |
|
| 2961 | 3119 | } |
| 2962 | 3120 | |
| 2963 | 3121 | // The non-breaking-space is a complex thing... |
@@ -2979,16 +3137,18 @@ discard block |
||
| 2979 | 3137 | $alt_images = glob($smileys_dir . $fname . '.{' . (implode(',', $exts)) . '}', GLOB_BRACE); |
| 2980 | 3138 | if (!empty($alt_images)) |
| 2981 | 3139 | { |
| 2982 | - foreach ($exts as $ext) |
|
| 2983 | - if (in_array($smileys_dir . $fname . '.' . $ext, $alt_images)) |
|
| 3140 | + foreach ($exts as $ext) { |
|
| 3141 | + if (in_array($smileys_dir . $fname . '.' . $ext, $alt_images)) |
|
| 2984 | 3142 | { |
| 2985 | 3143 | $smileysto[$i] = $fname . '.' . $ext; |
| 3144 | + } |
|
| 2986 | 3145 | break; |
| 2987 | 3146 | } |
| 2988 | 3147 | } |
| 2989 | 3148 | // If we have no image, just leave the text version in place |
| 2990 | - else |
|
| 2991 | - continue; |
|
| 3149 | + else { |
|
| 3150 | + continue; |
|
| 3151 | + } |
|
| 2992 | 3152 | } |
| 2993 | 3153 | |
| 2994 | 3154 | $specialChars = $smcFunc['htmlspecialchars']($smileysfrom[$i], ENT_QUOTES); |
@@ -3064,12 +3224,14 @@ discard block |
||
| 3064 | 3224 | global $boardurl, $image_proxy_enabled, $image_proxy_secret; |
| 3065 | 3225 | |
| 3066 | 3226 | // Only use the proxy if enabled and necessary |
| 3067 | - if (empty($image_proxy_enabled) || parse_url($url, PHP_URL_SCHEME) === 'https') |
|
| 3068 | - return $url; |
|
| 3227 | + if (empty($image_proxy_enabled) || parse_url($url, PHP_URL_SCHEME) === 'https') { |
|
| 3228 | + return $url; |
|
| 3229 | + } |
|
| 3069 | 3230 | |
| 3070 | 3231 | // We don't need to proxy our own resources |
| 3071 | - if (strpos(strtr($url, array('http://' => 'https://')), strtr($boardurl, array('http://' => 'https://'))) === 0) |
|
| 3072 | - return strtr($url, array('http://' => 'https://')); |
|
| 3232 | + if (strpos(strtr($url, array('http://' => 'https://')), strtr($boardurl, array('http://' => 'https://'))) === 0) { |
|
| 3233 | + return strtr($url, array('http://' => 'https://')); |
|
| 3234 | + } |
|
| 3073 | 3235 | |
| 3074 | 3236 | // By default, use SMF's own image proxy script |
| 3075 | 3237 | $proxied_url = strtr($boardurl, array('http://' => 'https://')) . '/proxy.php?request=' . urlencode($url) . '&hash=' . md5($url . $image_proxy_secret); |
@@ -3094,35 +3256,41 @@ discard block |
||
| 3094 | 3256 | global $scripturl, $context, $modSettings, $db_show_debug, $db_cache; |
| 3095 | 3257 | |
| 3096 | 3258 | // In case we have mail to send, better do that - as obExit doesn't always quite make it... |
| 3097 | - if (!empty($context['flush_mail'])) |
|
| 3098 | - // @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\ |
|
| 3259 | + if (!empty($context['flush_mail'])) { |
|
| 3260 | + // @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\ |
|
| 3099 | 3261 | AddMailQueue(true); |
| 3262 | + } |
|
| 3100 | 3263 | |
| 3101 | 3264 | $add = preg_match('~^(ftp|http)[s]?://~', $setLocation) == 0 && substr($setLocation, 0, 6) != 'about:'; |
| 3102 | 3265 | |
| 3103 | - if ($add) |
|
| 3104 | - $setLocation = $scripturl . ($setLocation != '' ? '?' . $setLocation : ''); |
|
| 3266 | + if ($add) { |
|
| 3267 | + $setLocation = $scripturl . ($setLocation != '' ? '?' . $setLocation : ''); |
|
| 3268 | + } |
|
| 3105 | 3269 | |
| 3106 | 3270 | // Put the session ID in. |
| 3107 | - if (defined('SID') && SID != '') |
|
| 3108 | - $setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '(?!\?' . preg_quote(SID, '/') . ')\\??/', $scripturl . '?' . SID . ';', $setLocation); |
|
| 3271 | + if (defined('SID') && SID != '') { |
|
| 3272 | + $setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '(?!\?' . preg_quote(SID, '/') . ')\\??/', $scripturl . '?' . SID . ';', $setLocation); |
|
| 3273 | + } |
|
| 3109 | 3274 | // Keep that debug in their for template debugging! |
| 3110 | - elseif (isset($_GET['debug'])) |
|
| 3111 | - $setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '\\??/', $scripturl . '?debug;', $setLocation); |
|
| 3275 | + elseif (isset($_GET['debug'])) { |
|
| 3276 | + $setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '\\??/', $scripturl . '?debug;', $setLocation); |
|
| 3277 | + } |
|
| 3112 | 3278 | |
| 3113 | 3279 | 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']))) |
| 3114 | 3280 | { |
| 3115 | - if (defined('SID') && SID != '') |
|
| 3116 | - $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '~') . '\?(?:' . SID . '(?:;|&|&))((?:board|topic)=[^#]+?)(#[^"]*?)?$~', |
|
| 3281 | + if (defined('SID') && SID != '') { |
|
| 3282 | + $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '~') . '\?(?:' . SID . '(?:;|&|&))((?:board|topic)=[^#]+?)(#[^"]*?)?$~', |
|
| 3117 | 3283 | function ($m) use ($scripturl) |
| 3118 | 3284 | { |
| 3119 | 3285 | return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html?' . SID. (isset($m[2]) ? "$m[2]" : ""); |
| 3286 | + } |
|
| 3120 | 3287 | }, $setLocation); |
| 3121 | - else |
|
| 3122 | - $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '~') . '\?((?:board|topic)=[^#"]+?)(#[^"]*?)?$~', |
|
| 3288 | + else { |
|
| 3289 | + $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '~') . '\?((?:board|topic)=[^#"]+?)(#[^"]*?)?$~', |
|
| 3123 | 3290 | function ($m) use ($scripturl) |
| 3124 | 3291 | { |
| 3125 | 3292 | return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html' . (isset($m[2]) ? "$m[2]" : ""); |
| 3293 | + } |
|
| 3126 | 3294 | }, $setLocation); |
| 3127 | 3295 | } |
| 3128 | 3296 | |
@@ -3133,8 +3301,9 @@ discard block |
||
| 3133 | 3301 | header('location: ' . str_replace(' ', '%20', $setLocation), true, $permanent ? 301 : 302); |
| 3134 | 3302 | |
| 3135 | 3303 | // Debugging. |
| 3136 | - if (isset($db_show_debug) && $db_show_debug === true) |
|
| 3137 | - $_SESSION['debug_redirect'] = $db_cache; |
|
| 3304 | + if (isset($db_show_debug) && $db_show_debug === true) { |
|
| 3305 | + $_SESSION['debug_redirect'] = $db_cache; |
|
| 3306 | + } |
|
| 3138 | 3307 | |
| 3139 | 3308 | obExit(false); |
| 3140 | 3309 | } |
@@ -3153,51 +3322,60 @@ discard block |
||
| 3153 | 3322 | |
| 3154 | 3323 | // Attempt to prevent a recursive loop. |
| 3155 | 3324 | ++$level; |
| 3156 | - if ($level > 1 && !$from_fatal_error && !$has_fatal_error) |
|
| 3157 | - exit; |
|
| 3158 | - if ($from_fatal_error) |
|
| 3159 | - $has_fatal_error = true; |
|
| 3325 | + if ($level > 1 && !$from_fatal_error && !$has_fatal_error) { |
|
| 3326 | + exit; |
|
| 3327 | + } |
|
| 3328 | + if ($from_fatal_error) { |
|
| 3329 | + $has_fatal_error = true; |
|
| 3330 | + } |
|
| 3160 | 3331 | |
| 3161 | 3332 | // Clear out the stat cache. |
| 3162 | 3333 | trackStats(); |
| 3163 | 3334 | |
| 3164 | 3335 | // If we have mail to send, send it. |
| 3165 | - if (!empty($context['flush_mail'])) |
|
| 3166 | - // @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\ |
|
| 3336 | + if (!empty($context['flush_mail'])) { |
|
| 3337 | + // @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\ |
|
| 3167 | 3338 | AddMailQueue(true); |
| 3339 | + } |
|
| 3168 | 3340 | |
| 3169 | 3341 | $do_header = $header === null ? !$header_done : $header; |
| 3170 | - if ($do_footer === null) |
|
| 3171 | - $do_footer = $do_header; |
|
| 3342 | + if ($do_footer === null) { |
|
| 3343 | + $do_footer = $do_header; |
|
| 3344 | + } |
|
| 3172 | 3345 | |
| 3173 | 3346 | // Has the template/header been done yet? |
| 3174 | 3347 | if ($do_header) |
| 3175 | 3348 | { |
| 3176 | 3349 | // Was the page title set last minute? Also update the HTML safe one. |
| 3177 | - if (!empty($context['page_title']) && empty($context['page_title_html_safe'])) |
|
| 3178 | - $context['page_title_html_safe'] = $smcFunc['htmlspecialchars'](un_htmlspecialchars($context['page_title'])) . (!empty($context['current_page']) ? ' - ' . $txt['page'] . ' ' . ($context['current_page'] + 1) : ''); |
|
| 3350 | + if (!empty($context['page_title']) && empty($context['page_title_html_safe'])) { |
|
| 3351 | + $context['page_title_html_safe'] = $smcFunc['htmlspecialchars'](un_htmlspecialchars($context['page_title'])) . (!empty($context['current_page']) ? ' - ' . $txt['page'] . ' ' . ($context['current_page'] + 1) : ''); |
|
| 3352 | + } |
|
| 3179 | 3353 | |
| 3180 | 3354 | // Start up the session URL fixer. |
| 3181 | 3355 | ob_start('ob_sessrewrite'); |
| 3182 | 3356 | |
| 3183 | - if (!empty($settings['output_buffers']) && is_string($settings['output_buffers'])) |
|
| 3184 | - $buffers = explode(',', $settings['output_buffers']); |
|
| 3185 | - elseif (!empty($settings['output_buffers'])) |
|
| 3186 | - $buffers = $settings['output_buffers']; |
|
| 3187 | - else |
|
| 3188 | - $buffers = array(); |
|
| 3357 | + if (!empty($settings['output_buffers']) && is_string($settings['output_buffers'])) { |
|
| 3358 | + $buffers = explode(',', $settings['output_buffers']); |
|
| 3359 | + } elseif (!empty($settings['output_buffers'])) { |
|
| 3360 | + $buffers = $settings['output_buffers']; |
|
| 3361 | + } else { |
|
| 3362 | + $buffers = array(); |
|
| 3363 | + } |
|
| 3189 | 3364 | |
| 3190 | - if (isset($modSettings['integrate_buffer'])) |
|
| 3191 | - $buffers = array_merge(explode(',', $modSettings['integrate_buffer']), $buffers); |
|
| 3365 | + if (isset($modSettings['integrate_buffer'])) { |
|
| 3366 | + $buffers = array_merge(explode(',', $modSettings['integrate_buffer']), $buffers); |
|
| 3367 | + } |
|
| 3192 | 3368 | |
| 3193 | - if (!empty($buffers)) |
|
| 3194 | - foreach ($buffers as $function) |
|
| 3369 | + if (!empty($buffers)) { |
|
| 3370 | + foreach ($buffers as $function) |
|
| 3195 | 3371 | { |
| 3196 | 3372 | $call = call_helper($function, true); |
| 3373 | + } |
|
| 3197 | 3374 | |
| 3198 | 3375 | // Is it valid? |
| 3199 | - if (!empty($call)) |
|
| 3200 | - ob_start($call); |
|
| 3376 | + if (!empty($call)) { |
|
| 3377 | + ob_start($call); |
|
| 3378 | + } |
|
| 3201 | 3379 | } |
| 3202 | 3380 | |
| 3203 | 3381 | // Display the screen in the logical order. |
@@ -3209,8 +3387,9 @@ discard block |
||
| 3209 | 3387 | loadSubTemplate(isset($context['sub_template']) ? $context['sub_template'] : 'main'); |
| 3210 | 3388 | |
| 3211 | 3389 | // Anything special to put out? |
| 3212 | - if (!empty($context['insert_after_template']) && !isset($_REQUEST['xml'])) |
|
| 3213 | - echo $context['insert_after_template']; |
|
| 3390 | + if (!empty($context['insert_after_template']) && !isset($_REQUEST['xml'])) { |
|
| 3391 | + echo $context['insert_after_template']; |
|
| 3392 | + } |
|
| 3214 | 3393 | |
| 3215 | 3394 | // Just so we don't get caught in an endless loop of errors from the footer... |
| 3216 | 3395 | if (!$footer_done) |
@@ -3219,14 +3398,16 @@ discard block |
||
| 3219 | 3398 | template_footer(); |
| 3220 | 3399 | |
| 3221 | 3400 | // (since this is just debugging... it's okay that it's after </html>.) |
| 3222 | - if (!isset($_REQUEST['xml'])) |
|
| 3223 | - displayDebug(); |
|
| 3401 | + if (!isset($_REQUEST['xml'])) { |
|
| 3402 | + displayDebug(); |
|
| 3403 | + } |
|
| 3224 | 3404 | } |
| 3225 | 3405 | } |
| 3226 | 3406 | |
| 3227 | 3407 | // Remember this URL in case someone doesn't like sending HTTP_REFERER. |
| 3228 | - if (strpos($_SERVER['REQUEST_URL'], 'action=dlattach') === false && strpos($_SERVER['REQUEST_URL'], 'action=viewsmfile') === false) |
|
| 3229 | - $_SESSION['old_url'] = $_SERVER['REQUEST_URL']; |
|
| 3408 | + if (strpos($_SERVER['REQUEST_URL'], 'action=dlattach') === false && strpos($_SERVER['REQUEST_URL'], 'action=viewsmfile') === false) { |
|
| 3409 | + $_SESSION['old_url'] = $_SERVER['REQUEST_URL']; |
|
| 3410 | + } |
|
| 3230 | 3411 | |
| 3231 | 3412 | // For session check verification.... don't switch browsers... |
| 3232 | 3413 | $_SESSION['USER_AGENT'] = empty($_SERVER['HTTP_USER_AGENT']) ? '' : $_SERVER['HTTP_USER_AGENT']; |
@@ -3235,9 +3416,10 @@ discard block |
||
| 3235 | 3416 | call_integration_hook('integrate_exit', array($do_footer)); |
| 3236 | 3417 | |
| 3237 | 3418 | // Don't exit if we're coming from index.php; that will pass through normally. |
| 3238 | - if (!$from_index) |
|
| 3239 | - exit; |
|
| 3240 | -} |
|
| 3419 | + if (!$from_index) { |
|
| 3420 | + exit; |
|
| 3421 | + } |
|
| 3422 | + } |
|
| 3241 | 3423 | |
| 3242 | 3424 | /** |
| 3243 | 3425 | * Get the size of a specified image with better error handling. |
@@ -3256,8 +3438,9 @@ discard block |
||
| 3256 | 3438 | $url = str_replace(' ', '%20', $url); |
| 3257 | 3439 | |
| 3258 | 3440 | // Can we pull this from the cache... please please? |
| 3259 | - if (($temp = cache_get_data('url_image_size-' . md5($url), 240)) !== null) |
|
| 3260 | - return $temp; |
|
| 3441 | + if (($temp = cache_get_data('url_image_size-' . md5($url), 240)) !== null) { |
|
| 3442 | + return $temp; |
|
| 3443 | + } |
|
| 3261 | 3444 | $t = microtime(); |
| 3262 | 3445 | |
| 3263 | 3446 | // Get the host to pester... |
@@ -3267,12 +3450,10 @@ discard block |
||
| 3267 | 3450 | if ($url == '' || $url == 'http://' || $url == 'https://') |
| 3268 | 3451 | { |
| 3269 | 3452 | return false; |
| 3270 | - } |
|
| 3271 | - elseif (!isset($match[1])) |
|
| 3453 | + } elseif (!isset($match[1])) |
|
| 3272 | 3454 | { |
| 3273 | 3455 | $size = @getimagesize($url); |
| 3274 | - } |
|
| 3275 | - else |
|
| 3456 | + } else |
|
| 3276 | 3457 | { |
| 3277 | 3458 | // Try to connect to the server... give it half a second. |
| 3278 | 3459 | $temp = 0; |
@@ -3309,12 +3490,14 @@ discard block |
||
| 3309 | 3490 | } |
| 3310 | 3491 | |
| 3311 | 3492 | // If we didn't get it, we failed. |
| 3312 | - if (!isset($size)) |
|
| 3313 | - $size = false; |
|
| 3493 | + if (!isset($size)) { |
|
| 3494 | + $size = false; |
|
| 3495 | + } |
|
| 3314 | 3496 | |
| 3315 | 3497 | // If this took a long time, we may never have to do it again, but then again we might... |
| 3316 | - if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $t)) > 0.8) |
|
| 3317 | - cache_put_data('url_image_size-' . md5($url), $size, 240); |
|
| 3498 | + if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $t)) > 0.8) { |
|
| 3499 | + cache_put_data('url_image_size-' . md5($url), $size, 240); |
|
| 3500 | + } |
|
| 3318 | 3501 | |
| 3319 | 3502 | // Didn't work. |
| 3320 | 3503 | return $size; |
@@ -3332,8 +3515,9 @@ discard block |
||
| 3332 | 3515 | |
| 3333 | 3516 | // Under SSI this function can be called more then once. That can cause some problems. |
| 3334 | 3517 | // So only run the function once unless we are forced to run it again. |
| 3335 | - if ($loaded && !$forceload) |
|
| 3336 | - return; |
|
| 3518 | + if ($loaded && !$forceload) { |
|
| 3519 | + return; |
|
| 3520 | + } |
|
| 3337 | 3521 | |
| 3338 | 3522 | $loaded = true; |
| 3339 | 3523 | |
@@ -3345,14 +3529,16 @@ discard block |
||
| 3345 | 3529 | $context['news_lines'] = array_filter(explode("\n", str_replace("\r", '', trim(addslashes($modSettings['news']))))); |
| 3346 | 3530 | for ($i = 0, $n = count($context['news_lines']); $i < $n; $i++) |
| 3347 | 3531 | { |
| 3348 | - if (trim($context['news_lines'][$i]) == '') |
|
| 3349 | - continue; |
|
| 3532 | + if (trim($context['news_lines'][$i]) == '') { |
|
| 3533 | + continue; |
|
| 3534 | + } |
|
| 3350 | 3535 | |
| 3351 | 3536 | // Clean it up for presentation ;). |
| 3352 | 3537 | $context['news_lines'][$i] = parse_bbc(stripslashes(trim($context['news_lines'][$i])), true, 'news' . $i); |
| 3353 | 3538 | } |
| 3354 | - if (!empty($context['news_lines'])) |
|
| 3355 | - $context['random_news_line'] = $context['news_lines'][mt_rand(0, count($context['news_lines']) - 1)]; |
|
| 3539 | + if (!empty($context['news_lines'])) { |
|
| 3540 | + $context['random_news_line'] = $context['news_lines'][mt_rand(0, count($context['news_lines']) - 1)]; |
|
| 3541 | + } |
|
| 3356 | 3542 | |
| 3357 | 3543 | if (!$user_info['is_guest']) |
| 3358 | 3544 | { |
@@ -3361,40 +3547,48 @@ discard block |
||
| 3361 | 3547 | $context['user']['alerts'] = &$user_info['alerts']; |
| 3362 | 3548 | |
| 3363 | 3549 | // Personal message popup... |
| 3364 | - if ($user_info['unread_messages'] > (isset($_SESSION['unread_messages']) ? $_SESSION['unread_messages'] : 0)) |
|
| 3365 | - $context['user']['popup_messages'] = true; |
|
| 3366 | - else |
|
| 3367 | - $context['user']['popup_messages'] = false; |
|
| 3550 | + if ($user_info['unread_messages'] > (isset($_SESSION['unread_messages']) ? $_SESSION['unread_messages'] : 0)) { |
|
| 3551 | + $context['user']['popup_messages'] = true; |
|
| 3552 | + } else { |
|
| 3553 | + $context['user']['popup_messages'] = false; |
|
| 3554 | + } |
|
| 3368 | 3555 | $_SESSION['unread_messages'] = $user_info['unread_messages']; |
| 3369 | 3556 | |
| 3370 | - if (allowedTo('moderate_forum')) |
|
| 3371 | - $context['unapproved_members'] = (!empty($modSettings['registration_method']) && ($modSettings['registration_method'] == 2 || (!empty($modSettings['coppaType']) && $modSettings['coppaType'] == 2))) || !empty($modSettings['approveAccountDeletion']) ? $modSettings['unapprovedMembers'] : 0; |
|
| 3557 | + if (allowedTo('moderate_forum')) { |
|
| 3558 | + $context['unapproved_members'] = (!empty($modSettings['registration_method']) && ($modSettings['registration_method'] == 2 || (!empty($modSettings['coppaType']) && $modSettings['coppaType'] == 2))) || !empty($modSettings['approveAccountDeletion']) ? $modSettings['unapprovedMembers'] : 0; |
|
| 3559 | + } |
|
| 3372 | 3560 | |
| 3373 | 3561 | $context['user']['avatar'] = array(); |
| 3374 | 3562 | |
| 3375 | 3563 | // Check for gravatar first since we might be forcing them... |
| 3376 | 3564 | if (($modSettings['gravatarEnabled'] && substr($user_info['avatar']['url'], 0, 11) == 'gravatar://') || !empty($modSettings['gravatarOverride'])) |
| 3377 | 3565 | { |
| 3378 | - if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($user_info['avatar']['url'], 'gravatar://') && strlen($user_info['avatar']['url']) > 11) |
|
| 3379 | - $context['user']['avatar']['href'] = get_gravatar_url($smcFunc['substr']($user_info['avatar']['url'], 11)); |
|
| 3380 | - else |
|
| 3381 | - $context['user']['avatar']['href'] = get_gravatar_url($user_info['email']); |
|
| 3566 | + if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($user_info['avatar']['url'], 'gravatar://') && strlen($user_info['avatar']['url']) > 11) { |
|
| 3567 | + $context['user']['avatar']['href'] = get_gravatar_url($smcFunc['substr']($user_info['avatar']['url'], 11)); |
|
| 3568 | + } else { |
|
| 3569 | + $context['user']['avatar']['href'] = get_gravatar_url($user_info['email']); |
|
| 3570 | + } |
|
| 3382 | 3571 | } |
| 3383 | 3572 | // Uploaded? |
| 3384 | - elseif ($user_info['avatar']['url'] == '' && !empty($user_info['avatar']['id_attach'])) |
|
| 3385 | - $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'; |
|
| 3573 | + elseif ($user_info['avatar']['url'] == '' && !empty($user_info['avatar']['id_attach'])) { |
|
| 3574 | + $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'; |
|
| 3575 | + } |
|
| 3386 | 3576 | // Full URL? |
| 3387 | - elseif (strpos($user_info['avatar']['url'], 'http://') === 0 || strpos($user_info['avatar']['url'], 'https://') === 0) |
|
| 3388 | - $context['user']['avatar']['href'] = $user_info['avatar']['url']; |
|
| 3577 | + elseif (strpos($user_info['avatar']['url'], 'http://') === 0 || strpos($user_info['avatar']['url'], 'https://') === 0) { |
|
| 3578 | + $context['user']['avatar']['href'] = $user_info['avatar']['url']; |
|
| 3579 | + } |
|
| 3389 | 3580 | // Otherwise we assume it's server stored. |
| 3390 | - elseif ($user_info['avatar']['url'] != '') |
|
| 3391 | - $context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/' . $smcFunc['htmlspecialchars']($user_info['avatar']['url']); |
|
| 3581 | + elseif ($user_info['avatar']['url'] != '') { |
|
| 3582 | + $context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/' . $smcFunc['htmlspecialchars']($user_info['avatar']['url']); |
|
| 3583 | + } |
|
| 3392 | 3584 | // No avatar at all? Fine, we have a big fat default avatar ;) |
| 3393 | - else |
|
| 3394 | - $context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/default.png'; |
|
| 3585 | + else { |
|
| 3586 | + $context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/default.png'; |
|
| 3587 | + } |
|
| 3395 | 3588 | |
| 3396 | - if (!empty($context['user']['avatar'])) |
|
| 3397 | - $context['user']['avatar']['image'] = '<img src="' . $context['user']['avatar']['href'] . '" alt="" class="avatar">'; |
|
| 3589 | + if (!empty($context['user']['avatar'])) { |
|
| 3590 | + $context['user']['avatar']['image'] = '<img src="' . $context['user']['avatar']['href'] . '" alt="" class="avatar">'; |
|
| 3591 | + } |
|
| 3398 | 3592 | |
| 3399 | 3593 | // Figure out how long they've been logged in. |
| 3400 | 3594 | $context['user']['total_time_logged_in'] = array( |
@@ -3402,8 +3596,7 @@ discard block |
||
| 3402 | 3596 | 'hours' => floor(($user_info['total_time_logged_in'] % 86400) / 3600), |
| 3403 | 3597 | 'minutes' => floor(($user_info['total_time_logged_in'] % 3600) / 60) |
| 3404 | 3598 | ); |
| 3405 | - } |
|
| 3406 | - else |
|
| 3599 | + } else |
|
| 3407 | 3600 | { |
| 3408 | 3601 | $context['user']['messages'] = 0; |
| 3409 | 3602 | $context['user']['unread_messages'] = 0; |
@@ -3411,12 +3604,14 @@ discard block |
||
| 3411 | 3604 | $context['user']['total_time_logged_in'] = array('days' => 0, 'hours' => 0, 'minutes' => 0); |
| 3412 | 3605 | $context['user']['popup_messages'] = false; |
| 3413 | 3606 | |
| 3414 | - if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 1) |
|
| 3415 | - $txt['welcome_guest'] .= $txt['welcome_guest_activate']; |
|
| 3607 | + if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 1) { |
|
| 3608 | + $txt['welcome_guest'] .= $txt['welcome_guest_activate']; |
|
| 3609 | + } |
|
| 3416 | 3610 | |
| 3417 | 3611 | // If we've upgraded recently, go easy on the passwords. |
| 3418 | - if (!empty($modSettings['disableHashTime']) && ($modSettings['disableHashTime'] == 1 || time() < $modSettings['disableHashTime'])) |
|
| 3419 | - $context['disable_login_hashing'] = true; |
|
| 3612 | + if (!empty($modSettings['disableHashTime']) && ($modSettings['disableHashTime'] == 1 || time() < $modSettings['disableHashTime'])) { |
|
| 3613 | + $context['disable_login_hashing'] = true; |
|
| 3614 | + } |
|
| 3420 | 3615 | } |
| 3421 | 3616 | |
| 3422 | 3617 | // Setup the main menu items. |
@@ -3429,8 +3624,8 @@ discard block |
||
| 3429 | 3624 | $context['show_pm_popup'] = $context['user']['popup_messages'] && !empty($options['popup_messages']) && (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'pm'); |
| 3430 | 3625 | |
| 3431 | 3626 | // 2.1+: Add the PM popup here instead. Theme authors can still override it simply by editing/removing the 'fPmPopup' in the array. |
| 3432 | - if ($context['show_pm_popup']) |
|
| 3433 | - addInlineJavaScript(' |
|
| 3627 | + if ($context['show_pm_popup']) { |
|
| 3628 | + addInlineJavaScript(' |
|
| 3434 | 3629 | jQuery(document).ready(function($) { |
| 3435 | 3630 | new smc_Popup({ |
| 3436 | 3631 | heading: ' . JavaScriptEscape($txt['show_personal_messages_heading']) . ', |
@@ -3438,24 +3633,28 @@ discard block |
||
| 3438 | 3633 | icon_class: \'generic_icons mail_new\' |
| 3439 | 3634 | }); |
| 3440 | 3635 | });'); |
| 3636 | + } |
|
| 3441 | 3637 | |
| 3442 | 3638 | // Add a generic "Are you sure?" confirmation message. |
| 3443 | 3639 | addInlineJavaScript(' |
| 3444 | 3640 | var smf_you_sure =' . JavaScriptEscape($txt['quickmod_confirm']) .';'); |
| 3445 | 3641 | |
| 3446 | 3642 | // Now add the capping code for avatars. |
| 3447 | - 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') |
|
| 3448 | - addInlineCss(' |
|
| 3643 | + 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') { |
|
| 3644 | + addInlineCss(' |
|
| 3449 | 3645 | img.avatar { max-width: ' . $modSettings['avatar_max_width_external'] . 'px; max-height: ' . $modSettings['avatar_max_height_external'] . 'px; }'); |
| 3646 | + } |
|
| 3450 | 3647 | |
| 3451 | 3648 | // Add max image limits |
| 3452 | - if (!empty($modSettings['max_image_width'])) |
|
| 3453 | - addInlineCss(' |
|
| 3649 | + if (!empty($modSettings['max_image_width'])) { |
|
| 3650 | + addInlineCss(' |
|
| 3454 | 3651 | .postarea .bbc_img { max-width: ' . $modSettings['max_image_width'] . 'px; }'); |
| 3652 | + } |
|
| 3455 | 3653 | |
| 3456 | - if (!empty($modSettings['max_image_height'])) |
|
| 3457 | - addInlineCss(' |
|
| 3654 | + if (!empty($modSettings['max_image_height'])) { |
|
| 3655 | + addInlineCss(' |
|
| 3458 | 3656 | .postarea .bbc_img { max-height: ' . $modSettings['max_image_height'] . 'px; }'); |
| 3657 | + } |
|
| 3459 | 3658 | |
| 3460 | 3659 | // This looks weird, but it's because BoardIndex.php references the variable. |
| 3461 | 3660 | $context['common_stats']['latest_member'] = array( |
@@ -3472,11 +3671,13 @@ discard block |
||
| 3472 | 3671 | ); |
| 3473 | 3672 | $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']); |
| 3474 | 3673 | |
| 3475 | - if (empty($settings['theme_version'])) |
|
| 3476 | - addJavaScriptVar('smf_scripturl', $scripturl); |
|
| 3674 | + if (empty($settings['theme_version'])) { |
|
| 3675 | + addJavaScriptVar('smf_scripturl', $scripturl); |
|
| 3676 | + } |
|
| 3477 | 3677 | |
| 3478 | - if (!isset($context['page_title'])) |
|
| 3479 | - $context['page_title'] = ''; |
|
| 3678 | + if (!isset($context['page_title'])) { |
|
| 3679 | + $context['page_title'] = ''; |
|
| 3680 | + } |
|
| 3480 | 3681 | |
| 3481 | 3682 | // Set some specific vars. |
| 3482 | 3683 | $context['page_title_html_safe'] = $smcFunc['htmlspecialchars'](un_htmlspecialchars($context['page_title'])) . (!empty($context['current_page']) ? ' - ' . $txt['page'] . ' ' . ($context['current_page'] + 1) : ''); |
@@ -3486,21 +3687,23 @@ discard block |
||
| 3486 | 3687 | $context['meta_tags'][] = array('property' => 'og:site_name', 'content' => $context['forum_name']); |
| 3487 | 3688 | $context['meta_tags'][] = array('property' => 'og:title', 'content' => $context['page_title_html_safe']); |
| 3488 | 3689 | |
| 3489 | - if (!empty($context['meta_keywords'])) |
|
| 3490 | - $context['meta_tags'][] = array('name' => 'keywords', 'content' => $context['meta_keywords']); |
|
| 3690 | + if (!empty($context['meta_keywords'])) { |
|
| 3691 | + $context['meta_tags'][] = array('name' => 'keywords', 'content' => $context['meta_keywords']); |
|
| 3692 | + } |
|
| 3491 | 3693 | |
| 3492 | - if (!empty($context['canonical_url'])) |
|
| 3493 | - $context['meta_tags'][] = array('property' => 'og:url', 'content' => $context['canonical_url']); |
|
| 3694 | + if (!empty($context['canonical_url'])) { |
|
| 3695 | + $context['meta_tags'][] = array('property' => 'og:url', 'content' => $context['canonical_url']); |
|
| 3696 | + } |
|
| 3494 | 3697 | |
| 3495 | - if (!empty($settings['og_image'])) |
|
| 3496 | - $context['meta_tags'][] = array('property' => 'og:image', 'content' => $settings['og_image']); |
|
| 3698 | + if (!empty($settings['og_image'])) { |
|
| 3699 | + $context['meta_tags'][] = array('property' => 'og:image', 'content' => $settings['og_image']); |
|
| 3700 | + } |
|
| 3497 | 3701 | |
| 3498 | 3702 | if (!empty($context['meta_description'])) |
| 3499 | 3703 | { |
| 3500 | 3704 | $context['meta_tags'][] = array('property' => 'og:description', 'content' => $context['meta_description']); |
| 3501 | 3705 | $context['meta_tags'][] = array('name' => 'description', 'content' => $context['meta_description']); |
| 3502 | - } |
|
| 3503 | - else |
|
| 3706 | + } else |
|
| 3504 | 3707 | { |
| 3505 | 3708 | $context['meta_tags'][] = array('property' => 'og:description', 'content' => $context['page_title_html_safe']); |
| 3506 | 3709 | $context['meta_tags'][] = array('name' => 'description', 'content' => $context['page_title_html_safe']); |
@@ -3525,8 +3728,9 @@ discard block |
||
| 3525 | 3728 | $memory_needed = memoryReturnBytes($needed); |
| 3526 | 3729 | |
| 3527 | 3730 | // should we account for how much is currently being used? |
| 3528 | - if ($in_use) |
|
| 3529 | - $memory_needed += function_exists('memory_get_usage') ? memory_get_usage() : (2 * 1048576); |
|
| 3731 | + if ($in_use) { |
|
| 3732 | + $memory_needed += function_exists('memory_get_usage') ? memory_get_usage() : (2 * 1048576); |
|
| 3733 | + } |
|
| 3530 | 3734 | |
| 3531 | 3735 | // if more is needed, request it |
| 3532 | 3736 | if ($memory_current < $memory_needed) |
@@ -3549,8 +3753,9 @@ discard block |
||
| 3549 | 3753 | */ |
| 3550 | 3754 | function memoryReturnBytes($val) |
| 3551 | 3755 | { |
| 3552 | - if (is_integer($val)) |
|
| 3553 | - return $val; |
|
| 3756 | + if (is_integer($val)) { |
|
| 3757 | + return $val; |
|
| 3758 | + } |
|
| 3554 | 3759 | |
| 3555 | 3760 | // Separate the number from the designator |
| 3556 | 3761 | $val = trim($val); |
@@ -3586,10 +3791,11 @@ discard block |
||
| 3586 | 3791 | header('last-modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); |
| 3587 | 3792 | |
| 3588 | 3793 | // Are we debugging the template/html content? |
| 3589 | - if (!isset($_REQUEST['xml']) && isset($_GET['debug']) && !isBrowser('ie')) |
|
| 3590 | - header('content-type: application/xhtml+xml'); |
|
| 3591 | - elseif (!isset($_REQUEST['xml'])) |
|
| 3592 | - header('content-type: text/html; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
| 3794 | + if (!isset($_REQUEST['xml']) && isset($_GET['debug']) && !isBrowser('ie')) { |
|
| 3795 | + header('content-type: application/xhtml+xml'); |
|
| 3796 | + } elseif (!isset($_REQUEST['xml'])) { |
|
| 3797 | + header('content-type: text/html; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
| 3798 | + } |
|
| 3593 | 3799 | } |
| 3594 | 3800 | |
| 3595 | 3801 | header('content-type: text/' . (isset($_REQUEST['xml']) ? 'xml' : 'html') . '; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
@@ -3598,8 +3804,9 @@ discard block |
||
| 3598 | 3804 | if ($context['in_maintenance'] && $context['user']['is_admin']) |
| 3599 | 3805 | { |
| 3600 | 3806 | $position = array_search('body', $context['template_layers']); |
| 3601 | - if ($position === false) |
|
| 3602 | - $position = array_search('main', $context['template_layers']); |
|
| 3807 | + if ($position === false) { |
|
| 3808 | + $position = array_search('main', $context['template_layers']); |
|
| 3809 | + } |
|
| 3603 | 3810 | |
| 3604 | 3811 | if ($position !== false) |
| 3605 | 3812 | { |
@@ -3627,23 +3834,25 @@ discard block |
||
| 3627 | 3834 | |
| 3628 | 3835 | foreach ($securityFiles as $i => $securityFile) |
| 3629 | 3836 | { |
| 3630 | - if (!file_exists($boarddir . '/' . $securityFile)) |
|
| 3631 | - unset($securityFiles[$i]); |
|
| 3837 | + if (!file_exists($boarddir . '/' . $securityFile)) { |
|
| 3838 | + unset($securityFiles[$i]); |
|
| 3839 | + } |
|
| 3632 | 3840 | } |
| 3633 | 3841 | |
| 3634 | 3842 | // We are already checking so many files...just few more doesn't make any difference! :P |
| 3635 | - if (!empty($modSettings['currentAttachmentUploadDir'])) |
|
| 3636 | - $path = $modSettings['attachmentUploadDir'][$modSettings['currentAttachmentUploadDir']]; |
|
| 3637 | - |
|
| 3638 | - else |
|
| 3639 | - $path = $modSettings['attachmentUploadDir']; |
|
| 3843 | + if (!empty($modSettings['currentAttachmentUploadDir'])) { |
|
| 3844 | + $path = $modSettings['attachmentUploadDir'][$modSettings['currentAttachmentUploadDir']]; |
|
| 3845 | + } else { |
|
| 3846 | + $path = $modSettings['attachmentUploadDir']; |
|
| 3847 | + } |
|
| 3640 | 3848 | |
| 3641 | 3849 | secureDirectory($path, true); |
| 3642 | 3850 | secureDirectory($cachedir); |
| 3643 | 3851 | |
| 3644 | 3852 | // If agreement is enabled, at least the english version shall exists |
| 3645 | - if ($modSettings['requireAgreement']) |
|
| 3646 | - $agreement = !file_exists($boarddir . '/agreement.txt'); |
|
| 3853 | + if ($modSettings['requireAgreement']) { |
|
| 3854 | + $agreement = !file_exists($boarddir . '/agreement.txt'); |
|
| 3855 | + } |
|
| 3647 | 3856 | |
| 3648 | 3857 | if (!empty($securityFiles) || (!empty($modSettings['cache_enable']) && !is_writable($cachedir)) || !empty($agreement)) |
| 3649 | 3858 | { |
@@ -3658,18 +3867,21 @@ discard block |
||
| 3658 | 3867 | echo ' |
| 3659 | 3868 | ', $txt['not_removed'], '<strong>', $securityFile, '</strong>!<br>'; |
| 3660 | 3869 | |
| 3661 | - if ($securityFile == 'Settings.php~' || $securityFile == 'Settings_bak.php~') |
|
| 3662 | - echo ' |
|
| 3870 | + if ($securityFile == 'Settings.php~' || $securityFile == 'Settings_bak.php~') { |
|
| 3871 | + echo ' |
|
| 3663 | 3872 | ', sprintf($txt['not_removed_extra'], $securityFile, substr($securityFile, 0, -1)), '<br>'; |
| 3873 | + } |
|
| 3664 | 3874 | } |
| 3665 | 3875 | |
| 3666 | - if (!empty($modSettings['cache_enable']) && !is_writable($cachedir)) |
|
| 3667 | - echo ' |
|
| 3876 | + if (!empty($modSettings['cache_enable']) && !is_writable($cachedir)) { |
|
| 3877 | + echo ' |
|
| 3668 | 3878 | <strong>', $txt['cache_writable'], '</strong><br>'; |
| 3879 | + } |
|
| 3669 | 3880 | |
| 3670 | - if (!empty($agreement)) |
|
| 3671 | - echo ' |
|
| 3881 | + if (!empty($agreement)) { |
|
| 3882 | + echo ' |
|
| 3672 | 3883 | <strong>', $txt['agreement_missing'], '</strong><br>'; |
| 3884 | + } |
|
| 3673 | 3885 | |
| 3674 | 3886 | echo ' |
| 3675 | 3887 | </p> |
@@ -3684,16 +3896,18 @@ discard block |
||
| 3684 | 3896 | <div class="windowbg alert" style="margin: 2ex; padding: 2ex; border: 2px dashed red;"> |
| 3685 | 3897 | ', sprintf($txt['you_are_post_banned'], $user_info['is_guest'] ? $txt['guest_title'] : $user_info['name']); |
| 3686 | 3898 | |
| 3687 | - if (!empty($_SESSION['ban']['cannot_post']['reason'])) |
|
| 3688 | - echo ' |
|
| 3899 | + if (!empty($_SESSION['ban']['cannot_post']['reason'])) { |
|
| 3900 | + echo ' |
|
| 3689 | 3901 | <div style="padding-left: 4ex; padding-top: 1ex;">', $_SESSION['ban']['cannot_post']['reason'], '</div>'; |
| 3902 | + } |
|
| 3690 | 3903 | |
| 3691 | - if (!empty($_SESSION['ban']['expire_time'])) |
|
| 3692 | - echo ' |
|
| 3904 | + if (!empty($_SESSION['ban']['expire_time'])) { |
|
| 3905 | + echo ' |
|
| 3693 | 3906 | <div>', sprintf($txt['your_ban_expires'], timeformat($_SESSION['ban']['expire_time'], false)), '</div>'; |
| 3694 | - else |
|
| 3695 | - echo ' |
|
| 3907 | + } else { |
|
| 3908 | + echo ' |
|
| 3696 | 3909 | <div>', $txt['your_ban_expires_never'], '</div>'; |
| 3910 | + } |
|
| 3697 | 3911 | |
| 3698 | 3912 | echo ' |
| 3699 | 3913 | </div>'; |
@@ -3709,8 +3923,9 @@ discard block |
||
| 3709 | 3923 | global $forum_copyright, $software_year, $forum_version; |
| 3710 | 3924 | |
| 3711 | 3925 | // Don't display copyright for things like SSI. |
| 3712 | - if (!isset($forum_version) || !isset($software_year)) |
|
| 3713 | - return; |
|
| 3926 | + if (!isset($forum_version) || !isset($software_year)) { |
|
| 3927 | + return; |
|
| 3928 | + } |
|
| 3714 | 3929 | |
| 3715 | 3930 | // Put in the version... |
| 3716 | 3931 | printf($forum_copyright, $forum_version, $software_year); |
@@ -3728,9 +3943,10 @@ discard block |
||
| 3728 | 3943 | $context['load_time'] = round(microtime(true) - $time_start, 3); |
| 3729 | 3944 | $context['load_queries'] = $db_count; |
| 3730 | 3945 | |
| 3731 | - foreach (array_reverse($context['template_layers']) as $layer) |
|
| 3732 | - loadSubTemplate($layer . '_below', true); |
|
| 3733 | -} |
|
| 3946 | + foreach (array_reverse($context['template_layers']) as $layer) { |
|
| 3947 | + loadSubTemplate($layer . '_below', true); |
|
| 3948 | + } |
|
| 3949 | + } |
|
| 3734 | 3950 | |
| 3735 | 3951 | /** |
| 3736 | 3952 | * Output the Javascript files |
@@ -3764,8 +3980,7 @@ discard block |
||
| 3764 | 3980 | { |
| 3765 | 3981 | echo ' |
| 3766 | 3982 | var ', $key, ';'; |
| 3767 | - } |
|
| 3768 | - else |
|
| 3983 | + } else |
|
| 3769 | 3984 | { |
| 3770 | 3985 | echo ' |
| 3771 | 3986 | var ', $key, ' = ', $value, ';'; |
@@ -3784,27 +3999,29 @@ discard block |
||
| 3784 | 3999 | foreach ($context['javascript_files'] as $id => $js_file) |
| 3785 | 4000 | { |
| 3786 | 4001 | // Last minute call! allow theme authors to disable single files. |
| 3787 | - if (!empty($settings['disable_files']) && in_array($id, $settings['disable_files'])) |
|
| 3788 | - continue; |
|
| 4002 | + if (!empty($settings['disable_files']) && in_array($id, $settings['disable_files'])) { |
|
| 4003 | + continue; |
|
| 4004 | + } |
|
| 3789 | 4005 | |
| 3790 | 4006 | // By default files don't get minimized unless the file explicitly says so! |
| 3791 | 4007 | if (!empty($js_file['options']['minimize']) && !empty($modSettings['minimize_files'])) |
| 3792 | 4008 | { |
| 3793 | - if (!empty($js_file['options']['async'])) |
|
| 3794 | - $toMinify['async'][] = $js_file; |
|
| 3795 | - elseif (!empty($js_file['options']['defer'])) |
|
| 3796 | - $toMinify['defer'][] = $js_file; |
|
| 3797 | - else |
|
| 3798 | - $toMinify['standard'][] = $js_file; |
|
| 4009 | + if (!empty($js_file['options']['async'])) { |
|
| 4010 | + $toMinify['async'][] = $js_file; |
|
| 4011 | + } elseif (!empty($js_file['options']['defer'])) { |
|
| 4012 | + $toMinify['defer'][] = $js_file; |
|
| 4013 | + } else { |
|
| 4014 | + $toMinify['standard'][] = $js_file; |
|
| 4015 | + } |
|
| 3799 | 4016 | |
| 3800 | 4017 | // Grab a random seed. |
| 3801 | - if (!isset($minSeed) && isset($js_file['options']['seed'])) |
|
| 3802 | - $minSeed = $js_file['options']['seed']; |
|
| 3803 | - } |
|
| 3804 | - |
|
| 3805 | - else |
|
| 3806 | - echo ' |
|
| 4018 | + if (!isset($minSeed) && isset($js_file['options']['seed'])) { |
|
| 4019 | + $minSeed = $js_file['options']['seed']; |
|
| 4020 | + } |
|
| 4021 | + } else { |
|
| 4022 | + echo ' |
|
| 3807 | 4023 | <script src="', $js_file['fileUrl'], '"', !empty($js_file['options']['async']) ? ' async' : '', !empty($js_file['options']['defer']) ? ' defer' : '', '></script>'; |
| 4024 | + } |
|
| 3808 | 4025 | } |
| 3809 | 4026 | |
| 3810 | 4027 | foreach ($toMinify as $js_files) |
@@ -3815,9 +4032,10 @@ discard block |
||
| 3815 | 4032 | |
| 3816 | 4033 | $minSuccessful = array_keys($result) === array('smf_minified'); |
| 3817 | 4034 | |
| 3818 | - foreach ($result as $minFile) |
|
| 3819 | - echo ' |
|
| 4035 | + foreach ($result as $minFile) { |
|
| 4036 | + echo ' |
|
| 3820 | 4037 | <script src="', $minFile['fileUrl'], $minSuccessful && isset($minSeed) ? $minSeed : '', '"', !empty($minFile['options']['async']) ? ' async' : '', !empty($minFile['options']['defer']) ? ' defer' : '', '></script>'; |
| 4038 | + } |
|
| 3821 | 4039 | } |
| 3822 | 4040 | } |
| 3823 | 4041 | } |
@@ -3831,8 +4049,9 @@ discard block |
||
| 3831 | 4049 | <script> |
| 3832 | 4050 | window.addEventListener("DOMContentLoaded", function() {'; |
| 3833 | 4051 | |
| 3834 | - foreach ($context['javascript_inline']['defer'] as $js_code) |
|
| 3835 | - echo $js_code; |
|
| 4052 | + foreach ($context['javascript_inline']['defer'] as $js_code) { |
|
| 4053 | + echo $js_code; |
|
| 4054 | + } |
|
| 3836 | 4055 | |
| 3837 | 4056 | echo ' |
| 3838 | 4057 | }); |
@@ -3844,8 +4063,9 @@ discard block |
||
| 3844 | 4063 | echo ' |
| 3845 | 4064 | <script>'; |
| 3846 | 4065 | |
| 3847 | - foreach ($context['javascript_inline']['standard'] as $js_code) |
|
| 3848 | - echo $js_code; |
|
| 4066 | + foreach ($context['javascript_inline']['standard'] as $js_code) { |
|
| 4067 | + echo $js_code; |
|
| 4068 | + } |
|
| 3849 | 4069 | |
| 3850 | 4070 | echo ' |
| 3851 | 4071 | </script>'; |
@@ -3873,23 +4093,26 @@ discard block |
||
| 3873 | 4093 | foreach ($context['css_files'] as $id => $file) |
| 3874 | 4094 | { |
| 3875 | 4095 | // Last minute call! allow theme authors to disable single files. |
| 3876 | - if (!empty($settings['disable_files']) && in_array($id, $settings['disable_files'])) |
|
| 3877 | - continue; |
|
| 4096 | + if (!empty($settings['disable_files']) && in_array($id, $settings['disable_files'])) { |
|
| 4097 | + continue; |
|
| 4098 | + } |
|
| 3878 | 4099 | |
| 3879 | 4100 | // Files are minimized unless they explicitly opt out. |
| 3880 | - if (!isset($file['options']['minimize'])) |
|
| 3881 | - $file['options']['minimize'] = true; |
|
| 4101 | + if (!isset($file['options']['minimize'])) { |
|
| 4102 | + $file['options']['minimize'] = true; |
|
| 4103 | + } |
|
| 3882 | 4104 | |
| 3883 | 4105 | if (!empty($file['options']['minimize']) && !empty($modSettings['minimize_files'])) |
| 3884 | 4106 | { |
| 3885 | 4107 | $toMinify[] = $file; |
| 3886 | 4108 | |
| 3887 | 4109 | // Grab a random seed. |
| 3888 | - if (!isset($minSeed) && isset($file['options']['seed'])) |
|
| 3889 | - $minSeed = $file['options']['seed']; |
|
| 4110 | + if (!isset($minSeed) && isset($file['options']['seed'])) { |
|
| 4111 | + $minSeed = $file['options']['seed']; |
|
| 4112 | + } |
|
| 4113 | + } else { |
|
| 4114 | + $normal[] = $file['fileUrl']; |
|
| 3890 | 4115 | } |
| 3891 | - else |
|
| 3892 | - $normal[] = $file['fileUrl']; |
|
| 3893 | 4116 | } |
| 3894 | 4117 | |
| 3895 | 4118 | if (!empty($toMinify)) |
@@ -3898,23 +4121,26 @@ discard block |
||
| 3898 | 4121 | |
| 3899 | 4122 | $minSuccessful = array_keys($result) === array('smf_minified'); |
| 3900 | 4123 | |
| 3901 | - foreach ($result as $minFile) |
|
| 3902 | - echo ' |
|
| 4124 | + foreach ($result as $minFile) { |
|
| 4125 | + echo ' |
|
| 3903 | 4126 | <link rel="stylesheet" href="', $minFile['fileUrl'], $minSuccessful && isset($minSeed) ? $minSeed : '', '">'; |
| 4127 | + } |
|
| 3904 | 4128 | } |
| 3905 | 4129 | |
| 3906 | 4130 | // Print the rest after the minified files. |
| 3907 | - if (!empty($normal)) |
|
| 3908 | - foreach ($normal as $nf) |
|
| 4131 | + if (!empty($normal)) { |
|
| 4132 | + foreach ($normal as $nf) |
|
| 3909 | 4133 | echo ' |
| 3910 | 4134 | <link rel="stylesheet" href="', $nf ,'">'; |
| 4135 | + } |
|
| 3911 | 4136 | |
| 3912 | 4137 | if ($db_show_debug === true) |
| 3913 | 4138 | { |
| 3914 | 4139 | // Try to keep only what's useful. |
| 3915 | 4140 | $repl = array($boardurl . '/Themes/' => '', $boardurl . '/' => ''); |
| 3916 | - foreach ($context['css_files'] as $file) |
|
| 3917 | - $context['debug']['sheets'][] = strtr($file['fileName'], $repl); |
|
| 4141 | + foreach ($context['css_files'] as $file) { |
|
| 4142 | + $context['debug']['sheets'][] = strtr($file['fileName'], $repl); |
|
| 4143 | + } |
|
| 3918 | 4144 | } |
| 3919 | 4145 | |
| 3920 | 4146 | if (!empty($context['css_header'])) |
@@ -3922,9 +4148,10 @@ discard block |
||
| 3922 | 4148 | echo ' |
| 3923 | 4149 | <style>'; |
| 3924 | 4150 | |
| 3925 | - foreach ($context['css_header'] as $css) |
|
| 3926 | - echo $css .' |
|
| 4151 | + foreach ($context['css_header'] as $css) { |
|
| 4152 | + echo $css .' |
|
| 3927 | 4153 | '; |
| 4154 | + } |
|
| 3928 | 4155 | |
| 3929 | 4156 | echo' |
| 3930 | 4157 | </style>'; |
@@ -3947,8 +4174,9 @@ discard block |
||
| 3947 | 4174 | $type = !empty($type) && in_array($type, $types) ? $type : false; |
| 3948 | 4175 | $data = is_array($data) ? $data : array(); |
| 3949 | 4176 | |
| 3950 | - if (empty($type) || empty($data)) |
|
| 3951 | - return $data; |
|
| 4177 | + if (empty($type) || empty($data)) { |
|
| 4178 | + return $data; |
|
| 4179 | + } |
|
| 3952 | 4180 | |
| 3953 | 4181 | // Different pages include different files, so we use a hash to label the different combinations |
| 3954 | 4182 | $hash = md5(implode(' ', array_map(function($file) { return $file['filePath'] . (int) @filesize($file['filePath']) . (int) @filemtime($file['filePath']); }, $data))); |
@@ -3957,13 +4185,14 @@ discard block |
||
| 3957 | 4185 | list($toCache, $async, $defer) = array_pad((array) cache_get_data('minimized_' . $settings['theme_id'] . '_' . $type . '_' . $hash, 86400), 3, null); |
| 3958 | 4186 | |
| 3959 | 4187 | // Already done? |
| 3960 | - if (!empty($toCache)) |
|
| 3961 | - return array('smf_minified' => array( |
|
| 4188 | + if (!empty($toCache)) { |
|
| 4189 | + return array('smf_minified' => array( |
|
| 3962 | 4190 | 'fileUrl' => $settings['theme_url'] . '/' . ($type == 'css' ? 'css' : 'scripts') . '/' . basename($toCache), |
| 3963 | 4191 | 'filePath' => $toCache, |
| 3964 | 4192 | 'fileName' => basename($toCache), |
| 3965 | 4193 | 'options' => array('async' => !empty($async), 'defer' => !empty($defer)), |
| 3966 | 4194 | )); |
| 4195 | + } |
|
| 3967 | 4196 | |
| 3968 | 4197 | |
| 3969 | 4198 | // No namespaces, sorry! |
@@ -3993,9 +4222,9 @@ discard block |
||
| 3993 | 4222 | |
| 3994 | 4223 | foreach ($data as $id => $file) |
| 3995 | 4224 | { |
| 3996 | - if (empty($file['filePath'])) |
|
| 3997 | - $toAdd = false; |
|
| 3998 | - else |
|
| 4225 | + if (empty($file['filePath'])) { |
|
| 4226 | + $toAdd = false; |
|
| 4227 | + } else |
|
| 3999 | 4228 | { |
| 4000 | 4229 | $seed = isset($file['options']['seed']) ? $file['options']['seed'] : ''; |
| 4001 | 4230 | $tempFile = str_replace($seed, '', $file['filePath']); |
@@ -4003,12 +4232,14 @@ discard block |
||
| 4003 | 4232 | } |
| 4004 | 4233 | |
| 4005 | 4234 | // A minified script should only be loaded asynchronously if all its components wanted to be. |
| 4006 | - if (empty($file['options']['async'])) |
|
| 4007 | - $async = false; |
|
| 4235 | + if (empty($file['options']['async'])) { |
|
| 4236 | + $async = false; |
|
| 4237 | + } |
|
| 4008 | 4238 | |
| 4009 | 4239 | // A minified script should only be deferred if all its components wanted to be. |
| 4010 | - if (empty($file['options']['defer'])) |
|
| 4011 | - $defer = false; |
|
| 4240 | + if (empty($file['options']['defer'])) { |
|
| 4241 | + $defer = false; |
|
| 4242 | + } |
|
| 4012 | 4243 | |
| 4013 | 4244 | // The file couldn't be located so it won't be added. Log this error. |
| 4014 | 4245 | if (empty($toAdd)) |
@@ -4074,12 +4305,14 @@ discard block |
||
| 4074 | 4305 | foreach (glob(rtrim($theme['dir'], '/') . '/' . ($type == 'css' ? 'css' : 'scripts') . '/minified*.' . $type) as $filename) |
| 4075 | 4306 | { |
| 4076 | 4307 | // Remove the cache entry |
| 4077 | - if (preg_match('~([a-zA-Z0-9]+)\.' . $type . '$~', $filename, $matches)) |
|
| 4078 | - cache_put_data('minimized_' . $theme['id'] . '_' . $type . '_' . $matches[1], null); |
|
| 4308 | + if (preg_match('~([a-zA-Z0-9]+)\.' . $type . '$~', $filename, $matches)) { |
|
| 4309 | + cache_put_data('minimized_' . $theme['id'] . '_' . $type . '_' . $matches[1], null); |
|
| 4310 | + } |
|
| 4079 | 4311 | |
| 4080 | 4312 | // Try to delete the file. Add it to our error list if it fails. |
| 4081 | - if (!@unlink($filename)) |
|
| 4082 | - $not_deleted[] = $filename; |
|
| 4313 | + if (!@unlink($filename)) { |
|
| 4314 | + $not_deleted[] = $filename; |
|
| 4315 | + } |
|
| 4083 | 4316 | } |
| 4084 | 4317 | } |
| 4085 | 4318 | } |
@@ -4111,8 +4344,9 @@ discard block |
||
| 4111 | 4344 | global $modSettings, $smcFunc; |
| 4112 | 4345 | |
| 4113 | 4346 | // Just make up a nice hash... |
| 4114 | - if ($new) |
|
| 4115 | - return sha1(md5($filename . time()) . mt_rand()); |
|
| 4347 | + if ($new) { |
|
| 4348 | + return sha1(md5($filename . time()) . mt_rand()); |
|
| 4349 | + } |
|
| 4116 | 4350 | |
| 4117 | 4351 | // Just make sure that attachment id is only a int |
| 4118 | 4352 | $attachment_id = (int) $attachment_id; |
@@ -4129,23 +4363,25 @@ discard block |
||
| 4129 | 4363 | 'id_attach' => $attachment_id, |
| 4130 | 4364 | )); |
| 4131 | 4365 | |
| 4132 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
| 4133 | - return false; |
|
| 4366 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
| 4367 | + return false; |
|
| 4368 | + } |
|
| 4134 | 4369 | |
| 4135 | 4370 | list ($file_hash) = $smcFunc['db_fetch_row']($request); |
| 4136 | 4371 | $smcFunc['db_free_result']($request); |
| 4137 | 4372 | } |
| 4138 | 4373 | |
| 4139 | 4374 | // Still no hash? mmm... |
| 4140 | - if (empty($file_hash)) |
|
| 4141 | - $file_hash = sha1(md5($filename . time()) . mt_rand()); |
|
| 4375 | + if (empty($file_hash)) { |
|
| 4376 | + $file_hash = sha1(md5($filename . time()) . mt_rand()); |
|
| 4377 | + } |
|
| 4142 | 4378 | |
| 4143 | 4379 | // Are we using multiple directories? |
| 4144 | - if (is_array($modSettings['attachmentUploadDir'])) |
|
| 4145 | - $path = $modSettings['attachmentUploadDir'][$dir]; |
|
| 4146 | - |
|
| 4147 | - else |
|
| 4148 | - $path = $modSettings['attachmentUploadDir']; |
|
| 4380 | + if (is_array($modSettings['attachmentUploadDir'])) { |
|
| 4381 | + $path = $modSettings['attachmentUploadDir'][$dir]; |
|
| 4382 | + } else { |
|
| 4383 | + $path = $modSettings['attachmentUploadDir']; |
|
| 4384 | + } |
|
| 4149 | 4385 | |
| 4150 | 4386 | return $path . '/' . $attachment_id . '_' . $file_hash .'.dat'; |
| 4151 | 4387 | } |
@@ -4160,8 +4396,9 @@ discard block |
||
| 4160 | 4396 | function ip2range($fullip) |
| 4161 | 4397 | { |
| 4162 | 4398 | // Pretend that 'unknown' is 255.255.255.255. (since that can't be an IP anyway.) |
| 4163 | - if ($fullip == 'unknown') |
|
| 4164 | - $fullip = '255.255.255.255'; |
|
| 4399 | + if ($fullip == 'unknown') { |
|
| 4400 | + $fullip = '255.255.255.255'; |
|
| 4401 | + } |
|
| 4165 | 4402 | |
| 4166 | 4403 | $ip_parts = explode('-', $fullip); |
| 4167 | 4404 | $ip_array = array(); |
@@ -4185,10 +4422,11 @@ discard block |
||
| 4185 | 4422 | $ip_array['low'] = $ip_parts[0]; |
| 4186 | 4423 | $ip_array['high'] = $ip_parts[1]; |
| 4187 | 4424 | return $ip_array; |
| 4188 | - } |
|
| 4189 | - elseif (count($ip_parts) == 2) // if ip 22.22.*-22.22.* |
|
| 4425 | + } elseif (count($ip_parts) == 2) { |
|
| 4426 | + // if ip 22.22.*-22.22.* |
|
| 4190 | 4427 | { |
| 4191 | 4428 | $valid_low = isValidIP($ip_parts[0]); |
| 4429 | + } |
|
| 4192 | 4430 | $valid_high = isValidIP($ip_parts[1]); |
| 4193 | 4431 | $count = 0; |
| 4194 | 4432 | $mode = (preg_match('/:/',$ip_parts[0]) > 0 ? ':' : '.'); |
@@ -4203,7 +4441,9 @@ discard block |
||
| 4203 | 4441 | $ip_parts[0] .= $mode . $min; |
| 4204 | 4442 | $valid_low = isValidIP($ip_parts[0]); |
| 4205 | 4443 | $count++; |
| 4206 | - if ($count > 9) break; |
|
| 4444 | + if ($count > 9) { |
|
| 4445 | + break; |
|
| 4446 | + } |
|
| 4207 | 4447 | } |
| 4208 | 4448 | } |
| 4209 | 4449 | |
@@ -4217,7 +4457,9 @@ discard block |
||
| 4217 | 4457 | $ip_parts[1] .= $mode . $max; |
| 4218 | 4458 | $valid_high = isValidIP($ip_parts[1]); |
| 4219 | 4459 | $count++; |
| 4220 | - if ($count > 9) break; |
|
| 4460 | + if ($count > 9) { |
|
| 4461 | + break; |
|
| 4462 | + } |
|
| 4221 | 4463 | } |
| 4222 | 4464 | } |
| 4223 | 4465 | |
@@ -4241,46 +4483,54 @@ discard block |
||
| 4241 | 4483 | { |
| 4242 | 4484 | global $modSettings; |
| 4243 | 4485 | |
| 4244 | - if (($host = cache_get_data('hostlookup-' . $ip, 600)) !== null) |
|
| 4245 | - return $host; |
|
| 4486 | + if (($host = cache_get_data('hostlookup-' . $ip, 600)) !== null) { |
|
| 4487 | + return $host; |
|
| 4488 | + } |
|
| 4246 | 4489 | $t = microtime(); |
| 4247 | 4490 | |
| 4248 | 4491 | // Try the Linux host command, perhaps? |
| 4249 | 4492 | if (!isset($host) && (strpos(strtolower(PHP_OS), 'win') === false || strpos(strtolower(PHP_OS), 'darwin') !== false) && mt_rand(0, 1) == 1) |
| 4250 | 4493 | { |
| 4251 | - if (!isset($modSettings['host_to_dis'])) |
|
| 4252 | - $test = @shell_exec('host -W 1 ' . @escapeshellarg($ip)); |
|
| 4253 | - else |
|
| 4254 | - $test = @shell_exec('host ' . @escapeshellarg($ip)); |
|
| 4494 | + if (!isset($modSettings['host_to_dis'])) { |
|
| 4495 | + $test = @shell_exec('host -W 1 ' . @escapeshellarg($ip)); |
|
| 4496 | + } else { |
|
| 4497 | + $test = @shell_exec('host ' . @escapeshellarg($ip)); |
|
| 4498 | + } |
|
| 4255 | 4499 | |
| 4256 | 4500 | // Did host say it didn't find anything? |
| 4257 | - if (strpos($test, 'not found') !== false) |
|
| 4258 | - $host = ''; |
|
| 4501 | + if (strpos($test, 'not found') !== false) { |
|
| 4502 | + $host = ''; |
|
| 4503 | + } |
|
| 4259 | 4504 | // Invalid server option? |
| 4260 | - elseif ((strpos($test, 'invalid option') || strpos($test, 'Invalid query name 1')) && !isset($modSettings['host_to_dis'])) |
|
| 4261 | - updateSettings(array('host_to_dis' => 1)); |
|
| 4505 | + elseif ((strpos($test, 'invalid option') || strpos($test, 'Invalid query name 1')) && !isset($modSettings['host_to_dis'])) { |
|
| 4506 | + updateSettings(array('host_to_dis' => 1)); |
|
| 4507 | + } |
|
| 4262 | 4508 | // Maybe it found something, after all? |
| 4263 | - elseif (preg_match('~\s([^\s]+?)\.\s~', $test, $match) == 1) |
|
| 4264 | - $host = $match[1]; |
|
| 4509 | + elseif (preg_match('~\s([^\s]+?)\.\s~', $test, $match) == 1) { |
|
| 4510 | + $host = $match[1]; |
|
| 4511 | + } |
|
| 4265 | 4512 | } |
| 4266 | 4513 | |
| 4267 | 4514 | // This is nslookup; usually only Windows, but possibly some Unix? |
| 4268 | 4515 | if (!isset($host) && stripos(PHP_OS, 'win') !== false && strpos(strtolower(PHP_OS), 'darwin') === false && mt_rand(0, 1) == 1) |
| 4269 | 4516 | { |
| 4270 | 4517 | $test = @shell_exec('nslookup -timeout=1 ' . @escapeshellarg($ip)); |
| 4271 | - if (strpos($test, 'Non-existent domain') !== false) |
|
| 4272 | - $host = ''; |
|
| 4273 | - elseif (preg_match('~Name:\s+([^\s]+)~', $test, $match) == 1) |
|
| 4274 | - $host = $match[1]; |
|
| 4518 | + if (strpos($test, 'Non-existent domain') !== false) { |
|
| 4519 | + $host = ''; |
|
| 4520 | + } elseif (preg_match('~Name:\s+([^\s]+)~', $test, $match) == 1) { |
|
| 4521 | + $host = $match[1]; |
|
| 4522 | + } |
|
| 4275 | 4523 | } |
| 4276 | 4524 | |
| 4277 | 4525 | // This is the last try :/. |
| 4278 | - if (!isset($host) || $host === false) |
|
| 4279 | - $host = @gethostbyaddr($ip); |
|
| 4526 | + if (!isset($host) || $host === false) { |
|
| 4527 | + $host = @gethostbyaddr($ip); |
|
| 4528 | + } |
|
| 4280 | 4529 | |
| 4281 | 4530 | // It took a long time, so let's cache it! |
| 4282 | - if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $t)) > 0.5) |
|
| 4283 | - cache_put_data('hostlookup-' . $ip, $host, 600); |
|
| 4531 | + if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $t)) > 0.5) { |
|
| 4532 | + cache_put_data('hostlookup-' . $ip, $host, 600); |
|
| 4533 | + } |
|
| 4284 | 4534 | |
| 4285 | 4535 | return $host; |
| 4286 | 4536 | } |
@@ -4316,20 +4566,21 @@ discard block |
||
| 4316 | 4566 | { |
| 4317 | 4567 | $encrypted = substr(crypt($word, 'uk'), 2, $max_chars); |
| 4318 | 4568 | $total = 0; |
| 4319 | - for ($i = 0; $i < $max_chars; $i++) |
|
| 4320 | - $total += $possible_chars[ord($encrypted{$i})] * pow(63, $i); |
|
| 4569 | + for ($i = 0; $i < $max_chars; $i++) { |
|
| 4570 | + $total += $possible_chars[ord($encrypted{$i})] * pow(63, $i); |
|
| 4571 | + } |
|
| 4321 | 4572 | $returned_ints[] = $max_chars == 4 ? min($total, 16777215) : $total; |
| 4322 | 4573 | } |
| 4323 | 4574 | } |
| 4324 | 4575 | return array_unique($returned_ints); |
| 4325 | - } |
|
| 4326 | - else |
|
| 4576 | + } else |
|
| 4327 | 4577 | { |
| 4328 | 4578 | // Trim characters before and after and add slashes for database insertion. |
| 4329 | 4579 | $returned_words = array(); |
| 4330 | - foreach ($words as $word) |
|
| 4331 | - if (($word = trim($word, '-_\'')) !== '') |
|
| 4580 | + foreach ($words as $word) { |
|
| 4581 | + if (($word = trim($word, '-_\'')) !== '') |
|
| 4332 | 4582 | $returned_words[] = $max_chars === null ? $word : substr($word, 0, $max_chars); |
| 4583 | + } |
|
| 4333 | 4584 | |
| 4334 | 4585 | // Filter out all words that occur more than once. |
| 4335 | 4586 | return array_unique($returned_words); |
@@ -4351,16 +4602,18 @@ discard block |
||
| 4351 | 4602 | global $settings, $txt; |
| 4352 | 4603 | |
| 4353 | 4604 | // Does the current loaded theme have this and we are not forcing the usage of this function? |
| 4354 | - if (function_exists('template_create_button') && !$force_use) |
|
| 4355 | - return template_create_button($name, $alt, $label = '', $custom = ''); |
|
| 4605 | + if (function_exists('template_create_button') && !$force_use) { |
|
| 4606 | + return template_create_button($name, $alt, $label = '', $custom = ''); |
|
| 4607 | + } |
|
| 4356 | 4608 | |
| 4357 | - if (!$settings['use_image_buttons']) |
|
| 4358 | - return $txt[$alt]; |
|
| 4359 | - elseif (!empty($settings['use_buttons'])) |
|
| 4360 | - return '<span class="generic_icons ' . $name . '" alt="' . $txt[$alt] . '"></span>' . ($label != '' ? ' <strong>' . $txt[$label] . '</strong>' : ''); |
|
| 4361 | - else |
|
| 4362 | - return '<img src="' . $settings['lang_images_url'] . '/' . $name . '" alt="' . $txt[$alt] . '" ' . $custom . '>'; |
|
| 4363 | -} |
|
| 4609 | + if (!$settings['use_image_buttons']) { |
|
| 4610 | + return $txt[$alt]; |
|
| 4611 | + } elseif (!empty($settings['use_buttons'])) { |
|
| 4612 | + return '<span class="generic_icons ' . $name . '" alt="' . $txt[$alt] . '"></span>' . ($label != '' ? ' <strong>' . $txt[$label] . '</strong>' : ''); |
|
| 4613 | + } else { |
|
| 4614 | + return '<img src="' . $settings['lang_images_url'] . '/' . $name . '" alt="' . $txt[$alt] . '" ' . $custom . '>'; |
|
| 4615 | + } |
|
| 4616 | + } |
|
| 4364 | 4617 | |
| 4365 | 4618 | /** |
| 4366 | 4619 | * Sets up all of the top menu buttons |
@@ -4403,9 +4656,10 @@ discard block |
||
| 4403 | 4656 | var user_menus = new smc_PopupMenu(); |
| 4404 | 4657 | user_menus.add("profile", "' . $scripturl . '?action=profile;area=popup"); |
| 4405 | 4658 | user_menus.add("alerts", "' . $scripturl . '?action=profile;area=alerts_popup;u='. $context['user']['id'] .'");', true); |
| 4406 | - if ($context['allow_pm']) |
|
| 4407 | - addInlineJavaScript(' |
|
| 4659 | + if ($context['allow_pm']) { |
|
| 4660 | + addInlineJavaScript(' |
|
| 4408 | 4661 | user_menus.add("pm", "' . $scripturl . '?action=pm;sa=popup");', true); |
| 4662 | + } |
|
| 4409 | 4663 | |
| 4410 | 4664 | if (!empty($modSettings['enable_ajax_alerts'])) |
| 4411 | 4665 | { |
@@ -4565,88 +4819,96 @@ discard block |
||
| 4565 | 4819 | |
| 4566 | 4820 | // Now we put the buttons in the context so the theme can use them. |
| 4567 | 4821 | $menu_buttons = array(); |
| 4568 | - foreach ($buttons as $act => $button) |
|
| 4569 | - if (!empty($button['show'])) |
|
| 4822 | + foreach ($buttons as $act => $button) { |
|
| 4823 | + if (!empty($button['show'])) |
|
| 4570 | 4824 | { |
| 4571 | 4825 | $button['active_button'] = false; |
| 4826 | + } |
|
| 4572 | 4827 | |
| 4573 | 4828 | // This button needs some action. |
| 4574 | - if (isset($button['action_hook'])) |
|
| 4575 | - $needs_action_hook = true; |
|
| 4829 | + if (isset($button['action_hook'])) { |
|
| 4830 | + $needs_action_hook = true; |
|
| 4831 | + } |
|
| 4576 | 4832 | |
| 4577 | 4833 | // Make sure the last button truly is the last button. |
| 4578 | 4834 | if (!empty($button['is_last'])) |
| 4579 | 4835 | { |
| 4580 | - if (isset($last_button)) |
|
| 4581 | - unset($menu_buttons[$last_button]['is_last']); |
|
| 4836 | + if (isset($last_button)) { |
|
| 4837 | + unset($menu_buttons[$last_button]['is_last']); |
|
| 4838 | + } |
|
| 4582 | 4839 | $last_button = $act; |
| 4583 | 4840 | } |
| 4584 | 4841 | |
| 4585 | 4842 | // Go through the sub buttons if there are any. |
| 4586 | - if (!empty($button['sub_buttons'])) |
|
| 4587 | - foreach ($button['sub_buttons'] as $key => $subbutton) |
|
| 4843 | + if (!empty($button['sub_buttons'])) { |
|
| 4844 | + foreach ($button['sub_buttons'] as $key => $subbutton) |
|
| 4588 | 4845 | { |
| 4589 | 4846 | if (empty($subbutton['show'])) |
| 4590 | 4847 | unset($button['sub_buttons'][$key]); |
| 4848 | + } |
|
| 4591 | 4849 | |
| 4592 | 4850 | // 2nd level sub buttons next... |
| 4593 | 4851 | if (!empty($subbutton['sub_buttons'])) |
| 4594 | 4852 | { |
| 4595 | 4853 | foreach ($subbutton['sub_buttons'] as $key2 => $sub_button2) |
| 4596 | 4854 | { |
| 4597 | - if (empty($sub_button2['show'])) |
|
| 4598 | - unset($button['sub_buttons'][$key]['sub_buttons'][$key2]); |
|
| 4855 | + if (empty($sub_button2['show'])) { |
|
| 4856 | + unset($button['sub_buttons'][$key]['sub_buttons'][$key2]); |
|
| 4857 | + } |
|
| 4599 | 4858 | } |
| 4600 | 4859 | } |
| 4601 | 4860 | } |
| 4602 | 4861 | |
| 4603 | 4862 | // Does this button have its own icon? |
| 4604 | - if (isset($button['icon']) && file_exists($settings['theme_dir'] . '/images/' . $button['icon'])) |
|
| 4605 | - $button['icon'] = '<img src="' . $settings['images_url'] . '/' . $button['icon'] . '" alt="">'; |
|
| 4606 | - elseif (isset($button['icon']) && file_exists($settings['default_theme_dir'] . '/images/' . $button['icon'])) |
|
| 4607 | - $button['icon'] = '<img src="' . $settings['default_images_url'] . '/' . $button['icon'] . '" alt="">'; |
|
| 4608 | - elseif (isset($button['icon'])) |
|
| 4609 | - $button['icon'] = '<span class="generic_icons ' . $button['icon'] . '"></span>'; |
|
| 4610 | - else |
|
| 4611 | - $button['icon'] = '<span class="generic_icons ' . $act . '"></span>'; |
|
| 4863 | + if (isset($button['icon']) && file_exists($settings['theme_dir'] . '/images/' . $button['icon'])) { |
|
| 4864 | + $button['icon'] = '<img src="' . $settings['images_url'] . '/' . $button['icon'] . '" alt="">'; |
|
| 4865 | + } elseif (isset($button['icon']) && file_exists($settings['default_theme_dir'] . '/images/' . $button['icon'])) { |
|
| 4866 | + $button['icon'] = '<img src="' . $settings['default_images_url'] . '/' . $button['icon'] . '" alt="">'; |
|
| 4867 | + } elseif (isset($button['icon'])) { |
|
| 4868 | + $button['icon'] = '<span class="generic_icons ' . $button['icon'] . '"></span>'; |
|
| 4869 | + } else { |
|
| 4870 | + $button['icon'] = '<span class="generic_icons ' . $act . '"></span>'; |
|
| 4871 | + } |
|
| 4612 | 4872 | |
| 4613 | 4873 | $menu_buttons[$act] = $button; |
| 4614 | 4874 | } |
| 4615 | 4875 | |
| 4616 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
| 4617 | - cache_put_data('menu_buttons-' . implode('_', $user_info['groups']) . '-' . $user_info['language'], $menu_buttons, $cacheTime); |
|
| 4876 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
| 4877 | + cache_put_data('menu_buttons-' . implode('_', $user_info['groups']) . '-' . $user_info['language'], $menu_buttons, $cacheTime); |
|
| 4878 | + } |
|
| 4618 | 4879 | } |
| 4619 | 4880 | |
| 4620 | 4881 | $context['menu_buttons'] = $menu_buttons; |
| 4621 | 4882 | |
| 4622 | 4883 | // Logging out requires the session id in the url. |
| 4623 | - if (isset($context['menu_buttons']['logout'])) |
|
| 4624 | - $context['menu_buttons']['logout']['href'] = sprintf($context['menu_buttons']['logout']['href'], $context['session_var'], $context['session_id']); |
|
| 4884 | + if (isset($context['menu_buttons']['logout'])) { |
|
| 4885 | + $context['menu_buttons']['logout']['href'] = sprintf($context['menu_buttons']['logout']['href'], $context['session_var'], $context['session_id']); |
|
| 4886 | + } |
|
| 4625 | 4887 | |
| 4626 | 4888 | // Figure out which action we are doing so we can set the active tab. |
| 4627 | 4889 | // Default to home. |
| 4628 | 4890 | $current_action = 'home'; |
| 4629 | 4891 | |
| 4630 | - if (isset($context['menu_buttons'][$context['current_action']])) |
|
| 4631 | - $current_action = $context['current_action']; |
|
| 4632 | - elseif ($context['current_action'] == 'search2') |
|
| 4633 | - $current_action = 'search'; |
|
| 4634 | - elseif ($context['current_action'] == 'theme') |
|
| 4635 | - $current_action = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'pick' ? 'profile' : 'admin'; |
|
| 4636 | - elseif ($context['current_action'] == 'register2') |
|
| 4637 | - $current_action = 'register'; |
|
| 4638 | - elseif ($context['current_action'] == 'login2' || ($user_info['is_guest'] && $context['current_action'] == 'reminder')) |
|
| 4639 | - $current_action = 'login'; |
|
| 4640 | - elseif ($context['current_action'] == 'groups' && $context['allow_moderation_center']) |
|
| 4641 | - $current_action = 'moderate'; |
|
| 4892 | + if (isset($context['menu_buttons'][$context['current_action']])) { |
|
| 4893 | + $current_action = $context['current_action']; |
|
| 4894 | + } elseif ($context['current_action'] == 'search2') { |
|
| 4895 | + $current_action = 'search'; |
|
| 4896 | + } elseif ($context['current_action'] == 'theme') { |
|
| 4897 | + $current_action = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'pick' ? 'profile' : 'admin'; |
|
| 4898 | + } elseif ($context['current_action'] == 'register2') { |
|
| 4899 | + $current_action = 'register'; |
|
| 4900 | + } elseif ($context['current_action'] == 'login2' || ($user_info['is_guest'] && $context['current_action'] == 'reminder')) { |
|
| 4901 | + $current_action = 'login'; |
|
| 4902 | + } elseif ($context['current_action'] == 'groups' && $context['allow_moderation_center']) { |
|
| 4903 | + $current_action = 'moderate'; |
|
| 4904 | + } |
|
| 4642 | 4905 | |
| 4643 | 4906 | // There are certain exceptions to the above where we don't want anything on the menu highlighted. |
| 4644 | 4907 | if ($context['current_action'] == 'profile' && !empty($context['user']['is_owner'])) |
| 4645 | 4908 | { |
| 4646 | 4909 | $current_action = !empty($_GET['area']) && $_GET['area'] == 'showalerts' ? 'self_alerts' : 'self_profile'; |
| 4647 | 4910 | $context[$current_action] = true; |
| 4648 | - } |
|
| 4649 | - elseif ($context['current_action'] == 'pm') |
|
| 4911 | + } elseif ($context['current_action'] == 'pm') |
|
| 4650 | 4912 | { |
| 4651 | 4913 | $current_action = 'self_pm'; |
| 4652 | 4914 | $context['self_pm'] = true; |
@@ -4703,12 +4965,14 @@ discard block |
||
| 4703 | 4965 | } |
| 4704 | 4966 | |
| 4705 | 4967 | // Not all actions are simple. |
| 4706 | - if (!empty($needs_action_hook)) |
|
| 4707 | - call_integration_hook('integrate_current_action', array(&$current_action)); |
|
| 4968 | + if (!empty($needs_action_hook)) { |
|
| 4969 | + call_integration_hook('integrate_current_action', array(&$current_action)); |
|
| 4970 | + } |
|
| 4708 | 4971 | |
| 4709 | - if (isset($context['menu_buttons'][$current_action])) |
|
| 4710 | - $context['menu_buttons'][$current_action]['active_button'] = true; |
|
| 4711 | -} |
|
| 4972 | + if (isset($context['menu_buttons'][$current_action])) { |
|
| 4973 | + $context['menu_buttons'][$current_action]['active_button'] = true; |
|
| 4974 | + } |
|
| 4975 | + } |
|
| 4712 | 4976 | |
| 4713 | 4977 | /** |
| 4714 | 4978 | * Generate a random seed and ensure it's stored in settings. |
@@ -4732,30 +4996,35 @@ discard block |
||
| 4732 | 4996 | global $modSettings, $settings, $boarddir, $sourcedir, $db_show_debug; |
| 4733 | 4997 | global $context, $txt; |
| 4734 | 4998 | |
| 4735 | - if ($db_show_debug === true) |
|
| 4736 | - $context['debug']['hooks'][] = $hook; |
|
| 4999 | + if ($db_show_debug === true) { |
|
| 5000 | + $context['debug']['hooks'][] = $hook; |
|
| 5001 | + } |
|
| 4737 | 5002 | |
| 4738 | 5003 | // Need to have some control. |
| 4739 | - if (!isset($context['instances'])) |
|
| 4740 | - $context['instances'] = array(); |
|
| 5004 | + if (!isset($context['instances'])) { |
|
| 5005 | + $context['instances'] = array(); |
|
| 5006 | + } |
|
| 4741 | 5007 | |
| 4742 | 5008 | $results = array(); |
| 4743 | - if (empty($modSettings[$hook])) |
|
| 4744 | - return $results; |
|
| 5009 | + if (empty($modSettings[$hook])) { |
|
| 5010 | + return $results; |
|
| 5011 | + } |
|
| 4745 | 5012 | |
| 4746 | 5013 | $functions = explode(',', $modSettings[$hook]); |
| 4747 | 5014 | // Loop through each function. |
| 4748 | 5015 | foreach ($functions as $function) |
| 4749 | 5016 | { |
| 4750 | 5017 | // Hook has been marked as "disabled". Skip it! |
| 4751 | - if (strpos($function, '!') !== false) |
|
| 4752 | - continue; |
|
| 5018 | + if (strpos($function, '!') !== false) { |
|
| 5019 | + continue; |
|
| 5020 | + } |
|
| 4753 | 5021 | |
| 4754 | 5022 | $call = call_helper($function, true); |
| 4755 | 5023 | |
| 4756 | 5024 | // Is it valid? |
| 4757 | - if (!empty($call)) |
|
| 4758 | - $results[$function] = call_user_func_array($call, $parameters); |
|
| 5025 | + if (!empty($call)) { |
|
| 5026 | + $results[$function] = call_user_func_array($call, $parameters); |
|
| 5027 | + } |
|
| 4759 | 5028 | |
| 4760 | 5029 | // Whatever it was suppose to call, it failed :( |
| 4761 | 5030 | elseif (!empty($function)) |
@@ -4771,8 +5040,9 @@ discard block |
||
| 4771 | 5040 | } |
| 4772 | 5041 | |
| 4773 | 5042 | // "Assume" the file resides on $boarddir somewhere... |
| 4774 | - else |
|
| 4775 | - log_error(sprintf($txt['hook_fail_call_to'], $function, $boarddir), 'general'); |
|
| 5043 | + else { |
|
| 5044 | + log_error(sprintf($txt['hook_fail_call_to'], $function, $boarddir), 'general'); |
|
| 5045 | + } |
|
| 4776 | 5046 | } |
| 4777 | 5047 | } |
| 4778 | 5048 | |
@@ -4794,12 +5064,14 @@ discard block |
||
| 4794 | 5064 | global $smcFunc, $modSettings; |
| 4795 | 5065 | |
| 4796 | 5066 | // Any objects? |
| 4797 | - if ($object) |
|
| 4798 | - $function = $function . '#'; |
|
| 5067 | + if ($object) { |
|
| 5068 | + $function = $function . '#'; |
|
| 5069 | + } |
|
| 4799 | 5070 | |
| 4800 | 5071 | // Any files to load? |
| 4801 | - if (!empty($file) && is_string($file)) |
|
| 4802 | - $function = $file . (!empty($function) ? '|' . $function : ''); |
|
| 5072 | + if (!empty($file) && is_string($file)) { |
|
| 5073 | + $function = $file . (!empty($function) ? '|' . $function : ''); |
|
| 5074 | + } |
|
| 4803 | 5075 | |
| 4804 | 5076 | // Get the correct string. |
| 4805 | 5077 | $integration_call = $function; |
@@ -4821,13 +5093,14 @@ discard block |
||
| 4821 | 5093 | if (!empty($current_functions)) |
| 4822 | 5094 | { |
| 4823 | 5095 | $current_functions = explode(',', $current_functions); |
| 4824 | - if (in_array($integration_call, $current_functions)) |
|
| 4825 | - return; |
|
| 5096 | + if (in_array($integration_call, $current_functions)) { |
|
| 5097 | + return; |
|
| 5098 | + } |
|
| 4826 | 5099 | |
| 4827 | 5100 | $permanent_functions = array_merge($current_functions, array($integration_call)); |
| 5101 | + } else { |
|
| 5102 | + $permanent_functions = array($integration_call); |
|
| 4828 | 5103 | } |
| 4829 | - else |
|
| 4830 | - $permanent_functions = array($integration_call); |
|
| 4831 | 5104 | |
| 4832 | 5105 | updateSettings(array($hook => implode(',', $permanent_functions))); |
| 4833 | 5106 | } |
@@ -4836,8 +5109,9 @@ discard block |
||
| 4836 | 5109 | $functions = empty($modSettings[$hook]) ? array() : explode(',', $modSettings[$hook]); |
| 4837 | 5110 | |
| 4838 | 5111 | // Do nothing, if it's already there. |
| 4839 | - if (in_array($integration_call, $functions)) |
|
| 4840 | - return; |
|
| 5112 | + if (in_array($integration_call, $functions)) { |
|
| 5113 | + return; |
|
| 5114 | + } |
|
| 4841 | 5115 | |
| 4842 | 5116 | $functions[] = $integration_call; |
| 4843 | 5117 | $modSettings[$hook] = implode(',', $functions); |
@@ -4860,12 +5134,14 @@ discard block |
||
| 4860 | 5134 | global $smcFunc, $modSettings; |
| 4861 | 5135 | |
| 4862 | 5136 | // Any objects? |
| 4863 | - if ($object) |
|
| 4864 | - $function = $function . '#'; |
|
| 5137 | + if ($object) { |
|
| 5138 | + $function = $function . '#'; |
|
| 5139 | + } |
|
| 4865 | 5140 | |
| 4866 | 5141 | // Any files to load? |
| 4867 | - if (!empty($file) && is_string($file)) |
|
| 4868 | - $function = $file . '|' . $function; |
|
| 5142 | + if (!empty($file) && is_string($file)) { |
|
| 5143 | + $function = $file . '|' . $function; |
|
| 5144 | + } |
|
| 4869 | 5145 | |
| 4870 | 5146 | // Get the correct string. |
| 4871 | 5147 | $integration_call = $function; |
@@ -4886,16 +5162,18 @@ discard block |
||
| 4886 | 5162 | { |
| 4887 | 5163 | $current_functions = explode(',', $current_functions); |
| 4888 | 5164 | |
| 4889 | - if (in_array($integration_call, $current_functions)) |
|
| 4890 | - updateSettings(array($hook => implode(',', array_diff($current_functions, array($integration_call))))); |
|
| 5165 | + if (in_array($integration_call, $current_functions)) { |
|
| 5166 | + updateSettings(array($hook => implode(',', array_diff($current_functions, array($integration_call))))); |
|
| 5167 | + } |
|
| 4891 | 5168 | } |
| 4892 | 5169 | |
| 4893 | 5170 | // Turn the function list into something usable. |
| 4894 | 5171 | $functions = empty($modSettings[$hook]) ? array() : explode(',', $modSettings[$hook]); |
| 4895 | 5172 | |
| 4896 | 5173 | // You can only remove it if it's available. |
| 4897 | - if (!in_array($integration_call, $functions)) |
|
| 4898 | - return; |
|
| 5174 | + if (!in_array($integration_call, $functions)) { |
|
| 5175 | + return; |
|
| 5176 | + } |
|
| 4899 | 5177 | |
| 4900 | 5178 | $functions = array_diff($functions, array($integration_call)); |
| 4901 | 5179 | $modSettings[$hook] = implode(',', $functions); |
@@ -4916,17 +5194,20 @@ discard block |
||
| 4916 | 5194 | global $context, $smcFunc, $txt, $db_show_debug; |
| 4917 | 5195 | |
| 4918 | 5196 | // Really? |
| 4919 | - if (empty($string)) |
|
| 4920 | - return false; |
|
| 5197 | + if (empty($string)) { |
|
| 5198 | + return false; |
|
| 5199 | + } |
|
| 4921 | 5200 | |
| 4922 | 5201 | // An array? should be a "callable" array IE array(object/class, valid_callable). |
| 4923 | 5202 | // A closure? should be a callable one. |
| 4924 | - if (is_array($string) || $string instanceof Closure) |
|
| 4925 | - return $return ? $string : (is_callable($string) ? call_user_func($string) : false); |
|
| 5203 | + if (is_array($string) || $string instanceof Closure) { |
|
| 5204 | + return $return ? $string : (is_callable($string) ? call_user_func($string) : false); |
|
| 5205 | + } |
|
| 4926 | 5206 | |
| 4927 | 5207 | // No full objects, sorry! pass a method or a property instead! |
| 4928 | - if (is_object($string)) |
|
| 4929 | - return false; |
|
| 5208 | + if (is_object($string)) { |
|
| 5209 | + return false; |
|
| 5210 | + } |
|
| 4930 | 5211 | |
| 4931 | 5212 | // Stay vitaminized my friends... |
| 4932 | 5213 | $string = $smcFunc['htmlspecialchars']($smcFunc['htmltrim']($string)); |
@@ -4935,8 +5216,9 @@ discard block |
||
| 4935 | 5216 | $string = load_file($string); |
| 4936 | 5217 | |
| 4937 | 5218 | // Loaded file failed |
| 4938 | - if (empty($string)) |
|
| 4939 | - return false; |
|
| 5219 | + if (empty($string)) { |
|
| 5220 | + return false; |
|
| 5221 | + } |
|
| 4940 | 5222 | |
| 4941 | 5223 | // Found a method. |
| 4942 | 5224 | if (strpos($string, '::') !== false) |
@@ -4957,8 +5239,9 @@ discard block |
||
| 4957 | 5239 | // Add another one to the list. |
| 4958 | 5240 | if ($db_show_debug === true) |
| 4959 | 5241 | { |
| 4960 | - if (!isset($context['debug']['instances'])) |
|
| 4961 | - $context['debug']['instances'] = array(); |
|
| 5242 | + if (!isset($context['debug']['instances'])) { |
|
| 5243 | + $context['debug']['instances'] = array(); |
|
| 5244 | + } |
|
| 4962 | 5245 | |
| 4963 | 5246 | $context['debug']['instances'][$class] = $class; |
| 4964 | 5247 | } |
@@ -4968,13 +5251,15 @@ discard block |
||
| 4968 | 5251 | } |
| 4969 | 5252 | |
| 4970 | 5253 | // Right then. This is a call to a static method. |
| 4971 | - else |
|
| 4972 | - $func = array($class, $method); |
|
| 5254 | + else { |
|
| 5255 | + $func = array($class, $method); |
|
| 5256 | + } |
|
| 4973 | 5257 | } |
| 4974 | 5258 | |
| 4975 | 5259 | // Nope! just a plain regular function. |
| 4976 | - else |
|
| 4977 | - $func = $string; |
|
| 5260 | + else { |
|
| 5261 | + $func = $string; |
|
| 5262 | + } |
|
| 4978 | 5263 | |
| 4979 | 5264 | // Right, we got what we need, time to do some checks. |
| 4980 | 5265 | if (!is_callable($func, false, $callable_name)) |
@@ -4990,17 +5275,18 @@ discard block |
||
| 4990 | 5275 | else |
| 4991 | 5276 | { |
| 4992 | 5277 | // What are we gonna do about it? |
| 4993 | - if ($return) |
|
| 4994 | - return $func; |
|
| 5278 | + if ($return) { |
|
| 5279 | + return $func; |
|
| 5280 | + } |
|
| 4995 | 5281 | |
| 4996 | 5282 | // If this is a plain function, avoid the heat of calling call_user_func(). |
| 4997 | 5283 | else |
| 4998 | 5284 | { |
| 4999 | - if (is_array($func)) |
|
| 5000 | - call_user_func($func); |
|
| 5001 | - |
|
| 5002 | - else |
|
| 5003 | - $func(); |
|
| 5285 | + if (is_array($func)) { |
|
| 5286 | + call_user_func($func); |
|
| 5287 | + } else { |
|
| 5288 | + $func(); |
|
| 5289 | + } |
|
| 5004 | 5290 | } |
| 5005 | 5291 | } |
| 5006 | 5292 | } |
@@ -5017,31 +5303,34 @@ discard block |
||
| 5017 | 5303 | { |
| 5018 | 5304 | global $sourcedir, $txt, $boarddir, $settings; |
| 5019 | 5305 | |
| 5020 | - if (empty($string)) |
|
| 5021 | - return false; |
|
| 5306 | + if (empty($string)) { |
|
| 5307 | + return false; |
|
| 5308 | + } |
|
| 5022 | 5309 | |
| 5023 | 5310 | if (strpos($string, '|') !== false) |
| 5024 | 5311 | { |
| 5025 | 5312 | list ($file, $string) = explode('|', $string); |
| 5026 | 5313 | |
| 5027 | 5314 | // Match the wildcards to their regular vars. |
| 5028 | - if (empty($settings['theme_dir'])) |
|
| 5029 | - $absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir)); |
|
| 5030 | - |
|
| 5031 | - else |
|
| 5032 | - $absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir'])); |
|
| 5315 | + if (empty($settings['theme_dir'])) { |
|
| 5316 | + $absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir)); |
|
| 5317 | + } else { |
|
| 5318 | + $absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir'])); |
|
| 5319 | + } |
|
| 5033 | 5320 | |
| 5034 | 5321 | // Load the file if it can be loaded. |
| 5035 | - if (file_exists($absPath)) |
|
| 5036 | - require_once($absPath); |
|
| 5322 | + if (file_exists($absPath)) { |
|
| 5323 | + require_once($absPath); |
|
| 5324 | + } |
|
| 5037 | 5325 | |
| 5038 | 5326 | // No? try a fallback to $sourcedir |
| 5039 | 5327 | else |
| 5040 | 5328 | { |
| 5041 | 5329 | $absPath = $sourcedir .'/'. $file; |
| 5042 | 5330 | |
| 5043 | - if (file_exists($absPath)) |
|
| 5044 | - require_once($absPath); |
|
| 5331 | + if (file_exists($absPath)) { |
|
| 5332 | + require_once($absPath); |
|
| 5333 | + } |
|
| 5045 | 5334 | |
| 5046 | 5335 | // Sorry, can't do much for you at this point. |
| 5047 | 5336 | else |
@@ -5080,8 +5369,9 @@ discard block |
||
| 5080 | 5369 | preg_match('~^(http|ftp)(s)?://([^/:]+)(:(\d+))?(.+)$~', $url, $match); |
| 5081 | 5370 | |
| 5082 | 5371 | // No scheme? No data for you! |
| 5083 | - if (empty($match[1])) |
|
| 5084 | - return false; |
|
| 5372 | + if (empty($match[1])) { |
|
| 5373 | + return false; |
|
| 5374 | + } |
|
| 5085 | 5375 | |
| 5086 | 5376 | // An FTP url. We should try connecting and RETRieving it... |
| 5087 | 5377 | elseif ($match[1] == 'ftp') |
@@ -5091,23 +5381,26 @@ discard block |
||
| 5091 | 5381 | |
| 5092 | 5382 | // Establish a connection and attempt to enable passive mode. |
| 5093 | 5383 | $ftp = new ftp_connection(($match[2] ? 'ssl://' : '') . $match[3], empty($match[5]) ? 21 : $match[5], 'anonymous', $webmaster_email); |
| 5094 | - if ($ftp->error !== false || !$ftp->passive()) |
|
| 5095 | - return false; |
|
| 5384 | + if ($ftp->error !== false || !$ftp->passive()) { |
|
| 5385 | + return false; |
|
| 5386 | + } |
|
| 5096 | 5387 | |
| 5097 | 5388 | // I want that one *points*! |
| 5098 | 5389 | fwrite($ftp->connection, 'RETR ' . $match[6] . "\r\n"); |
| 5099 | 5390 | |
| 5100 | 5391 | // Since passive mode worked (or we would have returned already!) open the connection. |
| 5101 | 5392 | $fp = @fsockopen($ftp->pasv['ip'], $ftp->pasv['port'], $err, $err, 5); |
| 5102 | - if (!$fp) |
|
| 5103 | - return false; |
|
| 5393 | + if (!$fp) { |
|
| 5394 | + return false; |
|
| 5395 | + } |
|
| 5104 | 5396 | |
| 5105 | 5397 | // The server should now say something in acknowledgement. |
| 5106 | 5398 | $ftp->check_response(150); |
| 5107 | 5399 | |
| 5108 | 5400 | $data = ''; |
| 5109 | - while (!feof($fp)) |
|
| 5110 | - $data .= fread($fp, 4096); |
|
| 5401 | + while (!feof($fp)) { |
|
| 5402 | + $data .= fread($fp, 4096); |
|
| 5403 | + } |
|
| 5111 | 5404 | fclose($fp); |
| 5112 | 5405 | |
| 5113 | 5406 | // All done, right? Good. |
@@ -5119,8 +5412,9 @@ discard block |
||
| 5119 | 5412 | elseif (isset($match[1]) && $match[1] == 'http') |
| 5120 | 5413 | { |
| 5121 | 5414 | // First try to use fsockopen, because it is fastest. |
| 5122 | - if ($keep_alive && $match[3] == $keep_alive_dom) |
|
| 5123 | - $fp = $keep_alive_fp; |
|
| 5415 | + if ($keep_alive && $match[3] == $keep_alive_dom) { |
|
| 5416 | + $fp = $keep_alive_fp; |
|
| 5417 | + } |
|
| 5124 | 5418 | if (empty($fp)) |
| 5125 | 5419 | { |
| 5126 | 5420 | // Open the socket on the port we want... |
@@ -5140,20 +5434,21 @@ discard block |
||
| 5140 | 5434 | fwrite($fp, 'GET ' . ($match[6] !== '/' ? str_replace(' ', '%20', $match[6]) : '') . ' HTTP/1.0' . "\r\n"); |
| 5141 | 5435 | fwrite($fp, 'Host: ' . $match[3] . (empty($match[5]) ? ($match[2] ? ':443' : '') : ':' . $match[5]) . "\r\n"); |
| 5142 | 5436 | fwrite($fp, 'user-agent: PHP/SMF' . "\r\n"); |
| 5143 | - if ($keep_alive) |
|
| 5144 | - fwrite($fp, 'connection: Keep-Alive' . "\r\n\r\n"); |
|
| 5145 | - else |
|
| 5146 | - fwrite($fp, 'connection: close' . "\r\n\r\n"); |
|
| 5147 | - } |
|
| 5148 | - else |
|
| 5437 | + if ($keep_alive) { |
|
| 5438 | + fwrite($fp, 'connection: Keep-Alive' . "\r\n\r\n"); |
|
| 5439 | + } else { |
|
| 5440 | + fwrite($fp, 'connection: close' . "\r\n\r\n"); |
|
| 5441 | + } |
|
| 5442 | + } else |
|
| 5149 | 5443 | { |
| 5150 | 5444 | fwrite($fp, 'POST ' . ($match[6] !== '/' ? $match[6] : '') . ' HTTP/1.0' . "\r\n"); |
| 5151 | 5445 | fwrite($fp, 'Host: ' . $match[3] . (empty($match[5]) ? ($match[2] ? ':443' : '') : ':' . $match[5]) . "\r\n"); |
| 5152 | 5446 | fwrite($fp, 'user-agent: PHP/SMF' . "\r\n"); |
| 5153 | - if ($keep_alive) |
|
| 5154 | - fwrite($fp, 'connection: Keep-Alive' . "\r\n"); |
|
| 5155 | - else |
|
| 5156 | - fwrite($fp, 'connection: close' . "\r\n"); |
|
| 5447 | + if ($keep_alive) { |
|
| 5448 | + fwrite($fp, 'connection: Keep-Alive' . "\r\n"); |
|
| 5449 | + } else { |
|
| 5450 | + fwrite($fp, 'connection: close' . "\r\n"); |
|
| 5451 | + } |
|
| 5157 | 5452 | fwrite($fp, 'content-type: application/x-www-form-urlencoded' . "\r\n"); |
| 5158 | 5453 | fwrite($fp, 'content-length: ' . strlen($post_data) . "\r\n\r\n"); |
| 5159 | 5454 | fwrite($fp, $post_data); |
@@ -5166,30 +5461,33 @@ discard block |
||
| 5166 | 5461 | { |
| 5167 | 5462 | $header = ''; |
| 5168 | 5463 | $location = ''; |
| 5169 | - while (!feof($fp) && trim($header = fgets($fp, 4096)) != '') |
|
| 5170 | - if (strpos($header, 'location:') !== false) |
|
| 5464 | + while (!feof($fp) && trim($header = fgets($fp, 4096)) != '') { |
|
| 5465 | + if (strpos($header, 'location:') !== false) |
|
| 5171 | 5466 | $location = trim(substr($header, strpos($header, ':') + 1)); |
| 5467 | + } |
|
| 5172 | 5468 | |
| 5173 | - if (empty($location)) |
|
| 5174 | - return false; |
|
| 5175 | - else |
|
| 5469 | + if (empty($location)) { |
|
| 5470 | + return false; |
|
| 5471 | + } else |
|
| 5176 | 5472 | { |
| 5177 | - if (!$keep_alive) |
|
| 5178 | - fclose($fp); |
|
| 5473 | + if (!$keep_alive) { |
|
| 5474 | + fclose($fp); |
|
| 5475 | + } |
|
| 5179 | 5476 | return fetch_web_data($location, $post_data, $keep_alive, $redirection_level + 1); |
| 5180 | 5477 | } |
| 5181 | 5478 | } |
| 5182 | 5479 | |
| 5183 | 5480 | // Make sure we get a 200 OK. |
| 5184 | - elseif (preg_match('~^HTTP/\S+\s+20[01]~i', $response) === 0) |
|
| 5185 | - return false; |
|
| 5481 | + elseif (preg_match('~^HTTP/\S+\s+20[01]~i', $response) === 0) { |
|
| 5482 | + return false; |
|
| 5483 | + } |
|
| 5186 | 5484 | |
| 5187 | 5485 | // Skip the headers... |
| 5188 | 5486 | while (!feof($fp) && trim($header = fgets($fp, 4096)) != '') |
| 5189 | 5487 | { |
| 5190 | - if (preg_match('~content-length:\s*(\d+)~i', $header, $match) != 0) |
|
| 5191 | - $content_length = $match[1]; |
|
| 5192 | - elseif (preg_match('~connection:\s*close~i', $header) != 0) |
|
| 5488 | + if (preg_match('~content-length:\s*(\d+)~i', $header, $match) != 0) { |
|
| 5489 | + $content_length = $match[1]; |
|
| 5490 | + } elseif (preg_match('~connection:\s*close~i', $header) != 0) |
|
| 5193 | 5491 | { |
| 5194 | 5492 | $keep_alive_dom = null; |
| 5195 | 5493 | $keep_alive = false; |
@@ -5201,17 +5499,19 @@ discard block |
||
| 5201 | 5499 | $data = ''; |
| 5202 | 5500 | if (isset($content_length)) |
| 5203 | 5501 | { |
| 5204 | - while (!feof($fp) && strlen($data) < $content_length) |
|
| 5205 | - $data .= fread($fp, $content_length - strlen($data)); |
|
| 5206 | - } |
|
| 5207 | - else |
|
| 5502 | + while (!feof($fp) && strlen($data) < $content_length) { |
|
| 5503 | + $data .= fread($fp, $content_length - strlen($data)); |
|
| 5504 | + } |
|
| 5505 | + } else |
|
| 5208 | 5506 | { |
| 5209 | - while (!feof($fp)) |
|
| 5210 | - $data .= fread($fp, 4096); |
|
| 5507 | + while (!feof($fp)) { |
|
| 5508 | + $data .= fread($fp, 4096); |
|
| 5509 | + } |
|
| 5211 | 5510 | } |
| 5212 | 5511 | |
| 5213 | - if (!$keep_alive) |
|
| 5214 | - fclose($fp); |
|
| 5512 | + if (!$keep_alive) { |
|
| 5513 | + fclose($fp); |
|
| 5514 | + } |
|
| 5215 | 5515 | } |
| 5216 | 5516 | |
| 5217 | 5517 | // If using fsockopen didn't work, try to use cURL if available. |
@@ -5224,17 +5524,18 @@ discard block |
||
| 5224 | 5524 | $fetch_data->get_url_data($url, $post_data); |
| 5225 | 5525 | |
| 5226 | 5526 | // no errors and a 200 result, then we have a good dataset, well we at least have data. ;) |
| 5227 | - if ($fetch_data->result('code') == 200 && !$fetch_data->result('error')) |
|
| 5228 | - $data = $fetch_data->result('body'); |
|
| 5229 | - else |
|
| 5230 | - return false; |
|
| 5527 | + if ($fetch_data->result('code') == 200 && !$fetch_data->result('error')) { |
|
| 5528 | + $data = $fetch_data->result('body'); |
|
| 5529 | + } else { |
|
| 5530 | + return false; |
|
| 5531 | + } |
|
| 5231 | 5532 | } |
| 5232 | 5533 | |
| 5233 | 5534 | // Neither fsockopen nor curl are available. Well, phooey. |
| 5234 | - else |
|
| 5235 | - return false; |
|
| 5236 | - } |
|
| 5237 | - else |
|
| 5535 | + else { |
|
| 5536 | + return false; |
|
| 5537 | + } |
|
| 5538 | + } else |
|
| 5238 | 5539 | { |
| 5239 | 5540 | // Umm, this shouldn't happen? |
| 5240 | 5541 | trigger_error('fetch_web_data(): Bad URL', E_USER_NOTICE); |
@@ -5254,8 +5555,9 @@ discard block |
||
| 5254 | 5555 | global $user_info, $smcFunc; |
| 5255 | 5556 | |
| 5256 | 5557 | // Make sure we have something to work with. |
| 5257 | - if (empty($topic)) |
|
| 5258 | - return array(); |
|
| 5558 | + if (empty($topic)) { |
|
| 5559 | + return array(); |
|
| 5560 | + } |
|
| 5259 | 5561 | |
| 5260 | 5562 | |
| 5261 | 5563 | // We already know the number of likes per message, we just want to know whether the current user liked it or not. |
@@ -5278,8 +5580,9 @@ discard block |
||
| 5278 | 5580 | 'topic' => $topic, |
| 5279 | 5581 | ) |
| 5280 | 5582 | ); |
| 5281 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 5282 | - $temp[] = (int) $row['content_id']; |
|
| 5583 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 5584 | + $temp[] = (int) $row['content_id']; |
|
| 5585 | + } |
|
| 5283 | 5586 | |
| 5284 | 5587 | cache_put_data($cache_key, $temp, $ttl); |
| 5285 | 5588 | } |
@@ -5300,8 +5603,9 @@ discard block |
||
| 5300 | 5603 | { |
| 5301 | 5604 | global $context; |
| 5302 | 5605 | |
| 5303 | - if (empty($string)) |
|
| 5304 | - return $string; |
|
| 5606 | + if (empty($string)) { |
|
| 5607 | + return $string; |
|
| 5608 | + } |
|
| 5305 | 5609 | |
| 5306 | 5610 | // UTF-8 occurences of MS special characters |
| 5307 | 5611 | $findchars_utf8 = array( |
@@ -5342,10 +5646,11 @@ discard block |
||
| 5342 | 5646 | '--', // — |
| 5343 | 5647 | ); |
| 5344 | 5648 | |
| 5345 | - if ($context['utf8']) |
|
| 5346 | - $string = str_replace($findchars_utf8, $replacechars, $string); |
|
| 5347 | - else |
|
| 5348 | - $string = str_replace($findchars_iso, $replacechars, $string); |
|
| 5649 | + if ($context['utf8']) { |
|
| 5650 | + $string = str_replace($findchars_utf8, $replacechars, $string); |
|
| 5651 | + } else { |
|
| 5652 | + $string = str_replace($findchars_iso, $replacechars, $string); |
|
| 5653 | + } |
|
| 5349 | 5654 | |
| 5350 | 5655 | return $string; |
| 5351 | 5656 | } |
@@ -5364,49 +5669,59 @@ discard block |
||
| 5364 | 5669 | { |
| 5365 | 5670 | global $context; |
| 5366 | 5671 | |
| 5367 | - if (!isset($matches[2])) |
|
| 5368 | - return ''; |
|
| 5672 | + if (!isset($matches[2])) { |
|
| 5673 | + return ''; |
|
| 5674 | + } |
|
| 5369 | 5675 | |
| 5370 | 5676 | $num = $matches[2][0] === 'x' ? hexdec(substr($matches[2], 1)) : (int) $matches[2]; |
| 5371 | 5677 | |
| 5372 | 5678 | // remove left to right / right to left overrides |
| 5373 | - if ($num === 0x202D || $num === 0x202E) |
|
| 5374 | - return ''; |
|
| 5679 | + if ($num === 0x202D || $num === 0x202E) { |
|
| 5680 | + return ''; |
|
| 5681 | + } |
|
| 5375 | 5682 | |
| 5376 | 5683 | // Quote, Ampersand, Apostrophe, Less/Greater Than get html replaced |
| 5377 | - if (in_array($num, array(0x22, 0x26, 0x27, 0x3C, 0x3E))) |
|
| 5378 | - return '&#' . $num . ';'; |
|
| 5684 | + if (in_array($num, array(0x22, 0x26, 0x27, 0x3C, 0x3E))) { |
|
| 5685 | + return '&#' . $num . ';'; |
|
| 5686 | + } |
|
| 5379 | 5687 | |
| 5380 | 5688 | if (empty($context['utf8'])) |
| 5381 | 5689 | { |
| 5382 | 5690 | // no control characters |
| 5383 | - if ($num < 0x20) |
|
| 5384 | - return ''; |
|
| 5691 | + if ($num < 0x20) { |
|
| 5692 | + return ''; |
|
| 5693 | + } |
|
| 5385 | 5694 | // text is text |
| 5386 | - elseif ($num < 0x80) |
|
| 5387 | - return chr($num); |
|
| 5695 | + elseif ($num < 0x80) { |
|
| 5696 | + return chr($num); |
|
| 5697 | + } |
|
| 5388 | 5698 | // all others get html-ised |
| 5389 | - else |
|
| 5390 | - return '&#' . $matches[2] . ';'; |
|
| 5391 | - } |
|
| 5392 | - else |
|
| 5699 | + else { |
|
| 5700 | + return '&#' . $matches[2] . ';'; |
|
| 5701 | + } |
|
| 5702 | + } else |
|
| 5393 | 5703 | { |
| 5394 | 5704 | // <0x20 are control characters, 0x20 is a space, > 0x10FFFF is past the end of the utf8 character set |
| 5395 | 5705 | // 0xD800 >= $num <= 0xDFFF are surrogate markers (not valid for utf8 text) |
| 5396 | - if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF)) |
|
| 5397 | - return ''; |
|
| 5706 | + if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF)) { |
|
| 5707 | + return ''; |
|
| 5708 | + } |
|
| 5398 | 5709 | // <0x80 (or less than 128) are standard ascii characters a-z A-Z 0-9 and punctuation |
| 5399 | - elseif ($num < 0x80) |
|
| 5400 | - return chr($num); |
|
| 5710 | + elseif ($num < 0x80) { |
|
| 5711 | + return chr($num); |
|
| 5712 | + } |
|
| 5401 | 5713 | // <0x800 (2048) |
| 5402 | - elseif ($num < 0x800) |
|
| 5403 | - return chr(($num >> 6) + 192) . chr(($num & 63) + 128); |
|
| 5714 | + elseif ($num < 0x800) { |
|
| 5715 | + return chr(($num >> 6) + 192) . chr(($num & 63) + 128); |
|
| 5716 | + } |
|
| 5404 | 5717 | // < 0x10000 (65536) |
| 5405 | - elseif ($num < 0x10000) |
|
| 5406 | - return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
| 5718 | + elseif ($num < 0x10000) { |
|
| 5719 | + return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
| 5720 | + } |
|
| 5407 | 5721 | // <= 0x10FFFF (1114111) |
| 5408 | - else |
|
| 5409 | - return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
| 5722 | + else { |
|
| 5723 | + return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
| 5724 | + } |
|
| 5410 | 5725 | } |
| 5411 | 5726 | } |
| 5412 | 5727 | |
@@ -5422,28 +5737,34 @@ discard block |
||
| 5422 | 5737 | */ |
| 5423 | 5738 | function fixchar__callback($matches) |
| 5424 | 5739 | { |
| 5425 | - if (!isset($matches[1])) |
|
| 5426 | - return ''; |
|
| 5740 | + if (!isset($matches[1])) { |
|
| 5741 | + return ''; |
|
| 5742 | + } |
|
| 5427 | 5743 | |
| 5428 | 5744 | $num = $matches[1][0] === 'x' ? hexdec(substr($matches[1], 1)) : (int) $matches[1]; |
| 5429 | 5745 | |
| 5430 | 5746 | // <0x20 are control characters, > 0x10FFFF is past the end of the utf8 character set |
| 5431 | 5747 | // 0xD800 >= $num <= 0xDFFF are surrogate markers (not valid for utf8 text), 0x202D-E are left to right overrides |
| 5432 | - if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num === 0x202D || $num === 0x202E) |
|
| 5433 | - return ''; |
|
| 5748 | + if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num === 0x202D || $num === 0x202E) { |
|
| 5749 | + return ''; |
|
| 5750 | + } |
|
| 5434 | 5751 | // <0x80 (or less than 128) are standard ascii characters a-z A-Z 0-9 and punctuation |
| 5435 | - elseif ($num < 0x80) |
|
| 5436 | - return chr($num); |
|
| 5752 | + elseif ($num < 0x80) { |
|
| 5753 | + return chr($num); |
|
| 5754 | + } |
|
| 5437 | 5755 | // <0x800 (2048) |
| 5438 | - elseif ($num < 0x800) |
|
| 5439 | - return chr(($num >> 6) + 192) . chr(($num & 63) + 128); |
|
| 5756 | + elseif ($num < 0x800) { |
|
| 5757 | + return chr(($num >> 6) + 192) . chr(($num & 63) + 128); |
|
| 5758 | + } |
|
| 5440 | 5759 | // < 0x10000 (65536) |
| 5441 | - elseif ($num < 0x10000) |
|
| 5442 | - return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
| 5760 | + elseif ($num < 0x10000) { |
|
| 5761 | + return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
| 5762 | + } |
|
| 5443 | 5763 | // <= 0x10FFFF (1114111) |
| 5444 | - else |
|
| 5445 | - return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
| 5446 | -} |
|
| 5764 | + else { |
|
| 5765 | + return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
| 5766 | + } |
|
| 5767 | + } |
|
| 5447 | 5768 | |
| 5448 | 5769 | /** |
| 5449 | 5770 | * Strips out invalid html entities, replaces others with html style { codes |
@@ -5456,17 +5777,19 @@ discard block |
||
| 5456 | 5777 | */ |
| 5457 | 5778 | function entity_fix__callback($matches) |
| 5458 | 5779 | { |
| 5459 | - if (!isset($matches[2])) |
|
| 5460 | - return ''; |
|
| 5780 | + if (!isset($matches[2])) { |
|
| 5781 | + return ''; |
|
| 5782 | + } |
|
| 5461 | 5783 | |
| 5462 | 5784 | $num = $matches[2][0] === 'x' ? hexdec(substr($matches[2], 1)) : (int) $matches[2]; |
| 5463 | 5785 | |
| 5464 | 5786 | // we don't allow control characters, characters out of range, byte markers, etc |
| 5465 | - if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num == 0x202D || $num == 0x202E) |
|
| 5466 | - return ''; |
|
| 5467 | - else |
|
| 5468 | - return '&#' . $num . ';'; |
|
| 5469 | -} |
|
| 5787 | + if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num == 0x202D || $num == 0x202E) { |
|
| 5788 | + return ''; |
|
| 5789 | + } else { |
|
| 5790 | + return '&#' . $num . ';'; |
|
| 5791 | + } |
|
| 5792 | + } |
|
| 5470 | 5793 | |
| 5471 | 5794 | /** |
| 5472 | 5795 | * Return a Gravatar URL based on |
@@ -5490,18 +5813,23 @@ discard block |
||
| 5490 | 5813 | $ratings = array('G', 'PG', 'R', 'X'); |
| 5491 | 5814 | $defaults = array('mm', 'identicon', 'monsterid', 'wavatar', 'retro', 'blank'); |
| 5492 | 5815 | $url_params = array(); |
| 5493 | - if (!empty($modSettings['gravatarMaxRating']) && in_array($modSettings['gravatarMaxRating'], $ratings)) |
|
| 5494 | - $url_params[] = 'rating=' . $modSettings['gravatarMaxRating']; |
|
| 5495 | - if (!empty($modSettings['gravatarDefault']) && in_array($modSettings['gravatarDefault'], $defaults)) |
|
| 5496 | - $url_params[] = 'default=' . $modSettings['gravatarDefault']; |
|
| 5497 | - if (!empty($modSettings['avatar_max_width_external'])) |
|
| 5498 | - $size_string = (int) $modSettings['avatar_max_width_external']; |
|
| 5499 | - if (!empty($modSettings['avatar_max_height_external']) && !empty($size_string)) |
|
| 5500 | - if ((int) $modSettings['avatar_max_height_external'] < $size_string) |
|
| 5816 | + if (!empty($modSettings['gravatarMaxRating']) && in_array($modSettings['gravatarMaxRating'], $ratings)) { |
|
| 5817 | + $url_params[] = 'rating=' . $modSettings['gravatarMaxRating']; |
|
| 5818 | + } |
|
| 5819 | + if (!empty($modSettings['gravatarDefault']) && in_array($modSettings['gravatarDefault'], $defaults)) { |
|
| 5820 | + $url_params[] = 'default=' . $modSettings['gravatarDefault']; |
|
| 5821 | + } |
|
| 5822 | + if (!empty($modSettings['avatar_max_width_external'])) { |
|
| 5823 | + $size_string = (int) $modSettings['avatar_max_width_external']; |
|
| 5824 | + } |
|
| 5825 | + if (!empty($modSettings['avatar_max_height_external']) && !empty($size_string)) { |
|
| 5826 | + if ((int) $modSettings['avatar_max_height_external'] < $size_string) |
|
| 5501 | 5827 | $size_string = $modSettings['avatar_max_height_external']; |
| 5828 | + } |
|
| 5502 | 5829 | |
| 5503 | - if (!empty($size_string)) |
|
| 5504 | - $url_params[] = 's=' . $size_string; |
|
| 5830 | + if (!empty($size_string)) { |
|
| 5831 | + $url_params[] = 's=' . $size_string; |
|
| 5832 | + } |
|
| 5505 | 5833 | } |
| 5506 | 5834 | $http_method = !empty($modSettings['force_ssl']) ? 'https://secure' : 'http://www'; |
| 5507 | 5835 | |
@@ -5520,22 +5848,26 @@ discard block |
||
| 5520 | 5848 | static $timezones = null, $lastwhen = null; |
| 5521 | 5849 | |
| 5522 | 5850 | // No point doing this over if we already did it once |
| 5523 | - if (!empty($timezones) && $when == $lastwhen) |
|
| 5524 | - return $timezones; |
|
| 5525 | - else |
|
| 5526 | - $lastwhen = $when; |
|
| 5851 | + if (!empty($timezones) && $when == $lastwhen) { |
|
| 5852 | + return $timezones; |
|
| 5853 | + } else { |
|
| 5854 | + $lastwhen = $when; |
|
| 5855 | + } |
|
| 5527 | 5856 | |
| 5528 | 5857 | // Parseable datetime string? |
| 5529 | - if (is_int($timestamp = strtotime($when))) |
|
| 5530 | - $when = $timestamp; |
|
| 5858 | + if (is_int($timestamp = strtotime($when))) { |
|
| 5859 | + $when = $timestamp; |
|
| 5860 | + } |
|
| 5531 | 5861 | |
| 5532 | 5862 | // A Unix timestamp? |
| 5533 | - elseif (is_numeric($when)) |
|
| 5534 | - $when = intval($when); |
|
| 5863 | + elseif (is_numeric($when)) { |
|
| 5864 | + $when = intval($when); |
|
| 5865 | + } |
|
| 5535 | 5866 | |
| 5536 | 5867 | // Invalid value? Just get current Unix timestamp. |
| 5537 | - else |
|
| 5538 | - $when = time(); |
|
| 5868 | + else { |
|
| 5869 | + $when = time(); |
|
| 5870 | + } |
|
| 5539 | 5871 | |
| 5540 | 5872 | // We'll need these too |
| 5541 | 5873 | $date_when = date_create('@' . $when); |
@@ -5550,8 +5882,9 @@ discard block |
||
| 5550 | 5882 | foreach ($priority_countries as $country) |
| 5551 | 5883 | { |
| 5552 | 5884 | $country_tzids = @timezone_identifiers_list(DateTimeZone::PER_COUNTRY, strtoupper(trim($country))); |
| 5553 | - if (!empty($country_tzids)) |
|
| 5554 | - $priority_tzids = array_merge($priority_tzids, $country_tzids); |
|
| 5885 | + if (!empty($country_tzids)) { |
|
| 5886 | + $priority_tzids = array_merge($priority_tzids, $country_tzids); |
|
| 5887 | + } |
|
| 5555 | 5888 | } |
| 5556 | 5889 | |
| 5557 | 5890 | // Antarctic research stations should be listed last, unless you're running a penguin forum |
@@ -5565,8 +5898,9 @@ discard block |
||
| 5565 | 5898 | foreach ($tzids as $tzid) |
| 5566 | 5899 | { |
| 5567 | 5900 | // We don't want UTC right now |
| 5568 | - if ($tzid == 'UTC') |
|
| 5569 | - continue; |
|
| 5901 | + if ($tzid == 'UTC') { |
|
| 5902 | + continue; |
|
| 5903 | + } |
|
| 5570 | 5904 | |
| 5571 | 5905 | $tz = timezone_open($tzid); |
| 5572 | 5906 | |
@@ -5587,13 +5921,14 @@ discard block |
||
| 5587 | 5921 | } |
| 5588 | 5922 | |
| 5589 | 5923 | // A time zone from a prioritized country? |
| 5590 | - if (in_array($tzid, $priority_tzids)) |
|
| 5591 | - $priority_zones[$tzkey] = true; |
|
| 5924 | + if (in_array($tzid, $priority_tzids)) { |
|
| 5925 | + $priority_zones[$tzkey] = true; |
|
| 5926 | + } |
|
| 5592 | 5927 | |
| 5593 | 5928 | // Keep track of the location and offset for this tzid |
| 5594 | - if (!empty($txt[$tzid])) |
|
| 5595 | - $zones[$tzkey]['locations'][] = $txt[$tzid]; |
|
| 5596 | - else |
|
| 5929 | + if (!empty($txt[$tzid])) { |
|
| 5930 | + $zones[$tzkey]['locations'][] = $txt[$tzid]; |
|
| 5931 | + } else |
|
| 5597 | 5932 | { |
| 5598 | 5933 | $tzid_parts = explode('/', $tzid); |
| 5599 | 5934 | $zones[$tzkey]['locations'][] = str_replace(array('St_', '_'), array('St. ', ' '), array_pop($tzid_parts)); |
@@ -5613,23 +5948,27 @@ discard block |
||
| 5613 | 5948 | date_timezone_set($date_when, timezone_open($tzvalue['tzid'])); |
| 5614 | 5949 | |
| 5615 | 5950 | // Use the custom description, if there is one |
| 5616 | - if (!empty($tztxt[$tzvalue['tzid']])) |
|
| 5617 | - $desc = $tztxt[$tzvalue['tzid']]; |
|
| 5951 | + if (!empty($tztxt[$tzvalue['tzid']])) { |
|
| 5952 | + $desc = $tztxt[$tzvalue['tzid']]; |
|
| 5953 | + } |
|
| 5618 | 5954 | // Otherwise, use the list of locations (max 5, so things don't get silly) |
| 5619 | - else |
|
| 5620 | - $desc = implode(', ', array_slice(array_unique($tzvalue['locations']), 0, 5)) . (count($tzvalue['locations']) > 5 ? ', ' . $txt['etc'] : ''); |
|
| 5955 | + else { |
|
| 5956 | + $desc = implode(', ', array_slice(array_unique($tzvalue['locations']), 0, 5)) . (count($tzvalue['locations']) > 5 ? ', ' . $txt['etc'] : ''); |
|
| 5957 | + } |
|
| 5621 | 5958 | |
| 5622 | 5959 | // Show the UTC offset and the abbreviation, if it's something like 'MST' and not '-06' |
| 5623 | 5960 | $desc = '[UTC' . date_format($date_when, 'P') . '] - ' . (!strspn($tzvalue['abbr'], '+-') ? $tzvalue['abbr'] . ' - ' : '') . $desc; |
| 5624 | 5961 | |
| 5625 | - if (isset($priority_zones[$tzkey])) |
|
| 5626 | - $priority_timezones[$tzvalue['tzid']] = $desc; |
|
| 5627 | - else |
|
| 5628 | - $timezones[$tzvalue['tzid']] = $desc; |
|
| 5962 | + if (isset($priority_zones[$tzkey])) { |
|
| 5963 | + $priority_timezones[$tzvalue['tzid']] = $desc; |
|
| 5964 | + } else { |
|
| 5965 | + $timezones[$tzvalue['tzid']] = $desc; |
|
| 5966 | + } |
|
| 5629 | 5967 | } |
| 5630 | 5968 | |
| 5631 | - if (!empty($priority_timezones)) |
|
| 5632 | - $priority_timezones[] = '-----'; |
|
| 5969 | + if (!empty($priority_timezones)) { |
|
| 5970 | + $priority_timezones[] = '-----'; |
|
| 5971 | + } |
|
| 5633 | 5972 | |
| 5634 | 5973 | $timezones = array_merge( |
| 5635 | 5974 | $priority_timezones, |
@@ -5646,8 +5985,9 @@ discard block |
||
| 5646 | 5985 | */ |
| 5647 | 5986 | function inet_ptod($ip_address) |
| 5648 | 5987 | { |
| 5649 | - if (!isValidIP($ip_address)) |
|
| 5650 | - return $ip_address; |
|
| 5988 | + if (!isValidIP($ip_address)) { |
|
| 5989 | + return $ip_address; |
|
| 5990 | + } |
|
| 5651 | 5991 | |
| 5652 | 5992 | $bin = inet_pton($ip_address); |
| 5653 | 5993 | return $bin; |
@@ -5659,13 +5999,15 @@ discard block |
||
| 5659 | 5999 | */ |
| 5660 | 6000 | function inet_dtop($bin) |
| 5661 | 6001 | { |
| 5662 | - if(empty($bin)) |
|
| 5663 | - return ''; |
|
| 6002 | + if(empty($bin)) { |
|
| 6003 | + return ''; |
|
| 6004 | + } |
|
| 5664 | 6005 | |
| 5665 | 6006 | global $db_type; |
| 5666 | 6007 | |
| 5667 | - if ($db_type == 'postgresql') |
|
| 5668 | - return $bin; |
|
| 6008 | + if ($db_type == 'postgresql') { |
|
| 6009 | + return $bin; |
|
| 6010 | + } |
|
| 5669 | 6011 | |
| 5670 | 6012 | $ip_address = inet_ntop($bin); |
| 5671 | 6013 | |
@@ -5690,26 +6032,32 @@ discard block |
||
| 5690 | 6032 | */ |
| 5691 | 6033 | function _safe_serialize($value) |
| 5692 | 6034 | { |
| 5693 | - if(is_null($value)) |
|
| 5694 | - return 'N;'; |
|
| 6035 | + if(is_null($value)) { |
|
| 6036 | + return 'N;'; |
|
| 6037 | + } |
|
| 5695 | 6038 | |
| 5696 | - if(is_bool($value)) |
|
| 5697 | - return 'b:'. (int) $value .';'; |
|
| 6039 | + if(is_bool($value)) { |
|
| 6040 | + return 'b:'. (int) $value .';'; |
|
| 6041 | + } |
|
| 5698 | 6042 | |
| 5699 | - if(is_int($value)) |
|
| 5700 | - return 'i:'. $value .';'; |
|
| 6043 | + if(is_int($value)) { |
|
| 6044 | + return 'i:'. $value .';'; |
|
| 6045 | + } |
|
| 5701 | 6046 | |
| 5702 | - if(is_float($value)) |
|
| 5703 | - return 'd:'. str_replace(',', '.', $value) .';'; |
|
| 6047 | + if(is_float($value)) { |
|
| 6048 | + return 'd:'. str_replace(',', '.', $value) .';'; |
|
| 6049 | + } |
|
| 5704 | 6050 | |
| 5705 | - if(is_string($value)) |
|
| 5706 | - return 's:'. strlen($value) .':"'. $value .'";'; |
|
| 6051 | + if(is_string($value)) { |
|
| 6052 | + return 's:'. strlen($value) .':"'. $value .'";'; |
|
| 6053 | + } |
|
| 5707 | 6054 | |
| 5708 | 6055 | if(is_array($value)) |
| 5709 | 6056 | { |
| 5710 | 6057 | $out = ''; |
| 5711 | - foreach($value as $k => $v) |
|
| 5712 | - $out .= _safe_serialize($k) . _safe_serialize($v); |
|
| 6058 | + foreach($value as $k => $v) { |
|
| 6059 | + $out .= _safe_serialize($k) . _safe_serialize($v); |
|
| 6060 | + } |
|
| 5713 | 6061 | |
| 5714 | 6062 | return 'a:'. count($value) .':{'. $out .'}'; |
| 5715 | 6063 | } |
@@ -5735,8 +6083,9 @@ discard block |
||
| 5735 | 6083 | |
| 5736 | 6084 | $out = _safe_serialize($value); |
| 5737 | 6085 | |
| 5738 | - if (isset($mbIntEnc)) |
|
| 5739 | - mb_internal_encoding($mbIntEnc); |
|
| 6086 | + if (isset($mbIntEnc)) { |
|
| 6087 | + mb_internal_encoding($mbIntEnc); |
|
| 6088 | + } |
|
| 5740 | 6089 | |
| 5741 | 6090 | return $out; |
| 5742 | 6091 | } |
@@ -5753,8 +6102,9 @@ discard block |
||
| 5753 | 6102 | function _safe_unserialize($str) |
| 5754 | 6103 | { |
| 5755 | 6104 | // Input is not a string. |
| 5756 | - if(empty($str) || !is_string($str)) |
|
| 5757 | - return false; |
|
| 6105 | + if(empty($str) || !is_string($str)) { |
|
| 6106 | + return false; |
|
| 6107 | + } |
|
| 5758 | 6108 | |
| 5759 | 6109 | $stack = array(); |
| 5760 | 6110 | $expected = array(); |
@@ -5770,43 +6120,38 @@ discard block |
||
| 5770 | 6120 | while($state != 1) |
| 5771 | 6121 | { |
| 5772 | 6122 | $type = isset($str[0]) ? $str[0] : ''; |
| 5773 | - if($type == '}') |
|
| 5774 | - $str = substr($str, 1); |
|
| 5775 | - |
|
| 5776 | - else if($type == 'N' && $str[1] == ';') |
|
| 6123 | + if($type == '}') { |
|
| 6124 | + $str = substr($str, 1); |
|
| 6125 | + } else if($type == 'N' && $str[1] == ';') |
|
| 5777 | 6126 | { |
| 5778 | 6127 | $value = null; |
| 5779 | 6128 | $str = substr($str, 2); |
| 5780 | - } |
|
| 5781 | - else if($type == 'b' && preg_match('/^b:([01]);/', $str, $matches)) |
|
| 6129 | + } else if($type == 'b' && preg_match('/^b:([01]);/', $str, $matches)) |
|
| 5782 | 6130 | { |
| 5783 | 6131 | $value = $matches[1] == '1' ? true : false; |
| 5784 | 6132 | $str = substr($str, 4); |
| 5785 | - } |
|
| 5786 | - else if($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches)) |
|
| 6133 | + } else if($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches)) |
|
| 5787 | 6134 | { |
| 5788 | 6135 | $value = (int)$matches[1]; |
| 5789 | 6136 | $str = $matches[2]; |
| 5790 | - } |
|
| 5791 | - else if($type == 'd' && preg_match('/^d:(-?[0-9]+\.?[0-9]*(E[+-][0-9]+)?);(.*)/s', $str, $matches)) |
|
| 6137 | + } else if($type == 'd' && preg_match('/^d:(-?[0-9]+\.?[0-9]*(E[+-][0-9]+)?);(.*)/s', $str, $matches)) |
|
| 5792 | 6138 | { |
| 5793 | 6139 | $value = (float)$matches[1]; |
| 5794 | 6140 | $str = $matches[3]; |
| 5795 | - } |
|
| 5796 | - else if($type == 's' && preg_match('/^s:([0-9]+):"(.*)/s', $str, $matches) && substr($matches[2], (int)$matches[1], 2) == '";') |
|
| 6141 | + } else if($type == 's' && preg_match('/^s:([0-9]+):"(.*)/s', $str, $matches) && substr($matches[2], (int)$matches[1], 2) == '";') |
|
| 5797 | 6142 | { |
| 5798 | 6143 | $value = substr($matches[2], 0, (int)$matches[1]); |
| 5799 | 6144 | $str = substr($matches[2], (int)$matches[1] + 2); |
| 5800 | - } |
|
| 5801 | - else if($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches)) |
|
| 6145 | + } else if($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches)) |
|
| 5802 | 6146 | { |
| 5803 | 6147 | $expectedLength = (int)$matches[1]; |
| 5804 | 6148 | $str = $matches[2]; |
| 5805 | 6149 | } |
| 5806 | 6150 | |
| 5807 | 6151 | // Object or unknown/malformed type. |
| 5808 | - else |
|
| 5809 | - return false; |
|
| 6152 | + else { |
|
| 6153 | + return false; |
|
| 6154 | + } |
|
| 5810 | 6155 | |
| 5811 | 6156 | switch($state) |
| 5812 | 6157 | { |
@@ -5834,8 +6179,9 @@ discard block |
||
| 5834 | 6179 | if($type == '}') |
| 5835 | 6180 | { |
| 5836 | 6181 | // Array size is less than expected. |
| 5837 | - if(count($list) < end($expected)) |
|
| 5838 | - return false; |
|
| 6182 | + if(count($list) < end($expected)) { |
|
| 6183 | + return false; |
|
| 6184 | + } |
|
| 5839 | 6185 | |
| 5840 | 6186 | unset($list); |
| 5841 | 6187 | $list = &$stack[count($stack)-1]; |
@@ -5844,8 +6190,9 @@ discard block |
||
| 5844 | 6190 | // Go to terminal state if we're at the end of the root array. |
| 5845 | 6191 | array_pop($expected); |
| 5846 | 6192 | |
| 5847 | - if(count($expected) == 0) |
|
| 5848 | - $state = 1; |
|
| 6193 | + if(count($expected) == 0) { |
|
| 6194 | + $state = 1; |
|
| 6195 | + } |
|
| 5849 | 6196 | |
| 5850 | 6197 | break; |
| 5851 | 6198 | } |
@@ -5853,8 +6200,9 @@ discard block |
||
| 5853 | 6200 | if($type == 'i' || $type == 's') |
| 5854 | 6201 | { |
| 5855 | 6202 | // Array size exceeds expected length. |
| 5856 | - if(count($list) >= end($expected)) |
|
| 5857 | - return false; |
|
| 6203 | + if(count($list) >= end($expected)) { |
|
| 6204 | + return false; |
|
| 6205 | + } |
|
| 5858 | 6206 | |
| 5859 | 6207 | $key = $value; |
| 5860 | 6208 | $state = 3; |
@@ -5888,8 +6236,9 @@ discard block |
||
| 5888 | 6236 | } |
| 5889 | 6237 | |
| 5890 | 6238 | // Trailing data in input. |
| 5891 | - if(!empty($str)) |
|
| 5892 | - return false; |
|
| 6239 | + if(!empty($str)) { |
|
| 6240 | + return false; |
|
| 6241 | + } |
|
| 5893 | 6242 | |
| 5894 | 6243 | return $data; |
| 5895 | 6244 | } |
@@ -5912,8 +6261,9 @@ discard block |
||
| 5912 | 6261 | |
| 5913 | 6262 | $out = _safe_unserialize($str); |
| 5914 | 6263 | |
| 5915 | - if (isset($mbIntEnc)) |
|
| 5916 | - mb_internal_encoding($mbIntEnc); |
|
| 6264 | + if (isset($mbIntEnc)) { |
|
| 6265 | + mb_internal_encoding($mbIntEnc); |
|
| 6266 | + } |
|
| 5917 | 6267 | |
| 5918 | 6268 | return $out; |
| 5919 | 6269 | } |
@@ -5928,12 +6278,14 @@ discard block |
||
| 5928 | 6278 | function smf_chmod($file, $value = 0) |
| 5929 | 6279 | { |
| 5930 | 6280 | // No file? no checks! |
| 5931 | - if (empty($file)) |
|
| 5932 | - return false; |
|
| 6281 | + if (empty($file)) { |
|
| 6282 | + return false; |
|
| 6283 | + } |
|
| 5933 | 6284 | |
| 5934 | 6285 | // Already writable? |
| 5935 | - if (is_writable($file)) |
|
| 5936 | - return true; |
|
| 6286 | + if (is_writable($file)) { |
|
| 6287 | + return true; |
|
| 6288 | + } |
|
| 5937 | 6289 | |
| 5938 | 6290 | // Do we have a file or a dir? |
| 5939 | 6291 | $isDir = is_dir($file); |
@@ -5949,10 +6301,9 @@ discard block |
||
| 5949 | 6301 | { |
| 5950 | 6302 | $isWritable = true; |
| 5951 | 6303 | break; |
| 6304 | + } else { |
|
| 6305 | + @chmod($file, $val); |
|
| 5952 | 6306 | } |
| 5953 | - |
|
| 5954 | - else |
|
| 5955 | - @chmod($file, $val); |
|
| 5956 | 6307 | } |
| 5957 | 6308 | |
| 5958 | 6309 | return $isWritable; |
@@ -5971,8 +6322,9 @@ discard block |
||
| 5971 | 6322 | global $txt; |
| 5972 | 6323 | |
| 5973 | 6324 | // Come on... |
| 5974 | - if (empty($json) || !is_string($json)) |
|
| 5975 | - return array(); |
|
| 6325 | + if (empty($json) || !is_string($json)) { |
|
| 6326 | + return array(); |
|
| 6327 | + } |
|
| 5976 | 6328 | |
| 5977 | 6329 | $returnArray = @json_decode($json, $returnAsArray); |
| 5978 | 6330 | |
@@ -6010,11 +6362,11 @@ discard block |
||
| 6010 | 6362 | $jsonDebug = $jsonDebug[0]; |
| 6011 | 6363 | loadLanguage('Errors'); |
| 6012 | 6364 | |
| 6013 | - if (!empty($jsonDebug)) |
|
| 6014 | - log_error($txt['json_'. $jsonError], 'critical', $jsonDebug['file'], $jsonDebug['line']); |
|
| 6015 | - |
|
| 6016 | - else |
|
| 6017 | - log_error($txt['json_'. $jsonError], 'critical'); |
|
| 6365 | + if (!empty($jsonDebug)) { |
|
| 6366 | + log_error($txt['json_'. $jsonError], 'critical', $jsonDebug['file'], $jsonDebug['line']); |
|
| 6367 | + } else { |
|
| 6368 | + log_error($txt['json_'. $jsonError], 'critical'); |
|
| 6369 | + } |
|
| 6018 | 6370 | |
| 6019 | 6371 | // Everyone expects an array. |
| 6020 | 6372 | return array(); |
@@ -6048,8 +6400,9 @@ discard block |
||
| 6048 | 6400 | global $db_show_debug, $modSettings; |
| 6049 | 6401 | |
| 6050 | 6402 | // Defensive programming anyone? |
| 6051 | - if (empty($data)) |
|
| 6052 | - return false; |
|
| 6403 | + if (empty($data)) { |
|
| 6404 | + return false; |
|
| 6405 | + } |
|
| 6053 | 6406 | |
| 6054 | 6407 | // Don't need extra stuff... |
| 6055 | 6408 | $db_show_debug = false; |
@@ -6057,11 +6410,11 @@ discard block |
||
| 6057 | 6410 | // Kill anything else. |
| 6058 | 6411 | ob_end_clean(); |
| 6059 | 6412 | |
| 6060 | - if (!empty($modSettings['CompressedOutput'])) |
|
| 6061 | - @ob_start('ob_gzhandler'); |
|
| 6062 | - |
|
| 6063 | - else |
|
| 6064 | - ob_start(); |
|
| 6413 | + if (!empty($modSettings['CompressedOutput'])) { |
|
| 6414 | + @ob_start('ob_gzhandler'); |
|
| 6415 | + } else { |
|
| 6416 | + ob_start(); |
|
| 6417 | + } |
|
| 6065 | 6418 | |
| 6066 | 6419 | // Set the header. |
| 6067 | 6420 | header($type); |
@@ -6093,8 +6446,9 @@ discard block |
||
| 6093 | 6446 | static $done = false; |
| 6094 | 6447 | |
| 6095 | 6448 | // If we don't need to do anything, don't |
| 6096 | - if (!$update && $done) |
|
| 6097 | - return; |
|
| 6449 | + if (!$update && $done) { |
|
| 6450 | + return; |
|
| 6451 | + } |
|
| 6098 | 6452 | |
| 6099 | 6453 | // Should we get a new copy of the official list of TLDs? |
| 6100 | 6454 | if ($update) |
@@ -6106,8 +6460,9 @@ discard block |
||
| 6106 | 6460 | // marauding bandits roaming on the surface. We don't want to waste precious electricity on |
| 6107 | 6461 | // pointlessly repeating background tasks, so we'll wait until the next regularly scheduled |
| 6108 | 6462 | // update to see if civilization has been restored. |
| 6109 | - if ($tlds === false) |
|
| 6110 | - $postapocalypticNightmare = true; |
|
| 6463 | + if ($tlds === false) { |
|
| 6464 | + $postapocalypticNightmare = true; |
|
| 6465 | + } |
|
| 6111 | 6466 | } |
| 6112 | 6467 | // If we aren't updating and the regex is valid, we're done |
| 6113 | 6468 | elseif (!empty($modSettings['tld_regex']) && @preg_match('~' . $modSettings['tld_regex'] . '~', null) !== false) |
@@ -6122,10 +6477,11 @@ discard block |
||
| 6122 | 6477 | // Clean $tlds and convert it to an array |
| 6123 | 6478 | $tlds = array_filter(explode("\n", strtolower($tlds)), function($line) { |
| 6124 | 6479 | $line = trim($line); |
| 6125 | - if (empty($line) || strpos($line, '#') !== false || strpos($line, ' ') !== false) |
|
| 6126 | - return false; |
|
| 6127 | - else |
|
| 6128 | - return true; |
|
| 6480 | + if (empty($line) || strpos($line, '#') !== false || strpos($line, ' ') !== false) { |
|
| 6481 | + return false; |
|
| 6482 | + } else { |
|
| 6483 | + return true; |
|
| 6484 | + } |
|
| 6129 | 6485 | }); |
| 6130 | 6486 | |
| 6131 | 6487 | // Convert Punycode to Unicode |
@@ -6217,8 +6573,7 @@ discard block |
||
| 6217 | 6573 | |
| 6218 | 6574 | $strlen = 'mb_strlen'; |
| 6219 | 6575 | $substr = 'mb_substr'; |
| 6220 | - } |
|
| 6221 | - else |
|
| 6576 | + } else |
|
| 6222 | 6577 | { |
| 6223 | 6578 | $strlen = $smcFunc['strlen']; |
| 6224 | 6579 | $substr = $smcFunc['substr']; |
@@ -6232,20 +6587,21 @@ discard block |
||
| 6232 | 6587 | |
| 6233 | 6588 | $first = $substr($string, 0, 1); |
| 6234 | 6589 | |
| 6235 | - if (empty($index[$first])) |
|
| 6236 | - $index[$first] = array(); |
|
| 6590 | + if (empty($index[$first])) { |
|
| 6591 | + $index[$first] = array(); |
|
| 6592 | + } |
|
| 6237 | 6593 | |
| 6238 | 6594 | if ($strlen($string) > 1) |
| 6239 | 6595 | { |
| 6240 | 6596 | // Sanity check on recursion |
| 6241 | - if ($depth > 99) |
|
| 6242 | - $index[$first][$substr($string, 1)] = ''; |
|
| 6243 | - |
|
| 6244 | - else |
|
| 6245 | - $index[$first] = $add_string_to_index($substr($string, 1), $index[$first]); |
|
| 6597 | + if ($depth > 99) { |
|
| 6598 | + $index[$first][$substr($string, 1)] = ''; |
|
| 6599 | + } else { |
|
| 6600 | + $index[$first] = $add_string_to_index($substr($string, 1), $index[$first]); |
|
| 6601 | + } |
|
| 6602 | + } else { |
|
| 6603 | + $index[$first][''] = ''; |
|
| 6246 | 6604 | } |
| 6247 | - else |
|
| 6248 | - $index[$first][''] = ''; |
|
| 6249 | 6605 | |
| 6250 | 6606 | $depth--; |
| 6251 | 6607 | return $index; |
@@ -6268,9 +6624,9 @@ discard block |
||
| 6268 | 6624 | $key_regex = preg_quote($key, $delim); |
| 6269 | 6625 | $new_key = $key; |
| 6270 | 6626 | |
| 6271 | - if (empty($value)) |
|
| 6272 | - $sub_regex = ''; |
|
| 6273 | - else |
|
| 6627 | + if (empty($value)) { |
|
| 6628 | + $sub_regex = ''; |
|
| 6629 | + } else |
|
| 6274 | 6630 | { |
| 6275 | 6631 | $sub_regex = $index_to_regex($value, $delim); |
| 6276 | 6632 | |
@@ -6278,22 +6634,22 @@ discard block |
||
| 6278 | 6634 | { |
| 6279 | 6635 | $new_key_array = explode('(?'.'>', $sub_regex); |
| 6280 | 6636 | $new_key .= $new_key_array[0]; |
| 6637 | + } else { |
|
| 6638 | + $sub_regex = '(?'.'>' . $sub_regex . ')'; |
|
| 6281 | 6639 | } |
| 6282 | - else |
|
| 6283 | - $sub_regex = '(?'.'>' . $sub_regex . ')'; |
|
| 6284 | 6640 | } |
| 6285 | 6641 | |
| 6286 | - if ($depth > 1) |
|
| 6287 | - $regex[$new_key] = $key_regex . $sub_regex; |
|
| 6288 | - else |
|
| 6642 | + if ($depth > 1) { |
|
| 6643 | + $regex[$new_key] = $key_regex . $sub_regex; |
|
| 6644 | + } else |
|
| 6289 | 6645 | { |
| 6290 | 6646 | if (($length += strlen($key_regex) + 1) < $max_length || empty($regex)) |
| 6291 | 6647 | { |
| 6292 | 6648 | $regex[$new_key] = $key_regex . $sub_regex; |
| 6293 | 6649 | unset($index[$key]); |
| 6650 | + } else { |
|
| 6651 | + break; |
|
| 6294 | 6652 | } |
| 6295 | - else |
|
| 6296 | - break; |
|
| 6297 | 6653 | } |
| 6298 | 6654 | } |
| 6299 | 6655 | |
@@ -6302,10 +6658,11 @@ discard block |
||
| 6302 | 6658 | $l1 = $strlen($k1); |
| 6303 | 6659 | $l2 = $strlen($k2); |
| 6304 | 6660 | |
| 6305 | - if ($l1 == $l2) |
|
| 6306 | - return strcmp($k1, $k2) > 0 ? 1 : -1; |
|
| 6307 | - else |
|
| 6308 | - return $l1 > $l2 ? -1 : 1; |
|
| 6661 | + if ($l1 == $l2) { |
|
| 6662 | + return strcmp($k1, $k2) > 0 ? 1 : -1; |
|
| 6663 | + } else { |
|
| 6664 | + return $l1 > $l2 ? -1 : 1; |
|
| 6665 | + } |
|
| 6309 | 6666 | }); |
| 6310 | 6667 | |
| 6311 | 6668 | $depth--; |
@@ -6316,21 +6673,24 @@ discard block |
||
| 6316 | 6673 | $index = array(); |
| 6317 | 6674 | $regex = ''; |
| 6318 | 6675 | |
| 6319 | - foreach ($strings as $string) |
|
| 6320 | - $index = $add_string_to_index($string, $index); |
|
| 6676 | + foreach ($strings as $string) { |
|
| 6677 | + $index = $add_string_to_index($string, $index); |
|
| 6678 | + } |
|
| 6321 | 6679 | |
| 6322 | 6680 | if ($returnArray === true) |
| 6323 | 6681 | { |
| 6324 | 6682 | $regex = array(); |
| 6325 | - while (!empty($index)) |
|
| 6326 | - $regex[] = '(?'.'>' . $index_to_regex($index, $delim) . ')'; |
|
| 6683 | + while (!empty($index)) { |
|
| 6684 | + $regex[] = '(?'.'>' . $index_to_regex($index, $delim) . ')'; |
|
| 6685 | + } |
|
| 6686 | + } else { |
|
| 6687 | + $regex = '(?'.'>' . $index_to_regex($index, $delim) . ')'; |
|
| 6327 | 6688 | } |
| 6328 | - else |
|
| 6329 | - $regex = '(?'.'>' . $index_to_regex($index, $delim) . ')'; |
|
| 6330 | 6689 | |
| 6331 | 6690 | // Restore PHP's internal character encoding to whatever it was originally |
| 6332 | - if (!empty($current_encoding)) |
|
| 6333 | - mb_internal_encoding($current_encoding); |
|
| 6691 | + if (!empty($current_encoding)) { |
|
| 6692 | + mb_internal_encoding($current_encoding); |
|
| 6693 | + } |
|
| 6334 | 6694 | |
| 6335 | 6695 | return $regex; |
| 6336 | 6696 | } |
@@ -6373,13 +6733,15 @@ discard block |
||
| 6373 | 6733 | // Need to add the trailing slash, or it puts it there & thinks there's a redirect when there isn't... |
| 6374 | 6734 | $url = str_ireplace('https://', 'http://', $url) . '/'; |
| 6375 | 6735 | $headers = @get_headers($url); |
| 6376 | - if ($headers === false) |
|
| 6377 | - return false; |
|
| 6736 | + if ($headers === false) { |
|
| 6737 | + return false; |
|
| 6738 | + } |
|
| 6378 | 6739 | |
| 6379 | 6740 | // Now to see if it came back https... |
| 6380 | 6741 | // First check for a redirect status code in first row (301, 302, 307) |
| 6381 | - if (strstr($headers[0], '301') === false && strstr($headers[0], '302') === false && strstr($headers[0], '307') === false) |
|
| 6382 | - return false; |
|
| 6742 | + if (strstr($headers[0], '301') === false && strstr($headers[0], '302') === false && strstr($headers[0], '307') === false) { |
|
| 6743 | + return false; |
|
| 6744 | + } |
|
| 6383 | 6745 | |
| 6384 | 6746 | // Search for the location entry to confirm https |
| 6385 | 6747 | $result = false; |
@@ -6417,8 +6779,7 @@ discard block |
||
| 6417 | 6779 | $is_admin = $user_info['is_admin']; |
| 6418 | 6780 | $mod_cache = !empty($user_info['mod_cache']) ? $user_info['mod_cache'] : null; |
| 6419 | 6781 | $ignoreboards = !empty($user_info['ignoreboards']) ? $user_info['ignoreboards'] : null; |
| 6420 | - } |
|
| 6421 | - else |
|
| 6782 | + } else |
|
| 6422 | 6783 | { |
| 6423 | 6784 | $request = $smcFunc['db_query']('', ' |
| 6424 | 6785 | SELECT mem.ignore_boards, mem.id_group, mem.additional_groups, mem.id_post_group |
@@ -6432,17 +6793,19 @@ discard block |
||
| 6432 | 6793 | |
| 6433 | 6794 | $row = $smcFunc['db_fetch_assoc']($request); |
| 6434 | 6795 | |
| 6435 | - if (empty($row['additional_groups'])) |
|
| 6436 | - $groups = array($row['id_group'], $row['id_post_group']); |
|
| 6437 | - else |
|
| 6438 | - $groups = array_merge( |
|
| 6796 | + if (empty($row['additional_groups'])) { |
|
| 6797 | + $groups = array($row['id_group'], $row['id_post_group']); |
|
| 6798 | + } else { |
|
| 6799 | + $groups = array_merge( |
|
| 6439 | 6800 | array($row['id_group'], $row['id_post_group']), |
| 6440 | 6801 | explode(',', $row['additional_groups']) |
| 6441 | 6802 | ); |
| 6803 | + } |
|
| 6442 | 6804 | |
| 6443 | 6805 | // Because history has proven that it is possible for groups to go bad - clean up in case. |
| 6444 | - foreach ($groups as $k => $v) |
|
| 6445 | - $groups[$k] = (int) $v; |
|
| 6806 | + foreach ($groups as $k => $v) { |
|
| 6807 | + $groups[$k] = (int) $v; |
|
| 6808 | + } |
|
| 6446 | 6809 | |
| 6447 | 6810 | $is_admin = in_array(1, $groups); |
| 6448 | 6811 | |
@@ -6459,8 +6822,9 @@ discard block |
||
| 6459 | 6822 | 'current_member' => $userid, |
| 6460 | 6823 | ) |
| 6461 | 6824 | ); |
| 6462 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 6463 | - $boards_mod[] = $row['id_board']; |
|
| 6825 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 6826 | + $boards_mod[] = $row['id_board']; |
|
| 6827 | + } |
|
| 6464 | 6828 | $smcFunc['db_free_result']($request); |
| 6465 | 6829 | |
| 6466 | 6830 | // Can any of the groups they're in moderate any of the boards? |
@@ -6472,8 +6836,9 @@ discard block |
||
| 6472 | 6836 | 'groups' => $groups, |
| 6473 | 6837 | ) |
| 6474 | 6838 | ); |
| 6475 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 6476 | - $boards_mod[] = $row['id_board']; |
|
| 6839 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 6840 | + $boards_mod[] = $row['id_board']; |
|
| 6841 | + } |
|
| 6477 | 6842 | $smcFunc['db_free_result']($request); |
| 6478 | 6843 | |
| 6479 | 6844 | // Just in case we've got duplicates here... |
@@ -6483,21 +6848,25 @@ discard block |
||
| 6483 | 6848 | } |
| 6484 | 6849 | |
| 6485 | 6850 | // Just build this here, it makes it easier to change/use - administrators can see all boards. |
| 6486 | - if ($is_admin) |
|
| 6487 | - $query_part['query_see_board'] = '1=1'; |
|
| 6851 | + if ($is_admin) { |
|
| 6852 | + $query_part['query_see_board'] = '1=1'; |
|
| 6853 | + } |
|
| 6488 | 6854 | // Otherwise just the groups in $user_info['groups']. |
| 6489 | - else |
|
| 6490 | - $query_part['query_see_board'] = '((FIND_IN_SET(' . implode(', b.member_groups) != 0 OR FIND_IN_SET(', $groups) . ', b.member_groups) != 0)' . (!empty($deny_boards_access) ? ' AND (FIND_IN_SET(' . implode(', b.deny_member_groups) = 0 AND FIND_IN_SET(', $groups) . ', b.deny_member_groups) = 0)' : '') . (isset($mod_cache) ? ' OR ' . $mod_cache['mq'] : '') . ')'; |
|
| 6855 | + else { |
|
| 6856 | + $query_part['query_see_board'] = '((FIND_IN_SET(' . implode(', b.member_groups) != 0 OR FIND_IN_SET(', $groups) . ', b.member_groups) != 0)' . (!empty($deny_boards_access) ? ' AND (FIND_IN_SET(' . implode(', b.deny_member_groups) = 0 AND FIND_IN_SET(', $groups) . ', b.deny_member_groups) = 0)' : '') . (isset($mod_cache) ? ' OR ' . $mod_cache['mq'] : '') . ')'; |
|
| 6857 | + } |
|
| 6491 | 6858 | |
| 6492 | 6859 | // Build the list of boards they WANT to see. |
| 6493 | 6860 | // This will take the place of query_see_boards in certain spots, so it better include the boards they can see also |
| 6494 | 6861 | |
| 6495 | 6862 | // If they aren't ignoring any boards then they want to see all the boards they can see |
| 6496 | - if (empty($ignoreboards)) |
|
| 6497 | - $query_part['query_wanna_see_board'] = $query_part['query_see_board']; |
|
| 6863 | + if (empty($ignoreboards)) { |
|
| 6864 | + $query_part['query_wanna_see_board'] = $query_part['query_see_board']; |
|
| 6865 | + } |
|
| 6498 | 6866 | // Ok I guess they don't want to see all the boards |
| 6499 | - else |
|
| 6500 | - $query_part['query_wanna_see_board'] = '(' . $query_part['query_see_board'] . ' AND b.id_board NOT IN (' . implode(',', $ignoreboards) . '))'; |
|
| 6867 | + else { |
|
| 6868 | + $query_part['query_wanna_see_board'] = '(' . $query_part['query_see_board'] . ' AND b.id_board NOT IN (' . implode(',', $ignoreboards) . '))'; |
|
| 6869 | + } |
|
| 6501 | 6870 | |
| 6502 | 6871 | return $query_part; |
| 6503 | 6872 | } |
@@ -6511,10 +6880,11 @@ discard block |
||
| 6511 | 6880 | { |
| 6512 | 6881 | $secure = false; |
| 6513 | 6882 | |
| 6514 | - if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') |
|
| 6515 | - $secure = true; |
|
| 6516 | - elseif (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on') |
|
| 6517 | - $secure = true; |
|
| 6883 | + if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') { |
|
| 6884 | + $secure = true; |
|
| 6885 | + } elseif (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on') { |
|
| 6886 | + $secure = true; |
|
| 6887 | + } |
|
| 6518 | 6888 | |
| 6519 | 6889 | return $secure; |
| 6520 | 6890 | } |
@@ -6531,11 +6901,12 @@ discard block |
||
| 6531 | 6901 | { |
| 6532 | 6902 | $url = iri_to_url($iri); |
| 6533 | 6903 | |
| 6534 | - if (filter_var($url, FILTER_VALIDATE_URL, $flags) !== false) |
|
| 6535 | - return $iri; |
|
| 6536 | - else |
|
| 6537 | - return false; |
|
| 6538 | -} |
|
| 6904 | + if (filter_var($url, FILTER_VALIDATE_URL, $flags) !== false) { |
|
| 6905 | + return $iri; |
|
| 6906 | + } else { |
|
| 6907 | + return false; |
|
| 6908 | + } |
|
| 6909 | + } |
|
| 6539 | 6910 | |
| 6540 | 6911 | /** |
| 6541 | 6912 | * A wrapper for `filter_var($url, FILTER_SANITIZE_URL)` that can handle URLs |
@@ -6578,8 +6949,9 @@ discard block |
||
| 6578 | 6949 | |
| 6579 | 6950 | $host = parse_url((strpos($iri, '://') === false ? 'http://' : '') . ltrim($iri, ':/'), PHP_URL_HOST); |
| 6580 | 6951 | |
| 6581 | - if (empty($host)) |
|
| 6582 | - return $iri; |
|
| 6952 | + if (empty($host)) { |
|
| 6953 | + return $iri; |
|
| 6954 | + } |
|
| 6583 | 6955 | |
| 6584 | 6956 | // Convert the domain using the Punycode algorithm |
| 6585 | 6957 | require_once($sourcedir . '/Class-Punycode.php'); |
@@ -6615,8 +6987,9 @@ discard block |
||
| 6615 | 6987 | |
| 6616 | 6988 | $host = parse_url((strpos($url, '://') === false ? 'http://' : '') . ltrim($url, ':/'), PHP_URL_HOST); |
| 6617 | 6989 | |
| 6618 | - if (empty($host)) |
|
| 6619 | - return $url; |
|
| 6990 | + if (empty($host)) { |
|
| 6991 | + return $url; |
|
| 6992 | + } |
|
| 6620 | 6993 | |
| 6621 | 6994 | // Decode the domain from Punycode |
| 6622 | 6995 | require_once($sourcedir . '/Class-Punycode.php'); |
@@ -6642,8 +7015,9 @@ discard block |
||
| 6642 | 7015 | { |
| 6643 | 7016 | global $user_info, $modSettings, $smcFunc, $txt; |
| 6644 | 7017 | |
| 6645 | - if (empty($modSettings['cron_last_checked'])) |
|
| 6646 | - $modSettings['cron_last_checked'] = 0; |
|
| 7018 | + if (empty($modSettings['cron_last_checked'])) { |
|
| 7019 | + $modSettings['cron_last_checked'] = 0; |
|
| 7020 | + } |
|
| 6647 | 7021 | |
| 6648 | 7022 | if (!empty($modSettings['cron_is_real_cron']) && time() - $modSettings['cron_last_checked'] > 84600) |
| 6649 | 7023 | { |
@@ -6663,9 +7037,9 @@ discard block |
||
| 6663 | 7037 | loadLanguage('ManageScheduledTasks'); |
| 6664 | 7038 | log_error($txt['cron_not_working']); |
| 6665 | 7039 | updateSettings(array('cron_is_real_cron' => 0)); |
| 7040 | + } else { |
|
| 7041 | + updateSettings(array('cron_last_checked' => time())); |
|
| 6666 | 7042 | } |
| 6667 | - else |
|
| 6668 | - updateSettings(array('cron_last_checked' => time())); |
|
| 6669 | 7043 | } |
| 6670 | 7044 | } |
| 6671 | 7045 | |