<?php
/*
活动成员表：pre_forum_activityapply
*/
if($start <= 1){
	truncatetable('forum_activityapply');
}

$maxcount = $xc->db['source']->result($xc->db['source']->query("SELECT count(actuid) FROM {$source_tablepre}activitymembers"), 0);

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

$query = $xc->db['source']->query("SELECT * FROM {$source_tablepre}activitymembers WHERE actuid >= $start AND  actuid < $start + $rpp") or dexit();
while ($pwpcmember =	$xc->db['source']->fetch_array($query)) {
	$pwpcmember	=	daddslashes($pwpcmember);

	//pre_forum_activityapply
	$applyid	=	$pwpcmember['actmid'];
	$tid		=	$pwpcmember['tid'];
	$username	=	$pwpcmember['username'];
	$uid		=	$pwpcmember['uid'];
	$message	=	$pwpcmember['message'];
	$verified	=	1;
	$dateline	=	$pwpcmember['signuptime'];
	$payment	=	-1;
	$ufielddata	=	$pwpcmember['mobile'] ? serialize(array('userfield' => array('mobile' => $pwpcmember['mobile']))) : '';

	$field1	=	array('applyid','tid','username','uid','message','verified','dateline','payment','ufielddata');
	$query1	=	getinsertsql("{$discuz_tablepre}forum_activityapply", $field1);

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