boardom Forum Index boardom
b2 message board
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How to avert SPAM bots
Goto page Previous  1, 2, 3, 4, 5, 6, 7, 8, 9
 
Post new topic   Reply to topic    boardom Forum Index -> Hacks
View previous topic :: View next topic  
Author Message
turtelina



Joined: 25 Jan 2002
Posts: 45
Location: Austria

PostPosted: Sun Jan 09, 2005 11:16 am    Post subject: Reply with quote

Hi Michael,

Just some feedback again because I am so fed up with all of these comment spam preventions on Wordpress blogs. Argh!!!!

Thank you for helping us protect our blog without all these things that drive regular commenters insane!

People always ask me why I stick to b2 and dont make the switch. It is because I have everything that I need, thanks to you.

And that was the word for this Sunday.

Cool
Back to top
View user's profile Send private message Visit poster's website
Cyberian75



Joined: 26 Sep 2002
Posts: 1285
Location: Oregon

PostPosted: Sun Jan 09, 2005 6:04 pm    Post subject: Reply with quote

Have you tried Spam Karma for WordPress, Connie? It seems to most effective.
_________________
Michael P.

Back to top
View user's profile Send private message AIM Address
turtelina



Joined: 25 Jan 2002
Posts: 45
Location: Austria

PostPosted: Sun Jan 09, 2005 6:17 pm    Post subject: Reply with quote

Oh thanks Michael, no, I am very happy!

I just wanted to stress how much I appreciate your work, and how much I am annoyed by the spam hacks that a lot of Wordpress users are using, because I cant leave a comment anywhere without being transferred to a pay page, or being told my comment is spam. It was driving me insane this morning, so I thought I must tell you how much I prefer your hacks (and therefore b2).

I cant blame anyone really, noone like spam, but as for hacks, yours are much better, and commenter friendly. Razz

Sorry, so confusing.
Back to top
View user's profile Send private message Visit poster's website
Cyberian75



Joined: 26 Sep 2002
Posts: 1285
Location: Oregon

PostPosted: Sun Jan 09, 2005 6:26 pm    Post subject: Reply with quote

Pay page???

Thanks! Smile
_________________
Michael P.

Back to top
View user's profile Send private message AIM Address
BDKR



Joined: 04 Jan 2003
Posts: 27
Location: Clearwater, Florida

PostPosted: Sat Jan 15, 2005 9:48 pm    Post subject: Reply with quote

Cyberian75 wrote:
BDKR wrote:
Awesome! Please let me know when you're done. Smile


It incorporates a few of my "hacks," though. You want to see a copy of it?


Hey! Sorry it took so long to get back here, but yes, it would be cool to see a copy!
Back to top
View user's profile Send private message Visit poster's website AIM Address MSN Messenger
Cyberian75



Joined: 26 Sep 2002
Posts: 1285
Location: Oregon

PostPosted: Sat Jan 15, 2005 10:12 pm    Post subject: Reply with quote

Here it is... Smile

Code:

<?php
require("b2config.php");
require("$b2inc/b2template.functions.php");
include("$b2inc/b2vars.php");
include("$b2inc/b2functions.php");

dbconnect();

function add_magic_quotes($array) {
   foreach ($array as $k => $v) {
      if (is_array($v)) {
         $array[$k] = add_magic_quotes($v);
      } else {
         $array[$k] = addslashes($v);
      }
   }
   return $array;
}

if (!get_magic_quotes_gpc()) {
   $HTTP_POST_VARS   = add_magic_quotes($HTTP_POST_VARS);
}

$author = trim($HTTP_POST_VARS["author"]);
$email = strtolower(trim($HTTP_POST_VARS["email"]));
$url = trim($HTTP_POST_VARS["url"]);
$comment = trim($HTTP_POST_VARS["comment"]);
$original_comment = $comment;
$comment_autobr = $HTTP_POST_VARS["comment_autobr"];
$comment_post_ID = $HTTP_POST_VARS["comment_post_ID"];
$notify = $HTTP_POST_VARS["notifyme"];
$ccounter = $HTTP_POST_VARS["ccounter"];
$comment_private = $HTTP_POST_VARS["comment_private"];

/* spam-protection */
$postdata = get_postdata($comment_post_ID);
$words = Array("blackjack","casino","debt","free","gambling","payday","poker","phentermine","morgage");

foreach ($words AS $word) {
   if (eregi("<\ *a\ *href\ *\=.*".$word.".*>", $comment)) {
      $spamcount++;
   }

}

if ($HTTP_POST_VARS["verify"] <> md5($postdata["Title"]) || empty($postdata["ID"]) || $postdata["CloseComment"] == 1 || $spamcount > 0) {
   mysql_query("INSERT INTO $tableblacklist (IP,name,URL) VALUES ('$REMOTE_ADDR','$author','$url')");
   exit("Your comment has been filtered as a SPAM!");
}
/* end spam-protection */

