bbsxp to phpbb

Keep Open and Learning
Post Reply
jiataifeng
Posts: 178
Joined: 30 Apr 2009 06:31

bbsxp to phpbb

Post by jiataifeng » 12 Aug 2018 23:04

一个是ASP论坛,一个是PHP论坛,本人试图从数据库角度直接把数据导过去,无奈过于复杂,改变一个帖子,引起十个表的变动。算了,再加上数据量不是很多,决定自动发帖。
1. 先把用户导过去。这里借助的工具是phpbb下的扩展exportimportusers,当然,为了正常运行,其helper也是需要安装的。
2.把帖子利用自动发帖工具“拷贝”过去。
3.修改帖子相关信息,比如发帖人,时间,IP。

jiataifeng
Posts: 178
Joined: 30 Apr 2009 06:31

Re: bbsxp to phpbb

Post by jiataifeng » 12 Aug 2018 23:12

1在转移用户。
在导入用户的时候,需要使用exportimportusers的XML用户格式。因此需要生成用户XML供其导入。


在Admin_User.asp显示用户的位置,添加如下代码。


UserRegisterDate = datediff("s",cdate("1970-01-01 00:00:00"),Rs("UserRegisterTime"))

response.write"<user>"

response.write"<user_id>"
response.write Rs("UserID")+50
response.write"</user_id>"

response.write"<user_ip>"
response.write Rs("UserRegisterIP")
response.write"</user_ip>"

response.write"<user_regdate>"
response.write UserRegisterDate
response.write"</user_regdate>"


response.write"<username>"
response.write Rs("UserName")
response.write"</username>"


response.write"<user_email>"
response.write Rs("UserEmail")
response.write"</user_email>"

response.write"<user_birthday/>"

response.write"<user_password>"
response.write "$2y$10$d1hgQisQ6BhAJZ1qEeahruVort5AuUvfcaroazE6K/itKxRmljm4O"
response.write"</user_password>"


response.write "</user>"


这样就生成了每个用户的XML。
最后把相应的XML集合到一起,导入就可以了。

jiataifeng
Posts: 178
Joined: 30 Apr 2009 06:31

Re: bbsxp to phpbb

Post by jiataifeng » 12 Aug 2018 23:14

1,开发自动发帖工具,首先是需求

bbsxp网站
1. 找到主题帖子,也就是topic帖子:发布时间,作者,ip,内容,有无附件,无有跟贴,下一篇等信息
2. 如果有附件,解析并恢复附件的名字(注意备份及恢复),以被后面使用(判断标准:url=UpFile/UpAttachment及]Image)
3. 如果有后续跟贴,做好记录,以备使用(判断标准,)

phpbb网站
4. 判断是否登录,如果没有登录,登录,找到session id.
5. add topic, 判断是否有附件,如有上传,发帖。
6. 修改作者,发表时间,及IP
7,根据记录,发表后续跟贴(处理附件),并修改相关信息
8,重复处理所有跟贴
9,重复处理所有主题
10,做好log,以便出现问题可以跟踪

jiataifeng
Posts: 178
Joined: 30 Apr 2009 06:31

Re: bbsxp to phpbb

Post by jiataifeng » 12 Aug 2018 23:17

后来发现,BBSXP的附件目录直接拷贝过去,帖子里关于附件的内容不用处理,附件就直接出现在phpbb的帖子里了。因此,帖子里的附件就不用处理了。
但是发现phpbb对文字大小的支持和bbsxp不一样,因此简单起见,把所有[size]标签都给删除了。
更新:
老网站
1. 找到主题帖子,也就是topic帖子:发布时间,作者,ip,内容,有无附件,无有跟贴,下一篇等信息
2. 如果有附件,解析并恢复附件的名字(注意备份及恢复),以被后面使用(判断标准:url=UpFile/UpAttachment及]Image)
3. 如果有后续跟贴,做好记录,以备使用(判断标准,)

