vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Modification Requests/Questions (Unpaid) (https://vborg.vbsupport.ru/forumdisplay.php?f=112)
-   -   vBCron and Pruning (https://vborg.vbsupport.ru/showthread.php?t=60175)

Indy 01-13-2004 08:47 PM

vBCron and Pruning
 
From what I was reading at vB, vB3 almost had this.

I would like to have vBCron prune threads older than xx days in selectable forums/catagories. Not worried about resetting counts, etc. since I do this manually every once in a while when I turn off the forums for maintenance.

I have a couple of FSOT type forums and we try to keep them pruned, but don't always do it!

Thanks!
Dan

allan grossman 01-29-2004 12:12 PM

I'm interested in this also - as I'm running a Usenet gateway and don't really need to keep more than six months' worth of posts.

I'd also like to see this incorporated with a cron job to flush and rebuild the search index. Anybody got ideas?

MRaburn 02-25-2004 06:52 AM

I think this is much needed but have never really found anyone in the VB arena to take the time to make something for the bigger boards. I've been waiting for years.

Andreas 02-25-2004 08:43 AM

@Indyshooter
Try this:
  1. [sql]ALTER TABLE forum ADD pruneafter INT DEFAULT 0 NOT NULL[/sql]
  2. In admincp/forum.php FIND
    PHP Code:

    print_yes_no_row($vbphrase['warn_administrators'], 'options[warnall]'$forum['warnall']); 

    BELOW that ADD
    PHP Code:

    print_input_row("Prune After<dfn>Stetting this to a value > 0 will automatically prune all threads from this forum where the last reply is older then the set amount of days</dfn>"'forum[pruneafter]'$forum['pruneafter']); 

  3. Place the following as prune.php in includes/cron
    PHP Code:

    <?php
    error_reporting
    (E_ALL & ~E_NOTICE);

    if (
    $DB_site == NULL)
    {
        exit;
    }

    require_once(
    './includes/functions_databuild.php');
    $forums $DB_site->query("SELECT forumid, pruneafter FROM " TABLE_PREFIX "forum WHERE pruneafter > 0");
    while (
    $forum $DB_site->fetch_array($forums)) {
      
    $threads $DB_site->query("SELECT threadid FROM " TABLE_PREFIX "thread WHERE forumid=$forum[forumid] AND lastpost <= " . (TIMENOW - ($forum['pruneafter'] * 86400)));
      while (
    $thread $DB_site->fetch_array($threads)) {
        
    delete_thread($thread['threadid'], 0);
      }
      
    build_forum_counters($forum['forumid']);
    }

    log_cron_action('Forums pruned'$nextitem);

    ?>

  4. Go to Forum Manager, Edit the Forums you want to be pruned automatically and set the number of days
  5. Create a Cron Job for prune.php

Use AS-IS, no warranties.

EricR 02-29-2004 06:44 PM

Many thanks Kirby, this is just what I was looking for :) I just have a few questions.

1) If I add a new forum later do I have to rerun the query?

2) Will this ignore sticky topics? If I have something as a sticky I'd like it to be exempt from any/all pruning functions including this auto-prune.


I have this installed and I've setup a few "tests" to confirm that it is working. I ran the task manually and it appears to work, I'll know more tomorrow after the scheduled task runs :)

Andreas 03-01-2004 12:03 AM

Quote:

If I add a new forum later do I have to rerun the query?
No. You will just have to set the amount of days in forum manager.

Quote:

ill this ignore sticky topics? If I have something as a sticky I'd like it to be exempt from any/all pruning functions including this auto-prune.
No, it will also delete sticky threads. But this can be modified easily:

Replace
PHP Code:

$threads $DB_site->query("SELECT threadid FROM " TABLE_PREFIX "thread WHERE forumid=$forum[forumid] AND lastpost <= " . (TIMENOW - ($forum['pruneafter'] * 86400))); 

With
PHP Code:

$threads $DB_site->query("SELECT threadid FROM " TABLE_PREFIX "thread WHERE forumid=$forum[forumid] AND sticky != 1 AND lastpost <= " . (TIMENOW - ($forum['pruneafter'] * 86400))); 

Then it should ingore sticky threads.

EricR 03-01-2004 12:42 AM

Thank you! :)

EricR 03-03-2004 11:16 PM

Just wanted to say thanks again Kirby, the script passed all of my tests :) All of the expired posts (open and closed) were automatically deleted and the sticky posts were unharmed https://vborg.vbsupport.ru/external/2011/01/19.gif Excellent!

Limitter 03-04-2004 06:17 AM

Modyfication by Pogo

http://www.vbulletin-germany.com/for...&threadid=9253

Limitter

Catch-22|BL 03-27-2004 03:26 PM

KirbyDE, I would encourage you to release your post as a hack. People will appreciate this information because it is useful for many large boards. I have to spend at least five hours a month sitting at my computer to manually do the prunes and it is very annoying.

allan grossman 03-27-2004 06:54 PM

Thank you, Kirby - that's exactly what I needed.

edit: I also think if they incorporate this into vB 3.1 they should slip Kirby a couple hundred bucks for his trouble :)

allan grossman 03-27-2004 07:34 PM

Quote:

Originally Posted by Limitter

Ich spreche kein Deutch :)

What does the mod do?

Indy 03-28-2004 04:42 AM

KirbyDE - Many Thanks!!

Haven't had a chance to apply your hack yet since I've been in the process of moving to a new server and all of the associated stuff that goes along with it.

I plan on doing so though!

Thanks again!
Indy

RCK 07-09-2004 08:53 PM

Yeah thanks for your help KirbyDE :)

JoeWho 10-11-2005 07:20 PM

Hi,

Will this work on 3.5.0.r3

I would like to use this if it would work?

JoeWho

EricR 11-06-2005 02:46 AM

Quote:

Originally Posted by JoeWho
Hi,

Will this work on 3.5.0.r3

I would like to use this if it would work?

JoeWho

This does not work with 3.5+, but thankfully Andreas released a plugin which makes it oh-so-simple. For those of use who already had this on 3.0, here's the steps to complete your upgrade to 3.5+.
  1. Grab the 3.5 plugin from Andreas's post here and install it. Overwrite can be left at the default "no".
  2. If you made any custom changes to the prune.php file you'll need to make the same changes to the plugin. To do so, open the Plugin Manager and edit the plugin "Auto-Prune Threads". This is the new location for the code that was previously in prune.php. For example, to preserve Stickies (make them immune to auto-prune), change the following:
    Find this (appears only once)
    Code:

    sticky IN (0,1)
    and change it to this
    Code:

    sticky != 1
  3. Delete your /includes/prune.php file, it is no longer needed.
  4. Delete your "Prune" task (which used to call the prune.php file) from the Scheduled Task Manager, it is no longer needed.

For 3.5, auto-prune is part of the hourly cleanup #1 in case you ever want to run it manually.

Many many thanks to Andreas for writing this AND helping me thru the upgrade steps :)


All times are GMT. The time now is 04:44 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01993 seconds
  • Memory Usage 1,772KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_code_printable
  • (5)bbcode_php_printable
  • (4)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (16)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete