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 

List of all comments
Goto page 1, 2, 3, 4, 5, 6  Next
 
Post new topic   Reply to topic    boardom Forum Index -> Hacks
View previous topic :: View next topic  
Author Message
stevem



Joined: 15 Mar 2003
Posts: 365

PostPosted: Sun Oct 31, 2004 5:32 pm    Post subject: List of all comments Reply with quote

If you want to stop spammers then use Cyberian's Comment Blacklist or How to avert SPAM bots.

It is useful to have a list of all the comments on your blog in case there is some old spam to weed out or you want IP addresses to add to the blacklist. The following code will list all the comments (from new to old) and also allow you to quickly delete them. Put it in a file called something like b2allcomments.php and make a link in b2menutop.txt. It can only be seen by logged-in users at level 8 or above but change that if you wish on line 12

16 Nov: Updated version can be found here This allows you to search for and delete comments with certain words
30 Dec: Another update here which allows you to show only the most recent posts in case you have thousands of them
22 Jan: Update here to search commenter's name and URL as well as the comment itself


Code:
<?php

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

dbconnect();
get_currentuserinfo();

if (!($user_login)) exit;
if ($user_level<8) exit;

if ($action=='deletecomment') {
    $standalone = 1;
   require_once("./b2header.php");

   if ($user_level == 0)
      die ("Cheatin' uh ?");

   $comment = $HTTP_GET_VARS['comment'];
   $p = $HTTP_GET_VARS['p'];
   $commentdata=get_commentdata($comment) or die("Oops, no comment with this ID. <a href=\"$PHP_SELF\">Go back</a> !");

   $query = "DELETE FROM $tablecomments WHERE comment_ID=$comment";
   $result = mysql_query($query) or die("Oops, no comment with this ID. <a href=\"$PHP_SELF\">Go back</a> !");

   header ("Location: $PHP_SELF");
}

?>
<html>
<head>
   <style type="text/css" media="screen">
   @import url( layout2b.css );
   </style>
   <title>Comments</title>
</head><body>
<h2>Comments</h2>

<div id="contentcomments">
<div class="storyContent">
<div><b><span style="color: #0099CC">::</span> <a href="index.php">return to the blog</a></b>    <a href="b2edit.php">:: return to edit</a></div>
<br /><br />
<?php
   $queryc = "SELECT * FROM $tablecomments WHERE comment_content NOT LIKE '%<trackback />%' ORDER BY comment_date DESC";
   $resultc = mysql_query($queryc);
   if ($resultc) {
?>

<?php // these lines are b2's motor, do not delete
   while($rowc = mysql_fetch_object($resultc)) {
       $commentdata = get_commentdata($rowc->comment_ID);
       $posting = $rowc->comment_post_ID;
       $commentauthor = $rowc->comment_author;
        $postdata = get_postdata($posting);
?>

      <p>
      <b><?php comment_author() ?></b> ( <?php comment_author_email_link() ?>
        <?php if(comment_author_url_link()=="") {$slash="";} else {$slash="/";} echo " $slash"; ?>
         <?php comment_author_url_link() ?> ) (IP: <?php comment_author_IP() ?>)
       <?php comment_date('D j M Y') ?> @ <?php comment_time('g:i a') ?>
      <?php
         echo " [ <a href=\"$PHP_SELF?action=deletecomment&p=".$postdata["ID"]."&comment=".$commentdata["comment_ID"]."\" onclick=\"return confirm('You are about to delete this comment by \'".htmlentities($commentauthor)."\'\\n  \'Cancel\' to stop, \'OK\' to delete.')\">Delete Comment</a> ]";
         ?><br />
         Comment was made in <b>
         <?php the_title() ?> <?php echo $the_date ?> @ <?php the_time('g:i a') ?></b><br /><br />
           <?php comment_text() ?>
           <br /><br /></p>

<?php //end of the loop, don't delete
}
}
?>
<br /><br />
<div><b><span style="color: #0099CC">::</span> <a href="index.php">return to the blog</a></b>    <a href="b2edit.php">:: return to edit</a></div>
</div></div>
</body>
</html>


Last edited by stevem on Sat Jan 22, 2005 6:41 pm; edited 8 times in total
Back to top
View user's profile Send private message
Sigg3



Joined: 03 Jul 2003
Posts: 898
Location: Oslo, Norway

PostPosted: Mon Nov 01, 2004 12:20 pm    Post subject: Reply with quote

Superb. I've been waiting for something like this:)

I'll make a b2 ant-SPAM package for the Cafelog resource center.

But first, I'll have lunch:)
_________________
Sigg3.net - You know you're worth it! | b2 Cafelog Resource Center | Fight my BattleImp!
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Sigg3



Joined: 03 Jul 2003
Posts: 898
Location: Oslo, Norway

PostPosted: Wed Nov 03, 2004 4:52 pm    Post subject: Reply with quote

OOOOPS!

I get a 404.
Comments.php doesn't exist. If it's b2comments.php, then I get "Please don't load page directly." Is it b2allcomments.php?
_________________
Sigg3.net - You know you're worth it! | b2 Cafelog Resource Center | Fight my BattleImp!
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
stevem



Joined: 15 Mar 2003
Posts: 365

PostPosted: Wed Nov 03, 2004 6:18 pm    Post subject: Reply with quote

