Home  >  Article  >  Backend Development  >  用php来限制每个ip每天浏览页面数量的实现思路_php技巧

用php来限制每个ip每天浏览页面数量的实现思路_php技巧

WBOY
WBOYOriginal
2016-05-16 20:22:461027browse

实现思路:首先,创建一个表,比如下面的

复制代码 代码如下:

  CREATE TABLE ip_log
  (

  ip_log_ip VARCHAR(40),
  ip_log_date DATE,
  ip_log_visits TINYINT(1),
  ip_log_page varchar(255),
  PRIMARY KEY(ip_log_page,ip_log_ip,ip_log_date),
  );

  然后,写代码,当用户访问时记录下ip信息,浏览次数初始值为1,

  当浏览页数等于设置的值时,不允许用户访问。

  最后你可以每天晚上00:00运行一个cron表中删除所有数据,比如使用truncate

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn