<!--#include file=conn.asp-->
<!--#include file=config.asp-->
<!--#include file=const.asp-->
<!--#include file=char.asp-->
<%
 '=========================================================
' File: uservote.asp
' Version:3.0
' Date: 2005-8-19
' Script Written by xmrxw
'=========================================================
' Copyright (C) 2004,2005 Xmrxw.Com All rights reserved.
' Web: http://www.xmrxw.com,http://www.xmzxw.com
' Email: info@mssky.com,super@mssky.com
' QQ：10689579　Msn：zdlmicr@hotmail.com
'=========================================================
dim action
action=checkStr(Request("action"))
response.buffer=true
stats="激活投票"
call nav()
if not founduser then
	Errmsg=Errmsg+"<br>"+"<li>您还没有登陆，请登陆后进行修改。"
	founderr=true
end if
if not chkpost then
 ErrMsg=ErrMsg+"<Br>"+"<li>您提交的数据不合法，请不要从外部提交发言。"
 FoundErr=True
end if

if founderr then
	call head_var("","")
	call Mslove_error()
else
	call head_var("基本资料修改","mymodify.asp")
strFileName="uservote.asp?"
Select Case action
	Case "active"
		Stats="激活投票"
		Call creat_vote()
	Case "vote"
		Stats="用户投票"
		Call user_vote()
	case else
		call main()
End Select
if founderr then call Mslove_error()
end if
call activeonline()
call footer()

sub creat_vote()''激活投票
dim Votename,Votenum
if mysex=0 then''女生投票
Votename="温柔型|阳光型|智慧型|清纯型|成熟型|才气型|古典型|浪漫型|时尚型|可爱型|性感型|妩媚型"
else
Votename="英俊型|儒雅型|现实型|幽默型|温柔型|运动型|智慧型|成熟型|才气型|浪漫型|性感型|阳光型"
end if
Votenum="0|0|0|0|0|0|0|0|0|0|0|0"
Set rs= Server.CreateObject("ADODB.Recordset")
sql="Select VoteUser,Votename,Votenum,TypeID,LockVote,Votetimeout From [Ms_vote] Where VoteUser='"&trim(membername)&"' and TypeID=0"
rs.Open sql,conn,1,3
	If Not (Rs.eof or Rs.bof) then
	errmsg=errmsg+"<br>"+"<li>您已经激活过投票功能了。"
	founderr=true
	exit sub
	else
	rs.addnew
	rs("VoteUser")=trim(membername)
	rs("Votename")=Votename
	rs("Votenum")=Votenum
	rs("TypeID")=0
	rs("LockVote")=0
	rs("Votetimeout")=now()
	rs.update
	end if
	rs.close
	sucmsg=sucmsg+"<br>"+"<li>您已成功激活投票。"
	call Mslove_suc()
end sub

sub user_vote()''用户投票
dim VoteID,markvalue,Votenum,j,votenum_1,votenumlen,fixid,spid,splitid
dim VoteUser
VoteID=checkStr(trim(request("VoteID")))
markvalue=checkStr(trim(request("markvalue")))
if VoteID="" or not isnumeric(VoteID) then
	errmsg=errmsg+"<br>"+"<li>参数错误。"
	founderr=true
	else
VoteID=cint(VoteID)
end if
spid=replace(markvalue,"'","")
spid=replace(spid,";","")
spid=replace(spid,"--","")
spid=replace(spid,")","")
fixid=replace(spid,",","")
fixid=Trim(replace(fixid," ",""))
if fixid="" or isnull(fixid) then
Errmsg=Errmsg+"<li>"+"没有选定投票项。"
Founderr=true
end if
if Founderr=true then exit sub
set rs=server.createobject("adodb.recordset")
sql="select Votenum,VoteUser from Ms_vote where VoteID="&VoteID&""
rs.Open sql,conn,1,1
if not (rs.eof and rs.bof) then
Votenum=rs("Votenum")
VoteUser=rs("VoteUser")
else
	errmsg=errmsg+"<br>"+"<li>对不起，没有该投票主题！。"
	founderr=true
	exit sub
end if
rs.close
if VoteUser=trim(membername) then
	errmsg=errmsg+"<br>"+"<li>对不起，您不能给自己投票。"
	founderr=true
	exit sub
end if
splitid=split(spid,",")
Votenum=split(Votenum,"|")
For j = 0 to UBound(Votenum)''循环读出数据库
	for i=0 to UBound(splitid)''循环取出提交ID
		if cint(splitid(i))=j Then
			Votenum(j)=Votenum(j)+1
		End If
	next
	votenum_1=""&votenum_1&""&votenum(j)&"|"
Next
votenumlen=len(votenum_1)
votenum_1=left(votenum_1,votenumlen-1)
conn.execute("UPDATE Ms_vote set Votenum='"&votenum_1&"',Voters=Voters+1 where VoteID="&VoteID&"")
	sucmsg=sucmsg+"<br>"+"<li>非常感谢您参与投票。"
	call Mslove_suc()
end sub
%>   
</body>
</html> 