<!--#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("")
If Dv_plus.plus_master Then
	Call Main()
Else
	Dvbbs.Stats="进行安装/设置"
	Dvbbs.Nav()
	Dvbbs.Head_var 0,"","申请版主","plus_QYmaster.asp"
	ErrCodes=ErrCodes+template_Strings(1)
End If
If ErrCodes<>"" Then 
	Call Showerr()
ElseIf SucCodes<>"" Then
	Call Showsuc()
End If
Set Dv_plus=Nothing 
Dvbbs.Footer

Sub Main()
	Dim Action:Action=Request("Action")
	If Action="AppSetup" Then
		Dvbbs.Stats="进行安装/设置"
		Dvbbs.Nav()
		Dvbbs.Head_var 0,"","申请版主","plus_QYmaster.asp"
		Call AppSetup()
	Else
		Dvbbs.Stats="安装/设置选项"
		Dvbbs.Nav()
		Dvbbs.Head_var 0,"","申请版主","plus_QYmaster.asp"
		Call SetupInfo()
	End If
End Sub

Sub	SetupInfo()
	Dim Showstr,Rs,Sql,Installed
	Showstr=template_Html(3)
	Set Rs=Dvbbs.execute("Select * From Dv_Plus Where plus_id='plus_QYmaster'")
	If Rs.Eof Or Rs.Bof Then
		Installed=False
		ShowIF Showstr,Installed,"None"
	Else
		Installed=True
		Sql=Rs.GetRows		
		ShowIF Showstr,Installed,Sql
	End If 
	Set Rs=Nothing
	Showstr=Replace(Showstr,"{$ShowBoardList}",ShowBoardList(Installed))
	Showstr=Replace(Showstr,"{$ShowBoardSelect}",ShowBoardSelect(Installed))
	Showstr=Replace(Showstr,"{$RecAdmin}",RecAdmin(Installed))
	Showstr=Replace(Showstr,"{$Stats}","欢迎使用版主申请安装/设定程序")
	Response.write Showstr
End Sub

