[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/ -> common.php (source)

   1  <?php
   2  /**
   3  *
   4  * @package phpBB3
   5  * @version $Id$
   6  * @copyright (c) 2005 phpBB Group
   7  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
   8  *
   9  * Minimum Requirement: PHP 4.3.3
  10  */
  11  
  12  /**
  13  */
  14  if (!defined('IN_PHPBB'))
  15  {
  16      exit;
  17  }
  18  
  19  require($phpbb_root_path . 'includes/startup.' . $phpEx);
  20  
  21  if (file_exists($phpbb_root_path . 'config.' . $phpEx))
  22  {
  23      require($phpbb_root_path . 'config.' . $phpEx);
  24  }
  25  
  26  if (!defined('PHPBB_INSTALLED'))
  27  {
  28      // Redirect the user to the installer
  29      require($phpbb_root_path . 'includes/functions.' . $phpEx);
  30  
  31      // We have to generate a full HTTP/1.1 header here since we can't guarantee to have any of the information
  32      // available as used by the redirect function
  33      $server_name = (!empty($_SERVER['HTTP_HOST'])) ? strtolower($_SERVER['HTTP_HOST']) : ((!empty($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : getenv('SERVER_NAME'));
  34      $server_port = (!empty($_SERVER['SERVER_PORT'])) ? (int) $_SERVER['SERVER_PORT'] : (int) getenv('SERVER_PORT');
  35      $secure = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 1 : 0;
  36  
  37      $script_name = (!empty($_SERVER['PHP_SELF'])) ? $_SERVER['PHP_SELF'] : getenv('PHP_SELF');
  38      if (!$script_name)
  39      {
  40          $script_name = (!empty($_SERVER['REQUEST_URI'])) ? $_SERVER['REQUEST_URI'] : getenv('REQUEST_URI');
  41      }
  42  
  43      // $phpbb_root_path accounts for redirects from e.g. /adm
  44      $script_path = trim(dirname($script_name)) . '/' . $phpbb_root_path . 'install/index.' . $phpEx;
  45      // Replace any number of consecutive backslashes and/or slashes with a single slash
  46      // (could happen on some proxy setups and/or Windows servers)
  47      $script_path = preg_replace('#[\\\\/]{2,}#', '/', $script_path);
  48      // Eliminate . and .. from the path
  49      $script_path = phpbb_clean_path($script_path);
  50  
  51      $url = (($secure) ? 'https://' : 'http://') . $server_name;
  52  
  53      if ($server_port && (($secure && $server_port <> 443) || (!$secure && $server_port <> 80)))
  54      {
  55          // HTTP HOST can carry a port number...
  56          if (strpos($server_name, ':') === false)
  57          {
  58              $url .= ':' . $server_port;
  59          }
  60      }
  61  
  62      $url .= $script_path;
  63      header('Location: ' . $url);
  64      exit;
  65  }
  66  
  67  if (defined('DEBUG_EXTRA'))
  68  {
  69      $base_memory_usage = 0;
  70      if (function_exists('memory_get_usage'))
  71      {
  72          $base_memory_usage = memory_get_usage();
  73      }
  74  }
  75  
  76  // Load Extensions
  77  // dl() is deprecated and disabled by default as of PHP 5.3.
  78  if (!empty($load_extensions) && function_exists('dl'))
  79  {
  80      $load_extensions = explode(',', $load_extensions);
  81  
  82      foreach ($load_extensions as $extension)
  83      {
  84          @dl(trim($extension));
  85      }
  86  }
  87  
  88  // Include files
  89  require($phpbb_root_path . 'includes/acm/acm_' . $acm_type . '.' . $phpEx);
  90  require($phpbb_root_path . 'includes/cache.' . $phpEx);
  91  require($phpbb_root_path . 'includes/template.' . $phpEx);
  92  require($phpbb_root_path . 'includes/session.' . $phpEx);
  93  require($phpbb_root_path . 'includes/auth.' . $phpEx);
  94  
  95  require($phpbb_root_path . 'includes/functions.' . $phpEx);
  96  require($phpbb_root_path . 'includes/functions_content.' . $phpEx);
  97  
  98  require($phpbb_root_path . 'includes/constants.' . $phpEx);
  99  require($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx);
 100  require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx);
 101  
 102  // Set PHP error handler to ours
 103  set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handler');
 104  
 105  // Instantiate some basic classes
 106  $user        = new user();
 107  $auth        = new auth();
 108  $template    = new template();
 109  $cache        = new cache();
 110  $db            = new $sql_db();
 111  
 112  // Connect to DB
 113  $db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, defined('PHPBB_DB_NEW_LINK') ? PHPBB_DB_NEW_LINK : false);
 114  
 115  // We do not need this any longer, unset for safety purposes
 116  unset($dbpasswd);
 117  
 118  // Grab global variables, re-cache if necessary
 119  $config = $cache->obtain_config();
 120  
 121  // Add own hook handler
 122  require($phpbb_root_path . 'includes/hooks/index.' . $phpEx);
 123  $phpbb_hook = new phpbb_hook(array('exit_handler', 'phpbb_user_session_handler', 'append_sid', array('template', 'display')));
 124  
 125  foreach ($cache->obtain_hooks() as $hook)
 126  {
 127      @include($phpbb_root_path . 'includes/hooks/' . $hook . '.' . $phpEx);
 128  }
 129  
 130  ?>


Generated: Wed Oct 2 15:03:47 2013 Cross-referenced by PHPXref 0.7.1