SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Zealot imagize's Avatar
    Join Date
    Oct 2004
    Location
    Australia
    Posts
    197
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Download Manager

    Hey,

    Im looking at creating a system that will protect my downloads from hotlinkers/leechers on other website. This system would have to only allow downloads from people on my website and not direct request and would also have to mask the locations of the files being downloaded.

    Can anyone help start me off.

  2. #2
    My precious!!! astericks's Avatar
    Join Date
    Mar 2002
    Location
    Vancouver, BC
    Posts
    1,971
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Make the following table in your db:
    downloads (id, file_location)

    well, let's say you have:
    download.php?id=123
    PHP Code:
    $sql "SELECT file_location FROM downloads WHERE id = " $_GET['id'];
    // then query database and retrieve results and let user download the file according to the file_location column in the table 
    hope this helps.

    asT.

  3. #3
    SitePoint Zealot imagize's Avatar
    Join Date
    Oct 2004
    Location
    Australia
    Posts
    197
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thankyou for your reply but what you posted is not what i need. Im fairly advanced at php and im looking for techniques such as masking file locations. Even something like download.php?id=123 will display a file location on the download screen and this enabling people to copy that address and start leeching it again.

  4. #4
    SitePoint Evangelist
    Join Date
    May 2004
    Location
    Germany
    Posts
    550
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    did you look at http://www.anti-leech.com/ ? i've never used it but this seems to be what you might want. Not a php solution though. And the downside is your user will have to install the antileech plugin

  5. #5
    SitePoint Zealot imagize's Avatar
    Join Date
    Oct 2004
    Location
    Australia
    Posts
    197
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I try to avoid free things as much as possible. I get more out of it if i make it myself. I can make the download manager, im just wondering is there a way to protect the direct downloads (other than using .htaccess files)

  6. #6
    SitePoint Member
    Join Date
    Oct 2004
    Location
    USA
    Posts
    0
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Lion, Looking for that solution as well.
    The best I found is to store files in DB, and control the authentication this way.

    Maybe not the best idea, but good really. Especially when we see the vbuletin guys did the same for their soft
    PHPCow.com
    News Publishing System & Content Management Solution

  7. #7
    o_O O_o BlueFire2k5's Avatar
    Join Date
    Mar 2003
    Location
    Sioux Falls, SD
    Posts
    475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Actually, there is a rather easy way to do this. You can mask the download path simply by placing the file to be downloaded in a folder that cannot be accessed by the web. Put it outside public_html/ or web/ or whatever you use, and then use this script...
    PHP Code:
    header('Content-Disposition: atachment; filename='.$filename);
    header('Content-Type: application/octet-stream');
    header('Content-Length: '.filesize('path/to/downloads/'.$filename));
    header('Pragma: no-cache');
    header('Expires: 0');
    $fp fopen('path/to/downloads/'.$filename'r');
    print 
    fread($fp,filesize('path/to/downloads/'.$filename));
    fclose($fp);
    exit(); 
    Cheers.
    "Sa souvraya niende misain ye."
    - Robert Jordan, The Wheel of Time

  8. #8
    SitePoint Member
    Join Date
    May 2002
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by BlueFire2k5
    Actually, there is a rather easy way to do this. You can mask the download path simply by placing the file to be downloaded in a folder that cannot be accessed by the web. Put it outside public_html/ or web/ or whatever you use, and then use this script...
    PHP Code:
         header('Content-Disposition: atachment; filename='.$filename);
         
    header('Content-Type: application/octet-stream');
         
    header('Content-Length: '.filesize('path/to/downloads/'.$filename));
         
    header('Pragma: no-cache');
         
    header('Expires: 0');
         
    $fp fopen('path/to/downloads/'.$filename'r');
         print 
    fread($fp,filesize('path/to/downloads/'.$filename));
         
    fclose($fp);
         exit(); 
    Cheers.
    Expanding on what BlueFire2k5 stated:

    fpassthru()

    and

    readfile()

    These two functions provide the functionality he describes in a simpler package (particularly readfile()). Keep in mind you would still need to send out the appropriate headers first, these functions reduce this:

    PHP Code:
      $fp fopen('path/to/downloads/'.$filename'r');
     print 
    fread($fp,filesize('path/to/downloads/'.$filename));
          
    fclose($fp);
          exit(); 
    to one or two lines.


Bookmarks

Posting Permissions

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