[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * @package Joomla.Administrator 5 * @subpackage com_admin 6 * 7 * @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All rights reserved. 8 * @license GNU General Public License version 2 or later; see LICENSE.txt 9 */ 10 11 use Joomla\CMS\Factory; 12 use Joomla\CMS\Filesystem\File; 13 use Joomla\CMS\Filesystem\Path; 14 use Joomla\CMS\Language\Text; 15 use Joomla\Registry\Registry; 16 use Joomla\Utilities\ArrayHelper; 17 18 // phpcs:disable PSR1.Files.SideEffects 19 \defined('_JEXEC') or die; 20 // phpcs:enable PSR1.Files.SideEffects 21 22 /** 23 * Notifies users of the new Behind Load Balancer option in Global Config, if we detect they might be behind a proxy 24 * 25 * @return boolean 26 * 27 * @since 3.9.26 28 */ 29 function admin_postinstall_behindproxy_condition() 30 { 31 $app = Factory::getApplication(); 32 33 if ($app->get('behind_loadbalancer', '0')) { 34 return false; 35 } 36 37 if (array_key_exists('HTTP_X_FORWARDED_FOR', $_SERVER) && !empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { 38 return true; 39 } 40 41 if (array_key_exists('HTTP_CLIENT_IP', $_SERVER) && !empty($_SERVER['HTTP_CLIENT_IP'])) { 42 return true; 43 } 44 45 return false; 46 } 47 48 49 /** 50 * Enables the Behind Load Balancer setting in Global Configuration 51 * 52 * @return void 53 * 54 * @since 3.9.26 55 */ 56 function behindproxy_postinstall_action() 57 { 58 $prev = ArrayHelper::fromObject(new JConfig()); 59 $data = array_merge($prev, array('behind_loadbalancer' => '1')); 60 61 $config = new Registry($data); 62 63 // Set the configuration file path. 64 $file = JPATH_CONFIGURATION . '/configuration.php'; 65 66 // Attempt to make the file writeable 67 if (Path::isOwner($file) && !Path::setPermissions($file, '0644')) { 68 Factory::getApplication()->enqueueMessage(Text::_('COM_CONFIG_ERROR_CONFIGURATION_PHP_NOTWRITABLE'), 'error'); 69 70 return; 71 } 72 73 // Attempt to write the configuration file as a PHP class named JConfig. 74 $configuration = $config->toString('PHP', array('class' => 'JConfig', 'closingtag' => false)); 75 76 if (!File::write($file, $configuration)) { 77 Factory::getApplication()->enqueueMessage(Text::_('COM_CONFIG_ERROR_WRITE_FAILED'), 'error'); 78 79 return; 80 } 81 82 // Attempt to make the file unwriteable 83 if (Path::isOwner($file) && !Path::setPermissions($file, '0444')) { 84 Factory::getApplication()->enqueueMessage(Text::_('COM_CONFIG_ERROR_CONFIGURATION_PHP_NOTUNWRITABLE'), 'error'); 85 } 86 }
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 |