As soon as I can I will be making an API that will include some things such as this. Basically the function you're looking for is the authenticate() function in the libs/ubbthreads.inc.php file. That function checks to see if a user is logged in, and grabs a variety of fields from the database if so.