Jump to content


Photo

Help with banning email or domain!


  • Please log in to reply
5 replies to this topic

#1 mrrodger

mrrodger
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 24 July 2006 - 05:11 PM

I'm sure this is simple but can someone please help? I  would like to add a script to my existing php form processing page that would ban a specific IP and/or email address. I keep getting spam from the same email address about 50 times a day. Please help!! Thank you!

#2 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 24 July 2006 - 05:16 PM

This should fix it for all of 30 seconds.

if ($email == "foo@bar.com") {
  echo "You are not allowed to post";
} else {
  // handle post.
}


#3 mrrodger

mrrodger
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 24 July 2006 - 05:31 PM

Thank you- that worked! Do you know how to do the same thing but with IP addresses?

#4 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 24 July 2006 - 05:35 PM

Carefull though... ip's are unreliable.

[code=php:0]
if ($_SERVER['REMOTE_ADDR'] == "192.168.12.89") {
  echo "You are not allowed to post";
} else {
  // handle post.
}

#5 gm04030276

gm04030276
  • Members
  • PipPip
  • Member
  • 14 posts

Posted 24 July 2006 - 06:05 PM

im just browsing here and wondered if you could use a flatfile database or a mysql database to hold and retrive the information for checking the email/ip against??

#6 ShogunWarrior

ShogunWarrior
  • Members
  • PipPipPip
  • Advanced Member
  • 528 posts
  • LocationIreland

Posted 24 July 2006 - 09:22 PM

You could have them in a text file like so:
203.188.122.186
222.172.213.221
123.123.154.224

Then at the start of your script:
<?php
$ip = @ $_SERVER['REMOTE_ADDR'];
$ips = file('ips.txt');
if( in_array($ip,$ips) ){die('You are not allowed to post.');}

<a href="http://www.daviddora...nmedia.com/">My New Site/Blog</a> | <a href="http://www.daviddora...m/check/">Check your page for broken links/images/scripts</a>

Zend Certified Engineer
Follow me on Twitter: http://twitter.com/davidd




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users