Home > php教程 > php手册 > body text

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

WBOY
Release: 2016-06-13 11:36:18
Original
811 people have browsed it

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

  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

source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!