<!--#include file="conn.asp"-->
<!--#include file="inc/const.asp"-->
<!--#include file="inc/plus_check.asp"-->
<%
'================================
'当前版本号：1.0
'程序作者：(21EClub)Andy
'21EClub网聚人 版权所有
'请尊重作者劳动成果，保留版权信息
'QQ:86093788 Http://Www.51Ent.Com
'================================
Dv_Plus.Name = "EC_Plus_Argue"
Dvbbs.stats = "发表辩论"
Dvbbs.LoadTemplates("")
Dvbbs.nav()
	Dvbbs.Head_var 0,0,Dv_Plus.Plus_Name,"EC_Argue_Index.asp"
		Argue_Nav_Link()

			If Dvbbs.userid=0 Then Dvbbs.AddErrCode(6):Dvbbs.Showerr()
%>
<!--#include file="EC_Argue_Const.asp"-->
<%
		Select Case Request.QueryString("Act")
			Case 2 : Save_Argue()
			Case 3 : Re_Argue()
			Case 4 : Save_ReArgue()
			Case 5 : ArgueVote()
			Case Else
				Add_Appear()
		End Select
Sub Add_Appear()
Dim EB_ArgueDays
Session("AppearTime") = 0
%>
<script language="javascript">
  function ChkAppear()
  {
	  if (document.Appear_Argue.Argue_Title.value==""){
	      alert("请输入辩论标题！");
		  document.Appear_Argue.Argue_Title.focus();
		  return false
		  }
	  if (document.Appear_Argue.Argue_Text.value==""){
	      alert("请输入论题描述！");
		  document.Appear_Argue.Argue_Text.focus();
		  return false
		  }
	  if (document.Appear_Argue.ZText.value==""){
	      alert("请输入正方观点！");
		  document.Appear_Argue.ZText.focus();
		  return false
		  }
	  if (document.Appear_Argue.FText.value==""){
	      alert("请输入反方观点！");
		  document.Appear_Argue.FText.focus();
		  return false
		  }
  }
</script>
<table border="0" width="<%=Dvbbs.mainsetting(0)%>" cellpadding=2 cellspacing=0 align=center>    <tr>
        <td width="156" valign="top">
<%Argue_ClassList("All")%>        </td>
        <td valign="top">
<table border="0" cellpadding=3 cellspacing=1 align=center class=Tableborder1 Style="Width:100%" width="547">
	<tr>
	<th height=23 colspan="2" >                        <p>发表新的辩论主题</p>
</th>
	</tr>
	<tr>
	<td align=center class=TableBody2 colspan="2">
                        <p align="left"><b>说明：<br></b>1、所有填写项目都为必填项<br>2、请不要试图发起任何违反国家有关法律的辩论主题<br>3、所有发起的辩论内容与本站无关，本站不承担因辩论内容引起的任何后果<br>	</td>
	</tr>
