I'm using PHP to write a using socket library application. How could I get the IP of the client? THanks for any help
I tried, but it's useless.
coolkid
2010-09-25 18:13:20
Did you check it against $_SERVER["HTTP_X_FORWARDED_FOR"] ?
Elliott
2010-09-25 18:17:35
Those variables are not available if he's using ordinary sockets.
nos
2010-09-25 19:28:38
A:
<?php
if ($_SERVER['HTTP_CLIENT_IP'])
$visitorIP = $_SERVER['HTTP_CLIENT_IP'];
elseif ($_SERVER['HTTP_X_FORWARDED'])
$visitorIP = $_SERVER['HTTP_X_FORWARDED'];
elseif ($_SERVER['HTTP_X_FORWARDED_FOR'])
$visitorIP = $_SERVER['HTTP_X_FORWARDED_FOR'];
else
$visitorIP = $_SERVER['REMOTE_ADDR'];
?>
For more/discussion - getting visitor's real IP address
Satya Prakash
2010-09-25 19:42:17
man your article is terrible. this variable can NOT hold the private LAN IP address. While other variables can contain NASDAQ quotes. And all these variables has nothing to do with this question.
Col. Shrapnel
2010-09-25 19:55:03