<%Response.Buffer=true response.expires=0 dim varr redim varr(3) varr(0)="管理员选举[周]" varr(1)="升级奖励[周]" varr(2)="升级奖励[10天]" varr(3)="升级奖励[15天]" set rsparam=conn.execute("select * from param") sub voteend(vnum) dim j,rs1,rs2,voted_user,end_time,temp_level,selstr,loop_num set rs1=conn.execute("select max(votenum) as maxnum from vote where votename='"&varr(vnum)&"' and exp_num=1") if rs1("maxnum")>0 then set rs2=conn.execute("select voted_user from vote where votename='"&varr(vnum)&"' and exp_num=1 and votenum="&rs1("maxnum")) do while not rs2.eof voted_user=replace(trim(rs2("voted_user"))," ","','") conn.execute("UPDATE user SET exp_num=exp_num+20 WHERE username in ('"&voted_user&"')") rs2.movenext loop end if set rs1=conn.execute("select * from vote where votename='"&varr(vnum)&"' and exp_num=1 order by votenum desc,id") selstr="" if vnum=0 then end_time=dateAdd("d",25,now()) conn.execute("UPDATE vrecord SET temp_level=0 WHERE votetype=0") temp_level=rsparam("lkick")+2 for j=1 to 6 if j=2 then temp_level=rsparam("lkick")+1 if j=4 then temp_level=rsparam("lkick") conn.execute("insert into vrecord (username,votetype,end_time,temp_level) values ('"&rs1("voteoptions")&"',0,'"&end_time&"',"&temp_level&")") selstr=selstr&rs1("voteoptions")&" " rs1.movenext next conn.Execute("INSERT INTO record (occ_env,occ_time,for_what) VALUES ('系统 终止了投票事件 《"&varr(vnum)&"》,〖"&trim(selstr)&"〗被当选为新的管理员 !','"&now()&"','上任管理员一周任期到')") else loop_num=1 if vnum=1 then loop_num=3 for j=1 to loop_num end_time=dateAdd("d",vnum*10,now()) conn.execute("insert into vrecord (username,votetype,end_time,temp_level) values ('"&rs1("voteoptions")&"',"&vnum&",'"&end_time&"',0)") conn.Execute("UPDATE user SET user_level=user_level+1 WHERE username='"&rs1("voteoptions")&"'") selstr=selstr&rs1("voteoptions")&" " rs1.movenext next conn.Execute("INSERT INTO record (occ_env,occ_time,for_what) VALUES ('系统 终止了投票事件 《"&varr(vnum)&"》,〖"&trim(selstr)&"〗获得了奖励 !','"&now()&"','投票终止时间到,系统自动终止')") end if conn.execute("UPDATE vote SET end_flag='"&now()&"' WHERE votename='"&varr(vnum)&"' and exp_num<>1") end sub sub votestart(vnum) dim rootRs dim j,rs1 Set rootRs=Server.CreateObject("ADODB.RecordSet") conn.execute("delete from vote WHERE votename='"&varr(vnum)&"'") conn.execute("delete from vrecord WHERE (DATEDIFF('s',end_time,now())>0)") set rs1=conn.execute("select username from vrecord where votetype="&vnum) filterstr="" do while not rs1.eof filterstr=filterstr&",'"&rs1("username")&"'" rs1.movenext loop select case vnum case "0" sqlstr="user_level<7" exp_num=rsparam("expauto1") total=20 case "1" sqlstr="user_level<6" exp_num=rsparam("expauto2") total=20 case "2" sqlstr="user_level=6" exp_num=rsparam("expauto3") total=10 case "3" sqlstr="user_level in (7,8,9)" exp_num=rsparam("expauto4") total=10 end select sqlstr="select username from user where "&sqlstr&" and username not in (''"&filterstr&") order by exp_num desc" rootRs.Open sqlstr,conn,1,1 if rootRs.recordcount>total then conn.Execute("INSERT INTO vote (votename,voteoptions,exp_num,begin_time,end_flag) VALUES ('"&varr(vnum)&"','"&varr(vnum)&"',"&exp_num&",'"&now()&"','"&now()&"')") for j=1 to 20 conn.Execute("INSERT INTO vote (votename,voteoptions,exp_num) VALUES ('"&varr(vnum)&"','"&rootRs("username")&"',1)") rootRs.movenext if rootRs.eof then exit for next conn.Execute("INSERT INTO record (occ_env,occ_time,for_what) VALUES ('系统 产生了投票事件 《"&varr(vnum)&"》 !','"&now()&"','系统自动产生')") end if end sub for i=0 to 3 set rs=conn.execute("select * from vote where votename='"&varr(i)&"' and exp_num<>1") if i<2 then daynum=6 else daynum=i*5-1 end if if (rs.eof or rs.bof) and rsparam("envoteauto") then call votestart(i) elseif (DATEDIFF("d",rs("begin_time"),now())>(daynum-1) and rs("begin_time")=rs("end_flag")) then call voteend(i) elseif DATEDIFF("d",rs("begin_time"),now())>daynum then call votestart(i) end if next Response.Redirect("tpxt.asp")%>