📄 vote.asp
字号:
<!--#include file="../Include/Class_Conn.asp" -->
<!--#include file="../Include/Class_Main.asp" -->
<%
Dim ds,i
Dim VoteResult,VoteID,VoteText,VoteUbound,VoteType,VoteNum,Result
VoteID=safeRequest("VoteID")
VoteResult=safeRequest("Vote")
VoteResult=Split(VoteResult,",")
VoteType=safeRequest("VoteType")
If Request.Cookies(sCacheName&"Vote"&VoteID)="" And Session("master_id")="" Then
If Ubound(VoteResult)<0 Then
Response.write "<div align=center>你还没有投票,不允许此操作。</div>"
Response.End()
End if
End if
set rs=conn.Execute("SELECT TITLE,VOTETEXT,VOTENUM,VOTETOTAL FROM pH_Vote WHERE ID="&VoteID&" And Lock=0")
If not rs.Eof And not rs.Bof then
ds=rs.getrows()
set rs=nothing
VoteText=ds(1,0)
VoteText=Split(VoteText,"|")
VoteNum=ds(2,0)
VoteNum=Split(VoteNum,"|")
VoteUbound=Ubound(VoteText)
REDIM userVote(VoteUbound+1)
For i=0 To VoteUbound
userVote(i)=0
Next
For i=0 To Ubound(VoteResult)
userVote(VoteResult(i))=1
Next
For i=0 To VoteUbound
If Request.Cookies(sCacheName&"Vote"&VoteID)="" Then
VoteNum(i)=VoteNum(i)+userVote(i)
Else
VoteNum(i)=VoteNum(i)+0
End if
Next
Result=Join(VoteNum,"|")
If Request.Cookies(sCacheName&"Vote"&VoteID)="" Then
sql="UPDATE pH_Vote SET VOTENUM='"&Result&"',VOTETOTAL=VoteTotal+1 WHERE ID="&VoteID&" And Lock=0"
conn.Execute(sql)
If Session("master_id")="" Then
Response.Cookies(sCacheName&"Vote"&VoteID)=1
Response.Cookies(sCacheName&"Vote"&VoteID).Expires=date+24
End If
ShowResult VoteText,VoteNum,ds(0,0),0
Else
ShowResult VoteText,VoteNum,ds(0,0),1
If Session("master_id")="" Then
Response.Cookies(sCacheName&"Vote"&VoteID)=1
Response.Cookies(sCacheName&"Vote"&VoteID).Expires=date+24
End If
End If
Else
Response.write ("请不要手动修改地址参数,同时请填写好所有必须填写的项目!")
Response.End()
End if
Sub ShowResult(VoteText,VoteNum,VoteTitle,IsVote)
Dim i,LoopNum,VoteCount,rate,j
VoteCount=0
If not IsArray(VoteText) And not IsArray(VoteNum) Then Response.end
%>
<html>
<head>
<style type="text/css">
<!--
td {
font-size: 12px;
}
-->
</style>
<title>查看投票</title>
</head>
<body>
<table width="600" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#E8F7FF">
<tr>
<td height="25" align="center" bgcolor="#C4ECFF">投票结果</td>
</tr>
<tr>
<td bgcolor="#FFFFFF"><table width="100%" border="0" align="center" cellpadding="10" cellspacing="0">
<tr>
<td>投票题目:<%=VoteTitle%> <br>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<%
For i=0 To Ubound(VoteNum)
VoteCount=VoteCount+VoteNum(i)
Next
j=1
For i=0 To Ubound(VoteText)
if votecount>0 then rate=Cint((VoteNum(i)/VoteCount) * 100)
%>
<tr>
<td width="200" height="25"> <%=i+1&". "&VoteText(i)%> </td>
<td width="80"><%=" 票数:"&VoteNum(i)%></td>
<td><img src="../Images/bar<%=j%>.gif" width="<%=rate%>" height="9" align="absmiddle"><img src="../Images/bar<%=j%>_1.gif" height="9" align="absmiddle"> <%=rate&"%"%> </td>
</tr>
<%j=j+1
If j Mod 5 =0 Then j=1
Next%>
</table></td>
</tr>
</table></td>
</tr>
<tr bgcolor="#E8F7FF">
<td height="22">
<%If IsVote=1 Then Response.Write "你已经投过票!" Else Response.Write "<font color=800000>这是你第一次投票!</font>"%></td>
</tr>
</table>
</body>
</html>
<%End Sub%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -