Jump to content


Photo

Checking text field for spam words


  • Please log in to reply
4 replies to this topic

#1 chrishau

chrishau
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 18 October 2006 - 09:17 AM

Hey! I have a problem... I have a tagboard on my homepage - www.dagangstas.net and it constantly gets filled up with spam so I deciced to do something about it and I want to create a filter that checks the tags for spam words. But I am not sure how.. Here is what I have so far!

$cjmsg = $_POST['cjmsg'];
$spam_array = array('breast enlargement', 'penis enlargement', 'weight loss', 'Incest Sex', 'Hentai Porn', 'Lose Weight', 'Free Money', 'Credit card', 'green card lottery', 'Viagra');

function contains_spam($spam_array,$cjmsg) {
	foreach ($spam_array as $spamitem) {
		
			return true;
	}
	return false;
}

As you can see the spam_array contains the words I want to ban and $cjmsg contains the tag. How can I check the words in $cjmsg against the spam array? Any help would be appreciated!! :)

#2 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 18 October 2006 - 09:23 AM

$cjmsg = $_POST['cjmsg'];
$spam_array = array('breast enlargement', 'penis enlargement', 'weight loss', 'Incest Sex', 'Hentai Porn', 'Lose Weight', 'Free Money', 'Credit card', 'green card lottery', 'Viagra');

if (in_array($cjmsg, $spam_array)) {
   // prevent update
} else {
  // do the update
}

though you should know..that's about as rudimentary as it comes... people can do all sorts of things to get around that, like doing V i a g a r a V..I..A..G..A..R..A  etc..  so you're going to have to do better than that..
Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#3 chrishau

chrishau
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 18 October 2006 - 09:36 AM

Thanks!

I know it is not the most advanced solution...but the battle has to begin somewhere right? :)

#4 xsist10

xsist10
  • Members
  • PipPipPip
  • Advanced Member
  • 114 posts

Posted 18 October 2006 - 09:46 AM

If you want to be really fancy you can send any board posts as an email to your webserver (with subject line: board_post or some such) and let your spam software (spamassassin, etc) sort it out. Then collect the email with a cronjob and post it.

Have a Google around and see if any anti-spam tools are out there that you can use on plain-text. There must be a few.

Otherwise just ban the IPs of the people who are posting spam.
SA PHP Archives - www.phparchives.za.org

#5 chrishau

chrishau
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 18 October 2006 - 09:54 AM

Thanks :)

Tried banning the ip's but they keep changing.. and tried sending mails to their providers aswell but nothing really happening there so will keep on trying!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users