<!--#include file="Script/Const.asp"-->
<!--#include file="Script/Inc.asp"-->
<%
'-------------------------------------------
' Dvbbs System Update Software
' Default File 
' 动网先锋 [AspSky Software, Inc.]
' ScriptEditor Fssunwin
' 2005-03-25
'-------------------------------------------
'显示主体页面

Call PageMain()
'处理提交数据
If Action = "5" Then
	Call UpdateProgam()
End If

Sub UpdateProgam()
	Dim Update_Type1,Update_Type2,Update_Type3,Update_Type4,Update_Type5,Update_Type6,Update_Type7
	'	取得操作参数
	'	1=升级数据库结构,2=更新模板结构及数据,3=更新默认数据,4=更新当前站点缓存,5=压缩数据库,6=备份数据库,7=更新模板结构,8=博客
	Update_Type1 = Request.Form("Update_Type1")
	Update_Type2 = Request.Form("Update_Type2")
	Update_Type3 = Request.Form("Update_Type3")
	Update_Type4 = Request.Form("Update_Type4")
	Update_Type5 = Request.Form("Update_Type5")
	Update_Type6 = Request.Form("Update_Type6")
	Update_Type7 = Request.Form("Update_Type7")
	DvbbsVersion = Request.Form("DvbbsVersion")
	If DvbbsVersion = "" Or Not IsNumeric(DvbbsVersion) Then DvbbsVersion = 0
	DvbbsVersion = Cint(DvbbsVersion)
	If DvbbsVersion > 1 Or DvbbsVersion < 0 Then DvbbsVersion = 0
	If Update_Type1 = "1" or Update_Type2 = "1" or Update_Type3 = "1" Then
		CheckData Conn,GetConnstr
		Conn.CommandTimeout=3600
		CheckData Conn_T,DefaultData
		If not (Checktable("Dv_setup",True) And Checktable("Dv_Board",True) And Checktable("Dv_Style",True)) Then
			Exit Sub
		End If
	End If

	'备份数据
	If Update_Type6 = "1" Then
		Call BackData()
	End If
	'更新数据库结构,仅7.0版本执行,7.1版本执行一行后退出
	If Update_Type1 = "1" Then
		Call UpdateSys()
	End If
	'更新模板结构
	If Update_Type7 = "1" Then
		Call UpdateStyleTable()
	End If
	'更新模板结构和数据
	If Update_Type2 = "1" Then
		Call UpdateStyle()
	End If
	'更新默认数据,仅7.0版本执行,7.1执行部分另外写函数
	'增加部分版面设置、系统设置更新、系统设置版面xml更新，以及Forum_ChanSetting字段更新
	If Update_Type3 = "1" And DvbbsVersion = 0 Then
		Call UpdateData()
	End If
	'7.1数据更新部分
	If Update_Type3 = "1" And DvbbsVersion = 1 Then
		Call NewVersion()
	End If
	'整合BOKE数据库
	If Request.Form("Update_Type8") = "1" Then
		Call AddBokeData()
	End If
	'更新缓存
	If Update_Type4 = "1" Then
		Call RemoveAllCache
	End If
	'压缩数据库
	If Update_Type5 = "1" Then
		Call CompressData()
	End If
	Call InnerHtml("UpdateInfo","<b>全部操作执行完成！</b>")
	SaveLog()
	If Update_Type5 <> "1" Then
		Call Footer()
	End If
End Sub

'整合BOKE数据库
Sub AddBokeData()
	'创建表
	Call CreateNewTable("[Dv_Boke_KeyWord]")
	Call CreateNewTable("[Dv_Boke_Post]")
	Call CreateNewTable("[Dv_Boke_Skins]")
	Call CreateNewTable("[Dv_Boke_SysCat]")
	Call CreateNewTable("[Dv_Boke_System]")
	Call CreateNewTable("[Dv_Boke_Topic]")
	Call CreateNewTable("[Dv_Boke_Upfile]")
	Call CreateNewTable("[Dv_Boke_User]")
	Call CreateNewTable("[Dv_Boke_UserCat]")
	Call CreateNewTable("[Dv_Boke_UserSave]")
	'创建索引
	'插入默认数据
	'模板
	Conn.Execute("InSert Into Dv_Boke_Skins (S_SkinName,S_Path,S_ViewPic,S_Builder) Values ('iBoke 默认风格','Boke/Skins/Default/','Boke/Skins/Default/viewlogo.png','AspSky.Net')")
	Conn.Execute("InSert Into Dv_Boke_Skins (S_SkinName,S_Path,S_ViewPic,S_Builder) Values ('iBoke 默认风格2','Boke/Skins/dvskin/','Boke/Skins/dvskin/viewlogo.png','AspSky.Net')")
	'系统分类
	Conn.Execute("InSert Into Dv_Boke_SysCat (sCatTitle,sType) Values ('个人空间',0)")
	Conn.Execute("InSert Into Dv_Boke_SysCat (sCatTitle,sType) Values ('电脑网络',0)")
	Conn.Execute("InSert Into Dv_Boke_SysCat (sCatTitle,sType) Values ('经济金融',0)")
	Conn.Execute("InSert Into Dv_Boke_SysCat (sCatTitle,sType) Values ('教育学习',0)")
	Conn.Execute("InSert Into Dv_Boke_SysCat (sCatTitle,sType) Values ('情感绿洲',0)")
	Conn.Execute("InSert Into Dv_Boke_SysCat (sCatTitle,sType) Values ('娱乐休闲',0)")
	Conn.Execute("InSert Into Dv_Boke_SysCat (sCatTitle,sType) Values ('少儿乐园',0)")
	Conn.Execute("InSert Into Dv_Boke_SysCat (sCatTitle,sType) Values ('原创文学',0)")
	Conn.Execute("InSert Into Dv_Boke_SysCat (sCatTitle,sType) Values ('生活百科',0)")
	Conn.Execute("InSert Into Dv_Boke_SysCat (sCatTitle,sType) Values ('大话天下',0)")
	Conn.Execute("InSert Into Dv_Boke_SysCat (sCatTitle,sType) Values ('体育竞技',0)")
	Conn.Execute("InSert Into Dv_Boke_SysCat (sCatTitle,sType) Values ('旅游自然',0)")
	Conn.Execute("InSert Into Dv_Boke_SysCat (sCatTitle,sType) Values ('网络游戏',0)")
	Conn.Execute("InSert Into Dv_Boke_SysCat (sCatTitle,sType) Values ('班级集体',0)")
	Conn.Execute("InSert Into Dv_Boke_SysCat (sCatTitle,sType) Values ('政法军事',0)")
	Conn.Execute("InSert Into Dv_Boke_SysCat (sCatTitle,sType) Values ('电子商务',0)")
	Conn.Execute("InSert Into Dv_Boke_SysCat (sCatTitle,sType) Values ('日记',1)")
	Conn.Execute("InSert Into Dv_Boke_SysCat (sCatTitle,sType) Values ('知识',1)")
	Conn.Execute("InSert Into Dv_Boke_SysCat (sCatTitle,sType) Values ('读书',1)")
	Conn.Execute("InSert Into Dv_Boke_SysCat (sCatTitle,sType) Values ('心情',1)")
	Conn.Execute("InSert Into Dv_Boke_SysCat (sCatTitle,sType) Values ('生活',1)")
	Conn.Execute("InSert Into Dv_Boke_SysCat (sCatTitle,sType) Values ('体育',1)")
	Conn.Execute("InSert Into Dv_Boke_SysCat (sCatTitle,sType) Values ('下载',1)")
	Conn.Execute("InSert Into Dv_Boke_SysCat (sCatTitle,sType) Values ('数码',1)")
	Conn.Execute("InSert Into Dv_Boke_SysCat (sCatTitle,sType) Values ('帖图',1)")
	Conn.Execute("InSert Into Dv_Boke_SysCat (sCatTitle,sType) Values ('电影',1)")
	Conn.Execute("InSert Into Dv_Boke_SysCat (sCatTitle,sType) Values ('音乐',1)")
	Conn.Execute("InSert Into Dv_Boke_SysCat (sCatTitle,sType) Values ('网络',1)")
	Conn.Execute("InSert Into Dv_Boke_SysCat (sCatTitle,sType) Values ('软件',1)")
	Conn.Execute("InSert Into Dv_Boke_SysCat (sCatTitle,sType) Values ('开发',1)")
	Conn.Execute("InSert Into Dv_Boke_SysCat (sCatTitle,sType) Values ('传媒',1)")
	Conn.Execute("InSert Into Dv_Boke_SysCat (sCatTitle,sType) Values ('交易',1)")
	'系统表
	Conn.Execute("InSert Into Dv_Boke_System (S_Name,S_Setting,S_Url,SkinID) Values ('动网博客','1,1,1,1,1,1,20,20,15,3,1,1,1|0|0|999|bbs.dvbbs.net|12|1|Arial|0|images/WaterMap.gif|0.7|110|35|4|120|100|1|1|1|Boke/UploadFile/|0,晴天|和煦|阴天|清爽|多云|有雾|小雨|中雨|雷雨|彩虹|酷热|寒冷|小雪|大雪|月圆|月缺,sun.gif|sun2.gif|yin.gif|yin.gif|yun.gif|wu.gif|xiaoyu.gif|yinyu.gif|leiyu.gif|caihong.gif|sun.gif|feng.gif|xue.gif|daxue.gif|moon.gif|moon2.gif,50,gif|jpg|jpeg|bmp|png|rar|txt|zip|mid,欢迎大家来到动网博客建立自己的网上家园,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1','http://www.iboker.com',1)")
