douganbi7686 2018-03-03 16:19
浏览 34

PHP一次下载唯一密码

I am looking for a php script which allows me to generate multiple passwords/tokens I can distribute to some people which they can enter on a website to download a file one time. After downloading the token shouldn't be used anymore. The file is the PDF version of a magazine, so the people who buy the printed version can also get the digital version.

Does anyone have an idea for me how I could solve this?

Regards,

Francis

  • 写回答

1条回答 默认 最新

  • dtmwnqng38644 2018-03-03 16:24
    关注

    When the token gets requested (e.g. paper-2018-03-03.pdf?token=12345), you verify whether a zero-length file exists with the name paper-2018-03-03.pdf.12345. If it does, download is refused. If it does not, the download goes on normally, but you use touch() to create the guard file.

    Or you can create the guard files when you give out the tokens; when a request comes in, if the guard file is there you allow the download and delete the guard file. If most people use their tokens, this might be simpler. The previous method allows you to better track downloads, though.

    To generate the token, any random generator is okay - you can use mt_rand() or uniqid() with the extra entropy flag turned on.

    This approach has the advantage of not needing a database; if you already have one, then storing the tokens in the database would work better.

    评论

报告相同问题?

悬赏问题

  • ¥15 我的数据无法存进链表里
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
  • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
  • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
  • ¥15 如何在炒股软件中,爬到我想看的日k线
  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端