how do you earn money with the script
You give each visitor that clicks and succesfully skips the adf.ly link a small amount of bitcoin, or just some satoshis, while you keep all the adrevenue the user itself made from clicking it.
This is what most faucets do these days, either through CPM/popups, or these links.
See
https://bitcointalk.org/index.php?board=212.0 for more information on them.
@OP does this also include protection against people faking their referer, so that it looks like they came/visited the link while in reality they didn't?