新网站
4. 判断是否登录,如果没有登录,登录,找到session id.
5. add topic, 判断是否有附件,如有上传,发帖。
6. 修改作者,发表时间,及IP
7,根据记录,发表后续跟贴(处理附件),并修改相关信息
8,重复处理所有跟贴
9,重复处理所有主题
10,做好log,以便出现问题可以跟踪



更改:
1. 附件问题解决,转移附件内容所在目录后,附件可以直接按帖子内容处理。
Last edited by jiataifeng on 13 Aug 2018 02:44, edited 2 times in total.

jiataifeng
Posts: 178
Joined: 30 Apr 2009 06:31

Re: bbsxp to phpbb

Post by jiataifeng » 12 Aug 2018 23:20

代码:
#include <IE.au3>
#include <Date.au3>


Sleep(5000)
Dim $currentTopicURL = "http://127.0.0.1:8080/ShowPost.asp?ThreadID=25"
$oIEbbsxp = _IECreate($currentTopicURL)

Dim $forumId = 2
Dim $sessionid = ""
$oIEphpbb = _IECreate("http://127.0.0.1/phpbb")

phpbbLogin($sessionid)


While 1

Dim $nextTopicURL, $postNumber, $topicID = 0
findTopicInfo($currentTopicURL, $postNumber, $nextTopicURL)
WriteLog("$postNumber:" & $postNumber & " $nextTopicURL:" & $nextTopicURL)

For $i = 0 To $postNumber
WriteLog("i:" & $i)

Dim $datetime, $author, $ip, $content, $title, $postID = 0
findPostInfo($i, $datetime, $author, $ip, $content, $title)
;WriteLog("i:"&$i&" $datetime:"&$datetime&" $author:"& $author&" $ip:"&$ip&" $title:"&$title&" $content:"&$content)

If $i = 0 Then

postTopic($content, $title, $forumId, $topicID, $postID)
;postTopic("test", "test",$forumId, $topicID, $postID)
Else
;http://127.0.0.1/phpbb/posting.php?mode ... 8c77e0f293
postPost($content, $title, $topicID, $postID)
EndIf
;Sleep(1000)
changePostInfo($datetime, $author, $ip, $postID, $forumId)
WriteLog("")

Next

If ($nextTopicURL) Then
$currentTopicURL = $nextTopicURL
Else
ExitLoop
EndIf
WriteLog("")
WEnd


Func getLinkByText(ByRef $oObject, $sMyString, ByRef $url)

Local $oLinks = _IELinkGetCollection($oObject)
For $oLink In $oLinks
Local $sLinkText = _IEPropertyGet($oLink, "innerText")

If $sLinkText == $sMyString Then
$url = $oLink.href
ExitLoop
EndIf
Next
EndFunc ;==>getLinkByText

Func phpbbLogin(ByRef $sessionid)
WriteLog("phpbbLogin0")
$url = "http://127.0.0.1/phpbb/ucp.php?mode=login"
getLinkByText($oIEphpbb, "Login", $url)
_IENavigate($oIEphpbb, $url)
waiLoding($oIEphpbb)


$un = _IEGetObjById($oIEphpbb, "username")
$un.value = "admin"

$un = _IEGetObjById($oIEphpbb, "password")
$un.value = "jtf123456"

Local $oForm = _IEFormGetObjByName($oIEphpbb, "login")
_IEFormElementCheckBoxSelect($oForm, 0, "", 1, "byIndex")

Local $oSubmit = _IEGetObjByName($oIEphpbb, "login", 1)
_IEAction($oSubmit, "click")
;Sleep(2000)
waiLoding($oIEphpbb)
;Sleep(1000)


$url = _IEPropertyGet($oIEphpbb, "locationurl")
$urls = StringSplit($url, '=')
$sessionid = $urls[$urls[0]]

WriteLog("phpbbLogin1")

EndFunc ;==>phpbbLogin