Sub AppSetup()
	If request.form("title")="" then
		Errcodes=Errcodes+"<li>请输入菜单的标题！"
		exit sub
	End If
	Dim Plus_SettingData,Plus_Setting,i,tmpstr,Isuse
	Isuse=Request("Isuse")
	If Isuse<>"1" And Isuse<>"0" Then Isuse="1"
	Isuse=CInt(Isuse)
	Plus_Setting=Array("RealName","phone","spec","birth","email","oicq","known","time","BeBM","FavBoard","reason","HowDo","theme","advice","course")
	Plus_SettingData=""
	Plus_SettingData=Trim(Request.Form("windowtype"))&"|"&Trim(Request.Form("windowwidth"))&"|"&Trim(Request.Form("windowheight"))&"|||"
	Plus_SettingData=Plus_SettingData&Trim(Request.Form("SubmitBoard"))&","&Trim(Replace(Replace(Request.Form("BoardSelect"),",","@")," ",""))&","
	For i=0 to Ubound(Plus_Setting)
		If Trim(Request.Form(Plus_Setting(i)))="1" Then
			Plus_SettingData=Plus_SettingData&"1,"
		Else
			Plus_SettingData=Plus_SettingData&"0,"
		End If
	Next
	Dim SendMsg,RecAdmin
	SendMsg=Request("SendMsg")
	If SendMsg="" Then SendMsg=0
	RecAdmin=Replace(Request("RecAdmin")," ","")
	RecAdmin=Replace(RecAdmin,",","|")
	Plus_SettingData=Plus_SettingData&SendMsg&","&RecAdmin&",0|||提交的版区ID,开放申请的版区ID（以@号分隔）,真实姓名是否必填,联系电话是否必填,专长是否必填,出生年月是否必填,E-Mail是否必填,OICQ/ICQ是否必填,如何知道本论坛是否必填,上网时间和时段是否必填,是否做过版主（副）或聊管是否必填,平时常活动的版面是否必填,申请当该版版主（副）的详细理由是否必填,如何才能更好的行使版主权利是否必填,该版所包括的话题是否必填,对情缘未了论坛的建议与看法是否必填,本论坛的发展方向是否必填,是否向管理员发送短信通知,接收短信通知的管理员（以|号分隔）,设置字段20|||"
	Dim plusmaster,masterlist
	plusmaster=Request.Form("plusmaster")
	plusmaster=split(plusmaster,Chr(10))
	masterlist=""
	For i=0 to UBound(plusmaster)
		If Trim(plusmaster(i)) <>"" Then
			If masterlist="" Then
				masterlist=plusmaster(i)
			Else
				masterlist=masterlist&"|"&plusmaster(i)
			End If
		End If
	Next
	Dim useTime,timesetting,Groupsetting,Plus_UserPost,Plus_userWealth,Plus_UserEP,Plus_UserCP
	Dim Plus_UserPower,Plus_ADDuserWealth,Plus_ADDUserEP,Plus_ADDUserCP,Plus_ADDUserPower,guestuse
	useTime=Request("useTime")
	If useTime="" Then useTime=0
	timesetting=Trim(Request("timesetting"))
	If timesetting="" Then timesetting="0|24"
	Groupsetting=Trim(Request("Groupsetting"))
	Plus_UserPost=Trim(Request("Plus_UserPost"))
	If Plus_UserPost="" or not IsNumeric(Plus_UserPost) Then Plus_UserPost=0
	Plus_userWealth=Trim(Request("Plus_userWealth"))
	If Plus_userWealth="" or not IsNumeric(Plus_userWealth) Then Plus_userWealth=0
	Plus_UserEP=Trim(Request("Plus_UserEP"))
	If Plus_UserEP="" or not IsNumeric(Plus_UserEP) Then Plus_UserEP=0
	Plus_UserCP=Trim(Request("Plus_UserCP"))
	If Plus_UserCP="" or not IsNumeric(Plus_UserCP) Then Plus_UserCP=0
	Plus_UserPower=Trim(Request("Plus_UserPower"))
	If Plus_UserPower="" or not IsNumeric(Plus_UserPower) Then Plus_UserPower=0
	Plus_ADDuserWealth=Trim(Request("Plus_ADDuserWealth"))
	If Plus_ADDuserWealth="" or not IsNumeric(Plus_ADDuserWealth) Then Plus_ADDuserWealth=0
	Plus_ADDUserEP=Trim(Request("Plus_ADDUserEP"))
	If Plus_ADDUserEP="" or not IsNumeric(Plus_ADDUserEP) Then Plus_ADDUserEP=0
	Plus_ADDUserCP=Trim(Request("Plus_ADDUserCP"))
	If Plus_ADDUserCP="" or not IsNumeric(Plus_ADDUserCP) Then Plus_ADDUserCP=0
	Plus_ADDUserPower=Trim(Request("Plus_ADDUserPower"))
	If Plus_ADDUserPower="" or not IsNumeric(Plus_ADDUserPower) Then Plus_ADDUserPower=0
	guestuse=Request("guestuse")
	tmpstr=useTime&","&timesetting&","&Groupsetting&","&masterlist&","&plus_UserPost&","
	tmpstr=tmpstr&Plus_userWealth&","&Plus_UserEP&","&Plus_UserCP&","&Plus_UserPower&","
	tmpstr=tmpstr&Plus_ADDuserWealth&","&Plus_ADDUserEP&","&Plus_ADDUserCP&","&Plus_ADDUserPower&","&guestuse
	Plus_SettingData=Plus_SettingData&tmpstr
	Dim Rs,Sql
	set rs=server.createobject("adodb.recordset")
	Sql="select * from [dv_plus] where plus_id='plus_QYmaster'"
	If Not IsObject(Conn) Then ConnectionDatabase
	Rs.open Sql,conn,1,3
	If Rs.Eof Or Rs.Bof Then
		Rs.addnew
	End If
	Rs("plus_ID")="plus_QYmaster"
	Rs("plus_type")=Request.Form("stype")
	Rs("plus_name")=Replace(Request.Form("title"),CHR(34),"")
	Rs("isuse")=Isuse
	Rs("IsShowMenu")=1
	Rs("Mainpage")=Replace(Request.Form("url"),CHR(34),"")
	Rs("plus_Copyright")=Replace(Request.Form("readme"),CHR(34),"")
	Rs("Plus_Setting")=Plus_SettingData
	Rs.update
	Rs.close
	set Rs=nothing
	SucCodes=SucCodes+template_Strings(0)
	DelForumPlusMenuCache
End Sub