End Sub

'7.1版本数据更新部分
Sub NewVersion()
	Dim Rs,Sql,i,j,Rs_1
	'更新版面部分数据
	Call InnerHtml("UpdateInfo","正在更新版面[Dv_Board]部分高级设置")
	Dim IsGroupSetting,Boardid,Board_Setting,UpBoard_Setting
	Set Rs = Conn.Execute("select Boardid,Board_Setting From Dv_Board")
	If Not Rs.Eof Then
		Boardid = Rs.GetRows(-1)
	End If
	Rs.Close
	Set Rs = Nothing
	If IsArray(Boardid) Then
		For i = 0 To UBound(Boardid, 2)
			Board_Setting = Split(Boardid(1, i),",")
			UpBoard_Setting = ""
			IsGroupSetting = ""
			For j = 0 To Ubound(Board_Setting) 
				If j=67 Then
					UpBoard_Setting = UpBoard_Setting & "1"
				Else
					UpBoard_Setting = UpBoard_Setting & Board_Setting(j)
				End IF
				If j<Ubound(Board_Setting) Then
					UpBoard_Setting = UpBoard_Setting & ","
				End If
			Next
			Conn.Execute("update Dv_Board Set Board_Setting='"&Replace(UpBoard_Setting,"'","''")&"',SID=1,CID=1 Where BoardID=" & Boardid(0, i))
		Next
	End If
	Call InnerHtml("UpdateInfo","更新版面[Dv_Board]部分高级设置完成")
	'更新系统设置部分数据和board_xml部分
	Call InnerHtml("UpdateInfo","正在更新表[Dv_setup]部分设置")
	Dim Forum_Boards
	'Forum_Boards = Split(Conn_T.Execute("SELECT Forum_Boards From Dv_setup")(0),"|||")
	Dim Old_Setting,New_Setting,UP_Setting,iSetting
	Old_Setting = Split(Conn.execute("SELECT Forum_setting From Dv_setup")(0),"|||")
	New_Setting = Split(Old_Setting(1),",")
	For i = 0 To Ubound(New_Setting)
		If i = 99 Then
			iSetting = iSetting & "1"
		ElseIf i = 89 Then
			iSetting = iSetting & "1"
		Else
			iSetting = iSetting & New_Setting(i)
		End If
		If i<Ubound(New_Setting) Then
			iSetting = iSetting & ","
		End If
	Next
	UP_Setting = Old_Setting(0) & "|||" & iSetting & "|||" & Old_Setting(2) & "|||" & Old_Setting(3) & "|||" & Old_Setting(4) & "|||" & Old_Setting(5)
	Conn.Execute("UpDate Dv_Setup Set Forum_setting = '"&Replace(UP_Setting,"'","''")&"',Forum_BoardXML='<accesspost />'")
	If Err.Number <> 0 Then
		Call InnerHtml("UpdateInfo","设置表[Dv_setup]数据更新出错,原因:" & Err.Description)
		Err.Clear()
	End If
	Call InnerHtml("UpdateInfo","更新表[Dv_setup]部分设置完成")
	UP_Setting = ""
	'系统后台菜单,帮助表
	Call InnerHtml("UpdateInfo","正在更新帮助表[Dv_help]数据")
	Set Rs_1 = Conn_T.Execute("SELECT H_content From Dv_help where H_id=1")
	Conn.Execute("update Dv_help Set H_content='" & Rs_1(0).Value & "' where H_id=1")
	Call InnerHtml("UpdateInfo","帮助表[Dv_help]数据更新完毕")
End Sub

'升级数据库结构
Sub UpdateSys()
	'7.1中的用户和帖子表数据更新，SQL版应做到SQL语句到查询分析器执行
	Call ModColumn("[Dv_BbsNews]","Title","varchar(250) null")
	If DvbbsVersion = 1 Then Exit Sub
	If Checktable("Dv_Plus_Tools_Log", False) Then
		Conn.Execute("Drop table [Dv_Plus_Tools_Log]")
	End If
	Call InnerHtml("UpdateInfo","<b>正在更新数据库结构</b>")
	Call InnerHtml("UpdateInfo","创建表[Dv_Plus_Tools_Buss]")
	Call CreateNewTable("[Dv_Plus_Tools_Buss]")
	Call AddIndex("[Dv_Plus_Tools_Buss]", "Tools_UserID", "[UserID]")
	Call AddIndex("[Dv_Plus_Tools_Buss]", "Tools_ToolsID", "[ToolsID]")
	Call AddIndex("[Dv_Plus_Tools_Buss]", "Buy_Tools", "[UserID], [ToolsID]")
	Call InnerHtml("UpdateInfo","创建表[Dv_Plus_Tools_Info]")
	Call CreateNewTable("[Dv_Plus_Tools_Info]")
	Call InnerHtml("UpdateInfo","创建表[Dv_MoneyLog]")
	Call CreateNewTable("[Dv_MoneyLog]")
	Call InnerHtml("UpdateInfo","正在更新索引和数据")
	Call AddIndex("[Dv_MoneyLog]", "UserID", "[AddUserID]")
	Call AddIndex("[Dv_MoneyLog]", "BoardID", "[BoardID]")
	Call AddIndex("[Dv_MoneyLog]", "Log_Type", "[Log_Type]")
	Call AddIndex("[Dv_MoneyLog]", "ToolsID", "[ToolsID]")
	Call AddIndex("[Dv_MoneyLog]", "UserTools", "[ToolsID], [AddUserID]")
	Call InnerHtml("UpdateInfo","创建表[Dv_Plus_Tools_MagicFace]")
	Call CreateNewTable("[Dv_Plus_Tools_MagicFace]")

	'---Dv_setup
	Call AddColumn("[Dv_Setup]", "[Forum_AdminFolder]", "varchar(255) null")
	Call AddColumn("[Dv_Setup]", "[Forum_BoardXML]", "text null")
	Call AddColumn("[Dv_Setup]", "[Forum_Css]", "text null")
	'---Dv_Board
	Call AddColumn("[Dv_Board]", "[Rules]", "text null")
	'--Dv_Admin
	Call AddColumn("[Dv_admin]", "[AcceptIP]", "varchar(255) Null")
	'--Dv_Topic
	Call ModColumn("[Dv_BestTopic]","Expression","varchar(100) null")
	'非商业用户的SQL版本用户请注释掉下面一行
	If IsSql = 0 Then
		Call AddColumn("[Dv_Topic]", "[GetMoney]", "int Not Null default 0")
		Call AddColumn("[Dv_Topic]", "[UseTools]", "varchar(255) Null")
		Call AddColumn("[Dv_Topic]", "[GetMoneyType]", "tinyint Not Null default 0")
		Call upColumn("[Dv_Topic]", "[GetMoney]", "0")
		Call upColumn("[Dv_Topic]", "[GetMoneyType]", "0")
		Call AddIndex("[Dv_Topic]", "GetMoneyType_List", "[Boardid], [GetMoneyType]")
		Call ModColumn("[Dv_Topic]","Expression","varchar(100) null")
		'--Dv_User
		Call AddColumn("[Dv_User]", "[UserMoney]", "int Not Null default 0")
		Call AddColumn("[Dv_User]", "[UserTicket]", "int Not Null default 0")
		Call AddColumn("[Dv_User]", "[FollowMsgID]", "text Null")
		Call AddColumn("[Dv_User]", "[Vip_StarTime]", "smalldatetime Null ")
		Call AddColumn("[Dv_User]", "[Vip_EndTime]", "smalldatetime Null ")
		Call AddIndex("[Dv_User]", "Dv_UserMoney", "[UserMoney]")
		Call AddIndex("[Dv_User]", "Dv_UserTicket", "[UserTicket]")
		Call AddIndex("[Dv_User]", "Dv_UserGroupID", "[UserGroupID]")
		Call ModColumn("[Dv_User]","UserMsg","varchar(100) null")
	'非商业用户的SQL版本用户请注释掉下面一行
	End If

	Dim Rs,Sql,i
	Dim TableName
	'更新分表数据结构
	'非商业用户的SQL版本用户请注释掉下面一行
	If IsSql = 0 Then
		SQL = "Select TableName From Dv_TableList Order by Id"
		SET Rs = Conn.Execute(SQL)
		If Not Rs.eof Then
			TableName=Rs.GetRows(-1)
		End If
		Rs.close:Set Rs = Nothing
		If IsArray(TableName) Then
			For i=0 To Ubound(TableName,2)
				If Checktable(TableName(0,i) & "", False) Then
					Call AddColumn("[" & TableName(0,i) & "]", "GetMoney", "int Not Null default 0")
					Call AddColumn("[" & TableName(0,i) & "]", "UseTools", "varchar(255) Null")
					Call AddColumn("[" & TableName(0,i) & "]", "GetMoneyType", "tinyint Not Null default 0")
					Call ModColumn("[" & TableName(0,i) & "]","Expression","varchar(100) null")
					Call AddIndex("[" & TableName(0,i) & "]", "PostUserID", "[PostUserID]")
				End If
			Next
		End If
	'非商业用户的SQL版本用户请注释掉下面一行
	End If
	Call InnerHtml("UpdateInfo","正在更新用户组表结构")
	Call DelColumn("[Dv_UserGroups]","IsDisp")
	Call ModColumn("[Dv_UserGroups]","IsSetting","varchar(50) null")
	Call ModColumn("[Dv_UserGroups]","GroupSetting","text null")
	Call ModColumn("[Dv_BoardPermission]","PSetting","text null")
	Call ModColumn("[Dv_UserAccess]","uc_Setting","text null")
	Call InnerHtml("UpdateInfo","更新用户组表结构完成")
	Call DelTable("[Dv_AdCode]")
	Call InnerHtml("UpdateInfo","正在删除原帮助模板数据")
	Call DelColumn("[Dv_StyleHelp]","Forum_CSS")
	Call DelColumn("[Dv_StyleHelp]","Page_List")
	Call InnerHtml("UpdateInfo","<b>数据库结构更新完成．</b>")