<form name="Appear_Argue" action="EC_Argue_Appear.asp?Act=2" method="post" onsubmit="return ChkAppear()"><tr>
	<td align=center class=TableBody1 width="80">
                        <p>辩论标题</p>
	</td>
	<td align=center class=TableBody1 width="452">
                        <p align="left"><input name="Argue_Title" class=form01 id="title"  size="60" maxlength="40">（限40字）
	</td>
                </tr>
                <tr>
	<td align=center class=TableBody1 width="80">
                        <p>论题描述</p>
	</td>
	<td align=center class=TableBody1 width="452">
                        <p align="left"><textarea name="Argue_Text" class=form01 id="dis" style="WIDTH: 430px; HEIGHT: 150px"></textarea>（限<%=Dv_Plus.Plus_Settings(4)%>字）

	</td>
                </tr>
                <tr>
	<td align=center class=TableBody1 width="80">
                        <p>正方主观点</p>
	</td>
	<td align=center class=TableBody1 width="452">
                        <p align="left"><input name="ZText" class=form01 id="title"  size="60" maxlength="40">（限40字）	</td>
                </tr>
                <tr>
	<td align=center class=TableBody1 width="80">
                        <p>反方主观点</p>
	</td>
	<td align=center class=TableBody1 width="452">
                        <p align="left"><input name="FText" class=form01 id="title"  size="60" maxlength="40">（限40字）	</td>
                </tr>
                <tr>
	<td align=center class=TableBody1 width="80">
                        <p>所属分类</p>
	</td>
	<td align=center class=TableBody1 width="452">
                        <p align="left"><%Argue_ClassList("FormSelect")%>	</td>
                </tr>
                <tr>
	<td align=center class=TableBody1 width="80">
                        <p>辩论进行时间</p>
	</td>
	<td align=center class=TableBody1 width="452">
                        <p align="left"><select name="ArgueDays" size="1">
					<%For EB_ArgueDays = 1 To 30%>
                                <option value="<%=EB_ArgueDays%>"><%=EB_ArgueDays%></option>
					<%Next%>
                                </select> 天</p>
	</td>
                </tr>
                <tr>
	<td align=center class=TableBody1 width="80">
                        <p>是否允许第三方看法</p>
	</td>
	<td align=center class=TableBody1 width="452">
                                <p align="left">
				<input type="radio" name="IsMiddle" value="1" checked>
            允许 
              <input name="IsMiddle" type="radio" value="0">
            不允许
				</p></td></tr><tr>
	<td align=center class=TableBody1 width="80">
                        <p>&nbsp;</p>
	</td>
	<td align=center class=TableBody1 width="452">
                        <p align="left"><input type="submit" name="Submit" value="发表论题"> 
                        &nbsp; 
                            <input type="reset" name="Cancel" value="重新填写"></p>
	</td>
                </tr></form>
</table>
        </td>
    </tr>
</table>
<%
	End Sub
		Sub Save_Argue()    '写入新论题
			Dim EB_Title,EB_ArgueText,EB_ZText,EB_FText,EB_ClassID,EB_IsMiddle,EB_ArgueDays,EB_Argue_Open
			Dim EB_Rs
			EB_Title = FilterHTML(Replace(Request.Form("Argue_Title"),"'","''"))
			EB_ArgueText = Replace(HTMLEncode(FilterHTML(Request.Form("Argue_Text"))),"'","''")
			EB_ZText = Replace(Request.Form("ZText"),"'","''")
			EB_FText = Replace(Request.Form("FText"),"'","''")
			EB_ClassID = Replace(Request.Form("Argue_ClassID"),"'","''")
			EB_IsMiddle = Replace(Request.Form("IsMiddle"),"'","''")
			EB_ArgueDays = Replace(Request.Form("ArgueDays"),"'","''")
			EB_Argue_Open = Dv_Plus.Plus_Settings(6)
				If Len(EB_Title) > 40 Or Len(EB_Title) < 5 Then
					ShowErr(2)
				Elseif Len(EB_ArgueText) > Dv_Plus.Plus_Settings(4) Or Len(EB_ArgueText) < 5 Then
					ShowErr(3)
				Elseif Len(EB_ZText) > Dv_Plus.Plus_Settings(4) Or Len(EB_ZText) < 5 Then
					ShowErr(4)
				Elseif Len(EB_FText) > Dv_Plus.Plus_Settings(4) Or Len(EB_FText) < 5 Then
					ShowErr(5)
				Elseif EB_ClassID = "" Then
					ShowErr(6)
				Elseif EB_IsMiddle = "" Then
					ShowErr(7)
				End if
						Select Case Session("AppearTime")
							Case 1 : ShowErr(12)
							Case Else
								Session("AppearTime") = 1
						End Select
					Set EB_Rs = Server.Createobject("Adodb.Recordset")
						EB_Rs.Open "Select Argue_Title,Argue_Text,Argue_FText,Argue_ZText,Argue_Class,Argue_IsMiddle,Argue_Open,Argue_Days,Argue_Hits,Argue_Votes,UserName From EC_ArgueTopic",ArgueConn,1,3
						EB_Rs.Addnew
							EB_Rs("Argue_Title") = EB_Title
							EB_Rs("Argue_Text") = EB_ArgueText
							EB_Rs("Argue_FText") = EB_FText
							EB_Rs("Argue_ZText") = EB_ZText
							EB_Rs("Argue_Class") = EB_ClassID
							EB_Rs("Argue_IsMiddle") = EB_IsMiddle
						If EB_Argue_Open = 1 Then      '论题是否需要验证
							EB_Rs("Argue_Open") = 0
						Else
							EB_Rs("Argue_Open") = 1
						End if
							EB_Rs("Argue_Days") = EB_ArgueDays
							EB_Rs("Argue_Hits") = 0
							EB_Rs("Argue_Votes") = "0|0"
							EB_Rs("UserName") = Dvbbs.MemberName
						EB_Rs.Update
						EB_Rs.Close : Set EB_Rs = Nothing
						ArgueConn.Close : Set ArgueConn = Nothing
