FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


PHP to detect users accessing site via proxy server





wangbin218200
I am after php code which detects if a user is accessing your site via a proxy server

this is the sort of code I have got.. is there a better way ?

<?php
// start code

// if getenv results in something, proxy detected

if (getenv('HTTP_X_FORWARDED_FOR')) {
$ip=getenv('HTTP_X_FORWARDED_FOR');
}

// otherwise no proxy detected

else {
$ip=getenv('REMOTE_ADDR');
}

// print the IP address on screen
echo $ip;
?>
hexkid
Yes, don't base your logic on the user's IP (direct or through proxy).

Remember that proxies may leave the HTT_X_FORWARDED_FOR empty; different users may connect from the same proxy; the same user may connect from different proxies on every request; ...


If these "shortcomings" do not bother you, I guess your code is ok.
Related topics
PHP Toturail
users online, using php and text file
About the Proxy server
The Definative Web Hosting Guide
PHP VS ASP
How to set up a proxy server at home?
connect to site via proxy & dreamweaver mx?
transparent proxy server over linux using squid
Anonymous Searching
Setting up a home proxy server
.: User login systems for your site :. CHEAP AND EASY!
I need to create proxy server in our network.
Affiliates
More IRC Questions
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.