PHP - Protecting digital Downloads

后端 未结 3 1336
刺人心
刺人心 2020-12-16 05:23

I\'m trying figure out how I can protect digital downloads in PHP. Just need some general directions so I can start my research. I don\'t seem to be able to find anything us

3条回答
  •  长情又很酷
    2020-12-16 05:43

    Just some examples: You can place your files outside of the webserver's document root or in a directory that is protected by a .htaccess file with a "deny from all" rule; then you deliver the files by a custom PHP function that sets the correct headers (mime-type, filesize etc.) and returns the file.

    You could create links with unique id's based on MD5 or SHA1 hashes - a mod_rewrite rule points the id to your PHP file, you lookup the id in the database and do your time checks, like

    example.com/downloads/73637/a8d157edafc60776d80b6141c877bc6b
    

    is rewritten to

    example.com/dl.php?id=a8d157edafc60776d80b6141c877bc6b&file=73637
    

    Here's an example of doing something you want with nginx and PHP: http://wiki.nginx.org/HttpSecureLinkModule

提交回复
热议问题