/    Sign up×
Community /Pin to ProfileBookmark

Will this code return the IP of the user and not the proxy?

Hi,

I’m having some problems with a spammer who is coming to my site thru various proxy servers so the IP is different all the time. I did a bit of googling and I found this code shown below.

I read that there is no way of tracking someone who’s using a proxy server. Is this true? Will the code below not work? I’m waiting on the spammer coming back, but in the mean time I thought I’ll post on here. ?

[code=php]/**
* Call as: $userp = GetUserIP();
*/
function GetUserIP() {

if (isset($_SERVER)) {

if (isset($_SERVER[“HTTP_X_FORWARDED_FOR”]))
return $_SERVER[“HTTP_X_FORWARDED_FOR”];

if (isset($_SERVER[“HTTP_CLIENT_IP”]))
return $_SERVER[“HTTP_CLIENT_IP”];

return $_SERVER[“REMOTE_ADDR”];
}

if (getenv(‘HTTP_X_FORWARDED_FOR’))
return getenv(‘HTTP_X_FORWARDED_FOR’);

if (getenv(‘HTTP_CLIENT_IP’))
return getenv(‘HTTP_CLIENT_IP’);

return getenv(‘REMOTE_ADDR’);
}[/code]

If this code doesn’t work, is there any way of banning traffic using proxy’s? I’ll put a temp ban on them :-))

Peace!

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@NogDogMar 22.2009 — Pretty much any "HTTP_" value is dependent on what the client decides to send (whether that client is the user's browser, a proxy server, or a robot script). While [i]some[/i] proxies may send some of those headers, there is no guarantee that any of them will be sent. Since many proxies are specifically set up to provide "anonymous" access, those likely will not send the user's IP in any of the request headers.

As far as blocking proxies, that could be done [i]if[/i] you have a list of proxy IP addresses that you want to block. There is no difference in blocking individual user IPs or proxy IPs.
Copy linkTweet thisAlerts:
@TopkatauthorMar 22.2009 — Hi NogDog,

Is there no way of catching someone on a Proxy? I can't ban this person? ?

There must be something that can be done to stop website abusers?
×

Success!

Help @Topkat spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.20,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...