SitePoint Sponsor

User Tag List

Results 1 to 13 of 13

Thread: Ebook downloads

  1. #1
    SitePoint Zealot
    Join Date
    Jan 2007
    Posts
    191
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Ebook downloads

    I'm trying to create a way for users who have purchased an ebook the ability to download the ebook, while keeping those who have not from downloading the ebook. My question is, How do you make a link to a document unaccessible to those who do not have permissions? So, the user logs in and I take them to the download page, and it shows the link if they have permissions, but doesn't if they don't. But to me that's not enough. Let's say if that link to the file somehow gets out, I don't want anybody being able to download it unless they have permission. Can a check be placed on the actual download link to check before opening a download dialog, or giving them the file? So, they won't even be able to plug the link to the file in the browser URL to download it unless they are authorized.

  2. #2
    SitePoint Evangelist hexburner's Avatar
    Join Date
    Jan 2007
    Location
    Belgium
    Posts
    591
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can use a PHP script to read the ebook and flush it. In the PHP script you can also check if the user is authorised to download the ebook or not.
    For example, to authorize a user you can use a session and set some session variables that can tell you if the person can download the ebook or not.
    FOR SALE: 1 set of morals, never used, will sell cheap

  3. #3
    SitePoint Zealot
    Join Date
    Jan 2007
    Posts
    191
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Tell me more about reading it and flushing it. The ebook is in PDF format.

  4. #4
    Once I was a Factory Worker goofy's Avatar
    Join Date
    Dec 2004
    Location
    Sydney Australia
    Posts
    559
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    if you want a simple solution you could try www.payloadz.com.
    Goofy
    Life is what you make it!
    Follow your dreams!

  5. #5
    SitePoint Member
    Join Date
    Nov 2005
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Maybe only read the file and echo it.of course,before the echo,you must set the content-type to the very value,such as header("Content-Type:application/pdf").

  6. #6
    SitePoint Addict
    Join Date
    Jan 2005
    Posts
    204
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by hexburner View Post
    You can use a PHP script to read the ebook and flush it. In the PHP script you can also check if the user is authorised to download the ebook or not.
    For example, to authorize a user you can use a session and set some session variables that can tell you if the person can download the ebook or not.
    in this way, the pdf will somehow have to rest in a folder on the server. if the public gets the url to the folder, they can access to the pdf still or they will not?

  7. #7
    SitePoint Addict
    Join Date
    Jan 2007
    Location
    Romania
    Posts
    203
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It doesn't have to rest in the web root. You can put it outside the web root and you users will not be able to get to that file directly.

  8. #8
    SitePoint Member
    Join Date
    May 2007
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Maybe this software may add to some of your thoughts on how you would want to do it http://www.laserbeammarketing.com/ddmsystem/

  9. #9
    SitePoint Member
    Join Date
    May 2007
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Post moved...
    Last edited by prtt75; Jun 26, 2007 at 04:15. Reason: wrong post... sorry

  10. #10
    SitePoint Addict
    Join Date
    Jan 2005
    Posts
    204
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    what are you talking, prtt75?

  11. #11
    SitePoint Member
    Join Date
    May 2007
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by x[E]nOn View Post
    what are you talking, prtt75?
    Oooops... Sorry. This is supposed to be posted here.. http://www.sitepoint.com/forums/showthread.php?t=486960.

    I got mixed-up doing article submission and replying to forums at the same time.

  12. #12
    SitePoint Zealot
    Join Date
    Jan 2007
    Posts
    191
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Read and Echo File

    Quote Originally Posted by aninfeel View Post
    Maybe only read the file and echo it.of course,before the echo,you must set the content-type to the very value,such as header("Content-Type:application/pdf").
    How well would this perform with a 13MB e-book? Does it just send to the user as it would a normal download?

  13. #13
    SitePoint Zealot
    Join Date
    Jan 2007
    Posts
    191
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thumbs up Works!

    Quote Originally Posted by aninfeel View Post
    Maybe only read the file and echo it.of course,before the echo,you must set the content-type to the very value,such as header("Content-Type:application/pdf").
    ok, everyone, I used this recommendation and it works. Here's the code for anyone else who wants to do this too.

    PHP Code:
    <?php 
    header
    ("Content-Type:application/pdf");
    $file '../testDownload/file.pdf';
    $fh fopen($file'r');
    echo 
    fread($fhfilesize($file));
    fclose($fh);
    Then you can add your permissions around it if you want.


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
  •