Jump to content

download limiter


Moksha

Recommended Posts

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?

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

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
  }

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.