ASP关于限制时间访问的问题

阿三阿四一起来 2017-12-05 11:55:04
原代码是这样的:
Function Stop_IP()
Dim Sqlin_IP,rsKill_IP,Kill_IPsql
Sqlin_IP=Request.ServerVariables("REMOTE_ADDR")
Kill_IPsql="select Sqlin_IP from SqlIn where Sqlin_IP='"&Sqlin_IP&"' and kill_ip=true"
Set rsKill_IP=Easp.db.Exec(Kill_IPsql)
If Not(rsKill_IP.eof or rsKill_IP.bof) Then
N_Alert(Neeao_Kill_Info)
Response.End
End If
rsKill_IP.close
End Function

我想修改成限制多少秒后可以访问,修改后没有限制了,请问错误在哪里,如何修改:

Function Stop_IP()
Dim Sqlin_IP,rsKill_IP,Kill_IPsql,SqlIn_TIME
Sqlin_IP=Request.ServerVariables("REMOTE_ADDR")
Kill_IPsql="select Sqlin_IP,SqlIn_TIME from SqlIn where Sqlin_IP='"&Sqlin_IP&"' and kill_ip=true"
Set rsKill_IP=server.createobject("adodb.recordset")
rsKill_IP.open Kill_IPsql,conn,1,1
SqlIn_TIME=rsKill_IP("SqlIn_TIME")
IF DateDiff("s",SqlIn_TIME,now())>= 12 then
Response.write " 提示文字 "
Response.End
End If
rsKill_IP.close
End Function
...全文
841 24 打赏 收藏 转发到动态 举报
写回复
用AI写文章
24 条回复
切换为时间正序
请发表友善的回复…
发表回复
qq_41267587 2017-12-31
  • 打赏
  • 举报
回复
sum1=request.Cookies("sum1") name1=request("name1") name2=request.cookies("name2") if name2=name1 then sum1=sum1+1 response.Cookies("sum1")=sum1 response.cookies("sum1").expires=data +1 response.Cookies("name1")=name1 response.cookies("name1").expires=data +1 if sum1=3 then sql="select * from biao where user='"&name1&"'" rs.open sql,conn,1,3 rs("lock")=true rs("lock")=now() rs.update rs.close set rs=nothing response.write"对不起由于你的提交次数超过限制,系统自动锁定该帐号" end if else response.Cookies("sum1")=1 response.cookies("sum1").expires=data +1 response.Cookies("name1")=name1 response.cookies("name1").expires=data +1 end if 参考这个方法试试吧
  • 打赏
  • 举报
回复
或者改写成如果记录三次后就锁定IP也可以,但不要用Session这种方式的,不知道哪位大侠能指点一二。
  • 打赏
  • 举报
回复
引用 20 楼 liudianhalf 的回复:
自己帮自己吧 既然是判断条件出问题,把几个值输出一下,或者简单写个测试页,看看问题出在哪 输出以后,应该可以看到是数据类型自动转换成字符型后判断了 a=9 b=12 虽然前面可能是这种定义方式,但貌似在服务器环境变化以后会产生类型自动转换为字符 response.write a>b response.write cint(a)>cint(b) 你可以加上if cint(datediff...)>cint(...)
我找到问题了,但不会写那种判断的代码 Kill_IPsql="select Sqlin_IP,SqlIn_TIME from SqlIn where Sqlin_IP='"&Sqlin_IP&"' and kill_ip=true" Set rsKill_IP=server.createobject("adodb.recordset") rsKill_IP.open Kill_IPsql,conn,1,1 SqlIn_TIME=rsKill_IP("SqlIn_TIME") If Not(rsKill_IP.eof or rsKill_IP.bof) Then SqlIn_TIME=rsKill_IP("SqlIn_TIME") IF DateDiff("s",SqlIn_TIME,now())>= Neeao_Ip_Time_yeson then Response.write " "&SqlIn_TIME&" " response.end else sql = "update [Qiledo_SqlIn] Set Sqlin_IP='"&Sqlin_IP&"',kill_ip=False where Sqlin_IP='"&Sqlin_IP&"'" conn.execute(sql) end if 以上红色的代码b]kill_ip为False后,SqlIn_TIME=rsKill_IP("SqlIn_TIME")这里就没有值读取不到造成的,但不知道b]kill_ip为False后怎样才能读取到时间的值(SqlIn_TIME=rsKill_IP("SqlIn_TIME")),大侠能帮看看如何写这代码吗?
liudianhalf 2017-12-13
  • 打赏
  • 举报
