Moksha Posted August 13, 2007 Share Posted August 13, 2007 Hi guys, im creating a basic site for a friend that allows registered users to login with an ID number. Once in the site they can see their personal details, and can also download a piece of software. The site also has an admin section where the admin user can add/edit/delete users, and the admin user will also be able to set the number of times that the software can be downloaded per month. Ive easily created the code for the site which allows people, and the admin user to login and see their details. I just want to know how would i implement the downloading thing. So essentialy when the person logs in they will have a link on to their software file that they can download it from. After they download it X times per month they will be prohibited from downloading it anymore. How would i do soemthign like this? Quote Link to comment https://forums.phpfreaks.com/topic/64622-download-limiter/ Share on other sites More sharing options...
NArc0t1c Posted August 13, 2007 Share Posted August 13, 2007 Not really a way to get passed this. You could push the file trough a php header, then the user can download. But then they could easily see the source of the download. You could use a crontab to change the file name every minute(md5 timestamp for filename) or so. And then just make a script to look for files, if one is found that timestamp is less than one minute, push the download header. There is a example of how to force a download using headers, just look on the forum. Quote Link to comment https://forums.phpfreaks.com/topic/64622-download-limiter/#findComment-322166 Share on other sites More sharing options...
gurroa Posted August 13, 2007 Share Posted August 13, 2007 You can let user download your file through the php script. <?php // download.php //... // first check wheter user can download this file once more time // you can save download times into your db. if ($user_can_download) { // if it is a zip file // you can store your file somewhere where users can reach it $file = './myfilestorage/file_01.zip'; Header('Content-type: application/x-zip-compressed'); Header('Content-Disposition: attachment; filename="file_01.zip"'); Header('Content-length: '.filesize($file)); readfile($file); Exit; } else { //... normal output telling user you can't download this file anymore } Quote Link to comment https://forums.phpfreaks.com/topic/64622-download-limiter/#findComment-322172 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.