| Author |
Message |
scottdallas

Joined: 04 May 2006 Posts: 1943 Location: US |
|
Removing SPAM ;) |
|
This may have seemed obvious to everyone but it just hit me today how to stop from getting tons and tons of spam in your comments. Add the 'spam filter' hack to cutenews.ru and add things like this to your filtered list:
[url
http
href
[img
I noticed that all the spam had the trend of using HTML and bbcode. So just stop people from being able to write those kinds of things This is saving me from getting thousands of spams on my sites.
_________________ www.scottdizzle.com uses cnr
last update: 07-22-08: 8:30 pm |
|
| Tue Mar 20, 2007 9:08 am |
|
 |
Guest
|
|
|
Please login to hide the ads.
|
|
|
|
 |
Heya Im Me
Joined: 01 Feb 2006 Posts: 189
|
|
|
|
You're absolutely right... I didn't even realize that! Good call, maybe I'll be able to go one day without seeing 100+ comments of spam
Thanks Scott,
-HIM
|
|
| Tue Mar 20, 2007 6:59 pm |
|
 |
scottdallas

Joined: 04 May 2006 Posts: 1943 Location: US |
|
|
|
It's working quite well for me. I do this standard on all cutenews.ru installations now. How's it working for you Heya Im Me?
_________________ www.scottdizzle.com uses cnr
last update: 07-22-08: 8:30 pm |
|
| Wed Apr 04, 2007 1:24 pm |
|
 |
Jorioz
Joined: 15 Aug 2006 Posts: 31 Location: Holland |
|
|
|
simple way to stop it indeed, i'll give it a try 
_________________ Take a look at my CuteNews.RU based website:
MUSIC IN CONTROL . NL |
|
| Wed Apr 04, 2007 4:26 pm |
|
 |
Jorioz
Joined: 15 Aug 2006 Posts: 31 Location: Holland |
|
|
|
maybe you could help me out with this:
when trying to post an url, i get this:
 |  | Warning: preg_match() [function.preg-match]: Compilation failed: missing terminating ] for character class at offset 4 in c:\domains\musicincontrol.nl\wwwroot\cms\plugins\spam.php on line 25
Warning: preg_match() [function.preg-match]: Compilation failed: missing terminating ] for character class at offset 4 in c:\domains\musicincontrol.nl\wwwroot\cms\plugins\spam.php on line 25 |
My spam.php:
 |  | <?php
/*
Plugin Name: Spam filter
Plugin URI: http://cutenews.ru
Description: Create a list with words and don't allow comments which contain these words.
Version: 0.1
Application: CuteNews
Author: Лёха zloy и красивый
Author URI: http://lexa.cutenews.ru
*/
add_filter('news-allow-addcomment', 'spam_filter');
add_filter('cutenews-options', 'spam_AddToOptions');
add_action('plugin-options', 'spam_CheckAdminOptions');
function spam_filter($allow){
global $name, $mail, $comments;
$barword = new PluginSettings('BarWord');
if ($comments){
foreach($barword->settings as $bad){
if (preg_match("/$bad/i", strtolower($comments))){$allow = false;}
}
}
return ($allow ? true : false);
}
function spam_AddToOptions($options){
global $PHP_SELF;
$options[] = array(
'name' => 'Spam filter',
'url' => $PHP_SELF.'?mod=options&action=spam',
'access' => '1',
);
return $options;
}
function spam_CheckAdminOptions(){
if ($_GET['action'] == 'spam'){spam_AdminOptions();}
}
function spam_AdminOptions(){
global $PHP_SELF;
echoheader('options', 'Spam');
$barword = new PluginSettings('BarWord');
$buffer = '<table border=0 cellpading=0 cellspacing=0 width="645">
<table border=0 cellpading=0 cellspacing=0 width="645" >
<form method=post action="'.$PHP_SELF.'?mod=options&action=spam">
<td width=321 height="33"><b>Add a word</b>
<table border=0 cellpading=0 cellspacing=0 width=379 class="panel" cellpadding="7" >
<tr>
<td width=79 height="25"> Word:
<td width=300 height="25">
<input type="text" name="add_badword"> <input type="submit" value="Add to list">
</tr>
</form>
</table>
<tr>
<td width=654 height="11">
<img height=20 border=0 src="skins/images/blank.gif" width=1>
</tr><tr>
<td width=654 height=14>
<b>Spam list</b>
</tr>
<tr>
<td width=654 height=1>
<table width=641 height=100% cellspacing=2 cellpadding=2>
<tr>
<td width=260 class="panel"><b>Word</b></td>
<td width=140 class="panel"> <b>Action</b></td>
</tr>';
if ($words = $barword->settings){
foreach($words as $key => $bad){
$i++;
if ($i%2 == 0){$bg = ' class="enabled"';}
else {$bg = ' class="disabled"';}
if ($bad){$buffer .= '<tr'.$bg.'><td>'.$bad.'<td><a href="'.$PHP_SELF.'?mod=options&action=spam&subaction=remove&id='.$key.'">[Remove]</a>';}
}
}
$buffer .= '</table></table>';
if ($_POST['add_badword']){
$barword -> settings[] = strtolower($_POST['add_badword']);
$barword -> save();
$buffer = 'The word was added!<br><br><a href="'.$PHP_SELF.'?mod=options&action=spam">Back to the list</a>';
}
if ($_GET['subaction'] == 'remove'){
unset($barword -> settings[$_GET['id']]);
$barword -> save();
$buffer = 'The word was removed from the list!<br><br><a href="'.$PHP_SELF.'?mod=options&action=spam">Back to the list</a>';
}
echo $buffer;
echofooter();
}
?> |
What's the problem??
_________________ Take a look at my CuteNews.RU based website:
MUSIC IN CONTROL . NL |
|
| Wed Apr 04, 2007 6:07 pm |
|
 |
