Ticket #11881: 11881.diff
File 11881.diff, 17.4 KB (added by , 15 years ago) |
---|
-
wp-settings.php
9 9 * @package WordPress 10 10 */ 11 11 12 13 12 /** 14 * Whether Multisite support is enabled13 * Stores the location of the WordPress directory of functions, classes, and core content. 15 14 * 16 * @since 3.0 17 * 18 * @return bool True if multisite is enabled, false otherwise. 15 * @since 1.0.0 19 16 */ 20 function is_multisite() { 21 if ( ( defined('MULTISITE') && MULTISITE ) || defined('VHOST') || defined('SUNRISE') ) 22 return true; 17 define('WPINC', 'wp-includes'); 23 18 24 return false; 25 } 19 // Load initialization functions 20 require(ABSPATH . WPINC . '/init.php'); 26 21 27 22 if ( !defined('WP_MEMORY_LIMIT') ) { 28 23 if( is_multisite() ) { … … 41 36 if ( function_exists('date_default_timezone_set') ) 42 37 date_default_timezone_set('UTC'); 43 38 44 /**45 * Turn register globals off.46 *47 * @access private48 * @since 2.1.049 * @return null Will return null if register_globals PHP directive was disabled50 */51 function wp_unregister_GLOBALS() {52 if ( !ini_get('register_globals') )53 return;54 55 if ( isset($_REQUEST['GLOBALS']) )56 die('GLOBALS overwrite attempt detected');57 58 // Variables that shouldn't be unset59 $noUnset = array('GLOBALS', '_GET', '_POST', '_COOKIE', '_REQUEST', '_SERVER', '_ENV', '_FILES', 'table_prefix');60 61 $input = array_merge($_GET, $_POST, $_COOKIE, $_SERVER, $_ENV, $_FILES, isset($_SESSION) && is_array($_SESSION) ? $_SESSION : array());62 foreach ( $input as $k => $v )63 if ( !in_array($k, $noUnset) && isset($GLOBALS[$k]) ) {64 $GLOBALS[$k] = NULL;65 unset($GLOBALS[$k]);66 }67 }68 69 39 wp_unregister_GLOBALS(); 70 40 71 41 unset( $wp_filter, $cache_lastcommentmodified, $cache_lastpostdate ); … … 80 50 if ( ! isset($blog_id) ) 81 51 $blog_id = 1; 82 52 83 // Fix for IIS when running with PHP ISAPI84 if ( empty( $_SERVER['REQUEST_URI'] ) || ( php_sapi_name() != 'cgi-fcgi' && preg_match( '/^Microsoft-IIS\//', $_SERVER['SERVER_SOFTWARE'] ) ) ) { 53 // Fix $_SERVER variables 54 wp_fix_server_vars(); 85 55 86 // IIS Mod-Rewrite 87 if (isset($_SERVER['HTTP_X_ORIGINAL_URL'])) { 88 $_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_ORIGINAL_URL']; 89 } 90 // IIS Isapi_Rewrite 91 else if (isset($_SERVER['HTTP_X_REWRITE_URL'])) { 92 $_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_REWRITE_URL']; 93 } 94 else 95 { 96 // Use ORIG_PATH_INFO if there is no PATH_INFO 97 if ( !isset($_SERVER['PATH_INFO']) && isset($_SERVER['ORIG_PATH_INFO']) ) 98 $_SERVER['PATH_INFO'] = $_SERVER['ORIG_PATH_INFO']; 56 require (ABSPATH . WPINC . '/version.php'); 99 57 100 // Some IIS + PHP configurations puts the script-name in the path-info (No need to append it twice) 101 if ( isset($_SERVER['PATH_INFO']) ) { 102 if ( $_SERVER['PATH_INFO'] == $_SERVER['SCRIPT_NAME'] ) 103 $_SERVER['REQUEST_URI'] = $_SERVER['PATH_INFO']; 104 else 105 $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'] . $_SERVER['PATH_INFO']; 106 } 58 if ( version_compare( $required_php_version, phpversion(), '>' ) ) 59 die( sprintf( /*WP_I18N_OLD_PHP*/'Your server is running PHP version %s$1 but WordPress requires at least %1$2.'/*/WP_I18N_OLD_PHP*/, phpversion(), $required_php_version ) ); 107 60 108 // Append the query string if it exists and isn't null109 if (isset($_SERVER['QUERY_STRING']) && !empty($_SERVER['QUERY_STRING'])) {110 $_SERVER['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];111 }112 }113 }114 115 // Fix for PHP as CGI hosts that set SCRIPT_FILENAME to something ending in php.cgi for all requests116 if ( isset($_SERVER['SCRIPT_FILENAME']) && ( strpos($_SERVER['SCRIPT_FILENAME'], 'php.cgi') == strlen($_SERVER['SCRIPT_FILENAME']) - 7 ) )117 $_SERVER['SCRIPT_FILENAME'] = $_SERVER['PATH_TRANSLATED'];118 119 // Fix for Dreamhost and other PHP as CGI hosts120 if (strpos($_SERVER['SCRIPT_NAME'], 'php.cgi') !== false)121 unset($_SERVER['PATH_INFO']);122 123 // Fix empty PHP_SELF124 $PHP_SELF = $_SERVER['PHP_SELF'];125 if ( empty($PHP_SELF) )126 $_SERVER['PHP_SELF'] = $PHP_SELF = preg_replace("/(\?.*)?$/",'',$_SERVER["REQUEST_URI"]);127 128 if ( version_compare( '4.3', phpversion(), '>' ) ) {129 die( sprintf( /*WP_I18N_OLD_PHP*/'Your server is running PHP version %s but WordPress requires at least 4.3.'/*/WP_I18N_OLD_PHP*/, phpversion() ) );130 }131 132 61 if ( !defined('WP_CONTENT_DIR') ) 133 62 define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' ); // no trailing slash, full paths only - WP_CONTENT_URL is defined further down 134 63 135 if ( file_exists(ABSPATH . '.maintenance') && !defined('WP_INSTALLING') ) { 136 include(ABSPATH . '.maintenance'); 137 // If the $upgrading timestamp is older than 10 minutes, don't die. 138 if ( ( time() - $upgrading ) < 600 ) { 139 if ( file_exists( WP_CONTENT_DIR . '/maintenance.php' ) ) { 140 require_once( WP_CONTENT_DIR . '/maintenance.php' ); 141 die(); 142 } 64 // Check if maintenance mode should be triggered. 65 if ( file_exists(ABSPATH . '.maintenance') && !defined('WP_INSTALLING') ) 66 wp_maintenance(); 143 67 144 $protocol = $_SERVER["SERVER_PROTOCOL"];145 if ( 'HTTP/1.1' != $protocol && 'HTTP/1.0' != $protocol )146 $protocol = 'HTTP/1.0';147 header( "$protocol 503 Service Unavailable", true, 503 );148 header( 'Content-Type: text/html; charset=utf-8' );149 header( 'Retry-After: 600' );150 ?>151 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">152 <html xmlns="http://www.w3.org/1999/xhtml">153 <head>154 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />155 <title>Maintenance</title>156 157 </head>158 <body>159 <h1>Briefly unavailable for scheduled maintenance. Check back in a minute.</h1>160 </body>161 </html>162 <?php163 die();164 }165 }166 167 68 if ( !extension_loaded('mysql') && !file_exists(WP_CONTENT_DIR . '/db.php') ) 168 69 die( /*WP_I18N_OLD_MYSQL*/'Your PHP installation appears to be missing the MySQL extension which is required by WordPress.'/*/WP_I18N_OLD_MYSQL*/ ); 169 70 170 /** 171 * PHP 4 standard microtime start capture. 172 * 173 * @access private 174 * @since 0.71 175 * @global int $timestart Seconds and Microseconds added together from when function is called. 176 * @return bool Always returns true. 177 */ 178 function timer_start() { 179 global $timestart; 180 $mtime = explode(' ', microtime() ); 181 $mtime = $mtime[1] + $mtime[0]; 182 $timestart = $mtime; 183 return true; 184 } 185 186 /** 187 * Return and/or display the time from the page start to when function is called. 188 * 189 * You can get the results and print them by doing: 190 * <code> 191 * $nTimePageTookToExecute = timer_stop(); 192 * echo $nTimePageTookToExecute; 193 * </code> 194 * 195 * Or instead, you can do: 196 * <code> 197 * timer_stop(1); 198 * </code> 199 * which will do what the above does. If you need the result, you can assign it to a variable, but 200 * most cases, you only need to echo it. 201 * 202 * @since 0.71 203 * @global int $timestart Seconds and Microseconds added together from when timer_start() is called 204 * @global int $timeend Seconds and Microseconds added together from when function is called 205 * 206 * @param int $display Use '0' or null to not echo anything and 1 to echo the total time 207 * @param int $precision The amount of digits from the right of the decimal to display. Default is 3. 208 * @return float The "second.microsecond" finished time calculation 209 */ 210 function timer_stop($display = 0, $precision = 3) { //if called like timer_stop(1), will echo $timetotal 211 global $timestart, $timeend; 212 $mtime = microtime(); 213 $mtime = explode(' ',$mtime); 214 $mtime = $mtime[1] + $mtime[0]; 215 $timeend = $mtime; 216 $timetotal = $timeend-$timestart; 217 $r = ( function_exists('number_format_i18n') ) ? number_format_i18n($timetotal, $precision) : number_format($timetotal, $precision); 218 if ( $display ) 219 echo $r; 220 return $r; 221 } 71 // Start timer. 222 72 timer_start(); 223 73 224 74 // Add define('WP_DEBUG', true); to wp-config.php to enable display of notices during development. … … 255 105 if ( !defined('MEDIA_TRASH') ) 256 106 define('MEDIA_TRASH', false); 257 107 258 /**259 * Stores the location of the WordPress directory of functions, classes, and core content.260 *261 * @since 1.0.0262 */263 define('WPINC', 'wp-includes');264 265 108 if ( !defined('WP_LANG_DIR') ) { 266 109 /** 267 110 * Stores the location of the language directory. First looks for language folder in WP_CONTENT_DIR … … 311 154 if ( is_wp_error($prefix) ) 312 155 wp_die(/*WP_I18N_BAD_PREFIX*/'<strong>ERROR</strong>: <code>$table_prefix</code> in <code>wp-config.php</code> can only contain numbers, letters, and underscores.'/*/WP_I18N_BAD_PREFIX*/); 313 156 314 /**315 * Copy an object.316 *317 * Returns a cloned copy of an object.318 *319 * @since 2.7.0320 *321 * @param object $object The object to clone322 * @return object The cloned object323 */324 function wp_clone( $object ) {325 static $can_clone;326 if ( !isset( $can_clone ) ) {327 $can_clone = version_compare( phpversion(), '5.0', '>=' );328 }329 return $can_clone ? clone( $object ) : $object;330 }331 332 /**333 * Whether the current request is in WordPress admin Panel334 *335 * Does not inform on whether the user is an admin! Use capability checks to336 * tell if the user should be accessing a section or not.337 *338 * @since 1.5.1339 *340 * @return bool True if inside WordPress administration pages.341 */342 function is_admin() {343 if ( defined('WP_ADMIN') )344 return WP_ADMIN;345 return false;346 }347 348 157 if ( file_exists(WP_CONTENT_DIR . '/object-cache.php') ) { 349 158 require_once (WP_CONTENT_DIR . '/object-cache.php'); 350 159 $_wp_using_ext_object_cache = true; … … 415 224 require (ABSPATH . WPINC . '/bookmark-template.php'); 416 225 require (ABSPATH . WPINC . '/kses.php'); 417 226 require (ABSPATH . WPINC . '/cron.php'); 418 require (ABSPATH . WPINC . '/version.php');419 227 require (ABSPATH . WPINC . '/deprecated.php'); 420 228 require (ABSPATH . WPINC . '/script-loader.php'); 421 229 require (ABSPATH . WPINC . '/taxonomy.php'); -
wp-admin/setup-config.php
24 24 error_reporting(0); 25 25 26 26 /**#@+ 27 * These threedefines are required to allow us to use require_wp_db() to load27 * These defines are required to allow us to use require_wp_db() to load 28 28 * the database class while being wp-content/db.php aware. 29 29 * @ignore 30 30 */ 31 31 define('ABSPATH', dirname(dirname(__FILE__)).'/'); 32 32 define('WPINC', 'wp-includes'); 33 33 define('WP_CONTENT_DIR', ABSPATH . 'wp-content'); 34 define('WP_DEBUG', false); 34 35 /**#@-*/ 35 36 37 require_once(ABSPATH . WPINC . '/init.php'); 36 38 require_once(ABSPATH . WPINC . '/compat.php'); 37 39 require_once(ABSPATH . WPINC . '/functions.php'); 38 40 require_once(ABSPATH . WPINC . '/classes.php'); -
wp-includes/init.php
1 <?php 2 /** 3 * Functions needed to initialize WordPress. 4 * 5 * These functions are loaded before WordPress is initialized in wp-settings.php 6 * and in other locations. 7 * 8 * @package WordPress 9 */ 10 11 /** 12 * Whether Multisite support is enabled 13 * 14 * @since 3.0 15 * 16 * @return bool True if multisite is enabled, false otherwise. 17 */ 18 function is_multisite() { 19 if ( ( defined('MULTISITE') && MULTISITE ) || defined('VHOST') || defined('SUNRISE') ) 20 return true; 21 22 return false; 23 } 24 25 /** 26 * Turn register globals off. 27 * 28 * @access private 29 * @since 2.1.0 30 * @return null Will return null if register_globals PHP directive was disabled 31 */ 32 function wp_unregister_GLOBALS() { 33 if ( !ini_get('register_globals') ) 34 return; 35 36 if ( isset($_REQUEST['GLOBALS']) ) 37 die('GLOBALS overwrite attempt detected'); 38 39 // Variables that shouldn't be unset 40 $noUnset = array('GLOBALS', '_GET', '_POST', '_COOKIE', '_REQUEST', '_SERVER', '_ENV', '_FILES', 'table_prefix'); 41 42 $input = array_merge($_GET, $_POST, $_COOKIE, $_SERVER, $_ENV, $_FILES, isset($_SESSION) && is_array($_SESSION) ? $_SESSION : array()); 43 foreach ( $input as $k => $v ) 44 if ( !in_array($k, $noUnset) && isset($GLOBALS[$k]) ) { 45 $GLOBALS[$k] = NULL; 46 unset($GLOBALS[$k]); 47 } 48 } 49 50 /** 51 * PHP 4 standard microtime start capture. 52 * 53 * @access private 54 * @since 0.71 55 * @global int $timestart Seconds and Microseconds added together from when function is called. 56 * @return bool Always returns true. 57 */ 58 function timer_start() { 59 global $timestart; 60 $mtime = explode(' ', microtime() ); 61 $mtime = $mtime[1] + $mtime[0]; 62 $timestart = $mtime; 63 return true; 64 } 65 66 /** 67 * Return and/or display the time from the page start to when function is called. 68 * 69 * You can get the results and print them by doing: 70 * <code> 71 * $nTimePageTookToExecute = timer_stop(); 72 * echo $nTimePageTookToExecute; 73 * </code> 74 * 75 * Or instead, you can do: 76 * <code> 77 * timer_stop(1); 78 * </code> 79 * which will do what the above does. If you need the result, you can assign it to a variable, but 80 * most cases, you only need to echo it. 81 * 82 * @since 0.71 83 * @global int $timestart Seconds and Microseconds added together from when timer_start() is called 84 * @global int $timeend Seconds and Microseconds added together from when function is called 85 * 86 * @param int $display Use '0' or null to not echo anything and 1 to echo the total time 87 * @param int $precision The amount of digits from the right of the decimal to display. Default is 3. 88 * @return float The "second.microsecond" finished time calculation 89 */ 90 function timer_stop($display = 0, $precision = 3) { //if called like timer_stop(1), will echo $timetotal 91 global $timestart, $timeend; 92 $mtime = microtime(); 93 $mtime = explode(' ',$mtime); 94 $mtime = $mtime[1] + $mtime[0]; 95 $timeend = $mtime; 96 $timetotal = $timeend-$timestart; 97 $r = ( function_exists('number_format_i18n') ) ? number_format_i18n($timetotal, $precision) : number_format($timetotal, $precision); 98 if ( $display ) 99 echo $r; 100 return $r; 101 } 102 103 /** 104 * Copy an object. 105 * 106 * Returns a cloned copy of an object. 107 * 108 * @since 2.7.0 109 * 110 * @param object $object The object to clone 111 * @return object The cloned object 112 */ 113 function wp_clone( $object ) { 114 static $can_clone; 115 if ( !isset( $can_clone ) ) { 116 $can_clone = version_compare( phpversion(), '5.0', '>=' ); 117 } 118 return $can_clone ? clone( $object ) : $object; 119 } 120 121 /** 122 * Whether the current request is in WordPress admin Panel 123 * 124 * Does not inform on whether the user is an admin! Use capability checks to 125 * tell if the user should be accessing a section or not. 126 * 127 * @since 1.5.1 128 * 129 * @return bool True if inside WordPress administration pages. 130 */ 131 function is_admin() { 132 if ( defined('WP_ADMIN') ) 133 return WP_ADMIN; 134 return false; 135 } 136 137 /** 138 * Displays maintenance message. 139 * 140 * @access private 141 * @since 3.0.0 142 */ 143 function wp_maintenance() { 144 include(ABSPATH . '.maintenance'); 145 // If the $upgrading timestamp is older than 10 minutes, don't die. 146 if ( ( time() - $upgrading ) < 600 ) { 147 if ( file_exists( WP_CONTENT_DIR . '/maintenance.php' ) ) { 148 require_once( WP_CONTENT_DIR . '/maintenance.php' ); 149 die(); 150 } 151 152 $protocol = $_SERVER["SERVER_PROTOCOL"]; 153 if ( 'HTTP/1.1' != $protocol && 'HTTP/1.0' != $protocol ) 154 $protocol = 'HTTP/1.0'; 155 header( "$protocol 503 Service Unavailable", true, 503 ); 156 header( 'Content-Type: text/html; charset=utf-8' ); 157 header( 'Retry-After: 600' ); 158 ?> 159 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 160 <html xmlns="http://www.w3.org/1999/xhtml"> 161 <head> 162 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 163 <title>Maintenance</title> 164 165 </head> 166 <body> 167 <h1>Briefly unavailable for scheduled maintenance. Check back in a minute.</h1> 168 </body> 169 </html> 170 <?php 171 die(); 172 } 173 } 174 175 /** 176 * Fix $_SERVER variables. 177 * 178 * @access private 179 * @since 3.0.0 180 */ 181 function wp_fix_server_vars() { 182 // Fix for IIS when running with PHP ISAPI 183 if ( empty( $_SERVER['REQUEST_URI'] ) || ( php_sapi_name() != 'cgi-fcgi' && preg_match( '/^Microsoft-IIS\//', $_SERVER['SERVER_SOFTWARE'] ) ) ) { 184 185 // IIS Mod-Rewrite 186 if (isset($_SERVER['HTTP_X_ORIGINAL_URL'])) { 187 $_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_ORIGINAL_URL']; 188 } 189 // IIS Isapi_Rewrite 190 else if (isset($_SERVER['HTTP_X_REWRITE_URL'])) { 191 $_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_REWRITE_URL']; 192 } 193 else 194 { 195 // Use ORIG_PATH_INFO if there is no PATH_INFO 196 if ( !isset($_SERVER['PATH_INFO']) && isset($_SERVER['ORIG_PATH_INFO']) ) 197 $_SERVER['PATH_INFO'] = $_SERVER['ORIG_PATH_INFO']; 198 199 // Some IIS + PHP configurations puts the script-name in the path-info (No need to append it twice) 200 if ( isset($_SERVER['PATH_INFO']) ) { 201 if ( $_SERVER['PATH_INFO'] == $_SERVER['SCRIPT_NAME'] ) 202 $_SERVER['REQUEST_URI'] = $_SERVER['PATH_INFO']; 203 else 204 $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'] . $_SERVER['PATH_INFO']; 205 } 206 207 // Append the query string if it exists and isn't null 208 if (isset($_SERVER['QUERY_STRING']) && !empty($_SERVER['QUERY_STRING'])) { 209 $_SERVER['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING']; 210 } 211 } 212 } 213 214 // Fix for PHP as CGI hosts that set SCRIPT_FILENAME to something ending in php.cgi for all requests 215 if ( isset($_SERVER['SCRIPT_FILENAME']) && ( strpos($_SERVER['SCRIPT_FILENAME'], 'php.cgi') == strlen($_SERVER['SCRIPT_FILENAME']) - 7 ) ) 216 $_SERVER['SCRIPT_FILENAME'] = $_SERVER['PATH_TRANSLATED']; 217 218 // Fix for Dreamhost and other PHP as CGI hosts 219 if (strpos($_SERVER['SCRIPT_NAME'], 'php.cgi') !== false) 220 unset($_SERVER['PATH_INFO']); 221 222 // Fix empty PHP_SELF 223 $PHP_SELF = $_SERVER['PHP_SELF']; 224 if ( empty($PHP_SELF) ) 225 $_SERVER['PHP_SELF'] = $PHP_SELF = preg_replace("/(\?.*)?$/",'',$_SERVER["REQUEST_URI"]); 226 } 227 No newline at end of file