Func changePostInfo($datetime, $author, $ip, $postID, $forumId)
;http://127.0.0.1/phpbb/mcp.php?i=main&m ... 8c77e0f293
WriteLog("")
$url = "http://127.0.0.1/phpbb/mcp.php?i=main&m ... details&f=" & $forumId & "&p=" & $postID & "&sid=" & $sessionid
_IENavigate($oIEphpbb, $url)
waiLoding($oIEphpbb)
$un = _IEGetObjById($oIEphpbb, "username")
$un.value = $author
waiLoding($oIEphpbb)
Local $oForm = _IEFormGetObjByName($oIEphpbb, "mcp_chgposter")

Local $oSubmit = _IEGetObjByName($oIEphpbb, "action[chgposter]")
_IEAction($oSubmit, "click")
;Sleep(2000)
waiLoding($oIEphpbb)
;Sleep(1000)

$html = _IEDocReadHTML($oIEphpbb)
$posLeft = StringInStr($html, "Posted by")
$posRight = StringInStr($html, "Change poster")

If $posLeft And $posRight Then
$html = StringMid($html, $posLeft, $posRight - $posLeft)
$pos = StringInStr($html, "u=2")
If ($pos <> 0) Then
MsgBox(0, "", "cannot change auther")
Exit
EndIf
Else
MsgBox(0, "", "cannot change auther")
Exit
EndIf

$iDateCalc = _DateDiff('s', "1970/01/01 00:00:00", $datetime)

$jxdatetime = _IEGetObjById($oIEphpbb, "jx_datetime")
$orgDateTime = $jxdatetime.value
$jxdatetime.value = ($iDateCalc-28800)

$jxip = _IEGetObjById($oIEphpbb, "jx_ip")
$jxip.value = $ip
waiLoding($oIEphpbb)

Local $oForm = _IEFormGetObjByName($oIEphpbb, "mcp_chgposttime")

Local $oSubmit = _IEGetObjByName($oIEphpbb, "action[chgposttime]")
_IEAction($oSubmit, "click")
;Sleep(2000)
waiLoding($oIEphpbb)
;Sleep(1000)

If ($jxdatetime.value == $orgDateTime) Then
MsgBox(0, "", "cannot change time")
Exit
EndIf

If ($jxip.value = "127.0.0.1") Then
MsgBox(0, "", "cannot change time")
Exit
EndIf

WriteLog("")

EndFunc ;==>changePostInfo

Func postTopic($content, $title, $forumId, ByRef $topicID, ByRef $postID)
WriteLog("")
$url = "http://127.0.0.1/phpbb/posting.php?mode=post&f=" & $forumId & "&sid=" & $sessionid
_IENavigate($oIEphpbb, $url)
waiLoding($oIEphpbb)
$un = _IEGetObjById($oIEphpbb, "subject")
$un.value = $title

$un = _IEGetObjById($oIEphpbb, "message")
$un.innertext = $content

Local $oForm = _IEFormGetObjByName($oIEphpbb, "postform")

Local $oSubmit = _IEGetObjByName($oIEphpbb, "post")
_IEAction($oSubmit, "click")
;Sleep(2000)
waiLoding($oIEphpbb)
;Sleep(1000)

getTopicId($topicID)
getPostId($postID)

WriteLog("")

EndFunc ;==>postTopic

Func getTopicId(ByRef $topicID)
$url = _IEPropertyGet($oIEphpbb, "locationurl")
$topicID = getNumberFromURL($url, "t=")
EndFunc ;==>getTopicId


Func getNumberFromURL($url, $spliter)

$leftpos = StringInStr($url, $spliter)
$rightpos = StringInStr($url, "&sid")
$msg = StringMid($url, $leftpos, $rightpos - $leftpos)

$msgs = StringSplit($msg, "=")
Return $msgs[$msgs[0]]
EndFunc ;==>getNumberFromURL

