get('behind_loadbalancer', '0')) { return false; } if (array_key_exists('HTTP_X_FORWARDED_FOR', $_SERVER) && !empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { return true; } if (array_key_exists('HTTP_CLIENT_IP', $_SERVER) && !empty($_SERVER['HTTP_CLIENT_IP'])) { return true; } return false; } /** * Enables the Behind Load Balancer setting in Global Configuration * * @return void * * @since 3.9.26 */ function behindproxy_postinstall_action() { $prev = ArrayHelper::fromObject(new JConfig()); $data = array_merge($prev, array('behind_loadbalancer' => '1')); $config = new Registry($data); // Set the configuration file path. $file = JPATH_CONFIGURATION . '/configuration.php'; // Attempt to make the file writeable if (Path::isOwner($file) && !Path::setPermissions($file, '0644')) { Factory::getApplication()->enqueueMessage(Text::_('COM_CONFIG_ERROR_CONFIGURATION_PHP_NOTWRITABLE'), 'error'); return; } // Attempt to write the configuration file as a PHP class named JConfig. $configuration = $config->toString('PHP', array('class' => 'JConfig', 'closingtag' => false)); if (!File::write($file, $configuration)) { Factory::getApplication()->enqueueMessage(Text::_('COM_CONFIG_ERROR_WRITE_FAILED'), 'error'); return; } // Attempt to make the file unwriteable if (Path::isOwner($file) && !Path::setPermissions($file, '0444')) { Factory::getApplication()->enqueueMessage(Text::_('COM_CONFIG_ERROR_CONFIGURATION_PHP_NOTUNWRITABLE'), 'error'); } }