End Sub

Sub UpdateStyleTable()
	'更新模板表结构
	Call InnerHtml("UpdateInfo","<b>正在更新模板数据表结构</b>")
	Call DelTable("[Dv_Style]")
	Call InnerHtml("UpdateInfo","原模板删除操作完成．")
	'创建模板数据表
	Call InnerHtml("UpdateInfo","正在创建新数据库结构")
	Call CreateNewTable("[Dv_Style]")
	Call InnerHtml("UpdateInfo","创建新数据库结构完成")
End Sub

Sub UpdateData()
	'更新分表数据数据
	Call InnerHtml("UpdateInfo","<b>正在初始化数据库新版默认数据</b>")
	Dim Rs,Sql,i
	Dim TableName
	'更新分表数据
	SQL = "Select TableName From Dv_TableList Order by Id"
	SET Rs = Conn.Execute(SQL)
	If Not Rs.eof Then
		TableName=Rs.GetRows(-1)
	End If
	Rs.close:Set Rs = Nothing
	'非商业用户的SQL版本用户请注释掉下面一行
	If IsSql = 0 Then
		If IsArray(TableName) Then
			For i=0 To Ubound(TableName,2)
				If Checktable(TableName(0,i) & "", False) Then
					Conn.Execute("Update " & TableName(0,i) & " set GetMoney=0,GetMoneyType=0,isagree='0|0'")
					Call InnerHtml("UpdateInfo","更新数据表" & TableName(0,i) & "完成.")
				End If
			Next
		End If
		'更用户表数据
		Conn.Execute("update Dv_user set UserMoney=0,UserTicket=0,UserToday='0|0|0|0|0'")
		Call InnerHtml("UpdateInfo","更新[Dv_USER]表金币，点券数据成功。")
	'非商业用户的SQL版本用户请注释掉下面一行
	End If
	'更新用户组表数据
	Call InnerHtml("UpdateInfo","正在更新用户组设置数据")
	Dim NewGroups
	Dim NewGroupsSetting,OldGroupsSetting,UpGroupsSetting
	Dim Temp1,Temp2,TitlePic
	'取出新库中特殊组的数据
	SQL = "Select UserGroupID,GroupSetting,ParentGID,TitlePic,MinArticle From [Dv_UserGroups] where UserGroupID<9 order by UserGroupID"
	SET Rs = Conn_T.Execute(SQL)
	If Not Rs.eof Then
		NewGroups = Rs.GetRows(-1)
	End If
	Rs.close
	Dim j
	i = 0
	If 	GetPrimaryKey("Dv_UserGroups",True)="" Then
		Call AddPRIMARYKEY("[Dv_UserGroups]","UserGroupID")
	End If
	Set Rs=Server.CreateObject("ADODB.RecordSet")
	Sql = "Select UserGroupID,GroupSetting,ParentGID,TitlePic,MinArticle From [Dv_UserGroups] Order by UserGroupID"
	Rs.Open sql, Conn, 1, 3
	Do While Not Rs.EOF
		If i<8 and Rs(2)=0 Then
			NewGroupsSetting = Split(NewGroups(1,i),",")	'UserGroupID = 1时，对应的 i=0
		Else
			NewGroupsSetting = Split(NewGroups(1,3),",")	'以新版UserGroupID=4的的参数为标准
		End If
		OldGroupsSetting = Split(Rs(1),",")
		Temp1 = Ubound(NewGroupsSetting)
		Temp2 = Ubound(OldGroupsSetting)
		For j = 0 To Temp1
			If j=57 or j=58 or j=59 or j=67 or j=69 or j=70 or j=71  Then
				UpGroupsSetting = UpGroupsSetting & NewGroupsSetting(j) 
			Else
				If j<Temp2 Then
					UpGroupsSetting = UpGroupsSetting & OldGroupsSetting(j)
				Else
					UpGroupsSetting = UpGroupsSetting & NewGroupsSetting(j) 
				End If
			End If
			If j<Temp1 Then
				UpGroupsSetting = UpGroupsSetting & ","
			End If
		Next
		Rs(1) = UpGroupsSetting
		UpGroupsSetting = ""
		TitlePic = Mid(Rs(3),InStrRev(Rs(3)&"", "/")+1)
		Rs(3) = TitlePic
		i = i + 1
	Rs.Update()
	Rs.MoveNext()
	Loop
	Rs.Close
	Sql = "Update [Dv_UserGroups] Set ParentGID=3 where ParentGID=4"	'注册组更新
	Conn.Execute(Sql)
	Sql = "Update [Dv_UserGroups] Set ParentGID=1 where UserGroupID<>4 and UserGroupID<8"	'系统组更新
	Conn.Execute(Sql)
	Sql = "Update [Dv_UserGroups] Set ParentGID=2 where UserGroupID=8"	'贵宾更新
	Conn.Execute(Sql)
	Sql = "Update [Dv_UserGroups] Set ParentGID=2 where UserGroupID>8 and MinArticle = -1"	'新增的特殊组更新
	Conn.Execute(Sql)
	Sql = "Update [Dv_UserGroups] Set ParentGID=3 where ParentGID<>3 and UserGroupID>8 and MinArticle <> -1"	'新增的特殊组更新
	Conn.Execute(Sql)
	Sql = "Update [Dv_UserGroups] Set Orders=0 where UserGroupID=5 or UserGroupID=6"
	Conn.Execute(Sql)
	Sql = "Update [Dv_UserGroups] Set IsSetting=''"
	Conn.Execute(Sql)
	Call InnerHtml("UpdateInfo","更新用户组设置数据完成")
	Set Rs = Conn.Execute("select * From [Dv_UserGroups] Order by UserGroupID")
    Do While Not Rs.EOF
		Conn.execute("Update Dv_user Set UserGroupID=" & Rs("UserGroupID").Value & "  where userclass='" & Rs("usertitle").Value & "'")
    Rs.MoveNext()
    Loop
    Rs.Close()
	Set Rs = Nothing
	Call InnerHtml("UpdateInfo","更新用户表UserGroupID数据完成")
	Call InnerHtml("UpdateInfo","正在更新版面自定义用户组设置数据")
	
	Dim Forum_Boards
	Forum_Boards = ""
	Set Rs = Conn.Execute("Select Boardid From Dv_Board order by rootid,orders")
	If Not Rs.Eof Then
		Forum_Boards = Rs.GetString(,,"",",","")
		Forum_Boards = Left(Forum_Boards,InStrRev(Forum_Boards, ",")-1)
	End If
	Rs.Close
	If Forum_Boards<>"" Then
		Conn.Execute("delete From Dv_BoardPermission where GroupID=4")
		Conn.Execute("delete From Dv_BoardPermission where Boardid not in("&Forum_Boards&")")
		Conn.Execute("delete From Dv_UserAccess where uc_boardid not in("&Forum_Boards&")")
		If GetPrimaryKey("Dv_BoardPermission",True)="" Then
			Call AddPRIMARYKEY("[Dv_BoardPermission]","Pid")
		End If
		Set Rs=Server.CreateObject("ADODB.RecordSet")
		Sql = "Select GroupID,PSetting From Dv_BoardPermission"
		Rs.Open sql, Conn, 1, 3
		Do While Not Rs.EOF
			If Rs(0)<8 Then
				NewGroupsSetting = Split(NewGroups(1,Rs(0)),",")	'UserGroupID = 1时，对应的 i=0
			Else
				NewGroupsSetting = Split(NewGroups(1,3),",")	'以新版UserGroupID=4的的参数为标准
			End If
			OldGroupsSetting = Split(Rs(1),",")
			Temp1 = Ubound(NewGroupsSetting)
			Temp2 = Ubound(OldGroupsSetting)
			For j = 0 To Temp1
				If j=57 or j=58 or j=59 or j=67 or j=69 or j=70 or j=71 Then
					UpGroupsSetting = UpGroupsSetting & NewGroupsSetting(j) 
				Else
					If j<Temp2 Then
						UpGroupsSetting = UpGroupsSetting & OldGroupsSetting(j)
					Else
						UpGroupsSetting = UpGroupsSetting & NewGroupsSetting(j) 
					End If
				End If
				If j<Temp1 Then
					UpGroupsSetting = UpGroupsSetting & ","
				End If
			Next
			Rs(1) = UpGroupsSetting
			UpGroupsSetting = ""
		Rs.Update()
		Rs.MoveNext()
		Loop
		Rs.Close
	Else
		Conn.Execute("delete From Dv_BoardPermission")
	End If
	Call InnerHtml("UpdateInfo","更新版面自定义用户组设置数据完成")
	Call InnerHtml("UpdateInfo","正在更新自定义用户设置数据")

	Set Rs=Server.CreateObject("ADODB.RecordSet")
	Sql = "Select uc_Setting From Dv_UserAccess"
	Rs.Open sql, Conn, 1, 3
	Do While Not Rs.EOF
		NewGroupsSetting = Split(NewGroups(1,3),",")	'以新版UserGroupID=4的的参数为标准
		OldGroupsSetting = Split(Rs(0),",")
		Temp1 = Ubound(NewGroupsSetting)
		Temp2 = Ubound(OldGroupsSetting)
		For j = 0 To Temp1
			If j=57 or j=58 or j=59 or j=67 or j=69 or j=70 or j=71 Then
				UpGroupsSetting = UpGroupsSetting & NewGroupsSetting(j) 
			Else
				If j<Temp2 Then
					UpGroupsSetting = UpGroupsSetting & OldGroupsSetting(j)
				Else
					UpGroupsSetting = UpGroupsSetting & NewGroupsSetting(j) 
				End If
			End If
			If j<Temp1 Then
				UpGroupsSetting = UpGroupsSetting & ","
			End If
		Next
		Rs(0) = UpGroupsSetting
		UpGroupsSetting = ""
	Rs.Update()
	Rs.MoveNext()
	Loop
	Rs.Close
	Call InnerHtml("UpdateInfo","更新自定义用户设置数据完成")

	Call InnerHtml("UpdateInfo","正在更新版面[Dv_Board]自定义用户组")
	Conn.Execute("update Dv_Board Set IsGroupSetting='',Sid=1,CID=1")
	Dim IsGroupSetting,Boardid,Board_Setting,UpBoard_Setting
	Set Rs = Conn.Execute("select Boardid,Board_Setting From Dv_Board")
	If Not Rs.Eof Then
		Boardid = Rs.GetRows(-1)
	End If
	Rs.Close
	Set Rs = Nothing
	If IsArray(Boardid) Then
		For i = 0 To UBound(Boardid, 2)
			Board_Setting = Split(Boardid(1, i),",")
			UpBoard_Setting = ""
			IsGroupSetting = ""
			For j = 0 To Ubound(Board_Setting) 
				If j=24 Then
					UpBoard_Setting = UpBoard_Setting & "1"
				ElseIf j=65 Then
					UpBoard_Setting = UpBoard_Setting & "灌水|广告|奖励|惩罚|好文章|内容不符|重复发帖"
				'7.1新增
				ElseIf j=67 Then
					UpBoard_Setting = UpBoard_Setting & "1"
				Else
					UpBoard_Setting = UpBoard_Setting & Board_Setting(j)
				End IF
				If j<Ubound(Board_Setting) Then
					UpBoard_Setting = UpBoard_Setting & ","
				End If
			Next
			Set Rs = Conn.Execute("select GroupID From Dv_BoardPerMission where BoardID=" & Boardid(0, i))
			If Not Rs.EOF Then
				IsGroupSetting = Rs.GetString(,,"",",","")
				IsGroupSetting = Left(IsGroupSetting,InStrRev(IsGroupSetting, ",")-1)
			End If
			Rs.Close
			Conn.Execute("update Dv_Board Set Board_Setting='"&Replace(UpBoard_Setting,"'","''")&"',IsGroupSetting='" & IsGroupSetting & "' Where BoardID=" & Boardid(0, i))
		Next
	End If
	Call InnerHtml("UpdateInfo","更新版面[Dv_Board]自定义用户组完成")
	Call InnerHtml("UpdateInfo","正在复制魔法表情数据")
	Dim Rs_1
	Set Rs_1 = Conn_T.Execute("select * From [Dv_Plus_Tools_MagicFace] Order by ID")
    Set Rs=Server.CreateObject("ADODB.RecordSet")
	Rs.Open "select * From [Dv_Plus_Tools_MagicFace] Order by ID", Conn, 1, 3
	If Rs.EOF Then
		Do While Not Rs_1.EOF
			Rs.AddNew()
			Rs("Title").Value = Rs_1("Title").Value
			Rs("MagicFace_s").Value = Rs_1("MagicFace_s").Value
			Rs("MagicFace_l").Value = Rs_1("MagicFace_l").Value
			Rs("MagicType").Value = Rs_1("MagicType").Value
			Rs("iMoney").Value = Rs_1("iMoney").Value
			Rs("iTicket").Value = Rs_1("iTicket").Value
			Rs("tMoney").Value = Rs_1("tMoney").Value
			Rs("tTicket").Value = Rs_1("tTicket").Value
			Rs("MagicSetting").Value = Rs_1("MagicSetting").Value
			Rs.Update()
			Rs_1.MoveNext()
		Loop
		Call InnerHtml("UpdateInfo","复制魔法表情数据成功．")
	Else
		Call InnerHtml("UpdateInfo","复制魔法表情数据取消，原因表中已经有记录．")
	End If
	Rs.Close()
	Rs_1.Close()

	If Checktable("Dv_Plus_Tools_Info", False) Then
		Call InnerHtml("UpdateInfo","正在复制道具数据")
		Set Rs_1 = Conn_T.Execute("select * From [Dv_Plus_Tools_Info] Order by ID")
		Set Rs=Server.CreateObject("ADODB.RecordSet")
		Rs.Open "select * From [Dv_Plus_Tools_Info] Order by ID", Conn, 1, 3
		If Rs.EOF Then
			Do While Not Rs_1.EOF
				Rs.AddNew()
				Rs("ToolsName").Value = Rs_1("ToolsName").Value
				Rs("ToolsInfo").Value = Rs_1("ToolsInfo").Value
				Rs("ToolsImg").Value = Rs_1("ToolsImg").Value
				Rs("IsStar").Value = Rs_1("IsStar").Value
				Rs("SysStock").Value = Rs_1("SysStock").Value
				Rs("UserStock").Value = Rs_1("UserStock").Value
				Rs("UserTicket").Value = Rs_1("UserTicket").Value
				Rs("UserMoney").Value = Rs_1("UserMoney").Value
				Rs("UserPost").Value = Rs_1("UserPost").Value
				Rs("UserWealth").Value = Rs_1("UserWealth").Value
				Rs("UserEp").Value = Rs_1("UserEp").Value
				Rs("UserCp").Value = Rs_1("UserCp").Value
				Rs("UserGroupID").Value = Rs_1("UserGroupID").Value
				Rs("BoardID").Value = Rs_1("BoardID").Value
				Rs("BuyType").Value = Rs_1("BuyType").Value
				Rs("ToolsSetting").Value = Rs_1("ToolsSetting").Value
				Rs.Update()
			Rs_1.MoveNext()
			Loop
			Call InnerHtml("UpdateInfo","复制道具数据成功．")
		Else
			Call InnerHtml("UpdateInfo","复制道具数据取消，原因表中已经有记录．")
		End If
		Rs.Close()
		Rs_1.Close()
	Else
		Call InnerHtml("UpdateInfo","由于道具表创建失败，复制道具数据失败．")
	End If
	Call InnerHtml("UpdateInfo","道具数据复制完毕")
	Conn.Execute("Update Dv_Plus_Tools_Info Set Boardid='" & Forum_Boards & "'")
	'更新默认数据
	Call InnerHtml("UpdateInfo","正在更新设置表[Dv_setup]数据")
	Dim Old_Setting,New_Setting,UP_Setting
	Old_Setting = Split(Conn.execute("SELECT Forum_setting From Dv_setup")(0),"|||")
	New_Setting = Split(Conn_T.Execute("SELECT Forum_setting From Dv_setup")(0),"|||")
	If Ubound(Old_Setting)=5 Then
		UP_Setting = Old_Setting(0) & "|||" & New_Setting(1) & "|||" & Old_Setting(2) & "|||" & Old_Setting(3) & "|||" & Old_Setting(4) & "|||" & Old_Setting(5)
	Else
		UP_Setting = New_Setting(0) & "|||" & New_Setting(1) & "|||" & New_Setting(2) & "|||" & New_Setting(3) & "|||" & New_Setting(4) & "|||" & New_Setting(5)
	End If
	If Err.Number <> 0 Then
		Call InnerHtml("UpdateInfo","设置表[Dv_setup]数据更新出错,原因:" & Err.Description)
		Err.Clear()
	End If
	'1,1,0,0,pay@aspsky.net,0,b63uvb8nsvsmbsaxszgvdr6svyus0l4t,1,1,1,1,1,1,1,100,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
	Conn.Execute("Update Dv_setup Set Forum_Sid=0,Forum_version='7.1.0',Forum_AdminFolder='admin/',Forum_ChanSetting='1,1,0,0,pay@aspsky.net,0,b63uvb8nsvsmbsaxszgvdr6svyus0l4t,1,1,1,1,1,1,1,100,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1',Forum_Boards='"&Forum_Boards&"',Forum_BoardXML='<accesspost />',Forum_setting='"&Replace(UP_Setting,"'","''")&"'")
	UP_Setting = ""
	Call InnerHtml("UpdateInfo","设置表[Dv_setup]数据更新完毕")
	Set Rs_1 = Conn_T.Execute("SELECT H_content From Dv_help where H_id=1")
	Conn.Execute("update Dv_help Set H_content='" & Rs_1(0).Value & "' where H_id=1")
	Rs_1.Close
	Conn.Execute("update Dv_user Set UserHidden=0")
	Call InnerHtml("UpdateInfo","<b>更新默认数据完成．</b>")
