[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * @package Joomla.API 5 * 6 * @copyright (C) 2019 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('HTTP/1.1 500 Internal Server Error'); 26 echo json_encode( 27 array('error' => 'You must install Joomla to use the API') 28 ); 29 30 exit(); 31 } else { 32 header('HTTP/1.1 500 Internal Server Error'); 33 echo json_encode( 34 array('error' => 'No configuration file found and no installation code available. Exiting...') 35 ); 36 37 exit; 38 } 39 } 40 41 // Pre-Load configuration. Don't remove the Output Buffering due to BOM issues, see JCode 26026 42 ob_start(); 43 require_once JPATH_CONFIGURATION . '/configuration.php'; 44 ob_end_clean(); 45 46 // System configuration. 47 $config = new JConfig(); 48 49 // Set the error_reporting 50 switch ($config->error_reporting) { 51 case 'default': 52 case '-1': 53 break; 54 55 case 'none': 56 case '0': 57 error_reporting(0); 58 59 break; 60 61 case 'simple': 62 error_reporting(E_ERROR | E_WARNING | E_PARSE); 63 ini_set('display_errors', 1); 64 65 break; 66 67 case 'maximum': 68 case 'development': // <= Stays for backward compatibility, @TODO: can be removed in 5.0 69 error_reporting(E_ALL); 70 ini_set('display_errors', 1); 71 72 break; 73 74 default: 75 error_reporting($config->error_reporting); 76 ini_set('display_errors', 1); 77 78 break; 79 } 80 81 define('JDEBUG', $config->debug); 82 83 // Check deprecation logging 84 if (empty($config->log_deprecated)) { 85 // Reset handler for E_USER_DEPRECATED 86 set_error_handler(null, E_USER_DEPRECATED); 87 } else { 88 // Make sure handler for E_USER_DEPRECATED is registered 89 set_error_handler(['Joomla\CMS\Exception\ExceptionHandler', 'handleUserDeprecatedErrors'], E_USER_DEPRECATED); 90 } 91 92 if (JDEBUG || $config->error_reporting === 'maximum') { 93 // Set new Exception handler with debug enabled 94 $errorHandler->setExceptionHandler( 95 [ 96 new \Symfony\Component\ErrorHandler\ErrorHandler(null, true), 97 'renderException', 98 ] 99 ); 100 } 101 102 /** 103 * Correctly set the allowing of IP Overrides if behind a trusted proxy/load balancer. 104 * 105 * We need to do this as high up the stack as we can, as the default in \Joomla\Utilities\IpHelper is to 106 * $allowIpOverride = true which is the wrong default for a generic site NOT behind a trusted proxy/load balancer. 107 */ 108 if (property_exists($config, 'behind_loadbalancer') && $config->behind_loadbalancer == 1) { 109 // If Joomla is configured to be behind a trusted proxy/load balancer, allow HTTP Headers to override the REMOTE_ADDR 110 IpHelper::setAllowIpOverrides(true); 111 } else { 112 // We disable the allowing of IP overriding using headers by default. 113 IpHelper::setAllowIpOverrides(false); 114 } 115 116 unset($config);
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Sep 7 05:41:13 2022 | Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer |