⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 voteshow.asp

📁 程序网络论坛HigroupBBS v4.00 默认管理员帐号密码都是Marcos
💻 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> &raquo; <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>&nbsp;建立者:"&rs("userName")&"<br>&nbsp;建立时间:"&mid(rs("addTime"),3)&_
			"</td><td><br>&nbsp;总票数:{$voteCount}<br><table>{$voteTable}<tr><td>&nbsp;</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>&nbsp;<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>&nbsp;<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
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -