dongshao5573 2011-07-01 19:42
浏览 35
已采纳

暂时使服务器文件公开

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.

  • 写回答

1条回答 默认 最新

  • dongpankao6133 2011-07-01 21:14
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 unity第一人称射击小游戏,有demo,在原脚本的基础上进行修改以达到要求
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line