求一个网页代码!同一个IP一天(24小时)内只能打开一个链接的代码

来源:百度知道 编辑:UC知道 时间:2024/06/23 06:30:39
同一个IP一天(24小时)内只能打开一个链接的代码!!
abingpow这位朋友 能不能把具体怎么做或是具体代码 给一下啊 我这方面不太懂 拜托了

用户访问时将IP记录到数据库,再次访问则判断,不超过一天则限制,否则更新IP访问日期
假设有表table1,内有字段id,ip,dt

<%
ip = getIP()
sql = "select id from table1 where ip='"+ip+"' and now-dt<=1"
rs.open sql,conn
if rs.eof then
rs.close
sql = "delete from table1 where ip='"+ip+"'"
conn.execute sql
sql = "insert into table1(ip,dt) values('"+ip+"',now)"
conn.execute sql
else
rs.close
response.write "你已经访问过本页了"
response.End()
end if

Function getIP()
Dim strIPAddr
If Request.ServerVariables("HTTP_X_FORWARDED_FOR") = "" OR InStr(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), "unknown") > 0 Then
strIPAddr = Request.ServerVariables("REMOTE_ADDR")
ElseIf InStr(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), ",") > 0 Then