Right before the if-block, find and add the part in bold on a test board, and make sure to read the comments:
Code:
// dates & thread title
$lastpostinfo = $vbulletin->forumcache["$lastpostarray[$forumid]"];
// this is just an example and you may need to reduce the queries!
// do _NOT_ do it this way because there can be a query per forum!
$forumhome_threadid = $lastpostinfo['lastthreadid'];
$forumhome_threadinfo = fetch_threadinfo($forumhome_threadid);
$forumhome_open = $forumhome_threadinfo['open'];
// if $forumhome_open is the number one, then the thread is open
Again, heed the comments, as this is untested code and you may need to edit the file to reduce the queries.