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

📄 vote.asp

📁 本系统是一套开源WEB的网站管理系统
💻 ASP
字号:
<%
'==============================================================
'程序名称:茂盛网站管理系统(Maoin CSM)
'当前版本:Maosin CMS Version 1.1   Powered by maosin.com
'程序作者:阿茂(李胜茂)
'网站地址:www.maosin.com   www.maosin.net
'      QQ:57861417  
'电子邮箱:maosin@163.com  maosin@maosin.com
'--------------------------------------------------------------
'Copyright (C) 2006 maosin.com All Rights Reserved.
'免费版本请在程序首页保留(Powered by:Maosin CMS)版权链接信息;
'您可以对此版本进行修改,美化,但请保留此ASP文件内的版权信息;
'茂盛设计网保留此软件的法律追究权利
'==============================================================
Sub showVote()
dim vt_id,sql,rs,strTemp
vt_id=trim(request.querystring("vt_id"))
if isInteger(vt_id)=false then
	response.write("<script>alert('ID参数错误,请输入一个整形参数!');</script>")
	exit sub
end if
'sql="select vt.vt_id,vt.vt_Name,vt.titlecolor,vi.item_id,vi.item_name,vi.item_count,vi.item_color from ms_votetopic as vt,ms_voteitem as vi where vt.vt_id="&vt_id&" and vt.start_date<=date() and vt.end_date>date() and vt.isLock=1 and vt.vt_id=vi.vt_id order by vi.item_id asc"
sql="select vt.vt_id,vt.vt_Name,vt.titlecolor,vi.item_id,vi.item_name,vi.item_count,vi.item_color,vt.end_date from ms_votetopic as vt,ms_voteitem as vi where vt.vt_id="&vt_id&" and vt.start_date<=date() and vt.isLock=1 and vt.vt_id=vi.vt_id order by vi.item_id asc"
set rs=conn.execute(sql)
dim vtID,vtName,vtColor,end_date,count_,voteCount,voteCount_,voteItemStr
if not rs.eof and not rs.bof then
vtID=rs(0)
vtName=rs(1)
vtColor=rs(2)
end_date=rs(7)
do while not rs.eof
	count_=count_+rs(5)
	rs.movenext
loop
rs.MoveFirst
strTemp="<table width=""100%"" border=""0"" cellpadding=""2"" cellspacing=""5""><tr> <td height=""50"" colspan=""2"" valign=""middle"" align=""center""><b>关于“<font color="""&vtColor&""">"&vtName&"</font>” 投票</b></td></tr>"
strTemp=strTemp&"<tr><td colspan=""2"" valign=""middle""><b>总投票数:</b><font color=""#ff4400"">"&count_&"</font> 票</td></r>"
do while not rs.eof  
if count_<=0 then
	voteCount_="1px"
	voteCount="0%"
else
  voteCount=FormatPercent(rs(5)/count_,2,-1)
  if rs(5)<=0 then
  	voteCount_="1px"
  else
  	voteCount_=voteCount
  end if
end if
  voteItemStr=voteItemStr&"<div><input type=""radio"" name=""item_id"" value="""&rs(3)&""" id=""voteItem"&rs(3)&"""> <label style=""cursor:hand;"" for=""voteItem"&rs(3)&""">"&rs(4)&"</label></div>"
  strTemp_=strTemp_&"<tr> <td width=""30%"" height=""25"" valign=""middle""> "&rs(4)&"</td><td width=""*"" valign=""middle""><span class=""voteCutline"" style=""background-color:"&rs(6)&";height:22px;width:"&voteCount_&";""></span>&nbsp;"&voteCount&"&nbsp;&nbsp;票数:"&rs(5)&"</td></tr>"
  rs.movenext
loop
strTemp=strTemp&strTemp_
strTemp=strTemp&"<tr><td colspan=""2"" valign=""middle"" align=""center""><br/>"
dim yesORno,voteForm
if end_date<=date then
	voteForm="<div style=""text-align:lelt;width:60%;font-weight:bold;color:#888888;"">此投票已经过期!</div>"
