Controlling Simultaneous Downloads from PHP

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • subhachu
    New Member
    • Jan 2009
    • 3

    Controlling Simultaneous Downloads from PHP

    Hi,
    I would like to know, how to control the simultaneous downloads in PHP, say may be by trackin' from MySQL....

    I need to allow only one IP to download a file... From my server... @ once.. Similar to ones found on the file-sharing sites!!!

    Can any one help me???
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #2
    Hi.

    I'm not sure PHP would be able to do this by itself. Although, I must admit, I have not explored this area very well.

    I suppose you could try something like:
    [code=php]
    <?php
    $res = mysql_query("SE LECT IsDownloading FROM someTable");
    $row = mysql_fetch_ass oc($res);
    if($row['IsDownloading']) {
    echo "Sorry, server is busy at the moment";
    }
    else {
    mysql_query("UP DATE someTable SET IsDownloading = TRUE");
    readfile("/path/to/file.ext");
    mysql_query("UP DATE someTable SET IsDownloading = FALSE");
    }
    ?>[/code]
    But that might not be enough.
    PHP might simply read the file into the output buffer and exit, even before the file is actually fully downloaded by the client.

    Comment

    • subhachu
      New Member
      • Jan 2009
      • 3

      #3
      Nice Try... Anyways Thankx

      "Atli ", thanks for that... but how can be find actually that the file is being downloaded??? In any ways or means??? ah...

      Comment

      • subhachu
        New Member
        • Jan 2009
        • 3

        #4
        dude, i found the answer... This actually works for Apache only... I found this module on the web and it solved my problem....

        Link: http://dominia.org/djao/limitipconn2.html

        THANKS A LOT BYTES!!! ;)

        Comment

        • Atli
          Recognized Expert Expert
          • Nov 2006
          • 5062

          #5
          Glad you found a solution.
          Thanks for sharing it!

          I'm definitely going to have to try that out when I get a chance :]

          Comment

          Working...