Well firstly PayPal IPN works like this
You send information they than show there processing part for payment. Then if information sent requires a information sent back it will find the file. Send information, your script will then respond saying it got the message and send back for the information on the order.
I think i have an unfinished script which you can have a look at just PM me.
The script gets told whether the user thats made a purchase was verified and the order completed etc (You should read up on the PayPal IPN PDF file which explains them all).
If completed then the Folder, .htaccess file and .htpasswd files should be created