Well, I haven't tried it but I guess it would look like the one that's in attachment.php, but you don't need to read everything since you only need the forumid. So maybe:
PHP Code:
if (!$attachmentinfo = $db->query_first_slave("
SELECT thread.forumid FROM " . TABLE_PREFIX . "attachment AS attachment
LEFT JOIN " . TABLE_PREFIX . "post AS post ON (post.postid = attachment.postid)
LEFT JOIN " . TABLE_PREFIX . "thread AS thread ON (post.threadid = thread.threadid)
WHERE " . ($vbulletin->GPC['postid'] ? "attachment.postid = " . $vbulletin->GPC['postid'] : "attachmentid = " . $vbulletin->GPC['attachmentid']) . "
"))
{
eval(standard_error(fetch_error('invalidid', $vbphrase['attachment'], $vbulletin->options['contactuslink'])));
}
if (!in_array($attachmentinfo['forumid'], array(1, 2, 3, 4))
{
// etc.
}