<?php
/*
pre_common_friendlink
*/

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

$query = "SELECT * FROM {$source_tablepre}bbslink WHERE (id BETWEEN $start AND $end)";
$rs = $xc->db['source']->execute($query);

$fieldarray = array('boardname', 'readme', 'url', 'logo');
while (!$rs->EOF) {
	foreach($fieldarray AS $field) {
		$dvl[$field] = daddslashes($rs->fields[$field]->value);
	}

	//$id = 0;
	$displayorder = 0;
	$name = cutstr(@strip_tags(trim($dvl['boardname'])), 100);
	$url = cutstr(@strip_tags(trim($dvl['url'])), 100);
	$description = cutstr(@strip_tags(trim($forumlink['readme'])), 200);
	$logo = cutstr(@strip_tags(trim($dvl['logo'])), 100);
	$type = 2;

	$field1	= array('displayorder','name','url','description','logo','type');
	$query1	= getinsertsql("{$discuz_tablepre}common_friendlink", $field1);

	if ($xc->db['discuz']->query($query1)) {
		$convertedrows ++;
	} else {
		reportlog("转换联盟论坛出错 url = $url");
	}

	$converted = 1;
	$totalrows ++;
	$rs->Movenext();
	$url = 'index.php?mod=dealdata&step='.$step.'&start='.($dvl['id']+1).'&stay='.$stay.'&totalrows='.$totalrows.'&convertedrows='.$convertedrows.'&sqlfilenum='.$sqlfilenum;
	file_put_contents(XCONVERT_ROOT.'./cache/lock/progress_'.$step.".txt", $url);
}
$rs->close();
?>