[ Index ]

PHP Cross Reference of phpBB-3.3.11-deutsch

title

Body

[close]

/ -> common.php (source)

   1  <?php
   2  /**
   3  *
   4  * This file is part of the phpBB Forum Software package.
   5  *
   6  * @copyright (c) phpBB Limited <https://www.phpbb.com>
   7  * @license GNU General Public License, version 2 (GPL-2.0)
   8  *
   9  * For full copyright and license information, please see
  10  * the docs/CREDITS.txt file.
  11  *
  12  */
  13  
  14  /**
  15  * Minimum Requirement: PHP 7.2.0
  16  */
  17  
  18  if (!defined('IN_PHPBB'))
  19  {
  20      exit;
  21  }
  22  
  23  require($phpbb_root_path . 'includes/startup.' . $phpEx);
  24  require($phpbb_root_path . 'phpbb/class_loader.' . $phpEx);
  25  
  26  $phpbb_class_loader = new \phpbb\class_loader('phpbb\\', "{$phpbb_root_path}phpbb/", $phpEx);
  27  $phpbb_class_loader->register();
  28  
  29  $phpbb_config_php_file = new \phpbb\config_php_file($phpbb_root_path, $phpEx);
  30  extract($phpbb_config_php_file->get_all());
  31  
  32  if (!defined('PHPBB_ENVIRONMENT'))
  33  {
  34      @define('PHPBB_ENVIRONMENT', 'production');
  35  }
  36  
  37  if (!defined('PHPBB_INSTALLED'))
  38  {
  39      // Redirect the user to the installer
  40      require($phpbb_root_path . 'includes/functions.' . $phpEx);
  41  
  42      // We have to generate a full HTTP/1.1 header here since we can't guarantee to have any of the information
  43      // available as used by the redirect function
  44      $server_name = (!empty($_SERVER['HTTP_HOST'])) ? strtolower($_SERVER['HTTP_HOST']) : ((!empty($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : getenv('SERVER_NAME'));
  45      $server_port = (!empty($_SERVER['SERVER_PORT'])) ? (int) $_SERVER['SERVER_PORT'] : (int) getenv('SERVER_PORT');
  46      $secure = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 1 : 0;
  47  
  48      if (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https')
  49      {
  50          $secure = 1;
  51          $server_port = 443;
  52      }
  53  
  54      $script_name = (!empty($_SERVER['REQUEST_URI'])) ? $_SERVER['REQUEST_URI'] : getenv('REQUEST_URI');
  55      if (!$script_name)
  56      {
  57          $script_name = (!empty($_SERVER['PHP_SELF'])) ? $_SERVER['PHP_SELF'] : getenv('PHP_SELF');
  58      }
  59  
  60      // $phpbb_root_path accounts for redirects from e.g. /adm
  61      $script_path = trim(dirname($script_name)) . '/' . $phpbb_root_path . 'install/app.' . $phpEx;
  62      // Replace any number of consecutive backslashes and/or slashes with a single slash
  63      // (could happen on some proxy setups and/or Windows servers)
  64      $script_path = preg_replace('#[\\\\/]{2,}#', '/', $script_path);
  65  
  66      // Eliminate . and .. from the path
  67      require($phpbb_root_path . 'phpbb/filesystem.' . $phpEx);
  68      $phpbb_filesystem = new phpbb\filesystem\filesystem();
  69      $script_path = $phpbb_filesystem->clean_path($script_path);
  70  
  71      $url = (($secure) ? 'https://' : 'http://') . $server_name;
  72  
  73      if ($server_port && (($secure && $server_port <> 443) || (!$secure && $server_port <> 80)))
  74      {
  75          // HTTP HOST can carry a port number...
  76          if (strpos($server_name, ':') === false)
  77          {
  78              $url .= ':' . $server_port;
  79          }
  80      }
  81  
  82      $url .= $script_path;
  83      header('Location: ' . $url);
  84      exit;
  85  }
  86  
  87  // In case $phpbb_adm_relative_path is not set (in case of an update), use the default.
  88  $phpbb_adm_relative_path = (isset($phpbb_adm_relative_path)) ? $phpbb_adm_relative_path : 'adm/';
  89  $phpbb_admin_path = (defined('PHPBB_ADMIN_PATH')) ? PHPBB_ADMIN_PATH : $phpbb_root_path . $phpbb_adm_relative_path;
  90  
  91  // Include files
  92  require($phpbb_root_path . 'includes/functions.' . $phpEx);
  93  require($phpbb_root_path . 'includes/functions_content.' . $phpEx);
  94  include($phpbb_root_path . 'includes/functions_compatibility.' . $phpEx);
  95  
  96  require($phpbb_root_path . 'includes/constants.' . $phpEx);
  97  require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx);
  98  
  99  // Registered before building the container so the development environment stay capable of intercepting
 100  // the container builder exceptions.
 101  if (PHPBB_ENVIRONMENT === 'development')
 102  {
 103      \phpbb\debug\debug::enable();
 104  }
 105  else
 106  {
 107      set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handler');
 108  }
 109  
 110  $phpbb_class_loader_ext = new \phpbb\class_loader('\\', "{$phpbb_root_path}ext/", $phpEx);
 111  $phpbb_class_loader_ext->register();
 112  
 113  // Set up container
 114  try
 115  {
 116      $phpbb_container_builder = new \phpbb\di\container_builder($phpbb_root_path, $phpEx);
 117  
 118      // Check that cache directory is writable before trying to build container
 119      $cache_dir = $phpbb_container_builder->get_cache_dir();
 120      if (file_exists($cache_dir) && !is_writable($phpbb_container_builder->get_cache_dir()))
 121      {
 122          die('Unable to write to the cache directory path "' . $cache_dir . '". Ensure that the web server user can write to the cache folder.');
 123      }
 124  
 125      $phpbb_container = $phpbb_container_builder->with_config($phpbb_config_php_file)->get_container();
 126  }
 127  catch (InvalidArgumentException $e)
 128  {
 129      if (PHPBB_ENVIRONMENT !== 'development')
 130      {
 131          trigger_error(
 132              'The requested environment ' . PHPBB_ENVIRONMENT . ' is not available.',
 133              E_USER_ERROR
 134          );
 135      }
 136      else
 137      {
 138          throw $e;
 139      }
 140  }
 141  
 142  if ($phpbb_container->getParameter('debug.error_handler'))
 143  {
 144      \phpbb\debug\debug::enable();
 145  }
 146  
 147  $phpbb_class_loader->set_cache($phpbb_container->get('cache.driver'));
 148  $phpbb_class_loader_ext->set_cache($phpbb_container->get('cache.driver'));
 149  
 150  $phpbb_container->get('dbal.conn')->set_debug_sql_explain($phpbb_container->getParameter('debug.sql_explain'));
 151  $phpbb_container->get('dbal.conn')->set_debug_load_time($phpbb_container->getParameter('debug.load_time'));
 152  require($phpbb_root_path . 'includes/compatibility_globals.' . $phpEx);
 153  
 154  register_compatibility_globals();
 155  
 156  // Add own hook handler
 157  require($phpbb_root_path . 'includes/hooks/index.' . $phpEx);
 158  $phpbb_hook = new phpbb_hook(array('exit_handler', 'phpbb_user_session_handler', 'append_sid', array('template', 'display')));
 159  
 160  /* @var $phpbb_hook_finder \phpbb\hook\finder */
 161  $phpbb_hook_finder = $phpbb_container->get('hook_finder');
 162  
 163  foreach ($phpbb_hook_finder->find() as $hook)
 164  {
 165      @include($phpbb_root_path . 'includes/hooks/' . $hook . '.' . $phpEx);
 166  }
 167  
 168  /**
 169  * Main event which is triggered on every page
 170  *
 171  * You can use this event to load function files and initiate objects
 172  *
 173  * NOTE:    At this point the global session ($user) and permissions ($auth)
 174  *        do NOT exist yet. If you need to use the user object
 175  *        (f.e. to include language files) or need to check permissions,
 176  *        please use the core.user_setup event instead!
 177  *
 178  * @event core.common
 179  * @since 3.1.0-a1
 180  */
 181  $phpbb_dispatcher->dispatch('core.common');


Generated: Sat Nov 4 14:26:03 2023 Cross-referenced by PHPXref 0.7.1