At the top of global.php there's a call to clean_array_gpc, I think if you put your code under that you could use $vbulletin->GPC['forumid']. But I guess that only works if a forum was somehow specified. Looking lower down in global.php it looks like if a threadid is specified it gets the forumid from the threadinfo, so you may have to put your code under that to make it work. I guess that could be a problem, if that code's supposed it be inserted at the top of the file (instead of at a hook location) then there's probably a reason.