I used to have a php function that did this, but it got lost when I decided to rewrite my portal. I'll rewrite it maybe tomorrow and get back to you.
There was also the really bad, kludgey way to do it, which required called ultimatebb.cgi?ubb=something-I-threw-in via iframe. I considered modifying ultimatebb.cgi to just throw out some stupid stuff, like
<html><body></body></html>
so the output works, but it'd probably be much, much better to edit ultimatebb.php, as it does a ton less work (does a couple if statements, and includes an html file). This would probably help with the load.