日期:2014-05-18 浏览次数:21463 次
共<span id="voteNum">0</span>票
<input type="button" id="btnVote" value="投票"/>
$(function(){
     $("#btnVote").click(function(){
           if($.cookie("vote")!=null){
               alert("已经投过票,请无重复投票,谢谢!");
               return;
           }else{
              $("#voteNum").text(parseInt($("#voteNum").text())+1); //票数加1
              alert("谢谢投票!");
              //写cookie到客户端
              $.cookie("vote","XXX", {expires: 7, path: ‘/’, domain: ‘jquery.com’, secure: true});
           }
     });
});
------解决方案--------------------
将IP记录数据库,,,,,,,,,, 读取数据库进行判读。。
------解决方案--------------------
最好只能做到,检测IP,并记录。
同时检查是否使用代理,若使用代理,拒绝投票,就可以了,cookie也用上,不过那个太容易绕过去了,
下面代码做代理检测的
       public static bool checkIpPro()
       {
           bool bl = false;
           string FY_IP = string.Empty;
           FY_IP = HttpContext.Current.Request.ServerVariables["ALL_HTTP"].ToLower();
           if (FY_IP.IndexOf("proxy") > 0 || FY_IP.IndexOf("http_via") > 0 || FY_IP.IndexOf("http_pragma") > 0 ||  
               !string.IsNullOrEmpty(HttpContext.Current.Request.ServerVariables["HTTP_PROXY_CONNECTION"])||
               !string.IsNullOrEmpty(HttpContext.Current.Request.ServerVariables["HTTP_VIA"]) ||  
               !string.IsNullOrEmpty(HttpContext.Current.Request.ServerVariables["HTTP_USER_AGENT_VIA"]) ||
               !string.IsNullOrEmpty(HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"] )||  
               !string.IsNullOrEmpty(HttpContext.Current.Request.ServerVariables["HTTP_PROXY_CONNECTION"] ) ||
            
              !string.IsNullOrEmpty(HttpContext.Current.Request.ServerVariables["HTTP_CACHE_INFO"])
               )
           {
               bl = true;
           }
           return bl;
       }
------解决方案--------------------
要放入数据库啊。用cookies?禁用了cookies或清除了cookies咋办?