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

📄 vote.asp

📁 依蓝旅游网站管理系统Elan2008.SP2
💻 ASP
字号:
<%
Option Explicit
Response.Buffer = True
Response.Expires = -1
Response.ExpiresAbsolute = Now() - 1
%>
<!--#Include File="Conn.asp"-->
<!--#Include File="Inc/Const.asp"-->
<%
On Error Resume Next
Dim VoteID
VoteID = EL_Common.ELRequest("VoteID", 3)
VoteID = EL_Common.ELClng(VoteID)
If VoteID < 1 Then
   EL_Common.ShowErrorMsg(EL_Common.Lang("Vote.NoVote", "没有任何调查"))
   Call ApplicationTerminate()
End If

Select Case Action
   Case "Show": Call ShowVote()
   Case "doVote": Call Vote()
End Select
Call EL_Common.ShowScriptError()
Call ApplicationTerminate()

Sub ShowVote()
   Dim VoteCmd, rsVote, HTML, VoteTitle
   Dim length, i, temp, VoteType, ArrVoteData(10, 1), TotalNum, Percent
   Call EL_Common.InitCommand(VoteCmd, "EL_SP_GetVote")
   With VoteCmd
      .Parameters.Append .CreateParameter("RETURN", 2, 4)
	  .Parameters.Append .CreateParameter("@Type", 3, 1, 4, 0)
      .Parameters.Append .CreateParameter("@VoteID", 3, 1, 4, VoteID)
      Set rsVote = .Execute()
   End With
   rsVote.Close()
   If VoteCmd(0) <> 1 Then
      GetVote = EL_Common.Lang("Vote.NoVote", "没有任何调查")
      Set rsVote = Nothing
      Set VoteCmd = Nothing
      Exit Sub
   End If
   rsVote.Open()
   VoteTitle = rsVote("Title")
   VoteType = rsVote("VoteType")
   TotalNum = 0
   length = 0
   For i = 1 To 10
      temp = rsVote("Options"& i)
	  If temp <> "" And Not IsNULL(temp) Then
	     ArrVoteData(i, 0) = temp
		 ArrVoteData(i, 1) = rsVote("Ballot"& i)
		 TotalNum = TotalNum + ArrVoteData(i, 1)
		 length = length + 1
	  End If
   Next
   rsVote.Close()
   Set rsVote = Nothing
   Set VoteCmd = Nothing
   
   HTML = EL_Common.Template(0, 37, 0)
   HTML = EL_Common.ReplaceCommonLabels(HTML)
   HTML = EL_Common.RegExpStaticLabel(HTML, "{$MetaKeywords}", "<meta name=""keywords"" content="""& MetaKeywords &""" />")
   HTML = EL_Common.RegExpStaticLabel(HTML, "{$MetaDescription}", "<meta name=""description"" content="""& MetaDescription &""" />")
   HTML = EL_Common.RegExpStaticLabel(HTML, "{$PageTitle}", EL_Common.Join2String(SiteTitle, EL_Common.Lang("Vote.Title", "网站调查"), EL_Common.TitleDivide))
   HTML = EL_Common.RegExpStaticLabel(HTML, "{$DefaultSkin}", EL_Common.Skin(0, 0, 0))
   
   EL_Common.ShowPath = EL_Common.ShowPath & EL_Common.Lang("BaseConfig.Path", "&nbsp;&gt;&gt;&nbsp;") & EL_Common.Lang("Vote.Title", "网站调查")
   HTML = EL_Common.RegExpStaticLabel(HTML, "{$ShowPath}", EL_Common.ShowPath)
   
   HTML = EL_Common.RegExpStaticLabel(HTML, "{$Title}", EL_Common.ServerHTMLEncode(VoteTitle)) 
   HTML = EL_Common.RegExpStaticLabel(HTML, "{$TotalNum}", TotalNum)    
   HTML = Label_VoteItems(HTML, length, TotalNum, Percent, ArrVoteData)
   HTML = EL_Common.RegExpStaticLabel(HTML, "{$ShowVoteForm}", EL_Common.GetVote(VoteID)) 
   
   
   Response.Write HTML
End Sub

Function Label_VoteItems(ByVal HTML, ByVal length, ByVal TotalNum, ByVal Percent, ByVal ArrVoteData)
   Dim Match, Matches, TempString, MatchString, VoteRegExp, ReturnString
   Set VoteRegExp = New RegExp
   VoteRegExp.IgnoreCase = True 
   VoteRegExp.Global = True  
   VoteRegExp.Pattern = "\[VoteItem\][\w\W]*\[\/VoteItem\]"        
   Set Matches = VoteRegExp.Execute(HTML)
   ReturnString = HTML
   TempString = ""
   For Each Match in Matches
      MatchString = Match.Value
      MatchString = EL_Common.ReplaceText(MatchString, "\[VoteItem\]", "")
      MatchString = EL_Common.ReplaceText(MatchString, "\[\/VoteItem\]", "")
	  Dim ItemHTML, i
	  TempString = ""
	  For i = 1 To length
	     If TotalNum > 0 Then
	        Percent = FormatNumber(ArrVoteData(i, 1)/TotalNum*100, 2, -1) &"%"
		 Else
	        Percent = "0.00%"
		 End If		 
		 ItemHTML = ""
		 ItemHTML = MatchString
		 ItemHTML = EL_Common.RegExpStaticLabel(ItemHTML, "{$Item_Index}", i) 
		 ItemHTML = EL_Common.RegExpStaticLabel(ItemHTML, "{$Item_Options}", ArrVoteData(i, 0)) 
		 ItemHTML = EL_Common.RegExpStaticLabel(ItemHTML, "{$Item_VoteNum}", ArrVoteData(i, 1)) 
		 ItemHTML = EL_Common.RegExpStaticLabel(ItemHTML, "{$Item_Percent}", Percent) 
		 TempString = TempString & ItemHTML
	  Next
	  ReturnString = Replace(ReturnString, Match.Value, TempString)
   Next
   Label_VoteItems = ReturnString
End Function

Sub Vote()
   Dim VoteItems, VoteType, SQL, ArrData, VoteUser
   
   VoteItems = EL_Common.ELRequest("VoteItems", 1)
   VoteType = EL_Common.ELRequest("VoteType", 2)
   
   If ComeURL = "" Then ComeURL = InstallDir &"Vote.asp?Action=Show&VoteID="& VoteID
   
   ArrData = EL_Common.GetFieldValue("Top 1 VoteID,VoteUser", "EL_Vote", "VoteID="& VoteID)
   VoteUser = ArrData(1)
   
   If VoteID = 0 Or ArrData(0) <> VoteID Then
      EL_Common.ShowErrorMsg(EL_Common.Lang("Vote.Error1", "指定调查不存在"))
	  Exit Sub
   End If
   
   If IsNULL(VoteUser) Then VoteUser = ""
   
   If EL_Common.FoundInArray(Split(VoteUser, "$"), RemoteIp) Then
      EL_Common.ShowErrorMsg(EL_Common.Lang("Vote.Error2", "对不起,您已经投过票"))
	  Exit Sub
   End If
   VoteUser = EL_Common.Join2String(VoteUser, RemoteIp, "$")
   If VoteType = 0 Then
      VoteItems = Int(EL_Common.ELClng(VoteItems))
	  If VoteItems < 1 Or VoteItems > 10 Then
	     EL_Common.ShowErrorMsg("页面参数错误")
	     Exit Sub
	  End If
	  SQL = "UPDATE EL_Vote SET Ballot"& VoteItems &"=Ballot"& VoteItems &"+1 WHERE VoteID="& VoteID
   Else
      Dim arr, i
	  VoteItems = Replace(VoteItems, " ", "")
	  arr = Split(VoteItems, ",")
	  SQL = "UPDATE EL_Vote SET "
	  For i = 0 To Ubound(arr)
	     arr(i) = Int(EL_Common.ELClng(arr(i)))
		 If arr(i) < 1 Or arr(i) > 10 Then
	        EL_Common.ShowErrorMsg("页面参数错误")
	        Exit Sub
	     End If
	     SQL = SQL &" Ballot"& arr(i) &"=Ballot"& arr(i) &"+1,"
	  Next
	  SQL = SQL &"VoteUser='"& VoteUser &"' WHERE VoteID="& VoteID
   End If   
   Conn.Execute(SQL)
   Call CloseConn()
   EL_Common.ShowScriptError()
   Response.Redirect ComeURL
End Sub
%>

⌨️ 快捷键说明

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