Forum Index
RegisterSearchFAQMemberlistUsergroupsLog in
Removing SPAM ;)

 
Reply to topic    Forum Index » Suggestions View previous topic
View next topic
Removing SPAM ;)
Author Message
scottdallas



Joined: 04 May 2006
Posts: 1943
Location: US

Post Removing SPAM ;) Reply with quote
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 Wink This is saving me from getting thousands of spams on my sites.

_________________
www.scottdizzle.com uses cnr Smile
last update: 07-22-08: 8:30 pm
Tue Mar 20, 2007 9:08 am View user's profile Send private message Visit poster's website AIM Address
Guest








Please login to hide the ads.

Heya Im Me



Joined: 01 Feb 2006
Posts: 189

Post Reply with quote
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 View user's profile Send private message
scottdallas



Joined: 04 May 2006
Posts: 1943
Location: US

Post Reply with quote
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 Smile
last update: 07-22-08: 8:30 pm
Wed Apr 04, 2007 1:24 pm View user's profile Send private message Visit poster's website AIM Address
Jorioz



Joined: 15 Aug 2006
Posts: 31
Location: Holland

Post Reply with quote
simple way to stop it indeed, i'll give it a try Smile

_________________
Take a look at my CuteNews.RU based website:

MUSIC IN CONTROL . NL
Wed Apr 04, 2007 4:26 pm View user's profile Send private message Visit poster's website
Jorioz



Joined: 15 Aug 2006
Posts: 31
Location: Holland

Post Reply with quote
maybe you could help me out with this:



when trying to post an url, i get this:



Code:
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:



Code:
<?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&amp;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&amp;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">&nbsp;Word:

           <td width=300 height="25">

           <input type="text" name="add_badword">&nbsp;&nbsp;<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">&nbsp;<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&amp;action=spam&amp;subaction=remove&amp;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&amp;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&amp;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 View user's profile Send private message Visit poster's website
Jorioz



Joined: 15 Aug 2006
Posts: 31
Location: Holland

Post Reply with quote
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 View user's profile Send private message Visit poster's website
Ramon



Joined: 12 Oct 2005
Posts: 473
Location: Hoogeveen, NL

Post Reply with quote
What version of PHP do you have running?

_________________
Sat Apr 07, 2007 4:09 pm View user's profile Send private message Visit poster's website
scottdallas



Joined: 04 May 2006
Posts: 1943
Location: US

Post Reply with quote
I never had a problem with the plugin and I'm no PHP expert to know why you're having the problem Sad I'm sorry. It just works for me.

_________________
www.scottdizzle.com uses cnr Smile
last update: 07-22-08: 8:30 pm
Sat Apr 07, 2007 7:25 pm View user's profile Send private message Visit poster's website AIM Address
Jorioz



Joined: 15 Aug 2006
Posts: 31
Location: Holland

Post Reply with quote
Ramon wrote:
What version of PHP do you have running?




Check here: http://musicincontrol.nl/phpinfo.php

_________________
Take a look at my CuteNews.RU based website:

MUSIC IN CONTROL . NL
Sat Apr 07, 2007 9:21 pm View user's profile Send private message Visit poster's website
Ramon



Joined: 12 Oct 2005
Posts: 473
Location: Hoogeveen, NL

Post Reply with quote
So you have musicincontrol running on a local server?



Anyways -> Try this



Code:
<?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&amp;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&amp;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">&nbsp;Word:

           <td width=300 height="25">

           <input type="text" name="add_badword">&nbsp;&nbsp;<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">&nbsp;<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&amp;action=spam&amp;subaction=remove&amp;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&amp;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&amp;action=spam">Back to the list</a>';

   }



   echo $buffer;



   echofooter();

}

?>


_________________
Sat Apr 07, 2007 11:17 pm View user's profile Send private message Visit poster's website
Jorioz



Joined: 15 Aug 2006
Posts: 31
Location: Holland

Post Reply with quote
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 View user's profile Send private message Visit poster's website
Ramon



Joined: 12 Oct 2005
Posts: 473
Location: Hoogeveen, NL

Post Reply with quote
Code:
<?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&amp;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&amp;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">&nbsp;Word:

           <td width=300 height="25">

           <input type="text" name="add_badword">&nbsp;&nbsp;<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">&nbsp;<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&amp;action=spam&amp;subaction=remove&amp;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&amp;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&amp;action=spam">Back to the list</a>';

   }



   echo $buffer;



   echofooter();

}

?>


_________________
Sun Apr 08, 2007 1:58 pm View user's profile Send private message Visit poster's website
Jorioz



Joined: 15 Aug 2006
Posts: 31
Location: Holland

Post Reply with quote
The comment (with spam) is placed, and i get this again:



Code:
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 View user's profile Send private message Visit poster's website
Display posts from previous:    
Reply to topic    Forum Index » Suggestions All times are GMT + 1 Hour
Page 1 of 1

 
Jump to: 
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 can download files in this forum



Powered by phpBB © 2001, 2005 phpBB Group
Design by Freestyle XL / Music Lyrics.