root/tags/1.5.1/wp-settings.php

Revision 1267, 16.9 kB (checked in by donncha, 7 months ago)

AUTOSAVE_INTERVAL, fixes #617 and #610, props hanifb

  • Property svn:eol-style set to native
Line 
1 <?php
2 /**
3  * Used to setup and fix common variables and include
4  * the WordPress procedural and class library.
5  *
6  * You should not have to change this file and allows
7  * for some configuration in wp-config.php.
8  *
9  * @package WordPress
10  */
11
12 if ( !defined('WP_MEMORY_LIMIT') )
13     define('WP_MEMORY_LIMIT', '32M');
14
15 if ( function_exists('memory_get_usage') && ( (int) @ini_get('memory_limit') < abs(intval(WP_MEMORY_LIMIT)) ) )
16     @ini_set('memory_limit', WP_MEMORY_LIMIT);
17
18
19 /**
20  * wp_unregister_GLOBALS() - Turn register globals off
21  *
22  * @access private
23  * @since 2.1.0
24  * @return null Will return null if register_globals PHP directive was disabled
25  */
26 function wp_unregister_GLOBALS() {
27     if ( !ini_get('register_globals') )
28         return;
29
30     if ( isset($_REQUEST['GLOBALS']) )
31         die('GLOBALS overwrite attempt detected');
32
33     // Variables that shouldn't be unset
34     $noUnset = array('GLOBALS', '_GET', '_POST', '_COOKIE', '_REQUEST', '_SERVER', '_ENV', '_FILES', 'table_prefix');
35
36     $input = array_merge($_GET, $_POST, $_COOKIE, $_SERVER, $_ENV, $_FILES, isset($_SESSION) && is_array($_SESSION) ? $_SESSION : array());
37     foreach ( $input as $k => $v )
38         if ( !in_array($k, $noUnset) && isset($GLOBALS[$k]) ) {
39             $GLOBALS[$k] = NULL;
40             unset($GLOBALS[$k]);
41         }
42 }
43
44 wp_unregister_GLOBALS();
45
46 unset( $wp_filter, $cache_lastcommentmodified, $cache_lastpostdate );
47
48 /**
49  * The $blog_id global, which you can change in the config allows you to create a simple
50  * multiple blog installation using just one WordPress and changing $blog_id around.
51  *
52  * @global int $blog_id
53  * @since 2.0.0
54  */
55 if ( ! isset($blog_id) )
56     $blog_id = 0;
57
58 // Fix for IIS, which doesn't set REQUEST_URI
59 if ( empty( $_SERVER['REQUEST_URI'] ) ) {
60
61     // IIS Mod-Rewrite
62     if (isset($_SERVER['HTTP_X_ORIGINAL_URL'])) {
63         $_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_ORIGINAL_URL'];
64     }
65     // IIS Isapi_Rewrite
66     else if (isset($_SERVER['HTTP_X_REWRITE_URL'])) {
67         $_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_REWRITE_URL'];
68     }
69     else
70     {
71         // Some IIS + PHP configurations puts the script-name in the path-info (No need to append it twice)
72         if ( isset($_SERVER['PATH_INFO']) ) {
73             if ( $_SERVER['PATH_INFO'] == $_SERVER['SCRIPT_NAME'] )
74                 $_SERVER['REQUEST_URI'] = $_SERVER['PATH_INFO'];
75             else
76                 $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'] . $_SERVER['PATH_INFO'];
77         }
78
79         // Append the query string if it exists and isn't null
80         if (isset($_SERVER['QUERY_STRING']) && !empty($_SERVER['QUERY_STRING'])) {
81             $_SERVER['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
82         }
83     }
84 }
85
86 // Fix for PHP as CGI hosts that set SCRIPT_FILENAME to something ending in php.cgi for all requests
87 if ( isset($_SERVER['SCRIPT_FILENAME']) && ( strpos($_SERVER['SCRIPT_FILENAME'], 'php.cgi') == strlen($_SERVER['SCRIPT_FILENAME']) - 7 ) )
88     $_SERVER['SCRIPT_FILENAME'] = $_SERVER['PATH_TRANSLATED'];
89
90 // Fix for Dreamhost and other PHP as CGI hosts
91 if (strpos($_SERVER['SCRIPT_NAME'], 'php.cgi') !== false)
92     unset($_SERVER['PATH_INFO']);
93
94 // Fix empty PHP_SELF
95 $PHP_SELF = $_SERVER['PHP_SELF'];
96 if ( empty($PHP_SELF) )
97     $_SERVER['PHP_SELF'] = $PHP_SELF = preg_replace("/(\?.*)?$/",'',$_SERVER["REQUEST_URI"]);
98
99 if ( version_compare( '4.3', phpversion(), '>' ) ) {
100     die( 'Your server is running PHP version ' . phpversion() . ' but WordPress requires at least 4.3.' );
101 }
102
103 if ( !extension_loaded('mysql') && !file_exists(ABSPATH . 'wp-content/db.php') )
104     die( 'Your PHP installation appears to be missing the MySQL extension which is required by WordPress.' );
105
106 /**
107  * timer_start() - PHP 4 standard microtime start capture
108  *
109  * @access private
110  * @since 0.71
111  * @global int $timestart Seconds and Microseconds added together from when function is called
112  * @return bool Always returns true
113  */
114 function timer_start() {
115     global $timestart;
116     $mtime = explode(' ', microtime() );
117     $mtime = $mtime[1] + $mtime[0];
118     $timestart = $mtime;
119     return true;
120 }
121
122 /**
123  * timer_stop() - Return and/or display the time from the page start to when function is called.
124  *
125  * You can get the results and print them by doing:
126  * <code>
127  * $nTimePageTookToExecute = timer_stop();
128  * echo $nTimePageTookToExecute;
129  * </code>
130  *
131  * Or instead, you can do:
132  * <code>
133  * timer_stop(1);
134  * </code>
135  * which will do what the above does. If you need the result, you can assign it to a variable, but
136  * most cases, you only need to echo it.
137  *
138  * @since 0.71
139  * @global int $timestart Seconds and Microseconds added together from when timer_start() is called
140  * @global int $timeend  Seconds and Microseconds added together from when function is called
141  *
142  * @param int $display Use '0' or null to not echo anything and 1 to echo the total time
143  * @param int $precision The amount of digits from the right of the decimal to display. Default is 3.
144  * @return float The "second.microsecond" finished time calculation
145  */
146 function timer_stop($display = 0, $precision = 3) { //if called like timer_stop(1), will echo $timetotal
147     global $timestart, $timeend;
148     $mtime = microtime();
149     $mtime = explode(' ',$mtime);
150     $mtime = $mtime[1] + $mtime[0];
151     $timeend = $mtime;
152     $timetotal = $timeend-$timestart;
153     $r = ( function_exists('number_format_i18n') ) ? number_format_i18n($timetotal, $precision) : number_format($timetotal, $precision);
154     if ( $display )
155         echo $r;
156     return $r;
157 }
158 timer_start();
159
160 // Add define('WP_DEBUG',true); to wp-config.php to enable display of notices during development.
161 if (defined('WP_DEBUG') and WP_DEBUG == true) {
162     error_reporting(E_ALL);
163 } else {
164     error_reporting(E_ALL ^ E_NOTICE ^ E_USER_NOTICE);
165 }
166
167 // For an advanced caching plugin to use, static because you would only want one
168 if ( defined('WP_CACHE') )
169     @include ABSPATH . 'wp-content/advanced-cache.php';
170
171 /**
172  * Stores the location of the WordPress directory of functions, classes, and core content.
173  *
174  * @since 1.0.0
175  */
176 define('WPINC', 'wp-includes');
177
178 if ( !defined('LANGDIR') ) {
179     /**
180      * Stores the location of the language directory. First looks for language folder in wp-content
181      * and uses that folder if it exists. Or it uses the "languages" folder in WPINC.
182      *
183      * @since 2.1.0
184      */
185     if ( file_exists(ABSPATH . 'wp-content/languages') && @is_dir(ABSPATH . 'wp-content/languages') )
186         define('LANGDIR', 'wp-content/languages'); // no leading slash, no trailing slash
187     else
188         define('LANGDIR', WPINC . '/languages'); // no leading slash, no trailing slash
189 }
190
191 /**
192  * Allows for the plugins directory to be moved from the default location.
193  *
194  * This isn't used everywhere. Constant is not used in plugin_basename()
195  * which might cause conflicts with changing this.
196  *
197  * @since 2.1
198  */
199 if ( !defined('PLUGINDIR') )
200     define('PLUGINDIR', 'wp-content/plugins'); // no leading slash, no trailing slash
201
202 require (ABSPATH . WPINC . '/compat.php');
203 require (ABSPATH . WPINC . '/functions.php');
204 require (ABSPATH . WPINC . '/classes.php');
205
206 require_wp_db();
207
208 if ( !empty($wpdb->error) )
209     dead_db();
210
211 $prefix = $wpdb->set_prefix($table_prefix);
212
213 if ( is_wp_error($prefix) )
214     wp_die('<strong>ERROR</strong>: <code>$table_prefix</code> in <code>wp-config.php</code> can only contain numbers, letters, and underscores.');
215 // Table names. prefix is bare "wp_"
216 $wpdb->blogs        = $wpdb->prefix . 'blogs';
217 $wpdb->site        = $wpdb->prefix . 'site';
218 $wpdb->sitemeta        = $wpdb->prefix . 'sitemeta';
219 $wpdb->sitecategories    = $wpdb->prefix . 'sitecategories';
220 $wpdb->signups        = $wpdb->prefix . 'signups';
221 $wpdb->registration_log    = $wpdb->prefix . 'registration_log';
222 $wpdb->blog_versions    = $wpdb->prefix . 'blog_versions';
223
224 if( defined( 'SUNRISE' ) )
225     include_once( ABSPATH . 'wp-content/sunrise.php' );
226
227 require_once ( ABSPATH . 'wpmu-settings.php' );
228 $prefix = $table_prefix;
229 $wpdb->prefix           = $table_prefix; // prefix now includes a blog_id
230 $wpdb->posts            = $wpdb->prefix . 'posts';
231 $wpdb->categories       = $wpdb->prefix . 'categories';
232 $wpdb->post2cat         = $wpdb->prefix . 'post2cat';
233 $wpdb->comments         = $wpdb->prefix . 'comments';
234 $wpdb->link2cat         = $wpdb->prefix . 'link2cat';
235 $wpdb->links            = $wpdb->prefix . 'links';
236 $wpdb->linkcategories   = $wpdb->prefix . 'linkcategories';
237 $wpdb->options          = $wpdb->prefix . 'options';
238 $wpdb->postmeta         = $wpdb->prefix . 'postmeta';
239 $wpdb->terms            = $wpdb->prefix . 'terms';
240 $wpdb->term_taxonomy    = $wpdb->prefix . 'term_taxonomy';
241 $wpdb->term_relationships = $wpdb->prefix . 'term_relationships';
242 $wpdb->siteid           = $current_blog->site_id;
243 $wpdb->blogid           = $current_blog->blog_id;
244
245 if ( defined('CUSTOM_USER_TABLE') )
246     $wpdb->users = CUSTOM_USER_TABLE;
247 if ( defined('CUSTOM_USER_META_TABLE') )
248     $wpdb->usermeta = CUSTOM_USER_META_TABLE;
249
250 if ( file_exists(ABSPATH . 'wp-content/object-cache.php') )
251     require_once (ABSPATH . 'wp-content/object-cache.php');
252 else
253     require_once (ABSPATH . WPINC . '/cache.php');
254
255 wp_cache_init();
256
257 if( !defined( "UPLOADS" ) )
258     define( "UPLOADS", "wp-content/blogs.dir/{$wpdb->blogid}/files/" );
259
260 require (ABSPATH . WPINC . '/plugin.php');
261 require (ABSPATH . WPINC . '/default-filters.php');
262
263 if( defined( "SHORTINIT" ) && constant( "SHORTINIT" ) == true ) // stop most of WP being loaded, we just want the basics
264     return;
265
266 include_once(ABSPATH . WPINC . '/streams.php');
267 include_once(ABSPATH . WPINC . '/gettext.php');
268 require_once (ABSPATH . WPINC . '/l10n.php');
269
270 if ( !is_blog_installed() && (strpos($_SERVER['PHP_SELF'], 'install.php') === false && !defined('WP_INSTALLING')) ) {
271     if ( defined('WP_SITEURL') )
272         $link = WP_SITEURL . '/wp-admin/install.php';
273     elseif (strpos($_SERVER['PHP_SELF'], 'wp-admin') !== false)
274         $link = preg_replace('|/wp-admin/?.*?$|', '/', $_SERVER['PHP_SELF']) . 'wp-admin/install.php';
275     else
276         $link = preg_replace('|/[^/]+?$|', '/', $_SERVER['PHP_SELF']) . 'wp-admin/install.php';
277     require_once(ABSPATH . WPINC . '/kses.php');
278     require_once(ABSPATH . WPINC . '/pluggable.php');
279     wp_redirect($link);
280     die(); // have to die here ~ Mark
281 }
282
283 require (ABSPATH . WPINC . '/formatting.php');
284 require (ABSPATH . WPINC . '/capabilities.php');
285 require (ABSPATH . WPINC . '/query.php');
286 require (ABSPATH . WPINC . '/theme.php');
287 require (ABSPATH . WPINC . '/user.php');
288 require (ABSPATH . WPINC . '/general-template.php');
289 require (ABSPATH . WPINC . '/link-template.php');
290 require (ABSPATH . WPINC . '/author-template.php');
291 require (ABSPATH . WPINC . '/post.php');
292 require (ABSPATH . WPINC . '/post-template.php');
293 require (ABSPATH . WPINC . '/category.php');
294 require (ABSPATH . WPINC . '/category-template.php');
295 require (ABSPATH . WPINC . '/comment.php');
296 require (ABSPATH . WPINC . '/comment-template.php');
297 require (ABSPATH . WPINC . '/rewrite.php');
298 require (ABSPATH . WPINC . '/feed.php');
299 require (ABSPATH . WPINC . '/bookmark.php');
300 require (ABSPATH . WPINC . '/bookmark-template.php');
301 require (ABSPATH . WPINC . '/kses.php');
302 require (ABSPATH . WPINC . '/cron.php');
303 require (ABSPATH . WPINC . '/version.php');
304 require (ABSPATH . WPINC . '/deprecated.php');
305 require (ABSPATH . WPINC . '/script-loader.php');
306 require (ABSPATH . WPINC . '/taxonomy.php');
307 require (ABSPATH . WPINC . '/update.php');
308 require (ABSPATH . WPINC . '/canonical.php');
309 require (ABSPATH . WPINC . '/shortcodes.php');
310 require (ABSPATH . WPINC . '/media.php');
311
312 require_once( ABSPATH . WPINC . '/wpmu-functions.php' );
313
314 if( defined( "WP_INSTALLING" ) == false )
315     $current_site->site_name = get_site_option('site_name');
316
317 if( $current_site->site_name == false ) {
318     $current_site->site_name = ucfirst( $current_site->domain );
319 }
320
321 if( defined('WP_INSTALLING') == false ) {
322     $locale = get_option('WPLANG');
323     if( $locale === false )
324         $locale = get_site_option('WPLANG');
325 }
326
327 $wpdb->hide_errors();
328 if( defined( 'MUPLUGINDIR' ) == false )
329     define( 'MUPLUGINDIR', 'wp-content/mu-plugins' );
330
331 if( is_dir( ABSPATH . MUPLUGINDIR ) ) {
332     if( $dh = opendir( ABSPATH . MUPLUGINDIR ) ) {
333         while( ( $plugin = readdir( $dh ) ) !== false ) {
334             if( substr( $plugin, -4 ) == '.php' ) {
335                 include_once( ABSPATH . MUPLUGINDIR . '/' . $plugin );
336             }
337         }
338     }
339 }
340 $wpdb->show_errors();
341
342 if ( '1' == $current_blog->deleted )
343     graceful_fail(__('This user has elected to delete their account and the content is no longer available.'));
344
345 if ( '2' == $current_blog->deleted )
346         graceful_fail(sprintf(__('This blog has not been activated yet. If you are having problems activating your blog, please contact <a href="mailto:%1$s">%1$s</a>.'), get_site_option( 'admin_email', "support@{$current_site->domain}" )));
347
348 if( $current_blog->archived == '1' )
349     graceful_fail(__('This blog has been archived or suspended.'));
350
351 if( $current_blog->spam == '1' )
352     graceful_fail(__('This blog has been archived or suspended.'));
353
354 define('COOKIEHASH', '');
355
356 /**
357  * Should be exactly the same as the default value of SECRET_KEY in wp-config-sample.php
358  * @since 2.5
359  */
360 $wp_default_secret_key = 'put your unique phrase here';
361
362 /**
363  * It is possible to define this in wp-config.php
364  * @since 2.0.0
365  */
366 if ( !defined('USER_COOKIE') )
367     define('USER_COOKIE', 'wordpressuser');
368
369 /**
370  * It is possible to define this in wp-config.php
371  * @since 2.0.0
372  */
373 if ( !defined('PASS_COOKIE') )
374     define('PASS_COOKIE', 'wordpresspass');
375
376 /**
377  * It is possible to define this in wp-config.php
378  * @since 2.5
379  */
380 if ( !defined('AUTH_COOKIE') )
381     define('AUTH_COOKIE', 'wordpress');
382
383 /**
384  * It is possible to define this in wp-config.php
385  * @since 2.3.0
386  */
387 if ( !defined('TEST_COOKIE') )
388     define('TEST_COOKIE', 'wordpress_test_cookie');
389
390 /**
391  * It is possible to define this in wp-config.php
392  * @since 1.2.0
393  */
394 if ( !defined('COOKIEPATH') )
395     define('COOKIEPATH', $current_site->path );
396
397 /**
398  * It is possible to define this in wp-config.php
399  * @since 1.5.0
400  */
401 if ( !defined('SITECOOKIEPATH') )
402     define('SITECOOKIEPATH', $current_site->path );
403
404 /**
405  * It is possible to define this in wp-config.php
406  * @since 2.0.0
407  */
408 if ( !defined('COOKIE_DOMAIN') )
409     define('COOKIE_DOMAIN', '.' . $current_site->domain);
410     
411 /**
412  * It is possible to define this in wp-config.php
413  * @since 2.5.0
414  */
415 if ( !defined( 'AUTOSAVE_INTERVAL' ) )
416     define( 'AUTOSAVE_INTERVAL', 60 );
417     
418
419 require (ABSPATH . WPINC . '/vars.php');
420
421 if ( !defined('PLUGINDIR') )
422     define('PLUGINDIR', 'wp-content/plugins'); // no leading slash, no trailing slash
423
424 if ( get_option('active_plugins') ) {
425     $current_plugins = get_option('active_plugins');
426     if ( is_array($current_plugins) ) {
427         foreach ($current_plugins as $plugin) {
428             if ('' != $plugin && file_exists(ABSPATH . PLUGINDIR . '/' . $plugin))
429                 include_once(ABSPATH . PLUGINDIR . '/' . $plugin);
430         }
431     }
432 }
433
434 require (ABSPATH . WPINC . '/pluggable.php');
435
436 /*
437  * In most cases the default internal encoding is latin1, which is of no use,
438  * since we want to use the mb_ functions for utf-8 strings
439  */
440 if (function_exists('mb_internal_encoding')) {
441     if (!@mb_internal_encoding(get_option('blog_charset')))
442         mb_internal_encoding('UTF-8');
443 }
444
445
446 if ( defined('WP_CACHE') && function_exists('wp_cache_postload') )
447     wp_cache_postload();
448
449 do_action('plugins_loaded');
450
451 // If already slashed, strip.
452 if ( get_magic_quotes_gpc() ) {
453     $_GET    = stripslashes_deep($_GET   );
454     $_POST   = stripslashes_deep($_POST  );
455     $_COOKIE = stripslashes_deep($_COOKIE);
456 }
457
458 // Escape with wpdb.
459 $_GET    = add_magic_quotes($_GET   );
460 $_POST   = add_magic_quotes($_POST  );
461 $_COOKIE = add_magic_quotes($_COOKIE);
462 $_SERVER = add_magic_quotes($_SERVER);
463
464 do_action('sanitize_comment_cookies');
465
466 /**
467  * WordPress Query object
468  * @global object $wp_the_query
469  * @since 2.0.0
470  */
471 $wp_the_query =& new WP_Query();
472
473 /**
474  * Holds the reference to @see $wp_the_query
475  * Use this global for WordPress queries
476  * @global object $wp_query
477  * @since 1.5.0
478  */
479 $wp_query     =& $wp_the_query;
480
481 /**
482  * Holds the WordPress Rewrite object for creating pretty URLs
483  * @global object $wp_rewrite
484  * @since 1.5.0
485  */
486 $wp_rewrite   =& new WP_Rewrite();
487
488 /**
489  * WordPress Object
490  * @global object $wp
491  * @since 2.0.0
492  */
493 $wp           =& new WP();
494
495
496 /**
497  * Web Path to the current active template directory
498  * @since 1.5
499  */
500 define('TEMPLATEPATH', get_template_directory());
501
502 /**
503  * Web Path to the current active template stylesheet directory
504  * @since 2.1
505  */
506 define('STYLESHEETPATH', get_stylesheet_directory());
507
508 // Load the default text localization domain.
509 load_default_textdomain();
510
511 /**
512  * The locale of the blog
513  * @since 1.5.0
514  */
515 $locale = get_locale();
516 $locale_file = ABSPATH . LANGDIR . "/$locale.php";
517 if ( is_readable($locale_file) )
518     require_once($locale_file);
519
520 // Pull in locale data after loading text domain.
521 require_once(ABSPATH . WPINC . '/locale.php');
522
523 /**
524  * WordPress Locale object for loading locale domain date and various strings.
525  * @global object $wp_locale
526  * @since 2.1.0
527  */
528 $wp_locale =& new WP_Locale();
529
530 // Load functions for active theme.
531 if ( TEMPLATEPATH !== STYLESHEETPATH && file_exists(STYLESHEETPATH . '/functions.php') )
532     include(STYLESHEETPATH . '/functions.php');
533 if ( file_exists(TEMPLATEPATH . '/functions.php') )
534     include(TEMPLATEPATH . '/functions.php');
535
536 /**
537  * shutdown_action_hook() - Runs just before PHP shuts down execution.
538  *
539  * @access private
540  * @since 1.2
541  */
542 function shutdown_action_hook() {
543     do_action('shutdown');
544     wp_cache_close();
545 }
546 register_shutdown_function('shutdown_action_hook');
547
548 $wp->init();  // Sets up current user.
549
550 // Everything is loaded and initialized.
551 do_action('init');
552
553 ?>
554
Note: See TracBrowser for help on using the browser.