End Sub

'更新模板结构及数据
Sub UpdateStyle()
	On Error Resume Next
	Dim CreatStr,Rs_1,k,Rs,TempCssStyle
	Call InnerHtml("UpdateInfo","<b>正在更新模板数据</b>")
	Set Rs=Server.CreateObject("ADODB.RecordSet")
	Set Rs_1 = Conn_T.Execute("select top 1 * from [Dv_Style]")
	Rs.Open "select * From Dv_Style", Conn, 1, 3
	If Err.Number <> 0 Then
		Call InnerHtml("UpdateInfo","模板数据更新出错,原因:" & Err.Description)
		Err.Clear()
		Exit Sub
	End If
	Rs.AddNew()
	For k = 1 To Rs.Fields.Count - 1
		Rs(k).Value = Rs_1(k).Value
	Next
	Rs.Update()
	Rs.MoveLast()
	Rs_1.Close()
	If Err.Number <> 0 Then
		Call InnerHtml("UpdateInfo","模板数据更新出错,原因:" & Err.Description)
		Err.Clear()
	Else
		Call InnerHtml("UpdateInfo","模板数据添加成功")
	End If
	Set Rs_1 = Conn_T.Execute("SELECT Forum_Css From Dv_setup")
	TempCssStyle = Replace(Rs_1(0).Value, "1|||", Rs(0).Value & "|||")
	Rs.Close()
	Conn.Execute("update Dv_setup Set Forum_Css='" & TempCssStyle & "'")
	Call InnerHtml("UpdateInfo","[Dv_setup]表模板[Forum_Css]数据更新成功")
	Call InnerHtml("UpdateInfo","<b>模板数据更新成功</b>")
