[ Index ]

PHP Cross Reference of phpBB-3.3.11-deutsch

title

Body

[close]

/install/ -> startup.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  /** @ignore */
  15  if (!defined('IN_PHPBB') || !defined('IN_INSTALL'))
  16  {
  17      exit;
  18  }
  19  
  20  function phpbb_require_updated($path, $phpbb_root_path, $optional = false)
  21  {
  22      $new_path = $phpbb_root_path . 'install/update/new/' . $path;
  23      $old_path = $phpbb_root_path . $path;
  24  
  25      if (file_exists($new_path))
  26      {
  27          require($new_path);
  28      }
  29      else if (!$optional || file_exists($old_path))
  30      {
  31          require($old_path);
  32      }
  33  }
  34  
  35  function phpbb_include_updated($path, $phpbb_root_path, $optional = false)
  36  {
  37      $new_path = $phpbb_root_path . 'install/update/new/' . $path;
  38      $old_path = $phpbb_root_path . $path;
  39  
  40      if (file_exists($new_path))
  41      {
  42          include($new_path);
  43      }
  44      else if (!$optional || file_exists($old_path))
  45      {
  46          include($old_path);
  47      }
  48  }
  49  
  50  function installer_msg_handler($errno, $msg_text, $errfile, $errline)
  51  {
  52      global $phpbb_installer_container, $msg_long_text;
  53  
  54      if (error_reporting() == 0)
  55      {
  56          return true;
  57      }
  58  
  59      // If the message handler is stripping text, fallback to the long version if available
  60      if (!$msg_text && !empty($msg_long_text))
  61      {
  62          $msg_text = $msg_long_text;
  63      }
  64  
  65      switch ($errno)
  66      {
  67          case E_NOTICE:
  68          case E_WARNING:
  69          case E_USER_WARNING:
  70          case E_USER_NOTICE:
  71              $msg = '[phpBB Debug] "' . $msg_text . '" in file ' . $errfile . ' on line ' . $errline;
  72  
  73              if (!empty($phpbb_installer_container))
  74              {
  75                  try
  76                  {
  77                      /** @var \phpbb\install\helper\iohandler\iohandler_interface $iohandler */
  78                      $iohandler = $phpbb_installer_container->get('installer.helper.iohandler');
  79                      $iohandler->add_warning_message($msg);
  80                  }
  81                  catch (\phpbb\install\helper\iohandler\exception\iohandler_not_implemented_exception $e)
  82                  {
  83                      print($msg);
  84                  }
  85              }
  86              else
  87              {
  88                  print($msg);
  89              }
  90  
  91              return;
  92          break;
  93          case E_USER_ERROR:
  94              $msg = '<b>General Error:</b><br>' . $msg_text . '<br> in file ' . $errfile . ' on line ' . $errline . '<br><br>';
  95  
  96              if (!empty($phpbb_installer_container))
  97              {
  98                  try
  99                  {
 100                      /** @var \phpbb\install\helper\iohandler\iohandler_interface $iohandler */
 101                      $iohandler = $phpbb_installer_container->get('installer.helper.iohandler');
 102                      $iohandler->add_error_message($msg);
 103                      $iohandler->send_response(true);
 104                      exit();
 105                  }
 106                  catch (\phpbb\install\helper\iohandler\exception\iohandler_not_implemented_exception $e)
 107                  {
 108                      throw new \phpbb\exception\runtime_exception($msg);
 109                  }
 110              }
 111              throw new \phpbb\exception\runtime_exception($msg);
 112          break;
 113          case E_DEPRECATED:
 114              return true;
 115          break;
 116      }
 117  
 118      return false;
 119  }
 120  
 121  /**
 122   * Register class loaders for installer
 123   *
 124   * @param string $phpbb_root_path phpBB root path
 125   * @param string $phpEx PHP file extension
 126   */
 127  function installer_class_loader($phpbb_root_path, $phpEx)
 128  {
 129      $phpbb_class_loader_new = new \phpbb\class_loader('phpbb\\', "{$phpbb_root_path}install/update/new/phpbb/", $phpEx);
 130      $phpbb_class_loader_new->register();
 131      $phpbb_class_loader = new \phpbb\class_loader('phpbb\\', "{$phpbb_root_path}phpbb/", $phpEx);
 132      $phpbb_class_loader->register();
 133      $phpbb_class_loader = new \phpbb\class_loader('phpbb\\convert\\', "{$phpbb_root_path}install/convert/", $phpEx);
 134      $phpbb_class_loader->register();
 135      $phpbb_class_loader_ext = new \phpbb\class_loader('\\', "{$phpbb_root_path}ext/", $phpEx);
 136      $phpbb_class_loader_ext->register();
 137  }
 138  
 139  /**
 140   * Installer shutdown function. Tries to resolve errors that might have occured
 141   * during execution of installer
 142   *
 143   * @param int $display_errors Original display errors value
 144   */
 145  function installer_shutdown_function($display_errors)
 146  {
 147      $error = error_get_last();
 148  
 149      if ($error)
 150      {
 151          // Restore original display errors value
 152          @ini_set('display_errors', $display_errors);
 153  
 154          // Manually define phpBB root path and phpEx. These will not be passed
 155          // on from app.php
 156          $phpbb_root_path = __DIR__ . '/../';
 157          $phpEx = 'php';
 158  
 159          installer_class_loader($phpbb_root_path, $phpEx);
 160          $supported_error_levels = E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_USER_DEPRECATED;
 161  
 162          $cache = new \phpbb\cache\driver\file(__DIR__ . '/../cache/installer/');
 163          $filesystem = new \phpbb\filesystem\filesystem();
 164          if (strpos($error['file'], $filesystem->realpath($cache->cache_dir)) !== false && is_writable($cache->cache_dir))
 165          {
 166              $file_age = @filemtime($error['file']);
 167  
 168              if ($file_age !== false && ($file_age + 60) < time())
 169              {
 170                  $cache->purge();
 171  
 172                  $symfony_request = new \phpbb\symfony_request(new \phpbb\request\request(new \phpbb\request\type_cast_helper()));
 173  
 174                  header('Location: ' . $symfony_request->getRequestUri());
 175                  exit();
 176              }
 177              else
 178              {
 179                  // Language system is not available
 180                  die('The installer has detected an issue with a cached file. Try reloading the page and/or manually clearing the cache to resolve the issue. If you require further assistance, please visit the <a href="https://www.phpbb.com/community/" target="_blank">phpBB support forums</a>.');
 181              }
 182          }
 183          else if ($error['type'] & $supported_error_levels)
 184          {
 185              // Convert core errors to user warnings for trigger_error()
 186              if ($error['type'] == E_CORE_ERROR || $error['type'] == E_COMPILE_ERROR)
 187              {
 188                  $error['type'] = E_USER_ERROR;
 189              }
 190              else if ($error['type'] == E_CORE_WARNING)
 191              {
 192                  $error['type'] = E_USER_WARNING;
 193              }
 194  
 195              try
 196              {
 197                  installer_msg_handler($error['type'], $error['message'], $error['file'], $error['line']);
 198              }
 199              catch (\phpbb\exception\runtime_exception $exception)
 200              {
 201                  echo '<!DOCTYPE html>';
 202                  echo '<html dir="ltr">';
 203                  echo '<head>';
 204                  echo '<meta charset="utf-8">';
 205                  echo '<meta http-equiv="X-UA-Compatible" content="IE=edge">';
 206                  echo '<title>General Error</title>';
 207                  echo '<style type="text/css">' . "\n" . '/* <![CDATA[ */' . "\n";
 208                  echo '* { margin: 0; padding: 0; } html { font-size: 100%; height: 100%; margin-bottom: 1px; background-color: #E4EDF0; } body { font-family: "Lucida Grande", Verdana, Helvetica, Arial, sans-serif; color: #536482; background: #E4EDF0; font-size: 62.5%; margin: 0; } ';
 209                  echo 'a:link, a:active, a:visited { color: #006699; text-decoration: none; } a:hover { color: #DD6900; text-decoration: underline; } ';
 210                  echo '#wrap { padding: 0 20px 15px 20px; min-width: 615px; } #page-header { text-align: right; height: 40px; } #page-footer { clear: both; font-size: 1em; text-align: center; } ';
 211                  echo '.panel { margin: 4px 0; background-color: #FFFFFF; border: solid 1px  #A9B8C2; } ';
 212                  echo '#errorpage #page-header a { font-weight: bold; line-height: 6em; } #errorpage #content { padding: 10px; } #errorpage #content h1 { line-height: 1.2em; margin-bottom: 0; color: #DF075C; } ';
 213                  echo '#errorpage #content div { margin-top: 20px; margin-bottom: 5px; border-bottom: 1px solid #CCCCCC; padding-bottom: 5px; color: #333333; font: bold 1.2em "Lucida Grande", Arial, Helvetica, sans-serif; text-decoration: none; line-height: 120%; text-align: left; } ';
 214                  echo "\n" . '/* ]]> */' . "\n";
 215                  echo '</style>';
 216                  echo '</head>';
 217                  echo '<body id="errorpage">';
 218                  echo '<div id="wrap">';
 219                  echo '    <div id="acp">';
 220                  echo '    <div class="panel">';
 221                  echo '        <div id="content">';
 222                  echo '            <h1>General Error</h1>';
 223  
 224                  echo '            <div>' . $exception->getMessage() . '</div>';
 225  
 226                  echo '        </div>';
 227                  echo '    </div>';
 228                  echo '    </div>';
 229                  echo '    <div id="page-footer">';
 230                  echo '        Powered by <a href="https://www.phpbb.com/">phpBB</a>&reg; Forum Software &copy; phpBB Limited';
 231                  echo '    </div>';
 232                  echo '</div>';
 233                  echo '</body>';
 234                  echo '</html>';
 235              }
 236          }
 237      }
 238  }
 239  
 240  phpbb_require_updated('includes/startup.' . $phpEx, $phpbb_root_path);
 241  phpbb_require_updated('phpbb/class_loader.' . $phpEx, $phpbb_root_path);
 242  
 243  installer_class_loader($phpbb_root_path, $phpEx);
 244  
 245  // In case $phpbb_adm_relative_path is not set (in case of an update), use the default.
 246  $phpbb_adm_relative_path = (isset($phpbb_adm_relative_path)) ? $phpbb_adm_relative_path : 'adm/';
 247  $phpbb_admin_path = (defined('PHPBB_ADMIN_PATH')) ? PHPBB_ADMIN_PATH : $phpbb_root_path . $phpbb_adm_relative_path;
 248  
 249  // Include files
 250  phpbb_require_updated('includes/compatibility_globals.' . $phpEx, $phpbb_root_path);
 251  phpbb_require_updated('includes/functions.' . $phpEx, $phpbb_root_path);
 252  phpbb_require_updated('includes/functions_content.' . $phpEx, $phpbb_root_path);
 253  phpbb_include_updated('includes/functions_compatibility.' . $phpEx, $phpbb_root_path);
 254  phpbb_require_updated('includes/functions_user.' . $phpEx, $phpbb_root_path);
 255  phpbb_require_updated('includes/utf/utf_tools.' . $phpEx, $phpbb_root_path);
 256  
 257  // Set PHP error handler to ours
 258  set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'installer_msg_handler');
 259  $php_ini = new \bantu\IniGetWrapper\IniGetWrapper();
 260  
 261  $ini_display_errors = $php_ini->getNumeric('display_errors');
 262  register_shutdown_function('installer_shutdown_function', $ini_display_errors);
 263  // Suppress errors until we have created the containers
 264  @ini_set('display_errors', 0);
 265  
 266  $phpbb_installer_container_builder = new \phpbb\di\container_builder($phpbb_root_path, $phpEx);
 267  $phpbb_installer_container_builder
 268      ->with_environment('installer')
 269      ->without_extensions();
 270  
 271  $other_config_path = $phpbb_root_path . 'install/update/new/config';
 272  $config_path = (file_exists($other_config_path . '/installer/config.yml')) ? $other_config_path : $phpbb_root_path . 'config';
 273  
 274  $phpbb_installer_container = $phpbb_installer_container_builder
 275      ->with_config_path($config_path)
 276      ->with_custom_parameters(array('cache.driver.class' => 'phpbb\cache\driver\file'))
 277      ->get_container();
 278  
 279  @ini_set('display_errors', $ini_display_errors);


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