回复
自己帮自己吧 既然是判断条件出问题,把几个值输出一下,或者简单写个测试页,看看问题出在哪 输出以后,应该可以看到是数据类型自动转换成字符型后判断了 a=9 b=12 虽然前面可能是这种定义方式,但貌似在服务器环境变化以后会产生类型自动转换为字符 response.write a>b response.write cint(a)>cint(b) 你可以加上if cint(datediff...)>cint(...)
  • 打赏
  • 举报
回复
有没有谁路过的帮我看看这是什么原因吗?
什么都不能 2017-12-06
  • 打赏
  • 举报
回复
没看懂,不是自己写好代码了吗?问题是什么?
  • 打赏
  • 举报
回复
以下是完整代码,只想在其中限制IP访问多少秒开放访问权限,请问如何修改? <% '--------定义部份------------------ Dim Neeao_Application_Value Dim Neeao_Post,Neeao_Get,Neeao_Inject,Neeao_Inject_Keyword,Neeao_Kill_IP,Neeao_Write_Data Dim Neeao_Alert_Url,Neeao_Alert_Info,Neeao_Kill_Info,Neeao_Alert_Type Dim Neeao_Sec_Forms,Neeao_Sec_Form_open,Neeao_Sec_Form If IsArray(Application("Neeao_config_info"))=False Then Call PutApplicationValue() Neeao_Application_Value = Application("Neeao_config_info") '获取配置信息 Neeao_Inject = Neeao_Application_Value(0) Neeao_Kill_IP = Neeao_Application_Value(1) Neeao_Write_Data = Neeao_Application_Value(2) Neeao_Alert_Url = Neeao_Application_Value(3) Neeao_Alert_Info = Neeao_Application_Value(4) Neeao_Kill_Info = Neeao_Application_Value(5) Neeao_Alert_Type = Neeao_Application_Value(6) Neeao_Sec_Forms = Neeao_Application_Value(7) Neeao_Sec_Form_open = Neeao_Application_Value(8) '安全页面参数 Neeao_Sec_Form = split(Neeao_Sec_Forms,"|") Neeao_Inject_Keyword = split(Neeao_Inject,"|") If Neeao_Kill_IP=1 Then Stop_IP If Request.Form<>"" Then StopInjection(Request.Form) If Request.QueryString<>"" Then StopInjection(Request.QueryString) If Request.Cookies<>"" Then StopInjection(Request.Cookies) Function Stop_IP() Dim Sqlin_IP,rsKill_IP,Kill_IPsql Sqlin_IP=Request.ServerVariables("REMOTE_ADDR") Kill_IPsql="select Sqlin_IP from SqlIn where Sqlin_IP='"&Sqlin_IP&"' and kill_ip=true" Set rsKill_IP=Easp.db.Exec(Kill_IPsql) If Not(rsKill_IP.eof or rsKill_IP.bof) Then N_Alert(Neeao_Kill_Info) Response.End End If rsKill_IP.close End Function 'sql通用防注入主函数 Function StopInjection(values) Dim Neeao_Get,Neeao_i For Each Neeao_Get In values If Neeao_Sec_Form_open = 1 Then For Neeao_i=0 To UBound(Neeao_Sec_Form) If Instr(LCase(SelfName),Neeao_Sec_Form(Neeao_i))> 0 Then Exit Function else Call Select_BadChar(values,Neeao_Get) End If Next Else Call Select_BadChar(values,Neeao_Get) End If Next End Function Function Select_BadChar(values,Neeao_Get) Dim Neeao_Xh Dim Neeao_ip,Neeao_url,Neeao_sql Neeao_ip = Request.ServerVariables("REMOTE_ADDR") Neeao_url = Request.ServerVariables("URL") For Neeao_Xh=0 To Ubound(Neeao_Inject_Keyword) If Instr(LCase(values(Neeao_Get)),Neeao_Inject_Keyword(Neeao_Xh))<>0 Then If Neeao_Write_Data = 1 Then Neeao_sql = "insert into SqlIn(Sqlin_IP,SqlIn_Web,SqlIn_FS,SqlIn_CS,SqlIn_SJ) values('"&Neeao_ip&"','"&Neeao_url&"','"&intype(values)&"','"&Neeao_Get&"','"&N_Replace(values(Neeao_Get))&"')" 'response.write Neeao_sql Easp.db.Exec(Neeao_sql) End If N_Alert(Neeao_Alert_Info) Response.End End If Next End Function '输出警告信息 Function N_Alert(Neeao_Alert_Info) Dim str 'response.write "test" str = "<"&"Script Language=JavaScript"&">" Select Case Neeao_Alert_Type Case 1 str = str & "window.opener=null; window.close();" Case 2 str = str & "alert('"&Neeao_Alert_Info&"');window.opener=null; window.close();" Case 3 str = str & "location.href='"&Neeao_Alert_Url&"';" Case 4 str = str & "alert('"&Neeao_Alert_Info&"');location.href='"&Neeao_Alert_Url&"';" end Select str = str & "<"&"/Script"&">" response.write str End Function '判断注入类型函数 Function intype(values) Select Case values Case Request.Form intype = "Post" Case Request.QueryString intype = "Get" Case Request.Cookies intype = "Cookies" end Select End Function '干掉xss脚本 Function N_Replace(N_urlString) N_urlString = Replace(N_urlString,"'","''") N_urlString = Replace(N_urlString, ">", ">") N_urlString = Replace(N_urlString, "<", "<") N_Replace = N_urlString End Function Sub PutApplicationValue() dim infosql,rsinfo set rsinfo=Easp.db.Exec("select N_In,Kill_IP,WriteSql,alert_url,alert_info,kill_info,N_type,Sec_Forms,Sec_Form_open from sqlconfig") Redim ApplicationValue(9) dim i for i=0 to 8 ApplicationValue(i)=rsinfo(i) next set rsinfo=nothing Application.Lock set Application("Neeao_config_info")=nothing Application("Neeao_config_info")=ApplicationValue Application.unlock end Sub '获取本页文件名 Function SelfName() SelfName = Mid(Request.ServerVariables("URL"),InstrRev(Request.ServerVariables("URL"),"/")+1) End Function %>
  • 打赏
  • 举报