End Sub

Function GetConnstr()
	Dim ConnStr
	If Request.Form("DataType") = "1" Then
		ConnStr = "Provider = Sqloledb; User ID = " & Request.Form("Data_SA") & "; Password = " & Request.Form("Data_Pass") & "; Initial Catalog = " & Request.Form("Data_Name") & "; Data Source = " & Request.Form("Data_Source") & ";"
		DateTime = "getdate()"
		IsSql = 1
	Else
		ConnStr = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source = " & Server.MapPath(Request.Form("Data_Path"))
		DateTime = "now()"
		IsSql = 0
	End If
	GetConnstr = ConnStr
End Function

Sub CreateNewTable(ByVal TableName)
	'建立新表
	On Error Resume Next
	Dim SQL
	Select Case TableName
		Case "[Dv_Plus_Tools_Buss]"
			If IsSql = 1 Then
				SQL = "CREATE TABLE [Dv_Plus_Tools_Buss] ([ID] int IDENTITY (1, 1) NOT NULL CONSTRAINT PK_Dv_Plus_Tools_Buss PRIMARY KEY," 
			Else
				SQL = "CREATE TABLE [Dv_Plus_Tools_Buss] ([ID] int IDENTITY (1, 1) NOT NULL CONSTRAINT PrimaryKey PRIMARY KEY,"
			End If
			SQL = SQL &_
				"[UserID] int NOT NULL ," & _
				"[UserName] varchar (50) NOT NULL ," & _
				"[ToolsID] int NOT NULL ," & _
				"[ToolsName] varchar (50) NOT NULL ," & _
				"[ToolsCount] int NOT NULL default 0," & _
				"[SaleCount] int NOT NULL default 0," & _
				"[UpdateTime] smalldatetime default " & DateTime & "," & _
				"[SaleMoney] int NOT NULL default 0," & _
				"[SaleTicket] int NOT NULL default 0" & _
				")"
		Case "[Dv_UserGroups]"
			If IsSql = 1 Then
				SQL = "CREATE TABLE [Dv_UserGroups] ([UserGroupID] int IDENTITY (1, 1) NOT NULL CONSTRAINT PK_Dv_UserGroups PRIMARY KEY," 
			Else
				SQL = "CREATE TABLE [Dv_UserGroups] ([UserGroupID] int IDENTITY (1, 1) NOT NULL CONSTRAINT PrimaryKey PRIMARY KEY,"
			End If
			SQL = SQL &_
					"[title] varchar(50) NULL ," & _
					"[usertitle] varchar(50) NULL," & _
					"[GroupSetting] text NULL," & _
					"[Orders] smallint NULL," & _
					"[MinArticle] int NULL," & _
					"[TitlePic] varchar(50) NULL," & _
					"[GroupPic] varchar(50) NULL," & _
					"[ParentGID] int NULL," & _
					"[IsSetting] varchar(50) NULL" & _
					")"
		Case "[Dv_Plus_Tools_Info]"
			If IsSql = 1 Then
				SQL = "CREATE TABLE [Dv_Plus_Tools_Info] ([ID] int IDENTITY (1, 1) NOT NULL CONSTRAINT PK_Dv_Plus_Tools_Info PRIMARY KEY," 
			Else
				SQL = "CREATE TABLE [Dv_Plus_Tools_Info] ([ID] int IDENTITY (1, 1) NOT NULL CONSTRAINT PrimaryKey PRIMARY KEY,"
			End If
			SQL = SQL &_
				"[ToolsName] varchar (50) NULL ," & _
				"[ToolsInfo] varchar (255) NULL ," & _
				"[ToolsImg] varchar (150) NULL ," & _
				"[IsStar] smallint NOT NULL default 1," & _
				"[SysStock] int NOT NULL default 0," & _
				"[UserStock] int NOT NULL default 0," & _
				"[UserTicket] int NOT NULL default 0," & _
				"[UserMoney] int NOT NULL default 0," & _
				"[UserPost] int NOT NULL default 0," & _
				"[UserWealth] int NOT NULL default 0," & _
				"[UserEp] int NOT NULL default 0," & _
				"[UserCp] int NOT NULL default 0," & _
				"[UserGroupID] varchar (255) NULL ," & _
				"[BoardID] text NULL ," & _
				"[BuyType] tinyint NOT NULL default 0," & _
				"[ToolsSetting] text " & _
				")"
		Case "[Dv_Plus_Tools_MagicFace]"
			If IsSql = 1 Then
				SQL = "CREATE TABLE [Dv_Plus_Tools_MagicFace] ([ID] int IDENTITY (1, 1) NOT NULL CONSTRAINT PK_Dv_Plus_Tools_MagicFace PRIMARY KEY,"
			Else
				SQL = "CREATE TABLE [Dv_Plus_Tools_MagicFace] ([ID] int IDENTITY (1, 1) NOT NULL CONSTRAINT PrimaryKey PRIMARY KEY,"
			End If
			SQL = SQL &_
				"[Title] varchar (50) NULL ," & _
				"[MagicFace_s] int NULL ," & _
				"[MagicFace_l] int NULL ," & _
				"[MagicType] smallint  NULL ," & _
				"[iMoney] int  NULL ," & _
				"[iTicket] int  NULL," & _
				"[tMoney] int  NULL ," & _
				"[tTicket] int NULL ," & _
				"[MagicSetting] varchar (255) NULL " & _
				")"
		Case "[Dv_MoneyLog]"
			If IsSql = 1 Then
				SQL = "CREATE TABLE [Dv_MoneyLog] ([Log_ID] int IDENTITY (1, 1) NOT NULL CONSTRAINT PK_Dv_MoneyLog PRIMARY KEY,"
			Else
				SQL = "CREATE TABLE [Dv_MoneyLog] ([Log_ID] int IDENTITY (1, 1) NOT NULL CONSTRAINT PrimaryKey PRIMARY KEY,"
			End If
			SQL = SQL &_
				"[ToolsID] int NOT NULL default 0," & _
				"[CountNum] int NOT NULL default 0," & _
				"[Log_Money] int NULL default 0," & _
				"[Log_Ticket] int NULL default 0," & _
				"[AddUserName] varchar (50) NULL ," & _
				"[AddUserID] int NULL default 0," & _
				"[Log_IP] varchar (40) NULL ," & _
				"[Log_Time] smalldatetime NOT NULL default " & DateTime & "," & _
				"[Log_Type] tinyint NULL default 0," & _
				"[BoardID] int NULL default 0," & _
				"[Conect] text NULL ," & _
				"[HMoney] varchar (250) NULL " & _
				")"
		Case "[Dv_Boke_KeyWord]"
			If IsSql = 1 Then
				SQL = "CREATE TABLE [Dv_Boke_KeyWord] ([KeyID] int IDENTITY (1, 1) NOT NULL CONSTRAINT PK_Dv_Boke_KeyWord PRIMARY KEY,"
			Else
				SQL = "CREATE TABLE [Dv_Boke_KeyWord] ([KeyID] int IDENTITY (1, 1) NOT NULL CONSTRAINT PrimaryKey PRIMARY KEY,"
			End If
			SQL = SQL &_
				"[UserID] int NOT NULL default 0," & _
				"[KeyWord] varchar (50) NULL ," & _
				"[nKeyWord] varchar (50) NULL ," & _
				"[LinkUrl] varchar (250) NULL ," & _
				"[LinkTitle] varchar (50) NULL ," & _
				"[NewWindows] tinyint NULL default 0" & _
				")"
		Case "[Dv_Boke_Post]"
			If IsSql = 1 Then
				SQL = "CREATE TABLE [Dv_Boke_Post] ([PostID] int IDENTITY (1, 1) NOT NULL CONSTRAINT PK_Dv_Boke_Post PRIMARY KEY,"
			Else
				SQL = "CREATE TABLE [Dv_Boke_Post] ([PostID] int IDENTITY (1, 1) NOT NULL CONSTRAINT PrimaryKey PRIMARY KEY,"
			End If
			SQL = SQL &_
				"[BokeUserID] int NOT NULL default 0," & _
				"[CatID] int NOT NULL default 0," & _
				"[sCatID] int NOT NULL default 0," & _
				"[ParentID] int NOT NULL default 0," & _
				"[RootID] int NOT NULL default 0," & _
				"[UserID] int NOT NULL default 0," & _
				"[UserName] varchar (50) NULL ," & _
				"[Title] varchar (250) NULL ," & _
				"[Content] text NULL ," & _
				"[JoinTime] smalldatetime NOT NULL default " & DateTime & "," & _
				"[IP] varchar (40) NULL ," & _
				"[sType] tinyint NULL default 0," & _
				"[IsUpfile] tinyint NULL default 0," & _
				"[IsLock] tinyint NULL default 0" & _
				")"
		Case "[Dv_Boke_Skins]"
			If IsSql = 1 Then
				SQL = "CREATE TABLE [Dv_Boke_Skins] ([S_ID] int IDENTITY (1, 1) NOT NULL CONSTRAINT PK_Dv_Boke_Skins PRIMARY KEY,"
			Else
				SQL = "CREATE TABLE [Dv_Boke_Skins] ([S_ID] int IDENTITY (1, 1) NOT NULL CONSTRAINT PrimaryKey PRIMARY KEY,"
			End If
			SQL = SQL &_
				"[S_SkinName] varchar (50) NULL ," & _
				"[S_Path] varchar (150) NULL ," & _
				"[S_ViewPic] varchar (50) NULL ," & _
				"[S_Info] varchar (250) NULL ," & _
				"[S_Builder] varchar (250) NULL " & _
				")"
		Case "[Dv_Boke_SysCat]"
			If IsSql = 1 Then
				SQL = "CREATE TABLE [Dv_Boke_SysCat] ([sCatID] int IDENTITY (1, 1) NOT NULL CONSTRAINT PK_Dv_Boke_SysCat PRIMARY KEY,"
			Else
				SQL = "CREATE TABLE [Dv_Boke_SysCat] ([sCatID] int IDENTITY (1, 1) NOT NULL CONSTRAINT PrimaryKey PRIMARY KEY,"
			End If
			SQL = SQL &_
				"[sCatTitle] varchar (20) NULL ," & _
				"[sCatNote] text NULL ," & _
				"[uCatNum] int NOT NULL default 0," & _
				"[TopicNum] int NOT NULL default 0," & _
				"[PostNum] int NOT NULL default 0," & _
				"[TodayNum] int NOT NULL default 0," & _
				"[sType] tinyint NOT NULL default 0," & _
				"[LastUpTime] smalldatetime NOT NULL default " & DateTime & "" & _
				")"
		Case "[Dv_Boke_System]"
			If IsSql = 1 Then
				SQL = "CREATE TABLE [Dv_Boke_System] ([S_id] int IDENTITY (1, 1) NOT NULL CONSTRAINT PK_Dv_Boke_System PRIMARY KEY,"
			Else
				SQL = "CREATE TABLE [Dv_Boke_System] ([S_id] int IDENTITY (1, 1) NOT NULL CONSTRAINT PrimaryKey PRIMARY KEY,"
			End If
			SQL = SQL &_
				"[S_Name] varchar (50) NULL ," & _
				"[S_Note] text NULL ," & _
				"[S_LastPostTime] smalldatetime NOT NULL default " & DateTime & "," & _
				"[S_TopicNum] int NOT NULL default 0," & _
				"[S_PhotoNum] int NOT NULL default 0," & _
				"[S_FavNum] int NOT NULL default 0," & _
				"[S_UserNum] int NOT NULL default 0," & _
				"[S_TodayNum] int NOT NULL default 0," & _
				"[S_PostNum] int NOT NULL default 0," & _
				"[S_Setting] text NULL ," & _
				"[S_Url] varchar (250) NULL ," & _
				"[S_sDomain] varchar (50) NULL ," & _
				"[SkinID] int NOT NULL default 0" & _
				")"
		Case "[Dv_Boke_Topic]"
			If IsSql = 1 Then
				SQL = "CREATE TABLE [Dv_Boke_Topic] ([TopicID] int IDENTITY (1, 1) NOT NULL CONSTRAINT PK_Dv_Boke_Topic PRIMARY KEY,"
			Else
				SQL = "CREATE TABLE [Dv_Boke_Topic] ([TopicID] int IDENTITY (1, 1) NOT NULL CONSTRAINT PrimaryKey PRIMARY KEY,"
			End If
			SQL = SQL &_
				"[CatID] int NOT NULL default 0," & _
				"[sCatID] int NOT NULL default 0," & _
				"[UserID] int NOT NULL default 0," & _
				"[UserName] varchar (50) NULL ," & _
				"[Title] varchar (250) NULL ," & _
				"[TitleNote] varchar (250) NULL ," & _
				"[PostTime] smalldatetime NOT NULL default " & DateTime & "," & _
				"[Child] int NOT NULL default 0," & _
				"[Hits] int NOT NULL default 0," & _
				"[IsView] tinyint NULL default 0," & _
				"[IsLock] tinyint NULL default 0," & _
				"[sType] tinyint NULL default 0," & _
				"[LastPostTime] smalldatetime NOT NULL default " & DateTime & "," & _
				"[IsBest] tinyint NULL default 0," & _
				"[S_Key] varchar (250) NULL ," & _
				"[Weather] smallint NULL default 0," & _
				"[VisitUser] text NULL ," & _
				"[PayMoney] money NULL default 0," & _
				"[PayNumber] smallint NULL default 0," & _
				"[PayTime] smallint NULL default 0," & _
				"[TrackBacks] int NULL default 0" & _
				")"
		Case "[Dv_Boke_Upfile]"
			If IsSql = 1 Then
				SQL = "CREATE TABLE [Dv_Boke_Upfile] ([ID] int IDENTITY (1, 1) NOT NULL CONSTRAINT PK_Dv_Boke_Upfile PRIMARY KEY,"
			Else
				SQL = "CREATE TABLE [Dv_Boke_Upfile] ([ID] int IDENTITY (1, 1) NOT NULL CONSTRAINT PrimaryKey PRIMARY KEY,"
			End If
			SQL = SQL &_
				"[BokeUserID] int NOT NULL default 0," & _
				"[UserID] int NOT NULL default 0," & _
				"[UserName] varchar (50) NULL ," & _
				"[CatID] int NOT NULL default 0," & _
				"[sType] int NOT NULL default 0," & _
				"[TopicID] int NOT NULL default 0," & _
				"[PostID] int NOT NULL default 0," & _
				"[IsTopic] tinyint NOT NULL default 0," & _
				"[Title] varchar (250) NULL ," & _
				"[FileName] varchar (100) NULL ," & _
				"[sFileName] varchar (100) NULL ," & _
				"[FileType] int NOT NULL default 0," & _
				"[FileSize] int NOT NULL default 0," & _
				"[FileNote] varchar (250) NULL ," & _
				"[DownNum] int NOT NULL default 0," & _
				"[ViewNum] int NOT NULL default 0," & _
				"[DateAndTime] smalldatetime NOT NULL default " & DateTime & "," & _
				"[PreviewImage] varchar (250) NULL ," & _
				"[IsLock] tinyint NULL default 0" & _
				")"
		Case "[Dv_Boke_User]"
			If IsSql = 1 Then
				SQL = "CREATE TABLE [Dv_Boke_User] ("
			Else
				SQL = "CREATE TABLE [Dv_Boke_User] ("
			End If
			SQL = SQL &_
				"[UserID] int NOT NULL default 0," & _
				"[UserName] varchar (50) NULL ," & _
				"[NickName] varchar (50) NULL ," & _
				"[BokeName] varchar (50) NULL ," & _
				"[PassWord] varchar (40) NULL ," & _
				"[BokeTitle] varchar (150) NULL ," & _
				"[BokeChildTitle] varchar (150) NULL ," & _
				"[BokeNote] text NULL ," & _
				"[JoinBokeTime] smalldatetime NOT NULL default " & DateTime & "," & _
				"[PageView] int NOT NULL default 0," & _
				"[TopicNum] int NOT NULL default 0," & _
				"[FavNum] int NOT NULL default 0," & _
				"[PhotoNum] int NOT NULL default 0," & _
				"[PostNum] int NOT NULL default 0," & _
				"[TodayNum] int NOT NULL default 0," & _
				"[Trackbacks] int NOT NULL default 0," & _
				"[SpaceSize] float NOT NULL default 0," & _
				"[XmlData] text NULL ," & _
				"[SysCatID] int NOT NULL default 0," & _
				"[BokeSetting] text NULL ," & _
				"[LastUpTime] smalldatetime NOT NULL default " & DateTime & "," & _
				"[SkinID] int NOT NULL default 0," & _
				"[Stats] int NOT NULL default 0" & _
				")"
		Case "[Dv_Boke_UserCat]"
			If IsSql = 1 Then
				SQL = "CREATE TABLE [Dv_Boke_UserCat] ([uCatID] int IDENTITY (1, 1) NOT NULL CONSTRAINT PK_Dv_Boke_UserCat PRIMARY KEY,"
			Else
				SQL = "CREATE TABLE [Dv_Boke_UserCat] ([uCatID] int IDENTITY (1, 1) NOT NULL CONSTRAINT PrimaryKey PRIMARY KEY,"
			End If
			SQL = SQL &_
				"[UserID] int NOT NULL default 0," & _
				"[uCatTitle] varchar (20) NULL ," & _
				"[uCatNote] text NULL ," & _
				"[OpenTime] smalldatetime NOT NULL default " & DateTime & "," & _
				"[uType] tinyint NOT NULL default 0," & _
				"[TopicNum] int NOT NULL default 0," & _
				"[PostNum] int NOT NULL default 0," & _
				"[TodayNum] int NOT NULL default 0," & _
				"[IsView] tinyint NULL default 0," & _
				"[LastUpTime] smalldatetime NOT NULL default " & DateTime & "" & _
				")"
		Case "[Dv_Boke_UserSave]"
			If IsSql = 1 Then
				SQL = "CREATE TABLE [Dv_Boke_UserSave] ("
			Else
				SQL = "CREATE TABLE [Dv_Boke_UserSave] ("
			End If
			SQL = SQL &_
				"[UserID] int NOT NULL default 0," & _
				"[SaveDate] int NOT NULL default 0," & _
				"[SaveNum] int NOT NULL default 0" & _
				")"
		Case "[Dv_Style]"
			Dim CreatStr
			Dim Rs_1,k
			If IsSql = 1 Then
				SQL = "CREATE TABLE [Dv_Style] ([ID] int IDENTITY (1, 1) NOT NULL CONSTRAINT PK_Dv_Style PRIMARY KEY , " & _
							"[StyleName] varchar(50) NOT NULL , "
			Else
				SQL = "CREATE TABLE [Dv_Style] ([ID] int IDENTITY (1, 1) NOT NULL CONSTRAINT PrimaryKey PRIMARY KEY , " & _
							"[StyleName] varchar(50) NOT NULL , "
			End If
			Set Rs_1 = Conn_T.Execute("select * From [Dv_Style]")
			If Not Rs_1.EOF Then
				For k = 2 To Rs_1.Fields.Count - 1
					SQL = SQL & ("[" & Rs_1(k).Name & "]" & _
										" text not Null default '|||@@@|||@@@|||@@@|||'")
					If k <> Rs_1.Fields.Count - 1 Then
						SQL = SQL & ","
					End If
				Next
				SQL = SQL & ")"
			Else
				Call InnerHtml("UpdateInfo","更新库中风格表数据不存在")
			End If
			Rs_1.Close()
			Set Rs_1 = Nothing
	End Select
	Conn.Execute(SQL)
	If Err.Number <> 0 Then
		Call InnerHtml("UpdateInfo","新建 " & TableName & " 表错误，原因" & Err.Description & "操作,跳过.")
		Err.Clear()
	Else
		Call InnerHtml("UpdateInfo","新建 " & TableName & " 表成功。")
	End If
