Re: [PHP] bad word filter

2001-07-24 Thread Don Read


On 24-Jul-2001 Ryan Fischer wrote:
> 
> Anyway, here's what I would do:
> 
> function filterWords($str){
> $badwords = array("shit", "fuck", "ass", "bitch");
> for($i=0; $i $str = $eregi_replace("$badwords[$i]", "*", $str);
> }
> return $str;
> }

Un-tested:
$badpat=join('|', $badwords);
$str = $preg_replace("/\b[$badpat]\b/gi", '!*@', $str);

Regards,
-- 
Don Read   [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] bad word filter

2001-07-24 Thread Tyler Longren

I waste my time because the clients pay me to. ;-)
They get what they want.  I told them there would very easy ways around the
filters.  but they insisted.

Thanks!
Tyler Longren
Captain Jack Communications
[EMAIL PROTECTED]
www.captainjack.com


- Original Message -
From: "Ryan Fischer" <[EMAIL PROTECTED]>
To: "Tyler Longren" <[EMAIL PROTECTED]>; "php-general"
<[EMAIL PROTECTED]>
Sent: Tuesday, July 24, 2001 2:27 PM
Subject: Re: [PHP] bad word filter


> You wrote:
> > I've been reading the "Profanity Filter" thread in the list archives
> but
> > haven't found anything real helpful.  Here's my code so far, this of
> course
> > won't work.
> >  > function filterWords($string, &$result) {
> > $badwords="shit, fuck, ass, bitch";
> > $word=explode(", ", $badwords);
> > for ($i=0; $i > $replace = str_replace("$word[$i]", "", $string);
> > }
> > }
> > $string = "Ass monkey";
> > filterWords("$string", $result);
> > print "$result";
> > ?>
> >
> > How can I scan for the $badwords in $string and replace $badwords with
> ?
>
> Why waste your time?  People will find a way around the filters anyway,
> if they really want to use the words you're censoring.  Just a point to
> be made.
>
> Anyway, here's what I would do:
>
> function filterWords($str){
> $badwords = array("shit", "fuck", "ass", "bitch");
> for($i=0; $i $str = $eregi_replace("$badwords[$i]", "*", $str);
> }
> return $str;
> }
> $str = filterWords("Ass monkey");
> print $str; // Prints "* monkey"
>
> If you want to get really fancy, you can replace the "*" with some
> function calculating just how many asterisks you need to censor out the
> current word for its length.  HTH.  :)
>
> --
>  -Ryan :: ICQ - 595003 :: GigaBoard - http://www.gigaboard.net/
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] bad word filter

2001-07-24 Thread Ryan Fischer

You wrote:
> I've been reading the "Profanity Filter" thread in the list archives
but
> haven't found anything real helpful.  Here's my code so far, this of
course
> won't work.
>  function filterWords($string, &$result) {
> $badwords="shit, fuck, ass, bitch";
> $word=explode(", ", $badwords);
> for ($i=0; $i $replace = str_replace("$word[$i]", "", $string);
> }
> }
> $string = "Ass monkey";
> filterWords("$string", $result);
> print "$result";
> ?>
>
> How can I scan for the $badwords in $string and replace $badwords with
?

Why waste your time?  People will find a way around the filters anyway,
if they really want to use the words you're censoring.  Just a point to
be made.

Anyway, here's what I would do:

function filterWords($str){
$badwords = array("shit", "fuck", "ass", "bitch");
for($i=0; $ihttp://www.gigaboard.net/



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] bad word filter

2001-07-24 Thread Tyler Longren

Hello everyone,

I've been reading the "Profanity Filter" thread in the list archives but
haven't found anything real helpful.  Here's my code so far, this of course
won't work.


How can I scan for the $badwords in $string and replace $badwords with ?

Thanks,
Tyler Longren
Captain Jack Communications
[EMAIL PROTECTED]
www.captainjack.com




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]