<?php
/*
评分
pre_forum_ratelog
*/

if($start <= 1) {
	truncatetable('forum_ratelog');
}

$query = $xc->db['source']->query("SELECT * FROM {$source_tablepre}ratelog WHERE id>=$start AND id<=$end")
	or die("检索数据表 '{$source_tablepre}polloptions' 错误！请将表 '{$source_tablepre}polloptions' 字段类型为 nText 的改为 Text 类型。");

$maxid = $xc->db['source']->result(
	$xc->db['source']->query("SELECT MAX(id) AS MAXID FROM {$source_tablepre}ratelog"),
	0,
	'MAXID'
);

if($start < $maxid) {
	$converted = 1;
}

while($r = $xc->db['source']->fetch_array($query)) {
	$r		=	daddslashes($r);

	$pid		=	$r['pid'];
	$username	=	$r['username'];
	$extcredits	=	$r['extcredits'];
	$dateline	=	timetounix($r['postdatetime']);
	$score		=	$r['score'];
	$reason		=	$r['reason'];

	$field1		=	array('pid', 'username', 'extcredits', 'dateline', 'score', 'reason');
	$query1		=	getinsertsql("{$discuz_tablepre}forum_ratelog", $field1);

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