Func getPostId(ByRef $postID)
$maxPostNum = -1
Local $oLinks = _IELinkGetCollection($oIEphpbb)
For $oLink In $oLinks
If StringInStr($oLink.href, "p=") Then
$postNum = getNumberFromURL($oLink.href, "p=")
If $postNum > $maxPostNum Then
$maxPostNum = $postNum
EndIf
EndIf
Next
If $maxPostNum > 0 Then
$postID = $maxPostNum
EndIf
EndFunc ;==>getPostId

Func postPost($content, $title, $topicID, ByRef $postID)
WriteLog("")
$url = "http://127.0.0.1/phpbb/posting.php?mode=reply&f=" & $forumId & "&t=" & $topicID & "&sid=" & $sessionid

_IENavigate($oIEphpbb, $url)
waiLoding($oIEphpbb)
If $title <> "" Then
$un = _IEGetObjById($oIEphpbb, "subject")
$un.value = $title
EndIf

$un = _IEGetObjById($oIEphpbb, "message")
$un.innertext = $content

Local $oForm = _IEFormGetObjByName($oIEphpbb, "postform")

Local $oSubmit = _IEGetObjByName($oIEphpbb, "post")
_IEAction($oSubmit, "click")
;Sleep(2000)
waiLoding($oIEphpbb)
;Sleep(1000)
getPostId($postID)

WriteLog("")

EndFunc ;==>postPost

Func findTopicInfo($currentTopicURL, ByRef $postNumber, ByRef $nextTopicURL)
WriteLog("0findTopicInfo")
_IENavigate($oIEbbsxp, $currentTopicURL)
waiLoding($oIEbbsxp)


$button = _IEGetObjById($oIEbbsxp, "PostNumber")
$postNumber = $button.value

Local $oForm = _IEFormGetObjByName($oIEbbsxp, "PostNumber")
Local $oQuery = _IEFormElementGetObjByName($oForm, "q")

getLinkByText($oIEbbsxp, "上一篇", $nextTopicURL)

WriteLog("1findTopicInfo")
EndFunc ;==>findTopicInfo

Func findPostInfo($num, ByRef $datetime, ByRef $author, ByRef $ip, ByRef $content, ByRef $title)
WriteLog("")

$temp = _IEGetObjById($oIEbbsxp, "PostDate" & $num)
$datetime = $temp.value

$temp = _IEGetObjById($oIEbbsxp, "PostIP" & $num)
$ip = $temp.value

$temp = _IEGetObjById($oIEbbsxp, "UserName" & $num)
$author = $temp.value

$temp = _IEGetObjById($oIEbbsxp, "TestCode" & $num)
$content = $temp.innertext

$temp = _IEGetObjById($oIEbbsxp, "Subject" & $num)
$title = $temp.value

WriteLog("")
EndFunc ;==>findPostInfo

Func waiLoding(ByRef $obj)
Sleep(50)
_IELoadWait($obj)
Sleep(50)
_IELoadWait($obj)
Sleep(50)
_IELoadWait($obj)
Sleep(50)
_IELoadWait($obj)
Sleep(50)
_IELoadWait($obj)
Sleep(50)
_IELoadWait($obj)
Sleep(50)
EndFunc ;==>waiLoding



Func WriteLog($String)
Local Const $sFilePath = "log.txt"
Local $hFileOpen = FileOpen($sFilePath, $FO_APPEND)
FileWrite($hFileOpen, _Now() & ":" & $String & @CRLF)
FileClose($hFileOpen)
EndFunc ;==>WriteLog

jiataifeng
Posts: 178
Joined: 30 Apr 2009 06:31

Re: bbsxp to phpbb

Post by jiataifeng » 12 Aug 2018 23:35

后来发现可以利用多线程来处理并加快速度


v2
老网站
1. 找到主题帖子,也就是topic帖子:发布时间,作者,ip,内容,无有跟贴,下一篇等信息
2.
3. 如果有后续跟贴,做好记录,以备使用(判断标准,)