%><table border="0" width="<%=Dvbbs.mainsetting(0)%>" cellpadding=2 cellspacing=0 align=center>    <tr>
        <td width="156" valign="top">
<%Argue_ClassList("All")%>        </td>
        <td valign="top">
<table border="0" cellpadding=3 cellspacing=1 align=center class=Tableborder1 Style="Width:100%" width="547">
	<tr>
	<th height=23 >                        <p>辩论主题发表完成</p>
</th>
	</tr>
	<tr>
	<td align=center class=TableBody2 height="50">
                        <p align="left"><%
Select Case EB_Argue_Open
	Case 1 : Response.Write "恭喜您！您的辩论主题已成功发表！"
	Case Else
		Response.Write "辩论主题已成功提交，请等待管理员审核！"
End Select
%><br>	</td>
	</tr><tr>
	<td align=center class=TableBody1 height="83">
                        <p align="center">
<b>您可进入我的论题查看论题状态</b>                        <p align="center"><a href="EC_Argue_My.asp">按此进入我的个人空间</a></p>
	</td>
</tr>
</table>
        </td>
    </tr>
</table>
<%
		End Sub
		Sub Re_Argue()
Dim EB_Rs,EB_SQL
Dim EB_ArgueID,EB_IsPorm,EB_ArgueIsMiddle
EB_ArgueID = Replace(Request("ArgueID"),"'","''")
EB_IsPorm = Request("IsPorm")
	If EB_ArgueID = "" Or Not IsNumeric(EB_ArgueID) Then ShowErr(10)
		Set EB_Rs = Server.CreateObject("Adodb.RecordSet")
		EB_SQL = "Select Appear_Date,Argue_Days,Argue_IsMiddle From EC_ArgueTopic Where Argue_Open =1 And ArgueID="&EB_ArgueID
		EB_Rs.Open EB_SQL,ArgueConn,1,1
			If Not(EB_Rs.BOF and EB_Rs.EOF) Then
				If EB_Rs("Appear_Date") + EB_Rs("Argue_Days") < Date() Then ShowErr(14)
				EB_ArgueIsMiddle = EB_Rs("Argue_IsMiddle")
			Else
				ShowErr(10)
			End if
		EB_Rs.Close : Set EB_Rs = Nothing
		ArgueConn.Close : Set ArgueConn = Nothing
Session("AppearTime") = 0
%>
<script language="javascript">
  function ChkAppear()
  {
	  if (document.Appear_Argue.Argue_Title.value==""){
	      alert("请输入观点标题！");
		  document.Appear_Argue.Argue_Title.focus();
		  return false
		  }
	  if (document.Appear_Argue.Argue_Text.value==""){
	      alert("请输入观点内容！");
		  document.Appear_Argue.Argue_Text.focus();
		  return false
		  }
  }
