1 (edited by 2008-11-18 09:56:50)

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

Re: [HACK] Word filter for comments

yeah, another filter http://cutephp.com/forum/style_emoticons/default/smile.gif
this is the third i believe http://cutephp.com/forum/style_emoticons/default/wink.gif

Re: [HACK] Word filter for comments

Name: Word Filter
Author: chad101
CuteNews Compatibility: 1.3.6 - * (no incompatibility reported yet)
Description: Stops certain words from being used in the comments. This filter allows you to replace certain words by a mask, delete those certain words from the comment, or just don't save comments with these certain words. A word from the author

NOTE: regular expressions must be enclosed in double quotes ""
I have enclosed installation instructions and tested this mod with PHP 4 and 5.
So much more can be done and I plan on fine tuning this. I'm seeking suggestions for future features.

As an example, I have also enclosed 3 rule sets
1, URL detection uses a regular expression and it will catch almost all instances of urls. The expression needs some more minor work but it is a start on the right path
2, Common bot words: typical pharmaceutical drug names and other phrases (with some regular expressions) a normal user would be making a comment about.
3, Curse words your typical 4 letter words and other offensive material.


Discussion Topic: here
Instructions:
Download the zip in the discussion topic and follow those instructions
mirror

Posts: 4

Pages 1

You must login or register to post a reply

CutePHP Forums → Hacks & Tricks / FAQ → [HACK] Word filter for comments