<?php
/*
相册：pre_home_album
*/
if($start <= 1) truncatetable('home_album');

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

	$albumid	=	$pwalbum['aid'];
	$albumname	=	$pwalbum['aname'];
	$catid		=	'';
	$uid		=	$pwalbum['ownerid'];
	$username	=	$pwalbum['owner'];
	$dateline	=	$pwalbum['crtime'];
	$updatetime	=	$pwalbum['lasttime'];
	$picnum		=	$pwalbum['photonum'];
	$pic		=	$pwalbum['lastphoto'];
	$picflag	=	$pwalbum > 0 ? 1 : 0;
	switch($pwalbum['memopen']) {
		case '0':$firend = 0; break;
		case '1':$friend = 1; break;
		case '2':$friend = 3; break;
		case '3':$friend = 4; break;
	}

	$password	=	'';
	$target_ids	=	'';

	$field1 = array('albumid','albumname','catid','uid','username','dateline','updatetime','picnum','pic','picflag','friend','password','target_ids');
	$query1 = getinsertsql("{$discuz_tablepre}home_album", $field1);
	
	if ($xc->db['discuz']->query($query1)) {
		$convertedrows ++;
	} else {
		reportlog("无法转换相册 id = $albumid ，SQL 语句如下 ：<br><textarea rows=\"3\" style=\"width: 100%;\">".$query1."</textarea>");
	}
	$converted = 1;
	$totalrows ++;
}
?>
