]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-settings.php
Wordpress 2.0.11
[autoinstalls/wordpress.git] / wp-settings.php
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                 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 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') )
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 timer_start();
65
66 // Change to E_ALL for development/debugging
67 error_reporting(E_ALL ^ E_NOTICE);
68
69 // For an advanced caching plugin to use, static because you would only want one
70 if ( defined('WP_CACHE') )
71         require (ABSPATH . 'wp-content/advanced-cache.php');
72
73 define('WPINC', 'wp-includes');
74 require_once (ABSPATH . WPINC . '/wp-db.php');
75
76 // Table names
77 $wpdb->posts            = $table_prefix . 'posts';
78 $wpdb->users            = $table_prefix . 'users';
79 $wpdb->categories       = $table_prefix . 'categories';
80 $wpdb->post2cat         = $table_prefix . 'post2cat';
81 $wpdb->comments         = $table_prefix . 'comments';
82 $wpdb->links            = $table_prefix . 'links';
83 $wpdb->linkcategories   = $table_prefix . 'linkcategories';
84 $wpdb->options          = $table_prefix . 'options';
85 $wpdb->postmeta         = $table_prefix . 'postmeta';
86 $wpdb->usermeta         = $table_prefix . 'usermeta';
87
88 $wpdb->prefix           = $table_prefix;
89
90 if ( defined('CUSTOM_USER_TABLE') )
91         $wpdb->users = CUSTOM_USER_TABLE;
92 if ( defined('CUSTOM_USER_META_TABLE') )
93         $wpdb->usermeta = CUSTOM_USER_META_TABLE;
94
95 // We're going to need to keep this around for a few months even though we're not using it internally
96
97 $tableposts = $wpdb->posts;
98 $tableusers = $wpdb->users;
99 $tablecategories = $wpdb->categories;
100 $tablepost2cat = $wpdb->post2cat;
101 $tablecomments = $wpdb->comments;
102 $tablelinks = $wpdb->links;
103 $tablelinkcategories = $wpdb->linkcategories;
104 $tableoptions = $wpdb->options;
105 $tablepostmeta = $wpdb->postmeta;
106
107 if ( file_exists(ABSPATH . 'wp-content/object-cache.php') )
108         require (ABSPATH . 'wp-content/object-cache.php');
109 else
110         require (ABSPATH . WPINC . '/cache.php');
111
112 // To disable persistant caching, add the below line to your wp-config.php file, uncommented of course.
113 // define('DISABLE_CACHE', true);
114
115 wp_cache_init();
116
117 require (ABSPATH . WPINC . '/functions.php');
118 require (ABSPATH . WPINC . '/default-filters.php');
119 require_once (ABSPATH . WPINC . '/wp-l10n.php');
120
121 $wpdb->hide_errors();
122 $db_check = $wpdb->get_var("SELECT option_value FROM $wpdb->options WHERE option_name = 'siteurl'");
123 if ( !$db_check && (!strstr($_SERVER['PHP_SELF'], 'install.php') && !defined('WP_INSTALLING')) ) {
124         if ( strstr($_SERVER['PHP_SELF'], 'wp-admin') )
125                 $link = 'install.php';
126         else
127                 $link = 'wp-admin/install.php';
128         die(sprintf(__("It doesn't look like you've installed WP yet. Try running <a href='%s'>install.php</a>."), $link));
129 }
130 $wpdb->show_errors();
131
132 require (ABSPATH . WPINC . '/functions-formatting.php');
133 require (ABSPATH . WPINC . '/functions-post.php');
134 require (ABSPATH . WPINC . '/capabilities.php');
135 require (ABSPATH . WPINC . '/classes.php');
136 require (ABSPATH . WPINC . '/template-functions-general.php');
137 require (ABSPATH . WPINC . '/template-functions-links.php');
138 require (ABSPATH . WPINC . '/template-functions-author.php');
139 require (ABSPATH . WPINC . '/template-functions-post.php');
140 require (ABSPATH . WPINC . '/template-functions-category.php');
141 require (ABSPATH . WPINC . '/comment-functions.php');
142 require (ABSPATH . WPINC . '/feed-functions.php');
143 require (ABSPATH . WPINC . '/links.php');
144 require (ABSPATH . WPINC . '/kses.php');
145 require (ABSPATH . WPINC . '/version.php');
146
147 if (!strstr($_SERVER['PHP_SELF'], 'install.php')) :
148     // Used to guarantee unique hash cookies
149     $cookiehash = md5(get_settings('siteurl')); // Remove in 1.4
150         define('COOKIEHASH', $cookiehash); 
151 endif;
152
153 if ( !defined('USER_COOKIE') )
154         define('USER_COOKIE', 'wordpressuser_'. COOKIEHASH);
155 if ( !defined('PASS_COOKIE') )
156         define('PASS_COOKIE', 'wordpresspass_'. COOKIEHASH);
157 if ( !defined('COOKIEPATH') )
158         define('COOKIEPATH', preg_replace('|https?://[^/]+|i', '', get_settings('home') . '/' ) );
159 if ( !defined('SITECOOKIEPATH') )
160         define('SITECOOKIEPATH', preg_replace('|https?://[^/]+|i', '', get_settings('siteurl') . '/' ) );
161 if ( !defined('COOKIE_DOMAIN') )
162         define('COOKIE_DOMAIN', false);
163
164 require (ABSPATH . WPINC . '/vars.php');
165
166 // Check for hacks file if the option is enabled
167 if (get_settings('hack_file')) {
168         if (file_exists(ABSPATH . '/my-hacks.php'))
169                 require(ABSPATH . '/my-hacks.php');
170 }
171
172 if ( get_settings('active_plugins') ) {
173         $current_plugins = get_settings('active_plugins');
174         if ( is_array($current_plugins) ) {
175                 foreach ($current_plugins as $plugin) {
176                         if ('' != $plugin && file_exists(ABSPATH . 'wp-content/plugins/' . $plugin))
177                                 include_once(ABSPATH . 'wp-content/plugins/' . $plugin);
178                 }
179         }
180 }
181
182 require (ABSPATH . WPINC . '/pluggable-functions.php');
183
184 if ( defined('WP_CACHE') && function_exists('wp_cache_postload') )
185         wp_cache_postload();
186
187 do_action('plugins_loaded');
188
189 // If already slashed, strip.
190 if ( get_magic_quotes_gpc() ) {
191         $_GET    = stripslashes_deep($_GET   );
192         $_POST   = stripslashes_deep($_POST  );
193         $_COOKIE = stripslashes_deep($_COOKIE);
194 }
195
196 // Escape with wpdb.
197 $_GET    = add_magic_quotes($_GET   );
198 $_POST   = add_magic_quotes($_POST  );
199 $_COOKIE = add_magic_quotes($_COOKIE);
200 $_SERVER = add_magic_quotes($_SERVER);
201
202 do_action('sanitize_comment_cookies');
203
204 $wp_the_query =& new WP_Query();
205 $wp_query     =& $wp_the_query;
206 $wp_rewrite   =& new WP_Rewrite();
207 $wp           =& new WP();
208
209 define('TEMPLATEPATH', get_template_directory());
210
211 // Load the default text localization domain.
212 load_default_textdomain();
213
214 // Pull in locale data after loading text domain.
215 require_once(ABSPATH . WPINC . '/locale.php');
216
217 // Load functions for active theme.
218 if ( file_exists(TEMPLATEPATH . "/functions.php") )
219         include(TEMPLATEPATH . "/functions.php");
220
221 function shutdown_action_hook() {
222         do_action('shutdown');
223         wp_cache_close();
224 }
225 register_shutdown_function('shutdown_action_hook');
226
227 // Everything is loaded and initialized.
228 do_action('init');
229
230 ?>