Hey,
We do something similar to this on our site (albeit that runs on vB 3.8.*).
The first thing you do is add an include to the vB global.php (Assuming your file is in the forumroot folder):
Code:
require_once("./global.php");
This allows you to tap into the back-end system of vBulletin, which includes their access to the database, and a variety of useful objects. With that done, you can verify a user is logged in:
Code:
if (!$vbulletin->userinfo['userid'])
{
print_no_permission();
}
And to deduct their username, use
Code:
$vbulletin->userinfo['username']
(Note: I did not verify the last line. If it does not work, create a blank php file, add the include from above, and have php spit out the full contents of the $vbuletin->userinfo array. Chances are that gives you a better idea).
HTH.
Peter