<!--#include file="inc/inc_syssite.asp"-->
<%
Dim ErrMsg
'Argue.asp
'---------------------------------------------------
'业务逻辑节
'---------------------------------------------------
Function GetArgues(iMode)
	Dim sRet
	select Case iMode
		Case 1
			'最新
			Sql="select top 2 argueid,topic,a_ico,actions Where istate=1 Order By argueid Desc"
		Case 2
			'最热
			Sql="select top 2 argueid,topic,a_ico,actions Where istate=1 Order By actions Desc"
		Case 3
			Sql="select top 5 argueid,topic,a_ico,actions Where istate=3 Order By  argueid Desc"
	End select
	If Sql="" Then
		ErrMsg="错误的操作参数"
		Exit Function
	End If
	Do While Not rs.Eof 
		sRet=sRet & "<li>" & rs("topic") & "</li>" & vbcrlf
		rs.Movenext
	Loop
	Set rs=Nothing
	GetArgues=sRet
	sRet=""
End Function

Function GetArgueList(iMode)
	Dim sRet,Sql,rs,sState
	select Case iMode
		Case 1
			'待审核
			Sql="select top 5 argueid,topic,a_ico,actions From oblog_argue Where istate=1 Order By argueid Desc"
		Case 2
			'最新的
			Sql="select top 5 argueid,topic,a_ico,actions  From oblog_argue Where istate=2 Order By argueid Desc"
		Case 3
			'关闭的
			Sql="select top 5 argueid,topic,a_ico,actions  From oblog_argue Where istate=3 Order By argueid Desc"
		Case 4
			Sql="select argueid,topic,a_ico,actions,addtime,idays,actions1,actions2,actions3,istate,istop From oblog_argue Where   userid=" & oblog.l_uid &" Order By argueid Desc"
		Case Else 'All
			Sql="select argueid,topic,a_ico,actions  From oblog_argue Where  Order By argueid Desc"
	End select
	If Sql="" Then
		ErrMsg="错误的操作参数"
		Exit Function
	End If
	Set rs=oblog.Execute(Sql)
	Do While Not rs.Eof
		If rs("istate")=1 Then
			sState="[待审]"
		ElseIf rs("istate")=2 Then
			sState="[正常]"
		ElseIf rs("istate")=3 Then
			sState="[关闭]"
		End If
		If rs("istop")=1 Then
			sState="[置顶]" & sState
		End If
		sRet=sRet & "<ul class=""a_title""><li>" & sState &"<a href=""bl.asp?cmd=show&blid=" & rs("argueid") & """ target=""_blank"">" & rs("topic") & "</a>&nbsp;&nbsp;" &  rs("addtime") & "&nbsp;&nbsp;" & rs("actions1") & "/" & rs("actions2") & "/" &  rs("actions3") 
		If rs("istate")=1 Or rs("istate")=2 Then
			sRet=sRet & "&nbsp;&nbsp;<a href=""bl.asp?cmd=edit&blid=" & rs("argueid") & """>修改</a>"
		End If
		sRet=sRet & "</li></ul>"
		rs.Movenext
	Loop
	Set rs=Nothing
	GetArgueList=sRet
	sRet=""
End Function

