看不懂下面这段……不知道是不是没取到Dv_bbs1数据表的名字?
elseif($step == 5) { //帖子
$dv_posttbl = isset($_GET['dv_posttbl']) ? $_GET['dv_posttbl'] : '';
if($tableid == 1) {
$rsSchema = $dbc->openSchema(20);
$dv_posttbl = $comma = '';
while(!$rsSchema->EOF) {
if($rsSchema->fields[TABLE_TYPE]->value == 'TABLE') {
$tablename = strtolower($rsSchema->fields[TABLE_NAME]->value);
if(in_array($tablename, array($source_tablepre.'bbs', $source_tablepre.'bbs1', $source_tablepre.'bbs2', $source_tablepre.'bbs3', $source_tablepre.'bbs4', $source_tablepre.'bbs5', $source_tablepre.'bbs6', $source_tablepre.'bbs7', $source_tablepre.'bbs8', $source_tablepre.'bbs9'))) {
$dv_posttbl .= $comma.$tablename;
$comma = ',';
}
}
$rsSchema->movenext();
}
$rsSchema->close();
}
$tablearray = explode(',', $dv_posttbl);
$tablecount = count($tablearray);
$key = $tableid - 1;
$posttable = $tablearray[$key];
if($start <= 1 && $tableid == 1) {
truncatetable('posts');
validid('announceid', $tablearray[0], '');
}
$sql = "SELECT * FROM $posttable WHERE (announceid BETWEEN $start AND $end)";
$rs = $dbc->execute($sql);
$fieldarray = array('announceid', 'parentid', 'boardid', 'username', 'postuserid', 'topic', 'body', 'dateandtime', 'rootid', 'ip', 'isupload');
while (!$rs->EOF) {
foreach($fieldarray AS $field) {
$p[$field] = daddslashes($rs->fields[$field]->value);
}
$tid = $p['rootid'];
$fid = $p['boardid'];
$first = $p['parentid'] == 0 ? 1 : 0;
$subject = cutstr(@strip_tags(trim($p['topic'])), 78);
$author = $p['username'];
$authorid = $p['postuserid'];
$dateline = accesstimetounix($p['dateandtime']);
$message = convertbbcode($p['body']);
$useip = $p['ip'];
$attachment = $p['isupload'];
$usesig = 1;
$bbcodeoff = 0;
$smileyoff = 0;
$parseurloff = 0;
$htmlon = @strip_tags($message) == $message ? 0 : 1;
$rate = 0;
$ratetimes = 0;
$sql = "INSERT INTO {$discuz_tablepre}posts (fid, tid, first, author, authorid, subject, dateline, message, useip, attachment, usesig, bbcodeoff, smileyoff, parseurloff, htmlon, rate, ratetimes) ".
"VALUES ('$fid', '$tid', '$first', '$author', '$authorid', '$subject', '$dateline', '$message', '$useip', '$attachment','$usesig', '$bbcodeoff', '$smileyoff', '$parseurloff', '$htmlon', '$rate', '$ratetimes')";
if(mysqlquery($sql)){
$pid = mysql_insert_id();
mysqlquery("UPDATE {$discuz_tablepre}attachments set pid='$pid' WHERE tid='$tid' AND pid='$p[announceid]'");
$convertedrows ++;
} else {
reportlog("无法转换帖子 subject = '$subject',SQL 语句如下 :<br><textarea rows=\"3\" style=\"width: 100%;\">".$sql."</textarea>");
}
$converted = 1;
$totalrows ++;
$rs->movenext();
}
$rs->Close();
if($converted || $end < $maxid) {
continue_redirect("&tableid=$tableid&dv_posttbl=$dv_posttbl");
} elseif($tableid < $tablecount) {
$sql = "SELECT MIN(announceid) AS minid, MAX(announceid) AS maxid FROM $tablearray[$key]";
$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 - 1;
echo "<hr><font color='red'>$tableid <= $tablecount</font><hr>";
continue_redirect("&tableid=".($tableid + 1)."&dv_posttbl=$dv_posttbl");
} else {
report('帖子');
stay_redirect();
} |