Changeset 42343 for trunk/src/wp-includes/load.php
- Timestamp:
- 11/30/2017 11:09:33 PM (9 years ago)
- File:
-
- 1 edited
-
trunk/src/wp-includes/load.php (modified) (39 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/load.php
r42217 r42343 28 28 */ 29 29 function wp_unregister_GLOBALS() { 30 if ( ! ini_get( 'register_globals' ) )30 if ( ! ini_get( 'register_globals' ) ) { 31 31 return; 32 33 if ( isset( $_REQUEST['GLOBALS'] ) ) 32 } 33 34 if ( isset( $_REQUEST['GLOBALS'] ) ) { 34 35 die( 'GLOBALS overwrite attempt detected' ); 36 } 35 37 36 38 // Variables that shouldn't be unset … … 38 40 39 41 $input = array_merge( $_GET, $_POST, $_COOKIE, $_SERVER, $_ENV, $_FILES, isset( $_SESSION ) && is_array( $_SESSION ) ? $_SESSION : array() ); 40 foreach ( $input as $k => $v ) 41 if ( !in_array( $k, $no_unset ) && isset( $GLOBALS[$k] ) ) { 42 unset( $GLOBALS[$k] ); 43 } 42 foreach ( $input as $k => $v ) { 43 if ( ! in_array( $k, $no_unset ) && isset( $GLOBALS[ $k ] ) ) { 44 unset( $GLOBALS[ $k ] ); 45 } 46 } 44 47 } 45 48 … … 58 61 $default_server_values = array( 59 62 'SERVER_SOFTWARE' => '', 60 'REQUEST_URI' => '',63 'REQUEST_URI' => '', 61 64 ); 62 65 … … 69 72 if ( isset( $_SERVER['HTTP_X_ORIGINAL_URL'] ) ) { 70 73 $_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_ORIGINAL_URL']; 71 } 72 // IIS Isapi_Rewrite 74 } // IIS Isapi_Rewrite 73 75 elseif ( isset( $_SERVER['HTTP_X_REWRITE_URL'] ) ) { 74 76 $_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_REWRITE_URL']; 75 77 } else { 76 78 // Use ORIG_PATH_INFO if there is no PATH_INFO 77 if ( ! isset( $_SERVER['PATH_INFO'] ) && isset( $_SERVER['ORIG_PATH_INFO'] ) )79 if ( ! isset( $_SERVER['PATH_INFO'] ) && isset( $_SERVER['ORIG_PATH_INFO'] ) ) { 78 80 $_SERVER['PATH_INFO'] = $_SERVER['ORIG_PATH_INFO']; 81 } 79 82 80 83 // Some IIS + PHP configurations puts the script-name in the path-info (No need to append it twice) 81 84 if ( isset( $_SERVER['PATH_INFO'] ) ) { 82 if ( $_SERVER['PATH_INFO'] == $_SERVER['SCRIPT_NAME'] ) 85 if ( $_SERVER['PATH_INFO'] == $_SERVER['SCRIPT_NAME'] ) { 83 86 $_SERVER['REQUEST_URI'] = $_SERVER['PATH_INFO']; 84 else87 } else { 85 88 $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'] . $_SERVER['PATH_INFO']; 89 } 86 90 } 87 91 … … 94 98 95 99 // Fix for PHP as CGI hosts that set SCRIPT_FILENAME to something ending in php.cgi for all requests 96 if ( isset( $_SERVER['SCRIPT_FILENAME'] ) && ( strpos( $_SERVER['SCRIPT_FILENAME'], 'php.cgi' ) == strlen( $_SERVER['SCRIPT_FILENAME'] ) - 7 ) ) 100 if ( isset( $_SERVER['SCRIPT_FILENAME'] ) && ( strpos( $_SERVER['SCRIPT_FILENAME'], 'php.cgi' ) == strlen( $_SERVER['SCRIPT_FILENAME'] ) - 7 ) ) { 97 101 $_SERVER['SCRIPT_FILENAME'] = $_SERVER['PATH_TRANSLATED']; 102 } 98 103 99 104 // Fix for Dreamhost and other PHP as CGI hosts 100 if ( strpos( $_SERVER['SCRIPT_NAME'], 'php.cgi' ) !== false ) 105 if ( strpos( $_SERVER['SCRIPT_NAME'], 'php.cgi' ) !== false ) { 101 106 unset( $_SERVER['PATH_INFO'] ); 107 } 102 108 103 109 // Fix empty PHP_SELF 104 110 $PHP_SELF = $_SERVER['PHP_SELF']; 105 if ( empty( $PHP_SELF ) ) 106 $_SERVER['PHP_SELF'] = $PHP_SELF = preg_replace( '/(\?.*)?$/', '', $_SERVER["REQUEST_URI"] ); 111 if ( empty( $PHP_SELF ) ) { 112 $_SERVER['PHP_SELF'] = $PHP_SELF = preg_replace( '/(\?.*)?$/', '', $_SERVER['REQUEST_URI'] ); 113 } 107 114 } 108 115 … … 152 159 function wp_favicon_request() { 153 160 if ( '/favicon.ico' == $_SERVER['REQUEST_URI'] ) { 154 header( 'Content-Type: image/vnd.microsoft.icon');161 header( 'Content-Type: image/vnd.microsoft.icon' ); 155 162 exit; 156 163 } … … 174 181 */ 175 182 function wp_maintenance() { 176 if ( ! file_exists( ABSPATH . '.maintenance' ) || wp_installing() ) 183 if ( ! file_exists( ABSPATH . '.maintenance' ) || wp_installing() ) { 177 184 return; 185 } 178 186 179 187 global $upgrading; … … 181 189 include( ABSPATH . '.maintenance' ); 182 190 // If the $upgrading timestamp is older than 10 minutes, don't die. 183 if ( ( time() - $upgrading ) >= 600 ) 191 if ( ( time() - $upgrading ) >= 600 ) { 184 192 return; 193 } 185 194 186 195 /** … … 267 276 function timer_stop( $display = 0, $precision = 3 ) { 268 277 global $timestart, $timeend; 269 $timeend = microtime( true );278 $timeend = microtime( true ); 270 279 $timetotal = $timeend - $timestart; 271 $r = ( function_exists( 'number_format_i18n' ) ) ? number_format_i18n( $timetotal, $precision ) : number_format( $timetotal, $precision );272 if ( $display ) 280 $r = ( function_exists( 'number_format_i18n' ) ) ? number_format_i18n( $timetotal, $precision ) : number_format( $timetotal, $precision ); 281 if ( $display ) { 273 282 echo $r; 283 } 274 284 return $r; 275 285 } … … 319 329 * @param bool $enable_debug_mode Whether to enable debug mode checks to occur. Default true. 320 330 */ 321 if ( ! apply_filters( 'enable_wp_debug_mode_checks', true ) ) {331 if ( ! apply_filters( 'enable_wp_debug_mode_checks', true ) ) { 322 332 return; 323 333 } … … 326 336 error_reporting( E_ALL ); 327 337 328 if ( WP_DEBUG_DISPLAY ) 338 if ( WP_DEBUG_DISPLAY ) { 329 339 ini_set( 'display_errors', 1 ); 330 elseif ( null !== WP_DEBUG_DISPLAY )340 } elseif ( null !== WP_DEBUG_DISPLAY ) { 331 341 ini_set( 'display_errors', 0 ); 342 } 332 343 333 344 if ( WP_DEBUG_LOG ) { … … 358 369 */ 359 370 function wp_set_lang_dir() { 360 if ( ! defined( 'WP_LANG_DIR' ) ) {361 if ( file_exists( WP_CONTENT_DIR . '/languages' ) && @is_dir( WP_CONTENT_DIR . '/languages' ) || ! @is_dir(ABSPATH . WPINC . '/languages') ) {371 if ( ! defined( 'WP_LANG_DIR' ) ) { 372 if ( file_exists( WP_CONTENT_DIR . '/languages' ) && @is_dir( WP_CONTENT_DIR . '/languages' ) || ! @is_dir( ABSPATH . WPINC . '/languages' ) ) { 362 373 /** 363 374 * Server path of the language directory. … … 368 379 */ 369 380 define( 'WP_LANG_DIR', WP_CONTENT_DIR . '/languages' ); 370 if ( ! defined( 'LANGDIR' ) ) {381 if ( ! defined( 'LANGDIR' ) ) { 371 382 // Old static relative path maintained for limited backward compatibility - won't work in some cases. 372 383 define( 'LANGDIR', 'wp-content/languages' ); … … 381 392 */ 382 393 define( 'WP_LANG_DIR', ABSPATH . WPINC . '/languages' ); 383 if ( ! defined( 'LANGDIR' ) ) {394 if ( ! defined( 'LANGDIR' ) ) { 384 395 // Old relative path maintained for backward compatibility. 385 396 define( 'LANGDIR', WPINC . '/languages' ); … … 400 411 401 412 require_once( ABSPATH . WPINC . '/wp-db.php' ); 402 if ( file_exists( WP_CONTENT_DIR . '/db.php' ) ) 413 if ( file_exists( WP_CONTENT_DIR . '/db.php' ) ) { 403 414 require_once( WP_CONTENT_DIR . '/db.php' ); 415 } 404 416 405 417 if ( isset( $wpdb ) ) { … … 424 436 function wp_set_wpdb_vars() { 425 437 global $wpdb, $table_prefix; 426 if ( ! empty( $wpdb->error ) )438 if ( ! empty( $wpdb->error ) ) { 427 439 dead_db(); 428 429 $wpdb->field_types = array( 'post_author' => '%d', 'post_parent' => '%d', 'menu_order' => '%d', 'term_id' => '%d', 'term_group' => '%d', 'term_taxonomy_id' => '%d', 430 'parent' => '%d', 'count' => '%d','object_id' => '%d', 'term_order' => '%d', 'ID' => '%d', 'comment_ID' => '%d', 'comment_post_ID' => '%d', 'comment_parent' => '%d', 431 'user_id' => '%d', 'link_id' => '%d', 'link_owner' => '%d', 'link_rating' => '%d', 'option_id' => '%d', 'blog_id' => '%d', 'meta_id' => '%d', 'post_id' => '%d', 432 'user_status' => '%d', 'umeta_id' => '%d', 'comment_karma' => '%d', 'comment_count' => '%d', 440 } 441 442 $wpdb->field_types = array( 443 'post_author' => '%d', 444 'post_parent' => '%d', 445 'menu_order' => '%d', 446 'term_id' => '%d', 447 'term_group' => '%d', 448 'term_taxonomy_id' => '%d', 449 'parent' => '%d', 450 'count' => '%d', 451 'object_id' => '%d', 452 'term_order' => '%d', 453 'ID' => '%d', 454 'comment_ID' => '%d', 455 'comment_post_ID' => '%d', 456 'comment_parent' => '%d', 457 'user_id' => '%d', 458 'link_id' => '%d', 459 'link_owner' => '%d', 460 'link_rating' => '%d', 461 'option_id' => '%d', 462 'blog_id' => '%d', 463 'meta_id' => '%d', 464 'post_id' => '%d', 465 'user_status' => '%d', 466 'umeta_id' => '%d', 467 'comment_karma' => '%d', 468 'comment_count' => '%d', 433 469 // multisite: 434 'active' => '%d', 'cat_id' => '%d', 'deleted' => '%d', 'lang_id' => '%d', 'mature' => '%d', 'public' => '%d', 'site_id' => '%d', 'spam' => '%d', 470 'active' => '%d', 471 'cat_id' => '%d', 472 'deleted' => '%d', 473 'lang_id' => '%d', 474 'mature' => '%d', 475 'public' => '%d', 476 'site_id' => '%d', 477 'spam' => '%d', 435 478 ); 436 479 … … 441 484 wp_die( 442 485 /* translators: 1: $table_prefix 2: wp-config.php */ 443 sprintf( __( '<strong>ERROR</strong>: %1$s in %2$s can only contain numbers, letters, and underscores.' ), 486 sprintf( 487 __( '<strong>ERROR</strong>: %1$s in %2$s can only contain numbers, letters, and underscores.' ), 444 488 '<code>$table_prefix</code>', 445 489 '<code>wp-config.php</code>' … … 463 507 global $_wp_using_ext_object_cache; 464 508 $current_using = $_wp_using_ext_object_cache; 465 if ( null !== $using ) 509 if ( null !== $using ) { 466 510 $_wp_using_ext_object_cache = $using; 511 } 467 512 return $current_using; 468 513 } … … 483 528 484 529 $first_init = false; 485 if ( ! function_exists( 'wp_cache_init' ) ) {530 if ( ! function_exists( 'wp_cache_init' ) ) { 486 531 if ( file_exists( WP_CONTENT_DIR . '/object-cache.php' ) ) { 487 require_once ( WP_CONTENT_DIR . '/object-cache.php' );532 require_once( WP_CONTENT_DIR . '/object-cache.php' ); 488 533 if ( function_exists( 'wp_cache_init' ) ) { 489 534 wp_using_ext_object_cache( true ); … … 508 553 509 554 if ( ! wp_using_ext_object_cache() ) { 510 require_once ( ABSPATH . WPINC . '/cache.php' );555 require_once( ABSPATH . WPINC . '/cache.php' ); 511 556 } 512 557 … … 571 616 function wp_get_mu_plugins() { 572 617 $mu_plugins = array(); 573 if ( ! is_dir( WPMU_PLUGIN_DIR ) )618 if ( ! is_dir( WPMU_PLUGIN_DIR ) ) { 574 619 return $mu_plugins; 575 if ( ! $dh = opendir( WPMU_PLUGIN_DIR ) ) 620 } 621 if ( ! $dh = opendir( WPMU_PLUGIN_DIR ) ) { 576 622 return $mu_plugins; 623 } 577 624 while ( ( $plugin = readdir( $dh ) ) !== false ) { 578 if ( substr( $plugin, -4 ) == '.php' ) 625 if ( substr( $plugin, -4 ) == '.php' ) { 579 626 $mu_plugins[] = WPMU_PLUGIN_DIR . '/' . $plugin; 627 } 580 628 } 581 629 closedir( $dh ); … … 600 648 */ 601 649 function wp_get_active_and_valid_plugins() { 602 $plugins = array();650 $plugins = array(); 603 651 $active_plugins = (array) get_option( 'active_plugins', array() ); 604 652 … … 609 657 } 610 658 611 if ( empty( $active_plugins ) || wp_installing() ) 659 if ( empty( $active_plugins ) || wp_installing() ) { 612 660 return $plugins; 661 } 613 662 614 663 $network_plugins = is_multisite() ? wp_get_active_network_plugins() : false; … … 620 669 // not already included as a network plugin 621 670 && ( ! $network_plugins || ! in_array( WP_PLUGIN_DIR . '/' . $plugin, $network_plugins ) ) 622 ) 623 $plugins[] = WP_PLUGIN_DIR . '/' . $plugin; 671 ) { 672 $plugins[] = WP_PLUGIN_DIR . '/' . $plugin; 673 } 624 674 } 625 675 return $plugins; … … 638 688 if ( function_exists( 'mb_internal_encoding' ) ) { 639 689 $charset = get_option( 'blog_charset' ); 640 if ( ! $charset || ! @mb_internal_encoding( $charset ) ) 690 if ( ! $charset || ! @mb_internal_encoding( $charset ) ) { 641 691 mb_internal_encoding( 'UTF-8' ); 692 } 642 693 } 643 694 } … … 655 706 // If already slashed, strip. 656 707 if ( get_magic_quotes_gpc() ) { 657 $_GET = stripslashes_deep( $_GET );658 $_POST = stripslashes_deep( $_POST );708 $_GET = stripslashes_deep( $_GET ); 709 $_POST = stripslashes_deep( $_POST ); 659 710 $_COOKIE = stripslashes_deep( $_COOKIE ); 660 711 } 661 712 662 713 // Escape with wpdb. 663 $_GET = add_magic_quotes( $_GET );664 $_POST = add_magic_quotes( $_POST );714 $_GET = add_magic_quotes( $_GET ); 715 $_POST = add_magic_quotes( $_POST ); 665 716 $_COOKIE = add_magic_quotes( $_COOKIE ); 666 717 $_SERVER = add_magic_quotes( $_SERVER ); … … 714 765 */ 715 766 function is_admin() { 716 if ( isset( $GLOBALS['current_screen'] ) ) 767 if ( isset( $GLOBALS['current_screen'] ) ) { 717 768 return $GLOBALS['current_screen']->in_admin(); 718 elseif ( defined( 'WP_ADMIN' ) )769 } elseif ( defined( 'WP_ADMIN' ) ) { 719 770 return WP_ADMIN; 771 } 720 772 721 773 return false; … … 737 789 */ 738 790 function is_blog_admin() { 739 if ( isset( $GLOBALS['current_screen'] ) ) 791 if ( isset( $GLOBALS['current_screen'] ) ) { 740 792 return $GLOBALS['current_screen']->in_admin( 'site' ); 741 elseif ( defined( 'WP_BLOG_ADMIN' ) )793 } elseif ( defined( 'WP_BLOG_ADMIN' ) ) { 742 794 return WP_BLOG_ADMIN; 795 } 743 796 744 797 return false; … … 760 813 */ 761 814 function is_network_admin() { 762 if ( isset( $GLOBALS['current_screen'] ) ) 815 if ( isset( $GLOBALS['current_screen'] ) ) { 763 816 return $GLOBALS['current_screen']->in_admin( 'network' ); 764 elseif ( defined( 'WP_NETWORK_ADMIN' ) )817 } elseif ( defined( 'WP_NETWORK_ADMIN' ) ) { 765 818 return WP_NETWORK_ADMIN; 819 } 766 820 767 821 return false; … … 784 838 */ 785 839 function is_user_admin() { 786 if ( isset( $GLOBALS['current_screen'] ) ) 840 if ( isset( $GLOBALS['current_screen'] ) ) { 787 841 return $GLOBALS['current_screen']->in_admin( 'user' ); 788 elseif ( defined( 'WP_USER_ADMIN' ) )842 } elseif ( defined( 'WP_USER_ADMIN' ) ) { 789 843 return WP_USER_ADMIN; 844 } 790 845 791 846 return false; … … 800 855 */ 801 856 function is_multisite() { 802 if ( defined( 'MULTISITE' ) ) 857 if ( defined( 'MULTISITE' ) ) { 803 858 return MULTISITE; 804 805 if ( defined( 'SUBDOMAIN_INSTALL' ) || defined( 'VHOST' ) || defined( 'SUNRISE' ) ) 859 } 860 861 if ( defined( 'SUBDOMAIN_INSTALL' ) || defined( 'VHOST' ) || defined( 'SUNRISE' ) ) { 806 862 return true; 863 } 807 864 808 865 return false; … … 820 877 function get_current_blog_id() { 821 878 global $blog_id; 822 return absint( $blog_id);879 return absint( $blog_id ); 823 880 } 824 881 … … 865 922 866 923 static $loaded = false; 867 if ( $loaded ) 924 if ( $loaded ) { 868 925 return; 926 } 869 927 $loaded = true; 870 928 871 if ( function_exists( 'did_action' ) && did_action( 'init' ) ) 929 if ( function_exists( 'did_action' ) && did_action( 'init' ) ) { 872 930 return; 931 } 873 932 874 933 // We need $wp_local_package … … 888 947 while ( true ) { 889 948 if ( defined( 'WPLANG' ) ) { 890 if ( '' == WPLANG ) 949 if ( '' == WPLANG ) { 891 950 break; 951 } 892 952 $locales[] = WPLANG; 893 953 } 894 954 895 if ( isset( $wp_local_package ) ) 955 if ( isset( $wp_local_package ) ) { 896 956 $locales[] = $wp_local_package; 897 898 if ( ! $locales ) 957 } 958 959 if ( ! $locales ) { 899 960 break; 900 901 if ( defined( 'WP_LANG_DIR' ) && @is_dir( WP_LANG_DIR ) ) 961 } 962 963 if ( defined( 'WP_LANG_DIR' ) && @is_dir( WP_LANG_DIR ) ) { 902 964 $locations[] = WP_LANG_DIR; 903 904 if ( defined( 'WP_CONTENT_DIR' ) && @is_dir( WP_CONTENT_DIR . '/languages' ) ) 965 } 966 967 if ( defined( 'WP_CONTENT_DIR' ) && @is_dir( WP_CONTENT_DIR . '/languages' ) ) { 905 968 $locations[] = WP_CONTENT_DIR . '/languages'; 906 907 if ( @is_dir( ABSPATH . 'wp-content/languages' ) ) 969 } 970 971 if ( @is_dir( ABSPATH . 'wp-content/languages' ) ) { 908 972 $locations[] = ABSPATH . 'wp-content/languages'; 909 910 if ( @is_dir( ABSPATH . WPINC . '/languages' ) ) 973 } 974 975 if ( @is_dir( ABSPATH . WPINC . '/languages' ) ) { 911 976 $locations[] = ABSPATH . WPINC . '/languages'; 912 913 if ( ! $locations ) 977 } 978 979 if ( ! $locations ) { 914 980 break; 981 } 915 982 916 983 $locations = array_unique( $locations ); … … 920 987 if ( file_exists( $location . '/' . $locale . '.mo' ) ) { 921 988 load_textdomain( 'default', $location . '/' . $locale . '.mo' ); 922 if ( defined( 'WP_SETUP_CONFIG' ) && file_exists( $location . '/admin-' . $locale . '.mo' ) ) 989 if ( defined( 'WP_SETUP_CONFIG' ) && file_exists( $location . '/admin-' . $locale . '.mo' ) ) { 923 990 load_textdomain( 'default', $location . '/admin-' . $locale . '.mo' ); 991 } 924 992 break 2; 925 993 } … … 957 1025 if ( ! is_null( $is_installing ) ) { 958 1026 $old_installing = $installing; 959 $installing = $is_installing;1027 $installing = $is_installing; 960 1028 return (bool) $old_installing; 961 1029 } … … 981 1049 return true; 982 1050 } 983 } elseif ( isset( $_SERVER['SERVER_PORT'] ) && ( '443' == $_SERVER['SERVER_PORT'] ) ) {1051 } elseif ( isset( $_SERVER['SERVER_PORT'] ) && ( '443' == $_SERVER['SERVER_PORT'] ) ) { 984 1052 return true; 985 1053 } … … 1036 1104 $ini_all = ini_get_all(); 1037 1105 } 1038 }1106 } 1039 1107 1040 1108 // Bit operator to workaround https://bugs.php.net/bug.php?id=44936 which changes access level to 63 in PHP 5.2.6 - 5.2.17. … … 1130 1198 return; 1131 1199 } 1132 $key = substr( sanitize_key( wp_unslash( $_REQUEST['wp_scrape_key'] ) ), 0, 32 );1200 $key = substr( sanitize_key( wp_unslash( $_REQUEST['wp_scrape_key'] ) ), 0, 32 ); 1133 1201 $nonce = wp_unslash( $_REQUEST['wp_scrape_nonce'] ); 1134 1202 1135 1203 if ( get_transient( 'scrape_key_' . $key ) !== $nonce ) { 1136 1204 echo "###### wp_scraping_result_start:$key ######"; 1137 echo wp_json_encode( array( 1138 'code' => 'scrape_nonce_failure', 1139 'message' => __( 'Scrape nonce check failed. Please try again.' ), 1140 ) ); 1205 echo wp_json_encode( 1206 array( 1207 'code' => 'scrape_nonce_failure', 1208 'message' => __( 'Scrape nonce check failed. Please try again.' ), 1209 ) 1210 ); 1141 1211 echo "###### wp_scraping_result_end:$key ######"; 1142 1212 die();
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)