<?php
/*
微博单补统计
统计用户广播数
*/

$maxuid = $xc->db['discuz']->result($xc->db['discuz']->query("SELECT max(uid) FROM {$discuz_tablepre}".($xc->config['db']['discuz_type'] == 'x' ? "common_member": "members")), 0);

if($start < $maxmid) {
	$converted = 1;
}
$m_fid = $xc->db['discuz']->result($xc->db['discuz']->query("SELECT fid FROM {$discuz_tablepre}forum_forum where name = '广播专版'"), 0);
$queryt = $xc->db['discuz']->query("SELECT uid FROM {$discuz_tablepre}common_member WHERE uid >= $start AND uid < $start + $rpp");
while($mem = $xc->db['discuz']->fetch_array($queryt)) {
	$feedcount = $xc->db['discuz']->result($xc->db['discuz']->query("SELECT COUNT(*) FROM {$discuz_tablepre}forum_thread WHERE authorid='$mem[uid]' AND fid ='$m_fid'"), 0);

	$xc->db['discuz']->query("UPDATE {$discuz_tablepre}common_member_count SET feeds='$feedcount' WHERE uid='$mem[uid]'");

	$follower = $xc->db['discuz']->result($xc->db['discuz']->query("SELECT COUNT(*) FROM {$discuz_tablepre}home_follow WHERE followuid='$mem[uid]'"), 0);
	$following = $xc->db['discuz']->result($xc->db['discuz']->query("SELECT COUNT(*) FROM {$discuz_tablepre}home_follow WHERE uid='$mem[uid]'"), 0);

	$xc->db['discuz']->query("UPDATE {$discuz_tablepre}common_member_count SET follower='$follower', following='$following' WHERE uid='$mem[uid]'");

	$converted = 1;
	$totalrows ++;
	$url = 'index.php?mod=dealdata&step='.$step.'&start='.($mem['uid']+1).'&stay='.$stay.'&totalrows='.$totalrows.'&convertedrows='.$convertedrows.'&sqlfilenum='.$sqlfilenum;
	file_put_contents(XCONVERT_ROOT.'./cache/lock/progress_'.$step.".txt", $url);
}

?>