@@ -1,9 +1,10 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | // Try to handle it with the upper level index.php. (it should know what to do.) |
| 4 | -if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) |
|
| 4 | +if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) { |
|
| 5 | 5 | include (dirname(dirname(__FILE__)) . '/index.php'); |
| 6 | -else |
|
| 6 | +} else { |
|
| 7 | 7 | exit; |
| 8 | +} |
|
| 8 | 9 | |
| 9 | 10 | ?> |
| 10 | 11 | \ No newline at end of file |
@@ -1,9 +1,10 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | // Try to handle it with the upper level index.php. (it should know what to do.) |
| 4 | -if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) |
|
| 4 | +if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) { |
|
| 5 | 5 | include (dirname(dirname(__FILE__)) . '/index.php'); |
| 6 | -else |
|
| 6 | +} else { |
|
| 7 | 7 | exit; |
| 8 | +} |
|
| 8 | 9 | |
| 9 | 10 | ?> |
| 10 | 11 | \ No newline at end of file |
@@ -12,7 +12,8 @@ |
||
| 12 | 12 | header('Location: ' . $boardurl); |
| 13 | 13 | } |
| 14 | 14 | // Can't find it... just forget it. |
| 15 | -else |
|
| 15 | +else { |
|
| 16 | 16 | exit; |
| 17 | +} |
|
| 17 | 18 | |
| 18 | 19 | ?> |
| 19 | 20 | \ No newline at end of file |
@@ -30,8 +30,9 @@ discard block |
||
| 30 | 30 | * @version 2.1 Beta 3 |
| 31 | 31 | */ |
| 32 | 32 | |
| 33 | -if (!defined('SMF')) |
|
| 33 | +if (!defined('SMF')) { |
|
| 34 | 34 | die('No direct access...'); |
| 35 | +} |
|
| 35 | 36 | |
| 36 | 37 | /** |
| 37 | 38 | * Subaction handler - manages the action and delegates control to the proper |
@@ -103,12 +104,12 @@ discard block |
||
| 103 | 104 | cache_put_data('minimized_css', null); |
| 104 | 105 | |
| 105 | 106 | // Follow the sa or just go to administration. |
| 106 | - if (isset($_GET['sa']) && !empty($subActions[$_GET['sa']])) |
|
| 107 | - call_helper($subActions[$_GET['sa']]); |
|
| 108 | - |
|
| 109 | - else |
|
| 110 | - call_helper($subActions['admin']); |
|
| 111 | -} |
|
| 107 | + if (isset($_GET['sa']) && !empty($subActions[$_GET['sa']])) { |
|
| 108 | + call_helper($subActions[$_GET['sa']]); |
|
| 109 | + } else { |
|
| 110 | + call_helper($subActions['admin']); |
|
| 111 | + } |
|
| 112 | + } |
|
| 112 | 113 | |
| 113 | 114 | /** |
| 114 | 115 | * This function allows administration of themes and their settings, |
@@ -130,15 +131,16 @@ discard block |
||
| 130 | 131 | checkSession(); |
| 131 | 132 | validateToken('admin-tm'); |
| 132 | 133 | |
| 133 | - if (isset($_POST['options']['known_themes'])) |
|
| 134 | - foreach ($_POST['options']['known_themes'] as $key => $id) |
|
| 134 | + if (isset($_POST['options']['known_themes'])) { |
|
| 135 | + foreach ($_POST['options']['known_themes'] as $key => $id) |
|
| 135 | 136 | $_POST['options']['known_themes'][$key] = (int) $id; |
| 137 | + } else { |
|
| 138 | + fatal_lang_error('themes_none_selectable', false); |
|
| 139 | + } |
|
| 136 | 140 | |
| 137 | - else |
|
| 138 | - fatal_lang_error('themes_none_selectable', false); |
|
| 139 | - |
|
| 140 | - if (!in_array($_POST['options']['theme_guests'], $_POST['options']['known_themes'])) |
|
| 141 | - fatal_lang_error('themes_default_selectable', false); |
|
| 141 | + if (!in_array($_POST['options']['theme_guests'], $_POST['options']['known_themes'])) { |
|
| 142 | + fatal_lang_error('themes_default_selectable', false); |
|
| 143 | + } |
|
| 142 | 144 | |
| 143 | 145 | // Commit the new settings. |
| 144 | 146 | updateSettings(array( |
@@ -146,8 +148,9 @@ discard block |
||
| 146 | 148 | 'theme_guests' => $_POST['options']['theme_guests'], |
| 147 | 149 | 'knownThemes' => implode(',', $_POST['options']['known_themes']), |
| 148 | 150 | )); |
| 149 | - if ((int) $_POST['theme_reset'] == 0 || in_array($_POST['theme_reset'], $_POST['options']['known_themes'])) |
|
| 150 | - updateMemberData(null, array('id_theme' => (int) $_POST['theme_reset'])); |
|
| 151 | + if ((int) $_POST['theme_reset'] == 0 || in_array($_POST['theme_reset'], $_POST['options']['known_themes'])) { |
|
| 152 | + updateMemberData(null, array('id_theme' => (int) $_POST['theme_reset'])); |
|
| 153 | + } |
|
| 151 | 154 | |
| 152 | 155 | redirectexit('action=admin;area=theme;' . $context['session_var'] . '=' . $context['session_id'] . ';sa=admin'); |
| 153 | 156 | } |
@@ -166,8 +169,9 @@ discard block |
||
| 166 | 169 | // Look for a non existent theme directory. (ie theme87.) |
| 167 | 170 | $theme_dir = $boarddir . '/Themes/theme'; |
| 168 | 171 | $i = 1; |
| 169 | - while (file_exists($theme_dir . $i)) |
|
| 170 | - $i++; |
|
| 172 | + while (file_exists($theme_dir . $i)) { |
|
| 173 | + $i++; |
|
| 174 | + } |
|
| 171 | 175 | |
| 172 | 176 | $context['new_theme_name'] = 'theme' . $i; |
| 173 | 177 | |
@@ -189,8 +193,9 @@ discard block |
||
| 189 | 193 | loadLanguage('Admin'); |
| 190 | 194 | isAllowedTo('admin_forum'); |
| 191 | 195 | |
| 192 | - if (isset($_REQUEST['th'])) |
|
| 193 | - return SetThemeSettings(); |
|
| 196 | + if (isset($_REQUEST['th'])) { |
|
| 197 | + return SetThemeSettings(); |
|
| 198 | + } |
|
| 194 | 199 | |
| 195 | 200 | if (isset($_POST['save'])) |
| 196 | 201 | { |
@@ -274,12 +279,13 @@ discard block |
||
| 274 | 279 | $context['themes'] = array(); |
| 275 | 280 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 276 | 281 | { |
| 277 | - if (!isset($context['themes'][$row['id_theme']])) |
|
| 278 | - $context['themes'][$row['id_theme']] = array( |
|
| 282 | + if (!isset($context['themes'][$row['id_theme']])) { |
|
| 283 | + $context['themes'][$row['id_theme']] = array( |
|
| 279 | 284 | 'id' => $row['id_theme'], |
| 280 | 285 | 'num_default_options' => 0, |
| 281 | 286 | 'num_members' => 0, |
| 282 | 287 | ); |
| 288 | + } |
|
| 283 | 289 | $context['themes'][$row['id_theme']][$row['variable']] = $row['value']; |
| 284 | 290 | } |
| 285 | 291 | $smcFunc['db_free_result']($request); |
@@ -293,8 +299,9 @@ discard block |
||
| 293 | 299 | 'guest_member' => -1, |
| 294 | 300 | ) |
| 295 | 301 | ); |
| 296 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 297 | - $context['themes'][$row['id_theme']]['num_default_options'] = $row['value']; |
|
| 302 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 303 | + $context['themes'][$row['id_theme']]['num_default_options'] = $row['value']; |
|
| 304 | + } |
|
| 298 | 305 | $smcFunc['db_free_result']($request); |
| 299 | 306 | |
| 300 | 307 | // Need to make sure we don't do custom fields. |
@@ -305,8 +312,9 @@ discard block |
||
| 305 | 312 | ) |
| 306 | 313 | ); |
| 307 | 314 | $customFields = array(); |
| 308 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 309 | - $customFields[] = $row['col_name']; |
|
| 315 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 316 | + $customFields[] = $row['col_name']; |
|
| 317 | + } |
|
| 310 | 318 | $smcFunc['db_free_result']($request); |
| 311 | 319 | $customFieldsQuery = empty($customFields) ? '' : ('AND variable NOT IN ({array_string:custom_fields})'); |
| 312 | 320 | |
@@ -321,14 +329,16 @@ discard block |
||
| 321 | 329 | 'custom_fields' => empty($customFields) ? array() : $customFields, |
| 322 | 330 | ) |
| 323 | 331 | ); |
| 324 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 325 | - $context['themes'][$row['id_theme']]['num_members'] = $row['value']; |
|
| 332 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 333 | + $context['themes'][$row['id_theme']]['num_members'] = $row['value']; |
|
| 334 | + } |
|
| 326 | 335 | $smcFunc['db_free_result']($request); |
| 327 | 336 | |
| 328 | 337 | // There has to be a Settings template! |
| 329 | - foreach ($context['themes'] as $k => $v) |
|
| 330 | - if (empty($v['theme_dir']) || (!file_exists($v['theme_dir'] . '/Settings.template.php') && empty($v['num_members']))) |
|
| 338 | + foreach ($context['themes'] as $k => $v) { |
|
| 339 | + if (empty($v['theme_dir']) || (!file_exists($v['theme_dir'] . '/Settings.template.php') && empty($v['num_members']))) |
|
| 331 | 340 | unset($context['themes'][$k]); |
| 341 | + } |
|
| 332 | 342 | |
| 333 | 343 | loadTemplate('Themes'); |
| 334 | 344 | $context['sub_template'] = 'reset_list'; |
@@ -343,16 +353,19 @@ discard block |
||
| 343 | 353 | checkSession(); |
| 344 | 354 | validateToken('admin-sto'); |
| 345 | 355 | |
| 346 | - if (empty($_POST['options'])) |
|
| 347 | - $_POST['options'] = array(); |
|
| 348 | - if (empty($_POST['default_options'])) |
|
| 349 | - $_POST['default_options'] = array(); |
|
| 356 | + if (empty($_POST['options'])) { |
|
| 357 | + $_POST['options'] = array(); |
|
| 358 | + } |
|
| 359 | + if (empty($_POST['default_options'])) { |
|
| 360 | + $_POST['default_options'] = array(); |
|
| 361 | + } |
|
| 350 | 362 | |
| 351 | 363 | // Set up the sql query. |
| 352 | 364 | $setValues = array(); |
| 353 | 365 | |
| 354 | - foreach ($_POST['options'] as $opt => $val) |
|
| 355 | - $setValues[] = array(-1, $_GET['th'], $opt, is_array($val) ? implode(',', $val) : $val); |
|
| 366 | + foreach ($_POST['options'] as $opt => $val) { |
|
| 367 | + $setValues[] = array(-1, $_GET['th'], $opt, is_array($val) ? implode(',', $val) : $val); |
|
| 368 | + } |
|
| 356 | 369 | |
| 357 | 370 | $old_settings = array(); |
| 358 | 371 | foreach ($_POST['default_options'] as $opt => $val) |
@@ -366,8 +379,8 @@ discard block |
||
| 366 | 379 | if (!empty($setValues)) |
| 367 | 380 | { |
| 368 | 381 | // Are there options in non-default themes set that should be cleared? |
| 369 | - if (!empty($old_settings)) |
|
| 370 | - $smcFunc['db_query']('', ' |
|
| 382 | + if (!empty($old_settings)) { |
|
| 383 | + $smcFunc['db_query']('', ' |
|
| 371 | 384 | DELETE FROM {db_prefix}themes |
| 372 | 385 | WHERE id_theme != {int:default_theme} |
| 373 | 386 | AND id_member = {int:guest_member} |
@@ -378,6 +391,7 @@ discard block |
||
| 378 | 391 | 'old_settings' => $old_settings, |
| 379 | 392 | ) |
| 380 | 393 | ); |
| 394 | + } |
|
| 381 | 395 | |
| 382 | 396 | $smcFunc['db_insert']('replace', |
| 383 | 397 | '{db_prefix}themes', |
@@ -391,8 +405,7 @@ discard block |
||
| 391 | 405 | cache_put_data('theme_settings-1', null, 90); |
| 392 | 406 | |
| 393 | 407 | redirectexit('action=admin;area=theme;' . $context['session_var'] . '=' . $context['session_id'] . ';sa=reset'); |
| 394 | - } |
|
| 395 | - elseif (isset($_POST['submit']) && $_POST['who'] == 1) |
|
| 408 | + } elseif (isset($_POST['submit']) && $_POST['who'] == 1) |
|
| 396 | 409 | { |
| 397 | 410 | checkSession(); |
| 398 | 411 | validateToken('admin-sto'); |
@@ -405,9 +418,9 @@ discard block |
||
| 405 | 418 | $old_settings = array(); |
| 406 | 419 | foreach ($_POST['default_options'] as $opt => $val) |
| 407 | 420 | { |
| 408 | - if ($_POST['default_options_master'][$opt] == 0) |
|
| 409 | - continue; |
|
| 410 | - elseif ($_POST['default_options_master'][$opt] == 1) |
|
| 421 | + if ($_POST['default_options_master'][$opt] == 0) { |
|
| 422 | + continue; |
|
| 423 | + } elseif ($_POST['default_options_master'][$opt] == 1) |
|
| 411 | 424 | { |
| 412 | 425 | // Delete then insert for ease of database compatibility! |
| 413 | 426 | $smcFunc['db_query']('substring', ' |
@@ -433,8 +446,7 @@ discard block |
||
| 433 | 446 | ); |
| 434 | 447 | |
| 435 | 448 | $old_settings[] = $opt; |
| 436 | - } |
|
| 437 | - elseif ($_POST['default_options_master'][$opt] == 2) |
|
| 449 | + } elseif ($_POST['default_options_master'][$opt] == 2) |
|
| 438 | 450 | { |
| 439 | 451 | $smcFunc['db_query']('', ' |
| 440 | 452 | DELETE FROM {db_prefix}themes |
@@ -449,8 +461,8 @@ discard block |
||
| 449 | 461 | } |
| 450 | 462 | |
| 451 | 463 | // Delete options from other themes. |
| 452 | - if (!empty($old_settings)) |
|
| 453 | - $smcFunc['db_query']('', ' |
|
| 464 | + if (!empty($old_settings)) { |
|
| 465 | + $smcFunc['db_query']('', ' |
|
| 454 | 466 | DELETE FROM {db_prefix}themes |
| 455 | 467 | WHERE id_theme != {int:default_theme} |
| 456 | 468 | AND id_member > {int:no_member} |
@@ -461,12 +473,13 @@ discard block |
||
| 461 | 473 | 'old_settings' => $old_settings, |
| 462 | 474 | ) |
| 463 | 475 | ); |
| 476 | + } |
|
| 464 | 477 | |
| 465 | 478 | foreach ($_POST['options'] as $opt => $val) |
| 466 | 479 | { |
| 467 | - if ($_POST['options_master'][$opt] == 0) |
|
| 468 | - continue; |
|
| 469 | - elseif ($_POST['options_master'][$opt] == 1) |
|
| 480 | + if ($_POST['options_master'][$opt] == 0) { |
|
| 481 | + continue; |
|
| 482 | + } elseif ($_POST['options_master'][$opt] == 1) |
|
| 470 | 483 | { |
| 471 | 484 | // Delete then insert for ease of database compatibility - again! |
| 472 | 485 | $smcFunc['db_query']('substring', ' |
@@ -491,8 +504,7 @@ discard block |
||
| 491 | 504 | 'value' => (is_array($val) ? implode(',', $val) : $val), |
| 492 | 505 | ) |
| 493 | 506 | ); |
| 494 | - } |
|
| 495 | - elseif ($_POST['options_master'][$opt] == 2) |
|
| 507 | + } elseif ($_POST['options_master'][$opt] == 2) |
|
| 496 | 508 | { |
| 497 | 509 | $smcFunc['db_query']('', ' |
| 498 | 510 | DELETE FROM {db_prefix}themes |
@@ -509,8 +521,7 @@ discard block |
||
| 509 | 521 | } |
| 510 | 522 | |
| 511 | 523 | redirectexit('action=admin;area=theme;' . $context['session_var'] . '=' . $context['session_id'] . ';sa=reset'); |
| 512 | - } |
|
| 513 | - elseif (!empty($_GET['who']) && $_GET['who'] == 2) |
|
| 524 | + } elseif (!empty($_GET['who']) && $_GET['who'] == 2) |
|
| 514 | 525 | { |
| 515 | 526 | checkSession('get'); |
| 516 | 527 | validateToken('admin-stor', 'request'); |
@@ -525,8 +536,9 @@ discard block |
||
| 525 | 536 | ) |
| 526 | 537 | ); |
| 527 | 538 | $customFields = array(); |
| 528 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 529 | - $customFields[] = $row['col_name']; |
|
| 539 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 540 | + $customFields[] = $row['col_name']; |
|
| 541 | + } |
|
| 530 | 542 | $smcFunc['db_free_result']($request); |
| 531 | 543 | } |
| 532 | 544 | $customFieldsQuery = empty($customFields) ? '' : ('AND variable NOT IN ({array_string:custom_fields})'); |
@@ -578,13 +590,13 @@ discard block |
||
| 578 | 590 | ) |
| 579 | 591 | ); |
| 580 | 592 | $context['theme_options'] = array(); |
| 581 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 582 | - $context['theme_options'][$row['variable']] = $row['value']; |
|
| 593 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 594 | + $context['theme_options'][$row['variable']] = $row['value']; |
|
| 595 | + } |
|
| 583 | 596 | $smcFunc['db_free_result']($request); |
| 584 | 597 | |
| 585 | 598 | $context['theme_options_reset'] = false; |
| 586 | - } |
|
| 587 | - else |
|
| 599 | + } else |
|
| 588 | 600 | { |
| 589 | 601 | $context['theme_options'] = array(); |
| 590 | 602 | $context['theme_options_reset'] = true; |
@@ -593,30 +605,32 @@ discard block |
||
| 593 | 605 | foreach ($context['options'] as $i => $setting) |
| 594 | 606 | { |
| 595 | 607 | // Just skip separators |
| 596 | - if (!is_array($setting)) |
|
| 597 | - continue; |
|
| 608 | + if (!is_array($setting)) { |
|
| 609 | + continue; |
|
| 610 | + } |
|
| 598 | 611 | |
| 599 | 612 | // Is this disabled? |
| 600 | 613 | if ($setting['id'] == 'calendar_start_day' && empty($modSettings['cal_enabled'])) |
| 601 | 614 | { |
| 602 | 615 | unset($context['options'][$i]); |
| 603 | 616 | continue; |
| 604 | - } |
|
| 605 | - elseif (($setting['id'] == 'topics_per_page' || $setting['id'] == 'messages_per_page') && !empty($modSettings['disableCustomPerPage'])) |
|
| 617 | + } elseif (($setting['id'] == 'topics_per_page' || $setting['id'] == 'messages_per_page') && !empty($modSettings['disableCustomPerPage'])) |
|
| 606 | 618 | { |
| 607 | 619 | unset($context['options'][$i]); |
| 608 | 620 | continue; |
| 609 | 621 | } |
| 610 | 622 | |
| 611 | - if (!isset($setting['type']) || $setting['type'] == 'bool') |
|
| 612 | - $context['options'][$i]['type'] = 'checkbox'; |
|
| 613 | - elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') |
|
| 614 | - $context['options'][$i]['type'] = 'number'; |
|
| 615 | - elseif ($setting['type'] == 'string') |
|
| 616 | - $context['options'][$i]['type'] = 'text'; |
|
| 623 | + if (!isset($setting['type']) || $setting['type'] == 'bool') { |
|
| 624 | + $context['options'][$i]['type'] = 'checkbox'; |
|
| 625 | + } elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') { |
|
| 626 | + $context['options'][$i]['type'] = 'number'; |
|
| 627 | + } elseif ($setting['type'] == 'string') { |
|
| 628 | + $context['options'][$i]['type'] = 'text'; |
|
| 629 | + } |
|
| 617 | 630 | |
| 618 | - if (isset($setting['options'])) |
|
| 619 | - $context['options'][$i]['type'] = 'list'; |
|
| 631 | + if (isset($setting['options'])) { |
|
| 632 | + $context['options'][$i]['type'] = 'list'; |
|
| 633 | + } |
|
| 620 | 634 | |
| 621 | 635 | $context['options'][$i]['value'] = !isset($context['theme_options'][$setting['id']]) ? '' : $context['theme_options'][$setting['id']]; |
| 622 | 636 | } |
@@ -641,8 +655,9 @@ discard block |
||
| 641 | 655 | { |
| 642 | 656 | global $txt, $context, $settings, $modSettings, $smcFunc; |
| 643 | 657 | |
| 644 | - if (empty($_GET['th']) && empty($_GET['id'])) |
|
| 645 | - return ThemeAdmin(); |
|
| 658 | + if (empty($_GET['th']) && empty($_GET['id'])) { |
|
| 659 | + return ThemeAdmin(); |
|
| 660 | + } |
|
| 646 | 661 | |
| 647 | 662 | $_GET['th'] = isset($_GET['th']) ? (int) $_GET['th'] : (int) $_GET['id']; |
| 648 | 663 | |
@@ -653,8 +668,9 @@ discard block |
||
| 653 | 668 | isAllowedTo('admin_forum'); |
| 654 | 669 | |
| 655 | 670 | // Validate inputs/user. |
| 656 | - if (empty($_GET['th'])) |
|
| 657 | - fatal_lang_error('no_theme', false); |
|
| 671 | + if (empty($_GET['th'])) { |
|
| 672 | + fatal_lang_error('no_theme', false); |
|
| 673 | + } |
|
| 658 | 674 | |
| 659 | 675 | // Fetch the smiley sets... |
| 660 | 676 | $sets = explode(',', 'none,' . $modSettings['smiley_sets_known']); |
@@ -662,8 +678,9 @@ discard block |
||
| 662 | 678 | $context['smiley_sets'] = array( |
| 663 | 679 | '' => $txt['smileys_no_default'] |
| 664 | 680 | ); |
| 665 | - foreach ($sets as $i => $set) |
|
| 666 | - $context['smiley_sets'][$set] = $smcFunc['htmlspecialchars']($set_names[$i]); |
|
| 681 | + foreach ($sets as $i => $set) { |
|
| 682 | + $context['smiley_sets'][$set] = $smcFunc['htmlspecialchars']($set_names[$i]); |
|
| 683 | + } |
|
| 667 | 684 | |
| 668 | 685 | $old_id = $settings['theme_id']; |
| 669 | 686 | $old_settings = $settings; |
@@ -688,8 +705,9 @@ discard block |
||
| 688 | 705 | if (file_exists($settings['theme_dir'] . '/index.template.php')) |
| 689 | 706 | { |
| 690 | 707 | $file_contents = implode('', file($settings['theme_dir'] . '/index.template.php')); |
| 691 | - if (preg_match('~\$settings\[\'theme_variants\'\]\s*=(.+?);~', $file_contents, $matches)) |
|
| 692 | - eval('global $settings;' . $matches[0]); |
|
| 708 | + if (preg_match('~\$settings\[\'theme_variants\'\]\s*=(.+?);~', $file_contents, $matches)) { |
|
| 709 | + eval('global $settings;' . $matches[0]); |
|
| 710 | + } |
|
| 693 | 711 | } |
| 694 | 712 | |
| 695 | 713 | // Submitting! |
@@ -698,37 +716,45 @@ discard block |
||
| 698 | 716 | checkSession(); |
| 699 | 717 | validateToken('admin-sts'); |
| 700 | 718 | |
| 701 | - if (empty($_POST['options'])) |
|
| 702 | - $_POST['options'] = array(); |
|
| 703 | - if (empty($_POST['default_options'])) |
|
| 704 | - $_POST['default_options'] = array(); |
|
| 719 | + if (empty($_POST['options'])) { |
|
| 720 | + $_POST['options'] = array(); |
|
| 721 | + } |
|
| 722 | + if (empty($_POST['default_options'])) { |
|
| 723 | + $_POST['default_options'] = array(); |
|
| 724 | + } |
|
| 705 | 725 | |
| 706 | 726 | // Make sure items are cast correctly. |
| 707 | 727 | foreach ($context['theme_settings'] as $item) |
| 708 | 728 | { |
| 709 | 729 | // Disregard this item if this is just a separator. |
| 710 | - if (!is_array($item)) |
|
| 711 | - continue; |
|
| 730 | + if (!is_array($item)) { |
|
| 731 | + continue; |
|
| 732 | + } |
|
| 712 | 733 | |
| 713 | 734 | foreach (array('options', 'default_options') as $option) |
| 714 | 735 | { |
| 715 | - if (!isset($_POST[$option][$item['id']])) |
|
| 716 | - continue; |
|
| 736 | + if (!isset($_POST[$option][$item['id']])) { |
|
| 737 | + continue; |
|
| 738 | + } |
|
| 717 | 739 | // Checkbox. |
| 718 | - elseif (empty($item['type'])) |
|
| 719 | - $_POST[$option][$item['id']] = $_POST[$option][$item['id']] ? 1 : 0; |
|
| 740 | + elseif (empty($item['type'])) { |
|
| 741 | + $_POST[$option][$item['id']] = $_POST[$option][$item['id']] ? 1 : 0; |
|
| 742 | + } |
|
| 720 | 743 | // Number |
| 721 | - elseif ($item['type'] == 'number') |
|
| 722 | - $_POST[$option][$item['id']] = (int) $_POST[$option][$item['id']]; |
|
| 744 | + elseif ($item['type'] == 'number') { |
|
| 745 | + $_POST[$option][$item['id']] = (int) $_POST[$option][$item['id']]; |
|
| 746 | + } |
|
| 723 | 747 | } |
| 724 | 748 | } |
| 725 | 749 | |
| 726 | 750 | // Set up the sql query. |
| 727 | 751 | $inserts = array(); |
| 728 | - foreach ($_POST['options'] as $opt => $val) |
|
| 729 | - $inserts[] = array(0, $_GET['th'], $opt, is_array($val) ? implode(',', $val) : $val); |
|
| 730 | - foreach ($_POST['default_options'] as $opt => $val) |
|
| 731 | - $inserts[] = array(0, 1, $opt, is_array($val) ? implode(',', $val) : $val); |
|
| 752 | + foreach ($_POST['options'] as $opt => $val) { |
|
| 753 | + $inserts[] = array(0, $_GET['th'], $opt, is_array($val) ? implode(',', $val) : $val); |
|
| 754 | + } |
|
| 755 | + foreach ($_POST['default_options'] as $opt => $val) { |
|
| 756 | + $inserts[] = array(0, 1, $opt, is_array($val) ? implode(',', $val) : $val); |
|
| 757 | + } |
|
| 732 | 758 | // If we're actually inserting something.. |
| 733 | 759 | if (!empty($inserts)) |
| 734 | 760 | { |
@@ -754,8 +780,9 @@ discard block |
||
| 754 | 780 | |
| 755 | 781 | foreach ($settings as $setting => $dummy) |
| 756 | 782 | { |
| 757 | - if (!in_array($setting, array('theme_url', 'theme_dir', 'images_url', 'template_dirs'))) |
|
| 758 | - $settings[$setting] = htmlspecialchars__recursive($settings[$setting]); |
|
| 783 | + if (!in_array($setting, array('theme_url', 'theme_dir', 'images_url', 'template_dirs'))) { |
|
| 784 | + $settings[$setting] = htmlspecialchars__recursive($settings[$setting]); |
|
| 785 | + } |
|
| 759 | 786 | } |
| 760 | 787 | |
| 761 | 788 | $context['settings'] = $context['theme_settings']; |
@@ -764,18 +791,21 @@ discard block |
||
| 764 | 791 | foreach ($context['settings'] as $i => $setting) |
| 765 | 792 | { |
| 766 | 793 | // Separators are dummies, so leave them alone. |
| 767 | - if (!is_array($setting)) |
|
| 768 | - continue; |
|
| 794 | + if (!is_array($setting)) { |
|
| 795 | + continue; |
|
| 796 | + } |
|
| 769 | 797 | |
| 770 | - if (!isset($setting['type']) || $setting['type'] == 'bool') |
|
| 771 | - $context['settings'][$i]['type'] = 'checkbox'; |
|
| 772 | - elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') |
|
| 773 | - $context['settings'][$i]['type'] = 'number'; |
|
| 774 | - elseif ($setting['type'] == 'string') |
|
| 775 | - $context['settings'][$i]['type'] = 'text'; |
|
| 798 | + if (!isset($setting['type']) || $setting['type'] == 'bool') { |
|
| 799 | + $context['settings'][$i]['type'] = 'checkbox'; |
|
| 800 | + } elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') { |
|
| 801 | + $context['settings'][$i]['type'] = 'number'; |
|
| 802 | + } elseif ($setting['type'] == 'string') { |
|
| 803 | + $context['settings'][$i]['type'] = 'text'; |
|
| 804 | + } |
|
| 776 | 805 | |
| 777 | - if (isset($setting['options'])) |
|
| 778 | - $context['settings'][$i]['type'] = 'list'; |
|
| 806 | + if (isset($setting['options'])) { |
|
| 807 | + $context['settings'][$i]['type'] = 'list'; |
|
| 808 | + } |
|
| 779 | 809 | |
| 780 | 810 | $context['settings'][$i]['value'] = !isset($settings[$setting['id']]) ? '' : $settings[$setting['id']]; |
| 781 | 811 | } |
@@ -828,8 +858,9 @@ discard block |
||
| 828 | 858 | $themeID = isset($_GET['th']) ? (int) $_GET['th'] : (int) $_GET['id']; |
| 829 | 859 | |
| 830 | 860 | // You can't delete the default theme! |
| 831 | - if ($themeID == 1) |
|
| 832 | - fatal_lang_error('no_access', false); |
|
| 861 | + if ($themeID == 1) { |
|
| 862 | + fatal_lang_error('no_access', false); |
|
| 863 | + } |
|
| 833 | 864 | |
| 834 | 865 | $theme_info = get_single_theme($themeID); |
| 835 | 866 | |
@@ -837,8 +868,9 @@ discard block |
||
| 837 | 868 | remove_theme($themeID); |
| 838 | 869 | |
| 839 | 870 | // And remove all its files and folders too. |
| 840 | - if (!empty($theme_info) && !empty($theme_info['theme_dir'])) |
|
| 841 | - remove_dir($theme_info['theme_dir']); |
|
| 871 | + if (!empty($theme_info) && !empty($theme_info['theme_dir'])) { |
|
| 872 | + remove_dir($theme_info['theme_dir']); |
|
| 873 | + } |
|
| 842 | 874 | |
| 843 | 875 | // Go back to the list page. |
| 844 | 876 | redirectexit('action=admin;area=theme;sa=list;' . $context['session_var'] . '=' . $context['session_id'] . ';done=removing'); |
@@ -863,12 +895,14 @@ discard block |
||
| 863 | 895 | $enableThemes = explode(',', $modSettings['enableThemes']); |
| 864 | 896 | |
| 865 | 897 | // Are we disabling it? |
| 866 | - if (isset($_GET['disabled'])) |
|
| 867 | - $enableThemes = array_diff($enableThemes, array($themeID)); |
|
| 898 | + if (isset($_GET['disabled'])) { |
|
| 899 | + $enableThemes = array_diff($enableThemes, array($themeID)); |
|
| 900 | + } |
|
| 868 | 901 | |
| 869 | 902 | // Nope? then enable it! |
| 870 | - else |
|
| 871 | - $enableThemes[] = (string) $themeID; |
|
| 903 | + else { |
|
| 904 | + $enableThemes[] = (string) $themeID; |
|
| 905 | + } |
|
| 872 | 906 | |
| 873 | 907 | // Update the setting. |
| 874 | 908 | $enableThemes = strtr(implode(',', $enableThemes), array(',,' => ',')); |
@@ -903,18 +937,21 @@ discard block |
||
| 903 | 937 | |
| 904 | 938 | $_SESSION['id_theme'] = 0; |
| 905 | 939 | |
| 906 | - if (isset($_GET['id'])) |
|
| 907 | - $_GET['th'] = $_GET['id']; |
|
| 940 | + if (isset($_GET['id'])) { |
|
| 941 | + $_GET['th'] = $_GET['id']; |
|
| 942 | + } |
|
| 908 | 943 | |
| 909 | 944 | // Saving a variant cause JS doesn't work - pretend it did ;) |
| 910 | 945 | if (isset($_POST['save'])) |
| 911 | 946 | { |
| 912 | 947 | // Which theme? |
| 913 | - foreach ($_POST['save'] as $k => $v) |
|
| 914 | - $_GET['th'] = (int) $k; |
|
| 948 | + foreach ($_POST['save'] as $k => $v) { |
|
| 949 | + $_GET['th'] = (int) $k; |
|
| 950 | + } |
|
| 915 | 951 | |
| 916 | - if (isset($_POST['vrt'][$k])) |
|
| 917 | - $_GET['vrt'] = $_POST['vrt'][$k]; |
|
| 952 | + if (isset($_POST['vrt'][$k])) { |
|
| 953 | + $_GET['vrt'] = $_POST['vrt'][$k]; |
|
| 954 | + } |
|
| 918 | 955 | } |
| 919 | 956 | |
| 920 | 957 | // Have we made a decision, or are we just browsing? |
@@ -992,8 +1029,9 @@ discard block |
||
| 992 | 1029 | else |
| 993 | 1030 | { |
| 994 | 1031 | // The forum's default theme is always 0 and we |
| 995 | - if (isset($_GET['th']) && $_GET['th'] == 0) |
|
| 996 | - $_GET['th'] = $modSettings['theme_guests']; |
|
| 1032 | + if (isset($_GET['th']) && $_GET['th'] == 0) { |
|
| 1033 | + $_GET['th'] = $modSettings['theme_guests']; |
|
| 1034 | + } |
|
| 997 | 1035 | |
| 998 | 1036 | updateMemberData((int) $_REQUEST['u'], array('id_theme' => (int) $_GET['th'])); |
| 999 | 1037 | |
@@ -1007,8 +1045,9 @@ discard block |
||
| 1007 | 1045 | ); |
| 1008 | 1046 | cache_put_data('theme_settings-' . $_GET['th'] . ':' . (int) $_REQUEST['u'], null, 90); |
| 1009 | 1047 | |
| 1010 | - if ($user_info['id'] == $_REQUEST['u']) |
|
| 1011 | - $_SESSION['id_variant'] = 0; |
|
| 1048 | + if ($user_info['id'] == $_REQUEST['u']) { |
|
| 1049 | + $_SESSION['id_variant'] = 0; |
|
| 1050 | + } |
|
| 1012 | 1051 | } |
| 1013 | 1052 | |
| 1014 | 1053 | redirectexit('action=profile;u=' . (int) $_REQUEST['u'] . ';area=theme'); |
@@ -1077,12 +1116,13 @@ discard block |
||
| 1077 | 1116 | ); |
| 1078 | 1117 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1079 | 1118 | { |
| 1080 | - if (!isset($context['available_themes'][$row['id_theme']])) |
|
| 1081 | - $context['available_themes'][$row['id_theme']] = array( |
|
| 1119 | + if (!isset($context['available_themes'][$row['id_theme']])) { |
|
| 1120 | + $context['available_themes'][$row['id_theme']] = array( |
|
| 1082 | 1121 | 'id' => $row['id_theme'], |
| 1083 | 1122 | 'selected' => $context['current_theme'] == $row['id_theme'], |
| 1084 | 1123 | 'num_users' => 0 |
| 1085 | 1124 | ); |
| 1125 | + } |
|
| 1086 | 1126 | $context['available_themes'][$row['id_theme']][$row['variable']] = $row['value']; |
| 1087 | 1127 | } |
| 1088 | 1128 | $smcFunc['db_free_result']($request); |
@@ -1095,9 +1135,9 @@ discard block |
||
| 1095 | 1135 | 'num_users' => 0 |
| 1096 | 1136 | ); |
| 1097 | 1137 | $guest_theme = 0; |
| 1138 | + } else { |
|
| 1139 | + $guest_theme = $modSettings['theme_guests']; |
|
| 1098 | 1140 | } |
| 1099 | - else |
|
| 1100 | - $guest_theme = $modSettings['theme_guests']; |
|
| 1101 | 1141 | |
| 1102 | 1142 | $request = $smcFunc['db_query']('', ' |
| 1103 | 1143 | SELECT id_theme, COUNT(*) AS the_count |
@@ -1110,15 +1150,17 @@ discard block |
||
| 1110 | 1150 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1111 | 1151 | { |
| 1112 | 1152 | // Figure out which theme it is they are REALLY using. |
| 1113 | - if (!empty($modSettings['knownThemes']) && !in_array($row['id_theme'], explode(',', $modSettings['knownThemes']))) |
|
| 1114 | - $row['id_theme'] = $guest_theme; |
|
| 1115 | - elseif (empty($modSettings['theme_allow'])) |
|
| 1116 | - $row['id_theme'] = $guest_theme; |
|
| 1153 | + if (!empty($modSettings['knownThemes']) && !in_array($row['id_theme'], explode(',', $modSettings['knownThemes']))) { |
|
| 1154 | + $row['id_theme'] = $guest_theme; |
|
| 1155 | + } elseif (empty($modSettings['theme_allow'])) { |
|
| 1156 | + $row['id_theme'] = $guest_theme; |
|
| 1157 | + } |
|
| 1117 | 1158 | |
| 1118 | - if (isset($context['available_themes'][$row['id_theme']])) |
|
| 1119 | - $context['available_themes'][$row['id_theme']]['num_users'] += $row['the_count']; |
|
| 1120 | - else |
|
| 1121 | - $context['available_themes'][$guest_theme]['num_users'] += $row['the_count']; |
|
| 1159 | + if (isset($context['available_themes'][$row['id_theme']])) { |
|
| 1160 | + $context['available_themes'][$row['id_theme']]['num_users'] += $row['the_count']; |
|
| 1161 | + } else { |
|
| 1162 | + $context['available_themes'][$guest_theme]['num_users'] += $row['the_count']; |
|
| 1163 | + } |
|
| 1122 | 1164 | } |
| 1123 | 1165 | $smcFunc['db_free_result']($request); |
| 1124 | 1166 | |
@@ -1137,8 +1179,9 @@ discard block |
||
| 1137 | 1179 | 'id_member' => isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'pick' ? array(-1, $context['current_member']) : array(-1), |
| 1138 | 1180 | ) |
| 1139 | 1181 | ); |
| 1140 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1141 | - $variant_preferences[$row['id_theme']] = $row['value']; |
|
| 1182 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1183 | + $variant_preferences[$row['id_theme']] = $row['value']; |
|
| 1184 | + } |
|
| 1142 | 1185 | $smcFunc['db_free_result']($request); |
| 1143 | 1186 | } |
| 1144 | 1187 | |
@@ -1149,17 +1192,18 @@ discard block |
||
| 1149 | 1192 | foreach ($context['available_themes'] as $id_theme => $theme_data) |
| 1150 | 1193 | { |
| 1151 | 1194 | // Don't try to load the forum or board default theme's data... it doesn't have any! |
| 1152 | - if ($id_theme == 0) |
|
| 1153 | - continue; |
|
| 1195 | + if ($id_theme == 0) { |
|
| 1196 | + continue; |
|
| 1197 | + } |
|
| 1154 | 1198 | |
| 1155 | 1199 | // The thumbnail needs the correct path. |
| 1156 | 1200 | $settings['images_url'] = &$theme_data['images_url']; |
| 1157 | 1201 | |
| 1158 | - if (file_exists($theme_data['theme_dir'] . '/languages/Settings.' . $user_info['language'] . '.php')) |
|
| 1159 | - include($theme_data['theme_dir'] . '/languages/Settings.' . $user_info['language'] . '.php'); |
|
| 1160 | - elseif (file_exists($theme_data['theme_dir'] . '/languages/Settings.' . $language . '.php')) |
|
| 1161 | - include($theme_data['theme_dir'] . '/languages/Settings.' . $language . '.php'); |
|
| 1162 | - else |
|
| 1202 | + if (file_exists($theme_data['theme_dir'] . '/languages/Settings.' . $user_info['language'] . '.php')) { |
|
| 1203 | + include($theme_data['theme_dir'] . '/languages/Settings.' . $user_info['language'] . '.php'); |
|
| 1204 | + } elseif (file_exists($theme_data['theme_dir'] . '/languages/Settings.' . $language . '.php')) { |
|
| 1205 | + include($theme_data['theme_dir'] . '/languages/Settings.' . $language . '.php'); |
|
| 1206 | + } else |
|
| 1163 | 1207 | { |
| 1164 | 1208 | $txt['theme_thumbnail_href'] = $theme_data['images_url'] . '/thumbnail.png'; |
| 1165 | 1209 | $txt['theme_description'] = ''; |
@@ -1184,15 +1228,17 @@ discard block |
||
| 1184 | 1228 | loadLanguage('Settings'); |
| 1185 | 1229 | |
| 1186 | 1230 | $context['available_themes'][$id_theme]['variants'] = array(); |
| 1187 | - foreach ($settings['theme_variants'] as $variant) |
|
| 1188 | - $context['available_themes'][$id_theme]['variants'][$variant] = array( |
|
| 1231 | + foreach ($settings['theme_variants'] as $variant) { |
|
| 1232 | + $context['available_themes'][$id_theme]['variants'][$variant] = array( |
|
| 1189 | 1233 | 'label' => isset($txt['variant_' . $variant]) ? $txt['variant_' . $variant] : $variant, |
| 1190 | 1234 | 'thumbnail' => !file_exists($theme_data['theme_dir'] . '/images/thumbnail.png') || file_exists($theme_data['theme_dir'] . '/images/thumbnail_' . $variant . '.png') ? $theme_data['images_url'] . '/thumbnail_' . $variant . '.png' : ($theme_data['images_url'] . '/thumbnail.png'), |
| 1191 | 1235 | ); |
| 1236 | + } |
|
| 1192 | 1237 | |
| 1193 | 1238 | $context['available_themes'][$id_theme]['selected_variant'] = isset($_GET['vrt']) ? $_GET['vrt'] : (!empty($variant_preferences[$id_theme]) ? $variant_preferences[$id_theme] : (!empty($settings['default_variant']) ? $settings['default_variant'] : $settings['theme_variants'][0])); |
| 1194 | - if (!isset($context['available_themes'][$id_theme]['variants'][$context['available_themes'][$id_theme]['selected_variant']]['thumbnail'])) |
|
| 1195 | - $context['available_themes'][$id_theme]['selected_variant'] = $settings['theme_variants'][0]; |
|
| 1239 | + if (!isset($context['available_themes'][$id_theme]['variants'][$context['available_themes'][$id_theme]['selected_variant']]['thumbnail'])) { |
|
| 1240 | + $context['available_themes'][$id_theme]['selected_variant'] = $settings['theme_variants'][0]; |
|
| 1241 | + } |
|
| 1196 | 1242 | |
| 1197 | 1243 | $context['available_themes'][$id_theme]['thumbnail_href'] = $context['available_themes'][$id_theme]['variants'][$context['available_themes'][$id_theme]['selected_variant']]['thumbnail']; |
| 1198 | 1244 | // Allow themes to override the text. |
@@ -1208,8 +1254,9 @@ discard block |
||
| 1208 | 1254 | // As long as we're not doing the default theme... |
| 1209 | 1255 | if (!isset($_REQUEST['u']) || $_REQUEST['u'] >= 0) |
| 1210 | 1256 | { |
| 1211 | - if ($guest_theme != 0) |
|
| 1212 | - $context['available_themes'][0] = $context['available_themes'][$guest_theme]; |
|
| 1257 | + if ($guest_theme != 0) { |
|
| 1258 | + $context['available_themes'][0] = $context['available_themes'][$guest_theme]; |
|
| 1259 | + } |
|
| 1213 | 1260 | |
| 1214 | 1261 | $context['available_themes'][0]['id'] = 0; |
| 1215 | 1262 | $context['available_themes'][0]['name'] = $txt['theme_forum_default']; |
@@ -1258,14 +1305,16 @@ discard block |
||
| 1258 | 1305 | $action = $smcFunc['htmlspecialchars'](trim($_GET['do'])); |
| 1259 | 1306 | |
| 1260 | 1307 | // Got any info from the specific form? |
| 1261 | - if (!isset($_POST['save_' . $action])) |
|
| 1262 | - fatal_lang_error('theme_install_no_action', false); |
|
| 1308 | + if (!isset($_POST['save_' . $action])) { |
|
| 1309 | + fatal_lang_error('theme_install_no_action', false); |
|
| 1310 | + } |
|
| 1263 | 1311 | |
| 1264 | 1312 | validateToken('admin-t-' . $action); |
| 1265 | 1313 | |
| 1266 | 1314 | // Hopefully the themes directory is writable, or we might have a problem. |
| 1267 | - if (!is_writable($themedir)) |
|
| 1268 | - fatal_lang_error('theme_install_write_error', 'critical'); |
|
| 1315 | + if (!is_writable($themedir)) { |
|
| 1316 | + fatal_lang_error('theme_install_write_error', 'critical'); |
|
| 1317 | + } |
|
| 1269 | 1318 | |
| 1270 | 1319 | // Call the function and handle the result. |
| 1271 | 1320 | $result = $subActions[$action](); |
@@ -1280,9 +1329,10 @@ discard block |
||
| 1280 | 1329 | } |
| 1281 | 1330 | |
| 1282 | 1331 | // Nope, show a nice error. |
| 1283 | - else |
|
| 1284 | - fatal_lang_error('theme_install_no_action', false); |
|
| 1285 | -} |
|
| 1332 | + else { |
|
| 1333 | + fatal_lang_error('theme_install_no_action', false); |
|
| 1334 | + } |
|
| 1335 | + } |
|
| 1286 | 1336 | |
| 1287 | 1337 | /** |
| 1288 | 1338 | * Installs a theme from a theme package. |
@@ -1298,8 +1348,9 @@ discard block |
||
| 1298 | 1348 | $dirtemp = $themedir . '/temp'; |
| 1299 | 1349 | |
| 1300 | 1350 | // Make sure the temp dir doesn't already exist |
| 1301 | - if (file_exists($dirtemp)) |
|
| 1302 | - remove_dir($dirtemp); |
|
| 1351 | + if (file_exists($dirtemp)) { |
|
| 1352 | + remove_dir($dirtemp); |
|
| 1353 | + } |
|
| 1303 | 1354 | |
| 1304 | 1355 | // Create the temp dir. |
| 1305 | 1356 | mkdir($dirtemp, 0777); |
@@ -1311,17 +1362,20 @@ discard block |
||
| 1311 | 1362 | smf_chmod($dirtemp, '0755'); |
| 1312 | 1363 | |
| 1313 | 1364 | // How about now? |
| 1314 | - if (!is_writable($dirtemp)) |
|
| 1315 | - fatal_lang_error('theme_install_write_error', 'critical'); |
|
| 1365 | + if (!is_writable($dirtemp)) { |
|
| 1366 | + fatal_lang_error('theme_install_write_error', 'critical'); |
|
| 1367 | + } |
|
| 1316 | 1368 | } |
| 1317 | 1369 | |
| 1318 | 1370 | // This happens when the admin session is gone and the user has to login again. |
| 1319 | - if (!isset($_FILES) || !isset($_FILES['theme_gz']) || empty($_FILES['theme_gz'])) |
|
| 1320 | - redirectexit('action=admin;area=theme;sa=admin;' . $context['session_var'] . '=' . $context['session_id']); |
|
| 1371 | + if (!isset($_FILES) || !isset($_FILES['theme_gz']) || empty($_FILES['theme_gz'])) { |
|
| 1372 | + redirectexit('action=admin;area=theme;sa=admin;' . $context['session_var'] . '=' . $context['session_id']); |
|
| 1373 | + } |
|
| 1321 | 1374 | |
| 1322 | 1375 | // Another error check layer, something went wrong with the upload. |
| 1323 | - if (isset($_FILES['theme_gz']['error']) && $_FILES['theme_gz']['error'] != 0) |
|
| 1324 | - fatal_lang_error('theme_install_error_file_' . $_FILES['theme_gz']['error'], false); |
|
| 1376 | + if (isset($_FILES['theme_gz']['error']) && $_FILES['theme_gz']['error'] != 0) { |
|
| 1377 | + fatal_lang_error('theme_install_error_file_' . $_FILES['theme_gz']['error'], false); |
|
| 1378 | + } |
|
| 1325 | 1379 | |
| 1326 | 1380 | // Get the theme's name. |
| 1327 | 1381 | $name = pathinfo($_FILES['theme_gz']['name'], PATHINFO_FILENAME); |
@@ -1352,11 +1406,10 @@ discard block |
||
| 1352 | 1406 | |
| 1353 | 1407 | // return all the info. |
| 1354 | 1408 | return $context['to_install']; |
| 1409 | + } else { |
|
| 1410 | + fatal_lang_error('theme_install_error_title', false); |
|
| 1411 | + } |
|
| 1355 | 1412 | } |
| 1356 | - |
|
| 1357 | - else |
|
| 1358 | - fatal_lang_error('theme_install_error_title', false); |
|
| 1359 | -} |
|
| 1360 | 1413 | |
| 1361 | 1414 | /** |
| 1362 | 1415 | * Makes a copy from the default theme, assigns a name for it and installs it. |
@@ -1370,15 +1423,17 @@ discard block |
||
| 1370 | 1423 | global $forum_version; |
| 1371 | 1424 | |
| 1372 | 1425 | // There's gotta be something to work with. |
| 1373 | - if (!isset($_REQUEST['copy']) || empty($_REQUEST['copy'])) |
|
| 1374 | - fatal_lang_error('theme_install_error_title', false); |
|
| 1426 | + if (!isset($_REQUEST['copy']) || empty($_REQUEST['copy'])) { |
|
| 1427 | + fatal_lang_error('theme_install_error_title', false); |
|
| 1428 | + } |
|
| 1375 | 1429 | |
| 1376 | 1430 | // Get a cleaner version. |
| 1377 | 1431 | $name = preg_replace('~[^A-Za-z0-9_\- ]~', '', $_REQUEST['copy']); |
| 1378 | 1432 | |
| 1379 | 1433 | // Is there a theme already named like this? |
| 1380 | - if (file_exists($themedir . '/' . $name)) |
|
| 1381 | - fatal_lang_error('theme_install_already_dir', false); |
|
| 1434 | + if (file_exists($themedir . '/' . $name)) { |
|
| 1435 | + fatal_lang_error('theme_install_already_dir', false); |
|
| 1436 | + } |
|
| 1382 | 1437 | |
| 1383 | 1438 | // This is a brand new theme so set all possible values. |
| 1384 | 1439 | $context['to_install'] = array( |
@@ -1398,8 +1453,9 @@ discard block |
||
| 1398 | 1453 | |
| 1399 | 1454 | // Buy some time. |
| 1400 | 1455 | @set_time_limit(600); |
| 1401 | - if (function_exists('apache_reset_timeout')) |
|
| 1402 | - @apache_reset_timeout(); |
|
| 1456 | + if (function_exists('apache_reset_timeout')) { |
|
| 1457 | + @apache_reset_timeout(); |
|
| 1458 | + } |
|
| 1403 | 1459 | |
| 1404 | 1460 | // Create subdirectories for css and javascript files. |
| 1405 | 1461 | mkdir($context['to_install']['theme_dir'] . '/css', 0777); |
@@ -1435,12 +1491,13 @@ discard block |
||
| 1435 | 1491 | |
| 1436 | 1492 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1437 | 1493 | { |
| 1438 | - if ($row['variable'] == 'theme_templates') |
|
| 1439 | - $theme_templates = $row['value']; |
|
| 1440 | - elseif ($row['variable'] == 'theme_layers') |
|
| 1441 | - $theme_layers = $row['value']; |
|
| 1442 | - else |
|
| 1443 | - continue; |
|
| 1494 | + if ($row['variable'] == 'theme_templates') { |
|
| 1495 | + $theme_templates = $row['value']; |
|
| 1496 | + } elseif ($row['variable'] == 'theme_layers') { |
|
| 1497 | + $theme_layers = $row['value']; |
|
| 1498 | + } else { |
|
| 1499 | + continue; |
|
| 1500 | + } |
|
| 1444 | 1501 | } |
| 1445 | 1502 | |
| 1446 | 1503 | $smcFunc['db_free_result']($request); |
@@ -1499,12 +1556,14 @@ discard block |
||
| 1499 | 1556 | global $themedir, $themeurl, $context; |
| 1500 | 1557 | |
| 1501 | 1558 | // Cannot use the theme dir as a theme dir. |
| 1502 | - if (!isset($_REQUEST['theme_dir']) || empty($_REQUEST['theme_dir']) || rtrim(realpath($_REQUEST['theme_dir']), '/\\') == realpath($themedir)) |
|
| 1503 | - fatal_lang_error('theme_install_invalid_dir', false); |
|
| 1559 | + if (!isset($_REQUEST['theme_dir']) || empty($_REQUEST['theme_dir']) || rtrim(realpath($_REQUEST['theme_dir']), '/\\') == realpath($themedir)) { |
|
| 1560 | + fatal_lang_error('theme_install_invalid_dir', false); |
|
| 1561 | + } |
|
| 1504 | 1562 | |
| 1505 | 1563 | // Check is there is "something" on the dir. |
| 1506 | - elseif (!is_dir($_REQUEST['theme_dir']) || !file_exists($_REQUEST['theme_dir'] . '/theme_info.xml')) |
|
| 1507 | - fatal_lang_error('theme_install_error', false); |
|
| 1564 | + elseif (!is_dir($_REQUEST['theme_dir']) || !file_exists($_REQUEST['theme_dir'] . '/theme_info.xml')) { |
|
| 1565 | + fatal_lang_error('theme_install_error', false); |
|
| 1566 | + } |
|
| 1508 | 1567 | |
| 1509 | 1568 | $name = basename($_REQUEST['theme_dir']); |
| 1510 | 1569 | $name = preg_replace(array('/\s/', '/\.[\.]+/', '/[^\w_\.\-]/'), array('_', '.', ''), $name); |
@@ -1548,24 +1607,27 @@ discard block |
||
| 1548 | 1607 | } |
| 1549 | 1608 | |
| 1550 | 1609 | // Any special layers? |
| 1551 | - if (isset($settings['catch_action']['layers'])) |
|
| 1552 | - $context['template_layers'] = $settings['catch_action']['layers']; |
|
| 1610 | + if (isset($settings['catch_action']['layers'])) { |
|
| 1611 | + $context['template_layers'] = $settings['catch_action']['layers']; |
|
| 1612 | + } |
|
| 1553 | 1613 | |
| 1554 | 1614 | // Any function to call? |
| 1555 | 1615 | if (isset($settings['catch_action']['function'])) |
| 1556 | 1616 | { |
| 1557 | 1617 | $hook = $settings['catch_action']['function']; |
| 1558 | 1618 | |
| 1559 | - if (!isset($settings['catch_action']['filename'])) |
|
| 1560 | - $settings['catch_action']['filename'] = ''; |
|
| 1619 | + if (!isset($settings['catch_action']['filename'])) { |
|
| 1620 | + $settings['catch_action']['filename'] = ''; |
|
| 1621 | + } |
|
| 1561 | 1622 | |
| 1562 | 1623 | add_integration_function('integrate_wrap_action', $hook, false, $settings['catch_action']['filename'], false); |
| 1563 | 1624 | call_integration_hook('integrate_wrap_action'); |
| 1564 | 1625 | } |
| 1565 | 1626 | // And finally, the main sub template ;). |
| 1566 | - if (isset($settings['catch_action']['sub_template'])) |
|
| 1567 | - $context['sub_template'] = $settings['catch_action']['sub_template']; |
|
| 1568 | -} |
|
| 1627 | + if (isset($settings['catch_action']['sub_template'])) { |
|
| 1628 | + $context['sub_template'] = $settings['catch_action']['sub_template']; |
|
| 1629 | + } |
|
| 1630 | + } |
|
| 1569 | 1631 | |
| 1570 | 1632 | /** |
| 1571 | 1633 | * Set an option via javascript. |
@@ -1584,12 +1646,14 @@ discard block |
||
| 1584 | 1646 | checkSession('get'); |
| 1585 | 1647 | |
| 1586 | 1648 | // This good-for-nothing pixel is being used to keep the session alive. |
| 1587 | - if (empty($_GET['var']) || !isset($_GET['val'])) |
|
| 1588 | - redirectexit($settings['images_url'] . '/blank.png'); |
|
| 1649 | + if (empty($_GET['var']) || !isset($_GET['val'])) { |
|
| 1650 | + redirectexit($settings['images_url'] . '/blank.png'); |
|
| 1651 | + } |
|
| 1589 | 1652 | |
| 1590 | 1653 | // Sorry, guests can't go any further than this. |
| 1591 | - if ($user_info['is_guest'] || $user_info['id'] == 0) |
|
| 1592 | - obExit(false); |
|
| 1654 | + if ($user_info['is_guest'] || $user_info['id'] == 0) { |
|
| 1655 | + obExit(false); |
|
| 1656 | + } |
|
| 1593 | 1657 | |
| 1594 | 1658 | $reservedVars = array( |
| 1595 | 1659 | 'actual_theme_url', |
@@ -1612,8 +1676,9 @@ discard block |
||
| 1612 | 1676 | ); |
| 1613 | 1677 | |
| 1614 | 1678 | // Can't change reserved vars. |
| 1615 | - if (in_array(strtolower($_GET['var']), $reservedVars)) |
|
| 1616 | - redirectexit($settings['images_url'] . '/blank.png'); |
|
| 1679 | + if (in_array(strtolower($_GET['var']), $reservedVars)) { |
|
| 1680 | + redirectexit($settings['images_url'] . '/blank.png'); |
|
| 1681 | + } |
|
| 1617 | 1682 | |
| 1618 | 1683 | // Use a specific theme? |
| 1619 | 1684 | if (isset($_GET['th']) || isset($_GET['id'])) |
@@ -1629,8 +1694,9 @@ discard block |
||
| 1629 | 1694 | { |
| 1630 | 1695 | $options['admin_preferences'] = !empty($options['admin_preferences']) ? smf_json_decode($options['admin_preferences'], true) : array(); |
| 1631 | 1696 | // New thingy... |
| 1632 | - if (isset($_GET['admin_key']) && strlen($_GET['admin_key']) < 5) |
|
| 1633 | - $options['admin_preferences'][$_GET['admin_key']] = $_GET['val']; |
|
| 1697 | + if (isset($_GET['admin_key']) && strlen($_GET['admin_key']) < 5) { |
|
| 1698 | + $options['admin_preferences'][$_GET['admin_key']] = $_GET['val']; |
|
| 1699 | + } |
|
| 1634 | 1700 | |
| 1635 | 1701 | // Change the value to be something nice, |
| 1636 | 1702 | $_GET['val'] = json_encode($options['admin_preferences']); |
@@ -1660,8 +1726,9 @@ discard block |
||
| 1660 | 1726 | global $context, $scripturl, $boarddir, $smcFunc, $txt; |
| 1661 | 1727 | |
| 1662 | 1728 | // @todo Should this be removed? |
| 1663 | - if (isset($_REQUEST['preview'])) |
|
| 1664 | - die('die() with fire'); |
|
| 1729 | + if (isset($_REQUEST['preview'])) { |
|
| 1730 | + die('die() with fire'); |
|
| 1731 | + } |
|
| 1665 | 1732 | |
| 1666 | 1733 | isAllowedTo('admin_forum'); |
| 1667 | 1734 | loadTemplate('Themes'); |
@@ -1675,11 +1742,11 @@ discard block |
||
| 1675 | 1742 | foreach ($context['themes'] as $key => $theme) |
| 1676 | 1743 | { |
| 1677 | 1744 | // There has to be a Settings template! |
| 1678 | - if (!file_exists($theme['theme_dir'] . '/index.template.php') && !file_exists($theme['theme_dir'] . '/css/index.css')) |
|
| 1679 | - unset($context['themes'][$key]); |
|
| 1680 | - |
|
| 1681 | - else |
|
| 1682 | - $context['themes'][$key]['can_edit_style'] = file_exists($theme['theme_dir'] . '/css/index.css'); |
|
| 1745 | + if (!file_exists($theme['theme_dir'] . '/index.template.php') && !file_exists($theme['theme_dir'] . '/css/index.css')) { |
|
| 1746 | + unset($context['themes'][$key]); |
|
| 1747 | + } else { |
|
| 1748 | + $context['themes'][$key]['can_edit_style'] = file_exists($theme['theme_dir'] . '/css/index.css'); |
|
| 1749 | + } |
|
| 1683 | 1750 | } |
| 1684 | 1751 | |
| 1685 | 1752 | $context['sub_template'] = 'edit_list'; |
@@ -1694,22 +1761,24 @@ discard block |
||
| 1694 | 1761 | $context['theme_id'] = $currentTheme['id']; |
| 1695 | 1762 | $context['browse_title'] = sprintf($txt['themeadmin_browsing_theme'], $currentTheme['name']); |
| 1696 | 1763 | |
| 1697 | - if (!file_exists($currentTheme['theme_dir'] . '/index.template.php') && !file_exists($currentTheme['theme_dir'] . '/css/index.css')) |
|
| 1698 | - fatal_lang_error('theme_edit_missing', false); |
|
| 1764 | + if (!file_exists($currentTheme['theme_dir'] . '/index.template.php') && !file_exists($currentTheme['theme_dir'] . '/css/index.css')) { |
|
| 1765 | + fatal_lang_error('theme_edit_missing', false); |
|
| 1766 | + } |
|
| 1699 | 1767 | |
| 1700 | 1768 | if (!isset($_REQUEST['filename'])) |
| 1701 | 1769 | { |
| 1702 | 1770 | if (isset($_GET['directory'])) |
| 1703 | 1771 | { |
| 1704 | - if (substr($_GET['directory'], 0, 1) == '.') |
|
| 1705 | - $_GET['directory'] = ''; |
|
| 1706 | - else |
|
| 1772 | + if (substr($_GET['directory'], 0, 1) == '.') { |
|
| 1773 | + $_GET['directory'] = ''; |
|
| 1774 | + } else |
|
| 1707 | 1775 | { |
| 1708 | 1776 | $_GET['directory'] = preg_replace(array('~^[\./\\:\0\n\r]+~', '~[\\\\]~', '~/[\./]+~'), array('', '/', '/'), $_GET['directory']); |
| 1709 | 1777 | |
| 1710 | 1778 | $temp = realpath($currentTheme['theme_dir'] . '/' . $_GET['directory']); |
| 1711 | - if (empty($temp) || substr($temp, 0, strlen(realpath($currentTheme['theme_dir']))) != realpath($currentTheme['theme_dir'])) |
|
| 1712 | - $_GET['directory'] = ''; |
|
| 1779 | + if (empty($temp) || substr($temp, 0, strlen(realpath($currentTheme['theme_dir']))) != realpath($currentTheme['theme_dir'])) { |
|
| 1780 | + $_GET['directory'] = ''; |
|
| 1781 | + } |
|
| 1713 | 1782 | } |
| 1714 | 1783 | } |
| 1715 | 1784 | |
@@ -1728,37 +1797,39 @@ discard block |
||
| 1728 | 1797 | 'href' => $scripturl . '?action=admin;area=theme;th=' . $_GET['th'] . ';' . $context['session_var'] . '=' . $context['session_id'] . ';sa=edit;directory=' . $temp, |
| 1729 | 1798 | 'size' => '', |
| 1730 | 1799 | )); |
| 1800 | + } else { |
|
| 1801 | + $context['theme_files'] = get_file_listing($currentTheme['theme_dir'], ''); |
|
| 1731 | 1802 | } |
| 1732 | - else |
|
| 1733 | - $context['theme_files'] = get_file_listing($currentTheme['theme_dir'], ''); |
|
| 1734 | 1803 | |
| 1735 | 1804 | $context['sub_template'] = 'edit_browse'; |
| 1736 | 1805 | |
| 1737 | 1806 | return; |
| 1738 | - } |
|
| 1739 | - else |
|
| 1807 | + } else |
|
| 1740 | 1808 | { |
| 1741 | - if (substr($_REQUEST['filename'], 0, 1) == '.') |
|
| 1742 | - $_REQUEST['filename'] = ''; |
|
| 1743 | - else |
|
| 1809 | + if (substr($_REQUEST['filename'], 0, 1) == '.') { |
|
| 1810 | + $_REQUEST['filename'] = ''; |
|
| 1811 | + } else |
|
| 1744 | 1812 | { |
| 1745 | 1813 | $_REQUEST['filename'] = preg_replace(array('~^[\./\\:\0\n\r]+~', '~[\\\\]~', '~/[\./]+~'), array('', '/', '/'), $_REQUEST['filename']); |
| 1746 | 1814 | |
| 1747 | 1815 | $temp = realpath($currentTheme['theme_dir'] . '/' . $_REQUEST['filename']); |
| 1748 | - if (empty($temp) || substr($temp, 0, strlen(realpath($currentTheme['theme_dir']))) != realpath($currentTheme['theme_dir'])) |
|
| 1749 | - $_REQUEST['filename'] = ''; |
|
| 1816 | + if (empty($temp) || substr($temp, 0, strlen(realpath($currentTheme['theme_dir']))) != realpath($currentTheme['theme_dir'])) { |
|
| 1817 | + $_REQUEST['filename'] = ''; |
|
| 1818 | + } |
|
| 1750 | 1819 | } |
| 1751 | 1820 | |
| 1752 | - if (empty($_REQUEST['filename'])) |
|
| 1753 | - fatal_lang_error('theme_edit_missing', false); |
|
| 1821 | + if (empty($_REQUEST['filename'])) { |
|
| 1822 | + fatal_lang_error('theme_edit_missing', false); |
|
| 1823 | + } |
|
| 1754 | 1824 | } |
| 1755 | 1825 | |
| 1756 | 1826 | if (isset($_POST['save'])) |
| 1757 | 1827 | { |
| 1758 | 1828 | if (checkSession('post', '', false) == '' && validateToken('admin-te-' . md5($_GET['th'] . '-' . $_REQUEST['filename']), 'post', false) == true) |
| 1759 | 1829 | { |
| 1760 | - if (is_array($_POST['entire_file'])) |
|
| 1761 | - $_POST['entire_file'] = implode("\n", $_POST['entire_file']); |
|
| 1830 | + if (is_array($_POST['entire_file'])) { |
|
| 1831 | + $_POST['entire_file'] = implode("\n", $_POST['entire_file']); |
|
| 1832 | + } |
|
| 1762 | 1833 | |
| 1763 | 1834 | $_POST['entire_file'] = rtrim(strtr($_POST['entire_file'], array("\r" => '', ' ' => "\t"))); |
| 1764 | 1835 | |
@@ -1770,10 +1841,11 @@ discard block |
||
| 1770 | 1841 | fclose($fp); |
| 1771 | 1842 | |
| 1772 | 1843 | $error = @file_get_contents($currentTheme['theme_url'] . '/tmp_' . session_id() . '.php'); |
| 1773 | - if (preg_match('~ <b>(\d+)</b><br( /)?' . '>$~i', $error) != 0) |
|
| 1774 | - $error_file = $currentTheme['theme_dir'] . '/tmp_' . session_id() . '.php'; |
|
| 1775 | - else |
|
| 1776 | - unlink($currentTheme['theme_dir'] . '/tmp_' . session_id() . '.php'); |
|
| 1844 | + if (preg_match('~ <b>(\d+)</b><br( /)?' . '>$~i', $error) != 0) { |
|
| 1845 | + $error_file = $currentTheme['theme_dir'] . '/tmp_' . session_id() . '.php'; |
|
| 1846 | + } else { |
|
| 1847 | + unlink($currentTheme['theme_dir'] . '/tmp_' . session_id() . '.php'); |
|
| 1848 | + } |
|
| 1777 | 1849 | } |
| 1778 | 1850 | |
| 1779 | 1851 | if (!isset($error_file)) |
@@ -1794,10 +1866,11 @@ discard block |
||
| 1794 | 1866 | $context['sub_template'] = 'edit_file'; |
| 1795 | 1867 | |
| 1796 | 1868 | // Recycle the submitted data. |
| 1797 | - if (is_array($_POST['entire_file'])) |
|
| 1798 | - $context['entire_file'] = $smcFunc['htmlspecialchars'](implode("\n", $_POST['entire_file'])); |
|
| 1799 | - else |
|
| 1800 | - $context['entire_file'] = $smcFunc['htmlspecialchars']($_POST['entire_file']); |
|
| 1869 | + if (is_array($_POST['entire_file'])) { |
|
| 1870 | + $context['entire_file'] = $smcFunc['htmlspecialchars'](implode("\n", $_POST['entire_file'])); |
|
| 1871 | + } else { |
|
| 1872 | + $context['entire_file'] = $smcFunc['htmlspecialchars']($_POST['entire_file']); |
|
| 1873 | + } |
|
| 1801 | 1874 | |
| 1802 | 1875 | $context['edit_filename'] = $smcFunc['htmlspecialchars']($_POST['filename']); |
| 1803 | 1876 | |
@@ -1820,17 +1893,17 @@ discard block |
||
| 1820 | 1893 | $context['sub_template'] = 'edit_style'; |
| 1821 | 1894 | |
| 1822 | 1895 | $context['entire_file'] = $smcFunc['htmlspecialchars'](strtr(file_get_contents($currentTheme['theme_dir'] . '/' . $_REQUEST['filename']), array("\t" => ' '))); |
| 1823 | - } |
|
| 1824 | - elseif (substr($_REQUEST['filename'], -13) == '.template.php') |
|
| 1896 | + } elseif (substr($_REQUEST['filename'], -13) == '.template.php') |
|
| 1825 | 1897 | { |
| 1826 | 1898 | $context['sub_template'] = 'edit_template'; |
| 1827 | 1899 | |
| 1828 | - if (!isset($error_file)) |
|
| 1829 | - $file_data = file($currentTheme['theme_dir'] . '/' . $_REQUEST['filename']); |
|
| 1830 | - else |
|
| 1900 | + if (!isset($error_file)) { |
|
| 1901 | + $file_data = file($currentTheme['theme_dir'] . '/' . $_REQUEST['filename']); |
|
| 1902 | + } else |
|
| 1831 | 1903 | { |
| 1832 | - if (preg_match('~(<b>.+?</b>:.+?<b>).+?(</b>.+?<b>\d+</b>)<br( /)?' . '>$~i', $error, $match) != 0) |
|
| 1833 | - $context['parse_error'] = $match[1] . $_REQUEST['filename'] . $match[2]; |
|
| 1904 | + if (preg_match('~(<b>.+?</b>:.+?<b>).+?(</b>.+?<b>\d+</b>)<br( /)?' . '>$~i', $error, $match) != 0) { |
|
| 1905 | + $context['parse_error'] = $match[1] . $_REQUEST['filename'] . $match[2]; |
|
| 1906 | + } |
|
| 1834 | 1907 | $file_data = file($error_file); |
| 1835 | 1908 | unlink($error_file); |
| 1836 | 1909 | } |
@@ -1844,8 +1917,9 @@ discard block |
||
| 1844 | 1917 | // Try to format the functions a little nicer... |
| 1845 | 1918 | $context['file_parts'][$j]['data'] = trim($context['file_parts'][$j]['data']) . "\n"; |
| 1846 | 1919 | |
| 1847 | - if (empty($context['file_parts'][$j]['lines'])) |
|
| 1848 | - unset($context['file_parts'][$j]); |
|
| 1920 | + if (empty($context['file_parts'][$j]['lines'])) { |
|
| 1921 | + unset($context['file_parts'][$j]); |
|
| 1922 | + } |
|
| 1849 | 1923 | $context['file_parts'][++$j] = array('lines' => 0, 'line' => $i + 1, 'data' => ''); |
| 1850 | 1924 | } |
| 1851 | 1925 | |
@@ -1854,8 +1928,7 @@ discard block |
||
| 1854 | 1928 | } |
| 1855 | 1929 | |
| 1856 | 1930 | $context['entire_file'] = $smcFunc['htmlspecialchars'](strtr(implode('', $file_data), array("\t" => ' '))); |
| 1857 | - } |
|
| 1858 | - else |
|
| 1931 | + } else |
|
| 1859 | 1932 | { |
| 1860 | 1933 | $context['sub_template'] = 'edit_file'; |
| 1861 | 1934 | |
@@ -1881,8 +1954,9 @@ discard block |
||
| 1881 | 1954 | |
| 1882 | 1955 | $_GET['th'] = isset($_GET['th']) ? (int) $_GET['th'] : (int) $_GET['id']; |
| 1883 | 1956 | |
| 1884 | - if (empty($_GET['th'])) |
|
| 1885 | - fatal_lang_error('theme_install_invalid_id'); |
|
| 1957 | + if (empty($_GET['th'])) { |
|
| 1958 | + fatal_lang_error('theme_install_invalid_id'); |
|
| 1959 | + } |
|
| 1886 | 1960 | |
| 1887 | 1961 | // Get the theme info. |
| 1888 | 1962 | $theme = get_single_theme($_GET['th']); |
@@ -1890,25 +1964,24 @@ discard block |
||
| 1890 | 1964 | |
| 1891 | 1965 | if (isset($_REQUEST['template']) && preg_match('~[\./\\\\:\0]~', $_REQUEST['template']) == 0) |
| 1892 | 1966 | { |
| 1893 | - if (file_exists($settings['default_theme_dir'] . '/' . $_REQUEST['template'] . '.template.php')) |
|
| 1894 | - $filename = $settings['default_theme_dir'] . '/' . $_REQUEST['template'] . '.template.php'; |
|
| 1895 | - |
|
| 1896 | - else |
|
| 1897 | - fatal_lang_error('no_access', false); |
|
| 1967 | + if (file_exists($settings['default_theme_dir'] . '/' . $_REQUEST['template'] . '.template.php')) { |
|
| 1968 | + $filename = $settings['default_theme_dir'] . '/' . $_REQUEST['template'] . '.template.php'; |
|
| 1969 | + } else { |
|
| 1970 | + fatal_lang_error('no_access', false); |
|
| 1971 | + } |
|
| 1898 | 1972 | |
| 1899 | 1973 | $fp = fopen($theme['theme_dir'] . '/' . $_REQUEST['template'] . '.template.php', 'w'); |
| 1900 | 1974 | fwrite($fp, file_get_contents($filename)); |
| 1901 | 1975 | fclose($fp); |
| 1902 | 1976 | |
| 1903 | 1977 | redirectexit('action=admin;area=theme;th=' . $context['theme_id'] . ';' . $context['session_var'] . '=' . $context['session_id'] . ';sa=copy'); |
| 1904 | - } |
|
| 1905 | - elseif (isset($_REQUEST['lang_file']) && preg_match('~^[^\./\\\\:\0]\.[^\./\\\\:\0]$~', $_REQUEST['lang_file']) != 0) |
|
| 1978 | + } elseif (isset($_REQUEST['lang_file']) && preg_match('~^[^\./\\\\:\0]\.[^\./\\\\:\0]$~', $_REQUEST['lang_file']) != 0) |
|
| 1906 | 1979 | { |
| 1907 | - if (file_exists($settings['default_theme_dir'] . '/languages/' . $_REQUEST['template'] . '.php')) |
|
| 1908 | - $filename = $settings['default_theme_dir'] . '/languages/' . $_REQUEST['template'] . '.php'; |
|
| 1909 | - |
|
| 1910 | - else |
|
| 1911 | - fatal_lang_error('no_access', false); |
|
| 1980 | + if (file_exists($settings['default_theme_dir'] . '/languages/' . $_REQUEST['template'] . '.php')) { |
|
| 1981 | + $filename = $settings['default_theme_dir'] . '/languages/' . $_REQUEST['template'] . '.php'; |
|
| 1982 | + } else { |
|
| 1983 | + fatal_lang_error('no_access', false); |
|
| 1984 | + } |
|
| 1912 | 1985 | |
| 1913 | 1986 | $fp = fopen($theme['theme_dir'] . '/languages/' . $_REQUEST['lang_file'] . '.php', 'w'); |
| 1914 | 1987 | fwrite($fp, file_get_contents($filename)); |
@@ -1923,16 +1996,18 @@ discard block |
||
| 1923 | 1996 | $dir = dir($settings['default_theme_dir']); |
| 1924 | 1997 | while ($entry = $dir->read()) |
| 1925 | 1998 | { |
| 1926 | - if (substr($entry, -13) == '.template.php') |
|
| 1927 | - $templates[] = substr($entry, 0, -13); |
|
| 1999 | + if (substr($entry, -13) == '.template.php') { |
|
| 2000 | + $templates[] = substr($entry, 0, -13); |
|
| 2001 | + } |
|
| 1928 | 2002 | } |
| 1929 | 2003 | $dir->close(); |
| 1930 | 2004 | |
| 1931 | 2005 | $dir = dir($settings['default_theme_dir'] . '/languages'); |
| 1932 | 2006 | while ($entry = $dir->read()) |
| 1933 | 2007 | { |
| 1934 | - if (preg_match('~^([^\.]+\.[^\.]+)\.php$~', $entry, $matches)) |
|
| 1935 | - $lang_files[] = $matches[1]; |
|
| 2008 | + if (preg_match('~^([^\.]+\.[^\.]+)\.php$~', $entry, $matches)) { |
|
| 2009 | + $lang_files[] = $matches[1]; |
|
| 2010 | + } |
|
| 1936 | 2011 | } |
| 1937 | 2012 | $dir->close(); |
| 1938 | 2013 | |
@@ -1940,21 +2015,23 @@ discard block |
||
| 1940 | 2015 | natcasesort($lang_files); |
| 1941 | 2016 | |
| 1942 | 2017 | $context['available_templates'] = array(); |
| 1943 | - foreach ($templates as $template) |
|
| 1944 | - $context['available_templates'][$template] = array( |
|
| 2018 | + foreach ($templates as $template) { |
|
| 2019 | + $context['available_templates'][$template] = array( |
|
| 1945 | 2020 | 'filename' => $template . '.template.php', |
| 1946 | 2021 | 'value' => $template, |
| 1947 | 2022 | 'already_exists' => false, |
| 1948 | 2023 | 'can_copy' => is_writable($theme['theme_dir']), |
| 1949 | 2024 | ); |
| 2025 | + } |
|
| 1950 | 2026 | $context['available_language_files'] = array(); |
| 1951 | - foreach ($lang_files as $file) |
|
| 1952 | - $context['available_language_files'][$file] = array( |
|
| 2027 | + foreach ($lang_files as $file) { |
|
| 2028 | + $context['available_language_files'][$file] = array( |
|
| 1953 | 2029 | 'filename' => $file . '.php', |
| 1954 | 2030 | 'value' => $file, |
| 1955 | 2031 | 'already_exists' => false, |
| 1956 | 2032 | 'can_copy' => file_exists($theme['theme_dir'] . '/languages') ? is_writable($theme['theme_dir'] . '/languages') : is_writable($theme['theme_dir']), |
| 1957 | 2033 | ); |
| 2034 | + } |
|
| 1958 | 2035 | |
| 1959 | 2036 | $dir = dir($theme['theme_dir']); |
| 1960 | 2037 | while ($entry = $dir->read()) |
@@ -645,12 +645,12 @@ |
||
| 645 | 645 | </dd>'; |
| 646 | 646 | } |
| 647 | 647 | // A Textarea? |
| 648 | - elseif ($setting['type'] == 'textarea') |
|
| 648 | + elseif ($setting['type'] == 'textarea') |
|
| 649 | 649 | { |
| 650 | 650 | echo ' |
| 651 | 651 | <dd> |
| 652 | 652 | <textarea rows="4" style="width: 95%;" cols="40" name="', !empty($setting['default']) ? 'default_' : '', 'options[', $setting['id'], ']" id="', $setting['id'], '">', $setting['value'], '</textarea>'; |
| 653 | - echo ' |
|
| 653 | + echo ' |
|
| 654 | 654 | </dd>'; |
| 655 | 655 | } |
| 656 | 656 | // A regular input box, then? |
@@ -54,9 +54,10 @@ discard block |
||
| 54 | 54 | <dd> |
| 55 | 55 | <div id="known_themes_list">'; |
| 56 | 56 | |
| 57 | - foreach ($context['themes'] as $theme) |
|
| 58 | - echo ' |
|
| 57 | + foreach ($context['themes'] as $theme) { |
|
| 58 | + echo ' |
|
| 59 | 59 | <label for="options-known_themes_', $theme['id'], '"><input type="checkbox" name="options[known_themes][]" id="options-known_themes_', $theme['id'], '" value="', $theme['id'], '"', $theme['known'] ? ' checked' : '', ' class="input_check"> ', $theme['name'], '</label><br>'; |
| 60 | + } |
|
| 60 | 61 | |
| 61 | 62 | echo ' |
| 62 | 63 | </div> |
@@ -73,9 +74,10 @@ discard block |
||
| 73 | 74 | <select name="options[theme_guests]" id="theme_guests">'; |
| 74 | 75 | |
| 75 | 76 | // Put an option for each theme in the select box. |
| 76 | - foreach ($context['themes'] as $theme) |
|
| 77 | - echo ' |
|
| 77 | + foreach ($context['themes'] as $theme) { |
|
| 78 | + echo ' |
|
| 78 | 79 | <option value="', $theme['id'], '"', $modSettings['theme_guests'] == $theme['id'] ? ' selected' : '', '>', $theme['name'], '</option>'; |
| 80 | + } |
|
| 79 | 81 | |
| 80 | 82 | echo ' |
| 81 | 83 | </select> |
@@ -90,9 +92,10 @@ discard block |
||
| 90 | 92 | <option value="0">', $txt['theme_forum_default'], '</option>'; |
| 91 | 93 | |
| 92 | 94 | // Same thing, this time for changing the theme of everyone. |
| 93 | - foreach ($context['themes'] as $theme) |
|
| 94 | - echo ' |
|
| 95 | + foreach ($context['themes'] as $theme) { |
|
| 96 | + echo ' |
|
| 95 | 97 | <option value="', $theme['id'], '">', $theme['name'], '</option>'; |
| 98 | + } |
|
| 96 | 99 | |
| 97 | 100 | echo ' |
| 98 | 101 | </select> |
@@ -189,11 +192,12 @@ discard block |
||
| 189 | 192 | global $context, $scripturl, $txt; |
| 190 | 193 | |
| 191 | 194 | // Show a nice confirmation message. |
| 192 | - if (isset($_GET['done'])) |
|
| 193 | - echo ' |
|
| 195 | + if (isset($_GET['done'])) { |
|
| 196 | + echo ' |
|
| 194 | 197 | <div class="infobox"> |
| 195 | 198 | ', $txt['theme_confirmed_' . $_GET['done']], ' |
| 196 | 199 | </div>'; |
| 200 | + } |
|
| 197 | 201 | |
| 198 | 202 | echo ' |
| 199 | 203 | <div id="admincenter">'; |
@@ -356,11 +360,12 @@ discard block |
||
| 356 | 360 | if (empty($setting) || !is_array($setting)) |
| 357 | 361 | { |
| 358 | 362 | // Insert a separator (unless this is the first item in the list) |
| 359 | - if ($i !== $first_option_key) |
|
| 360 | - echo ' |
|
| 363 | + if ($i !== $first_option_key) { |
|
| 364 | + echo ' |
|
| 361 | 365 | </dl> |
| 362 | 366 | <hr> |
| 363 | 367 | <dl class="settings">'; |
| 368 | + } |
|
| 364 | 369 | |
| 365 | 370 | // Should we give a name to this section? |
| 366 | 371 | if (is_string($setting) && !empty($setting)) |
@@ -368,9 +373,9 @@ discard block |
||
| 368 | 373 | $titled_section = true; |
| 369 | 374 | echo ' |
| 370 | 375 | <dt><b>' . $setting . '</b></dt><dd></dd>'; |
| 376 | + } else { |
|
| 377 | + $titled_section = false; |
|
| 371 | 378 | } |
| 372 | - else |
|
| 373 | - $titled_section = false; |
|
| 374 | 379 | |
| 375 | 380 | continue; |
| 376 | 381 | } |
@@ -379,19 +384,21 @@ discard block |
||
| 379 | 384 | <dt ', $context['theme_options_reset'] ? 'style="width:50%"' : '', '>'; |
| 380 | 385 | |
| 381 | 386 | // Show the change option box ? |
| 382 | - if ($context['theme_options_reset']) |
|
| 383 | - echo ' |
|
| 387 | + if ($context['theme_options_reset']) { |
|
| 388 | + echo ' |
|
| 384 | 389 | <span class="floatleft"><select name="', !empty($setting['default']) ? 'default_' : '', 'options_master[', $setting['id'], ']" onchange="this.form.options_', $setting['id'], '.disabled = this.selectedIndex != 1;"> |
| 385 | 390 | <option value="0" selected>', $txt['themeadmin_reset_options_none'], '</option> |
| 386 | 391 | <option value="1">', $txt['themeadmin_reset_options_change'], '</option> |
| 387 | 392 | <option value="2">', $txt['themeadmin_reset_options_default'], '</option> |
| 388 | 393 | </select> </span>'; |
| 394 | + } |
|
| 389 | 395 | |
| 390 | 396 | echo ' |
| 391 | 397 | <label for="options_', $setting['id'], '">', !$titled_section ? '<b>' : '', $setting['label'], !$titled_section ? '</b>' : '', '</label>'; |
| 392 | - if (isset($setting['description'])) |
|
| 393 | - echo ' |
|
| 398 | + if (isset($setting['description'])) { |
|
| 399 | + echo ' |
|
| 394 | 400 | <br><span class="smalltext">', $setting['description'], '</span>'; |
| 401 | + } |
|
| 395 | 402 | echo ' |
| 396 | 403 | </dt>'; |
| 397 | 404 | |
@@ -433,13 +440,11 @@ discard block |
||
| 433 | 440 | |
| 434 | 441 | echo ' |
| 435 | 442 | <input type="number"', $min . $max . $step; |
| 436 | - } |
|
| 437 | - else if (isset($setting['type']) && $setting['type'] == 'url') |
|
| 443 | + } else if (isset($setting['type']) && $setting['type'] == 'url') |
|
| 438 | 444 | { |
| 439 | 445 | echo' |
| 440 | 446 | <input type="url"'; |
| 441 | - } |
|
| 442 | - else |
|
| 447 | + } else |
|
| 443 | 448 | { |
| 444 | 449 | echo ' |
| 445 | 450 | <input type="text"'; |
@@ -483,8 +488,8 @@ discard block |
||
| 483 | 488 | <br>'; |
| 484 | 489 | |
| 485 | 490 | // @todo Why can't I edit the default theme popup. |
| 486 | - if ($context['theme_settings']['theme_id'] != 1) |
|
| 487 | - echo ' |
|
| 491 | + if ($context['theme_settings']['theme_id'] != 1) { |
|
| 492 | + echo ' |
|
| 488 | 493 | <div class="cat_bar"> |
| 489 | 494 | <h3 class="catbg config_hd"> |
| 490 | 495 | ', $txt['theme_edit'], ' |
@@ -500,6 +505,7 @@ discard block |
||
| 500 | 505 | </li> |
| 501 | 506 | </ul> |
| 502 | 507 | </div>'; |
| 508 | + } |
|
| 503 | 509 | |
| 504 | 510 | echo ' |
| 505 | 511 | <div class="cat_bar"> |
@@ -553,9 +559,10 @@ discard block |
||
| 553 | 559 | <dd> |
| 554 | 560 | <select id="variant" name="options[default_variant]" onchange="changeVariant(this.value)">'; |
| 555 | 561 | |
| 556 | - foreach ($context['theme_variants'] as $key => $variant) |
|
| 557 | - echo ' |
|
| 562 | + foreach ($context['theme_variants'] as $key => $variant) { |
|
| 563 | + echo ' |
|
| 558 | 564 | <option value="', $key, '"', $context['default_variant'] == $key ? ' selected' : '', '>', $variant['label'], '</option>'; |
| 565 | + } |
|
| 559 | 566 | |
| 560 | 567 | echo ' |
| 561 | 568 | </select> |
@@ -590,11 +597,12 @@ discard block |
||
| 590 | 597 | if (empty($setting) || !is_array($setting)) |
| 591 | 598 | { |
| 592 | 599 | // We don't need a separator before the first list element |
| 593 | - if ($i !== $first_setting_key) |
|
| 594 | - echo ' |
|
| 600 | + if ($i !== $first_setting_key) { |
|
| 601 | + echo ' |
|
| 595 | 602 | </dl> |
| 596 | 603 | <hr> |
| 597 | 604 | <dl class="settings">'; |
| 605 | + } |
|
| 598 | 606 | |
| 599 | 607 | // Add a fake heading? |
| 600 | 608 | if (is_string($setting) && !empty($setting)) |
@@ -602,9 +610,9 @@ discard block |
||
| 602 | 610 | $titled_section = true; |
| 603 | 611 | echo ' |
| 604 | 612 | <dt><b>' . $setting . '</b></dt><dd></dd>'; |
| 613 | + } else { |
|
| 614 | + $titled_section = false; |
|
| 605 | 615 | } |
| 606 | - else |
|
| 607 | - $titled_section = false; |
|
| 608 | 616 | |
| 609 | 617 | continue; |
| 610 | 618 | } |
@@ -613,9 +621,10 @@ discard block |
||
| 613 | 621 | <dt> |
| 614 | 622 | <label for="', $setting['id'], '">', !$titled_section ? '<b>' : '', $setting['label'], !$titled_section ? '</b>' : '', '</label>:'; |
| 615 | 623 | |
| 616 | - if (isset($setting['description'])) |
|
| 617 | - echo '<br> |
|
| 624 | + if (isset($setting['description'])) { |
|
| 625 | + echo '<br> |
|
| 618 | 626 | <span class="smalltext">', $setting['description'], '</span>'; |
| 627 | + } |
|
| 619 | 628 | |
| 620 | 629 | echo ' |
| 621 | 630 | </dt>'; |
@@ -636,9 +645,10 @@ discard block |
||
| 636 | 645 | <dd> |
| 637 | 646 | <select name="', !empty($setting['default']) ? 'default_' : '', 'options[', $setting['id'], ']" id="', $setting['id'], '">'; |
| 638 | 647 | |
| 639 | - foreach ($setting['options'] as $value => $label) |
|
| 640 | - echo ' |
|
| 648 | + foreach ($setting['options'] as $value => $label) { |
|
| 649 | + echo ' |
|
| 641 | 650 | <option value="', $value, '"', $value == $setting['value'] ? ' selected' : '', '>', $label, '</option>'; |
| 651 | + } |
|
| 642 | 652 | |
| 643 | 653 | echo ' |
| 644 | 654 | </select> |
@@ -667,13 +677,11 @@ discard block |
||
| 667 | 677 | |
| 668 | 678 | echo ' |
| 669 | 679 | <input type="number"', $min . $max . $step; |
| 670 | - } |
|
| 671 | - else if (isset($setting['type']) && $setting['type'] == 'url') |
|
| 680 | + } else if (isset($setting['type']) && $setting['type'] == 'url') |
|
| 672 | 681 | { |
| 673 | 682 | echo' |
| 674 | 683 | <input type="url"'; |
| 675 | - } |
|
| 676 | - else |
|
| 684 | + } else |
|
| 677 | 685 | { |
| 678 | 686 | echo ' |
| 679 | 687 | <input type="text"'; |
@@ -826,21 +834,23 @@ discard block |
||
| 826 | 834 | <div class="windowbg">'; |
| 827 | 835 | |
| 828 | 836 | // Oops! there was an error :( |
| 829 | - if (!empty($context['error_message'])) |
|
| 830 | - echo ' |
|
| 837 | + if (!empty($context['error_message'])) { |
|
| 838 | + echo ' |
|
| 831 | 839 | <p> |
| 832 | 840 | ', $context['error_message'], ' |
| 833 | 841 | </p>'; |
| 842 | + } |
|
| 834 | 843 | |
| 835 | 844 | // Not much to show except a link back... |
| 836 | - else |
|
| 837 | - echo ' |
|
| 845 | + else { |
|
| 846 | + echo ' |
|
| 838 | 847 | <p> |
| 839 | 848 | <a href="', $scripturl, '?action=admin;area=theme;sa=list;th=', $context['installed_theme']['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $context['installed_theme']['name'], '</a> ', $txt['theme_' . (isset($context['installed_theme']['updated']) ? 'updated' : 'installed') . '_message'], ' |
| 840 | 849 | </p> |
| 841 | 850 | <p> |
| 842 | 851 | <a href="', $scripturl, '?action=admin;area=theme;sa=admin;', $context['session_var'], '=', $context['session_id'], '">', $txt['back'], '</a> |
| 843 | 852 | </p>'; |
| 853 | + } |
|
| 844 | 854 | |
| 845 | 855 | echo ' |
| 846 | 856 | </div> |
@@ -907,10 +917,11 @@ discard block |
||
| 907 | 917 | <span class="floatleft">', $template['filename'], $template['already_exists'] ? ' <span class="error">(' . $txt['themeadmin_edit_exists'] . ')</span>' : '', '</span> |
| 908 | 918 | <span class="floatright">'; |
| 909 | 919 | |
| 910 | - if ($template['can_copy']) |
|
| 911 | - echo '<a href="', $scripturl, '?action=admin;area=theme;th=', $context['theme_id'], ';', $context['session_var'], '=', $context['session_id'], ';sa=copy;template=', $template['value'], '" data-confirm="', $template['already_exists'] ? $txt['themeadmin_edit_overwrite_confirm'] : $txt['themeadmin_edit_copy_confirm'], '" class="you_sure">', $txt['themeadmin_edit_do_copy'], '</a>'; |
|
| 912 | - else |
|
| 913 | - echo $txt['themeadmin_edit_no_copy']; |
|
| 920 | + if ($template['can_copy']) { |
|
| 921 | + echo '<a href="', $scripturl, '?action=admin;area=theme;th=', $context['theme_id'], ';', $context['session_var'], '=', $context['session_id'], ';sa=copy;template=', $template['value'], '" data-confirm="', $template['already_exists'] ? $txt['themeadmin_edit_overwrite_confirm'] : $txt['themeadmin_edit_copy_confirm'], '" class="you_sure">', $txt['themeadmin_edit_do_copy'], '</a>'; |
|
| 922 | + } else { |
|
| 923 | + echo $txt['themeadmin_edit_no_copy']; |
|
| 924 | + } |
|
| 914 | 925 | |
| 915 | 926 | echo ' |
| 916 | 927 | </span> |
@@ -933,11 +944,12 @@ discard block |
||
| 933 | 944 | echo ' |
| 934 | 945 | <div id="admincenter">'; |
| 935 | 946 | |
| 936 | - if (!empty($context['browse_title'])) |
|
| 937 | - echo ' |
|
| 947 | + if (!empty($context['browse_title'])) { |
|
| 948 | + echo ' |
|
| 938 | 949 | <div class="cat_bar"> |
| 939 | 950 | <h3 class="catbg">', $context['browse_title'], '</h3> |
| 940 | 951 | </div>'; |
| 952 | + } |
|
| 941 | 953 | |
| 942 | 954 | echo ' |
| 943 | 955 | <table class="table_grid tborder"> |
@@ -957,14 +969,13 @@ discard block |
||
| 957 | 969 | <tr class="windowbg"> |
| 958 | 970 | <td>'; |
| 959 | 971 | |
| 960 | - if ($file['is_editable']) |
|
| 961 | - echo '<a href="', $file['href'], '"', $file['is_template'] ? ' style="font-weight: bold;"' : '', '>', $file['filename'], '</a>'; |
|
| 962 | - |
|
| 963 | - elseif ($file['is_directory']) |
|
| 964 | - echo '<a href="', $file['href'], '" class="is_directory"><span class="generic_icons folder"></span>', $file['filename'], '</a>'; |
|
| 965 | - |
|
| 966 | - else |
|
| 967 | - echo $file['filename']; |
|
| 972 | + if ($file['is_editable']) { |
|
| 973 | + echo '<a href="', $file['href'], '"', $file['is_template'] ? ' style="font-weight: bold;"' : '', '>', $file['filename'], '</a>'; |
|
| 974 | + } elseif ($file['is_directory']) { |
|
| 975 | + echo '<a href="', $file['href'], '" class="is_directory"><span class="generic_icons folder"></span>', $file['filename'], '</a>'; |
|
| 976 | + } else { |
|
| 977 | + echo $file['filename']; |
|
| 978 | + } |
|
| 968 | 979 | |
| 969 | 980 | echo ' |
| 970 | 981 | </td> |
@@ -986,11 +997,12 @@ discard block |
||
| 986 | 997 | { |
| 987 | 998 | global $context, $settings, $scripturl, $txt; |
| 988 | 999 | |
| 989 | - if ($context['session_error']) |
|
| 990 | - echo ' |
|
| 1000 | + if ($context['session_error']) { |
|
| 1001 | + echo ' |
|
| 991 | 1002 | <div class="errorbox"> |
| 992 | 1003 | ', $txt['error_session_timeout'], ' |
| 993 | 1004 | </div>'; |
| 1005 | + } |
|
| 994 | 1006 | |
| 995 | 1007 | // From now on no one can complain that editing css is difficult. If you disagree, go to www.w3schools.com. |
| 996 | 1008 | echo ' |
@@ -1053,17 +1065,18 @@ discard block |
||
| 1053 | 1065 | try |
| 1054 | 1066 | { |
| 1055 | 1067 | '; |
| 1056 | - if (isBrowser('is_ie')) |
|
| 1057 | - echo ' |
|
| 1068 | + if (isBrowser('is_ie')) { |
|
| 1069 | + echo ' |
|
| 1058 | 1070 | var sheets = frames["css_preview_box"].document.styleSheets; |
| 1059 | 1071 | for (var j = 0; j < sheets.length; j++) |
| 1060 | 1072 | { |
| 1061 | 1073 | if (sheets[j].id == "css_preview_box") |
| 1062 | 1074 | sheets[j].cssText = document.forms.stylesheetForm.entire_file.value; |
| 1063 | 1075 | }'; |
| 1064 | - else |
|
| 1065 | - echo ' |
|
| 1076 | + } else { |
|
| 1077 | + echo ' |
|
| 1066 | 1078 | setInnerHTML(frames["css_preview_box"].document.getElementById("css_preview_sheet"), document.forms.stylesheetForm.entire_file.value);'; |
| 1079 | + } |
|
| 1067 | 1080 | echo ' |
| 1068 | 1081 | } |
| 1069 | 1082 | catch (e) |
@@ -1115,9 +1128,10 @@ discard block |
||
| 1115 | 1128 | </div> |
| 1116 | 1129 | <div class="windowbg">'; |
| 1117 | 1130 | |
| 1118 | - if (!$context['allow_save']) |
|
| 1119 | - echo ' |
|
| 1131 | + if (!$context['allow_save']) { |
|
| 1132 | + echo ' |
|
| 1120 | 1133 | ', $txt['theme_edit_no_save'], ': ', $context['allow_save_filename'], '<br>'; |
| 1134 | + } |
|
| 1121 | 1135 | |
| 1122 | 1136 | echo ' |
| 1123 | 1137 | <textarea name="entire_file" cols="80" rows="20" style="width: 96%; font-family: monospace; margin-top: 1ex; white-space: pre;" onkeyup="setPreviewTimeout();" onchange="refreshPreview(true);">', $context['entire_file'], '</textarea><br> |
@@ -1130,9 +1144,10 @@ discard block |
||
| 1130 | 1144 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">'; |
| 1131 | 1145 | |
| 1132 | 1146 | // Hopefully it exists. |
| 1133 | - if (isset($context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token'])) |
|
| 1134 | - echo ' |
|
| 1147 | + if (isset($context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token'])) { |
|
| 1148 | + echo ' |
|
| 1135 | 1149 | <input type="hidden" name="', $context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token_var'], '" value="', $context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token'], '">'; |
| 1150 | + } |
|
| 1136 | 1151 | |
| 1137 | 1152 | echo ' |
| 1138 | 1153 | </form> |
@@ -1146,18 +1161,20 @@ discard block |
||
| 1146 | 1161 | { |
| 1147 | 1162 | global $context, $scripturl, $txt; |
| 1148 | 1163 | |
| 1149 | - if ($context['session_error']) |
|
| 1150 | - echo ' |
|
| 1164 | + if ($context['session_error']) { |
|
| 1165 | + echo ' |
|
| 1151 | 1166 | <div class="errorbox"> |
| 1152 | 1167 | ', $txt['error_session_timeout'], ' |
| 1153 | 1168 | </div>'; |
| 1169 | + } |
|
| 1154 | 1170 | |
| 1155 | - if (isset($context['parse_error'])) |
|
| 1156 | - echo ' |
|
| 1171 | + if (isset($context['parse_error'])) { |
|
| 1172 | + echo ' |
|
| 1157 | 1173 | <div class="errorbox"> |
| 1158 | 1174 | ', $txt['themeadmin_edit_error'], ' |
| 1159 | 1175 | <div><pre>', $context['parse_error'], '</pre></div> |
| 1160 | 1176 | </div>'; |
| 1177 | + } |
|
| 1161 | 1178 | |
| 1162 | 1179 | // Just show a big box.... gray out the Save button if it's not saveable... (ie. not 777.) |
| 1163 | 1180 | echo ' |
@@ -1168,16 +1185,18 @@ discard block |
||
| 1168 | 1185 | </div> |
| 1169 | 1186 | <div class="windowbg">'; |
| 1170 | 1187 | |
| 1171 | - if (!$context['allow_save']) |
|
| 1172 | - echo ' |
|
| 1188 | + if (!$context['allow_save']) { |
|
| 1189 | + echo ' |
|
| 1173 | 1190 | ', $txt['theme_edit_no_save'], ': ', $context['allow_save_filename'], '<br>'; |
| 1191 | + } |
|
| 1174 | 1192 | |
| 1175 | - foreach ($context['file_parts'] as $part) |
|
| 1176 | - echo ' |
|
| 1193 | + foreach ($context['file_parts'] as $part) { |
|
| 1194 | + echo ' |
|
| 1177 | 1195 | <label for="on_line', $part['line'], '">', $txt['themeadmin_edit_on_line'], ' ', $part['line'], '</label>:<br> |
| 1178 | 1196 | <div class="centertext"> |
| 1179 | 1197 | <textarea id="on_line', $part['line'], '" name="entire_file[]" cols="80" rows="', $part['lines'] > 14 ? '14' : $part['lines'], '" class="edit_file">', $part['data'], '</textarea> |
| 1180 | 1198 | </div>'; |
| 1199 | + } |
|
| 1181 | 1200 | |
| 1182 | 1201 | echo ' |
| 1183 | 1202 | <div class="padding righttext"> |
@@ -1186,9 +1205,10 @@ discard block |
||
| 1186 | 1205 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">'; |
| 1187 | 1206 | |
| 1188 | 1207 | // Hopefully it exists. |
| 1189 | - if (isset($context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token'])) |
|
| 1190 | - echo ' |
|
| 1208 | + if (isset($context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token'])) { |
|
| 1209 | + echo ' |
|
| 1191 | 1210 | <input type="hidden" name="', $context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token_var'], '" value="', $context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token'], '">'; |
| 1211 | + } |
|
| 1192 | 1212 | |
| 1193 | 1213 | echo ' |
| 1194 | 1214 | </div> |
@@ -1204,18 +1224,20 @@ discard block |
||
| 1204 | 1224 | { |
| 1205 | 1225 | global $context, $scripturl, $txt; |
| 1206 | 1226 | |
| 1207 | - if ($context['session_error']) |
|
| 1208 | - echo ' |
|
| 1227 | + if ($context['session_error']) { |
|
| 1228 | + echo ' |
|
| 1209 | 1229 | <div class="errorbox"> |
| 1210 | 1230 | ', $txt['error_session_timeout'], ' |
| 1211 | 1231 | </div>'; |
| 1232 | + } |
|
| 1212 | 1233 | |
| 1213 | 1234 | //Is this file writeable? |
| 1214 | - if (!$context['allow_save']) |
|
| 1215 | - echo ' |
|
| 1235 | + if (!$context['allow_save']) { |
|
| 1236 | + echo ' |
|
| 1216 | 1237 | <div class="errorbox"> |
| 1217 | 1238 | ', $txt['theme_edit_no_save'], ': ', $context['allow_save_filename'], ' |
| 1218 | 1239 | </div>'; |
| 1240 | + } |
|
| 1219 | 1241 | |
| 1220 | 1242 | // Just show a big box.... gray out the Save button if it's not saveable... (ie. not 777.) |
| 1221 | 1243 | echo ' |
@@ -1231,9 +1253,10 @@ discard block |
||
| 1231 | 1253 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">'; |
| 1232 | 1254 | |
| 1233 | 1255 | // Hopefully it exists. |
| 1234 | - if (isset($context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token'])) |
|
| 1235 | - echo ' |
|
| 1256 | + if (isset($context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token'])) { |
|
| 1257 | + echo ' |
|
| 1236 | 1258 | <input type="hidden" name="', $context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token_var'], '" value="', $context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token'], '">'; |
| 1259 | + } |
|
| 1237 | 1260 | |
| 1238 | 1261 | echo ' |
| 1239 | 1262 | </div> |
@@ -64,9 +64,10 @@ discard block |
||
| 64 | 64 | <strong>', $txt['administrators'], ':</strong> |
| 65 | 65 | ', implode(', ', $context['administrators']); |
| 66 | 66 | // If we have lots of admins... don't show them all. |
| 67 | - if (!empty($context['more_admins_link'])) |
|
| 68 | - echo ' |
|
| 67 | + if (!empty($context['more_admins_link'])) { |
|
| 68 | + echo ' |
|
| 69 | 69 | (', $context['more_admins_link'], ')'; |
| 70 | + } |
|
| 70 | 71 | |
| 71 | 72 | echo ' |
| 72 | 73 | </div> |
@@ -83,16 +84,18 @@ discard block |
||
| 83 | 84 | foreach ($area['areas'] as $item_id => $item) |
| 84 | 85 | { |
| 85 | 86 | // No point showing the 'home' page here, we're already on it! |
| 86 | - if ($area_id == 'forum' && $item_id == 'index') |
|
| 87 | - continue; |
|
| 87 | + if ($area_id == 'forum' && $item_id == 'index') { |
|
| 88 | + continue; |
|
| 89 | + } |
|
| 88 | 90 | |
| 89 | 91 | $url = isset($item['url']) ? $item['url'] : $scripturl . '?action=admin;area=' . $item_id . (!empty($context[$context['admin_menu_name']]['extra_parameters']) ? $context[$context['admin_menu_name']]['extra_parameters'] : ''); |
| 90 | - if (!empty($item['icon_file'])) |
|
| 91 | - echo ' |
|
| 92 | + if (!empty($item['icon_file'])) { |
|
| 93 | + echo ' |
|
| 92 | 94 | <a href="', $url, '" class="admin_group', !empty($item['inactive']) ? ' inactive' : '', '"><img class="large_admin_menu_icon_file" src="', $item['icon_file'], '" alt="">', $item['label'], '</a>'; |
| 93 | - else |
|
| 94 | - echo ' |
|
| 95 | + } else { |
|
| 96 | + echo ' |
|
| 95 | 97 | <a href="', $url, '"><span class="large_', $item['icon_class'], !empty($item['inactive']) ? ' inactive' : '', '"></span>', $item['label'], '</a>'; |
| 98 | + } |
|
| 96 | 99 | } |
| 97 | 100 | |
| 98 | 101 | echo ' |
@@ -103,10 +106,11 @@ discard block |
||
| 103 | 106 | </div>'; |
| 104 | 107 | |
| 105 | 108 | // The below functions include all the scripts needed from the simplemachines.org site. The language and format are passed for internationalization. |
| 106 | - if (empty($modSettings['disable_smf_js'])) |
|
| 107 | - echo ' |
|
| 109 | + if (empty($modSettings['disable_smf_js'])) { |
|
| 110 | + echo ' |
|
| 108 | 111 | <script src="', $scripturl, '?action=viewsmfile;filename=current-version.js"></script> |
| 109 | 112 | <script src="', $scripturl, '?action=viewsmfile;filename=latest-news.js"></script>'; |
| 113 | + } |
|
| 110 | 114 | |
| 111 | 115 | // This sets the announcements and current versions themselves ;). |
| 112 | 116 | echo ' |
@@ -185,9 +189,10 @@ discard block |
||
| 185 | 189 | <em>', $version['version'], '</em>'; |
| 186 | 190 | |
| 187 | 191 | // more details for this item, show them a link |
| 188 | - if ($context['can_admin'] && isset($version['more'])) |
|
| 189 | - echo |
|
| 192 | + if ($context['can_admin'] && isset($version['more'])) { |
|
| 193 | + echo |
|
| 190 | 194 | ' <a href="', $scripturl, $version['more'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['version_check_more'], '</a>'; |
| 195 | + } |
|
| 191 | 196 | echo ' |
| 192 | 197 | <br>'; |
| 193 | 198 | } |
@@ -218,20 +223,22 @@ discard block |
||
| 218 | 223 | |
| 219 | 224 | foreach ($context['credits'] as $section) |
| 220 | 225 | { |
| 221 | - if (isset($section['pretext'])) |
|
| 222 | - echo ' |
|
| 226 | + if (isset($section['pretext'])) { |
|
| 227 | + echo ' |
|
| 223 | 228 | <p>', $section['pretext'], '</p><hr>'; |
| 229 | + } |
|
| 224 | 230 | |
| 225 | 231 | echo ' |
| 226 | 232 | <dl>'; |
| 227 | 233 | |
| 228 | 234 | foreach ($section['groups'] as $group) |
| 229 | 235 | { |
| 230 | - if (isset($group['title'])) |
|
| 231 | - echo ' |
|
| 236 | + if (isset($group['title'])) { |
|
| 237 | + echo ' |
|
| 232 | 238 | <dt> |
| 233 | 239 | <strong>', $group['title'], ':</strong> |
| 234 | 240 | </dt>'; |
| 241 | + } |
|
| 235 | 242 | |
| 236 | 243 | echo ' |
| 237 | 244 | <dd>', implode(', ', $group['members']), '</dd>'; |
@@ -240,10 +247,11 @@ discard block |
||
| 240 | 247 | echo ' |
| 241 | 248 | </dl>'; |
| 242 | 249 | |
| 243 | - if (isset($section['posttext'])) |
|
| 244 | - echo ' |
|
| 250 | + if (isset($section['posttext'])) { |
|
| 251 | + echo ' |
|
| 245 | 252 | <hr> |
| 246 | 253 | <p>', $section['posttext'], '</p>'; |
| 254 | + } |
|
| 247 | 255 | } |
| 248 | 256 | |
| 249 | 257 | echo ' |
@@ -259,9 +267,10 @@ discard block |
||
| 259 | 267 | smfSupportVersions.forum = "', $context['forum_version'], '";'; |
| 260 | 268 | |
| 261 | 269 | // Don't worry, none of this is logged, it's just used to give information that might be of use. |
| 262 | - foreach ($context['current_versions'] as $variable => $version) |
|
| 263 | - echo ' |
|
| 270 | + foreach ($context['current_versions'] as $variable => $version) { |
|
| 271 | + echo ' |
|
| 264 | 272 | smfSupportVersions.', $variable, ' = "', $version['version'], '";'; |
| 273 | + } |
|
| 265 | 274 | |
| 266 | 275 | // Now we just have to include the script and wait ;). |
| 267 | 276 | echo ' |
@@ -358,8 +367,8 @@ discard block |
||
| 358 | 367 | <tbody>'; |
| 359 | 368 | |
| 360 | 369 | // Loop through every source file displaying its version - using javascript. |
| 361 | - foreach ($context['file_versions'] as $filename => $version) |
|
| 362 | - echo ' |
|
| 370 | + foreach ($context['file_versions'] as $filename => $version) { |
|
| 371 | + echo ' |
|
| 363 | 372 | <tr class="windowbg"> |
| 364 | 373 | <td class="half_table"> |
| 365 | 374 | ', $filename, ' |
@@ -371,6 +380,7 @@ discard block |
||
| 371 | 380 | <em id="currentSources', $filename, '">??</em> |
| 372 | 381 | </td> |
| 373 | 382 | </tr>'; |
| 383 | + } |
|
| 374 | 384 | |
| 375 | 385 | // Default template files. |
| 376 | 386 | echo ' |
@@ -396,8 +406,8 @@ discard block |
||
| 396 | 406 | <table id="Default" class="table_grid"> |
| 397 | 407 | <tbody>'; |
| 398 | 408 | |
| 399 | - foreach ($context['default_template_versions'] as $filename => $version) |
|
| 400 | - echo ' |
|
| 409 | + foreach ($context['default_template_versions'] as $filename => $version) { |
|
| 410 | + echo ' |
|
| 401 | 411 | <tr class="windowbg"> |
| 402 | 412 | <td class="half_table"> |
| 403 | 413 | ', $filename, ' |
@@ -409,6 +419,7 @@ discard block |
||
| 409 | 419 | <em id="currentDefault', $filename, '">??</em> |
| 410 | 420 | </td> |
| 411 | 421 | </tr>'; |
| 422 | + } |
|
| 412 | 423 | |
| 413 | 424 | // Now the language files... |
| 414 | 425 | echo ' |
@@ -436,8 +447,8 @@ discard block |
||
| 436 | 447 | |
| 437 | 448 | foreach ($context['default_language_versions'] as $language => $files) |
| 438 | 449 | { |
| 439 | - foreach ($files as $filename => $version) |
|
| 440 | - echo ' |
|
| 450 | + foreach ($files as $filename => $version) { |
|
| 451 | + echo ' |
|
| 441 | 452 | <tr class="windowbg"> |
| 442 | 453 | <td class="half_table"> |
| 443 | 454 | ', $filename, '.<em>', $language, '</em>.php |
@@ -449,6 +460,7 @@ discard block |
||
| 449 | 460 | <em id="current', $filename, '.', $language, '">??</em> |
| 450 | 461 | </td> |
| 451 | 462 | </tr>'; |
| 463 | + } |
|
| 452 | 464 | } |
| 453 | 465 | |
| 454 | 466 | echo ' |
@@ -478,8 +490,8 @@ discard block |
||
| 478 | 490 | <table id="Templates" class="table_grid"> |
| 479 | 491 | <tbody>'; |
| 480 | 492 | |
| 481 | - foreach ($context['template_versions'] as $filename => $version) |
|
| 482 | - echo ' |
|
| 493 | + foreach ($context['template_versions'] as $filename => $version) { |
|
| 494 | + echo ' |
|
| 483 | 495 | <tr class="windowbg"> |
| 484 | 496 | <td class="half_table"> |
| 485 | 497 | ', $filename, ' |
@@ -491,6 +503,7 @@ discard block |
||
| 491 | 503 | <em id="currentTemplates', $filename, '">??</em> |
| 492 | 504 | </td> |
| 493 | 505 | </tr>'; |
| 506 | + } |
|
| 494 | 507 | |
| 495 | 508 | echo ' |
| 496 | 509 | </tbody> |
@@ -520,8 +533,8 @@ discard block |
||
| 520 | 533 | <table id="Tasks" class="table_grid"> |
| 521 | 534 | <tbody>'; |
| 522 | 535 | |
| 523 | - foreach ($context['tasks_versions'] as $filename => $version) |
|
| 524 | - echo ' |
|
| 536 | + foreach ($context['tasks_versions'] as $filename => $version) { |
|
| 537 | + echo ' |
|
| 525 | 538 | <tr class="windowbg"> |
| 526 | 539 | <td class="half_table"> |
| 527 | 540 | ', $filename, ' |
@@ -533,6 +546,7 @@ discard block |
||
| 533 | 546 | <em id="currentTasks', $filename, '">??</em> |
| 534 | 547 | </td> |
| 535 | 548 | </tr>'; |
| 549 | + } |
|
| 536 | 550 | |
| 537 | 551 | echo ' |
| 538 | 552 | </tbody> |
@@ -574,9 +588,10 @@ discard block |
||
| 574 | 588 | { |
| 575 | 589 | global $context, $scripturl, $txt, $modSettings; |
| 576 | 590 | |
| 577 | - if (!empty($context['saved_successful'])) |
|
| 578 | - echo ' |
|
| 591 | + if (!empty($context['saved_successful'])) { |
|
| 592 | + echo ' |
|
| 579 | 593 | <div class="infobox">', $txt['settings_saved'], '</div>'; |
| 594 | + } |
|
| 580 | 595 | |
| 581 | 596 | // First section is for adding/removing words from the censored list. |
| 582 | 597 | echo ' |
@@ -591,11 +606,12 @@ discard block |
||
| 591 | 606 | <p>', $txt['admin_censored_where'], '</p>'; |
| 592 | 607 | |
| 593 | 608 | // Show text boxes for censoring [bad ] => [good ]. |
| 594 | - foreach ($context['censored_words'] as $vulgar => $proper) |
|
| 595 | - echo ' |
|
| 609 | + foreach ($context['censored_words'] as $vulgar => $proper) { |
|
| 610 | + echo ' |
|
| 596 | 611 | <div class="block"> |
| 597 | 612 | <input type="text" name="censor_vulgar[]" value="', $vulgar, '" size="30"> => <input type="text" name="censor_proper[]" value="', $proper, '" size="30"> |
| 598 | 613 | </div>'; |
| 614 | + } |
|
| 599 | 615 | |
| 600 | 616 | // Now provide a way to censor more words. |
| 601 | 617 | echo ' |
@@ -669,19 +685,21 @@ discard block |
||
| 669 | 685 | <div class="windowbg2 noup"> |
| 670 | 686 | ', $txt['not_done_reason']; |
| 671 | 687 | |
| 672 | - if (!empty($context['continue_percent'])) |
|
| 673 | - echo ' |
|
| 688 | + if (!empty($context['continue_percent'])) { |
|
| 689 | + echo ' |
|
| 674 | 690 | <div class="progress_bar"> |
| 675 | 691 | <div class="full_bar">', $context['continue_percent'], '%</div> |
| 676 | 692 | <div class="green_percent" style="width: ', $context['continue_percent'], '%;"> </div> |
| 677 | 693 | </div>'; |
| 694 | + } |
|
| 678 | 695 | |
| 679 | - if (!empty($context['substep_enabled'])) |
|
| 680 | - echo ' |
|
| 696 | + if (!empty($context['substep_enabled'])) { |
|
| 697 | + echo ' |
|
| 681 | 698 | <div class="progress_bar"> |
| 682 | 699 | <div class="full_bar">', $context['substep_title'], ' (', $context['substep_continue_percent'], '%)</div> |
| 683 | 700 | <div class="blue_percent" style="width: ', $context['substep_continue_percent'], '%;"> </div> |
| 684 | 701 | </div>'; |
| 702 | + } |
|
| 685 | 703 | |
| 686 | 704 | echo ' |
| 687 | 705 | <form action="', $scripturl, $context['continue_get_data'], '" method="post" accept-charset="', $context['character_set'], '" name="autoSubmit" id="autoSubmit"> |
@@ -716,35 +734,40 @@ discard block |
||
| 716 | 734 | { |
| 717 | 735 | global $context, $txt, $settings, $scripturl; |
| 718 | 736 | |
| 719 | - if (!empty($context['saved_successful'])) |
|
| 720 | - echo ' |
|
| 737 | + if (!empty($context['saved_successful'])) { |
|
| 738 | + echo ' |
|
| 721 | 739 | <div class="infobox">', $txt['settings_saved'], '</div>'; |
| 722 | - elseif (!empty($context['saved_failed'])) |
|
| 723 | - echo ' |
|
| 740 | + } elseif (!empty($context['saved_failed'])) { |
|
| 741 | + echo ' |
|
| 724 | 742 | <div class="errorbox">', sprintf($txt['settings_not_saved'], $context['saved_failed']), '</div>'; |
| 743 | + } |
|
| 725 | 744 | |
| 726 | - if (!empty($context['settings_pre_javascript'])) |
|
| 727 | - echo ' |
|
| 745 | + if (!empty($context['settings_pre_javascript'])) { |
|
| 746 | + echo ' |
|
| 728 | 747 | <script>', $context['settings_pre_javascript'], '</script>'; |
| 748 | + } |
|
| 729 | 749 | |
| 730 | - if (!empty($context['settings_insert_above'])) |
|
| 731 | - echo $context['settings_insert_above']; |
|
| 750 | + if (!empty($context['settings_insert_above'])) { |
|
| 751 | + echo $context['settings_insert_above']; |
|
| 752 | + } |
|
| 732 | 753 | |
| 733 | 754 | echo ' |
| 734 | 755 | <div id="admincenter"> |
| 735 | 756 | <form id="admin_form_wrapper" action="', $context['post_url'], '" method="post" accept-charset="', $context['character_set'], '"', !empty($context['force_form_onsubmit']) ? ' onsubmit="' . $context['force_form_onsubmit'] . '"' : '', '>'; |
| 736 | 757 | |
| 737 | 758 | // Is there a custom title? |
| 738 | - if (isset($context['settings_title'])) |
|
| 739 | - echo ' |
|
| 759 | + if (isset($context['settings_title'])) { |
|
| 760 | + echo ' |
|
| 740 | 761 | <div class="cat_bar"> |
| 741 | 762 | <h3 class="catbg">', $context['settings_title'], '</h3> |
| 742 | 763 | </div>'; |
| 764 | + } |
|
| 743 | 765 | |
| 744 | 766 | // Have we got a message to display? |
| 745 | - if (!empty($context['settings_message'])) |
|
| 746 | - echo ' |
|
| 767 | + if (!empty($context['settings_message'])) { |
|
| 768 | + echo ' |
|
| 747 | 769 | <div class="information">', $context['settings_message'], '</div>'; |
| 770 | + } |
|
| 748 | 771 | |
| 749 | 772 | // Now actually loop through all the variables. |
| 750 | 773 | $is_open = false; |
@@ -797,8 +820,9 @@ discard block |
||
| 797 | 820 | // Hang about? Are you pulling my leg - a callback?! |
| 798 | 821 | if (is_array($config_var) && $config_var['type'] == 'callback') |
| 799 | 822 | { |
| 800 | - if (function_exists('template_callback_' . $config_var['name'])) |
|
| 801 | - call_user_func('template_callback_' . $config_var['name']); |
|
| 823 | + if (function_exists('template_callback_' . $config_var['name'])) { |
|
| 824 | + call_user_func('template_callback_' . $config_var['name']); |
|
| 825 | + } |
|
| 802 | 826 | |
| 803 | 827 | continue; |
| 804 | 828 | } |
@@ -828,9 +852,10 @@ discard block |
||
| 828 | 852 | $text_types = array('color', 'date', 'datetime', 'datetime-local', 'email', 'month', 'time'); |
| 829 | 853 | |
| 830 | 854 | // Show the [?] button. |
| 831 | - if ($config_var['help']) |
|
| 832 | - echo ' |
|
| 855 | + if ($config_var['help']) { |
|
| 856 | + echo ' |
|
| 833 | 857 | <a id="setting_', $config_var['name'], '_help" href="', $scripturl, '?action=helpadmin;help=', $config_var['help'], '" onclick="return reqOverlayDiv(this.href);"><span class="generic_icons help" title="', $txt['help'], '"></span></a> '; |
| 858 | + } |
|
| 834 | 859 | |
| 835 | 860 | echo ' |
| 836 | 861 | <a id="setting_', $config_var['name'], '"></a> <span', ($config_var['disabled'] ? ' style="color: #777777;"' : ($config_var['invalid'] ? ' class="error"' : '')), '><label for="', $config_var['name'], '">', $config_var['label'], '</label>', $subtext, ($config_var['type'] == 'password' ? '<br><em>' . $txt['admin_confirm_password'] . '</em>' : ''), '</span> |
@@ -839,22 +864,25 @@ discard block |
||
| 839 | 864 | $config_var['preinput']; |
| 840 | 865 | |
| 841 | 866 | // Show a check box. |
| 842 | - if ($config_var['type'] == 'check') |
|
| 843 | - echo ' |
|
| 867 | + if ($config_var['type'] == 'check') { |
|
| 868 | + echo ' |
|
| 844 | 869 | <input type="checkbox"', $javascript, $disabled, ' name="', $config_var['name'], '" id="', $config_var['name'], '"', ($config_var['value'] ? ' checked' : ''), ' value="1" class="input_check">'; |
| 870 | + } |
|
| 845 | 871 | // Escape (via htmlspecialchars.) the text box. |
| 846 | - elseif ($config_var['type'] == 'password') |
|
| 847 | - echo ' |
|
| 872 | + elseif ($config_var['type'] == 'password') { |
|
| 873 | + echo ' |
|
| 848 | 874 | <input type="password"', $disabled, $javascript, ' name="', $config_var['name'], '[0]"', ($config_var['size'] ? ' size="' . $config_var['size'] . '"' : ''), ' value="*#fakepass#*" onfocus="this.value = \'\'; this.form.', $config_var['name'], '.disabled = false;" class="input_password"><br> |
| 849 | 875 | <input type="password" disabled id="', $config_var['name'], '" name="', $config_var['name'], '[1]"', ($config_var['size'] ? ' size="' . $config_var['size'] . '"' : ''), ' class="input_password">'; |
| 876 | + } |
|
| 850 | 877 | // Show a selection box. |
| 851 | 878 | elseif ($config_var['type'] == 'select') |
| 852 | 879 | { |
| 853 | 880 | echo ' |
| 854 | 881 | <select name="', $config_var['name'], '" id="', $config_var['name'], '" ', $javascript, $disabled, (!empty($config_var['multiple']) ? ' multiple="multiple"' : ''), (!empty($config_var['multiple']) && !empty($config_var['size']) ? ' size="' . $config_var['size'] . '"' : ''), '>'; |
| 855 | - foreach ($config_var['data'] as $option) |
|
| 856 | - echo ' |
|
| 882 | + foreach ($config_var['data'] as $option) { |
|
| 883 | + echo ' |
|
| 857 | 884 | <option value="', $option[0], '"', (!empty($config_var['value']) && ($option[0] == $config_var['value'] || (!empty($config_var['multiple']) && in_array($option[0], $config_var['value']))) ? ' selected' : ''), '>', $option[1], '</option>'; |
| 885 | + } |
|
| 858 | 886 | echo ' |
| 859 | 887 | </select>'; |
| 860 | 888 | } |
@@ -868,15 +896,17 @@ discard block |
||
| 868 | 896 | <legend class="board_selector"><a href="#">', $txt['select_boards_from_list'], '</a></legend>'; |
| 869 | 897 | foreach ($context['board_list'] as $id_cat => $cat) |
| 870 | 898 | { |
| 871 | - if (!$first) |
|
| 872 | - echo ' |
|
| 899 | + if (!$first) { |
|
| 900 | + echo ' |
|
| 873 | 901 | <hr>'; |
| 902 | + } |
|
| 874 | 903 | echo ' |
| 875 | 904 | <strong>', $cat['name'], '</strong> |
| 876 | 905 | <ul>'; |
| 877 | - foreach ($cat['boards'] as $id_board => $brd) |
|
| 878 | - echo ' |
|
| 906 | + foreach ($cat['boards'] as $id_board => $brd) { |
|
| 907 | + echo ' |
|
| 879 | 908 | <li><label><input type="checkbox" name="', $config_var['name'], '[', $brd['id'], ']" value="1" class="input_check"', in_array($brd['id'], $config_var['value']) ? ' checked' : '', '> ', $brd['child_level'] > 0 ? str_repeat(' ', $brd['child_level']) : '', $brd['name'], '</label></li>'; |
| 909 | + } |
|
| 880 | 910 | |
| 881 | 911 | echo ' |
| 882 | 912 | </ul>'; |
@@ -886,12 +916,14 @@ discard block |
||
| 886 | 916 | </fieldset>'; |
| 887 | 917 | } |
| 888 | 918 | // Text area? |
| 889 | - elseif ($config_var['type'] == 'large_text') |
|
| 890 | - echo ' |
|
| 919 | + elseif ($config_var['type'] == 'large_text') { |
|
| 920 | + echo ' |
|
| 891 | 921 | <textarea rows="', (!empty($config_var['size']) ? $config_var['size'] : (!empty($config_var['rows']) ? $config_var['rows'] : 4)), '" cols="', (!empty($config_var['cols']) ? $config_var['cols'] : 30), '" ', $javascript, $disabled, ' name="', $config_var['name'], '" id="', $config_var['name'], '">', $config_var['value'], '</textarea>'; |
| 922 | + } |
|
| 892 | 923 | // Permission group? |
| 893 | - elseif ($config_var['type'] == 'permissions') |
|
| 894 | - theme_inline_permissions($config_var['name']); |
|
| 924 | + elseif ($config_var['type'] == 'permissions') { |
|
| 925 | + theme_inline_permissions($config_var['name']); |
|
| 926 | + } |
|
| 895 | 927 | // BBC selection? |
| 896 | 928 | elseif ($config_var['type'] == 'bbc') |
| 897 | 929 | { |
@@ -902,20 +934,22 @@ discard block |
||
| 902 | 934 | |
| 903 | 935 | foreach ($context['bbc_columns'] as $bbcColumn) |
| 904 | 936 | { |
| 905 | - foreach ($bbcColumn as $bbcTag) |
|
| 906 | - echo ' |
|
| 937 | + foreach ($bbcColumn as $bbcTag) { |
|
| 938 | + echo ' |
|
| 907 | 939 | <li class="list_bbc floatleft"> |
| 908 | 940 | <input type="checkbox" name="', $config_var['name'], '_enabledTags[]" id="tag_', $config_var['name'], '_', $bbcTag['tag'], '" value="', $bbcTag['tag'], '"', !in_array($bbcTag['tag'], $context['bbc_sections'][$config_var['name']]['disabled']) ? ' checked' : '', ' class="input_check"> <label for="tag_', $config_var['name'], '_', $bbcTag['tag'], '">', $bbcTag['tag'], '</label>', $bbcTag['show_help'] ? ' (<a href="' . $scripturl . '?action=helpadmin;help=tag_' . $bbcTag['tag'] . '" onclick="return reqOverlayDiv(this.href);">?</a>)' : '', ' |
| 909 | 941 | </li>'; |
| 942 | + } |
|
| 910 | 943 | } |
| 911 | 944 | echo ' </ul> |
| 912 | 945 | <input type="checkbox" id="bbc_', $config_var['name'], '_select_all" onclick="invertAll(this, this.form, \'', $config_var['name'], '_enabledTags\');"', $context['bbc_sections'][$config_var['name']]['all_selected'] ? ' checked' : '', ' class="input_check"> <label for="bbc_', $config_var['name'], '_select_all"><em>', $txt['bbcTagsToUse_select_all'], '</em></label> |
| 913 | 946 | </fieldset>'; |
| 914 | 947 | } |
| 915 | 948 | // A simple message? |
| 916 | - elseif ($config_var['type'] == 'var_message') |
|
| 917 | - echo ' |
|
| 949 | + elseif ($config_var['type'] == 'var_message') { |
|
| 950 | + echo ' |
|
| 918 | 951 | <div', !empty($config_var['name']) ? ' id="' . $config_var['name'] . '"' : '', '>', $config_var['var_message'], '</div>'; |
| 952 | + } |
|
| 919 | 953 | // Assume it must be a text box |
| 920 | 954 | else |
| 921 | 955 | { |
@@ -940,63 +974,70 @@ discard block |
||
| 940 | 974 | ' . $config_var['postinput'] : '', |
| 941 | 975 | '</dd>'; |
| 942 | 976 | } |
| 943 | - } |
|
| 944 | - |
|
| 945 | - else |
|
| 977 | + } else |
|
| 946 | 978 | { |
| 947 | 979 | // Just show a separator. |
| 948 | - if ($config_var == '') |
|
| 949 | - echo ' |
|
| 980 | + if ($config_var == '') { |
|
| 981 | + echo ' |
|
| 950 | 982 | </dl> |
| 951 | 983 | <hr> |
| 952 | 984 | <dl class="settings">'; |
| 953 | - else |
|
| 954 | - echo ' |
|
| 985 | + } else { |
|
| 986 | + echo ' |
|
| 955 | 987 | <dd> |
| 956 | 988 | <strong>' . $config_var . '</strong> |
| 957 | 989 | </dd>'; |
| 990 | + } |
|
| 958 | 991 | } |
| 959 | 992 | } |
| 960 | 993 | |
| 961 | - if ($is_open) |
|
| 962 | - echo ' |
|
| 994 | + if ($is_open) { |
|
| 995 | + echo ' |
|
| 963 | 996 | </dl>'; |
| 997 | + } |
|
| 964 | 998 | |
| 965 | - if (empty($context['settings_save_dont_show'])) |
|
| 966 | - echo ' |
|
| 999 | + if (empty($context['settings_save_dont_show'])) { |
|
| 1000 | + echo ' |
|
| 967 | 1001 | <input type="submit" value="', $txt['save'], '"', (!empty($context['save_disabled']) ? ' disabled' : ''), (!empty($context['settings_save_onclick']) ? ' onclick="' . $context['settings_save_onclick'] . '"' : ''), ' class="button_submit">'; |
| 1002 | + } |
|
| 968 | 1003 | |
| 969 | - if ($is_open) |
|
| 970 | - echo ' |
|
| 1004 | + if ($is_open) { |
|
| 1005 | + echo ' |
|
| 971 | 1006 | </div>'; |
| 1007 | + } |
|
| 972 | 1008 | |
| 973 | 1009 | |
| 974 | 1010 | // At least one token has to be used! |
| 975 | - if (isset($context['admin-ssc_token'])) |
|
| 976 | - echo ' |
|
| 1011 | + if (isset($context['admin-ssc_token'])) { |
|
| 1012 | + echo ' |
|
| 977 | 1013 | <input type="hidden" name="', $context['admin-ssc_token_var'], '" value="', $context['admin-ssc_token'], '">'; |
| 1014 | + } |
|
| 978 | 1015 | |
| 979 | - if (isset($context['admin-dbsc_token'])) |
|
| 980 | - echo ' |
|
| 1016 | + if (isset($context['admin-dbsc_token'])) { |
|
| 1017 | + echo ' |
|
| 981 | 1018 | <input type="hidden" name="', $context['admin-dbsc_token_var'], '" value="', $context['admin-dbsc_token'], '">'; |
| 1019 | + } |
|
| 982 | 1020 | |
| 983 | - if (isset($context['admin-mp_token'])) |
|
| 984 | - echo ' |
|
| 1021 | + if (isset($context['admin-mp_token'])) { |
|
| 1022 | + echo ' |
|
| 985 | 1023 | <input type="hidden" name="', $context['admin-mp_token_var'], '" value="', $context['admin-mp_token'], '">'; |
| 1024 | + } |
|
| 986 | 1025 | |
| 987 | 1026 | echo ' |
| 988 | 1027 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
| 989 | 1028 | </form> |
| 990 | 1029 | </div>'; |
| 991 | 1030 | |
| 992 | - if (!empty($context['settings_post_javascript'])) |
|
| 993 | - echo ' |
|
| 1031 | + if (!empty($context['settings_post_javascript'])) { |
|
| 1032 | + echo ' |
|
| 994 | 1033 | <script> |
| 995 | 1034 | ', $context['settings_post_javascript'], ' |
| 996 | 1035 | </script>'; |
| 1036 | + } |
|
| 997 | 1037 | |
| 998 | - if (!empty($context['settings_insert_below'])) |
|
| 999 | - echo $context['settings_insert_below']; |
|
| 1038 | + if (!empty($context['settings_insert_below'])) { |
|
| 1039 | + echo $context['settings_insert_below']; |
|
| 1040 | + } |
|
| 1000 | 1041 | |
| 1001 | 1042 | // We may have added a board listing. If we did, we need to make it work. |
| 1002 | 1043 | addInlineJavascript(' |
@@ -1019,9 +1060,10 @@ discard block |
||
| 1019 | 1060 | { |
| 1020 | 1061 | global $context, $txt; |
| 1021 | 1062 | |
| 1022 | - if (!empty($context['saved_successful'])) |
|
| 1023 | - echo ' |
|
| 1063 | + if (!empty($context['saved_successful'])) { |
|
| 1064 | + echo ' |
|
| 1024 | 1065 | <div class="infobox">', $txt['settings_saved'], '</div>'; |
| 1066 | + } |
|
| 1025 | 1067 | |
| 1026 | 1068 | // Standard fields. |
| 1027 | 1069 | template_show_list('standard_profile_fields'); |
@@ -1053,11 +1095,12 @@ discard block |
||
| 1053 | 1095 | if (isset($_GET['msg'])) |
| 1054 | 1096 | { |
| 1055 | 1097 | loadLanguage('Errors'); |
| 1056 | - if (isset($txt['custom_option_' . $_GET['msg']])) |
|
| 1057 | - echo ' |
|
| 1098 | + if (isset($txt['custom_option_' . $_GET['msg']])) { |
|
| 1099 | + echo ' |
|
| 1058 | 1100 | <div class="errorbox">', |
| 1059 | 1101 | $txt['custom_option_' . $_GET['msg']], ' |
| 1060 | 1102 | </div>'; |
| 1103 | + } |
|
| 1061 | 1104 | } |
| 1062 | 1105 | |
| 1063 | 1106 | echo ' |
@@ -1123,9 +1166,10 @@ discard block |
||
| 1123 | 1166 | <dd> |
| 1124 | 1167 | <select name="placement" id="placement">'; |
| 1125 | 1168 | |
| 1126 | - foreach ($context['cust_profile_fields_placement'] as $order => $name) |
|
| 1127 | - echo ' |
|
| 1169 | + foreach ($context['cust_profile_fields_placement'] as $order => $name) { |
|
| 1170 | + echo ' |
|
| 1128 | 1171 | <option value="', $order, '"', $context['field']['placement'] == $order ? ' selected' : '', '>', $txt['custom_profile_placement_' . $name], '</option>'; |
| 1172 | + } |
|
| 1129 | 1173 | |
| 1130 | 1174 | echo ' |
| 1131 | 1175 | </select> |
@@ -1148,9 +1192,10 @@ discard block |
||
| 1148 | 1192 | </dt> |
| 1149 | 1193 | <dd> |
| 1150 | 1194 | <select name="field_type" id="field_type" onchange="updateInputBoxes();">'; |
| 1151 | - foreach (array('text', 'textarea', 'select', 'radio', 'check') as $field_type) |
|
| 1152 | - echo ' |
|
| 1195 | + foreach (array('text', 'textarea', 'select', 'radio', 'check') as $field_type) { |
|
| 1196 | + echo ' |
|
| 1153 | 1197 | <option value="', $field_type, '"', $context['field']['type'] == $field_type ? ' selected' : '', '>', $txt['custom_profile_type_' . $field_type], '</option>'; |
| 1198 | + } |
|
| 1154 | 1199 | |
| 1155 | 1200 | echo ' |
| 1156 | 1201 | </select> |
@@ -1251,9 +1296,10 @@ discard block |
||
| 1251 | 1296 | </fieldset> |
| 1252 | 1297 | <input type="submit" name="save" value="', $txt['save'], '" class="button_submit">'; |
| 1253 | 1298 | |
| 1254 | - if ($context['fid']) |
|
| 1255 | - echo ' |
|
| 1299 | + if ($context['fid']) { |
|
| 1300 | + echo ' |
|
| 1256 | 1301 | <input type="submit" name="delete" value="', $txt['delete'], '" data-confirm="', $txt['custom_edit_delete_sure'], '" class="button_submit you_sure">'; |
| 1302 | + } |
|
| 1257 | 1303 | |
| 1258 | 1304 | echo ' |
| 1259 | 1305 | </div> |
@@ -1296,8 +1342,7 @@ discard block |
||
| 1296 | 1342 | { |
| 1297 | 1343 | echo ' |
| 1298 | 1344 | <p class="centertext"><strong>', $txt['admin_search_results_none'], '</strong></p>'; |
| 1299 | - } |
|
| 1300 | - else |
|
| 1345 | + } else |
|
| 1301 | 1346 | { |
| 1302 | 1347 | echo ' |
| 1303 | 1348 | <ol class="search_results">'; |
@@ -1323,9 +1368,10 @@ discard block |
||
| 1323 | 1368 | <li> |
| 1324 | 1369 | <a href="', $result['url'], '"><strong>', $result['name'], '</strong></a> [', isset($txt['admin_search_section_' . $result['type']]) ? $txt['admin_search_section_' . $result['type']] : $result['type'], ']'; |
| 1325 | 1370 | |
| 1326 | - if ($result['help']) |
|
| 1327 | - echo ' |
|
| 1371 | + if ($result['help']) { |
|
| 1372 | + echo ' |
|
| 1328 | 1373 | <p class="double_height">', $result['help'], '</p>'; |
| 1374 | + } |
|
| 1329 | 1375 | |
| 1330 | 1376 | echo ' |
| 1331 | 1377 | </li>'; |
@@ -1365,18 +1411,20 @@ discard block |
||
| 1365 | 1411 | <strong>', $txt['setup_verification_answer'], '</strong> |
| 1366 | 1412 | </dd>'; |
| 1367 | 1413 | |
| 1368 | - if (!empty($context['qa_by_lang'][$lang_id])) |
|
| 1369 | - foreach ($context['qa_by_lang'][$lang_id] as $q_id) |
|
| 1414 | + if (!empty($context['qa_by_lang'][$lang_id])) { |
|
| 1415 | + foreach ($context['qa_by_lang'][$lang_id] as $q_id) |
|
| 1370 | 1416 | { |
| 1371 | 1417 | $question = $context['question_answers'][$q_id]; |
| 1418 | + } |
|
| 1372 | 1419 | echo ' |
| 1373 | 1420 | <dt> |
| 1374 | 1421 | <input type="text" name="question[', $lang_id, '][', $q_id, ']" value="', $question['question'], '" size="50" class="input_text verification_question"> |
| 1375 | 1422 | </dt> |
| 1376 | 1423 | <dd>'; |
| 1377 | - foreach ($question['answers'] as $answer) |
|
| 1378 | - echo ' |
|
| 1424 | + foreach ($question['answers'] as $answer) { |
|
| 1425 | + echo ' |
|
| 1379 | 1426 | <input type="text" name="answer[', $lang_id, '][', $q_id, '][]" value="', $answer, '" size="50" class="input_text verification_answer">'; |
| 1427 | + } |
|
| 1380 | 1428 | |
| 1381 | 1429 | echo ' |
| 1382 | 1430 | <div class="qa_add_answer"><a href="javascript:void(0);" onclick="return addAnswer(this);">[ ', $txt['setup_verification_add_answer'], ' ]</a></div> |
@@ -1415,11 +1463,12 @@ discard block |
||
| 1415 | 1463 | ', $txt['errors_found'], ': |
| 1416 | 1464 | <ul>'; |
| 1417 | 1465 | |
| 1418 | - foreach ($context['repair_errors'] as $error) |
|
| 1419 | - echo ' |
|
| 1466 | + foreach ($context['repair_errors'] as $error) { |
|
| 1467 | + echo ' |
|
| 1420 | 1468 | <li> |
| 1421 | 1469 | ', $error, ' |
| 1422 | 1470 | </li>'; |
| 1471 | + } |
|
| 1423 | 1472 | |
| 1424 | 1473 | echo ' |
| 1425 | 1474 | </ul> |
@@ -1429,16 +1478,15 @@ discard block |
||
| 1429 | 1478 | <p class="padding"> |
| 1430 | 1479 | <strong><a href="', $scripturl, '?action=admin;area=repairboards;fixErrors;', $context['session_var'], '=', $context['session_id'], '">', $txt['yes'], '</a> - <a href="', $scripturl, '?action=admin;area=maintain">', $txt['no'], '</a></strong> |
| 1431 | 1480 | </p>'; |
| 1432 | - } |
|
| 1433 | - else |
|
| 1434 | - echo ' |
|
| 1481 | + } else { |
|
| 1482 | + echo ' |
|
| 1435 | 1483 | <p>', $txt['maintain_no_errors'], '</p> |
| 1436 | 1484 | <p class="padding"> |
| 1437 | 1485 | <a href="', $scripturl, '?action=admin;area=maintain;sa=routine">', $txt['maintain_return'], '</a> |
| 1438 | 1486 | </p>'; |
| 1487 | + } |
|
| 1439 | 1488 | |
| 1440 | - } |
|
| 1441 | - else |
|
| 1489 | + } else |
|
| 1442 | 1490 | { |
| 1443 | 1491 | if (!empty($context['redirect_to_recount'])) |
| 1444 | 1492 | { |
@@ -1450,8 +1498,7 @@ discard block |
||
| 1450 | 1498 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
| 1451 | 1499 | <input type="submit" name="recount" id="recount_now" value="', $txt['errors_recount_now'], '"> |
| 1452 | 1500 | </form>'; |
| 1453 | - } |
|
| 1454 | - else |
|
| 1501 | + } else |
|
| 1455 | 1502 | { |
| 1456 | 1503 | echo ' |
| 1457 | 1504 | <p>', $txt['errors_fixed'], '</p> |
@@ -1603,8 +1650,8 @@ discard block |
||
| 1603 | 1650 | function template_admin_quick_search() |
| 1604 | 1651 | { |
| 1605 | 1652 | global $context, $txt, $scripturl; |
| 1606 | - if ($context['user']['is_admin']) |
|
| 1607 | - echo ' |
|
| 1653 | + if ($context['user']['is_admin']) { |
|
| 1654 | + echo ' |
|
| 1608 | 1655 | <span class="floatright admin_search"> |
| 1609 | 1656 | <span class="generic_icons filter centericon"></span> |
| 1610 | 1657 | <input type="search" name="search_term" value="', $txt['admin_search'], '" onclick="if (this.value == \'', $txt['admin_search'], '\') this.value = \'\';" class="input_text"> |
@@ -1615,6 +1662,7 @@ discard block |
||
| 1615 | 1662 | </select> |
| 1616 | 1663 | <input type="submit" name="search_go" id="search_go" value="', $txt['admin_search_go'], '" class="button_submit"> |
| 1617 | 1664 | </span>'; |
| 1618 | -} |
|
| 1665 | + } |
|
| 1666 | + } |
|
| 1619 | 1667 | |
| 1620 | 1668 | ?> |
| 1621 | 1669 | \ No newline at end of file |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 3 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * Retrieve a list and several other statistics of the users currently online. |
@@ -45,8 +46,9 @@ discard block |
||
| 45 | 46 | } |
| 46 | 47 | |
| 47 | 48 | // Not allowed sort method? Bang! Error! |
| 48 | - elseif (!in_array($membersOnlineOptions['sort'], $allowed_sort_options)) |
|
| 49 | - trigger_error('Sort method for getMembersOnlineStats() function is not allowed', E_USER_NOTICE); |
|
| 49 | + elseif (!in_array($membersOnlineOptions['sort'], $allowed_sort_options)) { |
|
| 50 | + trigger_error('Sort method for getMembersOnlineStats() function is not allowed', E_USER_NOTICE); |
|
| 51 | + } |
|
| 50 | 52 | |
| 51 | 53 | // Initialize the array that'll be returned later on. |
| 52 | 54 | $membersOnlineStats = array( |
@@ -63,8 +65,9 @@ discard block |
||
| 63 | 65 | // Get any spiders if enabled. |
| 64 | 66 | $spiders = array(); |
| 65 | 67 | $spider_finds = array(); |
| 66 | - if (!empty($modSettings['show_spider_online']) && ($modSettings['show_spider_online'] < 3 || allowedTo('admin_forum')) && !empty($modSettings['spider_name_cache'])) |
|
| 67 | - $spiders = smf_json_decode($modSettings['spider_name_cache'], true); |
|
| 68 | + if (!empty($modSettings['show_spider_online']) && ($modSettings['show_spider_online'] < 3 || allowedTo('admin_forum')) && !empty($modSettings['spider_name_cache'])) { |
|
| 69 | + $spiders = smf_json_decode($modSettings['spider_name_cache'], true); |
|
| 70 | + } |
|
| 68 | 71 | |
| 69 | 72 | // Load the users online right now. |
| 70 | 73 | $request = $smcFunc['db_query']('', ' |
@@ -92,9 +95,7 @@ discard block |
||
| 92 | 95 | $membersOnlineStats['num_guests']++; |
| 93 | 96 | |
| 94 | 97 | continue; |
| 95 | - } |
|
| 96 | - |
|
| 97 | - elseif (empty($row['show_online']) && empty($membersOnlineOptions['show_hidden'])) |
|
| 98 | + } elseif (empty($row['show_online']) && empty($membersOnlineOptions['show_hidden'])) |
|
| 98 | 99 | { |
| 99 | 100 | // Just increase the stats and don't add this hidden user to any list. |
| 100 | 101 | $membersOnlineStats['num_users_hidden']++; |
@@ -102,10 +103,11 @@ discard block |
||
| 102 | 103 | } |
| 103 | 104 | |
| 104 | 105 | // Some basic color coding... |
| 105 | - if (!empty($row['online_color'])) |
|
| 106 | - $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>'; |
|
| 107 | - else |
|
| 108 | - $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
| 106 | + if (!empty($row['online_color'])) { |
|
| 107 | + $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>'; |
|
| 108 | + } else { |
|
| 109 | + $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
| 110 | + } |
|
| 109 | 111 | |
| 110 | 112 | // Buddies get counted and highlighted. |
| 111 | 113 | $is_buddy = in_array($row['id_member'], $user_info['buddies']); |
@@ -132,12 +134,13 @@ discard block |
||
| 132 | 134 | $membersOnlineStats['list_users_online'][$row[$membersOnlineOptions['sort']] . '_' . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link; |
| 133 | 135 | |
| 134 | 136 | // Store all distinct (primary) membergroups that are shown. |
| 135 | - if (!isset($membersOnlineStats['online_groups'][$row['id_group']])) |
|
| 136 | - $membersOnlineStats['online_groups'][$row['id_group']] = array( |
|
| 137 | + if (!isset($membersOnlineStats['online_groups'][$row['id_group']])) { |
|
| 138 | + $membersOnlineStats['online_groups'][$row['id_group']] = array( |
|
| 137 | 139 | 'id' => $row['id_group'], |
| 138 | 140 | 'name' => $row['group_name'], |
| 139 | 141 | 'color' => $row['online_color'] |
| 140 | 142 | ); |
| 143 | + } |
|
| 141 | 144 | } |
| 142 | 145 | $smcFunc['db_free_result']($request); |
| 143 | 146 | |
@@ -198,11 +201,12 @@ discard block |
||
| 198 | 201 | $settingsToUpdate = array(); |
| 199 | 202 | |
| 200 | 203 | // More members on now than ever were? Update it! |
| 201 | - if (!isset($modSettings['mostOnline']) || $total_users_online >= $modSettings['mostOnline']) |
|
| 202 | - $settingsToUpdate = array( |
|
| 204 | + if (!isset($modSettings['mostOnline']) || $total_users_online >= $modSettings['mostOnline']) { |
|
| 205 | + $settingsToUpdate = array( |
|
| 203 | 206 | 'mostOnline' => $total_users_online, |
| 204 | 207 | 'mostDate' => time() |
| 205 | 208 | ); |
| 209 | + } |
|
| 206 | 210 | |
| 207 | 211 | $date = strftime('%Y-%m-%d', forum_time(false)); |
| 208 | 212 | |
@@ -234,8 +238,9 @@ discard block |
||
| 234 | 238 | { |
| 235 | 239 | list ($modSettings['mostOnlineToday']) = $smcFunc['db_fetch_row']($request); |
| 236 | 240 | |
| 237 | - if ($total_users_online > $modSettings['mostOnlineToday']) |
|
| 238 | - trackStats(array('most_on' => $total_users_online)); |
|
| 241 | + if ($total_users_online > $modSettings['mostOnlineToday']) { |
|
| 242 | + trackStats(array('most_on' => $total_users_online)); |
|
| 243 | + } |
|
| 239 | 244 | |
| 240 | 245 | $total_users_online = max($total_users_online, $modSettings['mostOnlineToday']); |
| 241 | 246 | } |
@@ -252,8 +257,9 @@ discard block |
||
| 252 | 257 | $settingsToUpdate['mostOnlineToday'] = $total_users_online; |
| 253 | 258 | } |
| 254 | 259 | |
| 255 | - if (!empty($settingsToUpdate)) |
|
| 256 | - updateSettings($settingsToUpdate); |
|
| 257 | -} |
|
| 260 | + if (!empty($settingsToUpdate)) { |
|
| 261 | + updateSettings($settingsToUpdate); |
|
| 262 | + } |
|
| 263 | + } |
|
| 258 | 264 | |
| 259 | 265 | ?> |
| 260 | 266 | \ No newline at end of file |
@@ -255,8 +255,8 @@ discard block |
||
| 255 | 255 | |
| 256 | 256 | case 'datetime': |
| 257 | 257 | if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d) ([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $datetime_matches) === 1) |
| 258 | - return 'str_to_date('. |
|
| 259 | - sprintf('\'%04d-%02d-%02d %02d:%02d:%02d\'', $datetime_matches[1], $datetime_matches[2], $datetime_matches[3], $datetime_matches[4], $datetime_matches[5] ,$datetime_matches[6]). |
|
| 258 | + return 'str_to_date(' . |
|
| 259 | + sprintf('\'%04d-%02d-%02d %02d:%02d:%02d\'', $datetime_matches[1], $datetime_matches[2], $datetime_matches[3], $datetime_matches[4], $datetime_matches[5], $datetime_matches[6]) . |
|
| 260 | 260 | ',\'%Y-%m-%d %h:%i:%s\')'; |
| 261 | 261 | else |
| 262 | 262 | smf_db_error_backtrace('Wrong value type sent to the database. Datetime expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
@@ -823,7 +823,7 @@ discard block |
||
| 823 | 823 | $connection |
| 824 | 824 | ); |
| 825 | 825 | |
| 826 | - if(!empty($keys) && (count($keys) > 0) && $method == '' && $returnmode > 0) |
|
| 826 | + if (!empty($keys) && (count($keys) > 0) && $method == '' && $returnmode > 0) |
|
| 827 | 827 | { |
| 828 | 828 | if ($returnmode == 1) |
| 829 | 829 | $return_var = smf_db_insert_id($table, $keys[0]) + count($insertRows) - 1; |
@@ -832,7 +832,7 @@ discard block |
||
| 832 | 832 | $return_var = array(); |
| 833 | 833 | $count = count($insertRows); |
| 834 | 834 | $start = smf_db_insert_id($table, $keys[0]); |
| 835 | - for ($i = 0; $i < $count; $i++ ) |
|
| 835 | + for ($i = 0; $i < $count; $i++) |
|
| 836 | 836 | $return_var[] = $start + $i; |
| 837 | 837 | } |
| 838 | 838 | return $return_var; |
@@ -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 | * Maps the implementations in this file (smf_db_function_name) |
@@ -33,8 +34,8 @@ discard block |
||
| 33 | 34 | global $smcFunc, $mysql_set_mode; |
| 34 | 35 | |
| 35 | 36 | // Map some database specific functions, only do this once. |
| 36 | - if (!isset($smcFunc['db_fetch_assoc'])) |
|
| 37 | - $smcFunc += array( |
|
| 37 | + if (!isset($smcFunc['db_fetch_assoc'])) { |
|
| 38 | + $smcFunc += array( |
|
| 38 | 39 | 'db_query' => 'smf_db_query', |
| 39 | 40 | 'db_quote' => 'smf_db_quote', |
| 40 | 41 | 'db_fetch_assoc' => 'mysqli_fetch_assoc', |
@@ -60,9 +61,11 @@ discard block |
||
| 60 | 61 | 'db_mb4' => false, |
| 61 | 62 | 'db_ping' => 'mysqli_ping', |
| 62 | 63 | ); |
| 64 | + } |
|
| 63 | 65 | |
| 64 | - if (!empty($db_options['persist'])) |
|
| 65 | - $db_server = 'p:' . $db_server; |
|
| 66 | + if (!empty($db_options['persist'])) { |
|
| 67 | + $db_server = 'p:' . $db_server; |
|
| 68 | + } |
|
| 66 | 69 | |
| 67 | 70 | $connection = mysqli_init(); |
| 68 | 71 | |
@@ -71,31 +74,35 @@ discard block |
||
| 71 | 74 | $success = false; |
| 72 | 75 | |
| 73 | 76 | if ($connection) { |
| 74 | - if (!empty($db_options['port'])) |
|
| 75 | - $success = mysqli_real_connect($connection, $db_server, $db_user, $db_passwd, '', $db_options['port'], null, $flags); |
|
| 76 | - else |
|
| 77 | - $success = mysqli_real_connect($connection, $db_server, $db_user, $db_passwd, '', 0, null, $flags); |
|
| 77 | + if (!empty($db_options['port'])) { |
|
| 78 | + $success = mysqli_real_connect($connection, $db_server, $db_user, $db_passwd, '', $db_options['port'], null, $flags); |
|
| 79 | + } else { |
|
| 80 | + $success = mysqli_real_connect($connection, $db_server, $db_user, $db_passwd, '', 0, null, $flags); |
|
| 81 | + } |
|
| 78 | 82 | } |
| 79 | 83 | |
| 80 | 84 | // Something's wrong, show an error if its fatal (which we assume it is) |
| 81 | 85 | if ($success === false) |
| 82 | 86 | { |
| 83 | - if (!empty($db_options['non_fatal'])) |
|
| 84 | - return null; |
|
| 85 | - else |
|
| 86 | - display_db_error(); |
|
| 87 | + if (!empty($db_options['non_fatal'])) { |
|
| 88 | + return null; |
|
| 89 | + } else { |
|
| 90 | + display_db_error(); |
|
| 91 | + } |
|
| 87 | 92 | } |
| 88 | 93 | |
| 89 | 94 | // Select the database, unless told not to |
| 90 | - if (empty($db_options['dont_select_db']) && !@mysqli_select_db($connection, $db_name) && empty($db_options['non_fatal'])) |
|
| 91 | - display_db_error(); |
|
| 95 | + if (empty($db_options['dont_select_db']) && !@mysqli_select_db($connection, $db_name) && empty($db_options['non_fatal'])) { |
|
| 96 | + display_db_error(); |
|
| 97 | + } |
|
| 92 | 98 | |
| 93 | 99 | // This makes it possible to have SMF automatically change the sql_mode and autocommit if needed. |
| 94 | - if (isset($mysql_set_mode) && $mysql_set_mode === true) |
|
| 95 | - $smcFunc['db_query']('', 'SET sql_mode = \'\', AUTOCOMMIT = 1', |
|
| 100 | + if (isset($mysql_set_mode) && $mysql_set_mode === true) { |
|
| 101 | + $smcFunc['db_query']('', 'SET sql_mode = \'\', AUTOCOMMIT = 1', |
|
| 96 | 102 | array(), |
| 97 | 103 | false |
| 98 | 104 | ); |
| 105 | + } |
|
| 99 | 106 | |
| 100 | 107 | return $connection; |
| 101 | 108 | } |
@@ -166,38 +173,46 @@ discard block |
||
| 166 | 173 | global $db_callback, $user_info, $db_prefix, $smcFunc; |
| 167 | 174 | |
| 168 | 175 | list ($values, $connection) = $db_callback; |
| 169 | - if (!is_object($connection)) |
|
| 170 | - display_db_error(); |
|
| 176 | + if (!is_object($connection)) { |
|
| 177 | + display_db_error(); |
|
| 178 | + } |
|
| 171 | 179 | |
| 172 | - if ($matches[1] === 'db_prefix') |
|
| 173 | - return $db_prefix; |
|
| 180 | + if ($matches[1] === 'db_prefix') { |
|
| 181 | + return $db_prefix; |
|
| 182 | + } |
|
| 174 | 183 | |
| 175 | 184 | if (!empty($user_info)) |
| 176 | 185 | { |
| 177 | - foreach (array_keys($user_info) as $key) |
|
| 178 | - if (strpos($key, 'query_') !== false && $key === $matches[1]) |
|
| 186 | + foreach (array_keys($user_info) as $key) { |
|
| 187 | + if (strpos($key, 'query_') !== false && $key === $matches[1]) |
|
| 179 | 188 | return $user_info[$matches[1]]; |
| 189 | + } |
|
| 180 | 190 | } |
| 181 | 191 | |
| 182 | - if ($matches[1] === 'empty') |
|
| 183 | - return '\'\''; |
|
| 192 | + if ($matches[1] === 'empty') { |
|
| 193 | + return '\'\''; |
|
| 194 | + } |
|
| 184 | 195 | |
| 185 | - if (!isset($matches[2])) |
|
| 186 | - smf_db_error_backtrace('Invalid value inserted or no type specified.', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 196 | + if (!isset($matches[2])) { |
|
| 197 | + smf_db_error_backtrace('Invalid value inserted or no type specified.', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 198 | + } |
|
| 187 | 199 | |
| 188 | - if ($matches[1] === 'literal') |
|
| 189 | - return '\'' . mysqli_real_escape_string($connection, $matches[2]) . '\''; |
|
| 200 | + if ($matches[1] === 'literal') { |
|
| 201 | + return '\'' . mysqli_real_escape_string($connection, $matches[2]) . '\''; |
|
| 202 | + } |
|
| 190 | 203 | |
| 191 | - if (!isset($values[$matches[2]])) |
|
| 192 | - smf_db_error_backtrace('The database value you\'re trying to insert does not exist: ' . (isset($smcFunc['htmlspecialchars']) ? $smcFunc['htmlspecialchars']($matches[2]) : htmlspecialchars($matches[2])), '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 204 | + if (!isset($values[$matches[2]])) { |
|
| 205 | + smf_db_error_backtrace('The database value you\'re trying to insert does not exist: ' . (isset($smcFunc['htmlspecialchars']) ? $smcFunc['htmlspecialchars']($matches[2]) : htmlspecialchars($matches[2])), '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 206 | + } |
|
| 193 | 207 | |
| 194 | 208 | $replacement = $values[$matches[2]]; |
| 195 | 209 | |
| 196 | 210 | switch ($matches[1]) |
| 197 | 211 | { |
| 198 | 212 | case 'int': |
| 199 | - if (!is_numeric($replacement) || (string) $replacement !== (string) (int) $replacement) |
|
| 200 | - smf_db_error_backtrace('Wrong value type sent to the database. Integer expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 213 | + if (!is_numeric($replacement) || (string) $replacement !== (string) (int) $replacement) { |
|
| 214 | + smf_db_error_backtrace('Wrong value type sent to the database. Integer expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 215 | + } |
|
| 201 | 216 | return (string) (int) $replacement; |
| 202 | 217 | break; |
| 203 | 218 | |
@@ -209,65 +224,73 @@ discard block |
||
| 209 | 224 | case 'array_int': |
| 210 | 225 | if (is_array($replacement)) |
| 211 | 226 | { |
| 212 | - if (empty($replacement)) |
|
| 213 | - smf_db_error_backtrace('Database error, given array of integer values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 227 | + if (empty($replacement)) { |
|
| 228 | + smf_db_error_backtrace('Database error, given array of integer values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 229 | + } |
|
| 214 | 230 | |
| 215 | 231 | foreach ($replacement as $key => $value) |
| 216 | 232 | { |
| 217 | - if (!is_numeric($value) || (string) $value !== (string) (int) $value) |
|
| 218 | - smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 233 | + if (!is_numeric($value) || (string) $value !== (string) (int) $value) { |
|
| 234 | + smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 235 | + } |
|
| 219 | 236 | |
| 220 | 237 | $replacement[$key] = (string) (int) $value; |
| 221 | 238 | } |
| 222 | 239 | |
| 223 | 240 | return implode(', ', $replacement); |
| 241 | + } else { |
|
| 242 | + smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 224 | 243 | } |
| 225 | - else |
|
| 226 | - smf_db_error_backtrace('Wrong value type sent to the database. Array of integers expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 227 | 244 | |
| 228 | 245 | break; |
| 229 | 246 | |
| 230 | 247 | case 'array_string': |
| 231 | 248 | if (is_array($replacement)) |
| 232 | 249 | { |
| 233 | - if (empty($replacement)) |
|
| 234 | - smf_db_error_backtrace('Database error, given array of string values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 250 | + if (empty($replacement)) { |
|
| 251 | + smf_db_error_backtrace('Database error, given array of string values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 252 | + } |
|
| 235 | 253 | |
| 236 | - foreach ($replacement as $key => $value) |
|
| 237 | - $replacement[$key] = sprintf('\'%1$s\'', mysqli_real_escape_string($connection, $value)); |
|
| 254 | + foreach ($replacement as $key => $value) { |
|
| 255 | + $replacement[$key] = sprintf('\'%1$s\'', mysqli_real_escape_string($connection, $value)); |
|
| 256 | + } |
|
| 238 | 257 | |
| 239 | 258 | return implode(', ', $replacement); |
| 259 | + } else { |
|
| 260 | + smf_db_error_backtrace('Wrong value type sent to the database. Array of strings expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 240 | 261 | } |
| 241 | - else |
|
| 242 | - smf_db_error_backtrace('Wrong value type sent to the database. Array of strings expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 243 | 262 | break; |
| 244 | 263 | |
| 245 | 264 | case 'date': |
| 246 | - if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d)$~', $replacement, $date_matches) === 1) |
|
| 247 | - return sprintf('\'%04d-%02d-%02d\'', $date_matches[1], $date_matches[2], $date_matches[3]); |
|
| 248 | - else |
|
| 249 | - smf_db_error_backtrace('Wrong value type sent to the database. Date expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 265 | + if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d)$~', $replacement, $date_matches) === 1) { |
|
| 266 | + return sprintf('\'%04d-%02d-%02d\'', $date_matches[1], $date_matches[2], $date_matches[3]); |
|
| 267 | + } else { |
|
| 268 | + smf_db_error_backtrace('Wrong value type sent to the database. Date expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 269 | + } |
|
| 250 | 270 | break; |
| 251 | 271 | |
| 252 | 272 | case 'time': |
| 253 | - if (preg_match('~^([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $time_matches) === 1) |
|
| 254 | - return sprintf('\'%02d:%02d:%02d\'', $time_matches[1], $time_matches[2], $time_matches[3]); |
|
| 255 | - else |
|
| 256 | - smf_db_error_backtrace('Wrong value type sent to the database. Time expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 273 | + if (preg_match('~^([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $time_matches) === 1) { |
|
| 274 | + return sprintf('\'%02d:%02d:%02d\'', $time_matches[1], $time_matches[2], $time_matches[3]); |
|
| 275 | + } else { |
|
| 276 | + smf_db_error_backtrace('Wrong value type sent to the database. Time expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 277 | + } |
|
| 257 | 278 | break; |
| 258 | 279 | |
| 259 | 280 | case 'datetime': |
| 260 | - if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d) ([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $datetime_matches) === 1) |
|
| 261 | - return 'str_to_date('. |
|
| 281 | + if (preg_match('~^(\d{4})-([0-1]?\d)-([0-3]?\d) ([0-1]?\d|2[0-3]):([0-5]\d):([0-5]\d)$~', $replacement, $datetime_matches) === 1) { |
|
| 282 | + return 'str_to_date('. |
|
| 262 | 283 | sprintf('\'%04d-%02d-%02d %02d:%02d:%02d\'', $datetime_matches[1], $datetime_matches[2], $datetime_matches[3], $datetime_matches[4], $datetime_matches[5] ,$datetime_matches[6]). |
| 263 | 284 | ',\'%Y-%m-%d %h:%i:%s\')'; |
| 264 | - else |
|
| 265 | - smf_db_error_backtrace('Wrong value type sent to the database. Datetime expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 285 | + } else { |
|
| 286 | + smf_db_error_backtrace('Wrong value type sent to the database. Datetime expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 287 | + } |
|
| 266 | 288 | break; |
| 267 | 289 | |
| 268 | 290 | case 'float': |
| 269 | - if (!is_numeric($replacement)) |
|
| 270 | - smf_db_error_backtrace('Wrong value type sent to the database. Floating point number expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 291 | + if (!is_numeric($replacement)) { |
|
| 292 | + smf_db_error_backtrace('Wrong value type sent to the database. Floating point number expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 293 | + } |
|
| 271 | 294 | return (string) (float) $replacement; |
| 272 | 295 | break; |
| 273 | 296 | |
@@ -281,32 +304,37 @@ discard block |
||
| 281 | 304 | break; |
| 282 | 305 | |
| 283 | 306 | case 'inet': |
| 284 | - if ($replacement == 'null' || $replacement == '') |
|
| 285 | - return 'null'; |
|
| 286 | - if (!isValidIP($replacement)) |
|
| 287 | - smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 307 | + if ($replacement == 'null' || $replacement == '') { |
|
| 308 | + return 'null'; |
|
| 309 | + } |
|
| 310 | + if (!isValidIP($replacement)) { |
|
| 311 | + smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 312 | + } |
|
| 288 | 313 | //we don't use the native support of mysql > 5.6.2 |
| 289 | 314 | return sprintf('unhex(\'%1$s\')', bin2hex(inet_pton($replacement))); |
| 290 | 315 | |
| 291 | 316 | case 'array_inet': |
| 292 | 317 | if (is_array($replacement)) |
| 293 | 318 | { |
| 294 | - if (empty($replacement)) |
|
| 295 | - smf_db_error_backtrace('Database error, given array of IPv4 or IPv6 values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 319 | + if (empty($replacement)) { |
|
| 320 | + smf_db_error_backtrace('Database error, given array of IPv4 or IPv6 values is empty. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 321 | + } |
|
| 296 | 322 | |
| 297 | 323 | foreach ($replacement as $key => $value) |
| 298 | 324 | { |
| 299 | - if ($replacement == 'null' || $replacement == '') |
|
| 300 | - $replacement[$key] = 'null'; |
|
| 301 | - if (!isValidIP($value)) |
|
| 302 | - smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 325 | + if ($replacement == 'null' || $replacement == '') { |
|
| 326 | + $replacement[$key] = 'null'; |
|
| 327 | + } |
|
| 328 | + if (!isValidIP($value)) { |
|
| 329 | + smf_db_error_backtrace('Wrong value type sent to the database. IPv4 or IPv6 expected.(' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 330 | + } |
|
| 303 | 331 | $replacement[$key] = sprintf('unhex(\'%1$s\')', bin2hex(inet_pton($value))); |
| 304 | 332 | } |
| 305 | 333 | |
| 306 | 334 | return implode(', ', $replacement); |
| 335 | + } else { |
|
| 336 | + smf_db_error_backtrace('Wrong value type sent to the database. Array of IPv4 or IPv6 expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 307 | 337 | } |
| 308 | - else |
|
| 309 | - smf_db_error_backtrace('Wrong value type sent to the database. Array of IPv4 or IPv6 expected. (' . $matches[2] . ')', '', E_USER_ERROR, __FILE__, __LINE__); |
|
| 310 | 338 | break; |
| 311 | 339 | |
| 312 | 340 | default: |
@@ -382,22 +410,25 @@ discard block |
||
| 382 | 410 | // Are we in SSI mode? If so try that username and password first |
| 383 | 411 | if (SMF == 'SSI' && !empty($ssi_db_user) && !empty($ssi_db_passwd)) |
| 384 | 412 | { |
| 385 | - if (empty($db_persist)) |
|
| 386 | - $db_connection = @mysqli_connect($db_server, $ssi_db_user, $ssi_db_passwd); |
|
| 387 | - else |
|
| 388 | - $db_connection = @mysqli_connect('p:' . $db_server, $ssi_db_user, $ssi_db_passwd); |
|
| 413 | + if (empty($db_persist)) { |
|
| 414 | + $db_connection = @mysqli_connect($db_server, $ssi_db_user, $ssi_db_passwd); |
|
| 415 | + } else { |
|
| 416 | + $db_connection = @mysqli_connect('p:' . $db_server, $ssi_db_user, $ssi_db_passwd); |
|
| 417 | + } |
|
| 389 | 418 | } |
| 390 | 419 | // Fall back to the regular username and password if need be |
| 391 | 420 | if (!$db_connection) |
| 392 | 421 | { |
| 393 | - if (empty($db_persist)) |
|
| 394 | - $db_connection = @mysqli_connect($db_server, $db_user, $db_passwd); |
|
| 395 | - else |
|
| 396 | - $db_connection = @mysqli_connect('p:' . $db_server, $db_user, $db_passwd); |
|
| 422 | + if (empty($db_persist)) { |
|
| 423 | + $db_connection = @mysqli_connect($db_server, $db_user, $db_passwd); |
|
| 424 | + } else { |
|
| 425 | + $db_connection = @mysqli_connect('p:' . $db_server, $db_user, $db_passwd); |
|
| 426 | + } |
|
| 397 | 427 | } |
| 398 | 428 | |
| 399 | - if (!$db_connection || !@mysqli_select_db($db_connection, $db_name)) |
|
| 400 | - $db_connection = false; |
|
| 429 | + if (!$db_connection || !@mysqli_select_db($db_connection, $db_name)) { |
|
| 430 | + $db_connection = false; |
|
| 431 | + } |
|
| 401 | 432 | |
| 402 | 433 | $connection = $db_connection; |
| 403 | 434 | } |
@@ -405,18 +436,20 @@ discard block |
||
| 405 | 436 | // One more query.... |
| 406 | 437 | $db_count = !isset($db_count) ? 1 : $db_count + 1; |
| 407 | 438 | |
| 408 | - if (empty($modSettings['disableQueryCheck']) && strpos($db_string, '\'') !== false && empty($db_values['security_override'])) |
|
| 409 | - smf_db_error_backtrace('Hacking attempt...', 'Illegal character (\') used in query...', true, __FILE__, __LINE__); |
|
| 439 | + if (empty($modSettings['disableQueryCheck']) && strpos($db_string, '\'') !== false && empty($db_values['security_override'])) { |
|
| 440 | + smf_db_error_backtrace('Hacking attempt...', 'Illegal character (\') used in query...', true, __FILE__, __LINE__); |
|
| 441 | + } |
|
| 410 | 442 | |
| 411 | 443 | // Use "ORDER BY null" to prevent Mysql doing filesorts for Group By clauses without an Order By |
| 412 | 444 | if (strpos($db_string, 'GROUP BY') !== false && strpos($db_string, 'ORDER BY') === false && preg_match('~^\s+SELECT~i', $db_string)) |
| 413 | 445 | { |
| 414 | 446 | // Add before LIMIT |
| 415 | - if ($pos = strpos($db_string, 'LIMIT ')) |
|
| 416 | - $db_string = substr($db_string, 0, $pos) . "\t\t\tORDER BY null\n" . substr($db_string, $pos, strlen($db_string)); |
|
| 417 | - else |
|
| 418 | - // Append it. |
|
| 447 | + if ($pos = strpos($db_string, 'LIMIT ')) { |
|
| 448 | + $db_string = substr($db_string, 0, $pos) . "\t\t\tORDER BY null\n" . substr($db_string, $pos, strlen($db_string)); |
|
| 449 | + } else { |
|
| 450 | + // Append it. |
|
| 419 | 451 | $db_string .= "\n\t\t\tORDER BY null"; |
| 452 | + } |
|
| 420 | 453 | } |
| 421 | 454 | |
| 422 | 455 | if (empty($db_values['security_override']) && (!empty($db_values) || strpos($db_string, '{db_prefix}') !== false)) |
@@ -438,8 +471,9 @@ discard block |
||
| 438 | 471 | list ($file, $line) = smf_db_error_backtrace('', '', 'return', __FILE__, __LINE__); |
| 439 | 472 | |
| 440 | 473 | // Initialize $db_cache if not already initialized. |
| 441 | - if (!isset($db_cache)) |
|
| 442 | - $db_cache = array(); |
|
| 474 | + if (!isset($db_cache)) { |
|
| 475 | + $db_cache = array(); |
|
| 476 | + } |
|
| 443 | 477 | |
| 444 | 478 | if (!empty($_SESSION['debug_redirect'])) |
| 445 | 479 | { |
@@ -465,17 +499,18 @@ discard block |
||
| 465 | 499 | while (true) |
| 466 | 500 | { |
| 467 | 501 | $pos = strpos($db_string, '\'', $pos + 1); |
| 468 | - if ($pos === false) |
|
| 469 | - break; |
|
| 502 | + if ($pos === false) { |
|
| 503 | + break; |
|
| 504 | + } |
|
| 470 | 505 | $clean .= substr($db_string, $old_pos, $pos - $old_pos); |
| 471 | 506 | |
| 472 | 507 | while (true) |
| 473 | 508 | { |
| 474 | 509 | $pos1 = strpos($db_string, '\'', $pos + 1); |
| 475 | 510 | $pos2 = strpos($db_string, '\\', $pos + 1); |
| 476 | - if ($pos1 === false) |
|
| 477 | - break; |
|
| 478 | - elseif ($pos2 === false || $pos2 > $pos1) |
|
| 511 | + if ($pos1 === false) { |
|
| 512 | + break; |
|
| 513 | + } elseif ($pos2 === false || $pos2 > $pos1) |
|
| 479 | 514 | { |
| 480 | 515 | $pos = $pos1; |
| 481 | 516 | break; |
@@ -491,29 +526,35 @@ discard block |
||
| 491 | 526 | $clean = trim(strtolower(preg_replace($allowed_comments_from, $allowed_comments_to, $clean))); |
| 492 | 527 | |
| 493 | 528 | // Comments? We don't use comments in our queries, we leave 'em outside! |
| 494 | - if (strpos($clean, '/*') > 2 || strpos($clean, '--') !== false || strpos($clean, ';') !== false) |
|
| 495 | - $fail = true; |
|
| 529 | + if (strpos($clean, '/*') > 2 || strpos($clean, '--') !== false || strpos($clean, ';') !== false) { |
|
| 530 | + $fail = true; |
|
| 531 | + } |
|
| 496 | 532 | // Trying to change passwords, slow us down, or something? |
| 497 | - elseif (strpos($clean, 'sleep') !== false && preg_match('~(^|[^a-z])sleep($|[^[_a-z])~s', $clean) != 0) |
|
| 498 | - $fail = true; |
|
| 499 | - elseif (strpos($clean, 'benchmark') !== false && preg_match('~(^|[^a-z])benchmark($|[^[a-z])~s', $clean) != 0) |
|
| 500 | - $fail = true; |
|
| 533 | + elseif (strpos($clean, 'sleep') !== false && preg_match('~(^|[^a-z])sleep($|[^[_a-z])~s', $clean) != 0) { |
|
| 534 | + $fail = true; |
|
| 535 | + } elseif (strpos($clean, 'benchmark') !== false && preg_match('~(^|[^a-z])benchmark($|[^[a-z])~s', $clean) != 0) { |
|
| 536 | + $fail = true; |
|
| 537 | + } |
|
| 501 | 538 | |
| 502 | - if (!empty($fail) && function_exists('log_error')) |
|
| 503 | - smf_db_error_backtrace('Hacking attempt...', 'Hacking attempt...' . "\n" . $db_string, E_USER_ERROR, __FILE__, __LINE__); |
|
| 539 | + if (!empty($fail) && function_exists('log_error')) { |
|
| 540 | + smf_db_error_backtrace('Hacking attempt...', 'Hacking attempt...' . "\n" . $db_string, E_USER_ERROR, __FILE__, __LINE__); |
|
| 541 | + } |
|
| 504 | 542 | } |
| 505 | 543 | |
| 506 | - if (empty($db_unbuffered)) |
|
| 507 | - $ret = @mysqli_query($connection, $db_string); |
|
| 508 | - else |
|
| 509 | - $ret = @mysqli_query($connection, $db_string, MYSQLI_USE_RESULT); |
|
| 544 | + if (empty($db_unbuffered)) { |
|
| 545 | + $ret = @mysqli_query($connection, $db_string); |
|
| 546 | + } else { |
|
| 547 | + $ret = @mysqli_query($connection, $db_string, MYSQLI_USE_RESULT); |
|
| 548 | + } |
|
| 510 | 549 | |
| 511 | - if ($ret === false && empty($db_values['db_error_skip'])) |
|
| 512 | - $ret = smf_db_error($db_string, $connection); |
|
| 550 | + if ($ret === false && empty($db_values['db_error_skip'])) { |
|
| 551 | + $ret = smf_db_error($db_string, $connection); |
|
| 552 | + } |
|
| 513 | 553 | |
| 514 | 554 | // Debugging. |
| 515 | - if (isset($db_show_debug) && $db_show_debug === true) |
|
| 516 | - $db_cache[$db_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st)); |
|
| 555 | + if (isset($db_show_debug) && $db_show_debug === true) { |
|
| 556 | + $db_cache[$db_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st)); |
|
| 557 | + } |
|
| 517 | 558 | |
| 518 | 559 | return $ret; |
| 519 | 560 | } |
@@ -560,12 +601,13 @@ discard block |
||
| 560 | 601 | // Decide which connection to use |
| 561 | 602 | $connection = $connection === null ? $db_connection : $connection; |
| 562 | 603 | |
| 563 | - if ($type == 'begin') |
|
| 564 | - return @mysqli_query($connection, 'BEGIN'); |
|
| 565 | - elseif ($type == 'rollback') |
|
| 566 | - return @mysqli_query($connection, 'ROLLBACK'); |
|
| 567 | - elseif ($type == 'commit') |
|
| 568 | - return @mysqli_query($connection, 'COMMIT'); |
|
| 604 | + if ($type == 'begin') { |
|
| 605 | + return @mysqli_query($connection, 'BEGIN'); |
|
| 606 | + } elseif ($type == 'rollback') { |
|
| 607 | + return @mysqli_query($connection, 'ROLLBACK'); |
|
| 608 | + } elseif ($type == 'commit') { |
|
| 609 | + return @mysqli_query($connection, 'COMMIT'); |
|
| 610 | + } |
|
| 569 | 611 | |
| 570 | 612 | return false; |
| 571 | 613 | } |
@@ -605,8 +647,9 @@ discard block |
||
| 605 | 647 | // 2013: Lost connection to server during query. |
| 606 | 648 | |
| 607 | 649 | // Log the error. |
| 608 | - if ($query_errno != 1213 && $query_errno != 1205 && function_exists('log_error')) |
|
| 609 | - log_error($txt['database_error'] . ': ' . $query_error . (!empty($modSettings['enableErrorQueryLogging']) ? "\n\n$db_string" : ''), 'database', $file, $line); |
|
| 650 | + if ($query_errno != 1213 && $query_errno != 1205 && function_exists('log_error')) { |
|
| 651 | + log_error($txt['database_error'] . ': ' . $query_error . (!empty($modSettings['enableErrorQueryLogging']) ? "\n\n$db_string" : ''), 'database', $file, $line); |
|
| 652 | + } |
|
| 610 | 653 | |
| 611 | 654 | // Database error auto fixing ;). |
| 612 | 655 | if (function_exists('cache_get_data') && (!isset($modSettings['autoFixDatabase']) || $modSettings['autoFixDatabase'] == '1')) |
@@ -615,8 +658,9 @@ discard block |
||
| 615 | 658 | $old_cache = @$modSettings['cache_enable']; |
| 616 | 659 | $modSettings['cache_enable'] = '1'; |
| 617 | 660 | |
| 618 | - if (($temp = cache_get_data('db_last_error', 600)) !== null) |
|
| 619 | - $db_last_error = max(@$db_last_error, $temp); |
|
| 661 | + if (($temp = cache_get_data('db_last_error', 600)) !== null) { |
|
| 662 | + $db_last_error = max(@$db_last_error, $temp); |
|
| 663 | + } |
|
| 620 | 664 | |
| 621 | 665 | if (@$db_last_error < time() - 3600 * 24 * 3) |
| 622 | 666 | { |
@@ -632,8 +676,9 @@ discard block |
||
| 632 | 676 | foreach ($tables as $table) |
| 633 | 677 | { |
| 634 | 678 | // Now, it's still theoretically possible this could be an injection. So backtick it! |
| 635 | - if (trim($table) != '') |
|
| 636 | - $fix_tables[] = '`' . strtr(trim($table), array('`' => '')) . '`'; |
|
| 679 | + if (trim($table) != '') { |
|
| 680 | + $fix_tables[] = '`' . strtr(trim($table), array('`' => '')) . '`'; |
|
| 681 | + } |
|
| 637 | 682 | } |
| 638 | 683 | } |
| 639 | 684 | |
@@ -642,8 +687,9 @@ discard block |
||
| 642 | 687 | // Table crashed. Let's try to fix it. |
| 643 | 688 | elseif ($query_errno == 1016) |
| 644 | 689 | { |
| 645 | - if (preg_match('~\'([^\.\']+)~', $query_error, $match) != 0) |
|
| 646 | - $fix_tables = array('`' . $match[1] . '`'); |
|
| 690 | + if (preg_match('~\'([^\.\']+)~', $query_error, $match) != 0) { |
|
| 691 | + $fix_tables = array('`' . $match[1] . '`'); |
|
| 692 | + } |
|
| 647 | 693 | } |
| 648 | 694 | // Indexes crashed. Should be easy to fix! |
| 649 | 695 | elseif ($query_errno == 1034 || $query_errno == 1035) |
@@ -662,13 +708,15 @@ discard block |
||
| 662 | 708 | |
| 663 | 709 | // Make a note of the REPAIR... |
| 664 | 710 | cache_put_data('db_last_error', time(), 600); |
| 665 | - if (($temp = cache_get_data('db_last_error', 600)) === null) |
|
| 666 | - updateSettingsFile(array('db_last_error' => time())); |
|
| 711 | + if (($temp = cache_get_data('db_last_error', 600)) === null) { |
|
| 712 | + updateSettingsFile(array('db_last_error' => time())); |
|
| 713 | + } |
|
| 667 | 714 | |
| 668 | 715 | // Attempt to find and repair the broken table. |
| 669 | - foreach ($fix_tables as $table) |
|
| 670 | - $smcFunc['db_query']('', " |
|
| 716 | + foreach ($fix_tables as $table) { |
|
| 717 | + $smcFunc['db_query']('', " |
|
| 671 | 718 | REPAIR TABLE $table", false, false); |
| 719 | + } |
|
| 672 | 720 | |
| 673 | 721 | // And send off an email! |
| 674 | 722 | sendmail($webmaster_email, $txt['database_error'], $txt['tried_to_repair'], null, 'dberror'); |
@@ -677,11 +725,12 @@ discard block |
||
| 677 | 725 | |
| 678 | 726 | // Try the query again...? |
| 679 | 727 | $ret = $smcFunc['db_query']('', $db_string, false, false); |
| 680 | - if ($ret !== false) |
|
| 681 | - return $ret; |
|
| 728 | + if ($ret !== false) { |
|
| 729 | + return $ret; |
|
| 730 | + } |
|
| 731 | + } else { |
|
| 732 | + $modSettings['cache_enable'] = $old_cache; |
|
| 682 | 733 | } |
| 683 | - else |
|
| 684 | - $modSettings['cache_enable'] = $old_cache; |
|
| 685 | 734 | |
| 686 | 735 | // Check for the "lost connection" or "deadlock found" errors - and try it just one more time. |
| 687 | 736 | if (in_array($query_errno, array(1205, 1213, 2006, 2013))) |
@@ -691,22 +740,25 @@ discard block |
||
| 691 | 740 | // Are we in SSI mode? If so try that username and password first |
| 692 | 741 | if (SMF == 'SSI' && !empty($ssi_db_user) && !empty($ssi_db_passwd)) |
| 693 | 742 | { |
| 694 | - if (empty($db_persist)) |
|
| 695 | - $db_connection = @mysqli_connect($db_server, $ssi_db_user, $ssi_db_passwd); |
|
| 696 | - else |
|
| 697 | - $db_connection = @mysqli_connect('p:' . $db_server, $ssi_db_user, $ssi_db_passwd); |
|
| 743 | + if (empty($db_persist)) { |
|
| 744 | + $db_connection = @mysqli_connect($db_server, $ssi_db_user, $ssi_db_passwd); |
|
| 745 | + } else { |
|
| 746 | + $db_connection = @mysqli_connect('p:' . $db_server, $ssi_db_user, $ssi_db_passwd); |
|
| 747 | + } |
|
| 698 | 748 | } |
| 699 | 749 | // Fall back to the regular username and password if need be |
| 700 | 750 | if (!$db_connection) |
| 701 | 751 | { |
| 702 | - if (empty($db_persist)) |
|
| 703 | - $db_connection = @mysqli_connect($db_server, $db_user, $db_passwd); |
|
| 704 | - else |
|
| 705 | - $db_connection = @mysqli_connect('p:' . $db_server, $db_user, $db_passwd); |
|
| 752 | + if (empty($db_persist)) { |
|
| 753 | + $db_connection = @mysqli_connect($db_server, $db_user, $db_passwd); |
|
| 754 | + } else { |
|
| 755 | + $db_connection = @mysqli_connect('p:' . $db_server, $db_user, $db_passwd); |
|
| 756 | + } |
|
| 706 | 757 | } |
| 707 | 758 | |
| 708 | - if (!$db_connection || !@mysqli_select_db($db_connection, $db_name)) |
|
| 709 | - $db_connection = false; |
|
| 759 | + if (!$db_connection || !@mysqli_select_db($db_connection, $db_name)) { |
|
| 760 | + $db_connection = false; |
|
| 761 | + } |
|
| 710 | 762 | } |
| 711 | 763 | |
| 712 | 764 | if ($db_connection) |
@@ -717,24 +769,27 @@ discard block |
||
| 717 | 769 | $ret = $smcFunc['db_query']('', $db_string, false, false); |
| 718 | 770 | |
| 719 | 771 | $new_errno = mysqli_errno($db_connection); |
| 720 | - if ($ret !== false || in_array($new_errno, array(1205, 1213))) |
|
| 721 | - break; |
|
| 772 | + if ($ret !== false || in_array($new_errno, array(1205, 1213))) { |
|
| 773 | + break; |
|
| 774 | + } |
|
| 722 | 775 | } |
| 723 | 776 | |
| 724 | 777 | // If it failed again, shucks to be you... we're not trying it over and over. |
| 725 | - if ($ret !== false) |
|
| 726 | - return $ret; |
|
| 778 | + if ($ret !== false) { |
|
| 779 | + return $ret; |
|
| 780 | + } |
|
| 727 | 781 | } |
| 728 | 782 | } |
| 729 | 783 | // Are they out of space, perhaps? |
| 730 | 784 | elseif ($query_errno == 1030 && (strpos($query_error, ' -1 ') !== false || strpos($query_error, ' 28 ') !== false || strpos($query_error, ' 12 ') !== false)) |
| 731 | 785 | { |
| 732 | - if (!isset($txt)) |
|
| 733 | - $query_error .= ' - check database storage space.'; |
|
| 734 | - else |
|
| 786 | + if (!isset($txt)) { |
|
| 787 | + $query_error .= ' - check database storage space.'; |
|
| 788 | + } else |
|
| 735 | 789 | { |
| 736 | - if (!isset($txt['mysql_error_space'])) |
|
| 737 | - loadLanguage('Errors'); |
|
| 790 | + if (!isset($txt['mysql_error_space'])) { |
|
| 791 | + loadLanguage('Errors'); |
|
| 792 | + } |
|
| 738 | 793 | |
| 739 | 794 | $query_error .= !isset($txt['mysql_error_space']) ? ' - check database storage space.' : $txt['mysql_error_space']; |
| 740 | 795 | } |
@@ -742,15 +797,17 @@ discard block |
||
| 742 | 797 | } |
| 743 | 798 | |
| 744 | 799 | // Nothing's defined yet... just die with it. |
| 745 | - if (empty($context) || empty($txt)) |
|
| 746 | - die($query_error); |
|
| 800 | + if (empty($context) || empty($txt)) { |
|
| 801 | + die($query_error); |
|
| 802 | + } |
|
| 747 | 803 | |
| 748 | 804 | // Show an error message, if possible. |
| 749 | 805 | $context['error_title'] = $txt['database_error']; |
| 750 | - if (allowedTo('admin_forum')) |
|
| 751 | - $context['error_message'] = nl2br($query_error) . '<br>' . $txt['file'] . ': ' . $file . '<br>' . $txt['line'] . ': ' . $line; |
|
| 752 | - else |
|
| 753 | - $context['error_message'] = $txt['try_again']; |
|
| 806 | + if (allowedTo('admin_forum')) { |
|
| 807 | + $context['error_message'] = nl2br($query_error) . '<br>' . $txt['file'] . ': ' . $file . '<br>' . $txt['line'] . ': ' . $line; |
|
| 808 | + } else { |
|
| 809 | + $context['error_message'] = $txt['try_again']; |
|
| 810 | + } |
|
| 754 | 811 | |
| 755 | 812 | if (allowedTo('admin_forum') && isset($db_show_debug) && $db_show_debug === true) |
| 756 | 813 | { |
@@ -780,25 +837,28 @@ discard block |
||
| 780 | 837 | $connection = $connection === null ? $db_connection : $connection; |
| 781 | 838 | |
| 782 | 839 | // With nothing to insert, simply return. |
| 783 | - if (empty($data)) |
|
| 784 | - return; |
|
| 840 | + if (empty($data)) { |
|
| 841 | + return; |
|
| 842 | + } |
|
| 785 | 843 | |
| 786 | 844 | // Replace the prefix holder with the actual prefix. |
| 787 | 845 | $table = str_replace('{db_prefix}', $db_prefix, $table); |
| 788 | 846 | |
| 789 | 847 | // Inserting data as a single row can be done as a single array. |
| 790 | - if (!is_array($data[array_rand($data)])) |
|
| 791 | - $data = array($data); |
|
| 848 | + if (!is_array($data[array_rand($data)])) { |
|
| 849 | + $data = array($data); |
|
| 850 | + } |
|
| 792 | 851 | |
| 793 | 852 | // Create the mold for a single row insert. |
| 794 | 853 | $insertData = '('; |
| 795 | 854 | foreach ($columns as $columnName => $type) |
| 796 | 855 | { |
| 797 | 856 | // Are we restricting the length? |
| 798 | - if (strpos($type, 'string-') !== false) |
|
| 799 | - $insertData .= sprintf('SUBSTRING({string:%1$s}, 1, ' . substr($type, 7) . '), ', $columnName); |
|
| 800 | - else |
|
| 801 | - $insertData .= sprintf('{%1$s:%2$s}, ', $type, $columnName); |
|
| 857 | + if (strpos($type, 'string-') !== false) { |
|
| 858 | + $insertData .= sprintf('SUBSTRING({string:%1$s}, 1, ' . substr($type, 7) . '), ', $columnName); |
|
| 859 | + } else { |
|
| 860 | + $insertData .= sprintf('{%1$s:%2$s}, ', $type, $columnName); |
|
| 861 | + } |
|
| 802 | 862 | } |
| 803 | 863 | $insertData = substr($insertData, 0, -2) . ')'; |
| 804 | 864 | |
@@ -807,8 +867,9 @@ discard block |
||
| 807 | 867 | |
| 808 | 868 | // Here's where the variables are injected to the query. |
| 809 | 869 | $insertRows = array(); |
| 810 | - foreach ($data as $dataRow) |
|
| 811 | - $insertRows[] = smf_db_quote($insertData, array_combine($indexed_columns, $dataRow), $connection); |
|
| 870 | + foreach ($data as $dataRow) { |
|
| 871 | + $insertRows[] = smf_db_quote($insertData, array_combine($indexed_columns, $dataRow), $connection); |
|
| 872 | + } |
|
| 812 | 873 | |
| 813 | 874 | // Determine the method of insertion. |
| 814 | 875 | $queryTitle = $method == 'replace' ? 'REPLACE' : ($method == 'ignore' ? 'INSERT IGNORE' : 'INSERT'); |
@@ -828,15 +889,16 @@ discard block |
||
| 828 | 889 | |
| 829 | 890 | if(!empty($keys) && (count($keys) > 0) && $method == '' && $returnmode > 0) |
| 830 | 891 | { |
| 831 | - if ($returnmode == 1) |
|
| 832 | - $return_var = smf_db_insert_id($table, $keys[0]) + count($insertRows) - 1; |
|
| 833 | - else if ($returnmode == 2) |
|
| 892 | + if ($returnmode == 1) { |
|
| 893 | + $return_var = smf_db_insert_id($table, $keys[0]) + count($insertRows) - 1; |
|
| 894 | + } else if ($returnmode == 2) |
|
| 834 | 895 | { |
| 835 | 896 | $return_var = array(); |
| 836 | 897 | $count = count($insertRows); |
| 837 | 898 | $start = smf_db_insert_id($table, $keys[0]); |
| 838 | - for ($i = 0; $i < $count; $i++ ) |
|
| 839 | - $return_var[] = $start + $i; |
|
| 899 | + for ($i = 0; $i < $count; $i++ ) { |
|
| 900 | + $return_var[] = $start + $i; |
|
| 901 | + } |
|
| 840 | 902 | } |
| 841 | 903 | return $return_var; |
| 842 | 904 | } |
@@ -854,8 +916,9 @@ discard block |
||
| 854 | 916 | */ |
| 855 | 917 | function smf_db_error_backtrace($error_message, $log_message = '', $error_type = false, $file = null, $line = null) |
| 856 | 918 | { |
| 857 | - if (empty($log_message)) |
|
| 858 | - $log_message = $error_message; |
|
| 919 | + if (empty($log_message)) { |
|
| 920 | + $log_message = $error_message; |
|
| 921 | + } |
|
| 859 | 922 | |
| 860 | 923 | foreach (debug_backtrace() as $step) |
| 861 | 924 | { |
@@ -874,12 +937,14 @@ discard block |
||
| 874 | 937 | } |
| 875 | 938 | |
| 876 | 939 | // A special case - we want the file and line numbers for debugging. |
| 877 | - if ($error_type == 'return') |
|
| 878 | - return array($file, $line); |
|
| 940 | + if ($error_type == 'return') { |
|
| 941 | + return array($file, $line); |
|
| 942 | + } |
|
| 879 | 943 | |
| 880 | 944 | // Is always a critical error. |
| 881 | - if (function_exists('log_error')) |
|
| 882 | - log_error($log_message, 'critical', $file, $line); |
|
| 945 | + if (function_exists('log_error')) { |
|
| 946 | + log_error($log_message, 'critical', $file, $line); |
|
| 947 | + } |
|
| 883 | 948 | |
| 884 | 949 | if (function_exists('fatal_error')) |
| 885 | 950 | { |
@@ -887,12 +952,12 @@ discard block |
||
| 887 | 952 | |
| 888 | 953 | // Cannot continue... |
| 889 | 954 | exit; |
| 955 | + } elseif ($error_type) { |
|
| 956 | + trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : ''), $error_type); |
|
| 957 | + } else { |
|
| 958 | + trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : '')); |
|
| 959 | + } |
|
| 890 | 960 | } |
| 891 | - elseif ($error_type) |
|
| 892 | - trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : ''), $error_type); |
|
| 893 | - else |
|
| 894 | - trigger_error($error_message . ($line !== null ? '<em>(' . basename($file) . '-' . $line . ')</em>' : '')); |
|
| 895 | -} |
|
| 896 | 961 | |
| 897 | 962 | /** |
| 898 | 963 | * Escape the LIKE wildcards so that they match the character and not the wildcard. |
@@ -909,10 +974,11 @@ discard block |
||
| 909 | 974 | '\\' => '\\\\', |
| 910 | 975 | ); |
| 911 | 976 | |
| 912 | - if ($translate_human_wildcards) |
|
| 913 | - $replacements += array( |
|
| 977 | + if ($translate_human_wildcards) { |
|
| 978 | + $replacements += array( |
|
| 914 | 979 | '*' => '%', |
| 915 | 980 | ); |
| 981 | + } |
|
| 916 | 982 | |
| 917 | 983 | return strtr($string, $replacements); |
| 918 | 984 | } |
@@ -926,8 +992,9 @@ discard block |
||
| 926 | 992 | */ |
| 927 | 993 | function smf_is_resource($result) |
| 928 | 994 | { |
| 929 | - if ($result instanceof mysqli_result) |
|
| 930 | - return true; |
|
| 995 | + if ($result instanceof mysqli_result) { |
|
| 996 | + return true; |
|
| 997 | + } |
|
| 931 | 998 | |
| 932 | 999 | return false; |
| 933 | 1000 | } |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | class CreatePost_Notify_Background extends SMF_BackgroundTask |
| 19 | 19 | { |
| 20 | 20 | /** |
| 21 | - * This handles notifications when a new post is created - new topic, reply, quotes and mentions. |
|
| 21 | + * This handles notifications when a new post is created - new topic, reply, quotes and mentions. |
|
| 22 | 22 | * @return bool Always returns true |
| 23 | 23 | */ |
| 24 | 24 | public function execute() |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | |
| 107 | 107 | // Don't send a notification if the watching member ignored the member who made the action. |
| 108 | 108 | if (!empty($data['pm_ignore_list']) && in_array($data['id_member_updated'], explode(',', $data['pm_ignore_list']))) |
| 109 | - continue; |
|
| 109 | + continue; |
|
| 110 | 110 | if (!in_array($type, array('reply', 'topic')) && $notify_types == 2 && $member != $data['id_member_started']) |
| 111 | 111 | continue; |
| 112 | 112 | elseif (in_array($type, array('reply', 'topic')) && $member == $posterOptions['id']) |
@@ -73,8 +73,9 @@ discard block |
||
| 73 | 73 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 74 | 74 | { |
| 75 | 75 | $groups = array_merge(array($row['id_group'], $row['id_post_group']), (empty($row['additional_groups']) ? array() : explode(',', $row['additional_groups']))); |
| 76 | - if (!in_array(1, $groups) && count(array_intersect($groups, explode(',', $row['member_groups']))) == 0) |
|
| 77 | - continue; |
|
| 76 | + if (!in_array(1, $groups) && count(array_intersect($groups, explode(',', $row['member_groups']))) == 0) { |
|
| 77 | + continue; |
|
| 78 | + } |
|
| 78 | 79 | |
| 79 | 80 | $members[] = $row['id_member']; |
| 80 | 81 | $watched[$row['id_member']] = $row; |
@@ -82,8 +83,9 @@ discard block |
||
| 82 | 83 | |
| 83 | 84 | $smcFunc['db_free_result']($request); |
| 84 | 85 | |
| 85 | - if (empty($members)) |
|
| 86 | - return true; |
|
| 86 | + if (empty($members)) { |
|
| 87 | + return true; |
|
| 88 | + } |
|
| 87 | 89 | |
| 88 | 90 | $members = array_unique($members); |
| 89 | 91 | $prefs = getNotifyPrefs($members, '', true); |
@@ -105,20 +107,23 @@ discard block |
||
| 105 | 107 | $notify_types = !empty($prefs[$member]['msg_notify_type']) ? $prefs[$member]['msg_notify_type'] : 1; |
| 106 | 108 | |
| 107 | 109 | // Don't send a notification if the watching member ignored the member who made the action. |
| 108 | - if (!empty($data['pm_ignore_list']) && in_array($data['id_member_updated'], explode(',', $data['pm_ignore_list']))) |
|
| 109 | - continue; |
|
| 110 | - if (!in_array($type, array('reply', 'topic')) && $notify_types == 2 && $member != $data['id_member_started']) |
|
| 111 | - continue; |
|
| 112 | - elseif (in_array($type, array('reply', 'topic')) && $member == $posterOptions['id']) |
|
| 113 | - continue; |
|
| 114 | - elseif (!in_array($type, array('reply', 'topic')) && $notify_types == 3) |
|
| 115 | - continue; |
|
| 116 | - elseif ($notify_types == 4) |
|
| 117 | - continue; |
|
| 110 | + if (!empty($data['pm_ignore_list']) && in_array($data['id_member_updated'], explode(',', $data['pm_ignore_list']))) { |
|
| 111 | + continue; |
|
| 112 | + } |
|
| 113 | + if (!in_array($type, array('reply', 'topic')) && $notify_types == 2 && $member != $data['id_member_started']) { |
|
| 114 | + continue; |
|
| 115 | + } elseif (in_array($type, array('reply', 'topic')) && $member == $posterOptions['id']) { |
|
| 116 | + continue; |
|
| 117 | + } elseif (!in_array($type, array('reply', 'topic')) && $notify_types == 3) { |
|
| 118 | + continue; |
|
| 119 | + } elseif ($notify_types == 4) { |
|
| 120 | + continue; |
|
| 121 | + } |
|
| 118 | 122 | |
| 119 | 123 | if ($frequency > 2 || (!empty($frequency) && $data['sent']) || in_array($member, $done_members) |
| 120 | - || (!empty($this->_details['members_only']) && !in_array($member, $this->_details['members_only']))) |
|
| 121 | - continue; |
|
| 124 | + || (!empty($this->_details['members_only']) && !in_array($member, $this->_details['members_only']))) { |
|
| 125 | + continue; |
|
| 126 | + } |
|
| 122 | 127 | |
| 123 | 128 | // Watched topic? |
| 124 | 129 | if (!empty($data['id_topic']) && $type != 'topic' && !empty($prefs[$member])) |
@@ -128,10 +133,12 @@ discard block |
||
| 128 | 133 | |
| 129 | 134 | if ($type == 'reply') |
| 130 | 135 | { |
| 131 | - if (!empty($prefs[$member]['msg_receive_body'])) |
|
| 132 | - $message_type .= '_body'; |
|
| 133 | - if (!empty($frequency)) |
|
| 134 | - $message_type .= '_once'; |
|
| 136 | + if (!empty($prefs[$member]['msg_receive_body'])) { |
|
| 137 | + $message_type .= '_body'; |
|
| 138 | + } |
|
| 139 | + if (!empty($frequency)) { |
|
| 140 | + $message_type .= '_once'; |
|
| 141 | + } |
|
| 135 | 142 | } |
| 136 | 143 | |
| 137 | 144 | $content_type = 'topic'; |
@@ -144,12 +151,14 @@ discard block |
||
| 144 | 151 | $content_type = 'board'; |
| 145 | 152 | |
| 146 | 153 | $message_type = !empty($frequency) ? 'notify_boards_once' : 'notify_boards'; |
| 147 | - if (!empty($prefs[$member]['msg_receive_body'])) |
|
| 148 | - $message_type .= '_body'; |
|
| 154 | + if (!empty($prefs[$member]['msg_receive_body'])) { |
|
| 155 | + $message_type .= '_body'; |
|
| 156 | + } |
|
| 149 | 157 | } |
| 150 | 158 | // If neither of the above, this might be a redundent row due to the OR clause in our SQL query, skip |
| 151 | - else |
|
| 152 | - continue; |
|
| 159 | + else { |
|
| 160 | + continue; |
|
| 161 | + } |
|
| 153 | 162 | |
| 154 | 163 | if ($pref & 0x02) |
| 155 | 164 | { |
@@ -212,14 +221,15 @@ discard block |
||
| 212 | 221 | ); |
| 213 | 222 | |
| 214 | 223 | // Insert the alerts if any |
| 215 | - if (!empty($alert_rows)) |
|
| 216 | - $smcFunc['db_insert']('', |
|
| 224 | + if (!empty($alert_rows)) { |
|
| 225 | + $smcFunc['db_insert']('', |
|
| 217 | 226 | '{db_prefix}user_alerts', |
| 218 | 227 | array('alert_time' => 'int', 'id_member' => 'int', 'id_member_started' => 'int', 'member_name' => 'string', |
| 219 | 228 | 'content_type' => 'string', 'content_id' => 'int', 'content_action' => 'string', 'is_read' => 'int', 'extra' => 'string'), |
| 220 | 229 | $alert_rows, |
| 221 | 230 | array() |
| 222 | 231 | ); |
| 232 | + } |
|
| 223 | 233 | |
| 224 | 234 | return true; |
| 225 | 235 | } |
@@ -230,8 +240,9 @@ discard block |
||
| 230 | 240 | |
| 231 | 241 | foreach ($quotedMembers as $id => $member) |
| 232 | 242 | { |
| 233 | - if (!isset($prefs[$id]) || $id == $posterOptions['id'] || empty($prefs[$id]['msg_quote'])) |
|
| 234 | - continue; |
|
| 243 | + if (!isset($prefs[$id]) || $id == $posterOptions['id'] || empty($prefs[$id]['msg_quote'])) { |
|
| 244 | + continue; |
|
| 245 | + } |
|
| 235 | 246 | |
| 236 | 247 | $done_members[] = $id; |
| 237 | 248 | |
@@ -283,32 +294,35 @@ discard block |
||
| 283 | 294 | { |
| 284 | 295 | if (preg_match('/\[quote(.*)?\]/i', $block, $matches)) |
| 285 | 296 | { |
| 286 | - if ($quote_level == 0) |
|
| 287 | - $message .= '[quote' . $matches[1] . ']'; |
|
| 297 | + if ($quote_level == 0) { |
|
| 298 | + $message .= '[quote' . $matches[1] . ']'; |
|
| 299 | + } |
|
| 288 | 300 | $quote_level++; |
| 289 | - } |
|
| 290 | - elseif (preg_match('/\[\/quote\]/i', $block)) |
|
| 301 | + } elseif (preg_match('/\[\/quote\]/i', $block)) |
|
| 291 | 302 | { |
| 292 | - if ($quote_level <= 1) |
|
| 293 | - $message .= '[/quote]'; |
|
| 303 | + if ($quote_level <= 1) { |
|
| 304 | + $message .= '[/quote]'; |
|
| 305 | + } |
|
| 294 | 306 | if ($quote_level >= 1) |
| 295 | 307 | { |
| 296 | 308 | $quote_level--; |
| 297 | 309 | $message .= "\n"; |
| 298 | 310 | } |
| 311 | + } elseif ($quote_level <= 1) { |
|
| 312 | + $message .= $block; |
|
| 299 | 313 | } |
| 300 | - elseif ($quote_level <= 1) |
|
| 301 | - $message .= $block; |
|
| 302 | 314 | } |
| 303 | 315 | |
| 304 | 316 | preg_match_all('/\[quote.*?link=msg=([0-9]+).*?\]/i', $message, $matches); |
| 305 | 317 | |
| 306 | 318 | $id_msgs = $matches[1]; |
| 307 | - foreach ($id_msgs as $k => $id_msg) |
|
| 308 | - $id_msgs[$k] = (int) $id_msg; |
|
| 319 | + foreach ($id_msgs as $k => $id_msg) { |
|
| 320 | + $id_msgs[$k] = (int) $id_msg; |
|
| 321 | + } |
|
| 309 | 322 | |
| 310 | - if (empty($id_msgs)) |
|
| 311 | - return array(); |
|
| 323 | + if (empty($id_msgs)) { |
|
| 324 | + return array(); |
|
| 325 | + } |
|
| 312 | 326 | |
| 313 | 327 | // Get the messages |
| 314 | 328 | $request = $smcFunc['db_query']('', ' |
@@ -326,8 +340,9 @@ discard block |
||
| 326 | 340 | $members = array(); |
| 327 | 341 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 328 | 342 | { |
| 329 | - if ($posterOptions['id'] == $row['id_member']) |
|
| 330 | - continue; |
|
| 343 | + if ($posterOptions['id'] == $row['id_member']) { |
|
| 344 | + continue; |
|
| 345 | + } |
|
| 331 | 346 | |
| 332 | 347 | $members[$row['id_member']] = $row; |
| 333 | 348 | } |
@@ -341,10 +356,11 @@ discard block |
||
| 341 | 356 | |
| 342 | 357 | foreach ($members as $id => $member) |
| 343 | 358 | { |
| 344 | - if (!empty($prefs[$id]['msg_mention'])) |
|
| 345 | - $done_members[] = $id; |
|
| 346 | - else |
|
| 347 | - continue; |
|
| 359 | + if (!empty($prefs[$id]['msg_mention'])) { |
|
| 360 | + $done_members[] = $id; |
|
| 361 | + } else { |
|
| 362 | + continue; |
|
| 363 | + } |
|
| 348 | 364 | |
| 349 | 365 | // Alerts' emails are always instant |
| 350 | 366 | if ($prefs[$id]['msg_mention'] & 0x02) |