View Single Post
  #6  
Old 02-07-2006, 09:04 AM
  B00MER's Avatar 
B00MER B00MER is offline
 

X-Guru
  
Join Date: Sep 2002
Location: Keller, TX (Cart-Lab.com)
Posts: 3,165
 

Default

I don't think the default takes Proxies or IP's behind LAN's into consideration. Here's a function that can easily be used in config.php to grab the absolute IP of the user. Thanks to NuLime for the function.
Code:
function fetch_remote_address() { $_SERVER = $GLOBALS['HTTP_SERVER_VARS']; # Record basic remote address. $remote_address = $_SERVER['REMOTE_ADDR']; # Take proxies into consideration or IPs behind a LAN. if (isset($_SERVER['HTTP_X_FORWARDED_FOR']) && $_SERVER['HTTP_X_FORWARDED_FOR'] != 'unknown' && $_SERVER['HTTP_X_FORWARDED_FOR'] != $_SERVER['REMOTE_ADDR']) { $HXFF_temp = preg_replace('/, ?unknown/i','',$_SERVER['HTTP_X_FORWARDED_FOR']); // Remove any trailing 'unknowns'. $remote_address .= ','.$HXFF_temp; } if (isset($_SERVER['HTTP_CLIENT_IP']) && $_SERVER['HTTP_CLIENT_IP'] != 'unknown' && $_SERVER['HTTP_CLIENT_IP'] != $_SERVER['HTTP_X_FORWARDED_FOR'] && $_SERVER['HTTP_CLIENT_IP'] != $_SERVER['REMOTE_ADDR']) { $HCI_temp = preg_replace('/, ?unknown/i','',$_SERVER['HTTP_CLIENT_IP']); // Remove any trailing 'unknowns'. $remote_address .= ','.$HCI_temp; } return $remote_address; }
__________________
Cart-Lab - 100+ Social Bookmarks for X-Cart.
Reply With Quote