Log in with username/password: lyceum/lyceum

root/trunk/src/lib/wp-settings.php

Revision 613, 8.3 kB (checked in by jjb, 4 years ago)

slugs!

Line 
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             unset($GLOBALS[$k]);
17 }
18 unregister_GLOBALS();
19
20 $HTTP_USER_AGENT = getenv('HTTP_USER_AGENT');
21 unset( $wp_filter, $cache_userdata, $cache_lastcommentmodified, $cache_lastpostdate, $cache_settings, $category_cache, $cache_categories );
22
23 if ( ! isset($blog_id) )
24     $blog_id = 1;
25
26 // Fix for IIS, which doesn't set REQUEST_URI
27 if ( empty( $_SERVER['REQUEST_URI'] ) ) {
28     $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME']; // Does this work under CGI?
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     }
34 }
35
36 // Fix for PHP as CGI hosts that set SCRIPT_FILENAME to something ending in php.cgi for all requests
37 if ( isset($_SERVER['SCRIPT_FILENAME']) && ( strpos($_SERVER['SCRIPT_FILENAME'], 'php.cgi') == strlen($_SERVER['SCRIPT_FILENAME']) - 7 ) )
38     $_SERVER['SCRIPT_FILENAME'] = $_SERVER['PATH_TRANSLATED'];
39
40 // Fix for Dreamhost and other PHP as CGI hosts
41 if ( strstr( $_SERVER['SCRIPT_NAME'], 'php.cgi' ) )
42     unset($_SERVER['PATH_INFO']);
43
44 // Fix empty PHP_SELF
45 $PHP_SELF = $_SERVER['PHP_SELF'];
46 if ( empty($PHP_SELF) )
47     $_SERVER['PHP_SELF'] = $PHP_SELF = preg_replace("/(\?.*)?$/",'',$_SERVER["REQUEST_URI"]);
48
49 function timer_start() {
50     global $timestart;
51     $mtime = explode(' ', microtime() );
52     $mtime = $mtime[1] + $mtime[0];
53     $timestart = $mtime;
54     return true;
55 }
56 timer_start();
57
58 // Change to E_ALL for development/debugging
59 //error_reporting(E_ALL ^ E_NOTICE);
60 //error_reporting(E_ALL);
61
62 // For an advanced caching plugin to use, static because you would only want one
63 if ( defined('WP_CACHE') )
64     require (ABSPATH . 'wp-content/advanced-cache.php');
65
66 define('WPINC', PRIVATE_REL_PATH . 'lib/wp-includes');
67 require_once (ABSPATH . WPINC . '/wp-db.php');
68
69 // Table names
70 $wpdb->posts            = $table_prefix . 'posts';
71 $wpdb->users            = $table_prefix . 'users';
72 $wpdb->categories       = $table_prefix . 'categories';
73 $wpdb->post2cat         = $table_prefix . 'post2cat';
74 $wpdb->comments         = $table_prefix . 'comments';
75 $wpdb->links            = $table_prefix . 'links';
76 $wpdb->linkcategories   = $table_prefix . 'linkcategories';
77 $wpdb->options          = $table_prefix . 'options';
78 $wpdb->postmeta         = $table_prefix . 'postmeta';
79 $wpdb->usermeta         = $table_prefix . 'usermeta';
80 $wpdb->blogs            = $table_prefix . 'blogs';
81 $wpdb->postsearch       = $table_prefix . 'postsearch';
82 $wpdb->sessions         = $table_prefix . 'sessions';
83
84 $wpdb->prefix           = $table_prefix;
85
86 if ( defined('CUSTOM_USER_TABLE') )
87     $wpdb->users = CUSTOM_USER_TABLE;
88 if ( defined('CUSTOM_USER_META_TABLE') )
89     $wpdb->usermeta = CUSTOM_USER_META_TABLE;
90
91 $tableposts = $wpdb->posts;
92 $tableusers = $wpdb->users;
93 $tablecategories = $wpdb->categories;
94 $tablepost2cat = $wpdb->post2cat;
95 $tablecomments = $wpdb->comments;
96 $tablelinks = $wpdb->links;
97 $tablelinkcategories = $wpdb->linkcategories;
98 $tableoptions = $wpdb->options;
99 $tablepostmeta = $wpdb->postmeta;
100
101 if ( file_exists(ABSPATH . 'wp-content/object-cache.php') )
102     require (ABSPATH . 'wp-content/object-cache.php');
103 else
104     require (ABSPATH . WPINC . '/cache.php');
105
106 // To disable persistant caching, add the below line to your wp-config.php file, uncommented of course.
107 define('DISABLE_CACHE', true);
108
109 wp_cache_init();
110
111 require (ABSPATH . WPINC . '/functions.php');
112 require (ABSPATH . WPINC . '/default-filters.php');
113 require_once (ABSPATH . WPINC . '/wp-l10n.php');
114
115 /*
116 $wpdb->hide_errors();
117 $db_check = $wpdb->get_var("SELECT option_value FROM $wpdb->options WHERE option_name = 'siteurl'");
118 if ( !$db_check && (!strstr($_SERVER['PHP_SELF'], 'install.php') && !defined('WP_INSTALLING')) ) {
119     if ( strstr($_SERVER['PHP_SELF'], 'wp-admin') )
120         $link = 'install.php';
121     else
122         $link = 'wp-admin/install.php';
123     die(sprintf(__("It doesn't look like you've installed WP yet. Try running <a href='%s'>install.php</a>."), $link));
124 }
125 $wpdb->show_errors();
126 */
127
128 require (ABSPATH . WPINC . '/functions-formatting.php');
129 require (ABSPATH . WPINC . '/functions-post.php');
130 require (ABSPATH . WPINC . '/capabilities.php');
131 require (ABSPATH . WPINC . '/classes.php');
132 require (ABSPATH . WPINC . '/template-functions-general.php');
133 require (ABSPATH . WPINC . '/template-functions-links.php');
134 require (ABSPATH . WPINC . '/template-functions-author.php');
135 require (ABSPATH . WPINC . '/template-functions-post.php');
136 require (ABSPATH . WPINC . '/template-functions-category.php');
137 require (ABSPATH . WPINC . '/comment-functions.php');
138 require (ABSPATH . WPINC . '/feed-functions.php');
139 require (ABSPATH . WPINC . '/links.php');
140 require (ABSPATH . WPINC . '/kses.php');
141 require (ABSPATH . WPINC . '/version.php');
142 require (PRIVATEROOT . 'lib/functions.php');
143 require (PRIVATEROOT . 'lib/session.php');
144
145 //TODO use cache
146 if (!isset($blogdata)){
147     if (!isset($_REQUEST['b']))
148         header('Location: '.PORTAL );//redirect to public portal
149     else {
150         $blogdata = $wpdb->get_row("SELECT * FROM `$wpdb->blogs` WHERE `slug`='{$_REQUEST['b']}'");
151 //    trace('$blogdata', array_print($blogdata));
152         $blog = $blogdata->id;
153         $blogstatus = $blogdata->status;
154     }
155 }
156 if (!isset($blog))
157     $blog = 'NULL';
158
159 if (!strstr($_SERVER['PHP_SELF'], 'install.php')) :
160     // Used to guarantee unique hash cookies
161     $cookiehash = md5(get_settings('siteurl')); // Remove in 1.4
162     define('COOKIEHASH', $cookiehash);
163 endif;
164
165 if ( !defined('USER_COOKIE') )
166     define('USER_COOKIE', 'wordpressuser_'. COOKIEHASH);
167 if ( !defined('PASS_COOKIE') )
168     define('PASS_COOKIE', 'wordpresspass_'. COOKIEHASH);
169 if ( !defined('COOKIEPATH') )
170     define('COOKIEPATH', preg_replace('|https?://[^/]+|i', '', get_settings('home') . '/' ) );
171 if ( !defined('SITECOOKIEPATH') )
172     define('SITECOOKIEPATH', preg_replace('|https?://[^/]+|i', '', get_settings('siteurl') . '/' ) );
173 if ( !defined('COOKIE_DOMAIN') )
174     define('COOKIE_DOMAIN', false);
175
176 require (ABSPATH . WPINC . '/vars.php');
177
178 // Check for hacks file if the option is enabled
179 if (get_settings('hack_file')) {
180     if (file_exists(ABSPATH . '/my-hacks.php'))
181         require(ABSPATH . '/my-hacks.php');
182 }
183
184 if ( get_settings('active_plugins') || get_settings('active_system_plugins')) {
185     $current_plugins = array_merge(get_settings('active_plugins'), get_settings('active_system_plugins'));
186     if ( is_array($current_plugins) ) {
187         foreach ($current_plugins as $plugin) {
188             if ('' != $plugin && file_exists(ABSPATH . 'wp-content/plugins/' . $plugin))
189                 include_once(ABSPATH . 'wp-content/plugins/' . $plugin);
190             else if ('' != $plugin && file_exists(ABSPATH . 'wp-content/systemplugins/' . $plugin))
191                 include_once(ABSPATH . 'wp-content/systemplugins/' . $plugin);
192         }
193     }
194 }
195
196 require (ABSPATH . WPINC . '/pluggable-functions.php');
197
198 if ( defined('WP_CACHE') && function_exists('wp_cache_postload') )
199     wp_cache_postload();
200
201 do_action('plugins_loaded');
202
203 // If already slashed, strip.
204 if ( get_magic_quotes_gpc() ) {
205     $_GET    = stripslashes_deep($_GET   );
206     $_POST   = stripslashes_deep($_POST  );
207     $_COOKIE = stripslashes_deep($_COOKIE);
208     $_SERVER = stripslashes_deep($_SERVER);
209 }
210
211 // Escape with wpdb.
212 $_GET    = add_magic_quotes($_GET   );
213 $_POST   = add_magic_quotes($_POST  );
214 $_COOKIE = add_magic_quotes($_COOKIE);
215 $_SERVER = add_magic_quotes($_SERVER);
216
217 $wp_query   = new WP_Query();
218 $wp_rewrite = new WP_Rewrite();
219 $wp         = new WP();
220
221 define('TEMPLATEPATH', get_template_directory());
222
223 // Load the default text localization domain.
224 load_default_textdomain();
225
226 // Pull in locale data after loading text domain.
227 require_once(ABSPATH . WPINC . '/locale.php');
228
229 // Load functions for active theme.
230 if ( file_exists(TEMPLATEPATH . "/functions.php") )
231     include(TEMPLATEPATH . "/functions.php");
232
233 function shutdown_action_hook() {
234     do_action('shutdown');
235     wp_cache_close();
236 }
237 register_shutdown_function('shutdown_action_hook');
238
239 session_start();
240
241 // Everything is loaded and initialized.
242 do_action('init');
243
244 ?>
Note: See TracBrowser for help on using the browser.
Log in with username/password: lyceum/lyceum