View Single Post
Old 2005-01-21, 01:41 AM   #18
Opti
I Didn't Do It
 
Opti's Avatar
 
Join Date: Aug 2003
Location: au
Posts: 795
Send a message via ICQ to Opti
here is some code that will determine the correct IP from any properly configured ISP proxy.

For anyone using a Submission script that logs webmaster IPs, using this code rather than simply relying on the REMOTE_ADDRESS variable to gather the IP will be a lot more effective.

PHP Code:
<?php
function getIP() {
   
$tmp = array();
   if  (isset(
$_SERVER['HTTP_X_FORWARDED_FOR']) && strpos($_SERVER['HTTP_X_FORWARDED_FOR'],',')) {
       
$tmp +=  explode(',',$_SERVER['HTTP_X_FORWARDED_FOR']);
   } elseif (isset(
$_SERVER['HTTP_X_FORWARDED_FOR'])) {
       
$tmp[] = $_SERVER['HTTP_X_FORWARDED_FOR'];
   }
   
$tmp[] = $_SERVER['REMOTE_ADDR'];
   return 
$tmp;
}
print_r(getIP());
?>
Check it what it outputs for your IP here:
http://xengio.com/XGOgetIP.php


(For LL owners that just glazed over thinking thats too technical for me.... it isnt as hard as it may look. If you can code html in notepad, you can likely incorporate that into almost any script all by yourself.)
Opti is offline   Reply With Quote