PDA

View Full Version : Automatic Zero-Reply Pruning


Revan
03-30-2005, 10:00 PM
This hack was requested by T3MEDIA here (https://vborg.vbsupport.ru/showthread.php?t=79062).


What this hack does:

Runs a cronjob every 15 days, deleting threads with zero replies
Uses vBulletin own thread deletion function. Accept no BS ;)
Rebuilds forum counters after thread deletion. Clean!


Well thats about it :)

kall
03-31-2005, 05:39 PM
Odd... your php file seems to be a ph p file.

:)

tnguy3n
03-31-2005, 05:44 PM
I'd look to thread table, and check for dateline = lastpost date. If they'r the same, then prune the thread (excepts for ones of admins). ;)

edit: nvm me. lol

Revan
03-31-2005, 06:37 PM
Odd... your php file seems to be a ph p file.

:)Reupped the attachment, and it stays that. It looks fine in Edit Post and on my desktop tho... :ermm:

Marco van Herwaarden
03-31-2005, 07:31 PM
Looks like a ph p file here also. But saving as php, strange.

T3MEDIA
04-02-2005, 01:04 PM
Question does it have usergroup permision? Thank you btw.
edit just looked it over. It does.

Bounce
04-17-2005, 10:06 PM
has anyone installed this ?

what will happen if I install it with 137,000 posts on my forumjust now...

will it delete the current 0 reply's ??? or will it only be from when I install it :nervous:

Bounce
04-18-2005, 07:56 PM
It says I have an error

Fatal error: Call to undefined function: delete_thread() in /var/www/html/forum/includes/cron/deletezerothreads.php on line 49

line 49 is:- "delete_thread($threads['threadid'], 1, $deletetype, $delinfo);"

I uploaded to /var/www/html/forum/includes/cron/ ???? :ermm: Is this right??

Marco van Herwaarden
04-18-2005, 08:31 PM
How are you running it? By directly going to the URL?

Bounce
04-18-2005, 08:32 PM
How are you running it? By directly going to the URL?

in admin cp

scheduled tasks "RUN NOW"
then the error comes up :rolleyes:

Edit:-I've took a screenie of it..am thinking its a typo in the file..I uploaded in ANSI

Revan
04-19-2005, 06:15 PM
try adding this right above the $prunedthreads query start:
require_once('./includes/functions_databuild.php');

Bounce
04-19-2005, 06:17 PM
try adding this right above the $prunedthreads query start:
require_once('./includes/functions_databuild.php');

ok thanks,before I do will this change my forums post counts..

as per "Rebuilds forum counters after thread deletion. Clean!"

Ideally I would want the users to have the same postcount,there an awful moany bunch lol

Bounce
04-19-2005, 10:50 PM
Worked a treat https://vborg.vbsupport.ru/external/2005/04/3.gif



thank you for a great hack, just a little Question

If I change the WHERE `replycount` = '0' to "1" will it work in the same way ?

Revan
04-20-2005, 05:52 AM
1. Im not sure if it changes the USERs postcounts, but it changes the FORUMs.
2. If you do that change, it will prune all threads where replies is EXACTLY 1. IE not 0 or 2, but 1.
If you want it to prune threads where reply count is 1 or less, then do WHERE `replycount`<= '1'

Bounce
04-20-2005, 02:26 PM
1. Im not sure if it changes the USERs postcounts, but it changes the FORUMs.
2. If you do that change, it will prune all threads where replies is EXACTLY 1. IE not 0 or 2, but 1.
If you want it to prune threads where reply count is 1 or less, then do WHERE `replycount`<= '1'


Brilliant stuff Revan,well done,works great,changes post count and forum stats,

Not to worry thou i'm happy with it...

Thanks again :up:

T3MEDIA
04-20-2005, 02:48 PM
Minor snag...

Some fourms have news areas and articles. where no one posts.
Could this have a tiny mod to ignore these forum id's?

Revan
04-21-2005, 10:40 AM
Add a variable like so:
$ignoreids = '4, 5, 6, 7, 8'; // or whatever your ignore ids is
change the SQL
WHERE `replycount` = '0' AND `forumid` NOT IN($ignoreids)

That should work OK. It is important that the variable has comma seperated values tho, else the SQL will complain.
You might want to try running the script right after applying the changes to test it, instead of not seeing the errors and thinking it runs OK ;)

T3MEDIA
04-21-2005, 11:00 AM
Add a variable like so:
$ignoreids = '4, 5, 6, 7, 8'; // or whatever your ignore ids is
change the SQL
WHERE `replycount` = '0' AND `forumid` NOT IN($ignoreids)

That should work OK. It is important that the variable has comma seperated values tho, else the SQL will complain.
You might want to try running the script right after applying the changes to test it, instead of not seeing the errors and thinking it runs OK ;)Thaaan-Q!

almqdad
05-04-2005, 09:27 AM
great hack

djr
05-06-2005, 03:04 AM
I must be pretty stupid, but I made a modification of this cron job to prune closed threads (not sticky) and I just can't get them to delete :'(

Any help would be appreciated!

<?php
/*================================================= =====================*\
|| ################################################## ################## ||
|| # vBulletin 3.0.7 - Licence Number
|| # ---------------------------------------------------------------- # ||
|| # Copyright ?2000?2005 Jelsoft Enterprises Ltd. All Rights Reserved. ||
|| # This file may not be redistributed in whole or significant part. # ||
|| # ---------------- VBULLETIN IS NOT FREE SOFTWARE ---------------- # ||
|| # http://www.vbulletin.com | http://www.vbulletin.com/license.html # ||
|| ################################################## ################## ||
\*================================================ ======================*/

// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);

if (!is_object($DB_site))
{
exit;
}

// ##########
// # Config #
// ##########
// Enter the forum id's of the forums to prune here
$forumpruneids = '27,28,29';

// Set this to 1 if you want to remove the threads physically, 0 to soft delete
$deletetype = 0;

// The deletion info, for DB inserts
$delinfo = array('userid' => $bbuserinfo['userid'], 'username' => $bbuserinfo['username'], 'reason' => 'Auto-Pruned Thread');
// ##############
// # End Config #
// ##############

require_once('./includes/functions_databuild.php');

$prunedthreads = $DB_site->query("SELECT * FROM " . TABLE_PREFIX . "thread WHERE open = 0 AND sticky != 1 AND forumid IN ($forumpruneids)");
while ($threads = $DB_site->fetch_array($prunedthreads))
{
delete_thread($threads['threadid'], 1, $deletetype, $delinfo);
build_forum_counters($threads['forumid']);
echo "Pruned Thread: $threads[threadid]<br />";
}

log_cron_action('Threads Pruned.', $nextitem);
/*================================================= =====================*\
|| ################################################## ##################
|| # Created: 4:15, Fri May 6th 2005
|| # CVS: $RCSfile: deleteclosed.php,v $ - $Revision: 1.00 $
|| ################################################## ##################
\*================================================ ======================*/
?>