PHP Code:
<?php
// ######################## SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);
if (!is_object($vbulletin->db))
{
exit;
}
// ########################################################################
// ######################### START MAIN SCRIPT ############################
// ########################################################################
require_once(DIR . '/includes/functions.php');
require_once(DIR . '/includes/adminfunctions.php');
require_once(DIR . '/includes/functions_databuild.php');
$delinfo = array(
'userid' => '0',
'username' => 'Time Limited Forum-Hack',
'reason' => ''
);
$forums = $vbulletin->db->query_read("SELECT physicallydelete, options, timelimit, forumid, title_clean FROM " . TABLE_PREFIX . "forum WHERE timelimited=1");
while ($forum = $vbulletin->db->fetch_array($forums))
{
$starttime = mktime(substr($forum['timelimit'], 0, 2), substr($forum['timelimit'], 3, 2))-1;
$endtime = mktime(substr($forum['timelimit'], 6, 2), substr($forum['timelimit'], 9, 2))-1;
$now = time();
// Overlapping day?
if ($endtime < $starttime)
{
$endtime += 86400;
}
if (($now < $starttime) OR ($now > $endtime))
{
// Hide Forum
$forum['options'] &= ~$vbulletin->bf_misc_forumoptions['active'];
// Disallow posting
$forum['options'] &= ~$vbulletin->bf_misc_forumoptions['allowposting'];
// Remove the threads
$threads = $vbulletin->db->query_read("SELECT * FROM " . TABLE_PREFIX . "thread
WHERE forumid=$forum[forumid]
AND visible IN (0,1)
");
while ($thread = $vbulletin->db->fetch_array($threads))
{
delete_thread($thread['threadid'], false, $forum['physicallydelete'], $delinfo, false, $thread);
}
log_cron_action("Time Limited Forum deactivated: $forum[title_clean]", $nextitem);
}
else
{
// Show Forum
$forum['options'] |= $vbulletin->bf_misc_forumoptions['active'];
// Allow posting
$forum['options'] |= $vbulletin->bf_misc_forumoptions['allowposting'];
log_cron_action("Time Limited Forum activated: $forum[title_clean]", $nextitem);
}
$vbulletin->db->query_write("UPDATE " . TABLE_PREFIX . "forum SET options=$forum[options] WHERE forumid=$forum[forumid]");
build_forum_counters($forum[forumid]);
}
build_forum_permissions();
?>
Am I fast? Written in just 2 minutes ...

Hmm ... but could be optimized. It uses one query/forum = bad.