'首页显示
Function GetOptions(Argueid,action)
	Dim rs,sRet,sRet1,i,sClass,sql,sStyle,sState,iPage,lPage,lAll,lPages
	Set rs=Server.CreateObject("Adodb.Recordset")
	If Argueid="" Then
	'仅显示一屏即可
		Sql="select top 20 a.topic,b.* From oblog_argue a,oblog_arguelist b Where a.argueid=b.argueid Order By b.id Desc"
	Else
		Sql="select a.topic,b.* From oblog_argue a,oblog_arguelist b Where a.argueid=b.argueid And a.argueid=" & Argueid & "  Order By b.id Desc"
	End If
	rs.Open sql,conn,1,3
	If rs.Eof Then
		GetOptions="<div id=argue_list_none></div>"
		Set rs=Nothing
		Exit Function
	End If
	iPage=20
	sRet="<div id=argue_list_options>"
	'分页
	If Request("page") = "" Or Request("page") ="0" then
		lPage = 1 
	Else
		lPage = Int(Request("page"))
	End If
	lAll=Int(rs.recordcount)
	'设置缓存大小 = 每页需显示的记录数目
	rs.CacheSize = iPage
	rs.PageSize = iPage
	rs.movefirst		
	lPages = rs.PageCount
	If lPage>lPages Then lPage=lPages
	rs.AbsolutePage = lPage
	sRet1=""
	i=0
	Do While Not rs.Eof And i < rs.PageSize
		If rs("action")=1 Then
			sState="正方"
			sStyle=0
		ElseIf rs("action")=2 Then
			sState="反方"
			sStyle=1
		ElseIf rs("action")=3 Then
			sState="第三方"
			sStyle=2
		Else
			sStyle=3
		End If
		If rs("rejoin")=1 Then 
			sState=sState & "," & "再次参与"
			sStyle=3
		End If
		sRet= sRet & "<div class=""a_option_title" & sStyle & """>" & Vbcrlf
		sRet= sRet & "<div class=""top""><div class=""title"">"
		If IsManager Then
			sRet= sRet & "[<a href=""bl.asp?cmd=dela&blid=" & rs("argueid") & "&a=" & rs("action") & "&re=" & rs("rejoin") & "&aid=" & rs("id") & """ onclick=""javascript:if (confirm('确认要删除该讨论吗？')==false) return false;"">删除</a>]"
		End If
		sRet= sRet & "<a href=""bl.asp?cmd=show&blid=" & rs("argueid") & """ class=""title"">" & rs("topic") & "</a></div><div class=""dire"">" & sState & "</div><div class=""both""></div></div>" & Vbcrlf
		sRet= sRet & "<div class=""content"">" & "<pre>" & Server.HtmlEncode(rs("content")) & "</pre></div>" & Vbcrlf
		sRet= sRet & "<div class=""end""><div class=""username""><a href=""#"">" & rs("author") & "</a></div><div class=""time"">" & rs("addtime")&"</div></div>" & Vbcrlf
		sRet= sRet & "<div class=""both""></div>" & Vbcrlf
		sRet= sRet & "</div>" & Vbcrlf
		i=i+1
		rs.Movenext
	Loop
	'挂分页代码
	G_P_Filename="bl.asp?cmd=show&blid=" & argueid & "&page="
	sRet= sRet & "<div class=a_option_title3>" & PageBarNum(lAll,iPage,lPage,G_P_Filename) & "</div>"
	GetOptions=sRet
	sRet=""
End Function

Function GetOneArgue(argueid,action,itype)
	Dim Sql,rs,sRet,sRet1
	If Argueid="" Then
		itype="1"
	Else
		Argueid=Int(Argueid)
	End If 
	If action="1" Then
		action="And action=1 "
	ElseIf action="2" Then
		action="And action=2 "
	End If
	'获取基本信息
	If itype="1" Then
		Sql="select top 1 * From oblog_argue Where istop=1 And istate=2 Order By argueid Desc" 
		Set rs=oblog.Execute(Sql)
		If rs.Eof Then
			Sql="select top 1 * From oblog_argue Where istop=0  And istate=2  Order By argueid Desc" 
			Set rs=oblog.Execute(Sql)
		End If
	Else
		Sql="select * From oblog_argue Where argueid=" & argueid
		Set rs=oblog.Execute(Sql)
	End If
	
	If rs.Eof Then
		ErrMsg="目标数据不存在"
		Exit Function
	End If
	sRet=sRet & "<div class=""c_Debate"">" & Vbcrlf
	sRet=sRet & "<div class=""title""><a href=""bl.asp?cmd=show&blid=" & rs("argueid") & """>" & rs("topic") & "</a></div>" & Vbcrlf
	sRet=sRet & "<a href=""#""><img src=""" & OB_IIF(rs("a_ico"),"plus/skins/bl/default/ico_bl.gif") & """ /></a>" & Vbcrlf
	sRet=sRet & "<div>开始时间：" & rs("addtime") & "</div>" & Vbcrlf
	sRet=sRet & "<div>结束时间：" & CheckDays(rs("addtime"),rs("iDays")) &"</div>" & Vbcrlf
	sRet=sRet & "<div>发起人：<a href=""go.asp?userid=" & rs("userid") & """ target=""target=_blank"">" & rs("username") &"</a>　　　关注程度：<span class=""blue"">" & IfHot(rs("actions")) &"</span> (" & rs("actions")&"人次)</div>" & Vbcrlf
	sRet=sRet & "<div><span class=""red_b"">正方观点：" & rs("action1") & "</span></div>" & Vbcrlf
	sRet=sRet & "<div><span class=""red"">得票" & rs("actions1")&"　</span></div>" & Vbcrlf
	sRet=sRet & "<div><span class=""blue_b"">反方观点：" & rs("action2") & "</span></div>" & Vbcrlf
	sRet=sRet & "<div><span class=""blue"">得票" & rs("actions2")&"　</span></div>" & Vbcrlf
	sRet=sRet & "<div><span class=""green"">第三方：得票" & rs("actions3")&"　</span></div>" & Vbcrlf
	sRet=sRet & "<div class=""txt_b13"">相关资料：</div>" & Vbcrlf
	sRet=sRet & "<div class=""txt_p"">" & rs("content")&"</div>" & Vbcrlf
	sRet=sRet & "</div>"
	GetOneArgue=sRet
	sRet=""
	sRet1=""
End Function