End Sub


Sub RemoveAllCache()
	Dim cachelist,i
	Call InnerHtml("UpdateInfo","<b>开始执行清理当前站点缓存</b>：")
	Cachelist=split(GetallCache(),",")
	If UBound(cachelist)>1 Then
		For i=0 to UBound(cachelist)-1
			DelCahe Cachelist(i)
			Call InnerHtml("UpdateInfo","更新 <b>"&cachelist(i)&"</b> 完成")
		Next
		Call InnerHtml("UpdateInfo","更新了"& UBound(cachelist)-1 &"个缓存对象<br>")
	Else
		Call InnerHtml("UpdateInfo","<b>当前站点全部缓存清理完成。</b>。")
	End If
End Sub

Function  GetallCache()
	Dim Cacheobj
	For Each Cacheobj in Application.Contents
		GetallCache = GetallCache & Cacheobj & ","
	Next
End Function

Sub DelCahe(MyCaheName)
	Application.Lock
	Application.Contents.Remove(MyCaheName)
	Application.unLock
End Sub

Sub CompressData()
	Call InnerHtml("UpdateInfo","<b>压缩数据库开始。</b>")
	If Not IsObject(Conn) Then
		CheckData Conn,GetConnstr
	End If
	Set Conn = Nothing
	Dim DBPath
	DBPath = Server.MapPath(Request.Form("Data_Path"))
	Dim BoolIs97
	BoolIs97 = Request.Form("boolIs97")
	CompactDB DBPath,boolIs97