Whoops sorry ! I called mine comments.php and so hard-coded it into the file. Either call the file comments.php or change the lines so that comments.php become b2allcomments.php:
Code:
header ("Location: comments.php");
to
Code:
header ("Location: $PHP_SELF");

and
Code:
echo " [ <a href=\"comments.php?action=deletecomment&p=".$postdata["ID"]."&comment=".$commentdata["comment_ID"]."\" onclick=\"return confirm('You are about to delete this comment by \'".htmlentities($commentauthor)."\'\\n  \'Cancel\' to stop, \'OK\' to delete.')\">Delete Comment</a> ]";
to
Code:
echo " [ <a href=\"$PHP_SELF?action=deletecomment&p=".$postdata["ID"]."&comment=".$commentdata["comment_ID"]."\" onclick=\"return confirm('You are about to delete this comment by \'".htmlentities($commentauthor)."\'\\n  \'Cancel\' to stop, \'OK\' to delete.')\">Delete Comment</a> ]";

I'll change it in the original posting. Thanks Smile


Last edited by stevem on Thu Nov 04, 2004 8:48 pm; edited 1 time in total
Back to top
View user's profile Send private message
Sigg3



Joined: 03 Jul 2003
Posts: 898
Location: Oslo, Norway

PostPosted: Thu Nov 04, 2004 9:47 am    Post subject: Reply with quote

Cheers.
_________________
Sigg3.net - You know you're worth it! | b2 Cafelog Resource Center | Fight my BattleImp!
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Cyberian75



Joined: 26 Sep 2002
Posts: 1283
Location: Oregon

PostPosted: Thu Nov 04, 2004 8:24 pm    Post subject: Reply with quote

Code:
header ("Location: comments.php");
to
Code:
header ("Location: $PHP_SELF");

_________________
Michael P.

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



Joined: 15 Mar 2003
Posts: 365

PostPosted: Thu Nov 04, 2004 8:48 pm    Post subject: Reply with quote

Smile
Back to top
View user's profile Send private message
DruidX



Joined: 22 Jul 2004
Posts: 6
Location: UK

PostPosted: Fri Nov 05, 2004 8:25 pm    Post subject: Reply with quote

Umm, Maybe I'm insane or something, but I don't seem to be able to delete comments using this. I cut-n-pasted the code as shown and made the appropriate link, but I when I click 'delete comment' and then refresh the page it doesn't show the comment as being deleted. I was wondering if it doesn't acctually delete the comments or if one has to do somthing extra to make them go away.

I've recently been attacked by 5 spam bots, and need this feature!
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Cyberian75



Joined: 26 Sep 2002
Posts: 1283
Location: Oregon

PostPosted: Fri Nov 05, 2004 8:56 pm    Post subject: Reply with quote

All the necessary codes seem to be in place, though.
_________________
Michael P.

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



Joined: 15 Mar 2003
Posts: 365

PostPosted: Fri Nov 05, 2004 9:33 pm    Post subject: Reply with quote

Yes it does delete the comments. The code is the same as that which is already supplied to delete a comment. Have you checked by looking at the post with the comment that the comment has been deleted? Can you delete a comment in the ordinary way in the Post/Edit window?
Back to top
View user's profile Send private message
Sigg3



Joined: 03 Jul 2003
Posts: 898
Location: Oslo, Norway

PostPosted: Tue Nov 09, 2004 10:43 am    Post subject: Reply with quote

Suggestion: a multiple delete function (check-boxes) and search tool?
I've about 400 comments making the job a pit one-sided.

I know wildcard searches can be done in mysql, but isn't there a way to implement this into the view all script?
_________________
Sigg3.net - You know you're worth it! | b2 Cafelog Resource Center | Fight my BattleImp!
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
stevem



Joined: 15 Mar 2003
Posts: 365

PostPosted: Tue Nov 09, 2004 3:27 pm    Post subject: Reply with quote

It should be possible to implement both of those though it may be the end of the week before I get the free time to do it.
Back to top
View user's profile Send private message
DruidX



Joined: 22 Jul 2004
Posts: 6
Location: UK

PostPosted: Wed Nov 10, 2004 12:21 am    Post subject: Reply with quote

Humm, it seems to have worked now, how very odd. Maybe for some reason it wasn't refreshing properly and I was looking at the cach or... Oh I don't know. I'm just happy that it has worked. Yay, no more evil spam Smile
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Sigg3



Joined: 03 Jul 2003
Posts: 898
Location: Oslo, Norway

PostPosted: Wed Nov 10, 2004 9:24 am    Post subject: Reply with quote

Be careful what you say, druidX, 'cause the second we grow stronger Spammers find new ways:p

Sigg3.net Policy on SPAMMERS
_________________
Sigg3.net - You know you're worth it! | b2 Cafelog Resource Center | Fight my BattleImp!
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
DruidX



Joined: 22 Jul 2004
Posts: 6
Location: UK

PostPosted: Wed Nov 10, 2004 6:59 pm    Post subject: Reply with quote

I suppose, but there will also always be nice people like you to help the rest of us protect ourselves Very Happy
Back to top
View user's profile Send private message Send e-mail Visit poster's website
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, 5, 6  Next
Page 1 of 6

 
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