vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.0 Full Releases (https://vborg.vbsupport.ru/forumdisplay.php?f=33)
-   -   Automatically Lock Old Threads (Via vB Cron) (https://vborg.vbsupport.ru/showthread.php?t=82242)

Gavin B. 05-29-2005 09:00 PM

Automatically Lock Old Threads (Via vB Cron)
 
This vB cron allows you to define a certain period of time for threads to be automatically locked.
  • Copy-paste the following into a new PHP file, and upload to ./includes/cron/YOURFILENAME.php
  • Enter the adminCP and go to scheduled tasks, click "add new scheduled task"
  • Setup when you want the script to run, and add the filename into the 'filename' field.

PHP Code:

<?php

    error_reporting
(E_ALL & ~E_NOTICE);
    
    
// start editing
    // forum ID's to monitor - put a comma between each one
    
    
DEFINE('FORUM_IDS''15,59,14');
    
    
// time span to go back to.
    // eg for months use; 6 MONTH or 9 MONTH
    // years; 1 YEAR or 2 YEAR
    // days; 5 DAY or 29 DAY
    
    
DEFINE('TIME_SPAN''6 MONTH');    
    
    
// stop editing here
    
    
if (!is_object($DB_site))
    {
        exit;
    }    
    
    
$DB_site->query("UPDATE " TABLE_PREFIX "thread SET open=0 WHERE forumid IN("FORUM_IDS .") AND FROM_UNIXTIME(dateline) <  DATE_SUB(CURDATE(),INTERVAL "TIME_SPAN .")");
    
    
log_cron_action('Old Threads Locked'$nextitem);

?>


Corriewf 05-30-2005 11:39 PM

I love the concept however this needs to be revised for last post activity as a lot of members use the same thread as an update thread which can go on for a long time.

TrentTech 05-31-2005 01:00 AM

Is the time based on when the thread is created, or when the last reply was?

Delphy 06-01-2005 10:00 AM

I wrote something similar for my board a while back.

What I would do is change the query to:
Code:

    $DB_site->query("UPDATE " . TABLE_PREFIX . "thread SET open=0 WHERE forumid IN(". FORUM_IDS .") AND open <> 0 AND FROM_UNIXTIME(lastpost) <  DATE_SUB(CURDATE(),INTERVAL ". TIME_SPAN .")");
This way you are:
1) Only locking threads that aren't already locked (saves re-locking already locked threads)
2) Basing it on the lastpost in the thread, so you don't lock active threads that are created within your timespan

What I also do is hard delete any that are locked and within another timeframe using the same cron job.

Regards,
Delphy

Corriewf 06-01-2005 12:58 PM

Thanks for that...... So when are the sims coming out to psp?

Logikos 06-02-2005 04:56 PM

Something like this has already been released. https://vborg.vbsupport.ru/showthrea...threadid=70302 and it goes by the last post date.


All times are GMT. The time now is 10:51 AM.

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.01673 seconds
  • Memory Usage 1,727KB
  • 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
  • (1)bbcode_code_printable
  • (1)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (6)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