Secure download system
Date: 08/25/06
(PHP Community) Keywords: html
I offered to help out a musician friend of mine who wants to sell some of his music video's and donate the funds to UNICEF. Trying to keep this stupid simple... so my thoughts are like this.
CC gateway -Paypal
Sale form that records the user's IP address (redundant because I always do this) and either makes a md5 hash of their first name and IP address or assigns a uniqueID to them.
Processing page (maybe xajax, not sure if I am ready to use it in production environment)
Output buffer a processing page then print a link/JS redirect on response from paypal.
If IPN data comes back good, changes a bool to true and purchase date.
1st option
Redirect to gateway form that takes via GET the unique ID hash and filename(validated against a regExp&ls listing of the secure file directory)
If the uniqueID matches the customer table, the specified file name/title is in the sold field, and their IP is the same... redirects to a download page that sends header for the content type then prints the video file to the client. To prevent file corruption, I'd used ob_start before the verification code, do a ob_get_contents() then log/email that to me if its length is > 0, then ob_clean_end output buffering, post the header and print the file on success. On failure, post txt/html or something and tell them why they can't get the video and to enter their name, email address. Most likely the customers will be French so this is going to be a bitch if something breaks. Estimated file size is 70-120 megabytes.
OR
On verification of emails, via Swift mailer, their invoice and requested video file is sent.
Source: http://community.livejournal.com/php/488389.html