20 defined(
'XOOPS_ROOT_PATH') or die('Restricted access');
31 function load(&$ts, $text)
34 if (!isset($censorConf)) {
37 $config = parent::loadConfig(dirname(__FILE__));
39 $censorConf = array_merge($censorConf,
$config);
42 if (empty($censorConf[
'censor_enable'])) {
46 if (empty($censorConf[
'censor_words'])) {
50 if (empty($censorConf[
'censor_admin']) &&
$GLOBALS[
'xoopsUserIsAdmin']) {
54 $replacement = $censorConf[
'censor_replace'];
55 foreach ($censorConf[
'censor_words'] as $bad) {
58 if (
false === strpos($text, $bad)) {
61 if (!empty($censorConf[
'censor_terminate'])) {
62 trigger_error(
"Censor words found", E_USER_ERROR);
66 $patterns[] =
"/(^|[^0-9a-z_]){$bad}([^0-9a-z_]|$)/siU";
67 $replacements[] =
"\\1{$replacement}\\2";
68 $text = preg_replace($patterns, $replacements, $text);