[ Index ]

PHP Cross Reference of BuddyPress

title

Body

[close]

/src/bp-forums/bbpress/ -> bb-load.php (source)

   1  <?php
   2  /**
   3   * Initialises the most fundamental parts of bbPress
   4   *
   5   * You should not have to change this file, all configuration
   6   * should be possible in bb-config.php
   7   *
   8   * @package bbPress
   9   */
  10  
  11  
  12  
  13  /**
  14   * Low level reasons to die
  15   */
  16  
  17  // Die if PHP is not new enough
  18  if ( version_compare( PHP_VERSION, '4.3', '<' ) ) {
  19      die( sprintf( 'Your server is running PHP version %s but bbPress requires at least 4.3', PHP_VERSION ) );
  20  }
  21  
  22  
  23  
  24  // Modify error reporting levels to exclude PHP notices
  25  error_reporting(E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING);
  26  
  27  
  28  /**
  29   * bb_timer_start() - PHP 4 standard microtime start capture
  30   *
  31   * @access private
  32   * @global int $bb_timestart Seconds and Microseconds added together from when function is called
  33   * @return bool Always returns true
  34   */
  35  function bb_timer_start()
  36  {
  37      global $bb_timestart;
  38      $mtime = explode( ' ', microtime() );
  39      $bb_timestart = $mtime[1] + $mtime[0];
  40      return true;
  41  }
  42  bb_timer_start();
  43  
  44  
  45  
  46  // Server detection
  47  
  48  /**
  49   * Whether the server software is Apache or something else
  50   * @global bool $is_apache
  51   */
  52  $is_apache = ( strpos( $_SERVER['SERVER_SOFTWARE'], 'Apache' ) !== false || strpos( $_SERVER['SERVER_SOFTWARE'], 'LiteSpeed' ) !== false);
  53  
  54  /**
  55   * Whether the server software is IIS or something else
  56   * @global bool $is_IIS
  57   */
  58  $is_IIS = ( strpos( $_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS' ) !== false || strpos( $_SERVER['SERVER_SOFTWARE'], 'ExpressionDevServer' ) !== false );
  59  
  60  /**
  61   * Whether the server software is IIS 7.X
  62   * @global bool $is_iis7
  63   */
  64  $is_iis7 = ( strpos( $_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS/7.' ) !== false );
  65  
  66  
  67  
  68  /**
  69   * Stabilise $_SERVER variables in various PHP environments
  70   */
  71  
  72  // Fix for IIS, which doesn't set REQUEST_URI
  73  if ( empty( $_SERVER['REQUEST_URI'] ) ) {
  74  
  75      // IIS Mod-Rewrite
  76      if (isset($_SERVER['HTTP_X_ORIGINAL_URL'])) {
  77          $_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_ORIGINAL_URL'];
  78      }
  79      // IIS Isapi_Rewrite
  80      else if (isset($_SERVER['HTTP_X_REWRITE_URL'])) {
  81          $_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_REWRITE_URL'];
  82      }
  83      else
  84      {
  85          // Use ORIG_PATH_INFO if there is no PATH_INFO
  86          if ( !isset($_SERVER['PATH_INFO']) && isset($_SERVER['ORIG_PATH_INFO']) )
  87              $_SERVER['PATH_INFO'] = $_SERVER['ORIG_PATH_INFO'];
  88  
  89          // Some IIS + PHP configurations puts the script-name in the path-info (No need to append it twice)
  90          if ( isset($_SERVER['PATH_INFO']) ) {
  91              if ( $_SERVER['PATH_INFO'] == $_SERVER['SCRIPT_NAME'] )
  92                  $_SERVER['REQUEST_URI'] = $_SERVER['PATH_INFO'];
  93              else
  94                  $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'] . $_SERVER['PATH_INFO'];
  95          }
  96  
  97          // Append the query string if it exists and isn't null
  98          if (isset($_SERVER['QUERY_STRING']) && !empty($_SERVER['QUERY_STRING'])) {
  99              $_SERVER['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
 100          }
 101      }
 102  }
 103  
 104  // Fix for PHP as CGI hosts that set SCRIPT_FILENAME to something ending in php.cgi for all requests
 105  if ( isset($_SERVER['SCRIPT_FILENAME']) && ( strpos($_SERVER['SCRIPT_FILENAME'], 'php.cgi') == strlen($_SERVER['SCRIPT_FILENAME']) - 7 ) )
 106      $_SERVER['SCRIPT_FILENAME'] = $_SERVER['PATH_TRANSLATED'];
 107  
 108  // Fix for Dreamhost and other PHP as CGI hosts
 109  if (strpos($_SERVER['SCRIPT_NAME'], 'php.cgi') !== false)
 110      unset($_SERVER['PATH_INFO']);
 111  
 112  // Fix empty PHP_SELF
 113  $PHP_SELF = $_SERVER['PHP_SELF'];
 114  if ( empty($PHP_SELF) )
 115      $_SERVER['PHP_SELF'] = $PHP_SELF = preg_replace("/(\?.*)?$/",'',$_SERVER["REQUEST_URI"]);
 116  
 117  
 118  
 119  /**
 120   * bbPress logging level constants - same as constants from BP_Log class
 121   */
 122  define( 'BB_LOG_NONE',    0 );
 123  define( 'BB_LOG_FAIL',    1 );
 124  define( 'BB_LOG_ERROR',   2 );
 125  define( 'BB_LOG_WARNING', 4 );
 126  define( 'BB_LOG_NOTICE',  8 );
 127  define( 'BB_LOG_DEBUG',   16 );
 128  
 129  /**
 130   * Combination of all errors (excluding none and debug)
 131   */
 132  define( 'BB_LOG_ALL', BB_LOG_FAIL + BB_LOG_ERROR + BB_LOG_WARNING + BB_LOG_NOTICE );
 133  
 134  /**
 135   * Define temporary $_bb_path as this files directory, then check for the special BB_PATH config file
 136   * which allows override of BB_PATH, but only outside of core files
 137   */
 138  $_bb_path = dirname( __FILE__ ) . '/';
 139  $_bb_config_path = dirname( $_bb_path ) . '/bb-config-path.php';
 140  if ( file_exists( $_bb_config_path ) ) {
 141      include_once( $_bb_config_path );
 142  }
 143  if ( !defined( 'BB_PATH' ) ) {
 144      define( 'BB_PATH', $_bb_path );
 145  }
 146  unset( $_bb_path, $_bb_config_path );
 147  
 148  /**
 149   * The bbPress includes path relative to BB_PATH
 150   */
 151  define( 'BB_INC', 'bb-includes/' );
 152  
 153  // Initialise $bb object
 154  $bb = new StdClass();
 155  
 156  if ( file_exists( BB_PATH . 'bb-config.php') ) {
 157  
 158      // The config file resides in BB_PATH
 159      require_once( BB_PATH . 'bb-config.php');
 160  
 161      // Load bb-settings.php
 162      require_once ( BB_PATH . 'bb-settings.php' );
 163  
 164  } elseif ( file_exists( dirname( BB_PATH ) . '/bb-config.php') ) {
 165  
 166      // The config file resides one level below BB_PATH
 167      require_once( dirname( BB_PATH ) . '/bb-config.php' );
 168  
 169      // Load bb-settings.php
 170      require_once ( BB_PATH . 'bb-settings.php' );
 171  
 172  } elseif ( !defined( 'BB_INSTALLING' ) || !BB_INSTALLING ) {
 173  
 174      // The config file doesn't exist and we aren't on the installation page
 175  
 176      // Cut to the chase, go to the installer and use it to deal with errors
 177      $install_uri = preg_replace( '|(/bb-admin)?/[^/]+?$|', '/', $_SERVER['PHP_SELF'] ) . 'bb-admin/install.php';
 178      header( 'Location: ' . $install_uri );
 179      die();
 180  
 181  }
 182  
 183  if ( isset( $_GET['doit'] ) && 'bb-subscribe' == $_GET['doit'] )
 184      require ( BB_PATH . 'bb-includes/action.subscribe.php' );


Generated: Thu Dec 7 01:01:35 2017 Cross-referenced by PHPXref 0.7.1