@@ -24,7 +24,7 @@ |
||
| 24 | 24 | * Used by VerificationCode() (Register.php). |
| 25 | 25 | * |
| 26 | 26 | * @param string $word |
| 27 | - * @return boolean false on failure |
|
| 27 | + * @return null|false false on failure |
|
| 28 | 28 | */ |
| 29 | 29 | |
| 30 | 30 | function createWaveFile($word) |
@@ -15,8 +15,9 @@ discard block |
||
| 15 | 15 | * @version 2.1 Beta 3 |
| 16 | 16 | */ |
| 17 | 17 | |
| 18 | -if (!defined('SMF')) |
|
| 18 | +if (!defined('SMF')) { |
|
| 19 | 19 | die('No direct access...'); |
| 20 | +} |
|
| 20 | 21 | |
| 21 | 22 | /** |
| 22 | 23 | * Creates a wave file that spells the letters of $word. |
@@ -32,8 +33,9 @@ discard block |
||
| 32 | 33 | global $settings, $user_info; |
| 33 | 34 | |
| 34 | 35 | // Allow max 2 requests per 20 seconds. |
| 35 | - if (($ip = cache_get_data('wave_file/' . $user_info['ip'], 20)) > 2 || ($ip2 = cache_get_data('wave_file/' . $user_info['ip2'], 20)) > 2) |
|
| 36 | - die(header('HTTP/1.1 400 Bad Request')); |
|
| 36 | + if (($ip = cache_get_data('wave_file/' . $user_info['ip'], 20)) > 2 || ($ip2 = cache_get_data('wave_file/' . $user_info['ip2'], 20)) > 2) { |
|
| 37 | + die(header('HTTP/1.1 400 Bad Request')); |
|
| 38 | + } |
|
| 37 | 39 | cache_put_data('wave_file/' . $user_info['ip'], $ip ? $ip + 1 : 1, 20); |
| 38 | 40 | cache_put_data('wave_file/' . $user_info['ip2'], $ip2 ? $ip2 + 1 : 1, 20); |
| 39 | 41 | |
@@ -41,16 +43,19 @@ discard block |
||
| 41 | 43 | mt_srand(end(unpack('n', md5($word . session_id())))); |
| 42 | 44 | |
| 43 | 45 | // Try to see if there's a sound font in the user's language. |
| 44 | - if (file_exists($settings['default_theme_dir'] . '/fonts/sound/a.' . $user_info['language'] . '.wav')) |
|
| 45 | - $sound_language = $user_info['language']; |
|
| 46 | + if (file_exists($settings['default_theme_dir'] . '/fonts/sound/a.' . $user_info['language'] . '.wav')) { |
|
| 47 | + $sound_language = $user_info['language']; |
|
| 48 | + } |
|
| 46 | 49 | |
| 47 | 50 | // English should be there. |
| 48 | - elseif (file_exists($settings['default_theme_dir'] . '/fonts/sound/a.english.wav')) |
|
| 49 | - $sound_language = 'english'; |
|
| 51 | + elseif (file_exists($settings['default_theme_dir'] . '/fonts/sound/a.english.wav')) { |
|
| 52 | + $sound_language = 'english'; |
|
| 53 | + } |
|
| 50 | 54 | |
| 51 | 55 | // Guess not... |
| 52 | - else |
|
| 53 | - return false; |
|
| 56 | + else { |
|
| 57 | + return false; |
|
| 58 | + } |
|
| 54 | 59 | |
| 55 | 60 | // File names are in lower case so lets make sure that we are only using a lower case string |
| 56 | 61 | $word = strtolower($word); |
@@ -60,20 +65,25 @@ discard block |
||
| 60 | 65 | for ($i = 0; $i < strlen($word); $i++) |
| 61 | 66 | { |
| 62 | 67 | $sound_letter = implode('', file($settings['default_theme_dir'] . '/fonts/sound/' . $word{$i} . '.' . $sound_language . '.wav')); |
| 63 | - if (strpos($sound_letter, 'data') === false) |
|
| 64 | - return false; |
|
| 68 | + if (strpos($sound_letter, 'data') === false) { |
|
| 69 | + return false; |
|
| 70 | + } |
|
| 65 | 71 | |
| 66 | 72 | $sound_letter = substr($sound_letter, strpos($sound_letter, 'data') + 8); |
| 67 | 73 | switch ($word{$i} === 's' ? 0 : mt_rand(0, 2)) |
| 68 | 74 | { |
| 69 | - case 0 : for ($j = 0, $n = strlen($sound_letter); $j < $n; $j++) |
|
| 70 | - for ($k = 0, $m = round(mt_rand(15, 25) / 10); $k < $m; $k++) |
|
| 71 | - $sound_word .= $word{$i} === 's' ? $sound_letter{$j} : chr(mt_rand(max(ord($sound_letter{$j}) - 1, 0x00), min(ord($sound_letter{$j}) + 1, 0xFF))); |
|
| 75 | + case 0 : for ($j = 0, $n = strlen($sound_letter); $j < $n; $j++) { |
|
| 76 | + for ($k = 0, $m = round(mt_rand(15, 25) / 10); |
|
| 77 | + } |
|
| 78 | + $k < $m; $k++) { |
|
| 79 | + $sound_word .= $word{$i} === 's' ? $sound_letter{$j} : chr(mt_rand(max(ord($sound_letter{$j}) - 1, 0x00), min(ord($sound_letter{$j}) + 1, 0xFF))); |
|
| 80 | + } |
|
| 72 | 81 | break; |
| 73 | 82 | |
| 74 | 83 | case 1: |
| 75 | - for ($j = 0, $n = strlen($sound_letter) - 1; $j < $n; $j += 2) |
|
| 76 | - $sound_word .= (mt_rand(0, 3) == 0 ? '' : $sound_letter{$j}) . (mt_rand(0, 3) === 0 ? $sound_letter{$j + 1} : $sound_letter{$j}) . (mt_rand(0, 3) === 0 ? $sound_letter{$j} : $sound_letter{$j + 1}) . $sound_letter{$j + 1} . (mt_rand(0, 3) == 0 ? $sound_letter{$j + 1} : ''); |
|
| 84 | + for ($j = 0, $n = strlen($sound_letter) - 1; $j < $n; $j += 2) { |
|
| 85 | + $sound_word .= (mt_rand(0, 3) == 0 ? '' : $sound_letter{$j}) . (mt_rand(0, 3) === 0 ? $sound_letter{$j + 1} : $sound_letter{$j}) . (mt_rand(0, 3) === 0 ? $sound_letter{$j} : $sound_letter{$j + 1}) . $sound_letter{$j + 1} . (mt_rand(0, 3) == 0 ? $sound_letter{$j + 1} : ''); |
|
| 86 | + } |
|
| 77 | 87 | $sound_word .= str_repeat($sound_letter{$n}, 2); |
| 78 | 88 | break; |
| 79 | 89 | |
@@ -81,10 +91,12 @@ discard block |
||
| 81 | 91 | $shift = 0; |
| 82 | 92 | for ($j = 0, $n = strlen($sound_letter); $j < $n; $j++) |
| 83 | 93 | { |
| 84 | - if (mt_rand(0, 10) === 0) |
|
| 85 | - $shift += mt_rand(-3, 3); |
|
| 86 | - for ($k = 0, $m = round(mt_rand(15, 25) / 10); $k < $m; $k++) |
|
| 87 | - $sound_word .= chr(min(max(ord($sound_letter{$j}) + $shift, 0x00), 0xFF)); |
|
| 94 | + if (mt_rand(0, 10) === 0) { |
|
| 95 | + $shift += mt_rand(-3, 3); |
|
| 96 | + } |
|
| 97 | + for ($k = 0, $m = round(mt_rand(15, 25) / 10); $k < $m; $k++) { |
|
| 98 | + $sound_word .= chr(min(max(ord($sound_letter{$j}) + $shift, 0x00), 0xFF)); |
|
| 99 | + } |
|
| 88 | 100 | } |
| 89 | 101 | break; |
| 90 | 102 | |
@@ -425,7 +425,7 @@ |
||
| 425 | 425 | * |
| 426 | 426 | * This is a recursive function, it will call itself if there are subdirs inside the main directory. |
| 427 | 427 | * @param string $path The absolute path to the directory to be removed |
| 428 | - * @return bool true when success, false on error. |
|
| 428 | + * @return false|null true when success, false on error. |
|
| 429 | 429 | */ |
| 430 | 430 | function remove_dir($path) |
| 431 | 431 | { |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 3 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * Gets a single theme's info. |
@@ -27,8 +28,9 @@ discard block |
||
| 27 | 28 | global $smcFunc, $modSettings; |
| 28 | 29 | |
| 29 | 30 | // No data, no fun! |
| 30 | - if (empty($id)) |
|
| 31 | - return false; |
|
| 31 | + if (empty($id)) { |
|
| 32 | + return false; |
|
| 33 | + } |
|
| 32 | 34 | |
| 33 | 35 | // Make sure $id is an int. |
| 34 | 36 | $id = (int) $id; |
@@ -171,8 +173,9 @@ discard block |
||
| 171 | 173 | global $sourcedir, $forum_version, $txt, $scripturl, $context; |
| 172 | 174 | global $explicit_images; |
| 173 | 175 | |
| 174 | - if (empty($path)) |
|
| 175 | - return false; |
|
| 176 | + if (empty($path)) { |
|
| 177 | + return false; |
|
| 178 | + } |
|
| 176 | 179 | |
| 177 | 180 | $xml_data = array(); |
| 178 | 181 | $explicit_images = false; |
@@ -229,9 +232,10 @@ discard block |
||
| 229 | 232 | ); |
| 230 | 233 | |
| 231 | 234 | // Assign the values to be stored. |
| 232 | - foreach ($xml_elements as $var => $name) |
|
| 233 | - if (!empty($theme_info_xml[$name])) |
|
| 235 | + foreach ($xml_elements as $var => $name) { |
|
| 236 | + if (!empty($theme_info_xml[$name])) |
|
| 234 | 237 | $xml_data[$var] = $theme_info_xml[$name]; |
| 238 | + } |
|
| 235 | 239 | |
| 236 | 240 | // Add the supported versions. |
| 237 | 241 | $xml_data['install_for'] = $install_versions; |
@@ -243,8 +247,9 @@ discard block |
||
| 243 | 247 | $explicit_images = true; |
| 244 | 248 | } |
| 245 | 249 | |
| 246 | - if (!empty($theme_info_xml['extra'])) |
|
| 247 | - $xml_data += smf_json_decode($theme_info_xml['extra'], true); |
|
| 250 | + if (!empty($theme_info_xml['extra'])) { |
|
| 251 | + $xml_data += smf_json_decode($theme_info_xml['extra'], true); |
|
| 252 | + } |
|
| 248 | 253 | |
| 249 | 254 | return $xml_data; |
| 250 | 255 | } |
@@ -262,12 +267,14 @@ discard block |
||
| 262 | 267 | global $settings, $explicit_images; |
| 263 | 268 | |
| 264 | 269 | // External use? no problem! |
| 265 | - if ($to_install) |
|
| 266 | - $context['to_install'] = $to_install; |
|
| 270 | + if ($to_install) { |
|
| 271 | + $context['to_install'] = $to_install; |
|
| 272 | + } |
|
| 267 | 273 | |
| 268 | 274 | // One last check. |
| 269 | - if (empty($context['to_install']['theme_dir']) || basename($context['to_install']['theme_dir']) == 'Themes') |
|
| 270 | - fatal_lang_error('theme_install_invalid_dir', false); |
|
| 275 | + if (empty($context['to_install']['theme_dir']) || basename($context['to_install']['theme_dir']) == 'Themes') { |
|
| 276 | + fatal_lang_error('theme_install_invalid_dir', false); |
|
| 277 | + } |
|
| 271 | 278 | |
| 272 | 279 | // OK, is this a newer version of an already installed theme? |
| 273 | 280 | if (!empty($context['to_install']['version'])) |
@@ -292,8 +299,8 @@ discard block |
||
| 292 | 299 | $smcFunc['db_free_result']($request); |
| 293 | 300 | |
| 294 | 301 | // Got something, lets figure it out what to do next. |
| 295 | - if (!empty($to_update) && !empty($to_update['version'])) |
|
| 296 | - switch (compareVersions($context['to_install']['version'], $to_update['version'])) |
|
| 302 | + if (!empty($to_update) && !empty($to_update['version'])) { |
|
| 303 | + switch (compareVersions($context['to_install']['version'], $to_update['version'])) |
|
| 297 | 304 | { |
| 298 | 305 | case 1: // Got a newer version, update the old entry. |
| 299 | 306 | $smcFunc['db_query']('', ' |
@@ -307,6 +314,7 @@ discard block |
||
| 307 | 314 | 'id_theme' => $to_update['id_theme'], |
| 308 | 315 | ) |
| 309 | 316 | ); |
| 317 | + } |
|
| 310 | 318 | |
| 311 | 319 | // Done with the update, tell the user about it. |
| 312 | 320 | $context['to_install']['updated'] = true; |
@@ -372,13 +380,15 @@ discard block |
||
| 372 | 380 | $context['to_install']['base_theme_url'] = $temp['theme_url']; |
| 373 | 381 | $context['to_install']['base_theme_dir'] = $temp['theme_dir']; |
| 374 | 382 | |
| 375 | - if (empty($explicit_images) && !empty($context['to_install']['base_theme_url'])) |
|
| 376 | - $context['to_install']['theme_url'] = $context['to_install']['base_theme_url']; |
|
| 383 | + if (empty($explicit_images) && !empty($context['to_install']['base_theme_url'])) { |
|
| 384 | + $context['to_install']['theme_url'] = $context['to_install']['base_theme_url']; |
|
| 385 | + } |
|
| 377 | 386 | } |
| 378 | 387 | |
| 379 | 388 | // Nope, sorry, couldn't find any theme already installed. |
| 380 | - else |
|
| 381 | - fatal_lang_error('package_get_error_theme_no_based_on_found', false, $context['to_install']['based_on']); |
|
| 389 | + else { |
|
| 390 | + fatal_lang_error('package_get_error_theme_no_based_on_found', false, $context['to_install']['based_on']); |
|
| 391 | + } |
|
| 382 | 392 | } |
| 383 | 393 | |
| 384 | 394 | unset($context['to_install']['based_on']); |
@@ -401,16 +411,18 @@ discard block |
||
| 401 | 411 | call_integration_hook('integrate_theme_install', array(&$context['to_install'], $id_theme)); |
| 402 | 412 | |
| 403 | 413 | $inserts = array(); |
| 404 | - foreach ($context['to_install'] as $var => $val) |
|
| 405 | - $inserts[] = array($id_theme, $var, $val); |
|
| 414 | + foreach ($context['to_install'] as $var => $val) { |
|
| 415 | + $inserts[] = array($id_theme, $var, $val); |
|
| 416 | + } |
|
| 406 | 417 | |
| 407 | - if (!empty($inserts)) |
|
| 408 | - $smcFunc['db_insert']('insert', |
|
| 418 | + if (!empty($inserts)) { |
|
| 419 | + $smcFunc['db_insert']('insert', |
|
| 409 | 420 | '{db_prefix}themes', |
| 410 | 421 | array('id_theme' => 'int', 'variable' => 'string-255', 'value' => 'string-65534'), |
| 411 | 422 | $inserts, |
| 412 | 423 | array('id_theme', 'variable') |
| 413 | 424 | ); |
| 425 | + } |
|
| 414 | 426 | |
| 415 | 427 | // Update the known and enable Theme's settings. |
| 416 | 428 | $known = strtr($modSettings['knownThemes'] . ',' . $id_theme, array(',,' => ',')); |
@@ -429,21 +441,24 @@ discard block |
||
| 429 | 441 | */ |
| 430 | 442 | function remove_dir($path) |
| 431 | 443 | { |
| 432 | - if (empty($path)) |
|
| 433 | - return false; |
|
| 444 | + if (empty($path)) { |
|
| 445 | + return false; |
|
| 446 | + } |
|
| 434 | 447 | |
| 435 | 448 | if (is_dir($path)) |
| 436 | 449 | { |
| 437 | 450 | $objects = scandir($path); |
| 438 | 451 | |
| 439 | - foreach ($objects as $object) |
|
| 440 | - if ($object != '.' && $object != '..') |
|
| 452 | + foreach ($objects as $object) { |
|
| 453 | + if ($object != '.' && $object != '..') |
|
| 441 | 454 | { |
| 442 | 455 | if (filetype($path . '/' . $object) == 'dir') |
| 443 | 456 | remove_dir($path . '/' . $object); |
| 457 | + } |
|
| 444 | 458 | |
| 445 | - else |
|
| 446 | - unlink($path . '/' . $object); |
|
| 459 | + else { |
|
| 460 | + unlink($path . '/' . $object); |
|
| 461 | + } |
|
| 447 | 462 | } |
| 448 | 463 | } |
| 449 | 464 | |
@@ -462,8 +477,9 @@ discard block |
||
| 462 | 477 | global $smcFunc, $modSettings; |
| 463 | 478 | |
| 464 | 479 | // Can't delete the default theme, sorry! |
| 465 | - if (empty($themeID) || $themeID == 1) |
|
| 466 | - return false; |
|
| 480 | + if (empty($themeID) || $themeID == 1) { |
|
| 481 | + return false; |
|
| 482 | + } |
|
| 467 | 483 | |
| 468 | 484 | $known = explode(',', $modSettings['knownThemes']); |
| 469 | 485 | $enable = explode(',', $modSettings['enableThemes']); |
@@ -513,8 +529,9 @@ discard block |
||
| 513 | 529 | updateSettings(array('enableThemes' => $enable, 'knownThemes' => $known)); |
| 514 | 530 | |
| 515 | 531 | // Fix it if the theme was the overall default theme. |
| 516 | - if ($modSettings['theme_guests'] == $themeID) |
|
| 517 | - updateSettings(array('theme_guests' => '1')); |
|
| 532 | + if ($modSettings['theme_guests'] == $themeID) { |
|
| 533 | + updateSettings(array('theme_guests' => '1')); |
|
| 534 | + } |
|
| 518 | 535 | |
| 519 | 536 | return true; |
| 520 | 537 | } |
@@ -531,13 +548,15 @@ discard block |
||
| 531 | 548 | global $scripturl, $txt, $context; |
| 532 | 549 | |
| 533 | 550 | // Is it even a directory? |
| 534 | - if (!is_dir($path)) |
|
| 535 | - fatal_lang_error('error_invalid_dir', 'critical'); |
|
| 551 | + if (!is_dir($path)) { |
|
| 552 | + fatal_lang_error('error_invalid_dir', 'critical'); |
|
| 553 | + } |
|
| 536 | 554 | |
| 537 | 555 | $dir = dir($path); |
| 538 | 556 | $entries = array(); |
| 539 | - while ($entry = $dir->read()) |
|
| 540 | - $entries[] = $entry; |
|
| 557 | + while ($entry = $dir->read()) { |
|
| 558 | + $entries[] = $entry; |
|
| 559 | + } |
|
| 541 | 560 | $dir->close(); |
| 542 | 561 | |
| 543 | 562 | natcasesort($entries); |
@@ -548,11 +567,12 @@ discard block |
||
| 548 | 567 | foreach ($entries as $entry) |
| 549 | 568 | { |
| 550 | 569 | // Skip all dot files, including .htaccess. |
| 551 | - if (substr($entry, 0, 1) == '.' || $entry == 'CVS') |
|
| 552 | - continue; |
|
| 570 | + if (substr($entry, 0, 1) == '.' || $entry == 'CVS') { |
|
| 571 | + continue; |
|
| 572 | + } |
|
| 553 | 573 | |
| 554 | - if (is_dir($path . '/' . $entry)) |
|
| 555 | - $listing1[] = array( |
|
| 574 | + if (is_dir($path . '/' . $entry)) { |
|
| 575 | + $listing1[] = array( |
|
| 556 | 576 | 'filename' => $entry, |
| 557 | 577 | 'is_writable' => is_writable($path . '/' . $entry), |
| 558 | 578 | 'is_directory' => true, |
@@ -562,13 +582,14 @@ discard block |
||
| 562 | 582 | 'href' => $scripturl . '?action=admin;area=theme;th=' . $_GET['th'] . ';' . $context['session_var'] . '=' . $context['session_id'] . ';sa=edit;directory=' . $relative . $entry, |
| 563 | 583 | 'size' => '', |
| 564 | 584 | ); |
| 565 | - else |
|
| 585 | + } else |
|
| 566 | 586 | { |
| 567 | 587 | $size = filesize($path . '/' . $entry); |
| 568 | - if ($size > 2048 || $size == 1024) |
|
| 569 | - $size = comma_format($size / 1024) . ' ' . $txt['themeadmin_edit_kilobytes']; |
|
| 570 | - else |
|
| 571 | - $size = comma_format($size) . ' ' . $txt['themeadmin_edit_bytes']; |
|
| 588 | + if ($size > 2048 || $size == 1024) { |
|
| 589 | + $size = comma_format($size / 1024) . ' ' . $txt['themeadmin_edit_kilobytes']; |
|
| 590 | + } else { |
|
| 591 | + $size = comma_format($size) . ' ' . $txt['themeadmin_edit_bytes']; |
|
| 592 | + } |
|
| 572 | 593 | |
| 573 | 594 | $listing2[] = array( |
| 574 | 595 | 'filename' => $entry, |
@@ -676,7 +676,7 @@ discard block |
||
| 676 | 676 | * - caches the formatting data from the setting for optimization. |
| 677 | 677 | * |
| 678 | 678 | * @param float $number A number |
| 679 | - * @param bool|int $override_decimal_count If set, will use the specified number of decimal places. Otherwise it's automatically determined |
|
| 679 | + * @param integer $override_decimal_count If set, will use the specified number of decimal places. Otherwise it's automatically determined |
|
| 680 | 680 | * @return string A formatted number |
| 681 | 681 | */ |
| 682 | 682 | function comma_format($number, $override_decimal_count = false) |
@@ -4987,7 +4987,7 @@ discard block |
||
| 4987 | 4987 | |
| 4988 | 4988 | /** |
| 4989 | 4989 | * @param string $ip_address An IP address in IPv4, IPv6 or decimal notation |
| 4990 | - * @return binary The IP address in binary or false |
|
| 4990 | + * @return string The IP address in binary or false |
|
| 4991 | 4991 | */ |
| 4992 | 4992 | function inet_ptod($ip_address) |
| 4993 | 4993 | { |
@@ -5385,7 +5385,7 @@ discard block |
||
| 5385 | 5385 | * It assumes the data is already a string. |
| 5386 | 5386 | * @param string $data The data to print |
| 5387 | 5387 | * @param string $type The content type. Defaults to Json. |
| 5388 | - * @return void |
|
| 5388 | + * @return false|null |
|
| 5389 | 5389 | */ |
| 5390 | 5390 | function smf_serverResponse($data = '', $type = 'Content-Type: application/json') |
| 5391 | 5391 | { |
@@ -5265,7 +5265,6 @@ discard block |
||
| 5265 | 5265 | |
| 5266 | 5266 | /** |
| 5267 | 5267 | * Tries different modes to make file/dirs writable. Wrapper function for chmod() |
| 5268 | - |
|
| 5269 | 5268 | * @param string $file The file/dir full path. |
| 5270 | 5269 | * @param int $value Not needed, added for legacy reasons. |
| 5271 | 5270 | * @return boolean true if the file/dir is already writable or the function was able to make it writable, false if the function couldn't make the file/dir writable. |
@@ -5305,7 +5304,6 @@ discard block |
||
| 5305 | 5304 | |
| 5306 | 5305 | /** |
| 5307 | 5306 | * Wrapper function for json_decode() with error handling. |
| 5308 | - |
|
| 5309 | 5307 | * @param string $json The string to decode. |
| 5310 | 5308 | * @param bool $returnAsArray To return the decoded string as an array or an object, SMF only uses Arrays but to keep on compatibility with json_decode its set to false as default. |
| 5311 | 5309 | * @param bool $logIt To specify if the error will be logged if theres any. |
@@ -1097,7 +1097,7 @@ discard block |
||
| 1097 | 1097 | 'height' => array('optional' => true, 'match' => '(\d+)'), |
| 1098 | 1098 | ), |
| 1099 | 1099 | 'content' => '$1', |
| 1100 | - 'validate' => function (&$tag, &$data, $disabled, $params) use ($modSettings, $context, $sourcedir, $txt) |
|
| 1100 | + 'validate' => function(&$tag, &$data, $disabled, $params) use ($modSettings, $context, $sourcedir, $txt) |
|
| 1101 | 1101 | { |
| 1102 | 1102 | $returnContext = ''; |
| 1103 | 1103 | |
@@ -1132,7 +1132,7 @@ discard block |
||
| 1132 | 1132 | } |
| 1133 | 1133 | |
| 1134 | 1134 | if ($currentAttachment['thumbnail']['has_thumb'] && empty($params['{width}']) && empty($params['{height}'])) |
| 1135 | - $returnContext .= '<a href="'. $currentAttachment['href']. ';image" id="link_'. $currentAttachment['id']. '" onclick="'. $currentAttachment['thumbnail']['javascript']. '"><img src="'. $currentAttachment['thumbnail']['href']. '" alt="' . $currentAttachment['name'] . '" id="thumb_'. $currentAttachment['id']. '"></a>'; |
|
| 1135 | + $returnContext .= '<a href="' . $currentAttachment['href'] . ';image" id="link_' . $currentAttachment['id'] . '" onclick="' . $currentAttachment['thumbnail']['javascript'] . '"><img src="' . $currentAttachment['thumbnail']['href'] . '" alt="' . $currentAttachment['name'] . '" id="thumb_' . $currentAttachment['id'] . '"></a>'; |
|
| 1136 | 1136 | else |
| 1137 | 1137 | $returnContext .= '<img src="' . $currentAttachment['href'] . ';image" alt="' . $currentAttachment['name'] . '"' . $width . $height . '/>'; |
| 1138 | 1138 | } |
@@ -1161,7 +1161,7 @@ discard block |
||
| 1161 | 1161 | 'type' => 'unparsed_content', |
| 1162 | 1162 | 'content' => '<div class="codeheader"><span class="code floatleft">' . $txt['code'] . '</span> <a class="codeoperation smf_select_text">' . $txt['code_select'] . '</a></div><code class="bbc_code">$1</code>', |
| 1163 | 1163 | // @todo Maybe this can be simplified? |
| 1164 | - 'validate' => isset($disabled['code']) ? null : function (&$tag, &$data, $disabled) use ($context) |
|
| 1164 | + 'validate' => isset($disabled['code']) ? null : function(&$tag, &$data, $disabled) use ($context) |
|
| 1165 | 1165 | { |
| 1166 | 1166 | if (!isset($disabled['code'])) |
| 1167 | 1167 | { |
@@ -1198,7 +1198,7 @@ discard block |
||
| 1198 | 1198 | 'type' => 'unparsed_equals_content', |
| 1199 | 1199 | 'content' => '<div class="codeheader"><span class="code floatleft">' . $txt['code'] . '</span> ($2) <a class="codeoperation smf_select_text">' . $txt['code_select'] . '</a></div><code class="bbc_code">$1</code>', |
| 1200 | 1200 | // @todo Maybe this can be simplified? |
| 1201 | - 'validate' => isset($disabled['code']) ? null : function (&$tag, &$data, $disabled) use ($context) |
|
| 1201 | + 'validate' => isset($disabled['code']) ? null : function(&$tag, &$data, $disabled) use ($context) |
|
| 1202 | 1202 | { |
| 1203 | 1203 | if (!isset($disabled['code'])) |
| 1204 | 1204 | { |
@@ -1242,7 +1242,7 @@ discard block |
||
| 1242 | 1242 | 'type' => 'unparsed_content', |
| 1243 | 1243 | 'content' => '<a href="mailto:$1" class="bbc_email">$1</a>', |
| 1244 | 1244 | // @todo Should this respect guest_hideContacts? |
| 1245 | - 'validate' => function (&$tag, &$data, $disabled) |
|
| 1245 | + 'validate' => function(&$tag, &$data, $disabled) |
|
| 1246 | 1246 | { |
| 1247 | 1247 | $data = strtr($data, array('<br>' => '')); |
| 1248 | 1248 | }, |
@@ -1261,7 +1261,7 @@ discard block |
||
| 1261 | 1261 | 'type' => 'unparsed_commas_content', |
| 1262 | 1262 | 'test' => '\d+,\d+\]', |
| 1263 | 1263 | 'content' => '<embed type="application/x-shockwave-flash" src="$1" width="$2" height="$3" play="true" loop="true" quality="high" AllowScriptAccess="never">', |
| 1264 | - 'validate' => function (&$tag, &$data, $disabled) |
|
| 1264 | + 'validate' => function(&$tag, &$data, $disabled) |
|
| 1265 | 1265 | { |
| 1266 | 1266 | if (isset($disabled['url'])) |
| 1267 | 1267 | $tag['content'] = '$1'; |
@@ -1306,7 +1306,7 @@ discard block |
||
| 1306 | 1306 | 'height' => array('optional' => true, 'value' => ' height="$1"', 'match' => '(\d+)'), |
| 1307 | 1307 | ), |
| 1308 | 1308 | 'content' => '<img src="$1" alt="{alt}" title="{title}"{width}{height} class="bbc_img resized">', |
| 1309 | - 'validate' => function (&$tag, &$data, $disabled) |
|
| 1309 | + 'validate' => function(&$tag, &$data, $disabled) |
|
| 1310 | 1310 | { |
| 1311 | 1311 | global $image_proxy_enabled, $image_proxy_secret, $boardurl; |
| 1312 | 1312 | |
@@ -1329,7 +1329,7 @@ discard block |
||
| 1329 | 1329 | 'tag' => 'img', |
| 1330 | 1330 | 'type' => 'unparsed_content', |
| 1331 | 1331 | 'content' => '<img src="$1" alt="" class="bbc_img">', |
| 1332 | - 'validate' => function (&$tag, &$data, $disabled) |
|
| 1332 | + 'validate' => function(&$tag, &$data, $disabled) |
|
| 1333 | 1333 | { |
| 1334 | 1334 | global $image_proxy_enabled, $image_proxy_secret, $boardurl; |
| 1335 | 1335 | |
@@ -1352,7 +1352,7 @@ discard block |
||
| 1352 | 1352 | 'tag' => 'iurl', |
| 1353 | 1353 | 'type' => 'unparsed_content', |
| 1354 | 1354 | 'content' => '<a href="$1" class="bbc_link">$1</a>', |
| 1355 | - 'validate' => function (&$tag, &$data, $disabled) |
|
| 1355 | + 'validate' => function(&$tag, &$data, $disabled) |
|
| 1356 | 1356 | { |
| 1357 | 1357 | $data = strtr($data, array('<br>' => '')); |
| 1358 | 1358 | $scheme = parse_url($data, PHP_URL_SCHEME); |
@@ -1366,7 +1366,7 @@ discard block |
||
| 1366 | 1366 | 'quoted' => 'optional', |
| 1367 | 1367 | 'before' => '<a href="$1" class="bbc_link">', |
| 1368 | 1368 | 'after' => '</a>', |
| 1369 | - 'validate' => function (&$tag, &$data, $disabled) |
|
| 1369 | + 'validate' => function(&$tag, &$data, $disabled) |
|
| 1370 | 1370 | { |
| 1371 | 1371 | if (substr($data, 0, 1) == '#') |
| 1372 | 1372 | $data = '#post_' . substr($data, 1); |
@@ -1446,7 +1446,7 @@ discard block |
||
| 1446 | 1446 | 'tag' => 'php', |
| 1447 | 1447 | 'type' => 'unparsed_content', |
| 1448 | 1448 | 'content' => '<span class="phpcode">$1</span>', |
| 1449 | - 'validate' => isset($disabled['php']) ? null : function (&$tag, &$data, $disabled) |
|
| 1449 | + 'validate' => isset($disabled['php']) ? null : function(&$tag, &$data, $disabled) |
|
| 1450 | 1450 | { |
| 1451 | 1451 | if (!isset($disabled['php'])) |
| 1452 | 1452 | { |
@@ -1544,7 +1544,7 @@ discard block |
||
| 1544 | 1544 | 'test' => '[1-7]\]', |
| 1545 | 1545 | 'before' => '<span style="font-size: $1;" class="bbc_size">', |
| 1546 | 1546 | 'after' => '</span>', |
| 1547 | - 'validate' => function (&$tag, &$data, $disabled) |
|
| 1547 | + 'validate' => function(&$tag, &$data, $disabled) |
|
| 1548 | 1548 | { |
| 1549 | 1549 | $sizes = array(1 => 0.7, 2 => 1.0, 3 => 1.35, 4 => 1.45, 5 => 2.0, 6 => 2.65, 7 => 3.95); |
| 1550 | 1550 | $data = $sizes[$data] . 'em'; |
@@ -1582,7 +1582,7 @@ discard block |
||
| 1582 | 1582 | 'tag' => 'time', |
| 1583 | 1583 | 'type' => 'unparsed_content', |
| 1584 | 1584 | 'content' => '$1', |
| 1585 | - 'validate' => function (&$tag, &$data, $disabled) |
|
| 1585 | + 'validate' => function(&$tag, &$data, $disabled) |
|
| 1586 | 1586 | { |
| 1587 | 1587 | if (is_numeric($data)) |
| 1588 | 1588 | $data = timeformat($data); |
@@ -1610,7 +1610,7 @@ discard block |
||
| 1610 | 1610 | 'tag' => 'url', |
| 1611 | 1611 | 'type' => 'unparsed_content', |
| 1612 | 1612 | 'content' => '<a href="$1" class="bbc_link" target="_blank">$1</a>', |
| 1613 | - 'validate' => function (&$tag, &$data, $disabled) |
|
| 1613 | + 'validate' => function(&$tag, &$data, $disabled) |
|
| 1614 | 1614 | { |
| 1615 | 1615 | $data = strtr($data, array('<br>' => '')); |
| 1616 | 1616 | $scheme = parse_url($data, PHP_URL_SCHEME); |
@@ -1624,7 +1624,7 @@ discard block |
||
| 1624 | 1624 | 'quoted' => 'optional', |
| 1625 | 1625 | 'before' => '<a href="$1" class="bbc_link" target="_blank">', |
| 1626 | 1626 | 'after' => '</a>', |
| 1627 | - 'validate' => function (&$tag, &$data, $disabled) |
|
| 1627 | + 'validate' => function(&$tag, &$data, $disabled) |
|
| 1628 | 1628 | { |
| 1629 | 1629 | $scheme = parse_url($data, PHP_URL_SCHEME); |
| 1630 | 1630 | if (empty($scheme)) |
@@ -1650,7 +1650,7 @@ discard block |
||
| 1650 | 1650 | { |
| 1651 | 1651 | if (isset($temp_bbc)) |
| 1652 | 1652 | $bbc_codes = $temp_bbc; |
| 1653 | - usort($codes, function ($a, $b) { |
|
| 1653 | + usort($codes, function($a, $b) { |
|
| 1654 | 1654 | return strcmp($a['tag'], $b['tag']); |
| 1655 | 1655 | }); |
| 1656 | 1656 | return $codes; |
@@ -1890,7 +1890,7 @@ discard block |
||
| 1890 | 1890 | # a run of Unicode domain name characters and a dot |
| 1891 | 1891 | [\p{L}\p{M}\p{N}\-.:@]+\. |
| 1892 | 1892 | # and then a TLD valid in the DNS or the reserved "local" TLD |
| 1893 | - (?:'. $modSettings['tld_regex'] .'|local) |
|
| 1893 | + (?:'. $modSettings['tld_regex'] . '|local) |
|
| 1894 | 1894 | ) |
| 1895 | 1895 | # followed by a non-domain character or end of line |
| 1896 | 1896 | (?=[^\p{L}\p{N}\-.]|$) |
@@ -1958,7 +1958,7 @@ discard block |
||
| 1958 | 1958 | )? |
| 1959 | 1959 | '; |
| 1960 | 1960 | |
| 1961 | - $data = preg_replace_callback('~' . $url_regex . '~xi' . ($context['utf8'] ? 'u' : ''), function ($matches) { |
|
| 1961 | + $data = preg_replace_callback('~' . $url_regex . '~xi' . ($context['utf8'] ? 'u' : ''), function($matches) { |
|
| 1962 | 1962 | $url = array_shift($matches); |
| 1963 | 1963 | |
| 1964 | 1964 | $scheme = parse_url($url, PHP_URL_SCHEME); |
@@ -2687,7 +2687,7 @@ discard block |
||
| 2687 | 2687 | for ($i = 0, $n = count($smileysfrom); $i < $n; $i++) |
| 2688 | 2688 | { |
| 2689 | 2689 | $specialChars = $smcFunc['htmlspecialchars']($smileysfrom[$i], ENT_QUOTES); |
| 2690 | - $smileyCode = '<img src="' . $smileys_path . $smileysto[$i] . '" alt="' . strtr($specialChars, array(':' => ':', '(' => '(', ')' => ')', '$' => '$', '[' => '[')). '" title="' . strtr($smcFunc['htmlspecialchars']($smileysdescs[$i]), array(':' => ':', '(' => '(', ')' => ')', '$' => '$', '[' => '[')) . '" class="smiley">'; |
|
| 2690 | + $smileyCode = '<img src="' . $smileys_path . $smileysto[$i] . '" alt="' . strtr($specialChars, array(':' => ':', '(' => '(', ')' => ')', '$' => '$', '[' => '[')) . '" title="' . strtr($smcFunc['htmlspecialchars']($smileysdescs[$i]), array(':' => ':', '(' => '(', ')' => ')', '$' => '$', '[' => '[')) . '" class="smiley">'; |
|
| 2691 | 2691 | |
| 2692 | 2692 | $smileyPregReplacements[$smileysfrom[$i]] = $smileyCode; |
| 2693 | 2693 | |
@@ -2704,7 +2704,7 @@ discard block |
||
| 2704 | 2704 | |
| 2705 | 2705 | // Replace away! |
| 2706 | 2706 | $message = preg_replace_callback($smileyPregSearch, |
| 2707 | - function ($matches) use ($smileyPregReplacements) |
|
| 2707 | + function($matches) use ($smileyPregReplacements) |
|
| 2708 | 2708 | { |
| 2709 | 2709 | return $smileyPregReplacements[$matches[1]]; |
| 2710 | 2710 | }, $message); |
@@ -2770,13 +2770,13 @@ discard block |
||
| 2770 | 2770 | { |
| 2771 | 2771 | if (defined('SID') && SID != '') |
| 2772 | 2772 | $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?(?:' . SID . '(?:;|&|&))((?:board|topic)=[^#]+?)(#[^"]*?)?$~', |
| 2773 | - function ($m) use ($scripturl) |
|
| 2773 | + function($m) use ($scripturl) |
|
| 2774 | 2774 | { |
| 2775 | - return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html?' . SID. (isset($m[2]) ? "$m[2]" : ""); |
|
| 2775 | + return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html?' . SID . (isset($m[2]) ? "$m[2]" : ""); |
|
| 2776 | 2776 | }, $setLocation); |
| 2777 | 2777 | else |
| 2778 | 2778 | $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?((?:board|topic)=[^#"]+?)(#[^"]*?)?$~', |
| 2779 | - function ($m) use ($scripturl) |
|
| 2779 | + function($m) use ($scripturl) |
|
| 2780 | 2780 | { |
| 2781 | 2781 | return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html' . (isset($m[2]) ? "$m[2]" : ""); |
| 2782 | 2782 | }, $setLocation); |
@@ -3099,7 +3099,7 @@ discard block |
||
| 3099 | 3099 | |
| 3100 | 3100 | // Add a generic "Are you sure?" confirmation message. |
| 3101 | 3101 | addInlineJavaScript(' |
| 3102 | - var smf_you_sure =' . JavaScriptEscape($txt['quickmod_confirm']) .';'); |
|
| 3102 | + var smf_you_sure =' . JavaScriptEscape($txt['quickmod_confirm']) . ';'); |
|
| 3103 | 3103 | |
| 3104 | 3104 | // Now add the capping code for avatars. |
| 3105 | 3105 | 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') |
@@ -3463,7 +3463,7 @@ discard block |
||
| 3463 | 3463 | |
| 3464 | 3464 | else |
| 3465 | 3465 | echo ' |
| 3466 | - <script src="', $settings['theme_url'] ,'/scripts/minified', ($do_deferred ? '_deferred' : '') ,'.js', $minSeed ,'"></script>'; |
|
| 3466 | + <script src="', $settings['theme_url'], '/scripts/minified', ($do_deferred ? '_deferred' : ''), '.js', $minSeed, '"></script>'; |
|
| 3467 | 3467 | } |
| 3468 | 3468 | |
| 3469 | 3469 | // Inline JavaScript - Actually useful some times! |
@@ -3541,14 +3541,14 @@ discard block |
||
| 3541 | 3541 | |
| 3542 | 3542 | else |
| 3543 | 3543 | echo ' |
| 3544 | - <link rel="stylesheet" href="', $settings['theme_url'] ,'/css/minified.css', $minSeed ,'">'; |
|
| 3544 | + <link rel="stylesheet" href="', $settings['theme_url'], '/css/minified.css', $minSeed, '">'; |
|
| 3545 | 3545 | } |
| 3546 | 3546 | |
| 3547 | 3547 | // Print the rest after the minified files. |
| 3548 | 3548 | if (!empty($normal)) |
| 3549 | 3549 | foreach ($normal as $nf) |
| 3550 | 3550 | echo ' |
| 3551 | - <link rel="stylesheet" href="', $nf ,'">'; |
|
| 3551 | + <link rel="stylesheet" href="', $nf, '">'; |
|
| 3552 | 3552 | |
| 3553 | 3553 | if ($db_show_debug === true) |
| 3554 | 3554 | { |
@@ -3564,7 +3564,7 @@ discard block |
||
| 3564 | 3564 | <style>'; |
| 3565 | 3565 | |
| 3566 | 3566 | foreach ($context['css_header'] as $css) |
| 3567 | - echo $css .' |
|
| 3567 | + echo $css . ' |
|
| 3568 | 3568 | '; |
| 3569 | 3569 | |
| 3570 | 3570 | echo' |
@@ -3594,7 +3594,7 @@ discard block |
||
| 3594 | 3594 | return false; |
| 3595 | 3595 | |
| 3596 | 3596 | // Did we already did this? |
| 3597 | - $toCache = cache_get_data('minimized_'. $settings['theme_id'] .'_'. $type, 86400); |
|
| 3597 | + $toCache = cache_get_data('minimized_' . $settings['theme_id'] . '_' . $type, 86400); |
|
| 3598 | 3598 | |
| 3599 | 3599 | // Already done? |
| 3600 | 3600 | if (!empty($toCache)) |
@@ -3602,25 +3602,25 @@ discard block |
||
| 3602 | 3602 | |
| 3603 | 3603 | // Yep, need a bunch of files. |
| 3604 | 3604 | require_once($sourcedir . '/minify/src/Minify.php'); |
| 3605 | - require_once($sourcedir . '/minify/src/'. strtoupper($type) .'.php'); |
|
| 3605 | + require_once($sourcedir . '/minify/src/' . strtoupper($type) . '.php'); |
|
| 3606 | 3606 | require_once($sourcedir . '/minify/src/Exception.php'); |
| 3607 | 3607 | require_once($sourcedir . '/minify/src/Converter.php'); |
| 3608 | 3608 | |
| 3609 | 3609 | // No namespaces, sorry! |
| 3610 | - $classType = 'MatthiasMullie\\Minify\\'. strtoupper($type); |
|
| 3610 | + $classType = 'MatthiasMullie\\Minify\\' . strtoupper($type); |
|
| 3611 | 3611 | |
| 3612 | 3612 | // Temp path. |
| 3613 | - $cTempPath = $settings['theme_dir'] .'/'. ($type == 'css' ? 'css' : 'scripts') .'/'; |
|
| 3613 | + $cTempPath = $settings['theme_dir'] . '/' . ($type == 'css' ? 'css' : 'scripts') . '/'; |
|
| 3614 | 3614 | |
| 3615 | 3615 | // What kind of file are we going to create? |
| 3616 | - $toCreate = $cTempPath .'minified'. ($do_deferred ? '_deferred' : '') .'.'. $type; |
|
| 3616 | + $toCreate = $cTempPath . 'minified' . ($do_deferred ? '_deferred' : '') . '.' . $type; |
|
| 3617 | 3617 | |
| 3618 | 3618 | // File has to exists, if it isn't try to create it. |
| 3619 | 3619 | if ((!file_exists($toCreate) && @fopen($toCreate, 'w') === false) || !smf_chmod($toCreate)) |
| 3620 | 3620 | { |
| 3621 | 3621 | loadLanguage('Errors'); |
| 3622 | 3622 | log_error(sprintf($txt['file_not_created'], $toCreate), 'general'); |
| 3623 | - cache_put_data('minimized_'. $settings['theme_id'] .'_'. $type, null); |
|
| 3623 | + cache_put_data('minimized_' . $settings['theme_id'] . '_' . $type, null); |
|
| 3624 | 3624 | |
| 3625 | 3625 | // The process failed so roll back to print each individual file. |
| 3626 | 3626 | return $data; |
@@ -3655,14 +3655,14 @@ discard block |
||
| 3655 | 3655 | { |
| 3656 | 3656 | loadLanguage('Errors'); |
| 3657 | 3657 | log_error(sprintf($txt['file_not_created'], $toCreate), 'general'); |
| 3658 | - cache_put_data('minimized_'. $settings['theme_id'] .'_'. $type, null); |
|
| 3658 | + cache_put_data('minimized_' . $settings['theme_id'] . '_' . $type, null); |
|
| 3659 | 3659 | |
| 3660 | 3660 | // The process failed so roll back to print each individual file. |
| 3661 | 3661 | return $data; |
| 3662 | 3662 | } |
| 3663 | 3663 | |
| 3664 | 3664 | // And create a long lived cache entry. |
| 3665 | - cache_put_data('minimized_'. $settings['theme_id'] .'_'. $type, $toCreate, 86400); |
|
| 3665 | + cache_put_data('minimized_' . $settings['theme_id'] . '_' . $type, $toCreate, 86400); |
|
| 3666 | 3666 | |
| 3667 | 3667 | return true; |
| 3668 | 3668 | } |
@@ -3719,7 +3719,7 @@ discard block |
||
| 3719 | 3719 | else |
| 3720 | 3720 | $path = $modSettings['attachmentUploadDir']; |
| 3721 | 3721 | |
| 3722 | - return $path . '/' . $attachment_id . '_' . $file_hash .'.dat'; |
|
| 3722 | + return $path . '/' . $attachment_id . '_' . $file_hash . '.dat'; |
|
| 3723 | 3723 | } |
| 3724 | 3724 | |
| 3725 | 3725 | /** |
@@ -3763,10 +3763,10 @@ discard block |
||
| 3763 | 3763 | $valid_low = isValidIP($ip_parts[0]); |
| 3764 | 3764 | $valid_high = isValidIP($ip_parts[1]); |
| 3765 | 3765 | $count = 0; |
| 3766 | - $mode = (preg_match('/:/',$ip_parts[0]) > 0 ? ':' : '.'); |
|
| 3766 | + $mode = (preg_match('/:/', $ip_parts[0]) > 0 ? ':' : '.'); |
|
| 3767 | 3767 | $max = ($mode == ':' ? 'ffff' : '255'); |
| 3768 | 3768 | $min = 0; |
| 3769 | - if(!$valid_low) |
|
| 3769 | + if (!$valid_low) |
|
| 3770 | 3770 | { |
| 3771 | 3771 | $ip_parts[0] = preg_replace('/\*/', '0', $ip_parts[0]); |
| 3772 | 3772 | $valid_low = isValidIP($ip_parts[0]); |
@@ -3780,7 +3780,7 @@ discard block |
||
| 3780 | 3780 | } |
| 3781 | 3781 | |
| 3782 | 3782 | $count = 0; |
| 3783 | - if(!$valid_high) |
|
| 3783 | + if (!$valid_high) |
|
| 3784 | 3784 | { |
| 3785 | 3785 | $ip_parts[1] = preg_replace('/\*/', $max, $ip_parts[1]); |
| 3786 | 3786 | $valid_high = isValidIP($ip_parts[1]); |
@@ -3793,7 +3793,7 @@ discard block |
||
| 3793 | 3793 | } |
| 3794 | 3794 | } |
| 3795 | 3795 | |
| 3796 | - if($valid_high && $valid_low) |
|
| 3796 | + if ($valid_high && $valid_low) |
|
| 3797 | 3797 | { |
| 3798 | 3798 | $ip_array['low'] = $ip_parts[0]; |
| 3799 | 3799 | $ip_array['high'] = $ip_parts[1]; |
@@ -3975,7 +3975,7 @@ discard block |
||
| 3975 | 3975 | addInlineJavaScript(' |
| 3976 | 3976 | var user_menus = new smc_PopupMenu(); |
| 3977 | 3977 | user_menus.add("profile", "' . $scripturl . '?action=profile;area=popup"); |
| 3978 | - user_menus.add("alerts", "' . $scripturl . '?action=profile;area=alerts_popup;u='. $context['user']['id'] .'");', true); |
|
| 3978 | + user_menus.add("alerts", "' . $scripturl . '?action=profile;area=alerts_popup;u=' . $context['user']['id'] . '");', true); |
|
| 3979 | 3979 | if ($context['allow_pm']) |
| 3980 | 3980 | addInlineJavaScript(' |
| 3981 | 3981 | user_menus.add("pm", "' . $scripturl . '?action=pm;sa=popup");', true); |
@@ -4603,7 +4603,7 @@ discard block |
||
| 4603 | 4603 | // No? try a fallback to $sourcedir |
| 4604 | 4604 | else |
| 4605 | 4605 | { |
| 4606 | - $absPath = $sourcedir .'/'. $file; |
|
| 4606 | + $absPath = $sourcedir . '/' . $file; |
|
| 4607 | 4607 | |
| 4608 | 4608 | if (file_exists($absPath)) |
| 4609 | 4609 | require_once($absPath); |
@@ -4684,15 +4684,15 @@ discard block |
||
| 4684 | 4684 | |
| 4685 | 4685 | // UTF-8 occurences of MS special characters |
| 4686 | 4686 | $findchars_utf8 = array( |
| 4687 | - "\xe2\80\x9a", // single low-9 quotation mark |
|
| 4688 | - "\xe2\80\x9e", // double low-9 quotation mark |
|
| 4689 | - "\xe2\80\xa6", // horizontal ellipsis |
|
| 4690 | - "\xe2\x80\x98", // left single curly quote |
|
| 4691 | - "\xe2\x80\x99", // right single curly quote |
|
| 4692 | - "\xe2\x80\x9c", // left double curly quote |
|
| 4693 | - "\xe2\x80\x9d", // right double curly quote |
|
| 4694 | - "\xe2\x80\x93", // en dash |
|
| 4695 | - "\xe2\x80\x94", // em dash |
|
| 4687 | + "\xe2\80\x9a", // single low-9 quotation mark |
|
| 4688 | + "\xe2\80\x9e", // double low-9 quotation mark |
|
| 4689 | + "\xe2\80\xa6", // horizontal ellipsis |
|
| 4690 | + "\xe2\x80\x98", // left single curly quote |
|
| 4691 | + "\xe2\x80\x99", // right single curly quote |
|
| 4692 | + "\xe2\x80\x9c", // left double curly quote |
|
| 4693 | + "\xe2\x80\x9d", // right double curly quote |
|
| 4694 | + "\xe2\x80\x93", // en dash |
|
| 4695 | + "\xe2\x80\x94", // em dash |
|
| 4696 | 4696 | ); |
| 4697 | 4697 | |
| 4698 | 4698 | // windows 1252 / iso equivalents |
@@ -4710,15 +4710,15 @@ discard block |
||
| 4710 | 4710 | |
| 4711 | 4711 | // safe replacements |
| 4712 | 4712 | $replacechars = array( |
| 4713 | - ',', // ‚ |
|
| 4714 | - ',,', // „ |
|
| 4715 | - '...', // … |
|
| 4716 | - "'", // ‘ |
|
| 4717 | - "'", // ’ |
|
| 4718 | - '"', // “ |
|
| 4719 | - '"', // ” |
|
| 4720 | - '-', // – |
|
| 4721 | - '--', // — |
|
| 4713 | + ',', // ‚ |
|
| 4714 | + ',,', // „ |
|
| 4715 | + '...', // … |
|
| 4716 | + "'", // ‘ |
|
| 4717 | + "'", // ’ |
|
| 4718 | + '"', // “ |
|
| 4719 | + '"', // ” |
|
| 4720 | + '-', // – |
|
| 4721 | + '--', // — |
|
| 4722 | 4722 | ); |
| 4723 | 4723 | |
| 4724 | 4724 | if ($context['utf8']) |
@@ -5004,7 +5004,7 @@ discard block |
||
| 5004 | 5004 | */ |
| 5005 | 5005 | function inet_dtop($bin) |
| 5006 | 5006 | { |
| 5007 | - if(empty($bin)) |
|
| 5007 | + if (empty($bin)) |
|
| 5008 | 5008 | return ''; |
| 5009 | 5009 | |
| 5010 | 5010 | global $db_type; |
@@ -5035,28 +5035,28 @@ discard block |
||
| 5035 | 5035 | */ |
| 5036 | 5036 | function _safe_serialize($value) |
| 5037 | 5037 | { |
| 5038 | - if(is_null($value)) |
|
| 5038 | + if (is_null($value)) |
|
| 5039 | 5039 | return 'N;'; |
| 5040 | 5040 | |
| 5041 | - if(is_bool($value)) |
|
| 5042 | - return 'b:'. (int) $value .';'; |
|
| 5041 | + if (is_bool($value)) |
|
| 5042 | + return 'b:' . (int) $value . ';'; |
|
| 5043 | 5043 | |
| 5044 | - if(is_int($value)) |
|
| 5045 | - return 'i:'. $value .';'; |
|
| 5044 | + if (is_int($value)) |
|
| 5045 | + return 'i:' . $value . ';'; |
|
| 5046 | 5046 | |
| 5047 | - if(is_float($value)) |
|
| 5048 | - return 'd:'. str_replace(',', '.', $value) .';'; |
|
| 5047 | + if (is_float($value)) |
|
| 5048 | + return 'd:' . str_replace(',', '.', $value) . ';'; |
|
| 5049 | 5049 | |
| 5050 | - if(is_string($value)) |
|
| 5051 | - return 's:'. strlen($value) .':"'. $value .'";'; |
|
| 5050 | + if (is_string($value)) |
|
| 5051 | + return 's:' . strlen($value) . ':"' . $value . '";'; |
|
| 5052 | 5052 | |
| 5053 | - if(is_array($value)) |
|
| 5053 | + if (is_array($value)) |
|
| 5054 | 5054 | { |
| 5055 | 5055 | $out = ''; |
| 5056 | - foreach($value as $k => $v) |
|
| 5056 | + foreach ($value as $k => $v) |
|
| 5057 | 5057 | $out .= _safe_serialize($k) . _safe_serialize($v); |
| 5058 | 5058 | |
| 5059 | - return 'a:'. count($value) .':{'. $out .'}'; |
|
| 5059 | + return 'a:' . count($value) . ':{' . $out . '}'; |
|
| 5060 | 5060 | } |
| 5061 | 5061 | |
| 5062 | 5062 | // safe_serialize cannot serialize resources or objects. |
@@ -5098,7 +5098,7 @@ discard block |
||
| 5098 | 5098 | function _safe_unserialize($str) |
| 5099 | 5099 | { |
| 5100 | 5100 | // Input is not a string. |
| 5101 | - if(empty($str) || !is_string($str)) |
|
| 5101 | + if (empty($str) || !is_string($str)) |
|
| 5102 | 5102 | return false; |
| 5103 | 5103 | |
| 5104 | 5104 | $stack = array(); |
@@ -5112,40 +5112,40 @@ discard block |
||
| 5112 | 5112 | * 3 - in array, expecting value or another array |
| 5113 | 5113 | */ |
| 5114 | 5114 | $state = 0; |
| 5115 | - while($state != 1) |
|
| 5115 | + while ($state != 1) |
|
| 5116 | 5116 | { |
| 5117 | 5117 | $type = isset($str[0]) ? $str[0] : ''; |
| 5118 | - if($type == '}') |
|
| 5118 | + if ($type == '}') |
|
| 5119 | 5119 | $str = substr($str, 1); |
| 5120 | 5120 | |
| 5121 | - else if($type == 'N' && $str[1] == ';') |
|
| 5121 | + else if ($type == 'N' && $str[1] == ';') |
|
| 5122 | 5122 | { |
| 5123 | 5123 | $value = null; |
| 5124 | 5124 | $str = substr($str, 2); |
| 5125 | 5125 | } |
| 5126 | - else if($type == 'b' && preg_match('/^b:([01]);/', $str, $matches)) |
|
| 5126 | + else if ($type == 'b' && preg_match('/^b:([01]);/', $str, $matches)) |
|
| 5127 | 5127 | { |
| 5128 | 5128 | $value = $matches[1] == '1' ? true : false; |
| 5129 | 5129 | $str = substr($str, 4); |
| 5130 | 5130 | } |
| 5131 | - else if($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches)) |
|
| 5131 | + else if ($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches)) |
|
| 5132 | 5132 | { |
| 5133 | - $value = (int)$matches[1]; |
|
| 5133 | + $value = (int) $matches[1]; |
|
| 5134 | 5134 | $str = $matches[2]; |
| 5135 | 5135 | } |
| 5136 | - else if($type == 'd' && preg_match('/^d:(-?[0-9]+\.?[0-9]*(E[+-][0-9]+)?);(.*)/s', $str, $matches)) |
|
| 5136 | + else if ($type == 'd' && preg_match('/^d:(-?[0-9]+\.?[0-9]*(E[+-][0-9]+)?);(.*)/s', $str, $matches)) |
|
| 5137 | 5137 | { |
| 5138 | - $value = (float)$matches[1]; |
|
| 5138 | + $value = (float) $matches[1]; |
|
| 5139 | 5139 | $str = $matches[3]; |
| 5140 | 5140 | } |
| 5141 | - else if($type == 's' && preg_match('/^s:([0-9]+):"(.*)/s', $str, $matches) && substr($matches[2], (int)$matches[1], 2) == '";') |
|
| 5141 | + else if ($type == 's' && preg_match('/^s:([0-9]+):"(.*)/s', $str, $matches) && substr($matches[2], (int) $matches[1], 2) == '";') |
|
| 5142 | 5142 | { |
| 5143 | - $value = substr($matches[2], 0, (int)$matches[1]); |
|
| 5144 | - $str = substr($matches[2], (int)$matches[1] + 2); |
|
| 5143 | + $value = substr($matches[2], 0, (int) $matches[1]); |
|
| 5144 | + $str = substr($matches[2], (int) $matches[1] + 2); |
|
| 5145 | 5145 | } |
| 5146 | - else if($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches)) |
|
| 5146 | + else if ($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches)) |
|
| 5147 | 5147 | { |
| 5148 | - $expectedLength = (int)$matches[1]; |
|
| 5148 | + $expectedLength = (int) $matches[1]; |
|
| 5149 | 5149 | $str = $matches[2]; |
| 5150 | 5150 | } |
| 5151 | 5151 | |
@@ -5153,10 +5153,10 @@ discard block |
||
| 5153 | 5153 | else |
| 5154 | 5154 | return false; |
| 5155 | 5155 | |
| 5156 | - switch($state) |
|
| 5156 | + switch ($state) |
|
| 5157 | 5157 | { |
| 5158 | 5158 | case 3: // In array, expecting value or another array. |
| 5159 | - if($type == 'a') |
|
| 5159 | + if ($type == 'a') |
|
| 5160 | 5160 | { |
| 5161 | 5161 | $stack[] = &$list; |
| 5162 | 5162 | $list[$key] = array(); |
@@ -5165,7 +5165,7 @@ discard block |
||
| 5165 | 5165 | $state = 2; |
| 5166 | 5166 | break; |
| 5167 | 5167 | } |
| 5168 | - if($type != '}') |
|
| 5168 | + if ($type != '}') |
|
| 5169 | 5169 | { |
| 5170 | 5170 | $list[$key] = $value; |
| 5171 | 5171 | $state = 2; |
@@ -5176,29 +5176,29 @@ discard block |
||
| 5176 | 5176 | return false; |
| 5177 | 5177 | |
| 5178 | 5178 | case 2: // in array, expecting end of array or a key |
| 5179 | - if($type == '}') |
|
| 5179 | + if ($type == '}') |
|
| 5180 | 5180 | { |
| 5181 | 5181 | // Array size is less than expected. |
| 5182 | - if(count($list) < end($expected)) |
|
| 5182 | + if (count($list) < end($expected)) |
|
| 5183 | 5183 | return false; |
| 5184 | 5184 | |
| 5185 | 5185 | unset($list); |
| 5186 | - $list = &$stack[count($stack)-1]; |
|
| 5186 | + $list = &$stack[count($stack) - 1]; |
|
| 5187 | 5187 | array_pop($stack); |
| 5188 | 5188 | |
| 5189 | 5189 | // Go to terminal state if we're at the end of the root array. |
| 5190 | 5190 | array_pop($expected); |
| 5191 | 5191 | |
| 5192 | - if(count($expected) == 0) |
|
| 5192 | + if (count($expected) == 0) |
|
| 5193 | 5193 | $state = 1; |
| 5194 | 5194 | |
| 5195 | 5195 | break; |
| 5196 | 5196 | } |
| 5197 | 5197 | |
| 5198 | - if($type == 'i' || $type == 's') |
|
| 5198 | + if ($type == 'i' || $type == 's') |
|
| 5199 | 5199 | { |
| 5200 | 5200 | // Array size exceeds expected length. |
| 5201 | - if(count($list) >= end($expected)) |
|
| 5201 | + if (count($list) >= end($expected)) |
|
| 5202 | 5202 | return false; |
| 5203 | 5203 | |
| 5204 | 5204 | $key = $value; |
@@ -5211,7 +5211,7 @@ discard block |
||
| 5211 | 5211 | |
| 5212 | 5212 | // Expecting array or value. |
| 5213 | 5213 | case 0: |
| 5214 | - if($type == 'a') |
|
| 5214 | + if ($type == 'a') |
|
| 5215 | 5215 | { |
| 5216 | 5216 | $data = array(); |
| 5217 | 5217 | $list = &$data; |
@@ -5220,7 +5220,7 @@ discard block |
||
| 5220 | 5220 | break; |
| 5221 | 5221 | } |
| 5222 | 5222 | |
| 5223 | - if($type != '}') |
|
| 5223 | + if ($type != '}') |
|
| 5224 | 5224 | { |
| 5225 | 5225 | $data = $value; |
| 5226 | 5226 | $state = 1; |
@@ -5233,7 +5233,7 @@ discard block |
||
| 5233 | 5233 | } |
| 5234 | 5234 | |
| 5235 | 5235 | // Trailing data in input. |
| 5236 | - if(!empty($str)) |
|
| 5236 | + if (!empty($str)) |
|
| 5237 | 5237 | return false; |
| 5238 | 5238 | |
| 5239 | 5239 | return $data; |
@@ -5287,7 +5287,7 @@ discard block |
||
| 5287 | 5287 | // Set different modes. |
| 5288 | 5288 | $chmodValues = $isDir ? array(0750, 0755, 0775, 0777) : array(0644, 0664, 0666); |
| 5289 | 5289 | |
| 5290 | - foreach($chmodValues as $val) |
|
| 5290 | + foreach ($chmodValues as $val) |
|
| 5291 | 5291 | { |
| 5292 | 5292 | // If it's writable, break out of the loop. |
| 5293 | 5293 | if (is_writable($file)) |
@@ -5325,13 +5325,13 @@ discard block |
||
| 5325 | 5325 | $returnArray = @json_decode($json, $returnAsArray); |
| 5326 | 5326 | |
| 5327 | 5327 | // PHP 5.3 so no json_last_error_msg() |
| 5328 | - switch(json_last_error()) |
|
| 5328 | + switch (json_last_error()) |
|
| 5329 | 5329 | { |
| 5330 | 5330 | case JSON_ERROR_NONE: |
| 5331 | 5331 | $jsonError = false; |
| 5332 | 5332 | break; |
| 5333 | 5333 | case JSON_ERROR_DEPTH: |
| 5334 | - $jsonError = 'JSON_ERROR_DEPTH'; |
|
| 5334 | + $jsonError = 'JSON_ERROR_DEPTH'; |
|
| 5335 | 5335 | break; |
| 5336 | 5336 | case JSON_ERROR_STATE_MISMATCH: |
| 5337 | 5337 | $jsonError = 'JSON_ERROR_STATE_MISMATCH'; |
@@ -5359,10 +5359,10 @@ discard block |
||
| 5359 | 5359 | loadLanguage('Errors'); |
| 5360 | 5360 | |
| 5361 | 5361 | if (!empty($jsonDebug)) |
| 5362 | - log_error($txt['json_'. $jsonError], 'critical', $jsonDebug['file'], $jsonDebug['line']); |
|
| 5362 | + log_error($txt['json_' . $jsonError], 'critical', $jsonDebug['file'], $jsonDebug['line']); |
|
| 5363 | 5363 | |
| 5364 | 5364 | else |
| 5365 | - log_error($txt['json_'. $jsonError], 'critical'); |
|
| 5365 | + log_error($txt['json_' . $jsonError], 'critical'); |
|
| 5366 | 5366 | |
| 5367 | 5367 | // Everyone expects an array. |
| 5368 | 5368 | return array(); |
@@ -5466,7 +5466,7 @@ discard block |
||
| 5466 | 5466 | }); |
| 5467 | 5467 | |
| 5468 | 5468 | // Convert Punycode to Unicode |
| 5469 | - $tlds = array_map(function ($input) { |
|
| 5469 | + $tlds = array_map(function($input) { |
|
| 5470 | 5470 | $prefix = 'xn--'; |
| 5471 | 5471 | $safe_char = 0xFFFC; |
| 5472 | 5472 | $base = 36; |
@@ -5482,7 +5482,7 @@ discard block |
||
| 5482 | 5482 | |
| 5483 | 5483 | foreach ($enco_parts as $encoded) |
| 5484 | 5484 | { |
| 5485 | - if (strpos($encoded,$prefix) !== 0 || strlen(trim(str_replace($prefix,'',$encoded))) == 0) |
|
| 5485 | + if (strpos($encoded, $prefix) !== 0 || strlen(trim(str_replace($prefix, '', $encoded))) == 0) |
|
| 5486 | 5486 | { |
| 5487 | 5487 | $output_parts[] = $encoded; |
| 5488 | 5488 | continue; |
@@ -5493,7 +5493,7 @@ discard block |
||
| 5493 | 5493 | $idx = 0; |
| 5494 | 5494 | $char = 0x80; |
| 5495 | 5495 | $decoded = array(); |
| 5496 | - $output=''; |
|
| 5496 | + $output = ''; |
|
| 5497 | 5497 | $delim_pos = strrpos($encoded, '-'); |
| 5498 | 5498 | |
| 5499 | 5499 | if ($delim_pos > strlen($prefix)) |
@@ -5509,7 +5509,7 @@ discard block |
||
| 5509 | 5509 | |
| 5510 | 5510 | for ($enco_idx = $delim_pos ? ($delim_pos + 1) : 0; $enco_idx < $enco_len; ++$deco_len) |
| 5511 | 5511 | { |
| 5512 | - for ($old_idx = $idx, $w = 1, $k = $base; 1 ; $k += $base) |
|
| 5512 | + for ($old_idx = $idx, $w = 1, $k = $base; 1; $k += $base) |
|
| 5513 | 5513 | { |
| 5514 | 5514 | $cp = ord($encoded{$enco_idx++}); |
| 5515 | 5515 | $digit = ($cp - 48 < 10) ? $cp - 22 : (($cp - 65 < 26) ? $cp - 65 : (($cp - 97 < 26) ? $cp - 97 : $base)); |
@@ -5550,15 +5550,15 @@ discard block |
||
| 5550 | 5550 | |
| 5551 | 5551 | // 2 bytes |
| 5552 | 5552 | elseif ($v < (1 << 11)) |
| 5553 | - $output .= chr(192+($v >> 6)) . chr(128+($v & 63)); |
|
| 5553 | + $output .= chr(192 + ($v >> 6)) . chr(128 + ($v & 63)); |
|
| 5554 | 5554 | |
| 5555 | 5555 | // 3 bytes |
| 5556 | 5556 | elseif ($v < (1 << 16)) |
| 5557 | - $output .= chr(224+($v >> 12)) . chr(128+(($v >> 6) & 63)) . chr(128+($v & 63)); |
|
| 5557 | + $output .= chr(224 + ($v >> 12)) . chr(128 + (($v >> 6) & 63)) . chr(128 + ($v & 63)); |
|
| 5558 | 5558 | |
| 5559 | 5559 | // 4 bytes |
| 5560 | 5560 | elseif ($v < (1 << 21)) |
| 5561 | - $output .= chr(240+($v >> 18)) . chr(128+(($v >> 12) & 63)) . chr(128+(($v >> 6) & 63)) . chr(128+($v & 63)); |
|
| 5561 | + $output .= chr(240 + ($v >> 18)) . chr(128 + (($v >> 12) & 63)) . chr(128 + (($v >> 6) & 63)) . chr(128 + ($v & 63)); |
|
| 5562 | 5562 | |
| 5563 | 5563 | // 'Conversion from UCS-4 to UTF-8 failed: malformed input at byte '.$k |
| 5564 | 5564 | else |
@@ -5665,7 +5665,7 @@ discard block |
||
| 5665 | 5665 | } |
| 5666 | 5666 | |
| 5667 | 5667 | // This recursive function creates the index array from the strings |
| 5668 | - $add_string_to_index = function ($string, $index) use (&$strlen, &$substr, &$add_string_to_index) |
|
| 5668 | + $add_string_to_index = function($string, $index) use (&$strlen, &$substr, &$add_string_to_index) |
|
| 5669 | 5669 | { |
| 5670 | 5670 | static $depth = 0; |
| 5671 | 5671 | $depth++; |
@@ -5692,7 +5692,7 @@ discard block |
||
| 5692 | 5692 | }; |
| 5693 | 5693 | |
| 5694 | 5694 | // This recursive function turns the index array into a regular expression |
| 5695 | - $index_to_regex = function (&$index, $delim) use (&$strlen, &$index_to_regex) |
|
| 5695 | + $index_to_regex = function(&$index, $delim) use (&$strlen, &$index_to_regex) |
|
| 5696 | 5696 | { |
| 5697 | 5697 | static $depth = 0; |
| 5698 | 5698 | $depth++; |
@@ -5716,11 +5716,11 @@ discard block |
||
| 5716 | 5716 | |
| 5717 | 5717 | if (count(array_keys($value)) == 1) |
| 5718 | 5718 | { |
| 5719 | - $new_key_array = explode('(?'.'>', $sub_regex); |
|
| 5719 | + $new_key_array = explode('(?' . '>', $sub_regex); |
|
| 5720 | 5720 | $new_key .= $new_key_array[0]; |
| 5721 | 5721 | } |
| 5722 | 5722 | else |
| 5723 | - $sub_regex = '(?'.'>' . $sub_regex . ')'; |
|
| 5723 | + $sub_regex = '(?' . '>' . $sub_regex . ')'; |
|
| 5724 | 5724 | } |
| 5725 | 5725 | |
| 5726 | 5726 | if ($depth > 1) |
@@ -5760,7 +5760,7 @@ discard block |
||
| 5760 | 5760 | $index = $add_string_to_index($string, $index); |
| 5761 | 5761 | |
| 5762 | 5762 | while (!empty($index)) |
| 5763 | - $regexes[] = '(?'.'>' . $index_to_regex($index, $delim) . ')'; |
|
| 5763 | + $regexes[] = '(?' . '>' . $index_to_regex($index, $delim) . ')'; |
|
| 5764 | 5764 | |
| 5765 | 5765 | // Restore PHP's internal character encoding to whatever it was originally |
| 5766 | 5766 | if (!empty($current_encoding)) |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 3 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * Update some basic statistics. |
@@ -122,10 +123,11 @@ discard block |
||
| 122 | 123 | $smcFunc['db_free_result']($result); |
| 123 | 124 | |
| 124 | 125 | // Add this to the number of unapproved members |
| 125 | - if (!empty($changes['unapprovedMembers'])) |
|
| 126 | - $changes['unapprovedMembers'] += $coppa_approvals; |
|
| 127 | - else |
|
| 128 | - $changes['unapprovedMembers'] = $coppa_approvals; |
|
| 126 | + if (!empty($changes['unapprovedMembers'])) { |
|
| 127 | + $changes['unapprovedMembers'] += $coppa_approvals; |
|
| 128 | + } else { |
|
| 129 | + $changes['unapprovedMembers'] = $coppa_approvals; |
|
| 130 | + } |
|
| 129 | 131 | } |
| 130 | 132 | } |
| 131 | 133 | } |
@@ -133,9 +135,9 @@ discard block |
||
| 133 | 135 | break; |
| 134 | 136 | |
| 135 | 137 | case 'message': |
| 136 | - if ($parameter1 === true && $parameter2 !== null) |
|
| 137 | - updateSettings(array('totalMessages' => true, 'maxMsgID' => $parameter2), true); |
|
| 138 | - else |
|
| 138 | + if ($parameter1 === true && $parameter2 !== null) { |
|
| 139 | + updateSettings(array('totalMessages' => true, 'maxMsgID' => $parameter2), true); |
|
| 140 | + } else |
|
| 139 | 141 | { |
| 140 | 142 | // SUM and MAX on a smaller table is better for InnoDB tables. |
| 141 | 143 | $result = $smcFunc['db_query']('', ' |
@@ -175,23 +177,25 @@ discard block |
||
| 175 | 177 | $parameter2 = text2words($parameter2); |
| 176 | 178 | |
| 177 | 179 | $inserts = array(); |
| 178 | - foreach ($parameter2 as $word) |
|
| 179 | - $inserts[] = array($word, $parameter1); |
|
| 180 | + foreach ($parameter2 as $word) { |
|
| 181 | + $inserts[] = array($word, $parameter1); |
|
| 182 | + } |
|
| 180 | 183 | |
| 181 | - if (!empty($inserts)) |
|
| 182 | - $smcFunc['db_insert']('ignore', |
|
| 184 | + if (!empty($inserts)) { |
|
| 185 | + $smcFunc['db_insert']('ignore', |
|
| 183 | 186 | '{db_prefix}log_search_subjects', |
| 184 | 187 | array('word' => 'string', 'id_topic' => 'int'), |
| 185 | 188 | $inserts, |
| 186 | 189 | array('word', 'id_topic') |
| 187 | 190 | ); |
| 191 | + } |
|
| 188 | 192 | } |
| 189 | 193 | break; |
| 190 | 194 | |
| 191 | 195 | case 'topic': |
| 192 | - if ($parameter1 === true) |
|
| 193 | - updateSettings(array('totalTopics' => true), true); |
|
| 194 | - else |
|
| 196 | + if ($parameter1 === true) { |
|
| 197 | + updateSettings(array('totalTopics' => true), true); |
|
| 198 | + } else |
|
| 195 | 199 | { |
| 196 | 200 | // Get the number of topics - a SUM is better for InnoDB tables. |
| 197 | 201 | // We also ignore the recycle bin here because there will probably be a bunch of one-post topics there. |
@@ -212,8 +216,9 @@ discard block |
||
| 212 | 216 | |
| 213 | 217 | case 'postgroups': |
| 214 | 218 | // Parameter two is the updated columns: we should check to see if we base groups off any of these. |
| 215 | - if ($parameter2 !== null && !in_array('posts', $parameter2)) |
|
| 216 | - return; |
|
| 219 | + if ($parameter2 !== null && !in_array('posts', $parameter2)) { |
|
| 220 | + return; |
|
| 221 | + } |
|
| 217 | 222 | |
| 218 | 223 | $postgroups = cache_get_data('updateStats:postgroups', 360); |
| 219 | 224 | if ($postgroups == null || $parameter1 == null) |
@@ -228,8 +233,9 @@ discard block |
||
| 228 | 233 | ) |
| 229 | 234 | ); |
| 230 | 235 | $postgroups = array(); |
| 231 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 232 | - $postgroups[$row['id_group']] = $row['min_posts']; |
|
| 236 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 237 | + $postgroups[$row['id_group']] = $row['min_posts']; |
|
| 238 | + } |
|
| 233 | 239 | $smcFunc['db_free_result']($request); |
| 234 | 240 | |
| 235 | 241 | // Sort them this way because if it's done with MySQL it causes a filesort :(. |
@@ -239,8 +245,9 @@ discard block |
||
| 239 | 245 | } |
| 240 | 246 | |
| 241 | 247 | // Oh great, they've screwed their post groups. |
| 242 | - if (empty($postgroups)) |
|
| 243 | - return; |
|
| 248 | + if (empty($postgroups)) { |
|
| 249 | + return; |
|
| 250 | + } |
|
| 244 | 251 | |
| 245 | 252 | // Set all membergroups from most posts to least posts. |
| 246 | 253 | $conditions = ''; |
@@ -298,10 +305,9 @@ discard block |
||
| 298 | 305 | { |
| 299 | 306 | $condition = 'id_member IN ({array_int:members})'; |
| 300 | 307 | $parameters['members'] = $members; |
| 301 | - } |
|
| 302 | - elseif ($members === null) |
|
| 303 | - $condition = '1=1'; |
|
| 304 | - else |
|
| 308 | + } elseif ($members === null) { |
|
| 309 | + $condition = '1=1'; |
|
| 310 | + } else |
|
| 305 | 311 | { |
| 306 | 312 | $condition = 'id_member = {int:member}'; |
| 307 | 313 | $parameters['member'] = $members; |
@@ -341,9 +347,9 @@ discard block |
||
| 341 | 347 | if (count($vars_to_integrate) != 0) |
| 342 | 348 | { |
| 343 | 349 | // Fetch a list of member_names if necessary |
| 344 | - if ((!is_array($members) && $members === $user_info['id']) || (is_array($members) && count($members) == 1 && in_array($user_info['id'], $members))) |
|
| 345 | - $member_names = array($user_info['username']); |
|
| 346 | - else |
|
| 350 | + if ((!is_array($members) && $members === $user_info['id']) || (is_array($members) && count($members) == 1 && in_array($user_info['id'], $members))) { |
|
| 351 | + $member_names = array($user_info['username']); |
|
| 352 | + } else |
|
| 347 | 353 | { |
| 348 | 354 | $member_names = array(); |
| 349 | 355 | $request = $smcFunc['db_query']('', ' |
@@ -352,14 +358,16 @@ discard block |
||
| 352 | 358 | WHERE ' . $condition, |
| 353 | 359 | $parameters |
| 354 | 360 | ); |
| 355 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 356 | - $member_names[] = $row['member_name']; |
|
| 361 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 362 | + $member_names[] = $row['member_name']; |
|
| 363 | + } |
|
| 357 | 364 | $smcFunc['db_free_result']($request); |
| 358 | 365 | } |
| 359 | 366 | |
| 360 | - if (!empty($member_names)) |
|
| 361 | - foreach ($vars_to_integrate as $var) |
|
| 367 | + if (!empty($member_names)) { |
|
| 368 | + foreach ($vars_to_integrate as $var) |
|
| 362 | 369 | call_integration_hook('integrate_change_member_data', array($member_names, $var, &$data[$var], &$knownInts, &$knownFloats)); |
| 370 | + } |
|
| 363 | 371 | } |
| 364 | 372 | } |
| 365 | 373 | |
@@ -367,16 +375,17 @@ discard block |
||
| 367 | 375 | foreach ($data as $var => $val) |
| 368 | 376 | { |
| 369 | 377 | $type = 'string'; |
| 370 | - if (in_array($var, $knownInts)) |
|
| 371 | - $type = 'int'; |
|
| 372 | - elseif (in_array($var, $knownFloats)) |
|
| 373 | - $type = 'float'; |
|
| 374 | - elseif ($var == 'birthdate') |
|
| 375 | - $type = 'date'; |
|
| 376 | - elseif ($var == 'member_ip') |
|
| 377 | - $type = 'inet'; |
|
| 378 | - elseif ($var == 'member_ip2') |
|
| 379 | - $type = 'inet'; |
|
| 378 | + if (in_array($var, $knownInts)) { |
|
| 379 | + $type = 'int'; |
|
| 380 | + } elseif (in_array($var, $knownFloats)) { |
|
| 381 | + $type = 'float'; |
|
| 382 | + } elseif ($var == 'birthdate') { |
|
| 383 | + $type = 'date'; |
|
| 384 | + } elseif ($var == 'member_ip') { |
|
| 385 | + $type = 'inet'; |
|
| 386 | + } elseif ($var == 'member_ip2') { |
|
| 387 | + $type = 'inet'; |
|
| 388 | + } |
|
| 380 | 389 | |
| 381 | 390 | // Doing an increment? |
| 382 | 391 | if ($type == 'int' && ($val === '+' || $val === '-')) |
@@ -390,8 +399,9 @@ discard block |
||
| 390 | 399 | { |
| 391 | 400 | if (preg_match('~^' . $var . ' (\+ |- |\+ -)([\d]+)~', $val, $match)) |
| 392 | 401 | { |
| 393 | - if ($match[1] != '+ ') |
|
| 394 | - $val = 'CASE WHEN ' . $var . ' <= ' . abs($match[2]) . ' THEN 0 ELSE ' . $val . ' END'; |
|
| 402 | + if ($match[1] != '+ ') { |
|
| 403 | + $val = 'CASE WHEN ' . $var . ' <= ' . abs($match[2]) . ' THEN 0 ELSE ' . $val . ' END'; |
|
| 404 | + } |
|
| 395 | 405 | $type = 'raw'; |
| 396 | 406 | } |
| 397 | 407 | } |
@@ -412,8 +422,9 @@ discard block |
||
| 412 | 422 | // Clear any caching? |
| 413 | 423 | if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2 && !empty($members)) |
| 414 | 424 | { |
| 415 | - if (!is_array($members)) |
|
| 416 | - $members = array($members); |
|
| 425 | + if (!is_array($members)) { |
|
| 426 | + $members = array($members); |
|
| 427 | + } |
|
| 417 | 428 | |
| 418 | 429 | foreach ($members as $member) |
| 419 | 430 | { |
@@ -446,29 +457,32 @@ discard block |
||
| 446 | 457 | { |
| 447 | 458 | global $modSettings, $smcFunc; |
| 448 | 459 | |
| 449 | - if (empty($changeArray) || !is_array($changeArray)) |
|
| 450 | - return; |
|
| 460 | + if (empty($changeArray) || !is_array($changeArray)) { |
|
| 461 | + return; |
|
| 462 | + } |
|
| 451 | 463 | |
| 452 | 464 | $toRemove = array(); |
| 453 | 465 | |
| 454 | 466 | // Go check if there is any setting to be removed. |
| 455 | - foreach ($changeArray as $k => $v) |
|
| 456 | - if ($v === null) |
|
| 467 | + foreach ($changeArray as $k => $v) { |
|
| 468 | + if ($v === null) |
|
| 457 | 469 | { |
| 458 | 470 | // Found some, remove them from the original array and add them to ours. |
| 459 | 471 | unset($changeArray[$k]); |
| 472 | + } |
|
| 460 | 473 | $toRemove[] = $k; |
| 461 | 474 | } |
| 462 | 475 | |
| 463 | 476 | // Proceed with the deletion. |
| 464 | - if (!empty($toRemove)) |
|
| 465 | - $smcFunc['db_query']('', ' |
|
| 477 | + if (!empty($toRemove)) { |
|
| 478 | + $smcFunc['db_query']('', ' |
|
| 466 | 479 | DELETE FROM {db_prefix}settings |
| 467 | 480 | WHERE variable IN ({array_string:remove})', |
| 468 | 481 | array( |
| 469 | 482 | 'remove' => $toRemove, |
| 470 | 483 | ) |
| 471 | 484 | ); |
| 485 | + } |
|
| 472 | 486 | |
| 473 | 487 | // In some cases, this may be better and faster, but for large sets we don't want so many UPDATEs. |
| 474 | 488 | if ($update) |
@@ -497,19 +511,22 @@ discard block |
||
| 497 | 511 | foreach ($changeArray as $variable => $value) |
| 498 | 512 | { |
| 499 | 513 | // Don't bother if it's already like that ;). |
| 500 | - if (isset($modSettings[$variable]) && $modSettings[$variable] == $value) |
|
| 501 | - continue; |
|
| 514 | + if (isset($modSettings[$variable]) && $modSettings[$variable] == $value) { |
|
| 515 | + continue; |
|
| 516 | + } |
|
| 502 | 517 | // If the variable isn't set, but would only be set to nothing'ness, then don't bother setting it. |
| 503 | - elseif (!isset($modSettings[$variable]) && empty($value)) |
|
| 504 | - continue; |
|
| 518 | + elseif (!isset($modSettings[$variable]) && empty($value)) { |
|
| 519 | + continue; |
|
| 520 | + } |
|
| 505 | 521 | |
| 506 | 522 | $replaceArray[] = array($variable, $value); |
| 507 | 523 | |
| 508 | 524 | $modSettings[$variable] = $value; |
| 509 | 525 | } |
| 510 | 526 | |
| 511 | - if (empty($replaceArray)) |
|
| 512 | - return; |
|
| 527 | + if (empty($replaceArray)) { |
|
| 528 | + return; |
|
| 529 | + } |
|
| 513 | 530 | |
| 514 | 531 | $smcFunc['db_insert']('replace', |
| 515 | 532 | '{db_prefix}settings', |
@@ -555,14 +572,17 @@ discard block |
||
| 555 | 572 | $start_invalid = $start < 0; |
| 556 | 573 | |
| 557 | 574 | // Make sure $start is a proper variable - not less than 0. |
| 558 | - if ($start_invalid) |
|
| 559 | - $start = 0; |
|
| 575 | + if ($start_invalid) { |
|
| 576 | + $start = 0; |
|
| 577 | + } |
|
| 560 | 578 | // Not greater than the upper bound. |
| 561 | - elseif ($start >= $max_value) |
|
| 562 | - $start = max(0, (int) $max_value - (((int) $max_value % (int) $num_per_page) == 0 ? $num_per_page : ((int) $max_value % (int) $num_per_page))); |
|
| 579 | + elseif ($start >= $max_value) { |
|
| 580 | + $start = max(0, (int) $max_value - (((int) $max_value % (int) $num_per_page) == 0 ? $num_per_page : ((int) $max_value % (int) $num_per_page))); |
|
| 581 | + } |
|
| 563 | 582 | // And it has to be a multiple of $num_per_page! |
| 564 | - else |
|
| 565 | - $start = max(0, (int) $start - ((int) $start % (int) $num_per_page)); |
|
| 583 | + else { |
|
| 584 | + $start = max(0, (int) $start - ((int) $start % (int) $num_per_page)); |
|
| 585 | + } |
|
| 566 | 586 | |
| 567 | 587 | $context['current_page'] = $start / $num_per_page; |
| 568 | 588 | |
@@ -592,77 +612,87 @@ discard block |
||
| 592 | 612 | |
| 593 | 613 | // Show all the pages. |
| 594 | 614 | $display_page = 1; |
| 595 | - for ($counter = 0; $counter < $max_value; $counter += $num_per_page) |
|
| 596 | - $pageindex .= $start == $counter && !$start_invalid ? sprintf($settings['page_index']['current_page'], $display_page++) : sprintf($base_link, $counter, $display_page++); |
|
| 615 | + for ($counter = 0; $counter < $max_value; $counter += $num_per_page) { |
|
| 616 | + $pageindex .= $start == $counter && !$start_invalid ? sprintf($settings['page_index']['current_page'], $display_page++) : sprintf($base_link, $counter, $display_page++); |
|
| 617 | + } |
|
| 597 | 618 | |
| 598 | 619 | // Show the right arrow. |
| 599 | 620 | $display_page = ($start + $num_per_page) > $max_value ? $max_value : ($start + $num_per_page); |
| 600 | - if ($start != $counter - $max_value && !$start_invalid) |
|
| 601 | - $pageindex .= $display_page > $counter - $num_per_page ? ' ' : sprintf($base_link, $display_page, $settings['page_index']['next_page']); |
|
| 602 | - } |
|
| 603 | - else |
|
| 621 | + if ($start != $counter - $max_value && !$start_invalid) { |
|
| 622 | + $pageindex .= $display_page > $counter - $num_per_page ? ' ' : sprintf($base_link, $display_page, $settings['page_index']['next_page']); |
|
| 623 | + } |
|
| 624 | + } else |
|
| 604 | 625 | { |
| 605 | 626 | // If they didn't enter an odd value, pretend they did. |
| 606 | 627 | $PageContiguous = (int) ($modSettings['compactTopicPagesContiguous'] - ($modSettings['compactTopicPagesContiguous'] % 2)) / 2; |
| 607 | 628 | |
| 608 | 629 | // Show the "prev page" link. (>prev page< 1 ... 6 7 [8] 9 10 ... 15 next page) |
| 609 | - if (!empty($start) && $show_prevnext) |
|
| 610 | - $pageindex .= sprintf($base_link, $start - $num_per_page, $settings['page_index']['previous_page']); |
|
| 611 | - else |
|
| 612 | - $pageindex .= ''; |
|
| 630 | + if (!empty($start) && $show_prevnext) { |
|
| 631 | + $pageindex .= sprintf($base_link, $start - $num_per_page, $settings['page_index']['previous_page']); |
|
| 632 | + } else { |
|
| 633 | + $pageindex .= ''; |
|
| 634 | + } |
|
| 613 | 635 | |
| 614 | 636 | // Show the first page. (prev page >1< ... 6 7 [8] 9 10 ... 15) |
| 615 | - if ($start > $num_per_page * $PageContiguous) |
|
| 616 | - $pageindex .= sprintf($base_link, 0, '1'); |
|
| 637 | + if ($start > $num_per_page * $PageContiguous) { |
|
| 638 | + $pageindex .= sprintf($base_link, 0, '1'); |
|
| 639 | + } |
|
| 617 | 640 | |
| 618 | 641 | // Show the ... after the first page. (prev page 1 >...< 6 7 [8] 9 10 ... 15 next page) |
| 619 | - if ($start > $num_per_page * ($PageContiguous + 1)) |
|
| 620 | - $pageindex .= strtr($settings['page_index']['expand_pages'], array( |
|
| 642 | + if ($start > $num_per_page * ($PageContiguous + 1)) { |
|
| 643 | + $pageindex .= strtr($settings['page_index']['expand_pages'], array( |
|
| 621 | 644 | '{LINK}' => JavaScriptEscape($smcFunc['htmlspecialchars']($base_link)), |
| 622 | 645 | '{FIRST_PAGE}' => $num_per_page, |
| 623 | 646 | '{LAST_PAGE}' => $start - $num_per_page * $PageContiguous, |
| 624 | 647 | '{PER_PAGE}' => $num_per_page, |
| 625 | 648 | )); |
| 649 | + } |
|
| 626 | 650 | |
| 627 | 651 | // Show the pages before the current one. (prev page 1 ... >6 7< [8] 9 10 ... 15 next page) |
| 628 | - for ($nCont = $PageContiguous; $nCont >= 1; $nCont--) |
|
| 629 | - if ($start >= $num_per_page * $nCont) |
|
| 652 | + for ($nCont = $PageContiguous; $nCont >= 1; $nCont--) { |
|
| 653 | + if ($start >= $num_per_page * $nCont) |
|
| 630 | 654 | { |
| 631 | 655 | $tmpStart = $start - $num_per_page * $nCont; |
| 656 | + } |
|
| 632 | 657 | $pageindex .= sprintf($base_link, $tmpStart, $tmpStart / $num_per_page + 1); |
| 633 | 658 | } |
| 634 | 659 | |
| 635 | 660 | // Show the current page. (prev page 1 ... 6 7 >[8]< 9 10 ... 15 next page) |
| 636 | - if (!$start_invalid) |
|
| 637 | - $pageindex .= sprintf($settings['page_index']['current_page'], $start / $num_per_page + 1); |
|
| 638 | - else |
|
| 639 | - $pageindex .= sprintf($base_link, $start, $start / $num_per_page + 1); |
|
| 661 | + if (!$start_invalid) { |
|
| 662 | + $pageindex .= sprintf($settings['page_index']['current_page'], $start / $num_per_page + 1); |
|
| 663 | + } else { |
|
| 664 | + $pageindex .= sprintf($base_link, $start, $start / $num_per_page + 1); |
|
| 665 | + } |
|
| 640 | 666 | |
| 641 | 667 | // Show the pages after the current one... (prev page 1 ... 6 7 [8] >9 10< ... 15 next page) |
| 642 | 668 | $tmpMaxPages = (int) (($max_value - 1) / $num_per_page) * $num_per_page; |
| 643 | - for ($nCont = 1; $nCont <= $PageContiguous; $nCont++) |
|
| 644 | - if ($start + $num_per_page * $nCont <= $tmpMaxPages) |
|
| 669 | + for ($nCont = 1; $nCont <= $PageContiguous; $nCont++) { |
|
| 670 | + if ($start + $num_per_page * $nCont <= $tmpMaxPages) |
|
| 645 | 671 | { |
| 646 | 672 | $tmpStart = $start + $num_per_page * $nCont; |
| 673 | + } |
|
| 647 | 674 | $pageindex .= sprintf($base_link, $tmpStart, $tmpStart / $num_per_page + 1); |
| 648 | 675 | } |
| 649 | 676 | |
| 650 | 677 | // Show the '...' part near the end. (prev page 1 ... 6 7 [8] 9 10 >...< 15 next page) |
| 651 | - if ($start + $num_per_page * ($PageContiguous + 1) < $tmpMaxPages) |
|
| 652 | - $pageindex .= strtr($settings['page_index']['expand_pages'], array( |
|
| 678 | + if ($start + $num_per_page * ($PageContiguous + 1) < $tmpMaxPages) { |
|
| 679 | + $pageindex .= strtr($settings['page_index']['expand_pages'], array( |
|
| 653 | 680 | '{LINK}' => JavaScriptEscape($smcFunc['htmlspecialchars']($base_link)), |
| 654 | 681 | '{FIRST_PAGE}' => $start + $num_per_page * ($PageContiguous + 1), |
| 655 | 682 | '{LAST_PAGE}' => $tmpMaxPages, |
| 656 | 683 | '{PER_PAGE}' => $num_per_page, |
| 657 | 684 | )); |
| 685 | + } |
|
| 658 | 686 | |
| 659 | 687 | // Show the last number in the list. (prev page 1 ... 6 7 [8] 9 10 ... >15< next page) |
| 660 | - if ($start + $num_per_page * $PageContiguous < $tmpMaxPages) |
|
| 661 | - $pageindex .= sprintf($base_link, $tmpMaxPages, $tmpMaxPages / $num_per_page + 1); |
|
| 688 | + if ($start + $num_per_page * $PageContiguous < $tmpMaxPages) { |
|
| 689 | + $pageindex .= sprintf($base_link, $tmpMaxPages, $tmpMaxPages / $num_per_page + 1); |
|
| 690 | + } |
|
| 662 | 691 | |
| 663 | 692 | // Show the "next page" link. (prev page 1 ... 6 7 [8] 9 10 ... 15 >next page<) |
| 664 | - if ($start != $tmpMaxPages && $show_prevnext) |
|
| 665 | - $pageindex .= sprintf($base_link, $start + $num_per_page, $settings['page_index']['next_page']); |
|
| 693 | + if ($start != $tmpMaxPages && $show_prevnext) { |
|
| 694 | + $pageindex .= sprintf($base_link, $start + $num_per_page, $settings['page_index']['next_page']); |
|
| 695 | + } |
|
| 666 | 696 | } |
| 667 | 697 | $pageindex .= $settings['page_index']['extra_after']; |
| 668 | 698 | |
@@ -688,8 +718,9 @@ discard block |
||
| 688 | 718 | if ($decimal_separator === null) |
| 689 | 719 | { |
| 690 | 720 | // Not set for whatever reason? |
| 691 | - if (empty($txt['number_format']) || preg_match('~^1([^\d]*)?234([^\d]*)(0*?)$~', $txt['number_format'], $matches) != 1) |
|
| 692 | - return $number; |
|
| 721 | + if (empty($txt['number_format']) || preg_match('~^1([^\d]*)?234([^\d]*)(0*?)$~', $txt['number_format'], $matches) != 1) { |
|
| 722 | + return $number; |
|
| 723 | + } |
|
| 693 | 724 | |
| 694 | 725 | // Cache these each load... |
| 695 | 726 | $thousands_separator = $matches[1]; |
@@ -721,17 +752,20 @@ discard block |
||
| 721 | 752 | static $non_twelve_hour; |
| 722 | 753 | |
| 723 | 754 | // Offset the time. |
| 724 | - if (!$offset_type) |
|
| 725 | - $time = $log_time + ($user_info['time_offset'] + $modSettings['time_offset']) * 3600; |
|
| 755 | + if (!$offset_type) { |
|
| 756 | + $time = $log_time + ($user_info['time_offset'] + $modSettings['time_offset']) * 3600; |
|
| 757 | + } |
|
| 726 | 758 | // Just the forum offset? |
| 727 | - elseif ($offset_type == 'forum') |
|
| 728 | - $time = $log_time + $modSettings['time_offset'] * 3600; |
|
| 729 | - else |
|
| 730 | - $time = $log_time; |
|
| 759 | + elseif ($offset_type == 'forum') { |
|
| 760 | + $time = $log_time + $modSettings['time_offset'] * 3600; |
|
| 761 | + } else { |
|
| 762 | + $time = $log_time; |
|
| 763 | + } |
|
| 731 | 764 | |
| 732 | 765 | // We can't have a negative date (on Windows, at least.) |
| 733 | - if ($log_time < 0) |
|
| 734 | - $log_time = 0; |
|
| 766 | + if ($log_time < 0) { |
|
| 767 | + $log_time = 0; |
|
| 768 | + } |
|
| 735 | 769 | |
| 736 | 770 | // Today and Yesterday? |
| 737 | 771 | if ($modSettings['todayMod'] >= 1 && $show_today === true) |
@@ -748,46 +782,53 @@ discard block |
||
| 748 | 782 | { |
| 749 | 783 | $h = strpos($user_info['time_format'], '%l') === false ? '%I' : '%l'; |
| 750 | 784 | $today_fmt = $h . ':%M' . $s . ' %p'; |
| 785 | + } else { |
|
| 786 | + $today_fmt = '%H:%M' . $s; |
|
| 751 | 787 | } |
| 752 | - else |
|
| 753 | - $today_fmt = '%H:%M' . $s; |
|
| 754 | 788 | |
| 755 | 789 | // Same day of the year, same year.... Today! |
| 756 | - if ($then['yday'] == $now['yday'] && $then['year'] == $now['year']) |
|
| 757 | - return $txt['today'] . timeformat($log_time, $today_fmt, $offset_type); |
|
| 790 | + if ($then['yday'] == $now['yday'] && $then['year'] == $now['year']) { |
|
| 791 | + return $txt['today'] . timeformat($log_time, $today_fmt, $offset_type); |
|
| 792 | + } |
|
| 758 | 793 | |
| 759 | 794 | // Day-of-year is one less and same year, or it's the first of the year and that's the last of the year... |
| 760 | - if ($modSettings['todayMod'] == '2' && (($then['yday'] == $now['yday'] - 1 && $then['year'] == $now['year']) || ($now['yday'] == 0 && $then['year'] == $now['year'] - 1) && $then['mon'] == 12 && $then['mday'] == 31)) |
|
| 761 | - return $txt['yesterday'] . timeformat($log_time, $today_fmt, $offset_type); |
|
| 795 | + if ($modSettings['todayMod'] == '2' && (($then['yday'] == $now['yday'] - 1 && $then['year'] == $now['year']) || ($now['yday'] == 0 && $then['year'] == $now['year'] - 1) && $then['mon'] == 12 && $then['mday'] == 31)) { |
|
| 796 | + return $txt['yesterday'] . timeformat($log_time, $today_fmt, $offset_type); |
|
| 797 | + } |
|
| 762 | 798 | } |
| 763 | 799 | |
| 764 | 800 | $str = !is_bool($show_today) ? $show_today : $user_info['time_format']; |
| 765 | 801 | |
| 766 | 802 | if (setlocale(LC_TIME, $txt['lang_locale'])) |
| 767 | 803 | { |
| 768 | - if (!isset($non_twelve_hour)) |
|
| 769 | - $non_twelve_hour = trim(strftime('%p')) === ''; |
|
| 770 | - if ($non_twelve_hour && strpos($str, '%p') !== false) |
|
| 771 | - $str = str_replace('%p', (strftime('%H', $time) < 12 ? $txt['time_am'] : $txt['time_pm']), $str); |
|
| 804 | + if (!isset($non_twelve_hour)) { |
|
| 805 | + $non_twelve_hour = trim(strftime('%p')) === ''; |
|
| 806 | + } |
|
| 807 | + if ($non_twelve_hour && strpos($str, '%p') !== false) { |
|
| 808 | + $str = str_replace('%p', (strftime('%H', $time) < 12 ? $txt['time_am'] : $txt['time_pm']), $str); |
|
| 809 | + } |
|
| 772 | 810 | |
| 773 | - foreach (array('%a', '%A', '%b', '%B') as $token) |
|
| 774 | - if (strpos($str, $token) !== false) |
|
| 811 | + foreach (array('%a', '%A', '%b', '%B') as $token) { |
|
| 812 | + if (strpos($str, $token) !== false) |
|
| 775 | 813 | $str = str_replace($token, strftime($token, $time), $str); |
| 776 | - } |
|
| 777 | - else |
|
| 814 | + } |
|
| 815 | + } else |
|
| 778 | 816 | { |
| 779 | 817 | // Do-it-yourself time localization. Fun. |
| 780 | - foreach (array('%a' => 'days_short', '%A' => 'days', '%b' => 'months_short', '%B' => 'months') as $token => $text_label) |
|
| 781 | - if (strpos($str, $token) !== false) |
|
| 818 | + foreach (array('%a' => 'days_short', '%A' => 'days', '%b' => 'months_short', '%B' => 'months') as $token => $text_label) { |
|
| 819 | + if (strpos($str, $token) !== false) |
|
| 782 | 820 | $str = str_replace($token, $txt[$text_label][(int) strftime($token === '%a' || $token === '%A' ? '%w' : '%m', $time)], $str); |
| 821 | + } |
|
| 783 | 822 | |
| 784 | - if (strpos($str, '%p') !== false) |
|
| 785 | - $str = str_replace('%p', (strftime('%H', $time) < 12 ? $txt['time_am'] : $txt['time_pm']), $str); |
|
| 823 | + if (strpos($str, '%p') !== false) { |
|
| 824 | + $str = str_replace('%p', (strftime('%H', $time) < 12 ? $txt['time_am'] : $txt['time_pm']), $str); |
|
| 825 | + } |
|
| 786 | 826 | } |
| 787 | 827 | |
| 788 | 828 | // Windows doesn't support %e; on some versions, strftime fails altogether if used, so let's prevent that. |
| 789 | - if ($context['server']['is_windows'] && strpos($str, '%e') !== false) |
|
| 790 | - $str = str_replace('%e', ltrim(strftime('%d', $time), '0'), $str); |
|
| 829 | + if ($context['server']['is_windows'] && strpos($str, '%e') !== false) { |
|
| 830 | + $str = str_replace('%e', ltrim(strftime('%d', $time), '0'), $str); |
|
| 831 | + } |
|
| 791 | 832 | |
| 792 | 833 | // Format any other characters.. |
| 793 | 834 | return strftime($str, $time); |
@@ -809,16 +850,19 @@ discard block |
||
| 809 | 850 | static $translation = array(); |
| 810 | 851 | |
| 811 | 852 | // Determine the character set... Default to UTF-8 |
| 812 | - if (empty($context['character_set'])) |
|
| 813 | - $charset = 'UTF-8'; |
|
| 853 | + if (empty($context['character_set'])) { |
|
| 854 | + $charset = 'UTF-8'; |
|
| 855 | + } |
|
| 814 | 856 | // Use ISO-8859-1 in place of non-supported ISO-8859 charsets... |
| 815 | - elseif (strpos($context['character_set'], 'ISO-8859-') !== false && !in_array($context['character_set'], array('ISO-8859-5', 'ISO-8859-15'))) |
|
| 816 | - $charset = 'ISO-8859-1'; |
|
| 817 | - else |
|
| 818 | - $charset = $context['character_set']; |
|
| 857 | + elseif (strpos($context['character_set'], 'ISO-8859-') !== false && !in_array($context['character_set'], array('ISO-8859-5', 'ISO-8859-15'))) { |
|
| 858 | + $charset = 'ISO-8859-1'; |
|
| 859 | + } else { |
|
| 860 | + $charset = $context['character_set']; |
|
| 861 | + } |
|
| 819 | 862 | |
| 820 | - if (empty($translation)) |
|
| 821 | - $translation = array_flip(get_html_translation_table(HTML_SPECIALCHARS, ENT_QUOTES, $charset)) + array(''' => '\'', ''' => '\'', ' ' => ' '); |
|
| 863 | + if (empty($translation)) { |
|
| 864 | + $translation = array_flip(get_html_translation_table(HTML_SPECIALCHARS, ENT_QUOTES, $charset)) + array(''' => '\'', ''' => '\'', ' ' => ' '); |
|
| 865 | + } |
|
| 822 | 866 | |
| 823 | 867 | return strtr($string, $translation); |
| 824 | 868 | } |
@@ -840,8 +884,9 @@ discard block |
||
| 840 | 884 | global $smcFunc; |
| 841 | 885 | |
| 842 | 886 | // It was already short enough! |
| 843 | - if ($smcFunc['strlen']($subject) <= $len) |
|
| 844 | - return $subject; |
|
| 887 | + if ($smcFunc['strlen']($subject) <= $len) { |
|
| 888 | + return $subject; |
|
| 889 | + } |
|
| 845 | 890 | |
| 846 | 891 | // Shorten it by the length it was too long, and strip off junk from the end. |
| 847 | 892 | return $smcFunc['substr']($subject, 0, $len) . '...'; |
@@ -860,10 +905,11 @@ discard block |
||
| 860 | 905 | { |
| 861 | 906 | global $user_info, $modSettings; |
| 862 | 907 | |
| 863 | - if ($timestamp === null) |
|
| 864 | - $timestamp = time(); |
|
| 865 | - elseif ($timestamp == 0) |
|
| 866 | - return 0; |
|
| 908 | + if ($timestamp === null) { |
|
| 909 | + $timestamp = time(); |
|
| 910 | + } elseif ($timestamp == 0) { |
|
| 911 | + return 0; |
|
| 912 | + } |
|
| 867 | 913 | |
| 868 | 914 | return $timestamp + ($modSettings['time_offset'] + ($use_user_offset ? $user_info['time_offset'] : 0)) * 3600; |
| 869 | 915 | } |
@@ -892,8 +938,9 @@ discard block |
||
| 892 | 938 | $array[$i] = $array[$j]; |
| 893 | 939 | $array[$j] = $temp; |
| 894 | 940 | |
| 895 | - for ($i = 1; $p[$i] == 0; $i++) |
|
| 896 | - $p[$i] = 1; |
|
| 941 | + for ($i = 1; $p[$i] == 0; $i++) { |
|
| 942 | + $p[$i] = 1; |
|
| 943 | + } |
|
| 897 | 944 | |
| 898 | 945 | $orders[] = $array; |
| 899 | 946 | } |
@@ -925,12 +972,14 @@ discard block |
||
| 925 | 972 | static $disabled; |
| 926 | 973 | |
| 927 | 974 | // Don't waste cycles |
| 928 | - if ($message === '') |
|
| 929 | - return ''; |
|
| 975 | + if ($message === '') { |
|
| 976 | + return ''; |
|
| 977 | + } |
|
| 930 | 978 | |
| 931 | 979 | // Just in case it wasn't determined yet whether UTF-8 is enabled. |
| 932 | - if (!isset($context['utf8'])) |
|
| 933 | - $context['utf8'] = (empty($modSettings['global_character_set']) ? $txt['lang_character_set'] : $modSettings['global_character_set']) === 'UTF-8'; |
|
| 980 | + if (!isset($context['utf8'])) { |
|
| 981 | + $context['utf8'] = (empty($modSettings['global_character_set']) ? $txt['lang_character_set'] : $modSettings['global_character_set']) === 'UTF-8'; |
|
| 982 | + } |
|
| 934 | 983 | |
| 935 | 984 | // Clean up any cut/paste issues we may have |
| 936 | 985 | $message = sanitizeMSCutPaste($message); |
@@ -942,13 +991,15 @@ discard block |
||
| 942 | 991 | return $message; |
| 943 | 992 | } |
| 944 | 993 | |
| 945 | - if ($smileys !== null && ($smileys == '1' || $smileys == '0')) |
|
| 946 | - $smileys = (bool) $smileys; |
|
| 994 | + if ($smileys !== null && ($smileys == '1' || $smileys == '0')) { |
|
| 995 | + $smileys = (bool) $smileys; |
|
| 996 | + } |
|
| 947 | 997 | |
| 948 | 998 | if (empty($modSettings['enableBBC']) && $message !== false) |
| 949 | 999 | { |
| 950 | - if ($smileys === true) |
|
| 951 | - parsesmileys($message); |
|
| 1000 | + if ($smileys === true) { |
|
| 1001 | + parsesmileys($message); |
|
| 1002 | + } |
|
| 952 | 1003 | |
| 953 | 1004 | return $message; |
| 954 | 1005 | } |
@@ -961,8 +1012,9 @@ discard block |
||
| 961 | 1012 | } |
| 962 | 1013 | |
| 963 | 1014 | // Ensure $modSettings['tld_regex'] contains a valid regex for the autolinker |
| 964 | - if (!empty($modSettings['autoLinkUrls'])) |
|
| 965 | - set_tld_regex(); |
|
| 1015 | + if (!empty($modSettings['autoLinkUrls'])) { |
|
| 1016 | + set_tld_regex(); |
|
| 1017 | + } |
|
| 966 | 1018 | |
| 967 | 1019 | // Allow mods access before entering the main parse_bbc loop |
| 968 | 1020 | call_integration_hook('integrate_pre_parsebbc', array(&$message, &$smileys, &$cache_id, &$parse_tags)); |
@@ -976,12 +1028,14 @@ discard block |
||
| 976 | 1028 | |
| 977 | 1029 | $temp = explode(',', strtolower($modSettings['disabledBBC'])); |
| 978 | 1030 | |
| 979 | - foreach ($temp as $tag) |
|
| 980 | - $disabled[trim($tag)] = true; |
|
| 1031 | + foreach ($temp as $tag) { |
|
| 1032 | + $disabled[trim($tag)] = true; |
|
| 1033 | + } |
|
| 981 | 1034 | } |
| 982 | 1035 | |
| 983 | - if (empty($modSettings['enableEmbeddedFlash'])) |
|
| 984 | - $disabled['flash'] = true; |
|
| 1036 | + if (empty($modSettings['enableEmbeddedFlash'])) { |
|
| 1037 | + $disabled['flash'] = true; |
|
| 1038 | + } |
|
| 985 | 1039 | |
| 986 | 1040 | /* The following bbc are formatted as an array, with keys as follows: |
| 987 | 1041 | |
@@ -1102,8 +1156,9 @@ discard block |
||
| 1102 | 1156 | $returnContext = ''; |
| 1103 | 1157 | |
| 1104 | 1158 | // BBC or the entire attachments feature is disabled |
| 1105 | - if (empty($modSettings['attachmentEnable']) || !empty($disabled['attach'])) |
|
| 1106 | - return $data; |
|
| 1159 | + if (empty($modSettings['attachmentEnable']) || !empty($disabled['attach'])) { |
|
| 1160 | + return $data; |
|
| 1161 | + } |
|
| 1107 | 1162 | |
| 1108 | 1163 | // Save the attach ID. |
| 1109 | 1164 | $attachID = $data; |
@@ -1114,8 +1169,9 @@ discard block |
||
| 1114 | 1169 | $currentAttachment = parseAttachBBC($attachID); |
| 1115 | 1170 | |
| 1116 | 1171 | // parseAttachBBC will return a string ($txt key) rather than diying with a fatal_error. Up to you to decide what to do. |
| 1117 | - if (is_string($currentAttachment)) |
|
| 1118 | - return $data = !empty($txt[$currentAttachment]) ? $txt[$currentAttachment] : $currentAttachment; |
|
| 1172 | + if (is_string($currentAttachment)) { |
|
| 1173 | + return $data = !empty($txt[$currentAttachment]) ? $txt[$currentAttachment] : $currentAttachment; |
|
| 1174 | + } |
|
| 1119 | 1175 | |
| 1120 | 1176 | if (!empty($currentAttachment['is_image'])) |
| 1121 | 1177 | { |
@@ -1131,15 +1187,17 @@ discard block |
||
| 1131 | 1187 | $height = ' height="' . $currentAttachment['height'] . '"'; |
| 1132 | 1188 | } |
| 1133 | 1189 | |
| 1134 | - if ($currentAttachment['thumbnail']['has_thumb'] && empty($params['{width}']) && empty($params['{height}'])) |
|
| 1135 | - $returnContext .= '<a href="'. $currentAttachment['href']. ';image" id="link_'. $currentAttachment['id']. '" onclick="'. $currentAttachment['thumbnail']['javascript']. '"><img src="'. $currentAttachment['thumbnail']['href']. '" alt="' . $currentAttachment['name'] . '" id="thumb_'. $currentAttachment['id']. '"></a>'; |
|
| 1136 | - else |
|
| 1137 | - $returnContext .= '<img src="' . $currentAttachment['href'] . ';image" alt="' . $currentAttachment['name'] . '"' . $width . $height . '/>'; |
|
| 1190 | + if ($currentAttachment['thumbnail']['has_thumb'] && empty($params['{width}']) && empty($params['{height}'])) { |
|
| 1191 | + $returnContext .= '<a href="'. $currentAttachment['href']. ';image" id="link_'. $currentAttachment['id']. '" onclick="'. $currentAttachment['thumbnail']['javascript']. '"><img src="'. $currentAttachment['thumbnail']['href']. '" alt="' . $currentAttachment['name'] . '" id="thumb_'. $currentAttachment['id']. '"></a>'; |
|
| 1192 | + } else { |
|
| 1193 | + $returnContext .= '<img src="' . $currentAttachment['href'] . ';image" alt="' . $currentAttachment['name'] . '"' . $width . $height . '/>'; |
|
| 1194 | + } |
|
| 1138 | 1195 | } |
| 1139 | 1196 | |
| 1140 | 1197 | // No image. Show a link. |
| 1141 | - else |
|
| 1142 | - $returnContext .= $currentAttachment['link']; |
|
| 1198 | + else { |
|
| 1199 | + $returnContext .= $currentAttachment['link']; |
|
| 1200 | + } |
|
| 1143 | 1201 | |
| 1144 | 1202 | // Gotta append what we just did. |
| 1145 | 1203 | $data = $returnContext; |
@@ -1170,8 +1228,9 @@ discard block |
||
| 1170 | 1228 | for ($php_i = 0, $php_n = count($php_parts); $php_i < $php_n; $php_i++) |
| 1171 | 1229 | { |
| 1172 | 1230 | // Do PHP code coloring? |
| 1173 | - if ($php_parts[$php_i] != '<?php') |
|
| 1174 | - continue; |
|
| 1231 | + if ($php_parts[$php_i] != '<?php') { |
|
| 1232 | + continue; |
|
| 1233 | + } |
|
| 1175 | 1234 | |
| 1176 | 1235 | $php_string = ''; |
| 1177 | 1236 | while ($php_i + 1 < count($php_parts) && $php_parts[$php_i] != '?>') |
@@ -1187,8 +1246,9 @@ discard block |
||
| 1187 | 1246 | $data = str_replace("\t", "<span style=\"white-space: pre;\">\t</span>", $data); |
| 1188 | 1247 | |
| 1189 | 1248 | // Recent Opera bug requiring temporary fix. &nsbp; is needed before </code> to avoid broken selection. |
| 1190 | - if ($context['browser']['is_opera']) |
|
| 1191 | - $data .= ' '; |
|
| 1249 | + if ($context['browser']['is_opera']) { |
|
| 1250 | + $data .= ' '; |
|
| 1251 | + } |
|
| 1192 | 1252 | } |
| 1193 | 1253 | }, |
| 1194 | 1254 | 'block_level' => true, |
@@ -1207,8 +1267,9 @@ discard block |
||
| 1207 | 1267 | for ($php_i = 0, $php_n = count($php_parts); $php_i < $php_n; $php_i++) |
| 1208 | 1268 | { |
| 1209 | 1269 | // Do PHP code coloring? |
| 1210 | - if ($php_parts[$php_i] != '<?php') |
|
| 1211 | - continue; |
|
| 1270 | + if ($php_parts[$php_i] != '<?php') { |
|
| 1271 | + continue; |
|
| 1272 | + } |
|
| 1212 | 1273 | |
| 1213 | 1274 | $php_string = ''; |
| 1214 | 1275 | while ($php_i + 1 < count($php_parts) && $php_parts[$php_i] != '?>') |
@@ -1224,8 +1285,9 @@ discard block |
||
| 1224 | 1285 | $data[0] = str_replace("\t", "<span style=\"white-space: pre;\">\t</span>", $data[0]); |
| 1225 | 1286 | |
| 1226 | 1287 | // Recent Opera bug requiring temporary fix. &nsbp; is needed before </code> to avoid broken selection. |
| 1227 | - if ($context['browser']['is_opera']) |
|
| 1228 | - $data[0] .= ' '; |
|
| 1288 | + if ($context['browser']['is_opera']) { |
|
| 1289 | + $data[0] .= ' '; |
|
| 1290 | + } |
|
| 1229 | 1291 | } |
| 1230 | 1292 | }, |
| 1231 | 1293 | 'block_level' => true, |
@@ -1263,11 +1325,13 @@ discard block |
||
| 1263 | 1325 | 'content' => '<embed type="application/x-shockwave-flash" src="$1" width="$2" height="$3" play="true" loop="true" quality="high" AllowScriptAccess="never">', |
| 1264 | 1326 | 'validate' => function (&$tag, &$data, $disabled) |
| 1265 | 1327 | { |
| 1266 | - if (isset($disabled['url'])) |
|
| 1267 | - $tag['content'] = '$1'; |
|
| 1328 | + if (isset($disabled['url'])) { |
|
| 1329 | + $tag['content'] = '$1'; |
|
| 1330 | + } |
|
| 1268 | 1331 | $scheme = parse_url($data[0], PHP_URL_SCHEME); |
| 1269 | - if (empty($scheme)) |
|
| 1270 | - $data[0] = '//' . ltrim($data[0], ':/'); |
|
| 1332 | + if (empty($scheme)) { |
|
| 1333 | + $data[0] = '//' . ltrim($data[0], ':/'); |
|
| 1334 | + } |
|
| 1271 | 1335 | }, |
| 1272 | 1336 | 'disabled_content' => '<a href="$1" target="_blank" class="new_win">$1</a>', |
| 1273 | 1337 | ), |
@@ -1314,14 +1378,16 @@ discard block |
||
| 1314 | 1378 | $scheme = parse_url($data, PHP_URL_SCHEME); |
| 1315 | 1379 | if ($image_proxy_enabled) |
| 1316 | 1380 | { |
| 1317 | - if (empty($scheme)) |
|
| 1318 | - $data = 'http://' . ltrim($data, ':/'); |
|
| 1381 | + if (empty($scheme)) { |
|
| 1382 | + $data = 'http://' . ltrim($data, ':/'); |
|
| 1383 | + } |
|
| 1319 | 1384 | |
| 1320 | - if ($scheme != 'https') |
|
| 1321 | - $data = $boardurl . '/proxy.php?request=' . urlencode($data) . '&hash=' . md5($data . $image_proxy_secret); |
|
| 1385 | + if ($scheme != 'https') { |
|
| 1386 | + $data = $boardurl . '/proxy.php?request=' . urlencode($data) . '&hash=' . md5($data . $image_proxy_secret); |
|
| 1387 | + } |
|
| 1388 | + } elseif (empty($scheme)) { |
|
| 1389 | + $data = '//' . ltrim($data, ':/'); |
|
| 1322 | 1390 | } |
| 1323 | - elseif (empty($scheme)) |
|
| 1324 | - $data = '//' . ltrim($data, ':/'); |
|
| 1325 | 1391 | }, |
| 1326 | 1392 | 'disabled_content' => '($1)', |
| 1327 | 1393 | ), |
@@ -1337,14 +1403,16 @@ discard block |
||
| 1337 | 1403 | $scheme = parse_url($data, PHP_URL_SCHEME); |
| 1338 | 1404 | if ($image_proxy_enabled) |
| 1339 | 1405 | { |
| 1340 | - if (empty($scheme)) |
|
| 1341 | - $data = 'http://' . ltrim($data, ':/'); |
|
| 1406 | + if (empty($scheme)) { |
|
| 1407 | + $data = 'http://' . ltrim($data, ':/'); |
|
| 1408 | + } |
|
| 1342 | 1409 | |
| 1343 | - if ($scheme != 'https') |
|
| 1344 | - $data = $boardurl . '/proxy.php?request=' . urlencode($data) . '&hash=' . md5($data . $image_proxy_secret); |
|
| 1410 | + if ($scheme != 'https') { |
|
| 1411 | + $data = $boardurl . '/proxy.php?request=' . urlencode($data) . '&hash=' . md5($data . $image_proxy_secret); |
|
| 1412 | + } |
|
| 1413 | + } elseif (empty($scheme)) { |
|
| 1414 | + $data = '//' . ltrim($data, ':/'); |
|
| 1345 | 1415 | } |
| 1346 | - elseif (empty($scheme)) |
|
| 1347 | - $data = '//' . ltrim($data, ':/'); |
|
| 1348 | 1416 | }, |
| 1349 | 1417 | 'disabled_content' => '($1)', |
| 1350 | 1418 | ), |
@@ -1356,8 +1424,9 @@ discard block |
||
| 1356 | 1424 | { |
| 1357 | 1425 | $data = strtr($data, array('<br>' => '')); |
| 1358 | 1426 | $scheme = parse_url($data, PHP_URL_SCHEME); |
| 1359 | - if (empty($scheme)) |
|
| 1360 | - $data = '//' . ltrim($data, ':/'); |
|
| 1427 | + if (empty($scheme)) { |
|
| 1428 | + $data = '//' . ltrim($data, ':/'); |
|
| 1429 | + } |
|
| 1361 | 1430 | }, |
| 1362 | 1431 | ), |
| 1363 | 1432 | array( |
@@ -1368,13 +1437,14 @@ discard block |
||
| 1368 | 1437 | 'after' => '</a>', |
| 1369 | 1438 | 'validate' => function (&$tag, &$data, $disabled) |
| 1370 | 1439 | { |
| 1371 | - if (substr($data, 0, 1) == '#') |
|
| 1372 | - $data = '#post_' . substr($data, 1); |
|
| 1373 | - else |
|
| 1440 | + if (substr($data, 0, 1) == '#') { |
|
| 1441 | + $data = '#post_' . substr($data, 1); |
|
| 1442 | + } else |
|
| 1374 | 1443 | { |
| 1375 | 1444 | $scheme = parse_url($data, PHP_URL_SCHEME); |
| 1376 | - if (empty($scheme)) |
|
| 1377 | - $data = '//' . ltrim($data, ':/'); |
|
| 1445 | + if (empty($scheme)) { |
|
| 1446 | + $data = '//' . ltrim($data, ':/'); |
|
| 1447 | + } |
|
| 1378 | 1448 | } |
| 1379 | 1449 | }, |
| 1380 | 1450 | 'disallow_children' => array('email', 'ftp', 'url', 'iurl'), |
@@ -1452,8 +1522,9 @@ discard block |
||
| 1452 | 1522 | { |
| 1453 | 1523 | $add_begin = substr(trim($data), 0, 5) != '<?'; |
| 1454 | 1524 | $data = highlight_php_code($add_begin ? '<?php ' . $data . '?>' : $data); |
| 1455 | - if ($add_begin) |
|
| 1456 | - $data = preg_replace(array('~^(.+?)<\?.{0,40}?php(?: |\s)~', '~\?>((?:</(font|span)>)*)$~'), '$1', $data, 2); |
|
| 1525 | + if ($add_begin) { |
|
| 1526 | + $data = preg_replace(array('~^(.+?)<\?.{0,40}?php(?: |\s)~', '~\?>((?:</(font|span)>)*)$~'), '$1', $data, 2); |
|
| 1527 | + } |
|
| 1457 | 1528 | } |
| 1458 | 1529 | }, |
| 1459 | 1530 | 'block_level' => false, |
@@ -1584,10 +1655,11 @@ discard block |
||
| 1584 | 1655 | 'content' => '$1', |
| 1585 | 1656 | 'validate' => function (&$tag, &$data, $disabled) |
| 1586 | 1657 | { |
| 1587 | - if (is_numeric($data)) |
|
| 1588 | - $data = timeformat($data); |
|
| 1589 | - else |
|
| 1590 | - $tag['content'] = '[time]$1[/time]'; |
|
| 1658 | + if (is_numeric($data)) { |
|
| 1659 | + $data = timeformat($data); |
|
| 1660 | + } else { |
|
| 1661 | + $tag['content'] = '[time]$1[/time]'; |
|
| 1662 | + } |
|
| 1591 | 1663 | }, |
| 1592 | 1664 | ), |
| 1593 | 1665 | array( |
@@ -1614,8 +1686,9 @@ discard block |
||
| 1614 | 1686 | { |
| 1615 | 1687 | $data = strtr($data, array('<br>' => '')); |
| 1616 | 1688 | $scheme = parse_url($data, PHP_URL_SCHEME); |
| 1617 | - if (empty($scheme)) |
|
| 1618 | - $data = '//' . ltrim($data, ':/'); |
|
| 1689 | + if (empty($scheme)) { |
|
| 1690 | + $data = '//' . ltrim($data, ':/'); |
|
| 1691 | + } |
|
| 1619 | 1692 | }, |
| 1620 | 1693 | ), |
| 1621 | 1694 | array( |
@@ -1627,8 +1700,9 @@ discard block |
||
| 1627 | 1700 | 'validate' => function (&$tag, &$data, $disabled) |
| 1628 | 1701 | { |
| 1629 | 1702 | $scheme = parse_url($data, PHP_URL_SCHEME); |
| 1630 | - if (empty($scheme)) |
|
| 1631 | - $data = '//' . ltrim($data, ':/'); |
|
| 1703 | + if (empty($scheme)) { |
|
| 1704 | + $data = '//' . ltrim($data, ':/'); |
|
| 1705 | + } |
|
| 1632 | 1706 | }, |
| 1633 | 1707 | 'disallow_children' => array('email', 'ftp', 'url', 'iurl'), |
| 1634 | 1708 | 'disabled_after' => ' ($1)', |
@@ -1648,8 +1722,9 @@ discard block |
||
| 1648 | 1722 | // This is mainly for the bbc manager, so it's easy to add tags above. Custom BBC should be added above this line. |
| 1649 | 1723 | if ($message === false) |
| 1650 | 1724 | { |
| 1651 | - if (isset($temp_bbc)) |
|
| 1652 | - $bbc_codes = $temp_bbc; |
|
| 1725 | + if (isset($temp_bbc)) { |
|
| 1726 | + $bbc_codes = $temp_bbc; |
|
| 1727 | + } |
|
| 1653 | 1728 | usort($codes, function ($a, $b) { |
| 1654 | 1729 | return strcmp($a['tag'], $b['tag']); |
| 1655 | 1730 | }); |
@@ -1669,8 +1744,9 @@ discard block |
||
| 1669 | 1744 | ); |
| 1670 | 1745 | if (!isset($disabled['li']) && !isset($disabled['list'])) |
| 1671 | 1746 | { |
| 1672 | - foreach ($itemcodes as $c => $dummy) |
|
| 1673 | - $bbc_codes[$c] = array(); |
|
| 1747 | + foreach ($itemcodes as $c => $dummy) { |
|
| 1748 | + $bbc_codes[$c] = array(); |
|
| 1749 | + } |
|
| 1674 | 1750 | } |
| 1675 | 1751 | |
| 1676 | 1752 | // Shhhh! |
@@ -1691,12 +1767,14 @@ discard block |
||
| 1691 | 1767 | foreach ($codes as $code) |
| 1692 | 1768 | { |
| 1693 | 1769 | // Make it easier to process parameters later |
| 1694 | - if (!empty($code['parameters'])) |
|
| 1695 | - ksort($code['parameters'], SORT_STRING); |
|
| 1770 | + if (!empty($code['parameters'])) { |
|
| 1771 | + ksort($code['parameters'], SORT_STRING); |
|
| 1772 | + } |
|
| 1696 | 1773 | |
| 1697 | 1774 | // If we are not doing every tag only do ones we are interested in. |
| 1698 | - if (empty($parse_tags) || in_array($code['tag'], $parse_tags)) |
|
| 1699 | - $bbc_codes[substr($code['tag'], 0, 1)][] = $code; |
|
| 1775 | + if (empty($parse_tags) || in_array($code['tag'], $parse_tags)) { |
|
| 1776 | + $bbc_codes[substr($code['tag'], 0, 1)][] = $code; |
|
| 1777 | + } |
|
| 1700 | 1778 | } |
| 1701 | 1779 | $codes = null; |
| 1702 | 1780 | } |
@@ -1707,8 +1785,9 @@ discard block |
||
| 1707 | 1785 | // It's likely this will change if the message is modified. |
| 1708 | 1786 | $cache_key = 'parse:' . $cache_id . '-' . md5(md5($message) . '-' . $smileys . (empty($disabled) ? '' : implode(',', array_keys($disabled))) . json_encode($context['browser']) . $txt['lang_locale'] . $user_info['time_offset'] . $user_info['time_format']); |
| 1709 | 1787 | |
| 1710 | - if (($temp = cache_get_data($cache_key, 240)) != null) |
|
| 1711 | - return $temp; |
|
| 1788 | + if (($temp = cache_get_data($cache_key, 240)) != null) { |
|
| 1789 | + return $temp; |
|
| 1790 | + } |
|
| 1712 | 1791 | |
| 1713 | 1792 | $cache_t = microtime(); |
| 1714 | 1793 | } |
@@ -1740,8 +1819,9 @@ discard block |
||
| 1740 | 1819 | $disabled['flash'] = true; |
| 1741 | 1820 | |
| 1742 | 1821 | // @todo Change maybe? |
| 1743 | - if (!isset($_GET['images'])) |
|
| 1744 | - $disabled['img'] = true; |
|
| 1822 | + if (!isset($_GET['images'])) { |
|
| 1823 | + $disabled['img'] = true; |
|
| 1824 | + } |
|
| 1745 | 1825 | |
| 1746 | 1826 | // @todo Interface/setting to add more? |
| 1747 | 1827 | } |
@@ -1767,8 +1847,9 @@ discard block |
||
| 1767 | 1847 | $pos = isset($matches[0][1]) ? $matches[0][1] : false; |
| 1768 | 1848 | |
| 1769 | 1849 | // Failsafe. |
| 1770 | - if ($pos === false || $last_pos > $pos) |
|
| 1771 | - $pos = strlen($message) + 1; |
|
| 1850 | + if ($pos === false || $last_pos > $pos) { |
|
| 1851 | + $pos = strlen($message) + 1; |
|
| 1852 | + } |
|
| 1772 | 1853 | |
| 1773 | 1854 | // Can't have a one letter smiley, URL, or email! (sorry.) |
| 1774 | 1855 | if ($last_pos < $pos - 1) |
@@ -1787,8 +1868,9 @@ discard block |
||
| 1787 | 1868 | |
| 1788 | 1869 | // <br> should be empty. |
| 1789 | 1870 | $empty_tags = array('br', 'hr'); |
| 1790 | - foreach ($empty_tags as $tag) |
|
| 1791 | - $data = str_replace(array('<' . $tag . '>', '<' . $tag . '/>', '<' . $tag . ' />'), '[' . $tag . ' /]', $data); |
|
| 1871 | + foreach ($empty_tags as $tag) { |
|
| 1872 | + $data = str_replace(array('<' . $tag . '>', '<' . $tag . '/>', '<' . $tag . ' />'), '[' . $tag . ' /]', $data); |
|
| 1873 | + } |
|
| 1792 | 1874 | |
| 1793 | 1875 | // b, u, i, s, pre... basic tags. |
| 1794 | 1876 | $closable_tags = array('b', 'u', 'i', 's', 'em', 'ins', 'del', 'pre', 'blockquote'); |
@@ -1797,8 +1879,9 @@ discard block |
||
| 1797 | 1879 | $diff = substr_count($data, '<' . $tag . '>') - substr_count($data, '</' . $tag . '>'); |
| 1798 | 1880 | $data = strtr($data, array('<' . $tag . '>' => '<' . $tag . '>', '</' . $tag . '>' => '</' . $tag . '>')); |
| 1799 | 1881 | |
| 1800 | - if ($diff > 0) |
|
| 1801 | - $data = substr($data, 0, -1) . str_repeat('</' . $tag . '>', $diff) . substr($data, -1); |
|
| 1882 | + if ($diff > 0) { |
|
| 1883 | + $data = substr($data, 0, -1) . str_repeat('</' . $tag . '>', $diff) . substr($data, -1); |
|
| 1884 | + } |
|
| 1802 | 1885 | } |
| 1803 | 1886 | |
| 1804 | 1887 | // Do <img ...> - with security... action= -> action-. |
@@ -1811,8 +1894,9 @@ discard block |
||
| 1811 | 1894 | $alt = empty($matches[3][$match]) ? '' : ' alt=' . preg_replace('~^"|"$~', '', $matches[3][$match]); |
| 1812 | 1895 | |
| 1813 | 1896 | // Remove action= from the URL - no funny business, now. |
| 1814 | - if (preg_match('~action(=|%3d)(?!dlattach)~i', $imgtag) != 0) |
|
| 1815 | - $imgtag = preg_replace('~action(?:=|%3d)(?!dlattach)~i', 'action-', $imgtag); |
|
| 1897 | + if (preg_match('~action(=|%3d)(?!dlattach)~i', $imgtag) != 0) { |
|
| 1898 | + $imgtag = preg_replace('~action(?:=|%3d)(?!dlattach)~i', 'action-', $imgtag); |
|
| 1899 | + } |
|
| 1816 | 1900 | |
| 1817 | 1901 | // Check if the image is larger than allowed. |
| 1818 | 1902 | if (!empty($modSettings['max_image_width']) && !empty($modSettings['max_image_height'])) |
@@ -1833,9 +1917,9 @@ discard block |
||
| 1833 | 1917 | |
| 1834 | 1918 | // Set the new image tag. |
| 1835 | 1919 | $replaces[$matches[0][$match]] = '[img width=' . $width . ' height=' . $height . $alt . ']' . $imgtag . '[/img]'; |
| 1920 | + } else { |
|
| 1921 | + $replaces[$matches[0][$match]] = '[img' . $alt . ']' . $imgtag . '[/img]'; |
|
| 1836 | 1922 | } |
| 1837 | - else |
|
| 1838 | - $replaces[$matches[0][$match]] = '[img' . $alt . ']' . $imgtag . '[/img]'; |
|
| 1839 | 1923 | } |
| 1840 | 1924 | |
| 1841 | 1925 | $data = strtr($data, $replaces); |
@@ -1848,16 +1932,18 @@ discard block |
||
| 1848 | 1932 | $no_autolink_area = false; |
| 1849 | 1933 | if (!empty($open_tags)) |
| 1850 | 1934 | { |
| 1851 | - foreach ($open_tags as $open_tag) |
|
| 1852 | - if (in_array($open_tag['tag'], $no_autolink_tags)) |
|
| 1935 | + foreach ($open_tags as $open_tag) { |
|
| 1936 | + if (in_array($open_tag['tag'], $no_autolink_tags)) |
|
| 1853 | 1937 | $no_autolink_area = true; |
| 1938 | + } |
|
| 1854 | 1939 | } |
| 1855 | 1940 | |
| 1856 | 1941 | // Don't go backwards. |
| 1857 | 1942 | // @todo Don't think is the real solution.... |
| 1858 | 1943 | $lastAutoPos = isset($lastAutoPos) ? $lastAutoPos : 0; |
| 1859 | - if ($pos < $lastAutoPos) |
|
| 1860 | - $no_autolink_area = true; |
|
| 1944 | + if ($pos < $lastAutoPos) { |
|
| 1945 | + $no_autolink_area = true; |
|
| 1946 | + } |
|
| 1861 | 1947 | $lastAutoPos = $pos; |
| 1862 | 1948 | |
| 1863 | 1949 | if (!$no_autolink_area) |
@@ -1966,17 +2052,19 @@ discard block |
||
| 1966 | 2052 | if ($scheme == 'mailto') |
| 1967 | 2053 | { |
| 1968 | 2054 | $email_address = str_replace('mailto:', '', $url); |
| 1969 | - if (!isset($disabled['email']) && filter_var($email_address, FILTER_VALIDATE_EMAIL) !== false) |
|
| 1970 | - return '[email=' . $email_address . ']' . $url . '[/email]'; |
|
| 1971 | - else |
|
| 1972 | - return $url; |
|
| 2055 | + if (!isset($disabled['email']) && filter_var($email_address, FILTER_VALIDATE_EMAIL) !== false) { |
|
| 2056 | + return '[email=' . $email_address . ']' . $url . '[/email]'; |
|
| 2057 | + } else { |
|
| 2058 | + return $url; |
|
| 2059 | + } |
|
| 1973 | 2060 | } |
| 1974 | 2061 | |
| 1975 | 2062 | // Are we linking a schemeless URL or naked domain name (e.g. "example.com")? |
| 1976 | - if (empty($scheme)) |
|
| 1977 | - $fullUrl = '//' . ltrim($url, ':/'); |
|
| 1978 | - else |
|
| 1979 | - $fullUrl = $url; |
|
| 2063 | + if (empty($scheme)) { |
|
| 2064 | + $fullUrl = '//' . ltrim($url, ':/'); |
|
| 2065 | + } else { |
|
| 2066 | + $fullUrl = $url; |
|
| 2067 | + } |
|
| 1980 | 2068 | |
| 1981 | 2069 | return '[url="' . str_replace(array('[', ']'), array('[', ']'), $fullUrl) . '"]' . $url . '[/url]'; |
| 1982 | 2070 | }, $data); |
@@ -2025,16 +2113,18 @@ discard block |
||
| 2025 | 2113 | } |
| 2026 | 2114 | |
| 2027 | 2115 | // Are we there yet? Are we there yet? |
| 2028 | - if ($pos >= strlen($message) - 1) |
|
| 2029 | - break; |
|
| 2116 | + if ($pos >= strlen($message) - 1) { |
|
| 2117 | + break; |
|
| 2118 | + } |
|
| 2030 | 2119 | |
| 2031 | 2120 | $tags = strtolower($message[$pos + 1]); |
| 2032 | 2121 | |
| 2033 | 2122 | if ($tags == '/' && !empty($open_tags)) |
| 2034 | 2123 | { |
| 2035 | 2124 | $pos2 = strpos($message, ']', $pos + 1); |
| 2036 | - if ($pos2 == $pos + 2) |
|
| 2037 | - continue; |
|
| 2125 | + if ($pos2 == $pos + 2) { |
|
| 2126 | + continue; |
|
| 2127 | + } |
|
| 2038 | 2128 | |
| 2039 | 2129 | $look_for = strtolower(substr($message, $pos + 2, $pos2 - $pos - 2)); |
| 2040 | 2130 | |
@@ -2044,8 +2134,9 @@ discard block |
||
| 2044 | 2134 | do |
| 2045 | 2135 | { |
| 2046 | 2136 | $tag = array_pop($open_tags); |
| 2047 | - if (!$tag) |
|
| 2048 | - break; |
|
| 2137 | + if (!$tag) { |
|
| 2138 | + break; |
|
| 2139 | + } |
|
| 2049 | 2140 | |
| 2050 | 2141 | if (!empty($tag['block_level'])) |
| 2051 | 2142 | { |
@@ -2059,10 +2150,11 @@ discard block |
||
| 2059 | 2150 | // The idea is, if we are LOOKING for a block level tag, we can close them on the way. |
| 2060 | 2151 | if (strlen($look_for) > 0 && isset($bbc_codes[$look_for[0]])) |
| 2061 | 2152 | { |
| 2062 | - foreach ($bbc_codes[$look_for[0]] as $temp) |
|
| 2063 | - if ($temp['tag'] == $look_for) |
|
| 2153 | + foreach ($bbc_codes[$look_for[0]] as $temp) { |
|
| 2154 | + if ($temp['tag'] == $look_for) |
|
| 2064 | 2155 | { |
| 2065 | 2156 | $block_level = !empty($temp['block_level']); |
| 2157 | + } |
|
| 2066 | 2158 | break; |
| 2067 | 2159 | } |
| 2068 | 2160 | } |
@@ -2084,15 +2176,15 @@ discard block |
||
| 2084 | 2176 | { |
| 2085 | 2177 | $open_tags = $to_close; |
| 2086 | 2178 | continue; |
| 2087 | - } |
|
| 2088 | - elseif (!empty($to_close) && $tag['tag'] != $look_for) |
|
| 2179 | + } elseif (!empty($to_close) && $tag['tag'] != $look_for) |
|
| 2089 | 2180 | { |
| 2090 | 2181 | if ($block_level === null && isset($look_for[0], $bbc_codes[$look_for[0]])) |
| 2091 | 2182 | { |
| 2092 | - foreach ($bbc_codes[$look_for[0]] as $temp) |
|
| 2093 | - if ($temp['tag'] == $look_for) |
|
| 2183 | + foreach ($bbc_codes[$look_for[0]] as $temp) { |
|
| 2184 | + if ($temp['tag'] == $look_for) |
|
| 2094 | 2185 | { |
| 2095 | 2186 | $block_level = !empty($temp['block_level']); |
| 2187 | + } |
|
| 2096 | 2188 | break; |
| 2097 | 2189 | } |
| 2098 | 2190 | } |
@@ -2100,8 +2192,9 @@ discard block |
||
| 2100 | 2192 | // We're not looking for a block level tag (or maybe even a tag that exists...) |
| 2101 | 2193 | if (!$block_level) |
| 2102 | 2194 | { |
| 2103 | - foreach ($to_close as $tag) |
|
| 2104 | - array_push($open_tags, $tag); |
|
| 2195 | + foreach ($to_close as $tag) { |
|
| 2196 | + array_push($open_tags, $tag); |
|
| 2197 | + } |
|
| 2105 | 2198 | continue; |
| 2106 | 2199 | } |
| 2107 | 2200 | } |
@@ -2113,10 +2206,12 @@ discard block |
||
| 2113 | 2206 | $pos2 = $pos - 1; |
| 2114 | 2207 | |
| 2115 | 2208 | // See the comment at the end of the big loop - just eating whitespace ;). |
| 2116 | - if (!empty($tag['block_level']) && substr($message, $pos, 4) == '<br>') |
|
| 2117 | - $message = substr($message, 0, $pos) . substr($message, $pos + 4); |
|
| 2118 | - if (!empty($tag['trim']) && $tag['trim'] != 'inside' && preg_match('~(<br>| |\s)*~', substr($message, $pos), $matches) != 0) |
|
| 2119 | - $message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0])); |
|
| 2209 | + if (!empty($tag['block_level']) && substr($message, $pos, 4) == '<br>') { |
|
| 2210 | + $message = substr($message, 0, $pos) . substr($message, $pos + 4); |
|
| 2211 | + } |
|
| 2212 | + if (!empty($tag['trim']) && $tag['trim'] != 'inside' && preg_match('~(<br>| |\s)*~', substr($message, $pos), $matches) != 0) { |
|
| 2213 | + $message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0])); |
|
| 2214 | + } |
|
| 2120 | 2215 | } |
| 2121 | 2216 | |
| 2122 | 2217 | if (!empty($to_close)) |
@@ -2129,8 +2224,9 @@ discard block |
||
| 2129 | 2224 | } |
| 2130 | 2225 | |
| 2131 | 2226 | // No tags for this character, so just keep going (fastest possible course.) |
| 2132 | - if (!isset($bbc_codes[$tags])) |
|
| 2133 | - continue; |
|
| 2227 | + if (!isset($bbc_codes[$tags])) { |
|
| 2228 | + continue; |
|
| 2229 | + } |
|
| 2134 | 2230 | |
| 2135 | 2231 | $inside = empty($open_tags) ? null : $open_tags[count($open_tags) - 1]; |
| 2136 | 2232 | $tag = null; |
@@ -2139,44 +2235,52 @@ discard block |
||
| 2139 | 2235 | $pt_strlen = strlen($possible['tag']); |
| 2140 | 2236 | |
| 2141 | 2237 | // Not a match? |
| 2142 | - if (strtolower(substr($message, $pos + 1, $pt_strlen)) != $possible['tag']) |
|
| 2143 | - continue; |
|
| 2238 | + if (strtolower(substr($message, $pos + 1, $pt_strlen)) != $possible['tag']) { |
|
| 2239 | + continue; |
|
| 2240 | + } |
|
| 2144 | 2241 | |
| 2145 | 2242 | $next_c = $message[$pos + 1 + $pt_strlen]; |
| 2146 | 2243 | |
| 2147 | 2244 | // A test validation? |
| 2148 | - if (isset($possible['test']) && preg_match('~^' . $possible['test'] . '~', substr($message, $pos + 1 + $pt_strlen + 1)) === 0) |
|
| 2149 | - continue; |
|
| 2245 | + if (isset($possible['test']) && preg_match('~^' . $possible['test'] . '~', substr($message, $pos + 1 + $pt_strlen + 1)) === 0) { |
|
| 2246 | + continue; |
|
| 2247 | + } |
|
| 2150 | 2248 | // Do we want parameters? |
| 2151 | 2249 | elseif (!empty($possible['parameters'])) |
| 2152 | 2250 | { |
| 2153 | - if ($next_c != ' ') |
|
| 2154 | - continue; |
|
| 2155 | - } |
|
| 2156 | - elseif (isset($possible['type'])) |
|
| 2251 | + if ($next_c != ' ') { |
|
| 2252 | + continue; |
|
| 2253 | + } |
|
| 2254 | + } elseif (isset($possible['type'])) |
|
| 2157 | 2255 | { |
| 2158 | 2256 | // Do we need an equal sign? |
| 2159 | - if (in_array($possible['type'], array('unparsed_equals', 'unparsed_commas', 'unparsed_commas_content', 'unparsed_equals_content', 'parsed_equals')) && $next_c != '=') |
|
| 2160 | - continue; |
|
| 2257 | + if (in_array($possible['type'], array('unparsed_equals', 'unparsed_commas', 'unparsed_commas_content', 'unparsed_equals_content', 'parsed_equals')) && $next_c != '=') { |
|
| 2258 | + continue; |
|
| 2259 | + } |
|
| 2161 | 2260 | // Maybe we just want a /... |
| 2162 | - if ($possible['type'] == 'closed' && $next_c != ']' && substr($message, $pos + 1 + $pt_strlen, 2) != '/]' && substr($message, $pos + 1 + $pt_strlen, 3) != ' /]') |
|
| 2163 | - continue; |
|
| 2261 | + if ($possible['type'] == 'closed' && $next_c != ']' && substr($message, $pos + 1 + $pt_strlen, 2) != '/]' && substr($message, $pos + 1 + $pt_strlen, 3) != ' /]') { |
|
| 2262 | + continue; |
|
| 2263 | + } |
|
| 2164 | 2264 | // An immediate ]? |
| 2165 | - if ($possible['type'] == 'unparsed_content' && $next_c != ']') |
|
| 2166 | - continue; |
|
| 2265 | + if ($possible['type'] == 'unparsed_content' && $next_c != ']') { |
|
| 2266 | + continue; |
|
| 2267 | + } |
|
| 2167 | 2268 | } |
| 2168 | 2269 | // No type means 'parsed_content', which demands an immediate ] without parameters! |
| 2169 | - elseif ($next_c != ']') |
|
| 2170 | - continue; |
|
| 2270 | + elseif ($next_c != ']') { |
|
| 2271 | + continue; |
|
| 2272 | + } |
|
| 2171 | 2273 | |
| 2172 | 2274 | // Check allowed tree? |
| 2173 | - if (isset($possible['require_parents']) && ($inside === null || !in_array($inside['tag'], $possible['require_parents']))) |
|
| 2174 | - continue; |
|
| 2175 | - elseif (isset($inside['require_children']) && !in_array($possible['tag'], $inside['require_children'])) |
|
| 2176 | - continue; |
|
| 2275 | + if (isset($possible['require_parents']) && ($inside === null || !in_array($inside['tag'], $possible['require_parents']))) { |
|
| 2276 | + continue; |
|
| 2277 | + } elseif (isset($inside['require_children']) && !in_array($possible['tag'], $inside['require_children'])) { |
|
| 2278 | + continue; |
|
| 2279 | + } |
|
| 2177 | 2280 | // If this is in the list of disallowed child tags, don't parse it. |
| 2178 | - elseif (isset($inside['disallow_children']) && in_array($possible['tag'], $inside['disallow_children'])) |
|
| 2179 | - continue; |
|
| 2281 | + elseif (isset($inside['disallow_children']) && in_array($possible['tag'], $inside['disallow_children'])) { |
|
| 2282 | + continue; |
|
| 2283 | + } |
|
| 2180 | 2284 | |
| 2181 | 2285 | $pos1 = $pos + 1 + $pt_strlen + 1; |
| 2182 | 2286 | |
@@ -2188,8 +2292,9 @@ discard block |
||
| 2188 | 2292 | foreach ($open_tags as $open_quote) |
| 2189 | 2293 | { |
| 2190 | 2294 | // Every parent quote this quote has flips the styling |
| 2191 | - if ($open_quote['tag'] == 'quote') |
|
| 2192 | - $quote_alt = !$quote_alt; |
|
| 2295 | + if ($open_quote['tag'] == 'quote') { |
|
| 2296 | + $quote_alt = !$quote_alt; |
|
| 2297 | + } |
|
| 2193 | 2298 | } |
| 2194 | 2299 | // Add a class to the quote to style alternating blockquotes |
| 2195 | 2300 | $possible['before'] = strtr($possible['before'], array('<blockquote>' => '<blockquote class="bbc_' . ($quote_alt ? 'alternate' : 'standard') . '_quote">')); |
@@ -2200,8 +2305,9 @@ discard block |
||
| 2200 | 2305 | { |
| 2201 | 2306 | // Build a regular expression for each parameter for the current tag. |
| 2202 | 2307 | $preg = array(); |
| 2203 | - foreach ($possible['parameters'] as $p => $info) |
|
| 2204 | - $preg[] = '(\s+' . $p . '=' . (empty($info['quoted']) ? '' : '"') . (isset($info['match']) ? $info['match'] : '(.+?)') . (empty($info['quoted']) ? '' : '"') . '\s*)' . (empty($info['optional']) ? '' : '?'); |
|
| 2308 | + foreach ($possible['parameters'] as $p => $info) { |
|
| 2309 | + $preg[] = '(\s+' . $p . '=' . (empty($info['quoted']) ? '' : '"') . (isset($info['match']) ? $info['match'] : '(.+?)') . (empty($info['quoted']) ? '' : '"') . '\s*)' . (empty($info['optional']) ? '' : '?'); |
|
| 2310 | + } |
|
| 2205 | 2311 | |
| 2206 | 2312 | // Extract the string that potentially holds our parameters. |
| 2207 | 2313 | $blob = preg_split('~\[/?(?:' . $alltags_regex . ')~i', substr($message, $pos)); |
@@ -2221,24 +2327,27 @@ discard block |
||
| 2221 | 2327 | |
| 2222 | 2328 | $match = preg_match('~^' . implode('', $preg) . '$~i', implode(' ', $given_params), $matches) !== 0; |
| 2223 | 2329 | |
| 2224 | - if ($match) |
|
| 2225 | - $blob_counter = count($blobs) + 1; |
|
| 2330 | + if ($match) { |
|
| 2331 | + $blob_counter = count($blobs) + 1; |
|
| 2332 | + } |
|
| 2226 | 2333 | } |
| 2227 | 2334 | |
| 2228 | 2335 | // Didn't match our parameter list, try the next possible. |
| 2229 | - if (!$match) |
|
| 2230 | - continue; |
|
| 2336 | + if (!$match) { |
|
| 2337 | + continue; |
|
| 2338 | + } |
|
| 2231 | 2339 | |
| 2232 | 2340 | $params = array(); |
| 2233 | 2341 | for ($i = 1, $n = count($matches); $i < $n; $i += 2) |
| 2234 | 2342 | { |
| 2235 | 2343 | $key = strtok(ltrim($matches[$i]), '='); |
| 2236 | - if (isset($possible['parameters'][$key]['value'])) |
|
| 2237 | - $params['{' . $key . '}'] = strtr($possible['parameters'][$key]['value'], array('$1' => $matches[$i + 1])); |
|
| 2238 | - elseif (isset($possible['parameters'][$key]['validate'])) |
|
| 2239 | - $params['{' . $key . '}'] = $possible['parameters'][$key]['validate']($matches[$i + 1]); |
|
| 2240 | - else |
|
| 2241 | - $params['{' . $key . '}'] = $matches[$i + 1]; |
|
| 2344 | + if (isset($possible['parameters'][$key]['value'])) { |
|
| 2345 | + $params['{' . $key . '}'] = strtr($possible['parameters'][$key]['value'], array('$1' => $matches[$i + 1])); |
|
| 2346 | + } elseif (isset($possible['parameters'][$key]['validate'])) { |
|
| 2347 | + $params['{' . $key . '}'] = $possible['parameters'][$key]['validate']($matches[$i + 1]); |
|
| 2348 | + } else { |
|
| 2349 | + $params['{' . $key . '}'] = $matches[$i + 1]; |
|
| 2350 | + } |
|
| 2242 | 2351 | |
| 2243 | 2352 | // Just to make sure: replace any $ or { so they can't interpolate wrongly. |
| 2244 | 2353 | $params['{' . $key . '}'] = strtr($params['{' . $key . '}'], array('$' => '$', '{' => '{')); |
@@ -2246,23 +2355,26 @@ discard block |
||
| 2246 | 2355 | |
| 2247 | 2356 | foreach ($possible['parameters'] as $p => $info) |
| 2248 | 2357 | { |
| 2249 | - if (!isset($params['{' . $p . '}'])) |
|
| 2250 | - $params['{' . $p . '}'] = ''; |
|
| 2358 | + if (!isset($params['{' . $p . '}'])) { |
|
| 2359 | + $params['{' . $p . '}'] = ''; |
|
| 2360 | + } |
|
| 2251 | 2361 | } |
| 2252 | 2362 | |
| 2253 | 2363 | $tag = $possible; |
| 2254 | 2364 | |
| 2255 | 2365 | // Put the parameters into the string. |
| 2256 | - if (isset($tag['before'])) |
|
| 2257 | - $tag['before'] = strtr($tag['before'], $params); |
|
| 2258 | - if (isset($tag['after'])) |
|
| 2259 | - $tag['after'] = strtr($tag['after'], $params); |
|
| 2260 | - if (isset($tag['content'])) |
|
| 2261 | - $tag['content'] = strtr($tag['content'], $params); |
|
| 2366 | + if (isset($tag['before'])) { |
|
| 2367 | + $tag['before'] = strtr($tag['before'], $params); |
|
| 2368 | + } |
|
| 2369 | + if (isset($tag['after'])) { |
|
| 2370 | + $tag['after'] = strtr($tag['after'], $params); |
|
| 2371 | + } |
|
| 2372 | + if (isset($tag['content'])) { |
|
| 2373 | + $tag['content'] = strtr($tag['content'], $params); |
|
| 2374 | + } |
|
| 2262 | 2375 | |
| 2263 | 2376 | $pos1 += strlen($given_param_string); |
| 2264 | - } |
|
| 2265 | - else |
|
| 2377 | + } else |
|
| 2266 | 2378 | { |
| 2267 | 2379 | $tag = $possible; |
| 2268 | 2380 | $params = array(); |
@@ -2273,8 +2385,9 @@ discard block |
||
| 2273 | 2385 | // Item codes are complicated buggers... they are implicit [li]s and can make [list]s! |
| 2274 | 2386 | if ($smileys !== false && $tag === null && isset($itemcodes[$message[$pos + 1]]) && $message[$pos + 2] == ']' && !isset($disabled['list']) && !isset($disabled['li'])) |
| 2275 | 2387 | { |
| 2276 | - if ($message[$pos + 1] == '0' && !in_array($message[$pos - 1], array(';', ' ', "\t", "\n", '>'))) |
|
| 2277 | - continue; |
|
| 2388 | + if ($message[$pos + 1] == '0' && !in_array($message[$pos - 1], array(';', ' ', "\t", "\n", '>'))) { |
|
| 2389 | + continue; |
|
| 2390 | + } |
|
| 2278 | 2391 | |
| 2279 | 2392 | $tag = $itemcodes[$message[$pos + 1]]; |
| 2280 | 2393 | |
@@ -2295,9 +2408,9 @@ discard block |
||
| 2295 | 2408 | { |
| 2296 | 2409 | array_pop($open_tags); |
| 2297 | 2410 | $code = '</li>'; |
| 2411 | + } else { |
|
| 2412 | + $code = ''; |
|
| 2298 | 2413 | } |
| 2299 | - else |
|
| 2300 | - $code = ''; |
|
| 2301 | 2414 | |
| 2302 | 2415 | // Now we open a new tag. |
| 2303 | 2416 | $open_tags[] = array( |
@@ -2344,12 +2457,14 @@ discard block |
||
| 2344 | 2457 | } |
| 2345 | 2458 | |
| 2346 | 2459 | // No tag? Keep looking, then. Silly people using brackets without actual tags. |
| 2347 | - if ($tag === null) |
|
| 2348 | - continue; |
|
| 2460 | + if ($tag === null) { |
|
| 2461 | + continue; |
|
| 2462 | + } |
|
| 2349 | 2463 | |
| 2350 | 2464 | // Propagate the list to the child (so wrapping the disallowed tag won't work either.) |
| 2351 | - if (isset($inside['disallow_children'])) |
|
| 2352 | - $tag['disallow_children'] = isset($tag['disallow_children']) ? array_unique(array_merge($tag['disallow_children'], $inside['disallow_children'])) : $inside['disallow_children']; |
|
| 2465 | + if (isset($inside['disallow_children'])) { |
|
| 2466 | + $tag['disallow_children'] = isset($tag['disallow_children']) ? array_unique(array_merge($tag['disallow_children'], $inside['disallow_children'])) : $inside['disallow_children']; |
|
| 2467 | + } |
|
| 2353 | 2468 | |
| 2354 | 2469 | // Is this tag disabled? |
| 2355 | 2470 | if (isset($disabled[$tag['tag']])) |
@@ -2359,14 +2474,13 @@ discard block |
||
| 2359 | 2474 | $tag['before'] = !empty($tag['block_level']) ? '<div>' : ''; |
| 2360 | 2475 | $tag['after'] = !empty($tag['block_level']) ? '</div>' : ''; |
| 2361 | 2476 | $tag['content'] = isset($tag['type']) && $tag['type'] == 'closed' ? '' : (!empty($tag['block_level']) ? '<div>$1</div>' : '$1'); |
| 2362 | - } |
|
| 2363 | - elseif (isset($tag['disabled_before']) || isset($tag['disabled_after'])) |
|
| 2477 | + } elseif (isset($tag['disabled_before']) || isset($tag['disabled_after'])) |
|
| 2364 | 2478 | { |
| 2365 | 2479 | $tag['before'] = isset($tag['disabled_before']) ? $tag['disabled_before'] : (!empty($tag['block_level']) ? '<div>' : ''); |
| 2366 | 2480 | $tag['after'] = isset($tag['disabled_after']) ? $tag['disabled_after'] : (!empty($tag['block_level']) ? '</div>' : ''); |
| 2481 | + } else { |
|
| 2482 | + $tag['content'] = $tag['disabled_content']; |
|
| 2367 | 2483 | } |
| 2368 | - else |
|
| 2369 | - $tag['content'] = $tag['disabled_content']; |
|
| 2370 | 2484 | } |
| 2371 | 2485 | |
| 2372 | 2486 | // we use this a lot |
@@ -2376,8 +2490,9 @@ discard block |
||
| 2376 | 2490 | if (!empty($tag['block_level']) && $tag['tag'] != 'html' && empty($inside['block_level'])) |
| 2377 | 2491 | { |
| 2378 | 2492 | $n = count($open_tags) - 1; |
| 2379 | - while (empty($open_tags[$n]['block_level']) && $n >= 0) |
|
| 2380 | - $n--; |
|
| 2493 | + while (empty($open_tags[$n]['block_level']) && $n >= 0) { |
|
| 2494 | + $n--; |
|
| 2495 | + } |
|
| 2381 | 2496 | |
| 2382 | 2497 | // Close all the non block level tags so this tag isn't surrounded by them. |
| 2383 | 2498 | for ($i = count($open_tags) - 1; $i > $n; $i--) |
@@ -2388,10 +2503,12 @@ discard block |
||
| 2388 | 2503 | $pos1 += $ot_strlen + 2; |
| 2389 | 2504 | |
| 2390 | 2505 | // Trim or eat trailing stuff... see comment at the end of the big loop. |
| 2391 | - if (!empty($open_tags[$i]['block_level']) && substr($message, $pos, 4) == '<br>') |
|
| 2392 | - $message = substr($message, 0, $pos) . substr($message, $pos + 4); |
|
| 2393 | - if (!empty($open_tags[$i]['trim']) && $tag['trim'] != 'inside' && preg_match('~(<br>| |\s)*~', substr($message, $pos), $matches) != 0) |
|
| 2394 | - $message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0])); |
|
| 2506 | + if (!empty($open_tags[$i]['block_level']) && substr($message, $pos, 4) == '<br>') { |
|
| 2507 | + $message = substr($message, 0, $pos) . substr($message, $pos + 4); |
|
| 2508 | + } |
|
| 2509 | + if (!empty($open_tags[$i]['trim']) && $tag['trim'] != 'inside' && preg_match('~(<br>| |\s)*~', substr($message, $pos), $matches) != 0) { |
|
| 2510 | + $message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0])); |
|
| 2511 | + } |
|
| 2395 | 2512 | |
| 2396 | 2513 | array_pop($open_tags); |
| 2397 | 2514 | } |
@@ -2409,16 +2526,19 @@ discard block |
||
| 2409 | 2526 | elseif ($tag['type'] == 'unparsed_content') |
| 2410 | 2527 | { |
| 2411 | 2528 | $pos2 = stripos($message, '[/' . substr($message, $pos + 1, $tag_strlen) . ']', $pos1); |
| 2412 | - if ($pos2 === false) |
|
| 2413 | - continue; |
|
| 2529 | + if ($pos2 === false) { |
|
| 2530 | + continue; |
|
| 2531 | + } |
|
| 2414 | 2532 | |
| 2415 | 2533 | $data = substr($message, $pos1, $pos2 - $pos1); |
| 2416 | 2534 | |
| 2417 | - if (!empty($tag['block_level']) && substr($data, 0, 4) == '<br>') |
|
| 2418 | - $data = substr($data, 4); |
|
| 2535 | + if (!empty($tag['block_level']) && substr($data, 0, 4) == '<br>') { |
|
| 2536 | + $data = substr($data, 4); |
|
| 2537 | + } |
|
| 2419 | 2538 | |
| 2420 | - if (isset($tag['validate'])) |
|
| 2421 | - $tag['validate']($tag, $data, $disabled, $params); |
|
| 2539 | + if (isset($tag['validate'])) { |
|
| 2540 | + $tag['validate']($tag, $data, $disabled, $params); |
|
| 2541 | + } |
|
| 2422 | 2542 | |
| 2423 | 2543 | $code = strtr($tag['content'], array('$1' => $data)); |
| 2424 | 2544 | $message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos2 + 3 + $tag_strlen); |
@@ -2434,34 +2554,40 @@ discard block |
||
| 2434 | 2554 | if (isset($tag['quoted'])) |
| 2435 | 2555 | { |
| 2436 | 2556 | $quoted = substr($message, $pos1, 6) == '"'; |
| 2437 | - if ($tag['quoted'] != 'optional' && !$quoted) |
|
| 2438 | - continue; |
|
| 2557 | + if ($tag['quoted'] != 'optional' && !$quoted) { |
|
| 2558 | + continue; |
|
| 2559 | + } |
|
| 2439 | 2560 | |
| 2440 | - if ($quoted) |
|
| 2441 | - $pos1 += 6; |
|
| 2561 | + if ($quoted) { |
|
| 2562 | + $pos1 += 6; |
|
| 2563 | + } |
|
| 2564 | + } else { |
|
| 2565 | + $quoted = false; |
|
| 2442 | 2566 | } |
| 2443 | - else |
|
| 2444 | - $quoted = false; |
|
| 2445 | 2567 | |
| 2446 | 2568 | $pos2 = strpos($message, $quoted == false ? ']' : '"]', $pos1); |
| 2447 | - if ($pos2 === false) |
|
| 2448 | - continue; |
|
| 2569 | + if ($pos2 === false) { |
|
| 2570 | + continue; |
|
| 2571 | + } |
|
| 2449 | 2572 | |
| 2450 | 2573 | $pos3 = stripos($message, '[/' . substr($message, $pos + 1, $tag_strlen) . ']', $pos2); |
| 2451 | - if ($pos3 === false) |
|
| 2452 | - continue; |
|
| 2574 | + if ($pos3 === false) { |
|
| 2575 | + continue; |
|
| 2576 | + } |
|
| 2453 | 2577 | |
| 2454 | 2578 | $data = array( |
| 2455 | 2579 | substr($message, $pos2 + ($quoted == false ? 1 : 7), $pos3 - ($pos2 + ($quoted == false ? 1 : 7))), |
| 2456 | 2580 | substr($message, $pos1, $pos2 - $pos1) |
| 2457 | 2581 | ); |
| 2458 | 2582 | |
| 2459 | - if (!empty($tag['block_level']) && substr($data[0], 0, 4) == '<br>') |
|
| 2460 | - $data[0] = substr($data[0], 4); |
|
| 2583 | + if (!empty($tag['block_level']) && substr($data[0], 0, 4) == '<br>') { |
|
| 2584 | + $data[0] = substr($data[0], 4); |
|
| 2585 | + } |
|
| 2461 | 2586 | |
| 2462 | 2587 | // Validation for my parking, please! |
| 2463 | - if (isset($tag['validate'])) |
|
| 2464 | - $tag['validate']($tag, $data, $disabled, $params); |
|
| 2588 | + if (isset($tag['validate'])) { |
|
| 2589 | + $tag['validate']($tag, $data, $disabled, $params); |
|
| 2590 | + } |
|
| 2465 | 2591 | |
| 2466 | 2592 | $code = strtr($tag['content'], array('$1' => $data[0], '$2' => $data[1])); |
| 2467 | 2593 | $message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos3 + 3 + $tag_strlen); |
@@ -2478,23 +2604,27 @@ discard block |
||
| 2478 | 2604 | elseif ($tag['type'] == 'unparsed_commas_content') |
| 2479 | 2605 | { |
| 2480 | 2606 | $pos2 = strpos($message, ']', $pos1); |
| 2481 | - if ($pos2 === false) |
|
| 2482 | - continue; |
|
| 2607 | + if ($pos2 === false) { |
|
| 2608 | + continue; |
|
| 2609 | + } |
|
| 2483 | 2610 | |
| 2484 | 2611 | $pos3 = stripos($message, '[/' . substr($message, $pos + 1, $tag_strlen) . ']', $pos2); |
| 2485 | - if ($pos3 === false) |
|
| 2486 | - continue; |
|
| 2612 | + if ($pos3 === false) { |
|
| 2613 | + continue; |
|
| 2614 | + } |
|
| 2487 | 2615 | |
| 2488 | 2616 | // We want $1 to be the content, and the rest to be csv. |
| 2489 | 2617 | $data = explode(',', ',' . substr($message, $pos1, $pos2 - $pos1)); |
| 2490 | 2618 | $data[0] = substr($message, $pos2 + 1, $pos3 - $pos2 - 1); |
| 2491 | 2619 | |
| 2492 | - if (isset($tag['validate'])) |
|
| 2493 | - $tag['validate']($tag, $data, $disabled, $params); |
|
| 2620 | + if (isset($tag['validate'])) { |
|
| 2621 | + $tag['validate']($tag, $data, $disabled, $params); |
|
| 2622 | + } |
|
| 2494 | 2623 | |
| 2495 | 2624 | $code = $tag['content']; |
| 2496 | - foreach ($data as $k => $d) |
|
| 2497 | - $code = strtr($code, array('$' . ($k + 1) => trim($d))); |
|
| 2625 | + foreach ($data as $k => $d) { |
|
| 2626 | + $code = strtr($code, array('$' . ($k + 1) => trim($d))); |
|
| 2627 | + } |
|
| 2498 | 2628 | $message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos3 + 3 + $tag_strlen); |
| 2499 | 2629 | $pos += strlen($code) - 1 + 2; |
| 2500 | 2630 | } |
@@ -2502,24 +2632,28 @@ discard block |
||
| 2502 | 2632 | elseif ($tag['type'] == 'unparsed_commas') |
| 2503 | 2633 | { |
| 2504 | 2634 | $pos2 = strpos($message, ']', $pos1); |
| 2505 | - if ($pos2 === false) |
|
| 2506 | - continue; |
|
| 2635 | + if ($pos2 === false) { |
|
| 2636 | + continue; |
|
| 2637 | + } |
|
| 2507 | 2638 | |
| 2508 | 2639 | $data = explode(',', substr($message, $pos1, $pos2 - $pos1)); |
| 2509 | 2640 | |
| 2510 | - if (isset($tag['validate'])) |
|
| 2511 | - $tag['validate']($tag, $data, $disabled, $params); |
|
| 2641 | + if (isset($tag['validate'])) { |
|
| 2642 | + $tag['validate']($tag, $data, $disabled, $params); |
|
| 2643 | + } |
|
| 2512 | 2644 | |
| 2513 | 2645 | // Fix after, for disabled code mainly. |
| 2514 | - foreach ($data as $k => $d) |
|
| 2515 | - $tag['after'] = strtr($tag['after'], array('$' . ($k + 1) => trim($d))); |
|
| 2646 | + foreach ($data as $k => $d) { |
|
| 2647 | + $tag['after'] = strtr($tag['after'], array('$' . ($k + 1) => trim($d))); |
|
| 2648 | + } |
|
| 2516 | 2649 | |
| 2517 | 2650 | $open_tags[] = $tag; |
| 2518 | 2651 | |
| 2519 | 2652 | // Replace them out, $1, $2, $3, $4, etc. |
| 2520 | 2653 | $code = $tag['before']; |
| 2521 | - foreach ($data as $k => $d) |
|
| 2522 | - $code = strtr($code, array('$' . ($k + 1) => trim($d))); |
|
| 2654 | + foreach ($data as $k => $d) { |
|
| 2655 | + $code = strtr($code, array('$' . ($k + 1) => trim($d))); |
|
| 2656 | + } |
|
| 2523 | 2657 | $message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos2 + 1); |
| 2524 | 2658 | $pos += strlen($code) - 1 + 2; |
| 2525 | 2659 | } |
@@ -2530,28 +2664,33 @@ discard block |
||
| 2530 | 2664 | if (isset($tag['quoted'])) |
| 2531 | 2665 | { |
| 2532 | 2666 | $quoted = substr($message, $pos1, 6) == '"'; |
| 2533 | - if ($tag['quoted'] != 'optional' && !$quoted) |
|
| 2534 | - continue; |
|
| 2667 | + if ($tag['quoted'] != 'optional' && !$quoted) { |
|
| 2668 | + continue; |
|
| 2669 | + } |
|
| 2535 | 2670 | |
| 2536 | - if ($quoted) |
|
| 2537 | - $pos1 += 6; |
|
| 2671 | + if ($quoted) { |
|
| 2672 | + $pos1 += 6; |
|
| 2673 | + } |
|
| 2674 | + } else { |
|
| 2675 | + $quoted = false; |
|
| 2538 | 2676 | } |
| 2539 | - else |
|
| 2540 | - $quoted = false; |
|
| 2541 | 2677 | |
| 2542 | 2678 | $pos2 = strpos($message, $quoted == false ? ']' : '"]', $pos1); |
| 2543 | - if ($pos2 === false) |
|
| 2544 | - continue; |
|
| 2679 | + if ($pos2 === false) { |
|
| 2680 | + continue; |
|
| 2681 | + } |
|
| 2545 | 2682 | |
| 2546 | 2683 | $data = substr($message, $pos1, $pos2 - $pos1); |
| 2547 | 2684 | |
| 2548 | 2685 | // Validation for my parking, please! |
| 2549 | - if (isset($tag['validate'])) |
|
| 2550 | - $tag['validate']($tag, $data, $disabled, $params); |
|
| 2686 | + if (isset($tag['validate'])) { |
|
| 2687 | + $tag['validate']($tag, $data, $disabled, $params); |
|
| 2688 | + } |
|
| 2551 | 2689 | |
| 2552 | 2690 | // For parsed content, we must recurse to avoid security problems. |
| 2553 | - if ($tag['type'] != 'unparsed_equals') |
|
| 2554 | - $data = parse_bbc($data, !empty($tag['parsed_tags_allowed']) ? false : true, '', !empty($tag['parsed_tags_allowed']) ? $tag['parsed_tags_allowed'] : array()); |
|
| 2691 | + if ($tag['type'] != 'unparsed_equals') { |
|
| 2692 | + $data = parse_bbc($data, !empty($tag['parsed_tags_allowed']) ? false : true, '', !empty($tag['parsed_tags_allowed']) ? $tag['parsed_tags_allowed'] : array()); |
|
| 2693 | + } |
|
| 2555 | 2694 | |
| 2556 | 2695 | $tag['after'] = strtr($tag['after'], array('$1' => $data)); |
| 2557 | 2696 | |
@@ -2563,34 +2702,40 @@ discard block |
||
| 2563 | 2702 | } |
| 2564 | 2703 | |
| 2565 | 2704 | // If this is block level, eat any breaks after it. |
| 2566 | - if (!empty($tag['block_level']) && substr($message, $pos + 1, 4) == '<br>') |
|
| 2567 | - $message = substr($message, 0, $pos + 1) . substr($message, $pos + 5); |
|
| 2705 | + if (!empty($tag['block_level']) && substr($message, $pos + 1, 4) == '<br>') { |
|
| 2706 | + $message = substr($message, 0, $pos + 1) . substr($message, $pos + 5); |
|
| 2707 | + } |
|
| 2568 | 2708 | |
| 2569 | 2709 | // Are we trimming outside this tag? |
| 2570 | - if (!empty($tag['trim']) && $tag['trim'] != 'outside' && preg_match('~(<br>| |\s)*~', substr($message, $pos + 1), $matches) != 0) |
|
| 2571 | - $message = substr($message, 0, $pos + 1) . substr($message, $pos + 1 + strlen($matches[0])); |
|
| 2710 | + if (!empty($tag['trim']) && $tag['trim'] != 'outside' && preg_match('~(<br>| |\s)*~', substr($message, $pos + 1), $matches) != 0) { |
|
| 2711 | + $message = substr($message, 0, $pos + 1) . substr($message, $pos + 1 + strlen($matches[0])); |
|
| 2712 | + } |
|
| 2572 | 2713 | } |
| 2573 | 2714 | |
| 2574 | 2715 | // Close any remaining tags. |
| 2575 | - while ($tag = array_pop($open_tags)) |
|
| 2576 | - $message .= "\n" . $tag['after'] . "\n"; |
|
| 2716 | + while ($tag = array_pop($open_tags)) { |
|
| 2717 | + $message .= "\n" . $tag['after'] . "\n"; |
|
| 2718 | + } |
|
| 2577 | 2719 | |
| 2578 | 2720 | // Parse the smileys within the parts where it can be done safely. |
| 2579 | 2721 | if ($smileys === true) |
| 2580 | 2722 | { |
| 2581 | 2723 | $message_parts = explode("\n", $message); |
| 2582 | - for ($i = 0, $n = count($message_parts); $i < $n; $i += 2) |
|
| 2583 | - parsesmileys($message_parts[$i]); |
|
| 2724 | + for ($i = 0, $n = count($message_parts); $i < $n; $i += 2) { |
|
| 2725 | + parsesmileys($message_parts[$i]); |
|
| 2726 | + } |
|
| 2584 | 2727 | |
| 2585 | 2728 | $message = implode('', $message_parts); |
| 2586 | 2729 | } |
| 2587 | 2730 | |
| 2588 | 2731 | // No smileys, just get rid of the markers. |
| 2589 | - else |
|
| 2590 | - $message = strtr($message, array("\n" => '')); |
|
| 2732 | + else { |
|
| 2733 | + $message = strtr($message, array("\n" => '')); |
|
| 2734 | + } |
|
| 2591 | 2735 | |
| 2592 | - if ($message !== '' && $message[0] === ' ') |
|
| 2593 | - $message = ' ' . substr($message, 1); |
|
| 2736 | + if ($message !== '' && $message[0] === ' ') { |
|
| 2737 | + $message = ' ' . substr($message, 1); |
|
| 2738 | + } |
|
| 2594 | 2739 | |
| 2595 | 2740 | // Cleanup whitespace. |
| 2596 | 2741 | $message = strtr($message, array(' ' => ' ', "\r" => '', "\n" => '<br>', '<br> ' => '<br> ', ' ' => "\n")); |
@@ -2599,15 +2744,16 @@ discard block |
||
| 2599 | 2744 | call_integration_hook('integrate_post_parsebbc', array(&$message, &$smileys, &$cache_id, &$parse_tags)); |
| 2600 | 2745 | |
| 2601 | 2746 | // Cache the output if it took some time... |
| 2602 | - if (isset($cache_key, $cache_t) && array_sum(explode(' ', microtime())) - array_sum(explode(' ', $cache_t)) > 0.05) |
|
| 2603 | - cache_put_data($cache_key, $message, 240); |
|
| 2747 | + if (isset($cache_key, $cache_t) && array_sum(explode(' ', microtime())) - array_sum(explode(' ', $cache_t)) > 0.05) { |
|
| 2748 | + cache_put_data($cache_key, $message, 240); |
|
| 2749 | + } |
|
| 2604 | 2750 | |
| 2605 | 2751 | // If this was a force parse revert if needed. |
| 2606 | 2752 | if (!empty($parse_tags)) |
| 2607 | 2753 | { |
| 2608 | - if (empty($temp_bbc)) |
|
| 2609 | - $bbc_codes = array(); |
|
| 2610 | - else |
|
| 2754 | + if (empty($temp_bbc)) { |
|
| 2755 | + $bbc_codes = array(); |
|
| 2756 | + } else |
|
| 2611 | 2757 | { |
| 2612 | 2758 | $bbc_codes = $temp_bbc; |
| 2613 | 2759 | unset($temp_bbc); |
@@ -2634,8 +2780,9 @@ discard block |
||
| 2634 | 2780 | static $smileyPregSearch = null, $smileyPregReplacements = array(); |
| 2635 | 2781 | |
| 2636 | 2782 | // No smiley set at all?! |
| 2637 | - if ($user_info['smiley_set'] == 'none' || trim($message) == '') |
|
| 2638 | - return; |
|
| 2783 | + if ($user_info['smiley_set'] == 'none' || trim($message) == '') { |
|
| 2784 | + return; |
|
| 2785 | + } |
|
| 2639 | 2786 | |
| 2640 | 2787 | // If smileyPregSearch hasn't been set, do it now. |
| 2641 | 2788 | if (empty($smileyPregSearch)) |
@@ -2646,8 +2793,7 @@ discard block |
||
| 2646 | 2793 | $smileysfrom = array('>:D', ':D', '::)', '>:(', ':))', ':)', ';)', ';D', ':(', ':o', '8)', ':P', '???', ':-[', ':-X', ':-*', ':\'(', ':-\\', '^-^', 'O0', 'C:-)', '0:)'); |
| 2647 | 2794 | $smileysto = array('evil.gif', 'cheesy.gif', 'rolleyes.gif', 'angry.gif', 'laugh.gif', 'smiley.gif', 'wink.gif', 'grin.gif', 'sad.gif', 'shocked.gif', 'cool.gif', 'tongue.gif', 'huh.gif', 'embarrassed.gif', 'lipsrsealed.gif', 'kiss.gif', 'cry.gif', 'undecided.gif', 'azn.gif', 'afro.gif', 'police.gif', 'angel.gif'); |
| 2648 | 2795 | $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'], '', '', '', ''); |
| 2649 | - } |
|
| 2650 | - else |
|
| 2796 | + } else |
|
| 2651 | 2797 | { |
| 2652 | 2798 | // Load the smileys in reverse order by length so they don't get parsed wrong. |
| 2653 | 2799 | if (($temp = cache_get_data('parsing_smileys', 480)) == null) |
@@ -2671,9 +2817,9 @@ discard block |
||
| 2671 | 2817 | $smcFunc['db_free_result']($result); |
| 2672 | 2818 | |
| 2673 | 2819 | cache_put_data('parsing_smileys', array($smileysfrom, $smileysto, $smileysdescs), 480); |
| 2820 | + } else { |
|
| 2821 | + list ($smileysfrom, $smileysto, $smileysdescs) = $temp; |
|
| 2674 | 2822 | } |
| 2675 | - else |
|
| 2676 | - list ($smileysfrom, $smileysto, $smileysdescs) = $temp; |
|
| 2677 | 2823 | } |
| 2678 | 2824 | |
| 2679 | 2825 | // The non-breaking-space is a complex thing... |
@@ -2750,35 +2896,41 @@ discard block |
||
| 2750 | 2896 | global $scripturl, $context, $modSettings, $db_show_debug, $db_cache; |
| 2751 | 2897 | |
| 2752 | 2898 | // In case we have mail to send, better do that - as obExit doesn't always quite make it... |
| 2753 | - if (!empty($context['flush_mail'])) |
|
| 2754 | - // @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\ |
|
| 2899 | + if (!empty($context['flush_mail'])) { |
|
| 2900 | + // @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\ |
|
| 2755 | 2901 | AddMailQueue(true); |
| 2902 | + } |
|
| 2756 | 2903 | |
| 2757 | 2904 | $add = preg_match('~^(ftp|http)[s]?://~', $setLocation) == 0 && substr($setLocation, 0, 6) != 'about:'; |
| 2758 | 2905 | |
| 2759 | - if ($add) |
|
| 2760 | - $setLocation = $scripturl . ($setLocation != '' ? '?' . $setLocation : ''); |
|
| 2906 | + if ($add) { |
|
| 2907 | + $setLocation = $scripturl . ($setLocation != '' ? '?' . $setLocation : ''); |
|
| 2908 | + } |
|
| 2761 | 2909 | |
| 2762 | 2910 | // Put the session ID in. |
| 2763 | - if (defined('SID') && SID != '') |
|
| 2764 | - $setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '(?!\?' . preg_quote(SID, '/') . ')\\??/', $scripturl . '?' . SID . ';', $setLocation); |
|
| 2911 | + if (defined('SID') && SID != '') { |
|
| 2912 | + $setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '(?!\?' . preg_quote(SID, '/') . ')\\??/', $scripturl . '?' . SID . ';', $setLocation); |
|
| 2913 | + } |
|
| 2765 | 2914 | // Keep that debug in their for template debugging! |
| 2766 | - elseif (isset($_GET['debug'])) |
|
| 2767 | - $setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '\\??/', $scripturl . '?debug;', $setLocation); |
|
| 2915 | + elseif (isset($_GET['debug'])) { |
|
| 2916 | + $setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '\\??/', $scripturl . '?debug;', $setLocation); |
|
| 2917 | + } |
|
| 2768 | 2918 | |
| 2769 | 2919 | 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']))) |
| 2770 | 2920 | { |
| 2771 | - if (defined('SID') && SID != '') |
|
| 2772 | - $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?(?:' . SID . '(?:;|&|&))((?:board|topic)=[^#]+?)(#[^"]*?)?$~', |
|
| 2921 | + if (defined('SID') && SID != '') { |
|
| 2922 | + $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?(?:' . SID . '(?:;|&|&))((?:board|topic)=[^#]+?)(#[^"]*?)?$~', |
|
| 2773 | 2923 | function ($m) use ($scripturl) |
| 2774 | 2924 | { |
| 2775 | 2925 | return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html?' . SID. (isset($m[2]) ? "$m[2]" : ""); |
| 2926 | + } |
|
| 2776 | 2927 | }, $setLocation); |
| 2777 | - else |
|
| 2778 | - $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?((?:board|topic)=[^#"]+?)(#[^"]*?)?$~', |
|
| 2928 | + else { |
|
| 2929 | + $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?((?:board|topic)=[^#"]+?)(#[^"]*?)?$~', |
|
| 2779 | 2930 | function ($m) use ($scripturl) |
| 2780 | 2931 | { |
| 2781 | 2932 | return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html' . (isset($m[2]) ? "$m[2]" : ""); |
| 2933 | + } |
|
| 2782 | 2934 | }, $setLocation); |
| 2783 | 2935 | } |
| 2784 | 2936 | |
@@ -2789,8 +2941,9 @@ discard block |
||
| 2789 | 2941 | header('Location: ' . str_replace(' ', '%20', $setLocation), true, $permanent ? 301 : 302); |
| 2790 | 2942 | |
| 2791 | 2943 | // Debugging. |
| 2792 | - if (isset($db_show_debug) && $db_show_debug === true) |
|
| 2793 | - $_SESSION['debug_redirect'] = $db_cache; |
|
| 2944 | + if (isset($db_show_debug) && $db_show_debug === true) { |
|
| 2945 | + $_SESSION['debug_redirect'] = $db_cache; |
|
| 2946 | + } |
|
| 2794 | 2947 | |
| 2795 | 2948 | obExit(false); |
| 2796 | 2949 | } |
@@ -2809,51 +2962,60 @@ discard block |
||
| 2809 | 2962 | |
| 2810 | 2963 | // Attempt to prevent a recursive loop. |
| 2811 | 2964 | ++$level; |
| 2812 | - if ($level > 1 && !$from_fatal_error && !$has_fatal_error) |
|
| 2813 | - exit; |
|
| 2814 | - if ($from_fatal_error) |
|
| 2815 | - $has_fatal_error = true; |
|
| 2965 | + if ($level > 1 && !$from_fatal_error && !$has_fatal_error) { |
|
| 2966 | + exit; |
|
| 2967 | + } |
|
| 2968 | + if ($from_fatal_error) { |
|
| 2969 | + $has_fatal_error = true; |
|
| 2970 | + } |
|
| 2816 | 2971 | |
| 2817 | 2972 | // Clear out the stat cache. |
| 2818 | 2973 | trackStats(); |
| 2819 | 2974 | |
| 2820 | 2975 | // If we have mail to send, send it. |
| 2821 | - if (!empty($context['flush_mail'])) |
|
| 2822 | - // @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\ |
|
| 2976 | + if (!empty($context['flush_mail'])) { |
|
| 2977 | + // @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\ |
|
| 2823 | 2978 | AddMailQueue(true); |
| 2979 | + } |
|
| 2824 | 2980 | |
| 2825 | 2981 | $do_header = $header === null ? !$header_done : $header; |
| 2826 | - if ($do_footer === null) |
|
| 2827 | - $do_footer = $do_header; |
|
| 2982 | + if ($do_footer === null) { |
|
| 2983 | + $do_footer = $do_header; |
|
| 2984 | + } |
|
| 2828 | 2985 | |
| 2829 | 2986 | // Has the template/header been done yet? |
| 2830 | 2987 | if ($do_header) |
| 2831 | 2988 | { |
| 2832 | 2989 | // Was the page title set last minute? Also update the HTML safe one. |
| 2833 | - if (!empty($context['page_title']) && empty($context['page_title_html_safe'])) |
|
| 2834 | - $context['page_title_html_safe'] = $smcFunc['htmlspecialchars'](un_htmlspecialchars($context['page_title'])) . (!empty($context['current_page']) ? ' - ' . $txt['page'] . ' ' . ($context['current_page'] + 1) : ''); |
|
| 2990 | + if (!empty($context['page_title']) && empty($context['page_title_html_safe'])) { |
|
| 2991 | + $context['page_title_html_safe'] = $smcFunc['htmlspecialchars'](un_htmlspecialchars($context['page_title'])) . (!empty($context['current_page']) ? ' - ' . $txt['page'] . ' ' . ($context['current_page'] + 1) : ''); |
|
| 2992 | + } |
|
| 2835 | 2993 | |
| 2836 | 2994 | // Start up the session URL fixer. |
| 2837 | 2995 | ob_start('ob_sessrewrite'); |
| 2838 | 2996 | |
| 2839 | - if (!empty($settings['output_buffers']) && is_string($settings['output_buffers'])) |
|
| 2840 | - $buffers = explode(',', $settings['output_buffers']); |
|
| 2841 | - elseif (!empty($settings['output_buffers'])) |
|
| 2842 | - $buffers = $settings['output_buffers']; |
|
| 2843 | - else |
|
| 2844 | - $buffers = array(); |
|
| 2997 | + if (!empty($settings['output_buffers']) && is_string($settings['output_buffers'])) { |
|
| 2998 | + $buffers = explode(',', $settings['output_buffers']); |
|
| 2999 | + } elseif (!empty($settings['output_buffers'])) { |
|
| 3000 | + $buffers = $settings['output_buffers']; |
|
| 3001 | + } else { |
|
| 3002 | + $buffers = array(); |
|
| 3003 | + } |
|
| 2845 | 3004 | |
| 2846 | - if (isset($modSettings['integrate_buffer'])) |
|
| 2847 | - $buffers = array_merge(explode(',', $modSettings['integrate_buffer']), $buffers); |
|
| 3005 | + if (isset($modSettings['integrate_buffer'])) { |
|
| 3006 | + $buffers = array_merge(explode(',', $modSettings['integrate_buffer']), $buffers); |
|
| 3007 | + } |
|
| 2848 | 3008 | |
| 2849 | - if (!empty($buffers)) |
|
| 2850 | - foreach ($buffers as $function) |
|
| 3009 | + if (!empty($buffers)) { |
|
| 3010 | + foreach ($buffers as $function) |
|
| 2851 | 3011 | { |
| 2852 | 3012 | $call = call_helper($function, true); |
| 3013 | + } |
|
| 2853 | 3014 | |
| 2854 | 3015 | // Is it valid? |
| 2855 | - if (!empty($call)) |
|
| 2856 | - ob_start($call); |
|
| 3016 | + if (!empty($call)) { |
|
| 3017 | + ob_start($call); |
|
| 3018 | + } |
|
| 2857 | 3019 | } |
| 2858 | 3020 | |
| 2859 | 3021 | // Display the screen in the logical order. |
@@ -2865,8 +3027,9 @@ discard block |
||
| 2865 | 3027 | loadSubTemplate(isset($context['sub_template']) ? $context['sub_template'] : 'main'); |
| 2866 | 3028 | |
| 2867 | 3029 | // Anything special to put out? |
| 2868 | - if (!empty($context['insert_after_template']) && !isset($_REQUEST['xml'])) |
|
| 2869 | - echo $context['insert_after_template']; |
|
| 3030 | + if (!empty($context['insert_after_template']) && !isset($_REQUEST['xml'])) { |
|
| 3031 | + echo $context['insert_after_template']; |
|
| 3032 | + } |
|
| 2870 | 3033 | |
| 2871 | 3034 | // Just so we don't get caught in an endless loop of errors from the footer... |
| 2872 | 3035 | if (!$footer_done) |
@@ -2875,14 +3038,16 @@ discard block |
||
| 2875 | 3038 | template_footer(); |
| 2876 | 3039 | |
| 2877 | 3040 | // (since this is just debugging... it's okay that it's after </html>.) |
| 2878 | - if (!isset($_REQUEST['xml'])) |
|
| 2879 | - displayDebug(); |
|
| 3041 | + if (!isset($_REQUEST['xml'])) { |
|
| 3042 | + displayDebug(); |
|
| 3043 | + } |
|
| 2880 | 3044 | } |
| 2881 | 3045 | } |
| 2882 | 3046 | |
| 2883 | 3047 | // Remember this URL in case someone doesn't like sending HTTP_REFERER. |
| 2884 | - if (strpos($_SERVER['REQUEST_URL'], 'action=dlattach') === false && strpos($_SERVER['REQUEST_URL'], 'action=viewsmfile') === false) |
|
| 2885 | - $_SESSION['old_url'] = $_SERVER['REQUEST_URL']; |
|
| 3048 | + if (strpos($_SERVER['REQUEST_URL'], 'action=dlattach') === false && strpos($_SERVER['REQUEST_URL'], 'action=viewsmfile') === false) { |
|
| 3049 | + $_SESSION['old_url'] = $_SERVER['REQUEST_URL']; |
|
| 3050 | + } |
|
| 2886 | 3051 | |
| 2887 | 3052 | // For session check verification.... don't switch browsers... |
| 2888 | 3053 | $_SESSION['USER_AGENT'] = empty($_SERVER['HTTP_USER_AGENT']) ? '' : $_SERVER['HTTP_USER_AGENT']; |
@@ -2891,9 +3056,10 @@ discard block |
||
| 2891 | 3056 | call_integration_hook('integrate_exit', array($do_footer)); |
| 2892 | 3057 | |
| 2893 | 3058 | // Don't exit if we're coming from index.php; that will pass through normally. |
| 2894 | - if (!$from_index) |
|
| 2895 | - exit; |
|
| 2896 | -} |
|
| 3059 | + if (!$from_index) { |
|
| 3060 | + exit; |
|
| 3061 | + } |
|
| 3062 | + } |
|
| 2897 | 3063 | |
| 2898 | 3064 | /** |
| 2899 | 3065 | * Get the size of a specified image with better error handling. |
@@ -2912,8 +3078,9 @@ discard block |
||
| 2912 | 3078 | $url = str_replace(' ', '%20', $url); |
| 2913 | 3079 | |
| 2914 | 3080 | // Can we pull this from the cache... please please? |
| 2915 | - if (($temp = cache_get_data('url_image_size-' . md5($url), 240)) !== null) |
|
| 2916 | - return $temp; |
|
| 3081 | + if (($temp = cache_get_data('url_image_size-' . md5($url), 240)) !== null) { |
|
| 3082 | + return $temp; |
|
| 3083 | + } |
|
| 2917 | 3084 | $t = microtime(); |
| 2918 | 3085 | |
| 2919 | 3086 | // Get the host to pester... |
@@ -2923,12 +3090,10 @@ discard block |
||
| 2923 | 3090 | if ($url == '' || $url == 'http://' || $url == 'https://') |
| 2924 | 3091 | { |
| 2925 | 3092 | return false; |
| 2926 | - } |
|
| 2927 | - elseif (!isset($match[1])) |
|
| 3093 | + } elseif (!isset($match[1])) |
|
| 2928 | 3094 | { |
| 2929 | 3095 | $size = @getimagesize($url); |
| 2930 | - } |
|
| 2931 | - else |
|
| 3096 | + } else |
|
| 2932 | 3097 | { |
| 2933 | 3098 | // Try to connect to the server... give it half a second. |
| 2934 | 3099 | $temp = 0; |
@@ -2967,12 +3132,14 @@ discard block |
||
| 2967 | 3132 | } |
| 2968 | 3133 | |
| 2969 | 3134 | // If we didn't get it, we failed. |
| 2970 | - if (!isset($size)) |
|
| 2971 | - $size = false; |
|
| 3135 | + if (!isset($size)) { |
|
| 3136 | + $size = false; |
|
| 3137 | + } |
|
| 2972 | 3138 | |
| 2973 | 3139 | // If this took a long time, we may never have to do it again, but then again we might... |
| 2974 | - if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $t)) > 0.8) |
|
| 2975 | - cache_put_data('url_image_size-' . md5($url), $size, 240); |
|
| 3140 | + if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $t)) > 0.8) { |
|
| 3141 | + cache_put_data('url_image_size-' . md5($url), $size, 240); |
|
| 3142 | + } |
|
| 2976 | 3143 | |
| 2977 | 3144 | // Didn't work. |
| 2978 | 3145 | return $size; |
@@ -2990,8 +3157,9 @@ discard block |
||
| 2990 | 3157 | |
| 2991 | 3158 | // Under SSI this function can be called more then once. That can cause some problems. |
| 2992 | 3159 | // So only run the function once unless we are forced to run it again. |
| 2993 | - if ($loaded && !$forceload) |
|
| 2994 | - return; |
|
| 3160 | + if ($loaded && !$forceload) { |
|
| 3161 | + return; |
|
| 3162 | + } |
|
| 2995 | 3163 | |
| 2996 | 3164 | $loaded = true; |
| 2997 | 3165 | |
@@ -3003,14 +3171,16 @@ discard block |
||
| 3003 | 3171 | $context['news_lines'] = array_filter(explode("\n", str_replace("\r", '', trim(addslashes($modSettings['news']))))); |
| 3004 | 3172 | for ($i = 0, $n = count($context['news_lines']); $i < $n; $i++) |
| 3005 | 3173 | { |
| 3006 | - if (trim($context['news_lines'][$i]) == '') |
|
| 3007 | - continue; |
|
| 3174 | + if (trim($context['news_lines'][$i]) == '') { |
|
| 3175 | + continue; |
|
| 3176 | + } |
|
| 3008 | 3177 | |
| 3009 | 3178 | // Clean it up for presentation ;). |
| 3010 | 3179 | $context['news_lines'][$i] = parse_bbc(stripslashes(trim($context['news_lines'][$i])), true, 'news' . $i); |
| 3011 | 3180 | } |
| 3012 | - if (!empty($context['news_lines'])) |
|
| 3013 | - $context['random_news_line'] = $context['news_lines'][mt_rand(0, count($context['news_lines']) - 1)]; |
|
| 3181 | + if (!empty($context['news_lines'])) { |
|
| 3182 | + $context['random_news_line'] = $context['news_lines'][mt_rand(0, count($context['news_lines']) - 1)]; |
|
| 3183 | + } |
|
| 3014 | 3184 | |
| 3015 | 3185 | if (!$user_info['is_guest']) |
| 3016 | 3186 | { |
@@ -3019,40 +3189,48 @@ discard block |
||
| 3019 | 3189 | $context['user']['alerts'] = &$user_info['alerts']; |
| 3020 | 3190 | |
| 3021 | 3191 | // Personal message popup... |
| 3022 | - if ($user_info['unread_messages'] > (isset($_SESSION['unread_messages']) ? $_SESSION['unread_messages'] : 0)) |
|
| 3023 | - $context['user']['popup_messages'] = true; |
|
| 3024 | - else |
|
| 3025 | - $context['user']['popup_messages'] = false; |
|
| 3192 | + if ($user_info['unread_messages'] > (isset($_SESSION['unread_messages']) ? $_SESSION['unread_messages'] : 0)) { |
|
| 3193 | + $context['user']['popup_messages'] = true; |
|
| 3194 | + } else { |
|
| 3195 | + $context['user']['popup_messages'] = false; |
|
| 3196 | + } |
|
| 3026 | 3197 | $_SESSION['unread_messages'] = $user_info['unread_messages']; |
| 3027 | 3198 | |
| 3028 | - if (allowedTo('moderate_forum')) |
|
| 3029 | - $context['unapproved_members'] = (!empty($modSettings['registration_method']) && ($modSettings['registration_method'] == 2 || (!empty($modSettings['coppaType']) && $modSettings['coppaType'] == 2))) || !empty($modSettings['approveAccountDeletion']) ? $modSettings['unapprovedMembers'] : 0; |
|
| 3199 | + if (allowedTo('moderate_forum')) { |
|
| 3200 | + $context['unapproved_members'] = (!empty($modSettings['registration_method']) && ($modSettings['registration_method'] == 2 || (!empty($modSettings['coppaType']) && $modSettings['coppaType'] == 2))) || !empty($modSettings['approveAccountDeletion']) ? $modSettings['unapprovedMembers'] : 0; |
|
| 3201 | + } |
|
| 3030 | 3202 | |
| 3031 | 3203 | $context['user']['avatar'] = array(); |
| 3032 | 3204 | |
| 3033 | 3205 | // Check for gravatar first since we might be forcing them... |
| 3034 | 3206 | if (($modSettings['gravatarEnabled'] && substr($user_info['avatar']['url'], 0, 11) == 'gravatar://') || !empty($modSettings['gravatarOverride'])) |
| 3035 | 3207 | { |
| 3036 | - if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($user_info['avatar']['url'], 'gravatar://') && strlen($user_info['avatar']['url']) > 11) |
|
| 3037 | - $context['user']['avatar']['href'] = get_gravatar_url($smcFunc['substr']($user_info['avatar']['url'], 11)); |
|
| 3038 | - else |
|
| 3039 | - $context['user']['avatar']['href'] = get_gravatar_url($user_info['email']); |
|
| 3208 | + if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($user_info['avatar']['url'], 'gravatar://') && strlen($user_info['avatar']['url']) > 11) { |
|
| 3209 | + $context['user']['avatar']['href'] = get_gravatar_url($smcFunc['substr']($user_info['avatar']['url'], 11)); |
|
| 3210 | + } else { |
|
| 3211 | + $context['user']['avatar']['href'] = get_gravatar_url($user_info['email']); |
|
| 3212 | + } |
|
| 3040 | 3213 | } |
| 3041 | 3214 | // Uploaded? |
| 3042 | - elseif ($user_info['avatar']['url'] == '' && !empty($user_info['avatar']['id_attach'])) |
|
| 3043 | - $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'; |
|
| 3215 | + elseif ($user_info['avatar']['url'] == '' && !empty($user_info['avatar']['id_attach'])) { |
|
| 3216 | + $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'; |
|
| 3217 | + } |
|
| 3044 | 3218 | // Full URL? |
| 3045 | - elseif (strpos($user_info['avatar']['url'], 'http://') === 0 || strpos($user_info['avatar']['url'], 'https://') === 0) |
|
| 3046 | - $context['user']['avatar']['href'] = $user_info['avatar']['url']; |
|
| 3219 | + elseif (strpos($user_info['avatar']['url'], 'http://') === 0 || strpos($user_info['avatar']['url'], 'https://') === 0) { |
|
| 3220 | + $context['user']['avatar']['href'] = $user_info['avatar']['url']; |
|
| 3221 | + } |
|
| 3047 | 3222 | // Otherwise we assume it's server stored. |
| 3048 | - elseif ($user_info['avatar']['url'] != '') |
|
| 3049 | - $context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/' . $smcFunc['htmlspecialchars']($user_info['avatar']['url']); |
|
| 3223 | + elseif ($user_info['avatar']['url'] != '') { |
|
| 3224 | + $context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/' . $smcFunc['htmlspecialchars']($user_info['avatar']['url']); |
|
| 3225 | + } |
|
| 3050 | 3226 | // No avatar at all? Fine, we have a big fat default avatar ;) |
| 3051 | - else |
|
| 3052 | - $context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/default.png'; |
|
| 3227 | + else { |
|
| 3228 | + $context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/default.png'; |
|
| 3229 | + } |
|
| 3053 | 3230 | |
| 3054 | - if (!empty($context['user']['avatar'])) |
|
| 3055 | - $context['user']['avatar']['image'] = '<img src="' . $context['user']['avatar']['href'] . '" alt="" class="avatar">'; |
|
| 3231 | + if (!empty($context['user']['avatar'])) { |
|
| 3232 | + $context['user']['avatar']['image'] = '<img src="' . $context['user']['avatar']['href'] . '" alt="" class="avatar">'; |
|
| 3233 | + } |
|
| 3056 | 3234 | |
| 3057 | 3235 | // Figure out how long they've been logged in. |
| 3058 | 3236 | $context['user']['total_time_logged_in'] = array( |
@@ -3060,8 +3238,7 @@ discard block |
||
| 3060 | 3238 | 'hours' => floor(($user_info['total_time_logged_in'] % 86400) / 3600), |
| 3061 | 3239 | 'minutes' => floor(($user_info['total_time_logged_in'] % 3600) / 60) |
| 3062 | 3240 | ); |
| 3063 | - } |
|
| 3064 | - else |
|
| 3241 | + } else |
|
| 3065 | 3242 | { |
| 3066 | 3243 | $context['user']['messages'] = 0; |
| 3067 | 3244 | $context['user']['unread_messages'] = 0; |
@@ -3069,12 +3246,14 @@ discard block |
||
| 3069 | 3246 | $context['user']['total_time_logged_in'] = array('days' => 0, 'hours' => 0, 'minutes' => 0); |
| 3070 | 3247 | $context['user']['popup_messages'] = false; |
| 3071 | 3248 | |
| 3072 | - if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 1) |
|
| 3073 | - $txt['welcome_guest'] .= $txt['welcome_guest_activate']; |
|
| 3249 | + if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 1) { |
|
| 3250 | + $txt['welcome_guest'] .= $txt['welcome_guest_activate']; |
|
| 3251 | + } |
|
| 3074 | 3252 | |
| 3075 | 3253 | // If we've upgraded recently, go easy on the passwords. |
| 3076 | - if (!empty($modSettings['disableHashTime']) && ($modSettings['disableHashTime'] == 1 || time() < $modSettings['disableHashTime'])) |
|
| 3077 | - $context['disable_login_hashing'] = true; |
|
| 3254 | + if (!empty($modSettings['disableHashTime']) && ($modSettings['disableHashTime'] == 1 || time() < $modSettings['disableHashTime'])) { |
|
| 3255 | + $context['disable_login_hashing'] = true; |
|
| 3256 | + } |
|
| 3078 | 3257 | } |
| 3079 | 3258 | |
| 3080 | 3259 | // Setup the main menu items. |
@@ -3087,8 +3266,8 @@ discard block |
||
| 3087 | 3266 | $context['show_pm_popup'] = $context['user']['popup_messages'] && !empty($options['popup_messages']) && (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'pm'); |
| 3088 | 3267 | |
| 3089 | 3268 | // 2.1+: Add the PM popup here instead. Theme authors can still override it simply by editing/removing the 'fPmPopup' in the array. |
| 3090 | - if ($context['show_pm_popup']) |
|
| 3091 | - addInlineJavaScript(' |
|
| 3269 | + if ($context['show_pm_popup']) { |
|
| 3270 | + addInlineJavaScript(' |
|
| 3092 | 3271 | jQuery(document).ready(function($) { |
| 3093 | 3272 | new smc_Popup({ |
| 3094 | 3273 | heading: ' . JavaScriptEscape($txt['show_personal_messages_heading']) . ', |
@@ -3096,15 +3275,17 @@ discard block |
||
| 3096 | 3275 | icon_class: \'generic_icons mail_new\' |
| 3097 | 3276 | }); |
| 3098 | 3277 | });'); |
| 3278 | + } |
|
| 3099 | 3279 | |
| 3100 | 3280 | // Add a generic "Are you sure?" confirmation message. |
| 3101 | 3281 | addInlineJavaScript(' |
| 3102 | 3282 | var smf_you_sure =' . JavaScriptEscape($txt['quickmod_confirm']) .';'); |
| 3103 | 3283 | |
| 3104 | 3284 | // Now add the capping code for avatars. |
| 3105 | - 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') |
|
| 3106 | - addInlineCss(' |
|
| 3285 | + 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') { |
|
| 3286 | + addInlineCss(' |
|
| 3107 | 3287 | img.avatar { max-width: ' . $modSettings['avatar_max_width_external'] . 'px; max-height: ' . $modSettings['avatar_max_height_external'] . 'px; }'); |
| 3288 | + } |
|
| 3108 | 3289 | |
| 3109 | 3290 | // This looks weird, but it's because BoardIndex.php references the variable. |
| 3110 | 3291 | $context['common_stats']['latest_member'] = array( |
@@ -3121,11 +3302,13 @@ discard block |
||
| 3121 | 3302 | ); |
| 3122 | 3303 | $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']); |
| 3123 | 3304 | |
| 3124 | - if (empty($settings['theme_version'])) |
|
| 3125 | - addJavaScriptVar('smf_scripturl', $scripturl); |
|
| 3305 | + if (empty($settings['theme_version'])) { |
|
| 3306 | + addJavaScriptVar('smf_scripturl', $scripturl); |
|
| 3307 | + } |
|
| 3126 | 3308 | |
| 3127 | - if (!isset($context['page_title'])) |
|
| 3128 | - $context['page_title'] = ''; |
|
| 3309 | + if (!isset($context['page_title'])) { |
|
| 3310 | + $context['page_title'] = ''; |
|
| 3311 | + } |
|
| 3129 | 3312 | |
| 3130 | 3313 | // Set some specific vars. |
| 3131 | 3314 | $context['page_title_html_safe'] = $smcFunc['htmlspecialchars'](un_htmlspecialchars($context['page_title'])) . (!empty($context['current_page']) ? ' - ' . $txt['page'] . ' ' . ($context['current_page'] + 1) : ''); |
@@ -3135,21 +3318,23 @@ discard block |
||
| 3135 | 3318 | $context['meta_tags'][] = array('property' => 'og:site_name', 'content' => $context['forum_name']); |
| 3136 | 3319 | $context['meta_tags'][] = array('property' => 'og:title', 'content' => $context['page_title_html_safe']); |
| 3137 | 3320 | |
| 3138 | - if (!empty($context['meta_keywords'])) |
|
| 3139 | - $context['meta_tags'][] = array('name' => 'keywords', 'content' => $context['meta_keywords']); |
|
| 3321 | + if (!empty($context['meta_keywords'])) { |
|
| 3322 | + $context['meta_tags'][] = array('name' => 'keywords', 'content' => $context['meta_keywords']); |
|
| 3323 | + } |
|
| 3140 | 3324 | |
| 3141 | - if (!empty($context['canonical_url'])) |
|
| 3142 | - $context['meta_tags'][] = array('property' => 'og:url', 'content' => $context['canonical_url']); |
|
| 3325 | + if (!empty($context['canonical_url'])) { |
|
| 3326 | + $context['meta_tags'][] = array('property' => 'og:url', 'content' => $context['canonical_url']); |
|
| 3327 | + } |
|
| 3143 | 3328 | |
| 3144 | - if (!empty($settings['og_image'])) |
|
| 3145 | - $context['meta_tags'][] = array('property' => 'og:image', 'content' => $settings['og_image']); |
|
| 3329 | + if (!empty($settings['og_image'])) { |
|
| 3330 | + $context['meta_tags'][] = array('property' => 'og:image', 'content' => $settings['og_image']); |
|
| 3331 | + } |
|
| 3146 | 3332 | |
| 3147 | 3333 | if (!empty($context['meta_description'])) |
| 3148 | 3334 | { |
| 3149 | 3335 | $context['meta_tags'][] = array('property' => 'og:description', 'content' => $context['meta_description']); |
| 3150 | 3336 | $context['meta_tags'][] = array('name' => 'description', 'content' => $context['meta_description']); |
| 3151 | - } |
|
| 3152 | - else |
|
| 3337 | + } else |
|
| 3153 | 3338 | { |
| 3154 | 3339 | $context['meta_tags'][] = array('property' => 'og:description', 'content' => $context['page_title_html_safe']); |
| 3155 | 3340 | $context['meta_tags'][] = array('name' => 'description', 'content' => $context['page_title_html_safe']); |
@@ -3175,8 +3360,9 @@ discard block |
||
| 3175 | 3360 | $memory_needed = memoryReturnBytes($needed); |
| 3176 | 3361 | |
| 3177 | 3362 | // should we account for how much is currently being used? |
| 3178 | - if ($in_use) |
|
| 3179 | - $memory_needed += function_exists('memory_get_usage') ? memory_get_usage() : (2 * 1048576); |
|
| 3363 | + if ($in_use) { |
|
| 3364 | + $memory_needed += function_exists('memory_get_usage') ? memory_get_usage() : (2 * 1048576); |
|
| 3365 | + } |
|
| 3180 | 3366 | |
| 3181 | 3367 | // if more is needed, request it |
| 3182 | 3368 | if ($memory_current < $memory_needed) |
@@ -3199,8 +3385,9 @@ discard block |
||
| 3199 | 3385 | */ |
| 3200 | 3386 | function memoryReturnBytes($val) |
| 3201 | 3387 | { |
| 3202 | - if (is_integer($val)) |
|
| 3203 | - return $val; |
|
| 3388 | + if (is_integer($val)) { |
|
| 3389 | + return $val; |
|
| 3390 | + } |
|
| 3204 | 3391 | |
| 3205 | 3392 | // Separate the number from the designator |
| 3206 | 3393 | $val = trim($val); |
@@ -3236,10 +3423,11 @@ discard block |
||
| 3236 | 3423 | header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); |
| 3237 | 3424 | |
| 3238 | 3425 | // Are we debugging the template/html content? |
| 3239 | - if (!isset($_REQUEST['xml']) && isset($_GET['debug']) && !isBrowser('ie')) |
|
| 3240 | - header('Content-Type: application/xhtml+xml'); |
|
| 3241 | - elseif (!isset($_REQUEST['xml'])) |
|
| 3242 | - header('Content-Type: text/html; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
| 3426 | + if (!isset($_REQUEST['xml']) && isset($_GET['debug']) && !isBrowser('ie')) { |
|
| 3427 | + header('Content-Type: application/xhtml+xml'); |
|
| 3428 | + } elseif (!isset($_REQUEST['xml'])) { |
|
| 3429 | + header('Content-Type: text/html; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
| 3430 | + } |
|
| 3243 | 3431 | } |
| 3244 | 3432 | |
| 3245 | 3433 | header('Content-Type: text/' . (isset($_REQUEST['xml']) ? 'xml' : 'html') . '; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
@@ -3248,8 +3436,9 @@ discard block |
||
| 3248 | 3436 | if ($context['in_maintenance'] && $context['user']['is_admin']) |
| 3249 | 3437 | { |
| 3250 | 3438 | $position = array_search('body', $context['template_layers']); |
| 3251 | - if ($position === false) |
|
| 3252 | - $position = array_search('main', $context['template_layers']); |
|
| 3439 | + if ($position === false) { |
|
| 3440 | + $position = array_search('main', $context['template_layers']); |
|
| 3441 | + } |
|
| 3253 | 3442 | |
| 3254 | 3443 | if ($position !== false) |
| 3255 | 3444 | { |
@@ -3277,15 +3466,15 @@ discard block |
||
| 3277 | 3466 | |
| 3278 | 3467 | foreach ($securityFiles as $i => $securityFile) |
| 3279 | 3468 | { |
| 3280 | - if (!file_exists($boarddir . '/' . $securityFile)) |
|
| 3281 | - unset($securityFiles[$i]); |
|
| 3469 | + if (!file_exists($boarddir . '/' . $securityFile)) { |
|
| 3470 | + unset($securityFiles[$i]); |
|
| 3471 | + } |
|
| 3282 | 3472 | } |
| 3283 | 3473 | |
| 3284 | 3474 | // We are already checking so many files...just few more doesn't make any difference! :P |
| 3285 | - if (!empty($modSettings['currentAttachmentUploadDir'])) |
|
| 3286 | - $path = $modSettings['attachmentUploadDir'][$modSettings['currentAttachmentUploadDir']]; |
|
| 3287 | - |
|
| 3288 | - else |
|
| 3475 | + if (!empty($modSettings['currentAttachmentUploadDir'])) { |
|
| 3476 | + $path = $modSettings['attachmentUploadDir'][$modSettings['currentAttachmentUploadDir']]; |
|
| 3477 | + } else |
|
| 3289 | 3478 | { |
| 3290 | 3479 | $path = $modSettings['attachmentUploadDir']; |
| 3291 | 3480 | $id_folder_thumb = 1; |
@@ -3294,8 +3483,9 @@ discard block |
||
| 3294 | 3483 | secureDirectory($cachedir); |
| 3295 | 3484 | |
| 3296 | 3485 | // If agreement is enabled, at least the english version shall exists |
| 3297 | - if ($modSettings['requireAgreement']) |
|
| 3298 | - $agreement = !file_exists($boarddir . '/agreement.txt'); |
|
| 3486 | + if ($modSettings['requireAgreement']) { |
|
| 3487 | + $agreement = !file_exists($boarddir . '/agreement.txt'); |
|
| 3488 | + } |
|
| 3299 | 3489 | |
| 3300 | 3490 | if (!empty($securityFiles) || (!empty($modSettings['cache_enable']) && !is_writable($cachedir)) || !empty($agreement)) |
| 3301 | 3491 | { |
@@ -3310,18 +3500,21 @@ discard block |
||
| 3310 | 3500 | echo ' |
| 3311 | 3501 | ', $txt['not_removed'], '<strong>', $securityFile, '</strong>!<br>'; |
| 3312 | 3502 | |
| 3313 | - if ($securityFile == 'Settings.php~' || $securityFile == 'Settings_bak.php~') |
|
| 3314 | - echo ' |
|
| 3503 | + if ($securityFile == 'Settings.php~' || $securityFile == 'Settings_bak.php~') { |
|
| 3504 | + echo ' |
|
| 3315 | 3505 | ', sprintf($txt['not_removed_extra'], $securityFile, substr($securityFile, 0, -1)), '<br>'; |
| 3506 | + } |
|
| 3316 | 3507 | } |
| 3317 | 3508 | |
| 3318 | - if (!empty($modSettings['cache_enable']) && !is_writable($cachedir)) |
|
| 3319 | - echo ' |
|
| 3509 | + if (!empty($modSettings['cache_enable']) && !is_writable($cachedir)) { |
|
| 3510 | + echo ' |
|
| 3320 | 3511 | <strong>', $txt['cache_writable'], '</strong><br>'; |
| 3512 | + } |
|
| 3321 | 3513 | |
| 3322 | - if (!empty($agreement)) |
|
| 3323 | - echo ' |
|
| 3514 | + if (!empty($agreement)) { |
|
| 3515 | + echo ' |
|
| 3324 | 3516 | <strong>', $txt['agreement_missing'], '</strong><br>'; |
| 3517 | + } |
|
| 3325 | 3518 | |
| 3326 | 3519 | echo ' |
| 3327 | 3520 | </p> |
@@ -3336,16 +3529,18 @@ discard block |
||
| 3336 | 3529 | <div class="windowbg alert" style="margin: 2ex; padding: 2ex; border: 2px dashed red;"> |
| 3337 | 3530 | ', sprintf($txt['you_are_post_banned'], $user_info['is_guest'] ? $txt['guest_title'] : $user_info['name']); |
| 3338 | 3531 | |
| 3339 | - if (!empty($_SESSION['ban']['cannot_post']['reason'])) |
|
| 3340 | - echo ' |
|
| 3532 | + if (!empty($_SESSION['ban']['cannot_post']['reason'])) { |
|
| 3533 | + echo ' |
|
| 3341 | 3534 | <div style="padding-left: 4ex; padding-top: 1ex;">', $_SESSION['ban']['cannot_post']['reason'], '</div>'; |
| 3535 | + } |
|
| 3342 | 3536 | |
| 3343 | - if (!empty($_SESSION['ban']['expire_time'])) |
|
| 3344 | - echo ' |
|
| 3537 | + if (!empty($_SESSION['ban']['expire_time'])) { |
|
| 3538 | + echo ' |
|
| 3345 | 3539 | <div>', sprintf($txt['your_ban_expires'], timeformat($_SESSION['ban']['expire_time'], false)), '</div>'; |
| 3346 | - else |
|
| 3347 | - echo ' |
|
| 3540 | + } else { |
|
| 3541 | + echo ' |
|
| 3348 | 3542 | <div>', $txt['your_ban_expires_never'], '</div>'; |
| 3543 | + } |
|
| 3349 | 3544 | |
| 3350 | 3545 | echo ' |
| 3351 | 3546 | </div>'; |
@@ -3361,8 +3556,9 @@ discard block |
||
| 3361 | 3556 | global $forum_copyright, $software_year, $forum_version; |
| 3362 | 3557 | |
| 3363 | 3558 | // Don't display copyright for things like SSI. |
| 3364 | - if (!isset($forum_version) || !isset($software_year)) |
|
| 3365 | - return; |
|
| 3559 | + if (!isset($forum_version) || !isset($software_year)) { |
|
| 3560 | + return; |
|
| 3561 | + } |
|
| 3366 | 3562 | |
| 3367 | 3563 | // Put in the version... |
| 3368 | 3564 | printf($forum_copyright, $forum_version, $software_year); |
@@ -3380,9 +3576,10 @@ discard block |
||
| 3380 | 3576 | $context['load_time'] = comma_format(round(array_sum(explode(' ', microtime())) - array_sum(explode(' ', $time_start)), 3)); |
| 3381 | 3577 | $context['load_queries'] = $db_count; |
| 3382 | 3578 | |
| 3383 | - foreach (array_reverse($context['template_layers']) as $layer) |
|
| 3384 | - loadSubTemplate($layer . '_below', true); |
|
| 3385 | -} |
|
| 3579 | + foreach (array_reverse($context['template_layers']) as $layer) { |
|
| 3580 | + loadSubTemplate($layer . '_below', true); |
|
| 3581 | + } |
|
| 3582 | + } |
|
| 3386 | 3583 | |
| 3387 | 3584 | /** |
| 3388 | 3585 | * Output the Javascript files |
@@ -3413,8 +3610,7 @@ discard block |
||
| 3413 | 3610 | { |
| 3414 | 3611 | echo ' |
| 3415 | 3612 | var ', $key, ';'; |
| 3416 | - } |
|
| 3417 | - else |
|
| 3613 | + } else |
|
| 3418 | 3614 | { |
| 3419 | 3615 | echo ' |
| 3420 | 3616 | var ', $key, ' = ', $value, ';'; |
@@ -3429,26 +3625,27 @@ discard block |
||
| 3429 | 3625 | foreach ($context['javascript_files'] as $id => $js_file) |
| 3430 | 3626 | { |
| 3431 | 3627 | // Last minute call! allow theme authors to disable single files. |
| 3432 | - if (!empty($settings['disable_files']) && in_array($id, $settings['disable_files'])) |
|
| 3433 | - continue; |
|
| 3628 | + if (!empty($settings['disable_files']) && in_array($id, $settings['disable_files'])) { |
|
| 3629 | + continue; |
|
| 3630 | + } |
|
| 3434 | 3631 | |
| 3435 | 3632 | // By default all files don't get minimized unless the file explicitly says so! |
| 3436 | 3633 | if (!empty($js_file['options']['minimize']) && !empty($modSettings['minimize_files'])) |
| 3437 | 3634 | { |
| 3438 | - if ($do_deferred && !empty($js_file['options']['defer'])) |
|
| 3439 | - $toMinifyDefer[] = $js_file; |
|
| 3440 | - |
|
| 3441 | - elseif (!$do_deferred && empty($js_file['options']['defer'])) |
|
| 3442 | - $toMinify[] = $js_file; |
|
| 3635 | + if ($do_deferred && !empty($js_file['options']['defer'])) { |
|
| 3636 | + $toMinifyDefer[] = $js_file; |
|
| 3637 | + } elseif (!$do_deferred && empty($js_file['options']['defer'])) { |
|
| 3638 | + $toMinify[] = $js_file; |
|
| 3639 | + } |
|
| 3443 | 3640 | |
| 3444 | 3641 | // Grab a random seed. |
| 3445 | - if (!isset($minSeed)) |
|
| 3446 | - $minSeed = $js_file['options']['seed']; |
|
| 3447 | - } |
|
| 3448 | - |
|
| 3449 | - elseif ((!$do_deferred && empty($js_file['options']['defer'])) || ($do_deferred && !empty($js_file['options']['defer']))) |
|
| 3450 | - echo ' |
|
| 3642 | + if (!isset($minSeed)) { |
|
| 3643 | + $minSeed = $js_file['options']['seed']; |
|
| 3644 | + } |
|
| 3645 | + } elseif ((!$do_deferred && empty($js_file['options']['defer'])) || ($do_deferred && !empty($js_file['options']['defer']))) { |
|
| 3646 | + echo ' |
|
| 3451 | 3647 | <script src="', $js_file['fileUrl'], '"', !empty($js_file['options']['async']) ? ' async="async"' : '', '></script>'; |
| 3648 | + } |
|
| 3452 | 3649 | } |
| 3453 | 3650 | |
| 3454 | 3651 | if ((!$do_deferred && !empty($toMinify)) || ($do_deferred && !empty($toMinifyDefer))) |
@@ -3456,14 +3653,14 @@ discard block |
||
| 3456 | 3653 | $result = custMinify(($do_deferred ? $toMinifyDefer : $toMinify), 'js', $do_deferred); |
| 3457 | 3654 | |
| 3458 | 3655 | // Minify process couldn't work, print each individual files. |
| 3459 | - if (!empty($result) && is_array($result)) |
|
| 3460 | - foreach ($result as $minFailedFile) |
|
| 3656 | + if (!empty($result) && is_array($result)) { |
|
| 3657 | + foreach ($result as $minFailedFile) |
|
| 3461 | 3658 | echo ' |
| 3462 | 3659 | <script src="', $minFailedFile['fileUrl'], '"', !empty($minFailedFile['options']['async']) ? ' async="async"' : '', '></script>'; |
| 3463 | - |
|
| 3464 | - else |
|
| 3465 | - echo ' |
|
| 3660 | + } else { |
|
| 3661 | + echo ' |
|
| 3466 | 3662 | <script src="', $settings['theme_url'] ,'/scripts/minified', ($do_deferred ? '_deferred' : '') ,'.js', $minSeed ,'"></script>'; |
| 3663 | + } |
|
| 3467 | 3664 | } |
| 3468 | 3665 | |
| 3469 | 3666 | // Inline JavaScript - Actually useful some times! |
@@ -3474,8 +3671,9 @@ discard block |
||
| 3474 | 3671 | echo ' |
| 3475 | 3672 | <script>'; |
| 3476 | 3673 | |
| 3477 | - foreach ($context['javascript_inline']['defer'] as $js_code) |
|
| 3478 | - echo $js_code; |
|
| 3674 | + foreach ($context['javascript_inline']['defer'] as $js_code) { |
|
| 3675 | + echo $js_code; |
|
| 3676 | + } |
|
| 3479 | 3677 | |
| 3480 | 3678 | echo ' |
| 3481 | 3679 | </script>'; |
@@ -3486,8 +3684,9 @@ discard block |
||
| 3486 | 3684 | echo ' |
| 3487 | 3685 | <script>'; |
| 3488 | 3686 | |
| 3489 | - foreach ($context['javascript_inline']['standard'] as $js_code) |
|
| 3490 | - echo $js_code; |
|
| 3687 | + foreach ($context['javascript_inline']['standard'] as $js_code) { |
|
| 3688 | + echo $js_code; |
|
| 3689 | + } |
|
| 3491 | 3690 | |
| 3492 | 3691 | echo ' |
| 3493 | 3692 | </script>'; |
@@ -3512,8 +3711,9 @@ discard block |
||
| 3512 | 3711 | foreach ($context['css_files'] as $id => $file) |
| 3513 | 3712 | { |
| 3514 | 3713 | // Last minute call! allow theme authors to disable single files. |
| 3515 | - if (!empty($settings['disable_files']) && in_array($id, $settings['disable_files'])) |
|
| 3516 | - continue; |
|
| 3714 | + if (!empty($settings['disable_files']) && in_array($id, $settings['disable_files'])) { |
|
| 3715 | + continue; |
|
| 3716 | + } |
|
| 3517 | 3717 | |
| 3518 | 3718 | // By default all files don't get minimized unless the file explicitly says so! |
| 3519 | 3719 | if (!empty($file['options']['minimize']) && !empty($modSettings['minimize_files'])) |
@@ -3521,12 +3721,12 @@ discard block |
||
| 3521 | 3721 | $toMinify[] = $file; |
| 3522 | 3722 | |
| 3523 | 3723 | // Grab a random seed. |
| 3524 | - if (!isset($minSeed)) |
|
| 3525 | - $minSeed = $file['options']['seed']; |
|
| 3724 | + if (!isset($minSeed)) { |
|
| 3725 | + $minSeed = $file['options']['seed']; |
|
| 3726 | + } |
|
| 3727 | + } else { |
|
| 3728 | + $normal[] = $file['fileUrl']; |
|
| 3526 | 3729 | } |
| 3527 | - |
|
| 3528 | - else |
|
| 3529 | - $normal[] = $file['fileUrl']; |
|
| 3530 | 3730 | } |
| 3531 | 3731 | |
| 3532 | 3732 | if (!empty($toMinify)) |
@@ -3534,28 +3734,30 @@ discard block |
||
| 3534 | 3734 | $result = custMinify($toMinify, 'css'); |
| 3535 | 3735 | |
| 3536 | 3736 | // Minify process couldn't work, print each individual files. |
| 3537 | - if (!empty($result) && is_array($result)) |
|
| 3538 | - foreach ($result as $minFailedFile) |
|
| 3737 | + if (!empty($result) && is_array($result)) { |
|
| 3738 | + foreach ($result as $minFailedFile) |
|
| 3539 | 3739 | echo ' |
| 3540 | 3740 | <link rel="stylesheet" href="', $minFailedFile['fileUrl'], '">'; |
| 3541 | - |
|
| 3542 | - else |
|
| 3543 | - echo ' |
|
| 3741 | + } else { |
|
| 3742 | + echo ' |
|
| 3544 | 3743 | <link rel="stylesheet" href="', $settings['theme_url'] ,'/css/minified.css', $minSeed ,'">'; |
| 3744 | + } |
|
| 3545 | 3745 | } |
| 3546 | 3746 | |
| 3547 | 3747 | // Print the rest after the minified files. |
| 3548 | - if (!empty($normal)) |
|
| 3549 | - foreach ($normal as $nf) |
|
| 3748 | + if (!empty($normal)) { |
|
| 3749 | + foreach ($normal as $nf) |
|
| 3550 | 3750 | echo ' |
| 3551 | 3751 | <link rel="stylesheet" href="', $nf ,'">'; |
| 3752 | + } |
|
| 3552 | 3753 | |
| 3553 | 3754 | if ($db_show_debug === true) |
| 3554 | 3755 | { |
| 3555 | 3756 | // Try to keep only what's useful. |
| 3556 | 3757 | $repl = array($boardurl . '/Themes/' => '', $boardurl . '/' => ''); |
| 3557 | - foreach ($context['css_files'] as $file) |
|
| 3558 | - $context['debug']['sheets'][] = strtr($file['fileName'], $repl); |
|
| 3758 | + foreach ($context['css_files'] as $file) { |
|
| 3759 | + $context['debug']['sheets'][] = strtr($file['fileName'], $repl); |
|
| 3760 | + } |
|
| 3559 | 3761 | } |
| 3560 | 3762 | |
| 3561 | 3763 | if (!empty($context['css_header'])) |
@@ -3563,9 +3765,10 @@ discard block |
||
| 3563 | 3765 | echo ' |
| 3564 | 3766 | <style>'; |
| 3565 | 3767 | |
| 3566 | - foreach ($context['css_header'] as $css) |
|
| 3567 | - echo $css .' |
|
| 3768 | + foreach ($context['css_header'] as $css) { |
|
| 3769 | + echo $css .' |
|
| 3568 | 3770 | '; |
| 3771 | + } |
|
| 3569 | 3772 | |
| 3570 | 3773 | echo' |
| 3571 | 3774 | </style>'; |
@@ -3590,15 +3793,17 @@ discard block |
||
| 3590 | 3793 | $data = !empty($data) ? $data : false; |
| 3591 | 3794 | $minFailed = array(); |
| 3592 | 3795 | |
| 3593 | - if (empty($type) || empty($data)) |
|
| 3594 | - return false; |
|
| 3796 | + if (empty($type) || empty($data)) { |
|
| 3797 | + return false; |
|
| 3798 | + } |
|
| 3595 | 3799 | |
| 3596 | 3800 | // Did we already did this? |
| 3597 | 3801 | $toCache = cache_get_data('minimized_'. $settings['theme_id'] .'_'. $type, 86400); |
| 3598 | 3802 | |
| 3599 | 3803 | // Already done? |
| 3600 | - if (!empty($toCache)) |
|
| 3601 | - return true; |
|
| 3804 | + if (!empty($toCache)) { |
|
| 3805 | + return true; |
|
| 3806 | + } |
|
| 3602 | 3807 | |
| 3603 | 3808 | // Yep, need a bunch of files. |
| 3604 | 3809 | require_once($sourcedir . '/minify/src/Minify.php'); |
@@ -3686,8 +3891,9 @@ discard block |
||
| 3686 | 3891 | global $modSettings, $smcFunc; |
| 3687 | 3892 | |
| 3688 | 3893 | // Just make up a nice hash... |
| 3689 | - if ($new) |
|
| 3690 | - return sha1(md5($filename . time()) . mt_rand()); |
|
| 3894 | + if ($new) { |
|
| 3895 | + return sha1(md5($filename . time()) . mt_rand()); |
|
| 3896 | + } |
|
| 3691 | 3897 | |
| 3692 | 3898 | // Grab the file hash if it wasn't added. |
| 3693 | 3899 | // Left this for legacy. |
@@ -3701,23 +3907,25 @@ discard block |
||
| 3701 | 3907 | 'id_attach' => $attachment_id, |
| 3702 | 3908 | )); |
| 3703 | 3909 | |
| 3704 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
| 3705 | - return false; |
|
| 3910 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
| 3911 | + return false; |
|
| 3912 | + } |
|
| 3706 | 3913 | |
| 3707 | 3914 | list ($file_hash) = $smcFunc['db_fetch_row']($request); |
| 3708 | 3915 | $smcFunc['db_free_result']($request); |
| 3709 | 3916 | } |
| 3710 | 3917 | |
| 3711 | 3918 | // Still no hash? mmm... |
| 3712 | - if (empty($file_hash)) |
|
| 3713 | - $file_hash = sha1(md5($filename . time()) . mt_rand()); |
|
| 3919 | + if (empty($file_hash)) { |
|
| 3920 | + $file_hash = sha1(md5($filename . time()) . mt_rand()); |
|
| 3921 | + } |
|
| 3714 | 3922 | |
| 3715 | 3923 | // Are we using multiple directories? |
| 3716 | - if (!empty($modSettings['currentAttachmentUploadDir'])) |
|
| 3717 | - $path = $modSettings['attachmentUploadDir'][$dir]; |
|
| 3718 | - |
|
| 3719 | - else |
|
| 3720 | - $path = $modSettings['attachmentUploadDir']; |
|
| 3924 | + if (!empty($modSettings['currentAttachmentUploadDir'])) { |
|
| 3925 | + $path = $modSettings['attachmentUploadDir'][$dir]; |
|
| 3926 | + } else { |
|
| 3927 | + $path = $modSettings['attachmentUploadDir']; |
|
| 3928 | + } |
|
| 3721 | 3929 | |
| 3722 | 3930 | return $path . '/' . $attachment_id . '_' . $file_hash .'.dat'; |
| 3723 | 3931 | } |
@@ -3732,8 +3940,9 @@ discard block |
||
| 3732 | 3940 | function ip2range($fullip) |
| 3733 | 3941 | { |
| 3734 | 3942 | // Pretend that 'unknown' is 255.255.255.255. (since that can't be an IP anyway.) |
| 3735 | - if ($fullip == 'unknown') |
|
| 3736 | - $fullip = '255.255.255.255'; |
|
| 3943 | + if ($fullip == 'unknown') { |
|
| 3944 | + $fullip = '255.255.255.255'; |
|
| 3945 | + } |
|
| 3737 | 3946 | |
| 3738 | 3947 | $ip_parts = explode('-', $fullip); |
| 3739 | 3948 | $ip_array = array(); |
@@ -3757,10 +3966,11 @@ discard block |
||
| 3757 | 3966 | $ip_array['low'] = $ip_parts[0]; |
| 3758 | 3967 | $ip_array['high'] = $ip_parts[1]; |
| 3759 | 3968 | return $ip_array; |
| 3760 | - } |
|
| 3761 | - elseif (count($ip_parts) == 2) // if ip 22.22.*-22.22.* |
|
| 3969 | + } elseif (count($ip_parts) == 2) { |
|
| 3970 | + // if ip 22.22.*-22.22.* |
|
| 3762 | 3971 | { |
| 3763 | 3972 | $valid_low = isValidIP($ip_parts[0]); |
| 3973 | + } |
|
| 3764 | 3974 | $valid_high = isValidIP($ip_parts[1]); |
| 3765 | 3975 | $count = 0; |
| 3766 | 3976 | $mode = (preg_match('/:/',$ip_parts[0]) > 0 ? ':' : '.'); |
@@ -3775,7 +3985,9 @@ discard block |
||
| 3775 | 3985 | $ip_parts[0] .= $mode . $min; |
| 3776 | 3986 | $valid_low = isValidIP($ip_parts[0]); |
| 3777 | 3987 | $count++; |
| 3778 | - if ($count > 9) break; |
|
| 3988 | + if ($count > 9) { |
|
| 3989 | + break; |
|
| 3990 | + } |
|
| 3779 | 3991 | } |
| 3780 | 3992 | } |
| 3781 | 3993 | |
@@ -3789,7 +4001,9 @@ discard block |
||
| 3789 | 4001 | $ip_parts[1] .= $mode . $max; |
| 3790 | 4002 | $valid_high = isValidIP($ip_parts[1]); |
| 3791 | 4003 | $count++; |
| 3792 | - if ($count > 9) break; |
|
| 4004 | + if ($count > 9) { |
|
| 4005 | + break; |
|
| 4006 | + } |
|
| 3793 | 4007 | } |
| 3794 | 4008 | } |
| 3795 | 4009 | |
@@ -3814,46 +4028,54 @@ discard block |
||
| 3814 | 4028 | { |
| 3815 | 4029 | global $modSettings; |
| 3816 | 4030 | |
| 3817 | - if (($host = cache_get_data('hostlookup-' . $ip, 600)) !== null) |
|
| 3818 | - return $host; |
|
| 4031 | + if (($host = cache_get_data('hostlookup-' . $ip, 600)) !== null) { |
|
| 4032 | + return $host; |
|
| 4033 | + } |
|
| 3819 | 4034 | $t = microtime(); |
| 3820 | 4035 | |
| 3821 | 4036 | // Try the Linux host command, perhaps? |
| 3822 | 4037 | if (!isset($host) && (strpos(strtolower(PHP_OS), 'win') === false || strpos(strtolower(PHP_OS), 'darwin') !== false) && mt_rand(0, 1) == 1) |
| 3823 | 4038 | { |
| 3824 | - if (!isset($modSettings['host_to_dis'])) |
|
| 3825 | - $test = @shell_exec('host -W 1 ' . @escapeshellarg($ip)); |
|
| 3826 | - else |
|
| 3827 | - $test = @shell_exec('host ' . @escapeshellarg($ip)); |
|
| 4039 | + if (!isset($modSettings['host_to_dis'])) { |
|
| 4040 | + $test = @shell_exec('host -W 1 ' . @escapeshellarg($ip)); |
|
| 4041 | + } else { |
|
| 4042 | + $test = @shell_exec('host ' . @escapeshellarg($ip)); |
|
| 4043 | + } |
|
| 3828 | 4044 | |
| 3829 | 4045 | // Did host say it didn't find anything? |
| 3830 | - if (strpos($test, 'not found') !== false) |
|
| 3831 | - $host = ''; |
|
| 4046 | + if (strpos($test, 'not found') !== false) { |
|
| 4047 | + $host = ''; |
|
| 4048 | + } |
|
| 3832 | 4049 | // Invalid server option? |
| 3833 | - elseif ((strpos($test, 'invalid option') || strpos($test, 'Invalid query name 1')) && !isset($modSettings['host_to_dis'])) |
|
| 3834 | - updateSettings(array('host_to_dis' => 1)); |
|
| 4050 | + elseif ((strpos($test, 'invalid option') || strpos($test, 'Invalid query name 1')) && !isset($modSettings['host_to_dis'])) { |
|
| 4051 | + updateSettings(array('host_to_dis' => 1)); |
|
| 4052 | + } |
|
| 3835 | 4053 | // Maybe it found something, after all? |
| 3836 | - elseif (preg_match('~\s([^\s]+?)\.\s~', $test, $match) == 1) |
|
| 3837 | - $host = $match[1]; |
|
| 4054 | + elseif (preg_match('~\s([^\s]+?)\.\s~', $test, $match) == 1) { |
|
| 4055 | + $host = $match[1]; |
|
| 4056 | + } |
|
| 3838 | 4057 | } |
| 3839 | 4058 | |
| 3840 | 4059 | // This is nslookup; usually only Windows, but possibly some Unix? |
| 3841 | 4060 | if (!isset($host) && stripos(PHP_OS, 'win') !== false && strpos(strtolower(PHP_OS), 'darwin') === false && mt_rand(0, 1) == 1) |
| 3842 | 4061 | { |
| 3843 | 4062 | $test = @shell_exec('nslookup -timeout=1 ' . @escapeshellarg($ip)); |
| 3844 | - if (strpos($test, 'Non-existent domain') !== false) |
|
| 3845 | - $host = ''; |
|
| 3846 | - elseif (preg_match('~Name:\s+([^\s]+)~', $test, $match) == 1) |
|
| 3847 | - $host = $match[1]; |
|
| 4063 | + if (strpos($test, 'Non-existent domain') !== false) { |
|
| 4064 | + $host = ''; |
|
| 4065 | + } elseif (preg_match('~Name:\s+([^\s]+)~', $test, $match) == 1) { |
|
| 4066 | + $host = $match[1]; |
|
| 4067 | + } |
|
| 3848 | 4068 | } |
| 3849 | 4069 | |
| 3850 | 4070 | // This is the last try :/. |
| 3851 | - if (!isset($host) || $host === false) |
|
| 3852 | - $host = @gethostbyaddr($ip); |
|
| 4071 | + if (!isset($host) || $host === false) { |
|
| 4072 | + $host = @gethostbyaddr($ip); |
|
| 4073 | + } |
|
| 3853 | 4074 | |
| 3854 | 4075 | // It took a long time, so let's cache it! |
| 3855 | - if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $t)) > 0.5) |
|
| 3856 | - cache_put_data('hostlookup-' . $ip, $host, 600); |
|
| 4076 | + if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $t)) > 0.5) { |
|
| 4077 | + cache_put_data('hostlookup-' . $ip, $host, 600); |
|
| 4078 | + } |
|
| 3857 | 4079 | |
| 3858 | 4080 | return $host; |
| 3859 | 4081 | } |
@@ -3889,20 +4111,21 @@ discard block |
||
| 3889 | 4111 | { |
| 3890 | 4112 | $encrypted = substr(crypt($word, 'uk'), 2, $max_chars); |
| 3891 | 4113 | $total = 0; |
| 3892 | - for ($i = 0; $i < $max_chars; $i++) |
|
| 3893 | - $total += $possible_chars[ord($encrypted{$i})] * pow(63, $i); |
|
| 4114 | + for ($i = 0; $i < $max_chars; $i++) { |
|
| 4115 | + $total += $possible_chars[ord($encrypted{$i})] * pow(63, $i); |
|
| 4116 | + } |
|
| 3894 | 4117 | $returned_ints[] = $max_chars == 4 ? min($total, 16777215) : $total; |
| 3895 | 4118 | } |
| 3896 | 4119 | } |
| 3897 | 4120 | return array_unique($returned_ints); |
| 3898 | - } |
|
| 3899 | - else |
|
| 4121 | + } else |
|
| 3900 | 4122 | { |
| 3901 | 4123 | // Trim characters before and after and add slashes for database insertion. |
| 3902 | 4124 | $returned_words = array(); |
| 3903 | - foreach ($words as $word) |
|
| 3904 | - if (($word = trim($word, '-_\'')) !== '') |
|
| 4125 | + foreach ($words as $word) { |
|
| 4126 | + if (($word = trim($word, '-_\'')) !== '') |
|
| 3905 | 4127 | $returned_words[] = $max_chars === null ? $word : substr($word, 0, $max_chars); |
| 4128 | + } |
|
| 3906 | 4129 | |
| 3907 | 4130 | // Filter out all words that occur more than once. |
| 3908 | 4131 | return array_unique($returned_words); |
@@ -3924,16 +4147,18 @@ discard block |
||
| 3924 | 4147 | global $settings, $txt; |
| 3925 | 4148 | |
| 3926 | 4149 | // Does the current loaded theme have this and we are not forcing the usage of this function? |
| 3927 | - if (function_exists('template_create_button') && !$force_use) |
|
| 3928 | - return template_create_button($name, $alt, $label = '', $custom = ''); |
|
| 4150 | + if (function_exists('template_create_button') && !$force_use) { |
|
| 4151 | + return template_create_button($name, $alt, $label = '', $custom = ''); |
|
| 4152 | + } |
|
| 3929 | 4153 | |
| 3930 | - if (!$settings['use_image_buttons']) |
|
| 3931 | - return $txt[$alt]; |
|
| 3932 | - elseif (!empty($settings['use_buttons'])) |
|
| 3933 | - return '<span class="generic_icons ' . $name . '" alt="' . $txt[$alt] . '"></span>' . ($label != '' ? ' <strong>' . $txt[$label] . '</strong>' : ''); |
|
| 3934 | - else |
|
| 3935 | - return '<img src="' . $settings['lang_images_url'] . '/' . $name . '" alt="' . $txt[$alt] . '" ' . $custom . '>'; |
|
| 3936 | -} |
|
| 4154 | + if (!$settings['use_image_buttons']) { |
|
| 4155 | + return $txt[$alt]; |
|
| 4156 | + } elseif (!empty($settings['use_buttons'])) { |
|
| 4157 | + return '<span class="generic_icons ' . $name . '" alt="' . $txt[$alt] . '"></span>' . ($label != '' ? ' <strong>' . $txt[$label] . '</strong>' : ''); |
|
| 4158 | + } else { |
|
| 4159 | + return '<img src="' . $settings['lang_images_url'] . '/' . $name . '" alt="' . $txt[$alt] . '" ' . $custom . '>'; |
|
| 4160 | + } |
|
| 4161 | + } |
|
| 3937 | 4162 | |
| 3938 | 4163 | /** |
| 3939 | 4164 | * Sets up all of the top menu buttons |
@@ -3976,9 +4201,10 @@ discard block |
||
| 3976 | 4201 | var user_menus = new smc_PopupMenu(); |
| 3977 | 4202 | user_menus.add("profile", "' . $scripturl . '?action=profile;area=popup"); |
| 3978 | 4203 | user_menus.add("alerts", "' . $scripturl . '?action=profile;area=alerts_popup;u='. $context['user']['id'] .'");', true); |
| 3979 | - if ($context['allow_pm']) |
|
| 3980 | - addInlineJavaScript(' |
|
| 4204 | + if ($context['allow_pm']) { |
|
| 4205 | + addInlineJavaScript(' |
|
| 3981 | 4206 | user_menus.add("pm", "' . $scripturl . '?action=pm;sa=popup");', true); |
| 4207 | + } |
|
| 3982 | 4208 | |
| 3983 | 4209 | if (!empty($modSettings['enable_ajax_alerts'])) |
| 3984 | 4210 | { |
@@ -4138,88 +4364,96 @@ discard block |
||
| 4138 | 4364 | |
| 4139 | 4365 | // Now we put the buttons in the context so the theme can use them. |
| 4140 | 4366 | $menu_buttons = array(); |
| 4141 | - foreach ($buttons as $act => $button) |
|
| 4142 | - if (!empty($button['show'])) |
|
| 4367 | + foreach ($buttons as $act => $button) { |
|
| 4368 | + if (!empty($button['show'])) |
|
| 4143 | 4369 | { |
| 4144 | 4370 | $button['active_button'] = false; |
| 4371 | + } |
|
| 4145 | 4372 | |
| 4146 | 4373 | // This button needs some action. |
| 4147 | - if (isset($button['action_hook'])) |
|
| 4148 | - $needs_action_hook = true; |
|
| 4374 | + if (isset($button['action_hook'])) { |
|
| 4375 | + $needs_action_hook = true; |
|
| 4376 | + } |
|
| 4149 | 4377 | |
| 4150 | 4378 | // Make sure the last button truly is the last button. |
| 4151 | 4379 | if (!empty($button['is_last'])) |
| 4152 | 4380 | { |
| 4153 | - if (isset($last_button)) |
|
| 4154 | - unset($menu_buttons[$last_button]['is_last']); |
|
| 4381 | + if (isset($last_button)) { |
|
| 4382 | + unset($menu_buttons[$last_button]['is_last']); |
|
| 4383 | + } |
|
| 4155 | 4384 | $last_button = $act; |
| 4156 | 4385 | } |
| 4157 | 4386 | |
| 4158 | 4387 | // Go through the sub buttons if there are any. |
| 4159 | - if (!empty($button['sub_buttons'])) |
|
| 4160 | - foreach ($button['sub_buttons'] as $key => $subbutton) |
|
| 4388 | + if (!empty($button['sub_buttons'])) { |
|
| 4389 | + foreach ($button['sub_buttons'] as $key => $subbutton) |
|
| 4161 | 4390 | { |
| 4162 | 4391 | if (empty($subbutton['show'])) |
| 4163 | 4392 | unset($button['sub_buttons'][$key]); |
| 4393 | + } |
|
| 4164 | 4394 | |
| 4165 | 4395 | // 2nd level sub buttons next... |
| 4166 | 4396 | if (!empty($subbutton['sub_buttons'])) |
| 4167 | 4397 | { |
| 4168 | 4398 | foreach ($subbutton['sub_buttons'] as $key2 => $sub_button2) |
| 4169 | 4399 | { |
| 4170 | - if (empty($sub_button2['show'])) |
|
| 4171 | - unset($button['sub_buttons'][$key]['sub_buttons'][$key2]); |
|
| 4400 | + if (empty($sub_button2['show'])) { |
|
| 4401 | + unset($button['sub_buttons'][$key]['sub_buttons'][$key2]); |
|
| 4402 | + } |
|
| 4172 | 4403 | } |
| 4173 | 4404 | } |
| 4174 | 4405 | } |
| 4175 | 4406 | |
| 4176 | 4407 | // Does this button have its own icon? |
| 4177 | - if (isset($button['icon']) && file_exists($settings['theme_dir'] . '/images/' . $button['icon'])) |
|
| 4178 | - $button['icon'] = '<img src="' . $settings['images_url'] . '/' . $button['icon'] . '" alt="">'; |
|
| 4179 | - elseif (isset($button['icon']) && file_exists($settings['default_theme_dir'] . '/images/' . $button['icon'])) |
|
| 4180 | - $button['icon'] = '<img src="' . $settings['default_images_url'] . '/' . $button['icon'] . '" alt="">'; |
|
| 4181 | - elseif (isset($button['icon'])) |
|
| 4182 | - $button['icon'] = '<span class="generic_icons ' . $button['icon'] . '"></span>'; |
|
| 4183 | - else |
|
| 4184 | - $button['icon'] = '<span class="generic_icons ' . $act . '"></span>'; |
|
| 4408 | + if (isset($button['icon']) && file_exists($settings['theme_dir'] . '/images/' . $button['icon'])) { |
|
| 4409 | + $button['icon'] = '<img src="' . $settings['images_url'] . '/' . $button['icon'] . '" alt="">'; |
|
| 4410 | + } elseif (isset($button['icon']) && file_exists($settings['default_theme_dir'] . '/images/' . $button['icon'])) { |
|
| 4411 | + $button['icon'] = '<img src="' . $settings['default_images_url'] . '/' . $button['icon'] . '" alt="">'; |
|
| 4412 | + } elseif (isset($button['icon'])) { |
|
| 4413 | + $button['icon'] = '<span class="generic_icons ' . $button['icon'] . '"></span>'; |
|
| 4414 | + } else { |
|
| 4415 | + $button['icon'] = '<span class="generic_icons ' . $act . '"></span>'; |
|
| 4416 | + } |
|
| 4185 | 4417 | |
| 4186 | 4418 | $menu_buttons[$act] = $button; |
| 4187 | 4419 | } |
| 4188 | 4420 | |
| 4189 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
| 4190 | - cache_put_data('menu_buttons-' . implode('_', $user_info['groups']) . '-' . $user_info['language'], $menu_buttons, $cacheTime); |
|
| 4421 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
| 4422 | + cache_put_data('menu_buttons-' . implode('_', $user_info['groups']) . '-' . $user_info['language'], $menu_buttons, $cacheTime); |
|
| 4423 | + } |
|
| 4191 | 4424 | } |
| 4192 | 4425 | |
| 4193 | 4426 | $context['menu_buttons'] = $menu_buttons; |
| 4194 | 4427 | |
| 4195 | 4428 | // Logging out requires the session id in the url. |
| 4196 | - if (isset($context['menu_buttons']['logout'])) |
|
| 4197 | - $context['menu_buttons']['logout']['href'] = sprintf($context['menu_buttons']['logout']['href'], $context['session_var'], $context['session_id']); |
|
| 4429 | + if (isset($context['menu_buttons']['logout'])) { |
|
| 4430 | + $context['menu_buttons']['logout']['href'] = sprintf($context['menu_buttons']['logout']['href'], $context['session_var'], $context['session_id']); |
|
| 4431 | + } |
|
| 4198 | 4432 | |
| 4199 | 4433 | // Figure out which action we are doing so we can set the active tab. |
| 4200 | 4434 | // Default to home. |
| 4201 | 4435 | $current_action = 'home'; |
| 4202 | 4436 | |
| 4203 | - if (isset($context['menu_buttons'][$context['current_action']])) |
|
| 4204 | - $current_action = $context['current_action']; |
|
| 4205 | - elseif ($context['current_action'] == 'search2') |
|
| 4206 | - $current_action = 'search'; |
|
| 4207 | - elseif ($context['current_action'] == 'theme') |
|
| 4208 | - $current_action = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'pick' ? 'profile' : 'admin'; |
|
| 4209 | - elseif ($context['current_action'] == 'register2') |
|
| 4210 | - $current_action = 'register'; |
|
| 4211 | - elseif ($context['current_action'] == 'login2' || ($user_info['is_guest'] && $context['current_action'] == 'reminder')) |
|
| 4212 | - $current_action = 'login'; |
|
| 4213 | - elseif ($context['current_action'] == 'groups' && $context['allow_moderation_center']) |
|
| 4214 | - $current_action = 'moderate'; |
|
| 4437 | + if (isset($context['menu_buttons'][$context['current_action']])) { |
|
| 4438 | + $current_action = $context['current_action']; |
|
| 4439 | + } elseif ($context['current_action'] == 'search2') { |
|
| 4440 | + $current_action = 'search'; |
|
| 4441 | + } elseif ($context['current_action'] == 'theme') { |
|
| 4442 | + $current_action = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'pick' ? 'profile' : 'admin'; |
|
| 4443 | + } elseif ($context['current_action'] == 'register2') { |
|
| 4444 | + $current_action = 'register'; |
|
| 4445 | + } elseif ($context['current_action'] == 'login2' || ($user_info['is_guest'] && $context['current_action'] == 'reminder')) { |
|
| 4446 | + $current_action = 'login'; |
|
| 4447 | + } elseif ($context['current_action'] == 'groups' && $context['allow_moderation_center']) { |
|
| 4448 | + $current_action = 'moderate'; |
|
| 4449 | + } |
|
| 4215 | 4450 | |
| 4216 | 4451 | // There are certain exceptions to the above where we don't want anything on the menu highlighted. |
| 4217 | 4452 | if ($context['current_action'] == 'profile' && !empty($context['user']['is_owner'])) |
| 4218 | 4453 | { |
| 4219 | 4454 | $current_action = !empty($_GET['area']) && $_GET['area'] == 'showalerts' ? 'self_alerts' : 'self_profile'; |
| 4220 | 4455 | $context[$current_action] = true; |
| 4221 | - } |
|
| 4222 | - elseif ($context['current_action'] == 'pm') |
|
| 4456 | + } elseif ($context['current_action'] == 'pm') |
|
| 4223 | 4457 | { |
| 4224 | 4458 | $current_action = 'self_pm'; |
| 4225 | 4459 | $context['self_pm'] = true; |
@@ -4262,12 +4496,14 @@ discard block |
||
| 4262 | 4496 | } |
| 4263 | 4497 | |
| 4264 | 4498 | // Not all actions are simple. |
| 4265 | - if (!empty($needs_action_hook)) |
|
| 4266 | - call_integration_hook('integrate_current_action', array(&$current_action)); |
|
| 4499 | + if (!empty($needs_action_hook)) { |
|
| 4500 | + call_integration_hook('integrate_current_action', array(&$current_action)); |
|
| 4501 | + } |
|
| 4267 | 4502 | |
| 4268 | - if (isset($context['menu_buttons'][$current_action])) |
|
| 4269 | - $context['menu_buttons'][$current_action]['active_button'] = true; |
|
| 4270 | -} |
|
| 4503 | + if (isset($context['menu_buttons'][$current_action])) { |
|
| 4504 | + $context['menu_buttons'][$current_action]['active_button'] = true; |
|
| 4505 | + } |
|
| 4506 | + } |
|
| 4271 | 4507 | |
| 4272 | 4508 | /** |
| 4273 | 4509 | * Generate a random seed and ensure it's stored in settings. |
@@ -4291,16 +4527,19 @@ discard block |
||
| 4291 | 4527 | global $modSettings, $settings, $boarddir, $sourcedir, $db_show_debug; |
| 4292 | 4528 | global $context, $txt; |
| 4293 | 4529 | |
| 4294 | - if ($db_show_debug === true) |
|
| 4295 | - $context['debug']['hooks'][] = $hook; |
|
| 4530 | + if ($db_show_debug === true) { |
|
| 4531 | + $context['debug']['hooks'][] = $hook; |
|
| 4532 | + } |
|
| 4296 | 4533 | |
| 4297 | 4534 | // Need to have some control. |
| 4298 | - if (!isset($context['instances'])) |
|
| 4299 | - $context['instances'] = array(); |
|
| 4535 | + if (!isset($context['instances'])) { |
|
| 4536 | + $context['instances'] = array(); |
|
| 4537 | + } |
|
| 4300 | 4538 | |
| 4301 | 4539 | $results = array(); |
| 4302 | - if (empty($modSettings[$hook])) |
|
| 4303 | - return $results; |
|
| 4540 | + if (empty($modSettings[$hook])) { |
|
| 4541 | + return $results; |
|
| 4542 | + } |
|
| 4304 | 4543 | |
| 4305 | 4544 | // Define some needed vars. |
| 4306 | 4545 | $function = false; |
@@ -4310,14 +4549,16 @@ discard block |
||
| 4310 | 4549 | foreach ($functions as $function) |
| 4311 | 4550 | { |
| 4312 | 4551 | // Hook has been marked as "disabled". Skip it! |
| 4313 | - if (strpos($function, '!') !== false) |
|
| 4314 | - continue; |
|
| 4552 | + if (strpos($function, '!') !== false) { |
|
| 4553 | + continue; |
|
| 4554 | + } |
|
| 4315 | 4555 | |
| 4316 | 4556 | $call = call_helper($function, true); |
| 4317 | 4557 | |
| 4318 | 4558 | // Is it valid? |
| 4319 | - if (!empty($call)) |
|
| 4320 | - $results[$function] = call_user_func_array($call, $parameters); |
|
| 4559 | + if (!empty($call)) { |
|
| 4560 | + $results[$function] = call_user_func_array($call, $parameters); |
|
| 4561 | + } |
|
| 4321 | 4562 | |
| 4322 | 4563 | // Whatever it was suppose to call, it failed :( |
| 4323 | 4564 | elseif (!empty($function)) |
@@ -4333,8 +4574,9 @@ discard block |
||
| 4333 | 4574 | } |
| 4334 | 4575 | |
| 4335 | 4576 | // "Assume" the file resides on $boarddir somewhere... |
| 4336 | - else |
|
| 4337 | - log_error(sprintf($txt['hook_fail_call_to'], $function, $boarddir), 'general'); |
|
| 4577 | + else { |
|
| 4578 | + log_error(sprintf($txt['hook_fail_call_to'], $function, $boarddir), 'general'); |
|
| 4579 | + } |
|
| 4338 | 4580 | } |
| 4339 | 4581 | } |
| 4340 | 4582 | |
@@ -4356,12 +4598,14 @@ discard block |
||
| 4356 | 4598 | global $smcFunc, $modSettings; |
| 4357 | 4599 | |
| 4358 | 4600 | // Any objects? |
| 4359 | - if ($object) |
|
| 4360 | - $function = $function . '#'; |
|
| 4601 | + if ($object) { |
|
| 4602 | + $function = $function . '#'; |
|
| 4603 | + } |
|
| 4361 | 4604 | |
| 4362 | 4605 | // Any files to load? |
| 4363 | - if (!empty($file) && is_string($file)) |
|
| 4364 | - $function = $file . (!empty($function) ? '|' . $function : ''); |
|
| 4606 | + if (!empty($file) && is_string($file)) { |
|
| 4607 | + $function = $file . (!empty($function) ? '|' . $function : ''); |
|
| 4608 | + } |
|
| 4365 | 4609 | |
| 4366 | 4610 | // Get the correct string. |
| 4367 | 4611 | $integration_call = $function; |
@@ -4383,13 +4627,14 @@ discard block |
||
| 4383 | 4627 | if (!empty($current_functions)) |
| 4384 | 4628 | { |
| 4385 | 4629 | $current_functions = explode(',', $current_functions); |
| 4386 | - if (in_array($integration_call, $current_functions)) |
|
| 4387 | - return; |
|
| 4630 | + if (in_array($integration_call, $current_functions)) { |
|
| 4631 | + return; |
|
| 4632 | + } |
|
| 4388 | 4633 | |
| 4389 | 4634 | $permanent_functions = array_merge($current_functions, array($integration_call)); |
| 4635 | + } else { |
|
| 4636 | + $permanent_functions = array($integration_call); |
|
| 4390 | 4637 | } |
| 4391 | - else |
|
| 4392 | - $permanent_functions = array($integration_call); |
|
| 4393 | 4638 | |
| 4394 | 4639 | updateSettings(array($hook => implode(',', $permanent_functions))); |
| 4395 | 4640 | } |
@@ -4398,8 +4643,9 @@ discard block |
||
| 4398 | 4643 | $functions = empty($modSettings[$hook]) ? array() : explode(',', $modSettings[$hook]); |
| 4399 | 4644 | |
| 4400 | 4645 | // Do nothing, if it's already there. |
| 4401 | - if (in_array($integration_call, $functions)) |
|
| 4402 | - return; |
|
| 4646 | + if (in_array($integration_call, $functions)) { |
|
| 4647 | + return; |
|
| 4648 | + } |
|
| 4403 | 4649 | |
| 4404 | 4650 | $functions[] = $integration_call; |
| 4405 | 4651 | $modSettings[$hook] = implode(',', $functions); |
@@ -4422,12 +4668,14 @@ discard block |
||
| 4422 | 4668 | global $smcFunc, $modSettings; |
| 4423 | 4669 | |
| 4424 | 4670 | // Any objects? |
| 4425 | - if ($object) |
|
| 4426 | - $function = $function . '#'; |
|
| 4671 | + if ($object) { |
|
| 4672 | + $function = $function . '#'; |
|
| 4673 | + } |
|
| 4427 | 4674 | |
| 4428 | 4675 | // Any files to load? |
| 4429 | - if (!empty($file) && is_string($file)) |
|
| 4430 | - $function = $file . '|' . $function; |
|
| 4676 | + if (!empty($file) && is_string($file)) { |
|
| 4677 | + $function = $file . '|' . $function; |
|
| 4678 | + } |
|
| 4431 | 4679 | |
| 4432 | 4680 | // Get the correct string. |
| 4433 | 4681 | $integration_call = $function; |
@@ -4448,16 +4696,18 @@ discard block |
||
| 4448 | 4696 | { |
| 4449 | 4697 | $current_functions = explode(',', $current_functions); |
| 4450 | 4698 | |
| 4451 | - if (in_array($integration_call, $current_functions)) |
|
| 4452 | - updateSettings(array($hook => implode(',', array_diff($current_functions, array($integration_call))))); |
|
| 4699 | + if (in_array($integration_call, $current_functions)) { |
|
| 4700 | + updateSettings(array($hook => implode(',', array_diff($current_functions, array($integration_call))))); |
|
| 4701 | + } |
|
| 4453 | 4702 | } |
| 4454 | 4703 | |
| 4455 | 4704 | // Turn the function list into something usable. |
| 4456 | 4705 | $functions = empty($modSettings[$hook]) ? array() : explode(',', $modSettings[$hook]); |
| 4457 | 4706 | |
| 4458 | 4707 | // You can only remove it if it's available. |
| 4459 | - if (!in_array($integration_call, $functions)) |
|
| 4460 | - return; |
|
| 4708 | + if (!in_array($integration_call, $functions)) { |
|
| 4709 | + return; |
|
| 4710 | + } |
|
| 4461 | 4711 | |
| 4462 | 4712 | $functions = array_diff($functions, array($integration_call)); |
| 4463 | 4713 | $modSettings[$hook] = implode(',', $functions); |
@@ -4478,17 +4728,20 @@ discard block |
||
| 4478 | 4728 | global $context, $smcFunc, $txt, $db_show_debug; |
| 4479 | 4729 | |
| 4480 | 4730 | // Really? |
| 4481 | - if (empty($string)) |
|
| 4482 | - return false; |
|
| 4731 | + if (empty($string)) { |
|
| 4732 | + return false; |
|
| 4733 | + } |
|
| 4483 | 4734 | |
| 4484 | 4735 | // An array? should be a "callable" array IE array(object/class, valid_callable). |
| 4485 | 4736 | // A closure? should be a callable one. |
| 4486 | - if (is_array($string) || $string instanceof Closure) |
|
| 4487 | - return $return ? $string : (is_callable($string) ? call_user_func($string) : false); |
|
| 4737 | + if (is_array($string) || $string instanceof Closure) { |
|
| 4738 | + return $return ? $string : (is_callable($string) ? call_user_func($string) : false); |
|
| 4739 | + } |
|
| 4488 | 4740 | |
| 4489 | 4741 | // No full objects, sorry! pass a method or a property instead! |
| 4490 | - if (is_object($string)) |
|
| 4491 | - return false; |
|
| 4742 | + if (is_object($string)) { |
|
| 4743 | + return false; |
|
| 4744 | + } |
|
| 4492 | 4745 | |
| 4493 | 4746 | // Stay vitaminized my friends... |
| 4494 | 4747 | $string = $smcFunc['htmlspecialchars']($smcFunc['htmltrim']($string)); |
@@ -4500,8 +4753,9 @@ discard block |
||
| 4500 | 4753 | $string = load_file($string); |
| 4501 | 4754 | |
| 4502 | 4755 | // Loaded file failed |
| 4503 | - if (empty($string)) |
|
| 4504 | - return false; |
|
| 4756 | + if (empty($string)) { |
|
| 4757 | + return false; |
|
| 4758 | + } |
|
| 4505 | 4759 | |
| 4506 | 4760 | // Found a method. |
| 4507 | 4761 | if (strpos($string, '::') !== false) |
@@ -4522,8 +4776,9 @@ discard block |
||
| 4522 | 4776 | // Add another one to the list. |
| 4523 | 4777 | if ($db_show_debug === true) |
| 4524 | 4778 | { |
| 4525 | - if (!isset($context['debug']['instances'])) |
|
| 4526 | - $context['debug']['instances'] = array(); |
|
| 4779 | + if (!isset($context['debug']['instances'])) { |
|
| 4780 | + $context['debug']['instances'] = array(); |
|
| 4781 | + } |
|
| 4527 | 4782 | |
| 4528 | 4783 | $context['debug']['instances'][$class] = $class; |
| 4529 | 4784 | } |
@@ -4533,13 +4788,15 @@ discard block |
||
| 4533 | 4788 | } |
| 4534 | 4789 | |
| 4535 | 4790 | // Right then. This is a call to a static method. |
| 4536 | - else |
|
| 4537 | - $func = array($class, $method); |
|
| 4791 | + else { |
|
| 4792 | + $func = array($class, $method); |
|
| 4793 | + } |
|
| 4538 | 4794 | } |
| 4539 | 4795 | |
| 4540 | 4796 | // Nope! just a plain regular function. |
| 4541 | - else |
|
| 4542 | - $func = $string; |
|
| 4797 | + else { |
|
| 4798 | + $func = $string; |
|
| 4799 | + } |
|
| 4543 | 4800 | |
| 4544 | 4801 | // Right, we got what we need, time to do some checks. |
| 4545 | 4802 | if (!is_callable($func, false, $callable_name)) |
@@ -4555,17 +4812,18 @@ discard block |
||
| 4555 | 4812 | else |
| 4556 | 4813 | { |
| 4557 | 4814 | // What are we gonna do about it? |
| 4558 | - if ($return) |
|
| 4559 | - return $func; |
|
| 4815 | + if ($return) { |
|
| 4816 | + return $func; |
|
| 4817 | + } |
|
| 4560 | 4818 | |
| 4561 | 4819 | // If this is a plain function, avoid the heat of calling call_user_func(). |
| 4562 | 4820 | else |
| 4563 | 4821 | { |
| 4564 | - if (is_array($func)) |
|
| 4565 | - call_user_func($func); |
|
| 4566 | - |
|
| 4567 | - else |
|
| 4568 | - $func(); |
|
| 4822 | + if (is_array($func)) { |
|
| 4823 | + call_user_func($func); |
|
| 4824 | + } else { |
|
| 4825 | + $func(); |
|
| 4826 | + } |
|
| 4569 | 4827 | } |
| 4570 | 4828 | } |
| 4571 | 4829 | } |
@@ -4582,31 +4840,34 @@ discard block |
||
| 4582 | 4840 | { |
| 4583 | 4841 | global $sourcedir, $txt, $boarddir, $settings; |
| 4584 | 4842 | |
| 4585 | - if (empty($string)) |
|
| 4586 | - return false; |
|
| 4843 | + if (empty($string)) { |
|
| 4844 | + return false; |
|
| 4845 | + } |
|
| 4587 | 4846 | |
| 4588 | 4847 | if (strpos($string, '|') !== false) |
| 4589 | 4848 | { |
| 4590 | 4849 | list ($file, $string) = explode('|', $string); |
| 4591 | 4850 | |
| 4592 | 4851 | // Match the wildcards to their regular vars. |
| 4593 | - if (empty($settings['theme_dir'])) |
|
| 4594 | - $absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir)); |
|
| 4595 | - |
|
| 4596 | - else |
|
| 4597 | - $absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir'])); |
|
| 4852 | + if (empty($settings['theme_dir'])) { |
|
| 4853 | + $absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir)); |
|
| 4854 | + } else { |
|
| 4855 | + $absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir'])); |
|
| 4856 | + } |
|
| 4598 | 4857 | |
| 4599 | 4858 | // Load the file if it can be loaded. |
| 4600 | - if (file_exists($absPath)) |
|
| 4601 | - require_once($absPath); |
|
| 4859 | + if (file_exists($absPath)) { |
|
| 4860 | + require_once($absPath); |
|
| 4861 | + } |
|
| 4602 | 4862 | |
| 4603 | 4863 | // No? try a fallback to $sourcedir |
| 4604 | 4864 | else |
| 4605 | 4865 | { |
| 4606 | 4866 | $absPath = $sourcedir .'/'. $file; |
| 4607 | 4867 | |
| 4608 | - if (file_exists($absPath)) |
|
| 4609 | - require_once($absPath); |
|
| 4868 | + if (file_exists($absPath)) { |
|
| 4869 | + require_once($absPath); |
|
| 4870 | + } |
|
| 4610 | 4871 | |
| 4611 | 4872 | // Sorry, can't do much for you at this point. |
| 4612 | 4873 | else |
@@ -4633,8 +4894,9 @@ discard block |
||
| 4633 | 4894 | global $user_info, $smcFunc; |
| 4634 | 4895 | |
| 4635 | 4896 | // Make sure we have something to work with. |
| 4636 | - if (empty($topic)) |
|
| 4637 | - return array(); |
|
| 4897 | + if (empty($topic)) { |
|
| 4898 | + return array(); |
|
| 4899 | + } |
|
| 4638 | 4900 | |
| 4639 | 4901 | |
| 4640 | 4902 | // We already know the number of likes per message, we just want to know whether the current user liked it or not. |
@@ -4657,8 +4919,9 @@ discard block |
||
| 4657 | 4919 | 'topic' => $topic, |
| 4658 | 4920 | ) |
| 4659 | 4921 | ); |
| 4660 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 4661 | - $temp[] = (int) $row['content_id']; |
|
| 4922 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 4923 | + $temp[] = (int) $row['content_id']; |
|
| 4924 | + } |
|
| 4662 | 4925 | |
| 4663 | 4926 | cache_put_data($cache_key, $temp, $ttl); |
| 4664 | 4927 | } |
@@ -4679,8 +4942,9 @@ discard block |
||
| 4679 | 4942 | { |
| 4680 | 4943 | global $context; |
| 4681 | 4944 | |
| 4682 | - if (empty($string)) |
|
| 4683 | - return $string; |
|
| 4945 | + if (empty($string)) { |
|
| 4946 | + return $string; |
|
| 4947 | + } |
|
| 4684 | 4948 | |
| 4685 | 4949 | // UTF-8 occurences of MS special characters |
| 4686 | 4950 | $findchars_utf8 = array( |
@@ -4721,10 +4985,11 @@ discard block |
||
| 4721 | 4985 | '--', // — |
| 4722 | 4986 | ); |
| 4723 | 4987 | |
| 4724 | - if ($context['utf8']) |
|
| 4725 | - $string = str_replace($findchars_utf8, $replacechars, $string); |
|
| 4726 | - else |
|
| 4727 | - $string = str_replace($findchars_iso, $replacechars, $string); |
|
| 4988 | + if ($context['utf8']) { |
|
| 4989 | + $string = str_replace($findchars_utf8, $replacechars, $string); |
|
| 4990 | + } else { |
|
| 4991 | + $string = str_replace($findchars_iso, $replacechars, $string); |
|
| 4992 | + } |
|
| 4728 | 4993 | |
| 4729 | 4994 | return $string; |
| 4730 | 4995 | } |
@@ -4743,49 +5008,59 @@ discard block |
||
| 4743 | 5008 | { |
| 4744 | 5009 | global $context; |
| 4745 | 5010 | |
| 4746 | - if (!isset($matches[2])) |
|
| 4747 | - return ''; |
|
| 5011 | + if (!isset($matches[2])) { |
|
| 5012 | + return ''; |
|
| 5013 | + } |
|
| 4748 | 5014 | |
| 4749 | 5015 | $num = $matches[2][0] === 'x' ? hexdec(substr($matches[2], 1)) : (int) $matches[2]; |
| 4750 | 5016 | |
| 4751 | 5017 | // remove left to right / right to left overrides |
| 4752 | - if ($num === 0x202D || $num === 0x202E) |
|
| 4753 | - return ''; |
|
| 5018 | + if ($num === 0x202D || $num === 0x202E) { |
|
| 5019 | + return ''; |
|
| 5020 | + } |
|
| 4754 | 5021 | |
| 4755 | 5022 | // Quote, Ampersand, Apostrophe, Less/Greater Than get html replaced |
| 4756 | - if (in_array($num, array(0x22, 0x26, 0x27, 0x3C, 0x3E))) |
|
| 4757 | - return '&#' . $num . ';'; |
|
| 5023 | + if (in_array($num, array(0x22, 0x26, 0x27, 0x3C, 0x3E))) { |
|
| 5024 | + return '&#' . $num . ';'; |
|
| 5025 | + } |
|
| 4758 | 5026 | |
| 4759 | 5027 | if (empty($context['utf8'])) |
| 4760 | 5028 | { |
| 4761 | 5029 | // no control characters |
| 4762 | - if ($num < 0x20) |
|
| 4763 | - return ''; |
|
| 5030 | + if ($num < 0x20) { |
|
| 5031 | + return ''; |
|
| 5032 | + } |
|
| 4764 | 5033 | // text is text |
| 4765 | - elseif ($num < 0x80) |
|
| 4766 | - return chr($num); |
|
| 5034 | + elseif ($num < 0x80) { |
|
| 5035 | + return chr($num); |
|
| 5036 | + } |
|
| 4767 | 5037 | // all others get html-ised |
| 4768 | - else |
|
| 4769 | - return '&#' . $matches[2] . ';'; |
|
| 4770 | - } |
|
| 4771 | - else |
|
| 5038 | + else { |
|
| 5039 | + return '&#' . $matches[2] . ';'; |
|
| 5040 | + } |
|
| 5041 | + } else |
|
| 4772 | 5042 | { |
| 4773 | 5043 | // <0x20 are control characters, 0x20 is a space, > 0x10FFFF is past the end of the utf8 character set |
| 4774 | 5044 | // 0xD800 >= $num <= 0xDFFF are surrogate markers (not valid for utf8 text) |
| 4775 | - if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF)) |
|
| 4776 | - return ''; |
|
| 5045 | + if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF)) { |
|
| 5046 | + return ''; |
|
| 5047 | + } |
|
| 4777 | 5048 | // <0x80 (or less than 128) are standard ascii characters a-z A-Z 0-9 and punctuation |
| 4778 | - elseif ($num < 0x80) |
|
| 4779 | - return chr($num); |
|
| 5049 | + elseif ($num < 0x80) { |
|
| 5050 | + return chr($num); |
|
| 5051 | + } |
|
| 4780 | 5052 | // <0x800 (2048) |
| 4781 | - elseif ($num < 0x800) |
|
| 4782 | - return chr(($num >> 6) + 192) . chr(($num & 63) + 128); |
|
| 5053 | + elseif ($num < 0x800) { |
|
| 5054 | + return chr(($num >> 6) + 192) . chr(($num & 63) + 128); |
|
| 5055 | + } |
|
| 4783 | 5056 | // < 0x10000 (65536) |
| 4784 | - elseif ($num < 0x10000) |
|
| 4785 | - return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
| 5057 | + elseif ($num < 0x10000) { |
|
| 5058 | + return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
| 5059 | + } |
|
| 4786 | 5060 | // <= 0x10FFFF (1114111) |
| 4787 | - else |
|
| 4788 | - return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
| 5061 | + else { |
|
| 5062 | + return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
| 5063 | + } |
|
| 4789 | 5064 | } |
| 4790 | 5065 | } |
| 4791 | 5066 | |
@@ -4801,28 +5076,34 @@ discard block |
||
| 4801 | 5076 | */ |
| 4802 | 5077 | function fixchar__callback($matches) |
| 4803 | 5078 | { |
| 4804 | - if (!isset($matches[1])) |
|
| 4805 | - return ''; |
|
| 5079 | + if (!isset($matches[1])) { |
|
| 5080 | + return ''; |
|
| 5081 | + } |
|
| 4806 | 5082 | |
| 4807 | 5083 | $num = $matches[1][0] === 'x' ? hexdec(substr($matches[1], 1)) : (int) $matches[1]; |
| 4808 | 5084 | |
| 4809 | 5085 | // <0x20 are control characters, > 0x10FFFF is past the end of the utf8 character set |
| 4810 | 5086 | // 0xD800 >= $num <= 0xDFFF are surrogate markers (not valid for utf8 text), 0x202D-E are left to right overrides |
| 4811 | - if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num === 0x202D || $num === 0x202E) |
|
| 4812 | - return ''; |
|
| 5087 | + if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num === 0x202D || $num === 0x202E) { |
|
| 5088 | + return ''; |
|
| 5089 | + } |
|
| 4813 | 5090 | // <0x80 (or less than 128) are standard ascii characters a-z A-Z 0-9 and punctuation |
| 4814 | - elseif ($num < 0x80) |
|
| 4815 | - return chr($num); |
|
| 5091 | + elseif ($num < 0x80) { |
|
| 5092 | + return chr($num); |
|
| 5093 | + } |
|
| 4816 | 5094 | // <0x800 (2048) |
| 4817 | - elseif ($num < 0x800) |
|
| 4818 | - return chr(($num >> 6) + 192) . chr(($num & 63) + 128); |
|
| 5095 | + elseif ($num < 0x800) { |
|
| 5096 | + return chr(($num >> 6) + 192) . chr(($num & 63) + 128); |
|
| 5097 | + } |
|
| 4819 | 5098 | // < 0x10000 (65536) |
| 4820 | - elseif ($num < 0x10000) |
|
| 4821 | - return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
| 5099 | + elseif ($num < 0x10000) { |
|
| 5100 | + return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
| 5101 | + } |
|
| 4822 | 5102 | // <= 0x10FFFF (1114111) |
| 4823 | - else |
|
| 4824 | - return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
| 4825 | -} |
|
| 5103 | + else { |
|
| 5104 | + return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
| 5105 | + } |
|
| 5106 | + } |
|
| 4826 | 5107 | |
| 4827 | 5108 | /** |
| 4828 | 5109 | * Strips out invalid html entities, replaces others with html style { codes |
@@ -4835,17 +5116,19 @@ discard block |
||
| 4835 | 5116 | */ |
| 4836 | 5117 | function entity_fix__callback($matches) |
| 4837 | 5118 | { |
| 4838 | - if (!isset($matches[2])) |
|
| 4839 | - return ''; |
|
| 5119 | + if (!isset($matches[2])) { |
|
| 5120 | + return ''; |
|
| 5121 | + } |
|
| 4840 | 5122 | |
| 4841 | 5123 | $num = $matches[2][0] === 'x' ? hexdec(substr($matches[2], 1)) : (int) $matches[2]; |
| 4842 | 5124 | |
| 4843 | 5125 | // we don't allow control characters, characters out of range, byte markers, etc |
| 4844 | - if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num == 0x202D || $num == 0x202E) |
|
| 4845 | - return ''; |
|
| 4846 | - else |
|
| 4847 | - return '&#' . $num . ';'; |
|
| 4848 | -} |
|
| 5126 | + if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num == 0x202D || $num == 0x202E) { |
|
| 5127 | + return ''; |
|
| 5128 | + } else { |
|
| 5129 | + return '&#' . $num . ';'; |
|
| 5130 | + } |
|
| 5131 | + } |
|
| 4849 | 5132 | |
| 4850 | 5133 | /** |
| 4851 | 5134 | * Return a Gravatar URL based on |
@@ -4869,18 +5152,23 @@ discard block |
||
| 4869 | 5152 | $ratings = array('G', 'PG', 'R', 'X'); |
| 4870 | 5153 | $defaults = array('mm', 'identicon', 'monsterid', 'wavatar', 'retro', 'blank'); |
| 4871 | 5154 | $url_params = array(); |
| 4872 | - if (!empty($modSettings['gravatarMaxRating']) && in_array($modSettings['gravatarMaxRating'], $ratings)) |
|
| 4873 | - $url_params[] = 'rating=' . $modSettings['gravatarMaxRating']; |
|
| 4874 | - if (!empty($modSettings['gravatarDefault']) && in_array($modSettings['gravatarDefault'], $defaults)) |
|
| 4875 | - $url_params[] = 'default=' . $modSettings['gravatarDefault']; |
|
| 4876 | - if (!empty($modSettings['avatar_max_width_external'])) |
|
| 4877 | - $size_string = (int) $modSettings['avatar_max_width_external']; |
|
| 4878 | - if (!empty($modSettings['avatar_max_height_external']) && !empty($size_string)) |
|
| 4879 | - if ((int) $modSettings['avatar_max_height_external'] < $size_string) |
|
| 5155 | + if (!empty($modSettings['gravatarMaxRating']) && in_array($modSettings['gravatarMaxRating'], $ratings)) { |
|
| 5156 | + $url_params[] = 'rating=' . $modSettings['gravatarMaxRating']; |
|
| 5157 | + } |
|
| 5158 | + if (!empty($modSettings['gravatarDefault']) && in_array($modSettings['gravatarDefault'], $defaults)) { |
|
| 5159 | + $url_params[] = 'default=' . $modSettings['gravatarDefault']; |
|
| 5160 | + } |
|
| 5161 | + if (!empty($modSettings['avatar_max_width_external'])) { |
|
| 5162 | + $size_string = (int) $modSettings['avatar_max_width_external']; |
|
| 5163 | + } |
|
| 5164 | + if (!empty($modSettings['avatar_max_height_external']) && !empty($size_string)) { |
|
| 5165 | + if ((int) $modSettings['avatar_max_height_external'] < $size_string) |
|
| 4880 | 5166 | $size_string = $modSettings['avatar_max_height_external']; |
| 5167 | + } |
|
| 4881 | 5168 | |
| 4882 | - if (!empty($size_string)) |
|
| 4883 | - $url_params[] = 's=' . $size_string; |
|
| 5169 | + if (!empty($size_string)) { |
|
| 5170 | + $url_params[] = 's=' . $size_string; |
|
| 5171 | + } |
|
| 4884 | 5172 | } |
| 4885 | 5173 | $http_method = !empty($modSettings['force_ssl']) && $modSettings['force_ssl'] == 2 ? 'https://secure' : 'http://www'; |
| 4886 | 5174 | |
@@ -4899,22 +5187,26 @@ discard block |
||
| 4899 | 5187 | static $timezones = null, $lastwhen = null; |
| 4900 | 5188 | |
| 4901 | 5189 | // No point doing this over if we already did it once |
| 4902 | - if (!empty($timezones) && $when == $lastwhen) |
|
| 4903 | - return $timezones; |
|
| 4904 | - else |
|
| 4905 | - $lastwhen = $when; |
|
| 5190 | + if (!empty($timezones) && $when == $lastwhen) { |
|
| 5191 | + return $timezones; |
|
| 5192 | + } else { |
|
| 5193 | + $lastwhen = $when; |
|
| 5194 | + } |
|
| 4906 | 5195 | |
| 4907 | 5196 | // Parseable datetime string? |
| 4908 | - if (is_int($timestamp = strtotime($when))) |
|
| 4909 | - $when = $timestamp; |
|
| 5197 | + if (is_int($timestamp = strtotime($when))) { |
|
| 5198 | + $when = $timestamp; |
|
| 5199 | + } |
|
| 4910 | 5200 | |
| 4911 | 5201 | // A Unix timestamp? |
| 4912 | - elseif (is_numeric($when)) |
|
| 4913 | - $when = intval($when); |
|
| 5202 | + elseif (is_numeric($when)) { |
|
| 5203 | + $when = intval($when); |
|
| 5204 | + } |
|
| 4914 | 5205 | |
| 4915 | 5206 | // Invalid value? Just get current Unix timestamp. |
| 4916 | - else |
|
| 4917 | - $when = time(); |
|
| 5207 | + else { |
|
| 5208 | + $when = time(); |
|
| 5209 | + } |
|
| 4918 | 5210 | |
| 4919 | 5211 | // We'll need this too |
| 4920 | 5212 | $later = (int) date_format(date_add(date_create('@' . $when), date_interval_create_from_date_string('1 year')), 'U'); |
@@ -4977,8 +5269,9 @@ discard block |
||
| 4977 | 5269 | foreach ($priority_countries as $country) |
| 4978 | 5270 | { |
| 4979 | 5271 | $country_tzids = @timezone_identifiers_list(DateTimeZone::PER_COUNTRY, strtoupper(trim($country))); |
| 4980 | - if (!empty($country_tzids)) |
|
| 4981 | - $priority_tzids = array_merge($priority_tzids, $country_tzids); |
|
| 5272 | + if (!empty($country_tzids)) { |
|
| 5273 | + $priority_tzids = array_merge($priority_tzids, $country_tzids); |
|
| 5274 | + } |
|
| 4982 | 5275 | } |
| 4983 | 5276 | |
| 4984 | 5277 | // Process the preferred timezones first, then the rest. |
@@ -4988,8 +5281,9 @@ discard block |
||
| 4988 | 5281 | foreach ($tzids as $tzid) |
| 4989 | 5282 | { |
| 4990 | 5283 | // We don't want UTC right now |
| 4991 | - if ($tzid == 'UTC') |
|
| 4992 | - continue; |
|
| 5284 | + if ($tzid == 'UTC') { |
|
| 5285 | + continue; |
|
| 5286 | + } |
|
| 4993 | 5287 | |
| 4994 | 5288 | // First, get the set of transition rules for this tzid |
| 4995 | 5289 | $tzinfo = timezone_transitions_get(timezone_open($tzid), $when, $later); |
@@ -5000,8 +5294,9 @@ discard block |
||
| 5000 | 5294 | $tz_location = timezone_location_get(timezone_open($tzid)); |
| 5001 | 5295 | |
| 5002 | 5296 | // Kazakstan |
| 5003 | - if ($tz_location['country_code'] == 'KZ') |
|
| 5004 | - $tzinfo[0]['abbr'] = str_replace(array('+05', '+06'), array('AQTT', 'ALMT'), $tzinfo[0]['abbr']); |
|
| 5297 | + if ($tz_location['country_code'] == 'KZ') { |
|
| 5298 | + $tzinfo[0]['abbr'] = str_replace(array('+05', '+06'), array('AQTT', 'ALMT'), $tzinfo[0]['abbr']); |
|
| 5299 | + } |
|
| 5005 | 5300 | |
| 5006 | 5301 | // Russia likes to experiment with time zones |
| 5007 | 5302 | if ($tz_location['country_code'] == 'RU') |
@@ -5012,19 +5307,22 @@ discard block |
||
| 5012 | 5307 | } |
| 5013 | 5308 | |
| 5014 | 5309 | // Still no good? We'll just mark it as a UTC offset |
| 5015 | - if (strspn($tzinfo[0]['abbr'], '+-') > 0) |
|
| 5016 | - $tzinfo[0]['abbr'] = 'UTC' . $tzinfo[0]['abbr']; |
|
| 5310 | + if (strspn($tzinfo[0]['abbr'], '+-') > 0) { |
|
| 5311 | + $tzinfo[0]['abbr'] = 'UTC' . $tzinfo[0]['abbr']; |
|
| 5312 | + } |
|
| 5017 | 5313 | } |
| 5018 | 5314 | |
| 5019 | 5315 | $tzkey = serialize($tzinfo); |
| 5020 | 5316 | |
| 5021 | 5317 | // Don't overwrite our preferred tzids |
| 5022 | - if (empty($zones[$tzkey]['tzid'])) |
|
| 5023 | - $zones[$tzkey]['tzid'] = $tzid; |
|
| 5318 | + if (empty($zones[$tzkey]['tzid'])) { |
|
| 5319 | + $zones[$tzkey]['tzid'] = $tzid; |
|
| 5320 | + } |
|
| 5024 | 5321 | |
| 5025 | 5322 | // A time zone from a prioritized country? |
| 5026 | - if (in_array($tzid, $priority_tzids)) |
|
| 5027 | - $priority_zones[$tzkey] = true; |
|
| 5323 | + if (in_array($tzid, $priority_tzids)) { |
|
| 5324 | + $priority_zones[$tzkey] = true; |
|
| 5325 | + } |
|
| 5028 | 5326 | |
| 5029 | 5327 | // Keep track of the location and offset for this tzid |
| 5030 | 5328 | $zones[$tzkey]['locations'][] = str_replace(array('St_', '_'), array('St. ', ' '), array_pop(explode('/', $tzid))); |
@@ -5041,15 +5339,17 @@ discard block |
||
| 5041 | 5339 | { |
| 5042 | 5340 | $tzinfo = unserialize($tzkey); |
| 5043 | 5341 | |
| 5044 | - if (!empty($timezone_descriptions[$tzvalue['tzid']])) |
|
| 5045 | - $desc = $timezone_descriptions[$tzvalue['tzid']]; |
|
| 5046 | - else |
|
| 5047 | - $desc = implode(', ', array_unique($tzvalue['locations'])); |
|
| 5342 | + if (!empty($timezone_descriptions[$tzvalue['tzid']])) { |
|
| 5343 | + $desc = $timezone_descriptions[$tzvalue['tzid']]; |
|
| 5344 | + } else { |
|
| 5345 | + $desc = implode(', ', array_unique($tzvalue['locations'])); |
|
| 5346 | + } |
|
| 5048 | 5347 | |
| 5049 | - if (isset($priority_zones[$tzkey])) |
|
| 5050 | - $priority_timezones[$tzvalue['tzid']] = $tzinfo[0]['abbr'] . ' - ' . $desc . ' [UTC' . date_format(date_create($tzvalue['tzid']), 'P') . ']'; |
|
| 5051 | - else |
|
| 5052 | - $timezones[$tzvalue['tzid']] = $tzinfo[0]['abbr'] . ' - ' . $desc . ' [UTC' . date_format(date_create($tzvalue['tzid']), 'P') . ']'; |
|
| 5348 | + if (isset($priority_zones[$tzkey])) { |
|
| 5349 | + $priority_timezones[$tzvalue['tzid']] = $tzinfo[0]['abbr'] . ' - ' . $desc . ' [UTC' . date_format(date_create($tzvalue['tzid']), 'P') . ']'; |
|
| 5350 | + } else { |
|
| 5351 | + $timezones[$tzvalue['tzid']] = $tzinfo[0]['abbr'] . ' - ' . $desc . ' [UTC' . date_format(date_create($tzvalue['tzid']), 'P') . ']'; |
|
| 5352 | + } |
|
| 5053 | 5353 | } |
| 5054 | 5354 | |
| 5055 | 5355 | $timezones = array_merge( |
@@ -5067,8 +5367,9 @@ discard block |
||
| 5067 | 5367 | */ |
| 5068 | 5368 | function inet_ptod($ip_address) |
| 5069 | 5369 | { |
| 5070 | - if (!isValidIP($ip_address)) |
|
| 5071 | - return $ip_address; |
|
| 5370 | + if (!isValidIP($ip_address)) { |
|
| 5371 | + return $ip_address; |
|
| 5372 | + } |
|
| 5072 | 5373 | |
| 5073 | 5374 | $bin = inet_pton($ip_address); |
| 5074 | 5375 | return $bin; |
@@ -5080,13 +5381,15 @@ discard block |
||
| 5080 | 5381 | */ |
| 5081 | 5382 | function inet_dtop($bin) |
| 5082 | 5383 | { |
| 5083 | - if(empty($bin)) |
|
| 5084 | - return ''; |
|
| 5384 | + if(empty($bin)) { |
|
| 5385 | + return ''; |
|
| 5386 | + } |
|
| 5085 | 5387 | |
| 5086 | 5388 | global $db_type; |
| 5087 | 5389 | |
| 5088 | - if ($db_type == 'postgresql') |
|
| 5089 | - return $bin; |
|
| 5390 | + if ($db_type == 'postgresql') { |
|
| 5391 | + return $bin; |
|
| 5392 | + } |
|
| 5090 | 5393 | |
| 5091 | 5394 | $ip_address = inet_ntop($bin); |
| 5092 | 5395 | |
@@ -5111,26 +5414,32 @@ discard block |
||
| 5111 | 5414 | */ |
| 5112 | 5415 | function _safe_serialize($value) |
| 5113 | 5416 | { |
| 5114 | - if(is_null($value)) |
|
| 5115 | - return 'N;'; |
|
| 5417 | + if(is_null($value)) { |
|
| 5418 | + return 'N;'; |
|
| 5419 | + } |
|
| 5116 | 5420 | |
| 5117 | - if(is_bool($value)) |
|
| 5118 | - return 'b:'. (int) $value .';'; |
|
| 5421 | + if(is_bool($value)) { |
|
| 5422 | + return 'b:'. (int) $value .';'; |
|
| 5423 | + } |
|
| 5119 | 5424 | |
| 5120 | - if(is_int($value)) |
|
| 5121 | - return 'i:'. $value .';'; |
|
| 5425 | + if(is_int($value)) { |
|
| 5426 | + return 'i:'. $value .';'; |
|
| 5427 | + } |
|
| 5122 | 5428 | |
| 5123 | - if(is_float($value)) |
|
| 5124 | - return 'd:'. str_replace(',', '.', $value) .';'; |
|
| 5429 | + if(is_float($value)) { |
|
| 5430 | + return 'd:'. str_replace(',', '.', $value) .';'; |
|
| 5431 | + } |
|
| 5125 | 5432 | |
| 5126 | - if(is_string($value)) |
|
| 5127 | - return 's:'. strlen($value) .':"'. $value .'";'; |
|
| 5433 | + if(is_string($value)) { |
|
| 5434 | + return 's:'. strlen($value) .':"'. $value .'";'; |
|
| 5435 | + } |
|
| 5128 | 5436 | |
| 5129 | 5437 | if(is_array($value)) |
| 5130 | 5438 | { |
| 5131 | 5439 | $out = ''; |
| 5132 | - foreach($value as $k => $v) |
|
| 5133 | - $out .= _safe_serialize($k) . _safe_serialize($v); |
|
| 5440 | + foreach($value as $k => $v) { |
|
| 5441 | + $out .= _safe_serialize($k) . _safe_serialize($v); |
|
| 5442 | + } |
|
| 5134 | 5443 | |
| 5135 | 5444 | return 'a:'. count($value) .':{'. $out .'}'; |
| 5136 | 5445 | } |
@@ -5156,8 +5465,9 @@ discard block |
||
| 5156 | 5465 | |
| 5157 | 5466 | $out = _safe_serialize($value); |
| 5158 | 5467 | |
| 5159 | - if (isset($mbIntEnc)) |
|
| 5160 | - mb_internal_encoding($mbIntEnc); |
|
| 5468 | + if (isset($mbIntEnc)) { |
|
| 5469 | + mb_internal_encoding($mbIntEnc); |
|
| 5470 | + } |
|
| 5161 | 5471 | |
| 5162 | 5472 | return $out; |
| 5163 | 5473 | } |
@@ -5174,8 +5484,9 @@ discard block |
||
| 5174 | 5484 | function _safe_unserialize($str) |
| 5175 | 5485 | { |
| 5176 | 5486 | // Input is not a string. |
| 5177 | - if(empty($str) || !is_string($str)) |
|
| 5178 | - return false; |
|
| 5487 | + if(empty($str) || !is_string($str)) { |
|
| 5488 | + return false; |
|
| 5489 | + } |
|
| 5179 | 5490 | |
| 5180 | 5491 | $stack = array(); |
| 5181 | 5492 | $expected = array(); |
@@ -5191,43 +5502,38 @@ discard block |
||
| 5191 | 5502 | while($state != 1) |
| 5192 | 5503 | { |
| 5193 | 5504 | $type = isset($str[0]) ? $str[0] : ''; |
| 5194 | - if($type == '}') |
|
| 5195 | - $str = substr($str, 1); |
|
| 5196 | - |
|
| 5197 | - else if($type == 'N' && $str[1] == ';') |
|
| 5505 | + if($type == '}') { |
|
| 5506 | + $str = substr($str, 1); |
|
| 5507 | + } else if($type == 'N' && $str[1] == ';') |
|
| 5198 | 5508 | { |
| 5199 | 5509 | $value = null; |
| 5200 | 5510 | $str = substr($str, 2); |
| 5201 | - } |
|
| 5202 | - else if($type == 'b' && preg_match('/^b:([01]);/', $str, $matches)) |
|
| 5511 | + } else if($type == 'b' && preg_match('/^b:([01]);/', $str, $matches)) |
|
| 5203 | 5512 | { |
| 5204 | 5513 | $value = $matches[1] == '1' ? true : false; |
| 5205 | 5514 | $str = substr($str, 4); |
| 5206 | - } |
|
| 5207 | - else if($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches)) |
|
| 5515 | + } else if($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches)) |
|
| 5208 | 5516 | { |
| 5209 | 5517 | $value = (int)$matches[1]; |
| 5210 | 5518 | $str = $matches[2]; |
| 5211 | - } |
|
| 5212 | - else if($type == 'd' && preg_match('/^d:(-?[0-9]+\.?[0-9]*(E[+-][0-9]+)?);(.*)/s', $str, $matches)) |
|
| 5519 | + } else if($type == 'd' && preg_match('/^d:(-?[0-9]+\.?[0-9]*(E[+-][0-9]+)?);(.*)/s', $str, $matches)) |
|
| 5213 | 5520 | { |
| 5214 | 5521 | $value = (float)$matches[1]; |
| 5215 | 5522 | $str = $matches[3]; |
| 5216 | - } |
|
| 5217 | - else if($type == 's' && preg_match('/^s:([0-9]+):"(.*)/s', $str, $matches) && substr($matches[2], (int)$matches[1], 2) == '";') |
|
| 5523 | + } else if($type == 's' && preg_match('/^s:([0-9]+):"(.*)/s', $str, $matches) && substr($matches[2], (int)$matches[1], 2) == '";') |
|
| 5218 | 5524 | { |
| 5219 | 5525 | $value = substr($matches[2], 0, (int)$matches[1]); |
| 5220 | 5526 | $str = substr($matches[2], (int)$matches[1] + 2); |
| 5221 | - } |
|
| 5222 | - else if($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches)) |
|
| 5527 | + } else if($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches)) |
|
| 5223 | 5528 | { |
| 5224 | 5529 | $expectedLength = (int)$matches[1]; |
| 5225 | 5530 | $str = $matches[2]; |
| 5226 | 5531 | } |
| 5227 | 5532 | |
| 5228 | 5533 | // Object or unknown/malformed type. |
| 5229 | - else |
|
| 5230 | - return false; |
|
| 5534 | + else { |
|
| 5535 | + return false; |
|
| 5536 | + } |
|
| 5231 | 5537 | |
| 5232 | 5538 | switch($state) |
| 5233 | 5539 | { |
@@ -5255,8 +5561,9 @@ discard block |
||
| 5255 | 5561 | if($type == '}') |
| 5256 | 5562 | { |
| 5257 | 5563 | // Array size is less than expected. |
| 5258 | - if(count($list) < end($expected)) |
|
| 5259 | - return false; |
|
| 5564 | + if(count($list) < end($expected)) { |
|
| 5565 | + return false; |
|
| 5566 | + } |
|
| 5260 | 5567 | |
| 5261 | 5568 | unset($list); |
| 5262 | 5569 | $list = &$stack[count($stack)-1]; |
@@ -5265,8 +5572,9 @@ discard block |
||
| 5265 | 5572 | // Go to terminal state if we're at the end of the root array. |
| 5266 | 5573 | array_pop($expected); |
| 5267 | 5574 | |
| 5268 | - if(count($expected) == 0) |
|
| 5269 | - $state = 1; |
|
| 5575 | + if(count($expected) == 0) { |
|
| 5576 | + $state = 1; |
|
| 5577 | + } |
|
| 5270 | 5578 | |
| 5271 | 5579 | break; |
| 5272 | 5580 | } |
@@ -5274,8 +5582,9 @@ discard block |
||
| 5274 | 5582 | if($type == 'i' || $type == 's') |
| 5275 | 5583 | { |
| 5276 | 5584 | // Array size exceeds expected length. |
| 5277 | - if(count($list) >= end($expected)) |
|
| 5278 | - return false; |
|
| 5585 | + if(count($list) >= end($expected)) { |
|
| 5586 | + return false; |
|
| 5587 | + } |
|
| 5279 | 5588 | |
| 5280 | 5589 | $key = $value; |
| 5281 | 5590 | $state = 3; |
@@ -5309,8 +5618,9 @@ discard block |
||
| 5309 | 5618 | } |
| 5310 | 5619 | |
| 5311 | 5620 | // Trailing data in input. |
| 5312 | - if(!empty($str)) |
|
| 5313 | - return false; |
|
| 5621 | + if(!empty($str)) { |
|
| 5622 | + return false; |
|
| 5623 | + } |
|
| 5314 | 5624 | |
| 5315 | 5625 | return $data; |
| 5316 | 5626 | } |
@@ -5333,8 +5643,9 @@ discard block |
||
| 5333 | 5643 | |
| 5334 | 5644 | $out = _safe_unserialize($str); |
| 5335 | 5645 | |
| 5336 | - if (isset($mbIntEnc)) |
|
| 5337 | - mb_internal_encoding($mbIntEnc); |
|
| 5646 | + if (isset($mbIntEnc)) { |
|
| 5647 | + mb_internal_encoding($mbIntEnc); |
|
| 5648 | + } |
|
| 5338 | 5649 | |
| 5339 | 5650 | return $out; |
| 5340 | 5651 | } |
@@ -5349,12 +5660,14 @@ discard block |
||
| 5349 | 5660 | function smf_chmod($file, $value = 0) |
| 5350 | 5661 | { |
| 5351 | 5662 | // No file? no checks! |
| 5352 | - if (empty($file)) |
|
| 5353 | - return false; |
|
| 5663 | + if (empty($file)) { |
|
| 5664 | + return false; |
|
| 5665 | + } |
|
| 5354 | 5666 | |
| 5355 | 5667 | // Already writable? |
| 5356 | - if (is_writable($file)) |
|
| 5357 | - return true; |
|
| 5668 | + if (is_writable($file)) { |
|
| 5669 | + return true; |
|
| 5670 | + } |
|
| 5358 | 5671 | |
| 5359 | 5672 | // Do we have a file or a dir? |
| 5360 | 5673 | $isDir = is_dir($file); |
@@ -5370,10 +5683,9 @@ discard block |
||
| 5370 | 5683 | { |
| 5371 | 5684 | $isWritable = true; |
| 5372 | 5685 | break; |
| 5686 | + } else { |
|
| 5687 | + @chmod($file, $val); |
|
| 5373 | 5688 | } |
| 5374 | - |
|
| 5375 | - else |
|
| 5376 | - @chmod($file, $val); |
|
| 5377 | 5689 | } |
| 5378 | 5690 | |
| 5379 | 5691 | return $isWritable; |
@@ -5392,8 +5704,9 @@ discard block |
||
| 5392 | 5704 | global $txt; |
| 5393 | 5705 | |
| 5394 | 5706 | // Come on... |
| 5395 | - if (empty($json) || !is_string($json)) |
|
| 5396 | - return array(); |
|
| 5707 | + if (empty($json) || !is_string($json)) { |
|
| 5708 | + return array(); |
|
| 5709 | + } |
|
| 5397 | 5710 | |
| 5398 | 5711 | $returnArray = array(); |
| 5399 | 5712 | $jsonError = false; |
@@ -5434,11 +5747,11 @@ discard block |
||
| 5434 | 5747 | $jsonDebug = $jsonDebug[0]; |
| 5435 | 5748 | loadLanguage('Errors'); |
| 5436 | 5749 | |
| 5437 | - if (!empty($jsonDebug)) |
|
| 5438 | - log_error($txt['json_'. $jsonError], 'critical', $jsonDebug['file'], $jsonDebug['line']); |
|
| 5439 | - |
|
| 5440 | - else |
|
| 5441 | - log_error($txt['json_'. $jsonError], 'critical'); |
|
| 5750 | + if (!empty($jsonDebug)) { |
|
| 5751 | + log_error($txt['json_'. $jsonError], 'critical', $jsonDebug['file'], $jsonDebug['line']); |
|
| 5752 | + } else { |
|
| 5753 | + log_error($txt['json_'. $jsonError], 'critical'); |
|
| 5754 | + } |
|
| 5442 | 5755 | |
| 5443 | 5756 | // Everyone expects an array. |
| 5444 | 5757 | return array(); |
@@ -5468,8 +5781,9 @@ discard block |
||
| 5468 | 5781 | global $db_show_debug, $modSettings; |
| 5469 | 5782 | |
| 5470 | 5783 | // Defensive programming anyone? |
| 5471 | - if (empty($data)) |
|
| 5472 | - return false; |
|
| 5784 | + if (empty($data)) { |
|
| 5785 | + return false; |
|
| 5786 | + } |
|
| 5473 | 5787 | |
| 5474 | 5788 | // Don't need extra stuff... |
| 5475 | 5789 | $db_show_debug = false; |
@@ -5477,11 +5791,11 @@ discard block |
||
| 5477 | 5791 | // Kill anything else. |
| 5478 | 5792 | ob_end_clean(); |
| 5479 | 5793 | |
| 5480 | - if (!empty($modSettings['CompressedOutput'])) |
|
| 5481 | - @ob_start('ob_gzhandler'); |
|
| 5482 | - |
|
| 5483 | - else |
|
| 5484 | - ob_start(); |
|
| 5794 | + if (!empty($modSettings['CompressedOutput'])) { |
|
| 5795 | + @ob_start('ob_gzhandler'); |
|
| 5796 | + } else { |
|
| 5797 | + ob_start(); |
|
| 5798 | + } |
|
| 5485 | 5799 | |
| 5486 | 5800 | // Set the header. |
| 5487 | 5801 | header($type); |
@@ -5513,8 +5827,9 @@ discard block |
||
| 5513 | 5827 | static $done = false; |
| 5514 | 5828 | |
| 5515 | 5829 | // If we don't need to do anything, don't |
| 5516 | - if (!$update && $done) |
|
| 5517 | - return; |
|
| 5830 | + if (!$update && $done) { |
|
| 5831 | + return; |
|
| 5832 | + } |
|
| 5518 | 5833 | |
| 5519 | 5834 | // Should we get a new copy of the official list of TLDs? |
| 5520 | 5835 | if ($update) |
@@ -5535,10 +5850,11 @@ discard block |
||
| 5535 | 5850 | // Clean $tlds and convert it to an array |
| 5536 | 5851 | $tlds = array_filter(explode("\n", strtolower($tlds)), function($line) { |
| 5537 | 5852 | $line = trim($line); |
| 5538 | - if (empty($line) || strpos($line, '#') !== false || strpos($line, ' ') !== false) |
|
| 5539 | - return false; |
|
| 5540 | - else |
|
| 5541 | - return true; |
|
| 5853 | + if (empty($line) || strpos($line, '#') !== false || strpos($line, ' ') !== false) { |
|
| 5854 | + return false; |
|
| 5855 | + } else { |
|
| 5856 | + return true; |
|
| 5857 | + } |
|
| 5542 | 5858 | }); |
| 5543 | 5859 | |
| 5544 | 5860 | // Convert Punycode to Unicode |
@@ -5592,8 +5908,9 @@ discard block |
||
| 5592 | 5908 | $idx += $digit * $w; |
| 5593 | 5909 | $t = ($k <= $bias) ? $tmin : (($k >= $bias + $tmax) ? $tmax : ($k - $bias)); |
| 5594 | 5910 | |
| 5595 | - if ($digit < $t) |
|
| 5596 | - break; |
|
| 5911 | + if ($digit < $t) { |
|
| 5912 | + break; |
|
| 5913 | + } |
|
| 5597 | 5914 | |
| 5598 | 5915 | $w = (int) ($w * ($base - $t)); |
| 5599 | 5916 | } |
@@ -5602,8 +5919,9 @@ discard block |
||
| 5602 | 5919 | $delta = intval($is_first ? ($delta / $damp) : ($delta / 2)); |
| 5603 | 5920 | $delta += intval($delta / ($deco_len + 1)); |
| 5604 | 5921 | |
| 5605 | - for ($k = 0; $delta > (($base - $tmin) * $tmax) / 2; $k += $base) |
|
| 5606 | - $delta = intval($delta / ($base - $tmin)); |
|
| 5922 | + for ($k = 0; $delta > (($base - $tmin) * $tmax) / 2; $k += $base) { |
|
| 5923 | + $delta = intval($delta / ($base - $tmin)); |
|
| 5924 | + } |
|
| 5607 | 5925 | |
| 5608 | 5926 | $bias = intval($k + ($base - $tmin + 1) * $delta / ($delta + $skew)); |
| 5609 | 5927 | $is_first = false; |
@@ -5612,8 +5930,9 @@ discard block |
||
| 5612 | 5930 | |
| 5613 | 5931 | if ($deco_len > 0) |
| 5614 | 5932 | { |
| 5615 | - for ($i = $deco_len; $i > $idx; $i--) |
|
| 5616 | - $decoded[$i] = $decoded[($i - 1)]; |
|
| 5933 | + for ($i = $deco_len; $i > $idx; $i--) { |
|
| 5934 | + $decoded[$i] = $decoded[($i - 1)]; |
|
| 5935 | + } |
|
| 5617 | 5936 | } |
| 5618 | 5937 | $decoded[$idx++] = $char; |
| 5619 | 5938 | } |
@@ -5621,24 +5940,29 @@ discard block |
||
| 5621 | 5940 | foreach ($decoded as $k => $v) |
| 5622 | 5941 | { |
| 5623 | 5942 | // 7bit are transferred literally |
| 5624 | - if ($v < 128) |
|
| 5625 | - $output .= chr($v); |
|
| 5943 | + if ($v < 128) { |
|
| 5944 | + $output .= chr($v); |
|
| 5945 | + } |
|
| 5626 | 5946 | |
| 5627 | 5947 | // 2 bytes |
| 5628 | - elseif ($v < (1 << 11)) |
|
| 5629 | - $output .= chr(192+($v >> 6)) . chr(128+($v & 63)); |
|
| 5948 | + elseif ($v < (1 << 11)) { |
|
| 5949 | + $output .= chr(192+($v >> 6)) . chr(128+($v & 63)); |
|
| 5950 | + } |
|
| 5630 | 5951 | |
| 5631 | 5952 | // 3 bytes |
| 5632 | - elseif ($v < (1 << 16)) |
|
| 5633 | - $output .= chr(224+($v >> 12)) . chr(128+(($v >> 6) & 63)) . chr(128+($v & 63)); |
|
| 5953 | + elseif ($v < (1 << 16)) { |
|
| 5954 | + $output .= chr(224+($v >> 12)) . chr(128+(($v >> 6) & 63)) . chr(128+($v & 63)); |
|
| 5955 | + } |
|
| 5634 | 5956 | |
| 5635 | 5957 | // 4 bytes |
| 5636 | - elseif ($v < (1 << 21)) |
|
| 5637 | - $output .= chr(240+($v >> 18)) . chr(128+(($v >> 12) & 63)) . chr(128+(($v >> 6) & 63)) . chr(128+($v & 63)); |
|
| 5958 | + elseif ($v < (1 << 21)) { |
|
| 5959 | + $output .= chr(240+($v >> 18)) . chr(128+(($v >> 12) & 63)) . chr(128+(($v >> 6) & 63)) . chr(128+($v & 63)); |
|
| 5960 | + } |
|
| 5638 | 5961 | |
| 5639 | 5962 | // 'Conversion from UCS-4 to UTF-8 failed: malformed input at byte '.$k |
| 5640 | - else |
|
| 5641 | - $output .= $safe_char; |
|
| 5963 | + else { |
|
| 5964 | + $output .= $safe_char; |
|
| 5965 | + } |
|
| 5642 | 5966 | } |
| 5643 | 5967 | |
| 5644 | 5968 | $output_parts[] = $output; |
@@ -5733,8 +6057,7 @@ discard block |
||
| 5733 | 6057 | |
| 5734 | 6058 | $strlen = 'mb_strlen'; |
| 5735 | 6059 | $substr = 'mb_substr'; |
| 5736 | - } |
|
| 5737 | - else |
|
| 6060 | + } else |
|
| 5738 | 6061 | { |
| 5739 | 6062 | $strlen = $smcFunc['strlen']; |
| 5740 | 6063 | $substr = $smcFunc['substr']; |
@@ -5748,20 +6071,21 @@ discard block |
||
| 5748 | 6071 | |
| 5749 | 6072 | $first = $substr($string, 0, 1); |
| 5750 | 6073 | |
| 5751 | - if (empty($index[$first])) |
|
| 5752 | - $index[$first] = array(); |
|
| 6074 | + if (empty($index[$first])) { |
|
| 6075 | + $index[$first] = array(); |
|
| 6076 | + } |
|
| 5753 | 6077 | |
| 5754 | 6078 | if ($strlen($string) > 1) |
| 5755 | 6079 | { |
| 5756 | 6080 | // Sanity check on recursion |
| 5757 | - if ($depth > 99) |
|
| 5758 | - $index[$first][$substr($string, 1)] = ''; |
|
| 5759 | - |
|
| 5760 | - else |
|
| 5761 | - $index[$first] = $add_string_to_index($substr($string, 1), $index[$first]); |
|
| 6081 | + if ($depth > 99) { |
|
| 6082 | + $index[$first][$substr($string, 1)] = ''; |
|
| 6083 | + } else { |
|
| 6084 | + $index[$first] = $add_string_to_index($substr($string, 1), $index[$first]); |
|
| 6085 | + } |
|
| 6086 | + } else { |
|
| 6087 | + $index[$first][''] = ''; |
|
| 5762 | 6088 | } |
| 5763 | - else |
|
| 5764 | - $index[$first][''] = ''; |
|
| 5765 | 6089 | |
| 5766 | 6090 | $depth--; |
| 5767 | 6091 | return $index; |
@@ -5784,9 +6108,9 @@ discard block |
||
| 5784 | 6108 | $key_regex = preg_quote($key, $delim); |
| 5785 | 6109 | $new_key = $key; |
| 5786 | 6110 | |
| 5787 | - if (empty($value)) |
|
| 5788 | - $sub_regex = ''; |
|
| 5789 | - else |
|
| 6111 | + if (empty($value)) { |
|
| 6112 | + $sub_regex = ''; |
|
| 6113 | + } else |
|
| 5790 | 6114 | { |
| 5791 | 6115 | $sub_regex = $index_to_regex($value, $delim); |
| 5792 | 6116 | |
@@ -5794,22 +6118,22 @@ discard block |
||
| 5794 | 6118 | { |
| 5795 | 6119 | $new_key_array = explode('(?'.'>', $sub_regex); |
| 5796 | 6120 | $new_key .= $new_key_array[0]; |
| 6121 | + } else { |
|
| 6122 | + $sub_regex = '(?'.'>' . $sub_regex . ')'; |
|
| 5797 | 6123 | } |
| 5798 | - else |
|
| 5799 | - $sub_regex = '(?'.'>' . $sub_regex . ')'; |
|
| 5800 | 6124 | } |
| 5801 | 6125 | |
| 5802 | - if ($depth > 1) |
|
| 5803 | - $regex[$new_key] = $key_regex . $sub_regex; |
|
| 5804 | - else |
|
| 6126 | + if ($depth > 1) { |
|
| 6127 | + $regex[$new_key] = $key_regex . $sub_regex; |
|
| 6128 | + } else |
|
| 5805 | 6129 | { |
| 5806 | 6130 | if (($length += strlen($key_regex) + 1) < $max_length || empty($regex)) |
| 5807 | 6131 | { |
| 5808 | 6132 | $regex[$new_key] = $key_regex . $sub_regex; |
| 5809 | 6133 | unset($index[$key]); |
| 6134 | + } else { |
|
| 6135 | + break; |
|
| 5810 | 6136 | } |
| 5811 | - else |
|
| 5812 | - break; |
|
| 5813 | 6137 | } |
| 5814 | 6138 | } |
| 5815 | 6139 | |
@@ -5818,10 +6142,11 @@ discard block |
||
| 5818 | 6142 | $l1 = $strlen($k1); |
| 5819 | 6143 | $l2 = $strlen($k2); |
| 5820 | 6144 | |
| 5821 | - if ($l1 == $l2) |
|
| 5822 | - return strcmp($k1, $k2) > 0 ? 1 : -1; |
|
| 5823 | - else |
|
| 5824 | - return $l1 > $l2 ? -1 : 1; |
|
| 6145 | + if ($l1 == $l2) { |
|
| 6146 | + return strcmp($k1, $k2) > 0 ? 1 : -1; |
|
| 6147 | + } else { |
|
| 6148 | + return $l1 > $l2 ? -1 : 1; |
|
| 6149 | + } |
|
| 5825 | 6150 | }); |
| 5826 | 6151 | |
| 5827 | 6152 | $depth--; |
@@ -5832,15 +6157,18 @@ discard block |
||
| 5832 | 6157 | $index = array(); |
| 5833 | 6158 | $regexes = array(); |
| 5834 | 6159 | |
| 5835 | - foreach ($strings as $string) |
|
| 5836 | - $index = $add_string_to_index($string, $index); |
|
| 6160 | + foreach ($strings as $string) { |
|
| 6161 | + $index = $add_string_to_index($string, $index); |
|
| 6162 | + } |
|
| 5837 | 6163 | |
| 5838 | - while (!empty($index)) |
|
| 5839 | - $regexes[] = '(?'.'>' . $index_to_regex($index, $delim) . ')'; |
|
| 6164 | + while (!empty($index)) { |
|
| 6165 | + $regexes[] = '(?'.'>' . $index_to_regex($index, $delim) . ')'; |
|
| 6166 | + } |
|
| 5840 | 6167 | |
| 5841 | 6168 | // Restore PHP's internal character encoding to whatever it was originally |
| 5842 | - if (!empty($current_encoding)) |
|
| 5843 | - mb_internal_encoding($current_encoding); |
|
| 6169 | + if (!empty($current_encoding)) { |
|
| 6170 | + mb_internal_encoding($current_encoding); |
|
| 6171 | + } |
|
| 5844 | 6172 | |
| 5845 | 6173 | return $regexes; |
| 5846 | 6174 | } |
@@ -402,7 +402,7 @@ |
||
| 402 | 402 | * A private function to find out the subscription details. |
| 403 | 403 | * |
| 404 | 404 | * @access private |
| 405 | - * @return boolean|void False on failure, otherwise just sets $_POST['item_number'] |
|
| 405 | + * @return false|null False on failure, otherwise just sets $_POST['item_number'] |
|
| 406 | 406 | */ |
| 407 | 407 | private function _findSubscription() |
| 408 | 408 | { |
@@ -236,7 +236,7 @@ |
||
| 236 | 236 | $header = 'POST /cgi-bin/webscr HTTP/1.1' . "\r\n"; |
| 237 | 237 | $header .= 'Content-Type: application/x-www-form-urlencoded' . "\r\n"; |
| 238 | 238 | $header .= 'Host: www.' . (!empty($modSettings['paidsubs_test']) ? 'sandbox.' : '') . 'paypal.com' . "\r\n"; |
| 239 | - $header .= 'Content-Length: ' . strlen ($requestString) . "\r\n"; |
|
| 239 | + $header .= 'Content-Length: ' . strlen($requestString) . "\r\n"; |
|
| 240 | 240 | $header .= 'Connection: close' . "\r\n\r\n"; |
| 241 | 241 | |
| 242 | 242 | // Open the connection. |
@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | // This won't be dedicated without this - this must exist in each gateway! |
| 15 | 15 | // SMF Payment Gateway: paypal |
| 16 | 16 | |
| 17 | -if (!defined('SMF')) |
|
| 17 | +if (!defined('SMF')) { |
|
| 18 | 18 | die('No direct access...'); |
| 19 | +} |
|
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * Class for returning available form data for this gateway |
@@ -118,8 +119,7 @@ discard block |
||
| 118 | 119 | { |
| 119 | 120 | $return_data['hidden']['p3'] = 1; |
| 120 | 121 | $return_data['hidden']['t3'] = strtoupper(substr($period, 0, 1)); |
| 121 | - } |
|
| 122 | - else |
|
| 122 | + } else |
|
| 123 | 123 | { |
| 124 | 124 | preg_match('~(\d*)(\w)~', $sub_data['real_length'], $match); |
| 125 | 125 | $unit = $match[1]; |
@@ -130,14 +130,15 @@ discard block |
||
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | // If it's repeatable do some javascript to respect this idea. |
| 133 | - if (!empty($sub_data['repeatable'])) |
|
| 134 | - $return_data['javascript'] = ' |
|
| 133 | + if (!empty($sub_data['repeatable'])) { |
|
| 134 | + $return_data['javascript'] = ' |
|
| 135 | 135 | document.write(\'<label for="do_paypal_recur"><input type="checkbox" name="do_paypal_recur" id="do_paypal_recur" checked onclick="switchPaypalRecur();" class="input_check">' . $txt['paid_make_recurring'] . '</label><br>\'); |
| 136 | 136 | |
| 137 | 137 | function switchPaypalRecur() |
| 138 | 138 | { |
| 139 | 139 | document.getElementById("paypal_cmd").value = document.getElementById("do_paypal_recur").checked ? "_xclick-subscriptions" : "_xclick"; |
| 140 | 140 | }'; |
| 141 | + } |
|
| 141 | 142 | |
| 142 | 143 | return $return_data; |
| 143 | 144 | } |
@@ -160,20 +161,24 @@ discard block |
||
| 160 | 161 | global $modSettings; |
| 161 | 162 | |
| 162 | 163 | // Has the user set up an email address? |
| 163 | - if ((empty($modSettings['paidsubs_test']) && empty($modSettings['paypal_email'])) || (!empty($modSettings['paidsubs_test']) && empty($modSettings['paypal_sandbox_email']))) |
|
| 164 | - return false; |
|
| 164 | + if ((empty($modSettings['paidsubs_test']) && empty($modSettings['paypal_email'])) || (!empty($modSettings['paidsubs_test']) && empty($modSettings['paypal_sandbox_email']))) { |
|
| 165 | + return false; |
|
| 166 | + } |
|
| 165 | 167 | // Check the correct transaction types are even here. |
| 166 | - if ((!isset($_POST['txn_type']) && !isset($_POST['payment_status'])) || (!isset($_POST['business']) && !isset($_POST['receiver_email']))) |
|
| 167 | - return false; |
|
| 168 | + if ((!isset($_POST['txn_type']) && !isset($_POST['payment_status'])) || (!isset($_POST['business']) && !isset($_POST['receiver_email']))) { |
|
| 169 | + return false; |
|
| 170 | + } |
|
| 168 | 171 | // Correct email address? |
| 169 | - if (!isset($_POST['business'])) |
|
| 170 | - $_POST['business'] = $_POST['receiver_email']; |
|
| 172 | + if (!isset($_POST['business'])) { |
|
| 173 | + $_POST['business'] = $_POST['receiver_email']; |
|
| 174 | + } |
|
| 171 | 175 | |
| 172 | 176 | // Are we testing? |
| 173 | - if (empty($modSettings['paidsubs_test']) && strtolower($modSettings['paypal_sandbox_email']) != strtolower($_POST['business']) && (empty($modSettings['paypal_additional_emails']) || !in_array(strtolower($_POST['business']), explode(',', strtolower($modSettings['paypal_additional_emails']))))) |
|
| 174 | - return false; |
|
| 175 | - elseif (strtolower($modSettings['paypal_email']) != strtolower($_POST['business']) && (empty($modSettings['paypal_additional_emails']) || !in_array(strtolower($_POST['business']), explode(',', $modSettings['paypal_additional_emails'])))) |
|
| 176 | - return false; |
|
| 177 | + if (empty($modSettings['paidsubs_test']) && strtolower($modSettings['paypal_sandbox_email']) != strtolower($_POST['business']) && (empty($modSettings['paypal_additional_emails']) || !in_array(strtolower($_POST['business']), explode(',', strtolower($modSettings['paypal_additional_emails']))))) { |
|
| 178 | + return false; |
|
| 179 | + } elseif (strtolower($modSettings['paypal_email']) != strtolower($_POST['business']) && (empty($modSettings['paypal_additional_emails']) || !in_array(strtolower($_POST['business']), explode(',', $modSettings['paypal_additional_emails'])))) { |
|
| 180 | + return false; |
|
| 181 | + } |
|
| 177 | 182 | return true; |
| 178 | 183 | } |
| 179 | 184 | |
@@ -192,15 +197,17 @@ discard block |
||
| 192 | 197 | global $modSettings, $txt; |
| 193 | 198 | |
| 194 | 199 | // Put this to some default value. |
| 195 | - if (!isset($_POST['txn_type'])) |
|
| 196 | - $_POST['txn_type'] = ''; |
|
| 200 | + if (!isset($_POST['txn_type'])) { |
|
| 201 | + $_POST['txn_type'] = ''; |
|
| 202 | + } |
|
| 197 | 203 | |
| 198 | 204 | // Build the request string - starting with the minimum requirement. |
| 199 | 205 | $requestString = 'cmd=_notify-validate'; |
| 200 | 206 | |
| 201 | 207 | // Now my dear, add all the posted bits in the order we got them |
| 202 | - foreach ($_POST as $k => $v) |
|
| 203 | - $requestString .= '&' . $k . '=' . urlencode($v); |
|
| 208 | + foreach ($_POST as $k => $v) { |
|
| 209 | + $requestString .= '&' . $k . '=' . urlencode($v); |
|
| 210 | + } |
|
| 204 | 211 | |
| 205 | 212 | // Can we use curl? |
| 206 | 213 | if (function_exists('curl_init') && $curl = curl_init((!empty($modSettings['paidsubs_test']) ? 'https://www.sandbox.' : 'http://www.') . 'paypal.com/cgi-bin/webscr')) |
@@ -240,14 +247,16 @@ discard block |
||
| 240 | 247 | $header .= 'Connection: close' . "\r\n\r\n"; |
| 241 | 248 | |
| 242 | 249 | // Open the connection. |
| 243 | - if (!empty($modSettings['paidsubs_test'])) |
|
| 244 | - $fp = fsockopen('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30); |
|
| 245 | - else |
|
| 246 | - $fp = fsockopen('www.paypal.com', 80, $errno, $errstr, 30); |
|
| 250 | + if (!empty($modSettings['paidsubs_test'])) { |
|
| 251 | + $fp = fsockopen('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30); |
|
| 252 | + } else { |
|
| 253 | + $fp = fsockopen('www.paypal.com', 80, $errno, $errstr, 30); |
|
| 254 | + } |
|
| 247 | 255 | |
| 248 | 256 | // Did it work? |
| 249 | - if (!$fp) |
|
| 250 | - generateSubscriptionError($txt['paypal_could_not_connect']); |
|
| 257 | + if (!$fp) { |
|
| 258 | + generateSubscriptionError($txt['paypal_could_not_connect']); |
|
| 259 | + } |
|
| 251 | 260 | |
| 252 | 261 | // Put the data to the port. |
| 253 | 262 | fputs($fp, $header . $requestString); |
@@ -256,8 +265,9 @@ discard block |
||
| 256 | 265 | while (!feof($fp)) |
| 257 | 266 | { |
| 258 | 267 | $this->return_data = fgets($fp, 1024); |
| 259 | - if (strcmp(trim($this->return_data), 'VERIFIED') === 0) |
|
| 260 | - break; |
|
| 268 | + if (strcmp(trim($this->return_data), 'VERIFIED') === 0) { |
|
| 269 | + break; |
|
| 270 | + } |
|
| 261 | 271 | } |
| 262 | 272 | |
| 263 | 273 | // Clean up. |
@@ -265,28 +275,34 @@ discard block |
||
| 265 | 275 | } |
| 266 | 276 | |
| 267 | 277 | // If this isn't verified then give up... |
| 268 | - if (strcmp(trim($this->return_data), 'VERIFIED') !== 0) |
|
| 269 | - exit; |
|
| 278 | + if (strcmp(trim($this->return_data), 'VERIFIED') !== 0) { |
|
| 279 | + exit; |
|
| 280 | + } |
|
| 270 | 281 | |
| 271 | 282 | // Check that this is intended for us. |
| 272 | - if (strtolower($modSettings['paypal_email']) != strtolower($_POST['business']) && (empty($modSettings['paypal_additional_emails']) || !in_array(strtolower($_POST['business']), explode(',', strtolower($modSettings['paypal_additional_emails']))))) |
|
| 273 | - exit; |
|
| 283 | + if (strtolower($modSettings['paypal_email']) != strtolower($_POST['business']) && (empty($modSettings['paypal_additional_emails']) || !in_array(strtolower($_POST['business']), explode(',', strtolower($modSettings['paypal_additional_emails']))))) { |
|
| 284 | + exit; |
|
| 285 | + } |
|
| 274 | 286 | |
| 275 | 287 | // Is this a subscription - and if so is it a secondary payment that we need to process? |
| 276 | 288 | // If so, make sure we get it in the expected format. Seems PayPal sometimes sends it without urlencoding. |
| 277 | - if (!empty($_POST['item_number']) && strpos($_POST['item_number'], ' ') !== false) |
|
| 278 | - $_POST['item_number'] = str_replace(' ', '+', $_POST['item_number']); |
|
| 279 | - if ($this->isSubscription() && (empty($_POST['item_number']) || strpos($_POST['item_number'], '+') === false)) |
|
| 280 | - // Calculate the subscription it relates to! |
|
| 289 | + if (!empty($_POST['item_number']) && strpos($_POST['item_number'], ' ') !== false) { |
|
| 290 | + $_POST['item_number'] = str_replace(' ', '+', $_POST['item_number']); |
|
| 291 | + } |
|
| 292 | + if ($this->isSubscription() && (empty($_POST['item_number']) || strpos($_POST['item_number'], '+') === false)) { |
|
| 293 | + // Calculate the subscription it relates to! |
|
| 281 | 294 | $this->_findSubscription(); |
| 295 | + } |
|
| 282 | 296 | |
| 283 | 297 | // Verify the currency! |
| 284 | - if (strtolower($_POST['mc_currency']) !== strtolower($modSettings['paid_currency_code'])) |
|
| 285 | - exit; |
|
| 298 | + if (strtolower($_POST['mc_currency']) !== strtolower($modSettings['paid_currency_code'])) { |
|
| 299 | + exit; |
|
| 300 | + } |
|
| 286 | 301 | |
| 287 | 302 | // Can't exist if it doesn't contain anything. |
| 288 | - if (empty($_POST['item_number'])) |
|
| 289 | - exit; |
|
| 303 | + if (empty($_POST['item_number'])) { |
|
| 304 | + exit; |
|
| 305 | + } |
|
| 290 | 306 | |
| 291 | 307 | // Return the id_sub and id_member |
| 292 | 308 | return explode('+', $_POST['item_number']); |
@@ -299,10 +315,11 @@ discard block |
||
| 299 | 315 | */ |
| 300 | 316 | public function isRefund() |
| 301 | 317 | { |
| 302 | - if ($_POST['payment_status'] === 'Refunded' || $_POST['payment_status'] === 'Reversed' || $_POST['txn_type'] === 'Refunded' || ($_POST['txn_type'] === 'reversal' && $_POST['payment_status'] === 'Completed')) |
|
| 303 | - return true; |
|
| 304 | - else |
|
| 305 | - return false; |
|
| 318 | + if ($_POST['payment_status'] === 'Refunded' || $_POST['payment_status'] === 'Reversed' || $_POST['txn_type'] === 'Refunded' || ($_POST['txn_type'] === 'reversal' && $_POST['payment_status'] === 'Completed')) { |
|
| 319 | + return true; |
|
| 320 | + } else { |
|
| 321 | + return false; |
|
| 322 | + } |
|
| 306 | 323 | } |
| 307 | 324 | |
| 308 | 325 | /** |
@@ -312,10 +329,11 @@ discard block |
||
| 312 | 329 | */ |
| 313 | 330 | public function isSubscription() |
| 314 | 331 | { |
| 315 | - if (substr($_POST['txn_type'], 0, 14) === 'subscr_payment' && $_POST['payment_status'] === 'Completed') |
|
| 316 | - return true; |
|
| 317 | - else |
|
| 318 | - return false; |
|
| 332 | + if (substr($_POST['txn_type'], 0, 14) === 'subscr_payment' && $_POST['payment_status'] === 'Completed') { |
|
| 333 | + return true; |
|
| 334 | + } else { |
|
| 335 | + return false; |
|
| 336 | + } |
|
| 319 | 337 | } |
| 320 | 338 | |
| 321 | 339 | /** |
@@ -325,10 +343,11 @@ discard block |
||
| 325 | 343 | */ |
| 326 | 344 | public function isPayment() |
| 327 | 345 | { |
| 328 | - if ($_POST['payment_status'] === 'Completed' && $_POST['txn_type'] === 'web_accept') |
|
| 329 | - return true; |
|
| 330 | - else |
|
| 331 | - return false; |
|
| 346 | + if ($_POST['payment_status'] === 'Completed' && $_POST['txn_type'] === 'web_accept') { |
|
| 347 | + return true; |
|
| 348 | + } else { |
|
| 349 | + return false; |
|
| 350 | + } |
|
| 332 | 351 | } |
| 333 | 352 | |
| 334 | 353 | /** |
@@ -341,10 +360,11 @@ discard block |
||
| 341 | 360 | // subscr_cancel is sent when the user cancels, subscr_eot is sent when the subscription reaches final payment |
| 342 | 361 | // Neither require us to *do* anything as per performCancel(). |
| 343 | 362 | // subscr_eot, if sent, indicates an end of payments term. |
| 344 | - if (substr($_POST['txn_type'], 0, 13) === 'subscr_cancel' || substr($_POST['txn_type'], 0, 10) === 'subscr_eot') |
|
| 345 | - return true; |
|
| 346 | - else |
|
| 347 | - return false; |
|
| 363 | + if (substr($_POST['txn_type'], 0, 13) === 'subscr_cancel' || substr($_POST['txn_type'], 0, 10) === 'subscr_eot') { |
|
| 364 | + return true; |
|
| 365 | + } else { |
|
| 366 | + return false; |
|
| 367 | + } |
|
| 348 | 368 | } |
| 349 | 369 | |
| 350 | 370 | /** |
@@ -409,8 +429,9 @@ discard block |
||
| 409 | 429 | global $smcFunc; |
| 410 | 430 | |
| 411 | 431 | // Assume we have this? |
| 412 | - if (empty($_POST['subscr_id'])) |
|
| 413 | - return false; |
|
| 432 | + if (empty($_POST['subscr_id'])) { |
|
| 433 | + return false; |
|
| 434 | + } |
|
| 414 | 435 | |
| 415 | 436 | // Do we have this in the database? |
| 416 | 437 | $request = $smcFunc['db_query']('', ' |
@@ -439,11 +460,12 @@ discard block |
||
| 439 | 460 | 'payer_email' => $_POST['payer_email'], |
| 440 | 461 | ) |
| 441 | 462 | ); |
| 442 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
| 443 | - return false; |
|
| 463 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
| 464 | + return false; |
|
| 465 | + } |
|
| 466 | + } else { |
|
| 467 | + return false; |
|
| 444 | 468 | } |
| 445 | - else |
|
| 446 | - return false; |
|
| 447 | 469 | } |
| 448 | 470 | list ($member_id, $subscription_id) = $smcFunc['db_fetch_row']($request); |
| 449 | 471 | $_POST['item_number'] = $member_id . '+' . $subscription_id; |
@@ -21,7 +21,7 @@ |
||
| 21 | 21 | { |
| 22 | 22 | /** |
| 23 | 23 | * This executes the task - loads up the information, puts the email in the queue and inserts alerts as needed. |
| 24 | - * @return bool Always returns true |
|
| 24 | + * @return boolean|null Always returns true |
|
| 25 | 25 | */ |
| 26 | 26 | public function execute() |
| 27 | 27 | { |
@@ -32,8 +32,9 @@ discard block |
||
| 32 | 32 | $members = membersAllowedTo('calendar_view'); |
| 33 | 33 | |
| 34 | 34 | // Don't alert the event creator |
| 35 | - if (!empty($this->_details['sender_id'])) |
|
| 36 | - $members = array_diff($members, array($this->_details['sender_id'])); |
|
| 35 | + if (!empty($this->_details['sender_id'])) { |
|
| 36 | + $members = array_diff($members, array($this->_details['sender_id'])); |
|
| 37 | + } |
|
| 37 | 38 | |
| 38 | 39 | // Having successfully figured this out, now let's get the preferences of everyone. |
| 39 | 40 | require_once($sourcedir . '/Subs-Notify.php'); |
@@ -44,10 +45,11 @@ discard block |
||
| 44 | 45 | if (!empty($this->_details['sender_id']) && empty($this->_details['sender_name'])) |
| 45 | 46 | { |
| 46 | 47 | loadMemberData($this->_details['sender_id'], 'minimal'); |
| 47 | - if (!empty($user_profile[$this->_details['sender_id']])) |
|
| 48 | - $this->_details['sender_name'] = $user_profile[$this->_details['sender_id']]['real_name']; |
|
| 49 | - else |
|
| 50 | - $this->_details['sender_id'] = 0; |
|
| 48 | + if (!empty($user_profile[$this->_details['sender_id']])) { |
|
| 49 | + $this->_details['sender_name'] = $user_profile[$this->_details['sender_id']]['real_name']; |
|
| 50 | + } else { |
|
| 51 | + $this->_details['sender_id'] = 0; |
|
| 52 | + } |
|
| 51 | 53 | } |
| 52 | 54 | |
| 53 | 55 | // So now we find out who wants what. |
@@ -59,9 +61,10 @@ discard block |
||
| 59 | 61 | |
| 60 | 62 | foreach ($prefs as $member => $pref_option) |
| 61 | 63 | { |
| 62 | - foreach ($alert_bits as $type => $bitvalue) |
|
| 63 | - if ($pref_option['event_new'] & $bitvalue) |
|
| 64 | + foreach ($alert_bits as $type => $bitvalue) { |
|
| 65 | + if ($pref_option['event_new'] & $bitvalue) |
|
| 64 | 66 | $notifies[$type][] = $member; |
| 67 | + } |
|
| 65 | 68 | } |
| 66 | 69 | |
| 67 | 70 | // Firstly, anyone who wants alerts. |
@@ -19,7 +19,7 @@ |
||
| 19 | 19 | class Likes_Notify_Background extends SMF_BackgroundTask |
| 20 | 20 | { |
| 21 | 21 | /** |
| 22 | - * This executes the task - loads up the information, puts the email in the queue and inserts alerts as needed. |
|
| 22 | + * This executes the task - loads up the information, puts the email in the queue and inserts alerts as needed. |
|
| 23 | 23 | * @return bool Always returns true |
| 24 | 24 | */ |
| 25 | 25 | public function execute() |
@@ -80,7 +80,7 @@ |
||
| 80 | 80 | /** |
| 81 | 81 | * Handles retrieving previews of news items, newsletters, signatures and warnings. |
| 82 | 82 | * Calls the appropriate function based on $_POST['item'] |
| 83 | - * @return void|bool Returns false if $_POST['item'] isn't set or isn't valid |
|
| 83 | + * @return false|null Returns false if $_POST['item'] isn't set or isn't valid |
|
| 84 | 84 | */ |
| 85 | 85 | function RetrievePreview() |
| 86 | 86 | { |
@@ -272,13 +272,13 @@ |
||
| 272 | 272 | $context['post_error']['messages'][] = $txt['mc_warning_template_error_no_body']; |
| 273 | 273 | // Add in few replacements. |
| 274 | 274 | /** |
| 275 | - * These are the defaults: |
|
| 276 | - * - {MEMBER} - Member Name. => current user for review |
|
| 277 | - * - {MESSAGE} - Link to Offending Post. (If Applicable) => not applicable here, so not replaced |
|
| 278 | - * - {FORUMNAME} - Forum Name. |
|
| 279 | - * - {SCRIPTURL} - Web address of forum. |
|
| 280 | - * - {REGARDS} - Standard email sign-off. |
|
| 281 | - */ |
|
| 275 | + * These are the defaults: |
|
| 276 | + * - {MEMBER} - Member Name. => current user for review |
|
| 277 | + * - {MESSAGE} - Link to Offending Post. (If Applicable) => not applicable here, so not replaced |
|
| 278 | + * - {FORUMNAME} - Forum Name. |
|
| 279 | + * - {SCRIPTURL} - Web address of forum. |
|
| 280 | + * - {REGARDS} - Standard email sign-off. |
|
| 281 | + */ |
|
| 282 | 282 | $find = array( |
| 283 | 283 | '{MEMBER}', |
| 284 | 284 | '{FORUMNAME}', |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 3 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * The main handler and designator for AJAX stuff - jumpto, message icons and previews |
@@ -32,8 +33,9 @@ discard block |
||
| 32 | 33 | // Easy adding of sub actions. |
| 33 | 34 | call_integration_hook('integrate_XMLhttpMain_subActions', array(&$subActions)); |
| 34 | 35 | |
| 35 | - if (!isset($_REQUEST['sa'], $subActions[$_REQUEST['sa']])) |
|
| 36 | - fatal_lang_error('no_access', false); |
|
| 36 | + if (!isset($_REQUEST['sa'], $subActions[$_REQUEST['sa']])) { |
|
| 37 | + fatal_lang_error('no_access', false); |
|
| 38 | + } |
|
| 37 | 39 | |
| 38 | 40 | call_helper($subActions[$_REQUEST['sa']]); |
| 39 | 41 | } |
@@ -57,8 +59,9 @@ discard block |
||
| 57 | 59 | foreach ($context['jump_to'] as $id_cat => $cat) |
| 58 | 60 | { |
| 59 | 61 | $context['jump_to'][$id_cat]['name'] = un_htmlspecialchars(strip_tags($cat['name'])); |
| 60 | - foreach ($cat['boards'] as $id_board => $board) |
|
| 61 | - $context['jump_to'][$id_cat]['boards'][$id_board]['name'] = un_htmlspecialchars(strip_tags($board['name'])); |
|
| 62 | + foreach ($cat['boards'] as $id_board => $board) { |
|
| 63 | + $context['jump_to'][$id_cat]['boards'][$id_board]['name'] = un_htmlspecialchars(strip_tags($board['name'])); |
|
| 64 | + } |
|
| 62 | 65 | } |
| 63 | 66 | |
| 64 | 67 | $context['sub_template'] = 'jump_to'; |
@@ -95,8 +98,9 @@ discard block |
||
| 95 | 98 | |
| 96 | 99 | $context['sub_template'] = 'generic_xml'; |
| 97 | 100 | |
| 98 | - if (!isset($_POST['item']) || !in_array($_POST['item'], $items)) |
|
| 99 | - return false; |
|
| 101 | + if (!isset($_POST['item']) || !in_array($_POST['item'], $items)) { |
|
| 102 | + return false; |
|
| 103 | + } |
|
| 100 | 104 | |
| 101 | 105 | $_POST['item'](); |
| 102 | 106 | } |
@@ -112,10 +116,11 @@ discard block |
||
| 112 | 116 | |
| 113 | 117 | $errors = array(); |
| 114 | 118 | $news = !isset($_POST['news'])? '' : $smcFunc['htmlspecialchars']($_POST['news'], ENT_QUOTES); |
| 115 | - if (empty($news)) |
|
| 116 | - $errors[] = array('value' => 'no_news'); |
|
| 117 | - else |
|
| 118 | - preparsecode($news); |
|
| 119 | + if (empty($news)) { |
|
| 120 | + $errors[] = array('value' => 'no_news'); |
|
| 121 | + } else { |
|
| 122 | + preparsecode($news); |
|
| 123 | + } |
|
| 119 | 124 | |
| 120 | 125 | $context['xml_data'] = array( |
| 121 | 126 | 'news' => array( |
@@ -148,10 +153,12 @@ discard block |
||
| 148 | 153 | $context['send_pm'] = !empty($_POST['send_pm']) ? 1 : 0; |
| 149 | 154 | $context['send_html'] = !empty($_POST['send_html']) ? 1 : 0; |
| 150 | 155 | |
| 151 | - if (empty($_POST['subject'])) |
|
| 152 | - $context['post_error']['messages'][] = $txt['error_no_subject']; |
|
| 153 | - if (empty($_POST['message'])) |
|
| 154 | - $context['post_error']['messages'][] = $txt['error_no_message']; |
|
| 156 | + if (empty($_POST['subject'])) { |
|
| 157 | + $context['post_error']['messages'][] = $txt['error_no_subject']; |
|
| 158 | + } |
|
| 159 | + if (empty($_POST['message'])) { |
|
| 160 | + $context['post_error']['messages'][] = $txt['error_no_message']; |
|
| 161 | + } |
|
| 155 | 162 | |
| 156 | 163 | prepareMailingForPreview(); |
| 157 | 164 | |
@@ -196,38 +203,41 @@ discard block |
||
| 196 | 203 | $preview_signature = !empty($_POST['signature']) ? $_POST['signature'] : $txt['no_signature_preview']; |
| 197 | 204 | $validation = profileValidateSignature($preview_signature); |
| 198 | 205 | |
| 199 | - if ($validation !== true && $validation !== false) |
|
| 200 | - $errors[] = array('value' => $txt['profile_error_' . $validation], 'attributes' => array('type' => 'error')); |
|
| 206 | + if ($validation !== true && $validation !== false) { |
|
| 207 | + $errors[] = array('value' => $txt['profile_error_' . $validation], 'attributes' => array('type' => 'error')); |
|
| 208 | + } |
|
| 201 | 209 | |
| 202 | 210 | censorText($preview_signature); |
| 203 | 211 | $preview_signature = parse_bbc($preview_signature, true, 'sig' . $user); |
| 204 | - } |
|
| 205 | - elseif (!$can_change) |
|
| 212 | + } elseif (!$can_change) |
|
| 206 | 213 | { |
| 207 | - if ($is_owner) |
|
| 208 | - $errors[] = array('value' => $txt['cannot_profile_extra_own'], 'attributes' => array('type' => 'error')); |
|
| 209 | - else |
|
| 210 | - $errors[] = array('value' => $txt['cannot_profile_extra_any'], 'attributes' => array('type' => 'error')); |
|
| 214 | + if ($is_owner) { |
|
| 215 | + $errors[] = array('value' => $txt['cannot_profile_extra_own'], 'attributes' => array('type' => 'error')); |
|
| 216 | + } else { |
|
| 217 | + $errors[] = array('value' => $txt['cannot_profile_extra_any'], 'attributes' => array('type' => 'error')); |
|
| 218 | + } |
|
| 219 | + } else { |
|
| 220 | + $errors[] = array('value' => $txt['no_user_selected'], 'attributes' => array('type' => 'error')); |
|
| 211 | 221 | } |
| 212 | - else |
|
| 213 | - $errors[] = array('value' => $txt['no_user_selected'], 'attributes' => array('type' => 'error')); |
|
| 214 | 222 | |
| 215 | 223 | $context['xml_data']['signatures'] = array( |
| 216 | 224 | 'identifier' => 'signature', |
| 217 | 225 | 'children' => array() |
| 218 | 226 | ); |
| 219 | - if (isset($current_signature)) |
|
| 220 | - $context['xml_data']['signatures']['children'][] = array( |
|
| 227 | + if (isset($current_signature)) { |
|
| 228 | + $context['xml_data']['signatures']['children'][] = array( |
|
| 221 | 229 | 'value' => $current_signature, |
| 222 | 230 | 'attributes' => array('type' => 'current'), |
| 223 | 231 | ); |
| 224 | - if (isset($preview_signature)) |
|
| 225 | - $context['xml_data']['signatures']['children'][] = array( |
|
| 232 | + } |
|
| 233 | + if (isset($preview_signature)) { |
|
| 234 | + $context['xml_data']['signatures']['children'][] = array( |
|
| 226 | 235 | 'value' => $preview_signature, |
| 227 | 236 | 'attributes' => array('type' => 'preview'), |
| 228 | 237 | ); |
| 229 | - if (!empty($errors)) |
|
| 230 | - $context['xml_data']['errors'] = array( |
|
| 238 | + } |
|
| 239 | + if (!empty($errors)) { |
|
| 240 | + $context['xml_data']['errors'] = array( |
|
| 231 | 241 | 'identifier' => 'error', |
| 232 | 242 | 'children' => array_merge( |
| 233 | 243 | array( |
@@ -239,7 +249,8 @@ discard block |
||
| 239 | 249 | $errors |
| 240 | 250 | ), |
| 241 | 251 | ); |
| 242 | -} |
|
| 252 | + } |
|
| 253 | + } |
|
| 243 | 254 | |
| 244 | 255 | /** |
| 245 | 256 | * Handles previewing user warnings |
@@ -261,15 +272,17 @@ discard block |
||
| 261 | 272 | $context['preview_subject'] = !empty($_POST['title']) ? trim($smcFunc['htmlspecialchars']($_POST['title'])) : ''; |
| 262 | 273 | if (isset($_POST['issuing'])) |
| 263 | 274 | { |
| 264 | - if (empty($_POST['title']) || empty($_POST['body'])) |
|
| 265 | - $context['post_error']['messages'][] = $txt['warning_notify_blank']; |
|
| 266 | - } |
|
| 267 | - else |
|
| 275 | + if (empty($_POST['title']) || empty($_POST['body'])) { |
|
| 276 | + $context['post_error']['messages'][] = $txt['warning_notify_blank']; |
|
| 277 | + } |
|
| 278 | + } else |
|
| 268 | 279 | { |
| 269 | - if (empty($_POST['title'])) |
|
| 270 | - $context['post_error']['messages'][] = $txt['mc_warning_template_error_no_title']; |
|
| 271 | - if (empty($_POST['body'])) |
|
| 272 | - $context['post_error']['messages'][] = $txt['mc_warning_template_error_no_body']; |
|
| 280 | + if (empty($_POST['title'])) { |
|
| 281 | + $context['post_error']['messages'][] = $txt['mc_warning_template_error_no_title']; |
|
| 282 | + } |
|
| 283 | + if (empty($_POST['body'])) { |
|
| 284 | + $context['post_error']['messages'][] = $txt['mc_warning_template_error_no_body']; |
|
| 285 | + } |
|
| 273 | 286 | // Add in few replacements. |
| 274 | 287 | /** |
| 275 | 288 | * These are the defaults: |
@@ -300,9 +313,9 @@ discard block |
||
| 300 | 313 | $warning_body = parse_bbc($warning_body, true); |
| 301 | 314 | } |
| 302 | 315 | $context['preview_message'] = $warning_body; |
| 316 | + } else { |
|
| 317 | + $context['post_error']['messages'][] = array('value' => $txt['cannot_issue_warning'], 'attributes' => array('type' => 'error')); |
|
| 303 | 318 | } |
| 304 | - else |
|
| 305 | - $context['post_error']['messages'][] = array('value' => $txt['cannot_issue_warning'], 'attributes' => array('type' => 'error')); |
|
| 306 | 319 | |
| 307 | 320 | $context['sub_template'] = 'warning'; |
| 308 | 321 | } |
@@ -1717,7 +1717,7 @@ discard block |
||
| 1717 | 1717 | /** |
| 1718 | 1718 | * Show today's birthdays. |
| 1719 | 1719 | * @param string $output_method The output method. If 'echo', displays a list of users, otherwise returns an array of info about them. |
| 1720 | - * @return void|array Displays a list of users or returns an array of info about them depending on output_method. |
|
| 1720 | + * @return null|string Displays a list of users or returns an array of info about them depending on output_method. |
|
| 1721 | 1721 | */ |
| 1722 | 1722 | function ssi_todaysBirthdays($output_method = 'echo') |
| 1723 | 1723 | { |
@@ -1746,7 +1746,7 @@ discard block |
||
| 1746 | 1746 | /** |
| 1747 | 1747 | * Shows today's holidays. |
| 1748 | 1748 | * @param string $output_method The output method. If 'echo', displays a list of holidays, otherwise returns an array of info about them. |
| 1749 | - * @return void|array Displays a list of holidays or returns an array of info about them depending on output_method |
|
| 1749 | + * @return null|string Displays a list of holidays or returns an array of info about them depending on output_method |
|
| 1750 | 1750 | */ |
| 1751 | 1751 | function ssi_todaysHolidays($output_method = 'echo') |
| 1752 | 1752 | { |
@@ -1773,7 +1773,7 @@ discard block |
||
| 1773 | 1773 | |
| 1774 | 1774 | /** |
| 1775 | 1775 | * @param string $output_method The output method. If 'echo', displays a list of events, otherwise returns an array of info about them. |
| 1776 | - * @return void|array Displays a list of events or returns an array of info about them depending on output_method |
|
| 1776 | + * @return null|string Displays a list of events or returns an array of info about them depending on output_method |
|
| 1777 | 1777 | */ |
| 1778 | 1778 | function ssi_todaysEvents($output_method = 'echo') |
| 1779 | 1779 | { |
@@ -1807,7 +1807,7 @@ discard block |
||
| 1807 | 1807 | /** |
| 1808 | 1808 | * Shows today's calendar items (events, birthdays and holidays) |
| 1809 | 1809 | * @param string $output_method The output method. If 'echo', displays a list of calendar items, otherwise returns an array of info about them. |
| 1810 | - * @return void|array Displays a list of calendar items or returns an array of info about them depending on output_method |
|
| 1810 | + * @return null|string Displays a list of calendar items or returns an array of info about them depending on output_method |
|
| 1811 | 1811 | */ |
| 1812 | 1812 | function ssi_todaysCalendar($output_method = 'echo') |
| 1813 | 1813 | { |
@@ -2198,7 +2198,7 @@ discard block |
||
| 2198 | 2198 | * @param int|string $id The ID or username of a user |
| 2199 | 2199 | * @param string $password The password to check |
| 2200 | 2200 | * @param bool $is_username If true, treats $id as a username rather than a user ID |
| 2201 | - * @return bool Whether or not the password is correct. |
|
| 2201 | + * @return null|boolean Whether or not the password is correct. |
|
| 2202 | 2202 | */ |
| 2203 | 2203 | function ssi_checkPassword($id = null, $password = null, $is_username = false) |
| 2204 | 2204 | { |
@@ -12,8 +12,9 @@ discard block |
||
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | 14 | // Don't do anything if SMF is already loaded. |
| 15 | -if (defined('SMF')) |
|
| 15 | +if (defined('SMF')) { |
|
| 16 | 16 | return true; |
| 17 | +} |
|
| 17 | 18 | |
| 18 | 19 | define('SMF', 'SSI'); |
| 19 | 20 | |
@@ -26,21 +27,24 @@ discard block |
||
| 26 | 27 | |
| 27 | 28 | // Remember the current configuration so it can be set back. |
| 28 | 29 | $ssi_magic_quotes_runtime = function_exists('get_magic_quotes_gpc') && get_magic_quotes_runtime(); |
| 29 | -if (function_exists('set_magic_quotes_runtime')) |
|
| 30 | +if (function_exists('set_magic_quotes_runtime')) { |
|
| 30 | 31 | @set_magic_quotes_runtime(0); |
| 32 | +} |
|
| 31 | 33 | $time_start = microtime(); |
| 32 | 34 | |
| 33 | 35 | // Just being safe... |
| 34 | -foreach (array('db_character_set', 'cachedir') as $variable) |
|
| 36 | +foreach (array('db_character_set', 'cachedir') as $variable) { |
|
| 35 | 37 | if (isset($GLOBALS[$variable])) |
| 36 | 38 | unset($GLOBALS[$variable]); |
| 39 | +} |
|
| 37 | 40 | |
| 38 | 41 | // Get the forum's settings for database and file paths. |
| 39 | 42 | require_once(dirname(__FILE__) . '/Settings.php'); |
| 40 | 43 | |
| 41 | 44 | // Make absolutely sure the cache directory is defined. |
| 42 | -if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) |
|
| 45 | +if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) { |
|
| 43 | 46 | $cachedir = $boarddir . '/cache'; |
| 47 | +} |
|
| 44 | 48 | |
| 45 | 49 | $ssi_error_reporting = error_reporting(defined('E_STRICT') ? E_ALL | E_STRICT : E_ALL); |
| 46 | 50 | /* Set this to one of three values depending on what you want to happen in the case of a fatal error. |
@@ -51,12 +55,14 @@ discard block |
||
| 51 | 55 | $ssi_on_error_method = false; |
| 52 | 56 | |
| 53 | 57 | // Don't do john didley if the forum's been shut down completely. |
| 54 | -if ($maintenance == 2 && (!isset($ssi_maintenance_off) || $ssi_maintenance_off !== true)) |
|
| 58 | +if ($maintenance == 2 && (!isset($ssi_maintenance_off) || $ssi_maintenance_off !== true)) { |
|
| 55 | 59 | die($mmessage); |
| 60 | +} |
|
| 56 | 61 | |
| 57 | 62 | // Fix for using the current directory as a path. |
| 58 | -if (substr($sourcedir, 0, 1) == '.' && substr($sourcedir, 1, 1) != '.') |
|
| 63 | +if (substr($sourcedir, 0, 1) == '.' && substr($sourcedir, 1, 1) != '.') { |
|
| 59 | 64 | $sourcedir = dirname(__FILE__) . substr($sourcedir, 1); |
| 65 | +} |
|
| 60 | 66 | |
| 61 | 67 | // Load the important includes. |
| 62 | 68 | require_once($sourcedir . '/QueryString.php'); |
@@ -81,34 +87,38 @@ discard block |
||
| 81 | 87 | cleanRequest(); |
| 82 | 88 | |
| 83 | 89 | // Seed the random generator? |
| 84 | -if (empty($modSettings['rand_seed']) || mt_rand(1, 250) == 69) |
|
| 90 | +if (empty($modSettings['rand_seed']) || mt_rand(1, 250) == 69) { |
|
| 85 | 91 | smf_seed_generator(); |
| 92 | +} |
|
| 86 | 93 | |
| 87 | 94 | // Check on any hacking attempts. |
| 88 | -if (isset($_REQUEST['GLOBALS']) || isset($_COOKIE['GLOBALS'])) |
|
| 95 | +if (isset($_REQUEST['GLOBALS']) || isset($_COOKIE['GLOBALS'])) { |
|
| 89 | 96 | die('No direct access...'); |
| 90 | -elseif (isset($_REQUEST['ssi_theme']) && (int) $_REQUEST['ssi_theme'] == (int) $ssi_theme) |
|
| 97 | +} elseif (isset($_REQUEST['ssi_theme']) && (int) $_REQUEST['ssi_theme'] == (int) $ssi_theme) { |
|
| 91 | 98 | die('No direct access...'); |
| 92 | -elseif (isset($_COOKIE['ssi_theme']) && (int) $_COOKIE['ssi_theme'] == (int) $ssi_theme) |
|
| 99 | +} elseif (isset($_COOKIE['ssi_theme']) && (int) $_COOKIE['ssi_theme'] == (int) $ssi_theme) { |
|
| 93 | 100 | die('No direct access...'); |
| 94 | -elseif (isset($_REQUEST['ssi_layers'], $ssi_layers) && (@get_magic_quotes_gpc() ? stripslashes($_REQUEST['ssi_layers']) : $_REQUEST['ssi_layers']) == $ssi_layers) |
|
| 101 | +} elseif (isset($_REQUEST['ssi_layers'], $ssi_layers) && (@get_magic_quotes_gpc() ? stripslashes($_REQUEST['ssi_layers']) : $_REQUEST['ssi_layers']) == $ssi_layers) { |
|
| 95 | 102 | die('No direct access...'); |
| 96 | -if (isset($_REQUEST['context'])) |
|
| 103 | +} |
|
| 104 | +if (isset($_REQUEST['context'])) { |
|
| 97 | 105 | die('No direct access...'); |
| 106 | +} |
|
| 98 | 107 | |
| 99 | 108 | // Gzip output? (because it must be boolean and true, this can't be hacked.) |
| 100 | -if (isset($ssi_gzip) && $ssi_gzip === true && ini_get('zlib.output_compression') != '1' && ini_get('output_handler') != 'ob_gzhandler' && version_compare(PHP_VERSION, '4.2.0', '>=')) |
|
| 109 | +if (isset($ssi_gzip) && $ssi_gzip === true && ini_get('zlib.output_compression') != '1' && ini_get('output_handler') != 'ob_gzhandler' && version_compare(PHP_VERSION, '4.2.0', '>=')) { |
|
| 101 | 110 | ob_start('ob_gzhandler'); |
| 102 | -else |
|
| 111 | +} else { |
|
| 103 | 112 | $modSettings['enableCompressedOutput'] = '0'; |
| 113 | +} |
|
| 104 | 114 | |
| 105 | 115 | // Primarily, this is to fix the URLs... |
| 106 | 116 | ob_start('ob_sessrewrite'); |
| 107 | 117 | |
| 108 | 118 | // Start the session... known to scramble SSI includes in cases... |
| 109 | -if (!headers_sent()) |
|
| 119 | +if (!headers_sent()) { |
|
| 110 | 120 | loadSession(); |
| 111 | -else |
|
| 121 | +} else |
|
| 112 | 122 | { |
| 113 | 123 | if (isset($_COOKIE[session_name()]) || isset($_REQUEST[session_name()])) |
| 114 | 124 | { |
@@ -142,12 +152,14 @@ discard block |
||
| 142 | 152 | loadTheme(isset($ssi_theme) ? (int) $ssi_theme : 0); |
| 143 | 153 | |
| 144 | 154 | // @todo: probably not the best place, but somewhere it should be set... |
| 145 | -if (!headers_sent()) |
|
| 155 | +if (!headers_sent()) { |
|
| 146 | 156 | header('Content-Type: text/html; charset=' . (empty($modSettings['global_character_set']) ? (empty($txt['lang_character_set']) ? 'ISO-8859-1' : $txt['lang_character_set']) : $modSettings['global_character_set'])); |
| 157 | +} |
|
| 147 | 158 | |
| 148 | 159 | // Take care of any banning that needs to be done. |
| 149 | -if (isset($_REQUEST['ssi_ban']) || (isset($ssi_ban) && $ssi_ban === true)) |
|
| 160 | +if (isset($_REQUEST['ssi_ban']) || (isset($ssi_ban) && $ssi_ban === true)) { |
|
| 150 | 161 | is_not_banned(); |
| 162 | +} |
|
| 151 | 163 | |
| 152 | 164 | // Do we allow guests in here? |
| 153 | 165 | if (empty($ssi_guest_access) && empty($modSettings['allow_guestAccess']) && $user_info['is_guest'] && basename($_SERVER['PHP_SELF']) != 'SSI.php') |
@@ -162,17 +174,19 @@ discard block |
||
| 162 | 174 | { |
| 163 | 175 | $context['template_layers'] = $ssi_layers; |
| 164 | 176 | template_header(); |
| 165 | -} |
|
| 166 | -else |
|
| 177 | +} else { |
|
| 167 | 178 | setupThemeContext(); |
| 179 | +} |
|
| 168 | 180 | |
| 169 | 181 | // Make sure they didn't muss around with the settings... but only if it's not cli. |
| 170 | -if (isset($_SERVER['REMOTE_ADDR']) && !isset($_SERVER['is_cli']) && session_id() == '') |
|
| 182 | +if (isset($_SERVER['REMOTE_ADDR']) && !isset($_SERVER['is_cli']) && session_id() == '') { |
|
| 171 | 183 | trigger_error($txt['ssi_session_broken'], E_USER_NOTICE); |
| 184 | +} |
|
| 172 | 185 | |
| 173 | 186 | // Without visiting the forum this session variable might not be set on submit. |
| 174 | -if (!isset($_SESSION['USER_AGENT']) && (!isset($_GET['ssi_function']) || $_GET['ssi_function'] !== 'pollVote')) |
|
| 187 | +if (!isset($_SESSION['USER_AGENT']) && (!isset($_GET['ssi_function']) || $_GET['ssi_function'] !== 'pollVote')) { |
|
| 175 | 188 | $_SESSION['USER_AGENT'] = $_SERVER['HTTP_USER_AGENT']; |
| 189 | +} |
|
| 176 | 190 | |
| 177 | 191 | // Have the ability to easily add functions to SSI. |
| 178 | 192 | call_integration_hook('integrate_SSI'); |
@@ -183,15 +197,18 @@ discard block |
||
| 183 | 197 | call_user_func('ssi_' . $_GET['ssi_function']); |
| 184 | 198 | exit; |
| 185 | 199 | } |
| 186 | -if (isset($_GET['ssi_function'])) |
|
| 200 | +if (isset($_GET['ssi_function'])) { |
|
| 187 | 201 | exit; |
| 202 | +} |
|
| 188 | 203 | // You shouldn't just access SSI.php directly by URL!! |
| 189 | -elseif (basename($_SERVER['PHP_SELF']) == 'SSI.php') |
|
| 204 | +elseif (basename($_SERVER['PHP_SELF']) == 'SSI.php') { |
|
| 190 | 205 | die(sprintf($txt['ssi_not_direct'], $user_info['is_admin'] ? '\'' . addslashes(__FILE__) . '\'' : '\'SSI.php\'')); |
| 206 | +} |
|
| 191 | 207 | |
| 192 | 208 | error_reporting($ssi_error_reporting); |
| 193 | -if (function_exists('set_magic_quotes_runtime')) |
|
| 209 | +if (function_exists('set_magic_quotes_runtime')) { |
|
| 194 | 210 | @set_magic_quotes_runtime($ssi_magic_quotes_runtime); |
| 211 | +} |
|
| 195 | 212 | |
| 196 | 213 | return true; |
| 197 | 214 | |
@@ -201,9 +218,10 @@ discard block |
||
| 201 | 218 | */ |
| 202 | 219 | function ssi_shutdown() |
| 203 | 220 | { |
| 204 | - if (!isset($_GET['ssi_function']) || $_GET['ssi_function'] != 'shutdown') |
|
| 205 | - template_footer(); |
|
| 206 | -} |
|
| 221 | + if (!isset($_GET['ssi_function']) || $_GET['ssi_function'] != 'shutdown') { |
|
| 222 | + template_footer(); |
|
| 223 | + } |
|
| 224 | + } |
|
| 207 | 225 | |
| 208 | 226 | /** |
| 209 | 227 | * Display a welcome message, like: Hey, User, you have 0 messages, 0 are new. |
@@ -216,15 +234,17 @@ discard block |
||
| 216 | 234 | |
| 217 | 235 | if ($output_method == 'echo') |
| 218 | 236 | { |
| 219 | - if ($context['user']['is_guest']) |
|
| 220 | - echo sprintf($txt[$context['can_register'] ? 'welcome_guest_register' : 'welcome_guest'], $txt['guest_title'], $context['forum_name_html_safe'], $scripturl . '?action=login', 'return reqOverlayDiv(this.href, ' . JavaScriptEscape($txt['login']) . ');', $scripturl . '?action=signup'); |
|
| 221 | - else |
|
| 222 | - echo $txt['hello_member'], ' <strong>', $context['user']['name'], '</strong>', allowedTo('pm_read') ? ', ' . (empty($context['user']['messages']) ? $txt['msg_alert_no_messages'] : (($context['user']['messages'] == 1 ? sprintf($txt['msg_alert_one_message'], $scripturl . '?action=pm') : sprintf($txt['msg_alert_many_message'], $scripturl . '?action=pm', $context['user']['messages'])) . ', ' . ($context['user']['unread_messages'] == 1 ? $txt['msg_alert_one_new'] : sprintf($txt['msg_alert_many_new'], $context['user']['unread_messages'])))) : ''; |
|
| 237 | + if ($context['user']['is_guest']) { |
|
| 238 | + echo sprintf($txt[$context['can_register'] ? 'welcome_guest_register' : 'welcome_guest'], $txt['guest_title'], $context['forum_name_html_safe'], $scripturl . '?action=login', 'return reqOverlayDiv(this.href, ' . JavaScriptEscape($txt['login']) . ');', $scripturl . '?action=signup'); |
|
| 239 | + } else { |
|
| 240 | + echo $txt['hello_member'], ' <strong>', $context['user']['name'], '</strong>', allowedTo('pm_read') ? ', ' . (empty($context['user']['messages']) ? $txt['msg_alert_no_messages'] : (($context['user']['messages'] == 1 ? sprintf($txt['msg_alert_one_message'], $scripturl . '?action=pm') : sprintf($txt['msg_alert_many_message'], $scripturl . '?action=pm', $context['user']['messages'])) . ', ' . ($context['user']['unread_messages'] == 1 ? $txt['msg_alert_one_new'] : sprintf($txt['msg_alert_many_new'], $context['user']['unread_messages'])))) : ''; |
|
| 241 | + } |
|
| 223 | 242 | } |
| 224 | 243 | // Don't echo... then do what?! |
| 225 | - else |
|
| 226 | - return $context['user']; |
|
| 227 | -} |
|
| 244 | + else { |
|
| 245 | + return $context['user']; |
|
| 246 | + } |
|
| 247 | + } |
|
| 228 | 248 | |
| 229 | 249 | /** |
| 230 | 250 | * Display a menu bar, like is displayed at the top of the forum. |
@@ -235,12 +255,14 @@ discard block |
||
| 235 | 255 | { |
| 236 | 256 | global $context; |
| 237 | 257 | |
| 238 | - if ($output_method == 'echo') |
|
| 239 | - template_menu(); |
|
| 258 | + if ($output_method == 'echo') { |
|
| 259 | + template_menu(); |
|
| 260 | + } |
|
| 240 | 261 | // What else could this do? |
| 241 | - else |
|
| 242 | - return $context['menu_buttons']; |
|
| 243 | -} |
|
| 262 | + else { |
|
| 263 | + return $context['menu_buttons']; |
|
| 264 | + } |
|
| 265 | + } |
|
| 244 | 266 | |
| 245 | 267 | /** |
| 246 | 268 | * Show a logout link. |
@@ -252,20 +274,23 @@ discard block |
||
| 252 | 274 | { |
| 253 | 275 | global $context, $txt, $scripturl; |
| 254 | 276 | |
| 255 | - if ($redirect_to != '') |
|
| 256 | - $_SESSION['logout_url'] = $redirect_to; |
|
| 277 | + if ($redirect_to != '') { |
|
| 278 | + $_SESSION['logout_url'] = $redirect_to; |
|
| 279 | + } |
|
| 257 | 280 | |
| 258 | 281 | // Guests can't log out. |
| 259 | - if ($context['user']['is_guest']) |
|
| 260 | - return false; |
|
| 282 | + if ($context['user']['is_guest']) { |
|
| 283 | + return false; |
|
| 284 | + } |
|
| 261 | 285 | |
| 262 | 286 | $link = '<a href="' . $scripturl . '?action=logout;' . $context['session_var'] . '=' . $context['session_id'] . '">' . $txt['logout'] . '</a>'; |
| 263 | 287 | |
| 264 | - if ($output_method == 'echo') |
|
| 265 | - echo $link; |
|
| 266 | - else |
|
| 267 | - return $link; |
|
| 268 | -} |
|
| 288 | + if ($output_method == 'echo') { |
|
| 289 | + echo $link; |
|
| 290 | + } else { |
|
| 291 | + return $link; |
|
| 292 | + } |
|
| 293 | + } |
|
| 269 | 294 | |
| 270 | 295 | /** |
| 271 | 296 | * Recent post list: [board] Subject by Poster Date |
@@ -281,17 +306,17 @@ discard block |
||
| 281 | 306 | global $modSettings, $context; |
| 282 | 307 | |
| 283 | 308 | // Excluding certain boards... |
| 284 | - if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0) |
|
| 285 | - $exclude_boards = array($modSettings['recycle_board']); |
|
| 286 | - else |
|
| 287 | - $exclude_boards = empty($exclude_boards) ? array() : (is_array($exclude_boards) ? $exclude_boards : array($exclude_boards)); |
|
| 309 | + if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0) { |
|
| 310 | + $exclude_boards = array($modSettings['recycle_board']); |
|
| 311 | + } else { |
|
| 312 | + $exclude_boards = empty($exclude_boards) ? array() : (is_array($exclude_boards) ? $exclude_boards : array($exclude_boards)); |
|
| 313 | + } |
|
| 288 | 314 | |
| 289 | 315 | // What about including certain boards - note we do some protection here as pre-2.0 didn't have this parameter. |
| 290 | 316 | if (is_array($include_boards) || (int) $include_boards === $include_boards) |
| 291 | 317 | { |
| 292 | 318 | $include_boards = is_array($include_boards) ? $include_boards : array($include_boards); |
| 293 | - } |
|
| 294 | - elseif ($include_boards != null) |
|
| 319 | + } elseif ($include_boards != null) |
|
| 295 | 320 | { |
| 296 | 321 | $include_boards = array(); |
| 297 | 322 | } |
@@ -328,8 +353,9 @@ discard block |
||
| 328 | 353 | { |
| 329 | 354 | global $modSettings; |
| 330 | 355 | |
| 331 | - if (empty($post_ids)) |
|
| 332 | - return; |
|
| 356 | + if (empty($post_ids)) { |
|
| 357 | + return; |
|
| 358 | + } |
|
| 333 | 359 | |
| 334 | 360 | // Allow the user to request more than one - why not? |
| 335 | 361 | $post_ids = is_array($post_ids) ? $post_ids : array($post_ids); |
@@ -364,8 +390,9 @@ discard block |
||
| 364 | 390 | global $scripturl, $txt, $user_info; |
| 365 | 391 | global $modSettings, $smcFunc, $context; |
| 366 | 392 | |
| 367 | - if (!empty($modSettings['enable_likes'])) |
|
| 368 | - $context['can_like'] = allowedTo('likes_like'); |
|
| 393 | + if (!empty($modSettings['enable_likes'])) { |
|
| 394 | + $context['can_like'] = allowedTo('likes_like'); |
|
| 395 | + } |
|
| 369 | 396 | |
| 370 | 397 | // Find all the posts. Newer ones will have higher IDs. |
| 371 | 398 | $request = $smcFunc['db_query']('substring', ' |
@@ -431,12 +458,13 @@ discard block |
||
| 431 | 458 | ); |
| 432 | 459 | |
| 433 | 460 | // Get the likes for each message. |
| 434 | - if (!empty($modSettings['enable_likes'])) |
|
| 435 | - $posts[$row['id_msg']]['likes'] = array( |
|
| 461 | + if (!empty($modSettings['enable_likes'])) { |
|
| 462 | + $posts[$row['id_msg']]['likes'] = array( |
|
| 436 | 463 | 'count' => $row['likes'], |
| 437 | 464 | 'you' => in_array($row['id_msg'], prepareLikesContext($row['id_topic'])), |
| 438 | 465 | 'can_like' => !$context['user']['is_guest'] && $row['id_member'] != $context['user']['id'] && !empty($context['can_like']), |
| 439 | 466 | ); |
| 467 | + } |
|
| 440 | 468 | } |
| 441 | 469 | $smcFunc['db_free_result']($request); |
| 442 | 470 | |
@@ -444,13 +472,14 @@ discard block |
||
| 444 | 472 | call_integration_hook('integrate_ssi_queryPosts', array(&$posts)); |
| 445 | 473 | |
| 446 | 474 | // Just return it. |
| 447 | - if ($output_method != 'echo' || empty($posts)) |
|
| 448 | - return $posts; |
|
| 475 | + if ($output_method != 'echo' || empty($posts)) { |
|
| 476 | + return $posts; |
|
| 477 | + } |
|
| 449 | 478 | |
| 450 | 479 | echo ' |
| 451 | 480 | <table style="border: none" class="ssi_table">'; |
| 452 | - foreach ($posts as $post) |
|
| 453 | - echo ' |
|
| 481 | + foreach ($posts as $post) { |
|
| 482 | + echo ' |
|
| 454 | 483 | <tr> |
| 455 | 484 | <td style="text-align: right; vertical-align: top; white-space: nowrap"> |
| 456 | 485 | [', $post['board']['link'], '] |
@@ -464,6 +493,7 @@ discard block |
||
| 464 | 493 | ', $post['time'], ' |
| 465 | 494 | </td> |
| 466 | 495 | </tr>'; |
| 496 | + } |
|
| 467 | 497 | echo ' |
| 468 | 498 | </table>'; |
| 469 | 499 | } |
@@ -481,25 +511,26 @@ discard block |
||
| 481 | 511 | global $settings, $scripturl, $txt, $user_info; |
| 482 | 512 | global $modSettings, $smcFunc, $context; |
| 483 | 513 | |
| 484 | - if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0) |
|
| 485 | - $exclude_boards = array($modSettings['recycle_board']); |
|
| 486 | - else |
|
| 487 | - $exclude_boards = empty($exclude_boards) ? array() : (is_array($exclude_boards) ? $exclude_boards : array($exclude_boards)); |
|
| 514 | + if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0) { |
|
| 515 | + $exclude_boards = array($modSettings['recycle_board']); |
|
| 516 | + } else { |
|
| 517 | + $exclude_boards = empty($exclude_boards) ? array() : (is_array($exclude_boards) ? $exclude_boards : array($exclude_boards)); |
|
| 518 | + } |
|
| 488 | 519 | |
| 489 | 520 | // Only some boards?. |
| 490 | 521 | if (is_array($include_boards) || (int) $include_boards === $include_boards) |
| 491 | 522 | { |
| 492 | 523 | $include_boards = is_array($include_boards) ? $include_boards : array($include_boards); |
| 493 | - } |
|
| 494 | - elseif ($include_boards != null) |
|
| 524 | + } elseif ($include_boards != null) |
|
| 495 | 525 | { |
| 496 | 526 | $output_method = $include_boards; |
| 497 | 527 | $include_boards = array(); |
| 498 | 528 | } |
| 499 | 529 | |
| 500 | 530 | $icon_sources = array(); |
| 501 | - foreach ($context['stable_icons'] as $icon) |
|
| 502 | - $icon_sources[$icon] = 'images_url'; |
|
| 531 | + foreach ($context['stable_icons'] as $icon) { |
|
| 532 | + $icon_sources[$icon] = 'images_url'; |
|
| 533 | + } |
|
| 503 | 534 | |
| 504 | 535 | // Find all the posts in distinct topics. Newer ones will have higher IDs. |
| 505 | 536 | $request = $smcFunc['db_query']('substring', ' |
@@ -524,13 +555,15 @@ discard block |
||
| 524 | 555 | ) |
| 525 | 556 | ); |
| 526 | 557 | $topics = array(); |
| 527 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 528 | - $topics[$row['id_topic']] = $row; |
|
| 558 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 559 | + $topics[$row['id_topic']] = $row; |
|
| 560 | + } |
|
| 529 | 561 | $smcFunc['db_free_result']($request); |
| 530 | 562 | |
| 531 | 563 | // Did we find anything? If not, bail. |
| 532 | - if (empty($topics)) |
|
| 533 | - return array(); |
|
| 564 | + if (empty($topics)) { |
|
| 565 | + return array(); |
|
| 566 | + } |
|
| 534 | 567 | |
| 535 | 568 | $recycle_board = !empty($modSettings['recycle_enable']) && !empty($modSettings['recycle_board']) ? (int) $modSettings['recycle_board'] : 0; |
| 536 | 569 | |
@@ -558,19 +591,22 @@ discard block |
||
| 558 | 591 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 559 | 592 | { |
| 560 | 593 | $row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']), array('<br>' => ' '))); |
| 561 | - if ($smcFunc['strlen']($row['body']) > 128) |
|
| 562 | - $row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...'; |
|
| 594 | + if ($smcFunc['strlen']($row['body']) > 128) { |
|
| 595 | + $row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...'; |
|
| 596 | + } |
|
| 563 | 597 | |
| 564 | 598 | // Censor the subject. |
| 565 | 599 | censorText($row['subject']); |
| 566 | 600 | censorText($row['body']); |
| 567 | 601 | |
| 568 | 602 | // Recycled icon |
| 569 | - if (!empty($recycle_board) && $topics[$row['id_topic']]['id_board']) |
|
| 570 | - $row['icon'] = 'recycled'; |
|
| 603 | + if (!empty($recycle_board) && $topics[$row['id_topic']]['id_board']) { |
|
| 604 | + $row['icon'] = 'recycled'; |
|
| 605 | + } |
|
| 571 | 606 | |
| 572 | - if (!empty($modSettings['messageIconChecks_enable']) && !isset($icon_sources[$row['icon']])) |
|
| 573 | - $icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 607 | + if (!empty($modSettings['messageIconChecks_enable']) && !isset($icon_sources[$row['icon']])) { |
|
| 608 | + $icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 609 | + } |
|
| 574 | 610 | |
| 575 | 611 | // Build the array. |
| 576 | 612 | $posts[] = array( |
@@ -609,13 +645,14 @@ discard block |
||
| 609 | 645 | call_integration_hook('integrate_ssi_recentTopics', array(&$posts)); |
| 610 | 646 | |
| 611 | 647 | // Just return it. |
| 612 | - if ($output_method != 'echo' || empty($posts)) |
|
| 613 | - return $posts; |
|
| 648 | + if ($output_method != 'echo' || empty($posts)) { |
|
| 649 | + return $posts; |
|
| 650 | + } |
|
| 614 | 651 | |
| 615 | 652 | echo ' |
| 616 | 653 | <table style="border: none" class="ssi_table">'; |
| 617 | - foreach ($posts as $post) |
|
| 618 | - echo ' |
|
| 654 | + foreach ($posts as $post) { |
|
| 655 | + echo ' |
|
| 619 | 656 | <tr> |
| 620 | 657 | <td style="text-align: right; vertical-align: top; white-space: nowrap"> |
| 621 | 658 | [', $post['board']['link'], '] |
@@ -629,6 +666,7 @@ discard block |
||
| 629 | 666 | ', $post['time'], ' |
| 630 | 667 | </td> |
| 631 | 668 | </tr>'; |
| 669 | + } |
|
| 632 | 670 | echo ' |
| 633 | 671 | </table>'; |
| 634 | 672 | } |
@@ -653,27 +691,30 @@ discard block |
||
| 653 | 691 | ) |
| 654 | 692 | ); |
| 655 | 693 | $return = array(); |
| 656 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 657 | - $return[] = array( |
|
| 694 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 695 | + $return[] = array( |
|
| 658 | 696 | 'id' => $row['id_member'], |
| 659 | 697 | 'name' => $row['real_name'], |
| 660 | 698 | 'href' => $scripturl . '?action=profile;u=' . $row['id_member'], |
| 661 | 699 | 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>', |
| 662 | 700 | 'posts' => $row['posts'] |
| 663 | 701 | ); |
| 702 | + } |
|
| 664 | 703 | $smcFunc['db_free_result']($request); |
| 665 | 704 | |
| 666 | 705 | // If mods want to do somthing with this list of members, let them do that now. |
| 667 | 706 | call_integration_hook('integrate_ssi_topPoster', array(&$return)); |
| 668 | 707 | |
| 669 | 708 | // Just return all the top posters. |
| 670 | - if ($output_method != 'echo') |
|
| 671 | - return $return; |
|
| 709 | + if ($output_method != 'echo') { |
|
| 710 | + return $return; |
|
| 711 | + } |
|
| 672 | 712 | |
| 673 | 713 | // Make a quick array to list the links in. |
| 674 | 714 | $temp_array = array(); |
| 675 | - foreach ($return as $member) |
|
| 676 | - $temp_array[] = $member['link']; |
|
| 715 | + foreach ($return as $member) { |
|
| 716 | + $temp_array[] = $member['link']; |
|
| 717 | + } |
|
| 677 | 718 | |
| 678 | 719 | echo implode(', ', $temp_array); |
| 679 | 720 | } |
@@ -705,8 +746,8 @@ discard block |
||
| 705 | 746 | ) |
| 706 | 747 | ); |
| 707 | 748 | $boards = array(); |
| 708 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 709 | - $boards[] = array( |
|
| 749 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 750 | + $boards[] = array( |
|
| 710 | 751 | 'id' => $row['id_board'], |
| 711 | 752 | 'num_posts' => $row['num_posts'], |
| 712 | 753 | 'num_topics' => $row['num_topics'], |
@@ -715,14 +756,16 @@ discard block |
||
| 715 | 756 | 'href' => $scripturl . '?board=' . $row['id_board'] . '.0', |
| 716 | 757 | 'link' => '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>' |
| 717 | 758 | ); |
| 759 | + } |
|
| 718 | 760 | $smcFunc['db_free_result']($request); |
| 719 | 761 | |
| 720 | 762 | // If mods want to do somthing with this list of boards, let them do that now. |
| 721 | 763 | call_integration_hook('integrate_ssi_topBoards', array(&$boards)); |
| 722 | 764 | |
| 723 | 765 | // If we shouldn't output or have nothing to output, just jump out. |
| 724 | - if ($output_method != 'echo' || empty($boards)) |
|
| 725 | - return $boards; |
|
| 766 | + if ($output_method != 'echo' || empty($boards)) { |
|
| 767 | + return $boards; |
|
| 768 | + } |
|
| 726 | 769 | |
| 727 | 770 | echo ' |
| 728 | 771 | <table class="ssi_table"> |
@@ -731,13 +774,14 @@ discard block |
||
| 731 | 774 | <th style="text-align: left">', $txt['board_topics'], '</th> |
| 732 | 775 | <th style="text-align: left">', $txt['posts'], '</th> |
| 733 | 776 | </tr>'; |
| 734 | - foreach ($boards as $sBoard) |
|
| 735 | - echo ' |
|
| 777 | + foreach ($boards as $sBoard) { |
|
| 778 | + echo ' |
|
| 736 | 779 | <tr> |
| 737 | 780 | <td>', $sBoard['link'], $sBoard['new'] ? ' <a href="' . $sBoard['href'] . '"><span class="new_posts">' . $txt['new'] . '</span></a>' : '', '</td> |
| 738 | 781 | <td style="text-align: right">', comma_format($sBoard['num_topics']), '</td> |
| 739 | 782 | <td style="text-align: right">', comma_format($sBoard['num_posts']), '</td> |
| 740 | 783 | </tr>'; |
| 784 | + } |
|
| 741 | 785 | echo ' |
| 742 | 786 | </table>'; |
| 743 | 787 | } |
@@ -770,12 +814,13 @@ discard block |
||
| 770 | 814 | ) |
| 771 | 815 | ); |
| 772 | 816 | $topic_ids = array(); |
| 773 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 774 | - $topic_ids[] = $row['id_topic']; |
|
| 817 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 818 | + $topic_ids[] = $row['id_topic']; |
|
| 819 | + } |
|
| 775 | 820 | $smcFunc['db_free_result']($request); |
| 821 | + } else { |
|
| 822 | + $topic_ids = array(); |
|
| 776 | 823 | } |
| 777 | - else |
|
| 778 | - $topic_ids = array(); |
|
| 779 | 824 | |
| 780 | 825 | $request = $smcFunc['db_query']('', ' |
| 781 | 826 | SELECT m.subject, m.id_topic, t.num_views, t.num_replies |
@@ -814,8 +859,9 @@ discard block |
||
| 814 | 859 | // If mods want to do somthing with this list of topics, let them do that now. |
| 815 | 860 | call_integration_hook('integrate_ssi_topTopics', array(&$topics, $type)); |
| 816 | 861 | |
| 817 | - if ($output_method != 'echo' || empty($topics)) |
|
| 818 | - return $topics; |
|
| 862 | + if ($output_method != 'echo' || empty($topics)) { |
|
| 863 | + return $topics; |
|
| 864 | + } |
|
| 819 | 865 | |
| 820 | 866 | echo ' |
| 821 | 867 | <table class="ssi_table"> |
@@ -824,8 +870,8 @@ discard block |
||
| 824 | 870 | <th style="text-align: left">', $txt['views'], '</th> |
| 825 | 871 | <th style="text-align: left">', $txt['replies'], '</th> |
| 826 | 872 | </tr>'; |
| 827 | - foreach ($topics as $sTopic) |
|
| 828 | - echo ' |
|
| 873 | + foreach ($topics as $sTopic) { |
|
| 874 | + echo ' |
|
| 829 | 875 | <tr> |
| 830 | 876 | <td style="text-align: left"> |
| 831 | 877 | ', $sTopic['link'], ' |
@@ -833,6 +879,7 @@ discard block |
||
| 833 | 879 | <td style="text-align: right">', comma_format($sTopic['num_views']), '</td> |
| 834 | 880 | <td style="text-align: right">', comma_format($sTopic['num_replies']), '</td> |
| 835 | 881 | </tr>'; |
| 882 | + } |
|
| 836 | 883 | echo ' |
| 837 | 884 | </table>'; |
| 838 | 885 | } |
@@ -868,12 +915,13 @@ discard block |
||
| 868 | 915 | { |
| 869 | 916 | global $txt, $context; |
| 870 | 917 | |
| 871 | - if ($output_method == 'echo') |
|
| 872 | - echo ' |
|
| 918 | + if ($output_method == 'echo') { |
|
| 919 | + echo ' |
|
| 873 | 920 | ', sprintf($txt['welcome_newest_member'], $context['common_stats']['latest_member']['link']), '<br>'; |
| 874 | - else |
|
| 875 | - return $context['common_stats']['latest_member']; |
|
| 876 | -} |
|
| 921 | + } else { |
|
| 922 | + return $context['common_stats']['latest_member']; |
|
| 923 | + } |
|
| 924 | + } |
|
| 877 | 925 | |
| 878 | 926 | /** |
| 879 | 927 | * Fetches a random member. |
@@ -922,8 +970,9 @@ discard block |
||
| 922 | 970 | } |
| 923 | 971 | |
| 924 | 972 | // Just to be sure put the random generator back to something... random. |
| 925 | - if ($random_type != '') |
|
| 926 | - mt_srand(time()); |
|
| 973 | + if ($random_type != '') { |
|
| 974 | + mt_srand(time()); |
|
| 975 | + } |
|
| 927 | 976 | |
| 928 | 977 | return $result; |
| 929 | 978 | } |
@@ -936,8 +985,9 @@ discard block |
||
| 936 | 985 | */ |
| 937 | 986 | function ssi_fetchMember($member_ids = array(), $output_method = 'echo') |
| 938 | 987 | { |
| 939 | - if (empty($member_ids)) |
|
| 940 | - return; |
|
| 988 | + if (empty($member_ids)) { |
|
| 989 | + return; |
|
| 990 | + } |
|
| 941 | 991 | |
| 942 | 992 | // Can have more than one member if you really want... |
| 943 | 993 | $member_ids = is_array($member_ids) ? $member_ids : array($member_ids); |
@@ -962,8 +1012,9 @@ discard block |
||
| 962 | 1012 | */ |
| 963 | 1013 | function ssi_fetchGroupMembers($group_id = null, $output_method = 'echo') |
| 964 | 1014 | { |
| 965 | - if ($group_id === null) |
|
| 966 | - return; |
|
| 1015 | + if ($group_id === null) { |
|
| 1016 | + return; |
|
| 1017 | + } |
|
| 967 | 1018 | |
| 968 | 1019 | $query_where = ' |
| 969 | 1020 | id_group = {int:id_group} |
@@ -990,8 +1041,9 @@ discard block |
||
| 990 | 1041 | { |
| 991 | 1042 | global $smcFunc, $memberContext; |
| 992 | 1043 | |
| 993 | - if ($query_where === null) |
|
| 994 | - return; |
|
| 1044 | + if ($query_where === null) { |
|
| 1045 | + return; |
|
| 1046 | + } |
|
| 995 | 1047 | |
| 996 | 1048 | // Fetch the members in question. |
| 997 | 1049 | $request = $smcFunc['db_query']('', ' |
@@ -1004,12 +1056,14 @@ discard block |
||
| 1004 | 1056 | )) |
| 1005 | 1057 | ); |
| 1006 | 1058 | $members = array(); |
| 1007 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1008 | - $members[] = $row['id_member']; |
|
| 1059 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1060 | + $members[] = $row['id_member']; |
|
| 1061 | + } |
|
| 1009 | 1062 | $smcFunc['db_free_result']($request); |
| 1010 | 1063 | |
| 1011 | - if (empty($members)) |
|
| 1012 | - return array(); |
|
| 1064 | + if (empty($members)) { |
|
| 1065 | + return array(); |
|
| 1066 | + } |
|
| 1013 | 1067 | |
| 1014 | 1068 | // If mods want to do somthing with this list of members, let them do that now. |
| 1015 | 1069 | call_integration_hook('integrate_ssi_queryMembers', array(&$members)); |
@@ -1018,23 +1072,25 @@ discard block |
||
| 1018 | 1072 | loadMemberData($members); |
| 1019 | 1073 | |
| 1020 | 1074 | // Draw the table! |
| 1021 | - if ($output_method == 'echo') |
|
| 1022 | - echo ' |
|
| 1075 | + if ($output_method == 'echo') { |
|
| 1076 | + echo ' |
|
| 1023 | 1077 | <table style="border: none" class="ssi_table">'; |
| 1078 | + } |
|
| 1024 | 1079 | |
| 1025 | 1080 | $query_members = array(); |
| 1026 | 1081 | foreach ($members as $member) |
| 1027 | 1082 | { |
| 1028 | 1083 | // Load their context data. |
| 1029 | - if (!loadMemberContext($member)) |
|
| 1030 | - continue; |
|
| 1084 | + if (!loadMemberContext($member)) { |
|
| 1085 | + continue; |
|
| 1086 | + } |
|
| 1031 | 1087 | |
| 1032 | 1088 | // Store this member's information. |
| 1033 | 1089 | $query_members[$member] = $memberContext[$member]; |
| 1034 | 1090 | |
| 1035 | 1091 | // Only do something if we're echo'ing. |
| 1036 | - if ($output_method == 'echo') |
|
| 1037 | - echo ' |
|
| 1092 | + if ($output_method == 'echo') { |
|
| 1093 | + echo ' |
|
| 1038 | 1094 | <tr> |
| 1039 | 1095 | <td style="text-align: right; vertical-align: top; white-space: nowrap"> |
| 1040 | 1096 | ', $query_members[$member]['link'], ' |
@@ -1042,12 +1098,14 @@ discard block |
||
| 1042 | 1098 | <br>', $query_members[$member]['avatar']['image'], ' |
| 1043 | 1099 | </td> |
| 1044 | 1100 | </tr>'; |
| 1101 | + } |
|
| 1045 | 1102 | } |
| 1046 | 1103 | |
| 1047 | 1104 | // End the table if appropriate. |
| 1048 | - if ($output_method == 'echo') |
|
| 1049 | - echo ' |
|
| 1105 | + if ($output_method == 'echo') { |
|
| 1106 | + echo ' |
|
| 1050 | 1107 | </table>'; |
| 1108 | + } |
|
| 1051 | 1109 | |
| 1052 | 1110 | // Send back the data. |
| 1053 | 1111 | return $query_members; |
@@ -1062,8 +1120,9 @@ discard block |
||
| 1062 | 1120 | { |
| 1063 | 1121 | global $txt, $scripturl, $modSettings, $smcFunc; |
| 1064 | 1122 | |
| 1065 | - if (!allowedTo('view_stats')) |
|
| 1066 | - return; |
|
| 1123 | + if (!allowedTo('view_stats')) { |
|
| 1124 | + return; |
|
| 1125 | + } |
|
| 1067 | 1126 | |
| 1068 | 1127 | $totals = array( |
| 1069 | 1128 | 'members' => $modSettings['totalMembers'], |
@@ -1092,8 +1151,9 @@ discard block |
||
| 1092 | 1151 | // If mods want to do somthing with the board stats, let them do that now. |
| 1093 | 1152 | call_integration_hook('integrate_ssi_boardStats', array(&$totals)); |
| 1094 | 1153 | |
| 1095 | - if ($output_method != 'echo') |
|
| 1096 | - return $totals; |
|
| 1154 | + if ($output_method != 'echo') { |
|
| 1155 | + return $totals; |
|
| 1156 | + } |
|
| 1097 | 1157 | |
| 1098 | 1158 | echo ' |
| 1099 | 1159 | ', $txt['total_members'], ': <a href="', $scripturl . '?action=mlist">', comma_format($totals['members']), '</a><br> |
@@ -1122,8 +1182,8 @@ discard block |
||
| 1122 | 1182 | call_integration_hook('integrate_ssi_whosOnline', array(&$return)); |
| 1123 | 1183 | |
| 1124 | 1184 | // Add some redundancy for backwards compatibility reasons. |
| 1125 | - if ($output_method != 'echo') |
|
| 1126 | - return $return + array( |
|
| 1185 | + if ($output_method != 'echo') { |
|
| 1186 | + return $return + array( |
|
| 1127 | 1187 | 'users' => $return['users_online'], |
| 1128 | 1188 | 'guests' => $return['num_guests'], |
| 1129 | 1189 | 'hidden' => $return['num_users_hidden'], |
@@ -1131,29 +1191,35 @@ discard block |
||
| 1131 | 1191 | 'num_users' => $return['num_users_online'], |
| 1132 | 1192 | 'total_users' => $return['num_users_online'] + $return['num_guests'], |
| 1133 | 1193 | ); |
| 1194 | + } |
|
| 1134 | 1195 | |
| 1135 | 1196 | echo ' |
| 1136 | 1197 | ', comma_format($return['num_guests']), ' ', $return['num_guests'] == 1 ? $txt['guest'] : $txt['guests'], ', ', comma_format($return['num_users_online']), ' ', $return['num_users_online'] == 1 ? $txt['user'] : $txt['users']; |
| 1137 | 1198 | |
| 1138 | 1199 | $bracketList = array(); |
| 1139 | - if (!empty($user_info['buddies'])) |
|
| 1140 | - $bracketList[] = comma_format($return['num_buddies']) . ' ' . ($return['num_buddies'] == 1 ? $txt['buddy'] : $txt['buddies']); |
|
| 1141 | - if (!empty($return['num_spiders'])) |
|
| 1142 | - $bracketList[] = comma_format($return['num_spiders']) . ' ' . ($return['num_spiders'] == 1 ? $txt['spider'] : $txt['spiders']); |
|
| 1143 | - if (!empty($return['num_users_hidden'])) |
|
| 1144 | - $bracketList[] = comma_format($return['num_users_hidden']) . ' ' . $txt['hidden']; |
|
| 1200 | + if (!empty($user_info['buddies'])) { |
|
| 1201 | + $bracketList[] = comma_format($return['num_buddies']) . ' ' . ($return['num_buddies'] == 1 ? $txt['buddy'] : $txt['buddies']); |
|
| 1202 | + } |
|
| 1203 | + if (!empty($return['num_spiders'])) { |
|
| 1204 | + $bracketList[] = comma_format($return['num_spiders']) . ' ' . ($return['num_spiders'] == 1 ? $txt['spider'] : $txt['spiders']); |
|
| 1205 | + } |
|
| 1206 | + if (!empty($return['num_users_hidden'])) { |
|
| 1207 | + $bracketList[] = comma_format($return['num_users_hidden']) . ' ' . $txt['hidden']; |
|
| 1208 | + } |
|
| 1145 | 1209 | |
| 1146 | - if (!empty($bracketList)) |
|
| 1147 | - echo ' (' . implode(', ', $bracketList) . ')'; |
|
| 1210 | + if (!empty($bracketList)) { |
|
| 1211 | + echo ' (' . implode(', ', $bracketList) . ')'; |
|
| 1212 | + } |
|
| 1148 | 1213 | |
| 1149 | 1214 | echo '<br> |
| 1150 | 1215 | ', implode(', ', $return['list_users_online']); |
| 1151 | 1216 | |
| 1152 | 1217 | // Showing membergroups? |
| 1153 | - if (!empty($settings['show_group_key']) && !empty($return['membergroups'])) |
|
| 1154 | - echo '<br> |
|
| 1218 | + if (!empty($settings['show_group_key']) && !empty($return['membergroups'])) { |
|
| 1219 | + echo '<br> |
|
| 1155 | 1220 | [' . implode('] [', $return['membergroups']) . ']'; |
| 1156 | -} |
|
| 1221 | + } |
|
| 1222 | + } |
|
| 1157 | 1223 | |
| 1158 | 1224 | /** |
| 1159 | 1225 | * Just like whosOnline except it also logs the online presence. |
@@ -1164,11 +1230,12 @@ discard block |
||
| 1164 | 1230 | { |
| 1165 | 1231 | writeLog(); |
| 1166 | 1232 | |
| 1167 | - if ($output_method != 'echo') |
|
| 1168 | - return ssi_whosOnline($output_method); |
|
| 1169 | - else |
|
| 1170 | - ssi_whosOnline($output_method); |
|
| 1171 | -} |
|
| 1233 | + if ($output_method != 'echo') { |
|
| 1234 | + return ssi_whosOnline($output_method); |
|
| 1235 | + } else { |
|
| 1236 | + ssi_whosOnline($output_method); |
|
| 1237 | + } |
|
| 1238 | + } |
|
| 1172 | 1239 | |
| 1173 | 1240 | // Shows a login box. |
| 1174 | 1241 | /** |
@@ -1181,11 +1248,13 @@ discard block |
||
| 1181 | 1248 | { |
| 1182 | 1249 | global $scripturl, $txt, $user_info, $context; |
| 1183 | 1250 | |
| 1184 | - if ($redirect_to != '') |
|
| 1185 | - $_SESSION['login_url'] = $redirect_to; |
|
| 1251 | + if ($redirect_to != '') { |
|
| 1252 | + $_SESSION['login_url'] = $redirect_to; |
|
| 1253 | + } |
|
| 1186 | 1254 | |
| 1187 | - if ($output_method != 'echo' || !$user_info['is_guest']) |
|
| 1188 | - return $user_info['is_guest']; |
|
| 1255 | + if ($output_method != 'echo' || !$user_info['is_guest']) { |
|
| 1256 | + return $user_info['is_guest']; |
|
| 1257 | + } |
|
| 1189 | 1258 | |
| 1190 | 1259 | // Create a login token |
| 1191 | 1260 | createToken('login'); |
@@ -1237,8 +1306,9 @@ discard block |
||
| 1237 | 1306 | |
| 1238 | 1307 | $boardsAllowed = array_intersect(boardsAllowedTo('poll_view'), boardsAllowedTo('poll_vote')); |
| 1239 | 1308 | |
| 1240 | - if (empty($boardsAllowed)) |
|
| 1241 | - return array(); |
|
| 1309 | + if (empty($boardsAllowed)) { |
|
| 1310 | + return array(); |
|
| 1311 | + } |
|
| 1242 | 1312 | |
| 1243 | 1313 | $request = $smcFunc['db_query']('', ' |
| 1244 | 1314 | SELECT p.id_poll, p.question, t.id_topic, p.max_votes, p.guest_vote, p.hide_results, p.expire_time |
@@ -1271,12 +1341,14 @@ discard block |
||
| 1271 | 1341 | $smcFunc['db_free_result']($request); |
| 1272 | 1342 | |
| 1273 | 1343 | // This user has voted on all the polls. |
| 1274 | - if (empty($row) || !is_array($row)) |
|
| 1275 | - return array(); |
|
| 1344 | + if (empty($row) || !is_array($row)) { |
|
| 1345 | + return array(); |
|
| 1346 | + } |
|
| 1276 | 1347 | |
| 1277 | 1348 | // If this is a guest who's voted we'll through ourselves to show poll to show the results. |
| 1278 | - if ($user_info['is_guest'] && (!$row['guest_vote'] || (isset($_COOKIE['guest_poll_vote']) && in_array($row['id_poll'], explode(',', $_COOKIE['guest_poll_vote']))))) |
|
| 1279 | - return ssi_showPoll($row['id_topic'], $output_method); |
|
| 1349 | + if ($user_info['is_guest'] && (!$row['guest_vote'] || (isset($_COOKIE['guest_poll_vote']) && in_array($row['id_poll'], explode(',', $_COOKIE['guest_poll_vote']))))) { |
|
| 1350 | + return ssi_showPoll($row['id_topic'], $output_method); |
|
| 1351 | + } |
|
| 1280 | 1352 | |
| 1281 | 1353 | $request = $smcFunc['db_query']('', ' |
| 1282 | 1354 | SELECT COUNT(DISTINCT id_member) |
@@ -1340,8 +1412,9 @@ discard block |
||
| 1340 | 1412 | // If mods want to do somthing with this list of polls, let them do that now. |
| 1341 | 1413 | call_integration_hook('integrate_ssi_recentPoll', array(&$return, $topPollInstead)); |
| 1342 | 1414 | |
| 1343 | - if ($output_method != 'echo') |
|
| 1344 | - return $return; |
|
| 1415 | + if ($output_method != 'echo') { |
|
| 1416 | + return $return; |
|
| 1417 | + } |
|
| 1345 | 1418 | |
| 1346 | 1419 | if ($allow_view_results) |
| 1347 | 1420 | { |
@@ -1350,19 +1423,20 @@ discard block |
||
| 1350 | 1423 | <strong>', $return['question'], '</strong><br> |
| 1351 | 1424 | ', !empty($return['allowed_warning']) ? $return['allowed_warning'] . '<br>' : ''; |
| 1352 | 1425 | |
| 1353 | - foreach ($return['options'] as $option) |
|
| 1354 | - echo ' |
|
| 1426 | + foreach ($return['options'] as $option) { |
|
| 1427 | + echo ' |
|
| 1355 | 1428 | <label for="', $option['id'], '">', $option['vote_button'], ' ', $option['option'], '</label><br>'; |
| 1429 | + } |
|
| 1356 | 1430 | |
| 1357 | 1431 | echo ' |
| 1358 | 1432 | <input type="submit" value="', $txt['poll_vote'], '" class="button_submit"> |
| 1359 | 1433 | <input type="hidden" name="poll" value="', $return['id'], '"> |
| 1360 | 1434 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
| 1361 | 1435 | </form>'; |
| 1436 | + } else { |
|
| 1437 | + echo $txt['poll_cannot_see']; |
|
| 1438 | + } |
|
| 1362 | 1439 | } |
| 1363 | - else |
|
| 1364 | - echo $txt['poll_cannot_see']; |
|
| 1365 | -} |
|
| 1366 | 1440 | |
| 1367 | 1441 | /** |
| 1368 | 1442 | * Shows the poll from the specified topic |
@@ -1376,13 +1450,15 @@ discard block |
||
| 1376 | 1450 | |
| 1377 | 1451 | $boardsAllowed = boardsAllowedTo('poll_view'); |
| 1378 | 1452 | |
| 1379 | - if (empty($boardsAllowed)) |
|
| 1380 | - return array(); |
|
| 1453 | + if (empty($boardsAllowed)) { |
|
| 1454 | + return array(); |
|
| 1455 | + } |
|
| 1381 | 1456 | |
| 1382 | - if ($topic === null && isset($_REQUEST['ssi_topic'])) |
|
| 1383 | - $topic = (int) $_REQUEST['ssi_topic']; |
|
| 1384 | - else |
|
| 1385 | - $topic = (int) $topic; |
|
| 1457 | + if ($topic === null && isset($_REQUEST['ssi_topic'])) { |
|
| 1458 | + $topic = (int) $_REQUEST['ssi_topic']; |
|
| 1459 | + } else { |
|
| 1460 | + $topic = (int) $topic; |
|
| 1461 | + } |
|
| 1386 | 1462 | |
| 1387 | 1463 | $request = $smcFunc['db_query']('', ' |
| 1388 | 1464 | SELECT |
@@ -1403,17 +1479,18 @@ discard block |
||
| 1403 | 1479 | ); |
| 1404 | 1480 | |
| 1405 | 1481 | // Either this topic has no poll, or the user cannot view it. |
| 1406 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 1407 | - return array(); |
|
| 1482 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 1483 | + return array(); |
|
| 1484 | + } |
|
| 1408 | 1485 | |
| 1409 | 1486 | $row = $smcFunc['db_fetch_assoc']($request); |
| 1410 | 1487 | $smcFunc['db_free_result']($request); |
| 1411 | 1488 | |
| 1412 | 1489 | // Check if they can vote. |
| 1413 | 1490 | $already_voted = false; |
| 1414 | - if (!empty($row['expire_time']) && $row['expire_time'] < time()) |
|
| 1415 | - $allow_vote = false; |
|
| 1416 | - elseif ($user_info['is_guest']) |
|
| 1491 | + if (!empty($row['expire_time']) && $row['expire_time'] < time()) { |
|
| 1492 | + $allow_vote = false; |
|
| 1493 | + } elseif ($user_info['is_guest']) |
|
| 1417 | 1494 | { |
| 1418 | 1495 | // There's a difference between "allowed to vote" and "already voted"... |
| 1419 | 1496 | $allow_vote = $row['guest_vote']; |
@@ -1423,10 +1500,9 @@ discard block |
||
| 1423 | 1500 | { |
| 1424 | 1501 | $already_voted = true; |
| 1425 | 1502 | } |
| 1426 | - } |
|
| 1427 | - elseif (!empty($row['voting_locked']) || !allowedTo('poll_vote', $row['id_board'])) |
|
| 1428 | - $allow_vote = false; |
|
| 1429 | - else |
|
| 1503 | + } elseif (!empty($row['voting_locked']) || !allowedTo('poll_vote', $row['id_board'])) { |
|
| 1504 | + $allow_vote = false; |
|
| 1505 | + } else |
|
| 1430 | 1506 | { |
| 1431 | 1507 | $request = $smcFunc['db_query']('', ' |
| 1432 | 1508 | SELECT id_member |
@@ -1508,8 +1584,9 @@ discard block |
||
| 1508 | 1584 | // If mods want to do somthing with this poll, let them do that now. |
| 1509 | 1585 | call_integration_hook('integrate_ssi_showPoll', array(&$return)); |
| 1510 | 1586 | |
| 1511 | - if ($output_method != 'echo') |
|
| 1512 | - return $return; |
|
| 1587 | + if ($output_method != 'echo') { |
|
| 1588 | + return $return; |
|
| 1589 | + } |
|
| 1513 | 1590 | |
| 1514 | 1591 | if ($return['allow_vote']) |
| 1515 | 1592 | { |
@@ -1518,17 +1595,17 @@ discard block |
||
| 1518 | 1595 | <strong>', $return['question'], '</strong><br> |
| 1519 | 1596 | ', !empty($return['allowed_warning']) ? $return['allowed_warning'] . '<br>' : ''; |
| 1520 | 1597 | |
| 1521 | - foreach ($return['options'] as $option) |
|
| 1522 | - echo ' |
|
| 1598 | + foreach ($return['options'] as $option) { |
|
| 1599 | + echo ' |
|
| 1523 | 1600 | <label for="', $option['id'], '">', $option['vote_button'], ' ', $option['option'], '</label><br>'; |
| 1601 | + } |
|
| 1524 | 1602 | |
| 1525 | 1603 | echo ' |
| 1526 | 1604 | <input type="submit" value="', $txt['poll_vote'], '" class="button_submit"> |
| 1527 | 1605 | <input type="hidden" name="poll" value="', $return['id'], '"> |
| 1528 | 1606 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
| 1529 | 1607 | </form>'; |
| 1530 | - } |
|
| 1531 | - else |
|
| 1608 | + } else |
|
| 1532 | 1609 | { |
| 1533 | 1610 | echo ' |
| 1534 | 1611 | <div class="ssi_poll"> |
@@ -1608,27 +1685,32 @@ discard block |
||
| 1608 | 1685 | 'is_approved' => 1, |
| 1609 | 1686 | ) |
| 1610 | 1687 | ); |
| 1611 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 1612 | - die; |
|
| 1688 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 1689 | + die; |
|
| 1690 | + } |
|
| 1613 | 1691 | $row = $smcFunc['db_fetch_assoc']($request); |
| 1614 | 1692 | $smcFunc['db_free_result']($request); |
| 1615 | 1693 | |
| 1616 | - if (!empty($row['voting_locked']) || ($row['selected'] != -1 && !$user_info['is_guest']) || (!empty($row['expire_time']) && time() > $row['expire_time'])) |
|
| 1617 | - redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
| 1694 | + if (!empty($row['voting_locked']) || ($row['selected'] != -1 && !$user_info['is_guest']) || (!empty($row['expire_time']) && time() > $row['expire_time'])) { |
|
| 1695 | + redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
| 1696 | + } |
|
| 1618 | 1697 | |
| 1619 | 1698 | // Too many options checked? |
| 1620 | - if (count($_REQUEST['options']) > $row['max_votes']) |
|
| 1621 | - redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
| 1699 | + if (count($_REQUEST['options']) > $row['max_votes']) { |
|
| 1700 | + redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
| 1701 | + } |
|
| 1622 | 1702 | |
| 1623 | 1703 | // It's a guest who has already voted? |
| 1624 | 1704 | if ($user_info['is_guest']) |
| 1625 | 1705 | { |
| 1626 | 1706 | // Guest voting disabled? |
| 1627 | - if (!$row['guest_vote']) |
|
| 1628 | - redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
| 1707 | + if (!$row['guest_vote']) { |
|
| 1708 | + redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
| 1709 | + } |
|
| 1629 | 1710 | // Already voted? |
| 1630 | - elseif (isset($_COOKIE['guest_poll_vote']) && in_array($row['id_poll'], explode(',', $_COOKIE['guest_poll_vote']))) |
|
| 1631 | - redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
| 1711 | + elseif (isset($_COOKIE['guest_poll_vote']) && in_array($row['id_poll'], explode(',', $_COOKIE['guest_poll_vote']))) { |
|
| 1712 | + redirectexit('topic=' . $row['id_topic'] . '.0'); |
|
| 1713 | + } |
|
| 1632 | 1714 | } |
| 1633 | 1715 | |
| 1634 | 1716 | $sOptions = array(); |
@@ -1682,11 +1764,13 @@ discard block |
||
| 1682 | 1764 | { |
| 1683 | 1765 | global $scripturl, $txt, $context; |
| 1684 | 1766 | |
| 1685 | - if (!allowedTo('search_posts')) |
|
| 1686 | - return; |
|
| 1767 | + if (!allowedTo('search_posts')) { |
|
| 1768 | + return; |
|
| 1769 | + } |
|
| 1687 | 1770 | |
| 1688 | - if ($output_method != 'echo') |
|
| 1689 | - return $scripturl . '?action=search'; |
|
| 1771 | + if ($output_method != 'echo') { |
|
| 1772 | + return $scripturl . '?action=search'; |
|
| 1773 | + } |
|
| 1690 | 1774 | |
| 1691 | 1775 | echo ' |
| 1692 | 1776 | <form action="', $scripturl, '?action=search2" method="post" accept-charset="', $context['character_set'], '"> |
@@ -1708,8 +1792,9 @@ discard block |
||
| 1708 | 1792 | // If mods want to do somthing with the news, let them do that now. Don't need to pass the news line itself, since it is already in $context. |
| 1709 | 1793 | call_integration_hook('integrate_ssi_news'); |
| 1710 | 1794 | |
| 1711 | - if ($output_method != 'echo') |
|
| 1712 | - return $context['random_news_line']; |
|
| 1795 | + if ($output_method != 'echo') { |
|
| 1796 | + return $context['random_news_line']; |
|
| 1797 | + } |
|
| 1713 | 1798 | |
| 1714 | 1799 | echo $context['random_news_line']; |
| 1715 | 1800 | } |
@@ -1723,8 +1808,9 @@ discard block |
||
| 1723 | 1808 | { |
| 1724 | 1809 | global $scripturl, $modSettings, $user_info; |
| 1725 | 1810 | |
| 1726 | - if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view') || !allowedTo('profile_view')) |
|
| 1727 | - return; |
|
| 1811 | + if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view') || !allowedTo('profile_view')) { |
|
| 1812 | + return; |
|
| 1813 | + } |
|
| 1728 | 1814 | |
| 1729 | 1815 | $eventOptions = array( |
| 1730 | 1816 | 'include_birthdays' => true, |
@@ -1735,13 +1821,15 @@ discard block |
||
| 1735 | 1821 | // The ssi_todaysCalendar variants all use the same hook and just pass on $eventOptions so the hooked code can distinguish different cases if necessary |
| 1736 | 1822 | call_integration_hook('integrate_ssi_calendar', array(&$return, $eventOptions)); |
| 1737 | 1823 | |
| 1738 | - if ($output_method != 'echo') |
|
| 1739 | - return $return['calendar_birthdays']; |
|
| 1824 | + if ($output_method != 'echo') { |
|
| 1825 | + return $return['calendar_birthdays']; |
|
| 1826 | + } |
|
| 1740 | 1827 | |
| 1741 | - foreach ($return['calendar_birthdays'] as $member) |
|
| 1742 | - echo ' |
|
| 1828 | + foreach ($return['calendar_birthdays'] as $member) { |
|
| 1829 | + echo ' |
|
| 1743 | 1830 | <a href="', $scripturl, '?action=profile;u=', $member['id'], '"><span class="fix_rtl_names">' . $member['name'] . '</span>' . (isset($member['age']) ? ' (' . $member['age'] . ')' : '') . '</a>' . (!$member['is_last'] ? ', ' : ''); |
| 1744 | -} |
|
| 1831 | + } |
|
| 1832 | + } |
|
| 1745 | 1833 | |
| 1746 | 1834 | /** |
| 1747 | 1835 | * Shows today's holidays. |
@@ -1752,8 +1840,9 @@ discard block |
||
| 1752 | 1840 | { |
| 1753 | 1841 | global $modSettings, $user_info; |
| 1754 | 1842 | |
| 1755 | - if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) |
|
| 1756 | - return; |
|
| 1843 | + if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) { |
|
| 1844 | + return; |
|
| 1845 | + } |
|
| 1757 | 1846 | |
| 1758 | 1847 | $eventOptions = array( |
| 1759 | 1848 | 'include_holidays' => true, |
@@ -1764,8 +1853,9 @@ discard block |
||
| 1764 | 1853 | // The ssi_todaysCalendar variants all use the same hook and just pass on $eventOptions so the hooked code can distinguish different cases if necessary |
| 1765 | 1854 | call_integration_hook('integrate_ssi_calendar', array(&$return, $eventOptions)); |
| 1766 | 1855 | |
| 1767 | - if ($output_method != 'echo') |
|
| 1768 | - return $return['calendar_holidays']; |
|
| 1856 | + if ($output_method != 'echo') { |
|
| 1857 | + return $return['calendar_holidays']; |
|
| 1858 | + } |
|
| 1769 | 1859 | |
| 1770 | 1860 | echo ' |
| 1771 | 1861 | ', implode(', ', $return['calendar_holidays']); |
@@ -1779,8 +1869,9 @@ discard block |
||
| 1779 | 1869 | { |
| 1780 | 1870 | global $modSettings, $user_info; |
| 1781 | 1871 | |
| 1782 | - if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) |
|
| 1783 | - return; |
|
| 1872 | + if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) { |
|
| 1873 | + return; |
|
| 1874 | + } |
|
| 1784 | 1875 | |
| 1785 | 1876 | $eventOptions = array( |
| 1786 | 1877 | 'include_events' => true, |
@@ -1791,14 +1882,16 @@ discard block |
||
| 1791 | 1882 | // The ssi_todaysCalendar variants all use the same hook and just pass on $eventOptions so the hooked code can distinguish different cases if necessary |
| 1792 | 1883 | call_integration_hook('integrate_ssi_calendar', array(&$return, $eventOptions)); |
| 1793 | 1884 | |
| 1794 | - if ($output_method != 'echo') |
|
| 1795 | - return $return['calendar_events']; |
|
| 1885 | + if ($output_method != 'echo') { |
|
| 1886 | + return $return['calendar_events']; |
|
| 1887 | + } |
|
| 1796 | 1888 | |
| 1797 | 1889 | foreach ($return['calendar_events'] as $event) |
| 1798 | 1890 | { |
| 1799 | - if ($event['can_edit']) |
|
| 1800 | - echo ' |
|
| 1891 | + if ($event['can_edit']) { |
|
| 1892 | + echo ' |
|
| 1801 | 1893 | <a href="' . $event['modify_href'] . '" style="color: #ff0000;">*</a> '; |
| 1894 | + } |
|
| 1802 | 1895 | echo ' |
| 1803 | 1896 | ' . $event['link'] . (!$event['is_last'] ? ', ' : ''); |
| 1804 | 1897 | } |
@@ -1813,8 +1906,9 @@ discard block |
||
| 1813 | 1906 | { |
| 1814 | 1907 | global $modSettings, $txt, $scripturl, $user_info; |
| 1815 | 1908 | |
| 1816 | - if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) |
|
| 1817 | - return; |
|
| 1909 | + if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) { |
|
| 1910 | + return; |
|
| 1911 | + } |
|
| 1818 | 1912 | |
| 1819 | 1913 | $eventOptions = array( |
| 1820 | 1914 | 'include_birthdays' => allowedTo('profile_view'), |
@@ -1827,19 +1921,22 @@ discard block |
||
| 1827 | 1921 | // The ssi_todaysCalendar variants all use the same hook and just pass on $eventOptions so the hooked code can distinguish different cases if necessary |
| 1828 | 1922 | call_integration_hook('integrate_ssi_calendar', array(&$return, $eventOptions)); |
| 1829 | 1923 | |
| 1830 | - if ($output_method != 'echo') |
|
| 1831 | - return $return; |
|
| 1924 | + if ($output_method != 'echo') { |
|
| 1925 | + return $return; |
|
| 1926 | + } |
|
| 1832 | 1927 | |
| 1833 | - if (!empty($return['calendar_holidays'])) |
|
| 1834 | - echo ' |
|
| 1928 | + if (!empty($return['calendar_holidays'])) { |
|
| 1929 | + echo ' |
|
| 1835 | 1930 | <span class="holiday">' . $txt['calendar_prompt'] . ' ' . implode(', ', $return['calendar_holidays']) . '<br></span>'; |
| 1931 | + } |
|
| 1836 | 1932 | if (!empty($return['calendar_birthdays'])) |
| 1837 | 1933 | { |
| 1838 | 1934 | echo ' |
| 1839 | 1935 | <span class="birthday">' . $txt['birthdays_upcoming'] . '</span> '; |
| 1840 | - foreach ($return['calendar_birthdays'] as $member) |
|
| 1841 | - echo ' |
|
| 1936 | + foreach ($return['calendar_birthdays'] as $member) { |
|
| 1937 | + echo ' |
|
| 1842 | 1938 | <a href="', $scripturl, '?action=profile;u=', $member['id'], '"><span class="fix_rtl_names">', $member['name'], '</span>', isset($member['age']) ? ' (' . $member['age'] . ')' : '', '</a>', !$member['is_last'] ? ', ' : ''; |
| 1939 | + } |
|
| 1843 | 1940 | echo ' |
| 1844 | 1941 | <br>'; |
| 1845 | 1942 | } |
@@ -1849,9 +1946,10 @@ discard block |
||
| 1849 | 1946 | <span class="event">' . $txt['events_upcoming'] . '</span> '; |
| 1850 | 1947 | foreach ($return['calendar_events'] as $event) |
| 1851 | 1948 | { |
| 1852 | - if ($event['can_edit']) |
|
| 1853 | - echo ' |
|
| 1949 | + if ($event['can_edit']) { |
|
| 1950 | + echo ' |
|
| 1854 | 1951 | <a href="' . $event['modify_href'] . '" style="color: #ff0000;">*</a> '; |
| 1952 | + } |
|
| 1855 | 1953 | echo ' |
| 1856 | 1954 | ' . $event['link'] . (!$event['is_last'] ? ', ' : ''); |
| 1857 | 1955 | } |
@@ -1875,25 +1973,29 @@ discard block |
||
| 1875 | 1973 | loadLanguage('Stats'); |
| 1876 | 1974 | |
| 1877 | 1975 | // Must be integers.... |
| 1878 | - if ($limit === null) |
|
| 1879 | - $limit = isset($_GET['limit']) ? (int) $_GET['limit'] : 5; |
|
| 1880 | - else |
|
| 1881 | - $limit = (int) $limit; |
|
| 1882 | - |
|
| 1883 | - if ($start === null) |
|
| 1884 | - $start = isset($_GET['start']) ? (int) $_GET['start'] : 0; |
|
| 1885 | - else |
|
| 1886 | - $start = (int) $start; |
|
| 1887 | - |
|
| 1888 | - if ($board !== null) |
|
| 1889 | - $board = (int) $board; |
|
| 1890 | - elseif (isset($_GET['board'])) |
|
| 1891 | - $board = (int) $_GET['board']; |
|
| 1892 | - |
|
| 1893 | - if ($length === null) |
|
| 1894 | - $length = isset($_GET['length']) ? (int) $_GET['length'] : 0; |
|
| 1895 | - else |
|
| 1896 | - $length = (int) $length; |
|
| 1976 | + if ($limit === null) { |
|
| 1977 | + $limit = isset($_GET['limit']) ? (int) $_GET['limit'] : 5; |
|
| 1978 | + } else { |
|
| 1979 | + $limit = (int) $limit; |
|
| 1980 | + } |
|
| 1981 | + |
|
| 1982 | + if ($start === null) { |
|
| 1983 | + $start = isset($_GET['start']) ? (int) $_GET['start'] : 0; |
|
| 1984 | + } else { |
|
| 1985 | + $start = (int) $start; |
|
| 1986 | + } |
|
| 1987 | + |
|
| 1988 | + if ($board !== null) { |
|
| 1989 | + $board = (int) $board; |
|
| 1990 | + } elseif (isset($_GET['board'])) { |
|
| 1991 | + $board = (int) $_GET['board']; |
|
| 1992 | + } |
|
| 1993 | + |
|
| 1994 | + if ($length === null) { |
|
| 1995 | + $length = isset($_GET['length']) ? (int) $_GET['length'] : 0; |
|
| 1996 | + } else { |
|
| 1997 | + $length = (int) $length; |
|
| 1998 | + } |
|
| 1897 | 1999 | |
| 1898 | 2000 | $limit = max(0, $limit); |
| 1899 | 2001 | $start = max(0, $start); |
@@ -1911,17 +2013,19 @@ discard block |
||
| 1911 | 2013 | ); |
| 1912 | 2014 | if ($smcFunc['db_num_rows']($request) == 0) |
| 1913 | 2015 | { |
| 1914 | - if ($output_method == 'echo') |
|
| 1915 | - die($txt['ssi_no_guests']); |
|
| 1916 | - else |
|
| 1917 | - return array(); |
|
| 2016 | + if ($output_method == 'echo') { |
|
| 2017 | + die($txt['ssi_no_guests']); |
|
| 2018 | + } else { |
|
| 2019 | + return array(); |
|
| 2020 | + } |
|
| 1918 | 2021 | } |
| 1919 | 2022 | list ($board) = $smcFunc['db_fetch_row']($request); |
| 1920 | 2023 | $smcFunc['db_free_result']($request); |
| 1921 | 2024 | |
| 1922 | 2025 | $icon_sources = array(); |
| 1923 | - foreach ($context['stable_icons'] as $icon) |
|
| 1924 | - $icon_sources[$icon] = 'images_url'; |
|
| 2026 | + foreach ($context['stable_icons'] as $icon) { |
|
| 2027 | + $icon_sources[$icon] = 'images_url'; |
|
| 2028 | + } |
|
| 1925 | 2029 | |
| 1926 | 2030 | if (!empty($modSettings['enable_likes'])) |
| 1927 | 2031 | { |
@@ -1945,12 +2049,14 @@ discard block |
||
| 1945 | 2049 | ) |
| 1946 | 2050 | ); |
| 1947 | 2051 | $posts = array(); |
| 1948 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1949 | - $posts[] = $row['id_first_msg']; |
|
| 2052 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2053 | + $posts[] = $row['id_first_msg']; |
|
| 2054 | + } |
|
| 1950 | 2055 | $smcFunc['db_free_result']($request); |
| 1951 | 2056 | |
| 1952 | - if (empty($posts)) |
|
| 1953 | - return array(); |
|
| 2057 | + if (empty($posts)) { |
|
| 2058 | + return array(); |
|
| 2059 | + } |
|
| 1954 | 2060 | |
| 1955 | 2061 | // Find the posts. |
| 1956 | 2062 | $request = $smcFunc['db_query']('', ' |
@@ -1980,24 +2086,28 @@ discard block |
||
| 1980 | 2086 | $last_space = strrpos($row['body'], ' '); |
| 1981 | 2087 | $last_open = strrpos($row['body'], '<'); |
| 1982 | 2088 | $last_close = strrpos($row['body'], '>'); |
| 1983 | - if (empty($last_space) || ($last_space == $last_open + 3 && (empty($last_close) || (!empty($last_close) && $last_close < $last_open))) || $last_space < $last_open || $last_open == $length - 6) |
|
| 1984 | - $cutoff = $last_open; |
|
| 1985 | - elseif (empty($last_close) || $last_close < $last_open) |
|
| 1986 | - $cutoff = $last_space; |
|
| 2089 | + if (empty($last_space) || ($last_space == $last_open + 3 && (empty($last_close) || (!empty($last_close) && $last_close < $last_open))) || $last_space < $last_open || $last_open == $length - 6) { |
|
| 2090 | + $cutoff = $last_open; |
|
| 2091 | + } elseif (empty($last_close) || $last_close < $last_open) { |
|
| 2092 | + $cutoff = $last_space; |
|
| 2093 | + } |
|
| 1987 | 2094 | |
| 1988 | - if ($cutoff !== false) |
|
| 1989 | - $row['body'] = $smcFunc['substr']($row['body'], 0, $cutoff); |
|
| 2095 | + if ($cutoff !== false) { |
|
| 2096 | + $row['body'] = $smcFunc['substr']($row['body'], 0, $cutoff); |
|
| 2097 | + } |
|
| 1990 | 2098 | $row['body'] .= '...'; |
| 1991 | 2099 | } |
| 1992 | 2100 | |
| 1993 | 2101 | $row['body'] = parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']); |
| 1994 | 2102 | |
| 1995 | - if (!empty($recycle_board) && $row['id_board'] == $recycle_board) |
|
| 1996 | - $row['icon'] = 'recycled'; |
|
| 2103 | + if (!empty($recycle_board) && $row['id_board'] == $recycle_board) { |
|
| 2104 | + $row['icon'] = 'recycled'; |
|
| 2105 | + } |
|
| 1997 | 2106 | |
| 1998 | 2107 | // Check that this message icon is there... |
| 1999 | - if (!empty($modSettings['messageIconChecks_enable']) && !isset($icon_sources[$row['icon']])) |
|
| 2000 | - $icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 2108 | + if (!empty($modSettings['messageIconChecks_enable']) && !isset($icon_sources[$row['icon']])) { |
|
| 2109 | + $icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 2110 | + } |
|
| 2001 | 2111 | |
| 2002 | 2112 | censorText($row['subject']); |
| 2003 | 2113 | censorText($row['body']); |
@@ -2034,16 +2144,18 @@ discard block |
||
| 2034 | 2144 | } |
| 2035 | 2145 | $smcFunc['db_free_result']($request); |
| 2036 | 2146 | |
| 2037 | - if (empty($return)) |
|
| 2038 | - return $return; |
|
| 2147 | + if (empty($return)) { |
|
| 2148 | + return $return; |
|
| 2149 | + } |
|
| 2039 | 2150 | |
| 2040 | 2151 | $return[count($return) - 1]['is_last'] = true; |
| 2041 | 2152 | |
| 2042 | 2153 | // If mods want to do somthing with this list of posts, let them do that now. |
| 2043 | 2154 | call_integration_hook('integrate_ssi_boardNews', array(&$return)); |
| 2044 | 2155 | |
| 2045 | - if ($output_method != 'echo') |
|
| 2046 | - return $return; |
|
| 2156 | + if ($output_method != 'echo') { |
|
| 2157 | + return $return; |
|
| 2158 | + } |
|
| 2047 | 2159 | |
| 2048 | 2160 | foreach ($return as $news) |
| 2049 | 2161 | { |
@@ -2095,9 +2207,10 @@ discard block |
||
| 2095 | 2207 | echo ' |
| 2096 | 2208 | </div>'; |
| 2097 | 2209 | |
| 2098 | - if (!$news['is_last']) |
|
| 2099 | - echo ' |
|
| 2210 | + if (!$news['is_last']) { |
|
| 2211 | + echo ' |
|
| 2100 | 2212 | <hr>'; |
| 2213 | + } |
|
| 2101 | 2214 | } |
| 2102 | 2215 | } |
| 2103 | 2216 | |
@@ -2111,8 +2224,9 @@ discard block |
||
| 2111 | 2224 | { |
| 2112 | 2225 | global $user_info, $scripturl, $modSettings, $txt, $context, $smcFunc; |
| 2113 | 2226 | |
| 2114 | - if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) |
|
| 2115 | - return; |
|
| 2227 | + if (empty($modSettings['cal_enabled']) || !allowedTo('calendar_view')) { |
|
| 2228 | + return; |
|
| 2229 | + } |
|
| 2116 | 2230 | |
| 2117 | 2231 | // Find all events which are happening in the near future that the member can see. |
| 2118 | 2232 | $request = $smcFunc['db_query']('', ' |
@@ -2137,20 +2251,23 @@ discard block |
||
| 2137 | 2251 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2138 | 2252 | { |
| 2139 | 2253 | // Check if we've already come by an event linked to this same topic with the same title... and don't display it if we have. |
| 2140 | - if (!empty($duplicates[$row['title'] . $row['id_topic']])) |
|
| 2141 | - continue; |
|
| 2254 | + if (!empty($duplicates[$row['title'] . $row['id_topic']])) { |
|
| 2255 | + continue; |
|
| 2256 | + } |
|
| 2142 | 2257 | |
| 2143 | 2258 | // Censor the title. |
| 2144 | 2259 | censorText($row['title']); |
| 2145 | 2260 | |
| 2146 | - if ($row['start_date'] < strftime('%Y-%m-%d', forum_time(false))) |
|
| 2147 | - $date = strftime('%Y-%m-%d', forum_time(false)); |
|
| 2148 | - else |
|
| 2149 | - $date = $row['start_date']; |
|
| 2261 | + if ($row['start_date'] < strftime('%Y-%m-%d', forum_time(false))) { |
|
| 2262 | + $date = strftime('%Y-%m-%d', forum_time(false)); |
|
| 2263 | + } else { |
|
| 2264 | + $date = $row['start_date']; |
|
| 2265 | + } |
|
| 2150 | 2266 | |
| 2151 | 2267 | // If the topic it is attached to is not approved then don't link it. |
| 2152 | - if (!empty($row['id_first_msg']) && !$row['approved']) |
|
| 2153 | - $row['id_board'] = $row['id_topic'] = $row['id_first_msg'] = 0; |
|
| 2268 | + if (!empty($row['id_first_msg']) && !$row['approved']) { |
|
| 2269 | + $row['id_board'] = $row['id_topic'] = $row['id_first_msg'] = 0; |
|
| 2270 | + } |
|
| 2154 | 2271 | |
| 2155 | 2272 | $return[$date][] = array( |
| 2156 | 2273 | 'id' => $row['id_event'], |
@@ -2169,24 +2286,27 @@ discard block |
||
| 2169 | 2286 | } |
| 2170 | 2287 | $smcFunc['db_free_result']($request); |
| 2171 | 2288 | |
| 2172 | - foreach ($return as $mday => $array) |
|
| 2173 | - $return[$mday][count($array) - 1]['is_last'] = true; |
|
| 2289 | + foreach ($return as $mday => $array) { |
|
| 2290 | + $return[$mday][count($array) - 1]['is_last'] = true; |
|
| 2291 | + } |
|
| 2174 | 2292 | |
| 2175 | 2293 | // If mods want to do somthing with this list of events, let them do that now. |
| 2176 | 2294 | call_integration_hook('integrate_ssi_recentEvents', array(&$return)); |
| 2177 | 2295 | |
| 2178 | - if ($output_method != 'echo' || empty($return)) |
|
| 2179 | - return $return; |
|
| 2296 | + if ($output_method != 'echo' || empty($return)) { |
|
| 2297 | + return $return; |
|
| 2298 | + } |
|
| 2180 | 2299 | |
| 2181 | 2300 | // Well the output method is echo. |
| 2182 | 2301 | echo ' |
| 2183 | 2302 | <span class="event">' . $txt['events'] . '</span> '; |
| 2184 | - foreach ($return as $mday => $array) |
|
| 2185 | - foreach ($array as $event) |
|
| 2303 | + foreach ($return as $mday => $array) { |
|
| 2304 | + foreach ($array as $event) |
|
| 2186 | 2305 | { |
| 2187 | 2306 | if ($event['can_edit']) |
| 2188 | 2307 | echo ' |
| 2189 | 2308 | <a href="' . $event['modify_href'] . '" style="color: #ff0000;">*</a> '; |
| 2309 | + } |
|
| 2190 | 2310 | |
| 2191 | 2311 | echo ' |
| 2192 | 2312 | ' . $event['link'] . (!$event['is_last'] ? ', ' : ''); |
@@ -2205,8 +2325,9 @@ discard block |
||
| 2205 | 2325 | global $smcFunc; |
| 2206 | 2326 | |
| 2207 | 2327 | // If $id is null, this was most likely called from a query string and should do nothing. |
| 2208 | - if ($id === null) |
|
| 2209 | - return; |
|
| 2328 | + if ($id === null) { |
|
| 2329 | + return; |
|
| 2330 | + } |
|
| 2210 | 2331 | |
| 2211 | 2332 | $request = $smcFunc['db_query']('', ' |
| 2212 | 2333 | SELECT passwd, member_name, is_activated |
@@ -2238,8 +2359,9 @@ discard block |
||
| 2238 | 2359 | $attachments_boards = boardsAllowedTo('view_attachments'); |
| 2239 | 2360 | |
| 2240 | 2361 | // No boards? Adios amigo. |
| 2241 | - if (empty($attachments_boards)) |
|
| 2242 | - return array(); |
|
| 2362 | + if (empty($attachments_boards)) { |
|
| 2363 | + return array(); |
|
| 2364 | + } |
|
| 2243 | 2365 | |
| 2244 | 2366 | // Is it an array? |
| 2245 | 2367 | $attachment_ext = (array) $attachment_ext; |
@@ -2323,8 +2445,9 @@ discard block |
||
| 2323 | 2445 | call_integration_hook('integrate_ssi_recentAttachments', array(&$attachments)); |
| 2324 | 2446 | |
| 2325 | 2447 | // So you just want an array? Here you can have it. |
| 2326 | - if ($output_method == 'array' || empty($attachments)) |
|
| 2327 | - return $attachments; |
|
| 2448 | + if ($output_method == 'array' || empty($attachments)) { |
|
| 2449 | + return $attachments; |
|
| 2450 | + } |
|
| 2328 | 2451 | |
| 2329 | 2452 | // Give them the default. |
| 2330 | 2453 | echo ' |
@@ -2335,14 +2458,15 @@ discard block |
||
| 2335 | 2458 | <th style="text-align: left; padding: 2">', $txt['downloads'], '</th> |
| 2336 | 2459 | <th style="text-align: left; padding: 2">', $txt['filesize'], '</th> |
| 2337 | 2460 | </tr>'; |
| 2338 | - foreach ($attachments as $attach) |
|
| 2339 | - echo ' |
|
| 2461 | + foreach ($attachments as $attach) { |
|
| 2462 | + echo ' |
|
| 2340 | 2463 | <tr> |
| 2341 | 2464 | <td>', $attach['file']['link'], '</td> |
| 2342 | 2465 | <td>', $attach['member']['link'], '</td> |
| 2343 | 2466 | <td style="text-align: center">', $attach['file']['downloads'], '</td> |
| 2344 | 2467 | <td>', $attach['file']['filesize'], '</td> |
| 2345 | 2468 | </tr>'; |
| 2469 | + } |
|
| 2346 | 2470 | echo ' |
| 2347 | 2471 | </table>'; |
| 2348 | 2472 | } |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | * |
| 61 | 61 | * @param string $grid_name The grid name |
| 62 | 62 | * @param bool $is_mini Is this a mini grid? |
| 63 | - * @return void|bool Returns false if the grid doesn't exist. |
|
| 63 | + * @return false|null Returns false if the grid doesn't exist. |
|
| 64 | 64 | */ |
| 65 | 65 | function template_show_month_grid($grid_name, $is_mini = false) |
| 66 | 66 | { |
@@ -312,7 +312,7 @@ discard block |
||
| 312 | 312 | * Shows a weekly grid |
| 313 | 313 | * |
| 314 | 314 | * @param string $grid_name The name of the grid |
| 315 | - * @return void|bool Returns false if the grid doesn't exist |
|
| 315 | + * @return false|null Returns false if the grid doesn't exist |
|
| 316 | 316 | */ |
| 317 | 317 | function template_show_week_grid($grid_name) |
| 318 | 318 | { |
@@ -253,9 +253,9 @@ discard block |
||
| 253 | 253 | { |
| 254 | 254 | // Sort events by start time (all day events will be listed first) |
| 255 | 255 | uasort($day['events'], function ($a, $b) { |
| 256 | - if ($a['start_timestamp'] == $b['start_timestamp']) |
|
| 257 | - return 0; |
|
| 258 | - return ($a['start_timestamp'] < $b['start_timestamp']) ? -1 : 1; |
|
| 256 | + if ($a['start_timestamp'] == $b['start_timestamp']) |
|
| 257 | + return 0; |
|
| 258 | + return ($a['start_timestamp'] < $b['start_timestamp']) ? -1 : 1; |
|
| 259 | 259 | }); |
| 260 | 260 | |
| 261 | 261 | echo ' |
@@ -436,9 +436,9 @@ discard block |
||
| 436 | 436 | { |
| 437 | 437 | // Sort events by start time (all day events will be listed first) |
| 438 | 438 | uasort($day['events'], function ($a, $b) { |
| 439 | - if ($a['start_timestamp'] == $b['start_timestamp']) |
|
| 440 | - return 0; |
|
| 441 | - return ($a['start_timestamp'] < $b['start_timestamp']) ? -1 : 1; |
|
| 439 | + if ($a['start_timestamp'] == $b['start_timestamp']) |
|
| 440 | + return 0; |
|
| 441 | + return ($a['start_timestamp'] < $b['start_timestamp']) ? -1 : 1; |
|
| 442 | 442 | }); |
| 443 | 443 | |
| 444 | 444 | foreach ($day['events'] as $event) |
@@ -40,8 +40,7 @@ discard block |
||
| 40 | 40 | ', template_show_week_grid('main'), ' |
| 41 | 41 | </div> |
| 42 | 42 | '; |
| 43 | - } |
|
| 44 | - else |
|
| 43 | + } else |
|
| 45 | 44 | { |
| 46 | 45 | echo ' |
| 47 | 46 | <div id="main_grid"> |
@@ -67,17 +66,19 @@ discard block |
||
| 67 | 66 | global $context, $settings, $txt, $scripturl, $modSettings; |
| 68 | 67 | |
| 69 | 68 | // If the grid doesn't exist, no point in proceeding. |
| 70 | - if (!isset($context['calendar_grid_' . $grid_name])) |
|
| 71 | - return false; |
|
| 69 | + if (!isset($context['calendar_grid_' . $grid_name])) { |
|
| 70 | + return false; |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | 73 | // A handy little pointer variable. |
| 74 | 74 | $calendar_data = &$context['calendar_grid_' . $grid_name]; |
| 75 | 75 | |
| 76 | 76 | // Some conditions for whether or not we should show the week links *here*. |
| 77 | - if (isset($calendar_data['show_week_links']) && ($calendar_data['show_week_links'] == 3 || (($calendar_data['show_week_links'] == 1 && $is_mini === true) || $calendar_data['show_week_links'] == 2 && $is_mini === false))) |
|
| 78 | - $show_week_links = true; |
|
| 79 | - else |
|
| 80 | - $show_week_links = false; |
|
| 77 | + if (isset($calendar_data['show_week_links']) && ($calendar_data['show_week_links'] == 3 || (($calendar_data['show_week_links'] == 1 && $is_mini === true) || $calendar_data['show_week_links'] == 2 && $is_mini === false))) { |
|
| 78 | + $show_week_links = true; |
|
| 79 | + } else { |
|
| 80 | + $show_week_links = false; |
|
| 81 | + } |
|
| 81 | 82 | |
| 82 | 83 | // Assuming that we've not disabled it, show the title block! |
| 83 | 84 | if (empty($calendar_data['disable_title'])) |
@@ -124,8 +125,9 @@ discard block |
||
| 124 | 125 | echo '<tr>'; |
| 125 | 126 | |
| 126 | 127 | // If we're showing week links, there's an extra column ahead of the week links, so let's think ahead and be prepared! |
| 127 | - if ($show_week_links === true) |
|
| 128 | - echo '<th> </th>'; |
|
| 128 | + if ($show_week_links === true) { |
|
| 129 | + echo '<th> </th>'; |
|
| 130 | + } |
|
| 129 | 131 | |
| 130 | 132 | // Now, loop through each actual day of the week. |
| 131 | 133 | foreach ($calendar_data['week_days'] as $day) |
@@ -172,29 +174,32 @@ discard block |
||
| 172 | 174 | // Additional classes are given for events, holidays, and birthdays. |
| 173 | 175 | if (!empty($day['events']) && !empty($calendar_data['highlight']['events'])) |
| 174 | 176 | { |
| 175 | - if ($is_mini === true && in_array($calendar_data['highlight']['events'], array(1, 3))) |
|
| 176 | - $classes[] = 'events'; |
|
| 177 | - elseif ($is_mini === false && in_array($calendar_data['highlight']['events'], array(2, 3))) |
|
| 178 | - $classes[] = 'events'; |
|
| 177 | + if ($is_mini === true && in_array($calendar_data['highlight']['events'], array(1, 3))) { |
|
| 178 | + $classes[] = 'events'; |
|
| 179 | + } elseif ($is_mini === false && in_array($calendar_data['highlight']['events'], array(2, 3))) { |
|
| 180 | + $classes[] = 'events'; |
|
| 181 | + } |
|
| 179 | 182 | } |
| 180 | 183 | if (!empty($day['holidays']) && !empty($calendar_data['highlight']['holidays'])) |
| 181 | 184 | { |
| 182 | - if ($is_mini === true && in_array($calendar_data['highlight']['holidays'], array(1, 3))) |
|
| 183 | - $classes[] = 'holidays'; |
|
| 184 | - elseif ($is_mini === false && in_array($calendar_data['highlight']['holidays'], array(2, 3))) |
|
| 185 | - $classes[] = 'holidays'; |
|
| 185 | + if ($is_mini === true && in_array($calendar_data['highlight']['holidays'], array(1, 3))) { |
|
| 186 | + $classes[] = 'holidays'; |
|
| 187 | + } elseif ($is_mini === false && in_array($calendar_data['highlight']['holidays'], array(2, 3))) { |
|
| 188 | + $classes[] = 'holidays'; |
|
| 189 | + } |
|
| 186 | 190 | } |
| 187 | 191 | if (!empty($day['birthdays']) && !empty($calendar_data['highlight']['birthdays'])) |
| 188 | 192 | { |
| 189 | - if ($is_mini === true && in_array($calendar_data['highlight']['birthdays'], array(1, 3))) |
|
| 190 | - $classes[] = 'birthdays'; |
|
| 191 | - elseif ($is_mini === false && in_array($calendar_data['highlight']['birthdays'], array(2, 3))) |
|
| 192 | - $classes[] = 'birthdays'; |
|
| 193 | + if ($is_mini === true && in_array($calendar_data['highlight']['birthdays'], array(1, 3))) { |
|
| 194 | + $classes[] = 'birthdays'; |
|
| 195 | + } elseif ($is_mini === false && in_array($calendar_data['highlight']['birthdays'], array(2, 3))) { |
|
| 196 | + $classes[] = 'birthdays'; |
|
| 197 | + } |
|
| 193 | 198 | } |
| 194 | - } |
|
| 195 | - else |
|
| 196 | - // Default Classes (either compact or comfortable and disabled). |
|
| 199 | + } else { |
|
| 200 | + // Default Classes (either compact or comfortable and disabled). |
|
| 197 | 201 | $classes[] = !empty($calendar_data['size']) && $calendar_data['size'] == 'small' ? 'compact' : 'comfortable'; |
| 202 | + } |
|
| 198 | 203 | $classes[] = 'disabled'; |
| 199 | 204 | |
| 200 | 205 | // Now, implode the classes for each day. |
@@ -208,17 +213,19 @@ discard block |
||
| 208 | 213 | $title_prefix = !empty($day['is_first_of_month']) && $context['current_month'] == $calendar_data['current_month'] && $is_mini === false ? (!empty($calendar_data['short_month_titles']) ? $txt['months_short'][$calendar_data['current_month']] . ' ' : $txt['months_titles'][$calendar_data['current_month']] . ' ') : ''; |
| 209 | 214 | |
| 210 | 215 | // The actual day number - be it a link, or just plain old text! |
| 211 | - if (!empty($modSettings['cal_daysaslink']) && $context['can_post']) |
|
| 212 | - echo '<a href="', $scripturl, '?action=calendar;sa=post;year=', $calendar_data['current_year'], ';month=', $calendar_data['current_month'], ';day=', $day['day'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="day_text">', $title_prefix, $day['day'], '</span></a>'; |
|
| 213 | - else |
|
| 214 | - echo '<span class="day_text">', $title_prefix, $day['day'], '</span>'; |
|
| 216 | + if (!empty($modSettings['cal_daysaslink']) && $context['can_post']) { |
|
| 217 | + echo '<a href="', $scripturl, '?action=calendar;sa=post;year=', $calendar_data['current_year'], ';month=', $calendar_data['current_month'], ';day=', $day['day'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="day_text">', $title_prefix, $day['day'], '</span></a>'; |
|
| 218 | + } else { |
|
| 219 | + echo '<span class="day_text">', $title_prefix, $day['day'], '</span>'; |
|
| 220 | + } |
|
| 215 | 221 | |
| 216 | 222 | // A lot of stuff, we're not showing on mini-calendars to conserve space. |
| 217 | 223 | if ($is_mini === false) |
| 218 | 224 | { |
| 219 | 225 | // Holidays are always fun, let's show them! |
| 220 | - if (!empty($day['holidays'])) |
|
| 221 | - echo '<div class="smalltext holiday"><span>', $txt['calendar_prompt'], '</span> ', implode(', ', $day['holidays']), '</div>'; |
|
| 226 | + if (!empty($day['holidays'])) { |
|
| 227 | + echo '<div class="smalltext holiday"><span>', $txt['calendar_prompt'], '</span> ', implode(', ', $day['holidays']), '</div>'; |
|
| 228 | + } |
|
| 222 | 229 | |
| 223 | 230 | // Happy Birthday Dear, Member! |
| 224 | 231 | if (!empty($day['birthdays'])) |
@@ -236,14 +243,16 @@ discard block |
||
| 236 | 243 | echo '<a href="', $scripturl, '?action=profile;u=', $member['id'], '"><span class="fix_rtl_names">', $member['name'], '</span>', isset($member['age']) ? ' (' . $member['age'] . ')' : '', '</a>', $member['is_last'] || ($count == 10 && $use_js_hide) ? '' : ', '; |
| 237 | 244 | |
| 238 | 245 | // 9...10! Let's stop there. |
| 239 | - if ($birthday_count == 10 && $use_js_hide) |
|
| 240 | - // !!TODO - Inline CSS and JavaScript should be moved. |
|
| 246 | + if ($birthday_count == 10 && $use_js_hide) { |
|
| 247 | + // !!TODO - Inline CSS and JavaScript should be moved. |
|
| 241 | 248 | echo '<span class="hidelink" id="bdhidelink_', $day['day'], '">...<br><a href="', $scripturl, '?action=calendar;month=', $calendar_data['current_month'], ';year=', $calendar_data['current_year'], ';showbd" onclick="document.getElementById(\'bdhide_', $day['day'], '\').style.display = \'\'; document.getElementById(\'bdhidelink_', $day['day'], '\').style.display = \'none\'; return false;">(', sprintf($txt['calendar_click_all'], count($day['birthdays'])), ')</a></span><span id="bdhide_', $day['day'], '" style="display: none;">, '; |
| 249 | + } |
|
| 242 | 250 | |
| 243 | 251 | ++$birthday_count; |
| 244 | 252 | } |
| 245 | - if ($use_js_hide) |
|
| 246 | - echo '</span>'; |
|
| 253 | + if ($use_js_hide) { |
|
| 254 | + echo '</span>'; |
|
| 255 | + } |
|
| 247 | 256 | |
| 248 | 257 | echo '</div>'; |
| 249 | 258 | } |
@@ -253,8 +262,9 @@ discard block |
||
| 253 | 262 | { |
| 254 | 263 | // Sort events by start time (all day events will be listed first) |
| 255 | 264 | uasort($day['events'], function($a, $b) { |
| 256 | - if ($a['start_timestamp'] == $b['start_timestamp']) |
|
| 257 | - return 0; |
|
| 265 | + if ($a['start_timestamp'] == $b['start_timestamp']) { |
|
| 266 | + return 0; |
|
| 267 | + } |
|
| 258 | 268 | return ($a['start_timestamp'] < $b['start_timestamp']) ? -1 : 1; |
| 259 | 269 | }); |
| 260 | 270 | |
@@ -270,17 +280,19 @@ discard block |
||
| 270 | 280 | |
| 271 | 281 | echo '<div class="event_wrapper', $event['starts_today'] == true ? ' event_starts_today' : '', $event['ends_today'] == true ? ' event_ends_today' : '', $event['allday'] == true ? ' allday' : '', $event['is_selected'] ? ' sel_event' : '', '">', $event['link'], '<br><span class="event_time', empty($event_icons_needed) ? ' floatright' : '', '">'; |
| 272 | 282 | |
| 273 | - if (!empty($event['start_time_local']) && $event['starts_today'] == true) |
|
| 274 | - echo trim(str_replace(':00 ', ' ', $event['start_time_local'])); |
|
| 275 | - elseif (!empty($event['end_time_local']) && $event['ends_today'] == true) |
|
| 276 | - echo strtolower($txt['ends']), ' ', trim(str_replace(':00 ', ' ', $event['end_time_local'])); |
|
| 277 | - elseif (!empty($event['allday'])) |
|
| 278 | - echo $txt['calendar_allday']; |
|
| 283 | + if (!empty($event['start_time_local']) && $event['starts_today'] == true) { |
|
| 284 | + echo trim(str_replace(':00 ', ' ', $event['start_time_local'])); |
|
| 285 | + } elseif (!empty($event['end_time_local']) && $event['ends_today'] == true) { |
|
| 286 | + echo strtolower($txt['ends']), ' ', trim(str_replace(':00 ', ' ', $event['end_time_local'])); |
|
| 287 | + } elseif (!empty($event['allday'])) { |
|
| 288 | + echo $txt['calendar_allday']; |
|
| 289 | + } |
|
| 279 | 290 | |
| 280 | 291 | echo '</span>'; |
| 281 | 292 | |
| 282 | - if (!empty($event['location'])) |
|
| 283 | - echo '<br><span class="event_location', empty($event_icons_needed) ? ' floatright' : '', '">' . $event['location'] . '</span>'; |
|
| 293 | + if (!empty($event['location'])) { |
|
| 294 | + echo '<br><span class="event_location', empty($event_icons_needed) ? ' floatright' : '', '">' . $event['location'] . '</span>'; |
|
| 295 | + } |
|
| 284 | 296 | |
| 285 | 297 | if ($event['can_edit'] || $event['can_export']) |
| 286 | 298 | { |
@@ -317,10 +329,11 @@ discard block |
||
| 317 | 329 | // Otherwise, assuming it's not a mini-calendar, we can show previous / next month days! |
| 318 | 330 | elseif ($is_mini === false) |
| 319 | 331 | { |
| 320 | - if (empty($current_month_started) && !empty($context['calendar_grid_prev'])) |
|
| 321 | - echo '<a href="', $scripturl, '?action=calendar;year=', $context['calendar_grid_prev']['current_year'], ';month=', $context['calendar_grid_prev']['current_month'], '">', $context['calendar_grid_prev']['last_of_month'] - $calendar_data['shift']-- +1, '</a>'; |
|
| 322 | - elseif (!empty($current_month_started) && !empty($context['calendar_grid_next'])) |
|
| 323 | - echo '<a href="', $scripturl, '?action=calendar;year=', $context['calendar_grid_next']['current_year'], ';month=', $context['calendar_grid_next']['current_month'], '">', $current_month_started + 1 == $count ? (!empty($calendar_data['short_month_titles']) ? $txt['months_short'][$context['calendar_grid_next']['current_month']] . ' ' : $txt['months_titles'][$context['calendar_grid_next']['current_month']] . ' ') : '', $final_count++, '</a>'; |
|
| 332 | + if (empty($current_month_started) && !empty($context['calendar_grid_prev'])) { |
|
| 333 | + echo '<a href="', $scripturl, '?action=calendar;year=', $context['calendar_grid_prev']['current_year'], ';month=', $context['calendar_grid_prev']['current_month'], '">', $context['calendar_grid_prev']['last_of_month'] - $calendar_data['shift']-- +1, '</a>'; |
|
| 334 | + } elseif (!empty($current_month_started) && !empty($context['calendar_grid_next'])) { |
|
| 335 | + echo '<a href="', $scripturl, '?action=calendar;year=', $context['calendar_grid_next']['current_year'], ';month=', $context['calendar_grid_next']['current_month'], '">', $current_month_started + 1 == $count ? (!empty($calendar_data['short_month_titles']) ? $txt['months_short'][$context['calendar_grid_next']['current_month']] . ' ' : $txt['months_titles'][$context['calendar_grid_next']['current_month']] . ' ') : '', $final_count++, '</a>'; |
|
| 336 | + } |
|
| 324 | 337 | } |
| 325 | 338 | |
| 326 | 339 | // Close this day and increase var count. |
@@ -332,8 +345,9 @@ discard block |
||
| 332 | 345 | } |
| 333 | 346 | |
| 334 | 347 | // Quick Month Navigation + Post Event Link on Main Grids! |
| 335 | - if ($is_mini === false) |
|
| 336 | - template_calendar_base($show_week_links === true ? 8 : 7); |
|
| 348 | + if ($is_mini === false) { |
|
| 349 | + template_calendar_base($show_week_links === true ? 8 : 7); |
|
| 350 | + } |
|
| 337 | 351 | |
| 338 | 352 | // The end of our main table. |
| 339 | 353 | echo '</table>'; |
@@ -350,8 +364,9 @@ discard block |
||
| 350 | 364 | global $context, $settings, $txt, $scripturl, $modSettings; |
| 351 | 365 | |
| 352 | 366 | // We might have no reason to proceed, if the variable isn't there. |
| 353 | - if (!isset($context['calendar_grid_' . $grid_name])) |
|
| 354 | - return false; |
|
| 367 | + if (!isset($context['calendar_grid_' . $grid_name])) { |
|
| 368 | + return false; |
|
| 369 | + } |
|
| 355 | 370 | |
| 356 | 371 | // Handy pointer. |
| 357 | 372 | $calendar_data = &$context['calendar_grid_' . $grid_name]; |
@@ -387,8 +402,9 @@ discard block |
||
| 387 | 402 | } |
| 388 | 403 | |
| 389 | 404 | // The Month Title + Week Number... |
| 390 | - if (!empty($calendar_data['week_title'])) |
|
| 391 | - echo $calendar_data['week_title']; |
|
| 405 | + if (!empty($calendar_data['week_title'])) { |
|
| 406 | + echo $calendar_data['week_title']; |
|
| 407 | + } |
|
| 392 | 408 | |
| 393 | 409 | echo ' |
| 394 | 410 | </h3> |
@@ -424,10 +440,11 @@ discard block |
||
| 424 | 440 | <tr class="days_wrapper"> |
| 425 | 441 | <td class="', implode(' ', $classes), ' act_day">'; |
| 426 | 442 | // Should the day number be a link? |
| 427 | - if (!empty($modSettings['cal_daysaslink']) && $context['can_post']) |
|
| 428 | - echo '<a href="', $scripturl, '?action=calendar;sa=post;month=', $month_data['current_month'], ';year=', $month_data['current_year'], ';day=', $day['day'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['days'][$day['day_of_week']], ' - ', $day['day'], '</a>'; |
|
| 429 | - else |
|
| 430 | - echo $txt['days'][$day['day_of_week']], ' - ', $day['day']; |
|
| 443 | + if (!empty($modSettings['cal_daysaslink']) && $context['can_post']) { |
|
| 444 | + echo '<a href="', $scripturl, '?action=calendar;sa=post;month=', $month_data['current_month'], ';year=', $month_data['current_year'], ';day=', $day['day'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['days'][$day['day_of_week']], ' - ', $day['day'], '</a>'; |
|
| 445 | + } else { |
|
| 446 | + echo $txt['days'][$day['day_of_week']], ' - ', $day['day']; |
|
| 447 | + } |
|
| 431 | 448 | |
| 432 | 449 | echo '</td> |
| 433 | 450 | <td class="', implode(' ', $classes), '', empty($day['events']) ? (' disabled' . ($context['can_post'] ? ' week_post' : '')) : ' events', ' event_col" data-css-prefix="' . $txt['events'] . ' ', (empty($day['events']) && empty($context['can_post'])) ? $txt['none'] : '', '">'; |
@@ -436,8 +453,9 @@ discard block |
||
| 436 | 453 | { |
| 437 | 454 | // Sort events by start time (all day events will be listed first) |
| 438 | 455 | uasort($day['events'], function($a, $b) { |
| 439 | - if ($a['start_timestamp'] == $b['start_timestamp']) |
|
| 440 | - return 0; |
|
| 456 | + if ($a['start_timestamp'] == $b['start_timestamp']) { |
|
| 457 | + return 0; |
|
| 458 | + } |
|
| 441 | 459 | return ($a['start_timestamp'] < $b['start_timestamp']) ? -1 : 1; |
| 442 | 460 | }); |
| 443 | 461 | |
@@ -449,15 +467,17 @@ discard block |
||
| 449 | 467 | |
| 450 | 468 | echo $event['link'], '<br><span class="event_time', empty($event_icons_needed) ? ' floatright' : '', '">'; |
| 451 | 469 | |
| 452 | - if (!empty($event['start_time_local'])) |
|
| 453 | - echo trim($event['start_time_local']), !empty($event['end_time_local']) ? ' – ' . trim($event['end_time_local']) : ''; |
|
| 454 | - else |
|
| 455 | - echo $txt['calendar_allday']; |
|
| 470 | + if (!empty($event['start_time_local'])) { |
|
| 471 | + echo trim($event['start_time_local']), !empty($event['end_time_local']) ? ' – ' . trim($event['end_time_local']) : ''; |
|
| 472 | + } else { |
|
| 473 | + echo $txt['calendar_allday']; |
|
| 474 | + } |
|
| 456 | 475 | |
| 457 | 476 | echo '</span>'; |
| 458 | 477 | |
| 459 | - if (!empty($event['location'])) |
|
| 460 | - echo '<br><span class="event_location', empty($event_icons_needed) ? ' floatright' : '', '">' . $event['location'] . '</span>'; |
|
| 478 | + if (!empty($event['location'])) { |
|
| 479 | + echo '<br><span class="event_location', empty($event_icons_needed) ? ' floatright' : '', '">' . $event['location'] . '</span>'; |
|
| 480 | + } |
|
| 461 | 481 | |
| 462 | 482 | if (!empty($event_icons_needed)) |
| 463 | 483 | { |
@@ -494,8 +514,7 @@ discard block |
||
| 494 | 514 | </div> |
| 495 | 515 | <br class="clear">'; |
| 496 | 516 | } |
| 497 | - } |
|
| 498 | - else |
|
| 517 | + } else |
|
| 499 | 518 | { |
| 500 | 519 | if (!empty($context['can_post'])) |
| 501 | 520 | { |
@@ -508,8 +527,9 @@ discard block |
||
| 508 | 527 | echo '</td> |
| 509 | 528 | <td class="', implode(' ', $classes), !empty($day['holidays']) ? ' holidays' : ' disabled', ' holiday_col" data-css-prefix="' . $txt['calendar_prompt'] . ' ">'; |
| 510 | 529 | // Show any holidays! |
| 511 | - if (!empty($day['holidays'])) |
|
| 512 | - echo implode('<br>', $day['holidays']); |
|
| 530 | + if (!empty($day['holidays'])) { |
|
| 531 | + echo implode('<br>', $day['holidays']); |
|
| 532 | + } |
|
| 513 | 533 | |
| 514 | 534 | echo '</td> |
| 515 | 535 | <td class="', implode(' ', $classes), '', !empty($day['birthdays']) ? ' birthdays' : ' disabled', ' birthday_col" data-css-prefix="' . $txt['birthdays'] . ' ">'; |
@@ -529,8 +549,9 @@ discard block |
||
| 529 | 549 | } |
| 530 | 550 | |
| 531 | 551 | // We'll show the lower column after our last month is shown. |
| 532 | - if ($iteration == $num_months) |
|
| 533 | - template_calendar_base(4); |
|
| 552 | + if ($iteration == $num_months) { |
|
| 553 | + template_calendar_base(4); |
|
| 554 | + } |
|
| 534 | 555 | |
| 535 | 556 | // Increase iteration for loop counting. |
| 536 | 557 | ++$iteration; |
@@ -592,8 +613,9 @@ discard block |
||
| 592 | 613 | echo ' |
| 593 | 614 | <form action="', $scripturl, '?action=calendar;sa=post" method="post" name="postevent" accept-charset="', $context['character_set'], '" onsubmit="submitonce(this);smc_saveEntities(\'postevent\', [\'evtitle\']);" style="margin: 0;">'; |
| 594 | 615 | |
| 595 | - if (!empty($context['event']['new'])) |
|
| 596 | - echo '<input type="hidden" name="eventid" value="', $context['event']['eventid'], '">'; |
|
| 616 | + if (!empty($context['event']['new'])) { |
|
| 617 | + echo '<input type="hidden" name="eventid" value="', $context['event']['eventid'], '">'; |
|
| 618 | + } |
|
| 597 | 619 | |
| 598 | 620 | // Start the main table. |
| 599 | 621 | echo ' |
@@ -643,9 +665,10 @@ discard block |
||
| 643 | 665 | { |
| 644 | 666 | echo ' |
| 645 | 667 | <optgroup label="', $category['name'], '">'; |
| 646 | - foreach ($category['boards'] as $board) |
|
| 647 | - echo ' |
|
| 668 | + foreach ($category['boards'] as $board) { |
|
| 669 | + echo ' |
|
| 648 | 670 | <option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', '>', $board['child_level'] > 0 ? str_repeat('==', $board['child_level'] - 1) . '=>' : '', ' ', $board['name'], ' </option>'; |
| 671 | + } |
|
| 649 | 672 | echo ' |
| 650 | 673 | </optgroup>'; |
| 651 | 674 | } |
@@ -681,9 +704,10 @@ discard block |
||
| 681 | 704 | <span class="label">', $txt['calendar_timezone'], '</span> |
| 682 | 705 | <select name="tz" id="tz"', !empty($context['event']['allday']) ? ' disabled' : '', '>'; |
| 683 | 706 | |
| 684 | - foreach ($context['all_timezones'] as $tz => $tzname) |
|
| 685 | - echo ' |
|
| 707 | + foreach ($context['all_timezones'] as $tz => $tzname) { |
|
| 708 | + echo ' |
|
| 686 | 709 | <option value="', $tz, '"', $tz == $context['event']['tz'] ? ' selected' : '', '>', $tzname, '</option>'; |
| 710 | + } |
|
| 687 | 711 | |
| 688 | 712 | echo ' |
| 689 | 713 | </select> |
@@ -698,9 +722,10 @@ discard block |
||
| 698 | 722 | echo ' |
| 699 | 723 | <input type="submit" value="', empty($context['event']['new']) ? $txt['save'] : $txt['post'], '" class="button_submit">'; |
| 700 | 724 | // Delete button? |
| 701 | - if (empty($context['event']['new'])) |
|
| 702 | - echo ' |
|
| 725 | + if (empty($context['event']['new'])) { |
|
| 726 | + echo ' |
|
| 703 | 727 | <input type="submit" name="deleteevent" value="', $txt['event_delete'], '" data-confirm="', $txt['calendar_confirm_delete'], '" class="button_submit you_sure">'; |
| 728 | + } |
|
| 704 | 729 | |
| 705 | 730 | echo ' |
| 706 | 731 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -744,9 +769,10 @@ discard block |
||
| 744 | 769 | |
| 745 | 770 | foreach ($context['clockicons'] as $t => $v) |
| 746 | 771 | { |
| 747 | - foreach ($v as $i) |
|
| 748 | - echo ' |
|
| 772 | + foreach ($v as $i) { |
|
| 773 | + echo ' |
|
| 749 | 774 | icons[\'', $t, '_', $i, '\'] = document.getElementById(\'', $t, '_', $i, '\');'; |
| 775 | + } |
|
| 750 | 776 | } |
| 751 | 777 | |
| 752 | 778 | echo ' |
@@ -771,13 +797,14 @@ discard block |
||
| 771 | 797 | |
| 772 | 798 | foreach ($context['clockicons'] as $t => $v) |
| 773 | 799 | { |
| 774 | - foreach ($v as $i) |
|
| 775 | - echo ' |
|
| 800 | + foreach ($v as $i) { |
|
| 801 | + echo ' |
|
| 776 | 802 | if (', $t, ' >= ', $i, ') |
| 777 | 803 | { |
| 778 | 804 | turnon.push("', $t, '_', $i, '"); |
| 779 | 805 | ', $t, ' -= ', $i, '; |
| 780 | 806 | }'; |
| 807 | + } |
|
| 781 | 808 | } |
| 782 | 809 | |
| 783 | 810 | echo ' |
@@ -841,9 +868,10 @@ discard block |
||
| 841 | 868 | |
| 842 | 869 | foreach ($context['clockicons'] as $t => $v) |
| 843 | 870 | { |
| 844 | - foreach ($v as $i) |
|
| 845 | - echo ' |
|
| 871 | + foreach ($v as $i) { |
|
| 872 | + echo ' |
|
| 846 | 873 | icons[\'', $t, '_', $i, '\'] = document.getElementById(\'', $t, '_', $i, '\');'; |
| 874 | + } |
|
| 847 | 875 | } |
| 848 | 876 | |
| 849 | 877 | echo ' |
@@ -860,13 +888,14 @@ discard block |
||
| 860 | 888 | |
| 861 | 889 | foreach ($context['clockicons'] as $t => $v) |
| 862 | 890 | { |
| 863 | - foreach ($v as $i) |
|
| 864 | - echo ' |
|
| 891 | + foreach ($v as $i) { |
|
| 892 | + echo ' |
|
| 865 | 893 | if (', $t, ' >= ', $i, ') |
| 866 | 894 | { |
| 867 | 895 | turnon.push("', $t, '_', $i, '"); |
| 868 | 896 | ', $t, ' -= ', $i, '; |
| 869 | 897 | }'; |
| 898 | + } |
|
| 870 | 899 | } |
| 871 | 900 | |
| 872 | 901 | echo ' |
@@ -925,9 +954,10 @@ discard block |
||
| 925 | 954 | |
| 926 | 955 | foreach ($context['clockicons'] as $t => $v) |
| 927 | 956 | { |
| 928 | - foreach ($v as $i) |
|
| 929 | - echo ' |
|
| 957 | + foreach ($v as $i) { |
|
| 958 | + echo ' |
|
| 930 | 959 | icons[\'', $t, '_', $i, '\'] = document.getElementById(\'', $t, '_', $i, '\');'; |
| 960 | + } |
|
| 931 | 961 | } |
| 932 | 962 | |
| 933 | 963 | echo ' |
@@ -948,13 +978,14 @@ discard block |
||
| 948 | 978 | |
| 949 | 979 | foreach ($context['clockicons'] as $t => $v) |
| 950 | 980 | { |
| 951 | - foreach ($v as $i) |
|
| 952 | - echo ' |
|
| 981 | + foreach ($v as $i) { |
|
| 982 | + echo ' |
|
| 953 | 983 | if (', $t, ' >= ', $i, ') |
| 954 | 984 | { |
| 955 | 985 | turnon.push("', $t, '_', $i, '"); |
| 956 | 986 | ', $t, ' -= ', $i, '; |
| 957 | 987 | }'; |
| 988 | + } |
|
| 958 | 989 | } |
| 959 | 990 | |
| 960 | 991 | echo ' |
@@ -227,7 +227,7 @@ |
||
| 227 | 227 | * @param int|string $verify_id The verification control ID |
| 228 | 228 | * @param string $display_type What type to display. Can be 'single' to only show one verification option or 'all' to show all of them |
| 229 | 229 | * @param bool $reset Whether to reset the internal tracking counter |
| 230 | - * @return bool False if there's nothing else to show, true if $display_type is 'single', nothing otherwise |
|
| 230 | + * @return boolean|null False if there's nothing else to show, true if $display_type is 'single', nothing otherwise |
|
| 231 | 231 | */ |
| 232 | 232 | function template_control_verification($verify_id, $display_type = 'all', $reset = false) |
| 233 | 233 | { |
@@ -53,14 +53,15 @@ discard block |
||
| 53 | 53 | foreach ($context['smileys'] as $location => $smileyRows) |
| 54 | 54 | { |
| 55 | 55 | $countLocations--; |
| 56 | - if ($location == 'postform') |
|
| 57 | - echo ' |
|
| 56 | + if ($location == 'postform') { |
|
| 57 | + echo ' |
|
| 58 | 58 | dropdown: |
| 59 | 59 | {'; |
| 60 | - elseif ($location == 'popup') |
|
| 61 | - echo ' |
|
| 60 | + } elseif ($location == 'popup') { |
|
| 61 | + echo ' |
|
| 62 | 62 | popup: |
| 63 | 63 | {'; |
| 64 | + } |
|
| 64 | 65 | |
| 65 | 66 | $numRows = count($smileyRows); |
| 66 | 67 | // This is needed because otherwise the editor will remove all the duplicate (empty) keys and leave only 1 additional line |
@@ -72,20 +73,21 @@ discard block |
||
| 72 | 73 | echo ' |
| 73 | 74 | ', JavaScriptEscape($smiley['code']), ': ', JavaScriptEscape($settings['smileys_url'] . '/' . $smiley['filename']), empty($smiley['isLast']) ? ',' : ''; |
| 74 | 75 | } |
| 75 | - if (empty($smileyRow['isLast']) && $numRows != 1) |
|
| 76 | - echo ', |
|
| 76 | + if (empty($smileyRow['isLast']) && $numRows != 1) { |
|
| 77 | + echo ', |
|
| 77 | 78 | \'-', $emptyPlaceholder++, '\': \'\','; |
| 79 | + } |
|
| 78 | 80 | } |
| 79 | 81 | echo ' |
| 80 | 82 | }', $countLocations != 0 ? ',' : ''; |
| 81 | 83 | } |
| 82 | 84 | echo ' |
| 83 | 85 | }'; |
| 84 | - } |
|
| 85 | - else |
|
| 86 | - echo ', |
|
| 86 | + } else { |
|
| 87 | + echo ', |
|
| 87 | 88 | emoticons: |
| 88 | 89 | {}'; |
| 90 | + } |
|
| 89 | 91 | |
| 90 | 92 | if ($context['show_bbc'] && $bbcContainer !== null) |
| 91 | 93 | { |
@@ -96,15 +98,16 @@ discard block |
||
| 96 | 98 | { |
| 97 | 99 | echo implode('|', $buttonRow); |
| 98 | 100 | $count_tags--; |
| 99 | - if (!empty($count_tags)) |
|
| 100 | - echo '||'; |
|
| 101 | + if (!empty($count_tags)) { |
|
| 102 | + echo '||'; |
|
| 103 | + } |
|
| 101 | 104 | } |
| 102 | 105 | |
| 103 | 106 | echo '",'; |
| 104 | - } |
|
| 105 | - else |
|
| 106 | - echo ', |
|
| 107 | + } else { |
|
| 108 | + echo ', |
|
| 107 | 109 | toolbar: "",'; |
| 110 | + } |
|
| 108 | 111 | |
| 109 | 112 | echo ' |
| 110 | 113 | }); |
@@ -145,43 +148,48 @@ discard block |
||
| 145 | 148 | </span>'; |
| 146 | 149 | |
| 147 | 150 | $tempTab = $context['tabindex']; |
| 148 | - if (!empty($context['drafts_pm_save'])) |
|
| 149 | - $tempTab++; |
|
| 150 | - elseif (!empty($context['drafts_save'])) |
|
| 151 | - $tempTab++; |
|
| 152 | - elseif ($editor_context['preview_type']) |
|
| 153 | - $tempTab++; |
|
| 154 | - elseif ($context['show_spellchecking']) |
|
| 155 | - $tempTab++; |
|
| 151 | + if (!empty($context['drafts_pm_save'])) { |
|
| 152 | + $tempTab++; |
|
| 153 | + } elseif (!empty($context['drafts_save'])) { |
|
| 154 | + $tempTab++; |
|
| 155 | + } elseif ($editor_context['preview_type']) { |
|
| 156 | + $tempTab++; |
|
| 157 | + } elseif ($context['show_spellchecking']) { |
|
| 158 | + $tempTab++; |
|
| 159 | + } |
|
| 156 | 160 | |
| 157 | 161 | $tempTab++; |
| 158 | 162 | $context['tabindex'] = $tempTab; |
| 159 | 163 | |
| 160 | - if (!empty($context['drafts_pm_save'])) |
|
| 161 | - echo ' |
|
| 164 | + if (!empty($context['drafts_pm_save'])) { |
|
| 165 | + echo ' |
|
| 162 | 166 | <input type="submit" name="save_draft" value="', $txt['draft_save'], '" tabindex="', --$tempTab, '" onclick="submitThisOnce(this);" accesskey="d" class="button_submit"> |
| 163 | 167 | <input type="hidden" id="id_pm_draft" name="id_pm_draft" value="', empty($context['id_pm_draft']) ? 0 : $context['id_pm_draft'], '">'; |
| 168 | + } |
|
| 164 | 169 | |
| 165 | - if (!empty($context['drafts_save'])) |
|
| 166 | - echo ' |
|
| 170 | + if (!empty($context['drafts_save'])) { |
|
| 171 | + echo ' |
|
| 167 | 172 | <input type="submit" name="save_draft" value="', $txt['draft_save'], '" tabindex="', --$tempTab, '" onclick="return confirm(' . JavaScriptEscape($txt['draft_save_note']) . ') && submitThisOnce(this);" accesskey="d" class="button_submit"> |
| 168 | 173 | <input type="hidden" id="id_draft" name="id_draft" value="', empty($context['id_draft']) ? 0 : $context['id_draft'], '">'; |
| 174 | + } |
|
| 169 | 175 | |
| 170 | - if ($context['show_spellchecking']) |
|
| 171 | - echo ' |
|
| 176 | + if ($context['show_spellchecking']) { |
|
| 177 | + echo ' |
|
| 172 | 178 | <input type="button" value="', $txt['spell_check'], '" tabindex="', --$tempTab, '" onclick="oEditorHandle_', $editor_id, '.spellCheckStart();" class="button_submit">'; |
| 179 | + } |
|
| 173 | 180 | |
| 174 | - if ($editor_context['preview_type']) |
|
| 175 | - echo ' |
|
| 181 | + if ($editor_context['preview_type']) { |
|
| 182 | + echo ' |
|
| 176 | 183 | <input type="submit" name="preview" value="', isset($editor_context['labels']['preview_button']) ? $editor_context['labels']['preview_button'] : $txt['preview'], '" tabindex="', --$tempTab, '" onclick="', $editor_context['preview_type'] == 2 ? 'return event.ctrlKey || previewPost();' : 'return submitThisOnce(this);', '" accesskey="p" class="button_submit">'; |
| 184 | + } |
|
| 177 | 185 | |
| 178 | 186 | |
| 179 | 187 | echo ' |
| 180 | 188 | <input type="submit" value="', isset($editor_context['labels']['post_button']) ? $editor_context['labels']['post_button'] : $txt['post'], '" name="post" tabindex="', --$tempTab, '" onclick="return submitThisOnce(this);" accesskey="s" class="button_submit">'; |
| 181 | 189 | |
| 182 | 190 | // Load in the PM autosaver if it's enabled |
| 183 | - if (!empty($context['drafts_pm_save']) && !empty($context['drafts_autosave'])) |
|
| 184 | - echo ' |
|
| 191 | + if (!empty($context['drafts_pm_save']) && !empty($context['drafts_autosave'])) { |
|
| 192 | + echo ' |
|
| 185 | 193 | <span class="righttext padding" style="display: block"> |
| 186 | 194 | <span id="throbber" style="display:none"><img src="' . $settings['images_url'] . '/loading_sm.gif" alt="" class="centericon"> </span> |
| 187 | 195 | <span id="draft_lastautosave" ></span> |
@@ -199,10 +207,11 @@ discard block |
||
| 199 | 207 | iFreq: ', (empty($modSettings['drafts_autosave_frequency']) ? 60000 : $modSettings['drafts_autosave_frequency'] * 1000), ' |
| 200 | 208 | }); |
| 201 | 209 | </script>'; |
| 210 | + } |
|
| 202 | 211 | |
| 203 | 212 | // Start an instance of the auto saver if its enabled |
| 204 | - if (!empty($context['drafts_save']) && !empty($context['drafts_autosave'])) |
|
| 205 | - echo ' |
|
| 213 | + if (!empty($context['drafts_save']) && !empty($context['drafts_autosave'])) { |
|
| 214 | + echo ' |
|
| 206 | 215 | <span class="righttext padding" style="display: block"> |
| 207 | 216 | <span id="throbber" style="display:none"><img src="' . $settings['images_url'] . '/loading_sm.gif" alt="" class="centericon"> </span> |
| 208 | 217 | <span id="draft_lastautosave" ></span> |
@@ -219,7 +228,8 @@ discard block |
||
| 219 | 228 | iFreq: ', $context['drafts_autosave_frequency'], ' |
| 220 | 229 | }); |
| 221 | 230 | </script>'; |
| 222 | -} |
|
| 231 | + } |
|
| 232 | + } |
|
| 223 | 233 | |
| 224 | 234 | /** |
| 225 | 235 | * This template displays a verification form |
@@ -236,50 +246,56 @@ discard block |
||
| 236 | 246 | $verify_context = &$context['controls']['verification'][$verify_id]; |
| 237 | 247 | |
| 238 | 248 | // Keep track of where we are. |
| 239 | - if (empty($verify_context['tracking']) || $reset) |
|
| 240 | - $verify_context['tracking'] = 0; |
|
| 249 | + if (empty($verify_context['tracking']) || $reset) { |
|
| 250 | + $verify_context['tracking'] = 0; |
|
| 251 | + } |
|
| 241 | 252 | |
| 242 | 253 | // How many items are there to display in total. |
| 243 | 254 | $total_items = count($verify_context['questions']) + ($verify_context['show_visual'] ? 1 : 0); |
| 244 | 255 | |
| 245 | 256 | // If we've gone too far, stop. |
| 246 | - if ($verify_context['tracking'] > $total_items) |
|
| 247 | - return false; |
|
| 257 | + if ($verify_context['tracking'] > $total_items) { |
|
| 258 | + return false; |
|
| 259 | + } |
|
| 248 | 260 | |
| 249 | 261 | // Loop through each item to show them. |
| 250 | 262 | for ($i = 0; $i < $total_items; $i++) |
| 251 | 263 | { |
| 252 | 264 | // If we're after a single item only show it if we're in the right place. |
| 253 | - if ($display_type == 'single' && $verify_context['tracking'] != $i) |
|
| 254 | - continue; |
|
| 265 | + if ($display_type == 'single' && $verify_context['tracking'] != $i) { |
|
| 266 | + continue; |
|
| 267 | + } |
|
| 255 | 268 | |
| 256 | - if ($display_type != 'single') |
|
| 257 | - echo ' |
|
| 269 | + if ($display_type != 'single') { |
|
| 270 | + echo ' |
|
| 258 | 271 | <div id="verification_control_', $i, '" class="verification_control">'; |
| 272 | + } |
|
| 259 | 273 | |
| 260 | 274 | // Display empty field, but only if we have one, and it's the first time. |
| 261 | - if ($verify_context['empty_field'] && empty($i)) |
|
| 262 | - echo ' |
|
| 275 | + if ($verify_context['empty_field'] && empty($i)) { |
|
| 276 | + echo ' |
|
| 263 | 277 | <div class="smalltext vv_special"> |
| 264 | 278 | ', $txt['visual_verification_hidden'], ': |
| 265 | 279 | <input type="text" name="', $_SESSION[$verify_id . '_vv']['empty_field'], '" autocomplete="off" size="30" value=""> |
| 266 | 280 | </div> |
| 267 | 281 | <br>'; |
| 282 | + } |
|
| 268 | 283 | |
| 269 | 284 | // Do the actual stuff - image first? |
| 270 | 285 | if ($i == 0 && $verify_context['show_visual']) |
| 271 | 286 | { |
| 272 | - if ($context['use_graphic_library']) |
|
| 273 | - echo ' |
|
| 287 | + if ($context['use_graphic_library']) { |
|
| 288 | + echo ' |
|
| 274 | 289 | <img src="', $verify_context['image_href'], '" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '">'; |
| 275 | - else |
|
| 276 | - echo ' |
|
| 290 | + } else { |
|
| 291 | + echo ' |
|
| 277 | 292 | <img src="', $verify_context['image_href'], ';letter=1" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_1"> |
| 278 | 293 | <img src="', $verify_context['image_href'], ';letter=2" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_2"> |
| 279 | 294 | <img src="', $verify_context['image_href'], ';letter=3" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_3"> |
| 280 | 295 | <img src="', $verify_context['image_href'], ';letter=4" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_4"> |
| 281 | 296 | <img src="', $verify_context['image_href'], ';letter=5" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_5"> |
| 282 | 297 | <img src="', $verify_context['image_href'], ';letter=6" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_6">'; |
| 298 | + } |
|
| 283 | 299 | |
| 284 | 300 | echo ' |
| 285 | 301 | <div class="smalltext" style="margin: 4px 0 8px 0;"> |
@@ -287,8 +303,7 @@ discard block |
||
| 287 | 303 | ', $txt['visual_verification_description'], ':', $display_type != 'quick_reply' ? '<br>' : '', ' |
| 288 | 304 | <input type="text" name="', $verify_id, '_vv[code]" value="', !empty($verify_context['text_value']) ? $verify_context['text_value'] : '', '" size="30" tabindex="', $context['tabindex']++, '" class="input_text" required> |
| 289 | 305 | </div>'; |
| 290 | - } |
|
| 291 | - else |
|
| 306 | + } else |
|
| 292 | 307 | { |
| 293 | 308 | // Where in the question array is this question? |
| 294 | 309 | $qIndex = $verify_context['show_visual'] ? $i - 1 : $i; |
@@ -300,21 +315,24 @@ discard block |
||
| 300 | 315 | </div>'; |
| 301 | 316 | } |
| 302 | 317 | |
| 303 | - if ($display_type != 'single') |
|
| 304 | - echo ' |
|
| 318 | + if ($display_type != 'single') { |
|
| 319 | + echo ' |
|
| 305 | 320 | </div>'; |
| 321 | + } |
|
| 306 | 322 | |
| 307 | 323 | // If we were displaying just one and we did it, break. |
| 308 | - if ($display_type == 'single' && $verify_context['tracking'] == $i) |
|
| 309 | - break; |
|
| 324 | + if ($display_type == 'single' && $verify_context['tracking'] == $i) { |
|
| 325 | + break; |
|
| 326 | + } |
|
| 310 | 327 | } |
| 311 | 328 | |
| 312 | 329 | // Assume we found something, always, |
| 313 | 330 | $verify_context['tracking']++; |
| 314 | 331 | |
| 315 | 332 | // Tell something displaying piecemeal to keep going. |
| 316 | - if ($display_type == 'single') |
|
| 317 | - return true; |
|
| 318 | -} |
|
| 333 | + if ($display_type == 'single') { |
|
| 334 | + return true; |
|
| 335 | + } |
|
| 336 | + } |
|
| 319 | 337 | |
| 320 | 338 | ?> |
| 321 | 339 | \ No newline at end of file |