[ Index ]

PHP Cross Reference of GlotPress

title

Body

[close]

/ -> gp-settings.php (source)

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


Generated: Thu May 23 03:59:56 2013 Hosted by follow the white rabbit.