If you want to run your own Bitcoin faucet, you need a good script.
The script from Faucetsystem is a script that comes with powerful protection.
It can be downloaded for free here: http://in.cur.lv/faucetscript
Now here's a tip: if you want to fund your faucet with your own (referral) faucet earnings, you'll need to edit the script so it will work with FaucetHub.
You can find a step-by-step guide (and download the modified script) here: