How can I limit number of downloads from my server using PHP?

Discussion in 'PHP' started by SIAWebDesign, Jan 17, 2010.

  1. #1
    Hi All,

    I'd like to be able to limit my users to 1 or 2 parallel (concurrent) downloads from my site. This is sort of like what rapid share or mega uploads do.

    Is this done with PHP? Or is this done on the server some how??

    Thanks in advance for all your help.
     
    SIAWebDesign, Jan 17, 2010 IP
  2. oxidati0n

    oxidati0n Peon

    Messages:
    744
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #2
    It's partially using complex algorithms, and partially using coding techniques.

    Rapidshare's technology is basically querying every specific download threshold (let's say every mb you download) and if it stops querying, it'll let you download again. It's pretty simple, but very costly for these services. What I've just mentioned is at a basic level, they have other things that save them more money without querying and to keep speeds of downloads really fast at the same time.

    But, that's something for you to do.
     
    oxidati0n, Jan 17, 2010 IP
  3. CodedCaffeine

    CodedCaffeine Peon

    Messages:
    130
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #3
    You can try having it download with a PHP script.

    The idea would be the person visits the link (download.php?file_id=gdsa9h340nbolcx). The script would log the IP in the database, then it would search the database for the file_id and find the direct link for it. Then, the php script can send a header saying it's a file, and you can "proxy" the file to download from that page without giving out the direct link.

    If the database contains two of the IP, then it could add a time+1hour to some sort of field in the database. Then when the person goes to download another file, if the database has two records, it can deny it, or if the database has two records and the time limit is up, it will remove the fields and allow the person to download.
     
    CodedCaffeine, Jan 17, 2010 IP
  4. szalinski

    szalinski Peon

    Messages:
    341
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #4
    apparently using mod_bandwith is in cpanel (if you enable it before compile) is supposed to do this. However even adding the proper directives, it has no effect.

    i think it might be worthwhile building mod_bw from source (the apache 2.x version of mod_bandwidth) and integrating with cpanel; at least, this is what i'm going to have to learn how to do soon, via trial and error.
     
    szalinski, Jan 19, 2010 IP