回复
IF DateDiff("s",SqlIn_TIME,now())< Neeao_Ip_Time_yeson the 如果这样写就有效,但是一直限制没有能按我设置的时间执行else下边的
  • 打赏
  • 举报
回复
引用 15 楼 hanpoyangtitan 的回复:
[quote=引用 14 楼 R3R4176 的回复:] [quote=引用 12 楼 hanpoyangtitan 的回复:] SqlIn_TIME=rsKill_IP("SqlIn_TIME") '这个地方调试一下 response.write SqlIn_TIME response.write Neeao_Ip_Time_yeson IF DateDiff("s",SqlIn_TIME,now())>= Neeao_Ip_Time_yeson then '这个地方看下有没有进来 response.write "解禁ip"
试了这句没有执行,直接跳到下一句去了,这句如何才能执行呢?[/quote] 符合DateDiff("s",SqlIn_TIME,now())>= Neeao_Ip_Time_yeson 就会执行啊,看打印出来的两个时间和差值[/quote] 刚测试看了一下数据同样是直接else跳到更新数据那句去了,而IF时间限制那句没执行,这句应该怎么写才起作用呢?
什么都不能 2017-12-06
  • 打赏
  • 举报
回复
引用 14 楼 R3R4176 的回复:
[quote=引用 12 楼 hanpoyangtitan 的回复:] SqlIn_TIME=rsKill_IP("SqlIn_TIME") '这个地方调试一下 response.write SqlIn_TIME response.write Neeao_Ip_Time_yeson IF DateDiff("s",SqlIn_TIME,now())>= Neeao_Ip_Time_yeson then '这个地方看下有没有进来 response.write "解禁ip"
试了这句没有执行,直接跳到下一句去了,这句如何才能执行呢?[/quote] 符合DateDiff("s",SqlIn_TIME,now())>= Neeao_Ip_Time_yeson 就会执行啊,看打印出来的两个时间和差值
  • 打赏
  • 举报
回复
引用 12 楼 hanpoyangtitan 的回复:
SqlIn_TIME=rsKill_IP("SqlIn_TIME") '这个地方调试一下 response.write SqlIn_TIME response.write Neeao_Ip_Time_yeson IF DateDiff("s",SqlIn_TIME,now())>= Neeao_Ip_Time_yeson then '这个地方看下有没有进来 response.write "解禁ip"
试了这句没有执行,直接跳到下一句去了,这句如何才能执行呢?
  • 打赏
  • 举报
回复
看了一下数据直接else跳到更新数据那句去了,而IF时间限制那句没执行,这句应该怎么写才起作用呢?
什么都不能 2017-12-06
  • 打赏
  • 举报
回复
SqlIn_TIME=rsKill_IP("SqlIn_TIME") '这个地方调试一下 response.write SqlIn_TIME response.write Neeao_Ip_Time_yeson IF DateDiff("s",SqlIn_TIME,now())>= Neeao_Ip_Time_yeson then '这个地方看下有没有进来 response.write "解禁ip"
  • 打赏
  • 举报
