PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
It is currently Fri May 24, 2019 11:31 pm

All times are UTC - 5 hours

Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: IP blocking
PostPosted: Sun May 19, 2002 2:39 am 
Forum Newbie

Joined: Fri May 03, 2002 9:41 pm
Posts: 4

Any help on this would be greatly appreciated.

Problem, have mail form that runs on php.
However I have this idiot that has taken it apon
itself to send me about 50 emails a day.
I have the IP & as it is coming from China I figure
I want to block to entire IP range. The script below is running
but it is not blocking this fool all the time.

Any ideas how to block this ratbag out?

Syntax: [ Download ] [ Hide ]
<script language="javascript">
var ip = '<!--#echo var="REMOTE_ADDR"-->'
if (ip == '61.154.*.*') {
alert("STOP! You are viewing this page from an IP address that is not allowed!");
alert("You really need to get a life!");
if (confirm("Do you want to leave peacefully? Or will I have to help you?"))
{location.href="" } else { ("OK you choose I don't care! Bye bye! Don't come back!"); {location.href="" }} }

 Post subject:
PostPosted: Sun May 19, 2002 8:57 am 
Site Admin

Joined: Thu Apr 18, 2002 3:14 pm
Posts: 1767
Location: Montreal, CA
Are you using PHP to send the email out?

 Post subject: You can try this
PostPosted: Fri May 24, 2002 8:12 am 
Forum Newbie
User avatar

Joined: Fri May 24, 2002 8:12 am
Posts: 1
Location: Ghent, Belgium, Europe
Since JAVA is a client side programming language, this means that it is run on this guy's machine. It is easy for this guy to prevent JAVA running on his machine. It is better to implement such a code in PHP, which is run on your server and which cannot be turned off that easily.
I suggest you put something like this at the top of you page (before your html - code or the header function won't work):

$ip_string = "$REMOTE_ADDR";
if ((substr($ip_string,0,7) == "61.154.") OR !(isset($REMOTE_ADDR)))
header( "Location:" );

this will send anyone from the IP-range 61.154.*.* or without an IP to google instead of to your site.
Be aware however, that people can also mess with their IP-adresses,
but lets hope your guy doesn't know how.

I am not a 100% sure about the substr-syntax, but I think it is OK


 Post subject:
PostPosted: Fri May 24, 2002 1:39 pm 
Forum Contributor

Joined: Sun May 19, 2002 9:58 am
Posts: 225
Location: Sussex, UK
JAVA != Javascript!

 Post subject:
PostPosted: Fri Jun 07, 2002 12:44 am 
Forum Contributor
User avatar

Joined: Wed May 29, 2002 3:46 am
Posts: 238
Location: Florida
Hey here's an idea that I've done before.
Instead of blocking his IP, why not exclude pages or certain parts of the script based on his IP?

Syntax: [ Download ] [ Hide ]
$ShoutBan = array("IP Adress to Ban");
$ShoutBanString = implode (":", $ShoutBan);
$Shoutverify = getenv("REMOTE_ADDR");
if (strstr($ShoutBanString,$Shoutverify)) &#123;
print "Sorry you have lost your privileges! This is most likely due to breaking the guidelines and/or rules for this form. If you think this is in error. Please contact me.";
else &#123;

Place Content you don't want him to see here. This could be whole PHP pages if it's placed at the top or just parts of a script like the "Submit" button. There are other ways, but this works for me.

Make sure this last part is intact.

&lt;? &#125; ?&gt;

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 5 hours

Who is online

Users browsing this forum: No registered users and 4 guests

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group