44 if (!empty($paramsConf))
45 $censorConf = $paramsConf;
47 if (!isset($censorConf)) {
48 $censorConf =
$xoops->getConfigs();
49 $config = parent::loadConfig(__DIR__);
51 $censorConf = array_merge($censorConf,
$config);
54 if (empty($censorConf[
'censor_enable'])) {
58 if (empty($censorConf[
'censor_words'])) {
62 if (!empty($censorConf[
'censor_admin']) && !
$xoops->userIsAdmin) {
66 $replacement = empty($censorConf[
'censor_replace']) ?
'!!censured!!' : $censorConf[
'censor_replace'];
67 if (is_array($censorConf[
'censor_words']))
foreach ($censorConf[
'censor_words'] as $bad) {
70 if (
false === strpos(
$text, $bad)) {
73 if (!empty($censorConf[
'censor_terminate'])) {
74 trigger_error(
"Censor words found", E_USER_ERROR);
78 $patterns[] =
"/(^|[^0-9a-z_]){$bad}([^0-9a-z_]|$)/siU";
79 $replacements[] =
"\\1{$replacement}\\2";
80 $text = preg_replace($patterns, $replacements,
$text);
load(MyTextSanitizer &$ts, $text, array $paramsConf=null)