回复
引用 8 楼 hanpoyangtitan 的回复:
你的程序连的是什么数据库, 错误信息是什么?
Function Stop_IP() Dim Sqlin_IP,rsKill_IP,Kill_IPsql,SqlIn_TIME Sqlin_IP=Request.ServerVariables("REMOTE_ADDR") Kill_IPsql="select Sqlin_IP,SqlIn_TIME from Qiledo_SqlIn where Sqlin_IP='"&Sqlin_IP&"' and kill_ip=true" Set rsKill_IP=server.createobject("adodb.recordset") rsKill_IP.open Kill_IPsql,conn,1,1 If Not(rsKill_IP.eof or rsKill_IP.bof) Then SqlIn_TIME=rsKill_IP("SqlIn_TIME") IF DateDiff("s",SqlIn_TIME,now())>= Neeao_Ip_Time_yeson then Response.write " "&SqlIn_TIME&" " response.end else sql = "update [Qiledo_SqlIn] Set Sqlin_IP='"&Sqlin_IP&"',kill_ip=False where Sqlin_IP='"&Sqlin_IP&"'" conn.execute(sql) end if End If rsKill_IP.close End Function 这样改没出错了,但是没起作用,是什么回事呢?
  • 打赏
  • 举报
回复
引用 8 楼 hanpoyangtitan 的回复:
你的程序连的是什么数据库, 错误信息是什么?
是SqlIn_TIME=rsKill_IP("SqlIn_TIME")这一行出错,不知道是什么意思了,看不懂: ADODB.Field ���� '800a0bcd' BOF �� EOF ����һ���ǡ��桱�����ߵ�ǰ�ļ�¼�ѱ�ɾ��������IJ���Ҫ��һ����ǰ�ļ�¼�� xx.asp���� 41
  • 打赏
  • 举报
回复
Function Stop_IP() Dim Sqlin_IP,rsKill_IP,Kill_IPsql,SqlIn_TIME Sqlin_IP=Request.ServerVariables("REMOTE_ADDR") Kill_IPsql="select Sqlin_IP,SqlIn_TIME from SqlIn where Sqlin_IP='"&Sqlin_IP&"' and kill_ip=true" Set rsKill_IP=server.createobject("adodb.recordset") rsKill_IP.open Kill_IPsql,conn,1,1 SqlIn_TIME=rsKill_IP("SqlIn_TIME") IF DateDiff("s",SqlIn_TIME,now())>= Neeao_Ip_Time_yeson then Response.write " "&SqlIn_TIME&" " response.end else sql = "update [SqlIn] set kill_ip = false,SqlIn_TIME = #now# where Sqlin_IP='"&Sqlin_IP&"'" conn.execute(sql) end if rsKill_IP.close End Function 是红色SqlIn_TIME=rsKill_IP("SqlIn_TIME")这一行出错,不知道是什么意思了,看不懂: ADODB.Field ���� '800a0bcd' BOF �� EOF ����һ���ǡ��桱�����ߵ�ǰ�ļ�¼�ѱ�ɾ��������IJ���Ҫ��һ����ǰ�ļ�¼�� xx.asp���� 41
什么都不能 2017-12-06
  • 打赏
  • 举报
回复
你的程序连的是什么数据库, 错误信息是什么?
  • 打赏
  • 举报
回复
引用 6 楼 hanpoyangtitan 的回复:
用把diff改为datediff 然后确保第2个,第3个是date类型,最好CDate一下CDate(SqlIn_TIME)
第2,3个是date类型测试输出是正常的,按照你这样改了也出错,我改成以下: Function Stop_IP() Dim Sqlin_IP,rsKill_IP,Kill_IPsql,SqlIn_TIME Sqlin_IP=Request.ServerVariables("REMOTE_ADDR") Kill_IPsql="select Sqlin_IP,SqlIn_TIME from SqlIn where Sqlin_IP='"&Sqlin_IP&"' and kill_ip=true" Set rsKill_IP=server.createobject("adodb.recordset") rsKill_IP.open Kill_IPsql,conn,1,1 SqlIn_TIME=rsKill_IP("SqlIn_TIME") IF DateDiff("s",SqlIn_TIME,now())>= Neeao_Ip_Time_yeson then Response.write " "&SqlIn_TIME&" " response.end else sql = "update [SqlIn] set kill_ip = false,SqlIn_TIME = #now# where Sqlin_IP='"&Sqlin_IP&"'" conn.execute(sql) end if rsKill_IP.close End Function 我这样改后IF DateDiff("s",SqlIn_TIME,now())>= Neeao_Ip_Time_yeson then这句没有出错了,但是到了上面红色那句出错,这出错应该如何改呢?
什么都不能 2017-12-06
  • 打赏
  • 举报
