<!--#include file="conn.asp"-->
<title>3鸟设社系统1.5 to 2.0 升级文件</title>

<p>3鸟设社系统1.5 to 2.0 升级文件</p>
<p>升级说明：</p>
<p>1、请将此文件copy到1.5版的根目录，然后执行。如果您的数据库结构改动过，将不能升级，请不要再执行此文件。</p>
<p>2、升级成功后，将2.0版的所有文件覆盖掉1.5版的文件，或将数据库文件copy到2.0版中，然后更改conn.asp和admin/conn.asp中的数据库连接路径，最后请删除此文件。</p>
<p>3、管理员登录的路径是admin/login.asp，初始用户名为admin，密码为57300354。</p>
<form name="form1" method="post" action="?action=step1">
  <p> 
    <input type="submit" name="Submit" value="第一步：更新数据库结构">
  </p>
</form>
<form name="form2" method="post" action="?action=step2">
  <input type="submit" name="Submit2" value="第二步：删除无用数据">
</form>
<%
dim sql,rs,action
action=Trim(Request.QueryString("action"))
select case action
	case "step1" call step1()
	case "step2" call step2()
end select


'///////////////第一步/////////////////
sub step1()

'创建表User
sql="Create Table UserInfo (ID INT IDENTITY (1, 1) NOT NULL PRIMARY KEY,"&_
"USR VARCHAR(10),"&_
"PWD VARCHAR(20),"&_
"Email VARCHAR(40),"&_
"QQ VARCHAR(15),"&_
"ICQ VARCHAR(15),"&_
"MSN VARCHAR(40),"&_
"Homepage VARCHAR(50),"&_
"Point INT Default 0,"&_
"RegDate DATETIME Default Now(),"&_
"LoginTimes INT Default 0,"&_
"LastLoginIP VARCHAR(15),"&_
"LastLogin DATETIME,"&_
"Power VARCHAR(12),"&_
"IsAdmin BIT Default 0,"&_
"LockUser BIT Default 0)"
set rs=conn.execute(sql)
conn.execute("insert into UserInfo (USR,PWD,Power,IsAdmin) values ('admin','57300354','1,1,1,1,1,1',1)")

'创建表Skin
sql="Create Table Skin (ID INT IDENTITY (1, 1) NOT NULL PRIMARY KEY,"&_
"SkinName VARCHAR(10),"&_
"SkinSetting TEXT)"
set rs=conn.execute(sql)
conn.execute("insert into Skin (SkinName,SkinSetting) values ('默认方案','#708090,,#EEEEEE,#FFFFFE,#EFEFEF,#000000,#FFFFFF,#778899,#DDEEFF,#000000,#778899,#778899,#778899,#778899,#778899,#708090,#FFFFFE,images/ydxz_logo.gif,images/bg.gif')")

'创建表Config
sql="Create Table Config (ID INT IDENTITY (1, 1) NOT NULL PRIMARY KEY,"&_
"SiteSetting TEXT,"&_
"FtpSetting VARCHAR(255),"&_
"AdsCode TEXT)"
set rs=conn.execute(sql)
conn.execute("insert into Config (SiteSetting,FtpSetting,AdsCode) values ('3鸟设社,http://ydxz.hzgb.net,yes,pause.htm,1,,yes,yes,yes,center,25,10,10,20,10,2,5,1,yes,pcpro@21cn.com','','')")

'创建表Message
sql="Create Table Message (ID INT IDENTITY (1, 1) NOT NULL PRIMARY KEY,"&_
"Title VARCHAR(60),"&_
"Content TEXT,"&_
"PostDate DATETIME Default Now())"
set rs=conn.execute(sql)

'创建表Class
sql="Create Table Class (ID INT IDENTITY (1, 1) NOT NULL PRIMARY KEY,"&_
"ParentID INT default 0,"&_
"ParentStr VARCHAR(50),"&_
"ChildID VARCHAR(255),"&_
"ClassName VARCHAR(20),"&_
"Sequence INT default 0)"
set rs=conn.execute(sql)

'将表SmallClass中的内容转移到表Class
sql="select * from smallclass order by smallclassid"
set rs=conn.execute(sql)
do while not rs.eof
	conn.execute("insert into Class (ParentID,ClassName,Sequence) values ("&rs(1)&",'"&rs(2)&"',"&rs(3)&")")
rs.movenext
loop
sql="select s.SmallClassID,c.ID from Class c inner join SmallClass s on s.SmallClass=c.ClassName"
set rs=conn.execute(sql)
do while not rs.eof
	conn.execute("update Software set SmallClassID="&rs(1)&" where SmallClassID="&rs(0))
rs.movenext
loop

'将表BigClass中的内容合并到表Class
sql="select * from bigclass order by bigclassid"
set rs=conn.execute(sql)
do while not rs.eof
	conn.execute("insert into class (parentid,classname,sequence) values (0,'"&rs(1)&"',"&rs(2)&")")
rs.movenext
loop

'更新分类
sql="select bigclassid,bigclass from bigclass order by bigclassid"
set rs=conn.execute(sql)
dim sql2,rs2
do while not rs.eof
    sql2="select top 1 id from class where classname='"&rs(1)&"'"
	set rs2=conn.execute(sql2)
	conn.execute("update class set ParentID="&rs2(0)&" where ParentID="&rs(0))
rs.movenext
loop
conn.execute("update Class set ParentStr=CSTR(ParentID)")

