I believe #1 is correct.
Would be best if you could find a script similiar to vBulletin's somewhere online, that is freely distributed. I'm sure there are several.
If not, then you should learn from vB's code, instead of simply copying it. Once you have learned and educated yourself, then you can write your own code for this, and only refer back to vB's when you need to!