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.


All times are GMT. The time now is 01:46 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.01671 seconds
  • Memory Usage 1,755KB
  • 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
  • (5)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)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
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete