padanius
Newbie
Karma: 0
Offline
Posts: 6
|
 |
« on: June 28, 2010, 20:13:34 » |
|
Hi,
when Joomla is behind a proxy or cache accelerator the logged IP number is that of the proxy, not that of the user.
You may modify the code in /components/com_jcomments/jcomments.class.php in order to log the correct IP of the user, as follows:
1) locate and comment this line :
// $this->userIP = $_SERVER['REMOTE_ADDR'];// getenv('REMOTE_ADDR');
and replace it with :
// start proxy IP mod by AEC 20100628 $headers = apache_request_headers(); if (array_key_exists('X-Forwarded-For', $headers)){ $this->userIP=$headers['X-Forwarded-For'] . ' via ' . $_SERVER["REMOTE_ADDR"]; } else { $this->userIP=$_SERVER["REMOTE_ADDR"]; } // end proxy IP mod by AEC 20100628
2) edit the field IP in the jos_jcomments table and increase the size to at least 45 ( varchar(45) ). If you have multiple proxies, you may have all proxies IPs plus the client IP inserted in this variable.
Just a note: X-Forwarded-For is usally added by teh proxy (if enabled to do so) but it may be spoofed, so there is no guarantee that the recorded IP is the real one, but at least for the good guys it will be OK; and you can always double check your proxy log with all the info collected here.
Hope the developers can add this to the meanstream code in future updates.
Enjoy!
AEC
|