2009-05-27 22:47:11 +00:00
|
|
|
<?php
|
2022-06-27 18:18:44 +00:00
|
|
|
|
2009-05-27 22:47:11 +00:00
|
|
|
/**
|
2012-06-30 21:09:54 +00:00
|
|
|
* @package Joomla.Site
|
|
|
|
*
|
2020-11-28 01:33:45 +00:00
|
|
|
* @copyright (C) 2005 Open Source Matters, Inc. <https://www.joomla.org>
|
2012-06-30 21:09:54 +00:00
|
|
|
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
2009-05-27 22:47:11 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
defined('_JEXEC') or die;
|
|
|
|
|
2024-02-19 14:44:22 +00:00
|
|
|
use Joomla\CMS\Uri\Uri;
|
2019-05-27 00:58:40 +00:00
|
|
|
use Joomla\CMS\Version;
|
2021-04-07 21:31:42 +00:00
|
|
|
use Joomla\Utilities\IpHelper;
|
2019-05-27 00:58:40 +00:00
|
|
|
|
2015-06-30 19:41:43 +00:00
|
|
|
// System includes
|
2016-07-09 17:29:18 +00:00
|
|
|
require_once JPATH_LIBRARIES . '/bootstrap.php';
|
2015-06-30 19:41:43 +00:00
|
|
|
|
2010-05-25 02:10:02 +00:00
|
|
|
// Installation check, and check on removal of the install directory.
|
2013-09-20 10:24:57 +00:00
|
|
|
if (
|
|
|
|
!file_exists(JPATH_CONFIGURATION . '/configuration.php')
|
2015-06-30 19:41:43 +00:00
|
|
|
|| (filesize(JPATH_CONFIGURATION . '/configuration.php') < 10)
|
2019-05-27 00:58:40 +00:00
|
|
|
|| (file_exists(JPATH_INSTALLATION . '/index.php') && (false === (new Version())->isInDevelopmentState()))
|
2013-09-28 12:18:07 +00:00
|
|
|
) {
|
2013-09-20 10:24:57 +00:00
|
|
|
if (file_exists(JPATH_INSTALLATION . '/index.php')) {
|
2024-02-19 14:44:22 +00:00
|
|
|
header('Location: ' . Uri::base() . 'installation/index.php');
|
2022-06-27 18:18:44 +00:00
|
|
|
|
2013-09-20 10:24:57 +00:00
|
|
|
exit;
|
|
|
|
} else {
|
2009-05-27 22:47:11 +00:00
|
|
|
echo 'No configuration file found and no installation code available. Exiting...';
|
2022-06-27 18:18:44 +00:00
|
|
|
|
2013-09-20 10:24:57 +00:00
|
|
|
exit;
|
2009-05-27 22:47:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-04-02 00:49:40 +00:00
|
|
|
// Pre-Load configuration. Don't remove the Output Buffering due to BOM issues, see JCode 26026
|
2011-08-28 07:30:37 +00:00
|
|
|
ob_start();
|
2013-09-20 10:24:57 +00:00
|
|
|
require_once JPATH_CONFIGURATION . '/configuration.php';
|
2011-08-28 07:30:37 +00:00
|
|
|
ob_end_clean();
|
2009-05-27 22:47:11 +00:00
|
|
|
|
2009-07-11 18:36:02 +00:00
|
|
|
// System configuration.
|
2012-06-25 20:57:15 +00:00
|
|
|
$config = new JConfig();
|
2011-09-29 14:04:30 +00:00
|
|
|
|
2020-03-20 17:21:07 +00:00
|
|
|
// Set the error_reporting, and adjust a global Error Handler
|
2011-09-29 14:04:30 +00:00
|
|
|
switch ($config->error_reporting) {
|
|
|
|
case 'default':
|
|
|
|
case '-1':
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'none':
|
|
|
|
case '0':
|
|
|
|
error_reporting(0);
|
2013-09-20 10:24:57 +00:00
|
|
|
|
2011-09-29 14:04:30 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'simple':
|
|
|
|
error_reporting(E_ERROR | E_WARNING | E_PARSE);
|
|
|
|
ini_set('display_errors', 1);
|
2013-09-20 10:24:57 +00:00
|
|
|
|
2011-09-29 14:04:30 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'maximum':
|
2020-04-11 21:29:01 +00:00
|
|
|
case 'development': // <= Stays for backward compatibility, @TODO: can be removed in 5.0
|
2011-09-29 14:04:30 +00:00
|
|
|
error_reporting(E_ALL);
|
|
|
|
ini_set('display_errors', 1);
|
2013-09-20 10:24:57 +00:00
|
|
|
|
2011-09-29 14:04:30 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
error_reporting($config->error_reporting);
|
|
|
|
ini_set('display_errors', 1);
|
2013-09-20 10:24:57 +00:00
|
|
|
|
2011-09-29 14:04:30 +00:00
|
|
|
break;
|
2009-05-27 22:47:11 +00:00
|
|
|
}
|
|
|
|
|
2018-11-13 00:01:06 +00:00
|
|
|
if (!defined('JDEBUG')) {
|
|
|
|
define('JDEBUG', $config->debug);
|
|
|
|
}
|
2009-05-27 22:47:11 +00:00
|
|
|
|
2021-08-20 12:51:39 +00:00
|
|
|
// Check deprecation logging
|
|
|
|
if (empty($config->log_deprecated)) {
|
|
|
|
// Reset handler for E_USER_DEPRECATED
|
|
|
|
set_error_handler(null, E_USER_DEPRECATED);
|
|
|
|
} else {
|
|
|
|
// Make sure handler for E_USER_DEPRECATED is registered
|
|
|
|
set_error_handler(['Joomla\CMS\Exception\ExceptionHandler', 'handleUserDeprecatedErrors'], E_USER_DEPRECATED);
|
|
|
|
}
|
|
|
|
|
2020-03-30 09:21:01 +00:00
|
|
|
if (JDEBUG || $config->error_reporting === 'maximum') {
|
|
|
|
// Set new Exception handler with debug enabled
|
|
|
|
$errorHandler->setExceptionHandler(
|
|
|
|
[
|
|
|
|
new \Symfony\Component\ErrorHandler\ErrorHandler(null, true),
|
|
|
|
'renderException',
|
|
|
|
]
|
|
|
|
);
|
2020-03-20 17:21:07 +00:00
|
|
|
}
|
|
|
|
|
2021-04-07 21:31:42 +00:00
|
|
|
/**
|
|
|
|
* Correctly set the allowing of IP Overrides if behind a trusted proxy/load balancer.
|
|
|
|
*
|
|
|
|
* We need to do this as high up the stack as we can, as the default in \Joomla\Utilities\IpHelper is to
|
|
|
|
* $allowIpOverride = true which is the wrong default for a generic site NOT behind a trusted proxy/load balancer.
|
|
|
|
*/
|
|
|
|
if (property_exists($config, 'behind_loadbalancer') && $config->behind_loadbalancer == 1) {
|
|
|
|
// If Joomla is configured to be behind a trusted proxy/load balancer, allow HTTP Headers to override the REMOTE_ADDR
|
|
|
|
IpHelper::setAllowIpOverrides(true);
|
|
|
|
} else {
|
|
|
|
// We disable the allowing of IP overriding using headers by default.
|
|
|
|
IpHelper::setAllowIpOverrides(false);
|
|
|
|
}
|
|
|
|
|
2011-09-29 14:04:30 +00:00
|
|
|
unset($config);
|