限制每日访问 [英] Limit Daily Access

查看:139
本文介绍了限制每日访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我应该允许每个IP每天2次访问。



我想创建一个mysql表,并在ip +时间ip访问网站,并创建一个cron作业,每24小时删除所有条目。



但我担心他可能会导致太多的服务器负载(如果我每天得到几个hundreth访问)。有没有更好或更简单的方法来限制每个IP每日访问两次?



我也在想使用cookie或会话,但我有0计划如何创建一个cookie来完成我需要的工作....



我非常感谢任何建议!



编辑:



有用的意见之后,我还需要一个建议,还有两件事:



- 将有一个公共代理检测脚本,足以阻止至少匿名和web代理?



- 可以单独限制每个IP的访问,并创建一个脚本,将删除的IP条目的第一次访问后24小时?

解决方案

保存(保存),而不是让cron作业每24小时删除所有数据ip,时间和访问数据库的次数是好的,几百行不是一个mysql数据库的问题(不要忘记在表上设置索引)。



但请注意,共享IP的用户可能无法访问您的信息页。



使用Cookie是有问题的,因为用户可以控制此信息,您不能限制。当然,这取决于您的应用程序阻止用户访问 的重要性。


I would like to implent a feature in my website that limits the access to a certain page.

It should allow 2 access per day per IP.

I was thinking of creating a mysql table and write in the ip+times the ip visited the website and than create a cron job that delets all entries every 24 hours.

But I am worried that his may causes too much server load (in case I get a few hundreth visits a day). Is there a better or simpler method to limit the daily access to two times per IP?

I was also thinking of using cookies or sessions, but I have got 0 plans on how to create a cookie that would do the job I need....

I am thankfull for any suggestions!

EDIT:

Two more things that I would need an advice about, after the helpful comments:

-will a public proxy detection script be enough to keep out at least the anonymous and web proxies?

-is it possible to limit the access for each IP individually and create a script, that will remove the entries for the IP exactly 24 hours after the first visit? Instead of having the cron job delete all data every 24 hours regardless of the time a visitor first came to my site?

解决方案

Saving ip, time and number of accesses to the database is fine, a few hundred rows is not a problem for a mysql database (don't forget to set indexes on the table).

But note that users with shared IP might have problems accessing your page.

Using cookies is problematic because the user can control this and you can't restrict that. Of course, it depends on your application how important is to block the user aftex n accesses.

这篇关于限制每日访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