PHP Cross Reference of WordPress Subversion HEAD |
| [ Index ] [ Classes ] [ Functions ] [ Variables ] [ Constants ] |
[Summary view] [Print] [Text view]
1 <?php 2 // Turn register globals off 3 function wp_unregister_GLOBALS() { 4 if ( !ini_get('register_globals') ) 5 return; 6 7 if ( isset($_REQUEST['GLOBALS']) ) 8 die('GLOBALS overwrite attempt detected'); 9 10 // Variables that shouldn't be unset 11 $noUnset = array('GLOBALS', '_GET', '_POST', '_COOKIE', '_REQUEST', '_SERVER', '_ENV', '_FILES', 'table_prefix'); 12 13 $input = array_merge($_GET, $_POST, $_COOKIE, $_SERVER, $_ENV, $_FILES, isset($_SESSION) && is_array($_SESSION) ? $_SESSION : array()); 14 foreach ( $input as $k => $v ) 15 if ( !in_array($k, $noUnset) && isset($GLOBALS[$k]) ) { 16 $GLOBALS[$k] = NULL; 17 unset($GLOBALS[$k]); 18 } 19 } 20 21 wp_unregister_GLOBALS(); 22 23 unset( $wp_filter, $wp_action, $cache_lastcommentmodified, $cache_lastpostdate ); 24 25 if ( ! isset($blog_id) ) 26 $blog_id = 1; 27 28 // Fix for IIS, which doesn't set REQUEST_URI 29 if ( empty( $_SERVER['REQUEST_URI'] ) ) { 30 31 // IIS Mod-Rewrite 32 if (isset($_SERVER['HTTP_X_ORIGINAL_URL'])) { 33 $_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_ORIGINAL_URL']; 34 } 35 // IIS Isapi_Rewrite 36 else if (isset($_SERVER['HTTP_X_REWRITE_URL'])) { 37 $_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_REWRITE_URL']; 38 } 39 else 40 { 41 // Some IIS + PHP configurations puts the script-name in the path-info (No need to append it twice) 42 if ( $_SERVER['PATH_INFO'] == $_SERVER['SCRIPT_NAME'] ) 43 $_SERVER['REQUEST_URI'] = $_SERVER['PATH_INFO']; 44 else 45 $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'] . $_SERVER['PATH_INFO']; 46 47 // Append the query string if it exists and isn't null 48 if (isset($_SERVER['QUERY_STRING']) && !empty($_SERVER['QUERY_STRING'])) { 49 $_SERVER['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING']; 50 } 51 } 52 } 53 54 // Fix for PHP as CGI hosts that set SCRIPT_FILENAME to something ending in php.cgi for all requests 55 if ( isset($_SERVER['SCRIPT_FILENAME']) && ( strpos($_SERVER['SCRIPT_FILENAME'], 'php.cgi') == strlen($_SERVER['SCRIPT_FILENAME']) - 7 ) ) 56 $_SERVER['SCRIPT_FILENAME'] = $_SERVER['PATH_TRANSLATED']; 57 58 // Fix for Dreamhost and other PHP as CGI hosts 59 if (strpos($_SERVER['SCRIPT_NAME'], 'php.cgi') !== false) 60 unset($_SERVER['PATH_INFO']); 61 62 // Fix empty PHP_SELF 63 $PHP_SELF = $_SERVER['PHP_SELF']; 64 if ( empty($PHP_SELF) ) 65 $_SERVER['PHP_SELF'] = $PHP_SELF = preg_replace("/(\?.*)?$/",'',$_SERVER["REQUEST_URI"]); 66 67 if ( version_compare( '4.2', phpversion(), '>' ) ) { 68 die( 'Your server is running PHP version ' . phpversion() . ' but WordPress requires at least 4.2.' ); 69 } 70 71 if ( !extension_loaded('mysql') && !file_exists(ABSPATH . 'wp-content/db.php') ) 72 die( 'Your PHP installation appears to be missing the MySQL which is required for WordPress.' ); 73 74 function timer_start() { 75 global $timestart; 76 $mtime = explode(' ', microtime() ); 77 $mtime = $mtime[1] + $mtime[0]; 78 $timestart = $mtime; 79 return true; 80 } 81 82 function timer_stop($display = 0, $precision = 3) { //if called like timer_stop(1), will echo $timetotal 83 global $timestart, $timeend; 84 $mtime = microtime(); 85 $mtime = explode(' ',$mtime); 86 $mtime = $mtime[1] + $mtime[0]; 87 $timeend = $mtime; 88 $timetotal = $timeend-$timestart; 89 $r = ( function_exists('number_format_i18n') ) ? number_format_i18n($timetotal, $precision) : number_format($timetotal, $precision); 90 if ( $display ) 91 echo $r; 92 return $r; 93 } 94 timer_start(); 95 96 // Add define('WP_DEBUG',true); to wp-config.php to enable display of notices during development. 97 if (defined('WP_DEBUG') and WP_DEBUG == true) { 98 error_reporting(E_ALL); 99 } else { 100 error_reporting(E_ALL ^ E_NOTICE); 101 } 102 103 // For an advanced caching plugin to use, static because you would only want one 104 if ( defined('WP_CACHE') ) 105 @include ABSPATH . 'wp-content/advanced-cache.php'; 106 107 define('WPINC', 'wp-includes'); 108 109 if ( !defined('LANGDIR') ) { 110 if ( file_exists(ABSPATH . 'wp-content/languages') && @is_dir(ABSPATH . 'wp-content/languages') ) 111 define('LANGDIR', 'wp-content/languages'); // no leading slash, no trailing slash 112 else 113 define('LANGDIR', WPINC . '/languages'); // no leading slash, no trailing slash 114 } 115 116 if ( !defined('PLUGINDIR') ) 117 define('PLUGINDIR', 'wp-content/plugins'); // no leading slash, no trailing slash 118 119 require (ABSPATH . WPINC . '/compat.php'); 120 require (ABSPATH . WPINC . '/functions.php'); 121 require (ABSPATH . WPINC . '/classes.php'); 122 123 require_wp_db(); 124 $prefix = $wpdb->set_prefix($table_prefix); 125 126 if ( is_wp_error($prefix) ) 127 wp_die("<strong>ERROR</strong>: <code>$table_prefix</code> in <code>wp-config.php</code> can only contain numbers, letters, and underscores."); 128 129 if ( file_exists(ABSPATH . 'wp-content/object-cache.php') ) 130 require_once (ABSPATH . 'wp-content/object-cache.php'); 131 else 132 require_once (ABSPATH . WPINC . '/cache.php'); 133 134 wp_cache_init(); 135 136 require (ABSPATH . WPINC . '/plugin.php'); 137 require (ABSPATH . WPINC . '/default-filters.php'); 138 include_once(ABSPATH . WPINC . '/streams.php'); 139 include_once(ABSPATH . WPINC . '/gettext.php'); 140 require_once (ABSPATH . WPINC . '/l10n.php'); 141 142 if ( !is_blog_installed() && (strpos($_SERVER['PHP_SELF'], 'install.php') === false && !defined('WP_INSTALLING')) ) { 143 if ( defined('WP_SITEURL') ) 144 $link = WP_SITEURL . '/wp-admin/install.php'; 145 elseif (strpos($_SERVER['PHP_SELF'], 'wp-admin') !== false) 146 $link = preg_replace('|/wp-admin/?.*?$|', '/', $_SERVER['PHP_SELF']) . 'wp-admin/install.php'; 147 else 148 $link = preg_replace('|/[^/]+?$|', '/', $_SERVER['PHP_SELF']) . 'wp-admin/install.php'; 149 require_once(ABSPATH . WPINC . '/kses.php'); 150 require_once(ABSPATH . WPINC . '/pluggable.php'); 151 wp_redirect($link); 152 die(); // have to die here ~ Mark 153 } 154 155 require (ABSPATH . WPINC . '/formatting.php'); 156 require (ABSPATH . WPINC . '/capabilities.php'); 157 require (ABSPATH . WPINC . '/query.php'); 158 require (ABSPATH . WPINC . '/theme.php'); 159 require (ABSPATH . WPINC . '/user.php'); 160 require (ABSPATH . WPINC . '/general-template.php'); 161 require (ABSPATH . WPINC . '/link-template.php'); 162 require (ABSPATH . WPINC . '/author-template.php'); 163 require (ABSPATH . WPINC . '/post.php'); 164 require (ABSPATH . WPINC . '/post-template.php'); 165 require (ABSPATH . WPINC . '/category.php'); 166 require (ABSPATH . WPINC . '/category-template.php'); 167 require (ABSPATH . WPINC . '/comment.php'); 168 require (ABSPATH . WPINC . '/comment-template.php'); 169 require (ABSPATH . WPINC . '/rewrite.php'); 170 require (ABSPATH . WPINC . '/feed.php'); 171 require (ABSPATH . WPINC . '/bookmark.php'); 172 require (ABSPATH . WPINC . '/bookmark-template.php'); 173 require (ABSPATH . WPINC . '/kses.php'); 174 require (ABSPATH . WPINC . '/cron.php'); 175 require (ABSPATH . WPINC . '/version.php'); 176 require (ABSPATH . WPINC . '/deprecated.php'); 177 require (ABSPATH . WPINC . '/script-loader.php'); 178 require (ABSPATH . WPINC . '/taxonomy.php'); 179 require (ABSPATH . WPINC . '/update.php'); 180 require (ABSPATH . WPINC . '/canonical.php'); 181 182 if (strpos($_SERVER['PHP_SELF'], 'install.php') === false) { 183 // Used to guarantee unique hash cookies 184 $cookiehash = md5(get_option('siteurl')); 185 define('COOKIEHASH', $cookiehash); 186 } 187 188 if ( !defined('USER_COOKIE') ) 189 define('USER_COOKIE', 'wordpressuser_'. COOKIEHASH); 190 if ( !defined('PASS_COOKIE') ) 191 define('PASS_COOKIE', 'wordpresspass_'. COOKIEHASH); 192 if ( !defined('TEST_COOKIE') ) 193 define('TEST_COOKIE', 'wordpress_test_cookie'); 194 if ( !defined('COOKIEPATH') ) 195 define('COOKIEPATH', preg_replace('|https?://[^/]+|i', '', get_option('home') . '/' ) ); 196 if ( !defined('SITECOOKIEPATH') ) 197 define('SITECOOKIEPATH', preg_replace('|https?://[^/]+|i', '', get_option('siteurl') . '/' ) ); 198 if ( !defined('COOKIE_DOMAIN') ) 199 define('COOKIE_DOMAIN', false); 200 201 require (ABSPATH . WPINC . '/vars.php'); 202 203 // Check for hacks file if the option is enabled 204 if (get_option('hack_file')) { 205 if (file_exists(ABSPATH . 'my-hacks.php')) 206 require(ABSPATH . 'my-hacks.php'); 207 } 208 209 if ( get_option('active_plugins') ) { 210 $current_plugins = get_option('active_plugins'); 211 if ( is_array($current_plugins) ) { 212 foreach ($current_plugins as $plugin) { 213 if ('' != $plugin && file_exists(ABSPATH . PLUGINDIR . '/' . $plugin)) 214 include_once(ABSPATH . PLUGINDIR . '/' . $plugin); 215 } 216 } 217 } 218 219 require (ABSPATH . WPINC . '/pluggable.php'); 220 221 if ( defined('WP_CACHE') && function_exists('wp_cache_postload') ) 222 wp_cache_postload(); 223 224 do_action('plugins_loaded'); 225 226 // If already slashed, strip. 227 if ( get_magic_quotes_gpc() ) { 228 $_GET = stripslashes_deep($_GET ); 229 $_POST = stripslashes_deep($_POST ); 230 $_COOKIE = stripslashes_deep($_COOKIE); 231 } 232 233 // Escape with wpdb. 234 $_GET = add_magic_quotes($_GET ); 235 $_POST = add_magic_quotes($_POST ); 236 $_COOKIE = add_magic_quotes($_COOKIE); 237 $_SERVER = add_magic_quotes($_SERVER); 238 239 do_action('sanitize_comment_cookies'); 240 241 $wp_the_query =& new WP_Query(); 242 $wp_query =& $wp_the_query; 243 $wp_rewrite =& new WP_Rewrite(); 244 $wp =& new WP(); 245 246 define('TEMPLATEPATH', get_template_directory()); 247 define('STYLESHEETPATH', get_stylesheet_directory()); 248 249 // Load the default text localization domain. 250 load_default_textdomain(); 251 252 $locale = get_locale(); 253 $locale_file = ABSPATH . LANGDIR . "/$locale.php"; 254 if ( is_readable($locale_file) ) 255 require_once($locale_file); 256 257 // Pull in locale data after loading text domain. 258 require_once(ABSPATH . WPINC . '/locale.php'); 259 260 $wp_locale =& new WP_Locale(); 261 262 // Load functions for active theme. 263 if ( TEMPLATEPATH !== STYLESHEETPATH && file_exists(STYLESHEETPATH . '/functions.php') ) 264 include(STYLESHEETPATH . '/functions.php'); 265 if ( file_exists(TEMPLATEPATH . '/functions.php') ) 266 include(TEMPLATEPATH . '/functions.php'); 267 268 function shutdown_action_hook() { 269 do_action('shutdown'); 270 wp_cache_close(); 271 } 272 register_shutdown_function('shutdown_action_hook'); 273 274 // Everything is loaded and initialized. 275 do_action('init'); 276 277 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated Thu Dec 6 06:47:08 2007 for RedAlt XRefs | Cross-referenced by PHPXref 0.6 and RedAlt |