Topic: [HACK] Word filter for comments
Name: Word filer for comments
Author: Ifa
CuteNews Compatibility: 1.3.6 - * (no incompatibility reported yet)
Description: This is a simple word filter. It replaces words of your choice with * (a with *, ab with **, abc with *** and so on)
Instructions:
First make a filter.txt into your cutenews folder, and add the words you want to list, like this:
word1
word2
word3
After that, inc/shows.inc.php and find line 535 (v1.4.6),
$output = replace_comment("show", $output);
Between it and
echo $output;
add this:
$file = str_replace(array("\r\n", "\r"), "\n", file_get_contents('filter.txt'));
$wordfilter = explode("\n", $file);
foreach ($wordfilter as $word) $output = str_ireplace($word, str_repeat("*", strlen($word)), $output);
This alternative code shows the first and the last letter, ie abcd -> a**d
$file = str_replace(array("\r\n", "\r"), "\n", file_get_contents('filter.txt'));
$wordfilter = explode("\n", $file);
foreach ($wordfilter as $word) $output = str_ireplace($word, substr($word, 0).str_repeat("*", strlen($word) - 2).substr($word, -1), $output);
These are case insensitive, so no need to worry about upper and lowercases
Note that this only edits the output, it's doesn't affect the comment saving. So in comment.txt the words are still unsensored