Topic: Modifying the Censor
The censor system is alright, but it only censors the word, and not the word with a prefix or suffix on it. I do know MySQL, so I'm wondering if anyone can direct me to where the censors are applied to a post. Thank you.
You are not logged in. Please login or register.
PunBB Forums → PunBB 1.2 troubleshooting → Modifying the Censor
The censor system is alright, but it only censors the word, and not the word with a prefix or suffix on it. I do know MySQL, so I'm wondering if anyone can direct me to where the censors are applied to a post. Thank you.
Doesn't the wildcard (*) cover prefixes/suffixes?
If it does, perhaps I've accidentally changed how posts are censored when I installed a mod or something.
Can someone still tell me where the censor is applied in the code? Just what file, general direction, etc.
Either include/functions.php or include/parser.php, I think the latter.
Ok, here we go, include/functions.php:
//
// Replace censored words in $text
//
function censor_words($text)
{
global $db;
static $search_for, $replace_with;
// If not already built in a previous call, build an array of censor words and their replacement text
if (!isset($search_for))
{
$result = $db->query('SELECT search_for, replace_with FROM '.$db->prefix.'censoring') or error('Unable to fetch censor word list', __FILE__, __LINE__, $db->error());
$num_words = $db->num_rows($result);
$search_for = array();
for ($i = 0; $i < $num_words; ++$i)
{
list($search_for[$i], $replace_with[$i]) = $db->fetch_row($result);
$search_for[$i] = '/\b('.str_replace('\*', '\w*?', preg_quote($search_for[$i], '/')).')\b/i';
}
}
if (!empty($search_for))
$text = substr(preg_replace($search_for, $replace_with, ' '.$text.' '), 1, -1);
return $text;
}
Thank you, I'll compare it to what is in my file.
PunBB Forums → PunBB 1.2 troubleshooting → Modifying the Censor
Powered by PunBB, supported by Informer Technologies, Inc.