<?php
/*
记录回复：pre_home_docomment
*/
if($start <= 1){
	truncatetable('home_docomment');
}

$maxcid = $xc->db['source']->result($xc->db['source']->query("SELECT max(cid) FROM {$source_tablepre}weibo_comment"), 0);
if($start < $maxcid){
	$converted = 1;
}
$query = $xc->db['source']->query("SELECT * FROM {$source_tablepre}weibo_comment WHERE cid >= $start AND cid < $start + $rpp") or dexit();
while ($comment = $xc->db['source']->fetch_array($query)) {
	$comment	=	daddslashes($comment);

	$id			=	$comment['cid'];
	$upid		=	$comment['upid'];
	$doid		=	$comment['mid'];
	$uid		=	$comment['uid'];
	$username	=	getusername($uid);
	$dateline	=	$comment['postdate'];
	$message	=	formatstr(convertbbcode($comment['content']));
	$ip			=	'';
	$grade		=	$comment['upid'] == '0' ? 1 : 2;

	$field1		=	array('id','upid','doid','uid','username','dateline','message','ip','grade');
	$query1		=	getinsertsql("{$discuz_tablepre}home_docomment", $field1);

	if ($xc->db['discuz']->query($query1)) {
		$convertedrows ++;
	} else {
		reportlog("无法转换空间记录回复 id = $id ，SQL 语句如下 ：<br><textarea rows=\"3\" style=\"width: 100%;\">".$sql."</textarea>");
	}
	$converted = 1;
	$totalrows ++;
	$url = 'index.php?mod=dealdata&step='.$step.'&start='.($comment['cid']+1).'&stay='.$stay.'&totalrows='.$totalrows.'&convertedrows='.$convertedrows.'&sqlfilenum='.$sqlfilenum;
	file_put_contents(XCONVERT_ROOT.'./cache/lock/progress_'.$step.".txt", $url);
}
?>