Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 177 lines (141 sloc) 6.01 kb
0bc8613 b2config.php replaced with wp-config.sample.php
mikelittle authored
1 <?php
ec02ded Move above
matt authored
2 // Turn register globals off
71a8451 Typos and more secure unsetting.
matt authored
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');
ec02ded Move above
matt authored
12
71a8451 Typos and more secure unsetting.
matt authored
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]);
ec02ded Move above
matt authored
17 }
18
71a8451 Typos and more secure unsetting.
matt authored
19 unregister_GLOBALS();
20
43e4a8a The great renaming.
saxmatt authored
21 $HTTP_HOST = getenv('HTTP_HOST'); /* domain name */
22 $REMOTE_ADDR = getenv('REMOTE_ADDR'); /* visitor's IP */
23 $HTTP_USER_AGENT = getenv('HTTP_USER_AGENT'); /* visitor's browser */
71a8451 Typos and more secure unsetting.
matt authored
24 unset( $wp_filter, $cache_userdata, $cache_lastcommentmodified, $cache_lastpostdate, $cache_settings, $category_cache, $cache_categories );
43e4a8a The great renaming.
saxmatt authored
25
a18a23e Work around IIS' lack of REQUEST_URI
saxmatt authored
26 // Fix for IIS, which doesn't set REQUEST_URI
720316d Do not touch REQUEST_URI if it is already set by the server.
rboren authored
27 if (! isset($_SERVER['REQUEST_URI'])) {
28 $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'];
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 }
12b4069 Fix REQUEST_URI construction for IIS. Bug 389. Patch from Dennis Wi…
rboren authored
34 }
a18a23e Work around IIS' lack of REQUEST_URI
saxmatt authored
35
da4a0d9 Fix for empty plugin strings, class include moved for timing.
saxmatt authored
36 if ( !(phpversion() >= '4.1') )
37 die( 'Your server is running PHP version ' . phpversion() . ' but WordPress requires at least 4.1' );
38
0d040b3 Sanity check mysql.
saxmatt authored
39 if ( !extension_loaded('mysql') )
40 die( 'Your PHP installation appears to be missing the MySQL which is required for WordPress.' );
41
551e52f Code cleanup and some fixes from the WP Japan folks.
saxmatt authored
42 function timer_start() {
43 global $timestart;
44 $mtime = explode(' ', microtime() );
45 $mtime = $mtime[1] + $mtime[0];
46 $timestart = $mtime;
47 return true;
48 }
49 timer_start();
da4a0d9 Fix for empty plugin strings, class include moved for timing.
saxmatt authored
50
9b09572 Turn down error reporting.
saxmatt authored
51 // Change to E_ALL for development/debugging
52 error_reporting(E_ALL ^ E_NOTICE);
53
70a449d Allow for plugins to kick in before everything if define in wp-config
saxmatt authored
54 // For an advanced caching plugin to use, static because you would only want one
55 if ( defined('WP_CACHE') )
56 require (ABSPATH . 'wp-content/advanced-cache.php');
57
edc7d7c Installation cleanup.
saxmatt authored
58 define('WPINC', 'wp-includes');
e9c7715 Using require_once will make it easier to incorporate WP functionalit…
emc3 authored
59 require_once (ABSPATH . WPINC . '/wp-db.php');
edc7d7c Installation cleanup.
saxmatt authored
60
25ae03e Giant commit, sorry mailing list people. Move all table names to new …
saxmatt authored
61 // Table names
2520d8e Include cleanups
saxmatt authored
62 $wpdb->posts = $table_prefix . 'posts';
63 $wpdb->users = $table_prefix . 'users';
64 $wpdb->categories = $table_prefix . 'categories';
65 $wpdb->post2cat = $table_prefix . 'post2cat';
66 $wpdb->comments = $table_prefix . 'comments';
67 $wpdb->links = $table_prefix . 'links';
68 $wpdb->linkcategories = $table_prefix . 'linkcategories';
69 $wpdb->options = $table_prefix . 'options';
70 $wpdb->postmeta = $table_prefix . 'postmeta';
25ae03e Giant commit, sorry mailing list people. Move all table names to new …
saxmatt authored
71
2765f58 Allow for custom user table. If rewriting user functions need to incl…
saxmatt authored
72 if ( defined('CUSTOM_USER_TABLE') )
73 $wpdb->users = CUSTOM_USER_TABLE;
74
8fff608 Sometimes we need to keep things around.
saxmatt authored
75 // We're going to need to keep this around for a few months even though we're not using it internally
76
77 $tableposts = $wpdb->posts;
78 $tableusers = $wpdb->users;
79 $tablecategories = $wpdb->categories;
80 $tablepost2cat = $wpdb->post2cat;
81 $tablecomments = $wpdb->comments;
82 $tablelinks = $wpdb->links;
83 $tablelinkcategories = $wpdb->linkcategories;
84 $tableoptions = $wpdb->options;
85 $tablepostmeta = $wpdb->postmeta;
86
9dc65ab Cleaning up some includes.
saxmatt authored
87 require (ABSPATH . WPINC . '/functions.php');
81e7d92 Some filter action and cleanup
saxmatt authored
88 require (ABSPATH . WPINC . '/default-filters.php');
ba04c52 Cleanup wp-l10n includes.
rboren authored
89 require_once (ABSPATH . WPINC . '/wp-l10n.php');
1bd4057 Bug fixes
saxmatt authored
90
91 $wpdb->hide_errors();
171fa8f And not or when checking if installing. Props: donncha
ryan authored
92 if ( !update_user_cache() && (!strstr($_SERVER['PHP_SELF'], 'install.php') && !defined('WP_INSTALLING')) ) {
ca2815f If we're already in wp-admin don't recursive link
saxmatt authored
93 if ( strstr($_SERVER['PHP_SELF'], 'wp-admin') )
94 $link = 'install.php';
95 else
96 $link = 'wp-admin/install.php';
139adf7 gettext install and upgrade. http://mosquito.wordpress.org/view.php?…
ryan authored
97 die(sprintf(__("It doesn't look like you've installed WP yet. Try running <a href='%s'>install.php</a>."), $link));
ca2815f If we're already in wp-admin don't recursive link
saxmatt authored
98 }
1bd4057 Bug fixes
saxmatt authored
99 $wpdb->show_errors();
100
ba407ff E_ALL fixes and cleanups.
saxmatt authored
101 require (ABSPATH . WPINC . '/functions-formatting.php');
40a8e68 Trackback and pingback cleanups.
saxmatt authored
102 require (ABSPATH . WPINC . '/functions-post.php');
da4a0d9 Fix for empty plugin strings, class include moved for timing.
saxmatt authored
103 require (ABSPATH . WPINC . '/classes.php');
2520d8e Include cleanups
saxmatt authored
104 require (ABSPATH . WPINC . '/template-functions-general.php');
105 require (ABSPATH . WPINC . '/template-functions-links.php');
106 require (ABSPATH . WPINC . '/template-functions-author.php');
107 require (ABSPATH . WPINC . '/template-functions-post.php');
108 require (ABSPATH . WPINC . '/template-functions-category.php');
109 require (ABSPATH . WPINC . '/comment-functions.php');
110 require (ABSPATH . WPINC . '/feed-functions.php');
9dc65ab Cleaning up some includes.
saxmatt authored
111 require (ABSPATH . WPINC . '/links.php');
112 require (ABSPATH . WPINC . '/kses.php');
2520d8e Include cleanups
saxmatt authored
113 require (ABSPATH . WPINC . '/version.php');
da4a0d9 Fix for empty plugin strings, class include moved for timing.
saxmatt authored
114
a2342f1 Define COOKIEHASH and new get_profile function. TODO: re-org function…
saxmatt authored
115 if (!strstr($_SERVER['PHP_SELF'], 'install.php') && !strstr($_SERVER['PHP_SELF'], 'wp-admin/import')) :
116 // Used to guarantee unique hash cookies
587429f Move to cookiehash define, use wp_login() function for auth.php.
saxmatt authored
117 $cookiehash = md5(get_settings('siteurl')); // Remove in 1.4
a2342f1 Define COOKIEHASH and new get_profile function. TODO: re-org function…
saxmatt authored
118 define('COOKIEHASH', $cookiehash);
119 endif;
5c97b54 Smilie fix from Jaykul, changed fool's siteurl fix to use faster preg…
saxmatt authored
120
9dc65ab Cleaning up some includes.
saxmatt authored
121 require (ABSPATH . WPINC . '/vars.php');
edc7d7c Installation cleanup.
saxmatt authored
122
70a449d Allow for plugins to kick in before everything if define in wp-config
saxmatt authored
123 do_action('core_files_loaded');
124
c26991b Move hack file include.
saxmatt authored
125 // Check for hacks file if the option is enabled
126 if (get_settings('hack_file')) {
127 if (file_exists(ABSPATH . '/my-hacks.php'))
128 require(ABSPATH . '/my-hacks.php');
129 }
130
ee4edd7 Load plugins even on plugin page.
saxmatt authored
131 if ( get_settings('active_plugins') ) {
a4aa259 Use array storage for plugins list.
saxmatt authored
132 $current_plugins = get_settings('active_plugins');
11f5bb3 Add a precautionary is_array() check around the plugin loading loop. …
ryan authored
133 if ( is_array($current_plugins) ) {
134 foreach ($current_plugins as $plugin) {
135 if ('' != $plugin && file_exists(ABSPATH . 'wp-content/plugins/' . $plugin))
136 include_once(ABSPATH . 'wp-content/plugins/' . $plugin);
137 }
e733249 Functional plugin implementation.
saxmatt authored
138 }
139 }
1127059 shutdown action hook.
saxmatt authored
140
08b02d9 Move plugin replacebale functions to pluggable-functions.php. http:/…
ryan authored
141 require (ABSPATH . WPINC . '/pluggable-functions.php');
142
70a449d Allow for plugins to kick in before everything if define in wp-config
saxmatt authored
143 if ( defined('WP_CACHE') && function_exists('wp_cache_postload') )
144 wp_cache_postload();
145
146 do_action('plugins_loaded');
147
b1f753a Define TEMPLATEPATH. Look for footer, sidebar, and header in the tem…
rboren authored
148 define('TEMPLATEPATH', get_template_directory());
149
0e73b09 Set the locale and load the default text domain after plugins are loa…
rboren authored
150 // Load the default text localization domain.
151 load_default_textdomain();
152
153 // Pull in locale data after loading text domain.
154 require_once(ABSPATH . WPINC . '/locale.php');
155
0aa0754 Security back ports from masquerade and MarkJaquith.
ryan authored
156 // If already slashed, strip.
157 if ( get_magic_quotes_gpc() ) {
158 $_GET = stripslashes_deep($_GET );
159 $_POST = stripslashes_deep($_POST );
160 $_COOKIE = stripslashes_deep($_COOKIE);
65bbec7 Comments refactoring and cleanup
saxmatt authored
161 }
162
0aa0754 Security back ports from masquerade and MarkJaquith.
ryan authored
163 // Escape with wpdb.
164 $_GET = add_magic_quotes($_GET );
165 $_POST = add_magic_quotes($_POST );
166 $_COOKIE = add_magic_quotes($_COOKIE);
167 $_SERVER = add_magic_quotes($_SERVER);
168
1127059 shutdown action hook.
saxmatt authored
169 function shutdown_action_hook() {
9838608 Allow multiple args to be passed to apply_filters and do_action. Mov…
rboren authored
170 do_action('shutdown');
1127059 shutdown action hook.
saxmatt authored
171 }
172 register_shutdown_function('shutdown_action_hook');
173
84f2d42 Add link filters for bug 743 (hat tip to morganiq). More abstraction…
rboren authored
174 // Everything is loaded.
9838608 Allow multiple args to be passed to apply_filters and do_action. Mov…
rboren authored
175 do_action('init');
139adf7 gettext install and upgrade. http://mosquito.wordpress.org/view.php?…
ryan authored
176 ?>
Something went wrong with that request. Please try again.