新网站
4. 判断是否登录,如果没有登录,登录,找到session id.
5. add topic, 发帖。
6. 修改作者,发表时间,及IP
7,根据记录,发表后续跟贴,并修改作者,发表时间,及IP
8,重复处理所有跟贴
9,重复处理所有主题
10,做好log,以便出现问题可以跟踪


改进:没有考虑多线程问题.
每个线程仅处理一个动作,尤其是对于那些比较耗时的线程,更应该简化功能.


utility.au3


Func getLinkByText(ByRef $oObject, $sMyString, ByRef $url)

Local $oLinks = _IELinkGetCollection($oObject)
For $oLink In $oLinks
Local $sLinkText = _IEPropertyGet($oLink, "innerText")

If $sLinkText == $sMyString Then
$url = $oLink.href
ExitLoop
EndIf
Next
EndFunc ;==>getLinkByText


Func phpbbLogin(ByRef $oIEphpbb, ByRef $sessionid)
WriteLog("phpbbLogin0")
$url = "http://127.0.0.1/phpbb/ucp.php?mode=login"
getLinkByText($oIEphpbb, "Login", $url)
_IENavigate($oIEphpbb, $url)
waiLoding($oIEphpbb)


$un = _IEGetObjById($oIEphpbb, "username")
$un.value = "admin"

$un = _IEGetObjById($oIEphpbb, "password")
$un.value = "jtf123456"

Local $oForm = _IEFormGetObjByName($oIEphpbb, "login")
_IEFormElementCheckBoxSelect($oForm, 0, "", 1, "byIndex")

Local $oSubmit = _IEGetObjByName($oIEphpbb, "login", 1)
_IEAction($oSubmit, "click")
;Sleep(2000)
waiLoding($oIEphpbb)
;Sleep(1000)


$url = _IEPropertyGet($oIEphpbb, "locationurl")
$urls = StringSplit($url, '=')
$sessionid = $urls[$urls[0]]

WriteLog("phpbbLogin1")

EndFunc ;==>phpbbLogin

Func WriteLog($String)
Local Const $sFilePath = "log.txt"
Local $hFileOpen = FileOpen($sFilePath, $FO_APPEND)
FileWrite($hFileOpen, _Now() & ":" & $String & @CRLF)
FileClose($hFileOpen)
EndFunc ;==>WriteLog

Func waiLoding(ByRef $obj)
Sleep(50)
_IELoadWait($obj)
Sleep(50)
_IELoadWait($obj)
Sleep(50)
_IELoadWait($obj)
Sleep(50)
_IELoadWait($obj)
Sleep(50)
_IELoadWait($obj)
Sleep(50)
_IELoadWait($obj)
Sleep(50)
EndFunc ;==>waiLoding




poster.au3


#include <IE.au3>

#include <Date.au3>
#include "utility.au3"


Dim $sessionid = ""
$oIEphpbb = _IECreate("http://127.0.0.1/phpbb")

phpbbLogin($oIEphpbb,$sessionid)

runInfo()

Func runInfo()
; Assign a Local variable the search handle of all files in the current directory.
$hSearch = FileFindFirstFile(@ScriptDir & "\data\poster\*.ini")

; Assign a Local variable the empty string which will contain the files names found.
Local $sFileName = "", $iResult = 0