Sub DelForumPlusMenuCache()
	Dim Templateslist
	Dvbbs.Name="Templateslist"
	If Dvbbs.ObjIsEmpty() Then  Dvbbs.ReloadTemplateslist()
	Templateslist= Dvbbs.Value
	Templateslist=split(Templateslist,"@@@")
	Dim i
	For i=0 to UBound(Templateslist)
		Templateslist(i)=split(Templateslist(i),"|||")
		'Dvbbs.DelCahe("ForumPlusMenu"&Templateslist(i)(0))
	Next
	'Dvbbs.DelCahe("Plus_Settingts")
End Sub

Sub ShowIF(Showstr,Installed,TmpData)
	Dim PSetting,TmpChk,i
	TmpChk=Array("","","{$RNchk}","{$PHchk}","{$SPchk}","{$BHchk}","{$EMchk}","{$OICQchk}","{$HKchk}","{$TMchk}","{$BMchk}","{$FBchk}","{$RSchk}","{$HDchk}","{$TEchk}","{$ADchk}","{$CSchk}")
	If Not Installed Then
		Showstr=Replace(Showstr,"{$Title}","<Font Color=Red>版主申请</Font>")
		Showstr=Replace(Showstr,"{$stype}",ShowStype(Installed,0))
		Showstr=Replace(Showstr,"{$readme}","版主申请插件由情缘未了开发")
		Showstr=Replace(Showstr,"{$Selected0}","Selected")
		Showstr=Replace(Showstr,"{$Selected1}","")
		Showstr=Replace(Showstr,"{$Selected2}","")
		Showstr=Replace(Showstr,"{$Selected3}","")
		Showstr=Replace(Showstr,"{$windowwidth}","0")
		Showstr=Replace(Showstr,"{$windowheight}","0")
		Showstr=Replace(Showstr,"{$url}","plus_QYmaster.asp")
		Showstr=Replace(Showstr,"{$SendMsgchkyes}","")
		Showstr=Replace(Showstr,"{$SendMsgchkno}","Checked")
		Showstr=Replace(Showstr,"{$Isusechkyes}","Checked")
		Showstr=Replace(Showstr,"{$Isusechkno}","")
		Showstr=Replace(Showstr,"{$utimechkyes}","")
		Showstr=Replace(Showstr,"{$utimechkno}","Checked")
		Showstr=Replace(Showstr,"{$timesetting}","0|24")
		Showstr=Replace(Showstr,"{$Groupsetting}","1@2@3@4@8")
		Showstr=Replace(Showstr,"{$plusmaster}","")
		Showstr=Replace(Showstr,"{$Plus_UserPost}","0")
		Showstr=Replace(Showstr,"{$Plus_userWealth}","0")
		Showstr=Replace(Showstr,"{$Plus_UserEP}","0")
		Showstr=Replace(Showstr,"{$Plus_UserCP}","0")
		Showstr=Replace(Showstr,"{$Plus_UserPower}","0")	
		For i=2 To 16
			Showstr=Replace(Showstr,TmpChk(i),"")	
		Next
	Else
		PSetting=Split(Server.HTMLEncode(TmpData(4,0)),"|||")
		PSetting(0)=split(PSetting(0),"|")
		PSetting(1)=split(PSetting(1),",")
		If UBound(PSetting)>2 Then
			PSetting(3)=Split(PSetting(3),",")
		End If
		Showstr=Replace(Showstr,"{$Title}",Server.HtmlEncode(TmpData(2,0)))
		Showstr=Replace(Showstr,"{$stype}",ShowStype(Installed,TmpData(1,0)))
		Showstr=Replace(Showstr,"{$readme}",server.htmlencode(TmpData(7,0)))
		Showstr=Replace(Showstr,"{$Selected0}","")
		Showstr=Replace(Showstr,"{$Selected1}","")
		Showstr=Replace(Showstr,"{$Selected2}","")
		Showstr=Replace(Showstr,"{$Selected3}","")
		Showstr=Replace(Showstr,"{$Selected"&PSetting(0)(0)&"}","Selected")
		Showstr=Replace(Showstr,"{$windowwidth}",PSetting(0)(1))
		Showstr=Replace(Showstr,"{$windowheight}",PSetting(0)(2))
		Showstr=Replace(Showstr,"{$url}",server.htmlencode(TmpData(5,0)))
		If PSetting(3)(0)="1" Then
			Showstr=Replace(Showstr,"{$utimechkyes}","Checked")
			Showstr=Replace(Showstr,"{$utimechkno}","")
		ElseIf PSetting(3)(0)="0" Then
			Showstr=Replace(Showstr,"{$utimechkyes}","")
			Showstr=Replace(Showstr,"{$utimechkno}","Checked")
		End If
		If PSetting(1)(17)="1" Then
			Showstr=Replace(Showstr,"{$SendMsgchkyes}","Checked")
			Showstr=Replace(Showstr,"{$SendMsgchkno}","")
		ElseIf PSetting(1)(17)="0" Then
			Showstr=Replace(Showstr,"{$SendMsgchkyes}","")
			Showstr=Replace(Showstr,"{$SendMsgchkno}","Checked")
		End If
		If Cint(TmpData(3,0))=1 Then
			Showstr=Replace(Showstr,"{$Isusechkyes}","Checked")
			Showstr=Replace(Showstr,"{$Isusechkno}","")
		ElseIf Cint(TmpData(3,0))=0 Then
			Showstr=Replace(Showstr,"{$Isusechkyes}","")
			Showstr=Replace(Showstr,"{$Isusechkno}","Checked")
		End If	
		Showstr=Replace(Showstr,"{$timesetting}",PSetting(3)(1))
		Showstr=Replace(Showstr,"{$Groupsetting}",PSetting(3)(2))
		Showstr=Replace(Showstr,"{$plusmaster}",Replace(PSetting(3)(3),"|",Chr(10)))
		Showstr=Replace(Showstr,"{$Plus_UserPost}",PSetting(3)(4))
		Showstr=Replace(Showstr,"{$Plus_userWealth}",PSetting(3)(5))
		Showstr=Replace(Showstr,"{$Plus_UserEP}",PSetting(3)(5))
		Showstr=Replace(Showstr,"{$Plus_UserCP}",PSetting(3)(7))
		Showstr=Replace(Showstr,"{$Plus_UserPower}",PSetting(3)(8))	
		For i=2 To 16
			If Cint(Trim(PSetting(1)(i)))=1 Then
				Showstr=Replace(Showstr,TmpChk(i),"Checked")
			Else
				Showstr=Replace(Showstr,TmpChk(i),"")	
			End If
		Next
	End If