sql="select id from class where ParentID=0 order by id"
set rs=conn.execute(sql)
dim ChildID
do while not rs.eof
    sql2="select id from class where ParentID="&rs(0)&" order by sequence"
	set rs2=conn.execute(sql2)
	ChildID=CSTR(rs2(0))
	rs2.movenext
	do while not rs2.eof
		ChildID=ChildID&","&CSTR(rs2(0))
		rs2.movenext
	loop
	set rs2=nothing
	conn.execute("update class set ChildID='"&ChildID&"' where ID="&rs(0))
	rs.movenext
loop

conn.execute("alter table Software add Keyword VARCHAR(40)")
conn.execute("update Software set Keyword=FileName")
conn.execute("alter table Software add Info VARCHAR(255)")
conn.execute("update Software set Info=FileSize&'|'&System&'|'&'|'")
conn.execute("alter table Software add Picture VARCHAR(255)")
conn.execute("update Software set Picture=Image&'|'&BigImage where Image<>''")
conn.execute("alter table Software alter LastHit DATETIME Default Date()")
conn.execute("alter table Software alter FileName VARCHAR(80)")
conn.execute("alter table Software alter FileSize VARCHAR(20)")
conn.execute("alter table Software alter Chinese VARCHAR(255)")
conn.execute("alter table Software alter Crack VARCHAR(255)")
conn.execute("update Software set FileName=FileName+' '+Ver")
conn.execute("alter table Software add FtpDown VARCHAR(100)")
conn.execute("alter table Software add AddDate DATETIME Default now()")
conn.execute("alter table Software add LastUpdate DATETIME Default now()")
conn.execute("update Software set AddDate=DateTime")
conn.execute("update Software set LastUpdate=Update")
conn.execute("update Software set Brief='    '&Brief")


'更新下载地址
conn.execute("alter table Software add URL TEXT")
sql="select URL1,URL2,URL3,URL1Text,URL2Text,URL3Text,Other,OtherText,ID from Software order by ID"
set rs=conn.execute(sql)
dim text
do while not rs.eof
	if rs(3)<>"" then
		text=rs(3)&"|"&rs(0)
	else
		text=rs(0)
	end if
	if rs(1)<>"" then
		if rs(4)<>"" then
			text=text&VBCrLf&rs(4)&"|"&rs(1)
		else
			text=text&VBCrLf&rs(1)
		end if
	end if
	if rs(2)<>"" then
		if rs(5)<>"" then
			text=text&VBCrLf&rs(5)&"|"&rs(2)
		else
			text=text&VBCrLf&rs(2)
		end if
	end if
	if rs(6)<>"" then
		if rs(7)<>"" then
			text=text&VBCrLf&rs(7)&"|"&rs(6)
		else
			text=text&VBCrLf&rs(6)
		end if
	end if
	conn.execute("update Software set URL='"&text&"' where ID="&rs(8))
rs.movenext
loop
set rs=nothing
conn.execute("update Software set Chinese=ChineseText&'|'+Chinese where ChineseText<>''")
conn.execute("update Software set Crack=CrackText&'|'+Crack where CrackText<>''")


conn.execute("alter table Software add ClassID INT Default 0")
conn.execute("update Software set ClassID=SmallClassID")
conn.execute("alter table Software add Poster VARCHAR(12)")
conn.execute("alter table Software add PostType TINYINT Default 0")
conn.execute("update Software set Poster='admin',PostType=0")
conn.execute("alter table Software add Point VARCHAR(20)")
sql="select Point1,Point2,Point3,Point4,Point5,ID from Software order by ID"
set rs=conn.execute(sql)
dim Point1,Point2,Point3,Point4,Point5
do while not rs.eof
	Point1=CStr(rs(0))
	Point2=CStr(rs(1))
	Point3=CStr(rs(2))
	Point4=CStr(rs(3))
	Point5=CStr(rs(4))
	conn.execute("update Software set Point='"&Point1&"'&','&'"&Point2&"'&','&'"&Point3&"'&','&'"&Point4&"'&','&'"&Point5&"' where ID="&rs(5))
rs.movenext
loop
set rs=nothing

response.write "<font color=red>第一步执行完毕，请执行第二步！</font>"
end sub


'///////////////第二步/////////////////
sub step2()
'删除无用的表和字段
conn.execute("alter table Software drop URL1")
conn.execute("alter table Software drop URL2")
conn.execute("alter table Software drop URL3")
conn.execute("alter table Software drop URL1Text")
conn.execute("alter table Software drop URL2Text")
conn.execute("alter table Software drop URL3Text")
conn.execute("alter table Software drop Other")
conn.execute("alter table Software drop OtherText")
conn.execute("alter table Software drop BigClassID")
conn.execute("alter table Software drop SmallClassID")
conn.execute("alter table Software drop FileSize")
conn.execute("alter table Software drop System")
conn.execute("alter table Software drop [Image]")
conn.execute("alter table Software drop BigImage")
conn.execute("alter table Software drop Ver")
conn.execute("alter table Software drop ChineseText")
conn.execute("alter table Software drop CrackText")
conn.execute("alter table Software drop Point1")
conn.execute("alter table Software drop Point2")
conn.execute("alter table Software drop Point3")
conn.execute("alter table Software drop Point4")
conn.execute("alter table Software drop Point5")
conn.execute("alter table Software drop [DateTime]")
conn.execute("alter table Software drop [Update]")
conn.execute("alter table Review drop Email")
conn.execute("Drop Table Admin")
conn.execute("Drop Table SmallClass")
conn.execute("Drop Table BigClass")

response.write "<font color=red>恭喜您，升级成功！</font>"

set rs=nothing
end sub

conn.close
set conn=nothing
%>