<!--#include file="conn.asp"-->
<!--#include file="inc/const.asp"-->
<!-- #include file="inc/myadmin.asp" -->
<!--#include file="inc/plus_check.asp"-->
<!--#include file="plus_QYmaster_Style.asp"-->
<%
'*************************************************************
'*插件名称： 版主申请插件 for Dv 7.1.0 bulid 2005-5-8 10:49
'*
'*程序：情缘未了工作室
'*
'*类型：原创
'*
'*主页：http://bbs.guocj.com  情缘未了免费资源网
'*
'*时间：2005-5-8 10:49
'*作用：主执行文件
'*************************************************************
Dvbbs.LoadTemplates("")
Call Main()
Set Dv_plus=Nothing 
Dvbbs.Footer

Sub Main()
	Dim Action:Action=Trim(Request("action"))
	If Action="Agree" Then
		Dvbbs.Stats="填写申请表"
		Dvbbs.Nav()
		Dvbbs.Head_var 0,"","申请版主","plus_QYmaster.asp"
		Call AppTable()
	ElseIf Action="Apply" Then
		Dvbbs.Stats="提交申请"
		Dvbbs.Nav()
		Dvbbs.Head_var 0,"","申请版主","plus_QYmaster.asp"
		Call PostApp()
	Else
		Dvbbs.Stats="阅读申请需知"
		Dvbbs.Nav()
		Dvbbs.Head_var 0,"","申请版主","plus_QYmaster.asp"
		Call Advert()
	End If
	If ErrCodes<>"" Then Call Showerr() End If
End Sub

Sub Advert()
	Dim Showstr
	Showstr=template_Html(0)
	Showstr=Replace(Showstr,"{$ForumName}",Dvbbs.Forum_info(0))
	Showstr=Replace(Showstr,"{$Stats}",Dvbbs.Stats)
	Response.write Showstr
End Sub

Sub AppTable()
	Dim Showstr
	Showstr=template_Html(1)
	Showstr=Showstr+template_Html(2)
	Showstr=Replace(Showstr,"{$Stats}",Dvbbs.Stats)
	Showstr=Replace(Showstr,"{$MemberName}",Dvbbs.MemberName)
	Showstr=Replace(Showstr,"{$BoardList}",ShowBoardList)
	Response.write Showstr
End Sub

