hello guys, i'm trying to create a simple script that block an user if the hostname contain an custom word for example if the user hostname contain "proxy" or "vpn" then the script should block that user and print white page or 404 any help ?
If i'm not totally off this should give you the functionality that you want. <?php if (substr_count($_SERVER["REMOTE_HOST"], "vpn") > 0) { die("Access denied, do not use a proxy!"); } ?> PHP: Live example: http://test.helgesverre.com/proxytest.php Note: Your web server must be configured to create this variable. For example in Apache you'll need HostnameLookups On inside httpd.conf for it to exist.
<?php $blocked_words = array( "vpn", "proxy", "word3" ); foreach($blocked_words as $word) { if (substr_count($_SERVER["REMOTE_HOST"], $word) > 0) { die("Access denied, do not use a proxy!"); } } ?> PHP: There you go
And, if you're smart, you'll change all those double quotes to single quotes, as they're not being parsed - with double quotes, PHP looks for variables inside the quotes, while it doesn't do that with single quotes. Not that important in this case, but a thing to remember when the amount of code-lines goes up into thousands, and you're looking for ways to improve speed.
there are much smarter ways to block proxies, maxmind DB geolite free, with cool accuracy, does return "Anonymous Proxy" for proxy users, instead of country, so this shall be much better