I don't have time to write a complete script, but you can use adduser.php as a guideline for the INSERT queries.
Issues:
The old real-name and username syntax might be different from the syntax UBB.threads uses, so you'll want to check those and decide whether it's a problem.
Unless the old passwords are cleartext or happen to be encoded exactly the
same way that UBB.threads does it (MD5 digest of the cleartext password), you won't be able to preserve them.