From 4c036aab373349dd9abd4b43dc97813fdef0870f Mon Sep 17 00:00:00 2001 From: ikkez Date: Sun, 24 Nov 2019 23:16:38 +0100 Subject: [PATCH] add X-Forwarded-For IP to log entries, bcosca/fatfree#1042 --- log.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/log.php b/log.php index 87b0ca13..5b7341d1 100644 --- a/log.php +++ b/log.php @@ -39,8 +39,11 @@ function write($text,$format='r') { $fw->write( $this->file, date($format). - (isset($_SERVER['REMOTE_ADDR'])? - (' ['.$_SERVER['REMOTE_ADDR'].']'):'').' '. + (isset($_SERVER['REMOTE_ADDR'])? + (' ['.$_SERVER['REMOTE_ADDR']. + (($fwd=filter_var($fw->get('HEADERS.X-Forwarded-For'), + FILTER_VALIDATE_IP))?(' ('.$fwd.')'):'') + .']'):'').' '. trim($line).PHP_EOL, TRUE );