I don\'t know if this is help for u, I find some code about resolving IP. Maybe u can try it.
if (getenv(HTTP_X_FORWARDED_FOR)){
$ip=getenv(HTTP_X_FORWARDED_FOR);
} else {
$ip=getenv(REMOTE_ADDR);
}
also, please be careful that if someone is request via proxy, then IP maybe the proxy server.