dtmsaqtly798322992 2010-08-13 01:17
浏览 33

用于查看图像的匿名用户计数器

I'm just starting with PHP. I'm currently building a site that will allow anonymous users to view images ten times a day. Any image viewed will increase the counter as well viewing a certain image more than once. Viewing more than the counter limit per day will not be allowed unless they register.

Just wondering what can I do with sessions and the database in order to make this possible. Also, how can I reset the counters in every 24 hours?

Sample codes would be much appreciated. Thanks.

BTW, I'm using kohana 3.

  • 写回答

1条回答 默认 最新

  • duandi1636 2010-08-13 01:30
    关注

    If you use sessions, then there's an easy way for people to get around it - disable cookies.

    You could base it on IP address, though you'd have to note that multiple people may sometimes have the same IP and one person may have multiple IPs. So you would have to be conservative with what you reject - you wouldn't want to reject the same IP from access something just ten times in a day.

    So, there's no ultra-reliable way of doing what you want to do, if you don't want to force people to register/login (and even then you'd have to account for people registering multiple times).

    I'd probably consider limiting it by IP, putting a row into the database for each view containing the date and the user's IP, and if the row exists, increment a third column. Once that column reaches say 100, disallow access. The next day, it'll all be reset by itself because your date column is now different.

    You may also consider putting a rule into robots.txt to prevent reputable search engines and the like grabbing 'cached' copies of the image.

    评论

报告相同问题?

悬赏问题

  • ¥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做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序