View previous topic :: View next topic |
Author |
Message |
stevem
Joined: 15 Mar 2003 Posts: 365
|
Posted: Thu Dec 30, 2004 12:08 pm Post subject: |
|
|
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 |
|
 |
lynn
Joined: 04 Jul 2003 Posts: 66 Location: USA
|
Posted: Thu Dec 30, 2004 1:59 pm Post subject: |
|
|
Nope. Still doesn't work. |
|
Back to top |
|
 |
stevem
Joined: 15 Mar 2003 Posts: 365
|
Posted: Thu Dec 30, 2004 2:08 pm Post subject: |
|
|
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 |
|
 |
lynn
Joined: 04 Jul 2003 Posts: 66 Location: USA
|
Posted: Thu Dec 30, 2004 6:36 pm Post subject: |
|
|
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 |
|
 |
stevem
Joined: 15 Mar 2003 Posts: 365
|
Posted: Thu Dec 30, 2004 7:04 pm Post subject: |
|
|
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 |
|
 |
stevem
Joined: 15 Mar 2003 Posts: 365
|
Posted: Thu Dec 30, 2004 7:35 pm Post subject: Update to b2allcomments.php |
|
|
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 |
|
 |
lynn
Joined: 04 Jul 2003 Posts: 66 Location: USA
|
Posted: Fri Dec 31, 2004 2:18 am Post subject: |
|
|
I am afraid to mess with success. |
|
Back to top |
|
 |
stevem
Joined: 15 Mar 2003 Posts: 365
|
Posted: Sat Jan 22, 2005 6:40 pm Post subject: |
|
|
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 |
|
 |
Lalika
Joined: 27 Jan 2005 Posts: 1
|
Posted: Thu Jan 27, 2005 11:34 pm Post subject: Really banging my head here.. |
|
|
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 |
|
 |
stevem
Joined: 15 Mar 2003 Posts: 365
|
Posted: Fri Jan 28, 2005 8:14 pm Post subject: |
|
|
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 in the code? You said it worked before if you changed it to
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 |
|
 |
|