<!--#include file="conn.asp"-->
<%
	'FSO组件的名称
	Private Const oFSO = "Scripting.FileSystemObject"
	'升级步骤总和（常量值+1）
	Private Const iTables = 18

	Private Const C_Items = 84
%>
<%
	Server.ScriptTimeOut=999999999

	Dim iStep,rs,go
	iStep=Request("step")
	go=Request("go")

	On Error Resume Next
	Dim strSql,strErrMsg
	Dim FoundErr
	Dim iNum
	FoundErr = False

	Call init()

	If iStep=2 Then
		Call BackDataBase()
	ElseIf iStep=1 Then
		Call doUpdate()
	End If

	If go <>"" Then
		Select Case go
			Case 0
				Call DoUpdateTeam()
			Case 1
				Call DoUpdateTeamPost()
			Case 2
				Call DoUpdateUpfile()
			Case 3
				Call CreateAlbum()
			Case 4
				Call CreateAlbumComment()
			Case 5
				Call CreateDigg()
			Case 6
				Call CreateUserDigg()
			Case 7
				Call CreateTeamSkin()
			Case 8
				Call InsertAblum()
			Case 9
				Call DoUpdateGroups()
			Case 10
				Call DoUpdateLog()
			Case 11
				Call DoUpdateRoles()
			Case 12
				Call DoUpdateSetup()
			Case 13
				Call DoUpdateSubject()
			Case 14
				Call DoUpdateSyslog()
			Case 15
				Call DoUpdateUser()
			Case 16
				Call DoUpdateConfig()
			Case 17
				Call ClearOldOBCodes()
			Case 18
				Call DoUpdateScore()
			Case Else

		End Select
	End If

	If go <>"" Then

		Call  CheckErr()

		If Not FoundErr Then
			Response.Write "<script>document.getElementById('info').innerHTML ='<font color=green>升级成功</font>'</script>"
		End If

		Response.Write "<script>document.getElementById('submit').innerHTML ='<input type=""button"" id =""go"" value=""点击返回 <<"" onClick=""window.history.back()"">'</script>"

	End if

	Private Sub ShowMain()
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Language" content="zh-CN" />
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<meta name="generator" content="OBLOG" />
<meta name="author" content="OBLOG" />
<meta name="keyword" content="OBLOG" />
<meta name="description" content="OBLOG" />
<title>Oblog 4.02 To Oblog 4.5 数据库升级程序</title>
<link href="admin/images/admin/style.css" rel="stylesheet" type="text/css" />
<style type="text/css" media="screen">
<!--
#Container { margin: 20px auto; width: 650px; background: #fff; border: 1px #444 solid; text-align: left; }
	#title { height: 21px; padding: 4px 0 0 6px; background: #777; border: 1px #ddd solid;border-bottom: 1px #444 solid; font-size: 14px; font-weight: 600; color: #fff; }
	#lasttme { margin: 10px; padding: 0 0 10px 6px; border-bottom: 1px #ddd solid; }
		#lasttme span { color: #f00; }
	#info { margin: 0 10px; padding: 10px; height: 350px; background: #ffd; overflow-y: auto; }

	#submit { margin: 10px; padding: 10px 0 0 6px; border-top: 1px #ddd solid; }
		#submit input { height: 35px;  }