else
	if Request.Cookies("maosinVote")("Vote"&vtID)=getIP then
		yesORno="<div style=""width:60%;text-align:left;font-weight:bold;"">您已经投过票了。非常感谢您的参与!</div><br/>"
	else
		yesORno="<div style=""width:60%;text-align:left;font-weight:bold;"">您还没有投票。请您在此投下您宝贵的一票!</div>"
		voteForm="<br/><div style=""width:60%;text-align:left;""><form action=""showvote.asp?action=saveVote"" name=""voteForm"" method=""post"">"&voteItemStr&"<br/><input type=""hidden"" name=""vt_id"" value="""&vtID&"""><input type=""submit"" value=""投上一票"" class=""but1"" onMouseOver=""this.className='but2'"" onMouseOut=""this.className='but1'""/> <input type=""button"" onClick=""javascript:self.close();"" value=""关闭窗口"" class=""but1"" onMouseOver=""this.className='but2'"" onMouseOut=""this.className='but1'""/></form></div>"
	end if
end if
strTemp=strTemp&yesORno&voteForm&"</td></r></table>"
response.write strTemp
else
	response.write("<div style=""text-align:center;width:60%;height:40px;padding-top:12px;font-weight:bold;color:#888888;"">此投票还没有添加投票选项!</div>")
end if
response.write("<div class=""voteOtherTitle"">本站的其它投票:</div>")
voteList(3)
response.write "<div style=""text-align:right;margin:5px;padding-bottom:5px;padding-right:10px;""><a href=""showvote.asp?action=votelist""><font color=""#333333"" style=""font-weight:bold;"">更多投票……</font></a></div>"
rs.close
set rs=nothing
End Sub
Sub voteList(listNum)
dim sql,rs,strTemp,endDiffD,currStatus,pageStr
sql="select * from ms_votetopic where isLock=1 and start_date<=date() order by vt_id desc"
Set rs=Server.CreateObject("ADODB.RecordSet")
rs.Open sql,connstr,1,1
if not rs.eof and not rs.bof then
	dim lineNo,getdate,pageNo,i,j
	if listNum>0 then
		rs.pagesize=100
	else
		rs.pagesize=20
	end if
	getdate=date
	pageNo=request("PageNO")
	if pageNo="" then
		rs.AbsolutePage=1
	else
		rs.Absolutepage=pageNo
	end if
	for i=1 to rs.pagecount
		pageStr=pageStr&"<a href=""showvote.asp?action=votelist&pageNo="&i&""">"&i&"</a>&nbsp;&nbsp;"
	next
	lineNo=1
	j=0
	do while not rs.eof and lineNo<=rs.pagesize
	if listNum>0 and j=listNum then
		exit do
	else
		if rs("end_date")=<getdate then
			currStatus="剩余天数:<font color=""#888888"">已经过期</font>"
		elseif rs("start_date")<=getdate and rs("end_date")>getdate then
				endDiffD=cint(DateDiff("d",getdate,rs("end_date")))
				currStatus="剩余天数:<font color=""#333333"">"&endDiffD&"</font> 天"
		end if
			strTemp_="<font color=""#88888"">『<a href=""?action=showvote&vt_id="&rs("vt_id")&"""><font color=""#888888"">查看</font></a> - 票数:<font color=""#333333"">"&conn.execute("select sum(item_count) from ms_voteItem where vt_id="&rs("vt_id")&"")(0)&"</font> - "&currStatus&"』</font>"
			strTemp=strTemp&"<div class=""votelist""><img src=""images/vote_ico.gif"" border=""0"" width=""12"" height=""12"" align=""absmiddle""> "&rs("vt_name")&"&nbsp;&nbsp; "&strTemp_&"</div>"
	end if
	rs.MoveNext
	j=j+1
	lineNo=lineNo+1
	loop
	if listNum>0 then
		response.write(strTemp)
	else
		response.write("<div class=""voteListTitle"">本站所有投票</div>")
		response.write(strTemp)
		response.write("<div class=""votePage"">分页:"&pageStr&"</div>")
	end if
else
	response.write("<div style=""height:40px;padding-top:15px;text-align:center;"">当前没有投票主题!</div>")
end if
End Sub
Sub saveVote()
	dim item_id,vt_id,rs
	item_id=trim(Request("item_id"))
	vt_id=trim(Request("vt_id"))
	if isInteger(item_id)=false then
		response.write("<script>alert('请选择您要投的选项');window.history.go(-1);</script>")
		exit sub
	end if
	if isInteger(vt_id)=false then
		response.write("<script>alert('ID参数出错,ID参数应为一个整型参数!');window.history.go(-1);</script>")
		exit sub
	end if
	if Request.Cookies("maosinVote")("Vote"&vt_id)=getIP then
		response.write("<script>alert('您已经投过票了,非常感谢您的参与!');window.history.go(-1);</script>")
		exit sub	
	else
	set rs=conn.execute("select end_date from ms_votetopic where vt_id="&cint(vt_id)&" and end_date>date() and start_date<=date()")
	if rs.eof and rs.bof then
		response.write("<script>alert('此项投票已经过期了或者不存在!');window.history.go(-1);</script>")
		exit sub
	else
		conn.execute "update ms_voteitem set item_count=item_count+1 where item_id="&cint(item_id)&" and vt_id="&vt_id
		response.Cookies("maosinVote")("Vote"&vt_id)=getIP()
		response.Cookies("maosinVote").Expires=DateAdd("d",30,now)
		response.write("<script>alert('投票成功,感谢您的参与!');window.location.href='"&request.servervariables("HTTP_REFERER")&"';</script>")
	end if
	end if
End Sub
'========================================================
'MaoSin CMS 1.1      Power by maosin.com
'Email: maosin@163.com , maosin@maosin.com
'Web: http://www.maosin.com  http://www.maosin.net
'Copyright (C) 2006 maosin.com All Rights Reserved.
'========================================================
%>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -