国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > ASP > 正文

ASP限制ip投票完整實例代碼_ASP教程

2024-05-04 11:04:26
字體:
來源:轉載
供稿:網友

推薦:ASP長數字用逗號隔開顯示實例代碼
% 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 =

由于工作關系,要做個人空間,其中有一功能是對用戶投票,要求同一IP只能對同一用戶投票一次,貼Asp代碼

  1. <% 
  2. '作者:無情 出處:  
  3. db_conn(dbs)  
  4. Voteusername=trim(request.QueryString("username"))  
  5. rs_create("select username from [user] where username ='"&Voteusername&"'")  
  6. if rs.eof and rs.bof then 
  7. response.write "錯誤的參數,請從正確訪問!" 
  8. response.end() 
  9. end if 
  10.  
  11. '第一種情況是第一次點擊,cookies為空,ip為空 
  12. '第二種情況是點第二個人投票,第一個人的cookies存在,第二個的的cookies不存在,但是ip存在 
  13. '第三種情況是換ip投票,cookies存在,ip為空 
  14.  
  15. if Request.cookies("dwww")(""&Voteusername&"")="" then 
  16. Response.cookies("dwww")(""&Voteusername&"")=Voteusername&"|" 
  17. Response.cookies("dwww").Expires=Date()+365 
  18. Call VoteBody() 
  19. else 
  20. if instr(request.cookies("dwww")(""&Voteusername&""),request.cookies("dwww")(""&Voteusername&"")&"|")<>0 then 
  21. Call VoteBody() 
  22. else 
  23. 'response.write "對不起,您已經投過票了!Cookies重復" 
  24. Response.Write "<script>alert('對不起,您已經投過票了!');history.back();</script>" 
  25. response.end() 
  26. end if  
  27. end if 
  28.  
  29. Sub VoteBody() 
  30. Voteusername=trim(request.QueryString("username")) 
  31. CheckIp = Request.ServerVariables("HTTP_X_FORWARDED_FOR"'繞過代理IP 
  32. If CheckIp = "" Then CheckIp=Request.ServerVariables("REMOTE_ADDR"
  33. GetUrl="" 
  34. GetUrl=Request.ServerVariables("Http_Referer"
  35.  
  36. sql="Select username,ip from vote where username= '"&Voteusername&"' and ip='"&CheckIp&"'" 
  37. rs_create(Sql) 
  38. If Not rs.Bof And Not rs.eof Then  
  39. 'response.write "對不起,您已經投過票了!IP重復" 
  40. Response.Write "<script>alert('對不起,您已經投過票了!');history.back();</script>" 
  41. response.end() 
  42. Else 
  43. conn.execute ("insert into vote (username,ip,addtime) values ('"&Voteusername&"','"&CheckIp&"','"&now()&"')"
  44. conn.execute ("update [user] set vote=vote+1 where username ='"&Voteusername&"'"
  45. 'response.write "投票成功!" 
  46. Response.Write "<script>alert('恭喜您,投票成功!');location.href='"&Request.ServerVariables("HTTP_REFERER")&"'</script>" 
  47. response.end() 
  48. End If  
  49. end Sub 
  50.  
  51. rs_close() 
  52. db_close() 
  53. %> 

分享:ASP制作登陸頁面驗證程序
用戶登錄驗證腳本,Chkpwd.asp % '=======用戶登錄驗證腳本======= '如果尚未定義Passed對象,則將其定義為false,表示沒有通過驗證 If IsEmpty(Session(Passed)) Then Session(Passed)=false End If 'Session(Passed)=False,表示尚未通過驗證,則開始讀取

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 普陀区| 文山县| 庄浪县| 新密市| 丰台区| 罗平县| 松滋市| 微博| 咸丰县| 会东县| 涟水县| 贵港市| 东乡族自治县| 米脂县| 桃园县| 中超| 红桥区| 湛江市| 高唐县| 博爱县| 通辽市| 彰化市| 云霄县| 舒城县| 辽中县| 平泉县| 尤溪县| 永登县| 若羌县| 阿瓦提县| 长垣县| 尼勒克县| 长宁县| 仁寿县| 蒲城县| 泸定县| 乌兰县| 科尔| 连山| 二手房| 黄陵县|