View Full Version : Auto Prune Threads
Andreas
11-01-2005, 10:00 PM
<font size="3">Auto Prune Threads</font>
Description
This hack gives you the ability to specify if you want to have
threads pruned from a forum after x days.
The amount of days can be set separately for each forum in forum manager.
Details
1 Product XML (3 Plugins, 1 Phrase)
Compatibility Note vBulletin 3.7
As of vBulletin 3.7 Beta 4, the hook used for this Mod does not exist any longer.
After installting this Mod, please change the Hook location to cron_script_cleanup_hourly
sitka
11-02-2005, 01:36 AM
looks cool will try out
Hi Andreas,
Is it also possible to have a Product for 'Auto Prune Closed Threads' please?
Acido
11-02-2005, 02:59 AM
looks cool will try out
Big Thanx ! I really need this tool.
Snake
11-02-2005, 06:43 AM
Nice one Kirby. :)
D@nny
11-02-2005, 09:44 AM
cool! I'm happy. :nervous:
nexialys
11-02-2005, 11:04 AM
AH HA... i knew it.. .lol
mcncyo
11-02-2005, 12:29 PM
I will install this one soon at my site.
Cyricx
11-02-2005, 03:43 PM
If I'm looking at the code right, if I set the prune to 0 it will never prune posts in that forum correct?
And does this prune threads that are sticky as well? I would love for this not to prune sticky threads.
Thanks bro!
trancetopia
11-02-2005, 05:08 PM
I really need this too :) Very BIG thanks for this.
SkyShadow
11-05-2005, 05:06 PM
Hello Andreas,
if I set the prune to 0 it will never prune posts in that forum correct?
Thanks for your support
VBUsers
11-05-2005, 06:54 PM
can i use this with 3.5.1?
steadicamop
11-12-2005, 09:39 AM
can i use this with 3.5.1?
It works in 3.5.1 - just tested it.
Small thing though, only a spelling mistake - in the AdminCP -> Forums -> Forum Manager (the whichever forum), it says "Stetting" instead of "Setting" - nothing major but thought I'd point it out.
Cracking idea though, thanks handy little extra!
Easily fixed ... just go to Search Phrases, search for "Stetting", and just change it .... like I said not a bug, just wanted to help :)
fn9mm
11-22-2005, 05:14 AM
Got big problems after a week with this plugin using 351
Only after a week cause that's the prune-delay i set for one forum,...
all my links to threads caused blank pages (page not found in IE)
even the non pruned threads
couldn't access admincp neither
got this error amongst others :
invalid argument for *** includes/init.php on line 67
forgot what *** was, sry
any ideas?
Andreas
11-22-2005, 05:22 AM
Yes, that the error is not caused by this Hack.
EricR
11-23-2005, 04:08 PM
And does this prune threads that are sticky as well? I would love for this not to prune sticky threads.
Out of the box this will prune stickies. To change this, go to your Plugin Manager and edit "Auto-Prune Threads".
Find this (appears only once):
sticky IN (0,1)
and change it to this
sticky != 1
Now stickies will be immune to the auto-prune.
For anyone upgrading from the 3.0 version, Andreas helped me through this and I posted instructions in the old 3.0 auto-prune (https://vborg.vbsupport.ru/showpost.php?p=813666&postcount=16) post.
Thanks again Andreas!
Vtec44
11-23-2005, 06:05 PM
installed! :D Thanks Andreas
Flow Fusion
11-27-2005, 02:15 PM
Thanks...!
Julie
12-16-2005, 12:05 PM
Howdy!
Is there a way to code in a, only prune X number of threads? Because once I pruned around 100 threads, with 100, 000 or so posts, and I... uhm... broke the server :P So I want to be a little carefull with that thing now :P Hehe... So what I'm looking for is:
A script that will prune X number of threads (and their posts, doesn't matter how many posts belong to them though) each sunday, at X hour (f.ex 4am server time) ... Possible?
Thanks :D
svoec
12-19-2005, 03:28 PM
This is one cool hack -- something VB has needed for a while --
Thanks so much --
Just one question -- what triggers the prune ? I don't see it listed in the scheduled tasks?
thanks
Wild Bronco
01-11-2006, 01:38 PM
Will it work on 3.5.3?
EricR
01-12-2006, 09:15 PM
This is one cool hack -- something VB has needed for a while --
Thanks so much --
Just one question -- what triggers the prune ? I don't see it listed in the scheduled tasks?
thanks
For 3.5, auto-prune is part of the hourly cleanup #1 in case you ever want to run it manually.
Will it work on 3.5.3?
hah ? works ?
PIKenPIK
01-31-2006, 11:43 AM
Great :)
set a forum on 1 day ... now let's see over 86.400 secs :D
DeanoG
04-26-2006, 04:08 PM
Great Hack Thanks ... Seems to work on v3.5.4
Konstantinos
05-03-2006, 02:37 PM
is there any prune users after not visiting the forum for X days ?
Eagle Creek
05-03-2006, 07:50 PM
Great!
Just what I was looking for :bunny:
Thx.
Eagle Creek
05-16-2006, 05:47 PM
What about sticky threads?
teedizz
05-17-2006, 08:33 PM
what does prune mean? delete?
Eagle Creek
05-17-2006, 09:37 PM
what does prune mean? delete?
Yes.
Will this Autoprune decrement users posts counts?
With the built in vBulletin prune, post counts aren't affected until "update counters" is ran for the post count.
I need to make sure it won't modify post counts unless I choose to run "update counters".
Thanks
Shazz
06-29-2006, 03:40 PM
If it does prune , and the thread counted in posts. And it got Pruned" would the posts count go down for the users?
________
cheap glass bongs (http://glassbongs.org/)
Will this Autoprune decrement users posts counts?
With the built in vBulletin prune, post counts aren't affected until "update counters" is ran for the post count.
I need to make sure it won't modify post counts unless I choose to run "update counters".
Thanks
Does anyone know?
SCRIPT3R
07-19-2006, 03:58 PM
Will this Autoprune decrement users posts counts?
With the built in vBulletin prune, post counts aren't affected until "update counters" is ran for the post count.
I need to make sure it won't modify post counts unless I choose to run "update counters".
Thanks
it shouldn't affect your user's post count's unless you "update counters"... but stranger things have happened.
Shazz
07-19-2006, 04:11 PM
It dosent?
Ive ran test of this prune etc.
No ones post ever changed.
________
Chrysler BR platform (http://www.dodge-wiki.com/wiki/Chrysler_BR_platform)
egyptsons
07-19-2006, 08:31 PM
great ;)
I want this one :)
Does the prune ignore sticky threads?
Marris
08-11-2006, 12:00 PM
Will this work with 3.6?
Viol8or
08-29-2006, 11:40 AM
Can anyone confirm this working under 3.6 or is there an alternative?
Acido
08-29-2006, 01:25 PM
working perfect in 3.6 :)
Quarterbore
08-29-2006, 07:55 PM
Does this physically remove the old threads from the database? Does the line of code that says "delete_thread($thread['threadid'], false, true, NULL, false, $thread);" use the built in vBulletin functions to remove the thread and posts?
Can someone help me find the "delete_thread" function?
Please confirm just what this script does...
Thanks!
EDIT:
OK, I think I figured out what this calls but it will take me some time to figure the code out.. I assume this is using the class_dm_threadpost.php file to handle the removal of the thread and that it will also remove the posts and that these removals are by removal or the rows of data from the database...
:alien:
adusei
09-14-2006, 03:32 PM
Hi,
tried this hack - and nothing happened :confused:
Ok, read the small text in the forum manager again, and it says:
"will automatically prune all Threads from this Forum where the last reply is older then the set amount of days"
A-HA! So, if I have threads WITHOUT any replies they won't be deleted. Is that right?
How can the code be changed to enable the pruning of threads without replies older than x days??? Possible?
TIA and best regards,
adusei
coffee
11-17-2006, 10:10 PM
Adusie,
Open the xml file and Edit line #27, by replacing where it says: "lastpost" with "dateline".
Then import the product with: "Allow Overwrite" option enabled.
btw, Working perfect in 3.6.3
TsirhCitna
12-25-2006, 02:12 PM
Does this work on sub-forums too?
As in will the setting it to prune on the parent effect the child forums too?
Does anyone know the function to move a thread? I rather have it move all the threads to a dedicated forum, then I can manually prune that single forum when my server is offline, since pruning is extremly CPU intensive when pruning thousands of threads.
I would like to change this:
delete_thread($thread['threadid'], false, true, NULL, false, $thread);
To move the thread to a dedicated forumID, that I use as a recycle bin.
Sir_Yaro
04-09-2007, 06:19 PM
works for 3.6.5:D
xrayeramy
04-10-2007, 05:24 AM
Anyone willing to hold a n00bs hand? I would love to use this to delete all threads in one forum at midnight each night. I need explicit instructions though, not just a bunch of code. Tell me where to put it, copy this, paste here, change this....and I can fly with it. But just giving me code...I'm lost.
MikeWarner
04-11-2007, 11:51 AM
Yes - over night (once a day) seems like a better idea than runing an intensive script like this each hour. How please? Thanks.
unnpro
05-07-2007, 08:03 AM
Yes - over night (once a day) seems like a better idea than runing an intensive script like this each hour. How please? Thanks.
- Disable or remove "Auto-Prune Threads" plugin in the plugin section
- Upload in your cron dir (includes/cron/) a php file (e.g. autoprune.php) with this code:
<?php
error_reporting(E_ALL & ~E_NOTICE);
if (!is_object($vbulletin->db))
{
exit;
}
require_once(DIR . '/includes/functions_databuild.php');
$forums = $vbulletin->db->query_read("SELECT forumid, pruneafter FROM " . TABLE_PREFIX . "forum WHERE pruneafter > 0");
while ($forum = $vbulletin->db->fetch_array($forums))
{
$threads = $vbulletin->db->query_read("SELECT threadid, forumid, visible, open, pollid, title FROM " . TABLE_PREFIX . "thread WHERE forumid=$forum[forumid] AND visible IN (0,1,2) AND sticky != 1 AND lastpost <= " . (TIMENOW - ($forum['pruneafter'] * 86400)));
while ($thread = $vbulletin->db->fetch_array($threads))
{
delete_thread($thread['threadid'], false, true, NULL, false, $thread);
}
build_forum_counters($forum['forumid']);
}
log_cron_action('Forums pruned', $nextitem);
?>- Create a new cronjob that runs autoprune.php whenever you want
That's all :)
DieselMinded
07-06-2007, 01:51 PM
Is there a better version for this? 3.6.7 ?
Does anyone know the function to move a thread? I rather have it move all the threads to a dedicated forum, then I can manually prune that single forum when my server is offline, since pruning is extremly CPU intensive when pruning thousands of threads.
I would like to change this:
delete_thread($thread['threadid'], false, true, NULL, false, $thread);
To move the thread to a dedicated forumID, that I use as a recycle bin.
Anyway I can do this?
Thanks
DeanoG
07-30-2007, 10:08 AM
Works on version 3.6.8
junkeeper
08-08-2007, 08:22 AM
- Disable or remove "Auto-Prune Threads" plugin in the plugin section
- Upload in your cron dir (includes/cron/) a php file (e.g. autoprune.php) with this code:
<?php
error_reporting(E_ALL & ~E_NOTICE);
if (!is_object($vbulletin->db))
{
exit;
}
require_once(DIR . '/includes/functions_databuild.php');
$forums = $vbulletin->db->query_read("SELECT forumid, pruneafter FROM " . TABLE_PREFIX . "forum WHERE pruneafter > 0");
while ($forum = $vbulletin->db->fetch_array($forums))
{
$threads = $vbulletin->db->query_read("SELECT threadid, forumid, visible, open, pollid, title FROM " . TABLE_PREFIX . "thread WHERE forumid=$forum[forumid] AND visible IN (0,1,2) AND sticky != 1 AND lastpost <= " . (TIMENOW - ($forum['pruneafter'] * 86400)));
while ($thread = $vbulletin->db->fetch_array($threads))
{
delete_thread($thread['threadid'], false, true, NULL, false, $thread);
}
build_forum_counters($forum['forumid']);
}
log_cron_action('Forums pruned', $nextitem);
?>- Create a new cronjob that runs autoprune.php whenever you want
That's all :)
Hi,
I'm just curious, how to specify the x days for each forum like the one in Forum Manager since the plugin has already been disabled or removed ?
I'm still stuck here.
wtf you lose your forum posts ammount
Andreas
02-10-2008, 08:58 AM
Yes - over night (once a day) seems like a better idea than runing an intensive script like this each hour. How please? Thanks.
If you run in only once/day, the amount of threads to delete is higher, eg. the script runs longer.
That's the reason why it is (by default) executed every hour, as this keeps the amount small.
wtf you lose your forum posts ammount
What else did you expect?
Pruned posts/threads are gone - forever.
mariocaz
02-21-2008, 05:04 PM
Is this work fine in 3.6.8 ?, because I installed it and set it in a specific forum that I want to delete all the threads that are 30 days old or more, but nothing happened the old threads still there in that forum.
Or only works since now for the future threads that will be in that forum ?
Mario
coffee
04-09-2008, 09:26 AM
Compatibilitty note vBulletin 3.7
As of vBulletin 3.7 Beta 4, the hook used for this Mod does not exist any longer.
After installting this Mod, please change the Hook location to cron_script_cleanup_hourly
Thank you for the update!
todosbaneados
04-20-2008, 02:36 PM
This mod works in vbulletin 3.7.0?
coffee
04-24-2008, 01:09 PM
Yes it does!
One thing you need to do is to change the hook location as mentioned above.
mariocaz
05-21-2008, 12:02 AM
and how can I change the hook ???, help!!
sdsvtdriver
05-21-2008, 11:45 PM
after installing into 3.5.4 I get this error message when I attempt to set the number of days on a forum:
Fatal error: Field pruneafter is not defined in $validfields in class vB_DataManager_Forum in includes\class_dm.php on line 485
Nogura
05-23-2008, 10:32 AM
and how can I change the hook ???, help!!
In your admin panel, go to Plugins & Products and then Plugin Manager. Select Edit on Auto-Prune Threads and select cron_script_cleanup_hourly from the drop-down box.
mariocaz
05-23-2008, 11:28 PM
Thank you very much Nogura!!
I did it, so I hope with this the mod works again perfectly.
sdsvtdriver
06-17-2008, 07:03 AM
after installing into 3.5.4 I get this error message when I attempt to set the number of days on a forum:
Any ideas?
This appears to be the only autoprune for 3.5.4 and I run an NNTP gateway which fills up fast. :)
sdsvtdriver
06-26-2008, 09:18 AM
anyone? :(
sdsvtdriver
06-30-2008, 08:46 AM
I had to manually add:
'pruneafter' => array(TYPE_UINT, REQ_NO),
in
./includes/class_dm_forum.php
the plugin
$this->validfields['pruneafter'] = array(TYPE_UINT, REQ_NO);
should have done the same thing, but didn't. Ideas?
isearchclick
08-02-2008, 12:06 AM
Andreas, i have uploaded your hack for auto prune i want to know if set to 0 will it delete threads or posts and if i just want the hack to delete thread say every 30 days will it do this no matter wheather the threads have replies or not please advise?
Tony
HI! is this hack will be released for 3.7-3.8?
creativepart
03-03-2009, 06:30 PM
Is there any reason it has to use cron_cleanup_hourly? Could it be set to cron_cleanup_daily and run only once per day?
Dimoks
05-21-2009, 06:58 AM
Hi
Please help me... I need mod for auto delete thread after X day... but amount of days set separately for each thread.
swapps
06-03-2009, 11:50 AM
Installed @ Vbulletin 3.8.1
Changed hook to "cron_script_cleanup_hourly1"
Works! Thx!
Darthvader2007
06-06-2009, 11:33 AM
I need this mod for auto prune topic's that cleanup by ( topic start date ) and not by ( last reply date )
Can someone help me please ??
Vbulletin 3.8.1
SBlueman
06-06-2009, 08:48 PM
Is there a SQL query to auto update the length of time for all your forums without having to go and edit each forum?
Darthvader2007
06-10-2009, 11:31 AM
I need this mod for auto prune topic's that cleanup by ( topic start date ) and not by ( last reply date )
Can someone help me please ??
Vbulletin 3.8.1
Nobody ?
Or is there a better MOD for vBulletin 3.8 ?
SirHappy
06-20-2009, 03:18 PM
thx. works in 3.8.3.
xlguy
08-17-2009, 10:37 AM
I need this mod for auto prune topic's that cleanup by ( topic start date ) and not by ( last reply date )
Can someone help me please ??
Vbulletin 3.8.1
Yes I'd also like this modification, let me know if you find anything.
appsfinder
01-31-2010, 09:43 AM
howdo i do this please change the Hook location to cron_script_cleanup_hourly
plus i cannot see setting in forum manager for this mod?
im on vb3.7 beta4
gunboard
06-11-2010, 12:53 PM
Hello,
here the xml for VB 3.8.x at own risk :) on gunboard.de it works perfect.
settings are in the forummanagement.
greets gunboard
Acido
06-23-2010, 11:07 PM
Someone have it working on vb4 ?
Macindy
07-03-2010, 11:32 AM
Does this plugin work with vb4?
Trevor Hannant
09-03-2010, 01:53 PM
Once installed using the XML file above, edit the hook location in:
AdminCP > Plugins & Products > Plugin Manager > Auto-Prune Threads
to use the cron_script_cleanup_hourly hook.
Works fine in my 4.0.6 install.
Edit - error caused by a space at the start of the above hook name in the XML - revised file attached.
Acido
09-08-2010, 03:33 AM
Works fine in my 4.0.6 install.
I confirm that.
Thank you very much trevor :up:
atcspaul
10-24-2010, 01:29 AM
thanks trevor. works great with 4.0.7 also
POL_ED
11-05-2010, 06:07 PM
Thanks.
Works great with 4.0.8 also
AusPhotography
12-27-2010, 06:54 AM
I've got a slightly modified version working in v4.1.0pl2 .
Based on Trevor's version https://vborg.vbsupport.ru/showpost.php?p=2093276&postcount=81
My mod is to NOT prune sticky threads ;)
TheGorf
02-05-2011, 05:10 AM
How are you avoiding stickies? I was looking at the simple code in this mod and I see:
while ($thread = $vbulletin->db->fetch_array($threads))
{
delete_thread($thread['threadid'], false, true, NULL, false, $thread);
}
That easily can be added with a IF block to evaluate if the thread is sticky. Is that all you did? Something like this:
while ($forum = $vbulletin->db->fetch_array($forums))
{
$threads = $vbulletin->db->query_read("SELECT threadid, forumid, visible, open, pollid, title, sticky FROM " . TABLE_PREFIX . "thread WHERE forumid=$forum[forumid] AND visible IN (0,1,2) AND sticky IN (0,1) AND lastpost <= " . (TIMENOW - ($forum['pruneafter'] * 86400)));
while ($thread = $vbulletin->db->fetch_array($threads))
{
if ( $thread['sticky'] == 0 )
{
delete_thread($thread['threadid'], false, true, NULL, false, $thread);
}
}
build_forum_counters($forum['forumid']);
}
which adds "sticky" to the thread query, and then ignores the delete_thread call if the thread is sticky. Hmmmm I bet it would be trivial to make this a checkbox option in the forum edit/setup page.
enbro
03-04-2011, 06:04 PM
I've installed this on my board which is 4.1.1 and it seems to be working, thanks so much!
Boofo
05-05-2011, 07:03 AM
I've got a slightly modified version working in v4.1.0pl2 .
Based on Trevor's version https://vborg.vbsupport.ru/showpost.php?p=2093276&postcount=81
My mod is to NOT prune sticky threads ;)
Well, let's see it. ;)
AusPhotography
05-22-2011, 09:06 AM
Works on 4.1.3
We also add this line AND sticky = 0
to the SQL to not remove sticky threads
http://www.ausphotography.net.au/forum/showlibrary.php?title=Culling_of_old_threads_-_site_maintenance
Infopro
07-21-2011, 01:56 PM
Would anyone have an idea on how I could make this check for deleted threads only and move them to a specific forum? After you've soft deleted many spam threads you might like to move them out of view to a specific forum for archiving instead of deleting.
Thanks!
res6cue
05-29-2012, 09:35 AM
Works great on 4.2.0!
I tweaked it a bit so that it won't delete sticky threads, and it will only delete threads that have no replies. I've also got it running on the daily cleanup instead of the hourly. It's perfect for what I need, which is to clean out my RSS feeds forum every 7 days.
Attached is my tweaked version, for anyone who might be interested:
Run daily (cron_script_cleanup_daily) instead of hourly
Do not delete sticky threads
Only delete threads with 0 replies
vBulletin® v3.8.12 by vBS, Copyright ©2000-2024, vBulletin Solutions Inc.