root/tags/0.8.3.1/bb-settings.php

Revision 995, 6.9 kB (checked in by mdawaffe, 8 months ago)

bring branches/0.8 in line with trunk@971

  • Property svn:eol-style set to native
Line 
1 <?php
2
3 if ( phpversion() < '4.2' )
4     die(sprintf('Your server is running PHP version %s but bbPress requires at least 4.2', phpversion()) );
5
6 if ( !$bb_table_prefix )
7     die('You must specify a table prefix in your <code>config.php</code> file.');
8
9 if ( !defined('BBPATH') )
10     die('This file cannot be called directly.');
11
12 // Turn register globals off
13 function bb_unregister_GLOBALS() {
14     if ( !ini_get('register_globals') )
15         return;
16
17     if ( isset($_REQUEST['GLOBALS']) )
18         die('GLOBALS overwrite attempt detected');
19
20     // Variables that shouldn't be unset
21     $noUnset = array('GLOBALS', '_GET', '_POST', '_COOKIE', '_REQUEST', '_SERVER', '_ENV', '_FILES', 'bb_table_prefix', 'bb');
22
23     $input = array_merge($_GET, $_POST, $_COOKIE, $_SERVER, $_ENV, $_FILES, isset($_SESSION) && is_array($_SESSION) ? $_SESSION : array());
24     foreach ( $input as $k => $v )
25         if ( !in_array($k, $noUnset) && isset($GLOBALS[$k]) ) {
26             $GLOBALS[$k] = NULL;
27             unset($GLOBALS[$k]);
28         }
29 }
30
31 bb_unregister_GLOBALS();
32
33 function bb_timer_start() {
34     global $bb_timestart;
35     $mtime = explode(' ', microtime() );
36     $bb_timestart = $mtime[1] + $mtime[0];
37     return true;
38 }
39 bb_timer_start();
40
41 $is_IIS = strstr($_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS') ? 1 : 0;
42 // Fix for IIS, which doesn't set REQUEST_URI
43 if ( empty( $_SERVER['REQUEST_URI'] ) ) {
44     $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME']; // Does this work under CGI?
45
46     // Append the query string if it exists and isn't null
47     if (isset($_SERVER['QUERY_STRING']) && !empty($_SERVER['QUERY_STRING']))
48         $_SERVER['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
49 }
50
51
52 error_reporting(E_ALL ^ E_NOTICE);
53
54 if ( isset($bb->uri) ) {
55     $bb->domain = preg_replace('|(?<!/)/(?!/).*$|', '', $bb->uri);
56     $bb->path = substr($bb->uri, strlen($bb->domain));
57 } elseif ( isset($bb->path) && isset($bb->domain) ) {
58     $bb->domain = rtrim($bb->domain, '/');
59     $bb->path = '/' . ltrim($bb->path, '/');
60 } else {
61     bb_die( '<code>$bb->uri</cade> must be set in your <code>config.php</code> file.' );
62 }
63
64 foreach ( array('wp_site_url', 'wp_home', 'path') as $p )
65     if ( isset($bb->$p) && $bb->$p )
66         $bb->$p = rtrim($bb->$p, '/');
67 unset($p);
68
69 $bb->path = "$bb->path/";
70 $bb->uri = $bb->domain . $bb->path;
71
72 define('BBINC', 'bb-includes/');
73 if ( !defined('BBLANGDIR') )
74     define('BBLANGDIR', BBPATH . BBINC . 'languages/'); // absolute path with trailing slash
75 if ( !defined('BBPLUGINDIR') )
76     define('BBPLUGINDIR', BBPATH . 'my-plugins/');
77 if ( !defined('BBPLUGINURL') )
78     define('BBPLUGINURL', $bb->uri . 'my-plugins/');
79 if ( !defined('BBTHEMEDIR') )
80     define('BBTHEMEDIR', BBPATH . 'my-templates/');
81 if ( !defined('BBTHEMEURL') )
82     define('BBTHEMEURL', $bb->uri . 'my-templates/');
83 if ( !defined('BBDEFAULTTHEMEDIR') )
84     define('BBDEFAULTTHEMEDIR', BBPATH . 'bb-templates/kakumei/');
85 if ( !defined('BBDEFAULTTHEMEURL') )
86     define('BBDEFAULTTHEMEURL', $bb->uri . 'bb-templates/kakumei/');
87
88 require( BBPATH . BBINC . 'db-base.php');
89 if ( extension_loaded('mysql') ) {
90     require( BBPATH . BBINC . 'db.php');
91 } elseif ( extension_loaded('mysqli') ) {
92     require( BBPATH . BBINC . 'db-mysqli.php');
93 } else {
94     die('Your PHP installation appears to be missing the MySQL which is required for bbPress.');
95 }
96
97 require( BBPATH . BBINC . 'compat.php');
98 require( BBPATH . BBINC . 'wp-functions.php');
99 require( BBPATH . BBINC . 'functions.php');
100 require( BBPATH . BBINC . 'wp-classes.php');
101 require( BBPATH . BBINC . 'classes.php');
102
103 if ( is_wp_error( $bbdb->set_prefix( $bb_table_prefix ) ) )
104     die('Your table prefix may only contain letters, numbers and underscores.');
105
106 foreach ( array('use_cache', 'secret', 'debug', 'wp_table_prefix', 'wp_home', 'wp_siteurl', 'cookiedomain', 'static_title', 'load_options', 'akismet_key') as $o )
107     if ( !isset($bb->$o) )
108         $bb->$o = false;
109 unset($o);
110
111 if ( defined('BB_INSTALLING') && BB_INSTALLING )
112 foreach ( array('active_plugins') as $i )
113     $bb->$i = false;
114 unset($i);
115
116 require( BBPATH . BBINC . 'formatting-functions.php');
117 require( BBPATH . BBINC . 'template-functions.php');
118 require( BBPATH . BBINC . 'capabilities.php');
119 require( BBPATH . BBINC . 'cache.php');
120 require( BBPATH . BBINC . 'deprecated.php');
121 if ( defined('BBLANG') && '' != constant('BBLANG') ) {
122     include_once(BBPATH . BBINC . 'streams.php');
123     include_once(BBPATH . BBINC . 'gettext.php');
124 }
125 if ( !( defined('DB_NAME') || defined('WP_BB') && WP_BB ) ) {  // Don't include these when WP is running.
126     require( BBPATH . BBINC . 'kses.php');
127     require( BBPATH . BBINC . 'l10n.php');
128 }
129 require( BBPATH . BBINC . 'bozo.php');
130 require( BBPATH . BBINC . 'akismet.php');
131 require( BBPATH . BBINC . 'default-filters.php');
132 require( BBPATH . BBINC . 'script-loader.php');
133
134 if ( !bb_is_installed() && false === strpos($_SERVER['PHP_SELF'], 'install.php') && !defined('BB_INSTALLING') )
135     die(sprintf(__('Doesn&#8217;t look like you&#8217;ve installed bbPress yet, <a href="%s">go here</a>.'), 'bb-admin/install.php'));
136
137 $bb_cache = new BB_Cache();
138
139 if ( $bb->load_options ) {
140     $bbdb->hide_errors();
141     bb_cache_all_options();
142     $bbdb->show_errors();
143 }
144
145 $_GET    = bb_global_sanitize($_GET   );
146 $_POST   = bb_global_sanitize($_POST  );
147 $_COOKIE = bb_global_sanitize($_COOKIE, false);
148 $_SERVER = bb_global_sanitize($_SERVER);
149
150 if ( defined('CUSTOM_USER_TABLE') )
151     $bbdb->users = CUSTOM_USER_TABLE;
152 if ( defined('CUSTOM_USER_META_TABLE') )
153     $bbdb->usermeta = CUSTOM_USER_META_TABLE;
154
155 define('BBHASH', $bb->wp_siteurl ? md5($bb->wp_siteurl) : md5($bb_table_prefix) );
156
157 if ( !isset( $bb->usercookie ) )
158     $bb->usercookie = ( $bb->wp_table_prefix ? 'wordpressuser_' : 'bb_user_' ) . BBHASH;
159 if ( !isset( $bb->passcookie ) )
160     $bb->passcookie = ( $bb->wp_table_prefix ? 'wordpresspass_' : 'bb_pass_' ) . BBHASH;
161 if ( !isset( $bb->cookiepath ) )
162     $bb->cookiepath = $bb->wp_home ? preg_replace('|https?://[^/]+|i', '', $bb->wp_home . '/' ) : $bb->path;
163 if ( !isset( $bb->sitecookiepath ) )
164     $bb->sitecookiepath = $bb->wp_siteurl ? preg_replace('|https?://[^/]+|i', '', $bb->wp_siteurl . '/' ) : $bb->path;
165 if ( !isset( $bb->tagpath ) )
166     $bb->tagpath = $bb->path;
167
168 if ( is_callable( 'glob' ) )
169     foreach ( glob(BBPLUGINDIR . '_*.php') as $_plugin )
170         require($_plugin);
171 unset($_plugin);
172 do_action( 'bb_underscore_plugins_loaded' );
173
174 if ( $plugins = bb_get_option( 'active_plugins' ) )
175     foreach ( (array) $plugins as $plugin )
176         if ( file_exists(BBPLUGINDIR . $plugin) )
177             require( BBPLUGINDIR . $plugin );
178 do_action( 'bb_plugins_loaded' );
179 unset($plugins, $plugin);
180
181 require( BBPATH . BBINC . 'pluggable.php');
182
183 // Load the default text localization domain.
184 load_default_textdomain();
185
186 // Pull in locale data after loading text domain.
187 require_once(BBPATH . BBINC . 'locale.php');
188 $bb_locale = new BB_Locale();
189
190 $bb_roles  = new BB_Roles();
191 do_action('bb_got_roles', '');
192
193 function bb_shutdown_action_hook() {
194     do_action('bb_shutdown', '');
195 }
196 register_shutdown_function('bb_shutdown_action_hook');
197
198 bb_current_user();
199
200 do_action('bb_init', '');
201
202 if ( bb_is_user_logged_in() && bb_has_broken_pass() )
203     bb_block_current_user();
204
205 $page = bb_get_uri_page();
206
207 bb_send_headers();
208
209 ?>
210
Note: See TracBrowser for help on using the browser.