| [ Index ] |
WordPress Source Cross Reference |
[Summary view] [Print] [Text view]
1 <?php 2 // Turn register globals off 3 function unregister_GLOBALS() { 4 if ( !ini_get('register_globals') ) 5 return; 6 7 if ( isset($_REQUEST['GLOBALS']) ) 8 wp_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 unset($GLOBALS[$k]); 17 } 18 19 unregister_GLOBALS(); 20 21 unset( $wp_filter, $cache_userdata, $cache_lastcommentmodified, $cache_lastpostdate, $cache_settings, $category_cache, $cache_categories ); 22 23 if ( ! isset($blog_id) ) 24 $blog_id = 1; 25 26 // Fix for IIS, which doesn't set REQUEST_URI 27 if ( empty( $_SERVER['REQUEST_URI'] ) ) { 28 $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME']; // Does this work under CGI? 29 30 // Append the query string if it exists and isn't null 31 if (isset($_SERVER['QUERY_STRING']) && !empty($_SERVER['QUERY_STRING'])) { 32 $_SERVER['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING']; 33 } 34 } 35 36 // Fix for PHP as CGI hosts that set SCRIPT_FILENAME to something ending in php.cgi for all requests 37 if ( isset($_SERVER['SCRIPT_FILENAME']) && ( strpos($_SERVER['SCRIPT_FILENAME'], 'php.cgi') == strlen($_SERVER['SCRIPT_FILENAME']) - 7 ) ) 38 $_SERVER['SCRIPT_FILENAME'] = $_SERVER['PATH_TRANSLATED']; 39 40 // Fix for Dreamhost and other PHP as CGI hosts 41 if ( strstr( $_SERVER['SCRIPT_NAME'], 'php.cgi' ) ) 42 unset($_SERVER['PATH_INFO']); 43 44 // Fix empty PHP_SELF 45 $PHP_SELF = $_SERVER['PHP_SELF']; 46 if ( empty($PHP_SELF) ) 47 $_SERVER['PHP_SELF'] = $PHP_SELF = preg_replace("/(\?.*)?$/",'',$_SERVER["REQUEST_URI"]); 48 49 if ( !(phpversion() >= '4.1') ) 50 wp_die( 'Your server is running PHP version ' . phpversion() . ' but WordPress requires at least 4.1' ); 51 52 if ( !extension_loaded('mysql') ) 53 wp_die( 'Your PHP installation appears to be missing the MySQL which is required for WordPress.' ); 54 55 function timer_start() { 56 global $timestart; 57 $mtime = explode(' ', microtime() ); 58 $mtime = $mtime[1] + $mtime[0]; 59 $timestart = $mtime; 60 return true; 61 } 62 timer_start(); 63 64 // Change to E_ALL for development/debugging 65 error_reporting(E_ALL ^ E_NOTICE); 66 67 // For an advanced caching plugin to use, static because you would only want one 68 if ( defined('WP_CACHE') ) 69 require (ABSPATH . 'wp-content/advanced-cache.php'); 70 71 define('WPINC', 'wp-includes'); 72 require_once (ABSPATH . WPINC . '/wp-db.php'); 73 74 // Table names 75 $wpdb->posts = $table_prefix . 'posts'; 76 $wpdb->users = $table_prefix . 'users'; 77 $wpdb->categories = $table_prefix . 'categories'; 78 $wpdb->post2cat = $table_prefix . 'post2cat'; 79 $wpdb->comments = $table_prefix . 'comments'; 80 $wpdb->link2cat = $table_prefix . 'link2cat'; 81 $wpdb->links = $table_prefix . 'links'; 82 $wpdb->linkcategories = $table_prefix . 'linkcategories'; 83 $wpdb->options = $table_prefix . 'options'; 84 $wpdb->postmeta = $table_prefix . 'postmeta'; 85 $wpdb->usermeta = $table_prefix . 'usermeta'; 86 87 $wpdb->prefix = $table_prefix; 88 89 if ( defined('CUSTOM_USER_TABLE') ) 90 $wpdb->users = CUSTOM_USER_TABLE; 91 if ( defined('CUSTOM_USER_META_TABLE') ) 92 $wpdb->usermeta = CUSTOM_USER_META_TABLE; 93 94 // To be removed in 2.2 95 $tableposts = $tableusers = $tablecategories = $tablepost2cat = $tablecomments = $tablelink2cat = $tablelinks = $tablelinkcategories = $tableoptions = $tablepostmeta = ''; 96 97 if ( file_exists(ABSPATH . 'wp-content/object-cache.php') ) 98 require (ABSPATH . 'wp-content/object-cache.php'); 99 else 100 require (ABSPATH . WPINC . '/cache.php'); 101 102 wp_cache_init(); 103 104 require (ABSPATH . WPINC . '/functions.php'); 105 require (ABSPATH . WPINC . '/plugin.php'); 106 require (ABSPATH . WPINC . '/default-filters.php'); 107 require_once (ABSPATH . WPINC . '/l10n.php'); 108 109 if ( !is_blog_installed() && (!strstr($_SERVER['PHP_SELF'], 'install.php') && !defined('WP_INSTALLING')) ) { 110 if ( strstr($_SERVER['PHP_SELF'], 'wp-admin') ) 111 $link = 'install.php'; 112 else 113 $link = 'wp-admin/install.php'; 114 wp_die(sprintf(__("It doesn't look like you've installed WP yet. Try running <a href='%s'>install.php</a>."), $link)); 115 } 116 117 require (ABSPATH . WPINC . '/formatting.php'); 118 require (ABSPATH . WPINC . '/capabilities.php'); 119 require (ABSPATH . WPINC . '/classes.php'); 120 require (ABSPATH . WPINC . '/query.php'); 121 require (ABSPATH . WPINC . '/theme.php'); 122 require (ABSPATH . WPINC . '/user.php'); 123 require (ABSPATH . WPINC . '/general-template.php'); 124 require (ABSPATH . WPINC . '/link-template.php'); 125 require (ABSPATH . WPINC . '/author-template.php'); 126 require (ABSPATH . WPINC . '/post.php'); 127 require (ABSPATH . WPINC . '/post-template.php'); 128 require (ABSPATH . WPINC . '/category.php'); 129 require (ABSPATH . WPINC . '/category-template.php'); 130 require (ABSPATH . WPINC . '/comment.php'); 131 require (ABSPATH . WPINC . '/comment-template.php'); 132 require (ABSPATH . WPINC . '/rewrite.php'); 133 require (ABSPATH . WPINC . '/feed.php'); 134 require (ABSPATH . WPINC . '/bookmark.php'); 135 require (ABSPATH . WPINC . '/bookmark-template.php'); 136 require (ABSPATH . WPINC . '/kses.php'); 137 require (ABSPATH . WPINC . '/cron.php'); 138 require (ABSPATH . WPINC . '/version.php'); 139 require (ABSPATH . WPINC . '/deprecated.php'); 140 require (ABSPATH . WPINC . '/script-loader.php'); 141 142 if (!strstr($_SERVER['PHP_SELF'], 'install.php')) : 143 // Used to guarantee unique hash cookies 144 $cookiehash = md5(get_settings('siteurl')); // Remove in 1.4 145 define('COOKIEHASH', $cookiehash); 146 endif; 147 148 if ( !defined('USER_COOKIE') ) 149 define('USER_COOKIE', 'wordpressuser_'. COOKIEHASH); 150 if ( !defined('PASS_COOKIE') ) 151 define('PASS_COOKIE', 'wordpresspass_'. COOKIEHASH); 152 if ( !defined('COOKIEPATH') ) 153 define('COOKIEPATH', preg_replace('|https?://[^/]+|i', '', get_settings('home') . '/' ) ); 154 if ( !defined('SITECOOKIEPATH') ) 155 define('SITECOOKIEPATH', preg_replace('|https?://[^/]+|i', '', get_settings('siteurl') . '/' ) ); 156 if ( !defined('COOKIE_DOMAIN') ) 157 define('COOKIE_DOMAIN', false); 158 159 require (ABSPATH . WPINC . '/vars.php'); 160 161 // Check for hacks file if the option is enabled 162 if (get_settings('hack_file')) { 163 if (file_exists(ABSPATH . '/my-hacks.php')) 164 require(ABSPATH . '/my-hacks.php'); 165 } 166 167 if ( get_settings('active_plugins') ) { 168 $current_plugins = get_settings('active_plugins'); 169 if ( is_array($current_plugins) ) { 170 foreach ($current_plugins as $plugin) { 171 if ('' != $plugin && file_exists(ABSPATH . 'wp-content/plugins/' . $plugin)) 172 include_once(ABSPATH . 'wp-content/plugins/' . $plugin); 173 } 174 } 175 } 176 177 require (ABSPATH . WPINC . '/pluggable.php'); 178 179 if ( defined('WP_CACHE') && function_exists('wp_cache_postload') ) 180 wp_cache_postload(); 181 182 do_action('plugins_loaded'); 183 184 // If already slashed, strip. 185 if ( get_magic_quotes_gpc() ) { 186 $_GET = stripslashes_deep($_GET ); 187 $_POST = stripslashes_deep($_POST ); 188 $_COOKIE = stripslashes_deep($_COOKIE); 189 } 190 191 // Escape with wpdb. 192 $_GET = add_magic_quotes($_GET ); 193 $_POST = add_magic_quotes($_POST ); 194 $_COOKIE = add_magic_quotes($_COOKIE); 195 $_SERVER = add_magic_quotes($_SERVER); 196 197 do_action('sanitize_comment_cookies'); 198 199 $wp_query = new WP_Query(); 200 $wp_rewrite = new WP_Rewrite(); 201 $wp = new WP(); 202 203 validate_current_theme(); 204 define('TEMPLATEPATH', get_template_directory()); 205 206 // Load the default text localization domain. 207 load_default_textdomain(); 208 209 // Pull in locale data after loading text domain. 210 require_once(ABSPATH . WPINC . '/locale.php'); 211 212 $wp_locale = new WP_Locale(); 213 214 // Load functions for active theme. 215 if ( file_exists(TEMPLATEPATH . "/functions.php") ) 216 include(TEMPLATEPATH . "/functions.php"); 217 218 function shutdown_action_hook() { 219 do_action('shutdown'); 220 wp_cache_close(); 221 } 222 register_shutdown_function('shutdown_action_hook'); 223 224 // Everything is loaded and initialized. 225 do_action('init'); 226 227 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Sat Jul 15 11:57:04 2006 | Courtesy of Taragana |