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 Previous  1, 2, 3, 4, 5, 6
 
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: Thu Dec 30, 2004 12:08 pm    Post subject: Reply with quote

I thought that might happen as you'd put the full URL elsewhere in b2allcomments.php, but I thought it best to try one thing at a time!
You have higher up in b2allcomments.php than what you changed before:
Code:
<a href="http://www.aeternam626.com/b2/<?php echo $PHP_SELF."?search=".$search."&action=deletecomment" ?>" onclick="return confirm('You are about to delete all comments containing \'<?php echo $search ?>\'\nCancel to stop, OK to delete')">Delete all comments including '<?php echo $search ?>'</a>
Replace it by
Code:
<a href="<?php echo "b2allcomments.php?search=".$search."&action=deletecomment" ?>" onclick="return confirm('You are about to delete all comments containing \'<?php echo $search ?>\'\nCancel to stop, OK to delete')">Delete all comments including '<?php echo $search ?>'</a>
(I hope that's correct!)
and I hope that search will then work properly.
Back to top
View user's profile Send private message
lynn



Joined: 04 Jul 2003
Posts: 66
Location: USA

PostPosted: Thu Dec 30, 2004 1:59 pm    Post subject: Reply with quote

Nope. Still doesn't work.
Back to top
View user's profile Send private message Visit poster's website
stevem



Joined: 15 Mar 2003
Posts: 365

PostPosted: Thu Dec 30, 2004 2:08 pm    Post subject: Reply with quote

lynn wrote:
Nope. Still doesn't work.
That's because it solves a future problem not the one you have at the moment
OK. In the line
Code:
<form method="post" action="<?php echo $PHP_SELF ?>">

replace it by
Code:
<form method="post" action="<?php echo 'b2allcomments.php' ?>">
Back to top
View user's profile Send private message
lynn



Joined: 04 Jul 2003
Posts: 66
Location: USA

PostPosted: Thu Dec 30, 2004 6:36 pm    Post subject: Reply with quote

YAHOOOOOOO! It works!!!!

So far I've only tested it with three comments I posted with a made up word. I had started a search on the word "holdem" and thought it would be a good idea to let the page finish loading before I hit delete and twenty minutes later it was still loading (that's how much spam I have!) when we had one of those minor power failures that last only long enough to restart the PC and mess up all the digital clocks in the house

But the important thing is IT WORKS! THANK YOU! THANK YOU! THANK YOU! THANK YOU! THANK YOU!

(You guys are not rid of me yet though. When I have time after all the deleting there are a few other things I need to make work.)
Back to top
View user's profile Send private message Visit poster's website
stevem



Joined: 15 Mar 2003
Posts: 365

PostPosted: Thu Dec 30, 2004 7:04 pm    Post subject: Reply with quote

Fantastic! If you have thousands of spam with the same search word you can limit how many are shown each time which saves time waiting for very long pages to load. BUT when you click on "Delete all comments including ..." it will still delete ALL of them.

So, suppose you only want to show the first 100 comments (you can choose any number you like) then
Code:
$queryc = "SELECT * FROM $tablecomments WHERE comment_content NOT LIKE '%<trackback />%' AND comment_content LIKE '%$search%' ORDER BY comment_date DESC";

should be changed to
Code:
$queryc = "SELECT * FROM $tablecomments WHERE comment_content NOT LIKE '%<trackback />%' AND comment_content LIKE '%$search%' ORDER BY comment_date DESC LIMIT 100";

All that's changed is adding (space) LIMIT 100 near the end of that line. Then you'll only see the first 100 comments but will delete all 1000 comments (or whatever) when you click on "Delete all comments including 'holdem'"
Back to top
View user's profile Send private message
stevem



Joined: 15 Mar 2003
Posts: 365

PostPosted: Thu Dec 30, 2004 7:35 pm    Post subject: Update to b2allcomments.php Reply with quote

Here's an update to b2allcomments.php which will allow you to choose to show only a certain number of comments. It should be emphasised that "Delete all ..." will still delete ALL searched for comments even if not shown.
This is useful if you have thousands of spam comments which you want to delete.