回复
首先
引用 5 楼 R3R4176 的回复:
[quote=引用 4 楼 hanpoyangtitan 的回复:] [quote=引用 3 楼 R3R4176 的回复:] [quote=引用 2 楼 hanpoyangtitan 的回复:] 没看懂,不是自己写好代码了吗?问题是什么?
上面代码如果kill_ip=true 侧永久无法访问网站,我想改成限制多少时间后又可以访问网站这样的 [/quote] 你这个表里不是有个记录封禁的时间吗? 设 bannedDatetime '从表里取出的封禁时间 if diff('s', bannedDatetime, now) < sys_settings_banned_datetime then showWarning "..." '指定的提示信息 response.end '终止 else sql = "update [table_name] set kill_ip = false,admit_datetime = #now# wher e....." conn.execute(sql) end if[/quote] 根据hanpoyangtitan兄的,我修改成以下: Dim Sqlin_IP,rsKill_IP,Kill_IPsql,SqlIn_TIME Sqlin_IP=Request.ServerVariables("REMOTE_ADDR") Kill_IPsql="select Sqlin_IP,SqlIn_TIME from SqlIn where Sqlin_IP='"&Sqlin_IP&"' and kill_ip=true" Set rsKill_IP=server.createobject("adodb.recordset") rsKill_IP.open Kill_IPsql,conn,1,1 SqlIn_TIME=rsKill_IP("SqlIn_TIME") if diff('s', SqlIn_TIME(这是提交入库的时间), now) < Neeao_Ip_Time_yeson(这是调用设置的时间如:10) then showWarning "提示信息" response.end else sql = "update [SqlIn] set kill_ip = false,SqlIn_TIME = #now# wher Sqlin_IP='"&Sqlin_IP&"'" conn.execute(sql) end if rsKill_IP.close End Function 以上括号文字只做说明作用,忽略。 但提示红色这行有错误,请问错误在哪里如何才能实现呢? Microsoft VBScript 编译器错误 错误 '800a03ea' 语法错误 xx.asp,行 42 if diff('s', SqlIn_TIME, now) < Neeao_Ip_Time_yeson then --------^[/quote] 用把diff改为datediff 然后确保第2个,第3个是date类型,最好CDate一下CDate(SqlIn_TIME)
  • 打赏
  • 举报
回复
引用 4 楼 hanpoyangtitan 的回复:
[quote=引用 3 楼 R3R4176 的回复:] [quote=引用 2 楼 hanpoyangtitan 的回复:] 没看懂,不是自己写好代码了吗?问题是什么?
上面代码如果kill_ip=true 侧永久无法访问网站,我想改成限制多少时间后又可以访问网站这样的 [/quote] 你这个表里不是有个记录封禁的时间吗? 设 bannedDatetime '从表里取出的封禁时间 if diff('s', bannedDatetime, now) < sys_settings_banned_datetime then showWarning "..." '指定的提示信息 response.end '终止 else sql = "update [table_name] set kill_ip = false,admit_datetime = #now# wher e....." conn.execute(sql) end if[/quote] 根据hanpoyangtitan兄的,我修改成以下: Dim Sqlin_IP,rsKill_IP,Kill_IPsql,SqlIn_TIME Sqlin_IP=Request.ServerVariables("REMOTE_ADDR") Kill_IPsql="select Sqlin_IP,SqlIn_TIME from SqlIn where Sqlin_IP='"&Sqlin_IP&"' and kill_ip=true" Set rsKill_IP=server.createobject("adodb.recordset") rsKill_IP.open Kill_IPsql,conn,1,1 SqlIn_TIME=rsKill_IP("SqlIn_TIME") if diff('s', SqlIn_TIME(这是提交入库的时间), now) < Neeao_Ip_Time_yeson(这是调用设置的时间如:10) then showWarning "提示信息" response.end else sql = "update [SqlIn] set kill_ip = false,SqlIn_TIME = #now# wher Sqlin_IP='"&Sqlin_IP&"'" conn.execute(sql) end if rsKill_IP.close End Function 以上括号文字只做说明作用,忽略。 但提示红色这行有错误,请问错误在哪里如何才能实现呢? Microsoft VBScript 编译器错误 错误 '800a03ea' 语法错误 xx.asp,行 42 if diff('s', SqlIn_TIME, now) < Neeao_Ip_Time_yeson then --------^
加载更多回复(2)

28,390

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