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 

Private Comments Hack
Goto page 1, 2, 3, 4  Next
 
Post new topic   Reply to topic    boardom Forum Index -> Hacks
View previous topic :: View next topic  
Author Message
Cyberian75



Joined: 26 Sep 2002
Posts: 1007
Location: Washington

PostPosted: Tue Sep 23, 2003 6:21 am    Post subject: Private Comments Hack Reply with quote

Since a friend of mine asked me to create this hack, I thought I would share it. Basically, with the "private comment" checked, the comment will only go to the owner of that blog and not shown publicly.

This hack requires a modification to the comments table of the b2 database.

You can get the hack from here. Smile
_________________
Michael P.


Last edited by Cyberian75 on Fri May 07, 2004 2:30 am; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website AIM Address
Tang-on



Joined: 14 Aug 2003
Posts: 22

PostPosted: Tue Sep 23, 2003 6:24 am    Post subject: Reply with quote

Page not found.
_________________
-Tang-on Smile
Back to top
View user's profile Send private message Visit poster's website
Tang-on



Joined: 14 Aug 2003
Posts: 22

PostPosted: Tue Sep 23, 2003 6:25 am    Post subject: Reply with quote

Oopss... sorry.. my mistake. Smile
_________________
-Tang-on Smile
Back to top
View user's profile Send private message Visit poster's website
epolady



Joined: 30 Jul 2002
Posts: 800
Location: Texas

PostPosted: Tue Sep 23, 2003 8:00 am    Post subject: Reply with quote

Hi Michael,

I left a comment on your blog, but I had a question. I didn't want to spam your comments, so I'll ask here. What does the comments page look like after someone has sent a private comment? Does it not show the private comment at all? Or does it give some indication that "this comment is viewable by the admin only" to the general public.

The reason I ask is that I don't generally log into my admin panel to read comments, I view them straight from the site, so I want to see if there are any private comments then I can view them via the admin panel.

Thanks & keep up the awesome work! Smile
_________________
No more support from me. Goodbye!
Go upgrade to WordPress, you'll find better support there.
Back to top
View user's profile Send private message
Cyberian75



Joined: 26 Sep 2002
Posts: 1007
Location: Washington

PostPosted: Tue Sep 23, 2003 4:08 pm    Post subject: Reply with quote

Epolady,

Private comments are not displayed at all. I thought this made more sense since comments are e-mailed to you anyway. I'm going to revise the hack so that it will say the comments are private or not when they are e-mailed to you.

Smile
_________________
Michael P.
Back to top
View user's profile Send private message Visit poster's website AIM Address
Cyberian75



Joined: 26 Sep 2002
Posts: 1007
Location: Washington

PostPosted: Tue Sep 23, 2003 4:53 pm    Post subject: Reply with quote

Revised. Smile
_________________
Michael P.
Back to top
View user's profile Send private message Visit poster's website AIM Address
epolady



Joined: 30 Jul 2002
Posts: 800
Location: Texas

PostPosted: Tue Sep 23, 2003 7:33 pm    Post subject: Reply with quote

Actually, I don't read comments via email. I turned notification off (never had it on, really).
_________________
No more support from me. Goodbye!
Go upgrade to WordPress, you'll find better support there.
Back to top
View user's profile Send private message
Viper007Bond



Joined: 15 Aug 2003
Posts: 266
Location: Portland, Oregon, USA

PostPosted: Tue Sep 23, 2003 11:57 pm    Post subject: Reply with quote

I agree. It'd be nice if it would display the comment, but not the contents and instead just say "Private Comment" and even a link to read it (that takes you to the read comments in the admin panel).
_________________
http://www.viper007bond.com

If you haven't already installed b2, I advise you look into WordPress or b2evo instead as b2 is dead.
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Cyberian75



Joined: 26 Sep 2002
Posts: 1007
Location: Washington

PostPosted: Wed Sep 24, 2003 1:09 am    Post subject: Reply with quote

I don't know about that one, because I think it beats the purpose of the comment being private. If I were to send a private comment, I wouldn't want any trace of it being displayed on the comments page.

Nevertheless, if there are enough requests for such a feature, I will revise the hack. Meanwhile, please put up with the inconvenience and turn on the comment notification.
_________________
Michael P.
Back to top
View user's profile Send private message Visit poster's website AIM Address
Cyberian75



Joined: 26 Sep 2002
Posts: 1007
Location: Washington

PostPosted: Wed Sep 24, 2003 1:55 am    Post subject: Reply with quote

By the way, if you don't want to receive your own comments from your blog when e-mail notification is turned on, locate the following line in b2comments.post.php file:

Code:

@mail($recipient, $subject, $notify_message, "From: b2@".$HTTP_SERVER_VARS['SERVER_NAME']."\r\n"."X-Mailer: b2 $b2_version - PHP/" . phpversion());


And replace it with:

Code:

