php限定时间内同一ip只能访问一次
建立一个数据表
CREATE TABLE `clicks` (
`ip` INT UNSIGNED NOT NULL ,
`time1` INT UNSIGNED NOT NULL ,
`time2` INT UNSIGNED NOT NULL ,
PRIMARY KEY ( `ip` )
) ENGINE = MYISAM
获取ip和当前时间插入到数据表
INSERT INTO clicks (ip,time2) VALUES (INET_ATON('{$_SERVER["REMOTE_ADDR"]}'),UNIX_TIMESTAMP()) ON DUPLICATE KEY UPDATE time1=time2, time2=UNIX_TIMESTAMP()
再次访问时进行验证
SELECT INET_NTOA(ip) FROM clicks WHERE ip=INET_ATON('{$_SERVER["REMOTE_ADDR"]}') AND time1+3600-time2+3600<=UNIX_TIMESTAMP();
在规定的时间内则允许,否则拒绝访问。