.u1 {  }
	.u1 .l1 { list-style: disc inside none; font-size: 10px; font-family:verdana,tahoma,Arial black,Arial,Helvetica,sans-serif; }
	.u1 .l2 { list-style: none inside none; color: #f00; }
.u2 {  }
	.u2 .l1 { list-style: disc inside none; font-size: 10px; font-family:verdana,tahoma,Arial black,Arial,Helvetica,sans-serif; }
	.u2 .l2 { list-style: none inside none; color: #f00; }
	.u2 .l3 { list-style: none inside none; }
ul#show {}
	ul#show li { margin: 10px 0 5px 0; }
		ul#show li input { height: 24px; border: 1px #eee solid; background: #fff; text-align: left; }
-->
</style>
</head>
<body>
<div id="Container">
	<div id="title">Oblog 4.02 To Oblog 4.5 数据库升级程序</div>
	<div id="lasttme">
		<div>最后更新：<span>2007年05月23日 22：00</span></div>
		<div>当前版本：<span><!--#include file="ver.asp"--></span></div>
	</div>
	<div id="info">
		升级步骤
		<ul>
			<li>方法一：直接点击下面的"备份数据库并开始升级"按钮进行一次性升级</li>
			<li>方法二：点击<a href="javascript:void(null);" onclick="document.getElementById('show').style.display='';" style="padding: 3px; border: 1px #eee solid; background: #fff; font-weight: 600; ">此处</a>进行分步升级</li>
			<li><b>* 注意：如果一次性升级出错，则可以点击分步升级只升级出错的表</b></li>
		</ul>
		<ul id="show" style="display:none;">
			<li><input type="button" id ="go0" value="更新oblog_team表 >>" onClick="document.getElementById('go0').disabled=true;window.location.href='?go=0'"></li>
			<li><input type="button" id ="go1" value="更新oblog_teampost表 >>" onClick="document.getElementById('go1').disabled=true;window.location.href='?go=1'"></li>
			<li><input type="button" id ="go2" value="更新oblog_upfile表 >>" onClick="document.getElementById('go2').disabled=true;window.location.href='?go=2'"></li>
			<li><input type="button" id ="go3" value="创建oblog_Album表 >>" onClick="document.getElementById('go3').disabled=true;window.location.href='?go=3'"></li>
			<li><input type="button" id ="go4" value="创建oblog_AlbumComment表 >>" onClick="document.getElementById('go4').disabled=true;window.location.href='?go=4'"></li>
			<li><input type="button" id ="go5" value="创建oblog_digg表 >>" onClick="document.getElementById('go5').disabled=true;window.location.href='?go=5'"></li>
			<li><input type="button" id ="go6" value="创建oblog_userdigg表 >>" onClick="document.getElementById('go6').disabled=true;window.location.href='?go=6'"></li>
			<li><input type="button" id ="go7" value="创建oblog_teamskin表 >>" onClick="document.getElementById('go7').disabled=true;window.location.href='?go=7'"></li>
			<li><input type="button" id ="go8" value="更新oblog_Album表 >>" onClick="document.getElementById('go8').disabled=true;window.location.href='?go=8'"></li>
			<li><input type="button" id ="go9" value="更新oblog_groups表 >>" onClick="document.getElementById('go9').disabled=true;window.location.href='?go=9'"></li>
			<li><input type="button" id ="go10" value="更新oblog_log表 >>" onClick="document.getElementById('go10').disabled=true;window.location.href='?go=10'"></li>
			<li><input type="button" id ="go11" value="更新oblog_roles表 >>" onClick="document.getElementById('go11').disabled=true;window.location.href='?go=11'"></li>
			<li><input type="button" id ="go12" value="更新oblog_setup表 >>" onClick="document.getElementById('go12').disabled=true;window.location.href='?go=12'"></li>
			<li><input type="button" id ="go13" value="更新oblog_subject表 >>" onClick="document.getElementById('go13').disabled=true;window.location.href='?go=13'"></li>
			<li><input type="button" id ="go14" value="更新oblog_syslog表 >>" onClick="document.getElementById('go14').disabled=true;window.location.href='?go=14'"></li>
			<li><input type="button" id ="go15" value="更新oblog_user表 >>" onClick="document.getElementById('go15').disabled=true;window.location.href='?go=15'"></li>
			<li><input type="button" id ="go16" value="更新oblog_config表 >>" onClick="document.getElementById('go16').disabled=true;window.location.href='?go=16'"></li>
			<li><input type="button" id ="go17" value="更新oblog_obcodes表 >>" onClick="document.getElementById('go17').disabled=true;window.location.href='?go=17'"></li>
		</ul>

	</div>
	<div id="submit"><input type="button" id ="go" value="备份数据库并开始升级 >>" onClick="document.getElementById('go').disabled=true;window.location.href='?step=2'"></div>
	<div class="clear"></div>
</div>
<div id="powered"><a href="http://www.oblog.cn" target="_blank"><img src="images/oblog_powered.gif" border="0" alt="Powered by Oblog." /></a></div>
</body>
</html>
<%
End Sub

Private Sub Init()
	Call ShowMain()
	Call Link_Database
	ReDim strErrMsg(iTables)
End Sub

Private Sub doUpdate()

	Call DoUpdateTeam()

	Call DoUpdateTeamPost()

	Call DoUpdateUpfile()

	Call CreateAlbum()

	Call CreateAlbumComment()

	Call CreateDigg()

	Call CreateUserDigg()

	Call CreateTeamSkin()

	Call InsertAblum()

	Call DoUpdateGroups()

	Call DoUpdateLog()

	Call DoUpdateRoles()

	Call DoUpdateSetup()

	Call DoUpdateSubject()

	Call DoUpdateSyslog()

	Call DoUpdateUser()

	Call DoUpdateConfig()

	Call ClearOldOBCodes()

	Call DoUpdateScore()

	Call  CheckErr()

	If Not FoundErr Then
		Response.Write "<script>document.getElementById('info').innerHTML ='<font color=green>升级成功</font>'</script>"
	End If

	Response.Write "<script>document.getElementById('go').disabled=false;</script>"

	Response.Write "<script>document.getElementById('submit').innerHTML ='<input type=""button"" id =""go"" value=""点击返回 <<"" onClick=""window.location.href=\'?step=0\'"">'</script>"

	Response.End

End Sub

Private Sub DoUpdateTeam()
	'-------------------------------------------------------------------------------------
		'更新oblog_team表
	'-------------------------------------------------------------------------------------
		iNum = 0

		Call Execute("ALTER TABLE oblog_team ADD t_domain NVARCHAR(255) NULL ",iNum)
		Call Execute("ALTER TABLE oblog_team ADD t_domainroot NVARCHAR(255) NULL ",iNum)
		Call Execute("ALTER TABLE oblog_team ADD viewpassword VARCHAR(50) NULL ",iNum)

		Call Execute("ALTER TABLE oblog_team ADD hideurl INT NULL DEFAULT 0",iNum)
		Call Execute("ALTER TABLE oblog_team ADD viewlimit INT NULL DEFAULT 0",iNum)

		Call Execute("ALTER TABLE oblog_team ADD user_skin_main NTEXT NULL ",iNum)
		Call Execute("ALTER TABLE oblog_team ADD user_skin_showlog NTEXT NULL ",iNum)
		Call Execute("ALTER TABLE oblog_team ADD bak_skin1 NTEXT NULL ",iNum)
		Call Execute("ALTER TABLE oblog_team ADD bak_skin2 NTEXT NULL ",iNum)

		Call Execute("ALTER TABLE oblog_team DROP COLUMN skin_main",iNum)
		Call Execute("ALTER TABLE oblog_team DROP COLUMN skin_list",iNum)

	'-------------------------------------------------------------------------------------
End Sub

Private Sub DoUpdateTeamPost()
	'-------------------------------------------------------------------------------------
		'更新oblog_teampost表
	'-------------------------------------------------------------------------------------
		iNum = 1

		Call Execute("ALTER TABLE oblog_teampost ALTER COLUMN ispass INT DEFAULT 0 ",iNum)

	'-------------------------------------------------------------------------------------
End Sub

Private Sub DoUpdateUpfile()
	'-------------------------------------------------------------------------------------
		'更新oblog_upfile表
	'-------------------------------------------------------------------------------------
		iNum = 2

		Call Execute("ALTER TABLE oblog_upfile ADD file_showname NVARCHAR(255) NULL ",iNum)

		Call Execute("ALTER TABLE oblog_upfile ADD filetype INT NULL DEFAULT 0",iNum)

	'-------------------------------------------------------------------------------------
End Sub

Private Sub CreateAlbum()
	'-------------------------------------------------------------------------------------
		'创建oblog_Album表
	'-------------------------------------------------------------------------------------
	iNum = 3

	strSql="Create Table oblog_Album("& _
		"photoID INT IDENTITY (1, 1) NOT NULL CONSTRAINT PK_oblog_Album PRIMARY KEY," & _
		"userID INT NULL DEFAULT 0 ," & _
		"photo_Name	NVARCHAR(255) NULL ," & _
		"photo_path	NVARCHAR(255) NULL ," & _
		"photo_size INT NULL DEFAULT 0 ," & _
		"photo_Title NVARCHAR(50) NULL ," & _
		"photo_Readme NVARCHAR(255) NULL ," & _
		"TeamID INT NULL DEFAULT 0 ," & _
		"isBigHead INT NULL DEFAULT 0 ," & _
		"isHide INT NULL DEFAULT 0 ," & _
		"sysClassId INT NULL DEFAULT 0 ," & _
		"userClassId INT NULL DEFAULT 0 ," & _
		"photo_width INT NULL DEFAULT 0 ," & _
		"photo_height INT NULL DEFAULT 0 ," & _
		"addtime  SMALLDATETIME NULL DEFAULT " &G_Sql_Now& "," & _
		"fileID int NULL DEFAULT 0 ," & _
		"commentnum int NULL DEFAULT 0 ," & _
		"isencomment int NULL DEFAULT 0 ," & _
		"views int NULL DEFAULT 0 )"

	'创建表
	Call Execute(strSql,iNum)

	'创建索引
	Call Execute("CREATE INDEX Index_Album_userID ON oblog_Album (userID)",iNum)
	Call Execute("CREATE INDEX Index_Album_TeamID ON oblog_Album (TeamID)",iNum)
	Call Execute("CREATE INDEX Index_Album_sysClassId ON oblog_Album (sysClassId)",iNum)
	Call Execute("CREATE INDEX Index_Album_userClassId ON oblog_Album (userClassId)",iNum)
	Call Execute("CREATE INDEX Index_Album_fileID ON oblog_Album (fileID)",iNum)
	Call Execute("CREATE INDEX Index_Album_commentnum ON oblog_Album (commentnum)",iNum)
	Call Execute("CREATE INDEX Index_Album_isencomment ON oblog_Album (isencomment)",iNum)
	Call Execute("CREATE INDEX Index_Album_views ON oblog_Album (views)",iNum)

	'-------------------------------------------------------------------------------------
End Sub

Private Sub CreateAlbumComment()
	'-------------------------------------------------------------------------------------
		'创建oblog_AlbumComment表
	'-------------------------------------------------------------------------------------
	iNum =4
	'复制Oblog_comment表结构到oblog_AlbumComment
	Call Execute("SELECT * INTO oblog_AlbumComment FROM Oblog_comment WHERE 1 <> 1 ",iNum)
	'增加一列
	Call Execute("ALTER TABLE oblog_AlbumComment ADD teamid INT NULL DEFAULT 0",iNum)
	'删除一列
	Call Execute("ALTER TABLE oblog_AlbumComment DROP COLUMN ubbedit",iNum)
	'删除一列
	Call Execute("ALTER TABLE oblog_AlbumComment DROP COLUMN commentid ",iNum)
	'创建主键列
	Call Execute("ALTER TABLE oblog_AlbumComment ADD commentid INT IDENTITY (1, 1) NOT NULL CONSTRAINT PK_oblog_AlbumComment PRIMARY KEY ",iNum)

	'创建索引
	Call Execute("CREATE INDEX Index_AlbumComment_mainid ON oblog_AlbumComment (mainid)",iNum)
	Call Execute("CREATE INDEX Index_AlbumComment_userid ON oblog_AlbumComment (userid)",iNum)
	Call Execute("CREATE INDEX Index_AlbumComment_teamid ON oblog_AlbumComment (teamid)",iNum)

	'-------------------------------------------------------------------------------------
End Sub

Private Sub CreateDigg()
	'-------------------------------------------------------------------------------------
		'创建oblog_digg表
	'-------------------------------------------------------------------------------------
	iNum =5

	strSql="Create Table oblog_digg("& _
		"did INT IDENTITY (1, 1) NOT NULL CONSTRAINT PK_oblog_digg PRIMARY KEY," & _
		"userID INT NULL DEFAULT 0 ," & _
		"diggid INT NULL DEFAULT 0 ," & _
		"addtime  SMALLDATETIME NULL DEFAULT " &G_Sql_Now& "," & _
		"logid INT NULL DEFAULT 0 ," & _
		"addip VARCHAR(50) NULL ," & _
		"isguest INT NULL DEFAULT 0 ," & _
		"authorid INT NULL DEFAULT 0 ," & _
		"username NVARCHAR(255) NULL ," & _
		"diggtype int NULL DEFAULT -1 )"

	'创建表
	Call Execute(strSql,iNum)

	'创建索引
	Call Execute("CREATE INDEX Index_digg_userID ON oblog_digg (userID)",iNum)
	Call Execute("CREATE INDEX Index_digg_diggid ON oblog_digg (diggid)",iNum)
	Call Execute("CREATE INDEX Index_digg_logid ON oblog_digg (logid)",iNum)
	Call Execute("CREATE INDEX Index_digg_authorid ON oblog_digg (authorid)",iNum)

	'-------------------------------------------------------------------------------------
End Sub

Private Sub CreateUserDigg()
	'-------------------------------------------------------------------------------------
		'创建oblog_userdigg表
	'-------------------------------------------------------------------------------------
	iNum = 6

	strSql="Create Table oblog_userdigg("& _
		"diggID INT IDENTITY (1, 1) NOT NULL CONSTRAINT PK_oblog_userdigg PRIMARY KEY," & _
		"diggtitle NVARCHAR(255) NULL ," & _
		"diggurl NVARCHAR(255) NULL ," & _
		"diggnum INT NULL DEFAULT 0 ," & _
		"diggdes NVARCHAR(255) NULL ," & _
		"authorid INT NULL DEFAULT 0 ," & _
		"classid INT NULL DEFAULT 0 ," & _
		"addtime  SMALLDATETIME NULL DEFAULT " &G_Sql_Now& "," & _
		"logid INT NULL DEFAULT 0 ," & _
		"author NVARCHAR(255) NULL ," & _
		"lastdiggtime  SMALLDATETIME NULL DEFAULT " &G_Sql_Now& "," & _
		"addip NVARCHAR(50) NULL ," & _
		"iState int NULL DEFAULT 0 )"

	'创建表
	Call Execute(strSql,iNum)

	'创建索引
	Call Execute("CREATE INDEX Index_userdigg_diggnum ON oblog_userdigg (diggnum)",iNum)
	Call Execute("CREATE INDEX Index_userdigg_logid ON oblog_userdigg (logid)",iNum)
	Call Execute("CREATE INDEX Index_userdigg_authorid ON oblog_userdigg (authorid)",iNum)
	Call Execute("CREATE INDEX Index_userdigg_classid ON oblog_userdigg (classid)",iNum)

	'-------------------------------------------------------------------------------------
End Sub

Private Sub CreateTeamSkin()
	'-------------------------------------------------------------------------------------
		'创建oblog_teamskin表
	'-------------------------------------------------------------------------------------
	iNum =7

	'复制Oblog_userskin表结构到oblog_teamskin
	Call Execute("SELECT * INTO oblog_teamskin FROM Oblog_userskin WHERE 1 <> 1 ",iNum)
	'删除一列
	Call Execute("ALTER TABLE oblog_teamskin DROP COLUMN id ",iNum)
	'创建主键列
	Call Execute("ALTER TABLE oblog_teamskin ADD id INT IDENTITY (1, 1) NOT NULL CONSTRAINT PK_oblog_AlbumComment PRIMARY KEY ",iNum)

	'创建索引
	Call Execute("CREATE INDEX Index_teamskin_classid ON oblog_teamskin (classid)",iNum)
	Call Execute("CREATE INDEX Index_teamskin_isdefault ON oblog_teamskin (isdefault)",iNum)
	Call Execute("CREATE INDEX Index_teamskin_ispass ON oblog_teamskin (ispass)",iNum)

	'-------------------------------------------------------------------------------------
End Sub

Private Sub InsertAblum()

	iNum = 8

	strSql = "INSERT INTO oblog_album " & _
	"(userid,photo_path,photo_size,photo_title,photo_readme,teamid,sysclassid," & _
	"userclassid,addtime,fileid,commentnum,isencomment,views) " & _
	"SELECT userid,file_path,file_size,""无标题"",file_readme,0,0,0,addtime,fileid,0,0,0 " & _
	"FROM oblog_upfile WHERE isphoto = 1"

	Call Execute(strSql,iNum)
End Sub

Private Sub DoUpdateGroups()
	'-------------------------------------------------------------------------------------
		'更新oblog_groups表
	'-------------------------------------------------------------------------------------
		iNum = 9

		'创建主键
		Call Execute("ALTER TABLE oblog_groups ADD CONSTRAINT PK_oblog_group PRIMARY KEY(groupid) ",iNum)

		Call Execute("ALTER TABLE oblog_groups ADD g_mailpost INT NULL DEFAULT 0",iNum)
		Call Execute("ALTER TABLE oblog_groups ADD g_download INT NULL DEFAULT 0",iNum)
		Call Execute("ALTER TABLE oblog_groups ADD g_getpwd INT NULL DEFAULT 0",iNum)

	'-------------------------------------------------------------------------------------
End Sub

Private Sub DoUpdateLog()
	'-------------------------------------------------------------------------------------
		'更新oblog_log表
	'-------------------------------------------------------------------------------------
		iNum = 10

		Call Execute("ALTER TABLE oblog_log ADD isNeedLogin INT NULL DEFAULT 0",iNum)
		Call Execute("ALTER TABLE oblog_log ADD ViewScores INT NULL DEFAULT 0",iNum)
		Call Execute("ALTER TABLE oblog_log ADD IsSpecial INT NULL DEFAULT 0",iNum)
		Call Execute("ALTER TABLE oblog_log ADD diggNum INT NULL DEFAULT 0",iNum)
		Call Execute("ALTER TABLE oblog_log ADD ViewGroupId INT NULL DEFAULT 0",iNum)

		'创建索引
		Call Execute("CREATE INDEX Index_log_classid ON oblog_log (IsSpecial)",iNum)
		Call Execute("CREATE INDEX Index_log_diggNum ON oblog_log (diggNum)",iNum)
		Call Execute("CREATE INDEX Index_log_ViewGroupId ON oblog_log (ViewGroupId)",iNum)

	'-------------------------------------------------------------------------------------
End Sub

Private Sub DoUpdateRoles()
	'-------------------------------------------------------------------------------------
		'更新oblog_roles表
	'-------------------------------------------------------------------------------------
		iNum = 11

		Call Execute("ALTER TABLE oblog_roles ADD r_words INT NULL DEFAULT 0",iNum)
		Call Execute("ALTER TABLE oblog_roles ADD r_IP INT NULL DEFAULT 0",iNum)
		Call Execute("ALTER TABLE oblog_roles ADD r_site_count INT NULL DEFAULT 0",iNum)
		Call Execute("ALTER TABLE oblog_roles ADD r_user_blog INT NULL DEFAULT 0",iNum)
		Call Execute("ALTER TABLE oblog_roles ADD r_user_rblog INT NULL DEFAULT 0",iNum)
		Call Execute("ALTER TABLE oblog_roles ADD r_user_cmt INT NULL DEFAULT 0",iNum)
		Call Execute("ALTER TABLE oblog_roles ADD r_user_msg INT NULL DEFAULT 0",iNum)
		Call Execute("ALTER TABLE oblog_roles ADD r_user_tag INT NULL DEFAULT 0",iNum)
		Call Execute("ALTER TABLE oblog_roles ADD r_group_user INT NULL DEFAULT 0",iNum)
		Call Execute("ALTER TABLE oblog_roles ADD r_group_blog INT NULL DEFAULT 0",iNum)
		Call Execute("ALTER TABLE oblog_roles ADD r_user_upfiles INT NULL DEFAULT 0",iNum)
		Call Execute("ALTER TABLE oblog_roles ADD r_list_upfiles INT NULL DEFAULT 0",iNum)
		Call Execute("ALTER TABLE oblog_roles ADD r_user_all INT NULL DEFAULT 0",iNum)
		Call Execute("ALTER TABLE oblog_roles ADD r_user_add INT NULL DEFAULT 0",iNum)
		Call Execute("ALTER TABLE oblog_roles ADD r_album_comment INT NULL DEFAULT 0",iNum)
		Call Execute("ALTER TABLE oblog_roles ADD r_user_digg INT NULL DEFAULT 0",iNum)

	'-------------------------------------------------------------------------------------
End Sub

Private Sub DoUpdateSetup()
	'-------------------------------------------------------------------------------------
		'更新oblog_setup表
	'-------------------------------------------------------------------------------------
		iNum = 12

		Call Execute("ALTER TABLE oblog_setup ADD log_count_Yesterday INT NULL DEFAULT 0",iNum)
		Call Execute("ALTER TABLE oblog_setup ADD log_Yesterday SMALLDATETIME NULL DEFAULT " &G_Sql_Now,iNum)

	'-------------------------------------------------------------------------------------
End Sub

Private Sub DoUpdateSubject()
	'-------------------------------------------------------------------------------------
		'更新oblog_subject表
	'-------------------------------------------------------------------------------------
		iNum = 13

		Call Execute("ALTER TABLE oblog_subject ADD ishide INT NULL DEFAULT 0",iNum)
		Call Execute("ALTER TABLE oblog_subject ADD addtime SMALLDATETIME NULL DEFAULT " &G_Sql_Now,iNum)
		Call Execute("ALTER TABLE oblog_subject ADD views INT NULL DEFAULT 0",iNum)
		Call Execute("ALTER TABLE oblog_subject ADD photo_path NVARCHAR(255) NULL ",iNum)

		'创建索引
		Call Execute("CREATE INDEX Index_subject_subjectType ON oblog_subject (subjectType)",iNum)
		Call Execute("CREATE INDEX Index_subject_ishide ON oblog_subject (ishide)",iNum)
		Call Execute("CREATE INDEX Index_subject_views ON oblog_subject (views)",iNum)

	'-------------------------------------------------------------------------------------
End Sub

Private Sub DoUpdateSyslog()
	'-------------------------------------------------------------------------------------
		'更新oblog_syslog表
	'-------------------------------------------------------------------------------------
		iNum = 14

		Call Execute("ALTER TABLE oblog_syslog ADD QueryStrings TEXT NULL",iNum)

	'-------------------------------------------------------------------------------------
End Sub

Private Sub DoUpdateUser()
	'-------------------------------------------------------------------------------------
		'更新oblog_user表
	'-------------------------------------------------------------------------------------
		iNum = 15

		Call Execute("ALTER TABLE oblog_user ADD TruePassword NVARCHAR(50) NULL ",iNum)
		Call Execute("ALTER TABLE oblog_user ADD passport_email NVARCHAR(50) NULL ",iNum)
		Call Execute("ALTER TABLE oblog_user ADD passport_password VARCHAR(50) NULL ",iNum)

		Call Execute("ALTER TABLE oblog_user ADD PlayerType INT NULL DEFAULT 0",iNum)
		Call Execute("ALTER TABLE oblog_user ADD passport_userid INT NULL DEFAULT 0",iNum)
		Call Execute("ALTER TABLE oblog_user ADD updateblognum INT NULL DEFAULT 0",iNum)
		Call Execute("ALTER TABLE oblog_user ADD diggs INT NULL DEFAULT 0",iNum)
		Call Execute("ALTER TABLE oblog_user ADD isdigg INT NULL DEFAULT 0",iNum)

		Call Execute("ALTER TABLE oblog_user ADD updateblogDate SMALLDATETIME NULL DEFAULT " &G_Sql_Now,iNum)

		'创建索引
		Call Execute("CREATE INDEX Index_user_diggs ON oblog_user (diggs)",iNum)
		Call Execute("CREATE INDEX Index_user_passport_userid ON oblog_user (passport_userid)",iNum)

	'-------------------------------------------------------------------------------------
End Sub

Private Sub DoUpdateConfig()

	iNum = 16

	On Error Resume Next
	Dim rs,ac,sConfig,i
	Dim strTemp
	Set rs = Conn.Execute("SELECT ob_Value FROM oblog_config WHERE Id=1")
	sConfig=rs(0)
	ac=Split(sConfig,"$$")

	If UBound(ac)<C_Items Then
		For i=1 To (C_Items-UBound(ac))
			sConfig=sConfig & "$$0"
		Next
		'重新分割
		ac=Split(sConfig,"$$")
	End If

	'日志自动保存为草稿的时间
	If ac(7) = "0" Or Not IsNumeric(ac(7)) Then ac(7) = 2
	'自动读取短消息的时间
	If ac(8) = "0" Or Not IsNumeric(ac(8)) Then ac(8) = 10
	'服务器操作系统语言
	ac(24) = 0
	'是否允许游客发表评论及留言
	If ac(27) = "0" Or Not IsNumeric(ac(27)) Or ac(27)>1 Then ac(27) = 1
	'用户发表评论，留言是否需要验证码
	If ac(30) = "0" Or Not IsNumeric(ac(30)) Or ac(30)>1 Then ac(30) = 0
	'系统相片列表调用相片总个数
	If ac(39) = "0" Then ac(39) = 500
	'评论排序方式
	If ac(40) = "0" Or Not IsNumeric(ac(40)) Or ac(40)>1 Then ac(40) = 0
	'博客列表每页显示博客条数
	If ac(42) = "0" Or Not IsNumeric(ac(42)) Then ac(42) = 30
	ac(54) = 0
	ac(55) = is_relativepath
	ac(56) = upload_dir
	ac(57) = logfilepath
	ac(58) = is_unamedir
	ac(59) = C_Reg_AutoCreate
	ac(60) = C_Spam_RegCodeTime
	ac(61) = C_Spam_ChkMinutes
	ac(62) = C_Spam_OneIp
	ac(63) = C_Spam_AllIp
	ac(64) = 30
	ac(65) = 5
	ac(66) = 30
	ac(67) = 0
	ac(68) = "8.a"
	ac(69) = P_QQ_NAME
	ac(70) = P_QQ_MASTERNAME
	ac(71) = p_Group_MaxUser
	ac(72) = 1
	ac(73) = P_TAGS_MAX
	ac(74) = P_TRACKBACK_MAX
	ac(75) = ""
	ac(76) = 1
	ac(77) = 30
	ac(78) = 30
	ac(79) = 500
	ac(80) = "GG"
	ac(81) = 0
	ac(82) = 0
	ac(83) = 0
	ac(84) = 1

	strTemp = Join(ac,"$$")

    Set rs = Server.CreateObject("adodb.recordset")
    rs.Open "SELECT ob_Value FROM oblog_config WHERE Id=1",Conn,1,3
    If rs.Eof Then rs.AddNew
    rs("ob_value")=strTemp
    rs.Update
    rs.Close
    Set rs = Nothing

	If Err.Number<>0 Then
		strErrMsg (iNum) = strErrMsg (iNum) &"<ul class=""u1"">"
		strErrMsg (iNum) = strErrMsg (iNum) &"	<li class=""l1"">" & Err.Description & "</li>"
		strErrMsg (iNum) = strErrMsg (iNum) &"	<li class=""l2"">" & Err.Number & "</li>"
		strErrMsg (iNum) = strErrMsg (iNum) &"</ul>"
	End If
	Err.Clear
End Sub

Private Sub ClearOldOBCodes()

	iNum = 17

	Call Execute("DELETE FROM oblog_obcodes WHERE istate=0 AND DATEDIFF("&G_Sql_d&",createtime,"&G_Sql_Now&")>=15",iNum)

End Sub

Private Sub DoUpdateScore()

	iNum = 18

	On Error Resume Next
	Dim rs,ac,sConfig,i
	Dim strTemp
	Set rs = Conn.Execute("SELECT ob_Value FROM oblog_config WHERE Id=3")
	sConfig=rs(0)
	ac=Split(sConfig,"$$")

	If UBound(ac)<C_Items Then
		For i=1 To (C_Items-UBound(ac))
			sConfig=sConfig & "$$0"
		Next
		'重新分割
		ac=Split(sConfig,"$$")
	End If

	ac(21) = 5
	ac(22) = 5

	strTemp = Join(ac,"$$")

    Set rs = Server.CreateObject("adodb.recordset")
    rs.Open "SELECT ob_Value FROM oblog_config WHERE Id=3",Conn,1,3
    If rs.Eof Then rs.AddNew
    rs("ob_value")=strTemp
    rs.Update
    rs.Close
    Set rs = Nothing

	If Err.Number<>0 Then
		strErrMsg (iNum) = strErrMsg (iNum) &"<ul class=""u1"">"
		strErrMsg (iNum) = strErrMsg (iNum) &"	<li class=""l1"">" & Err.Description & "</li>"
		strErrMsg (iNum) = strErrMsg (iNum) &"	<li class=""l2"">" & Err.Number & "</li>"
		strErrMsg (iNum) = strErrMsg (iNum) &"</ul>"
	End If
	Err.Clear
End Sub

Private Sub CheckErr()
	Dim i
	Dim strTemp
	For i = 0 To UBound(strErrMsg)
		If strErrMsg(i) <> "" Then
			FoundErr = True
			strTemp = strTemp & strErrMsg(i)
		End if
	Next
	If strTemp <>"" Then
		Response.Write  "<script>document.getElementById('info').innerHTML  ='"&htm2js(strTemp)&"'</script>"
	End if
End Sub

Private Sub Execute(sSql,i)
	On Error Resume Next
	Call conn.Execute(sSql)
	If Err.Number<>0 Then
		If Err.Number<>-2147467259 Then
			strErrMsg (i) = strErrMsg (i) &"<ul class=""u2"">"
			strErrMsg (i) = strErrMsg (i) &"	<li class=""l1"">" & sSql & "</li>"
			strErrMsg (i) = strErrMsg (i) &"	<li class=""l2"">" & Err.Description & "</li>"
			strErrMsg (i) = strErrMsg (i) &"	<li class=""l3"">" & Err.Number & "</li>"
			strErrMsg (i) = strErrMsg (i) &"</ul>"
		End if
	End If
	Err.Clear
End Sub

Private Sub Echo(sStr)
	Response.Write sStr
	Response.Flush
End Sub

Private Sub BackDataBase()
	On Error Resume Next
	Call Link_Database
	Server.ScriptTimeOut=999999999
	Dim dbPath,tempString,dbName
	Dim fso, Engine, strDBPath
	Randomize
	tempString=Int(9000*Rnd)+1000
	dbpath=server.mappath(db)
	strDBPath = left(dbPath,instrrev(DBPath,"\"))
	DBName = Right (dbPath,Len(dbPath)-Len(strDBPath))
	DBName = Left (DBName,InStr(DBName,"."))
	Set fso = Server.CreateObject(oFSO)
	If fso.FileExists(dbPath) Then
		fso.CopyFile dbpath,strDBPath & DBName&tempString&".mdb"
		Set fso = nothing
		Set Engine = nothing
		Response.Write  "<script language=""javascript"">if (confirm('数据库(" &DBName&tempString&".mdb)备份成功\n点击确定升级数据库！')==true) {window.location.href='?step=1';}</script>"
	Else
		Response.Write  "<script language=""javascript"">alert('数据库没有找到!');</script>"
	End If
	If IsObject (conn) Then Set conn=Nothing
End Sub

Public Function htm2js(Str)
	If Str = "" Or IsNull(Str) Then Str = " "
	Str = Replace(Str, "\", "\\")
	Str = Replace(Str, "'", "\'")
	Str = Replace(Str, Chr(13), "")
	Str = Replace(Str, Chr(10), "\n")
	htm2js = Str
End Function
%>