hey
I have $_POST['comment'] right, basically, can someone help me with checking if $_POST['comment'] has swear words and if so replace them with #'s.
thanks.

hey
I have $_POST['comment'] right, basically, can someone help me with checking if $_POST['comment'] has swear words and if so replace them with #'s.
thanks.
Silly idea, but couldnt you impliment a sort of bbcode feature on it?
Rather then checking when its posted, it checks where its displayed.
eg having your filter file with all your swearwords etc... in and then having filter wrapped around it?
filter($comment);
Or something?
edit, like this:
filter.php
then when defining the $content variable or w/e have something like this:PHP Code:<?
function filter($content){ // our nice filter function
$content = nl2br(htmlspecialchars($content)); // our message that we want to put the filter in
$filter = array( // The filter tags
"SWEARWORDHERE", // omg, a swear word
"SWEARWORDHERE", // omg, another swear word
);
$html = array( // The HTML counter part of the tags
"#########",
"#########",
);
$content = preg_replace($filter, $html, $content); // replaces all filtered words tags with their HTML counter parts
return nl2br($content);
}
?>
then obviously include the filter file in every page the filter is included onPHP Code:$content = filter($r['content']);
Theres probably an easier way to do it, but mehPHP Code:include("filter.php");
Last edited by CHTom; 21-12-2006 at 02:26 PM.
Want to hide these adverts? Register an account for free!