fix: [flood protection] default to REMOTE_ADDR if the selected default logging IP source header is not populated

pull/92/head
iglocska 2022-02-20 11:49:57 +01:00
parent 3745739158
commit b046990153
No known key found for this signature in database
GPG Key ID: BEA224F1FEF113AC
1 changed files with 3 additions and 0 deletions

View File

@ -17,6 +17,9 @@ class FloodProtectionComponent extends Component
public function initialize(array $config): void
{
$ip_source = Configure::check('security.logging.ip_source') ? Configure::read('security.logging.ip_source') : 'REMOTE_ADDR';
if (!isset($_SERVER[$ip_source])) {
$ip_source = 'REMOTE_ADDR';
}
$this->remote_ip = $_SERVER[$ip_source];
$temp = explode(PHP_EOL, $_SERVER[$ip_source]);
if (count($temp) > 1) {