End Sub

'=====================压缩参数=========================
Sub CompactDB(DBPath, boolIs97)
	On Error Resume Next
	Dim Fso, Engine, strDBPath,JET_3X
	strDBPath = Left(DBPath,InstrRev(DBPath,"\"))
	Set Fso = CreateObject("Scripting.FileSystemObject")
	If Err.Number <> 0 Then
		Err.Clear()
		Call InnerHtml("UpdateInfo","<b>出错原因" & Err.Description & "，当前站点可能不支持FSO组件，压缩操作跳过。</b>")
		Exit Sub
	End If
	If Fso.FileExists(DBPath) Then
			Fso.CopyFile DBPath,strDBPath & "CompactDBTemp.mdb"
			Set Engine = CreateObject("JRO.JetEngine")
			If BoolIs97 = "True" Then
				Engine.CompactDatabase "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDBPath & "CompactDBTemp.mdb", _
				"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDBPath & "CompactDBTemp1.mdb;" _
				& "Jet OLEDB:Engine Type=" & JET_3X
			Else
				Engine.CompactDatabase "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDBPath & "CompactDBTemp.mdb", _
				"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDBPath & "CompactDBTemp1.mdb"
			End If
		Fso.CopyFile strDBPath & "CompactDBTemp1.mdb",DBPath
		Fso.DeleteFile(strDBPath & "CompactDBTemp.mdb")
		Fso.DeleteFile(strDBPath & "CompactDBTemp1.mdb")
		Set Fso = nothing
		Set Engine = nothing
		If Err.Number <> 0 Then
			Err.Clear()
			Call InnerHtml("UpdateInfo","<b>出错原因" & Err.Description & "操作,压缩操作跳过。</b>")
			Exit Sub
		End If
		Call InnerHtml("UpdateInfo","你的数据库, " & Replace(DBPath,"\","\\") & ", 已经压缩成功!")
	Else
		Call InnerHtml("UpdateInfo","数据库名称或路径不正确. 请重试!")
	End If
End Sub

Sub BackData()
	If Not IsObject(Conn) Then
		CheckData Conn,GetConnstr
	End If
	Dim DBPath
	Dim BackDBPath,Fso
	BackDBPath = "BackupData/"
	DBPath = Server.MapPath(Request.Form("Data_Path"))
	BackDBPath = BackDBPath & year(now) & "_" & month(now) & "_" & day(now) & "_" &  hour(now)  & "_" &  minute(now) &".mdb"
	BackDBPath = Server.MapPath(BackDBPath)
	On Error Resume Next
	Set Fso = Server.createobject("scripting.filesystemobject")
	If Err.Number <> 0 Then
		Err.Clear()
		Call InnerHtml("UpdateInfo","<b>出错原因" & Err.Description & "，当前站点可能不支持FSO组件，备份操作跳过。</b>")
		Exit Sub
	End If
	If Fso.Fileexists(DBPath) then
		Fso.Copyfile DBPath,BackDBPath
		Call InnerHtml("UpdateInfo","备份数据库成功，您备份的数据库路径为:" & Replace(BackDBPath,"\","\\"))
	Else
		Call InnerHtml("UpdateInfo","找不到您所需要备份的文件。")
	End if
	If Err.Number <> 0 Then
		Err.Clear()
		Call InnerHtml("UpdateInfo","<b>出错原因" & Err.Description & "操作,备份操作跳过。</b>")
		Exit Sub
	End If
	Set Fso = Nothing
End Sub

Sub SaveLog()
	Dim XmlDom
	Dim FilePath
	FilePath = "data/UpdateReport.xml"
	FilePath = Server.MapPath(FilePath)
	Dim node,attributes,createCDATASection,ChildNode
	Set XmlDom = Server.CreateObject("MSXML.DOMDocument")
'添加记录
	If Not XmlDom.load(FilePath) Then
		XmlDom.loadxml "<?xml version=""1.0"" encoding=""gb2312""?><UpdateLog/>"
	End If
	Set node=XmlDom.createNode(1,"UpdateReport","")
	Set attributes=XmlDom.createAttribute("AddTime")
	attributes.text = Now()
	node.attributes.setNamedItem(attributes)
	Set ChildNode = XmlDom.createNode(1,"ReportInfo","")
	Set createCDATASection=XmlDom.createCDATASection(replace(Replace(ReportTxt,"\\","\"),"]]>","]]&gt;"))
	ChildNode.appendChild(createCDATASection)
	node.appendChild(ChildNode)
	XmlDom.documentElement.appendChild(node)
	XmlDom.save FilePath
	Set XmlDom = Nothing
End Sub
%>