'仅管理员可以删除辩题
Function isManager()
	isManager=false
	If Session("adminname")<>"" Or Session("m_name")<>""  Then
		isManager=true
	End If
End Function

Function JoinArgue()
	Dim Sql,rs,bJoined,action,actionSql,Content
	'判断是否登录
	If oblog.checkuserlogined()=false Then
		ErrMsg="必须登录才能参与辩论"
		Exit Function
	End If
	
	oblog.chk_commenttime
	
	argueid=Int(Request("blid"))	
	action=CInt(Request("action"))
	Content=Trim(Request("edit"))
	
	If Content="" Then
		oblog.AddErrStr ("请输入评论内容！") 
	Else
		If Len(Content)>1000 Then
			oblog.AddErrStr ("评论内容不能大于1000字！")
		Else
			If oblog.chk_badword(Content) > 0 Then oblog.AddErrStr ("内容中含有系统不允许发布的关键字！") 
		End If
	End If
	If oblog.Errstr<>"" Then oblog.showUserErr
	'判断当前状态
	Sql="select addtime,idays,istate From oblog_argue Where argueid=" & argueid
	Set rs=oblog.Execute(Sql)
	If rs.Eof Then
		ErrMsg="目标数据不存在"
	Else
		If rs("istate")=1 Then
			ErrMsg="该辩题还没有被审核"
		ElseIf rs("istate")=3 Then
			ErrMsg="该辩题已经结束"
		Else
			If CheckDays(rs(0),rs(1))<=Now Then
				'关闭
				oblog.Execute("Update oblog_argue Set istate=3 Where argueid=" & argueid)
				ErrMsg="辩论已关闭"
			End If
		End If
		If ErrMsg<>"" Then
			rs.Close
			Exit Function
		End If
	End If
	Set rs=Nothing
	'判断之前是否参加
	
	Sql="select action From oblog_arguelist Where userid=" & oblog.l_uid & " And argueid=" & argueid
	Set rs=oblog.Execute(Sql)
	If Not rs.Eof Then
		bJoined=1
		action=rs(0)
	Else
		bJoined=0
	End If	
	select Case action
		Case 1
			actionSql="actions1=actions1+1"
		Case 2
			actionSql="actions2=actions2+1"
		Case 3
			actionSql="actions3=actions3+1"
	End select
	rs.Close
	rs.Open "select *  From oblog_arguelist Where 1=0",conn,1,3
	rs.AddNew
	rs("argueid")=Int(argueid)
	rs("action")=Cint(action)
	rs("content")=Request("edit")
	rs("userid")=oblog.l_uid
	rs("addtime")=oblog.ServerDate(Now)
	rs("addip")=oblog.userip
	rs("author")=oblog.l_uname
	rs("rejoin")=bJoined
	rs.update
	rs.Close
	'数据更新
	If bJoined=0 Then oblog.execute ("Update oblog_argue Set " & actionSql & " Where argueid=" & argueid)
	oblog.execute ("Update oblog_argue Set actions=actions+1 Where argueid=" & argueid)
	Session("chk_commenttime")=oblog.ServerDate(now())
	Response.Cookies(cookies_name)("LastComment") = oblog.ServerDate(now())
	Response.Redirect "bl.asp?blid=" & argueid
End Function

Function CheckDays(byval addtime,byval idays)
	CheckDays=Dateadd("d",addtime,iDays)
End Function

Function JoinForm(id)
	Dim sRet,rs,sErr
	If id="" Then 
		Exit Function
	End If
	Set rs=oblog.Execute("select istate From oblog_argue Where argueid=" & Int(Id))
	If rs.Eof Then
		sErr="该辩论不存在"
	Else
		If rs(0)=1 Then
			sErr="该辩论还未通过审核"
		ElseIf rs(0)=3 Then
			sErr="该辩论已经关闭"
		End If
	End If
		
	sRet="<div class=""a_option_title3"">"
	If sErr<>"" Then
		sRet=sRet & sErr
	Else
		sRet=sRet &"<form action='bl.asp?cmd=joinsave&blid=" & id &"' method='post' name='commentform' id='commentform'>"& vbcrlf 
		sRet=sRet & "<input type=radio name=action value=1>支持正方<input type=radio name=action value=2>支持反方<input type=radio name=action value=3 checked>第三方观点"
		sRet=sRet & "<br/>观点只记录一次，但是你可以随时发布评论(小于1000字)"
		sRet=sRet & "<br/><textarea cols=""50"" rows=""5"" name=""edit""></textarea>" & vbcrlf 
		sRet=sRet & "<br/><span id=""ob_code""></span><input type='submit' value=' 提交 '></ul>" & vbcrlf 
		sRet=sRet & "</form>"
	End If
	sRet=sRet & "</div>"& vbcrlf 
	JoinForm=sRet
	sRet=""
End Function

