 |
 |
 |
 |
 |
| Author |
Message |
kirby145

Joined: 08 Sep 2007 Posts: 36 Location: look behind you |
|
Improved Spam list plugin |
|
This is a very small improvement but definately a time saver. Now on the spam word blocker plugin when you add or remove a word, you don't have to go through another page to continue. This just keeps it all on one page and makes a little message telling you if it worked.
Simply paste this in /plugins/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 = '<p>Word successfully added!</p><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>';}
}
}
}
if ($_GET['subaction'] == 'remove'){
unset($barword -> settings[$_GET['id']]);
$barword -> save();
$buffer = '<p>The word was removed from the list!</p><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>';}
}
}
}
echo $buffer;
echofooter();
}
?> |
I'm not a php expert but I was able to figure this little trick out 
|
|
| Sat Sep 15, 2007 4:57 am |
|
 |
Guest
|
|
|
Please login to hide the ads.
|
|
|
|
 |
kirby145

Joined: 08 Sep 2007 Posts: 36 Location: look behind you |
|
|
| Sat Sep 15, 2007 4:57 am |
|
 |
D72

Joined: 22 Feb 2007 Posts: 217 Location: NL |
|
|
|
But does it actually improve the current spam plugin? Or is this just a timesaver to add and remove spam words?
I think the current spam plugin is not "Spam Proof" at all. I use at several websites, a guestbook by a comment page and after a couple of weeks, the spam bots find their way to my guestbook and ahve to setup a standalone guestbook.
So if this is really an improved spam plugin...
Please tell us.
|
|
| Mon Oct 01, 2007 12:45 pm |
|
 |
kirby145

Joined: 08 Sep 2007 Posts: 36 Location: look behind you |
|
|
|
Nope just a timesaver sorry. I'm sure next version will improve some of its spam blocking though.
|
|
| Wed Oct 03, 2007 4:04 am |
|
 |
D72

Joined: 22 Feb 2007 Posts: 217 Location: NL |
|
|
|
that's a shame. I used your code anyway and waiting patiently for a improved spam blocker
i hate spam!
|
|
| Sat Oct 06, 2007 1:13 am |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum
|
|
 |
 |
 |
|