PHP Code:
$twodaysago = TIMENOW - (48 * 60 * 60);
$endofday = TIMENOW - (24 * 60 * 60);
$getthreadexpires = $vbulletin->db->query_read("
SELECT thread.* as thread, thread.threadid as tid, forum.forumid AS fid, forum.title AS ftitle, postlink.url as postlinkurl
FROM " . TABLE_PREFIX . "thread AS thread
LEFT JOIN " . TABLE_PREFIX . "postlink AS postlink ON (thread.firstpostid = postlink.postid)
LEFT JOIN " . TABLE_PREFIX . "forum AS forum ON (thread.forumid = forum.forumid)
WHERE forum.forumid IN($included_forums)
AND thread.thread_expiry <> 0
AND thread.thread_expiry >= $twodaysago
AND thread.thread_expiry <= $endofday
$adminwhere
");
//Check To See If Results
if ($vbulletin->db->num_rows($getthreadexpires)) {
while ($getthreadexpire = $vbulletin->db->fetch_array($getthreadexpires))
{
//Move Thread To Archive Forum
require_once(DIR . '/includes/functions_databuild.php');
$threadman =& datamanager_init('Thread', $vbulletin, ERRTYPE_ARRAY, 'threadpost');
$threadman->set_existing($getthreadexpire);
$threadman->set('forumid', $vbulletin->options['threadexpiration_forumarchive']);
$threadman->save();
build_forum_counters($getthreadexpire['forumid']);
build_forum_counters($archive_forum);
}