In my opinion (trying to be helpful), you are going down the wrong path. Restructure and modularize your code on paper and then just rewrite your code to stand-alone -- while keeping in mind your desire to integrate with other products.
The approach you are taking will be too time consuming. I am sure you will have to learn a few new code structures before you are done, but you will always have your old code on vBulletin to observe it's execution.
My two cents.