End Sub

Function ShowStype(Installed,tPlus_type)
	Dim Rs
	Set Rs=Dvbbs.Execute("Select * From Dv_Plus Where Plus_type='0'")
	If Rs.Eof And Rs.bof Then
		ShowStype=ShowStype & "<option value=0>作为一级菜单</option>"
	Else
		If Installed And Clng(tPlus_type)=0 Then
			ShowStype=ShowStype & "<option value=0 selected>作为一级菜单</option>"
		Else
			ShowStype=ShowStype & "<option value=0>作为一级菜单</option>"
		End If
		Do While Not Rs.Eof
			ShowStype=ShowStype & "<option value="&rs("id")
			If Installed And Clng(tPlus_type)=Rs("ID") Then ShowStype=ShowStype & " selected "
			ShowStype=ShowStype & ">"&Server.htmlencode(rs("plus_name"))&"</option>"
		Rs.MoveNext
		Loop
	End If
	Set Rs=Nothing
End Function

Function RecAdmin(Installed)
	Dim i,j,k,Rs,Sql,tmpBSchk,BSchk
	If Installed=true Then
		Set Rs=Dvbbs.Execute("select Plus_Setting from [dv_plus] where plus_id='plus_QYmaster'")
		tmpBSchk=Rs(0)
		Set Rs=Nothing
		tmpBSchk=Split(tmpBSchk,"|||")
		tmpBSchk(1)=Split(tmpBSchk(1),",")
		BSchk=Split(tmpBSchk(1)(18),"|")
	End If
	If Not IsObject(Conn) Then ConnectionDatabase
	Set Rs=Conn.execute("Select adduser From "&Admintable)
	If Not (Rs.Eof Or Rs.Bof) Then
		Sql=Rs.GetRows
		RecAdmin = "<table width=""100%"" border=""0"" cellspacing=""0"" cellpadding=""0"" >"
		k=0
		For i=0 To Ubound(Sql,2)
			k=k+1
			If k=1 Then RecAdmin = RecAdmin & "<tr>"
				RecAdmin = RecAdmin & "<td width=""1%"">&nbsp;<input type=checkbox value="""&Sql(0,i)&""" name=""RecAdmin""" 
				If Installed Then
					For j=0 to Ubound(BSchk)
						If BSchk(j)=Sql(0,i) Then
							RecAdmin = RecAdmin & " checked"
						End If
					Next
				End If
				RecAdmin = RecAdmin & ">&nbsp;</td>"
				RecAdmin = RecAdmin & "<td>" & Sql(0,i) & "</td>"
			If k=3 Then
				k=0
				RecAdmin = RecAdmin & "</tr>"
			End If
		Next
		RecAdmin = RecAdmin & "</table>"
	Else
		RecAdmin = "暂无任何管理员"
	End If
	Set Rs=Nothing
