Skip to content

Commit

Permalink
add X-Forwarded-For IP to log entries, bcosca/fatfree#1042
Browse files Browse the repository at this point in the history
  • Loading branch information
ikkez committed Nov 24, 2019
1 parent 397b6cd commit 4c036aa
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions log.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
Expand Down

0 comments on commit 4c036aa

Please sign in to comment.