<?php
/*
	This script will handle running the vbulletin schedule tasks
	(see the Scheduled Tasks menu in the Admincp).  This avoids
	having users trigger ajax calls when hitting the site.  It
	also avoids the problem where the scheduled tasks fail to
	run because there is not enough traffic to trigger all of the
	scripts in a timely fashion.

	To use do the following
	1. Copy the script to your webserver.  Preferable outside of the webroot
		directory.
	2. Set the $core variable to the path to your vb core directory
	3. Add an entry to your system cron to run the script (recommend running every 		minute)
		/path/to/php /path/to/file/vbcron.php
*/

//set this to your vb core directory
$core = '';

/*================== DO NOT EDIT BELOW THIS LINE ========================*/
require_once($core . '/vb/vb.php');
vB::init();

$options = getopt('', array('count::'));
$count = (isset($options['count']) ? $options['count'] : 1);

$request = new vB_Request_Cli();
vB::setRequest($request);

//sign is as guest, we don't need elevated permissions to run cron
$request->createSessionForUser(0);

$cronapi = vB_Api::instance('cron');

for ($i = 0; $i < $count; $i++)
{
	$cronapi->run();
}
