?? voteshow.asp
字號:
<!--#include file="MarcosCB.asp"-->
<%
getConn()
dim theAct,voteId,optionId,pageTitle,pageOther
voteId=getPost("voteId")
theAct=getPost("theAct")
optionId=getPost("optionId")
if not isNumeric(voteId) then
echo "參數錯誤!"
closeConn()
response.end
end if
if theAct<>"" then
isIn()
end if
select case theAct
case "setLock"
isAdmin()
conn.execute("update Marcos_Vote set isLocked=true where voteId="&voteId)
locate "voteShow.asp?voteId="&voteId
case "unLock"
isAdmin()
conn.execute("update Marcos_Vote set isLocked=false where voteId="&voteId)
locate "voteShow.asp?voteId="&voteId
case "setTop"
isAdmin()
conn.execute("update Marcos_Vote set isTop=true where voteId="&voteId)
locate "voteShow.asp?voteId="&voteId
case "unTop"
isAdmin()
conn.execute("update Marcos_Vote set isTop=false where voteId="&voteId)
locate "voteShow.asp?voteId="&voteId
case "voteIt"
voteIt(optionId)
delPageIndex()
locate "voteShow.asp?voteId="&voteId
case "del"
isAdmin()
conn.execute("delete from Marcos_Vote where voteId="&voteId)
delPageIndex()
locate "voteList.asp"
end select
str=getMainCode(mySkinId)
sql="select * from Marcos_Vote where voteId="&voteId
rs.open sql,conn,1,1
if rs.eof then
echo "投票并不存在(可能已經被刪除)!"
closeConn()
response.end
else
pageTitle="<a href=""voteList.asp"">投票列表</a> » <a href=""javascript:location.reload();"">"&encodeStr(rs("voteTitle"))&"</a>"
pageOther="<script>document.title+=' - 查看投票:"&encodeStr(rs("voteTitle"))&"';</script>"
nowWhere "查看投票:"&encodeStr(rs("voteTitle")),"voteShow.asp?voteId="&voteId
conn.execute("update Marcos_Vote set visitCount=visitCount+1 where voteId="&voteId)
end if
showHead str,pageTitle,pageOther
showBody()
showFoot(str)
sub showBody()
dim str
pageCode=getPageCode(mySkinId,"PageShow")
PageShow=split(pageCode,"$$$")
body=replace(PageShow(0),"{$pageList}","")
str="<tr><td valign=top width=200><br> 建立者:"&rs("userName")&"<br> 建立時間:"&mid(rs("addTime"),3)&_
"</td><td><br> 總票數:{$voteCount}<br><table>{$voteTable}<tr><td> </td></tr></table></td></tr>"
voteTable=getVoteResult(rs("voteContent"),rs("voteResult"),rs("voteCount"),rs("isMulti"))
str=replace(str,"{$voteTable}",voteTable)
str=replace(str,"{$voteCount}",rs("voteCount"))
body=replace(body,"{$topicTitle}",encodeStr(rs("voteTitle")))
body=body&str
body=body&PageShow(2)
if isVotedTrue() then
str="<input type=button value=""您已經投過票了"" disabled=true>"
else
str="<input type=submit value=""我投一票""><input type=hidden name=""theAct"" value=""voteIt"">"
end if
if getValue("userId")="" then
str="<input type=button value=""請先登錄"" disabled=true>"
end if
if isAdminTrue() then
str=str&"<input type=button value=""刪除投票"" onclick=""if(confirm('你確認要刪除這個投票嗎?'))location.href='voteShow.asp?theAct=del&voteId="&voteId&"';"">"
if rs("isLocked")=false then
str=str&"<input type=button value=""鎖定投票"" onclick=""if(confirm('你確認要鎖定這個投票嗎?'))location.href='voteShow.asp?theAct=setLock&voteId="&voteId&"';"">"
else
str=str&"<input type=button value=""解鎖投票"" onclick=""if(confirm('你確認要解鎖這個投票嗎?'))location.href='voteShow.asp?theAct=unLock&voteId="&voteId&"';"">"
end if
if rs("isTop")=false then
str=str&"<input type=button value=""置頂投票"" onclick=""if(confirm('你確認要置頂這個投票嗎?'))location.href='voteShow.asp?theAct=setTop&voteId="&voteId&"';"">"
else
str=str&"<input type=button value=""解除置頂"" onclick=""if(confirm('你確認要解除置頂這個投票嗎?'))location.href='voteShow.asp?theAct=unTop&voteId="&voteId&"';"">"
end if
end if
rs.close
queryTimes=queryTimes+1
body=replace(body,"{$pageList}",str)
body=replace(body,"{$newReply}","")
echo body
end sub
function getVoteResult(content,result,voteNum,isMulti)
dim i,str,percentBar
theOption=split(enCodeStr(content),"$$$")
theResult=split(fixNull(result),"$$$")
for i=0 to uBound(theOption)
if not isMulti then
str=str&"<tr height=""20""><td align=right> <input type=radio name=optionId value="""&i&_
""" {$checked"&i&"}> {$theOption}</td><td><img src=""images/{$styleRoot}/percentBar.gif"">{$theResult}</td></tr>"
else
str=str&"<tr height=""20""><td align=right> <input type=checkbox name=optionId value="""&i&_
""" {$checked"&i&"}> {$theOption}</td><td><img src=""images/{$styleRoot}/percentBar.gif"">{$theResult}</td></tr>"
end if
str=replace(str,"{$theOption}",theOption(i))
if voteNum<>0 then
percentBar=fix(theResult(i)/voteNum*10000)/100
percentBar="<img src=""images/{$styleRoot}/percentBar.gif"" height=10 width="""&percentBar*1.2&"""> "&theResult(i)&" 票 "&percentBar&"%"
else
percentBar=" 0"
end if
str=replace(str,"{$theResult}",percentBar)
if not isMulti then
str=replace(str,"{$checked0}","checked")
end if
next
getVoteResult=str
end function
function isVotedTrue()
dim i,votedUser
isVotedTrue=false
sql="select votedUser from Marcos_Vote where voteId="&voteId
set rs_sys=conn.execute(sql)
votedUser=split(fixNull(rs_sys(0)),"$$$")
for i=0 to uBound(votedUser)
if lcase(votedUser(i))=lcase(getValue("userName")) then
isVotedTrue=true
exit for
end if
next
queryTimes=queryTimes+1
end function
sub voteIt(id)
dim i,votedUser,theResult
if isVotedTrue() then
exit sub
end if
sql="select voteResult,votedUser,isLocked,isMulti from Marcos_Vote where voteId="&voteId
set rs_sys=conn.execute(sql)
if rs_sys(2)=true then
echo "<script>alert('對不起,該投票已經被鎖定!');history.back();</script>"
closeConn()
response.end
end if
voteResult=split(rs_sys(0),"$$$")
if rs_sys(3) then
for i=1 to request.form("optionId").count
voteResult(request.form("optionId")(i))=voteResult(request.form("optionId")(i))+1
next
voteCount=request.form("optionId").count
else
voteResult(id)=voteResult(id)+1
voteCount=1
end if
for i=0 to uBound(voteResult)
theResult=theResult&voteResult(i)&"$$$"
next
theResult=left(theResult,len(theResult)-3)
votedUser=fixNull(rs_sys(1))
if votedUser="" then
votedUser=getValue("userName")
else
votedUser=votedUser&"$$$"&getValue("userName")
end if
if rs_sys(0)=theResult then
exit sub
end if
conn.execute("update Marcos_Vote set lastVoteTime='"&now()&"',voteCount=voteCount+"&voteCount&",voteResult='"&theResult&"',votedUser='"&votedUser&"' where voteId="&voteId)
end sub
closeConn()
%>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -