| [ Index ] |
PHP Cross Reference of GlotPress |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * Loads needed libraries and does the preliminary work. You should not have to 4 * edit this file. Everything should be configurable from the outside. Starts the 5 * routing logic in the end. 6 */ 7 8 if ( defined( 'GP_DEBUG' ) && GP_DEBUG ) { 9 error_reporting( E_ALL ); 10 } else { 11 if ( defined( 'E_RECOVERABLE_ERROR' ) ) 12 error_reporting( E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING | E_RECOVERABLE_ERROR ); 13 else 14 error_reporting( E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING ); 15 } 16 17 require_once( GP_PATH . GP_INC . '/system.php' ); 18 19 gp_unregister_GLOBALS(); 20 21 if ( !defined( 'BACKPRESS_PATH' ) ) { 22 define( 'BACKPRESS_PATH', GP_PATH . GP_INC . 'backpress/' ); 23 } 24 25 if ( !defined( 'GP_POMO_PATH' ) ) { 26 define( 'GP_POMO_PATH', GP_PATH . 'pomo/' ); 27 } 28 29 if ( !defined( 'GP_LOCALES_PATH' ) ) { 30 define( 'GP_LOCALES_PATH', GP_PATH . 'locales/' ); 31 } 32 33 34 if ( !defined( 'GP_LANG_PATH' ) ) { 35 define( 'GP_LANG_PATH', GP_PATH . 'languages/' ); 36 } 37 38 if ( !defined( 'GP_PLUGINS_PATH' ) ) { 39 define( 'GP_PLUGINS_PATH', GP_PATH . 'plugins/' ); 40 } 41 42 if ( !defined( 'DATE_MYSQL' ) ) { 43 define( 'DATE_MYSQL', 'Y-m-d H:i:s' ); 44 } 45 46 if ( !defined( 'GP_TESTS_PATH' ) ) { 47 define( 'GP_TESTS_PATH', GP_PATH . 't/' ); 48 } 49 50 51 require_once( GP_PATH . GP_INC . 'gp.php'); 52 53 /* 54 * In most cases the default internal encoding is latin1, which is of no use, 55 * since we want to use the mb_ functions for UTF-8 strings 56 */ 57 if (function_exists('mb_internal_encoding')) { 58 mb_internal_encoding('UTF-8'); 59 } 60 61 require_once( BACKPRESS_PATH . 'class.bp-log.php' ); 62 $gp_log = new BP_Log(); 63 if ( defined( 'GP_LOG_LEVEL' ) ) { 64 $gp_log->set_level( GP_LOG_LEVEL ); 65 } 66 if ( defined( 'GP_LOG_TYPE' ) ) { 67 $gp_log->set_type( GP_LOG_TYPE ); 68 } 69 if ( defined( 'GP_LOG_FILENAME' ) ) { 70 $gp_log->set_filename( GP_LOG_FILENAME ); 71 } 72 $gp_log->notice('Logging started'); 73 74 // Load core BackPress functions 75 require_once( BACKPRESS_PATH . 'functions.core.php' ); 76 require_once( BACKPRESS_PATH . 'functions.compat.php' ); 77 require_once( BACKPRESS_PATH . 'functions.formatting.php' ); 78 79 // alleviate the magic_quotes_gpc effects 80 if ( get_magic_quotes_gpc() ) { 81 $_GET = stripslashes_deep( $_GET ); 82 $_POST = stripslashes_deep( $_POST ); 83 $_COOKIE = stripslashes_deep( $_COOKIE ); 84 } 85 86 $_GET = gp_urldecode_deep( $_GET ); 87 88 require_once( BACKPRESS_PATH . 'class.wp-error.php' ); 89 90 if ( !defined( 'GP_DATABASE_CLASS_INCLUDE' ) ) { 91 define( 'GP_DATABASE_CLASS_INCLUDE', BACKPRESS_PATH . 'class.bpdb-multi.php' ); 92 } 93 94 if ( GP_DATABASE_CLASS_INCLUDE ) { 95 require_once( GP_DATABASE_CLASS_INCLUDE ); 96 } 97 98 if ( !defined( 'GP_DATABASE_CLASS' ) ) { 99 define( 'GP_DATABASE_CLASS', 'BPDB_Multi' ); 100 } 101 102 if ( in_array( GP_DATABASE_CLASS, array( 'BPDB', 'BPDB_Multi' ) ) ) { 103 /** 104 * Define BackPress Database errors if not already done - no localisation at this stage 105 */ 106 if ( !defined( 'BPDB__CONNECT_ERROR_MESSAGE' ) ) { 107 define( 'BPDB__CONNECT_ERROR_MESSAGE', 'ERROR: Could not establish a database connection' ); 108 } 109 if ( !defined( 'BPDB__CONNECT_ERROR_MESSAGE' ) ) { 110 define( 'BPDB__SELECT_ERROR_MESSAGE', 'ERROR: Can\'t select database.' ); 111 } 112 if ( !defined( 'BPDB__ERROR_STRING' ) ) { 113 define( 'BPDB__ERROR_STRING', 'ERROR: GlotPress database error - "%s" for query "%s" via caller "%s"' ); 114 } 115 if ( !defined( 'BPDB__ERROR_HTML' ) ) { 116 define( 'BPDB__ERROR_HTML', '<div id="error"><p class="bpdberror"><strong>Database error:</strong> [%s]<br /><code>%s</code><br />Caller: %s</p></div>' ); 117 } 118 if ( !defined( 'BPDB__DB_VERSION_ERROR' ) ) { 119 define( 'BPDB__DB_VERSION_ERROR', 'ERROR: GlotPress requires MySQL 4.0.0 or higher' ); 120 } 121 if ( !defined( 'BPDB__PHP_EXTENSION_MISSING' ) ) { 122 define( 'BPDB__PHP_EXTENSION_MISSING', 'ERROR: GlotPress requires The MySQL PHP extension' ); 123 } 124 } 125 126 // Die if there is no database table prefix 127 if ( !$gp_table_prefix ) { 128 die( 'You must specify a table prefix in your <code>gp-config.php</code> file.' ); 129 } 130 131 // Setup the global database connection 132 $gpdb_class = GP_DATABASE_CLASS; 133 $gpdb = new $gpdb_class( array( 134 'name' => GPDB_NAME, 135 'user' => GPDB_USER, 136 'password' => GPDB_PASSWORD, 137 'host' => GPDB_HOST, 138 'charset' => defined( 'GPDB_CHARSET' ) ? GPDB_CHARSET : false, 139 'collate' => defined( 'GPDB_COLLATE' ) ? GPDB_COLLATE : false 140 ) ); 141 unset( $gpdb_class ); 142 143 $gpdb->table_names = array('translations', 'translation_sets', 'originals', 'projects', 'users', 'usermeta', 'meta', 'permissions', 'api_keys', ); 144 foreach( $gpdb->table_names as $table ) { 145 $gpdb->tables[$table] = false; 146 } 147 unset( $table ); 148 149 // Set the prefix on the tables 150 if ( is_wp_error( $gpdb->set_prefix( $gp_table_prefix ) ) ) { 151 die( 'Your table prefix may only contain letters, numbers and underscores.' ); 152 } 153 154 if ( defined( 'CUSTOM_USER_TABLE' ) ) 155 $gpdb->users = CUSTOM_USER_TABLE; 156 157 if ( defined( 'CUSTOM_USER_META_TABLE' ) ) 158 $gpdb->usermeta = CUSTOM_USER_META_TABLE; 159 160 if ( defined( 'CUSTOM_PERMISSIONS_TABLE' ) ) 161 $gpdb->permissions = CUSTOM_PERMISSIONS_TABLE; 162 163 if ( !function_exists( 'add_filter' ) ) { 164 require_once( BACKPRESS_PATH . 'functions.plugin-api.php' ); 165 } 166 167 if ( !defined( 'GP_TMPL_PATH' ) ) 168 define( 'GP_TMPL_PATH', GP_PATH . 'gp-templates/' ); 169 170 require_once( GP_PATH . GP_INC . 'lambda.php'); 171 172 require_once( GP_PATH . GP_INC . 'meta.php' ); 173 require_once( GP_PATH . GP_INC . 'misc.php' ); 174 require_once( GP_PATH . GP_INC . 'url.php' ); 175 require_once( GP_PATH . GP_INC . 'strings.php' ); 176 177 require_once( GP_PATH . GP_INC . 'template.php' ); 178 require_once( GP_PATH . GP_INC . 'template-links.php' ); 179 180 require_once( GP_PATH . GP_INC . 'cli.php' ); 181 182 /** 183 * Define the full path to the object cache functions include 184 */ 185 if ( !defined( 'GP_OBJECT_CACHE_FUNCTIONS_INCLUDE' ) ) { 186 define( 'GP_OBJECT_CACHE_FUNCTIONS_INCLUDE', BACKPRESS_PATH . 'loader.wp-object-cache.php' ); 187 } 188 189 // Load the database class 190 if ( GP_OBJECT_CACHE_FUNCTIONS_INCLUDE && !function_exists( 'wp_cache_init' ) ) { 191 require_once( GP_OBJECT_CACHE_FUNCTIONS_INCLUDE ); 192 } 193 194 // Instantiate the $wp_object_cache object using wp_cache_init() 195 if ( !isset( $wp_object_cache ) && function_exists( 'wp_cache_init' ) ) { 196 wp_cache_init(); 197 if ( function_exists( 'wp_cache_add_global_groups' ) ) { 198 wp_cache_add_global_groups( array( 'users', 'userlogins', 'usermeta', 'usermail', 'usernicename' ) ); 199 } 200 } 201 202 require_once( GP_PATH . GP_INC . 'class.bp-options.php' ); 203 require_once( BACKPRESS_PATH . 'functions.bp-options.php' ); 204 205 require_once( BACKPRESS_PATH . 'class.wp-http.php' ); 206 207 require_once( BACKPRESS_PATH . 'class.wp-dependencies.php' ); 208 require_once( BACKPRESS_PATH . 'class.wp-styles.php' ); 209 require_once( BACKPRESS_PATH . 'functions.wp-styles.php' ); 210 require_once( BACKPRESS_PATH . 'class.wp-scripts.php' ); 211 require_once( BACKPRESS_PATH . 'functions.wp-scripts.php' ); 212 require_once( GP_PATH . GP_INC . 'assets-loader.php' ); 213 214 require_once( GP_PATH . GP_INC . 'default-filters.php' ); 215 require_once( BACKPRESS_PATH . 'functions.kses.php' ); 216 217 require_once( GP_POMO_PATH . 'mo.php' ); 218 require_once( GP_POMO_PATH . 'po.php' ); 219 require_once( GP_PATH . GP_INC . 'l10n.php' ); 220 221 require_once( GP_LOCALES_PATH . 'locales.php' ); 222 223 // Users and authentication 224 if ( !class_exists( 'WP_Users' ) ) { 225 require_once( BACKPRESS_PATH . 'class.wp-users.php' ); 226 $wp_users_object = new WP_Users( $gpdb ); 227 } 228 229 230 if ( !defined( 'WP_AUTH_COOKIE_VERSION' ) ) { 231 define( 'WP_AUTH_COOKIE_VERSION', 2 ); 232 } 233 234 // WP_Pass 235 if ( !class_exists( 'WP_Pass' ) ) { 236 require_once( BACKPRESS_PATH . 'class.wp-pass.php' ); 237 } 238 239 // We assume all variables set in this file will be global. 240 // If the file is inovked inside a function, we will lose them all. 241 // So, make all local variables, global 242 gp_set_globals( get_defined_vars() ); 243 244 /** 245 * It is possible to define this in wp-config.php and it will be used as the domain for all cookies. 246 * Set it carefully for sharing cookies amonst subdomains 247 * 248 * @link http://curl.haxx.se/rfc/cookie_spec.html 249 */ 250 if ( !defined('GP_COOKIE_DOMAIN') ) 251 define('GP_COOKIE_DOMAIN', false); 252 253 if ( !class_exists( 'WP_Auth' ) ) { 254 require_once( BACKPRESS_PATH . 'class.wp-auth.php' ); 255 $cookies = array(); 256 $cookies['auth'][] = array( 257 'domain' => GP_COOKIE_DOMAIN, 258 'path' => gp_url_path(), 259 'name' => gp_const_get( 'GP_AUTH_COOKIE', 'glotpress_auth' ), 260 ); 261 $cookies['secure_auth'][] = array( 262 'domain' => GP_COOKIE_DOMAIN, 263 'path' => gp_url_path(), 264 'name' => gp_const_get( 'GP_SECURE_AUTH_COOKIE', 'glotpress_sec_auth' ), 265 'secure' => 'true', 266 ); 267 268 $cookies['logged_in'][] = array( 269 'domain' => GP_COOKIE_DOMAIN, 270 'path' => gp_url_path(), 271 'name' => gp_const_get( 'GP_LOGGED_IN_COOKIE', 'glotpress_logged_in' ), 272 ); 273 $wp_auth_object = new WP_Auth( $gpdb, $wp_users_object, $cookies ); 274 unset( $cookies ); 275 } 276 277 require_once( GP_PATH . GP_INC . 'warnings.php' ); 278 require_once( GP_PATH . GP_INC . 'validation.php' ); 279 require_once( GP_PATH . GP_INC . 'google.php' ); 280 require_once( GP_PATH . GP_INC . 'advanced-permissions.php' ); 281 282 require_once GP_PATH . GP_INC . 'thing.php'; 283 foreach( glob( GP_PATH . GP_INC . 'things/*.php' ) as $thing_file ) { 284 require_once $thing_file; 285 } 286 287 require_once( GP_PATH . GP_INC . 'route.php' ); 288 require_once( GP_PATH . GP_INC . 'router.php' ); 289 foreach( glob( GP_PATH . GP_INC . 'routes/*.php' ) as $route_file ) { 290 require_once $route_file; 291 } 292 293 GP::$translation_warnings = new GP_Translation_Warnings(); 294 GP::$builtin_translation_warnings = new GP_Builtin_Translation_Warnings(); 295 GP::$builtin_translation_warnings->add_all( GP::$translation_warnings ); 296 GP::$router = new GP_Router(); 297 GP::$formats = array(); 298 299 foreach( glob( GP_PATH . GP_INC . 'formats/format_*.php' ) as $format_file ) { 300 require_once $format_file; 301 } 302 unset( $format_file ); 303 304 // Let's do it again, there are more variables added since last time we called it 305 gp_set_globals( get_defined_vars() ); 306 307 require_once( GP_PATH . GP_INC . 'plugin.php' ); 308 309 $plugins = glob( GP_PLUGINS_PATH . '*.php' ); 310 if ( $plugins ) { 311 foreach( $plugins as $plugin ) { 312 require_once $plugin; 313 } 314 } 315 316 $plugin_dirs = glob( GP_PLUGINS_PATH . '*', GLOB_ONLYDIR ); 317 if ( $plugin_dirs ) { 318 foreach( $plugin_dirs as $plugin_dir ) { 319 $plugin = "$plugin_dir/" . basename( $plugin_dir ) . '.php'; 320 if ( is_readable( $plugin ) ) require_once $plugin; 321 } 322 } 323 unset( $plugins, $plugin, $plugin_dirs, $plugin_dir ); 324 325 do_action( 'plugins_loaded' ); 326 327 if ( defined( 'GP_INSTALLING' ) && GP_INSTALLING ) 328 return; 329 else 330 define( 'GP_INSTALLING', false ); 331 332 if ( !defined( 'GP_ROUTING') ) { 333 define( 'GP_ROUTING', false ); 334 } 335 336 if ( ( !defined( 'GP_INSTALLING' ) || !GP_INSTALLING ) && !gp_is_installed() ) { 337 if ( GP_ROUTING ) { 338 $install_uri = preg_replace( '|/[^/]+?$|', '/', $_SERVER['PHP_SELF'] ) . 'install.php'; 339 header( 'Location: ' . $install_uri ); 340 } 341 return; 342 } 343 344 gp_populate_notices(); 345 346 function gp_shutdown_action_hook() { 347 do_action( 'shutdown' ); 348 } 349 register_shutdown_function( 'gp_shutdown_action_hook' ); 350 351 do_action( 'init' ); 352 353 if ( GP_ROUTING ) { 354 GP::$router->route(); 355 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Tue Feb 7 03:59:02 2012 | Hosted by follow the white rabbit. |