<?php

/*
'**************************************************************************************************
' 程序名称: CCTVAI开源音乐管理系统
' 官方网站: http://www.cctvai.com
' 联系 Q Q: 1542367792
' QQ交流群：136687984
' 版本：(终结版)
' 备注：未经书面授权，不得向任何第三方提供本软件系统！
' 功能，模板，插件，扩展，定制请联系QQ：1542367792
'**************************************************************************************************
*/
error_reporting(0);
include "../../include/cctvai.conn.php";
include "../function_common.php";
admincheck(4);
/*if(Smallfivesolution()==$_SERVER['SERVER_NAME']) {
} else {
	echo Smallfivesq();
	exit();
}*/
$action=SafeRequest("action", "get");
?>
<!DOCTYPE html>
<html>
 <head> 
  <meta charset="gbk" /> 
  <meta name="renderer" content="webkit" /> 
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /> 
  <title>后台管理中心</title> 
  <link href="../css/add.css" rel="stylesheet" /> 
  <style type="text/css">
.table2{width: 100%;max-width: 100%;border-collapse: collapse;border-spacing: 0;}
.table2 td{font-size: 12px;border-top: 1px solid #ddd;padding: 8px;vertical-align: top;}
.table2 tr:hover{text-decoration: none;background-color: #e6f2fb;}
.table2 th{border-bottom: 2px solid #ddd;vertical-align: bottom;padding: 2px;text-align: left;}
.table3{width: 100%;max-width: 100%;border-collapse: collapse;border-spacing: 0;}
.table3 tr:hover{text-decoration: none;background-color: #e6f2fb;}
.table3 td{font-size: 12px;line-height:25px;border-top: 1px solid #ddd;padding: 5px;vertical-align: top;border-right: solid 1px #ddd;}
.table3 th{border-bottom: 2px solid #ddd;vertical-align: bottom;padding: 2px;text-align: left;}
</style> 
  <script language="javascript">
function SelectAll() {
	for (var i = 0; i < document.myform.CD_ClassID.length; i++) {
		document.myform.CD_ClassID.options[i].selected = true;
	}
}
function UnSelectAll() {
	for (var i = 0; i < document.myform.CD_ClassID.length; i++) {
		document.myform.CD_ClassID.options[i].selected = false;
	}
}
function $(vId) {
	return document.all ? document.all[vId] : document.getElementById(vId);
}
function switchSupport(vTribe, vFlag) {
	vTribes = {
		'Modifylock' : '0',
		'Modifyskin' : '1',
		'ModifySex' : '2',
		'Modifyisbest' : '3',
		'Modifycheckmusic' : '4',
		'Modifygrade' : '5',
		'Modifyvipgrade' : '6',
		'Modifyviprank' : '7',
		'Modifyvipindate' : '8',
		'Modifyvipenddate' : '9',
		'Modifypoints' : '10',
		'Modifyhits' : '11',
		'Modifyrank' : '12',
		'ModifyDeleted' : '13'
		
		
	};
	
	for (var i = 0; i < 11; i++) {
		try {
			$('supportTribe' + vTribes[vTribe]).style.color = vFlag ? 'red' : '#000';
			$('supportTitle' + vTribes[vTribe]).style.color = vFlag ? 'black' : '#000';
		} catch (e) {}
		try {
			$('myform').elements['support[' + vTribe + '][soldier][' + i + ']'].disabled = vFlag ? false : true;
			$('myform').elements['support[' + vTribe + '][soldier][' + i + ']'].style.borderColor = vFlag ? '#F93' : '#CCC';
		} catch (e) {}
		try {
			$('myform').elements['support[' + vTribe + '][level][' + i + ']'].disabled = vFlag ? false : true;
		} catch (e) {}
	}
}

</script> 
 </head> 
 <body>
<?php
switch($action) {
	case 'edit':
		Edit();
		break;
	default:
		Main();
		break;
}
?>
</body>
</html>
<?php
Function Main() {
	global $db;
	$id=SafeRequest("id", "get");
?> 
  <div class="contents"> 
   <div class="panel"> 
    <div style="padding: 8px;"> 
     <a href="user.php" class="btn">所有会员</a> 
     <a href="?action=add" class="btn ">添加会员</a> 
     <a href="?action=users" class="btn ">普通会员</a> 
     <a href="?action=vips" class="btn ">VIP会员</a> 
     <a href="?action=userqq" class="btn ">QQ登录会员</a> 
     <a href="?action=isbest" class="btn ">推荐会员</a> 
     <a href="?action=checkmusic" class="btn ">音乐认证</a> 
     <a href="?action=checkmm" class="btn ">美女认证</a> 
     <a href="?action=vlock" class="btn ">锁定会员</a> 
    </div> 
   </div> 
  </div> 
  <div class="contents"> 
   <div class="panel"> 
    <div class="panel-head"> 
     <strong>若要批量修改某个属性的值，请先选中其左侧的复选框，然后再设定属性值。 </strong> 
    </div> 
    <form method="post" id="myform" name="myform" action="?action=edit"> 
     <table class="table3"> 
      <tbody> 
       <tr> 
        <td align="left"><input type='radio' id='BatchType1' name='BatchType' value='1' <?php if($id<>''){echo ' checked';}?>></td> 
        <td width="120" align="left"><label for="BatchType1">修改指定会员ID</label></td> 
        <td align="left"><input type="text" id="CD_ID" name="CD_ID" class="input input_hd length_6" value="<?php echo $id;?>"></td> 
       </tr> 
       <tr> 
        <td width="30" align="center"><input type="checkbox" name="Modifylock" value="Yes" id="support[Modifylock][is_able]" onClick="switchSupport('Modifylock', this.checked)" /></td> 
        <td width="100" align=" left" id="supportTribe0"><label for="support[Modifylock][is_able]">状态</label></td> 
        <td><select name="cd_lock" id="support[Modifylock][soldier][0]" disabled="" > <option value="0">正常会员</option> <option value="1">锁定会员</option> </select></td> 
       </tr> 
       <tr> 
        <td width="30" align="center"><input type="checkbox" name="Modifyskin" value="Yes" id="support[Modifyskin][is_able]" onClick="switchSupport('Modifyskin', this.checked)" /></td> 
        <td width="100" align=" left" id="supportTribe1"><label for="support[Modifyskin][is_able]">空间风格</label></td> 
        <td><select name="cd_skin" id="support[Modifyskin][soldier][0]" disabled="" ><option value="5" selected>落日余晖</option> <option value="4" >甜蜜生活</option> <option value="3" >炫彩风车</option> <option value="2" >独自旅行</option> <option value="1" >超脱元素</option> </select></td> 
       </tr> 
       <tr> 
        <td width="30" align="center"><input type="checkbox" name="ModifySex" value="Yes" id="support[ModifySex][is_able]" onClick="switchSupport('ModifySex', this.checked)" /></td> 
        <td width="100" align=" left" id="supportTribe2"><label for="support[ModifySex][is_able]">性别</label></td> 
        <td><select name="cd_sex" id="support[ModifySex][soldier][0]" disabled="" > <option value="帅哥">帅哥</option> <option value="美女">美女</option> </select></td> 
       </tr> 
       <tr> 
        <td width="30" align="center"><input type="checkbox" name="Modifyisbest" value="Yes" id="support[Modifyisbest][is_able]" onClick="switchSupport('Modifyisbest', this.checked)" /></td> 
        <td width="100" align=" left" id="supportTribe3"><label for="support[Modifyisbest][is_able]">推荐</label></td> 
        <td><select name="cd_isbest" id="support[Modifyisbest][soldier][0]" disabled="" > <option value="1">是</option> <option value="0">否</option> </select></td> 
       </tr> 
       <tr> 
        <td width="30" align="center"><input type="checkbox" name="Modifycheckmusic" value="Yes" id="support[Modifycheckmusic][is_able]" onClick="switchSupport('Modifycheckmusic', this.checked)" /></td> 
        <td width="100" align=" left" id="supportTribe4"><label for="support[Modifycheckmusic][is_able]">音乐认证</label></td> 
        <td><select name="cd_checkmusic" id="support[Modifycheckmusic][soldier][0]" disabled="" > <option value="1">是</option> <option value="0">否</option> </select></td> 
       </tr> 
       <tr> 
        <td width="30" align="center"><input type="checkbox" name="Modifygrade" value="Yes" id="support[Modifygrade][is_able]" onClick="switchSupport('Modifygrade', this.checked)" /></td> 
        <td width="100" align=" left" id="supportTribe5"><label for="support[Modifygrade][is_able]">用户组</label></td> 
        <td><select name="cd_grade" id="support[Modifygrade][soldier][0]" disabled="" > <option value="0" selected>普通会员</option> <option value="1" >VIP会员</option> </select></td> 
       </tr> 
       <tr> 
        <td width="30" align="center"><input type="checkbox" name="Modifyvipgrade" value="Yes" id="support[Modifyvipgrade][is_able]" onClick="switchSupport('Modifyvipgrade', this.checked)" /></td> 
        <td width="100" align=" left" id="supportTribe6"><label for="support[Modifyvipgrade][is_able]">VIP类型</label></td> 
        <td><select name="cd_vipgrade" id="support[Modifyvipgrade][soldier][0]" disabled="" > <option value="0" selected>普通用户</option> <option value="1" >月付会员</option> <option value="2" >年付会员</option>  </select></td> 
       </tr> 
       <tr> 
        <td width="30" align="center"><input type="checkbox" name="Modifyviprank" value="Yes" id="support[Modifyviprank][is_able]" onClick="switchSupport('Modifyviprank', this.checked)" /></td> 
        <td width="100" align=" left" id="supportTribe7"><label for="support[Modifyviprank][is_able]">VIP经验</label></td> 
        <td><input name="cd_viprank" id="support[Modifyviprank][soldier][0]" disabled="" value="" type="text" class="input input_hd length_1"></td> 
       </tr> 
       <tr> 
        <td width="30" align="center"><input type="checkbox" name="Modifyvipindate" value="Yes" id="support[Modifyvipindate][is_able]" onClick="switchSupport('Modifyvipindate', this.checked)" /></td> 
        <td width="100" align=" left" id="supportTribe8"><label for="support[Modifyvipindate][is_able]">VIP开通日期</label></td> 
        <td><input name="cd_vipindate" value="" id="support[Modifyvipindate][soldier][0]" disabled="" type="text" class="input input_hd length_3"></td> 
       </tr> 
       <tr> 
        <td width="30" align="center"><input type="checkbox" name="Modifyvipenddate" value="Yes" id="support[Modifyvipenddate][is_able]" onClick="switchSupport('Modifyvipenddate', this.checked)" /></td> 
        <td width="100" align=" left" id="supportTribe9"><label for="support[Modifyvipenddate][is_able]">VIP到期日期</label></td> 
        <td><input name="cd_vipenddate" value="" id="support[Modifyvipenddate][soldier][0]" disabled="" type="text" class="input input_hd length_3"></td> 
       </tr>
       <tr> 
        <td width="30" align="center"><input type="checkbox" name="Modifypoints" value="Yes" id="support[Modifypoints][is_able]" onClick="switchSupport('Modifypoints', this.checked)" /></td> 
        <td width="100" align=" left" id="supportTribe10"><label for="support[Modifypoints][is_able]">金币</label></td> 
        <td><input name="cd_points" id="support[Modifypoints][soldier][0]" disabled="" value="" type="text" class="input input_hd length_1"></td> 
       </tr>
       <tr> 
        <td width="30" align="center"><input type="checkbox" name="Modifyhits" value="Yes" id="support[Modifyhits][is_able]" onClick="switchSupport('Modifyhits', this.checked)" /></td> 
        <td width="100" align=" left" id="supportTribe11"><label for="support[Modifyhits][is_able]">人气</label></td> 
        <td><input name="cd_hits" id="support[Modifyhits][soldier][0]" disabled="" value="" type="text" class="input input_hd length_1"></td> 
       </tr>
       <tr> 
        <td width="30" align="center"><input type="checkbox" name="Modifyrank" value="Yes" id="support[Modifyrank][is_able]" onClick="switchSupport('Modifyrank', this.checked)" /></td> 
        <td width="100" align=" left" id="supportTribe12"><label for="support[Modifyrank][is_able]">经验</label></td> 
        <td><input name="cd_rank" id="support[Modifyrank][soldier][0]" disabled="" value="" type="text" class="input input_hd length_1"></td> 
       </tr>
       <tr> 
        <td width="30" align="center"><input type="checkbox" name="ModifyDeleted" value="Yes" id="support[ModifyDeleted][is_able]" onClick="switchSupport('ModifyDeleted', this.checked)" /></td> 
        <td width="100" align=" left" id="supportTribe13"><label for="support[ModifyDeleted][is_able]">删除帐号</label></td> 
        <td> &nbsp;&nbsp;<font color="#d01f3c">注意：批量删除不可恢复，请慎重！</font> </td> 
       </tr>
       <tr> 
        <td height="35" colspan="3" align="left" bgcolor="#FAFBF7" class="td_border"> <button type="submit" id="adddance" class="btn btn_submit J_ajax_submit_btn" style="margin-left: 10px;">确定提交</button> &nbsp;&nbsp;<font color="#d01f3c">注意：批量设置只对该表进行设置，不与积分,奖惩,动态挂钩！</font> </td> 
       </tr> 
      </tbody> 
     </table> 
    </form>
   </div> 
  </div> 		
<?php
}
Function Edit() {
	global $db;
	$cctvai_Com_CD_ID=SafeRequest('CD_ID', 'post');
	$cctvai_Com_BatchType=SafeRequest('BatchType', 'post');
	$cctvai_Com_lock=SafeRequest('cd_lock', 'post');
	$cctvai_Com_skin=SafeRequest('cd_skin', 'post');
	$cctvai_Com_sex=SafeRequest('cd_sex', 'post');
	$cctvai_Com_isbest=SafeRequest('cd_isbest', 'post');
	$cctvai_Com_checkmusic=SafeRequest('cd_checkmusic', 'post');
	$cctvai_Com_grade=SafeRequest('cd_grade', 'post');
	$cctvai_Com_vipgrade=SafeRequest('cd_vipgrade', 'post');
	$cctvai_Com_viprank=SafeRequest('cd_viprank', 'post');
	$cctvai_Com_vipindate=SafeRequest('cd_vipindate', 'post');
	$cctvai_Com_vipenddate=SafeRequest('cd_vipenddate', 'post');
	$cctvai_Com_points=SafeRequest('cd_points', 'post');
	$cctvai_Com_hits=SafeRequest('cd_hits', 'post');
	$cctvai_Com_rank=SafeRequest('cd_rank', 'post');
	$cctvai_Com_ModifyDeleted=SafeRequest('ModifyDeleted', 'post');
	$cctvai_Com_Modifylock=SafeRequest('Modifylock', 'post');
	$cctvai_Com_Modifyskin=SafeRequest('Modifyskin', 'post');
	$cctvai_Com_ModifySex=SafeRequest('ModifySex', 'post');
	$cctvai_Com_Modifyisbest=SafeRequest('Modifyisbest', 'post');
	$cctvai_Com_Modifycheckmusic=SafeRequest('Modifycheckmusic', 'post');
	$cctvai_Com_Modifygrade=SafeRequest('Modifygrade', 'post');
	$cctvai_Com_Modifyvipgrade=SafeRequest('Modifyvipgrade', 'post');
	$cctvai_Com_Modifyviprank=SafeRequest('Modifyviprank', 'post');
	$cctvai_Com_Modifyvipindate=SafeRequest('Modifyvipindate', 'post');
	$cctvai_Com_Modifyvipenddate=SafeRequest('Modifyvipenddate', 'post');
	$cctvai_Com_Modifypoints=SafeRequest('Modifypoints', 'post');
	$cctvai_Com_Modifyhits=SafeRequest('Modifyhits', 'post');
	$cctvai_Com_Modifyrank=SafeRequest('Modifyrank', 'post');
	If($cctvai_Com_BatchType=='1') {
		$sql1="cd_id in ($cctvai_Com_CD_ID)";
	}
	If($cctvai_Com_Modifylock=='Yes') {
		if($db->query($sql='update ' . tname('user') . " set cd_lock='" . $cctvai_Com_lock . "' where " . $sql1 . '')) {
		}
	}
	If($cctvai_Com_Modifyskin=='Yes') {
		if($db->query($sql='update ' . tname('user') . " set cd_skin='" . $cctvai_Com_skin . "' where " . $sql1 . '')) {
		}
	}
	If($cctvai_Com_ModifySex=='Yes') {
		if($db->query($sql='update ' . tname('user') . " set cd_sex='" . $cctvai_Com_sex . "' where " . $sql1 . '')) {
		}
	}
	If($cctvai_Com_Modifyisbest=='Yes') {
		if($db->query($sql='update ' . tname('user') . " set cd_isbest='" . $cctvai_Com_isbest . "' where " . $sql1 . '')) {
		}
	}
	If($cctvai_Com_Modifycheckmusic=='Yes') {
		if($db->query($sql='update ' . tname('user') . " set cd_checkmusic='" . $cctvai_Com_checkmusic . "' where " . $sql1 . '')) {
		}
	}
	If($cctvai_Com_Modifygrade=='Yes') {
		if($db->query($sql='update ' . tname('user') . " set cd_grade='" . $cctvai_Com_grade . "' where " . $sql1 . '')) {
		}
	}
	If($cctvai_Com_Modifyvipgrade=='Yes') {
		if($db->query($sql='update ' . tname('user') . " set cd_vipgrade='" . $cctvai_Com_vipgrade . "' where " . $sql1 . '')) {
		}
	}
	If($cctvai_Com_Modifyviprank=='Yes') {
		if($db->query($sql='update ' . tname('user') . " set cd_viprank='" . $cctvai_Com_viprank . "' where " . $sql1 . '')) {
		}
	}
	If($cctvai_Com_Modifyvipindate=='Yes') {
		if($db->query($sql='update ' . tname('user') . " set cd_vipindate='" . $cctvai_Com_vipindate . "' where " . $sql1 . '')) {
		}
	}
	If($cctvai_Com_Modifyvipenddate=='Yes') {
		if($db->query($sql='update ' . tname('user') . " set cd_vipenddate='" . $cctvai_Com_vipenddate . "' where " . $sql1 . '')) {
		}
	}
	If($cctvai_Com_Modifypoints=='Yes') {
		if($db->query($sql='update ' . tname('user') . " set cd_points='" . $cctvai_Com_points . "' where " . $sql1 . '')) {
		}
	}
	If($cctvai_Com_Modifyrank=='Yes') {
		if($db->query($sql='update ' . tname('user') . " set cd_rank='" . $cctvai_Com_rank . "' where " . $sql1 . '')) {
		}
	}
	If($cctvai_Com_Modifyhits=='Yes') {
		if($db->query($sql='update ' . tname('user') . " set cd_hits='" . $cctvai_Com_hits . "' where " . $sql1 . '')) {
		}
	}
	If($cctvai_Com_ModifyDeleted=='Yes') {
		$arr = explode(",",$cctvai_Com_CD_ID);
		$num = count($arr);
		$query=$db->query("select cd_url from " . tname('pic') . " where cd_uid in ($cctvai_Com_CD_ID)");
		while($row=$db->fetch_array($query)) {
			@unlink(_cctvai_root_ . "upload/album/" . $row['cd_url'] . ".thumb." . fileext($row['cd_url']));
			@unlink(_cctvai_root_ . "upload/album/" . $row['cd_url'] . ".thumb_180x180." . fileext($row['cd_url']));
			@unlink(_cctvai_root_ . "upload/album/" . $row['cd_url']);
		}
		$query=$db->query("select cd_id,cd_verified from " . tname('user') . " where cd_id in ($cctvai_Com_CD_ID)");
		while($row=$db->fetch_array($query)) {
			$verified=$row['cd_verified'];
			@unlink(_cctvai_root_ . "upload/userpic/" . $cd_id . ".jpg");
			@unlink(_cctvai_root_ . "upload/userpic/" . $cd_id . "_48x48.jpg");
			@unlink(_cctvai_root_ . "upload/userpic/" . $cd_id . "_120x120.jpg");
			@unlink(_cctvai_root_ . "upload/userpic/" . $cd_id . "_200x200.jpg");
			if(file_exists($verified)) {
				@unlink(_cctvai_root_ . $verified);
			}
		}
		$sql="delete from " . tname('user') . " where cd_id in ($cctvai_Com_CD_ID)";
		if($db->query($sql)) {
			$db->query("delete from " . tname('comment') . " where cd_uid in ($cctvai_Com_CD_ID)");
			$db->query("delete from " . tname('wall') . " where cd_uid in ($cctvai_Com_CD_ID)");
			$db->query("delete from " . tname('blog') . " where cd_uid in ($cctvai_Com_CD_ID)");
			$db->query("delete from " . tname('pic') . " where cd_uid in ($cctvai_Com_CD_ID)");
			$db->query("delete from " . tname('bill') . " where cd_uid in ($cctvai_Com_CD_ID)");
			$db->query("delete from " . tname('slot') . " where cd_uid in ($cctvai_Com_CD_ID)");
			$db->query("delete from " . tname('fav') . " where cd_uid in ($cctvai_Com_CD_ID)");
			$db->query("delete from " . tname('down') . " where cd_uid in ($cctvai_Com_CD_ID)");
			$db->query("delete from " . tname('fans') . " where cd_uid in ($cctvai_Com_CD_ID) or cd_uids in ($cctvai_Com_CD_ID)");
			$db->query("delete from " . tname('feed') . " where cd_uid in ($cctvai_Com_CD_ID)");
			$db->query("delete from " . tname('footprints') . " where cd_uid in ($cctvai_Com_CD_ID) or cd_uids in ($cctvai_Com_CD_ID)");
			$db->query("delete from " . tname('friend') . " where cd_uid in ($cctvai_Com_CD_ID) or cd_uids in ($cctvai_Com_CD_ID)");
			$db->query("delete from " . tname('friendgroup') . " where cd_uid in ($cctvai_Com_CD_ID)");
			$db->query("delete from " . tname('message') . " where cd_uid in ($cctvai_Com_CD_ID) or cd_uids in ($cctvai_Com_CD_ID)");
			$db->query("delete from " . tname('notice') . " where cd_uid in ($cctvai_Com_CD_ID) or cd_uids in ($cctvai_Com_CD_ID)");
			$db->query("delete from " . tname('session') . " where cd_uid in ($cctvai_Com_CD_ID)");
		}
		$db->query('update '.tname('system')." set cd_usermub=cd_usermub-'$num'");//全局数据统计
	}
	showmessage('恭喜您，批量设置数据成功！', 'user.php', 0);
}
?>