End Function

Function ShowBoardList(Installed)
	Dim i,j,Rs,Sql,tmpBSchk,BSchk
	If Installed=true Then
		Set Rs=Dvbbs.Execute("select Plus_Setting from [dv_plus] where plus_id='plus_QYmaster'")
		tmpBSchk=Rs(0)
		Set Rs=Nothing
		tmpBSchk=Split(tmpBSchk,"|||")
		tmpBSchk(1)=Split(tmpBSchk(1),",")
		BSchk=tmpBSchk(1)(0)
	End If
	Set Rs=Dvbbs.execute("Select boardid,boardtype,depth From Dv_Board order by rootid,orders") 
	If Not (Rs.Eof Or Rs.Bof) Then
		Sql=Rs.GetRows
		For i=0 To Ubound(Sql,2)
			ShowBoardList=ShowBoardList & "<option value="""&Sql(0,i)&""""
			If Installed Then
				If Cint(Sql(0,i))=Cint(BSchk) Then
					ShowBoardList=ShowBoardList & " selected"
				End If
			End If
			ShowBoardList=ShowBoardList & ">"
			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
			ShowBoardList = ShowBoardList & Sql(1,i)&"</option>"
		Next
	Else
		ShowBoardList = "<option value=""0"">暂无任何版区</option>"
	End If
	Set Rs=Nothing
End Function

Function ShowBoardSelect(Installed)
	Dim i,j,k,Rs,Sql,BSchk,tmpBSchk,tmpBSchk2
	If Installed=true Then
		Set Rs=Dvbbs.Execute("select Plus_Setting from [dv_plus] where plus_id='plus_QYmaster'")
		tmpBSchk=Rs(0)
		Set Rs=Nothing
		tmpBSchk=Split(tmpBSchk,"|||")
		tmpBSchk(1)=Split(tmpBSchk(1),",")
		BSchk=Split(tmpBSchk(1)(1),"@")
	End If
	Set Rs=Dvbbs.execute("Select boardid,boardtype,depth From Dv_Board order by rootid,orders")
	If Not (Rs.Eof Or Rs.Bof) Then
		Sql=Rs.GetRows
		ShowBoardSelect = "<table width=""100%"" border=""0"" cellspacing=""0"" cellpadding=""0"" >"
		k=0
		For i=0 To Ubound(Sql,2)
			k=k+1
			If k=1 or Cint(Sql(2,i))=0 Then ShowBoardSelect = ShowBoardSelect & "<tr>"
			If Cint(Sql(2,i))>0 Then
				ShowBoardSelect = ShowBoardSelect & "<td width=""1%"">&nbsp;<input type=checkbox value="""&Sql(0,i)&""" name=""BoardSelect""" 
				If Installed Then
					For j=0 to Ubound(BSchk)
						If Cint(BSchk(j))=Cint(Sql(0,i)) Then
							ShowBoardSelect = ShowBoardSelect & " checked"
						End If
					Next
				End If
				ShowBoardSelect = ShowBoardSelect & ">&nbsp;</td>"
				ShowBoardSelect = ShowBoardSelect & "<td>" & Sql(1,i) & "</td>"
			Else
				ShowBoardSelect = ShowBoardSelect & "<td colspan=""4"">" &Sql(1,i) & "</td>" 
			End If
			If k=2 or Cint(Sql(2,i))=0 Then
				k=0
				ShowBoardSelect = ShowBoardSelect & "</tr>"
			End If
		Next
		ShowBoardSelect = ShowBoardSelect & "</table>"
	Else
		ShowBoardList = "暂无任何版区"
	End If
	Set Rs=Nothing
End Function

%>