root/tags/1_0-rc1/wp-settings.php

Revision 592, 9.8 kB (checked in by donncha, 2 years ago)

WP merge

  • Property svn:eol-style set to native
Line 
1 <?php
2 if( defined( 'ABSPATH' ) == false )
3     die();
4
5 // Turn register globals off
6 function unregister_GLOBALS() {
7     if ( !ini_get('register_globals') )
8         return;
9
10     if ( isset($_REQUEST['GLOBALS']) )
11         die('GLOBALS overwrite attempt detected');
12
13     // Variables that shouldn't be unset
14     $noUnset = array('GLOBALS', '_GET', '_POST', '_COOKIE', '_REQUEST', '_SERVER', '_ENV', '_FILES', 'table_prefix');
15
16     $input = array_merge($_GET, $_POST, $_COOKIE, $_SERVER, $_ENV, $_FILES, isset($_SESSION) && is_array($_SESSION) ? $_SESSION : array());
17     foreach ( $input as $k => $v )
18         if ( !in_array($k, $noUnset) && isset($GLOBALS[$k]) )
19             unset($GLOBALS[$k]);
20 }
21
22 unregister_GLOBALS();
23
24 $HTTP_USER_AGENT = getenv('HTTP_USER_AGENT');
25 unset( $wp_filter, $cache_userdata, $cache_lastcommentmodified, $cache_lastpostdate, $cache_settings, $category_cache, $cache_categories );
26
27 if ( ! isset($blog_id) )
28     $blog_id = 0;
29
30 // Fix for IIS, which doesn't set REQUEST_URI
31 if ( empty( $_SERVER['REQUEST_URI'] ) ) {
32     $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME']; // Does this work under CGI?
33
34     // Append the query string if it exists and isn't null
35     if (isset($_SERVER['QUERY_STRING']) && !empty($_SERVER['QUERY_STRING'])) {
36         $_SERVER['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
37     }
38 }
39
40 // Fix for PHP as CGI hosts that set SCRIPT_FILENAME to something ending in php.cgi for all requests
41 if ( isset($_SERVER['SCRIPT_FILENAME']) && ( strpos($_SERVER['SCRIPT_FILENAME'], 'php.cgi') == strlen($_SERVER['SCRIPT_FILENAME']) - 7 ) )
42     $_SERVER['SCRIPT_FILENAME'] = $_SERVER['PATH_TRANSLATED'];
43
44 // Fix for Dreamhost and other PHP as CGI hosts
45 if ( strstr( $_SERVER['SCRIPT_NAME'], 'php.cgi' ) )
46     unset($_SERVER['PATH_INFO']);
47
48 // Fix empty PHP_SELF
49 $PHP_SELF = $_SERVER['PHP_SELF'];
50 if ( empty($PHP_SELF) )
51     $_SERVER['PHP_SELF'] = $PHP_SELF = preg_replace("/(\?.*)?$/",'',$_SERVER["REQUEST_URI"]);
52
53 if ( !(phpversion() >= '4.1') )
54     die( 'Your server is running PHP version ' . phpversion() . ' but WordPress requires at least 4.1' );
55
56 if ( !extension_loaded('mysql') )
57     die( 'Your PHP installation appears to be missing the MySQL which is required for WordPress.' );
58
59 function timer_start() {
60     global $timestart;
61     $mtime = explode(' ', microtime() );
62     $mtime = $mtime[1] + $mtime[0];
63     $timestart = $mtime;
64     return true;
65 }
66 timer_start();
67
68 // Change to E_ALL for development/debugging
69 error_reporting(E_ALL ^ E_NOTICE);
70
71 // For an advanced caching plugin to use, static because you would only want one
72 if ( defined('WP_CACHE') )
73     require (ABSPATH . 'wp-content/advanced-cache.php');
74
75 define('WPINC', 'wp-includes');
76 require_once (ABSPATH . WPINC . '/wp-db.php');
77
78 $wpdb->blogs        = $table_prefix . 'blogs';
79 $wpdb->users        = $table_prefix . 'users';
80 $wpdb->usermeta        = $table_prefix . 'usermeta';
81 $wpdb->site        = $table_prefix . 'site';
82 $wpdb->sitemeta        = $table_prefix . 'sitemeta';
83 $wpdb->sitecategories    = $table_prefix . 'sitecategories';
84 $wpdb->signups        = $table_prefix . 'signups';
85
86 require_once ( ABSPATH . 'wpmu-settings.php' );
87 $wpdb->siteid           = $site_id;
88 $wpdb->blogid           = $blog_id;
89 $wpdb->posts            = $table_prefix . 'posts';
90 $wpdb->categories       = $table_prefix . 'categories';
91 $wpdb->post2cat         = $table_prefix . 'post2cat';
92 $wpdb->comments         = $table_prefix . 'comments';
93 $wpdb->link2cat         = $table_prefix . 'link2cat';
94 $wpdb->links            = $table_prefix . 'links';
95 $wpdb->linkcategories   = $table_prefix . 'linkcategories';
96 $wpdb->options          = $table_prefix . 'options';
97 $wpdb->postmeta         = $table_prefix . 'postmeta';
98 $wpdb->prefix           = $table_prefix;
99
100 if ( defined('CUSTOM_USER_TABLE') )
101     $wpdb->users = CUSTOM_USER_TABLE;
102 if ( defined('CUSTOM_USER_META_TABLE') )
103     $wpdb->usermeta = CUSTOM_USER_META_TABLE;
104
105 // We're going to need to keep this around for a few months even though we're not using it internally
106
107 $tableposts = $wpdb->posts;
108 $tableusers = $wpdb->users;
109 $tablecategories = $wpdb->categories;
110 $tablepost2cat = $wpdb->post2cat;
111 $tablecomments = $wpdb->comments;
112 $tablelink2cat = $wpdb->link2cat;
113 $tablelinks = $wpdb->links;
114 $tablelinkcategories = $wpdb->linkcategories;
115 $tableoptions = $wpdb->options;
116 $tablepostmeta = $wpdb->postmeta;
117
118 if ( file_exists(ABSPATH . 'wp-content/object-cache.php') )
119     require (ABSPATH . 'wp-content/object-cache.php');
120 else
121     require (ABSPATH . WPINC . '/cache.php');
122
123 // To disable persistant caching, add the below line to your wp-config.php file, uncommented of course.
124 // define('DISABLE_CACHE', true);
125
126 wp_cache_init();
127
128 if( defined( "BLOGDEFINITION" ) && constant( "BLOGDEFINITION" ) == true )
129     return;
130
131 define( "UPLOADS", "wp-content/blogs.dir/{$wpdb->blogid}/files" );
132
133 require (ABSPATH . WPINC . '/functions.php');
134 require (ABSPATH . WPINC . '/plugin.php');
135 require (ABSPATH . WPINC . '/default-filters.php');
136 require_once (ABSPATH . WPINC . '/l10n.php');
137
138 $wpdb->hide_errors();
139 $db_check = $wpdb->get_var("SELECT option_value FROM $wpdb->options WHERE option_name = 'siteurl'");
140 if ( !$db_check && (!strstr($_SERVER['PHP_SELF'], 'install.php') && !defined('WP_INSTALLING')) ) {
141     if ( strstr($_SERVER['PHP_SELF'], 'wp-admin') )
142         $link = 'install.php';
143     else
144         $link = 'wp-admin/install.php';
145     die(sprintf(__("It doesn't look like you've installed WP yet. Try running <a href='%s'>install.php</a>."), $link));
146 }
147 $wpdb->show_errors();
148
149 require (ABSPATH . WPINC . '/formatting.php');
150 require (ABSPATH . WPINC . '/capabilities.php');
151 require (ABSPATH . WPINC . '/classes.php');
152 require (ABSPATH . WPINC . '/query.php');
153 require (ABSPATH . WPINC . '/theme.php');
154 require (ABSPATH . WPINC . '/user.php');
155 require (ABSPATH . WPINC . '/general-template.php');
156 require (ABSPATH . WPINC . '/link-template.php');
157 require (ABSPATH . WPINC . '/author-template.php');
158 require (ABSPATH . WPINC . '/post.php');
159 require (ABSPATH . WPINC . '/post-template.php');
160 require (ABSPATH . WPINC . '/category.php');
161 require (ABSPATH . WPINC . '/category-template.php');
162 require (ABSPATH . WPINC . '/comment.php');
163 require (ABSPATH . WPINC . '/comment-template.php');
164 require (ABSPATH . WPINC . '/rewrite.php');
165 require (ABSPATH . WPINC . '/feed.php');
166 require (ABSPATH . WPINC . '/bookmark.php');
167 require (ABSPATH . WPINC . '/bookmark-template.php');
168 require (ABSPATH . WPINC . '/kses.php');
169 require (ABSPATH . WPINC . '/cron.php');
170 require (ABSPATH . WPINC . '/version.php');
171 require (ABSPATH . WPINC . '/deprecated.php');
172 require (ABSPATH . WPINC . '/script-loader.php');
173
174 require_once( ABSPATH . WPINC . '/wpmu-functions.php' );
175
176 if( defined( "WP_INSTALLING" ) == false ) {
177     $current_site->site_name = get_site_option('site_name');
178 }
179
180 if( $current_site->site_name == false ) {
181     $current_site->site_name = ucfirst( $current_site->domain );
182 }
183
184 if( defined( "WP_INSTALLING" ) == false ) {
185     $locale = get_option( "WPLANG" );
186     if( $locale == false )
187         $locale = get_site_option( "WPLANG" );
188 }
189
190 $wpdb->hide_errors();
191 $plugins = glob( ABSPATH . 'wp-content/mu-plugins/*.php' );
192 if( is_array( $plugins ) ) {
193     foreach ( $plugins as $plugin ) {
194         if( is_file( $plugin ) )
195             include_once( $plugin );
196     }
197 }
198 $wpdb->show_errors();
199
200 if ( '1' == $current_blog->deleted )
201     graceful_fail('This user has elected to delete their account and the content is no longer available.');
202
203 if ( '2' == $current_blog->deleted )
204         graceful_fail("This blog has not been activated yet. If you are having problems activating your blog, please contact <a href='mailto:support@{$current_site->domain}'>support@{$current_site->domain}</a>.");
205
206 if( $current_blog->archived == '1' )
207     graceful_fail( 'This blog has been archived or suspended.' );
208
209 if( $current_blog->spam == '1' )
210     graceful_fail( 'This blog has been archived or suspended.' );
211
212 if (!strstr($_SERVER['PHP_SELF'], 'install.php') && !strstr($_SERVER['PHP_SELF'], 'wp-admin/import')) :
213     // Used to guarantee unique hash cookies
214     $cookiehash = ''; // Remove in 1.4
215     define('COOKIEHASH', '');
216 endif;
217
218 if ( !defined('USER_COOKIE') )
219     define('USER_COOKIE', 'wordpressuser');
220 if ( !defined('PASS_COOKIE') )
221     define('PASS_COOKIE', 'wordpresspass');
222 if ( !defined('COOKIEPATH') )
223     define('COOKIEPATH', preg_replace('|https?://[^/]+|i', '', get_settings('home') . '/' ) );
224 if ( !defined('SITECOOKIEPATH') )
225     define('SITECOOKIEPATH', preg_replace('|https?://[^/]+|i', '', get_settings('siteurl') . '/' ) );
226 if ( !defined('COOKIE_DOMAIN') )
227     define('COOKIE_DOMAIN', false);
228
229 require (ABSPATH . WPINC . '/vars.php');
230
231 if ( get_settings('active_plugins') ) {
232     $current_plugins = get_settings('active_plugins');
233     if ( is_array($current_plugins) ) {
234         foreach ($current_plugins as $plugin) {
235             if ('' != $plugin && file_exists(ABSPATH . 'wp-content/plugins/' . $plugin))
236                 include_once(ABSPATH . 'wp-content/plugins/' . $plugin);
237         }
238     }
239 }
240
241 require (ABSPATH . WPINC . '/pluggable.php');
242
243 if ( defined('WP_CACHE') && function_exists('wp_cache_postload') )
244     wp_cache_postload();
245
246 do_action('plugins_loaded');
247
248 // If already slashed, strip.
249 if ( get_magic_quotes_gpc() ) {
250     $_GET    = stripslashes_deep($_GET   );
251     $_POST   = stripslashes_deep($_POST  );
252     $_COOKIE = stripslashes_deep($_COOKIE);
253 }
254
255 // Escape with wpdb.
256 $_GET    = add_magic_quotes($_GET   );
257 $_POST   = add_magic_quotes($_POST  );
258 $_COOKIE = add_magic_quotes($_COOKIE);
259 $_SERVER = add_magic_quotes($_SERVER);
260
261 do_action('sanitize_comment_cookies');
262
263 $wp_query   = new WP_Query();
264 $wp_rewrite = new WP_Rewrite();
265 $wp         = new WP();
266
267 define('TEMPLATEPATH', get_template_directory());
268
269 // Load the default text localization domain.
270 load_default_textdomain();
271
272 // Pull in locale data after loading text domain.
273 require_once(ABSPATH . WPINC . '/locale.php');
274
275 $wp_locale = new WP_Locale();
276
277 // Load functions for active theme.
278 if ( file_exists(TEMPLATEPATH . "/functions.php") )
279     include(TEMPLATEPATH . "/functions.php");
280
281 function shutdown_action_hook() {
282     do_action('shutdown');
283     wp_cache_close();
284 }
285 register_shutdown_function('shutdown_action_hook');
286
287 // Everything is loaded and initialized.
288 do_action('init');
289
290 ?>
291
Note: See TracBrowser for help on using the browser.