(Lynn don't bother with this update since it doesn't have the changes you needed to make it work for your case. Just use the code change in the previous post )

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> !");

   if ($search!="") {
      $query = "DELETE FROM $tablecomments WHERE comment_content NOT LIKE '%<trackback />%' AND comment_content LIKE '%$search%'";
   } else {
      $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>
   <link rel="stylesheet" href="<?php echo $b2inc; ?>/b2.css" type="text/css">
   <title>Comments</title>
</head><body>
<h2><?php if ($search!="") {
      echo "Comments including '$search'";
   } else {
      echo "All Comments";
   }
   if ($lim) {
      echo " (only most recent $lim comments shown)";
   }  ?>
</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 />

<form method="post" action="<?php echo $PHP_SELF ?>">
<input type=submit name="submit" value="Show comments with" class="search">
<input type=text name="search">    

<?php
   if ($lim) {$qlim=" LIMIT ".$lim;} else {$qlim="";}
   $queryc = "SELECT * FROM $tablecomments WHERE comment_content NOT LIKE '%<trackback />%' AND comment_content LIKE '%$search%' ORDER BY comment_date DESC".$qlim;
   $resultc = mysql_query($queryc);

if ($search!="" && mysql_num_rows($resultc)>0) { ?>
<a href="<?php echo $PHP_SELF."?search=".$search."&action=deletecomment" ?>" onclick="return confirm('You are about to delete ALL comments containing \'<?php echo $search ?>\'\nCancel to stop, OK to delete')">Delete all comments including '<?php echo $search ?>'</a>
<?php if ($lim) {echo "<br />Please note that only the most recent $lim comments are shown but ALL will be deleted";}?>
<?php } ?>
<br />Maximum number of most recent comments to show (leave empty to show all comments)
<input type=text name="lim" size="5" value=<?php echo $lim ?>>
</form><br /><br />

<?php
   if ($resultc) {

 // 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)."\'\\nCancel 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>
Back to top
View user's profile Send private message
lynn



Joined: 04 Jul 2003
Posts: 66
Location: USA

PostPosted: Fri Dec 31, 2004 2:18 am    Post subject: Reply with quote

I am afraid to mess with success.
Back to top
View user's profile Send private message Visit poster's website
stevem



Joined: 15 Mar 2003
Posts: 365

PostPosted: Sat Jan 22, 2005 6:40 pm    Post subject: Reply with quote

Another update which searches the 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> !");

   if ($search!="") {
      $query = "DELETE FROM $tablecomments WHERE comment_content NOT LIKE '%<trackback />%' AND (comment_content LIKE '%$search%' OR comment_author_url LIKE '%$search%' OR comment_author LIKE '%$search%')";
   } else {
      $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>
   <link rel="stylesheet" href="<?php echo $b2inc; ?>/b2.css" type="text/css">
   <title>Comments</title>
</head><body>
<h2><?php if ($search!="") {
      echo "Comments including '$search'";
   } else {
      echo "All Comments";
   }
   if ($lim) {
      echo " (only most recent $lim comments shown)";
   }  ?>
</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 />

<form method="post" action="<?php echo $PHP_SELF ?>">
<input type=submit name="submit" value="Show comments with" class="search">
<input type=text name="search">    

<?php
   if ($lim) {$qlim=" LIMIT ".$lim;} else {$qlim="";}
   $queryc = "SELECT * FROM $tablecomments WHERE comment_content NOT LIKE '%<trackback />%' AND (comment_content LIKE '%$search%' OR comment_author_url LIKE '%$search%' OR comment_author LIKE '%$search%') ORDER BY comment_date DESC".$qlim;
   $resultc = mysql_query($queryc);

if ($search!="" && mysql_num_rows($resultc)>0) { ?>
<a href="<?php echo $PHP_SELF."?search=".$search."&action=deletecomment" ?>" onclick="return confirm('You are about to delete ALL comments containing \'<?php echo $search ?>\'\nCancel to stop, OK to delete')">Delete all comments including '<?php echo $search ?>'</a>
<?php if ($lim) {echo "<br />Please note that only the most recent $lim comments are shown but ALL will be deleted";}?>
<?php } ?>
<br />Maximum number of most recent comments to show (leave empty to show all comments)
<input type=text name="lim" size="5" value=<?php echo $lim ?>>
</form><br /><br />

<?php
   if ($resultc) {

 // 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)."\'\\nCancel 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>
Back to top
View user's profile Send private message
Lalika



Joined: 27 Jan 2005
Posts: 1

PostPosted: Thu Jan 27, 2005 11:34 pm    Post subject: Really banging my head here.. Reply with quote

Thank you so so much for creating this, it seems like a beacon of light from a sea of headaches.

I'm freaking out over two problems I'm having and will sing songs in your honor for any help. Before I get into them I'll add that I've read through the boards and php help resoources and still don't see what my problem is. I wouldn't ask if I really wasn't super frustrated and just can't figure the dumb thing out. Ok, here goes:

A. I can't get any link to the allcomments page onto my menu top. It makes no sense to me why, everything seems to be in their right places..

So I just go directly to allcomments.php and..

B. I'm not deleting multiples. I have an excruiciating amount of spam and when I search - delete I go to my 404 page. When I search to see if possibly the spam was really deleted and just isn't showing up here... well it's not been deleted. I'm going to cry if I have to really individually delete each of these.

C is simply that I'd like to remove the drop down question of are-you-sure-you-want-to-delete-this/these and I seem to not be removing the right code as it's ignoring me.

In fact, I can't seem to make even the slightest little changes to allcomments, just as a test. I'm just..flabberasted. I really thought i was getting a handle on all this and then... well yea.

So after all that, any ideas?
Back to top
View user's profile Send private message Visit poster's website
stevem



Joined: 15 Mar 2003
Posts: 365

PostPosted: Fri Jan 28, 2005 8:14 pm    Post subject: Reply with quote

A. When you put the line into b2menutop.txt did you make sure you used a tab between the 3 arts
Code:
8   b2allcomments.php   All Comments

you must use tabs between 8 and b2allcomments.php and between b2allcomments.php and All Comments. Don't use spaces because it won't work.
If you aren't sure how to insert a tab, copy and paste from the other lines.

B. Do you have any
Code:
$PHP_SELF
in the code? You said it worked before if you changed it to
Code:
b2allcomments.php


C. Just remove
Code:
onclick="return confirm('You are about to delete ALL comments containing \'<?php echo $search ?>\'\nCancel to stop, OK to delete')"
for multiple deletes or
Code:
onclick=\"return confirm('You are about to delete this comment by \'".htmlentities($commentauthor)."\'\\nCancel to stop, OK to delete.')\"
for single deletes. BUT be careful, if you click on the wrong thing the comment will be gone for ever.
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 Previous  1, 2, 3, 4, 5, 6
Page 6 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