返回列表 回复 发帖

动网至雷傲论坛数据转换程序

  1. 'DV2LB.vbs
  2. '
  3. '动网至雷傲论坛数据转换程序
  4. '转换程序编制:
  5. '雷傲论坛河北代理
  6. '一窍不通
  7. '
  8. LBDataPath = "."'转换后雷傲论坛数据存放路径
  9. DVDBName = "dvbbs6.mdb"'动网数据库路径名称
  10. Title = "DV2LB数据转换程序(β0.11)"
  11. Welcome
  12. AllTimeBegin = Timer
  13. ThisTime = Now
  14. timeUTC = "1970-1-1 8:00:00"
  15. Set fso = CreateObject("Scripting.FileSystemObject")
  16. LBPathAll = fso.GetAbsolutePathName(LBDataPath) & "/"
  17. DVDBNameAll = fso.GetAbsolutePathName(DVDBName)
  18. dataDir = LBPathAll & "data\"
  19. Set DBConnection = CreateObject("Adodb.Connection")
  20. ConnectionString = "driver={Microsoft Access Driver (*.mdb)};dbq="&DVDBNameAll
  21. DBConnection.Open ConnectionString
  22. Set rs = CreateObject("Adodb.Recordset")
  23. ChangeMemberData
  24. ChangeClassData
  25. ChangeForumsData
  26. ChangeMemberFriend
  27. ChangeShareForums
  28. ChangeFav
  29. DBConnection.close
  30. Set DBConnection = nothing
  31. AllTimeEnd = Timer
  32. AllTime = AllTimeEnd - AllTimeBegin
  33. MsgBox "动网至雷傲数据转换完成.共用时"& alltime &"秒",vbInformation,Title &"—数据转换完成"
  34. Sub Welcome()
  35.     Dim intDoIt
  36.    
  37.     L_Welcome_MsgBox_Message_Text="动网至雷傲论坛数据转换程序"&vbnewline&vbnewline&"程序编制:"&vbnewline&"雷傲论坛河北代理  一窍不通"&vbnewline&vbnewline&"是否进行论坛数据转换?"
  38.     L_Welcome_MsgBox_Title_Text=Title&"——提示"
  39.         
  40.     intDoIt =  MsgBox(L_Welcome_MsgBox_Message_Text,    _   
  41.                       vbOKCancel + vbInformation,       _
  42.                       L_Welcome_MsgBox_Title_Text )
  43.     If intDoIt = vbCancel Then
  44.         WScript.Quit
  45.     End If
  46. End Sub
  47. Sub ChangeMemberData()
  48. 'Doit = MsgBox ("用户数据转换", vbokcancel ,Title&"——用户数据转换")
  49. 'If (Doit = vbcancel) Then Exit Sub
  50. memberDir = LBPathAll & "members\"
  51. If not fso.FolderExists(memberDir) Then fso.CreateFolder(memberDir)
  52. 'On Error Resume Next
  53. rs.open "user",DBConnection
  54. While not rs.eof
  55. UserName = ChangeName(rs("UserName"))
  56. If UserName<>"" Then
  57. userinfos = rs("userinfo")
  58. If userinfos<>"" Then
  59. userinfo = split(userinfos,"|||")
  60. Else
  61. userinfos = "||||||||||||||||||||||||||||||||||||||||||"
  62. userinfo = split(userinfos,"|||")
  63. End If
  64. If rs("sex") Then mSex="m" Else mSex="f"
  65. Select Case rs("usergroupid")
  66. Case "1" MemberCode = "ad"
  67. Case "2" MemberCode = "smo"
  68. Case "3" MemberCode = "mo"
  69. Case "4" MemberCode = "me"
  70. Case "8" MemberCode = "rz"
  71. Case Else MemberCode = "me"
  72. End Select
  73. MData = UserName & vbtab & rs("UserPassword") & vbtab & rs("title") & vbtab _
  74. & MemberCode & vbtab & rs("article") & vbtab & rs("useremail") & vbtab _
  75. & rs("showre") & vbtab & vbtab & rs("homepage") & vbtab & rs("oicq") & vbtab _
  76. & rs("icq") & vbtab & userinfo(4) & userinfo(5) & vbtab & ChangeString(userinfo(2)) & vbtab  _
  77. & changedate(rs("adddate")) & vbtab & vbtab & ChangeString(rs("sign")) & vbtab & vbtab & vbtab & vbtab  _
  78. & userinfo(3) & vbtab & vbtab & userinfo(6) & vbtab & vbtab & vbtab & vbtab & rs("userpower") & vbtab _
  79. & changedate(rs("lastlogin")) & vbtab & rs("logins") & vbtab & vbtab & vbtab _
  80. & vbtab & -rs("userdel") & vbtab & mSex & vbtab & userinfo(11) & vbtab  _
  81. & userinfo(10) & vbtab & userinfo(9) & vbtab _
  82. & rs("birthday") & vbtab & vbtab & vbtab & rs("usergroup") & vbtab _
  83. & vbtab
  84. 'MsgBox mdata
  85. MemberName = LCase(UserName)
  86. MemberName = memberDir & MemberName & ".cgi"
  87. Set MFile = fso.opentextfile (MemberName,2,true)
  88. MFile.Write(MData)
  89. MFile.close
  90. End If
  91. rs.movenext
  92. Wend
  93. rs.close
  94. End Sub
  95. Sub ChangeClassData()
  96. 'Doit = MsgBox ("论坛分类数据转换", _
  97. 'vbokcancel,Title & "——论坛分类转换")
  98. 'If Doit = vbcancel Then Exit Sub
  99. If not fso.FolderExists(dataDir) Then fso.CreateFolder(dataDir)
  100. sql = "select * from board where parentid=0 order by rootid"
  101. Set rsClass = DBConnection.execute(sql)
  102. While not rsclass.eof
  103. AllFourms=""
  104. sql = "select * from board where parentid=" & rsClass("boardid") &" order by orders"
  105. Set rsB = DBConnection.execute(sql)
  106. While not rsB.eof
  107. LastPostInfo = split (rsB("lastpost"),"$")
  108. master = rsB("boardmaster")
  109. If master<>"" Then master = Replace(master,"|",",")
  110. fData = rsb("boardid") & vbtab & rsClass("boardtype") & vbtab & rsClass("rootid") & vbtab _
  111. & rsB("boardtype") & vbtab & ChangeString(rsB("readme")) & vbtab & master & vbtab _
  112. & "off" & vbtab & "on" & vbtab & "no" & vbtab &  "yes" & vbtab & ChangeName(LastPostInfo(0)) & vbtab _
  113. & changedate(LastPostInfo(2)) & "%%%" & LastPostInfo(6) & "%%%" & LastPostInfo(3) & vbtab _
  114. & rsB("lasttopicnum") & vbtab _
  115. & rsB("lastbbsnum") & vbtab & vbtab & vbtab & vbtab & vbtab & "no" & vbtab & "yes" & vbtab _
  116. & rsB("indeximg") & vbtab & vbtab
  117. forumDir = LBPathAll & "forum" & rsB("boardid")
  118. If not fso.FolderExists(forumDir) Then fso.CreateFolder (forumDir)
  119. Set fFile=fso.opentextfile (forumDir & "\foruminfo.cgi",2,true)
  120. fFile.Write(fData)
  121. fFile.close
  122. AllForums = AllForums & fData & vbnewline
  123. rsB.movenext
  124. Wend
  125. rsB.close
  126. rsClass.movenext
  127. Wend
  128. rsClass.close
  129. AllForumsFileName = LBPathAll & "data\allforums.cgi"
  130. Set AllForumsFile = fso.opentextfile(AllForumsFileName,2,true)
  131. AllForumsFile.Write(Allforums)
  132. AllForumsFile.close
  133. End Sub
  134. Sub ChangeForumsData()
  135. 'Doit = MsgBox("帖子数据转换",_
  136. 'vbokcanel,Title & "——帖子数据转换")
  137. 'If Doit = vbcancel Then Exit Sub
  138. BoardDataDir = LBPathAll & "boarddata"
  139. If not fso.FolderExists(BoardDataDir) Then fso.CreateFolder(BoardDataDir)
  140. AbsontopFileName = BoardDataDir & "\absontop.cgi"
  141. sql = "select * from board where not depth=0"
  142. Set rsForum = DBConnection.execute(sql)
  143. While not rsForum.eof
  144. BoardID = rsForum("boardid")
  145. BoardDir = LBPathAll & "forum" & BoardID
  146. If not fso.FolderExists(BoardDir) Then fso.CreateFolder(BoardDir)
  147. ListFileName = BoardDataDir & "\list" & BoardID & ".cgi"
  148. JinghuaFileName = BoardDataDir & "\jinhua" & BoardID & ".cgi"
  149. OntopFileName = BoardDataDir & "\ontop" & BoardID & ".cgi"
  150. sql = "select * from topic where boardid = "& BoardID &" and not locktopic=2 order by lastposttime desc"
  151. Set rsThread = DBConnection.execute(sql)
  152. While not rsThread.eof
  153. TopicID = rsThread("topicid")
  154. voteoption = ""
  155. If rsThread("isbest")=1 Then
  156. Set JinghuaFile = fso.OpenTextFile(JinghuaFileName,8,true)
  157. JinghuaFile.Write(TopicID & vbnewline)
  158. JinghuaFile.Close
  159. End If
  160. istop = rsThread("istop")
  161. If istop=2 Then
  162. Set AbsontopFile = fso.OpenTextFile(AbsontopFileName,8,true)
  163. AbsontopFile.Write(BoardID & "|" & TopicID)
  164. AbsontopFile.Close
  165. ElseIf istop=1 Then
  166. Set OntopFile = fso.OpenTextFile(OntopFileName,8,true)
  167. OntopFile.Write(TopicID & vbnewline)
  168. OntopFile.Close
  169. End If
  170. sql = "select * from "& rsThread("posttable") &" where  boardid = "& boardid &" and rootid = "& TopicID & " and not locktopic=2 order by dateandtime"
  171. Set rsTopic = DBConnection.execute(sql)
  172. If not(rsTopic.bof and rstopic.eof) Then
  173. If rsThread("isvote") = 1 Then
  174. TopicType = "Poll"
  175. sql = "select * from vote where voteid = "& rsThread("pollid")
  176. Set rsVote = DBConnection.execute(sql)
  177. If rsVote("votetype")=1 Then votetype = "yes"Else votetype = "no"
  178. voteoption = rsVote("vote")
  179. voteoptions = split(voteoption,"|")
  180. voteoption = join(voteoptions,"<br>")
  181. sql = "select * from voteuser where voteid="& rsVote("voteid")
  182. Set rsVoteUser = DBConnection.execute(sql)
  183. PollFileName = BoardDir & "\" & TopicID & ".poll.cgi"
  184. Set PollFile = fso.OpenTextFile(PollFileName,2,true)
  185. While not rsVoteUser.eof
  186. sql = "select username from user where userid="& rsVoteUser("Userid")
  187. Set rs = DBConnection.execute(sql)
  188. If not (rs.bof and rs.eof) Then postname = ChangeName(rs(0))
  189. rs.close
  190. If votetype = "yes" Then
  191. postoption = ""
  192. postoptions = split(rsVoteUser("voteoption"),",")
  193. For i = 0 to UBound(postoptions)
  194. If postoptions(i) <> "" Then postoption = postoption & "*!#&*" & postname & vbtab & postoptions(i)+1 & vbtab & vbnewline
  195. Next
  196. Else
  197. postoption = "*!#&*" & postname & vbtab & rsVoteUser("voteoption")+1 & vbtab & vbnewline
  198. End If
  199. PollFile.Write(postoption)
  200. rsVoteUser.movenext
  201. Wend
  202. PollFile.Close
  203. rsVoteUser.Close
  204. rsVote.Close
  205. ElseIf rsThread("locktopic") = 1 Then
  206. TopicType = "Close"
  207. Else
  208. Topictype = "Open"
  209. End If
  210. 'On Error Resume Next
  211. If rsTopic("signflag")=1 Then signflag = "yes" Else signflag = "no"
  212. Topic = ChangeName(rsTopic("username")) & vbtab & "*#!&*" & rsTopic("topic") & vbtab _
  213. & rsTopic("ip") & vbtab & "yes" & vbtab & signflag & vbtab _
  214. & Changedate(rsTopic("dateandtime")) & vbtab & ChangeString(rsTopic("body")) & vbtab _
  215. & voteoption & vbtab & vbnewline
  216. rsTopic.movenext
  217. While not rsTopic.eof
  218. If rsTopic("signflag")=1 Then signflag = "yes" Else signflag = "no"
  219. Topic = Topic & ChangeName(rstopic("username")) & vbtab & "*#!&*" & rsTopic("topic") & vbtab _
  220. & rsTopic("ip") & vbtab & "yes" & vbtab & signflag & vbtab _
  221. & Changedate(rsTopic("dateandtime")) & vbtab & ChangeString(rstopic("body")) & vbtab _
  222. & "" & vbtab & vbnewline
  223. rsTopic.movenext
  224. Wend
  225. rsTopic.Close
  226. '
  227. TopicFileName = BoardDir & "\" & TopicID & ".thd.cgi"
  228. Set TopicFile = fso.OpenTextFile(TopicFileName,2,true)
  229. TopicFile.write(topic)
  230. TopicFile.close
  231. 'If err Then
  232. 'MsgBox err.number & Err.Description & " " & TopicID & vbnewline & topic & vbnewline & "end"
  233. 'err.clear
  234. 'WScript.Quit
  235. 'End If
  236. lastpost = split(rsThread("lastpost"),"$")
  237. TopicIndex = TopicID & vbtab & rsThread("title") & vbtab & vbtab & topictype & vbtab _
  238. & rsThread("child") & vbtab & rsThread("hits") & vbtab & ChangeName(rsThread("postusername")) & vbtab _
  239. & changedate(rsThread("dateandtime")) & vbtab & ChangeName(lastpost(0)) & vbtab _
  240. & changedate(rsThread("lastposttime")) & vbtab & "" & vbtab & ChangeString(lastpost(3)) & vbtab & vbnewline
  241. TopicIndexName = BoardDir & "\" & TopicID & ".pl"
  242. Set IndexFile = fso.OpenTextFile(TopicIndexName,2,true)
  243. IndexFile.Write(TopicIndex)
  244. IndexFile.Close
  245. Set ListFile = fso.OpenTextFile(ListFileName,8,true)
  246. ListFile.Write(TopicIndex)
  247. ListFile.Close
  248. End If
  249. rsThread.movenext
  250. Wend
  251. rsForum.movenext
  252. rsThread.close
  253. Wend
  254. rsForum.Close
  255. End Sub
  256. Sub ChangeMemberFriend()
  257. '转化用户好友名单
  258. friendDir = LBPathAll & "memfriend\"
  259. If not fso.FolderExists(friendDir) Then fso.createFolder(friendDir)
  260. rs.open "Friend",DBConnection
  261. While not rs.eof
  262. fName = ChangeName(rs("f_username"))
  263. fName = LCase(fName)
  264. friendName = friendDir & fName & ".cgi"
  265. Set memfriendFile = fso.opentextfile(friendName,8,true)
  266. memfriendFile.Write("*#!&*" & ChangeName(rs("f_friend")) & vbnewline)
  267. memfriendFile.close
  268. rs.movenext
  269. Wend
  270. rs.close
  271. End Sub
  272. Sub ChangeShareforums()
  273. '转化联盟论坛
  274. shareForums = ""
  275. rs.open "bbslink",DBConnection
  276. If not(rs.bof and rs.eof) Then
  277. While not rs.eof
  278. shareForum = rs("boardname") & vbtab & rs("url") & vbtab & ChangeString(rs("readme")) & vbtab & vbtab & rs("logo") & vbtab & vbnewline
  279. shareForums = shareForums & shareForum
  280. rs.movenext
  281. Wend
  282. rs.close
  283. shareFileName = dataDir & "shareforums.cgi"
  284. Set shareFile = fso.opentextfile(shareFileName,2,true)
  285. shareFile.write(shareForums)
  286. shareFile.close
  287. End If
  288. End Sub
  289. Sub ChangeFav()
  290. '转化个人收藏夹
  291. favDir = LBPathAll & "memfav"
  292. If not fso.FolderExists(favDir) Then fso.CreateFolder(favDir)
  293. rs.open "bookmark",DBConnection
  294. While not rs.eof
  295. fav0 = split(rs("url"),"?")
  296. fav1 = split(fav0(1),"&")
  297. fav11 = split(fav1(0),"=")
  298. fav12 = split(fav1(1),"=")
  299. fName = ChangeName(rs("username"))
  300. favName = favDir & "\" & LCase(fName)
  301. Set favFile = fso.OpenTextFile(favName,8,true)
  302. favFile.Write(fav11(1) & vbtab & fav12(1) & vbtab & vbnewline)
  303. favFile.Close
  304. rs.movenext
  305. Wend
  306. rs.close
  307. End Sub
  308. Function ChangeDate(date1)
  309. ChangeDate = DateDiff("s",timeUTC,date1)
  310. End Function
  311. Function ChangeString(string1)
  312. 'On Error Resume Next
  313. strings = string1
  314. If strings<>"" Then
  315. strings = Replace(strings,vbtab,"")
  316. ChangeString = Replace(strings,vbcrlf,"<br>")
  317. End If
  318. End Function
  319. Function ChangeName(iUserName)
  320. 'On Error Resume Next
  321. inUserName = iUserName
  322. Set regex = new regexp
  323. regEx.Global = True
  324. regEx.Pattern = "[\`\~\!\@\#\$\%\^\&\*\(\)\-\_\+\=\|\\\{\[\}\]\:\;""\'\<\,\>\.\?\/]"
  325. ChangeName = regEx.Replace(inUserName,"")
  326. End Function
复制代码
返回列表