前两天编了个计数器 记IP的 测试了两天发现不对 有错 天 改变后 记录却没有按照我向的更新 看了半天也找不到错 看看 咱们论坛里可有人能帮我看看 =======代码开始=========== <% \'数据库链接 dim jsconn set jsconn = server.CreateObject("adodb.connection") jsconn.connectionstring = "Driver={Microsoft Access Driver (*.mdb)};Dbq="&_ server.MapPath("/jishuqi/db1.mdb") jsconn.open \'建立RECORDSET set jstj = server.CreateObject("ADODB.recordset") jstj.open "select * from tj where id =1",jsconn,2,2,1 set js = server.CreateObject("ADODB.recordset") js.open "ip",jsconn,2,2,2 \'获得IP函数 function getip() getip = request.ServerVariables("http_x_forwarded_for") if getip = "" then getip = request.ServerVariables("remote_addr") end if end function
\'获得URL函数 function geturl() geturl=request.ServerVariables("HTTP_REFERER") if geturl = "" then geturl = "天外飞来" end if end function \'检测是否登陆过 函数 function checkip() if request.Cookies("jishu")="" then response.Cookies("jishu")="True" response.Cookies("jishu").expires = DateAdd("h", 1, now) checkip = "False" else checkip = "True" end if end function \'天数改变函数 sub changeday() today = jstj("today") jstj("today")=0 jstj("yesterday")=today if today >= jstj("top") then jstj("top")=today end if jstj.update end sub \'删除IP记录函数 sub delip() sqlstr="delete * from ip where start <=#"&date()&"#" jsconn.execute(sqlstr) end sub \'月份改变函数 sub changemonth() changeday() tmonth = jstj("month") jstj("month")=0 jstj("lastmonth")=tmonth jstj.update delip() end sub \'检测时间是否改变 函数 sub checktime() temp = application("js_time") if temp = empty then application("js_time") = date() end if if application("js_time") <> date() then if month(application("js_time")) <> month(date()) then changemonth() else changeday() end if application("js_time") = date() end if end sub \'主要内容开始 if checkip() = "False" then checktime() js.addnew js("ip")=getip() js("url")=geturl() js("start")=now() js.update today = jstj("today") tmonth = jstj("month") jstj("today")=today+1 jstj("month")=tmonth+1 jstj("sum")=jstj("sum")+1 jstj.update end if \'显示IP记录 response.Write("<a href=?action=view>今日"&jstj("today")&"位</a> <a href=?action=view&sdate="&dateadd("d",-1,date())&">昨日"&jstj("yesterday")&"位</a> 本月"&jstj("month")&"位 上月"&jstj("lastmonth")&"位 共"&jstj("sum")&"位 日最高"&jstj("top")&"位") action=request("action") if action = "view" then sdate = request("sdate") if sdate = "" then sdate = date() end if set jst = server.CreateObject("ADODB.recordset") jst.open "select * from ip where start >=#"&sdate&"# and start <=#"&dateadd("d",1,sdate)&"#",jsconn,2,2,1 if not jst.eof and not jst.bof then response.Write("<table><tr><td>编号</td><td>IP</td><td>URL</td><td>TIME</td></tr>") jst.movefirst while not jst.eof response.Write("<tr><td>"&jst("id")&"</td><td>"&jst("ip")&"</td><td>"&jst("url")&"</td><td>"&jst("start")&"</td></tr>") jst.movenext wend response.Write("</table>") end if jst.close set jst = nothing end if \'数据库关闭 jstj.close set jstj = nothing js.close set js = nothing jsconn.close set jsconn=nothing %>
=======代码结束=========== 地址是 fly.ahstu.cn |