Function MainForm()
	Dim sRet,rs,sTopic,a_ico,sAction1,sAction2,argueid,sContent,sDays
	argueid=Request("blid")
	If argueid<>"" Then argueid=Int(argueid)
	If argueid<>"" Then
		'关闭后不允许再编辑
		Set rs=oblog.Execute("select * From oblog_argue Where argueid=" & argueid & " And istate<>3")
		If rs.Eof Then
			MainForm="辩论编号不存在或已关闭，不能进行修改<br/>如果您是管理员，请重开该辩论后进行操作"
			Exit Function
		End If
		If (Not IsManager) And rs("userid")<>oblog.l_uid Then
			MainForm="您无权编辑该信息"
			Set rs=Nothing
			Exit Function			
		End If
		sTopic=rs("topic")
		a_ico=OB_IIF(rs("a_ico"),"plus/skins/bl/default/ico_bl.gif")
		sAction1=rs("action1")
		sAction2=rs("action2")
		sContent=rs("content")
		sDays=rs("iDays")
		Set rs=Nothing
	Else
		a_ico="plus/skins/bl/default/ico_bl.gif"
	End If
	sRet=sRet & "<div class=""a_option_title1"">"
	sRet=sRet & "<div id=""list"">" &vbCrLf 
	sRet=sRet & "    <form action=""bl.asp?blid=" & argueid &""" method=""post"" name=""oblogform"" id=""oblogform"" onSubmit=""return VerifySubmit()"">" &vbCrLf 
	sRet=sRet & "    <ul class=""list_edit"">" &vbCrLf 
	sRet=sRet & "    辩论标题：<input name=""topic"" type=text id=""topic"" size=""50"" maxlength=""100"" value=""" & sTopic &"""> <font color=""#FF0000""> *</font>" &vbCrLf 
	sRet=sRet & "    </ul>" &vbCrLf 
	sRet=sRet & "    <ul class=""list_edit"">" &vbCrLf 
	sRet=sRet & "    设置图标：<input name=""a_ico"" type=text id=""a_ico"" size=""50"" maxlength=""200"" value=""" & a_ico & """ onblur=""checkImg();""> <font color=""#FF0000""> *</font>" &vbCrLf 
	sRet=sRet & "    </ul>" &vbCrLf 
	sRet=sRet & "  	</ul>" &vbCrLf 
	sRet=sRet & "  	<ul class=""list_edit"">" &vbCrLf 
	sRet=sRet & "  		<img id=""argueImg"" src=""" & a_ico &""" width=""66"" height=""50"">" &vbCrLf 
	sRet=sRet & "  	</ul>" &vbCrLf 
	sRet=sRet & "  	" &vbCrLf 
	sRet=sRet & "    <ul class=""list_edit"">" &vbCrLf 
	sRet=sRet & "       正文,不超过5000字符(不支持任意Html标记) :<br/>" &vbCrLf 
	sRet=sRet & "       <textarea id=""edit"" name=""edit"" rows=""10"" cols=""57"">" & Server.HtmlEncode(sContent) & "</textarea > " &vbCrLf 
	sRet=sRet & "    </ul>" &vbCrLf 
	sRet=sRet & "	" &vbCrLf 
	sRet=sRet & "    <ul class=""list_edit"">正方观点：<input name=""action1"" type=text id=""action1"" size=""50"" maxlength=""200"" value=""" & sAction1 & """> <font color=""#FF0000""> *</font>(最多100字)" &vbCrLf 
	sRet=sRet & "    </ul>" &vbCrLf 
	sRet=sRet & "    <ul class=""list_edit"">反方观点：<input name=""action2"" type=text id=""action2"" size=""50"" maxlength=""200"" value=""" & sAction2 & """> <font color=""#FF0000""> *</font>(最多100字)" &vbCrLf 
	sRet=sRet & "    </ul>" &vbCrLf 
	sRet=sRet & "    <ul class=""list_edit"">辩论天数：<input name=""idays"" type=text id=""idays"" size=""6"" maxlength=""8"" value=""" & sDays & """> <font color=""#FF0000""> *</font>(自审核通过之日算起)" &vbCrLf 
	sRet=sRet & "    </ul>" &vbCrLf 
	sRet=sRet & "    <ul class=""list_edit"">" &vbCrLf 
	sRet=sRet & "    	<input type=""hidden"" name=""ArgueId"" value=""" & ArgueId & """ />" &vbCrLf 
	sRet=sRet & "    	<input type=""hidden"" name=""cmd"" value=""save"" />" &vbCrLf 
	sRet=sRet & "        <input type=""submit"" value=""提交审核"" />" &vbCrLf 
	sRet=sRet & "        <input type=""reset"" value=""清除重写"" />" &vbCrLf 
	sRet=sRet & "    </ul>" &vbCrLf 
	sRet=sRet & "    </form>" &vbCrLf 
	sRet=sRet & "</div>" &vbCrLf
	MainForm=sRet
	sRet=""
End Function

Sub Save()
	Dim rs,sRet,sTopic,a_ico,sAction1,sAction2,argueid,sContent,sDays
	ArgueId=Request("blid")
	If ArgueId<>"" Then ArgueId  = CLng(Request("ArgueId"))
    If oblog.ChkPost() = False Then
        oblog.AddErrStr ("系统不允许从外部提交！")
        oblog.showUserErr
        Exit Sub
    End If    
    'If oblog.CacheConfig(30) = 1 Then
    '    If Not oblog.codepass Then 
    '    	oblog.AddErrStr ("验证码错误，请刷新后重新输入！")
    '    	oblog.showUserErr
    '    Else
    '    	Session("code")=""
    '  	End If
    'End If    
 
    sTopic = Request.Form("topic")
    a_ico = Request.Form("a_ico")  
    sContent=Request.Form("edit")
    sAction1 = Request.Form("action1")
    sAction2 = Request.Form("action2")
    sDays = Request.Form("iDays")
    'Check
    If sTopic = "" Or oblog.strLength(sTopic) > 100 Then oblog.AddErrStr ("标题不能为空(不能大于100)！")   	
    If sContent = "" Or oblog.strLength(sContent) > 5000 Then oblog.AddErrStr ("内容不能为空且不能大于5000字符")
    If oblog.chk_badword(sTopic) > 0 Then oblog.AddErrStr ("标题中含有系统不允许发布的关键字！")
    If oblog.chk_badword(sContent) > 0 Then oblog.AddErrStr ("内容中含有系统不允许发布的关键字！")    
    If sAction1 = "" Or oblog.strLength(sAction1) > 100 Then oblog.AddErrStr ("正方观点不能为空(不能大于100)！")   	
    If sAction2 = "" Or oblog.strLength(sAction2) > 100 Then oblog.AddErrStr ("反方观点不能为空(不能大于100)！")   	
    If Not IsNumeric(sDays) Then oblog.AddErrStr ("请正确输入天数")    
    If oblog.ErrStr <> "" Then oblog.showUserErr
    Set rs=Server.CreateObject("Adodb.Recordset")
    If ArgueId<>"" Then  
    	If isManager=false Then  	
    		rs.Open "select * From oblog_argue Where argueid=" & ArgueId & " And userid=" & oblog.l_uid,conn,1,3
	    Else
	    	rs.Open "select * From oblog_argue Where argueid=" & ArgueId,conn,1,3
		End If
    	If rs.Eof Then
    		rs.Close
    		Set rs=Nothing
    		oblog.AddErrStr ("目标数据不存在，请返回重新操作！")
        oblog.showUserErr    		
    	End If
  	Else  		
  		sTopic=EncodeJP(oblog.filt_astr(stopic, 250))
  		'Response.Write "select * From oblog_argue Where topic='" & sTopic & "' And userid=" & oblog.l_uid
  		rs.Open "select * From oblog_argue Where topic='" & sTopic & "' And userid=" & oblog.l_uid,conn,1,3
  		If Not rs.Eof Then
  			rs.Close
    		Set rs=Nothing
    		oblog.AddErrStr ("您之前发布过同样标题的内容，请重新选择一个新的标题！")
        oblog.showUserErr
      End If    		
      rs.AddNew
   	End If
    '开始写入操作
    rs("topic") =  EncodeJP(oblog.filtpath(oblog.filt_badword(sTopic)))
    rs("content") = EncodeJP(oblog.filtpath(oblog.filt_badword(sContent))) 
    rs("a_ico") = a_ico    
    rs("iDays") = sDays    
    rs("action1")=sAction1
    rs("action2")=sAction2
    '仅在添加时增加该字段
    If ArgueId="" Then 
	    rs("userid")=oblog.l_uid
	    rs("username")=oblog.l_uname
	     rs("istate")=1
	    rs("istop")=0
	End If
    rs("addtime") = oblog.ServerDate(Now)
    rs.Update
    rs.Close
    If argueid<>"" Then
    	oblog.ShowMsg "修改完成","bl.asp?cmd=show&blid=" & argueid
	Else	
    	oblog.ShowMsg "已提交辩论，等待管理员审核","bl.asp"
    End If
End Sub

Function GetTheme()
	Dim oFso,oStream,sRet,objReg
	'If Application(cache_name&"_bl_theme_main")="" Then
		Application.Lock
		Set oFso=Server.CreateObject("Scripting.FileSystemObject")
		Set oStream=oFSO.OpenTextFile(Server.Mappath("plus/skins/bl/default/main.htm"),1,False)
		sRet = oStream.ReadAll
		Application(oblog.cache_name&"_bl_theme_main")=sRet
		Application.Unlock
		sRet=""
		Set oStream=Nothing
		Set oFso=Nothing
	'End If
	GetTheme=Application(oblog.cache_name&"_bl_theme_main")	
End Function

Function MakeLeftBar()
	Dim sRet
	sRet="<div class=""new_top"">最新辩论</div>" & Vbcrlf
	sRet=sRet & "			<div class=""new"">" & Vbcrlf
	Dim rst
	Set rst=oblog.Execute("select top 2 * From oblog_argue Where istate=2 Order By argueid Desc")
	Do While Not rst.Eof
		sRet=sRet & "<div class=""s_Debate"">" & Vbcrlf
		sRet=sRet & "	<div class=""title""><a href=""bl.asp?cmd=show&blid="&rst("argueid")&""">" & rst("topic") & "</a></div>" & Vbcrlf
		sRet=sRet & "	<a href=""bl.asp?cmd=show&blid=" & rst("argueid") & """><img src=""" & OB_IIF(rst("a_ico"),"plus/skins/bl/default/ico_bl.gif") & """ /></a>发起人：<a href=""go.asp?userid=" & rst("userid") & """ target=""_blank"">" & rst("username") & "</a>" & Vbcrlf
		sRet=sRet & "	<div><span class=""red"">正：得票" & rst("actions1") & "　</span></div>" & Vbcrlf
		sRet=sRet & "	<div><span class=""blue"">反：得票" & rst("actions2") & "　</span></div>" & Vbcrlf
		sRet=sRet & "	<div><span class=""green"">第三方：得票" & rst("actions3") & "　</span></div>" & Vbcrlf
		sRet=sRet & "	<div>开始时间：" & rst("addtime") & "</div>" & Vbcrlf
		sRet=sRet & "	<div>结束时间：" & CheckDays(rst("addtime"),rst("iDays")) & "</div>" & Vbcrlf
		sRet=sRet & "	<div>关注程度：<span class=""blue"">" & IfHot(rst("actions")) &"</span> (" & rst("actions") & "人次)</div>" & Vbcrlf
		sRet=sRet & "</div>" & Vbcrlf
		rst.Movenext
	Loop
	rst.Close
	sRet=sRet & "</div>" & Vbcrlf
	sRet=sRet & "<div class=""new_end""></div>" & Vbcrlf
	
	sRet=sRet & "<div class=""hot_top"">最热辩论</div>" & Vbcrlf
	sRet=sRet & "<div class=""hot"">" & Vbcrlf
	
	Set rst=oblog.Execute("select top 2 * From oblog_argue Where istate=2 Order By actions Desc")
	Do While Not rst.Eof
	sRet=sRet & "	<div class=""s_Debate"">" & Vbcrlf
	sRet=sRet & "		<div class=""title""><a  href=""bl.asp?cmd=show&blid=" & rst("argueid") & """>" & rst("topic") & "</a></div>" & Vbcrlf
	sRet=sRet & "		<a  href=""bl.asp?cmd=show&blid=" & rst("argueid") & """><img src=""" & OB_IIF(rst("a_ico"),"plus/skins/bl/default/ico_bl.gif") & """  /></a>发起人：<a href=""go.asp?userid=" & rst("userid")&""" target=""_blank"">" & rst("username") & "</a>" & Vbcrlf
	sRet=sRet & "		<div><span class=""red"">正：得票" & rst("actions1") & "　</span></div>" & Vbcrlf
	sRet=sRet & "		<div><span class=""blue"">反：得票" & rst("actions2") & "　</span></div>" & Vbcrlf
	sRet=sRet & "		<div><span class=""green"">第三方：得票" & rst("actions3") & "　</span></div>" & Vbcrlf
	sRet=sRet & "		<div>开始时间：" & rst("addtime") & "</div>" & Vbcrlf
	sRet=sRet & "		<div>结束时间：" & CheckDays(rst("addtime"),rst("iDays")) & "</div>" & Vbcrlf
	sRet=sRet & "		<div>关注程度：<span class=""blue"">" & IfHot(rst("actions")) &"</span> (" & rst("actions") & "人次)</div>" & Vbcrlf
	sRet=sRet & "	</div>" & Vbcrlf
		rst.Movenext
	Loop
	rst.Close
	sRet=sRet & "</div>" & Vbcrlf
	sRet=sRet & "<div class=""hot_end""></div>" & Vbcrlf
	
	sRet=sRet & "<div class=""old_top"">以前辩论</div>" & Vbcrlf
	sRet=sRet & "<ul class=""old"">" & Vbcrlf
	Set rst=oblog.Execute("select top 2 * From oblog_argue Where istate=3 Order By actions Desc")
	Do While Not rst.Eof
	sRet=sRet & "<li><a  href=""bl.asp?cmd=show&blid=" & rst("argueid") & """>" & rst("topic") & "</a> <span class=""red"">正" & rst("actions1") & "</span>　<span class=""blue"">反" & rst("actions2") & "</span></li>" & Vbcrlf
		rst.Movenext
	Loop
	rst.Close
	sRet=sRet & "</ul>" & Vbcrlf
	sRet=sRet & "<div class=""old_end""></div>" & Vbcrlf
	MakeLeftBar=sRet
	sRet=""
End Function

Function AdminList()
	Dim sRet,Sql,rs,sState
	Set rs=oblog.Execute("select argueid,topic,username,userid,addtime,istate,istop,actions1,actions2 From oblog_argue Order By argueid Desc")
	sRet="<div class=""a_option_title1"">"
	sRet=sRet & "<ul class=""old"">"
	Do While Not rs.Eof
		If rs("istate")=1 Then
			sState="[待审]"
		ElseIf rs("istate")=2 Then
			sState="[正常]"
		ElseIf rs("istate")=3 Then
			sState="[关闭]"
		End If
		If rs("istop")=1 Then
			sState="[置顶]" & sState
		End If
		sRet=sRet & "<li>" &sState &"<a href=""bl.asp?cmd=show&blid=" & rs(0) & """ target=""_blank"">" & ProTitle(rs(1),20) & "</a> <span class=""red"">正"& rs("actions1")&"</span>　<span class=""blue"">反"& rs("actions1") & "&nbsp;&nbsp;&nbsp;&nbsp;"
		If rs("istate")<>3 Then
			sRet=sRet & "<a href=""bl.asp?cmd=edit&blid=" & rs(0) & """>修改</a>&nbsp;&nbsp;"
		End If
		If rs("istate")=1 Then
			sRet=sRet & "<a href=""bl.asp?cmd=pass1&blid=" & rs(0) & """>通过</a>&nbsp;&nbsp;"
		ElseIf rs("istate")=2  Then
			sRet=sRet & "<a href=""bl.asp?cmd=pass0&blid=" & rs(0) & """>关闭</a>&nbsp;&nbsp;"
		ElseIf rs("istate")=3  Then
			sRet=sRet & "<a href=""bl.asp?cmd=pass2&blid=" & rs(0) & """>重开</a>&nbsp;&nbsp;"
		End If
		If rs("istop")=0  Then
			sRet=sRet & "<a href=""bl.asp?cmd=top1&blid=" & rs(0) & """>置顶</a>&nbsp;&nbsp;"
		Else
			sRet=sRet & "<a href=""bl.asp?cmd=top0&blid=" & rs(0) & """>撤顶</a>&nbsp;&nbsp;"
		End If
		sRet=sRet & "<a href=""bl.asp?cmd=del&blid=" & rs(0) & """  onclick=""javascript:if (confirm('确认要删除该辩论吗？')==false) return false;"">删除</a>&nbsp;&nbsp;"
		sRet=sRet & "</span></li>"			
		rs.Movenext
	Loop
	sRet=sRet & "</ul></div>"
	AdminList=sRet
End Function

Function ProTitle(title,ilen)
	Dim sTitle,len1,i
	If IsNull(title) Then
		sTitle=""
	Else
		sTitle=title
	End If
	len1=Len(title)
	If len1>=ilen Then
		sTitle=Left(sTitle,ilen)
	Else
		For i=1 To (ilen-Len1)
			sTitle=sTitle & "&nbsp;"
		Next
	End If
	ProTitle=sTitle
End Function

Function IfHot(v)
	v=OB_IIF(v,0)
	If v<50 Then
		IfHot="<span class=""blue"">凉</span>"
	Else
		IfHot="<span class=""red"">热</span>"
	End If
End Function
Function ReturnErr(sErr)
	Dim sRet
	sRet=sRet & "<div class=""a_option_title0"">" &vbCrLf 
	sRet=sRet & " <div class=""top""><div class=""title"">辩论模块信息提示</div><div class=""dire""></div><div class=""both""></div></div>" &vbCrLf 
	sRet=sRet & " <div class=""content"">" & sErr & "</div>" &vbCrLf 
	sRet=sRet & " <div class=""end""><div class=""username"">Oblog Module</div>" &vbCrLf 
	sRet=sRet & " <div class=""both""></div>" &vbCrLf 
	sRet=sRet & "</div>" &vbCrLf 
	ReturnErr=sRet
	sRet=""
End Function
'---------------------------------------------------
'页面逻辑节
'---------------------------------------------------

Dim cmd,PageFrameWork,PageBody,Argueid,sMain,sBody,sCaption
cmd=LCase(Request("cmd"))
Argueid=Request("blid")
If cmd="" and Argueid<>"" Then cmd="show"
'Call MakeHtml
'获取功能页面内容
'页面上主要是两个标签，一是bl_main,一个是bl_replys
select Case cmd
	Case "add","edit"
		If cmd="add" Then
			sCaption="新增辩论"
		Else
			sCaption="编辑辩论"
		End If
		If not  oblog.checkuserlogined Then
			sMain=ReturnErr("<a href=""login.asp?fromurl=bl.asp?cmd=add"">请先登录</a>!")
		Else
			sMain=MainForm
		End If
		'OB_Debug oblog.l_uid,1
	Case "save"
		If not  oblog.checkuserlogined Then
			sMain=ReturnErr("请先登录!")
		Else
			Call Save
		End If
	Case "joinsave"
		Call JoinArgue
		sMain=ReturnErr(ErrMsg)
	Case "mine"
		If not  oblog.checkuserlogined Then
			sMain=ReturnErr("<a href=""login.asp?fromurl=bl.asp?cmd=add"">请先登录</a>!")
		Else
			sCaption="我发起的辩论"
			sMain=GetArgueList(4)
		End If
	'管理用
	Case "pass0"
		If isManager=true Then
			If argueid<>"" Then
				oblog.Execute("Update oblog_argue Set iState=3 Where argueid=" & argueid)
				oblog.ShowMsg "已经关闭该辩论","bl.asp?cmd=admin"
			End If
		End If
	Case "pass1"
		If isManager=true Then
			If argueid<>"" Then
				oblog.Execute("Update oblog_argue Set iState=2 Where argueid=" & argueid)
				oblog.ShowMsg "已经通过该辩论的审核","bl.asp?cmd=admin"
			End If
		End If
	Case "pass2"
		If isManager=true Then
			If argueid<>"" Then
				oblog.Execute("Update oblog_argue Set iState=2,addtime='" & Now &"' Where argueid=" & argueid)
				oblog.ShowMsg "已将该辩论重新设置为活跃状态","bl.asp?cmd=admin"
			End If
		End If
	Case "top0"
		If isManager=true Then
			If argueid<>"" Then
				oblog.Execute("Update oblog_argue Set istop=0 Where argueid=" & argueid)
				oblog.ShowMsg "已经取消该辩论的精华资格","bl.asp?cmd=admin"
			End If
		End If
	Case "top1"
		If isManager=true Then
			If argueid<>"" Then
				oblog.Execute("Update oblog_argue Set istop=0")
				oblog.Execute("Update oblog_argue Set istop=1 Where argueid=" & argueid)
				oblog.ShowMsg "已经设置该辩论为置顶，将在首位显示","bl.asp?cmd=admin"
			End If
		End If
	Case "del"
		If isManager=true Then
			If argueid<>"" Then
				oblog.Execute("Delete From  oblog_argue  Where argueid=" & argueid)
				oblog.Execute("Delete From  oblog_arguelist  Where argueid=" & argueid)
				oblog.ShowMsg "已经删除该辩论的所有信息","bl.asp?cmd=admin"
			End If
		End If
	Case "dela"
		If isManager=true Then
			If argueid<>"" Then
				oblog.Execute("Delete From  oblog_arguelist  Where id=" & Int(Request("aid")))
				'非重复参与减轻一票,重复参与不减,总参与人数不减少
				If Cint(Request("re"))=0 Then
					select Case Cint(Request("a"))
						Case 1
							oblog.Execute "Update oblog_argue Set actions1=actions1-1 Where argueid=" & Int(Request("blid")) 
						Case 2
							oblog.Execute "Update oblog_argue Set actions2=actions2-1 Where argueid=" & Int(Request("blid")) 
						Case 3
							oblog.Execute "Update oblog_argue Set actions3=actions3-1 Where argueid=" & Int(Request("blid")) 
					End select
				End If 
				oblog.ShowMsg "已经删除该讨论信息","bl.asp?cmd=show&blid=" & Int(Request("blid"))
			End If
		End If
	Case "show"
		sMain=GetOneArgue(Argueid,"","")
		sBody=GetOptions(Argueid,"")
		sBody=sBody & JoinForm(Argueid)
	Case "admin"
		sCaption="系统管理"
		sMain=AdminList()
	Case Else
		sCaption="推荐辩论"
		sMain=GetOneArgue(Argueid,"","1")
		sBody=GetOptions("","")
End select
'进行页面显示
If sCaption="" Then sCaption="信息提示"
PageFrameWork=	GetTheme
PageFrameWork=Replace(PageFrameWork,"$bl_caption$",sCaption)
PageFrameWork=Replace(PageFrameWork,"$bl_main$",sMain)	
PageFrameWork=Replace(PageFrameWork,"$bl_body$",sBody)
PageFrameWork=Replace(PageFrameWork,"$bl_left$",MakeLeftBar)
If isManager=true Then
	PageFrameWork=Replace(PageFrameWork,"$bl_admin$","<a href=""bl.asp?cmd=admin"">管理</a>")
Else
	PageFrameWork=Replace(PageFrameWork,"$bl_admin$","")
End If
Response.Write PageFrameWork
%>