⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sf1up.asp

📁 1 要转换的SF1.x数据库文件必须为1.4以上的版本, 不然可能无法正常转换 2 由于转换要求2.0数据库文件必须无任何论坛、用户、帖子数据, 因此随本转换程序提供了一个真正的数据全空的数据库文件!
💻 ASP
字号:
<!--#INCLUDE FILE="inc/md5_inc.asp"-->
<%
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'
' SF 1.x --> SF 2.0
'
' 雪人论坛1.0 access版本 到 雪人论坛2.0 access版本的转换程序
'
' 版本: 1.0.2003.6.29
' 作者: 雪人
' 雪人论坛官方站点: http://www.xinboard.net
'
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' 注意: 本程序必须上传到SF2论坛目录下运行(因为需要使用md5_inc.asp)
'
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'
' 相关说明:
'
' sf1.x
' 用户表: members
' 论坛表: forum
' 主题表: topic
' 帖子表: reply
'
' sf2
' 用户表: sf_user
' 论坛表: sf_forum
' 主题表: sf_thread
' 帖子表: sf_post
'
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'
' 作者不担保本程序产生的结果完全正确!
'
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
%>
<HTML>
<HEAD>
<TITLE>[雪人论坛1.0] 到 [雪人论坛2.0 access版本] 转换程序</TITLE>
<META http-equiv="Content-Type" content="text/html; charset=gb2312">
<STYLE>
<!--
body {font-family: 'Verdana'; font-size: 12px; color: #333333}
-->
</STYLE>
</HEAD>

<BODY bgcolor="#FFFFFF" text="#000000" leftmargin="10" topmargin="10">

<B>SF1.x数据 转换为SF2.0数据<BR><BR>注意: 如果原数据较多, 转换过程可能会花费较长的时间. 出现<font color=red>正常结束</font>字样表示转换正常结束</B><BR><BR>
<%


''''''''''''''''''''''''''''''''''''
' 重设脚本超时时间
'''''''''''''''
server.ScriptTimeout = 6000



''''''''''''''''''''''''''''''''''''
' 定义数据库连接串
' 注意SF2数据库要用随本转换程序自带的"空数据库", 不要用SF2免费版内的数据库文件!
'
'''''''''''''''

' sf1DB 连接SF1.x数据库
sf1DB = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("sf1.mdb")

' sf1DB 连接SF2.0数据库
sf2DB = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("sf2.mdb")







'''''''''''''''''''''''''''''''''''''''''''''''''''
' 不熟悉SF数据结构和ASP的用户不要修改下面的程序!
''''''''''''''''''

Set sf1Conn = Server.CreateObject("ADODB.Connection")
sf1Conn.Open sf1DB

Set sf2Conn = Server.CreateObject("ADODB.Connection")
sf2Conn.Open sf2DB

usercounter = 0
forumcounter = 0
threadcounter = 0
postcounter = 0

function ChkSql(StrSql)
	if (IsNull(StrSql)) or (len(strsql) <2)then
		ChkStr = " "
		exit function 
	else
		ChkSql = Replace(StrSql, "'", "''")
	end if
end function

response.write "----------------用户转换开始-------------------<BR>"
Set rs = sf1Conn.Execute("select member_id, m_name, m_password, m_reg_day, m_posts from members order by member_id")
if not (rs.bof or rs.eof) then
	i = 1
	do until rs.eof
		if rs("member_id") > i then
			do until rs("member_id") = i
				StrSql = "insert into sf_user(username, password, email, question, result, usergroup, homepage, icq, qq, msn, [like], sex, country, signature, showemail,invisible, usertitle, joindate, lastvisit, lastactivity, lastposttime, lastpostid, lastposttitle, posts, pmpopup, avatar, defineavatar, avatarwidth, avatarheight, birthday, ipaddress, lastforum, forbidpost) values("
				StrSql = StrSql & "'SF2update_blank', "
				StrSql = StrSql & "'SF2update_blank', "
				StrSql = StrSql & "'email@email.net', "
				StrSql = StrSql & "'question', "
				StrSql = StrSql & "'result', "
				StrSql = StrSql & "0, '', '', '', '', '', 0, '', '', 1, 0, '', '" & now() & "', '" & now() & "', '" & now() & "', '" & now() &"', 0, '', 0, 1, '1.gif', '', 0, 0, '1900-01-01', '" & cstr(request.ServerVariables("REMOTE_ADDR")) & "',0, 0)"
				sf2Conn.Execute(strsql)
				i = i + 1
			loop
		else
			StrSql = "insert into sf_user(username, password, email, question, result, usergroup, homepage, icq, qq, msn, [like], sex, country, signature, showemail,invisible, usertitle, joindate, lastvisit, lastactivity, lastposttime, lastpostid, lastposttitle, posts, pmpopup, avatar, defineavatar, avatarwidth, avatarheight, birthday, ipaddress, lastforum, forbidpost, rating) values("
			StrSql = StrSql & "'" & rs("m_name") & "', "
			StrSql = StrSql & "'" & md5(rs("m_password")) & "', "
			' email写为一个无效地址
			StrSql = StrSql & "'a@email.bbb', "
			StrSql = StrSql & "'????????', "
			StrSql = StrSql & "'!!!!!!!!', "
			StrSql = StrSql & "0, '', '', '', '', '', 0, '', '', 1, 0, '', '" & rs("m_reg_day") & "', '" & now() & "', '03-01-01 00:00:00', '" & now() &"', 0, '', " & rs("m_posts") & ", 1, '1.gif', '', 0, 0, '1900-01-01', '127.0.0.1',0, 0, " & rs("m_posts") & ")"
			usercounter = usercounter + 1
			response.write " 正在转换用户 - " & rs("m_name") & " 该用户注册序号为" & i & "<BR>"
			sf2Conn.Execute(strsql)
			i = i + 1
			rs.MoveNext
		end if
	loop
	response.write "删除临时数据...<BR>"
	sf2Conn.Execute("DELETE FROM sf_user WHERE username='SF2update_blank'")
end if

response.write "----------------------------------<BR>用户转换完毕, 共转换" & usercounter & "名用户<BR>----------------------------------<BR>"

response.write "----------------论坛版块转换开始-------------------<BR>"
sf2Conn.Execute("insert into sf_cate(catetitle, displayorder) values('新分类', 30)")
Set rs = sf2Conn.Execute("select cateid from sf_cate order by cateid DESC")
cateid = rs("cateid")
Set rs = sf1Conn.Execute("select forum_id, f_name, f_description, f_count, f_rcount from forum order by forum_id ASC")
if not (rs.bof or rs.eof) then
	i = 1
	do until rs.eof
		if rs("forum_id") > i then
			do until rs("forum_id") = i
				StrSql = "insert into sf_forum(cateid, title, description, active, displayorder, replycount, lastposttitle, lastpostid, lastpost, lastposter, lastposterid, threadcount, allowuploadfile, allowposting, daysprune, allowbbcode, allowimages, countposts, canmove, canopenclose, canreply, caneditpost, candeletepost, canpostpoll, onlyuser, onlymember, memberlist) values("
				StrSql = StrSql & "0, 'SF2update_blank', 'SF2update_blank', 1, 30, 0,'',0,'2003-05-01 1:01:01','',0, 0, "
				StrSql = StrSql & "1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, '')"
				sf2Conn.Execute(strsql)
				i = i + 1
			loop
		else
			StrSql = "insert into sf_forum(cateid, title, description, active, displayorder, replycount, lastposttitle, lastpostid, lastpost, lastposter, lastposterid, threadcount, allowuploadfile, allowposting, daysprune, allowbbcode, allowimages, countposts, canmove, canopenclose, canreply, caneditpost, candeletepost, canpostpoll, onlyuser, onlymember, memberlist) values("
			StrSql = StrSql & cateid & ",'" & rs("f_name") & "','" & ChkSql(rs("f_description")) & "', 1, 30, " & rs("f_rcount") & ",'',0,'2003-05-01 1:01:01','',0, " & rs("f_count") & ", "
			StrSql = StrSql & "1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, '')"
			forumcounter = forumcounter + 1
			response.write " 正在转换论坛版块 - " & left(rs("f_name"), 20) & " 该版块序号为" & i & "<BR>"
			sf2Conn.Execute(StrSql)
			i = i + 1
			rs.MoveNext
		end if
	loop
	response.write "删除临时数据...<BR>"
	sf2Conn.Execute("DELETE FROM sf_forum WHERE title='SF2update_blank'")
end if

response.write "----------------------------------<BR>论坛转换完毕, 共转换" & forumcounter & "个版块<BR>----------------------------------<BR>"

response.write "----------------主题转换开始-------------------<BR>"
Set rs = sf1Conn.Execute("SELECT Members.*, Topics.* FROM Members INNER JOIN Topics ON Members.Member_id = Topics.T_Originator order by topic_id ASC")

if not (rs.bof or rs.eof) then
	i = 1
	do until rs.eof
		if rs("topic_id") > i then
			do until rs("topic_id") = i
				StrSql = "insert into sf_thread(title, lastpost, forumid, pollid, [open], replycount, postusername, postuserid, lastposter, lastposterid, dateline, views, iconid, notes, visible, moved, best, displayorder, rating) values("
				StrSql = StrSql & "'SF2update_blank', "
				StrSql = StrSql & "'" & now() & "', "
				StrSql = StrSql & "0, -1, 1, 1, 'SF2update_blank', 0, "
				StrSql = StrSql & "'SF2update_blank', 0, '" & now() & "', 0, 0, '', 1, 0, 0, 0, 0)"
				sf2Conn.Execute(strsql)
				i = i + 1
			loop
		else
			StrSql = "insert into sf_thread(title, lastpost, forumid, pollid, [open], replycount, postusername, postuserid, lastposter, lastposterid, dateline, views, iconid, notes, visible, moved, best, displayorder, rating) values("
			StrSql = StrSql & "'" & ChkSql(rs("t_subject")) & " ', "
			StrSql = StrSql & "'" & rs("t_date") & "', "
			StrSql = StrSql & rs("forum_id") & ", -1, 1, 1, '" & ChkSql(rs("m_name")) & "', " & rs("member_id") & ", "
			StrSql = StrSql & "'" & ChkSql(rs("m_name")) & "', " & rs("member_id") & ", '" & now() & "', 0, 0, '', 1, 0, 0, 0, 0)"
			threadcounter = threadcounter + 1
			response.write " 正在转换主题 - " & rs("t_subject") & " 该主题序号为" & i & "<BR>"
			sf2Conn.Execute(strsql)
			i = i + 1
			rs.MoveNext
		end if
	loop
	response.write "删除临时数据...<BR>"
	sf2Conn.Execute("DELETE FROM sf_thread WHERE title='SF2update_blank'")
end if

response.write "----------------------------------<BR>主题转换完毕, 共转换" & threadcounter & "个主题<BR>----------------------------------<BR>"


response.write "----------------帖子转换开始-------------------<BR>"

Set rs = sf1Conn.Execute("SELECT Members.*, Topics.* FROM Members INNER JOIN Topics ON Members.Member_id = Topics.T_Originator")
if not (rs.bof or rs.eof) then
	do until rs.eof
		StrSql = "insert into sf_post(threadid, forumid, parentid, username, userid, title, dateline, pagetext, attachmentid, allowsmilie, allowautourl, allowxbcode, showsignature, ipaddress, iconid, layer, visible, notes, editdate) values("
		StrSql = StrSql & rs("topic_id") & ", "
		StrSql = StrSql & rs("forum_id") & ", "
		StrSql = StrSql & "-1, "
		StrSql = StrSql & "'" & rs("m_name") & "', "
		StrSql = StrSql & rs("member_id") & ", "
		StrSql = StrSql & "'无标题', "
		StrSql = StrSql & "'" & rs("t_date") & "', "
		msg = rs("t_message")
		StrSql = StrSql & "'" & ChkSql(msg) & " ', "
		StrSql = StrSql & "0, 1, 0, 1, 0, '" & rs("t_ip") & "', 0, 1, 1, '', '" & now() & "')"
		postcounter = postcounter + 1
		response.write " 正在转换第" & postcounter & "篇帖子<BR>"
		sf2Conn.Execute(strsql)
		rs.MoveNext
	loop
end if

Set rs = sf1Conn.Execute("SELECT Members.*, Reply.* FROM Members INNER JOIN Reply ON Members.Member_id = Reply.R_Posted_By")
if not (rs.bof or rs.eof) then
	do until rs.eof
		StrSql = "insert into sf_post(threadid, forumid, parentid, username, userid, title, dateline, pagetext, attachmentid, allowsmilie, allowautourl, allowxbcode, showsignature, ipaddress, iconid, layer, visible, notes, editdate) values("
		StrSql = StrSql & rs("topic_id") & ", "
		StrSql = StrSql & rs("forum_id") & ", "
		StrSql = StrSql & "1, "
		StrSql = StrSql & "'" & rs("m_name") & "', "
		StrSql = StrSql & rs("member_id") & ", "
		StrSql = StrSql & "'无标题', "
		StrSql = StrSql & "'" & rs("r_posted") & "', "
		msg = rs("r_message")
		StrSql = StrSql & "'" & ChkSql(msg) & " ', "
		StrSql = StrSql & "0, 1, 0, 1, 0, '" & rs("r_ip") & "', 0, 2, 1, '', '" & now() & "')"
		postcounter = postcounter + 1
		response.write " 正在转换第" & postcounter & "篇帖子<BR>"
		sf2Conn.Execute(strsql)
		rs.MoveNext
	loop
end if
response.write "删除临时数据...<BR>"
sf2Conn.Execute("DELETE FROM sf_post WHERE title='SF2update_blank'")

response.write "----------------------------------<BR>帖子转换完毕, 共转换" & postcounter & "个帖子<BR>----------------------------------<BR>"




''''''''''''''''''''''''''''''''''''
' 结束转换
'''''''''''''''
response.write "<BR><BR><B>全部转换完毕, 注册用户" & usercounter & ", 论坛版块" & forumcounter & ", 主题" & threadcounter & ", 帖子" & postcounter & "<BR><font color=red>正常结束</font></B><BR>"


sf1Conn.close
sf2Conn.close
Set sf1Conn = nothing
Set sf2Conn = nothing
Set rs = nothing
%>
</BODY>
</HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -