ASP限制ip投票完整實(shí)例代碼_ASP教程
教程Tag:暫無(wú)Tag,歡迎添加,賺取U幣!
推薦:ASP長(zhǎng)數(shù)字用逗號(hào)隔開(kāi)顯示實(shí)例代碼% Function Comma(str) If Not(IsNumeric(str)) Or str = 0 Then Result = 0 ElseIf Len(Fix(str)) 4 Then Result = str Else Pos = Instr(1,str,.) If Pos 0 Then Dec = Mid(str,Pos) End if Res = StrReverse(Fix(str)) LoopCount = 1 While LoopCount =
由于工作關(guān)系,要做個(gè)人空間,其中有一功能是對(duì)用戶投票,要求同一IP只能對(duì)同一用戶投票一次,貼Asp代碼
- <%
- '作者:無(wú)情 出處:
- db_conn(dbs)
- Voteusername=trim(request.QueryString("username"))
- rs_create("select username from [user] where username ='"&Voteusername&"'")
- if rs.eof and rs.bof then
- response.write "錯(cuò)誤的參數(shù),請(qǐng)從正確訪問(wèn)!"
- response.end()
- end if
- '第一種情況是第一次點(diǎn)擊,cookies為空,ip為空
- '第二種情況是點(diǎn)第二個(gè)人投票,第一個(gè)人的cookies存在,第二個(gè)的的cookies不存在,但是ip存在
- '第三種情況是換ip投票,cookies存在,ip為空
- if Request.cookies("dwww")(""&Voteusername&"")="" then
- Response.cookies("dwww")(""&Voteusername&"")=Voteusername&"|"
- Response.cookies("dwww").Expires=Date()+365
- Call VoteBody()
- else
- if instr(request.cookies("dwww")(""&Voteusername&""),request.cookies("dwww")(""&Voteusername&"")&"|")<>0 then
- Call VoteBody()
- else
- 'response.write "對(duì)不起,您已經(jīng)投過(guò)票了!Cookies重復(fù)"
- Response.Write "<script>alert('對(duì)不起,您已經(jīng)投過(guò)票了!');history.back();</script>"
- response.end()
- end if
- end if
- Sub VoteBody()
- Voteusername=trim(request.QueryString("username"))
- CheckIp = Request.ServerVariables("HTTP_X_FORWARDED_FOR") '繞過(guò)代理IP
- If CheckIp = "" Then CheckIp=Request.ServerVariables("REMOTE_ADDR")
- GetUrl=""
- GetUrl=Request.ServerVariables("Http_Referer")
- sql="Select username,ip from vote where username= '"&Voteusername&"' and ip='"&CheckIp&"'"
- rs_create(Sql)
- If Not rs.Bof And Not rs.eof Then
- 'response.write "對(duì)不起,您已經(jīng)投過(guò)票了!IP重復(fù)"
- Response.Write "<script>alert('對(duì)不起,您已經(jīng)投過(guò)票了!');history.back();</script>"
- response.end()
- Else
- conn.execute ("insert into vote (username,ip,addtime) values ('"&Voteusername&"','"&CheckIp&"','"&now()&"')")
- conn.execute ("update [user] set vote=vote+1 where username ='"&Voteusername&"'")
- 'response.write "投票成功!"
- Response.Write "<script>alert('恭喜您,投票成功!');location.href='"&Request.ServerVariables("HTTP_REFERER")&"'</script>"
- response.end()
- End If
- end Sub
- rs_close()
- db_close()
- %>
分享:ASP制作登陸頁(yè)面驗(yàn)證程序用戶登錄驗(yàn)證腳本,Chkpwd.asp % '=======用戶登錄驗(yàn)證腳本======= '如果尚未定義Passed對(duì)象,則將其定義為false,表示沒(méi)有通過(guò)驗(yàn)證 If IsEmpty(Session(Passed)) Then Session(Passed)=false End If 'Session(Passed)=False,表示尚未通過(guò)驗(yàn)證,則開(kāi)始讀取
相關(guān)ASP教程:
- asp FSO 讀寫文件本文件實(shí)現(xiàn)代碼
- asp中isNull、isEmpty和空字符串的區(qū)別
- asp獲取用戶真實(shí)IP地址的方法
- asp連接sqlserver數(shù)據(jù)庫(kù)實(shí)現(xiàn)代碼
- asp中正則表達(dá)式過(guò)濾html代碼函數(shù)
- asp中g(shù)et post提交表單區(qū)別
- 網(wǎng)頁(yè)模板:ASP內(nèi)建對(duì)象Request
- xmlhttp的open方法使用詳解
- ASP的常用的自定義函數(shù)大全
- asp中用for循環(huán)的一個(gè)小技巧
- eWebEditor v3.8 列目錄
- ASP無(wú)組件分頁(yè)實(shí)現(xiàn)思路及代碼
- 相關(guān)鏈接:
- 教程說(shuō)明:
ASP教程-ASP限制ip投票完整實(shí)例代碼
。