又经过两天仔细研究LeadBBS的数据库,终于发现其LeadBBS_Announce表中在最有有一个rootidbak的域记录主题的id,因此修改转换程序。
ld314acc-dz550.php原程序如下:
} elseif ($step == 5) { //帖子
if($start <= 1 && $tableid == 0) {
mysql_query("TRUNCATE TABLE {$dz_tblpre}posts") or dexit("清空帖子表错误".mysqlerror());
$sql = "SELECT MIN(ID) AS minid, MAX(ID) AS maxid FROM {$ld_tblpre}Announce";
$rs = $dbc->execute($sql);
if (!$rs->EOF) {
$start = $rs->fields[minid]->value;
$maxid = $rs->fields[maxid]->value;
}
$rs->close();
$start = $start > 1 ? $start : 1;
$end = $start + $rpp - 1;
}
$sql = "SELECT * FROM {$ld_tblpre}Announce WHERE (ID BETWEEN $start AND $end)";
$rs = $dbc->execute($sql);
$fieldarray = array('id', 'boardid', 'parentid', 'username', 'userid', 'ndatetime', 'lasttime', 'title', 'printcontent', 'visitip', 'lastuser', 'hits', 'childnum', 'goodflag');
while(!$rs->EOF) {
foreach($fieldarray AS $field) {
$post[$field] = $rs->fields[$field]->value;
}
$post = daddslashes($post);
$fid = $post['boardid'];
$tid = $post['parentid'] == 0 ? $post['id'] : $post['parentid'];
$first = $post['parentid'] == 0 ? 1 : 0;
$author = cutstr(htmlspecialchars(trim($post['username'])),15);
$authorid = $post['userid'];
$subject = $post['title'] ? cutstr(htmlspecialchars(trim(@strip_tags($post['title']))),78) : '';
$dateline = sqltimetounix($post['ndatetime']);
$message = str_replace("../images/", 'leadbbsfile/', preg_replace("/\ \;\s*/", '',$post['printcontent']));
$message = str_replace("./images/", 'leadbbsfile/', preg_replace("/\ \;\s*/", '',$message));
$message = str_replace("/images/", 'leadbbsfile/', preg_replace("/\ \;\s*/", '',$message));
$useip = $post['visitip'];
$invisible = 0;
$usesig = 1;
$htmlon = 1;
$bbcodeoff = '1';
$smileyoff = '1';
$parseurloff = '1';
$attachment = '0';
$rate = '0';
$ratetimes = '0';
$query1 = "INSERT INTO `{$dz_tblpre}posts` ( `fid` , `tid` , `first` , `author` , `authorid` , `subject` , `dateline` , `message` , `useip` , `invisible` , `usesig` , `htmlon` , `bbcodeoff` , `smileyoff` , `parseurloff` , `attachment` , `rate` , `ratetimes` ) VALUES ('$fid','$tid','$first','$author','$authorid','$subject','$dateline','$message','$useip','$invisible','$usesig','$htmlon','$bbcodeoff','$smileyoff','$parseurloff','$attachment','$rate','$ratetimes');";
if (mysql_query($query1)) {
$convertedrows ++;
} else {
reportlog("无法转换帖子 pid = $pid subject = '$subject',SQL 语句如下 :<br><textarea rows=\"3\" style=\"width: 100%;\">".$query1."</textarea>".mysqlerror());
}
$converted = 1;
$totalrows ++;
$rs->movenext();
}
$rs->Close();
if($converted || $end < $maxid) {
continue_redirect("&maxid=$maxid");
} else {
report('帖子');
stay_redirect();
}
修改上面红子的两句为
$fieldarray = array('id', 'boardid', 'parentid', 'username', 'userid', 'ndatetime', 'lasttime', 'title', 'printcontent', 'visitip', 'lastuser', 'hits', 'childnum', 'goodflag', 'rootidbak');
$tid=$post['parentid'] == 0 ? $post['id'] : $post['rootidbak'];
大功告成 |