PDA

View Full Version : Need script to close forum by cron job


BadGuy
02-20-2011, 12:36 PM
Hi

Looking for someone to make a small script to close forum by cron job

Check this thread : ( check post #4 )
https://vborg.vbsupport.ru/showthread.php?t=207069

Best Regards

kh99
02-20-2011, 02:00 PM
The forum open/close is controlled by $vbulletin->options['bbactive'], so I started looking at how you might set that using a script. But since it's saved in the datastore it gets pretty complicated. But then I realized you could just override it in a plugin using the init_startup hook. Setting $vbulletin->options['bbactive'] to false will close the forum, so you could add whatever other check you wanted, like


if (check something outside vbulletin)
{
$vbulletin->options['bbactive'] = false;
}


and maybe check the contents of a file or something. (Of course whatever you do gets done on every page access, so hopefully it's fast).

Someone else recently asked about having banners appear/disappear based on the time of day (https://vborg.vbsupport.ru/showthread.php?p=2163631#post2163631), so another option might be to use that and make the forum automatically close between certain hours. I guess in that case you'd want it to just use the server time so it would match up with the cron job, so it could be something like:

$thishour = date("G");
if ($thishour >= 1 && $thishour < 3)
{
$vbulletin->options['bbactive'] = false;
}

(to have the forum down between 1 and 3 AM, for example. ETA: The condition was wrong originally, had to make it ">=" for the starting hour).

Anyway, I know it's not exactly what you asked for, but maybe some of it will be useful.