暂时公开服务器文件
我有一个 Joomla!网站,对于每个用户我都有一个图像。 我想要的是将图像对用户保密,但暂时将其(好吧,副本)公开。
我的想法是让用户单击一个调用“publish.php”脚本的链接。 该脚本将获取用户名并创建一个临时(30 秒)文件夹,并将其私有图像复制到该临时文件夹中。
然后,该脚本将生成一个随机密钥并使用用户名和密钥构建一个 URL,即 www.site.com/photos/get_photo.php?key=username.*key*
然后当有人访问该 URL 时链接(通过 QR 扫描仪)“get_photo.php”脚本将检查密钥是否有效以及是否显示图像。
我希望照片公开,因为给定 URL,任何人都可以看到它,但不公开,因为任何人都可以继续轮询我的服务器,并在照片可用时向下拖动照片。
我对原始照片的安全性感到困惑,如果它们是私有的,则脚本无法访问它们,但如果它们是公开的,则无法达到暂时公开它们的目的。
下一个问题是在一个脚本中生成一个可由另一个脚本验证的密钥。
非常感谢您的指导。
I have a Joomla! site and for each user I have an image.
What I want is to keep the image private to the user but temporarily make it (well, a copy) public.
My thinking was to have the user click a link which calls a "publish.php" script.
This script would take the user name and create a temporary (30 seconds) folder and copy their private image into that temporary folder.
The script would then generate a random key and build a URL using the username and key i.e. www.site.com/photos/get_photo.php?key=username.*key*
Then when someone goes to that link (via QR scanner) the "get_photo.php" script would check the key was valid and if it was display the image.
I want the photos public in the sense that given the URL anyone can see it but not public in the sense that anyone can keep polling my server and dragging down photos as and when they become available.
I'm stuck with the security of the original photos, if they are private the script can't access them but if they are public, if defeats the purpose of making them temporarily public.
Next problem is generating a key in one script that can be verified by the other script.
Many thanks for any guidance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您要承担复制文件的开销,您不妨使用 php 脚本读取并输出文件本身。我不确定你如何跟踪你的图像,但如果它在数据库中,你可以添加一个时间戳列,标记它何时被公开。然后让脚本检查该时间戳以查看它是否在过去 30 秒内公开。如果有,请在图像上执行 file_get_contents,设置适当的图像标题并输出它,如果没有,则可能会加载默认错误图像。
If you are going to go through the overhead of copying the file, you might as well have a php script read and output the file itself. I'm not sure how you are keeping track of your images, but if its in a database you could add a column for a timestamp which marks when it has been made public. Then have the script check that timestamp to see if it was made public within the last 30 seconds. If it has, do a file_get_contents on the image, set the appropriate image header and output it, if not maybe have it load a default error image.