serving purchased files |
[eluser]slowgary[/eluser]
You'd probably need to have the user set up an account, capturing their email address (preferably sending them an email with a confirmation link). Then you'd use a payment gateway to collect their payment. Upon completed payment transaction you would set the file as downloadable for that user, using a date stamp for expiration. So you'd have a few database tables: Code: Users You'd have the user fill out a form, store the info in the 'users' table, and send them an email with a link in it back to a script on your site to confirm the email address. The link could have a few parameters like: http://www.yoursite.com/email_confirm.ph...NLABSUFD7G The validation string could be a hashed string, created from their user_id, username, and email address. So you'd do something like: Code: //get user info from database So now the user has an account with a confirmed email address. After selecting a file and paying through your gateway, you'd check which file they purchased and put an entry into the downloadables table: Code: mysql_query("INSERT INTO `downloadables` VALUES('{$_GET['user_id']}', '{$_GET['file_id']}', '".strtotime('+2 days')."'"); Then when a user logs in you'd have a script check the downloadables table for that user's files: Code: $results = mysql_query("SELECT `file_id`, `file_name` FROM `files` WHERE `file_id` IN (SELECT `file_id` FROM `downloadables` WHERE `user_id` = '$_GET['user_id']' AND `expiry` > '".time()."'")); Then downloader_script.php would have to check the downloadables table again to make sure the user wasn't fudging the system, then it would have to check the files table and force-download the file, like so: Code: $result = mysql_query("SELECT `file_name` FROM `files` WHERE `file_id` IN (SELECT `file_id` FROM `downloadables` WHERE `file_id` = '$file_id' AND `user_id` = 'user_id')"); It would be good practice to keep the files above the web root, so that people can't just type in the url to your files. Also, the junk above is just a basic idea, don't in any way copy the code because it will make me puke for sure. Hope that helps |
Messages In This Thread |
serving purchased files - by El Forum - 03-21-2009, 10:00 PM
serving purchased files - by El Forum - 03-21-2009, 10:22 PM
serving purchased files - by El Forum - 03-21-2009, 10:29 PM
serving purchased files - by El Forum - 03-21-2009, 10:50 PM
serving purchased files - by El Forum - 03-21-2009, 10:54 PM
serving purchased files - by El Forum - 03-21-2009, 10:54 PM
serving purchased files - by El Forum - 03-21-2009, 10:56 PM
serving purchased files - by El Forum - 03-22-2009, 12:16 AM
serving purchased files - by El Forum - 03-22-2009, 04:18 AM
serving purchased files - by El Forum - 03-22-2009, 06:23 AM
serving purchased files - by El Forum - 03-22-2009, 08:32 PM
serving purchased files - by El Forum - 03-22-2009, 09:49 PM
|