if ($recipient <> $email) {
   @mail($recipient, $subject, $notify_message, "From: b2@".$HTTP_SERVER_VARS['SERVER_NAME']."\r\n"."X-Mailer: b2 $b2_version - PHP/" . phpversion());
}


So, as long as you use the e-mail you put in your profile, you won't receive your own comments on your blog.
_________________
Michael P.
Back to top
View user's profile Send private message Visit poster's website AIM Address
Cyberian75



Joined: 26 Sep 2002
Posts: 1007
Location: Washington

PostPosted: Wed Sep 24, 2003 3:33 am    Post subject: Reply with quote

Epolady and Viper007Bond,

I have revised the hack to display a message and a direct link to the comment in the b2edit page. You still have to modify b2comment.post.php file, but you must not change the SQL syntax for the comments page.

It's documented in the instruction. Smile
_________________
Michael P.
Back to top
View user's profile Send private message Visit poster's website AIM Address
Reese



Joined: 07 Sep 2002
Posts: 60

PostPosted: Wed Sep 24, 2003 4:51 pm    Post subject: Reply with quote

I'm going to try and install this later on, when I'm thinking more clearly. That'll probably require a pot of coffee.

Thanks for writing this hack. Smile
_________________
---
Back to top
View user's profile Send private message Visit poster's website AIM Address
billy



Joined: 05 Jul 2003
Posts: 40

PostPosted: Sat Sep 27, 2003 6:15 pm    Post subject: Reply with quote

Hi i just tryed to install this hack and when i tryed to test it i got:
Quote:
There is an error with the database, it can't store your comment...
Contact the webmaster
Back to top
View user's profile Send private message
Cyberian75



Joined: 26 Sep 2002
Posts: 1007
Location: Washington

PostPosted: Sat Sep 27, 2003 6:20 pm    Post subject: Reply with quote

Do you have any other hack installed for the comments? That error could occur if the SQL INSERT syntax in b2comments.post.php file is wrong.
_________________
Michael P.
Back to top
View user's profile Send private message Visit poster's website AIM Address
billy



Joined: 05 Jul 2003
Posts: 40

PostPosted: Sat Sep 27, 2003 6:27 pm    Post subject: Reply with quote

i don't think i've installed any hacks that have to do with comments before, here's my b2comments.post.php file:
Code:
<?php

# if you want to change the paths here, remember to put your new path BEFORE $b2inc,
#  like this: "b2/$b2inc/b2functions.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_GET_VARS    = add_magic_quotes($HTTP_GET_VARS);
   $HTTP_POST_VARS   = add_magic_quotes($HTTP_POST_VARS);
   $HTTP_COOKIE_VARS = add_magic_quotes($HTTP_COOKIE_VARS);
}

$author = trim($HTTP_POST_VARS["author"]);
$email = 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"];
$comment_private = $HTTP_POST_VARS["comment_private"];


if ($require_name_email && ($email == "" || $email == "@" || $author == "" || $author == "name")) { //original fix by Dodo, and then Drinyth
   echo "Error: please fill the required fields (name, email)";
   exit;
}
if ($comment == "comment" || $comment == "") {
   echo "Error: please type a comment";
   exit;
}

$user_ip = $HTTP_SERVER_VARS['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);
if (strlen($email) < 6) {
   $email = '';
}
$url = trim(strip_tags($url));
$url = ((!stristr($url, '://')) && ($url != '')) ? 'http://'.$url : $url;
if (strlen($url) < 7) {
   $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);

/* flood-protection */
$query = "SELECT * 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) < 30)
      $ok=0;
}
/* end flood-protection */

if ($ok) {

   $query = "INSERT INTO $tablecomments VALUES ('0','$comment_post_ID','$author','$email','$url','$user_ip','$now','$comment','0','$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>");

   if ($comments_notify) {

      $notify_message  = "New comment on your post #$comment_post_ID.\r\n\r\n";
      
if ($comment_private) {
   $comment_private_yesno = 'yes';
}
else {
   $comment_private_yesno = 'no';
}
      $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 .= "comment: \n".stripslashes($original_comment)."\r\n\r\n";
      $notify_message .= "You can see all comments on this post there: \r\n";
      $notify_message .= $siteurl.'/'.$blogfilename.$querystring_start.'p'.$querystring_equal.$comment_post_ID.$querystring_separator.'c'.$querystring_equal.'1'."\r\n\r\n";
 
      $postdata = get_postdata($comment_post_ID);
      $authordata = get_userdata($postdata["Author_ID"]);
      $recipient = $authordata["user_email"];
      $subject = "comment on post #$comment_post_ID \"".$postdata["Title"]."\"";

      @mail($recipient, $subject, $notify_message, "From: b2@".$HTTP_SERVER_VARS['SERVER_NAME']."\r\n"."X-Mailer: b2 $b2_version - PHP/" . phpversion());
      
   }

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

   header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
   header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
   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 {
   die("Sorry, you can only post a new comment every 30 seconds");
}

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

 
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