PDA

View Full Version : PHP help needed



RYANNNNN
21-12-2006, 02:13 PM
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.

CHTom
21-12-2006, 02:17 PM
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

<?
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 when defining the $content variable or w/e have something like this:

$content = filter($r['content']);

then obviously include the filter file in every page the filter is included on


include("filter.php");

Theres probably an easier way to do it, but meh

Want to hide these adverts? Register an account for free!