</script>
<table border="0" width="<%=Dvbbs.mainsetting(0)%>" cellpadding=2 cellspacing=0 align=center>    <tr>
        <td width="156" valign="top">
<%Argue_ClassList("All")%>        </td>
        <td valign="top">
<table border="0" cellpadding=3 cellspacing=1 align=center class=Tableborder1 Style="Width:100%" width="547">
	<tr>
	<th height=23 colspan="2" >                        <p>发表辩论观点</p>
</th>
	</tr>
	<tr>
	<td align=center class=TableBody2 colspan="2">
                        <p align="left"><b>说明：<br></b>1、所有填写项目都为必填项<br>2、请不要试图发起任何违反国家有关法律的辩论内容<br>3、所有发起的辩论内容与本站无关，本站不承担因辩论内容引起的任何后果<br>	</td>
	</tr>
<form name="Appear_Argue" action="EC_Argue_Appear.asp?Act=4" method="post" onsubmit="return ChkAppear()"><tr>
	<td align=center class=TableBody1 width="80">
                        <p>观点标题</p>
	</td>
	<td align=center class=TableBody1 width="452">
                        <p align="left"><input name="Argue_Title" class=form01 id="title"  size="60" maxlength="40">（限40字）
	</td>
                </tr>
                <tr>
	<td align=center class=TableBody1 width="80">
                            <p>观点立场</p>
	</td>
	<td align=center class=TableBody1 width="452">
                        <p align="left"><select name="IsPorm" size="1">
                            <option value="1" <%If EB_IsPorm = 1 Then Response.Write "selected"%>>正方</option>
                            <option value="2" <%If EB_IsPorm = 2 Then Response.Write "selected"%>>反方</option>
			    <%
			    If EB_ArgueIsMiddle = 1 Then
			    %><option value="3" <%If EB_IsPorm = 3 Then Response.Write "selected"%>>第三方</option>
			    <%End if%>
                            
                                </select></p>


	</td>
                </tr>
                <tr>
	<td align=center class=TableBody1 width="80">
                        <p>观点内容</p>
	</td>
	<td align=center class=TableBody1 width="452">
                        <p align="left"><textarea name="Argue_Text" class=form01 id="dis" style="WIDTH: 430px; HEIGHT: 150px"></textarea>（限<%=Dv_Plus.Plus_Settings(5)%>字）

	</td>
                </tr>
<tr>
	<td align=center class=TableBody1 width="80">
                        <p><input type="hidden" name="ArgueID" value="<%=EB_ArgueID%>"></p>
	</td>
	<td align=center class=TableBody1 width="452">
                        <p align="left"><input type="submit" name="Submit" value="发表观点"> 
                        &nbsp; 
                            <input type="reset" name="Cancel" value="重新填写"></p>
	</td>
                </tr></form>
</table>
        </td>
    </tr>
