[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/includes/ -> framework.php (source)

   1  <?php
   2  
   3  /**
   4   * @package    Joomla.Site
   5   *
   6   * @copyright  (C) 2005 Open Source Matters, Inc. <https://www.joomla.org>
   7   * @license    GNU General Public License version 2 or later; see LICENSE.txt
   8   */
   9  
  10  defined('_JEXEC') or die;
  11  
  12  use Joomla\CMS\Version;
  13  use Joomla\Utilities\IpHelper;
  14  
  15  // System includes
  16  require_once JPATH_LIBRARIES . '/bootstrap.php';
  17  
  18  // Installation check, and check on removal of the install directory.
  19  if (
  20      !file_exists(JPATH_CONFIGURATION . '/configuration.php')
  21      || (filesize(JPATH_CONFIGURATION . '/configuration.php') < 10)
  22      || (file_exists(JPATH_INSTALLATION . '/index.php') && (false === (new Version())->isInDevelopmentState()))
  23  ) {
  24      if (file_exists(JPATH_INSTALLATION . '/index.php')) {
  25          header('Location: ' . substr($_SERVER['REQUEST_URI'], 0, strpos($_SERVER['REQUEST_URI'], 'index.php')) . 'installation/index.php');
  26  
  27          exit;
  28      } else {
  29          echo 'No configuration file found and no installation code available. Exiting...';
  30  
  31          exit;
  32      }
  33  }
  34  
  35  // Pre-Load configuration. Don't remove the Output Buffering due to BOM issues, see JCode 26026
  36  ob_start();
  37  require_once JPATH_CONFIGURATION . '/configuration.php';
  38  ob_end_clean();
  39  
  40  // System configuration.
  41  $config = new JConfig();
  42  
  43  // Set the error_reporting, and adjust a global Error Handler
  44  switch ($config->error_reporting) {
  45      case 'default':
  46      case '-1':
  47          break;
  48  
  49      case 'none':
  50      case '0':
  51          error_reporting(0);
  52  
  53          break;
  54  
  55      case 'simple':
  56          error_reporting(E_ERROR | E_WARNING | E_PARSE);
  57          ini_set('display_errors', 1);
  58  
  59          break;
  60  
  61      case 'maximum':
  62      case 'development': // <= Stays for backward compatibility, @TODO: can be removed in 5.0
  63          error_reporting(E_ALL);
  64          ini_set('display_errors', 1);
  65  
  66          break;
  67  
  68      default:
  69          error_reporting($config->error_reporting);
  70          ini_set('display_errors', 1);
  71  
  72          break;
  73  }
  74  
  75  if (!defined('JDEBUG')) {
  76      define('JDEBUG', $config->debug);
  77  }
  78  
  79  // Check deprecation logging
  80  if (empty($config->log_deprecated)) {
  81      // Reset handler for E_USER_DEPRECATED
  82      set_error_handler(null, E_USER_DEPRECATED);
  83  } else {
  84      // Make sure handler for E_USER_DEPRECATED is registered
  85      set_error_handler(['Joomla\CMS\Exception\ExceptionHandler', 'handleUserDeprecatedErrors'], E_USER_DEPRECATED);
  86  }
  87  
  88  if (JDEBUG || $config->error_reporting === 'maximum') {
  89      // Set new Exception handler with debug enabled
  90      $errorHandler->setExceptionHandler(
  91          [
  92              new \Symfony\Component\ErrorHandler\ErrorHandler(null, true),
  93              'renderException'
  94          ]
  95      );
  96  }
  97  
  98  /**
  99   * Correctly set the allowing of IP Overrides if behind a trusted proxy/load balancer.
 100   *
 101   * We need to do this as high up the stack as we can, as the default in \Joomla\Utilities\IpHelper is to
 102   * $allowIpOverride = true which is the wrong default for a generic site NOT behind a trusted proxy/load balancer.
 103   */
 104  if (property_exists($config, 'behind_loadbalancer') && $config->behind_loadbalancer == 1) {
 105      // If Joomla is configured to be behind a trusted proxy/load balancer, allow HTTP Headers to override the REMOTE_ADDR
 106      IpHelper::setAllowIpOverrides(true);
 107  } else {
 108      // We disable the allowing of IP overriding using headers by default.
 109      IpHelper::setAllowIpOverrides(false);
 110  }
 111  
 112  unset($config);


Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer