Results 1 to 9 of 9

Thread: PHP Download

  1. #1

    Exclamation PHP Download

    Hello,

    Ok I have this problem, I will be greatful if anyone can solve it.

    I want to let my users to download only one file at a time. Just like rapidshare does for FREE users. Free users can only download one file at a time and once a file is downloaded, he can proceed to download another.

    If someone can tell me the PHP code for this or can tell me the logic, it will be helpful.



    THanx

  2. #2
    Join Date
    Aug 2003
    Posts
    2,067
    Easiest way is to put their ip address into a mysql table as they start, and remove it when they finish a file or after a certain amount of time. Some suggested readings are:
    http://www.php.net/mysql
    http://www.php.net/filesystem
    http://www.php.net/variables.predefined
    Warning: include('signature') [function.include]: failed to open stream: No such file or directory in eval'd code on line 38
    Warning: include() [function.include]: Failed opening 'signature' for inclusion (include_path='.:/usr/local/php5/lib/php') in eval'd code on line 38

  3. #3
    How would I know, how much will it take for the visitor to download?

    Could be hez on dial-up or Cable or satellite

  4. #4
    Join Date
    Nov 2003
    Posts
    682
    You don't need to. Just put their IP address in your database, then use readfile() to give them the download, then take their IP address out of the database. Before each file is downloaded, you just check whether or not their IP is already listed. You can use connection_aborted() to check if the user cancelled their download as well.

  5. #5
    Join Date
    Nov 2004
    Location
    Northamptonshire
    Posts
    56
    Quote Originally Posted by brendandonhu
    You don't need to. Just put their IP address in your database, then use readfile() to give them the download, then take their IP address out of the database. Before each file is downloaded, you just check whether or not their IP is already listed. You can use connection_aborted() to check if the user cancelled their download as well.
    That will break big style for AOL users and anyone else who's ISP uses a passive proxy. Sessions / Cookies may be a better choice
    Andrew Hutchings (A-Wing) - Linux Jedi
    A-Wing Internet Services
    Windows is the path to the darkside...Windows leads to Blue Screen. Blue Screen leads to downtime. Downtime leads to suffering...I sense much Windows in you.

  6. #6
    Join Date
    Jul 2006
    Posts
    95
    Why not just set the session variable before the download and unset it after download is finished?

  7. #7
    Join Date
    Nov 2003
    Posts
    682
    I don't think any ISP is actually going to switch IPs in the middle of a file transfer, on the other hand, the user has complete control of cookies if you use that.

  8. #8
    Join Date
    Nov 2004
    Location
    Northamptonshire
    Posts
    56
    Quote Originally Posted by brendandonhu
    I don't think any ISP is actually going to switch IPs in the middle of a file transfer, on the other hand, the user has complete control of cookies if you use that.
    When a request goes through AOL it goes through a random proxy each time, so the IP will change with every request.
    Hence why I suggested sessions/cookies instead as the only way you will unique identify each client is with some kind of client side data transfer.
    Andrew Hutchings (A-Wing) - Linux Jedi
    A-Wing Internet Services
    Windows is the path to the darkside...Windows leads to Blue Screen. Blue Screen leads to downtime. Downtime leads to suffering...I sense much Windows in you.

  9. #9
    Join Date
    Aug 2003
    Posts
    2,067
    I am developing a script which will do what the OP asked and then some more; but it will be a commercial product later, so I am not going to go into too much details on how things are handled by the script. But what I can say is, from my testing so far, although I didn't test with AOL (I used Signet and this other popular ISP in SG/MY which also proxy's their user and share an IP pool), either the users doesn't seem to change IP address after there's session data registered, or none of my alpha testers on decide to report any issues about it... I'll give it some more testing when I have more time.

    Please note that if you are using sessions/cookies alone, user can simply open 'another brower' (IE: using IE and open Firefox) and achieve two downloads at a time...
    Warning: include('signature') [function.include]: failed to open stream: No such file or directory in eval'd code on line 38
    Warning: include() [function.include]: Failed opening 'signature' for inclusion (include_path='.:/usr/local/php5/lib/php') in eval'd code on line 38

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •