.:: Bots United ::.

.:: Bots United ::. (http://forums.bots-united.com/index.php)
-   General Programming (http://forums.bots-united.com/forumdisplay.php?f=25)
-   -   PHP Message Help (http://forums.bots-united.com/showthread.php?t=6362)

Ancient 16-06-2007 09:00

PHP Message Help
 
I'm trying to fend off spammers in my hosting contact form and I have this idea to help stop it.

In these emails they are sending the form with keywords in it like for example: $badwords.

And I'm trying to make a code for it to search what they wrote and send and if it finds one of the $badwords that it will die();.

What I have is:
Code:

$badwords = array(array('sex', 'porn', 'unknown', 'Unkown', 'geocities', 'tripod', 'http://'));
 
if(in_array(array('sex', 'porn', 'unknown', 'Unkown', 'geocities', 'tripod', 'http://'), $badwords));

How can I hook it up to search the $message for $badwords?

Whistler 16-06-2007 12:37

Re: PHP Message Help
 
try strstr() function.

Ancient 16-06-2007 20:39

Re: PHP Message Help
 
Code:

elseif(stristr($message, array('unknown', 'sex', 'porn', 'some sites', 'community', 'support', 'label', 'tripod', 'geocities', 'yahoo')) === FALSE)
 {
  die("there is something bad");
 }

Doesn't work well.

It will die weither there is a $badword or not.
I have also tried it true, and stristr and they all come back with the die weither the $badword is in it or not.
It works for finding something in a subject, but the subject doesn't have an array.

Code:

elseif(!stristr($subject, 'unknown') == FALSE)
 {
  die("Subject is bad");
 }

I found out when there is more than 1 option to look for it will ignore the script or string and move on.
Also if the string is in a certain way it will always die looking in the string or not.

Whistler 17-06-2007 09:42

Re: PHP Message Help
 
well... just use a for loop then :)

PHP Code:

for ($i 0$i count ($badwords); $i++)
  {
    if (
strstr ($message$badwords[i]) != FALSE)
      {
        die (
"bad words detected");
      }
  } 


Ancient 02-11-2007 04:04

Re: PHP Message Help
 
Thanks for the loop, runs great when searching a file extension against an extensions array list.

The Storm 30-01-2011 22:40

Re: PHP Message Help
 
stristr() will work but the you have to change the condition from == to != . :)
Oh this is old thread, the spam bot had confused me...


All times are GMT +2. The time now is 06:40.

Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.