Re: Question on explode and join.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi. I have just added a profanity filter to a current project which runs
like so (all form values are passed into the session after checking for
required fields etc). $swearbox is an array containing profanities so I
won't include it here!

$_SESSION['profane'] = false;

   foreach ($_POST as $value) {
       foreach ($swearbox as $profanity) {
           if (preg_match("/$profanity/i", $value)) {
           $errors = true;
           $_SESSION['profane'] = true;
           mail(TECHEMAIL, 'profane content attack attempt on DJST', "From:
{$_SERVER['REMOTE_ADDRESS']} Time: " . date('d F Y G:i:s', time()-TIMEDIFF),
'whoops@xxxxxxxxxxxxxxxxxxxxxx');
           }
       }
   }

...if $errors is true at the end of processing I send the user back to the
form. In this instance if there are rude words $_SESSION['profane'] is set
and we warn the user.





--
http://www.web-buddha.co.uk
http://www.projectkarma.co.uk

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux