<?php
//升级管理员
truncatetable('common_admincp_member');

$str = '';
$query = $xc->db['source']->query("SELECT * FROM {$source_tablepre}admin") or dexit("检索数据表 '{$source_tablepre}admin' 错误！<br>请将数据表 '{$source_tablepre}admin' 字段类型为 nText 的改为 Text 类型。", 'mssql');

while($admin = $xc->db['source']->fetch_assoc($query)) {
	$admin	= array_change_key_case($admin);
	$admin	= daddslashes($admin);
	if($admin['flag'] == '1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45') {
		//加入后台管理团队
		$uid	=	$xc->db['discuz']->result($xc->db['discuz']->query("SELECT uid FROM {$discuz_tablepre}ucenter_members WHERE username='$admin[adduser]' LIMIT 1;"), 0);
		if($uid == '1'){	continue;	}
		$cpgroupid	= '0';
		$customperm	= '';
		$field1	=	array('uid','cpgroupid','customperm');
		$query1	=	getinsertsql("{$discuz_tablepre}common_admincp_member", $field1);

		if ($xc->db['discuz']->query($query1)) {
			if($xc->db['discuz']->query("UPDATE {$discuz_tablepre}common_member SET adminid='1', groupid='1' WHERE uid='$uid' LIMIT 1;")){
				$str .= $admin[adduser].'被升级为管理员<br>';
				$convertedrows ++;	
			} else {
				$xc->db['discuz']->query("DELETE {$discuz_tablepre}common_admincp_member SET adminid='1', groupid='1' WHERE uid='$uid' LIMIT 1");
			}
		} else {
			reportlog("升级管理员出错 uid=$uid");
		}
		$totalrows ++;
	}
}
?>