Jorioz
Joined: 15 Aug 2006 Posts: 31 Location: Holland |
|
|
|
Scott? Any idea?
You recommended the use of this spam-filter so I think you have some knowledge of this script...
_________________ Take a look at my CuteNews.RU based website:
MUSIC IN CONTROL . NL |
|
| Sat Apr 07, 2007 12:24 pm |
|
 |
Ramon
Joined: 12 Oct 2005 Posts: 473 Location: Hoogeveen, NL |
|
|
|
What version of PHP do you have running?
_________________
 |
|
| Sat Apr 07, 2007 4:09 pm |
|
 |
scottdallas

Joined: 04 May 2006 Posts: 1943 Location: US |
|
|
|
I never had a problem with the plugin and I'm no PHP expert to know why you're having the problem I'm sorry. It just works for me.
_________________ www.scottdizzle.com uses cnr
last update: 07-22-08: 8:30 pm |
|
| Sat Apr 07, 2007 7:25 pm |
|
 |
Jorioz
Joined: 15 Aug 2006 Posts: 31 Location: Holland |
|
|
| Sat Apr 07, 2007 9:21 pm |
|
 |
Ramon
Joined: 12 Oct 2005 Posts: 473 Location: Hoogeveen, NL |
|
|
|
So you have musicincontrol running on a local server?
Anyways -> Try this
 |  | <?php
/*
Plugin Name: Spam filter
Plugin URI: http://cutenews.ru
Description: Create a list with words and don't allow comments which contain these words.
Version: 0.1
Application: CuteNews
Author: ???? zloy ? ????????
Author URI: http://lexa.cutenews.ru
*/
add_filter('news-allow-addcomment', 'spam_filter');
add_filter('cutenews-options', 'spam_AddToOptions');
add_action('plugin-options', 'spam_CheckAdminOptions');
function spam_filter($allow){
global $name, $mail, $comments;
$barword = new PluginSettings('BarWord');
if ($comments){
foreach($barword->settings as $bad){
if (@preg_match("/$bad/i", strtolower($comments))){$allow = false;}
}
}
return ($allow ? true : false);
}
function spam_AddToOptions($options){
global $PHP_SELF;
$options[] = array(
'name' => 'Spam filter',
'url' => $PHP_SELF.'?mod=options&action=spam',
'access' => '1',
);
return $options;
}
function spam_CheckAdminOptions(){
if ($_GET['action'] == 'spam'){spam_AdminOptions();}
}
function spam_AdminOptions(){
global $PHP_SELF;
echoheader('options', 'Spam');
$barword = new PluginSettings('BarWord');
$buffer = '<table border=0 cellpading=0 cellspacing=0 width="645">
<table border=0 cellpading=0 cellspacing=0 width="645" >
<form method=post action="'.$PHP_SELF.'?mod=options&action=spam">
<td width=321 height="33"><b>Add a word</b>
<table border=0 cellpading=0 cellspacing=0 width=379 class="panel" cellpadding="7" >
<tr>
<td width=79 height="25"> Word:
<td width=300 height="25">
<input type="text" name="add_badword"> <input type="submit" value="Add to list">
</tr>
</form>
</table>
<tr>
<td width=654 height="11">
<img height=20 border=0 src="skins/images/blank.gif" width=1>
</tr><tr>
<td width=654 height=14>
<b>Spam list</b>
</tr>
<tr>
<td width=654 height=1>
<table width=641 height=100% cellspacing=2 cellpadding=2>
<tr>
<td width=260 class="panel"><b>Word</b></td>
<td width=140 class="panel"> <b>Action</b></td>
</tr>';
if ($words = $barword->settings){
foreach($words as $key => $bad){
$i++;
if ($i%2 == 0){$bg = ' class="enabled"';}
else {$bg = ' class="disabled"';}
if ($bad){$buffer .= '<tr'.$bg.'><td>'.$bad.'<td><a href="'.$PHP_SELF.'?mod=options&action=spam&subaction=remove&id='.$key.'">[Remove]</a>';}
}
}
$buffer .= '</table></table>';
if ($_POST['add_badword']){
$barword -> settings[] = strtolower($_POST['add_badword']);
$barword -> save();
$buffer = 'The word was added!<br><br><a href="'.$PHP_SELF.'?mod=options&action=spam">Back to the list</a>';
}
if ($_GET['subaction'] == 'remove'){
unset($barword -> settings[$_GET['id']]);
$barword -> save();
$buffer = 'The word was removed from the list!<br><br><a href="'.$PHP_SELF.'?mod=options&action=spam">Back to the list</a>';
}
echo $buffer;
echofooter();
}
?> |
_________________
 |