While 1
$sFileName = FileFindNextFile($hSearch)
; If there is no more file matching the search.
If @error Then
Sleep(100)
$hSearch = FileFindFirstFile(@ScriptDir & "\data\poster\*.ini")
Else
$author=IniRead(@ScriptDir & "\data\poster\"&$sFileName,"data","author","")
$forumId = IniRead(@ScriptDir & "\data\poster\"&$sFileName,"data","forumId",0)
$postID=IniRead(@ScriptDir & "\data\poster\"&$sFileName,"data","postID",0)
changePostInfo($author,$postID,$forumId)
FileDelete(@ScriptDir & "\data\poster\"&$sFileName)
EndIf

WEnd

FileClose($hSearch)
EndFunc ;==>Example

Func changePostInfo($author, $postID, $forumId)
;http://127.0.0.1/phpbb/mcp.php?i=main&m ... 8c77e0f293
WriteLog("")
$url = "http://127.0.0.1/phpbb/mcp.php?i=main&m ... details&f=" & $forumId & "&p=" & $postID & "&sid=" & $sessionid
_IENavigate($oIEphpbb, $url)
waiLoding($oIEphpbb)
$un = _IEGetObjById($oIEphpbb, "username")
$un.value = $author
waiLoding($oIEphpbb)
Local $oForm = _IEFormGetObjByName($oIEphpbb, "mcp_chgposter")

Local $oSubmit = _IEGetObjByName($oIEphpbb, "action[chgposter]")
_IEAction($oSubmit, "click")
;Sleep(2000)
waiLoding($oIEphpbb)
;Sleep(1000)

$html = _IEDocReadHTML($oIEphpbb)
$posLeft = StringInStr($html, "Posted by")
$posRight = StringInStr($html, "Change poster")

If $posLeft And $posRight Then
$html = StringMid($html, $posLeft, $posRight - $posLeft)
$pos = StringInStr($html, "u=2")
If ($pos <> 0) Then
MsgBox(0, "", "cannot change auther")
Exit
EndIf
Else
MsgBox(0, "", "cannot change auther")
Exit
EndIf

WriteLog("")

EndFunc ;==>changePostInfo






dateip.au3


#include <IE.au3>

#include <Date.au3>

#include "utility.au3"

Dim $sessionid = ""
$oIEphpbb = _IECreate("http://127.0.0.1/phpbb")

phpbbLogin($oIEphpbb,$sessionid)


runInfo()

Func runInfo()
; Assign a Local variable the search handle of all files in the current directory.
$hSearch = FileFindFirstFile(@ScriptDir & "\data\dateip\*.ini")

; Assign a Local variable the empty string which will contain the files names found.
Local $sFileName = "", $iResult = 0

While 1
$sFileName = FileFindNextFile($hSearch)
; If there is no more file matching the search.
If @error Then
Sleep(100)
$hSearch = FileFindFirstFile(@ScriptDir & "\data\dateip\*.ini")
Else
$date=IniRead(@ScriptDir & "\data\dateip\"&$sFileName,"data","date","")
$forumId = IniRead(@ScriptDir & "\data\dateip\"&$sFileName,"data","forumId",0)
$postID=IniRead(@ScriptDir & "\data\dateip\"&$sFileName,"data","postID",0)
$ip=IniRead(@ScriptDir & "\data\dateip\"&$sFileName,"data","ip",0)

changePostInfo($date,$ip,$postID,$forumId)
FileDelete(@ScriptDir & "\data\dateip\"&$sFileName)
EndIf

WEnd

FileClose($hSearch)
EndFunc ;==>Example

Func changePostInfo($datetime, $ip, $postID, $forumId)
;http://127.0.0.1/phpbb/mcp.php?i=main&m ... 8c77e0f293
WriteLog("")
$url = "http://127.0.0.1/phpbb/mcp.php?i=main&m ... details&f=" & $forumId & "&p=" & $postID & "&sid=" & $sessionid
_IENavigate($oIEphpbb, $url)
waiLoding($oIEphpbb)

$jxdatetime = _IEGetObjById($oIEphpbb, "jx_datetime")
$orgDateTime = $jxdatetime.value
$jxdatetime.value = $datetime

$jxip = _IEGetObjById($oIEphpbb, "jx_ip")
$jxip.value = $ip
waiLoding($oIEphpbb)

Local $oForm = _IEFormGetObjByName($oIEphpbb, "mcp_chgposttime")

Local $oSubmit = _IEGetObjByName($oIEphpbb, "action[chgposttime]")
_IEAction($oSubmit, "click")
;Sleep(2000)
waiLoding($oIEphpbb)
;Sleep(1000)

If ($jxdatetime.value == $orgDateTime) Then
MsgBox(0, "", "cannot change time")
Exit
EndIf

If ($jxip.value = "127.0.0.1") Then
MsgBox(0, "", "cannot change time")
Exit
EndIf

WriteLog("")

EndFunc ;==>changePostInfo


websitetransfer.au3


#include <IE.au3>
#include <Date.au3>
#include "utility.au3"

Sleep(5000)
Dim $currentTopicURL = "http://127.0.0.1:8080/ShowPost.asp?menu ... eadID=2244"
$oIEbbsxp = _IECreate($currentTopicURL)

Dim $forumId = 5
Dim $sessionid = ""
$oIEphpbb = _IECreate("http://127.0.0.1/phpbb")

phpbbLogin($oIEphpbb,$sessionid)


While 1

Dim $nextTopicURL, $postNumber, $topicID = 0
findTopicInfo($currentTopicURL, $postNumber, $nextTopicURL)
WriteLog("$postNumber:" & $postNumber & " $nextTopicURL:" & $nextTopicURL)

For $i = 0 To $postNumber
WriteLog("i:" & $i)

Dim $datetime, $author, $ip, $content, $title, $postID = 0
findPostInfo($i, $datetime, $author, $ip, $content, $title)
;WriteLog("i:"&$i&" $datetime:"&$datetime&" $author:"& $author&" $ip:"&$ip&" $title:"&$title&" $content:"&$content)

If $i = 0 Then

postTopic($content, $title, $forumId, $topicID, $postID)
;postTopic("test", "test",$forumId, $topicID, $postID)
Else
;http://127.0.0.1/phpbb/posting.php?mode ... 8c77e0f293
postPost($content, $title, $topicID, $postID)
EndIf
;Sleep(1000)
$iDateCalc = _DateDiff('s', "1970/01/01 00:00:00", $datetime) - 28800
FileWriteto($iDateCalc, $author, $ip, $postID, $forumId)
WriteLog("")
Next

If ($nextTopicURL) Then
$currentTopicURL = $nextTopicURL
Else
ExitLoop
EndIf
WriteLog("")
WEnd

Func FileWriteto($iDateCalc, $author, $ip, $postID, $forumId)
IniWrite(@ScriptDir & "\data\poster\"&$postID&".ini","data","author",$author)
IniWrite(@ScriptDir & "\data\poster\"&$postID&".ini","data","forumId",$forumId)
IniWrite(@ScriptDir & "\data\poster\"&$postID&".ini","data","postID",$postID)

IniWrite(@ScriptDir & "\data\dateip\"&$postID&".ini","data","date",$iDateCalc)
IniWrite(@ScriptDir & "\data\dateip\"&$postID&".ini","data","ip",$ip)
IniWrite(@ScriptDir & "\data\dateip\"&$postID&".ini","data","forumId",$forumId)
IniWrite(@ScriptDir & "\data\dateip\"&$postID&".ini","data","postID",$postID)
EndFunc

Func postTopic($content, $title, $forumId, ByRef $topicID, ByRef $postID)
WriteLog("")
$url = "http://127.0.0.1/phpbb/posting.php?mode=post&f=" & $forumId & "&sid=" & $sessionid
_IENavigate($oIEphpbb, $url)
waiLoding($oIEphpbb)
$un = _IEGetObjById($oIEphpbb, "subject")
$un.value = $title

$un = _IEGetObjById($oIEphpbb, "message")
$un.innertext = $content

Local $oForm = _IEFormGetObjByName($oIEphpbb, "postform")

Local $oSubmit = _IEGetObjByName($oIEphpbb, "post")
_IEAction($oSubmit, "click")
;Sleep(2000)
waiLoding($oIEphpbb)
;Sleep(1000)

getTopicId($topicID)
getPostId($postID)

WriteLog("")

EndFunc ;==>postTopic

Func getTopicId(ByRef $topicID)
$url = _IEPropertyGet($oIEphpbb, "locationurl")
$topicID = getNumberFromURL($url, "t=")
EndFunc ;==>getTopicId


Func getNumberFromURL($url, $spliter)

$leftpos = StringInStr($url, $spliter)
$rightpos = StringInStr($url, "&sid")
$msg = StringMid($url, $leftpos, $rightpos - $leftpos)

$msgs = StringSplit($msg, "=")
Return $msgs[$msgs[0]]
EndFunc ;==>getNumberFromURL

Func getPostId(ByRef $postID)
$maxPostNum = -1
Local $oLinks = _IELinkGetCollection($oIEphpbb)
For $oLink In $oLinks
If StringInStr($oLink.href, "p=") Then
$postNum = getNumberFromURL($oLink.href, "p=")
If $postNum > $maxPostNum Then
$maxPostNum = $postNum
EndIf
EndIf
Next
If $maxPostNum > 0 Then
$postID = $maxPostNum
EndIf
EndFunc ;==>getPostId

Func postPost($content, $title, $topicID, ByRef $postID)
WriteLog("")
$url = "http://127.0.0.1/phpbb/posting.php?mode=reply&f=" & $forumId & "&t=" & $topicID & "&sid=" & $sessionid

_IENavigate($oIEphpbb, $url)
waiLoding($oIEphpbb)
If $title <> "" Then
$un = _IEGetObjById($oIEphpbb, "subject")
$un.value = $title
EndIf

$un = _IEGetObjById($oIEphpbb, "message")
$un.innertext = $content

Local $oForm = _IEFormGetObjByName($oIEphpbb, "postform")

Local $oSubmit = _IEGetObjByName($oIEphpbb, "post")
_IEAction($oSubmit, "click")
;Sleep(2000)
waiLoding($oIEphpbb)
;Sleep(1000)
getPostId($postID)

WriteLog("")

EndFunc ;==>postPost

Func findTopicInfo($currentTopicURL, ByRef $postNumber, ByRef $nextTopicURL)
WriteLog("0findTopicInfo")
_IENavigate($oIEbbsxp, $currentTopicURL)
waiLoding($oIEbbsxp)


$button = _IEGetObjById($oIEbbsxp, "PostNumber")
$postNumber = $button.value

Local $oForm = _IEFormGetObjByName($oIEbbsxp, "PostNumber")
Local $oQuery = _IEFormElementGetObjByName($oForm, "q")

getLinkByText($oIEbbsxp, "上一篇", $nextTopicURL)

WriteLog("1findTopicInfo")
EndFunc ;==>findTopicInfo

Func findPostInfo($num, ByRef $datetime, ByRef $author, ByRef $ip, ByRef $content, ByRef $title)
WriteLog("")

$temp = _IEGetObjById($oIEbbsxp, "PostDate" & $num)
$datetime = $temp.value

$temp = _IEGetObjById($oIEbbsxp, "PostIP" & $num)
$ip = $temp.value

$temp = _IEGetObjById($oIEbbsxp, "UserName" & $num)
$author = $temp.value

$temp = _IEGetObjById($oIEbbsxp, "TestCode" & $num)
$content = $temp.innertext

$temp = _IEGetObjById($oIEbbsxp, "Subject" & $num)
$title = $temp.value

WriteLog("")
EndFunc ;==>findPostInfo
Last edited by jiataifeng on 13 Aug 2018 02:44, edited 1 time in total.

jiataifeng
Posts: 178
Joined: 30 Apr 2009 06:31

Re: bbsxp to phpbb

Post by jiataifeng » 12 Aug 2018 23:38

最后说明一点,修改帖子信息是借助了phpbb的扩展\ext\javiexin\chgposttime,但是他的时间是年月日时分秒,而不是1970开始算起的秒。我自己稍微修改了一下这个extension,使得可以直接输入秒的数据库格式,同时加上了对IP的修改。

如果采取多线程,8000左右的帖子半天就搞定了。

Post Reply