</table>
<%
		End Sub
		Sub Save_ReArgue()
			Dim EB_Rs,EB_SQL
			Dim EB_Title,EB_ArgueText,EB_ArgueID,EB_IsPorm
			EB_Title = FilterHTML(Replace(Request.Form("Argue_Title"),"'","''"))
			EB_ArgueText = Replace(HTMLEncode(FilterHTML(Request.Form("Argue_Text"))),"'","''")
			EB_ArgueID = Replace(Request.Form("ArgueID"),"'","''")
			EB_IsPorm = Replace(Request.Form("IsPorm"),"'","''")
				If EB_ArgueID = "" Or Not IsNumeric(EB_ArgueID) Then ShowErr(10)
					If Len(EB_Title) > 40 Or Len(EB_Title) < 5 Then
						ShowErr(2)
					Elseif Len(EB_ArgueText) > Dv_Plus.Plus_Settings(5) Or Len(EB_ArgueText) < 5 Then
						ShowErr(8)
					Elseif EB_IsPorm > 3 Or EB_IsPorm < 1 Then
						ShowErr(15)
					End if
						Select Case Session("AppearTime")
							Case 1 : ShowErr(12)
							Case Else
								Session("AppearTime") = 1
						End Select
		Set EB_Rs = Server.CreateObject("Adodb.RecordSet")
		EB_SQL = "Select Appear_Date,Argue_Days,Argue_IsMiddle From EC_ArgueTopic Where Argue_Open =1 And ArgueID="&EB_ArgueID
		EB_Rs.Open EB_SQL,ArgueConn,1,1
			If Not(EB_Rs.BOF and EB_Rs.EOF) Then
				If EB_Rs("Appear_Date") + EB_Rs("Argue_Days") < Date() Then : ShowErr(14)
				Elseif Not EB_Rs("IsMiddle") = 1 Then      '判断当前论题是否允许第三方观点
					If EB_IsPorm = 3 Then ShowErr(15)
			Else
				ShowErr(10)   '当前论题不存在
			End if
		EB_Rs.Close
'写入辩论观点
						EB_Rs.Open "Select ArgueID,Appear_Title,Appear_Text,IsPorm,UserName From EC_ArgueList",ArgueConn,1,3
						EB_Rs.Addnew
							EB_Rs("ArgueID") = EB_ArgueID
							EB_Rs("Appear_Title") = EB_Title
							EB_Rs("Appear_Text") = EB_ArgueText
							EB_Rs("IsPorm") = EB_IsPorm
							EB_Rs("UserName") = Dvbbs.MemberName
						EB_Rs.Update
		EB_Rs.Close : Set EB_Rs = Nothing
		ArgueConn.Close : Set ArgueConn = Nothing
%><table border="0" width="<%=Dvbbs.mainsetting(0)%>" cellpadding=2 cellspacing=0 align=center>    <tr>
        <td width="156" valign="top">
<%Argue_ClassList("All")%>        </td>
        <td valign="top">
<table border="0" cellpadding=3 cellspacing=1 align=center class=Tableborder1 Style="Width:100%" width="547">
	<tr>
	<th height=23 >                        <p>辩论观点发表完成</p>
</th>
	</tr>
	<tr>
	<td align=center class=TableBody2 height="50">
                        <p align="center">您的观点已成功发表，感谢您的支持！	</td>
	</tr><tr>
	<td align=center class=TableBody1 height="83">
                        <p align="center">
<b><font color="red">您现在可进行以下操作</font></b>                        <p align="center"><a href="EC_DispArgue.asp?ArgueID=<%=EB_ArgueID%>"><font color="blue">返回当前论题</font></a><font color="blue"> 
                        &nbsp;</font><a href="EC_Argue_My.asp"><font color="blue">进入我的个人空间</font></a> 
                        </p>
	</td>
</tr>
</table>
        </td>
    </tr>
</table>
<%
		End Sub
		Sub ArgueVote()