|
| Sat Apr 07, 2007 11:17 pm |
|
 |
Jorioz
Joined: 15 Aug 2006 Posts: 31 Location: Holland |
|
|
|
No local host (sohosted.com).
When I use this code, I get an empty page when trying to add comment (even when it's not containing any spam)
_________________ Take a look at my CuteNews.RU based website:
MUSIC IN CONTROL . NL |
|
| Sun Apr 08, 2007 1:40 pm |
|
 |
Ramon
Joined: 12 Oct 2005 Posts: 473 Location: Hoogeveen, NL |
|
|
|
 |  | <?php
/*
Plugin Name: Spam filter
Plugin URI: http://cutenews.ru
Description: Create a list with words and don't allow comments which contain these words.
Version: 0.1
Application: CuteNews
Author: ???? zloy ? ????????
Author URI: http://lexa.cutenews.ru
*/
add_filter('news-allow-addcomment', 'spam_filter');
add_filter('cutenews-options', 'spam_AddToOptions');
add_action('plugin-options', 'spam_CheckAdminOptions');
function spam_filter($allow){
global $name, $mail, $comments;
$barword = new PluginSettings('BarWord');
if ($comments){
foreach($barword->settings as $bad){
if (preg_match("@/$bad/@i", strtolower($comments))){$allow = false;}
}
}
return ($allow ? true : false);
}
function spam_AddToOptions($options){
global $PHP_SELF;
$options[] = array(
'name' => 'Spam filter',
'url' => $PHP_SELF.'?mod=options&action=spam',
'access' => '1',
);
return $options;
}
function spam_CheckAdminOptions(){
if ($_GET['action'] == 'spam'){spam_AdminOptions();}
}
function spam_AdminOptions(){
global $PHP_SELF;
echoheader('options', 'Spam');
$barword = new PluginSettings('BarWord');
$buffer = '<table border=0 cellpading=0 cellspacing=0 width="645">
<table border=0 cellpading=0 cellspacing=0 width="645" >
<form method=post action="'.$PHP_SELF.'?mod=options&action=spam">
<td width=321 height="33"><b>Add a word</b>
<table border=0 cellpading=0 cellspacing=0 width=379 class="panel" cellpadding="7" >
<tr>
<td width=79 height="25"> Word:
<td width=300 height="25">
<input type="text" name="add_badword"> <input type="submit" value="Add to list">
</tr>
</form>
</table>
<tr>
<td width=654 height="11">
<img height=20 border=0 src="skins/images/blank.gif" width=1>
</tr><tr>
<td width=654 height=14>
<b>Spam list</b>
</tr>
<tr>
<td width=654 height=1>
<table width=641 height=100% cellspacing=2 cellpadding=2>
<tr>
<td width=260 class="panel"><b>Word</b></td>
<td width=140 class="panel"> <b>Action</b></td>
</tr>';
if ($words = $barword->settings){
foreach($words as $key => $bad){
$i++;
if ($i%2 == 0){$bg = ' class="enabled"';}
else {$bg = ' class="disabled"';}
if ($bad){$buffer .= '<tr'.$bg.'><td>'.$bad.'<td><a href="'.$PHP_SELF.'?mod=options&action=spam&subaction=remove&id='.$key.'">[Remove]</a>';}
}
}
$buffer .= '</table></table>';
if ($_POST['add_badword']){
$barword -> settings[] = strtolower($_POST['add_badword']);
$barword -> save();
$buffer = 'The word was added!<br><br><a href="'.$PHP_SELF.'?mod=options&action=spam">Back to the list</a>';
}
if ($_GET['subaction'] == 'remove'){
unset($barword -> settings[$_GET['id']]);
$barword -> save();
$buffer = 'The word was removed from the list!<br><br><a href="'.$PHP_SELF.'?mod=options&action=spam">Back to the list</a>';
}
echo $buffer;
echofooter();
}
?> |
_________________
 |
|
| Sun Apr 08, 2007 1:58 pm |
|
 |
Jorioz
Joined: 15 Aug 2006 Posts: 31 Location: Holland |
|
|
|
The comment (with spam) is placed, and i get this again:
 |  | Warning: preg_match() [function.preg-match]: Compilation failed: missing terminating ] for character class at offset 6 in c:\domains\musicincontrol.nl\wwwroot\cms\plugins\spam.php on line 25
Warning: preg_match() [function.preg-match]: Compilation failed: missing terminating ] for character class at offset 6 in c:\domains\musicincontrol.nl\wwwroot\cms\plugins\spam.php on line 25 |
_________________ Take a look at my CuteNews.RU based website:
MUSIC IN CONTROL . NL |
|
| Sun Apr 08, 2007 4:29 pm |
|
 |
|