Function ShowBoardList()
	Dim i,j,Rs,Sql,TmdDate1,TmdDate2
	If Dv_plus.plus_Settings(1)="0" or Dv_plus.plus_Settings(1)="" or Dv_plus.plus_Settings(1)=" " Then
		Set Rs=Dvbbs.execute("Select boardid,boardtype,depth From Dv_Board order by rootid,orders") 
	Else
		TmdDate1=Split(Dv_plus.plus_Settings(1),"@")
		For i=0 To Ubound(TmdDate1)
			TmdDate2=TmdDate2&Cint(TmdDate1(i))
			If i=Ubound(TmdDate1) Then
				TmdDate2=TmdDate2
			Else
				TmdDate2=TmdDate2&", "
			End If
		Next
		Set Rs=Dvbbs.execute("Select boardid,boardtype,depth From Dv_Board Where boardid in ("&TmdDate2&") order by rootid,orders") 
	End IF
	If Not (Rs.Eof Or Rs.Bof) Then
		Sql=Rs.GetRows
		For i=0 To Ubound(Sql,2)
			ShowBoardList=ShowBoardList & "<option value="""&Sql(1,i)&""">"
			If Dv_plus.plus_Settings(1)="0" or Dv_plus.plus_Settings(1)="" or Dv_plus.plus_Settings(1)=" " Then
				Select Case Sql(2,i)
					Case 0
						ShowBoardList = ShowBoardList & "╋"
					Case 1
						ShowBoardList = ShowBoardList & "&nbsp;&nbsp;├"
				End Select
				If Sql(2,i)>1 Then
					For j=2 To Sql(2,i)
						ShowBoardList = ShowBoardList & "&nbsp;&nbsp;│"
					Next
					ShowBoardList = ShowBoardList & "&nbsp;&nbsp;├"
				End If
			End If
			ShowBoardList = ShowBoardList & Sql(1,i)&"</option>"
		Next
	Else
		ShowBoardList = "<option value=""0"">暂无任何版区</option>"
	End If
End Function

Sub PostApp()
	Dim Content,Rs,cond
	If Cint(Dv_plus.plus_Settings(17))=1 Then
		If Not IsObject(Conn) Then ConnectionDatabase
		If Dv_plus.plus_Settings(18)="" or Dv_plus.plus_Settings(18)=" " Then
			cond=" Where adduser in ("&Replace(Dv_plus.plus_Settings(18),"|",",")&")"
		Else
			cond=""
		End If
		Set Rs=Conn.execute("Select adduser From "&Admintable&cond)
		If Not (Rs.eof or Rs.bof) Then
			Do While not Rs.eof
				Dvbbs.execute("Insert into Dv_Message (sender,incept,title,content,sendtime,isSend) values ('系统中心','"&Dvbbs.CheckStr(Rs(0))&"','"&Dvbbs.CheckStr(Dvbbs.Membername&"申请成为『"&Trim(Request.Form("Board"))&"』的版主")&"','"&Dvbbs.CheckStr(Dvbbs.Membername&" 已于 "&now()&" 提交了申请，希望成为 『"&Trim(Request.Form("Board"))&"』 的版主，请审核！")&"',"&SqlNowString&",1)")
				UPDATE_User_Msg(Dvbbs.CheckStr(Rs(0)))
			Rs.movenext
			Loop
		End If
		Set Rs=Nothing
	End If
	Content="<BR>[B]论坛ID：[/B][B][Color=Blue]"&Dvbbs.MemberName&"[/Color][/B]<BR><BR>"
	Content=Content+"[B]申请的版块：[/B]"&Trim(Request.Form("Board"))&"<BR><BR>"
	Content=Content+"[B]真名：[/B]"&Trim(Request.Form("RealName"))&"<BR><BR>"
	Content=Content+"[B]目前居住地：[/B]"&Trim(Request.Form("address"))&"<BR><BR>"
	Content=Content+"[B]电话号码：[/B]"&Trim(Request.Form("phone"))&"<BR><BR>"
	Content=Content+"[B]专长：[/B]"&Trim(Request.Form("spec"))&"<BR><BR>"
	Content=Content+"[B]出生年份：[/B]"&Trim(Request.Form("birth"))&"<BR><BR>"
	Content=Content+"[B]电子邮件：[/B]"&Trim(Request.Form("email"))&"<BR><BR>"
	Content=Content+"[B]OICQ/ICQ：[/B]"&Trim(Request.Form("oicq"))&"<BR><BR>"
	Content=Content+"[B]是如何知道本论坛的：[/B]"&Trim(Request.Form("known"))&"<BR><BR>"
	Content=Content+"[B]平均上网时间和时段（小时/天）：[/B]"&Trim(Request.Form("time"))&"<BR><BR>"
	Content=Content+"[B]否做过版主（副）或聊管？：[/B]"&Trim(Request.Form("BeBM"))&"<BR><BR>"
	Content=Content+"[B]平时常活动的版面有：[/B]"&Trim(Request.Form("FavBoard"))&"<BR><BR>"
	Content=Content+"[B]申请当该版版主（副）的详细理由：[/B]"&Trim(Request.Form("reason"))&"<BR><BR>"
	Content=Content+"[B]如何能更好的行使版主权利：[/B]"&Trim(Request.Form("HowDo"))&"<BR><BR>"
	Content=Content+"[B]认为该版所包括的话题：[/B]"&Trim(Request.Form("theme"))&"<BR><BR>"
	Content=Content+"[B]对情缘未了论坛的建议与看法：[/B]"&Trim(Request.Form("advice"))&"<BR><BR>"
	Content=Content+"[B]认为本论坛该向哪个方向发展：[/B]"&Trim(Request.Form("course"))&"<BR><BR>"
	Response.write "<Form method=post name=Dvform Action=Savepost.asp?Action=snew&boardid="&Dv_plus.plus_Settings(0)&">"
	Response.write "<input type=""hidden"" name=body Value="""&Content&""">"
	Response.write "<input type=""hidden"" name=topic Value="""&Dvbbs.MemberName&"申请成为『"&Trim(Request.Form("Board"))&"』的版主"">"
	Response.write "<input type=""hidden"" name=""dvbbs"" value="&Dvbbs.Forum_sn&">"
	Response.write "<input type=""hidden"" name=""TotalUseTable"" value="&Dvbbs.NowUseBBS&">"
	Response.write "<input type=""hidden"" name=""username"" value="&Dvbbs.MemberName&">"
	Response.write "<input type=""hidden"" name=""passwd"" value="&Dvbbs.MemberWord&">"
	Response.write "<input type=""hidden"" name=""signflag"" value="&Trim(Request.Form("signflag"))&">"
	Response.write "<input type=""hidden"" name=""emailflag"" value="&Trim(Request.Form("emailflag"))&">"
	Response.write "</Form>"
	Response.write "<Script>document.Dvform.submit();</Script>"
End Sub

'更新用户短信通知信息（新短信条数||新短讯ID||发信人名）
Sub UPDATE_User_Msg(username)
	Dim msginfo,i,UP_UserInfo,newmsg
	newmsg=newincept(username)
	If newmsg>0 Then
		msginfo=newincept(username) & "||" & inceptid(1,username) & "||" & inceptid(2,username)
	Else
		msginfo="0||0||null"
	End If
	Dvbbs.execute("UPDATE [Dv_User] Set UserMsg='"&Dvbbs.CheckStr(msginfo)&"' WHERE username='"&Dvbbs.CheckStr(username)&"'")
	If username=Dvbbs.MemberName Then
		UP_UserInfo=Session(Dvbbs.CacheName & "UserID")
		UP_UserInfo(30)=msginfo
		Session(Dvbbs.CacheName & "UserID")=UP_UserInfo
	Else
		Call Dvbbs.NeedUpdateList(username,1)
	End If
End Sub

'统计留言
Function newincept(iusername)
Dim Rs
Rs=Dvbbs.execute("SELECT Count(id) FROM Dv_Message WHERE flag=0 And issend=1 And DelR=0 And incept='"& iusername &"'")
    newincept=Rs(0)
	Set Rs=nothing
	If isnull(newincept) Then newincept=0
End Function

Function inceptid(stype,iusername)
	Dim Rs
	Set Rs=Dvbbs.execute("SELECT top 1 id,sender FROM Dv_Message WHERE flag=0 And issend=1 And DelR=0 And incept='"& iusername &"'")
	If not rs.eof Then
		If stype=1 Then
			inceptid=Rs(0)
		Else
			inceptid=Rs(1)
		End If
	Else
		If stype=1 Then
			inceptid=0
		Else
			inceptid="null"
		End If
	End If
	Set Rs=nothing
End Function
%>