if ($require_name_email && (empty($email) || $email == "@" || empty($author) || $author == "name")) {
   echo "Error: please fill the required fields (name and e-mail).";
   echo "\n<br><br>\n<a href=\"javascript:history.go(-1);\">go back</a>\n\n";
   exit;
}
if ($require_name_email && (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$", $email))) {
   echo "Error: e-mail address is mal-formed.";
   echo "\n<br><br>\n<a href=\"javascript:history.go(-1);\">go back</a>\n\n";
   exit;
}
if ($comment == "comment" || empty($comment)) {
   echo "Error: please type a comment.";
   echo "\n<br><br>\n<a href=\"javascript:history.go(-1);\">go back</a>\n\n";
   exit;
}

$user_ip = $REMOTE_ADDR;
$user_domain = gethostbyaddr($user_ip);
$time_difference = get_settings("time_difference");
$now = date("Y-m-d H:i:s",(time() + ($time_difference * 3600)));

$author = strip_tags($author);
$email = strip_tags($email);
$url = trim(strip_tags($url));
if (!eregi("^(http:\/\/)?([0-9a-z-]+\.)*([0-9a-z-]{1,61})(\.[a-z]{2,6})(\.[a-z]{2})?", $url)) {
   $url = '';
}
$comment = strip_tags($comment, $comment_allowed_tags);
$comment = balanceTags($comment, 1);
$comment = convert_chars($comment);
$comment = format_to_post($comment);

$comment_author = $author;
$comment_author_email = $email;
$comment_author_url = $url;

$author = addslashes($author);
$email = addslashes($email);
$url = addslashes($url);

/* blacklist */
eregi("([0-9a-z-]+\.)*([0-9a-z-]{1,61})(\.[a-z]{2,6})(\.[a-z]{2})?", $url, $matches);
$url_array = explode(".", $matches[0]);

switch (count($url_array)) {
   case 2:
      $url_append = $url_array[0];
      break;
   case 3:
      $url_append = $url_array[1];
      break;
   case 4:
      $url_append = $url_array[1].".".$url_array[2];
      break;
   default:
      $url_append = $matches[0];
      break;
}

$blquery = "SELECT ID FROM $tableblacklist WHERE IP='$user_ip'";
if (!empty($matches[0])) {
   $blquery .= " OR URL LIKE '%$url_append%'";
}
$blquery .= " ORDER BY ID DESC LIMIT 1";
$blresult = mysql_query($blquery);

if (mysql_num_rows($blresult)) {
   exit("You're banned from leaving comments on this blog!");
}
/* end blacklist */

/* flood-protection */

$query = "SELECT comment_date FROM $tablecomments WHERE comment_author_IP='$user_ip' ORDER BY comment_date DESC LIMIT 1";
$result = mysql_query($query);
$ok=1;
if (!empty($result)) {
   while($row = mysql_fetch_object($result)) {
      $then=$row->comment_date;
   }
   $time_lastcomment=mysql2date("U","$then");
   $time_newcomment=mysql2date("U","$now");
   if (($time_newcomment - $time_lastcomment) < 15)
      $ok=0;
}
/* end flood-protection */

if ($ok) {
   $query = "INSERT INTO $tablecomments VALUES ('0','$comment_post_ID','$author','$email','$url','$user_ip','$now','$comment','0','$notify', '$comment_private')";
   $result = mysql_query($query);
   if (!$result) {
      die ("There is an error with the database, it can't store your comment...<br>Contact the <a href=\"mailto:$admin_email\">webmaster</a>");
   }
   
   $comment_ID = mysql_insert_id();

   if ($comments_notify) {
      if ($notify == 1) {
         $notify_yesno = 'yes';
      }
      else {
         $notify_yesno = 'no';
      }
   
   if ($comment_private) {
      $comment_private_yesno = 'yes';
   }
   else {
      $comment_private_yesno = 'no';
   }

      $notify_message  = "New comment on your post #$comment_post_ID.\r\n\r\n";
      $notify_message .= "author  : $comment_author (IP: $user_ip -- $user_domain)\r\n";
      $notify_message .= "e-mail  : $comment_author_email\r\n";
      $notify_message .= "url     : $comment_author_url\r\n";
      $notify_message .= "private : $comment_private_yesno\r\n";
      $notify_message .= "notify  : $notify_yesno\r\n";
      $notify_message .= "comment : \n".stripslashes($original_comment)."\r\n\r\n";
      $notify_message .= "You can see all comments on this post here: \r\n";
      $notify_message .= $siteurl.'/b2edit.php'.$querystring_start.'p'.$querystring_equal.$comment_post_ID.'&c'.$querystring_equal.'1'.'&more'.$querystring_equal.'1&blogonly=1#c'.$comment_ID;

      $authordata = get_userdata($postdata["Author_ID"]);
      $recipient = $authordata["user_email"];
      $subject = "comment on post #$comment_post_ID \"".stripslashes($postdata["Title"])."\"";
      
      if ($recipient <> $comment_author_email) {
         @mail($recipient, $subject, $notify_message, "From: ".$comment_author." <".$comment_author_email.">\r\n"."X-Mailer: b2 $b2_version - PHP/" . phpversion());
      }

      // "Notify Me" hack by Michael H. Park (http://www.MichaelPark.net)
      if ($ccounter > 0 && $comment_private == 0) {
         $notify_comment  = "There's a new comment on post #$comment_post_ID.\r\n\r\n";
         $notify_comment .= "author : $comment_author\r\n";
         $notify_comment .= "url    : $comment_author_url\r\n";
         $notify_comment .= "comment: \n".stripslashes($original_comment)."\r\n\r\n";
         $notify_comment .= "You can reply via here:\r\n";
         $notify_comment .= $siteurl.'/'.$blogfilename.$querystring_start.'p'.$querystring_equal.$comment_post_ID.'&c'.$querystring_equal.'1&blogonly=1#c'.$comment_ID;

         // get e-mails of all commenters with "notify me" turned on for a particular post
         $nquery = " SELECT DISTINCT comment_author_email, comment_notify " .
                 " FROM $tableposts LEFT JOIN $tablecomments ON ID = comment_post_id " .
                 " WHERE ID = '$comment_post_ID' AND comment_notify = 1 " .
                 " ORDER BY comment_ID DESC";

         $nresult = mysql_query($nquery) or die(mysql_error());
         
         while ($row = mysql_fetch_array($nresult)) {
            $commenter_email = $row["comment_author_email"];
            $comment_notify = $row["comment_notify"];
            
            // e-mail out the new comment except to the current commenter
            if ($commenter_email <> $email) {
               @mail($commenter_email, $subject, $notify_comment, "From: ".$comment_author." <".$comment_author_email.">\r\n"."X-Mailer: b2 $b2_version - PHP/" . phpversion());
            }
            
            // update the "notify me" status if it's been changed since the last comment by the same commenter
            elseif ($commenter_email == $email && $comment_notify <> $notify) {
               $nupdate = mysql_query("UPDATE $tablecomments " .
                                 " SET comment_notify = '$notify' " .
                                 " WHERE comment_post_id = '$comment_post_ID' AND comment_author_email = '$email' ")
                                 or die(mysql_error());
   
               $stat_message = "Your notification status has been changed.\r\n";
               $stat_subject = "Your notification status for post #$comment_post_ID \"".$postdata["Title"]."\"";
   
               @mail($commenter_email, $stat_subject, $stat_message, "From: b2@".$HTTP_SERVER_VARS['SERVER_NAME']."\r\n"."X-Mailer: b2 $b2_version - PHP/" . phpversion());
            }
         }
      } // end hack
   }

   if (empty($email)) {
      $email = " "; // this to make sure a cookie is set for 'no email'
   }
   if (empty($url)) {
      $url = " "; // this to make sure a cookie is set for 'no url'
   }
   if (empty($notify)) {
      $notify = 0;
   }
   
   setcookie("comment_author",$author, time()+30000000, "/", ".michaelpark.net");
   setcookie("comment_author_email",$email, time()+30000000, "/", ".michaelpark.net");
   setcookie("comment_author_url",$url, time()+30000000, "/", ".michaelpark.net");
   setcookie("comment_author_notify",$notify, time()+30000000, "/", ".michaelpark.net");

   header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
   header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
   header("content-type: text/html;charset=iso-8859-I");
   header("Cache-Control: no-cache, must-revalidate");
   header("Pragma: no-cache");

   $location = (!empty($HTTP_POST_VARS['redirect_to'])) ? $HTTP_POST_VARS['redirect_to'] : $HTTP_SERVER_VARS["HTTP_REFERER"];
   if ($is_IIS) {
      header("Refresh: 0;url=$location");
   } else {
      header("Location: $location");
   }
} else {
   echo "Sorry, you can only post a new comment every 15 second.";
   echo "\n<br><br><a href=\"javascript:history.go(-1);\">go back</a>\n\n";
   die();
}
?>

_________________
Michael P.

Back to top
View user's profile Send private message AIM Address
Display posts from previous:   
Post new topic   Reply to topic    boardom Forum Index -> Hacks All times are GMT + 1 Hour
Goto page Previous  1, 2, 3, 4, 5, 6, 7, 8, 9
Page 9 of 9

 
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


Powered by phpBB 2 © 2001, 2002 phpBB Group