Dim EB_Rs,EB_SQL
Dim EB_ArgueID,EB_IsPorm,EB_ZVoteUserList,EB_FVoteUserList,EB_ArgueVotes
	EB_ArgueID = Replace(Request("ArgueID"),"'","''")
	EB_IsPorm = Replace(Request("IsPorm"),"'","''")
			If EB_IsPorm > 2 Or EB_IsPorm < 1 Then ShowErr(17)  '判断立场是否正确
				If Dvbbs.MyUserInfo(8) < Dv_Plus.Plus_Settings(12) Then ShowErr(13)  '判断帖子数是否允许投票
		Set EB_Rs = Server.CreateObject("Adodb.RecordSet")
		EB_SQL = "Select Argue_Votes,ZVoteUserList,FVoteUserList,Appear_Date,Argue_Days From EC_ArgueTopic Where Argue_Open =1 And ArgueID="&EB_ArgueID
		EB_Rs.Open EB_SQL,ArgueConn,3,3
			If Not(EB_Rs.BOF and EB_Rs.EOF) Then
					If EB_Rs("Appear_Date") + EB_Rs("Argue_Days") < Date() Then ShowErr(14)
				EB_ZVoteUserList = "|"&EB_Rs("ZVoteUserList")&"|"
				EB_FVoteUserList = "|"&EB_Rs("FVoteUserList")&"|"
				'判断用户是否投过票
					If InStr(EB_ZVoteUserList,"|"&Dvbbs.MemberName&"|") > 0 Then
						ShowErr(11)  
					Elseif InStr(EB_FVoteUserList,"|"&Dvbbs.MemberName&"|") > 0 Then
						ShowErr(11)
					End if
				EB_ArgueVotes = Split(EB_Rs("Argue_Votes"),"|")
						If EB_IsPorm = 1 Then
							If EB_Rs("ZVoteUserList") <> "" Then
								EB_Rs("ZVoteUserList") = EB_Rs("ZVoteUserList")&"|"&Dvbbs.MemberName
							Else
								EB_Rs("ZVoteUserList") = Dvbbs.MemberName
							End if
				EB_Rs("Argue_Votes") = EB_ArgueVotes(0) + 1&"|"&EB_ArgueVotes(1)  '正方加一票
						Elseif EB_IsPorm = 2 Then
							If EB_Rs("FVoteUserList") <> "" Then
								EB_Rs("FVoteUserList") = EB_Rs("FVoteUserList")&"|"&Dvbbs.MemberName
							Else
								EB_Rs("FVoteUserList") = Dvbbs.MemberName
							End if
				EB_Rs("Argue_Votes") = EB_ArgueVotes(0)&"|"&EB_ArgueVotes(1) + 1  '反方加一票
						End if
		EB_Rs.Update
			Else
				ShowErr(10)
			End if
		EB_Rs.Close : Set EB_Rs = Nothing
		ArgueConn.Close : Set ArgueConn = Nothing
%><table border="0" width="<%=Dvbbs.mainsetting(0)%>" cellpadding=2 cellspacing=0 align=center>    <tr>
        <td width="156" valign="top">
<%Argue_ClassList("All")%>        </td>
        <td valign="top">
<table border="0" cellpadding=3 cellspacing=1 align=center class=Tableborder1 Style="Width:100%" width="547">
	<tr>
	<th height=23 >                        <p>投票结果</p>
</th>
	</tr>
	<tr>
	<td align=center class=TableBody2 height="76">
                        <p align="center"><font color="blue">感谢您的投票，现在的辩论情况为</font><br><b><font color="red"><%If EB_IsPorm = 1 Then%></font>正方：<font color="red"><%=EB_ArgueVotes(0) + 1%></font></b>票 
                        &nbsp;<b>反方：</b><font color="red"><%=EB_ArgueVotes(1)%></font>票<b><font color="red"><%Else%></font>正方：<font color="red"><%=EB_ArgueVotes(0)%></font></b>票 
                        &nbsp;<b>反方：</b><font color="red"><%=EB_ArgueVotes(1) + 1%></font>票<b><font color="red"><%End if%></font></b>	</td>
	</tr><tr>
	<td align=center class=TableBody1 height="83">
                        <p align="center">
<b><font color="red">您现在可进行以下操作</font></b>                        <p align="center"><a href="EC_DispArgue.asp?ArgueID=<%=EB_ArgueID%>"><font color="blue">返回当前论题</font></a><font color="blue"> 
                        &nbsp;</font><a href="EC_Argue_My.asp"><font color="blue">进入我的个人空间</font></a> 
                        </p>
	</td>
</tr>
</table>
        </td>
    </tr>
</table>
<%
		End Sub
Argue_Copyright()
%>