📄 view.asp
字号:
<!--#include file="config.asp"-->
<%
Dim sid,yrs
sid=Request.QueryString("sid")
If sid="" Then
Response.Write "<script>alert('ID号不能为空!');window.close()</script>"
Response.End
End If
If not IsNumeric(sid) Then
Response.Write "<script>alert('ID号为非数字!');window.close()</script>"
Response.End
End If
Set yrs=Server.CreateObject("ADODB.RecordSet")
yrs.open "Select * from XH_Subject where id="&sid,conn,1,1
If (yrs.eof and yrs.bof) Then
Response.Write "<script>alert('此ID号不存在或已被删除!');window.close()</script>"
Response.End
End If
yrs.close
Set yrs=nothing
Dim tp,tt,vtip,fIP,prs
If Request.Form("submit")="投票" Then
If RestrictIP=True Then
fIP=Request.ServerVariables("Remote_Addr")
Set rs=Server.CreateObject("ADODB.RecordSet")
rs.open "Select * from XH_IP where sid="&sid&" and ip='"&fIP&"'",conn,1,3
If not(rs.eof and rs.bof) Then
Response.Write "<script>alert('你已经投过票了!');window.close()</script>"
Response.End
Else
rs.addnew
rs("sid")=sid
rs("ip")=fIP
rs("vtime")=now()
rs.update
End If
rs.close
Set rs=nothing
conn.execute("delete from XH_IP where datediff('h',vtime,now())>="&refuseTime)
End If
Set rs=Server.CreateObject("ADODB.RecordSet")
rs.open "Select * from XH_Title where sid="&sid,conn,1,1
If not(rs.eof and rs.bof) Then
Do while not rs.eof
tp=split(Trim(Request.Form(""&rs("id")&""))&",",",")
For tt=0 to Ubound(tp)-1
If tp(tt)<>"" Then
Set prs=Server.CreateObject("ADODB.RecordSet")
prs.open "Select ps from XH_Question where id="&tp(tt),conn,1,3
prs("ps")=prs("ps")+1
prs.update
prs.close
Set prs=nothing
conn.execute("update XH_Title set vcount=vcount+1 where id="&rs("id"))
End If
Next
rs.MoveNext
Loop
End If
rs.close
Set rs=nothing
End If
%>
<%
if AllowView=true then
Response.Write "<script>alert('管理员设置为不允许查看投票结果,如果你是管理员,请登陆后再查看!');location.href='login.asp'</script>"
Response.End
end if
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>雪晖在线投票系统--查看投票结果</title>
<link rel="stylesheet" type="text/css" href="css.css">
</head>
<body topmargin="0" leftmargin="0">
<div align="center">
<%
Set rs=Server.CreateObject("ADODB.RecordSet")
rs.open "select * from XH_Title where sid="&sid,conn,1,1
If not (rs.eof and rs.bof) Then
Do While not rs.eof
%>
<table border="0" width="40%" id="table1" cellspacing="1" cellpadding="3" class="tableborder" style="border-color:#3366FF; border-collapse: collapse">
<tr>
<th colspan="4" bgcolor="#3366FF"><font color="#FFFFFF"><%=rs("title")%></font></th>
</tr>
<tr>
<td colspan="4" align="center" bgcolor="#99CCFF">该问题总投票人数:<%=rs("vcount")%>人</td>
</tr>
<%
Dim rsq,rsp,zps
zps=0
Set rsp=Server.CreateObject("ADODB.RecordSet")
rsp.open "select ps from XH_Question where tid="&rs("id"),conn,1,1
Do While not rsp.eof
zps=zps+rsp("ps")
rsp.MoveNext
loop
rsp.close
Set rsp=nothing
Set rsq=Server.CreateObject("ADODB.RecordSet")
rsq.open "select * from XH_Question where tid="&rs("id"),conn,1,1
If not (rsq.eof and rsq.bof) Then
Do While not rsq.eof
%>
<tr>
<td class="tablebody1"><%=rsq("question")%></td>
<td class="tablebody1" width="10%" nowrap><b><%=rsq("ps")%></b>票</td>
<td class="tablebody1" width="80">
<table border="0" width="<%if zps<>0 then%><%=80*formatNumber((rsq("ps")/zps),3)%><%end if%>" cellspacing="0" cellpadding="0" height="5" bgcolor="#CC99FF">
<tr>
<td></td>
</tr>
</table>
</td>
<td class="tablebody1" width="18%" nowrap>占<b><%If zps=0 Then Response.Write "0.0%" Else Response.Write FormatPercent((rsq("ps")/zps),3) End If%></b></td>
</tr>
<%
rsq.MoveNext
Loop
End If
rsq.close
Set rsq=nothing
%>
</table><br>
<%
rs.MoveNext
Loop
End If
rs.close
Set rs=nothing
Conn.close
Set Conn=nothing
%>
</div>
<div align="center">
<input type="button" name="button" value="关闭" onclick="javascript:window.close()" style="color: #FFFFFF; border: 1px dotted #FFCCCC; background-color: #0099FF; font-weight:bold">
</div>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -