root/tags/2.1.1/wp-settings.php

Revision 4763, 9.2 kB (checked in by ryan, 2 years ago)

Always load gettext.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
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, $cache_userdata, $cache_lastcommentmodified, $cache_lastpostdate, $cache_settings, $category_cache, $cache_categories );
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     $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME']; // Does this work under CGI?
31
32     // Append the query string if it exists and isn't null
33     if (isset($_SERVER['QUERY_STRING']) && !empty($_SERVER['QUERY_STRING'])) {
34         $_SERVER['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
35     }
36 }
37
38 // Fix for PHP as CGI hosts that set SCRIPT_FILENAME to something ending in php.cgi for all requests
39 if ( isset($_SERVER['SCRIPT_FILENAME']) && ( strpos($_SERVER['SCRIPT_FILENAME'], 'php.cgi') == strlen($_SERVER['SCRIPT_FILENAME']) - 7 ) )
40     $_SERVER['SCRIPT_FILENAME'] = $_SERVER['PATH_TRANSLATED'];
41
42 // Fix for Dreamhost and other PHP as CGI hosts
43 if ( strstr( $_SERVER['SCRIPT_NAME'], 'php.cgi' ) )
44     unset($_SERVER['PATH_INFO']);
45
46 // Fix empty PHP_SELF
47 $PHP_SELF = $_SERVER['PHP_SELF'];
48 if ( empty($PHP_SELF) )
49     $_SERVER['PHP_SELF'] = $PHP_SELF = preg_replace("/(\?.*)?$/",'',$_SERVER["REQUEST_URI"]);
50
51 if ( !(phpversion() >= '4.1') )
52     die( 'Your server is running PHP version ' . phpversion() . ' but WordPress requires at least 4.1' );
53
54 if ( !extension_loaded('mysql') && !file_exists(ABSPATH . 'wp-content/db.php') )
55     die( 'Your PHP installation appears to be missing the MySQL which is required for WordPress.' );
56
57 function timer_start() {
58     global $timestart;
59     $mtime = explode(' ', microtime() );
60     $mtime = $mtime[1] + $mtime[0];
61     $timestart = $mtime;
62     return true;
63 }
64
65 function timer_stop($display = 0, $precision = 3) { //if called like timer_stop(1), will echo $timetotal
66     global $timestart, $timeend;
67     $mtime = microtime();
68     $mtime = explode(' ',$mtime);
69     $mtime = $mtime[1] + $mtime[0];
70     $timeend = $mtime;
71     $timetotal = $timeend-$timestart;
72     $r = number_format($timetotal, $precision);
73     if ( $display )
74         echo $r;
75     return $r;
76 }
77 timer_start();
78
79 // Change to E_ALL for development/debugging
80 error_reporting(E_ALL ^ E_NOTICE);
81
82 // For an advanced caching plugin to use, static because you would only want one
83 if ( defined('WP_CACHE') )
84     require (ABSPATH . 'wp-content/advanced-cache.php');
85
86 define('WPINC', 'wp-includes');
87
88 if ( !defined('LANGDIR') ) {
89     if ( file_exists(ABSPATH . 'wp-content/languages') && @is_dir(ABSPATH . 'wp-content/languages') )
90         define('LANGDIR', 'wp-content/languages'); // no leading slash, no trailing slash
91     else
92         define('LANGDIR', WPINC . '/languages'); // no leading slash, no trailing slash
93 }
94
95 if ( !defined('PLUGINDIR') )
96     define('PLUGINDIR', 'wp-content/plugins'); // no leading slash, no trailing slash
97 if ( file_exists(ABSPATH . 'wp-content/db.php') )
98     require (ABSPATH . 'wp-content/db.php');
99 else
100     require_once (ABSPATH . WPINC . '/wp-db.php');
101
102 // $table_prefix is deprecated as of 2.1
103 $wpdb->prefix = $table_prefix;
104
105 if ( preg_match('|[^a-z0-9_]|i', $wpdb->prefix) && !file_exists(ABSPATH . 'wp-content/db.php') )
106     die("<strong>ERROR</strong>: <code>$table_prefix</code> in <code>wp-config.php</code> can only contain numbers, letters, and underscores.");
107
108 // Table names
109 $wpdb->posts          = $wpdb->prefix . 'posts';
110 $wpdb->users          = $wpdb->prefix . 'users';
111 $wpdb->categories     = $wpdb->prefix . 'categories';
112 $wpdb->post2cat       = $wpdb->prefix . 'post2cat';
113 $wpdb->comments       = $wpdb->prefix . 'comments';
114 $wpdb->link2cat       = $wpdb->prefix . 'link2cat';
115 $wpdb->links          = $wpdb->prefix . 'links';
116 $wpdb->options        = $wpdb->prefix . 'options';
117 $wpdb->postmeta       = $wpdb->prefix . 'postmeta';
118 $wpdb->usermeta       = $wpdb->prefix . 'usermeta';
119
120 if ( defined('CUSTOM_USER_TABLE') )
121     $wpdb->users = CUSTOM_USER_TABLE;
122 if ( defined('CUSTOM_USER_META_TABLE') )
123     $wpdb->usermeta = CUSTOM_USER_META_TABLE;
124
125 // To be removed in 2.2
126 $tableposts = $tableusers = $tablecategories = $tablepost2cat = $tablecomments = $tablelink2cat = $tablelinks = $tablelinkcategories = $tableoptions = $tablepostmeta = '';
127
128 if ( file_exists(ABSPATH . 'wp-content/object-cache.php') )
129     require (ABSPATH . 'wp-content/object-cache.php');
130 else
131     require (ABSPATH . WPINC . '/cache.php');
132
133 wp_cache_init();
134
135 require (ABSPATH . WPINC . '/functions.php');
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() && (!strstr($_SERVER['PHP_SELF'], 'install.php') && !defined('WP_INSTALLING')) ) {
143     if ( strstr($_SERVER['PHP_SELF'], 'wp-admin') )
144         $link = 'install.php';
145     else
146         $link = 'wp-admin/install.php';
147     wp_die(sprintf("It doesn't look like you've installed WP yet. Try running <a href='%s'>install.php</a>.", $link));
148 }
149
150 require (ABSPATH . WPINC . '/formatting.php');
151 require (ABSPATH . WPINC . '/capabilities.php');
152 require (ABSPATH . WPINC . '/classes.php');
153 require (ABSPATH . WPINC . '/query.php');
154 require (ABSPATH . WPINC . '/theme.php');
155 require (ABSPATH . WPINC . '/user.php');
156 require (ABSPATH . WPINC . '/general-template.php');
157 require (ABSPATH . WPINC . '/link-template.php');
158 require (ABSPATH . WPINC . '/author-template.php');
159 require (ABSPATH . WPINC . '/post.php');
160 require (ABSPATH . WPINC . '/post-template.php');
161 require (ABSPATH . WPINC . '/category.php');
162 require (ABSPATH . WPINC . '/category-template.php');
163 require (ABSPATH . WPINC . '/comment.php');
164 require (ABSPATH . WPINC . '/comment-template.php');
165 require (ABSPATH . WPINC . '/rewrite.php');
166 require (ABSPATH . WPINC . '/feed.php');
167 require (ABSPATH . WPINC . '/bookmark.php');
168 require (ABSPATH . WPINC . '/bookmark-template.php');
169 require (ABSPATH . WPINC . '/kses.php');
170 require (ABSPATH . WPINC . '/cron.php');
171 require (ABSPATH . WPINC . '/version.php');
172 require (ABSPATH . WPINC . '/deprecated.php');
173 require (ABSPATH . WPINC . '/script-loader.php');
174
175 if (!strstr($_SERVER['PHP_SELF'], 'install.php')) :
176     // Used to guarantee unique hash cookies
177     $cookiehash = md5(get_option('siteurl'));
178     define('COOKIEHASH', $cookiehash);
179 endif;
180
181 if ( !defined('USER_COOKIE') )
182     define('USER_COOKIE', 'wordpressuser_'. COOKIEHASH);
183 if ( !defined('PASS_COOKIE') )
184     define('PASS_COOKIE', 'wordpresspass_'. COOKIEHASH);
185 if ( !defined('COOKIEPATH') )
186     define('COOKIEPATH', preg_replace('|https?://[^/]+|i', '', get_option('home') . '/' ) );
187 if ( !defined('SITECOOKIEPATH') )
188     define('SITECOOKIEPATH', preg_replace('|https?://[^/]+|i', '', get_option('siteurl') . '/' ) );
189 if ( !defined('COOKIE_DOMAIN') )
190     define('COOKIE_DOMAIN', false);
191
192 require (ABSPATH . WPINC . '/vars.php');
193
194 // Check for hacks file if the option is enabled
195 if (get_option('hack_file')) {
196     if (file_exists(ABSPATH . '/my-hacks.php'))
197         require(ABSPATH . '/my-hacks.php');
198 }
199
200 if ( get_option('active_plugins') ) {
201     $current_plugins = get_option('active_plugins');
202     if ( is_array($current_plugins) ) {
203         foreach ($current_plugins as $plugin) {
204             if ('' != $plugin && file_exists(ABSPATH . 'wp-content/plugins/' . $plugin))
205                 include_once(ABSPATH . 'wp-content/plugins/' . $plugin);
206         }
207     }
208 }
209
210 require (ABSPATH . WPINC . '/pluggable.php');
211
212 if ( defined('WP_CACHE') && function_exists('wp_cache_postload') )
213     wp_cache_postload();
214
215 do_action('plugins_loaded');
216
217 // If already slashed, strip.
218 if ( get_magic_quotes_gpc() ) {
219     $_GET    = stripslashes_deep($_GET   );
220     $_POST   = stripslashes_deep($_POST  );
221     $_COOKIE = stripslashes_deep($_COOKIE);
222 }
223
224 // Escape with wpdb.
225 $_GET    = add_magic_quotes($_GET   );
226 $_POST   = add_magic_quotes($_POST  );
227 $_COOKIE = add_magic_quotes($_COOKIE);
228 $_SERVER = add_magic_quotes($_SERVER);
229
230 do_action('sanitize_comment_cookies');
231
232 $wp_the_query =& new WP_Query();
233 $wp_query     =& $wp_the_query;
234 $wp_rewrite   =& new WP_Rewrite();
235 $wp           =& new WP();
236
237 validate_current_theme();
238 define('TEMPLATEPATH', get_template_directory());
239 define('STYLESHEETPATH', get_stylesheet_directory());
240
241 // Load the default text localization domain.
242 load_default_textdomain();
243
244 $locale = get_locale();
245 $locale_file = ABSPATH . LANGDIR . "/$locale.php";
246 if ( is_readable($locale_file) )
247     require_once($locale_file);
248
249 // Pull in locale data after loading text domain.
250 require_once(ABSPATH . WPINC . '/locale.php');
251
252 $wp_locale =& new WP_Locale();
253
254 // Load functions for active theme.
255 if ( TEMPLATEPATH !== STYLESHEETPATH && file_exists(STYLESHEETPATH . '/functions.php') )
256     include(STYLESHEETPATH . '/functions.php');
257 if ( file_exists(TEMPLATEPATH . '/functions.php') )
258     include(TEMPLATEPATH . '/functions.php');
259
260 function shutdown_action_hook() {
261     do_action('shutdown');
262     wp_cache_close();
263 }
264 register_shutdown_function('shutdown_action_hook');
265
266 // Everything is loaded and initialized.
267 do_action('init');
268
269 ?>
270
Note: See TracBrowser for help on using the browser.